ソースを参照

后台-撤回订单-删除旧代码,删除没有使用的备份公证处dao

Xpy 7 ヶ月 前
コミット
1058c8a0df

+ 14 - 0
app/common/dao/gzc/GzcLogDao.php

@@ -11,4 +11,18 @@ class GzcLogDao extends BaseDao
11 11
     {
12 12
         return GzcLog::class;
13 13
     }
14
+    /**
15
+     * 公证处推送记录失效
16
+     */
17
+    public function loseGzcLog($orderId)
18
+    {
19
+        return $this->getModel()::getDB()->where('link_id',$orderId)->update(['gzc' => 0,'success' => 0]);
20
+    }
21
+    /**
22
+     * 恢复正常
23
+     */
24
+    public function recoverGzcLogs($orderId)
25
+    {
26
+        return $this->getModel()::getDB()->where('link_id',$orderId)->update(['gzc' => 1,'success' => 1]);
27
+    }
14 28
 }

+ 27 - 0
app/common/dao/user/UserOrderKillOrRecoverRecordsDao.php

@@ -0,0 +1,27 @@
1
+<?php
2
+
3
+namespace app\common\dao\user;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\user\UserOrderKillOrRecoverRecords;
7
+
8
+class UserOrderKillOrRecoverRecordsDao extends BaseDao
9
+{
10
+    protected function getModel(): string
11
+    {
12
+        return UserOrderKillOrRecoverRecords::class;
13
+    }
14
+
15
+    /**
16
+     * 插入撤销或恢复订单记录
17
+     */
18
+    public function insertKillOrRecoverRecord(array $data)
19
+    {
20
+        try {
21
+            return $this->getModel()::getDB()->insert($data);
22
+        } catch (\Exception $e) {
23
+            return false;
24
+        }
25
+    }
26
+}
27
+

+ 19 - 0
app/common/model/user/UserOrderKillOrRecoverRecords.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserOrderKillOrRecoverRecords extends BaseModel
8
+{
9
+    public static function tablePk(): ?string//hajimi
10
+    {
11
+        return 'id';
12
+    }
13
+
14
+    public static function tableName(): string
15
+    {
16
+        return 'user_order_kill_or_recover_records';
17
+    }
18
+}
19
+

+ 19 - 0
app/common/model/user/UserOrderKillRecord.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserOrderKillRecord extends BaseModel
8
+{
9
+    public static function tablePk(): ?string//hajimi
10
+    {
11
+        return 'id';
12
+    }
13
+
14
+    public static function tableName(): string
15
+    {
16
+        return 'user_order_kill_records';
17
+    }
18
+}
19
+

+ 13 - 185
app/common/repositories/store/order/StoreOrderRepository.php

@@ -11,6 +11,7 @@
11 11
 namespace app\common\repositories\store\order;
12 12
 
13 13
 
14
+use app\common\dao\gzc\GzcLogDao;
14 15
 use app\common\dao\store\order\StoreOrderDao;
15 16
 use app\common\dao\user\UserDao;
16 17
 use app\common\dao\user\UserPvLogDao;
@@ -19,7 +20,6 @@ use app\common\dao\user\UserSignScoreDao;
19 20
 use app\common\dao\user\UserSignGongxianDao;
20 21
 use app\common\dao\user\UserBillDao;
21 22
 use app\common\dao\user\UserOrderKillOrRecoverRecordsDao;
22
-use app\common\dao\backup\BackupGzcLogsDao;
23 23
 use app\common\dao\backup\BackupUserDao;
24 24
 use app\common\dao\backup\BackupUserChangeDao;
25 25
 use app\common\dao\util\TableOpsDao;
@@ -164,8 +164,8 @@ class StoreOrderRepository extends BaseRepository
164 164
     private $userSignGongxianDao;
165 165
     /** @var UserBillDao */
166 166
     private $userBillDao;
167
-    /** @var backupGzcLogsDao */
168
-    private $backupGzcLogsDao;
167
+    /**@var GzcLogDao */
168
+    private $gzcLogDao;
169 169
     /** @var backupUserDao */
170 170
     private $backupUserDao;
171 171
     /** @var BackupUserChangeDao */
@@ -197,7 +197,7 @@ class StoreOrderRepository extends BaseRepository
197 197
         $this->userSignScoreDao = app()->make(UserSignScoreDao::class);
198 198
         $this->userSignGongxianDao = app()->make(UserSignGongxianDao::class);
199 199
         $this->userBillDao = app()->make(UserBillDao::class);
200
-        $this->backupGzcLogsDao = app()->make(BackupGzcLogsDao::class);
200
+        $this->gzcLogDao = app()->make(GzcLogDao::class);
201 201
         $this->backupUserDao = app()->make(BackupUserDao::class);
202 202
         $this->backupUserChangeDao = app()->make(BackupUserChangeDao::class);
203 203
         $this->tableOpsDao = app()->make(TableOpsDao::class);
@@ -12478,13 +12478,6 @@ class StoreOrderRepository extends BaseRepository
12478 12478
         }
12479 12479
         try {
12480 12480
             Db::startTrans();
12481
-            //$spreadUid = Db::name('user')->where('uid', $uid)->value('spread_uid');
12482
-            //$pv = $this->getTableValue('user_pv_log', [['order_id', '=', $orderId], ['status', '=', 1]], 'pv');
12483
-//            $payVr = $this->getTableValue('user_sign_vr', [['order_id', '=', $orderId], ['type', '=', 2]], 'number');
12484
-//            $score = $this->getTableValue('user_sign_score', [['order_id', '=', $orderId], ['status', '=', 1], ['source_type', '=', 3], ['uid', '=', $uid], ['pm', '=', 1]], 'reward_socre');
12485
-//            $payScore = $this->getTableValue('user_sign_score', [['order_id', '=', $orderId], ['status', '=', 1], ['pm', '=', 2], ['uid', '=', $uid]], 'reward_socre');
12486
-//            $gongXian = $this->getTableValue('user_sign_gongxian', [['order_id', '=', $orderId], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $uid]], 'number');
12487
-//            $yangLaoJin = $this->getTableValue('user_bill', [['link_id', '=', $orderId], ['status', '=', 1], ['pm', '=', 1], ['uid', '=', $uid]], 'number');
12488 12481
             //查找是否有推荐人
12489 12482
             $spreadUid = $this->userDao->getSpreadUidFromUid($uid);
12490 12483
             //取出pv
@@ -12499,28 +12492,6 @@ class StoreOrderRepository extends BaseRepository
12499 12492
             // 养老金
12500 12493
             $yangLaoJin = $this->userBillDao->getYanglaoFromUidOrderId($orderId, $uid);
12501 12494
             if ($spreadUid) {
12502
-                //如果有推荐人就执行
12503
-//                $spreadScore = $this->getTableValue('user_sign_score', [['order_id', '=', $orderId], ['uid', '=', $spreadUid], ['status', '=', 1]], 'reward_socre');
12504
-//                $spreadGongXian = $this->getTableValue('user_sign_gongxian', [['order_id', '=', $orderId], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $spreadUid]], 'number');
12505
-//                $spreadYlj = $this->getTableValue('user_bill', [['link_id', '=', $orderId], ['commission_type', '=', 5], ['uid', '=', $spreadUid]], 'number');
12506
-//                $spreadYongJin = $this->getTableValue('user_bill', [['link_id', '=', $orderId], ['commission_type', '=', 3], ['uid', '=', $spreadUid]], 'number');
12507
-//                $spreadUser = Db::name('user')->where('uid', $spreadUid)->find();
12508
-//                Db::name('backup_user')->insert($spreadUser);
12509
-                //                Db::name('user')->where('uid', $spreadUid)->update([
12510
-                //                    'score' => Db::raw("score - {$spreadScore}"),
12511
-                //                    'per_contribute' => Db::raw("per_contribute - {$spreadGongXian}"),
12512
-                //                    'brokerage_price' => Db::raw("brokerage_price - {$spreadYongJin}"),
12513
-                //                    'annuity' => Db::raw("annuity - {$spreadYlj}"),
12514
-                //                ]);
12515
-//                Db::name('backup_user_change')->insert([
12516
-//                    'uid' => $spreadUid,
12517
-//                    'order_id' => $orderId,
12518
-//                    'score' => $spreadScore ?: 0,
12519
-//                    'per_contribute' => $spreadGongXian ?: 0,
12520
-//                    'brokerage_price' => $spreadYongJin ?: 0,
12521
-//                    'user' => 2,
12522
-//                ]);
12523
-
12524 12495
                 $spreadScore = $this->userSignScoreDao->getRewardScoreFromStatusUidOrderId($orderId, $spreadUid);//积分
12525 12496
                 $spreadGongXian = $this->userSignGongxianDao->getGongxianFromUidOrderId($orderId, $spreadUid);//贡献
12526 12497
                 $spreadYlj = $this->userBillDao->getYljFromCommissionTypeUidOrderId($orderId, $spreadUid);//养老金
@@ -12534,8 +12505,8 @@ class StoreOrderRepository extends BaseRepository
12534 12505
                     'brokerage_price' => Db::raw("brokerage_price - {$spreadYongJin}"),
12535 12506
                     'annuity' => Db::raw("annuity - {$spreadYlj}"),
12536 12507
                 ];
12537
-                $this->userDao->saveAll($userUpdateList);
12538
-                $saveSpreaadUserChangeList = [//将奖励数目进行备份
12508
+                $this->userDao->saveAll($userUpdateList);//执行
12509
+                $saveSpreadUserChangeList = [//将奖励数目进行备份
12539 12510
                     'uid' => $spreadUid,
12540 12511
                     'order_id' => $orderId,
12541 12512
                     'score' => $spreadScore ?: 0,
@@ -12543,16 +12514,12 @@ class StoreOrderRepository extends BaseRepository
12543 12514
                     'brokerage_price' => $spreadYongJin ?: 0,
12544 12515
                     'user' => 2,
12545 12516
                 ];
12546
-                $this->backupUserChangeDao->saveAll($saveSpreaadUserChangeList);
12517
+                $this->backupUserChangeDao->saveAll($saveSpreadUserChangeList);
12547 12518
             }
12548
-//            $smSpreadUid = $this->getTableValue('user_sign_score', [['order_id', '=', $orderId], ['mark', 'like', '%扫码%'], ['status', '=', 1]], 'uid');
12549
-//            $smSpreadScore = $this->getTableValue('user_sign_score', [['order_id', '=', $orderId], ['uid', '=', $smSpreadUid], ['status', '=', 1]], 'reward_socre');
12550
-//            $spreadYongJinTwoUid = $this->getTableValue('user_bill', [['link_id', '=', $orderId], ['commission_type', '=', 3], ['uid', 'not in', [$uid, $spreadUid]]], 'uid');
12551
-//            $spreadYongJinTwo = $this->getTableValue('user_bill', [['link_id', '=', $orderId], ['commission_type', '=', 3], ['uid', '=', $spreadYongJinTwoUid]], 'number');
12552 12519
             $smSpreadUid = $this->userSignScoreDao->getUidFromMarkLikeStatusOrderId($orderId);//查找扫码消费的uid
12553
-            $smSpreadScore = $this->userSignScoreDao->getScoreFromUidOrderId($orderId,$smSpreadUid);
12554
-            $spreadYongJinTwoUid = $this->userBillDao->getYongjinTwoUidFromOrderId($orderId, $uid, $spreadUid);
12555
-            $spreadYongJinTwo = $this->userBillDao->getYongjinFromCommissionTypeUidOrderId($orderId, $spreadYongJinTwoUid);
12520
+            $smSpreadScore = $this->userSignScoreDao->getScoreFromUidOrderId($orderId,$smSpreadUid);//扫码消费积分
12521
+            $spreadYongJinTwoUid = $this->userBillDao->getYongjinTwoUidFromOrderId($orderId, $uid, $spreadUid);//第二推荐
12522
+            $spreadYongJinTwo = $this->userBillDao->getYongjinFromCommissionTypeUidOrderId($orderId, $spreadYongJinTwoUid);//第二推荐佣金
12556 12523
             $useScore = $payScore - $score;//将花费的积分减去购买获得的积分
12557 12524
 //            $user = Db::name('user')->where('uid', $uid)->find();
12558 12525
 //            Db::name('backup_user')->insert($user);//用户信息备份,大概也是不需要
@@ -12565,23 +12532,6 @@ class StoreOrderRepository extends BaseRepository
12565 12532
                 'annuity' => Db::raw("annuity - {$yangLaoJin}"),
12566 12533
             ];
12567 12534
             $this->userDao->saveAll($updateUserOrderAwardList);
12568
-//            Db::name('user')->where('uid', $uid)->update([
12569
-//                'pv' => Db::raw("pv - {$pv}"),
12570
-//                'vr' => Db::raw("vr + {$payVr}"),
12571
-//                'score' => Db::raw("score + {$uscore}"),
12572
-//                'contribute' => Db::raw("contribute - {$gongXian}"),
12573
-//                'annuity' => Db::raw("annuity - {$yangLaoJin}"),
12574
-//            ]);
12575
-//            Db::name('backup_user_change')->insert([
12576
-//                'uid' => $uid,
12577
-//                'order_id' => $orderId,
12578
-//                'pv' => $pv ?: 0,
12579
-//                'vr' => $payVr ?: 0,
12580
-//                'score' => $uscore ?: 0,
12581
-//                'contribute' => $gongXian ?: 0,
12582
-//                'annuity' => $yangLaoJin ?: 0,
12583
-//                'user' => 1,
12584
-//            ]);
12585 12535
             $saveUserChangeList = [
12586 12536
                 'uid' => $uid,
12587 12537
                 'order_id' => $orderId,
@@ -12594,15 +12544,6 @@ class StoreOrderRepository extends BaseRepository
12594 12544
             ];
12595 12545
             $this->backupUserChangeDao->saveAll($saveUserChangeList);
12596 12546
             if ($spreadYongJinTwoUid) {
12597
-//                $spreadUserTwo = Db::name('user')->where('uid', $spreadYongJinTwoUid)->find();
12598
-//                Db::name('backup_user')->insert($spreadUserTwo);//同理,不需要备份原user表数
12599
-///               Db::name('user')->where('uid', $spreadYongJinTwoUid)->dec('brokerage_price', $spreadYongJinTwo)->update();
12600
-                ///                 Db::name('backup_user_change')->insert([
12601
-                ////                    'uid' => $spreadYongJinTwoUid,
12602
-                ////                    'order_id' => $orderId,
12603
-                ////                    'brokerage_price' => $spreadYongJinTwo ?: 0,
12604
-                ////                    'user' => 3,
12605
-                ////                ]);
12606 12547
                 $updateSpreadUserTwoList = [
12607 12548
                     'uid' => $spreadYongJinTwoUid,
12608 12549
                     'brokerage_price' => $spreadYongJinTwo
@@ -12617,15 +12558,6 @@ class StoreOrderRepository extends BaseRepository
12617 12558
                 $this->backupUserChangeDao->saveAll($saveSpreadUserTwoChangeList);
12618 12559
             }
12619 12560
             if ($smSpreadUid) {
12620
-//                $smUserTwo = Db::name('user')->where('uid', $smSpreadUid)->find();
12621
-//                Db::name('backup_user')->insert($smUserTwo);//同理
12622
-//                Db::name('user')->where('uid', $smSpreadUid)->dec('score', $smSpreadScore)->update();
12623
-//                Db::name('backup_user_change')->insert([
12624
-//                    'uid' => $smSpreadUid,
12625
-//                    'order_id' => $orderId,
12626
-//                    'score' => $smSpreadScore ?: 0,
12627
-//                    'user' => 4,
12628
-//                ]);
12629 12561
                 $updateSpreadSMUserList = [
12630 12562
                     'uid' => $smSpreadUid,
12631 12563
                     'score' => $smSpreadScore
@@ -12639,14 +12571,6 @@ class StoreOrderRepository extends BaseRepository
12639 12571
                 ];
12640 12572
                 $this->backupUserChangeDao->saveAll($saveSpreadSMUserChangeList);
12641 12573
             }
12642
-            // $this->backupAndDelete('store_order', ['group_order_id' => $groupOrderId]);
12643
-            // $this->backupAndDelete('store_group_order', ['group_order_id' => $groupOrderId]);
12644
-            // $this->backupAndDelete('user_pv_log', ['order_id' => $orderId]);
12645
-            // $this->backupAndDelete('user_sign_vr', ['order_id' => $orderId]);
12646
-            // $this->backupAndDelete('user_sign_score', ['order_id' => $orderId]);
12647
-            // $this->backupAndDelete('user_sign_gongxian', ['order_id' => $orderId]);
12648
-            // $this->backupAndDelete('user_bill', ['link_id' => $orderId]);
12649
-            // $this->backupAndDelete('gzc_logs', ['link_id' => $orderId]);
12650 12574
             $ops = [
12651 12575
                 ['store_order', ['group_order_id' => $groupOrderId]],
12652 12576
                 ['store_group_order', ['group_order_id' => $groupOrderId]],
@@ -12657,18 +12581,13 @@ class StoreOrderRepository extends BaseRepository
12657 12581
                 ['user_bill', ['link_id' => $orderId]],
12658 12582
                 ['gzc_logs', ['link_id' => $orderId]],
12659 12583
             ];
12660
-            $this->tableOpsDao->backupAndDeleteBatch($ops);
12584
+            $this->tableOpsDao->backupAndDeleteBatch($ops);//备份数据以及删除源数据
12585
+            $this->gzcLogDao->loseGzcLog($orderId);//公证处设置失效
12661 12586
             Db::commit();
12662 12587
         } catch (\Exception $e) {
12663 12588
             Db::rollback();
12664 12589
             return false;
12665 12590
         }
12666
-        // Db::name('user_order_kill_records')->insert([
12667
-        //     'operation_id' => $adminId,
12668
-        //     'uid' => $uid,
12669
-        //     'order_id' => $orderId,
12670
-        //     'mark' => '后台管理员撤销订单记录',
12671
-        // ]);
12672 12591
         $this->userOrderKillOrRecoverRecordsDao->insertKillOrRecoverRecord([
12673 12592
             'operation_id' => $adminId,
12674 12593
             'uid' => $uid,
@@ -12689,14 +12608,6 @@ class StoreOrderRepository extends BaseRepository
12689 12608
         try {
12690 12609
             /** @var easterOrder $model */
12691 12610
             Db::startTrans();
12692
-            // $this->easterOrder('store_order', ['group_order_id' => $groupOrderId]);
12693
-            // $this->easterOrder('store_group_order', ['group_order_id' => $groupOrderId]);
12694
-            // $this->easterOrder('user_pv_log', ['order_id' => $orderId]);
12695
-            // $this->easterOrder('user_sign_vr', ['order_id' => $orderId]);
12696
-            // $this->easterOrder('user_sign_score', ['order_id' => $orderId]);
12697
-            // $this->easterOrder('user_sign_gongxian', ['order_id' => $orderId]);
12698
-            // $this->easterOrder('user_bill', ['link_id' => $orderId]);
12699
-            // $this->easterOrder('gzc_logs', ['link_id' => $orderId]);
12700 12611
             $restoreOps = [
12701 12612
                 ['store_order', ['group_order_id' => $groupOrderId]],
12702 12613
                 ['store_group_order', ['group_order_id' => $groupOrderId]],
@@ -12709,16 +12620,12 @@ class StoreOrderRepository extends BaseRepository
12709 12620
             ];
12710 12621
             $this->tableOpsDao->restoreBatch($restoreOps);
12711 12622
             $this->easterUserAward(['order_id' => $orderId]);
12623
+            $this->gzcLogDao->recoverGzcLogs($orderId);//公证处设置有效
12712 12624
             Db::commit();
12713 12625
         } catch (\Exception $e) {
12714 12626
             Db::rollback();
12715 12627
             return false;
12716 12628
         }
12717
-//        Db::name('user_order_recover_records')->insert([
12718
-//            'operation_id' => $adminId,
12719
-//            'order_id' => $orderId,
12720
-//            'mark' => '恢复订单记录',
12721
-//        ]);
12722 12629
         $this->userOrderKillOrRecoverRecordsDao->insertKillOrRecoverRecord([
12723 12630
             'operation_id' => null,
12724 12631
             'uid' => null,
@@ -12727,85 +12634,6 @@ class StoreOrderRepository extends BaseRepository
12727 12634
         ]);
12728 12635
         return true;
12729 12636
     }
12730
-//    private function backupAndDelete(string $table, array $where): void
12731
-//    {
12732
-//        $backupTable = 'backup_' . $table;
12733
-//        $rows = Db::name($table)->where($where)->select()->toArray();
12734
-//        if ($rows) {
12735
-//            Db::name($backupTable)->insertAll($rows);
12736
-//            Db::name($table)->where($where)->delete();
12737
-//        }
12738
-//    }
12739
-//
12740
-//    private function getTableValue(string $table, array $where, string $field, $default = 0)
12741
-//    {
12742
-//        $value = Db::name($table)->where($where)->value($field);
12743
-//        return $value ?? $default;
12744
-//    }
12745
-//
12746
-//    private function easterOrder(string $table, array $where): void
12747
-//    {
12748
-//        $backupTable = 'backup_' . $table;
12749
-//        $rows = Db::name($backupTable)->where($where)->select()->toArray();
12750
-//        if ($rows) {
12751
-//            foreach ($rows as &$row) {
12752
-//                if (isset($row['del_time'])) unset($row['del_time']);
12753
-//            }
12754
-//            unset($row);
12755
-//            Db::name($table)->insertAll($rows);
12756
-//            Db::name($backupTable)->where($where)->delete();
12757
-//        }
12758
-//    }
12759
-//    private function easterUserAward(array $where): void
12760
-//    {
12761
-//        $row = Db::name('backup_user_change')->where($where)->where('user', 1)->field('pv, vr, score, contribute, annuity,uid')->find();
12762
-//        if ($row) {
12763
-//            $uid = $row['uid'];
12764
-//            $pv = $row['pv'];
12765
-//            $vr = $row['vr'];
12766
-//            $score = $row['score'];
12767
-//            $contribute = $row['contribute'];
12768
-//            $annuity = $row['annuity'];
12769
-//            Db::name('user')->where('uid', $uid)->update([
12770
-//                'pv' => Db::raw("pv + {$pv}"),
12771
-//                'vr' => Db::raw("vr - {$vr}"),
12772
-//                'score' => Db::raw("score - {$score}"),
12773
-//                'contribute' => Db::raw("contribute + {$contribute}"),
12774
-//                'annuity' => Db::raw("annuity + {$annuity}"),
12775
-//            ]);
12776
-//        }
12777
-//        $row2 = Db::name('backup_user_change')->where($where)->where('user', 2)->field('brokerage_price, score, per_contribute, annuity,uid')->find();
12778
-//        if ($row2) {
12779
-//            $spreadUid = $row2['uid'];
12780
-//            $spreadScore = $row2['score'];
12781
-//            $per_contribute = $row2['per_contribute'];
12782
-//            $spreadAnnuity = $row2['annuity'];
12783
-//            $spreadYongJin = $row2['brokerage_price'];
12784
-//            Db::name('user')->where('uid', $spreadUid)->update([
12785
-//                'score' => Db::raw("score + {$spreadScore}"),
12786
-//                'contribute' => Db::raw("contribute + {$per_contribute}"),
12787
-//                'annuity' => Db::raw("annuity + {$spreadAnnuity}"),
12788
-//                'brokerage_price' => Db::raw("brokerage_price + {$spreadYongJin}"),
12789
-//                'per_contribute' => Db::raw("per_contribute + {$per_contribute}"),
12790
-//            ]);
12791
-//        }
12792
-//        $row3 = Db::name('backup_user_change')->where($where)->where('user', 3)->field('brokerage_price,uid')->find();
12793
-//        if ($row3) {
12794
-//            $spreadUidTwo = $row3['uid'];
12795
-//            $spreadYongJin2 = $row3['brokerage_price'];
12796
-//            Db::name('user')->where('uid', $spreadUidTwo)->update([
12797
-//                'brokerage_price' => Db::raw("brokerage_price + {$spreadYongJin2}"),
12798
-//            ]);
12799
-//        }
12800
-//        $row4 = Db::name('backup_user_change')->where($where)->where('user', 4)->field('score,uid')->find();
12801
-//        if ($row4) {
12802
-//            $spreadUidThree = $row4['uid'];
12803
-//            $spreadScore3 = $row4['score'];
12804
-//            Db::name('user')->where('uid', $spreadUidThree)->update([
12805
-//                'score' => Db::raw("score + {$spreadScore3}"),
12806
-//            ]);
12807
-//        }
12808
-//    }
12809 12637
     public function easterUserAward(array $where): void
12810 12638
     {
12811 12639
         $orderId = $where['order_id'];

+ 0 - 234
app/controller/admin/order/Order.php

@@ -353,147 +353,12 @@ class Order extends BaseController
353 353
             return app('json')->fail('操作失败');
354 354
         }
355 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('操作成功');
474 356
     }
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
-//    }
490 357
     /**
491 358
      * 展示撤回订单列表,恢复订单
492 359
      */
493 360
     public function killOrderLst()  //撤回订单的列表
494 361
     {
495
-//        $query = Db::name('backup_store_order')->paginate(20)->toArray();
496
-//        return app('json')->success($query, '获取成功');
497 362
         $list = $this->repository->getKillOrderList();
498 363
         return app('json')->success($list, '获取成功');
499 364
     }
@@ -508,104 +373,5 @@ class Order extends BaseController
508 373
             return app('json')->fail('操作失败');
509 374
         }
510 375
         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('撤回成功');
541 376
     }
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
-//    }
611 377
 }