Kefu.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace addons\shopro\controller;
  3. /**
  4. * 客服接口
  5. */
  6. class Kefu extends Base
  7. {
  8. protected $noNeedLogin = [];
  9. protected $noNeedRight = ['*'];
  10. /**
  11. * 对接Fastadmin插件市场WorkerMan客服插件
  12. */
  13. public function historyGoods()
  14. {
  15. $viewList = \addons\shopro\model\UserView::getGoodsList();
  16. if(!empty($viewList)) {
  17. foreach($viewList as $k => &$v) {
  18. $v->id = $v->goods_id;
  19. $v->logo = $v->goods->image;
  20. $v->subject = $v->goods->title;
  21. $v->note = $v->goods->subtitle;
  22. $v->price = $v->goods->price;
  23. unset($v['goods']);
  24. unset($v['goods_id']);
  25. unset($v['user_id']);
  26. }
  27. }
  28. $this->success('浏览历史', $viewList);
  29. }
  30. public function historyOrder()
  31. {
  32. $orderList = \addons\shopro\model\Order::getList(['type' => 'all']);
  33. if(!empty($orderList)) {
  34. foreach($orderList['data'] as $k => &$v) {
  35. $order = [];
  36. $order['id'] = $v['id'];
  37. $order['subject'] = $v['item'][0]['goods_title'];
  38. $order['logo'] = $v['item'][0]['goods_image'];
  39. $order['note'] = "订单编号:{$v['order_sn']}";
  40. $order['price'] = $v['total_amount'];
  41. $order['number'] = 23;
  42. $itemNumber = count($v['item']);
  43. if($itemNumber == 1) {
  44. $order['subject'] = "{$order['subject']}...等{$itemNumber}个产品";
  45. }
  46. $v = $order;
  47. }
  48. }
  49. $this->success('order', $orderList);
  50. }
  51. }