Userlabel.php
3.78 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
namespace app\mobile\controller;
use app\home\logic\UsersLogic;
use app\home\model\Message;
use think\Cookie;
use think\Page;
use think\Request;
use think\Session;
use think\Verify;
use think\db;
use think\Cache;
use qcloudcos\Conf;
use qcloudcos\Myqcloudcos;
class userlabel extends MobileBase
{
//查询自定义标签
public function user_label(){
$user = session('user');
$store_id= getMobileStoId();;
$data['storeId'] = getMobileStoId();
$this->assign('storeid', $store_id );
$accdb = tpCache('shop_info.ERPId', getMobileStoId());
/* 获取商家自定义标签*/
$list= getApiData_java_p("/api/erp/marketing/vip/interest/label/page",$accdb ,$data, 1, 50, null, "GET");
if ($list) {
$list = json_decode($list, true);
$pagedata = $list['data']['pageData'];
$this->assign('list', $pagedata);
}
/* 获取商家设置*/
$store_config= M('store_config')->where("store_id", $store_id)->find();
if ($store_config) {
$switch_list = $store_config['switch_list'];
$switch_list = json_decode($switch_list, true);
$is_dj = $switch_list['rank_switch'];
$user_label_set = $switch_list['user_label_set'];//是否开启的名称
$user_label_val = $switch_list['user_label_val'];//获取的积分或成长值
$user_label_type = $switch_list['user_label_type'];//是否为积分还是成长值
$this->assign('user_label_set', $user_label_set);
$this->assign('user_label_val', $user_label_val);
$this->assign('user_label_type', $user_label_type);
$this->assign('is_dj', $is_dj);
//查询会员的标签
if ($user['erpvipid']) {
$data['VIPId'] = urlencode($user['erpvipid']);
$vip_user = getApiData_java_p("/api/erp/marketing/vip/interest/label/get", $accdb, $data, 1, 1000, null, "GET");
$vip_user = json_decode($vip_user, true);
$label_data = $vip_user['data'];
$label_id = $label_data['VipLabelId'];
$label_name = $label_data['VipLabel'];
$this->assign('label_id1', $label_id);
$this->assign('label_name1', $label_name);
if ($label_name) {
$label_name = explode(",", $label_name);
$this->assign('label_name', $label_name);
}
$label_id = explode(",", $label_id);
$arr = $label_name[0];
$this->assign('arrs', $arr);
$this->assign('label_id', $label_id);
}
}
return $this->fetch('', getMobileStoId());
}
/*保存与修改会员自定义标签*/
public function ajax_add_label(){
$stoid=getMobileStoId();
$accdb = tpCache("shop_info.ERPId", $stoid);
$user = session('user');
$label_data=I('post.');
$vipid=$user['erpvipid'];
$labelid=$label_data['labelId'];
$label=$label_data['label'];
$val=$label_data['val'];
$type=$label_data['type'];
$type=(int)$type+1;
if(!$val){ $type=0; }
$time=date("YmdHis");
$random=rand(1000,9999);
$fromType="REWARD";
$orderNo=$accdb.$time.$random;
$data['VIPId']=$vipid;
$data['VIPLabelId']=$labelid;
$data['VIPLabel']=$label;
$data['OrderNo']= $orderNo;
$data['Type']= $type;
$data['FromType']= $fromType;
$data['Value']=$val;
$data['Remark']=$label_data["remark"];
$rec=getApiData_java_p("/api/erp/marketing/vip/interest/label/update",$accdb ,$data, null, null, null, "put");
$rec=json_decode($rec,true);
return json(['data' => $rec]);
}
}