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