ServiceLogic.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. //订单列表
  41. public static function list(array $data = []): Json
  42. {
  43. $db = OrderModel::alias('a')
  44. ->leftJoin('good b', 'b.id=a.good_id AND b.is_del=' . CommonModel::$del_normal)
  45. ->where(['a.is_del'=>CommonModel::$del_normal, 'a.uid' => self::$aid]);
  46. if ($data['status'] != '') $db->where('a.status', $data['status']);
  47. $count = $db->count('a.id');
  48. $list = $db
  49. ->field('a.id,a.orderCode,b.good_name,a.num,a.status,a.addtime,a.type,a.price,a.total_price')
  50. ->page($data['page'], $data['size'])
  51. ->order('a.id', 'desc')
  52. ->select()
  53. ->toArray();
  54. return json_show(CommonModel::$success, '获取订单列表成功', ['count' => $count, 'list' => $list]);
  55. }
  56. //订单详情
  57. public static function info(int $id = 0): Json
  58. {
  59. $rs = OrderModel::alias('a')
  60. ->field('a.id,a.orderCode,a.status,a.addtime,a.type,b.good_name,a.num,c.contactor,c.mobile,c.addr,c.addr_code,a.price,a.total_price,a.post_name,a.post_code,a.remark,"支付流水号" p')
  61. ->leftJoin('good b', 'b.id=a.good_id AND b.is_del=' . CommonModel::$del_normal)
  62. ->leftJoin('addr c', 'c.id=a.addr_id AND c.is_del=' . CommonModel::$del_normal)
  63. ->leftJoin('pay_info d', 'd.id=a.pay_info_id')
  64. ->where(['a.is_del' => CommonModel::$del_normal, 'a.id' => $id, 'a.uid' => self::$aid])
  65. ->withAttr('addr', function ($val, $da) {
  66. return $da['addr_code'] ? get_addr_name($da['addr_code']) . $val : $val;
  67. })
  68. ->findOrEmpty()
  69. ->toArray();
  70. return $rs ? json_show(CommonModel::$success, '获取订单详情成功', $rs) : json_show(CommonModel::$error_param, '该订单不存在');
  71. }
  72. }