ServiceLogic.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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\OrderServiceModel;
  7. use app\model\ServiceModel;
  8. use app\model\VideoModel;
  9. use think\Exception;
  10. use think\facade\Config;
  11. use think\facade\Db;
  12. use think\response\Json;
  13. class ServiceLogic extends BaseLogic
  14. {
  15. //列表
  16. public static function list(array $data = []): Json
  17. {
  18. $db = ServiceModel::where([
  19. 'is_del' => CommonModel::$del_normal,
  20. 'company_id' => self::$company_id,
  21. 'card_id' => self::$card_id,
  22. ]);
  23. $count = $db->count('id');
  24. $list = $db
  25. ->field('id,original_price,activity_price,title,activity_status')
  26. ->page($data['page'], $data['size'])
  27. ->order(['id' => 'desc'])
  28. ->select()
  29. ->toArray();
  30. return json_show(CommonModel::$success, '获取服务列表成功', ['count' => $count, 'list' => $list]);
  31. }
  32. //详情
  33. public static function read(int $id = 0): Json
  34. {
  35. $info = ServiceModel::field('id,original_price,activity_price,title,content,starttime,endtime,expiretime,activity_status')
  36. ->where(['id' => $id, 'is_del' => CommonModel::$del_normal])
  37. ->findOrEmpty()
  38. ->toArray();
  39. return $info ? json_show(CommonModel::$success, '获取服务详情成功', $info) : json_show(CommonModel::$error_param, '服务为空');
  40. }
  41. //订单列表
  42. public static function orderList(array $data = []): Json
  43. {
  44. $db = OrderServiceModel::alias('a')
  45. ->leftJoin('service b', 'b.id=a.service_id AND b.is_del=' . CommonModel::$del_normal)
  46. ->where(['a.is_del' => CommonModel::$del_normal, 'a.uid' => self::$aid]);
  47. if ($data['status'] != '') $db->where('a.status', $data['status']);
  48. $count = $db->count('a.id');
  49. $list = $db
  50. ->field('a.id,a.orderCode,b.title,a.num,a.status,a.addtime,a.type,a.price,a.total_price')
  51. ->page($data['page'], $data['size'])
  52. ->order('a.id', 'desc')
  53. ->select()
  54. ->toArray();
  55. return json_show(CommonModel::$success, '获取服务订单列表成功', ['count' => $count, 'list' => $list]);
  56. }
  57. //订单详情
  58. public static function orderInfo(int $id = 0): Json
  59. {
  60. $rs = OrderServiceModel::alias('a')
  61. ->field('a.id,a.orderCode,a.status,a.addtime,a.type,b.title,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')
  62. ->leftJoin('service b', 'b.id=a.service_id AND b.is_del=' . CommonModel::$del_normal)
  63. ->leftJoin('addr c', 'c.id=a.addr_id AND c.is_del=' . CommonModel::$del_normal)
  64. ->leftJoin('pay_info d', 'd.id=a.pay_info_id')
  65. ->where(['a.is_del' => CommonModel::$del_normal, 'a.id' => $id, 'a.uid' => self::$aid])
  66. ->withAttr('addr', function ($val, $da) {
  67. return $da['addr_code'] ? get_addr_name($da['addr_code']) . $val : $val;
  68. })
  69. ->findOrEmpty()
  70. ->toArray();
  71. return $rs ? json_show(CommonModel::$success, '获取服务订单详情成功', $rs) : json_show(CommonModel::$error_param, '该服务订单不存在');
  72. }
  73. }