|
|
@@ -4,6 +4,7 @@
|
|
4
|
4
|
* @Author: Qinii
|
|
5
|
5
|
* @Date: 2020/5/28
|
|
6
|
6
|
*/
|
|
|
7
|
+
|
|
7
|
8
|
namespace app\controller\api\store\merchant;
|
|
8
|
9
|
|
|
9
|
10
|
use think\App;
|
|
|
@@ -19,14 +20,14 @@ class Taskorderlianc extends BaseController
|
|
19
|
20
|
/**
|
|
20
|
21
|
* 会员升级
|
|
21
|
22
|
*/
|
|
22
|
|
- public function member_update($orderInfo,$goods_of_info,$user_id)
|
|
|
23
|
+ public function member_update($orderInfo, $goods_of_info, $user_id)
|
|
23
|
24
|
{
|
|
24
|
25
|
//
|
|
25
|
26
|
//$user_id = $userInfo['id'];
|
|
26
|
27
|
$order_id = $orderInfo['id'];
|
|
27
|
28
|
|
|
28
|
29
|
//code...
|
|
29
|
|
- $pay_gb = round($orderInfo['num'] * $orderInfo['gb_num'],2);
|
|
|
30
|
+ $pay_gb = round($orderInfo['num'] * $orderInfo['gb_num'], 2);
|
|
30
|
31
|
//$pay_vr = round($orderInfo['num'] * $orderInfo['vr_num'],2);
|
|
31
|
32
|
//付款按照700的VR付款 start
|
|
32
|
33
|
$vr_num = 0;
|
|
|
@@ -36,14 +37,13 @@ class Taskorderlianc extends BaseController
|
|
36
|
37
|
$vr_num = 7000;
|
|
37
|
38
|
} elseif ($orderInfo['price'] == 11800) {
|
|
38
|
39
|
$vr_num = 2100;
|
|
39
|
|
- }elseif($orderInfo['price'] == 10620){
|
|
|
40
|
+ } elseif ($orderInfo['price'] == 10620) {
|
|
40
|
41
|
$vr_num = 6300;
|
|
41
|
42
|
}
|
|
42
|
43
|
|
|
43
|
44
|
|
|
44
|
|
-
|
|
45
|
45
|
$pay_gb1 = $vr_num;
|
|
46
|
|
- $pay_vr1 =$orderInfo['price'];//记录VR值
|
|
|
46
|
+ $pay_vr1 = $orderInfo['price'];//记录VR值
|
|
47
|
47
|
|
|
48
|
48
|
|
|
49
|
49
|
// $result = Db::name("old_user_jbp")->where("id",$user_id)->dec("vr",$orderInfo['price'])->save();//1.0jbp旧表
|
|
|
@@ -51,43 +51,41 @@ class Taskorderlianc extends BaseController
|
|
51
|
51
|
|
|
52
|
52
|
|
|
53
|
53
|
$result = true;
|
|
54
|
|
- if($result) {
|
|
|
54
|
+ if ($result) {
|
|
55
|
55
|
$invite_id = $goods_of_info['spread_id'];
|
|
56
|
56
|
|
|
57
|
57
|
|
|
58
|
58
|
$zs_ylj = 0; //养老金赋值
|
|
59
|
59
|
|
|
60
|
60
|
|
|
61
|
|
- if($goods_of_info['money'] == 1180){
|
|
|
61
|
+ if ($goods_of_info['money'] == 1180) {
|
|
62
|
62
|
//修改订单到账状态
|
|
63
|
|
- $zs_ylj = round(700 * 0.05,2);//计算的养老金 金额
|
|
64
|
|
- }elseif($goods_of_info['money'] == 11800){
|
|
65
|
|
- $zs_ylj = round(7000 * 0.05,2);//计算的养老金 金额
|
|
66
|
|
- }elseif($goods_of_info['money'] == 3540){
|
|
67
|
|
- $zs_ylj = round(2100 * 0.05,2);//计算的养老金 金额
|
|
68
|
|
- }elseif($goods_of_info['money'] == 10620){
|
|
69
|
|
- $zs_ylj = round(6300 * 0.05,2);//计算的养老金 金额
|
|
70
|
|
- }elseif($goods_of_info['money'] == 9440){
|
|
71
|
|
- $zs_ylj = round(5600 * 0.05,2);//八单计算的养老金 金额
|
|
72
|
|
- }elseif($goods_of_info['money'] == 2360){
|
|
73
|
|
- $zs_ylj = round(1400 * 0.05,2);//两单计算的养老金 金额
|
|
|
63
|
+ $zs_ylj = round(700 * 0.05, 2);//计算的养老金 金额
|
|
|
64
|
+ } elseif ($goods_of_info['money'] == 11800) {
|
|
|
65
|
+ $zs_ylj = round(7000 * 0.05, 2);//计算的养老金 金额
|
|
|
66
|
+ } elseif ($goods_of_info['money'] == 3540) {
|
|
|
67
|
+ $zs_ylj = round(2100 * 0.05, 2);//计算的养老金 金额
|
|
|
68
|
+ } elseif ($goods_of_info['money'] == 10620) {
|
|
|
69
|
+ $zs_ylj = round(6300 * 0.05, 2);//计算的养老金 金额
|
|
|
70
|
+ } elseif ($goods_of_info['money'] == 9440) {
|
|
|
71
|
+ $zs_ylj = round(5600 * 0.05, 2);//八单计算的养老金 金额
|
|
|
72
|
+ } elseif ($goods_of_info['money'] == 2360) {
|
|
|
73
|
+ $zs_ylj = round(1400 * 0.05, 2);//两单计算的养老金 金额
|
|
74
|
74
|
}
|
|
75
|
75
|
|
|
76
|
76
|
|
|
77
|
|
-
|
|
78
|
|
-
|
|
79
|
77
|
$uid = $user_id;
|
|
80
|
78
|
$new_user_id = $uid;
|
|
81
|
|
- if(empty($new_user_id)) {
|
|
82
|
|
- abort(0,"当前绑定会员查询错误");
|
|
|
79
|
+ if (empty($new_user_id)) {
|
|
|
80
|
+ abort(0, "当前绑定会员查询错误");
|
|
83
|
81
|
}
|
|
84
|
82
|
|
|
85
|
|
- $new_nums =Db::name("old_user_of_goods")->where("user_id", $uid)->sum("money");
|
|
|
83
|
+ $new_nums = Db::name("old_user_of_goods")->where("user_id", $uid)->sum("money");
|
|
86
|
84
|
|
|
87
|
85
|
//增加过后权益对比 获取当前权益等级
|
|
88
|
|
- $old_level_id = Db::name("old_user_jbp")->where("id",$uid)->find();
|
|
|
86
|
+ $old_level_id = Db::name("old_user_jbp")->where("id", $uid)->find();
|
|
89
|
87
|
|
|
90
|
|
- $old_level_info = Db::name("old_user_level")->where("id",$old_level_id['user_level_id'])->find();
|
|
|
88
|
+ $old_level_info = Db::name("old_user_level")->where("id", $old_level_id['user_level_id'])->find();
|
|
91
|
89
|
|
|
92
|
90
|
|
|
93
|
91
|
$level_info = [];
|
|
|
@@ -97,8 +95,8 @@ class Taskorderlianc extends BaseController
|
|
97
|
95
|
//计算会员等级 升级
|
|
98
|
96
|
foreach ($level_list as $key => $value) {
|
|
99
|
97
|
# code...
|
|
100
|
|
- if($new_nums>=$value['money']) {
|
|
101
|
|
- $level_info = $value;
|
|
|
98
|
+ if ($new_nums >= $value['money']) {
|
|
|
99
|
+ $level_info = $value;
|
|
102
|
100
|
break;
|
|
103
|
101
|
}
|
|
104
|
102
|
}
|
|
|
@@ -107,21 +105,20 @@ class Taskorderlianc extends BaseController
|
|
107
|
105
|
$zs_withdraw_quota = $orderInfo['price'];
|
|
108
|
106
|
|
|
109
|
107
|
|
|
110
|
|
- if($old_level_info['id'] == $level_info['id']) {
|
|
|
108
|
+ if ($old_level_info['id'] == $level_info['id']) {
|
|
111
|
109
|
//未到达升级权益 不改变用户等级
|
|
112
|
110
|
$update_status = false;
|
|
113
|
|
- }else{
|
|
|
111
|
+ } else {
|
|
114
|
112
|
$update_status = true;
|
|
115
|
113
|
$user_level = $level_info['id'];
|
|
116
|
114
|
//var_dump( $user_level);
|
|
117
|
|
- Db::name("old_user_jbp")->where("id",$new_user_id)->save(['user_level_id'=>$user_level]);//1.0jbp旧表
|
|
118
|
|
- Db::name("user")->where("uid",$new_user_id)->save(['user_level_id_old'=>$user_level]);//2.0新表
|
|
|
115
|
+ Db::name("old_user_jbp")->where("id", $new_user_id)->save(['user_level_id' => $user_level]);//1.0jbp旧表
|
|
|
116
|
+ Db::name("user")->where("uid", $new_user_id)->save(['user_level_id_old' => $user_level]);//2.0新表
|
|
119
|
117
|
|
|
120
|
118
|
// todo 同时改变他的权益
|
|
121
|
119
|
}
|
|
122
|
120
|
|
|
123
|
121
|
|
|
124
|
|
-
|
|
125
|
122
|
// Db::name("old_user_jbp")->where("id",$new_user_id)->inc("withdraw_quota",$zs_withdraw_quota)->save();//1.0jbp旧表
|
|
126
|
123
|
// Db::name("user")->where("uid",$new_user_id)->save(['withdraw_quota_old'=>$zs_withdraw_quota]);//2.0新表
|
|
127
|
124
|
|
|
|
@@ -135,55 +132,54 @@ class Taskorderlianc extends BaseController
|
|
135
|
132
|
|
|
136
|
133
|
|
|
137
|
134
|
//检查是不是订单价格是1180或者11800,更改VR
|
|
138
|
|
- 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){
|
|
|
135
|
+ 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) {
|
|
139
|
136
|
//修改订单到账状态
|
|
140
|
137
|
|
|
141
|
138
|
|
|
142
|
|
- 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()]);
|
|
|
139
|
+ 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()]);
|
|
143
|
140
|
|
|
144
|
141
|
|
|
145
|
142
|
}
|
|
146
|
143
|
}
|
|
147
|
144
|
|
|
148
|
145
|
|
|
149
|
|
-
|
|
150
|
|
- if($result) {
|
|
|
146
|
+ if ($result) {
|
|
151
|
147
|
//更改订单状态
|
|
152
|
148
|
|
|
153
|
149
|
Db::commit();
|
|
154
|
|
- $new_user_name = Db::name("old_user_jbp")->where("id",$new_user_id)->value("user_name");
|
|
|
150
|
+ $new_user_name = Db::name("old_user_jbp")->where("id", $new_user_id)->value("user_name");
|
|
155
|
151
|
$new_user_name = empty($new_user_name) ? "" : $new_user_name;
|
|
156
|
152
|
|
|
157
|
153
|
//记录日志信息
|
|
158
|
154
|
|
|
159
|
|
- if($user_id == $invite_id) {
|
|
|
155
|
+ if ($user_id == $invite_id) {
|
|
160
|
156
|
//报单中心=推荐人 GB记录日志有问题需要传入指定参数去计算
|
|
161
|
157
|
//$money = Db::name("old_user_jbp")->where("id",$user_id)->value("gb");
|
|
162
|
158
|
//$appoint_money = $money - $zs_invite_gb;
|
|
163
|
159
|
|
|
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){
|
|
|
160
|
+ 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
|
161
|
|
|
166
|
162
|
|
|
167
|
|
- $this->change_user_log66($user_id,"vr",2,$pay_vr1,"declare_expend",'权益消费VR-'.$new_user_name);
|
|
|
163
|
+ $this->change_user_log66($user_id, "vr", 2, $pay_vr1, "declare_expend", '权益消费VR-' . $new_user_name);
|
|
168
|
164
|
|
|
169
|
165
|
}
|
|
170
|
|
- }else{
|
|
|
166
|
+ } else {
|
|
171
|
167
|
|
|
172
|
|
- 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){
|
|
|
168
|
+ 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) {
|
|
173
|
169
|
|
|
174
|
170
|
|
|
175
|
|
- $this->change_user_log66($user_id,"vr",2,$pay_vr1,"declare_expend",'权益消费VR-'.$new_user_name);
|
|
|
171
|
+ $this->change_user_log66($user_id, "vr", 2, $pay_vr1, "declare_expend", '权益消费VR-' . $new_user_name);
|
|
176
|
172
|
|
|
177
|
173
|
}
|
|
178
|
174
|
}
|
|
179
|
175
|
// $this->change_user_log66($new_user_id,'gb',1,$zs_gb,"levle_update_zs","权益升级达标赠送");
|
|
180
|
|
- $this->change_user_log66($new_user_id,'withdraw_quota_old',1,$zs_withdraw_quota,"levle_update_zs","权益升级达标赠送");
|
|
|
176
|
+ $this->change_user_log66($new_user_id, 'withdraw_quota_old', 1, $zs_withdraw_quota, "levle_update_zs", "权益升级达标赠送");
|
|
181
|
177
|
// $this->change_user_log66($invite_id,'gb',1,$zs_invite_gb,"levle_update_zs","邀请-".$new_user_name);
|
|
182
|
178
|
// echo 123;return;
|
|
183
|
179
|
//处理查看是否有待发放佣金
|
|
184
|
180
|
// $zs_withdraw_quota
|
|
185
|
|
- Db::name("old_user_jbp")->where("id",$new_user_id)->inc("total_withdraw_quota",$zs_withdraw_quota)->save();//1.0jbp旧表
|
|
186
|
|
- Db::name("user")->where("uid",$new_user_id)->inc("total_withdraw_quota_old",$zs_withdraw_quota)->save();
|
|
|
181
|
+ Db::name("old_user_jbp")->where("id", $new_user_id)->inc("total_withdraw_quota", $zs_withdraw_quota)->save();//1.0jbp旧表
|
|
|
182
|
+ Db::name("user")->where("uid", $new_user_id)->inc("total_withdraw_quota_old", $zs_withdraw_quota)->save();
|
|
187
|
183
|
// $this->releaseTobeAmount($new_user_id,$zs_withdraw_quota);
|
|
188
|
184
|
// $this->success("支付成功",['is_cash'=>0]);
|
|
189
|
185
|
}
|
|
|
@@ -191,34 +187,34 @@ class Taskorderlianc extends BaseController
|
|
191
|
187
|
// $this->error("操作失败");
|
|
192
|
188
|
}
|
|
193
|
189
|
|
|
194
|
|
- function change_user_log66($user_id,$type,$change_status,$money,$routine,$remark="",$is_admin=1,$appoint_money = 0)
|
|
|
190
|
+ function change_user_log66($user_id, $type, $change_status, $money, $routine, $remark = "", $is_admin = 1, $appoint_money = 0)
|
|
195
|
191
|
{
|
|
196
|
192
|
$transition = [
|
|
197
|
|
- 'pv'=>1,
|
|
198
|
|
- "gb"=>2,
|
|
199
|
|
- "df"=>3,
|
|
200
|
|
- "vr"=>4,
|
|
201
|
|
- "bt"=>5,
|
|
202
|
|
- "withdraw_quota_old"=>6,
|
|
203
|
|
- "unsettled_pension"=>7,
|
|
204
|
|
- "amount_old"=>8
|
|
|
193
|
+ 'pv' => 1,
|
|
|
194
|
+ "gb" => 2,
|
|
|
195
|
+ "df" => 3,
|
|
|
196
|
+ "vr" => 4,
|
|
|
197
|
+ "bt" => 5,
|
|
|
198
|
+ "withdraw_quota_old" => 6,
|
|
|
199
|
+ "unsettled_pension" => 7,
|
|
|
200
|
+ "amount_old" => 8
|
|
205
|
201
|
];
|
|
206
|
|
- $routineInfo = Db::name("old_routine_log_of_key")->where("key",$routine)->find();
|
|
207
|
|
- if(empty($routineInfo)) {
|
|
|
202
|
+ $routineInfo = Db::name("old_routine_log_of_key")->where("key", $routine)->find();
|
|
|
203
|
+ if (empty($routineInfo)) {
|
|
208
|
204
|
return false;
|
|
209
|
205
|
}
|
|
210
|
206
|
$key_id = isset($routineInfo['id']) ? $routineInfo['id'] : 0;
|
|
211
|
207
|
//再去查询变更前的 金额
|
|
212
|
|
- if($appoint_money > 0) {
|
|
|
208
|
+ if ($appoint_money > 0) {
|
|
213
|
209
|
$alter_money = $appoint_money;
|
|
214
|
|
- }else{
|
|
|
210
|
+ } else {
|
|
215
|
211
|
//再去查询变更前的 金额
|
|
216
|
|
- $alter_money = Db::name("user")->where('uid',$user_id)->value($type);
|
|
|
212
|
+ $alter_money = Db::name("user")->where('uid', $user_id)->value($type);
|
|
217
|
213
|
}
|
|
218
|
|
- if($change_status == 1) {
|
|
|
214
|
+ if ($change_status == 1) {
|
|
219
|
215
|
//新增前
|
|
220
|
|
- $alter_money = $alter_money-$money;
|
|
221
|
|
- }else if($change_status == 2){
|
|
|
216
|
+ $alter_money = $alter_money - $money;
|
|
|
217
|
+ } else if ($change_status == 2) {
|
|
222
|
218
|
//减少前
|
|
223
|
219
|
$alter_money = $alter_money + $money;
|
|
224
|
220
|
}
|
|
|
@@ -231,46 +227,47 @@ class Taskorderlianc extends BaseController
|
|
231
|
227
|
$inser_data['remark'] = $remark;
|
|
232
|
228
|
$inser_data['is_admin'] = $is_admin;
|
|
233
|
229
|
$inser_data['create_time'] = time();
|
|
234
|
|
- $inser_data['alter_money'] = isset($alter_money) ? $alter_money : 0;
|
|
|
230
|
+ $inser_data['alter_money'] = isset($alter_money) ? $alter_money : 0;
|
|
235
|
231
|
Db::name("old_user_log")->insert($inser_data);
|
|
236
|
232
|
}
|
|
237
|
233
|
|
|
238
|
234
|
//添加推广佣金/养老金日志(养老金金额)
|
|
239
|
|
- public function bill_user_log($uid,$name,$num,$mark){
|
|
|
235
|
+ public function bill_user_log($uid, $name, $num, $mark)
|
|
|
236
|
+ {
|
|
240
|
237
|
|
|
241
|
|
- $con_data = Db::name('user')->where("uid",$uid)->find();
|
|
|
238
|
+ $con_data = Db::name('user')->where("uid", $uid)->find();
|
|
242
|
239
|
//如果是会员专区就即刻到账
|
|
243
|
240
|
|
|
244
|
|
- Db::name('user')->where("uid",$con_data['uid'])->update(['brokerage_price'=> $con_data['brokerage_price'] + $num]);
|
|
|
241
|
+ Db::name('user')->where("uid", $con_data['uid'])->update(['brokerage_price' => $con_data['brokerage_price'] + $num]);
|
|
245
|
242
|
|
|
246
|
243
|
|
|
247
|
244
|
$bill = [
|
|
248
|
|
- 'uid'=>$uid,
|
|
249
|
|
- 'link_id'=>0,//关联订单id
|
|
250
|
|
- 'pm'=>1,//0:支出,1:获得
|
|
251
|
|
- 'title'=>$name,//账单标题
|
|
252
|
|
- 'category'=>'now_money',//明细种类
|
|
253
|
|
- 'type'=>'commission',//明细类型
|
|
254
|
|
- 'number'=>$num,//明细数字
|
|
255
|
|
- 'balance'=>0,//剩余
|
|
256
|
|
- 'mark'=>$mark,//备注
|
|
257
|
|
- 'create_time'=>date('Y-m-d H:i:s'),//添加时间
|
|
258
|
|
- 'status'=>1,//0待确定,1有效,-1无效
|
|
259
|
|
- 'commission_type'=>8,//佣金类型 1代理费 2 消费佣金 3直推奖√ 4辖区佣金\r\n5 养老金√ 6 广告费
|
|
|
245
|
+ 'uid' => $uid,
|
|
|
246
|
+ 'link_id' => 0,//关联订单id
|
|
|
247
|
+ 'pm' => 1,//0:支出,1:获得
|
|
|
248
|
+ 'title' => $name,//账单标题
|
|
|
249
|
+ 'category' => 'now_money',//明细种类
|
|
|
250
|
+ 'type' => 'commission',//明细类型
|
|
|
251
|
+ 'number' => $num,//明细数字
|
|
|
252
|
+ 'balance' => 0,//剩余
|
|
|
253
|
+ 'mark' => $mark,//备注
|
|
|
254
|
+ 'create_time' => date('Y-m-d H:i:s'),//添加时间
|
|
|
255
|
+ 'status' => 1,//0待确定,1有效,-1无效
|
|
|
256
|
+ 'commission_type' => 8,//佣金类型 1代理费 2 消费佣金 3直推奖√ 4辖区佣金\r\n5 养老金√ 6 广告费
|
|
260
|
257
|
//7 跨店奖励√ 8平台奖励 9渠道商\r\n10 推荐创客收益√ 11分红奖金√ 12代理区域收益√ 13消费循环佣金
|
|
261
|
258
|
//14-推荐代理收益√ 15邀请小区团长升级√ 16大v分享奖√ 17创客合伙人√ 18积分奖励√ 19创客补贴√’
|
|
262
|
|
- 'order_sn'=>0,//订单号
|
|
263
|
|
- 'tripartite'=>0,//
|
|
264
|
|
- 'type_shop'=>0,//0平台1多多进宝2唯品会3苏宁易购4网易考拉5淘宝客6京东联盟7饿了么8线上
|
|
265
|
|
- 'mer_id'=>0,//商户id
|
|
266
|
|
- 'source'=>0,//1线下 0线上
|
|
267
|
|
- 'order_type'=>1,//1自营 2 第三方 订单类型
|
|
268
|
|
- 'is_red_brokerage'=>0,//1红积分对冲佣金 0正常佣金
|
|
269
|
|
- 'gzc'=>3,//养老金是否已进入公证处log表0:未进入。1:已进入
|
|
270
|
|
- 'take_time'=>'',//结算时间
|
|
271
|
|
- 'district_id'=>'',//
|
|
272
|
|
- 'street_id'=>'',//
|
|
273
|
|
- 'month'=>'',//月份
|
|
|
259
|
+ 'order_sn' => 0,//订单号
|
|
|
260
|
+ 'tripartite' => 0,//
|
|
|
261
|
+ 'type_shop' => 0,//0平台1多多进宝2唯品会3苏宁易购4网易考拉5淘宝客6京东联盟7饿了么8线上
|
|
|
262
|
+ 'mer_id' => 0,//商户id
|
|
|
263
|
+ 'source' => 0,//1线下 0线上
|
|
|
264
|
+ 'order_type' => 1,//1自营 2 第三方 订单类型
|
|
|
265
|
+ 'is_red_brokerage' => 0,//1红积分对冲佣金 0正常佣金
|
|
|
266
|
+ 'gzc' => 3,//养老金是否已进入公证处log表0:未进入。1:已进入
|
|
|
267
|
+ 'take_time' => '',//结算时间
|
|
|
268
|
+ 'district_id' => '',//
|
|
|
269
|
+ 'street_id' => '',//
|
|
|
270
|
+ 'month' => '',//月份
|
|
274
|
271
|
|
|
275
|
272
|
|
|
276
|
273
|
];
|
|
|
@@ -279,77 +276,192 @@ class Taskorderlianc extends BaseController
|
|
279
|
276
|
}
|
|
280
|
277
|
|
|
281
|
278
|
|
|
|
279
|
+ public function lst2()
|
|
|
280
|
+ {
|
|
|
281
|
+
|
|
282
|
282
|
|
|
|
283
|
+ $week_record = 10500 + 50000; //20250310
|
|
283
|
284
|
|
|
284
|
|
- public function lst2(){
|
|
|
285
|
+ // 查询测试人员账号信息
|
|
|
286
|
+ //18973958920
|
|
|
287
|
+ //15186694339
|
|
|
288
|
+ //18833633835
|
|
|
289
|
+ //19525470098
|
|
|
290
|
+ //17756507016
|
|
|
291
|
+ //18226705337
|
|
|
292
|
+ $testAccount = ['18973958920', '15186694339', '18833633835', '19525470098', '17756507016', '18226705337'];
|
|
|
293
|
+ $removeUserList = Db::name("user")
|
|
|
294
|
+ ->whereIn('account', $testAccount)
|
|
|
295
|
+ ->where("status", "<>", 0)
|
|
|
296
|
+ ->where('is_del', '<>', 1)
|
|
|
297
|
+ ->select()
|
|
|
298
|
+ ->toArray();
|
|
|
299
|
+ $removeUserIdList = array_column($removeUserList, 'uid');
|
|
|
300
|
+ // 定义分红金额
|
|
|
301
|
+ $week_record = $this->getTeamPvByTime('last_week', $removeUserIdList);
|
|
|
302
|
+ // 分红金额 - 红包金额
|
|
|
303
|
+ $redEnvelope = $this->getRedEnvelopeByTime('last_week', $removeUserIdList);
|
|
285
|
304
|
|
|
|
305
|
+ $week_record -= $redEnvelope;
|
|
286
|
306
|
|
|
287
|
307
|
|
|
|
308
|
+ $originator_award = round(($week_record * 0.05), 2);
|
|
288
|
309
|
|
|
|
310
|
+ $list = Db::name("user")->where("originator_id_old", ">", 0)->where("status", 1)->field("uid,originator_id_old")->select()->toArray();
|
|
289
|
311
|
|
|
|
312
|
+ // foreach($list as $k=>$v){
|
|
|
313
|
+ // var_dump($v);
|
|
|
314
|
+ // }
|
|
290
|
315
|
|
|
|
316
|
+ // return;
|
|
291
|
317
|
|
|
292
|
|
- }
|
|
|
318
|
+ $sum_money = Db::name("old_user_lianc")->sum("number");
|
|
|
319
|
+
|
|
|
320
|
+ $lianc_list = Db::name("old_user_lianc")->order("id desc")->field("id,number,title")->select()->toArray();
|
|
|
321
|
+ $user_arr = [];
|
|
|
322
|
+
|
|
|
323
|
+ $lianc_list_arr = [];
|
|
|
324
|
+ foreach ($lianc_list as $key => $value) {
|
|
|
325
|
+ # code...
|
|
|
326
|
+ $lianc_list_arr[$value['id']] = $value;
|
|
|
327
|
+ }
|
|
293
|
328
|
|
|
294
|
|
- //添加复购金
|
|
295
|
|
- public function fugou_user_log($uid,$num,$order_id,$type_inc_des,$status=-1){
|
|
296
|
|
-
|
|
297
|
|
- $fugou_data = Db::name('user')->where("uid",$uid)->find();
|
|
298
|
|
-
|
|
299
|
|
-
|
|
300
|
|
- $bill = [
|
|
301
|
|
- 'uid'=>$uid,
|
|
302
|
|
- 'number'=>$num,//数量
|
|
303
|
|
- 'status'=>$status,//复购金状态1-有效 0-失效 -1待确认
|
|
304
|
|
- 'mark'=>"复购金",//备注
|
|
305
|
|
- 'desc'=>"10%作为复购金",//描述
|
|
306
|
|
- 'order_id'=>$order_id,//订单id
|
|
307
|
|
- 'surplus'=>0,//剩余
|
|
308
|
|
- 'order_type'=>11,//关联订单ID
|
|
309
|
|
- 'type'=>$type_inc_des,//复购金类型 :1赠送,2消耗
|
|
310
|
|
- 'settlement_time'=>date('Y-m-d H:i:s'),//添加时间,
|
|
311
|
|
- 'addtime'=>time(),
|
|
312
|
|
- ];
|
|
313
|
|
-
|
|
314
|
|
- Db::name('user_sign_fugou')->insert($bill);
|
|
|
329
|
+ foreach ($list as $key => $value) {
|
|
|
330
|
+ # code...
|
|
|
331
|
+ $user_arr[$value['originator_id_old']]['people'][] = $value['uid'];
|
|
|
332
|
+ $user_arr[$value['originator_id_old']]['money'] = $lianc_list_arr[$value['originator_id_old']]['number'];
|
|
|
333
|
+ $user_arr[$value['originator_id_old']]['title'] = $lianc_list_arr[$value['originator_id_old']]['title'];
|
|
|
334
|
+ $user_arr[$value['originator_id_old']]['id'] = $lianc_list_arr[$value['originator_id_old']]['id'];
|
|
315
|
335
|
}
|
|
316
|
336
|
|
|
|
337
|
+
|
|
|
338
|
+ //处理计算权重 和平均分配的金额
|
|
|
339
|
+ $total_num = 0;
|
|
|
340
|
+ $count_num = 0;
|
|
|
341
|
+ foreach ($user_arr as $key => $value) {
|
|
|
342
|
+ # code...
|
|
|
343
|
+ $total_num += round($value['money'] * count($value['people']) / 1000, 2);
|
|
|
344
|
+ $count_num += count($value['people']);
|
|
|
345
|
+ }
|
|
|
346
|
+ foreach ($user_arr as $key => $value) {
|
|
|
347
|
+ # code...
|
|
|
348
|
+ $rate = round((count($value['people']) * $value['money']) / $total_num, 2) / 1000;
|
|
|
349
|
+ $user_arr[$key]['rate'] = $rate;
|
|
|
350
|
+ $distribution_money = round($originator_award * $rate, 2);
|
|
|
351
|
+ $user_arr[$key]['distribution_money'] = $distribution_money;
|
|
|
352
|
+ $user_arr[$key]['people_award'] = round($distribution_money / count($value['people']), 2);//可分配佣金
|
|
|
353
|
+ }
|
|
|
354
|
+
|
|
|
355
|
+ $count = 0;
|
|
|
356
|
+ foreach ($user_arr as $key => $value) {
|
|
|
357
|
+ $distribution_money = $value['distribution_money'];
|
|
|
358
|
+ # code...
|
|
|
359
|
+ foreach ($value['people'] as $k => $v) {
|
|
|
360
|
+ # code...
|
|
|
361
|
+ $award = $value['people_award'];
|
|
|
362
|
+
|
|
|
363
|
+ //90给佣金,10给复购金
|
|
|
364
|
+ $yj_90 = $award * 0.9;
|
|
|
365
|
+ $fg_10 = $award * 0.1;
|
|
|
366
|
+
|
|
|
367
|
+ Db::name("user")->where("uid", $v)->inc("brokerage_price", $yj_90)->save();
|
|
|
368
|
+ $res = Db::name("user")->where("uid", $v)->inc("total_amount_old", $yj_90)->save();
|
|
|
369
|
+ Db::name("user")->where("uid", $v)->inc("amount_old", $yj_90)->save();//不用冻结金额和提现额度来限制佣金发放
|
|
|
370
|
+ $res3 = Db::name("user")->where("uid", $v)->inc("fugou", $fg_10)->save();
|
|
|
371
|
+
|
|
|
372
|
+ $res = true;
|
|
|
373
|
+ if ($res) {
|
|
|
374
|
+ $$count = $count + 1;
|
|
|
375
|
+ $this->change_user_log($v, 'amount_old', 1, $yj_90, "relation_profits", "联创分红入账" . "-" . $value['title']);
|
|
|
376
|
+ //入账
|
|
|
377
|
+ $week_data = [];
|
|
|
378
|
+ $week_data['user_id'] = $v;
|
|
|
379
|
+ $week_data['user_lianc_id'] = $value['id'];
|
|
|
380
|
+ $week_data['money'] = $yj_90;
|
|
|
381
|
+ $week_data['remark'] = "联创分红入账主动执行" . $yj_90;
|
|
|
382
|
+ $week_data['all_record'] = $originator_award;
|
|
|
383
|
+ $week_data['all_amount'] = $distribution_money;
|
|
|
384
|
+ $week_data['create_time'] = time();
|
|
|
385
|
+ Db::name("old_user_originator")->insert($week_data);
|
|
|
386
|
+
|
|
|
387
|
+ $userdatassss = db::name("user")->where("uid", $v)->find();
|
|
|
388
|
+ $datas_log = [
|
|
|
389
|
+ 'note' => "名称:" . $userdatassss['nickname'] . " 用户:" . $v . " 新增联创佣金:" . $yj_90,
|
|
|
390
|
+ 'create_time' => date('Y-m-d H:i:s')
|
|
|
391
|
+ ];
|
|
|
392
|
+ Db::name('test_log')->insert($datas_log); //数据存到2.0数据表中
|
|
|
393
|
+ $this->bill_user_log111111($v, "联创分佣", $yj_90, "联创明细入账", 12);//股权分佣明细2.0系统
|
|
|
394
|
+
|
|
|
395
|
+ $this->fugou_user_log($v, $fg_10, 16, 1, 1);//复购金明细入账
|
|
|
396
|
+
|
|
|
397
|
+ } else {
|
|
|
398
|
+ // ..
|
|
|
399
|
+ }
|
|
|
400
|
+ }
|
|
|
401
|
+ }
|
|
|
402
|
+ }
|
|
|
403
|
+
|
|
|
404
|
+ //添加复购金
|
|
|
405
|
+ public function fugou_user_log($uid, $num, $order_id, $type_inc_des, $status = -1)
|
|
|
406
|
+ {
|
|
|
407
|
+
|
|
|
408
|
+ $fugou_data = Db::name('user')->where("uid", $uid)->find();
|
|
|
409
|
+
|
|
|
410
|
+
|
|
|
411
|
+ $bill = [
|
|
|
412
|
+ 'uid' => $uid,
|
|
|
413
|
+ 'number' => $num,//数量
|
|
|
414
|
+ 'status' => $status,//复购金状态1-有效 0-失效 -1待确认
|
|
|
415
|
+ 'mark' => "复购金",//备注
|
|
|
416
|
+ 'desc' => "10%作为复购金",//描述
|
|
|
417
|
+ 'order_id' => $order_id,//订单id
|
|
|
418
|
+ 'surplus' => 0,//剩余
|
|
|
419
|
+ 'order_type' => 11,//关联订单ID
|
|
|
420
|
+ 'type' => $type_inc_des,//复购金类型 :1赠送,2消耗
|
|
|
421
|
+ 'settlement_time' => date('Y-m-d H:i:s'),//添加时间,
|
|
|
422
|
+ 'addtime' => time(),
|
|
|
423
|
+ ];
|
|
|
424
|
+
|
|
|
425
|
+ Db::name('user_sign_fugou')->insert($bill);
|
|
|
426
|
+ }
|
|
|
427
|
+
|
|
317
|
428
|
//添加平台分佣2.0系统收益明细日志(养老金金额)
|
|
318
|
|
- public function bill_user_log111111($uid,$name,$num,$mark,$comm){
|
|
|
429
|
+ public function bill_user_log111111($uid, $name, $num, $mark, $comm)
|
|
|
430
|
+ {
|
|
319
|
431
|
|
|
320
|
|
- $con_data = Db::name('user')->where("uid",$uid)->find();
|
|
|
432
|
+ $con_data = Db::name('user')->where("uid", $uid)->find();
|
|
321
|
433
|
//如果是会员专区就即刻到账
|
|
322
|
434
|
|
|
323
|
435
|
// Db::name('user')->where("uid",$con_data['uid'])->update(['brokerage_price'=> $con_data['brokerage_price'] + $num]);
|
|
324
|
436
|
|
|
325
|
437
|
|
|
326
|
438
|
$bill = [
|
|
327
|
|
- 'uid'=>$uid,
|
|
328
|
|
- 'link_id'=>0,//关联订单id
|
|
329
|
|
- 'pm'=>1,//0:支出,1:获得
|
|
330
|
|
- 'title'=>$name,//账单标题
|
|
331
|
|
- 'category'=>'now_money',//明细种类
|
|
332
|
|
- 'type'=>'commission',//明细类型
|
|
333
|
|
- 'number'=>$num,//明细数字
|
|
334
|
|
- 'balance'=>0,//剩余
|
|
335
|
|
- 'mark'=>$mark,//备注
|
|
336
|
|
- 'create_time'=>date('Y-m-d H:i:s'),//添加时间
|
|
337
|
|
- 'status'=>1,//0待确定,1有效,-1无效
|
|
338
|
|
- 'commission_type'=>$comm,//佣金类型 1代理费 2 消费佣金 3直推奖√ 4辖区佣金\r\n5 养老金√ 6 广告费
|
|
|
439
|
+ 'uid' => $uid,
|
|
|
440
|
+ 'link_id' => 0,//关联订单id
|
|
|
441
|
+ 'pm' => 1,//0:支出,1:获得
|
|
|
442
|
+ 'title' => $name,//账单标题
|
|
|
443
|
+ 'category' => 'now_money',//明细种类
|
|
|
444
|
+ 'type' => 'commission',//明细类型
|
|
|
445
|
+ 'number' => $num,//明细数字
|
|
|
446
|
+ 'balance' => 0,//剩余
|
|
|
447
|
+ 'mark' => $mark,//备注
|
|
|
448
|
+ 'create_time' => date('Y-m-d H:i:s'),//添加时间
|
|
|
449
|
+ 'status' => 1,//0待确定,1有效,-1无效
|
|
|
450
|
+ 'commission_type' => $comm,//佣金类型 1代理费 2 消费佣金 3直推奖√ 4辖区佣金\r\n5 养老金√ 6 广告费
|
|
339
|
451
|
//7 跨店奖励√ 8平台奖励 9渠道商\r\n10 推荐创客收益√ 11分红奖金√ 12代理区域收益√ 13消费循环佣金
|
|
340
|
452
|
//14-推荐代理收益√ 15邀请小区团长升级√ 16大v分享奖√ 17创客合伙人√ 18积分奖励√ 19创客补贴√’
|
|
341
|
|
- 'order_sn'=>0,//订单号
|
|
342
|
|
- 'tripartite'=>0,//
|
|
343
|
|
- 'type_shop'=>0,//0平台1多多进宝2唯品会3苏宁易购4网易考拉5淘宝客6京东联盟7饿了么8线上
|
|
344
|
|
- 'mer_id'=>0,//商户id
|
|
345
|
|
- 'source'=>0,//1线下 0线上
|
|
346
|
|
- 'order_type'=>1,//1自营 2 第三方 订单类型
|
|
347
|
|
- 'is_red_brokerage'=>0,//1红积分对冲佣金 0正常佣金
|
|
348
|
|
- 'gzc'=>3,//养老金是否已进入公证处log表0:未进入。1:已进入
|
|
349
|
|
- 'take_time'=>'',//结算时间
|
|
350
|
|
- 'district_id'=>'',//
|
|
351
|
|
- 'street_id'=>'',//
|
|
352
|
|
- 'month'=>'',//月份
|
|
|
453
|
+ 'order_sn' => 0,//订单号
|
|
|
454
|
+ 'tripartite' => 0,//
|
|
|
455
|
+ 'type_shop' => 0,//0平台1多多进宝2唯品会3苏宁易购4网易考拉5淘宝客6京东联盟7饿了么8线上
|
|
|
456
|
+ 'mer_id' => 0,//商户id
|
|
|
457
|
+ 'source' => 0,//1线下 0线上
|
|
|
458
|
+ 'order_type' => 1,//1自营 2 第三方 订单类型
|
|
|
459
|
+ 'is_red_brokerage' => 0,//1红积分对冲佣金 0正常佣金
|
|
|
460
|
+ 'gzc' => 3,//养老金是否已进入公证处log表0:未进入。1:已进入
|
|
|
461
|
+ 'take_time' => '',//结算时间
|
|
|
462
|
+ 'district_id' => '',//
|
|
|
463
|
+ 'street_id' => '',//
|
|
|
464
|
+ 'month' => '',//月份
|
|
353
|
465
|
|
|
354
|
466
|
|
|
355
|
467
|
];
|
|
|
@@ -392,39 +504,39 @@ class Taskorderlianc extends BaseController
|
|
392
|
504
|
// }
|
|
393
|
505
|
|
|
394
|
506
|
|
|
395
|
|
- public function change_user_log($user_id,$type,$change_status,$money,$routine,$remark="",$is_admin=1,$appoint_money = 0)
|
|
|
507
|
+ public function change_user_log($user_id, $type, $change_status, $money, $routine, $remark = "", $is_admin = 1, $appoint_money = 0)
|
|
396
|
508
|
{
|
|
397
|
509
|
$transition = [
|
|
398
|
|
- 'pv'=>1,
|
|
399
|
|
- "gb"=>2,
|
|
400
|
|
- "df"=>3,
|
|
401
|
|
- "vr"=>4,
|
|
402
|
|
- "bt"=>5,
|
|
403
|
|
- "withdraw_quota"=>6,
|
|
404
|
|
- "unsettled_pension"=>7,
|
|
405
|
|
- "amount_old"=>8
|
|
|
510
|
+ 'pv' => 1,
|
|
|
511
|
+ "gb" => 2,
|
|
|
512
|
+ "df" => 3,
|
|
|
513
|
+ "vr" => 4,
|
|
|
514
|
+ "bt" => 5,
|
|
|
515
|
+ "withdraw_quota" => 6,
|
|
|
516
|
+ "unsettled_pension" => 7,
|
|
|
517
|
+ "amount_old" => 8
|
|
406
|
518
|
];
|
|
407
|
|
- $routineInfo = Db::name("old_routine_log_of_key")->where("key",$routine)->find();
|
|
408
|
|
- if(empty($routineInfo)) {
|
|
|
519
|
+ $routineInfo = Db::name("old_routine_log_of_key")->where("key", $routine)->find();
|
|
|
520
|
+ if (empty($routineInfo)) {
|
|
409
|
521
|
return false;
|
|
410
|
522
|
}
|
|
411
|
523
|
$key_id = isset($routineInfo['id']) ? $routineInfo['id'] : 0;
|
|
412
|
524
|
|
|
413
|
|
- if($appoint_money > 0) {
|
|
|
525
|
+ if ($appoint_money > 0) {
|
|
414
|
526
|
$alter_money = $appoint_money;
|
|
415
|
|
- }else{
|
|
|
527
|
+ } else {
|
|
416
|
528
|
//再去查询变更前的 金额
|
|
417
|
|
- $alter_money = Db::name("user")->where('uid',$user_id)->value($type);
|
|
|
529
|
+ $alter_money = Db::name("user")->where('uid', $user_id)->value($type);
|
|
418
|
530
|
}
|
|
419
|
|
- if($change_status == 1) {
|
|
|
531
|
+ if ($change_status == 1) {
|
|
420
|
532
|
//新增前
|
|
421
|
|
- $alter_money = $alter_money-$money;
|
|
422
|
|
- }else if($change_status == 2){
|
|
|
533
|
+ $alter_money = $alter_money - $money;
|
|
|
534
|
+ } else if ($change_status == 2) {
|
|
423
|
535
|
//减少前
|
|
424
|
536
|
$alter_money = $alter_money + $money;
|
|
425
|
537
|
}
|
|
426
|
|
- if($alter_money < 0) {
|
|
427
|
|
- $alter_money =0;
|
|
|
538
|
+ if ($alter_money < 0) {
|
|
|
539
|
+ $alter_money = 0;
|
|
428
|
540
|
}
|
|
429
|
541
|
$inser_data = [];
|
|
430
|
542
|
$inser_data['user_id'] = $user_id;
|
|
|
@@ -440,60 +552,125 @@ class Taskorderlianc extends BaseController
|
|
440
|
552
|
}
|
|
441
|
553
|
|
|
442
|
554
|
|
|
443
|
|
-
|
|
444
|
555
|
/**
|
|
445
|
556
|
* 释放待发放佣金
|
|
446
|
557
|
*/
|
|
447
|
|
- public function releaseTobeAmount($user_id,$amount,$output)
|
|
|
558
|
+ public function releaseTobeAmount($user_id, $amount, $output)
|
|
448
|
559
|
{
|
|
449
|
560
|
$userInfo = Db::name("user")->find($user_id);
|
|
450
|
|
- if(empty($userInfo)) {
|
|
|
561
|
+ if (empty($userInfo)) {
|
|
451
|
562
|
return false;
|
|
452
|
563
|
}
|
|
453
|
564
|
$withdraw_quota = empty($userInfo['withdraw_quota_old']) ? 0 : $userInfo['withdraw_quota_old'];
|
|
454
|
565
|
$old_amount = empty($userInfo['tobe_amount_old']) ? 0 : $userInfo['tobe_amount_old'];
|
|
455
|
|
- Db::name("user")->where("uid",$user_id)->save(['tobe_amount_old'=>0]);
|
|
|
566
|
+ Db::name("user")->where("uid", $user_id)->save(['tobe_amount_old' => 0]);
|
|
456
|
567
|
$amount += $old_amount;
|
|
457
|
568
|
$inc_amount = 0;
|
|
458
|
569
|
$inc_tobe_amount = 0;
|
|
459
|
570
|
$dec_withdraw_quota = 0;
|
|
460
|
571
|
|
|
461
|
|
- if(($amount - $withdraw_quota) > 0) {
|
|
|
572
|
+ if (($amount - $withdraw_quota) > 0) {
|
|
462
|
573
|
$diff_money = $amount - $withdraw_quota;
|
|
463
|
574
|
$inc_amount = $withdraw_quota;
|
|
464
|
575
|
$dec_withdraw_quota = $withdraw_quota;
|
|
465
|
576
|
$inc_tobe_amount = $diff_money;
|
|
466
|
|
- }elseif(($amount - $withdraw_quota)==0){
|
|
|
577
|
+ } elseif (($amount - $withdraw_quota) == 0) {
|
|
467
|
578
|
$inc_amount = $withdraw_quota;
|
|
468
|
579
|
$dec_withdraw_quota = $withdraw_quota;
|
|
469
|
|
- }else {
|
|
|
580
|
+ } else {
|
|
470
|
581
|
// <0的情况
|
|
471
|
582
|
$diff_money = $withdraw_quota - $amount;
|
|
472
|
583
|
$inc_amount = $amount;
|
|
473
|
584
|
$dec_withdraw_quota = $amount;
|
|
474
|
585
|
}
|
|
475
|
|
- if($inc_tobe_amount != 0 ) {
|
|
|
586
|
+ if ($inc_tobe_amount != 0) {
|
|
476
|
587
|
|
|
477
|
|
- $res = Db::name("user")->where("uid",$user_id)->inc("tobe_amount_old",$inc_tobe_amount)->fetchSql()->inc("amount",$inc_amount)->dec("withdraw_quota_old",$dec_withdraw_quota)->save();
|
|
|
588
|
+ $res = Db::name("user")->where("uid", $user_id)->inc("tobe_amount_old", $inc_tobe_amount)->fetchSql()->inc("amount", $inc_amount)->dec("withdraw_quota_old", $dec_withdraw_quota)->save();
|
|
478
|
589
|
|
|
479
|
590
|
|
|
480
|
|
-
|
|
481
|
|
- }else {
|
|
482
|
|
- $res = Db::name("user")->where("uid",$user_id)->inc("amount_old",$inc_amount)->fetchSql()->dec("withdraw_quota_old",$dec_withdraw_quota)->save();
|
|
|
591
|
+ } else {
|
|
|
592
|
+ $res = Db::name("user")->where("uid", $user_id)->inc("amount_old", $inc_amount)->fetchSql()->dec("withdraw_quota_old", $dec_withdraw_quota)->save();
|
|
483
|
593
|
|
|
484
|
594
|
}
|
|
485
|
595
|
//记录日志 提现额度消费
|
|
486
|
|
- if($dec_withdraw_quota > 0) {
|
|
487
|
|
- $this->change_user_log($user_id,'withdraw_quota',2,$dec_withdraw_quota,"conversion_tobe_amount","佣金额度兑换佣金");
|
|
|
596
|
+ if ($dec_withdraw_quota > 0) {
|
|
|
597
|
+ $this->change_user_log($user_id, 'withdraw_quota', 2, $dec_withdraw_quota, "conversion_tobe_amount", "佣金额度兑换佣金");
|
|
488
|
598
|
}
|
|
489
|
599
|
}
|
|
490
|
600
|
|
|
|
601
|
+ public function getTime($timePeriod)
|
|
|
602
|
+ {
|
|
|
603
|
+ // 定义时间区间
|
|
|
604
|
+ $now = time();
|
|
|
605
|
+ $startTime = '';
|
|
|
606
|
+ $endTime = '';
|
|
|
607
|
+ if ($timePeriod == 'last_week') {
|
|
|
608
|
+ // 上周的时间区间
|
|
|
609
|
+ $startTime = date('Y-m-d', strtotime('monday last week', $now)); // 上周星期一的开始时间
|
|
|
610
|
+ $endTime = date('Y-m-d', strtotime('sunday last week', $now)); // 上周星期日的结束时间
|
|
|
611
|
+ } elseif ($timePeriod == 'this_week') {
|
|
|
612
|
+ // 这周的时间区间
|
|
|
613
|
+ $startTime = date('Y-m-d', strtotime('monday this week', $now)); // 这周星期一的开始时间
|
|
|
614
|
+ $endTime = date('Y-m-d', strtotime('sunday this week', $now)); // 这周星期日的结束时间
|
|
|
615
|
+ }
|
|
|
616
|
+ // return ['startTime' => '2025-03-10', 'endTime' => '2025-03-23'];
|
|
|
617
|
+ return ['startTime' => $startTime, 'endTime' => $endTime];
|
|
|
618
|
+ }
|
|
491
|
619
|
|
|
|
620
|
+ public function getTeamPvByTime($timePeriod = 'last_week', $removeUserIdList = [])
|
|
|
621
|
+ {
|
|
|
622
|
+ $timeMap = $this->getTime($timePeriod);
|
|
|
623
|
+ $startTime = $timeMap['startTime'];
|
|
|
624
|
+ $endTime = $timeMap['endTime'];
|
|
|
625
|
+
|
|
|
626
|
+ // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
|
|
|
627
|
+ $orders = Db::name("store_order")
|
|
|
628
|
+ ->where('mer_id', 496)
|
|
|
629
|
+ ->whereNotIn('uid', $removeUserIdList)
|
|
|
630
|
+ ->whereIn('status', [0, 1, 2, 3])
|
|
|
631
|
+ ->whereIn("total_price", [1180, 11800, 10620, 2360, 9440])
|
|
|
632
|
+ ->whereBetween("pay_time", [$startTime . ' 00:00:00', $endTime . ' 23:59:59'])
|
|
|
633
|
+ ->whereNotNull("pay_time") // 排除 pay_time 为 NULL 的订单
|
|
|
634
|
+ ->select();
|
|
|
635
|
+
|
|
|
636
|
+ // 计算总业绩
|
|
|
637
|
+ $totalPv = 0;
|
|
|
638
|
+ foreach ($orders as $order) {
|
|
|
639
|
+ switch ($order['total_price']) {
|
|
|
640
|
+ case 1180:
|
|
|
641
|
+ $totalPv += 700;
|
|
|
642
|
+ break;
|
|
|
643
|
+ case 11800:
|
|
|
644
|
+ $totalPv += 7000;
|
|
|
645
|
+ break;
|
|
|
646
|
+ case 10620:
|
|
|
647
|
+ $totalPv += 6300;
|
|
|
648
|
+ break;
|
|
|
649
|
+ case 2360:
|
|
|
650
|
+ $totalPv += 1400;
|
|
|
651
|
+ break;
|
|
|
652
|
+ case 9440:
|
|
|
653
|
+ $totalPv += 5600;
|
|
|
654
|
+ break;
|
|
|
655
|
+ }
|
|
|
656
|
+ }
|
|
492
|
657
|
|
|
|
658
|
+ return $totalPv;
|
|
|
659
|
+ }
|
|
493
|
660
|
|
|
494
|
|
-
|
|
495
|
|
-
|
|
496
|
|
-
|
|
497
|
|
-
|
|
498
|
|
-
|
|
|
661
|
+ public function getRedEnvelopeByTime($timePeriod = 'last_week', $removeUserIdList = [])
|
|
|
662
|
+ {
|
|
|
663
|
+ $timeMap = $this->getTime($timePeriod);
|
|
|
664
|
+ $startTime = $timeMap['startTime'];
|
|
|
665
|
+ $endTime = $timeMap['endTime'];
|
|
|
666
|
+
|
|
|
667
|
+ // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
|
|
|
668
|
+ $redEnvelopeList = Db::name("user_sign_hongbao")
|
|
|
669
|
+ ->whereNotIn('uid', $removeUserIdList)
|
|
|
670
|
+ ->where('status', 1)
|
|
|
671
|
+ ->whereBetween("settlement_time", [$startTime . ' 00:00:00', $endTime . ' 23:59:59'])
|
|
|
672
|
+ ->select()
|
|
|
673
|
+ ->toArray();
|
|
|
674
|
+ return floor(array_sum(array_column($redEnvelopeList, 'number')) * 100) / 100;
|
|
|
675
|
+ }
|
|
499
|
676
|
}
|