|
|
@@ -13,220 +13,6 @@ use think\Request;
|
|
13
|
13
|
class TaskZeroLineOrderLianc
|
|
14
|
14
|
{
|
|
15
|
15
|
|
|
16
|
|
- /**
|
|
17
|
|
- * 会员升级
|
|
18
|
|
- */
|
|
19
|
|
- public function member_update($orderInfo, $goods_of_info, $user_id)
|
|
20
|
|
- {
|
|
21
|
|
- //
|
|
22
|
|
- //$user_id = $userInfo['id'];
|
|
23
|
|
- $order_id = $orderInfo['id'];
|
|
24
|
|
-
|
|
25
|
|
- //code...
|
|
26
|
|
- $pay_gb = round($orderInfo['num'] * $orderInfo['gb_num'], 2);
|
|
27
|
|
- //$pay_vr = round($orderInfo['num'] * $orderInfo['vr_num'],2);
|
|
28
|
|
- //付款按照700的VR付款 start
|
|
29
|
|
- $vr_num = 0;
|
|
30
|
|
- if ($orderInfo['price'] == 1180) {
|
|
31
|
|
- $vr_num = 700;
|
|
32
|
|
- } elseif ($orderInfo['price'] == 11800) {
|
|
33
|
|
- $vr_num = 7000;
|
|
34
|
|
- } elseif ($orderInfo['price'] == 11800) {
|
|
35
|
|
- $vr_num = 2100;
|
|
36
|
|
- } elseif ($orderInfo['price'] == 10620) {
|
|
37
|
|
- $vr_num = 6300;
|
|
38
|
|
- }
|
|
39
|
|
-
|
|
40
|
|
-
|
|
41
|
|
- $pay_gb1 = $vr_num;
|
|
42
|
|
- $pay_vr1 = $orderInfo['price'];//记录VR值
|
|
43
|
|
-
|
|
44
|
|
-
|
|
45
|
|
- // $result = Db::name("old_user_jbp")->where("id",$user_id)->dec("vr",$orderInfo['price'])->save();//1.0jbp旧表
|
|
46
|
|
- // Db::name("user")->where("uid",$user_id)->dec("vr",$orderInfo['price'])->save();//2.0新表
|
|
47
|
|
-
|
|
48
|
|
-
|
|
49
|
|
- $result = true;
|
|
50
|
|
- if ($result) {
|
|
51
|
|
- $invite_id = $goods_of_info['spread_id'];
|
|
52
|
|
-
|
|
53
|
|
-
|
|
54
|
|
- $zs_ylj = 0; //养老金赋值
|
|
55
|
|
-
|
|
56
|
|
-
|
|
57
|
|
- if ($goods_of_info['money'] == 1180) {
|
|
58
|
|
- //修改订单到账状态
|
|
59
|
|
- $zs_ylj = round(700 * 0.05, 2);//计算的养老金 金额
|
|
60
|
|
- } elseif ($goods_of_info['money'] == 11800) {
|
|
61
|
|
- $zs_ylj = round(7000 * 0.05, 2);//计算的养老金 金额
|
|
62
|
|
- } elseif ($goods_of_info['money'] == 3540) {
|
|
63
|
|
- $zs_ylj = round(2100 * 0.05, 2);//计算的养老金 金额
|
|
64
|
|
- } elseif ($goods_of_info['money'] == 10620) {
|
|
65
|
|
- $zs_ylj = round(6300 * 0.05, 2);//计算的养老金 金额
|
|
66
|
|
- } elseif ($goods_of_info['money'] == 9440) {
|
|
67
|
|
- $zs_ylj = round(5600 * 0.05, 2);//八单计算的养老金 金额
|
|
68
|
|
- } elseif ($goods_of_info['money'] == 2360) {
|
|
69
|
|
- $zs_ylj = round(1400 * 0.05, 2);//两单计算的养老金 金额
|
|
70
|
|
- }
|
|
71
|
|
-
|
|
72
|
|
-
|
|
73
|
|
- $uid = $user_id;
|
|
74
|
|
- $new_user_id = $uid;
|
|
75
|
|
- if (empty($new_user_id)) {
|
|
76
|
|
- abort(0, "当前绑定会员查询错误");
|
|
77
|
|
- }
|
|
78
|
|
-
|
|
79
|
|
- $new_nums = Db::name("old_user_of_goods")->where("user_id", $uid)->sum("money");
|
|
80
|
|
-
|
|
81
|
|
- //增加过后权益对比 获取当前权益等级
|
|
82
|
|
- $old_level_id = Db::name("old_user_jbp")->where("id", $uid)->find();
|
|
83
|
|
-
|
|
84
|
|
- $old_level_info = Db::name("old_user_level")->where("id", $old_level_id['user_level_id'])->find();
|
|
85
|
|
-
|
|
86
|
|
-
|
|
87
|
|
- $level_info = [];
|
|
88
|
|
- $level_list = Db::name("old_user_level")->order("money desc")->select();
|
|
89
|
|
-
|
|
90
|
|
-
|
|
91
|
|
- //计算会员等级 升级
|
|
92
|
|
- foreach ($level_list as $key => $value) {
|
|
93
|
|
- # code...
|
|
94
|
|
- if ($new_nums >= $value['money']) {
|
|
95
|
|
- $level_info = $value;
|
|
96
|
|
- break;
|
|
97
|
|
- }
|
|
98
|
|
- }
|
|
99
|
|
-
|
|
100
|
|
- $zs_gb = $orderInfo['price'] * 3;
|
|
101
|
|
- $zs_withdraw_quota = $orderInfo['price'];
|
|
102
|
|
-
|
|
103
|
|
-
|
|
104
|
|
- if ($old_level_info['id'] == $level_info['id']) {
|
|
105
|
|
- //未到达升级权益 不改变用户等级
|
|
106
|
|
- $update_status = false;
|
|
107
|
|
- } else {
|
|
108
|
|
- $update_status = true;
|
|
109
|
|
- $user_level = $level_info['id'];
|
|
110
|
|
- //var_dump( $user_level);
|
|
111
|
|
- Db::name("old_user_jbp")->where("id", $new_user_id)->save(['user_level_id' => $user_level]);//1.0jbp旧表
|
|
112
|
|
- Db::name("user")->where("uid", $new_user_id)->save(['user_level_id_old' => $user_level]);//2.0新表
|
|
113
|
|
-
|
|
114
|
|
- // todo 同时改变他的权益
|
|
115
|
|
- }
|
|
116
|
|
-
|
|
117
|
|
-
|
|
118
|
|
- // Db::name("old_user_jbp")->where("id",$new_user_id)->inc("withdraw_quota",$zs_withdraw_quota)->save();//1.0jbp旧表
|
|
119
|
|
- // Db::name("user")->where("uid",$new_user_id)->save(['withdraw_quota_old'=>$zs_withdraw_quota]);//2.0新表
|
|
120
|
|
-
|
|
121
|
|
- // 下发邀请人赠送的GB
|
|
122
|
|
- // $zs_invite_gb = round($orderInfo['price']*0.3,2);
|
|
123
|
|
- // //todo
|
|
124
|
|
- // Db::name("old_user_jbp")->where("id",$invite_id)->inc("gb",$zs_invite_gb)->save();//1.0jbp旧表
|
|
125
|
|
- // Db::name("user")->where("uid",$invite_id)->inc("score",$zs_invite_gb)->save();//2.0新表
|
|
126
|
|
-
|
|
127
|
|
- //$old_have_pension = Db::name("old_user_jbp")->where("id",$invite_id)->value("have_pension");
|
|
128
|
|
-
|
|
129
|
|
-
|
|
130
|
|
- //检查是不是订单价格是1180或者11800,更改VR
|
|
131
|
|
- if ($goods_of_info['money'] == 1180 || $goods_of_info['money'] == 11800 || $goods_of_info['money'] == 3540 || $goods_of_info['money'] == 10620 || $goods_of_info['money'] == 9440 || $goods_of_info['money'] == 2360) {
|
|
132
|
|
- //修改订单到账状态
|
|
133
|
|
-
|
|
134
|
|
-
|
|
135
|
|
- Db::name("old_user_of_goods")->where("order_id", $goods_of_info1['id'])->save(['status' => 1, 'pay_gb' => 0, 'pay_vr' => $pay_vr1, 'pay_bt' => 0, 'create_time' => time()]);
|
|
136
|
|
-
|
|
137
|
|
-
|
|
138
|
|
- }
|
|
139
|
|
- }
|
|
140
|
|
-
|
|
141
|
|
-
|
|
142
|
|
- if ($result) {
|
|
143
|
|
- //更改订单状态
|
|
144
|
|
-
|
|
145
|
|
- Db::commit();
|
|
146
|
|
- $new_user_name = Db::name("old_user_jbp")->where("id", $new_user_id)->value("user_name");
|
|
147
|
|
- $new_user_name = empty($new_user_name) ? "" : $new_user_name;
|
|
148
|
|
-
|
|
149
|
|
- //记录日志信息
|
|
150
|
|
-
|
|
151
|
|
- if ($user_id == $invite_id) {
|
|
152
|
|
- //报单中心=推荐人 GB记录日志有问题需要传入指定参数去计算
|
|
153
|
|
- //$money = Db::name("old_user_jbp")->where("id",$user_id)->value("gb");
|
|
154
|
|
- //$appoint_money = $money - $zs_invite_gb;
|
|
155
|
|
-
|
|
156
|
|
- if ($goods_of_info['money'] == 1180 || $goods_of_info['money'] == 11800 || $goods_of_info['money'] == 3540 || $goods_of_info['money'] == 10620 || $goods_of_info['money'] == 9440 || $goods_of_info['money'] == 2360) {
|
|
157
|
|
-
|
|
158
|
|
-
|
|
159
|
|
- $this->change_user_log66($user_id, "vr", 2, $pay_vr1, "declare_expend", '权益消费VR-' . $new_user_name);
|
|
160
|
|
-
|
|
161
|
|
- }
|
|
162
|
|
- } else {
|
|
163
|
|
-
|
|
164
|
|
- if ($goods_of_info['money'] == 1180 || $goods_of_info['money'] == 11800 || $goods_of_info['money'] == 3540 || $goods_of_info['money'] == 10620 || $goods_of_info['money'] == 9440 || $goods_of_info['money'] == 2360) {
|
|
165
|
|
-
|
|
166
|
|
-
|
|
167
|
|
- $this->change_user_log66($user_id, "vr", 2, $pay_vr1, "declare_expend", '权益消费VR-' . $new_user_name);
|
|
168
|
|
-
|
|
169
|
|
- }
|
|
170
|
|
- }
|
|
171
|
|
- // $this->change_user_log66($new_user_id,'gb',1,$zs_gb,"levle_update_zs","权益升级达标赠送");
|
|
172
|
|
- $this->change_user_log66($new_user_id, 'withdraw_quota_old', 1, $zs_withdraw_quota, "levle_update_zs", "权益升级达标赠送");
|
|
173
|
|
- // $this->change_user_log66($invite_id,'gb',1,$zs_invite_gb,"levle_update_zs","邀请-".$new_user_name);
|
|
174
|
|
- // echo 123;return;
|
|
175
|
|
- //处理查看是否有待发放佣金
|
|
176
|
|
- // $zs_withdraw_quota
|
|
177
|
|
- Db::name("old_user_jbp")->where("id", $new_user_id)->inc("total_withdraw_quota", $zs_withdraw_quota)->save();//1.0jbp旧表
|
|
178
|
|
- Db::name("user")->where("uid", $new_user_id)->inc("total_withdraw_quota_old", $zs_withdraw_quota)->save();
|
|
179
|
|
- // $this->releaseTobeAmount($new_user_id,$zs_withdraw_quota);
|
|
180
|
|
- // $this->success("支付成功",['is_cash'=>0]);
|
|
181
|
|
- }
|
|
182
|
|
- Db::rollback();
|
|
183
|
|
- // $this->error("操作失败");
|
|
184
|
|
- }
|
|
185
|
|
-
|
|
186
|
|
- function change_user_log66($user_id, $type, $change_status, $money, $routine, $remark = "", $is_admin = 1, $appoint_money = 0)
|
|
187
|
|
- {
|
|
188
|
|
- $transition = [
|
|
189
|
|
- 'pv' => 1,
|
|
190
|
|
- "gb" => 2,
|
|
191
|
|
- "df" => 3,
|
|
192
|
|
- "vr" => 4,
|
|
193
|
|
- "bt" => 5,
|
|
194
|
|
- "withdraw_quota_old" => 6,
|
|
195
|
|
- "unsettled_pension" => 7,
|
|
196
|
|
- "amount_old" => 8
|
|
197
|
|
- ];
|
|
198
|
|
- $routineInfo = Db::name("old_routine_log_of_key")->where("key", $routine)->find();
|
|
199
|
|
- if (empty($routineInfo)) {
|
|
200
|
|
- return false;
|
|
201
|
|
- }
|
|
202
|
|
- $key_id = isset($routineInfo['id']) ? $routineInfo['id'] : 0;
|
|
203
|
|
- //再去查询变更前的 金额
|
|
204
|
|
- if ($appoint_money > 0) {
|
|
205
|
|
- $alter_money = $appoint_money;
|
|
206
|
|
- } else {
|
|
207
|
|
- //再去查询变更前的 金额
|
|
208
|
|
- $alter_money = Db::name("user")->where('uid', $user_id)->value($type);
|
|
209
|
|
- }
|
|
210
|
|
- if ($change_status == 1) {
|
|
211
|
|
- //新增前
|
|
212
|
|
- $alter_money = $alter_money - $money;
|
|
213
|
|
- } else if ($change_status == 2) {
|
|
214
|
|
- //减少前
|
|
215
|
|
- $alter_money = $alter_money + $money;
|
|
216
|
|
- }
|
|
217
|
|
- $inser_data = [];
|
|
218
|
|
- $inser_data['user_id'] = $user_id;
|
|
219
|
|
- $inser_data['type'] = $transition[$type];
|
|
220
|
|
- $inser_data['change_status'] = $change_status;
|
|
221
|
|
- $inser_data['money'] = $money;
|
|
222
|
|
- $inser_data['routine_log_of_key_id'] = $key_id;
|
|
223
|
|
- $inser_data['remark'] = $remark;
|
|
224
|
|
- $inser_data['is_admin'] = $is_admin;
|
|
225
|
|
- $inser_data['create_time'] = time();
|
|
226
|
|
- $inser_data['alter_money'] = isset($alter_money) ? $alter_money : 0;
|
|
227
|
|
- Db::name("old_user_log")->insert($inser_data);
|
|
228
|
|
- }
|
|
229
|
|
-
|
|
230
|
16
|
//添加推广佣金/养老金日志(养老金金额)
|
|
231
|
17
|
public function bill_user_log($uid, $name, $num, $mark)
|
|
232
|
18
|
{
|