StoreService.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\api\controller\user;
  3. use app\models\store\StoreServiceLog;
  4. use app\models\store\StoreService as StoreServiceModel;
  5. use app\Request;
  6. use crmeb\services\UtilService;
  7. /**
  8. * 客服类
  9. * Class StoreService
  10. * @package app\api\controller\user
  11. */
  12. class StoreService
  13. {
  14. /**
  15. * 客服列表
  16. * @param Request $request
  17. * @return mixed
  18. */
  19. public function lst(Request $request)
  20. {
  21. list($page, $limit) = UtilService::getMore([['page',0],['limit',0]], $request, true);
  22. // if(!$page || !$limit) return app('json')->successful([]);
  23. $serviceInfoList = StoreServiceModel::lst($page, $limit);
  24. if(!count($serviceInfoList)) return app('json')->successful([]);
  25. return app('json')->successful($serviceInfoList->hidden(['notify', 'status', 'mer_id', 'add_time'])->toArray());
  26. }
  27. /**
  28. * 客服聊天记录
  29. * @param Request $request
  30. * @param $toUid
  31. * @return array
  32. */
  33. public function record(Request $request, $toUid)
  34. {
  35. list($page, $limit) = UtilService::getMore([['page',0],['limit',0]], $request, true);
  36. if(!$toUid) return app('json')->fail('参数错误');
  37. $uid = $request->uid();
  38. if(!$limit || !$page) return app('json')->successful([]);
  39. $serviceLogList = StoreServiceLog::lst($uid, $toUid, $page, $limit);
  40. if(!$serviceLogList) return app('json')->successful([]);
  41. $serviceLogList = $serviceLogList->hidden(['mer_id'])->toArray();
  42. $idArr = array_column($serviceLogList, 'id');
  43. array_multisort($idArr,SORT_ASC,$serviceLogList);
  44. return app('json')->successful($serviceLogList);
  45. }
  46. }