|
|
@@ -4,9 +4,15 @@ namespace app\command;
|
|
4
|
4
|
|
|
5
|
5
|
use app\common\model\user\UserCertification;
|
|
6
|
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
|
10
|
use think\console\Command;
|
|
8
|
11
|
use think\console\Input;
|
|
9
|
12
|
use think\console\Output;
|
|
|
13
|
+use think\db\exception\DataNotFoundException;
|
|
|
14
|
+use think\db\exception\DbException;
|
|
|
15
|
+use think\db\exception\ModelNotFoundException;
|
|
10
|
16
|
use think\facade\Db;
|
|
11
|
17
|
use think\facade\Log;
|
|
12
|
18
|
|
|
|
@@ -38,18 +44,31 @@ class GzcAddByBillCommand extends Command
|
|
38
|
44
|
*/
|
|
39
|
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
|
62
|
$cursor = Db::name('user_bill')
|
|
44
|
63
|
->where('status', 1)
|
|
45
|
64
|
->where('is_gzc', 0)
|
|
46
|
65
|
->where('commission_type', 5)
|
|
47
|
|
- ->select()
|
|
48
|
|
- ->toArray();
|
|
49
|
|
- if ($cursor) {
|
|
|
66
|
+ ->whereNotIn('uid', $testUserIdList)
|
|
|
67
|
+ ->select()->toArray();
|
|
|
68
|
+ if($cursor) {
|
|
50
|
69
|
foreach ($cursor as $bill) {
|
|
51
|
70
|
$type_shop = $bill['type_shop'] ?? 0;
|
|
52
|
|
- switch ($type_shop) {
|
|
|
71
|
+ switch ($type_shop){
|
|
53
|
72
|
case "0":
|
|
54
|
73
|
$online = $cursor = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
|
|
55
|
74
|
break;
|
|
|
@@ -57,7 +76,7 @@ class GzcAddByBillCommand extends Command
|
|
57
|
76
|
$online = Db::table('rrx_order_pdd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
58
|
77
|
break;
|
|
59
|
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
|
80
|
break;
|
|
62
|
81
|
case "3":
|
|
63
|
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
|
99
|
case "9":
|
|
81
|
100
|
$online = Db::table('rrx_order_huafei')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
82
|
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
|
110
|
default:
|
|
84
|
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
|
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
|
141
|
'out_trade_no' => $online['order_sn'],
|
|
117
|
|
- 'link_id' => $bill['bill_id']
|
|
|
142
|
+ 'link_id'=> $bill['bill_id']
|
|
118
|
143
|
];
|
|
119
|
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
|
146
|
if ($test_user == 0 && $check <= 0) {
|
|
122
|
147
|
$OrderGzcRepository->create($create);
|
|
123
|
148
|
Db::name('user_bill')
|
|
124
|
149
|
->where('bill_id', $bill['bill_id'])
|
|
125
|
150
|
->where('commission_type', 5)
|
|
126
|
151
|
->update([
|
|
127
|
|
- 'is_gzc' => 1,
|
|
128
|
|
- 'gzc' => 1
|
|
|
152
|
+ 'is_gzc' => 1,
|
|
|
153
|
+ 'gzc' => 1
|
|
129
|
154
|
]);
|
|
130
|
155
|
}
|
|
131
|
156
|
}
|