Bläddra i källkod

将公证处独立出来

sunxbiao 1 år sedan
förälder
incheckning
258dd17706
3 ändrade filer med 136 tillägg och 1 borttagningar
  1. 134 0
      app/command/GzcAddByBillCommand.php
  2. 1 1
      app/command/PensionTasks.php
  3. 1 0
      config/console.php

+ 134 - 0
app/command/GzcAddByBillCommand.php

@@ -0,0 +1,134 @@
1
+<?php
2
+
3
+namespace app\command;
4
+
5
+use app\common\model\user\UserCertification;
6
+use app\common\repositories\merchant\order\OrderGzcRepository;
7
+use think\console\Command;
8
+use think\console\Input;
9
+use think\console\Output;
10
+use think\facade\Db;
11
+use think\facade\Log;
12
+
13
+class GzcAddByBillCommand extends Command
14
+{
15
+    protected function configure()
16
+    {
17
+        // 配置命令名称及描述
18
+        $this->setName('gzcAddByBill')
19
+            ->setDescription('从bill表中查询未提交到公证处的养老金记录,并提交公证处');
20
+    }
21
+
22
+    protected function execute(Input $input, Output $output)
23
+    {
24
+        // 在这里执行任务的具体内容
25
+        $output->writeln('定时任务执行中...');
26
+
27
+        $nowTime = time();
28
+        $this->billGzcAdd($nowTime);
29
+
30
+        $output->writeln('定时任务执行完成');
31
+    }
32
+
33
+    /**
34
+     * 线下支付订单公证处IN10入账
35
+     * @param $nowTime
36
+     * author: php迷途小书童
37
+     * created: 2021/3/20 9:26
38
+     */
39
+    public function billGzcAdd($nowTime)
40
+    {
41
+        /** @var OrderGzcRepository $OrderGzcRepository */
42
+        $OrderGzcRepository = app()->make(OrderGzcRepository::class);
43
+        $cursor = Db::name('user_bill')
44
+            ->where('status', 1)
45
+            ->where('is_gzc', 0)
46
+            ->where('commission_type', 5)
47
+            ->select()
48
+            ->toArray();
49
+        if ($cursor) {
50
+            foreach ($cursor as $bill) {
51
+                $type_shop = $bill['type_shop'] ?? 0;
52
+                switch ($type_shop) {
53
+                    case "0":
54
+                        $online = $cursor = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
55
+                        break;
56
+                    case "1":
57
+                        $online = Db::table('rrx_order_pdd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
58
+                        break;
59
+                    case "2":
60
+                        $online = Db::table('rrx_order_vip')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
61
+                        break;
62
+                    case "3":
63
+                        $online = Db::table('rrx_order_su')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
64
+                        break;
65
+                    case "4":
66
+                        $online = '';
67
+                        break;
68
+                    case "5":
69
+                        $online = Db::table('rrx_order_tb')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
70
+                        break;
71
+                    case "6":
72
+                        $online = Db::table('rrx_order_jd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
73
+                        break;
74
+                    case "7":
75
+                        $online = '';
76
+                        break;
77
+                    case "8":
78
+                        $online = '';
79
+                        break;
80
+                    case "9":
81
+                        $online = Db::table('rrx_order_huafei')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
82
+                        break;
83
+                    default:
84
+                        $online = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
85
+                }
86
+                if (!$online) {
87
+                    Log::info($bill['uid'] . '查询不到订单');
88
+                    continue;
89
+                }
90
+
91
+                $certification = UserCertification::getInstance()->where('uid', $bill['uid'])->find();
92
+                if (!$certification) {
93
+                    Log::info($online['uid'] . '没有实名认证');
94
+                    continue;
95
+                }
96
+
97
+                $pension = $bill['number'] ?? 0;
98
+                if ($pension <= 0) {
99
+                    Log::info($online['order_sn'] . 'pension' . $pension);
100
+                    continue;
101
+                }
102
+
103
+                //新增入账明细记录
104
+                list($msec, $sec) = explode(' ', microtime());
105
+                $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
106
+                $orderId = 'IN10' . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369));
107
+                $create = [
108
+                    'uid' => $online['uid'],
109
+                    'platform_no' => $orderId,
110
+                    'account_type' => 1,
111
+                    'user_name' => $certification['user_name'],
112
+                    'mobile' => $certification['mobile'],
113
+                    'user_card' => $certification['user_card'],
114
+                    'pension' => $pension,
115
+                    'order_type' => $type_shop,
116
+                    'out_trade_no' => $online['order_sn'],
117
+                    'link_id' => $bill['bill_id']
118
+                ];
119
+                $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
120
+                $check = Db::name("gzc_logs")->where("link_id", $bill['bill_id'])->where("order_type", $type_shop)->count();
121
+                if ($test_user == 0 && $check <= 0) {
122
+                    $OrderGzcRepository->create($create);
123
+                    Db::name('user_bill')
124
+                        ->where('bill_id', $bill['bill_id'])
125
+                        ->where('commission_type', 5)
126
+                        ->update([
127
+                            'is_gzc' => 1,
128
+                            'gzc' => 1
129
+                        ]);
130
+                }
131
+            }
132
+        }
133
+    }
134
+}

+ 1 - 1
app/command/PensionTasks.php

@@ -64,7 +64,7 @@ class PensionTasks extends Command
64 64
 //            $this->doThridVipOrderGzc($nowTime, $timeLimit = 30);
65 65
 //            $this->doThridDyOrderGzc($nowTime, $timeLimit = 30);
66 66
 //            $this->doThridHfOrderGzc($nowTime, $timeLimit = 30);
67
-            $this->billGzcAdd($nowTime);
67
+//            $this->billGzcAdd($nowTime);
68 68
             //升级
69 69
 //            $this -> doUpgrade();
70 70
         } catch (\Throwable $e) {

+ 1 - 0
config/console.php

@@ -28,5 +28,6 @@ return [
28 28
         'movie_film' => 'app\command\MovieFilmCommand',
29 29
         'cinema_film_sched' => 'app\command\CinemaSchedCommand',
30 30
         'repair_pv_log' => 'app\command\repairPvLog',
31
+        'gzcAddByBill' => 'app\command\GzcAddByBillCommand',
31 32
     ],
32 33
 ];