|
|
@@ -8,15 +8,114 @@ use think\facade\Db;
|
|
8
|
8
|
|
|
9
|
9
|
class TaskPartnerProfits
|
|
10
|
10
|
{
|
|
|
11
|
+ public function getTime($timePeriod)
|
|
|
12
|
+ {
|
|
|
13
|
+ // 定义时间区间
|
|
|
14
|
+ $now = time();
|
|
|
15
|
+ $startTime = '';
|
|
|
16
|
+ $endTime = '';
|
|
|
17
|
+ if ($timePeriod == 'last_week') {
|
|
|
18
|
+ // 上周的时间区间
|
|
|
19
|
+ $startTime = date('Y-m-d', strtotime('monday last week', $now)); // 上周星期一的开始时间
|
|
|
20
|
+ $endTime = date('Y-m-d', strtotime('sunday last week', $now)); // 上周星期日的结束时间
|
|
|
21
|
+ } elseif ($timePeriod == 'this_week') {
|
|
|
22
|
+ // 这周的时间区间
|
|
|
23
|
+ $startTime = date('Y-m-d', strtotime('monday this week', $now)); // 这周星期一的开始时间
|
|
|
24
|
+ $endTime = date('Y-m-d', strtotime('sunday this week', $now)); // 这周星期日的结束时间
|
|
|
25
|
+ }
|
|
|
26
|
+// return ['startTime' => '2025-03-10', 'endTime' => '2025-03-23'];
|
|
|
27
|
+ return ['startTime' => $startTime, 'endTime' => $endTime];
|
|
|
28
|
+ }
|
|
|
29
|
+
|
|
|
30
|
+ public function getTeamPvByTime($timePeriod = 'last_week', $removeUserIdList = [])
|
|
|
31
|
+ {
|
|
|
32
|
+ $timeMap = $this->getTime($timePeriod);
|
|
|
33
|
+ $startTime = $timeMap['startTime'];
|
|
|
34
|
+ $endTime = $timeMap['endTime'];
|
|
|
35
|
+
|
|
|
36
|
+ // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
|
|
|
37
|
+ $orders = Db::name("store_order")
|
|
|
38
|
+ ->where('mer_id', 496)
|
|
|
39
|
+ ->whereNotIn('uid', $removeUserIdList)
|
|
|
40
|
+ ->whereIn('status', [0, 1, 2, 3])
|
|
|
41
|
+ ->whereIn("total_price", [1180, 11800, 10620, 2360, 9440])
|
|
|
42
|
+ ->whereBetween("pay_time", [$startTime . ' 00:00:00', $endTime . ' 23:59:59'])
|
|
|
43
|
+ ->whereNotNull("pay_time") // 排除 pay_time 为 NULL 的订单
|
|
|
44
|
+ ->select();
|
|
|
45
|
+
|
|
|
46
|
+ // 计算总业绩
|
|
|
47
|
+ $totalPv = 0;
|
|
|
48
|
+ foreach ($orders as $order) {
|
|
|
49
|
+ switch ($order['total_price']) {
|
|
|
50
|
+ case 1180:
|
|
|
51
|
+ $totalPv += 700;
|
|
|
52
|
+ break;
|
|
|
53
|
+ case 11800:
|
|
|
54
|
+ $totalPv += 7000;
|
|
|
55
|
+ break;
|
|
|
56
|
+ case 10620:
|
|
|
57
|
+ $totalPv += 6300;
|
|
|
58
|
+ break;
|
|
|
59
|
+ case 2360:
|
|
|
60
|
+ $totalPv += 1400;
|
|
|
61
|
+ break;
|
|
|
62
|
+ case 9440:
|
|
|
63
|
+ $totalPv += 5600;
|
|
|
64
|
+ break;
|
|
|
65
|
+ }
|
|
|
66
|
+ }
|
|
|
67
|
+
|
|
|
68
|
+ return $totalPv;
|
|
|
69
|
+ }
|
|
|
70
|
+
|
|
|
71
|
+ public function getRedEnvelopeByTime($timePeriod = 'last_week', $removeUserIdList = [])
|
|
|
72
|
+ {
|
|
|
73
|
+ $timeMap = $this->getTime($timePeriod);
|
|
|
74
|
+ $startTime = $timeMap['startTime'];
|
|
|
75
|
+ $endTime = $timeMap['endTime'];
|
|
|
76
|
+
|
|
|
77
|
+ // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
|
|
|
78
|
+ $redEnvelopeList = Db::name("user_sign_hongbao")
|
|
|
79
|
+ ->whereNotIn('uid', $removeUserIdList)
|
|
|
80
|
+ ->where('status', 1)
|
|
|
81
|
+ ->whereBetween("settlement_time", [$startTime . ' 00:00:00', $endTime . ' 23:59:59'])
|
|
|
82
|
+ ->select()
|
|
|
83
|
+ ->toArray();
|
|
|
84
|
+ return floor(array_sum(array_column($redEnvelopeList, 'number')) * 100) / 100;
|
|
|
85
|
+ }
|
|
|
86
|
+
|
|
11
|
87
|
public function partnerProfits()
|
|
12
|
88
|
{
|
|
|
89
|
+ // 查询测试人员账号信息
|
|
|
90
|
+ //18973958920
|
|
|
91
|
+ //15186694339
|
|
|
92
|
+ //18833633835
|
|
|
93
|
+ //19525470098
|
|
|
94
|
+ //17756507016
|
|
|
95
|
+ //18226705337
|
|
|
96
|
+ $testAccount = ['18973958920', '15186694339', '18833633835', '19525470098', '17756507016', '18226705337'];
|
|
|
97
|
+ $removeUserList = Db::name("user")
|
|
|
98
|
+ ->whereIn('account', $testAccount)
|
|
|
99
|
+ ->where("status", "<>", 0)
|
|
|
100
|
+ ->where('is_del', '<>', 1)
|
|
|
101
|
+ ->select()
|
|
|
102
|
+ ->toArray();
|
|
|
103
|
+ $removeUserIdList = array_column($removeUserList, 'uid');
|
|
13
|
104
|
// 定义分红金额
|
|
14
|
|
- $weekRecord = 10500 + 50000;
|
|
|
105
|
+ $weekRecord = $this->getTeamPvByTime('last_week', $removeUserIdList);
|
|
|
106
|
+ // 分红金额 - 红包金额
|
|
|
107
|
+ $redEnvelope = $this->getRedEnvelopeByTime('last_week', $removeUserIdList);
|
|
|
108
|
+
|
|
|
109
|
+ $weekRecord -= $redEnvelope;
|
|
|
110
|
+ if ($weekRecord <= 0) {
|
|
|
111
|
+ return json('无效分红金额');
|
|
|
112
|
+ }
|
|
|
113
|
+
|
|
15
|
114
|
|
|
16
|
115
|
// 1、获取用户星级信息
|
|
17
|
116
|
//$star_list = Db::name("user_star")->order("statement_all_num desc")->select()->toArray();//旧星级等级
|
|
18
|
117
|
$starList = Db::name("old_user_starlevel")
|
|
19
|
|
- ->whereIn('title', ['初级', '中级'])
|
|
|
118
|
+ ->whereIn('title', ['初级', '中级', '高级'])
|
|
20
|
119
|
->order("statement_all_num desc")
|
|
21
|
120
|
->select()
|
|
22
|
121
|
->toArray();//星级等级
|
|
|
@@ -26,8 +125,10 @@ class TaskPartnerProfits
|
|
26
|
125
|
|
|
27
|
126
|
// 3、获取 分红用户 信息 (`user_group` tinyint(1) DEFAULT '1' COMMENT '1消费者 2,推广业务员 3,业务经理 4初级合伙人5中级合伙人 6高级合伙人 7.懂事',)
|
|
28
|
127
|
$list = Db::name("user")
|
|
29
|
|
- ->where("user_group", "IN", [4, 5])
|
|
|
128
|
+// ->whereNotIn('uid', $removeUserIdList)
|
|
|
129
|
+ ->where("user_group", "IN", [4, 5, 6])
|
|
30
|
130
|
->where("status", "<>", 0)
|
|
|
131
|
+ ->where('is_del', '<>', 1)
|
|
31
|
132
|
->select()
|
|
32
|
133
|
->toArray();
|
|
33
|
134
|
|
|
|
@@ -37,35 +138,36 @@ class TaskPartnerProfits
|
|
37
|
138
|
$salesArr['初级']['divider_people'][] = $value['uid'];
|
|
38
|
139
|
} else if ($value['user_group'] == 5) {
|
|
39
|
140
|
$salesArr['中级']['divider_people'][] = $value['uid'];
|
|
|
141
|
+ } else if ($value['user_group'] == 6) {
|
|
|
142
|
+ $salesArr['高级']['divider_people'][] = $value['uid'];
|
|
40
|
143
|
}
|
|
41
|
144
|
}
|
|
42
|
145
|
|
|
43
|
|
-
|
|
44
|
146
|
// 5、移除特定人员
|
|
45
|
147
|
// 要移动的ID数组
|
|
46
|
|
- $ids_to_remove_from_junior = array(12, 69, 144); // 从初级中移除的ID
|
|
47
|
|
- $ids_to_remove_from_intermediate = array(49); // 从中级中移除的ID
|
|
48
|
|
- // 查找初级并获取其divider_people
|
|
49
|
|
- $junior = &$salesArr['初级']['divider_people']; // 使用引用,以便直接修改数组
|
|
50
|
|
- // 查找中级并获取其divider_people
|
|
51
|
|
- $intermediate = &$salesArr['中级']['divider_people']; // 使用引用,以便直接修改数组
|
|
52
|
|
- // 从初级的divider_people中移除特定的ID
|
|
53
|
|
- foreach ($ids_to_remove_from_junior as $id) {
|
|
54
|
|
- $key = array_search($id, $junior);
|
|
55
|
|
- if ($key !== false) {
|
|
56
|
|
- unset($junior[$key]); // 移除初级中的特定ID
|
|
57
|
|
- }
|
|
58
|
|
- }
|
|
59
|
|
- // 从中级的divider_people中移除特定的ID
|
|
60
|
|
- foreach ($ids_to_remove_from_intermediate as $id) {
|
|
61
|
|
- $key = array_search($id, $intermediate);
|
|
62
|
|
- if ($key !== false) {
|
|
63
|
|
- unset($intermediate[$key]); // 移除中级中的特定ID
|
|
64
|
|
- }
|
|
65
|
|
- }
|
|
66
|
|
- // 重置数组的索引,因为unset会留下空位
|
|
67
|
|
- $salesArr['初级']['divider_people'] = array_values($junior);
|
|
68
|
|
- $salesArr['中级']['divider_people'] = array_values($intermediate);
|
|
|
148
|
+// $ids_to_remove_from_junior = array(12, 69, 144); // 从初级中移除的ID
|
|
|
149
|
+// $ids_to_remove_from_intermediate = array(49); // 从中级中移除的ID
|
|
|
150
|
+// // 查找初级并获取其divider_people
|
|
|
151
|
+// $junior = &$salesArr['初级']['divider_people']; // 使用引用,以便直接修改数组
|
|
|
152
|
+// // 查找中级并获取其divider_people
|
|
|
153
|
+// $intermediate = &$salesArr['中级']['divider_people']; // 使用引用,以便直接修改数组
|
|
|
154
|
+// // 从初级的divider_people中移除特定的ID
|
|
|
155
|
+// foreach ($ids_to_remove_from_junior as $id) {
|
|
|
156
|
+// $key = array_search($id, $junior);
|
|
|
157
|
+// if ($key !== false) {
|
|
|
158
|
+// unset($junior[$key]); // 移除初级中的特定ID
|
|
|
159
|
+// }
|
|
|
160
|
+// }
|
|
|
161
|
+// // 从中级的divider_people中移除特定的ID
|
|
|
162
|
+// foreach ($ids_to_remove_from_intermediate as $id) {
|
|
|
163
|
+// $key = array_search($id, $intermediate);
|
|
|
164
|
+// if ($key !== false) {
|
|
|
165
|
+// unset($intermediate[$key]); // 移除中级中的特定ID
|
|
|
166
|
+// }
|
|
|
167
|
+// }
|
|
|
168
|
+// // 重置数组的索引,因为unset会留下空位
|
|
|
169
|
+// $salesArr['初级']['divider_people'] = array_values($junior);
|
|
|
170
|
+// $salesArr['中级']['divider_people'] = array_values($intermediate);
|
|
69
|
171
|
|
|
70
|
172
|
|
|
71
|
173
|
// 6、执行分开发放
|
|
|
@@ -74,14 +176,16 @@ class TaskPartnerProfits
|
|
74
|
176
|
// 6.1 计算可分红金额
|
|
75
|
177
|
//比如这个周的总业绩是 8400
|
|
76
|
178
|
//周总业绩(8400) * 合伙人级别的分佣比例(15%) = 可分红的佣金(1260)
|
|
77
|
|
- $salesArr[$key]['fs_money_nums'] = round($weekRecord * $value['profit_rate'], 2);
|
|
|
179
|
+// $salesArr[$key]['fs_money_nums'] = round($weekRecord * $value['profit_rate'], 2);
|
|
|
180
|
+ $salesArr[$key]['fs_money_nums'] = floor(($weekRecord * ($value['profit_rate'] / 100)) * 100) / 100;
|
|
78
|
181
|
//可分红的业绩(分为两半,各50%,一部分是分给双联盟比例,一部分是小业绩比例)
|
|
79
|
182
|
//把本周的业绩(8400) * 合伙人级别的分佣比例(15%) * 0.5 = 630(可分红佣金的 50%)
|
|
80
|
|
- $salesArr[$key]['fs_money'] = round($salesArr[$key]['fs_money_nums'] / 2, 2);
|
|
|
183
|
+// $salesArr[$key]['fs_money'] = round($salesArr[$key]['fs_money_nums'] / 2, 2);
|
|
|
184
|
+ $salesArr[$key]['fs_money'] = floor(($salesArr[$key]['fs_money_nums'] / 2) * 100) / 100;
|
|
81
|
185
|
|
|
82
|
186
|
// 6.2 计算所有人的 PV值
|
|
83
|
187
|
$salesArr[$key]['maxValueAll'] = 0;
|
|
84
|
|
- $salesArr[$key]['sumOfOthers'] = 0;
|
|
|
188
|
+ $salesArr[$key]['sumOfOthersAll'] = 0;
|
|
85
|
189
|
$salesArr[$key]['dividerPeoplePv'] = [];
|
|
86
|
190
|
foreach ($value['divider_people'] as $k => $v) {
|
|
87
|
191
|
// 6.2.1 查出分红人的所有部门 即 下级用户
|
|
|
@@ -94,8 +198,8 @@ class TaskPartnerProfits
|
|
94
|
198
|
$subordinatesBatch = $this->getSubordinatesBatch($spreadUserUidList[$v]);
|
|
95
|
199
|
// 6.2.3 获取所有部门(下线)的PV值
|
|
96
|
200
|
foreach ($subordinatesBatch as $k1 => $v1) {
|
|
97
|
|
- // 获取当前下线的PV值
|
|
98
|
|
- $pv = $this->getPv(array_merge($v1, [$k1]));
|
|
|
201
|
+ // 获取当前下线的PV值, 忽略测试人员的账号
|
|
|
202
|
+ $pv = $this->getPv(array_merge($v1, [$k1]), $removeUserIdList);
|
|
99
|
203
|
if (!empty($pv)) {
|
|
100
|
204
|
$partnerProfitsPvListByUid[$v][$k1] = $pv;
|
|
101
|
205
|
}
|
|
|
@@ -113,18 +217,18 @@ class TaskPartnerProfits
|
|
113
|
217
|
$salesArr[$key]['dividerPeoplePv'][$v]['maxValue'] = $maxValue;
|
|
114
|
218
|
$salesArr[$key]['dividerPeoplePv'][$v]['sumOfOthers'] = $sumOfOthers;
|
|
115
|
219
|
$salesArr[$key]['maxValueAll'] += $maxValue;
|
|
116
|
|
- $salesArr[$key]['sumOfOthers'] += $sumOfOthers;
|
|
|
220
|
+ $salesArr[$key]['sumOfOthersAll'] += $sumOfOthers;
|
|
117
|
221
|
}
|
|
118
|
222
|
}
|
|
119
|
223
|
}
|
|
120
|
|
- // return app('json')->success([]);
|
|
121
|
224
|
|
|
122
|
225
|
// 7、执行分红
|
|
|
226
|
+ $testRecord = [];
|
|
123
|
227
|
foreach ($salesArr as $key => $value) {
|
|
124
|
228
|
$amount = $value['fs_money'];//可分红的总佣金,分红佣金的一半,中级合伙61.95
|
|
125
|
229
|
$fsMoneyNums = $value['fs_money_nums'];//中级合伙人级别,可分红的总佣金
|
|
126
|
230
|
$maxValueAll = $value['maxValueAll'];//当前级别合伙人下面所有的双联盟业绩
|
|
127
|
|
- $sumOfOthers = $value['sumOfOthers'];//当前级别合伙人下面所有的小区(业绩小的部分)总业绩
|
|
|
231
|
+ $sumOfOthersAll = $value['sumOfOthersAll'];//当前级别合伙人下面所有的小区(业绩小的部分)总业绩
|
|
128
|
232
|
|
|
129
|
233
|
if (count($value['divider_people']) <= 0) {
|
|
130
|
234
|
continue;
|
|
|
@@ -132,17 +236,25 @@ class TaskPartnerProfits
|
|
132
|
236
|
//每人分红金额
|
|
133
|
237
|
foreach ($value['divider_people'] as $v) {
|
|
134
|
238
|
|
|
|
239
|
+ //个人小区(佣金少的一部分) 权重 计算权重
|
|
|
240
|
+ //返回是数组,下标0是最小的值(业绩小的),下标1是最大的值(业绩大的)
|
|
|
241
|
+ $userPvSmallNum = $value['dividerPeoplePv'][$v]['sumOfOthers'] ?? 0;
|
|
|
242
|
+// $myMixMoney = round($amount * ($userPvSmallNum / $sumOfOthersAll), 2);
|
|
|
243
|
+ $myMixMoney = floor(($amount * (floor(($userPvSmallNum / $sumOfOthersAll) * 100) / 100)) * 100) / 100;
|
|
|
244
|
+
|
|
135
|
245
|
//个人双区总佣金 权重 计算
|
|
136
|
|
- $myBill = $value['dividerPeoplePv'][$v]['maxValue'];//比如uerid是12,他的双区总业绩就是287742
|
|
|
246
|
+ $myBill = $value['dividerPeoplePv'][$v]['maxValue'] ?? 0;
|
|
137
|
247
|
//中级合伙人。userid=17可以分到双区可分红的金额
|
|
138
|
248
|
//可分红的佣金 * (中级合伙人个人的双区总业绩 / 当前等级所有合伙人的双联盟业绩) = 当前用户可以获取到的分红佣金(双区联盟总业绩加权佣金),287742 * (61.95/431032)=41.36
|
|
139
|
|
- $myWeightMoney = round($amount * ($myBill / $maxValueAll), 2);
|
|
|
249
|
+// $myWeightMoney = round($amount * ($myBill / $maxValueAll), 2);
|
|
|
250
|
+ $myWeightMoney = floor(($amount * (floor((($myBill + $userPvSmallNum) / ($maxValueAll + $sumOfOthersAll)) * 100) / 100)) * 100) / 100;
|
|
140
|
251
|
|
|
141
|
|
- //个人小区(佣金少的一部分) 权重 计算权重
|
|
142
|
|
- //返回是数组,下标0是最小的值(业绩小的),下标1是最大的值(业绩大的)
|
|
143
|
|
- $userPvSmallNum = $value['dividerPeoplePv'][$v]['sumOfOthers'];
|
|
144
|
|
- $myMixMoney = round($amount * ($userPvSmallNum / $sumOfOthers), 2);
|
|
145
|
252
|
|
|
|
253
|
+ $salesArr[$key]['dividerPeoplePv'][$v]['myWeightMoney'] = $myWeightMoney;
|
|
|
254
|
+ $salesArr[$key]['dividerPeoplePv'][$v]['myMixMoney'] = $myMixMoney;
|
|
|
255
|
+ $salesArr[$key]['dividerPeoplePv'][$v]['maxValueAll'] = $maxValueAll;
|
|
|
256
|
+ $salesArr[$key]['dividerPeoplePv'][$v]['sumOfOthersAll'] = $sumOfOthersAll;
|
|
|
257
|
+ $salesArr[$key]['dividerPeoplePv'][$v]['weekRecord'] = $weekRecord;
|
|
146
|
258
|
|
|
147
|
259
|
# code...
|
|
148
|
260
|
$allAward = $myWeightMoney + $myMixMoney;
|
|
|
@@ -154,7 +266,7 @@ class TaskPartnerProfits
|
|
154
|
266
|
|
|
155
|
267
|
$userdatassss = db::name("old_user_jbp")->where("id", $v)->find();
|
|
156
|
268
|
$datas_log = [
|
|
157
|
|
- 'note' => "名称:" . $userdatassss['nick_name'] . " 用户:" . $v . " 双联盟总业绩:" . $maxValueAll . " 我的双区业绩:" . $myBill . " 小区总业绩:" . $sumOfOthers . " 我的业绩小的:" . $userPvSmallNum[0] . " 可分红佣金:" . $amount . " 可分红总佣金:" . $fsMoneyNums . " 小区业绩可分红:" . $myMixMoney . " 大区业绩可分红:" . $myWeightMoney . " 实际分得:" . $yj_90,
|
|
|
269
|
+ 'note' => "名称:" . $userdatassss['nick_name'] . " 用户:" . $v . " 双联盟总业绩:" . $maxValueAll . " 我的双区业绩:" . $myBill . " 小区总业绩:" . $sumOfOthersAll . " 我的业绩小的:" . $userPvSmallNum[0] . " 可分红佣金:" . $amount . " 可分红总佣金:" . $fsMoneyNums . " 小区业绩可分红:" . $myMixMoney . " 大区业绩可分红:" . $myWeightMoney . " 实际分得:" . $yj_90,
|
|
158
|
270
|
'create_time' => date('Y-m-d H:i:s')
|
|
159
|
271
|
];
|
|
160
|
272
|
$con_data = Db::name('test_log')->insert($datas_log); //数据存到2.0数据表中
|
|
|
@@ -189,7 +301,9 @@ class TaskPartnerProfits
|
|
189
|
301
|
$this->bill_user_log111111($v, "合伙人分佣", $yj_90, "合伙人分佣明细入账", 11);//联创分佣明细2.0系统
|
|
190
|
302
|
$this->fugou_user_log($v, $fg_10, 16, 1, 1);//复购金明细入账
|
|
191
|
303
|
}
|
|
|
304
|
+
|
|
192
|
305
|
}
|
|
|
306
|
+ return json($salesArr);
|
|
193
|
307
|
}
|
|
194
|
308
|
|
|
195
|
309
|
/**
|
|
|
@@ -227,6 +341,29 @@ class TaskPartnerProfits
|
|
227
|
341
|
}
|
|
228
|
342
|
|
|
229
|
343
|
/**
|
|
|
344
|
+ * 获取该会员的所有下级会员
|
|
|
345
|
+ */
|
|
|
346
|
+ public function getSpreadUserUidAccountListByUidList($uid, $account = '')
|
|
|
347
|
+ {
|
|
|
348
|
+ $son_ids = Db::name("user")
|
|
|
349
|
+ ->where("spread_uid", $uid)
|
|
|
350
|
+ ->field("uid,spread_uid,account")
|
|
|
351
|
+ ->select()
|
|
|
352
|
+ ->toArray();
|
|
|
353
|
+ $new_array_ids = [];
|
|
|
354
|
+ foreach ($son_ids as $key => $value) {
|
|
|
355
|
+ $childList = $this->getSpreadUserUidAccountListByUidList($value['uid'], $value['account']);
|
|
|
356
|
+ $new_array_ids[] = [
|
|
|
357
|
+ '当前用户ID' => $value['uid'],
|
|
|
358
|
+ '当前用户的上级用户ID' => $value['spread_uid'],
|
|
|
359
|
+ '用户账号(手机号)' => $value['account'],
|
|
|
360
|
+ '当前用户的下级用户列表' => $childList
|
|
|
361
|
+ ];
|
|
|
362
|
+ }
|
|
|
363
|
+ return $new_array_ids;
|
|
|
364
|
+ }
|
|
|
365
|
+
|
|
|
366
|
+ /**
|
|
230
|
367
|
* 递归查询单个用户的下级用户
|
|
231
|
368
|
*
|
|
232
|
369
|
* @param int $uid 用户ID
|
|
|
@@ -375,11 +512,15 @@ class TaskPartnerProfits
|
|
375
|
512
|
}
|
|
376
|
513
|
|
|
377
|
514
|
// 获取用户PV值
|
|
378
|
|
- public function getPv($userIdList)
|
|
|
515
|
+ public function getPv($userIdList, $removeUserIdList = [])
|
|
379
|
516
|
{
|
|
|
517
|
+ if (!empty($removeUserIdList)) {
|
|
|
518
|
+ $userIdList = array_values(array_diff($userIdList, $removeUserIdList));
|
|
|
519
|
+ }
|
|
380
|
520
|
// 基础查询构建器
|
|
381
|
521
|
$user_team_amount = Db::name("old_user_of_goods")
|
|
382
|
522
|
->whereIn("user_id", $userIdList)
|
|
|
523
|
+ ->where('status', 1)
|
|
383
|
524
|
->where('money', 1180)
|
|
384
|
525
|
->select();
|
|
385
|
526
|
//$money1180Records = $this->old_user_of_goods->where('status', 1)->where('money', 1180)->select();
|
|
|
@@ -392,6 +533,7 @@ class TaskPartnerProfits
|
|
392
|
533
|
// 获取 status 为 1 且 money 为 11800 的记录集合
|
|
393
|
534
|
$money11800Records = Db::name("old_user_of_goods")
|
|
394
|
535
|
->whereIn("user_id", $userIdList)
|
|
|
536
|
+ ->where('status', 1)
|
|
395
|
537
|
->where('money', 11800)
|
|
396
|
538
|
->select();
|
|
397
|
539
|
// 计算 status 为 1 且 money 为 11800 的记录总和(减去相应值后)
|
|
|
@@ -402,6 +544,7 @@ class TaskPartnerProfits
|
|
402
|
544
|
|
|
403
|
545
|
$money10620Records = Db::name("old_user_of_goods")
|
|
404
|
546
|
->whereIn("user_id", $userIdList)
|
|
|
547
|
+ ->where('status', 1)
|
|
405
|
548
|
->where('money', 10620)
|
|
406
|
549
|
->select();
|
|
407
|
550
|
// 计算 status 为 1 且 money 为 10620 的记录总和(减去相应值后)
|
|
|
@@ -413,6 +556,7 @@ class TaskPartnerProfits
|
|
413
|
556
|
|
|
414
|
557
|
$money9440Records = Db::name("old_user_of_goods")
|
|
415
|
558
|
->whereIn("user_id", $userIdList)
|
|
|
559
|
+ ->where('status', 1)
|
|
416
|
560
|
->where('money', 9440)
|
|
417
|
561
|
->select();
|
|
418
|
562
|
// 计算 status 为 1 且 money 为 9440 的记录总和(减去相应值后)
|
|
|
@@ -423,6 +567,7 @@ class TaskPartnerProfits
|
|
423
|
567
|
|
|
424
|
568
|
$money2360Records = Db::name("old_user_of_goods")
|
|
425
|
569
|
->whereIn("user_id", $userIdList)
|
|
|
570
|
+ ->where('status', 1)
|
|
426
|
571
|
->where('money', 2360)
|
|
427
|
572
|
->select();
|
|
428
|
573
|
// 计算 status 为 1 且 money 为 2360 的记录总和(减去相应值后)
|
|
|
@@ -432,16 +577,16 @@ class TaskPartnerProfits
|
|
432
|
577
|
}
|
|
433
|
578
|
|
|
434
|
579
|
// 计算除去特定值后的总和
|
|
435
|
|
- //$otherMoneyRecords = $this->old_user_of_goods->where('status', 1)->whereNotIn('money', [1180, 11800])->select();
|
|
436
|
|
- $otherMoneyRecords = Db::name("old_user_of_goods")
|
|
437
|
|
- ->whereIn("user_id", $userIdList)
|
|
438
|
|
- ->whereNotIn('money', [1180, 11800, 10620, 9440, 2360])
|
|
439
|
|
- ->select();
|
|
|
580
|
+ $otherMoneyRecords = [];
|
|
|
581
|
+// $otherMoneyRecords = Db::name("old_user_of_goods")
|
|
|
582
|
+// ->whereIn("user_id", $userIdList)
|
|
|
583
|
+// ->whereNotIn('money', [1180, 11800, 10620, 9440, 2360])
|
|
|
584
|
+// ->select();
|
|
440
|
585
|
$otherMoneySum = 0;
|
|
441
|
586
|
foreach ($otherMoneyRecords as $record) {
|
|
442
|
587
|
$otherMoneySum += $record['money'];
|
|
443
|
588
|
}
|
|
444
|
|
- return $money1180Sum + $money11800Sum + $money10620Sum + $money9440Sum + $money2360Sum + round($otherMoneySum * 0.7, 2);
|
|
|
589
|
+ return $money1180Sum + $money11800Sum + $money10620Sum + $money9440Sum + $money2360Sum + (floor($otherMoneySum * 70) / 100);
|
|
445
|
590
|
}
|
|
446
|
591
|
|
|
447
|
592
|
//发放佣金 示例: $this->change_user_log($v,'amount',1,$all_award,"member_award","星级分红入账"."-".$value['title']);//释放佣金
|