ServiceLogic.php 1.4 KB

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