|
|
@@ -45,6 +45,7 @@ class Notify
|
|
45
|
45
|
$pay_type = $pay_type == 'wx_lite' ? 1 : 4;
|
|
46
|
46
|
switch ($type){
|
|
47
|
47
|
case 'pay':
|
|
|
48
|
+ //商城集合订单
|
|
48
|
49
|
Db::name('store_group_order') -> where('group_order_sn',$requestId[0]) -> update(['rand'=>$requestId[1]]);
|
|
49
|
50
|
// 判断代付是否支付过
|
|
50
|
51
|
$group_order = Db::name('store_group_order')->where('group_order_sn', $requestId[0])->find();
|
|
|
@@ -72,8 +73,463 @@ class Notify
|
|
72
|
73
|
break;
|
|
73
|
74
|
}
|
|
74
|
75
|
$post_data_str['expend']['open_id'] = $post_data_str['expend']['open_id'] ?? '';
|
|
75
|
|
- Db::name('store_order')->where('group_order_id', $group_order_id)->update(['pay_open_id' => $post_data_str['expend']['open_id']]);
|
|
|
76
|
+
|
|
|
77
|
+ //start
|
|
|
78
|
+ //分配逻辑
|
|
|
79
|
+ // $store_order_data = Db::name('store_order')->where('group_order_id', $group_order_id)->find();
|
|
|
80
|
+
|
|
|
81
|
+ //精彩生活
|
|
|
82
|
+ // if($store_order_data['mer_id'] == 439){
|
|
|
83
|
+ // if(!empty($store_order_data)){}
|
|
|
84
|
+ // }
|
|
|
85
|
+
|
|
|
86
|
+ //$group_order = Db::name('store_group_order')->where('group_order_sn',$group_order_id)->find();
|
|
|
87
|
+ //var_dump($group_order['group_order_id']);return;
|
|
|
88
|
+ //分配逻辑
|
|
|
89
|
+ $store_order_data = Db::name('store_order')->where('group_order_id',$group_order_id)->find();
|
|
|
90
|
+
|
|
|
91
|
+ //找到对应的商品id(product_id)
|
|
|
92
|
+ $store_order_product_data = Db::name('store_order_product')->where('order_id',$store_order_data['order_id'])->find();
|
|
|
93
|
+ //找到对应的商品让利金额或比例
|
|
|
94
|
+ $store_product_data = Db::name('store_product')->where('product_id',$store_order_product_data['product_id'])->find();
|
|
|
95
|
+ //下单用户
|
|
|
96
|
+ $user_data = Db::name('user')->where('uid',$store_order_data['uid'])->find();
|
|
|
97
|
+ //var_dump($user_data['spread_uid']);
|
|
|
98
|
+
|
|
|
99
|
+ $concession_pri = $store_product_data['concession_pri'];//商家让利金额
|
|
|
100
|
+
|
|
|
101
|
+
|
|
|
102
|
+ $spread_uid = 0;//下单用户上级uid
|
|
|
103
|
+ $fgj_pri=0;//推广者的佣金抽10%到个人复购金
|
|
|
104
|
+
|
|
|
105
|
+ $pv = 0; //待分配的PV
|
|
|
106
|
+
|
|
|
107
|
+
|
|
|
108
|
+ //var_dump($store_product_data['concession_pri']);return;
|
|
|
109
|
+ //精彩生活
|
|
|
110
|
+ if($store_order_data['mer_id'] == 439){
|
|
|
111
|
+
|
|
|
112
|
+
|
|
|
113
|
+ //分配参数
|
|
|
114
|
+ $job_par = [];
|
|
|
115
|
+ if(!empty($store_order_data)){
|
|
|
116
|
+ $job_par = json_decode($store_order_data['fzone_paytype'], true);
|
|
|
117
|
+ //if($job_par['note'] == "现金"){
|
|
|
118
|
+ //普通消费者
|
|
|
119
|
+ $ylj_pri = round($concession_pri * 0.3,2);
|
|
|
120
|
+ $pv = round($concession_pri * 0.35,2);
|
|
|
121
|
+
|
|
|
122
|
+ //分配养老金给消费者
|
|
|
123
|
+ $ylj_amount_mine = $user_data['annuity'] + $ylj_pri;
|
|
|
124
|
+ //分配积分和贡献值给消费者
|
|
|
125
|
+ $con = $user_data['contribute'] + $pv;
|
|
|
126
|
+ $score = $user_data['score'] + $pv;
|
|
|
127
|
+
|
|
|
128
|
+ //Db::name('user')->where('uid',$user_data['uid'])->update(['annuity'=>$ylj_amount_mine,"contribute"=>$con,"score"=>$score]);
|
|
|
129
|
+
|
|
|
130
|
+ $this->bill_user_log($user_data['uid'],$ylj_pri,$store_order_data['order_id'],5,$group_order['group_order_sn'],'消费获得养老金'.$ylj_pri,$store_order_data['mer_id'],0);
|
|
|
131
|
+ $this->con_log($user_data['uid'],$pv,$store_order_data['order_id'],11,"购买精彩生活商品赠送贡献值");
|
|
|
132
|
+ $this->score_log($user_data['uid'],$pv,$store_order_data['order_id'],11,"购买精彩生活商品赠送积分");
|
|
|
133
|
+
|
|
|
134
|
+ //给推广者分配养老金
|
|
|
135
|
+ //给推广者分配佣金
|
|
|
136
|
+ if($user_data['spread_uid'] != 0){
|
|
|
137
|
+ //查询下单用户上级身份
|
|
|
138
|
+ $spread_data = Db::name('user')->where('uid',$user_data['spread_uid'])->find();
|
|
|
139
|
+
|
|
|
140
|
+ //业务员或以上的推荐人等级
|
|
|
141
|
+ //user_group=1是消费者 3%,2:业务员 5%,3:业务经理7%,4:初级合伙人9%,5:中级合伙人11%,6:高级合伙人13%,7:董事15%
|
|
|
142
|
+ if($spread_data['user_group'] > 1){
|
|
|
143
|
+
|
|
|
144
|
+ // //给推广者分配佣金
|
|
|
145
|
+ $yj_amount = 0;
|
|
|
146
|
+ $ylj_amount = $spread_data['annuity'] + round($pv * 0.05,2);
|
|
|
147
|
+ $ssf = 0;//变量
|
|
|
148
|
+ $yj_amount_90 = 0;//90%的佣金
|
|
|
149
|
+
|
|
|
150
|
+ if($spread_data['user_group'] == 2){
|
|
|
151
|
+ $ssf =round($pv * 0.07,2);
|
|
|
152
|
+ $con = $spread_data['contribute'] + round($pv * 0.07,2);
|
|
|
153
|
+ $score = $spread_data['score'] + round($pv * 0.07,2);
|
|
|
154
|
+
|
|
|
155
|
+
|
|
|
156
|
+ $yj_amount_90 = round($pv * 0.07,2) * 0.9;
|
|
|
157
|
+ $fgj_amount_10 = round($pv * 0.07,2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
158
|
+
|
|
|
159
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
160
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
161
|
+ $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
162
|
+
|
|
|
163
|
+
|
|
|
164
|
+
|
|
|
165
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
166
|
+ }else if($spread_data['user_group'] == 3){
|
|
|
167
|
+ $ssf =round($pv * 0.09,2);
|
|
|
168
|
+ $con = $spread_data['contribute'] + round($pv * 0.09,2);
|
|
|
169
|
+ $score = $spread_data['score'] + round($pv * 0.09,2);
|
|
|
170
|
+
|
|
|
171
|
+ $yj_amount_90 = round($pv * 0.09,2) * 0.9;
|
|
|
172
|
+ $fgj_amount_10 = round($pv * 0.09,2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
173
|
+
|
|
|
174
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
175
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
176
|
+ $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
177
|
+
|
|
|
178
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
179
|
+ }else if($spread_data['user_group'] == 4){
|
|
|
180
|
+ $ssf =round($pv * 0.11,2);
|
|
|
181
|
+ $con = $spread_data['contribute'] + round($pv * 0.11,2);
|
|
|
182
|
+ $score = $spread_data['score'] + round($pv * 0.11,2);
|
|
|
183
|
+
|
|
|
184
|
+
|
|
|
185
|
+ $yj_amount_90 = round($pv * 0.11,2) * 0.9;
|
|
|
186
|
+ $fgj_amount_10 = round($pv * 0.11,2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
187
|
+
|
|
|
188
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
189
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
190
|
+ $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
191
|
+
|
|
|
192
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
193
|
+ }else if($spread_data['user_group'] == 5){
|
|
|
194
|
+ $ssf =round($pv * 0.13,2);
|
|
|
195
|
+ $con = $spread_data['contribute'] + round($pv * 0.13,2);
|
|
|
196
|
+ $score = $spread_data['score'] + round($pv * 0.13,2);
|
|
|
197
|
+ // $yj_amount = $spread_data['brokerage_price'] + round($pv * 0.13,2);
|
|
|
198
|
+
|
|
|
199
|
+ $yj_amount_90 = round($pv * 0.13,2) * 0.9;
|
|
|
200
|
+ $fgj_amount_10 = round($pv * 0.13,2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
201
|
+
|
|
|
202
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
203
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
204
|
+ $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
205
|
+
|
|
|
206
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
207
|
+ }else if($spread_data['user_group'] == 6){
|
|
|
208
|
+ $ssf =round($pv * 0.15,2);
|
|
|
209
|
+ $con = $spread_data['contribute'] + round($pv * 0.15,2);
|
|
|
210
|
+ $score = $spread_data['score'] + round($pv * 0.15,2);
|
|
|
211
|
+ // $yj_amount = $spread_data['brokerage_price'] + round($pv * 0.15,2);
|
|
|
212
|
+
|
|
|
213
|
+ $yj_amount_90 = round($pv * 0.15,2) * 0.9;
|
|
|
214
|
+ $fgj_amount_10 = round($pv * 0.15,2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
215
|
+
|
|
|
216
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
217
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
218
|
+ $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
219
|
+
|
|
|
220
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
221
|
+ }else if($spread_data['user_group'] == 7){
|
|
|
222
|
+ $ssf =round($pv * 0.17,2);
|
|
|
223
|
+ $con = $spread_data['contribute'] + round($pv * 0.17,2);
|
|
|
224
|
+ $score = $spread_data['score'] + round($pv * 0.17,2);
|
|
|
225
|
+ // $yj_amount = $spread_data['brokerage_price'] + round($pv * 0.17,2);
|
|
|
226
|
+
|
|
|
227
|
+ $yj_amount_90 = round($pv * 0.17,2) * 0.9;
|
|
|
228
|
+ $fgj_amount_10 = round($pv * 0.17,2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
229
|
+
|
|
|
230
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
231
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
232
|
+ $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
233
|
+
|
|
|
234
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
235
|
+ }
|
|
|
236
|
+
|
|
|
237
|
+ //贡献值
|
|
|
238
|
+ $this->con_log($spread_data['uid'],$ssf,$store_order_data['order_id'],11,"精彩生活区商品赠送贡献值");
|
|
|
239
|
+ //积分
|
|
|
240
|
+ $this->score_log($spread_data['uid'],$ssf,$store_order_data['order_id'],11,"精彩生活区商品赠送积分");
|
|
|
241
|
+ // //推广佣金
|
|
|
242
|
+ $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.$yj_amount_90,$store_order_data['mer_id'],0);
|
|
|
243
|
+ //养老金
|
|
|
244
|
+ $this->bill_user_log($spread_data['uid'],round($pv * 0.05,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'推广获得养老金'.round($pv * 0.05,2),$store_order_data['mer_id'],0);
|
|
|
245
|
+ }
|
|
|
246
|
+
|
|
|
247
|
+ //普通用户推广人
|
|
|
248
|
+ if($spread_data['user_group'] == 1){
|
|
|
249
|
+ //给推广者分配佣金
|
|
|
250
|
+ // $ylj_amount = $spread_data['annuity'] + round($pv * 0.3,2);
|
|
|
251
|
+ $yj_amount_90 = round($pv * 0.03,2) * 0.9;
|
|
|
252
|
+ $fgj_amount_10 = round($pv * 0.03,2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
253
|
+
|
|
|
254
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
255
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
256
|
+ $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
257
|
+
|
|
|
258
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
|
|
|
259
|
+
|
|
|
260
|
+ $con = $spread_data['contribute'] + round($pv * 0.03,2);
|
|
|
261
|
+ $score = $spread_data['score'] + round($pv * 0.03,2);
|
|
|
262
|
+
|
|
|
263
|
+ //贡献值和积分
|
|
|
264
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(["contribute"=>$con,"score"=>$score]);
|
|
|
265
|
+
|
|
|
266
|
+ //推广养老金
|
|
|
267
|
+
|
|
|
268
|
+ //推广佣金
|
|
|
269
|
+ $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.$yj_amount_90,$store_order_data['mer_id'],0);
|
|
|
270
|
+ $this->con_log($spread_data['uid'],round($pv * 0.03,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值");
|
|
|
271
|
+ $this->score_log($spread_data['uid'],round($pv * 0.03,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分");
|
|
|
272
|
+
|
|
|
273
|
+
|
|
|
274
|
+
|
|
|
275
|
+ }
|
|
|
276
|
+
|
|
|
277
|
+
|
|
|
278
|
+
|
|
|
279
|
+ }
|
|
|
280
|
+
|
|
|
281
|
+ //锁客收益
|
|
|
282
|
+ if($user_data['mer_id'] != 0){
|
|
|
283
|
+
|
|
|
284
|
+ $merchant_data = Db::name('merchant')->where('mer_id',$user_data['mer_id'])->find();
|
|
|
285
|
+
|
|
|
286
|
+ $merchant_user_data = Db::name('user')->where('uid',$merchant_data['uid'])->find();
|
|
|
287
|
+
|
|
|
288
|
+ if(!empty($merchant_user_data)){
|
|
|
289
|
+ //$merchant_amount = $merchant_user_data['brokerage_price'] + round($pv * 0.05,2);
|
|
|
290
|
+ //给推广者分配佣金
|
|
|
291
|
+
|
|
|
292
|
+ $yj_amount_90 = round($pv * 0.05,2) * 0.9;
|
|
|
293
|
+ $fgj_amount_10 = round($pv * 0.05,2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
294
|
+
|
|
|
295
|
+ $yj_amount = $merchant_user_data['brokerage_price'] + $yj_amount_90;
|
|
|
296
|
+ $fgj_amount = $merchant_user_data['fugou'] + $fgj_amount_10;
|
|
|
297
|
+ $this->fugou_user_log($merchant_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
298
|
+
|
|
|
299
|
+
|
|
|
300
|
+
|
|
|
301
|
+ //Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
|
|
|
302
|
+ //推广佣金
|
|
|
303
|
+ $this->bill_user_log($merchant_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'. $yj_amount_90,$store_order_data['mer_id'],0);
|
|
|
304
|
+
|
|
|
305
|
+ }
|
|
|
306
|
+
|
|
|
307
|
+ }
|
|
|
308
|
+
|
|
|
309
|
+
|
|
|
310
|
+ //}
|
|
|
311
|
+ //var_dump($ylj_amount);
|
|
|
312
|
+ }
|
|
|
313
|
+
|
|
|
314
|
+ //VIP专区
|
|
|
315
|
+ }else if($store_order_data['mer_id'] == 496){
|
|
|
316
|
+
|
|
|
317
|
+ //业务员和以上推广的等级获得推广佣金
|
|
|
318
|
+ $le_yw_amount = 0;
|
|
|
319
|
+ //获赠的贡献值和积分
|
|
|
320
|
+ $gx_jf = 0;
|
|
|
321
|
+ $yj1 = 0;
|
|
|
322
|
+ if($store_product_data['price'] == 1180){
|
|
|
323
|
+ $pv = 1000;
|
|
|
324
|
+ $gx_jf = 700;
|
|
|
325
|
+ $yj1 = 100;
|
|
|
326
|
+ $le_yw_amount = 300;
|
|
|
327
|
+ }else if($store_product_data['price'] == 10620){
|
|
|
328
|
+ $pv = 9000;
|
|
|
329
|
+ $gx_jf = 6300;
|
|
|
330
|
+ $yj1 = 900;
|
|
|
331
|
+ $le_yw_amount = 2700;
|
|
|
332
|
+ }else if($store_product_data['price'] == 11800){
|
|
|
333
|
+ $pv = 10000;
|
|
|
334
|
+ $gx_jf = 7000;
|
|
|
335
|
+ $yj1 = 1000;
|
|
|
336
|
+ $le_yw_amount = 3000;
|
|
|
337
|
+ }
|
|
|
338
|
+
|
|
|
339
|
+ $ylj_pri = round($pv * 0.035,2);
|
|
|
340
|
+ //$pv = round($pv * 0.35,2);
|
|
|
341
|
+
|
|
|
342
|
+ //分配养老金给消费者
|
|
|
343
|
+ //普通用户获取贡献值和pv3.5%养老金和积分
|
|
|
344
|
+ $ylj_amount_mine = $user_data['annuity'] + $ylj_pri;
|
|
|
345
|
+ $gxz_amount_mine = $user_data['contribute'] + $gx_jf;
|
|
|
346
|
+ $jf_amount_mine = $user_data['score'] + $gx_jf;
|
|
|
347
|
+
|
|
|
348
|
+
|
|
|
349
|
+ //Db::name('user')->where('uid',$user_data['uid'])->update(['annuity'=>$ylj_amount_mine,'contribute'=> $gxz_amount_mine,'score'=> $jf_amount_mine]);
|
|
|
350
|
+
|
|
|
351
|
+ $this->bill_user_log($user_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
|
|
|
352
|
+
|
|
|
353
|
+ $this->con_log($user_data['uid'],$gx_jf,$store_order_data['order_id'],11,"购买会员专区商品赠送贡献值");
|
|
|
354
|
+ $this->score_log($user_data['uid'],$gx_jf,$store_order_data['order_id'],11,"购买会员专区商品赠送积分");
|
|
|
355
|
+
|
|
|
356
|
+ //给推广者分配养老金
|
|
|
357
|
+ //给推广者分配佣金
|
|
|
358
|
+ if($user_data['spread_uid'] != 0){
|
|
|
359
|
+ //查询下单用户上级身份
|
|
|
360
|
+ $spread_data = Db::name('user')->where('uid',$user_data['spread_uid'])->find();
|
|
|
361
|
+
|
|
|
362
|
+ //user_group=1是消费者,2:业务,3:业务经理,4:初级合伙人,5:中级合伙人,6:高级合伙人,7:董事
|
|
|
363
|
+ //业务或以上等级推广人
|
|
|
364
|
+ //获得养老金、佣金、贡献值和积分
|
|
|
365
|
+ if($spread_data['user_group'] > 1){
|
|
|
366
|
+
|
|
|
367
|
+
|
|
|
368
|
+
|
|
|
369
|
+ $con =0;//贡献值
|
|
|
370
|
+ $score = 0;//积分
|
|
|
371
|
+ //养老金
|
|
|
372
|
+ $uer_bill = $spread_data['annuity'] + round($pv * 0.035,2);
|
|
|
373
|
+
|
|
|
374
|
+
|
|
|
375
|
+ $yj_amount_90 = $le_yw_amount * 0.9;
|
|
|
376
|
+ $fgj_amount_10 = $le_yw_amount * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
377
|
+
|
|
|
378
|
+ $yongjin = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
379
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
380
|
+
|
|
|
381
|
+
|
|
|
382
|
+
|
|
|
383
|
+
|
|
|
384
|
+ if($spread_data['user_group'] == 2){
|
|
|
385
|
+
|
|
|
386
|
+ $con = $spread_data['contribute'] + round($pv * 0.07,2);
|
|
|
387
|
+ $score = $spread_data['brokerage_price'] + round($pv * 0.07,2);
|
|
|
388
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
|
|
|
389
|
+
|
|
|
390
|
+ //贡献值
|
|
|
391
|
+ $this->con_log($spread_data['uid'],round($pv * 0.07,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值");
|
|
|
392
|
+ //积分
|
|
|
393
|
+ $this->score_log($spread_data['uid'],round($pv * 0.07,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分");
|
|
|
394
|
+
|
|
|
395
|
+ }else if($spread_data['user_group'] == 3){
|
|
|
396
|
+ $con = $spread_data['contribute'] + round($pv * 0.09,2);
|
|
|
397
|
+ $score = $spread_data['brokerage_price'] + round($pv * 0.09,2);
|
|
|
398
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
|
|
|
399
|
+
|
|
|
400
|
+ //贡献值
|
|
|
401
|
+ $this->con_log($spread_data['uid'],round($pv * 0.09,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值");
|
|
|
402
|
+ //积分
|
|
|
403
|
+ $this->score_log($spread_data['uid'],round($pv * 0.09,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分");
|
|
|
404
|
+
|
|
|
405
|
+
|
|
|
406
|
+ }else if($spread_data['user_group'] == 4){
|
|
|
407
|
+ $con = $spread_data['contribute'] + round($pv * 0.11,2);
|
|
|
408
|
+ $score = $spread_data['brokerage_price'] + round($pv * 0.11,2);
|
|
|
409
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
|
|
|
410
|
+
|
|
|
411
|
+ //贡献值
|
|
|
412
|
+ $this->con_log($spread_data['uid'],round($pv * 0.11,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值");
|
|
|
413
|
+ //积分
|
|
|
414
|
+ $this->score_log($spread_data['uid'],round($pv * 0.11,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分");
|
|
|
415
|
+
|
|
|
416
|
+
|
|
|
417
|
+ }else if($spread_data['user_group'] == 5){
|
|
|
418
|
+ $con = $spread_data['contribute'] + round($pv * 0.13,2);
|
|
|
419
|
+ $score = $spread_data['brokerage_price'] + round($pv * 0.13,2);
|
|
|
420
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
|
|
|
421
|
+
|
|
|
422
|
+ //贡献值
|
|
|
423
|
+ $this->con_log($spread_data['uid'],round($pv * 0.13,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值");
|
|
|
424
|
+ //积分
|
|
|
425
|
+ $this->score_log($spread_data['uid'],round($pv * 0.13,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分");
|
|
|
426
|
+
|
|
|
427
|
+ }else if($spread_data['user_group'] == 6){
|
|
|
428
|
+ $con = $spread_data['contribute'] + round($pv * 0.15,2);
|
|
|
429
|
+ $score = $spread_data['brokerage_price'] + round($pv * 0.15,2);
|
|
|
430
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
|
|
|
431
|
+
|
|
|
432
|
+ //贡献值
|
|
|
433
|
+ $this->con_log($spread_data['uid'],round($pv * 0.15,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值");
|
|
|
434
|
+ //积分
|
|
|
435
|
+ $this->score_log($spread_data['uid'],round($pv * 0.15,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分");
|
|
|
436
|
+
|
|
|
437
|
+
|
|
|
438
|
+ }else if($spread_data['user_group'] == 7){
|
|
|
439
|
+ $con = $spread_data['contribute'] + round($pv * 0.17,2);
|
|
|
440
|
+ $score = $spread_data['brokerage_price'] + round($pv * 0.17,2);
|
|
|
441
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
|
|
|
442
|
+
|
|
|
443
|
+ //贡献值
|
|
|
444
|
+ $this->con_log($spread_data['uid'],round($pv * 0.17,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值");
|
|
|
445
|
+ //积分
|
|
|
446
|
+ $this->score_log($spread_data['uid'],round($pv * 0.17,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分");
|
|
|
447
|
+
|
|
|
448
|
+
|
|
|
449
|
+ }
|
|
|
450
|
+ //养老金
|
|
|
451
|
+ $this->bill_user_log($spread_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
|
|
|
452
|
+ //佣金
|
|
|
453
|
+ $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'. $yj_amount_90,$store_order_data['mer_id']);
|
|
|
454
|
+ //复购金
|
|
|
455
|
+ $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
456
|
+
|
|
|
457
|
+ }
|
|
|
458
|
+
|
|
|
459
|
+ //普通的用户推广人
|
|
|
460
|
+ if($spread_data['user_group'] == 1){
|
|
|
461
|
+ // $yj_amount = $spread_data['annuity'] + round($pv * 0.01,2);
|
|
|
462
|
+ // Db::name('user')->where('uid',$user_data['spread_uid'])->update(['annuity'=>$ylj_amount,'brokerage_price'=>$yj_amount]);
|
|
|
463
|
+ // //推广养老金
|
|
|
464
|
+ // $this->bill_user_log($user_data['spread_uid'],round($pv * 0.01,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'推广获得养老金'.round($pv * 0.01,2),$store_order_data['mer_id']);
|
|
|
465
|
+ // //推广佣金
|
|
|
466
|
+ // $this->bill_user_log($user_data['spread_uid'],round($pv * 0.01,2),$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.round($pv * 0.01,2),$store_order_data['mer_id']);
|
|
|
467
|
+
|
|
|
468
|
+ //获取贡献值和积分和佣金
|
|
|
469
|
+ $gx_jf = $spread_data['contribute'] + round($pv * 0.03,2);
|
|
|
470
|
+
|
|
|
471
|
+ //$yj111 = $spread_data['brokerage_price'] + $yj1;
|
|
|
472
|
+
|
|
|
473
|
+ $yj_amount_90 = round($yj1 * 0.9,2);
|
|
|
474
|
+ $fgj_amount_10 = round($yj1 * 0.1,2);//推广者的佣金抽10%到个人复购金
|
|
|
475
|
+
|
|
|
476
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
477
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
478
|
+ $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
479
|
+
|
|
|
480
|
+
|
|
|
481
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $gx_jf,'score'=> $gx_jf,'brokerage_price'=> $yj_amount,'fugou'=>$fgj_amount]);
|
|
|
482
|
+ $this->con_log($spread_data['uid'],round($pv * 0.03,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值");
|
|
|
483
|
+ $this->score_log($spread_data['uid'],round($pv * 0.03,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分");
|
|
|
484
|
+ //推广佣金
|
|
|
485
|
+ $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.$yj_amount_90,$store_order_data['mer_id']);
|
|
|
486
|
+ }
|
|
|
487
|
+
|
|
|
488
|
+
|
|
|
489
|
+
|
|
|
490
|
+
|
|
|
491
|
+ }
|
|
|
492
|
+ //锁客收益
|
|
|
493
|
+ if($user_data['mer_id'] != 0){
|
|
|
494
|
+
|
|
|
495
|
+ $merchant_data = Db::name('merchant')->where('mer_id',$user_data['mer_id'])->find();
|
|
|
496
|
+
|
|
|
497
|
+ $merchant_user_data = Db::name('user')->where('uid',$merchant_data['uid'])->find();
|
|
|
498
|
+
|
|
|
499
|
+ if(!empty($merchant_user_data)){
|
|
|
500
|
+
|
|
|
501
|
+
|
|
|
502
|
+ $yj_amount_90 = round($pv * 0.035,2) * 0.9;
|
|
|
503
|
+ $fgj_amount_10 = round($pv * 0.035,2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
504
|
+
|
|
|
505
|
+ $yj_amount = $merchant_data['brokerage_price'] + $yj_amount_90;
|
|
|
506
|
+ $fgj_amount = $merchant_data['fugou'] + $fgj_amount_10;
|
|
|
507
|
+ $this->fugou_user_log($merchant_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
|
|
|
508
|
+
|
|
|
509
|
+
|
|
|
510
|
+
|
|
|
511
|
+ //Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
|
|
|
512
|
+ //推广佣金
|
|
|
513
|
+ $this->bill_user_log($merchant_data['uid'],round($pv * 0.35,2),$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得拥金'.round($pv * 0.35,2),$store_order_data['mer_id']);
|
|
|
514
|
+ }
|
|
|
515
|
+
|
|
|
516
|
+ }
|
|
|
517
|
+
|
|
|
518
|
+
|
|
|
519
|
+ }
|
|
|
520
|
+
|
|
|
521
|
+
|
|
|
522
|
+ //利润分配 end
|
|
|
523
|
+ //商城订单
|
|
|
524
|
+ //如果注释了event事件,需要手动修改订单状态 1:代发货
|
|
|
525
|
+ Db::name('store_order')->where('group_order_id', $group_order_id)->update(['status'=>0]);
|
|
|
526
|
+
|
|
|
527
|
+ $orderss = Db::name('store_order')->where('group_order_id', $group_order_id)->update(['paid'=>1,'pay_time'=>date('Y-m-d H:i:s'),'pay_open_id' => $post_data_str['expend']['open_id']]);
|
|
|
528
|
+
|
|
|
529
|
+ Db::name('store_group_order')->where('group_order_id',$group_order_id)->update(['paid'=>1,'pay_time'=>date('Y-m-d H:i:s')]);
|
|
|
530
|
+
|
|
76
|
531
|
event('pay_success_order', ['order_sn' => $requestId[0],'pay_type'=>$pay_type]);
|
|
|
532
|
+
|
|
77
|
533
|
break;
|
|
78
|
534
|
case 'pay_channel':
|
|
79
|
535
|
//渠道商
|
|
|
@@ -494,4 +950,132 @@ class Notify
|
|
494
|
950
|
}
|
|
495
|
951
|
return $newList;
|
|
496
|
952
|
}
|
|
|
953
|
+
|
|
|
954
|
+
|
|
|
955
|
+
|
|
|
956
|
+
|
|
|
957
|
+ //添加贡献值日志
|
|
|
958
|
+ public function con_log($uid,$num,$order_id,$order_type,$mark){
|
|
|
959
|
+
|
|
|
960
|
+ $con_data = Db::name('user')->where("uid",$uid)->find();
|
|
|
961
|
+
|
|
|
962
|
+ $con = [
|
|
|
963
|
+ 'uid'=>$uid,
|
|
|
964
|
+ 'number'=>$num,//赠送数量
|
|
|
965
|
+ 'status'=>-1,//红包状态
|
|
|
966
|
+ 'mark'=>$mark,//备注
|
|
|
967
|
+ 'desc'=>'',//描述
|
|
|
968
|
+ 'order_id'=>$order_id,//订单id
|
|
|
969
|
+ 'surplus'=> $con_data['contribute'],//剩余
|
|
|
970
|
+ 'order_type'=>$order_type,//订单类型
|
|
|
971
|
+ 'type'=>1,//1增加,2消耗
|
|
|
972
|
+ 'settlement_time'=>date('Y-m-d H:i:s'),
|
|
|
973
|
+ 'addtime'=>time()
|
|
|
974
|
+ ];
|
|
|
975
|
+
|
|
|
976
|
+ Db::name('user_sign_gongxian')->insert($con);
|
|
|
977
|
+ }
|
|
|
978
|
+
|
|
|
979
|
+ //添加积分日志
|
|
|
980
|
+ public function score_log($uid,$num,$order_id,$order_type,$mark){
|
|
|
981
|
+
|
|
|
982
|
+ $score_data = Db::name('user')->where("uid",$uid)->find();
|
|
|
983
|
+
|
|
|
984
|
+ $score = [
|
|
|
985
|
+ 'uid'=>$uid,
|
|
|
986
|
+ 'continuity_day'=>0,//连续签到天数
|
|
|
987
|
+ 'reward_socre'=>$num,//积分数量
|
|
|
988
|
+ 'signin_time'=>0,//签到时间
|
|
|
989
|
+ 'source_uid'=>0,//赠送积分用户来源id
|
|
|
990
|
+ 'status'=>-1,//积分状态1:有效,0:失效,1:待确认
|
|
|
991
|
+ 'mark'=> $mark,//备注
|
|
|
992
|
+ 'order_id'=>$order_id,//订单id
|
|
|
993
|
+ 'pm'=>1,//1收入,2支出
|
|
|
994
|
+ 'surplus'=> $score_data['score'],//剩余
|
|
|
995
|
+ 'order_type'=>$order_type,//订单类型 ,10精彩生活区,11会员区,12复购区
|
|
|
996
|
+ 'source_type'=>3,//积分类型,1签到,2分享好友注册赠送,3自己下单赠送
|
|
|
997
|
+
|
|
|
998
|
+ 'settlement_time'=>date('Y-m-d H:i:s'),
|
|
|
999
|
+ 'addtime'=>time()
|
|
|
1000
|
+ ];
|
|
|
1001
|
+
|
|
|
1002
|
+ Db::name('user_sign_score')->insert($score);
|
|
|
1003
|
+ }
|
|
|
1004
|
+
|
|
|
1005
|
+ //添加推广佣金/养老金日志(养老金金额)
|
|
|
1006
|
+ public function bill_user_log($uid,$num,$order_id,$comm_order_type,$order_sn,$mark,$merid,$ds=1){
|
|
|
1007
|
+
|
|
|
1008
|
+ $con_data = Db::name('user')->where("uid",$uid)->find();
|
|
|
1009
|
+ $name = '';
|
|
|
1010
|
+ if($comm_order_type==3){
|
|
|
1011
|
+ $name = '直推奖';
|
|
|
1012
|
+ }else if($comm_order_type==5){
|
|
|
1013
|
+ $name = '养老金';
|
|
|
1014
|
+ }
|
|
|
1015
|
+
|
|
|
1016
|
+ $bill = [
|
|
|
1017
|
+ 'uid'=>$uid,
|
|
|
1018
|
+ 'link_id'=>$order_id,//关联订单id
|
|
|
1019
|
+ 'pm'=>1,//0:支出,1:获得
|
|
|
1020
|
+ 'title'=>$name,//账单标题
|
|
|
1021
|
+ 'category'=>'now_money',//明细种类
|
|
|
1022
|
+ 'type'=>'commission',//明细类型
|
|
|
1023
|
+ 'number'=>$num,//明细数字
|
|
|
1024
|
+ 'balance'=>0,//剩余
|
|
|
1025
|
+ 'mark'=>$mark,//备注
|
|
|
1026
|
+ 'create_time'=>date('Y-m-d H:i:s'),//添加时间
|
|
|
1027
|
+ 'status'=>$ds,//0待确定,1有效,-1无效
|
|
|
1028
|
+ 'commission_type'=>$comm_order_type,//佣金类型 1代理费 2 消费佣金 3直推奖√ 4辖区佣金\r\n5 养老金√ 6 广告费
|
|
|
1029
|
+ //7 跨店奖励√ 8平台奖励 9渠道商\r\n10 推荐创客收益√ 11分红奖金√ 12代理区域收益√ 13消费循环佣金
|
|
|
1030
|
+ //14-推荐代理收益√ 15邀请小区团长升级√ 16大v分享奖√ 17创客合伙人√ 18积分奖励√ 19创客补贴√’
|
|
|
1031
|
+ 'order_sn'=>$order_sn,//订单号
|
|
|
1032
|
+ 'tripartite'=>0,//
|
|
|
1033
|
+ 'type_shop'=>0,//0平台1多多进宝2唯品会3苏宁易购4网易考拉5淘宝客6京东联盟7饿了么8线上
|
|
|
1034
|
+ 'mer_id'=>$merid,//商户id
|
|
|
1035
|
+ 'source'=>0,//1线下 0线上
|
|
|
1036
|
+ 'order_type'=>1,//1自营 2 第三方 订单类型
|
|
|
1037
|
+ 'is_red_brokerage'=>0,//1红积分对冲佣金 0正常佣金
|
|
|
1038
|
+ 'gzc'=>3,//养老金是否已进入公证处log表0:未进入。1:已进入
|
|
|
1039
|
+ 'take_time'=>'',//结算时间
|
|
|
1040
|
+ 'district_id'=>'',//
|
|
|
1041
|
+ 'street_id'=>'',//
|
|
|
1042
|
+ 'month'=>'',//月份
|
|
|
1043
|
+
|
|
|
1044
|
+
|
|
|
1045
|
+ ];
|
|
|
1046
|
+
|
|
|
1047
|
+ Db::name('user_bill')->insert($bill);
|
|
|
1048
|
+ }
|
|
|
1049
|
+
|
|
|
1050
|
+ //添加复购金
|
|
|
1051
|
+ public function fugou_user_log($uid,$num,$order_id,$type_inc_des){
|
|
|
1052
|
+
|
|
|
1053
|
+ $bill = [
|
|
|
1054
|
+ 'uid'=>$uid,
|
|
|
1055
|
+ 'number'=>$num,//数量
|
|
|
1056
|
+ 'status'=>1,//复购金状态1-有效 0-失效 -1待确认
|
|
|
1057
|
+ 'mark'=>"复购金",//备注
|
|
|
1058
|
+ 'desc'=>"抽取佣金的10%作为复购金",//描述
|
|
|
1059
|
+ 'order_id'=>$order_id,//订单id
|
|
|
1060
|
+ 'surplus'=>0,//剩余
|
|
|
1061
|
+ 'order_type'=>11,//关联订单ID
|
|
|
1062
|
+ 'type'=>$type_inc_des,//复购金类型 :1赠送,2消耗
|
|
|
1063
|
+ 'settlement_time'=>date('Y-m-d H:i:s'),//添加时间,
|
|
|
1064
|
+ 'addtime'=>time(),
|
|
|
1065
|
+ ];
|
|
|
1066
|
+
|
|
|
1067
|
+ Db::name('user_sign_fugou')->insert($bill);
|
|
|
1068
|
+ }
|
|
|
1069
|
+
|
|
|
1070
|
+
|
|
|
1071
|
+
|
|
|
1072
|
+
|
|
|
1073
|
+
|
|
|
1074
|
+
|
|
|
1075
|
+
|
|
|
1076
|
+
|
|
|
1077
|
+
|
|
|
1078
|
+
|
|
|
1079
|
+
|
|
|
1080
|
+
|
|
497
|
1081
|
}
|