|
|
@@ -348,254 +348,264 @@ class Order extends BaseController
|
|
348
|
348
|
if (!in_array($adminId, [1,28,29])) {//超级管理员,财务,老总
|
|
349
|
349
|
return app('json')->fail('后台权限不足');
|
|
350
|
350
|
}
|
|
351
|
|
- try {
|
|
352
|
|
- Db::startTrans();
|
|
353
|
|
- //查找是否有推荐人
|
|
354
|
|
- $spreadUid = Db::name('user')->where('uid', $uid)->value('spread_uid');
|
|
355
|
|
- //取出pv
|
|
356
|
|
- $pv = $this->getValue('user_pv_log', [['order_id', '=', $order_id], ['status', '=', 1],], 'pv');
|
|
357
|
|
- //取出 vr
|
|
358
|
|
- $payVr = $this->getValue('user_sign_vr', [['order_id', '=', $order_id], ['type', '=', 2],], 'number');
|
|
359
|
|
- //取出购买赠送积分 / 支出积分
|
|
360
|
|
- $score = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['source_type', '=', 3], ['uid', '=', $uid], ['pm', '=', 1],], 'reward_socre');
|
|
361
|
|
- $payScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 2], ['uid', '=', $uid],], 'reward_socre');
|
|
362
|
|
- // 贡献值
|
|
363
|
|
- $gongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $uid],], 'number');
|
|
364
|
|
- // 养老金
|
|
365
|
|
- $yangLaoJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 1], ['uid', '=', $uid],], 'number');
|
|
366
|
|
- if($spreadUid){ //如果有推荐人就执行
|
|
367
|
|
- $spreadScore = 0;
|
|
368
|
|
- $spreadGongXian = 0;
|
|
369
|
|
- $spreadYlj = 0;
|
|
370
|
|
- $spreadYongJin = 0;
|
|
371
|
|
- $spreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid', '=', $spreadUid], ['status', '=', 1],], 'reward_socre');
|
|
372
|
|
- $spreadGongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $spreadUid],], 'number');
|
|
373
|
|
- $spreadYlj = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 5], ['uid', '=', $spreadUid],], 'number'); //推荐获得养老金
|
|
374
|
|
- $spreadYongJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '=', $spreadUid],], 'number'); //推荐获得佣金
|
|
375
|
|
- $spreadUser = Db::name('user')->where('uid', $spreadUid)->find();
|
|
376
|
|
- Db::name('backup_user')->insert($spreadUser); //插入备份表
|
|
377
|
|
- Db::name('user')->where('uid', $spreadUid) //更新数据
|
|
378
|
|
- ->update([
|
|
379
|
|
- 'score' => Db::raw("score - {$spreadScore}"),
|
|
380
|
|
- 'per_contribute' => Db::raw("per_contribute - {$spreadGongXian}"),
|
|
381
|
|
- 'brokerage_price' => Db::raw("brokerage_price - {$spreadYongJin}"),
|
|
382
|
|
- 'annuity' => Db::raw("annuity - {$spreadYlj}"),
|
|
383
|
|
- ]);
|
|
384
|
|
- $userhjm1 =[
|
|
385
|
|
- 'uid' => $spreadUid,
|
|
386
|
|
- 'order_id' => $order_id,
|
|
387
|
|
- 'score' => $spreadScore??0,
|
|
388
|
|
- 'per_contribute' => $spreadGongXian??0,
|
|
389
|
|
- 'brokerage_price' => $spreadYongJin??0,
|
|
390
|
|
- 'user' => 2,
|
|
391
|
|
- ];
|
|
392
|
|
- Db::name('backup_user_change')->insert($userhjm1); //插入更新数据记录表
|
|
393
|
|
- }
|
|
394
|
|
- //扫吗消费
|
|
395
|
|
- $smSpreadUid = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['mark','like','%扫码%'], ['status', '=', 1],], 'uid');
|
|
396
|
|
- $smSpreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid','=',$smSpreadUid], ['status', '=', 1],], 'reward_socre');
|
|
397
|
|
- //第二推荐
|
|
398
|
|
- $spreadYongJinTwoUid = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', 'not in', [$uid, $spreadUid]],], 'uid');
|
|
399
|
|
- $spreadYongJinTwo = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '=', $spreadYongJinTwoUid],], 'number');
|
|
400
|
|
- //更新购买用户的user表
|
|
401
|
|
- $uscore = $payScore - $score;
|
|
402
|
|
- $user = Db::name('user')->where('uid', $uid)->find();
|
|
403
|
|
- Db::name('backup_user')->insert($user);
|
|
404
|
|
- Db::name('user')->where('uid', $uid)
|
|
405
|
|
- ->update([
|
|
406
|
|
- 'pv' => Db::raw("pv - {$pv}"),
|
|
407
|
|
- 'vr' => Db::raw("vr + {$payVr}"),
|
|
408
|
|
- 'score' => Db::raw("score + {$uscore}"),
|
|
409
|
|
- 'contribute' => Db::raw("contribute - {$gongXian}"),
|
|
410
|
|
- 'annuity' => Db::raw("annuity - {$yangLaoJin}"),
|
|
411
|
|
- ]);
|
|
412
|
|
- $userhjm =[
|
|
413
|
|
- 'uid' => $uid,
|
|
414
|
|
- 'order_id' => $order_id,
|
|
415
|
|
- 'pv' => $pv??0,
|
|
416
|
|
- 'vr' => $payVr??0,
|
|
417
|
|
- 'score' => $uscore??0,
|
|
418
|
|
- 'contribute' => $gongXian??0,
|
|
419
|
|
- 'annuity' => $yangLaoJin??0,
|
|
420
|
|
- 'user' => 1,
|
|
421
|
|
- ];
|
|
422
|
|
- Db::name('backup_user_change')->insert($userhjm);//具体修改插入对应表
|
|
423
|
|
- //第二推荐
|
|
424
|
|
- if($spreadYongJinTwoUid) {
|
|
425
|
|
- $spreadUserTwo = Db::name('user')->where('uid', $spreadYongJinTwoUid)->find();
|
|
426
|
|
- Db::name('backup_user')->insert($spreadUserTwo);
|
|
427
|
|
- Db::name('user')->where('uid', $spreadYongJinTwoUid)->dec('brokerage_price', $spreadYongJinTwo)->update();
|
|
428
|
|
- $userhjm2 =[
|
|
429
|
|
- 'uid' => $spreadYongJinTwoUid,
|
|
430
|
|
- 'order_id' => $order_id,
|
|
431
|
|
- 'brokerage_price' => $spreadYongJinTwo??0,
|
|
432
|
|
- 'user' => 3,
|
|
433
|
|
- ];
|
|
434
|
|
- Db::name('backup_user_change')->insert($userhjm2);
|
|
435
|
|
- }//扫码消费
|
|
436
|
|
- if($smSpreadUid){
|
|
437
|
|
- $smUserTwo = Db::name('user')->where('uid', $smSpreadUid)->find();
|
|
438
|
|
- Db::name('backup_user')->insert($smUserTwo);
|
|
439
|
|
- Db::name('user')->where('uid', $smSpreadUid)->dec('score', $smSpreadScore)->update();
|
|
440
|
|
- $userhjm3 =[
|
|
441
|
|
- 'uid' => $smSpreadUid,
|
|
442
|
|
- 'order_id' => $order_id,
|
|
443
|
|
- 'score' => $smSpreadScore??0,
|
|
444
|
|
- 'user' => 4,
|
|
445
|
|
- ];
|
|
446
|
|
- Db::name('backup_user_change')->insert($userhjm3);
|
|
447
|
|
- }
|
|
448
|
|
- // 删除订单相关表p;
|
|
449
|
|
- $this->backupAndDelete('store_order', ['group_order_id' => $group_order_id]);
|
|
450
|
|
- $this->backupAndDelete('store_group_order', ['group_order_id' => $group_order_id]);
|
|
451
|
|
- $this->backupAndDelete('user_pv_log', ['order_id' => $order_id]);
|
|
452
|
|
- $this->backupAndDelete('user_sign_vr', ['order_id' => $order_id]);
|
|
453
|
|
- $this->backupAndDelete('user_sign_score', ['order_id' => $order_id]);
|
|
454
|
|
- $this->backupAndDelete('user_sign_gongxian', ['order_id' => $order_id]);
|
|
455
|
|
- $this->backupAndDelete('user_bill', ['link_id' => $order_id]);
|
|
456
|
|
- $this->backupAndDelete('gzc_logs', ['link_id' => $order_id]);
|
|
457
|
|
- Db::commit();
|
|
458
|
|
- } catch (\Exception $e) {
|
|
459
|
|
- Db::rollback();
|
|
460
|
|
- return app('json')->fail('操作失败'. $e->getMessage());
|
|
|
351
|
+ $ok = $this->repository->useKillOrderRewards($group_order_id, $order_id, $uid,$adminId);
|
|
|
352
|
+ if (!$ok) {
|
|
|
353
|
+ return app('json')->fail('操作失败');
|
|
461
|
354
|
}
|
|
462
|
|
- Db::name("user_order_kill_records")->insert([//记录哪位管理员撤销的订单
|
|
463
|
|
- 'operation_id' => $adminId,
|
|
464
|
|
- 'uid' => $uid,
|
|
465
|
|
- 'order_id' => $order_id,
|
|
466
|
|
- 'mark' => '后台管理员撤销订单记录'
|
|
467
|
|
- ]);
|
|
468
|
355
|
return app('json')->success('操作成功');
|
|
|
356
|
+// try {
|
|
|
357
|
+// Db::startTrans();
|
|
|
358
|
+// //查找是否有推荐人
|
|
|
359
|
+// $spreadUid = Db::name('user')->where('uid', $uid)->value('spread_uid');
|
|
|
360
|
+// //取出pv
|
|
|
361
|
+// $pv = $this->getValue('user_pv_log', [['order_id', '=', $order_id], ['status', '=', 1],], 'pv');
|
|
|
362
|
+// //取出 vr
|
|
|
363
|
+// $payVr = $this->getValue('user_sign_vr', [['order_id', '=', $order_id], ['type', '=', 2],], 'number');
|
|
|
364
|
+// //取出购买赠送积分 / 支出积分
|
|
|
365
|
+// $score = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['source_type', '=', 3], ['uid', '=', $uid], ['pm', '=', 1],], 'reward_socre');
|
|
|
366
|
+// $payScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 2], ['uid', '=', $uid],], 'reward_socre');
|
|
|
367
|
+// // 贡献值
|
|
|
368
|
+// $gongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $uid],], 'number');
|
|
|
369
|
+// // 养老金
|
|
|
370
|
+// $yangLaoJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 1], ['uid', '=', $uid],], 'number');
|
|
|
371
|
+// if($spreadUid){ //如果有推荐人就执行
|
|
|
372
|
+// $spreadScore = 0;
|
|
|
373
|
+// $spreadGongXian = 0;
|
|
|
374
|
+// $spreadYlj = 0;
|
|
|
375
|
+// $spreadYongJin = 0;
|
|
|
376
|
+// $spreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid', '=', $spreadUid], ['status', '=', 1],], 'reward_socre');
|
|
|
377
|
+// $spreadGongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $spreadUid],], 'number');
|
|
|
378
|
+// $spreadYlj = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 5], ['uid', '=', $spreadUid],], 'number'); //推荐获得养老金
|
|
|
379
|
+// $spreadYongJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '=', $spreadUid],], 'number'); //推荐获得佣金
|
|
|
380
|
+// $spreadUser = Db::name('user')->where('uid', $spreadUid)->find();
|
|
|
381
|
+// Db::name('backup_user')->insert($spreadUser); //插入备份表
|
|
|
382
|
+// Db::name('user')->where('uid', $spreadUid) //更新数据
|
|
|
383
|
+// ->update([
|
|
|
384
|
+// 'score' => Db::raw("score - {$spreadScore}"),
|
|
|
385
|
+// 'per_contribute' => Db::raw("per_contribute - {$spreadGongXian}"),
|
|
|
386
|
+// 'brokerage_price' => Db::raw("brokerage_price - {$spreadYongJin}"),
|
|
|
387
|
+// 'annuity' => Db::raw("annuity - {$spreadYlj}"),
|
|
|
388
|
+// ]);
|
|
|
389
|
+// $userhjm1 =[
|
|
|
390
|
+// 'uid' => $spreadUid,
|
|
|
391
|
+// 'order_id' => $order_id,
|
|
|
392
|
+// 'score' => $spreadScore??0,
|
|
|
393
|
+// 'per_contribute' => $spreadGongXian??0,
|
|
|
394
|
+// 'brokerage_price' => $spreadYongJin??0,
|
|
|
395
|
+// 'user' => 2,
|
|
|
396
|
+// ];
|
|
|
397
|
+// Db::name('backup_user_change')->insert($userhjm1); //插入更新数据记录表
|
|
|
398
|
+// }
|
|
|
399
|
+// //扫吗消费
|
|
|
400
|
+// $smSpreadUid = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['mark','like','%扫码%'], ['status', '=', 1],], 'uid');
|
|
|
401
|
+// $smSpreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid','=',$smSpreadUid], ['status', '=', 1],], 'reward_socre');
|
|
|
402
|
+// //第二推荐
|
|
|
403
|
+// $spreadYongJinTwoUid = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', 'not in', [$uid, $spreadUid]],], 'uid');
|
|
|
404
|
+// $spreadYongJinTwo = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '=', $spreadYongJinTwoUid],], 'number');
|
|
|
405
|
+// //更新购买用户的user表
|
|
|
406
|
+// $uscore = $payScore - $score;
|
|
|
407
|
+// $user = Db::name('user')->where('uid', $uid)->find();
|
|
|
408
|
+// Db::name('backup_user')->insert($user);
|
|
|
409
|
+// Db::name('user')->where('uid', $uid)
|
|
|
410
|
+// ->update([
|
|
|
411
|
+// 'pv' => Db::raw("pv - {$pv}"),
|
|
|
412
|
+// 'vr' => Db::raw("vr + {$payVr}"),
|
|
|
413
|
+// 'score' => Db::raw("score + {$uscore}"),
|
|
|
414
|
+// 'contribute' => Db::raw("contribute - {$gongXian}"),
|
|
|
415
|
+// 'annuity' => Db::raw("annuity - {$yangLaoJin}"),
|
|
|
416
|
+// ]);
|
|
|
417
|
+// $userhjm =[
|
|
|
418
|
+// 'uid' => $uid,
|
|
|
419
|
+// 'order_id' => $order_id,
|
|
|
420
|
+// 'pv' => $pv??0,
|
|
|
421
|
+// 'vr' => $payVr??0,
|
|
|
422
|
+// 'score' => $uscore??0,
|
|
|
423
|
+// 'contribute' => $gongXian??0,
|
|
|
424
|
+// 'annuity' => $yangLaoJin??0,
|
|
|
425
|
+// 'user' => 1,
|
|
|
426
|
+// ];
|
|
|
427
|
+// Db::name('backup_user_change')->insert($userhjm);//具体修改插入对应表
|
|
|
428
|
+// //第二推荐
|
|
|
429
|
+// if($spreadYongJinTwoUid) {
|
|
|
430
|
+// $spreadUserTwo = Db::name('user')->where('uid', $spreadYongJinTwoUid)->find();
|
|
|
431
|
+// Db::name('backup_user')->insert($spreadUserTwo);
|
|
|
432
|
+// Db::name('user')->where('uid', $spreadYongJinTwoUid)->dec('brokerage_price', $spreadYongJinTwo)->update();
|
|
|
433
|
+// $userhjm2 =[
|
|
|
434
|
+// 'uid' => $spreadYongJinTwoUid,
|
|
|
435
|
+// 'order_id' => $order_id,
|
|
|
436
|
+// 'brokerage_price' => $spreadYongJinTwo??0,
|
|
|
437
|
+// 'user' => 3,
|
|
|
438
|
+// ];
|
|
|
439
|
+// Db::name('backup_user_change')->insert($userhjm2);
|
|
|
440
|
+// }//扫码消费
|
|
|
441
|
+// if($smSpreadUid){
|
|
|
442
|
+// $smUserTwo = Db::name('user')->where('uid', $smSpreadUid)->find();
|
|
|
443
|
+// Db::name('backup_user')->insert($smUserTwo);
|
|
|
444
|
+// Db::name('user')->where('uid', $smSpreadUid)->dec('score', $smSpreadScore)->update();
|
|
|
445
|
+// $userhjm3 =[
|
|
|
446
|
+// 'uid' => $smSpreadUid,
|
|
|
447
|
+// 'order_id' => $order_id,
|
|
|
448
|
+// 'score' => $smSpreadScore??0,
|
|
|
449
|
+// 'user' => 4,
|
|
|
450
|
+// ];
|
|
|
451
|
+// Db::name('backup_user_change')->insert($userhjm3);
|
|
|
452
|
+// }
|
|
|
453
|
+// // 删除订单相关表p;
|
|
|
454
|
+// $this->backupAndDelete('store_order', ['group_order_id' => $group_order_id]);
|
|
|
455
|
+// $this->backupAndDelete('store_group_order', ['group_order_id' => $group_order_id]);
|
|
|
456
|
+// $this->backupAndDelete('user_pv_log', ['order_id' => $order_id]);
|
|
|
457
|
+// $this->backupAndDelete('user_sign_vr', ['order_id' => $order_id]);
|
|
|
458
|
+// $this->backupAndDelete('user_sign_score', ['order_id' => $order_id]);
|
|
|
459
|
+// $this->backupAndDelete('user_sign_gongxian', ['order_id' => $order_id]);
|
|
|
460
|
+// $this->backupAndDelete('user_bill', ['link_id' => $order_id]);
|
|
|
461
|
+// $this->backupAndDelete('gzc_logs', ['link_id' => $order_id]);
|
|
|
462
|
+// Db::commit();
|
|
|
463
|
+// } catch (\Exception $e) {
|
|
|
464
|
+// Db::rollback();
|
|
|
465
|
+// return app('json')->fail('操作失败'. $e->getMessage());
|
|
|
466
|
+// }
|
|
|
467
|
+// Db::name("user_order_kill_records")->insert([//记录哪位管理员撤销的订单
|
|
|
468
|
+// 'operation_id' => $adminId,
|
|
|
469
|
+// 'uid' => $uid,
|
|
|
470
|
+// 'order_id' => $order_id,
|
|
|
471
|
+// 'mark' => '后台管理员撤销订单记录'
|
|
|
472
|
+// ]);
|
|
|
473
|
+// return app('json')->success('操作成功');
|
|
469
|
474
|
}
|
|
470
|
|
-
|
|
471
|
|
- private function backupAndDelete($table, array $where)//备份并删除
|
|
472
|
|
- {
|
|
473
|
|
- $backupTable = 'backup_' . $table;
|
|
474
|
|
- $rows = Db::name($table)->where($where)->select()->toArray();
|
|
475
|
|
- if ($rows) {
|
|
476
|
|
- Db::name($backupTable)->insertAll($rows);
|
|
477
|
|
- Db::name($table)->where($where)->delete();
|
|
478
|
|
- }
|
|
479
|
|
- }
|
|
480
|
|
- private function getValue($table, array $where, string $field, $default = 0)//查找
|
|
481
|
|
- {
|
|
482
|
|
- $value = Db::name($table)->where($where)->value($field);
|
|
483
|
|
- return $value ?? $default;
|
|
484
|
|
- }
|
|
485
|
|
-
|
|
|
475
|
+//
|
|
|
476
|
+// private function backupAndDelete($table, array $where)//备份并删除
|
|
|
477
|
+// {
|
|
|
478
|
+// $backupTable = 'backup_' . $table;
|
|
|
479
|
+// $rows = Db::name($table)->where($where)->select()->toArray();
|
|
|
480
|
+// if ($rows) {
|
|
|
481
|
+// Db::name($backupTable)->insertAll($rows);
|
|
|
482
|
+// Db::name($table)->where($where)->delete();
|
|
|
483
|
+// }
|
|
|
484
|
+// }
|
|
|
485
|
+// private function getValue($table, array $where, string $field, $default = 0)//查找
|
|
|
486
|
+// {
|
|
|
487
|
+// $value = Db::name($table)->where($where)->value($field);
|
|
|
488
|
+// return $value ?? $default;
|
|
|
489
|
+// }
|
|
486
|
490
|
/**
|
|
487
|
491
|
* 展示撤回订单列表,恢复订单
|
|
488
|
492
|
*/
|
|
489
|
493
|
public function killOrderLst() //撤回订单的列表
|
|
490
|
494
|
{
|
|
491
|
|
- $query = Db::name('backup_store_order')->paginate(20)->toArray();
|
|
492
|
|
- return app('json')->success($query, '获取成功');
|
|
|
495
|
+// $query = Db::name('backup_store_order')->paginate(20)->toArray();
|
|
|
496
|
+// return app('json')->success($query, '获取成功');
|
|
|
497
|
+ $list = $this->repository->getKillOrderList();
|
|
|
498
|
+ return app('json')->success($list, '获取成功');
|
|
493
|
499
|
}
|
|
494
|
500
|
public function easterKillOrder(){ //恢复订单
|
|
495
|
501
|
$group_order_id = request()->param('group_order_id');
|
|
496
|
502
|
$order_id = request()->param('order_id');
|
|
497
|
|
- $adminId = $this->request->adminId();
|
|
498
|
503
|
if (empty($order_id) || empty($group_order_id)) {
|
|
499
|
504
|
return app('json')->fail('参数缺失');
|
|
500
|
505
|
}
|
|
501
|
|
- try {
|
|
502
|
|
- Db::startTrans();
|
|
503
|
|
- // 恢复订单相关表
|
|
504
|
|
- $this->easterOrder('store_order', ['group_order_id' => $group_order_id]);
|
|
505
|
|
- $this->easterOrder('store_group_order', ['group_order_id' => $group_order_id]);
|
|
506
|
|
- // 恢复 pv
|
|
507
|
|
- $this->easterOrder('user_pv_log', ['order_id' => $order_id]);
|
|
508
|
|
- // 恢复 vr
|
|
509
|
|
- $this->easterOrder('user_sign_vr', ['order_id' => $order_id]);
|
|
510
|
|
- // 恢复 积分
|
|
511
|
|
- $this->easterOrder('user_sign_score', ['order_id' => $order_id]);
|
|
512
|
|
- // 恢复 贡献值
|
|
513
|
|
- $this->easterOrder('user_sign_gongxian', ['order_id' => $order_id]);
|
|
514
|
|
- // 恢复 佣金/养老金等
|
|
515
|
|
- $this->easterOrder('user_bill', ['link_id' => $order_id]);
|
|
516
|
|
- // 恢复 公证处
|
|
517
|
|
- $this->easterOrder('gzc_logs', ['link_id' => $order_id]);
|
|
518
|
|
- //恢复用户奖励
|
|
519
|
|
- $this->easterUserAward(['order_id' => $order_id]);
|
|
520
|
|
- Db::commit();
|
|
521
|
|
- } catch (\Exception $e) {
|
|
522
|
|
- Db::rollback();
|
|
523
|
|
- return app('json')->fail('撤回失败: '.$e->getMessage());
|
|
524
|
|
- }
|
|
525
|
|
- Db::name("user_order_recover_records")->insert([//记录恢复的订单
|
|
526
|
|
- 'operation_id' => $adminId,
|
|
527
|
|
- 'order_id' => $order_id,
|
|
528
|
|
- 'mark' => '恢复订单记录'
|
|
529
|
|
- ]);
|
|
530
|
|
- return app('json')->success('撤回成功');
|
|
531
|
|
- }
|
|
532
|
|
- private function easterOrder($table, array $where) //恢复表数据
|
|
533
|
|
- {
|
|
534
|
|
- $backupTable = 'backup_' . $table;
|
|
535
|
|
- $rows = Db::name($backupTable)->where($where)->select()->toArray();
|
|
536
|
|
-
|
|
537
|
|
- if ($rows) {
|
|
538
|
|
- foreach ($rows as &$row) {
|
|
539
|
|
- if (isset($row['del_time'])) unset($row['del_time']);
|
|
540
|
|
- }
|
|
541
|
|
- unset($row);
|
|
542
|
|
- Db::name($table)->insertAll($rows);
|
|
543
|
|
- Db::name($backupTable)->where($where)->delete();
|
|
544
|
|
- }
|
|
545
|
|
- }
|
|
546
|
|
- private function easterUserAward(array $where){ //恢复奖励
|
|
547
|
|
- $row = Db::name('backup_user_change')->where($where)->where('user', 1)->field('pv, vr, score, contribute, annuity,uid')->find();
|
|
548
|
|
- $uid = $row['uid'];
|
|
549
|
|
- $pv = $row['pv'];
|
|
550
|
|
- $vr = $row['vr'];
|
|
551
|
|
- $score= $row['score'];
|
|
552
|
|
- $contribute = $row['contribute'];
|
|
553
|
|
- $annuity = $row['annuity'];
|
|
554
|
|
- Db::name('user') //更新订单用户
|
|
555
|
|
- ->where('uid', $uid)
|
|
556
|
|
- ->update([
|
|
557
|
|
- 'pv' => Db::raw("pv + {$pv}"),
|
|
558
|
|
- 'vr' => Db::raw("vr - {$vr}"),
|
|
559
|
|
- 'score' => Db::raw("score - {$score}"),
|
|
560
|
|
- 'contribute' => Db::raw("contribute + {$contribute}"),
|
|
561
|
|
- 'annuity' => Db::raw("annuity + {$annuity}"),
|
|
562
|
|
- ]);
|
|
563
|
|
- $row2 = Db::name('backup_user_change')->where($where)->where('user', 2)->field('brokerage_price, score, per_contribute, annuity,uid')->find();
|
|
564
|
|
- if ($row2) {
|
|
565
|
|
- $spreadUid = $row2['uid'];
|
|
566
|
|
- $spreadScore = $row2['score'];
|
|
567
|
|
- $per_contribute = $row2['per_contribute'];
|
|
568
|
|
- $spreadAnnuity = $row2['annuity'];
|
|
569
|
|
- $spreadYongJin = $row2['brokerage_price'];
|
|
570
|
|
- Db::name('user') //更新推荐人
|
|
571
|
|
- ->where('uid', $spreadUid)
|
|
572
|
|
- ->update([
|
|
573
|
|
- 'score' => Db::raw("score + {$spreadScore}"),
|
|
574
|
|
- 'contribute' => Db::raw("contribute + {$per_contribute}"),
|
|
575
|
|
- 'annuity' => Db::raw("annuity + {$spreadAnnuity}"),
|
|
576
|
|
- 'brokerage_price' => Db::raw("brokerage_price + {$spreadYongJin}"),
|
|
577
|
|
- 'per_contribute'=> Db::raw("per_contribute + {$per_contribute}"),
|
|
578
|
|
- ]);
|
|
579
|
|
- }
|
|
580
|
|
- $row3 = Db::name('backup_user_change')->where($where)->where('user', 3)->field('brokerage_price,uid')->find();
|
|
581
|
|
- if ($row3) {
|
|
582
|
|
- $spreadUidTwo = $row3['uid']; //第二推荐人
|
|
583
|
|
- $spreadYongJin2 = $row3['brokerage_price'];
|
|
584
|
|
- Db::name('user')
|
|
585
|
|
- ->where('uid', $spreadUidTwo)
|
|
586
|
|
- ->update([
|
|
587
|
|
- 'brokerage_price' => Db::raw("brokerage_price + {$spreadYongJin2}"),
|
|
588
|
|
- ]);
|
|
589
|
|
- }
|
|
590
|
|
- $row4 = Db::name('backup_user_change')->where($where)->where('user', 4)->field('score,uid')->find();
|
|
591
|
|
- if ($row4) {
|
|
592
|
|
- $spreadUidThree = $row4['uid']; //扫码
|
|
593
|
|
- $spreadScore3 = $row4['score'];
|
|
594
|
|
- Db::name('user')
|
|
595
|
|
- ->where('uid', $spreadUidThree)
|
|
596
|
|
- ->update([
|
|
597
|
|
- 'score' => Db::raw("score + {$spreadScore3}"),
|
|
598
|
|
- ]);
|
|
|
506
|
+ $ok = $this->repository->recoverOrderByAdmin($group_order_id, $order_id);
|
|
|
507
|
+ if (!$ok) {
|
|
|
508
|
+ return app('json')->fail('操作失败');
|
|
599
|
509
|
}
|
|
|
510
|
+ return app('json')->success('操作成功');
|
|
|
511
|
+// try {
|
|
|
512
|
+// Db::startTrans();
|
|
|
513
|
+// // 恢复订单相关表
|
|
|
514
|
+// $this->easterOrder('store_order', ['group_order_id' => $group_order_id]);
|
|
|
515
|
+// $this->easterOrder('store_group_order', ['group_order_id' => $group_order_id]);
|
|
|
516
|
+// // 恢复 pv
|
|
|
517
|
+// $this->easterOrder('user_pv_log', ['order_id' => $order_id]);
|
|
|
518
|
+// // 恢复 vr
|
|
|
519
|
+// $this->easterOrder('user_sign_vr', ['order_id' => $order_id]);
|
|
|
520
|
+// // 恢复 积分
|
|
|
521
|
+// $this->easterOrder('user_sign_score', ['order_id' => $order_id]);
|
|
|
522
|
+// // 恢复 贡献值
|
|
|
523
|
+// $this->easterOrder('user_sign_gongxian', ['order_id' => $order_id]);
|
|
|
524
|
+// // 恢复 佣金/养老金等
|
|
|
525
|
+// $this->easterOrder('user_bill', ['link_id' => $order_id]);
|
|
|
526
|
+// // 恢复 公证处
|
|
|
527
|
+// $this->easterOrder('gzc_logs', ['link_id' => $order_id]);
|
|
|
528
|
+// //恢复用户奖励
|
|
|
529
|
+// $this->easterUserAward(['order_id' => $order_id]);
|
|
|
530
|
+// Db::commit();
|
|
|
531
|
+// } catch (\Exception $e) {
|
|
|
532
|
+// Db::rollback();
|
|
|
533
|
+// return app('json')->fail('撤回失败: '.$e->getMessage());
|
|
|
534
|
+// }
|
|
|
535
|
+// Db::name("user_order_recover_records")->insert([//记录恢复的订单
|
|
|
536
|
+// 'operation_id' => $adminId,
|
|
|
537
|
+// 'order_id' => $order_id,
|
|
|
538
|
+// 'mark' => '恢复订单记录'
|
|
|
539
|
+// ]);
|
|
|
540
|
+// return app('json')->success('撤回成功');
|
|
600
|
541
|
}
|
|
|
542
|
+// private function easterOrder($table, array $where) //恢复表数据
|
|
|
543
|
+// {
|
|
|
544
|
+// $backupTable = 'backup_' . $table;
|
|
|
545
|
+// $rows = Db::name($backupTable)->where($where)->select()->toArray();
|
|
|
546
|
+//
|
|
|
547
|
+// if ($rows) {
|
|
|
548
|
+// foreach ($rows as &$row) {
|
|
|
549
|
+// if (isset($row['del_time'])) unset($row['del_time']);
|
|
|
550
|
+// }
|
|
|
551
|
+// unset($row);
|
|
|
552
|
+// Db::name($table)->insertAll($rows);
|
|
|
553
|
+// Db::name($backupTable)->where($where)->delete();
|
|
|
554
|
+// }
|
|
|
555
|
+// }
|
|
|
556
|
+// private function easterUserAward(array $where){ //恢复奖励
|
|
|
557
|
+// $row = Db::name('backup_user_change')->where($where)->where('user', 1)->field('pv, vr, score, contribute, annuity,uid')->find();
|
|
|
558
|
+// $uid = $row['uid'];
|
|
|
559
|
+// $pv = $row['pv'];
|
|
|
560
|
+// $vr = $row['vr'];
|
|
|
561
|
+// $score= $row['score'];
|
|
|
562
|
+// $contribute = $row['contribute'];
|
|
|
563
|
+// $annuity = $row['annuity'];
|
|
|
564
|
+// Db::name('user') //更新订单用户
|
|
|
565
|
+// ->where('uid', $uid)
|
|
|
566
|
+// ->update([
|
|
|
567
|
+// 'pv' => Db::raw("pv + {$pv}"),
|
|
|
568
|
+// 'vr' => Db::raw("vr - {$vr}"),
|
|
|
569
|
+// 'score' => Db::raw("score - {$score}"),
|
|
|
570
|
+// 'contribute' => Db::raw("contribute + {$contribute}"),
|
|
|
571
|
+// 'annuity' => Db::raw("annuity + {$annuity}"),
|
|
|
572
|
+// ]);
|
|
|
573
|
+// $row2 = Db::name('backup_user_change')->where($where)->where('user', 2)->field('brokerage_price, score, per_contribute, annuity,uid')->find();
|
|
|
574
|
+// if ($row2) {
|
|
|
575
|
+// $spreadUid = $row2['uid'];
|
|
|
576
|
+// $spreadScore = $row2['score'];
|
|
|
577
|
+// $per_contribute = $row2['per_contribute'];
|
|
|
578
|
+// $spreadAnnuity = $row2['annuity'];
|
|
|
579
|
+// $spreadYongJin = $row2['brokerage_price'];
|
|
|
580
|
+// Db::name('user') //更新推荐人
|
|
|
581
|
+// ->where('uid', $spreadUid)
|
|
|
582
|
+// ->update([
|
|
|
583
|
+// 'score' => Db::raw("score + {$spreadScore}"),
|
|
|
584
|
+// 'contribute' => Db::raw("contribute + {$per_contribute}"),
|
|
|
585
|
+// 'annuity' => Db::raw("annuity + {$spreadAnnuity}"),
|
|
|
586
|
+// 'brokerage_price' => Db::raw("brokerage_price + {$spreadYongJin}"),
|
|
|
587
|
+// 'per_contribute'=> Db::raw("per_contribute + {$per_contribute}"),
|
|
|
588
|
+// ]);
|
|
|
589
|
+// }
|
|
|
590
|
+// $row3 = Db::name('backup_user_change')->where($where)->where('user', 3)->field('brokerage_price,uid')->find();
|
|
|
591
|
+// if ($row3) {
|
|
|
592
|
+// $spreadUidTwo = $row3['uid']; //第二推荐人
|
|
|
593
|
+// $spreadYongJin2 = $row3['brokerage_price'];
|
|
|
594
|
+// Db::name('user')
|
|
|
595
|
+// ->where('uid', $spreadUidTwo)
|
|
|
596
|
+// ->update([
|
|
|
597
|
+// 'brokerage_price' => Db::raw("brokerage_price + {$spreadYongJin2}"),
|
|
|
598
|
+// ]);
|
|
|
599
|
+// }
|
|
|
600
|
+// $row4 = Db::name('backup_user_change')->where($where)->where('user', 4)->field('score,uid')->find();
|
|
|
601
|
+// if ($row4) {
|
|
|
602
|
+// $spreadUidThree = $row4['uid']; //扫码
|
|
|
603
|
+// $spreadScore3 = $row4['score'];
|
|
|
604
|
+// Db::name('user')
|
|
|
605
|
+// ->where('uid', $spreadUidThree)
|
|
|
606
|
+// ->update([
|
|
|
607
|
+// 'score' => Db::raw("score + {$spreadScore3}"),
|
|
|
608
|
+// ]);
|
|
|
609
|
+// }
|
|
|
610
|
+// }
|
|
601
|
611
|
}
|