Service.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. namespace app\controller\service;
  3. use app\common\repositories\store\order\StoreOrderRepository;
  4. use app\common\repositories\store\order\StoreOrderStatusRepository;
  5. use app\common\repositories\store\order\StoreRefundOrderRepository;
  6. use app\common\repositories\store\product\ProductRepository;
  7. use app\common\repositories\store\service\StoreServiceLogRepository;
  8. use app\common\repositories\store\service\StoreServiceUserRepository;
  9. use app\common\repositories\system\ExtendRepository;
  10. use crmeb\basic\BaseController;
  11. use crmeb\services\UploadService;
  12. use think\App;
  13. class Service extends BaseController
  14. {
  15. protected $repository;
  16. public function __construct(App $app, StoreServiceUserRepository $repository)
  17. {
  18. parent::__construct($app);
  19. $this->repository = $repository;
  20. }
  21. /**
  22. * 客服列表
  23. * @return \think\response\Json
  24. * @author wuhaotian
  25. * @email 442384644@qq.com
  26. * @date 2024/7/8
  27. */
  28. public function serviceUserList()
  29. {
  30. [$page, $limit] = $this->getPage();
  31. $where = $this->request->params(['keyword']);
  32. $admin = $this->request->adminInfo();
  33. $where['service_id'] = $admin->service_id;
  34. return app('json')->success($this->repository->serviceUserList($where, $admin->mer_id, $page, $limit));
  35. }
  36. /**
  37. * 用户备注
  38. * @param $uid
  39. * @param StoreServiceUserRepository $serviceUserRepository
  40. * @param ExtendRepository $extendRepository
  41. * @return \think\response\Json
  42. * @author wuhaotian
  43. * @email 442384644@qq.com
  44. * @date 2024/7/8
  45. */
  46. public function mark($uid, StoreServiceUserRepository $serviceUserRepository, ExtendRepository $extendRepository)
  47. {
  48. $data = $this->request->params(['mark']);
  49. $service = $this->request->adminInfo();
  50. if ($service->mer_id && !$serviceUserRepository->existsWhere(['uid' => (int)$uid, 'mer_id' => $service->mer_id])) {
  51. return app('json')->fail('用户不存在');
  52. }
  53. $extendRepository->updateInfo(ExtendRepository::TYPE_SERVICE_USER_MARK, (int)$uid, $service->mer_id, (string)$data['mark']);
  54. return app('json')->success('备注成功');
  55. }
  56. /**
  57. * 聊天历史
  58. * @param $uid
  59. * @param StoreServiceLogRepository $logRepository
  60. * @return \think\response\Json
  61. * @author wuhaotian
  62. * @email 442384644@qq.com
  63. * @date 2024/7/8
  64. */
  65. public function history($uid, StoreServiceLogRepository $logRepository)
  66. {
  67. [$page, $limit] = $this->getPage();
  68. $where = $this->request->params(['last_id']);
  69. $service = $this->request->adminInfo();
  70. return app('json')->success($logRepository->serviceList($service->mer_id, $service->service_id, (int)$uid, $page, $limit, $where['last_id']));
  71. }
  72. /**
  73. * 文件上传
  74. * @param $field
  75. * @return \think\response\Json
  76. * @author wuhaotian
  77. * @email 442384644@qq.com
  78. * @date 2024/7/8
  79. */
  80. public function upload($field)
  81. {
  82. $file = $this->request->file($field);
  83. if (!$file) return app('json')->fail('请上传图片');
  84. $upload = UploadService::create();
  85. $data = $upload->to('attach')->validate()->move($field);
  86. if ($data === false) {
  87. return app('json')->fail($upload->getError());
  88. }
  89. return app('json')->success(['src' => tidy_url($upload->getFileInfo()->filePath)]);
  90. }
  91. /**
  92. * 获取订单详情
  93. * @param $id
  94. * @return \think\response\Json
  95. * @author wuhaotian
  96. * @email 442384644@qq.com
  97. * @date 2024/7/8
  98. */
  99. public function getOrderInfo($id)
  100. {
  101. return app('json')->success(app()->make(StoreOrderRepository::class)->getOne($id, null));
  102. }
  103. /**
  104. * 获取订单状态
  105. * @param $id
  106. * @return \think\response\Json
  107. * @author wuhaotian
  108. * @email 442384644@qq.com
  109. * @date 2024/7/8
  110. */
  111. public function orderStatus($id)
  112. {
  113. [$page, $limit] = $this->getPage();
  114. $where = $this->request->params(['date','user_type']);
  115. $where['id'] = $id;
  116. return app('json')->success(app()->make(StoreOrderRepository::class)->getOrderStatus($where, $page, $limit));
  117. }
  118. /**
  119. * 获取退款订单
  120. * @param $id
  121. * @return \think\response\Json
  122. * @author wuhaotian
  123. * @email 442384644@qq.com
  124. * @date 2024/7/8
  125. */
  126. public function getRefundOder($id)
  127. {
  128. $data = app()->make(StoreRefundOrderRepository::class)->getOne($id);
  129. if (!$data) return app('json')->fail("数据不存在");
  130. return app('json')->success($data);
  131. }
  132. /**
  133. * 订单物流
  134. * @param $id
  135. * @return \think\response\Json
  136. * @author wuhaotian
  137. * @email 442384644@qq.com
  138. * @date 2024/7/8
  139. */
  140. public function orderExpress($id)
  141. {
  142. $make = app()->make(StoreOrderRepository::class);
  143. return app('json')->success($make->express($id, null));
  144. }
  145. /**
  146. * 退款订单物流
  147. * @param $id
  148. * @return \think\response\Json
  149. * @author wuhaotian
  150. * @email 442384644@qq.com
  151. * @date 2024/7/8
  152. */
  153. public function refundOrderExpress($id)
  154. {
  155. $make = app()->make(StoreRefundOrderRepository::class);
  156. return app('json')->success($make->express($id));
  157. }
  158. /**
  159. * 商品详情
  160. * @param $id
  161. * @return \think\response\Json
  162. * @author wuhaotian
  163. * @email 442384644@qq.com
  164. * @date 2024/7/8
  165. */
  166. public function product($id)
  167. {
  168. $data = app()->make(ProductRepository::class)->getWhere(['product_id' => $id],'*',['content']);
  169. return app('json')->success($data);
  170. }
  171. }