Просмотр исходного кода

计划任务-修复养老金进入公证处记录

sunxbiao 1 год назад
Родитель
Сommit
9529ba67e7

+ 40 - 2
app/command/GzcAddByBillCommand.php

@@ -18,7 +18,45 @@ class GzcAddByBillCommand extends Command
18 18
     protected function execute(Input $input, Output $output)
19 19
     {
20 20
         $output->writeln('定时任务执行中...');
21
-        $this->billGzcAdd();
21
+        // $this->billGzcAdd();
22
+
23
+        $gzcLogList = Db::name("gzc_logs")
24
+            ->where('link_id', '=', 0)
25
+            ->select()
26
+            ->toArray();
27
+        $orderSnList = array_column($gzcLogList, 'out_trade_no');
28
+        $userBillList = Db::name('user_bill')
29
+            ->where('status', 1)
30
+            ->where('commission_type', 5)
31
+            ->whereIn('order_sn', $orderSnList)
32
+            ->select()
33
+            ->toArray();
34
+        $userBillMap = [];
35
+        foreach ($userBillList as $key => $value) {
36
+            $userBillMap[$value['order_sn'] . '_' . $value['uid'] . '_' . $value['number']] = [
37
+                'bill_id' => $value['bill_id'],
38
+                'type_shop' => $value['type_shop']
39
+            ];
40
+        }
41
+        unset($userBillList);
42
+        $str = '';
43
+        foreach ($gzcLogList as $value) {
44
+            if (isset($userBillMap[$value['out_trade_no'] . '_' . $value['uid'] . '_' . $value['pension']])) {
45
+                $update = [
46
+                    'link_id' => $userBillMap[$value['out_trade_no'] . '_' . $value['uid'] . '_' . $value['pension']]['bill_id'],
47
+                    'order_type' => $userBillMap[$value['out_trade_no'] . '_' . $value['uid'] . '_' . $value['pension']]['type_shop'],
48
+                ];
49
+                if (empty($value['platform_no'])) {
50
+                    $update['platform_no'] = 'IN10' . (int)(microtime(true) * 1000) . mt_rand(10000, 99999);
51
+                }
52
+                Db::name("gzc_logs")
53
+                    ->where('id', '=', $value['id'])
54
+                    ->update($update);
55
+                $str .= $value['id'] . '、';
56
+            }
57
+        }
58
+        echo $str;
59
+        // $gzcLogList = Db::query('SELECT out_trade_no, order_type, uid, pension FROM rrx_gzc_logs GROUP BY out_trade_no, order_type, uid, pension HAVING COUNT(*) > 1');
22 60
         $output->writeln('定时任务执行完成');
23 61
     }
24 62
 
@@ -30,7 +68,7 @@ class GzcAddByBillCommand extends Command
30 68
         // 1. 使用chunk分批处理
31 69
         Db::name('user_bill')
32 70
             ->where('status', 1)
33
-            ->where('is_gzc', 0)
71
+            ->where('gzc', 0)
34 72
             ->where('commission_type', 5)
35 73
             ->whereNotIn('uid', $testUserIdList)
36 74
             ->chunk(100, function ($bills) {

+ 21 - 18
app/common/repositories/store/order/StoreOrderRepository.php

@@ -9629,23 +9629,6 @@ class StoreOrderRepository extends BaseRepository
9629 9629
                         $sm_status = 1;
9630 9630
                         Db::name('store_order')->where("order_id", $order_id)->update(['gzc' => 1]);
9631 9631
 
9632
-                        //添加养老金到公证处日志
9633
-                        $ylj_data_log = [
9634
-                            'user_name' => $get_cer_datas['user_name'],
9635
-                            "mobile" => $get_cer_datas['mobile'],
9636
-                            "user_card" => $get_cer_datas['user_card'],//身份证
9637
-                            "pension" => $num,//养老金额度
9638
-                            "out_trade_no" => $order_from_mer['order_sn'],//订单号
9639
-                            "account_type" =>  $pay_type,//支付方式(3:微信,4:组合)
9640
-                            "order_type" => 0,//订单类型(2:)
9641
-                            "pay_time" => date('Y-m-d H:i:s'),
9642
-                            "create_time" => date('Y-m-d H:i:s'),
9643
-                            "update_time" => date('Y-m-d H:i:s'),
9644
-                            "uid" => $uid,
9645
-                        ];
9646
-
9647
-                        Db::name('gzc_logs')->insert($ylj_data_log);
9648
-
9649 9632
                     }
9650 9633
                 }
9651 9634
 
@@ -9689,6 +9672,7 @@ class StoreOrderRepository extends BaseRepository
9689 9672
             'order_type' => 1,//1自营  2 第三方  订单类型
9690 9673
             'is_red_brokerage' => 0,//1红积分对冲佣金 0正常佣金
9691 9674
             'gzc' => $sm_status,//养老金是否已进入公证处log表0:未进入。1:已进入
9675
+            'is_gzc' => $sm_status,//0:未发起 1:已发起 2:已成功
9692 9676
             'take_time' => $take_time,//结算时间
9693 9677
             'district_id' => '',//
9694 9678
             'street_id' => '',//
@@ -9696,7 +9680,26 @@ class StoreOrderRepository extends BaseRepository
9696 9680
 
9697 9681
         ];
9698 9682
 
9699
-        Db::name('user_bill')->insert($bill);
9683
+        $bill_id = Db::name('user_bill')->insertGetId($bill);
9684
+        if ($sm_status == 1) {
9685
+            //添加养老金到公证处日志
9686
+            $ylj_data_log = [
9687
+                'user_name' => $get_cer_datas['user_name'],
9688
+                "mobile" => $get_cer_datas['mobile'],
9689
+                "user_card" => $get_cer_datas['user_card'],//身份证
9690
+                "pension" => $num,//养老金额度
9691
+                "out_trade_no" => $order_from_mer['order_sn'],//订单号
9692
+                "account_type" => $pay_type,//支付方式(3:微信,4:组合)
9693
+                "order_type" => 0,//订单类型(2:)
9694
+                "pay_time" => date('Y-m-d H:i:s'),
9695
+                "create_time" => date('Y-m-d H:i:s'),
9696
+                "update_time" => date('Y-m-d H:i:s'),
9697
+                "uid" => $uid,
9698
+                "platform_no" => 'IN10' . (int)(microtime(true) * 1000) . mt_rand(10000, 99999),
9699
+                "link_id" => $bill_id
9700
+            ];
9701
+            Db::name('gzc_logs')->insert($ylj_data_log);
9702
+        }
9700 9703
     }
9701 9704
 
9702 9705
     //添加复购金

+ 23 - 21
app/controller/api/Notify.php

@@ -1728,25 +1728,7 @@ class Notify
1728 1728
                         $sm_status = 1;
1729 1729
                         $ds = 1;
1730 1730
                         Db::name('store_order')->where("order_id", $order_id)->update(['gzc' => 1]);
1731
-
1732
-                        //添加养老金到公证处日志
1733
-                        $ylj_data_log = [
1734
-                            'user_name' => $get_cer_datas['user_name'],
1735
-                            "mobile" => $get_cer_datas['mobile'],
1736
-                            "user_card" => $get_cer_datas['user_card'],//身份证
1737
-                            "pension" => $num,//养老金额度
1738
-                            "out_trade_no" =>  $order_from_mer['order_sn'],//订单号
1739
-                            "account_type" =>  $pay_type,//支付方式(3:微信,4:组合)
1740
-                            "order_type" => 0,//订单类型(2:)
1741
-                            "pay_time" => date('Y-m-d H:i:s'),
1742
-                            "create_time" => date('Y-m-d H:i:s'),
1743
-                            "update_time" => date('Y-m-d H:i:s'),
1744
-                            "uid" => $uid,
1745
-                        ];
1746
-
1747
-                        Db::name('gzc_logs')->insert($ylj_data_log);
1748
-
1749
-                    } 
1731
+                    }
1750 1732
                 }
1751 1733
             }
1752 1734
             $ds = 1;
@@ -1787,6 +1769,7 @@ class Notify
1787 1769
             'order_type'=>1,//1自营  2 第三方  订单类型
1788 1770
             'is_red_brokerage'=>0,//1红积分对冲佣金 0正常佣金
1789 1771
             'gzc'=> $sm_status,//养老金是否已进入公证处log表0:未进入。1:已进入
1772
+            'is_gzc' => $sm_status,//0:未发起 1:已发起 2:已成功
1790 1773
             'take_time'=>$take_time,//结算时间
1791 1774
             'district_id'=>'',//
1792 1775
             'street_id'=>'',//
@@ -1794,8 +1777,27 @@ class Notify
1794 1777
 
1795 1778
         ];
1796 1779
 
1797
-        Db::name('user_bill')->insert($bill);
1798
-        
1780
+        $bill_id = Db::name('user_bill')->insertGetId($bill);
1781
+
1782
+        if ($sm_status == 1) {
1783
+            //添加养老金到公证处日志
1784
+            $ylj_data_log = [
1785
+                'user_name' => $get_cer_datas['user_name'],
1786
+                "mobile" => $get_cer_datas['mobile'],
1787
+                "user_card" => $get_cer_datas['user_card'],//身份证
1788
+                "pension" => $num,//养老金额度
1789
+                "out_trade_no" => $order_from_mer['order_sn'],//订单号
1790
+                "account_type" => $pay_type,//支付方式(3:微信,4:组合)
1791
+                "order_type" => 0,//订单类型(2:)
1792
+                "pay_time" => date('Y-m-d H:i:s'),
1793
+                "create_time" => date('Y-m-d H:i:s'),
1794
+                "update_time" => date('Y-m-d H:i:s'),
1795
+                "uid" => $uid,
1796
+                "platform_no" => 'IN10' . (int)(microtime(true) * 1000) . mt_rand(10000, 99999),
1797
+                "link_id" => $bill_id
1798
+            ];
1799
+            Db::name('gzc_logs')->insert($ylj_data_log);
1800
+        }
1799 1801
     }
1800 1802
 
1801 1803
     //添加复购金