123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\mobile\logic;
- use app\model\CommonModel;
- use app\model\ServiceModel;
- use think\response\Json;
- class ServiceLogic extends BaseLogic
- {
- //列表
- public static function list(array $data = []): Json
- {
- $db = ServiceModel::where([
- 'is_del' => CommonModel::$del_normal,
- 'company_id' => self::$company_id,
- 'card_id' => self::$card_id,
- ]);
- $count = $db->count('id');
- $list = $db
- ->field('id,original_price,activity_price,title,activity_status')
- ->page($data['page'], $data['size'])
- ->order(['id' => 'desc'])
- ->select()
- ->toArray();
- return json_show(CommonModel::$success, '获取服务列表成功', ['count' => $count, 'list' => $list]);
- }
- //详情
- public static function read(int $id = 0): Json
- {
- $info = ServiceModel::field('id,original_price,activity_price,title,content,starttime,endtime,expiretime,activity_status')
- ->where(['id' => $id, 'is_del' => CommonModel::$del_normal])
- ->findOrEmpty()
- ->toArray();
- return $info ? json_show(CommonModel::$success, '获取服务详情成功', $info) : json_show(CommonModel::$error_param, '服务为空');
- }
- }
|