Explorar o código

计划任务-测试独立的分红脚本

sunxbiao hai 1 ano
pai
achega
4297b3b4a9
Modificáronse 1 ficheiros con 47 adicións e 22 borrados
  1. 47 22
      app/command/GzcAddByBillCommand.php

+ 47 - 22
app/command/GzcAddByBillCommand.php

@@ -4,9 +4,15 @@ namespace app\command;
4
 
4
 
5
 use app\common\model\user\UserCertification;
5
 use app\common\model\user\UserCertification;
6
 use app\common\repositories\merchant\order\OrderGzcRepository;
6
 use app\common\repositories\merchant\order\OrderGzcRepository;
7
+use app\common\repositories\merchant\order\OrderMerchantRepository;
8
+use app\common\repositories\store\order\StoreOrderRepository;
9
+use app\common\repositories\user\UserRepository;
7
 use think\console\Command;
10
 use think\console\Command;
8
 use think\console\Input;
11
 use think\console\Input;
9
 use think\console\Output;
12
 use think\console\Output;
13
+use think\db\exception\DataNotFoundException;
14
+use think\db\exception\DbException;
15
+use think\db\exception\ModelNotFoundException;
10
 use think\facade\Db;
16
 use think\facade\Db;
11
 use think\facade\Log;
17
 use think\facade\Log;
12
 
18
 
@@ -38,18 +44,31 @@ class GzcAddByBillCommand extends Command
38
      */
44
      */
39
     public function billGzcAdd($nowTime)
45
     public function billGzcAdd($nowTime)
40
     {
46
     {
41
-        /** @var OrderGzcRepository $OrderGzcRepository */
42
-        $OrderGzcRepository = app()->make(OrderGzcRepository::class);
47
+        $OrderGzcRepository      = app()->make(OrderGzcRepository::class);
48
+        $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
49
+        $StoreOrderRepository    = app()->make(StoreOrderRepository::class);
50
+        $testUserIdList = [];
51
+        /** @var UserRepository $userRepository */
52
+        $userRepository = app()->make(UserRepository::class);
53
+        try {
54
+            $userIdData = $userRepository->selectWhere(['test_user' => 1], 'uid')->toArray();
55
+            if (!empty($userIdData)) {
56
+                $testUserIdList = array_column($userIdData, 'uid');
57
+            }
58
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
59
+
60
+        }
61
+
43
         $cursor = Db::name('user_bill')
62
         $cursor = Db::name('user_bill')
44
             ->where('status', 1)
63
             ->where('status', 1)
45
             ->where('is_gzc', 0)
64
             ->where('is_gzc', 0)
46
             ->where('commission_type', 5)
65
             ->where('commission_type', 5)
47
-            ->select()
48
-            ->toArray();
49
-        if ($cursor) {
66
+            ->whereNotIn('uid', $testUserIdList)
67
+            ->select()->toArray();
68
+        if($cursor) {
50
             foreach ($cursor as $bill) {
69
             foreach ($cursor as $bill) {
51
                 $type_shop = $bill['type_shop'] ?? 0;
70
                 $type_shop = $bill['type_shop'] ?? 0;
52
-                switch ($type_shop) {
71
+                switch ($type_shop){
53
                     case "0":
72
                     case "0":
54
                         $online = $cursor = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
73
                         $online = $cursor = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
55
                         break;
74
                         break;
@@ -57,7 +76,7 @@ class GzcAddByBillCommand extends Command
57
                         $online = Db::table('rrx_order_pdd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
76
                         $online = Db::table('rrx_order_pdd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
58
                         break;
77
                         break;
59
                     case "2":
78
                     case "2":
60
-                        $online = Db::table('rrx_order_vip')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
79
+                        $online =  Db::table('rrx_order_vip')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
61
                         break;
80
                         break;
62
                     case "3":
81
                     case "3":
63
                         $online = Db::table('rrx_order_su')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
82
                         $online = Db::table('rrx_order_su')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
@@ -80,6 +99,14 @@ class GzcAddByBillCommand extends Command
80
                     case "9":
99
                     case "9":
81
                         $online = Db::table('rrx_order_huafei')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
100
                         $online = Db::table('rrx_order_huafei')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
82
                         break;
101
                         break;
102
+                    case "10":
103
+                        $online = Db::table('rrx_order_merchant')
104
+                            ->where('uid', $bill['uid'])
105
+                            ->where('out_trade_no', $bill['order_sn'])
106
+                            ->where('paid', 1)
107
+                            ->where('status', 1)
108
+                            ->find();
109
+                        break;
83
                     default:
110
                     default:
84
                         $online = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
111
                         $online = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
85
                 }
112
                 }
@@ -101,31 +128,29 @@ class GzcAddByBillCommand extends Command
101
                 }
128
                 }
102
 
129
 
103
                 //新增入账明细记录
130
                 //新增入账明细记录
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,
131
+                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
132
+                $create    = [
133
+                    'uid'          => $online['uid'],
134
+                    'platform_no'  => $orderId,
110
                     'account_type' => 1,
135
                     '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,
136
+                    'user_name'    => $certification['user_name'],
137
+                    'mobile'       => $certification['mobile'],
138
+                    'user_card'    => $certification['user_card'],
139
+                    'pension'      => $pension,
140
+                    'order_type'   => $type_shop,
116
                     'out_trade_no' => $online['order_sn'],
141
                     'out_trade_no' => $online['order_sn'],
117
-                    'link_id' => $bill['bill_id']
142
+                    'link_id'=> $bill['bill_id']
118
                 ];
143
                 ];
119
                 $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
144
                 $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();
145
+                $check     = Db::name("gzc_logs")->where("link_id", $bill['bill_id'])->where("order_type", $type_shop)->count();
121
                 if ($test_user == 0 && $check <= 0) {
146
                 if ($test_user == 0 && $check <= 0) {
122
                     $OrderGzcRepository->create($create);
147
                     $OrderGzcRepository->create($create);
123
                     Db::name('user_bill')
148
                     Db::name('user_bill')
124
                         ->where('bill_id', $bill['bill_id'])
149
                         ->where('bill_id', $bill['bill_id'])
125
                         ->where('commission_type', 5)
150
                         ->where('commission_type', 5)
126
                         ->update([
151
                         ->update([
127
-                            'is_gzc' => 1,
128
-                            'gzc' => 1
152
+                            'is_gzc'          => 1,
153
+                            'gzc'             => 1
129
                         ]);
154
                         ]);
130
                 }
155
                 }
131
             }
156
             }