|
|
@@ -140,6 +140,8 @@ class GzcAddByBillCommand extends Command
|
|
140
|
140
|
$delAllIdList = [];
|
|
141
|
141
|
$delYongJin = [];
|
|
142
|
142
|
$yjNum = 0.00;
|
|
|
143
|
+ $yongjinKouchu = [];
|
|
|
144
|
+ $yongjinKouchuDelBillIdList = [];
|
|
143
|
145
|
foreach ($userBillMap as $userBillArr) {
|
|
144
|
146
|
$allIds = [];
|
|
145
|
147
|
$baoLiuIds = [];
|
|
|
@@ -173,6 +175,11 @@ class GzcAddByBillCommand extends Command
|
|
173
|
175
|
foreach ($yjDataList as $billData) {
|
|
174
|
176
|
$delYongJin[] = $billData['bill_id'];
|
|
175
|
177
|
$yjNum += $billData['number'];
|
|
|
178
|
+ if (!isset($yongjinKouchu[$billData['uid']])) {
|
|
|
179
|
+ $yongjinKouchu[$billData['uid']] = 0.00;
|
|
|
180
|
+ }
|
|
|
181
|
+ $yongjinKouchu[$billData['uid']] += $billData['number'];
|
|
|
182
|
+ $yongjinKouchuDelBillIdList[$billData['uid']][] = $billData['bill_id'];
|
|
176
|
183
|
}
|
|
177
|
184
|
}
|
|
178
|
185
|
$delIdList = array_values(array_diff($allIds, [$yjDataOne['bill_id']]));
|
|
|
@@ -183,9 +190,46 @@ class GzcAddByBillCommand extends Command
|
|
183
|
190
|
$delAllIdList = array_merge($delAllIdList, $delIdList);
|
|
184
|
191
|
}
|
|
185
|
192
|
|
|
186
|
|
- echo '删除的Bill记录' . implode(',', $delAllIdList) . "\n";
|
|
187
|
|
- echo '删除的佣金记录' . implode(',', $delYongJin) . "\n";
|
|
188
|
|
- echo '删除的佣金金额' . $yjNum . "\n";
|
|
|
193
|
+ echo '应删除的Bill记录' . implode(',', $delAllIdList) . "\n";
|
|
|
194
|
+ echo '应删除的佣金记录' . implode(',', $delYongJin) . "\n";
|
|
|
195
|
+ echo '应删除的佣金金额' . $yjNum . "\n";
|
|
|
196
|
+
|
|
|
197
|
+ $successDecYongjin = 0.00;
|
|
|
198
|
+ $fallDelBillIdList = [];
|
|
|
199
|
+ if (!empty($yongjinKouchu)) {
|
|
|
200
|
+ foreach ($yongjinKouchu as $uid => $number) {
|
|
|
201
|
+ $user = Db::name('user')->where('uid', '=', $uid)->find();
|
|
|
202
|
+ if ($user) {
|
|
|
203
|
+ if ($user['brokerage_price'] >= $number) {
|
|
|
204
|
+ $updateNum = Db::name('user')->where('uid', '=', $uid)->dec('brokerage_price', $number)->update();
|
|
|
205
|
+ if ($updateNum) {
|
|
|
206
|
+ $successDecYongjin += $number;
|
|
|
207
|
+ echo "用户佣金扣除成功(uid:$uid ,账号:{$user['account']} ,用户佣金余额:{$user['brokerage_price']},应扣除佣金:$number )\n";
|
|
|
208
|
+ continue;
|
|
|
209
|
+ } else {
|
|
|
210
|
+ echo "用户佣金余额不足(uid:$uid ,账号:{$user['account']} ,用户佣金余额:{$user['brokerage_price']},应扣除佣金:$number )\n";
|
|
|
211
|
+ }
|
|
|
212
|
+ } else {
|
|
|
213
|
+ echo "用户佣金余额不足(uid:$uid ,账号:{$user['account']} ,用户佣金余额:{$user['brokerage_price']},应扣除佣金:$number )\n";
|
|
|
214
|
+ }
|
|
|
215
|
+ } else {
|
|
|
216
|
+ echo "未查询到用户信息(uid:$uid ,应扣除佣金:$number )\n";
|
|
|
217
|
+ }
|
|
|
218
|
+ $fallDelBillIdList = array_values(array_merge($fallDelBillIdList, $yongjinKouchuDelBillIdList[$uid]));
|
|
|
219
|
+ }
|
|
|
220
|
+ }
|
|
|
221
|
+ echo '因佣金扣减失败而不能删除的佣金记录:' . implode(',', $fallDelBillIdList) . "\n";
|
|
|
222
|
+ echo '成功扣减佣金总额:' . $successDecYongjin . "\n";
|
|
|
223
|
+ $delAllIdList = array_values(array_diff($delAllIdList, $fallDelBillIdList));
|
|
|
224
|
+ echo '实际删除的Bill记录' . implode(',', $delAllIdList) . "\n";
|
|
|
225
|
+ Db::name("user_bill")
|
|
|
226
|
+ ->whereIn('bill_id', $delAllIdList)
|
|
|
227
|
+ ->delete();
|
|
|
228
|
+ Db::name("gzc_logs")
|
|
|
229
|
+ ->whereIn('link_id', $delAllIdList)
|
|
|
230
|
+ ->delete();
|
|
|
231
|
+ $delYongJin = array_values(array_diff($delYongJin, $fallDelBillIdList));
|
|
|
232
|
+ echo '实际应删除的佣金记录' . implode(',', $delYongJin) . "\n";
|
|
189
|
233
|
|
|
190
|
234
|
$output->writeln('定时任务执行完成');
|
|
191
|
235
|
}
|