ServiceLogic.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\mobile\logic;
  3. use app\model\CommonModel;
  4. use app\model\ServiceModel;
  5. use think\response\Json;
  6. class ServiceLogic extends BaseLogic
  7. {
  8. //列表
  9. public static function list(array $data = []): Json
  10. {
  11. $db = ServiceModel::where([
  12. 'is_del' => CommonModel::$del_normal,
  13. 'company_id' => self::$company_id,
  14. 'card_id' => self::$card_id,
  15. ]);
  16. $count = $db->count('id');
  17. $list = $db
  18. ->field('id,original_price,activity_price,title,activity_status')
  19. ->page($data['page'], $data['size'])
  20. ->order(['id' => 'desc'])
  21. ->select()
  22. ->toArray();
  23. return json_show(CommonModel::$success, '获取服务列表成功', ['count' => $count, 'list' => $list]);
  24. }
  25. //详情
  26. public static function read(int $id = 0): Json
  27. {
  28. $info = ServiceModel::field('id,original_price,activity_price,title,content,starttime,endtime,expiretime,activity_status')
  29. ->where(['id' => $id, 'is_del' => CommonModel::$del_normal])
  30. ->findOrEmpty()
  31. ->toArray();
  32. return $info ? json_show(CommonModel::$success, '获取服务详情成功', $info) : json_show(CommonModel::$error_param, '服务为空');
  33. }
  34. }