|
|
@@ -48,6 +48,8 @@ class PensionTasks extends Command
|
|
48
|
48
|
$this->doOfflineOrderGzc($nowTime, $timeLimit = 1);
|
|
49
|
49
|
//在线订单符合条件的养老金收集(线上收货后第8天)
|
|
50
|
50
|
$this->doOnlineOrderGzc($timeLimit = 8);
|
|
|
51
|
+ //在线订单符合条件的话费养老金收集(话费到账后第1天)
|
|
|
52
|
+ $this->doOnlineHuuafeiOrderGzc($timeLimit = 1);
|
|
51
|
53
|
//第三方订单符合条件的养老金收集(三方结算后第2天)
|
|
52
|
54
|
$this->doThridPddOrderGzc($nowTime, $timeLimit = 2);
|
|
53
|
55
|
$this->doThridJdOrderGzc($nowTime, $timeLimit = 2);
|
|
|
@@ -161,8 +163,176 @@ class PensionTasks extends Command
|
|
161
|
163
|
}
|
|
162
|
164
|
}
|
|
163
|
165
|
|
|
|
166
|
+
|
|
|
167
|
+
|
|
|
168
|
+
|
|
164
|
169
|
/**
|
|
165
|
|
- * 在线支付公证处IN10入账
|
|
|
170
|
+ * 话费支付订单公证处IN10入账
|
|
|
171
|
+ * @param $nowTime
|
|
|
172
|
+ * @param $timeLimit
|
|
|
173
|
+ * author: php迷途小书童
|
|
|
174
|
+ * created: 2021/3/20 9:26
|
|
|
175
|
+ */
|
|
|
176
|
+ public function doOnlineHuuafeiOrderGzc($timeLimit)
|
|
|
177
|
+ {
|
|
|
178
|
+ // 普通订单
|
|
|
179
|
+ $cursor = Db::table('rrx_order_huafei')->where('status', 3)->where('gzc', 0)->cursor();
|
|
|
180
|
+ $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
|
|
181
|
+ $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
|
|
|
182
|
+ $OrderGzcRepository = app()->make(OrderGzcRepository::class);
|
|
|
183
|
+ foreach ($cursor as $online) {
|
|
|
184
|
+
|
|
|
185
|
+ if (time() < strtotime($online['finish_time']) + 3600 * 24) {
|
|
|
186
|
+ Log::info('还没有话费到账后' . $timeLimit . '天');
|
|
|
187
|
+ continue;
|
|
|
188
|
+ }
|
|
|
189
|
+
|
|
|
190
|
+
|
|
|
191
|
+ $certification = UserCertification::getInstance()->where('uid', $online['uid'])->find();
|
|
|
192
|
+ if (!$certification) {
|
|
|
193
|
+ Log::info($online['uid'] . '没有实名认证');
|
|
|
194
|
+ continue;
|
|
|
195
|
+ }
|
|
|
196
|
+ //查询养老金金额
|
|
|
197
|
+ $UserBillRepository = app()->make(UserBillRepository::class);
|
|
|
198
|
+ $bill = $UserBillRepository->getWhere(['uid' => $online['uid'], 'order_sn' => $online['order_sn'], 'commission_type' => 5]);
|
|
|
199
|
+ $pension = $bill->number ?? 0;
|
|
|
200
|
+ if ($pension <= 0) {
|
|
|
201
|
+ Log::info($online['order_sn'] . 'pension' . $pension);
|
|
|
202
|
+ continue;
|
|
|
203
|
+ }
|
|
|
204
|
+
|
|
|
205
|
+ //首信易分账
|
|
|
206
|
+ // $StoreOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
207
|
+ // if ($online['pay_type'] > 0) {
|
|
|
208
|
+ // $StoreOrderRepository->splitOrder($online);
|
|
|
209
|
+ // }
|
|
|
210
|
+ $StoreOrderRepository = [];
|
|
|
211
|
+ Db::transaction(function () use ($certification, $online, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
|
|
|
212
|
+ //新增入账明细记录
|
|
|
213
|
+ $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
|
|
|
214
|
+ $create = [
|
|
|
215
|
+ 'uid' => $online['uid'],
|
|
|
216
|
+ 'platform_no' => $orderId,
|
|
|
217
|
+ 'account_type' => 3,//账号类型1银行卡2支付宝3微信
|
|
|
218
|
+ 'user_name' => $certification['user_name'],
|
|
|
219
|
+ 'mobile' => $certification['mobile'],
|
|
|
220
|
+ 'user_card' => $certification['user_card'],
|
|
|
221
|
+ 'pension' => $pension,
|
|
|
222
|
+ 'order_type' => 2,
|
|
|
223
|
+ 'out_trade_no' => $online['order_sn']
|
|
|
224
|
+ ];
|
|
|
225
|
+ $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
|
|
|
226
|
+ $check = Db::name("gzc_logs")->where("out_trade_no", $online['order_sn'])->where("order_type", 2)->count();
|
|
|
227
|
+ if ($test_user == 0 && $check <= 0) {
|
|
|
228
|
+ $OrderGzcRepository->create($create);
|
|
|
229
|
+ }
|
|
|
230
|
+ $order = StoreOrder::getInstance()->find($online['order_id']);
|
|
|
231
|
+ $order->gzc = 1;
|
|
|
232
|
+ $order->save();
|
|
|
233
|
+ });
|
|
|
234
|
+ }
|
|
|
235
|
+
|
|
|
236
|
+
|
|
|
237
|
+
|
|
|
238
|
+ // 普通订单(红包,积分,京东,佣金,复购金,养老金,贡献值)
|
|
|
239
|
+ $cursor = Db::table('rrx_order_huafei')->where('status', 3)->where('bill_status', 0)->cursor();
|
|
|
240
|
+ $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
|
|
241
|
+ $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
|
|
|
242
|
+ $OrderGzcRepository = app()->make(OrderGzcRepository::class);
|
|
|
243
|
+ foreach ($cursor as $online) {
|
|
|
244
|
+ if (time() < strtotime($online['finish_time']) + 3600 * 24) {
|
|
|
245
|
+ Log::info('还没有话费到账后' . $timeLimit . '天');
|
|
|
246
|
+ continue;
|
|
|
247
|
+ }
|
|
|
248
|
+
|
|
|
249
|
+ Db::transaction(function () use ($online) {
|
|
|
250
|
+ //订单状态改为已结算
|
|
|
251
|
+ Db::name('rrx_order_huafei')
|
|
|
252
|
+ ->where('status', 3)->where('bill_status', 0)
|
|
|
253
|
+ ->where('order_sn', $online['order_sn'])
|
|
|
254
|
+ ->update([
|
|
|
255
|
+ 'bill_status'=> 1,
|
|
|
256
|
+ 'bill_create_time' => time()
|
|
|
257
|
+ ]);
|
|
|
258
|
+
|
|
|
259
|
+ // 结算积分
|
|
|
260
|
+ $user_sign_score_list = Db::name('user_sign_score')
|
|
|
261
|
+ ->where('status', -1)
|
|
|
262
|
+ ->where('order_id', $online['order_sn'])
|
|
|
263
|
+ ->whereIn('type', [1, 2])
|
|
|
264
|
+ ->select()
|
|
|
265
|
+ ->toArray();
|
|
|
266
|
+ foreach ($user_sign_score_list as $user_sign_score) {
|
|
|
267
|
+ // 修改积分
|
|
|
268
|
+ Db::name('user')
|
|
|
269
|
+ ->where('uid', $user_sign_score['uid'])
|
|
|
270
|
+ ->inc('score', (float)$user_sign_score['reward_socre'])
|
|
|
271
|
+ ->update();
|
|
|
272
|
+ Db::name('user_sign_score')
|
|
|
273
|
+ ->where('status', -1)
|
|
|
274
|
+ ->where('id', $user_sign_score['id'])
|
|
|
275
|
+ ->update([
|
|
|
276
|
+ 'status' => 1,
|
|
|
277
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
278
|
+ ]);
|
|
|
279
|
+ }
|
|
|
280
|
+
|
|
|
281
|
+ // 结算复购金
|
|
|
282
|
+ $user_sign_fugou_list = Db::name('user_sign_fugou')
|
|
|
283
|
+ ->where('status', -1)
|
|
|
284
|
+ ->where('order_id', $online['order_sn'])
|
|
|
285
|
+ ->whereIn('type', [1, 2])
|
|
|
286
|
+ ->select()
|
|
|
287
|
+ ->toArray();
|
|
|
288
|
+ foreach ($user_sign_fugou_list as $user_sign_fugou) {
|
|
|
289
|
+ // 修改复购金
|
|
|
290
|
+ Db::name('user')
|
|
|
291
|
+ ->where('uid', $user_sign_fugou['uid'])
|
|
|
292
|
+ ->inc('fugou', (float)$user_sign_fugou['number'])
|
|
|
293
|
+ ->update();
|
|
|
294
|
+ Db::name('user_sign_fugou')
|
|
|
295
|
+ ->where('status', -1)
|
|
|
296
|
+ ->where('id', $user_sign_fugou['id'])
|
|
|
297
|
+ ->update([
|
|
|
298
|
+ 'status' => 1,
|
|
|
299
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
300
|
+ ]);
|
|
|
301
|
+ }
|
|
|
302
|
+
|
|
|
303
|
+
|
|
|
304
|
+ // 结算贡献值
|
|
|
305
|
+ $user_sign_gongxian_list = Db::name('user_sign_gongxian')
|
|
|
306
|
+ ->where('status', -1)
|
|
|
307
|
+ ->where('order_id', $online['order_sn'])
|
|
|
308
|
+ ->whereIn('type', [1, 2])
|
|
|
309
|
+ ->select()
|
|
|
310
|
+ ->toArray();
|
|
|
311
|
+ foreach ($user_sign_gongxian_list as $user_sign_gongxian) {
|
|
|
312
|
+ // 修改贡献值
|
|
|
313
|
+ Db::name('user')
|
|
|
314
|
+ ->where('uid', $user_sign_gongxian['uid'])
|
|
|
315
|
+ ->inc('contribute', (float)$user_sign_gongxian['number'])
|
|
|
316
|
+ ->update();
|
|
|
317
|
+ Db::name('user_sign_gongxian')
|
|
|
318
|
+ ->where('status', -1)
|
|
|
319
|
+ ->where('id', $user_sign_gongxian['id'])
|
|
|
320
|
+ ->update([
|
|
|
321
|
+ 'status' => 1,
|
|
|
322
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
323
|
+ ]);
|
|
|
324
|
+ }
|
|
|
325
|
+
|
|
|
326
|
+ });
|
|
|
327
|
+ }
|
|
|
328
|
+
|
|
|
329
|
+
|
|
|
330
|
+ }
|
|
|
331
|
+
|
|
|
332
|
+
|
|
|
333
|
+
|
|
|
334
|
+ /**
|
|
|
335
|
+ * 在线支付公证处IN10入账 (红包,积分,京东,佣金,复购金,养老金,贡献值)
|
|
166
|
336
|
* @param $nowTime
|
|
167
|
337
|
* @param $timeLimit
|
|
168
|
338
|
* author: php迷途小书童
|
|
|
@@ -170,11 +340,8 @@ class PensionTasks extends Command
|
|
170
|
340
|
*/
|
|
171
|
341
|
public function doOnlineOrderGzc($timeLimit)
|
|
172
|
342
|
{
|
|
173
|
|
- $cursor = Db::table('rrx_store_order')
|
|
174
|
|
- ->where('paid', 1)
|
|
175
|
|
- ->where('gzc', 0)
|
|
176
|
|
- ->where('pay_type', 'in', '0,1,2,4')
|
|
177
|
|
- ->cursor();
|
|
|
343
|
+ // 普通订单
|
|
|
344
|
+ $cursor = Db::table('rrx_store_order')->where('paid', 1)->where('gzc', 0)->where('pay_type', 'in', '0,1,2,4')->cursor();
|
|
178
|
345
|
$StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
|
179
|
346
|
$OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
|
|
180
|
347
|
$OrderGzcRepository = app()->make(OrderGzcRepository::class);
|
|
|
@@ -251,11 +418,9 @@ class PensionTasks extends Command
|
|
251
|
418
|
|
|
252
|
419
|
});
|
|
253
|
420
|
}
|
|
254
|
|
- $cursor = Db::table('rrx_store_order')
|
|
255
|
|
- ->where('paid', 1)
|
|
256
|
|
- ->where('is_settlement', 0)
|
|
257
|
|
- ->where('pay_type', 'in', '0,1,2,4')
|
|
258
|
|
- ->cursor();
|
|
|
421
|
+
|
|
|
422
|
+ // 普通订单(红包,积分,京东,佣金,复购金,养老金,贡献值)
|
|
|
423
|
+ $cursor = Db::table('rrx_store_order')->where('paid', 1)->where('is_settlement', 0)->where('pay_type', 'in', '0,1,2,4')->cursor();
|
|
259
|
424
|
$StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
|
260
|
425
|
$OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
|
|
261
|
426
|
$OrderGzcRepository = app()->make(OrderGzcRepository::class);
|
|
|
@@ -281,7 +446,7 @@ class PensionTasks extends Command
|
|
281
|
446
|
|
|
282
|
447
|
$StoreOrderRepository = app()->make(StoreOrderRepository::class);
|
|
283
|
448
|
Db::transaction(function () use ($online, $StoreOrderRepository) {
|
|
284
|
|
- $order = StoreOrder::getInstance()->find($online['order_id']);
|
|
|
449
|
+ $order = StoreOrder::getInstance()->find($online['order_id']);
|
|
285
|
450
|
$order->is_settlement = 1;
|
|
286
|
451
|
$order->settlement_time = date('Y-m-d H:i:s');
|
|
287
|
452
|
$order->save();
|
|
|
@@ -307,6 +472,101 @@ class PensionTasks extends Command
|
|
307
|
472
|
'settlement_time' => date('Y-m-d H:i:s')
|
|
308
|
473
|
]);
|
|
309
|
474
|
}
|
|
|
475
|
+
|
|
|
476
|
+ // 结算红包
|
|
|
477
|
+ $user_sign_hongbao_list = Db::name('user_sign_hongbao')
|
|
|
478
|
+ ->where('status', -1)
|
|
|
479
|
+ ->where('order_id', $online['order_id'])
|
|
|
480
|
+ ->whereIn('type', [1, 2])
|
|
|
481
|
+ ->select()
|
|
|
482
|
+ ->toArray();
|
|
|
483
|
+ foreach ($user_sign_hongbao_list as $user_sign_hongbao) {
|
|
|
484
|
+ // 修改红包
|
|
|
485
|
+ Db::name('user')
|
|
|
486
|
+ ->where('uid', $user_sign_hongbao['uid'])
|
|
|
487
|
+ ->inc('hongbao', (float)$user_sign_hongbao['number'])
|
|
|
488
|
+ ->update();
|
|
|
489
|
+ Db::name('user_sign_hongbao')
|
|
|
490
|
+ ->where('status', -1)
|
|
|
491
|
+ ->where('id', $user_sign_hongbao['id'])
|
|
|
492
|
+ ->update([
|
|
|
493
|
+ 'status' => 1,
|
|
|
494
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
495
|
+ ]);
|
|
|
496
|
+ }
|
|
|
497
|
+
|
|
|
498
|
+
|
|
|
499
|
+ // 结算京豆
|
|
|
500
|
+ $user_sign_jingdou_list = Db::name('user_sign_jingdou')
|
|
|
501
|
+ ->where('status', -1)
|
|
|
502
|
+ ->where('order_id', $online['order_id'])
|
|
|
503
|
+ ->whereIn('type', [1, 2])
|
|
|
504
|
+ ->select()
|
|
|
505
|
+ ->toArray();
|
|
|
506
|
+ foreach ($user_sign_jingdou_list as $user_sign_jingdou) {
|
|
|
507
|
+ // 修改京豆
|
|
|
508
|
+ Db::name('user')
|
|
|
509
|
+ ->where('uid', $user_sign_jingdou['uid'])
|
|
|
510
|
+ ->inc('jingdou', (float)$user_sign_jingdou['number'])
|
|
|
511
|
+ ->update();
|
|
|
512
|
+ Db::name('user_sign_jingdou')
|
|
|
513
|
+ ->where('status', -1)
|
|
|
514
|
+ ->where('id', $user_sign_jingdou['id'])
|
|
|
515
|
+ ->update([
|
|
|
516
|
+ 'status' => 1,
|
|
|
517
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
518
|
+ ]);
|
|
|
519
|
+ }
|
|
|
520
|
+
|
|
|
521
|
+
|
|
|
522
|
+
|
|
|
523
|
+ // 结算复购金
|
|
|
524
|
+ $user_sign_fugou_list = Db::name('user_sign_fugou')
|
|
|
525
|
+ ->where('status', -1)
|
|
|
526
|
+ ->where('order_id', $online['order_id'])
|
|
|
527
|
+ ->whereIn('type', [1, 2])
|
|
|
528
|
+ ->select()
|
|
|
529
|
+ ->toArray();
|
|
|
530
|
+ foreach ($user_sign_fugou_list as $user_sign_fugou) {
|
|
|
531
|
+ // 修改复购金
|
|
|
532
|
+ Db::name('user')
|
|
|
533
|
+ ->where('uid', $user_sign_fugou['uid'])
|
|
|
534
|
+ ->inc('fugou', (float)$user_sign_fugou['number'])
|
|
|
535
|
+ ->update();
|
|
|
536
|
+ Db::name('user_sign_fugou')
|
|
|
537
|
+ ->where('status', -1)
|
|
|
538
|
+ ->where('id', $user_sign_fugou['id'])
|
|
|
539
|
+ ->update([
|
|
|
540
|
+ 'status' => 1,
|
|
|
541
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
542
|
+ ]);
|
|
|
543
|
+ }
|
|
|
544
|
+
|
|
|
545
|
+
|
|
|
546
|
+ // 结算贡献值
|
|
|
547
|
+ $user_sign_gongxian_list = Db::name('user_sign_gongxian')
|
|
|
548
|
+ ->where('status', -1)
|
|
|
549
|
+ ->where('order_id', $online['order_id'])
|
|
|
550
|
+ ->whereIn('type', [1, 2])
|
|
|
551
|
+ ->select()
|
|
|
552
|
+ ->toArray();
|
|
|
553
|
+ foreach ($user_sign_gongxian_list as $user_sign_gongxian) {
|
|
|
554
|
+ // 修改贡献值
|
|
|
555
|
+ Db::name('user')
|
|
|
556
|
+ ->where('uid', $user_sign_gongxian['uid'])
|
|
|
557
|
+ ->inc('contribute', (float)$user_sign_gongxian['number'])
|
|
|
558
|
+ ->update();
|
|
|
559
|
+ Db::name('user_sign_gongxian')
|
|
|
560
|
+ ->where('status', -1)
|
|
|
561
|
+ ->where('id', $user_sign_gongxian['id'])
|
|
|
562
|
+ ->update([
|
|
|
563
|
+ 'status' => 1,
|
|
|
564
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
565
|
+ ]);
|
|
|
566
|
+ }
|
|
|
567
|
+
|
|
|
568
|
+
|
|
|
569
|
+ // 结算佣金
|
|
310
|
570
|
$user_bill_list = Db::name('user_bill')
|
|
311
|
571
|
->where('status', 0)
|
|
312
|
572
|
->where('commission_type','<>', 5)
|
|
|
@@ -350,6 +610,7 @@ class PensionTasks extends Command
|
|
350
|
610
|
]);
|
|
351
|
611
|
}
|
|
352
|
612
|
}
|
|
|
613
|
+ //按角色结算
|
|
353
|
614
|
$StoreOrderRepository->close_order($online['order_id']);
|
|
354
|
615
|
});
|
|
355
|
616
|
}
|