|
|
@@ -3,19 +3,11 @@
|
|
3
|
3
|
namespace app\command;
|
|
4
|
4
|
|
|
5
|
5
|
use app\common\model\store\order\StoreOrder;
|
|
6
|
|
-use app\common\model\user\UserCertification;
|
|
7
|
|
-use app\common\repositories\merchant\order\OrderGzcRepository;
|
|
8
|
|
-use app\common\repositories\merchant\order\OrderMerchantRepository;
|
|
9
|
6
|
use app\common\repositories\store\order\StoreOrderRepository;
|
|
10
|
|
-use app\common\repositories\store\order\StoreOrderStatusRepository;
|
|
11
|
|
-use app\common\repositories\user\UserBillRepository;
|
|
12
|
|
-use app\common\repositories\user\UserRepository;
|
|
13
|
|
-use Carbon\Carbon;
|
|
14
|
7
|
use think\console\Command;
|
|
15
|
8
|
use think\console\Input;
|
|
16
|
9
|
use think\console\Output;
|
|
17
|
10
|
use think\facade\Db;
|
|
18
|
|
-use think\facade\Log;
|
|
19
|
11
|
|
|
20
|
12
|
class CommercialAreaOrderIndependentAccount extends Command
|
|
21
|
13
|
{
|
|
|
@@ -46,9 +38,6 @@ class CommercialAreaOrderIndependentAccount extends Command
|
|
46
|
38
|
{
|
|
47
|
39
|
// 商户信息
|
|
48
|
40
|
$merchants = [];
|
|
49
|
|
-// $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
|
50
|
|
-// $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
|
|
51
|
|
-// $OrderGzcRepository = app()->make(OrderGzcRepository::class);
|
|
52
|
41
|
|
|
53
|
42
|
/** @var StoreOrderRepository $storeOrderRepository */
|
|
54
|
43
|
$storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
@@ -57,7 +46,7 @@ class CommercialAreaOrderIndependentAccount extends Command
|
|
57
|
46
|
// 订单状态(0:待发货;1:待收货;2:待评价;3:已完成;4已申请退款;-1:已退款)5未支付 6已取消'
|
|
58
|
47
|
$status = [2, 3];
|
|
59
|
48
|
// 已支付、未结算
|
|
60
|
|
- $where = ['paid' => 1, 'gzc' => 0, 'is_del' => 0, 'is_system_del' => 0];
|
|
|
49
|
+ $where = ['paid' => 1, 'is_independentaccount' => 0, 'is_del' => 0, 'is_system_del' => 0];
|
|
61
|
50
|
// 普通订单 @todo 排除 特殊商户{$excludeMerId}:精彩生活区、会员区、复购区
|
|
62
|
51
|
$cursor = Db::table('rrx_store_order')->where($where)->where('pay_type', 'in', '1,2,4')->whereIn('status', $status)
|
|
63
|
52
|
->whereNotIn('mer_id', $excludeMerId)->cursor();
|
|
|
@@ -76,229 +65,15 @@ class CommercialAreaOrderIndependentAccount extends Command
|
|
76
|
65
|
$isSuccessed = $storeOrderRepository->prepareExecuteIndependentAccount(
|
|
77
|
66
|
$value, $group_order, $independentAccount['api_key'], $independentAccount['hf_member_id'], $independentAccount['hf_platform_member_id'], $value['cost'], $value['con_pri']
|
|
78
|
67
|
);
|
|
79
|
|
- Db::name("log")->insert(array('data' => '商贸区-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));//日志记录
|
|
|
68
|
+ if ($isSuccessed) {
|
|
|
69
|
+ Db::name("log")->insert(array('data' => '商贸区-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));//日志记录
|
|
80
|
70
|
|
|
81
|
|
-// Db::transaction(function () use ($certification, $online, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
|
|
82
|
|
-// //新增入账明细记录
|
|
83
|
|
-// $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
|
|
84
|
|
-// $create = [
|
|
85
|
|
-// 'uid' => $online['uid'],
|
|
86
|
|
-// 'platform_no' => $orderId,
|
|
87
|
|
-// 'account_type' => $online['pay_type'] == 1 ? 3 : 2,
|
|
88
|
|
-// 'user_name' => $certification['user_name'],
|
|
89
|
|
-// 'mobile' => $certification['mobile'],
|
|
90
|
|
-// 'user_card' => $certification['user_card'],
|
|
91
|
|
-// 'pension' => $pension,
|
|
92
|
|
-// 'order_type' => 2,
|
|
93
|
|
-// 'out_trade_no' => $online['order_sn']
|
|
94
|
|
-// ];
|
|
95
|
|
-// $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
|
|
96
|
|
-// $check = Db::name("gzc_logs")->where("out_trade_no", $online['order_sn'])->where("order_type", 2)->count();
|
|
97
|
|
-// if ($test_user == 0 && $check <= 0) {
|
|
98
|
|
-// $OrderGzcRepository->create($create);
|
|
99
|
|
-// }
|
|
100
|
|
- $order = StoreOrder::getInstance()->find($value['order_id']);
|
|
101
|
|
- $order->gzc = 1;
|
|
102
|
|
- $order->save();
|
|
103
|
|
-// });
|
|
|
71
|
+ $order = StoreOrder::getInstance()->where('order_id', $value['order_id'])->find();
|
|
|
72
|
+ $order->is_independentaccount = 1;
|
|
|
73
|
+ $order->save();
|
|
|
74
|
+ }
|
|
104
|
75
|
}
|
|
105
|
76
|
}
|
|
106
|
|
-
|
|
107
|
|
- // 普通订单(红包,积分,京东,佣金,复购金,养老金,贡献值)
|
|
108
|
|
-// $cursor = Db::table('rrx_store_order')->where('paid', 1)->where('is_settlement', 0)->where('pay_type', 'in', '0,1,2,4')->cursor();
|
|
109
|
|
-// $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
|
110
|
|
-// $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
|
|
111
|
|
-// $OrderGzcRepository = app()->make(OrderGzcRepository::class);
|
|
112
|
|
-// foreach ($cursor as $online) {
|
|
113
|
|
-// $status = $StoreOrderStatusRepository->getWhere(['order_id' => $online['order_id'], 'change_type' => 'take']);
|
|
114
|
|
-// if ($online['mer_id'] == 496) {
|
|
115
|
|
-// if (!in_array($online['status'], [0, 1, 2, 3])) {
|
|
116
|
|
-// continue;
|
|
117
|
|
-// }
|
|
118
|
|
-// if (time() < strtotime($online['pay_time']) + 3600 * 24) {
|
|
119
|
|
-// Log::info('还没有到收货后' . $timeLimit . '天');
|
|
120
|
|
-// continue;
|
|
121
|
|
-// }
|
|
122
|
|
-// } else {
|
|
123
|
|
-// if (!in_array($online['status'], [2, 3])) {
|
|
124
|
|
-// continue;
|
|
125
|
|
-// }
|
|
126
|
|
-// if (Carbon::now()->modify("-{$timeLimit} days")->lt($status->change_time ?? $status['change_time'])) {
|
|
127
|
|
-// Log::info('还没有到收货后' . $timeLimit . '天');
|
|
128
|
|
-// continue;
|
|
129
|
|
-// }
|
|
130
|
|
-// }
|
|
131
|
|
-//
|
|
132
|
|
-// $StoreOrderRepository = app()->make(StoreOrderRepository::class);
|
|
133
|
|
-// Db::transaction(function () use ($online, $StoreOrderRepository) {
|
|
134
|
|
-// $order = StoreOrder::getInstance()->find($online['order_id']);
|
|
135
|
|
-// $order->is_settlement = 1;
|
|
136
|
|
-// $order->settlement_time = date('Y-m-d H:i:s');
|
|
137
|
|
-// $order->save();
|
|
138
|
|
-//
|
|
139
|
|
-// // 结算积分
|
|
140
|
|
-// $user_sign_score_list = Db::name('user_sign_score')
|
|
141
|
|
-// ->where('status', -1)
|
|
142
|
|
-// ->where('order_id', $online['order_id'])
|
|
143
|
|
-// ->whereIn('type', [1, 2])
|
|
144
|
|
-// ->select()
|
|
145
|
|
-// ->toArray();
|
|
146
|
|
-// foreach ($user_sign_score_list as $user_sign_score) {
|
|
147
|
|
-// // 修改积分
|
|
148
|
|
-// Db::name('user')
|
|
149
|
|
-// ->where('uid', $user_sign_score['uid'])
|
|
150
|
|
-// ->inc('score', (float)$user_sign_score['reward_socre'])
|
|
151
|
|
-// ->update();
|
|
152
|
|
-// Db::name('user_sign_score')
|
|
153
|
|
-// ->where('status', -1)
|
|
154
|
|
-// ->where('id', $user_sign_score['id'])
|
|
155
|
|
-// ->update([
|
|
156
|
|
-// 'status' => 1,
|
|
157
|
|
-// 'settlement_time' => date('Y-m-d H:i:s')
|
|
158
|
|
-// ]);
|
|
159
|
|
-// }
|
|
160
|
|
-//
|
|
161
|
|
-// // 结算红包
|
|
162
|
|
-// $user_sign_hongbao_list = Db::name('user_sign_hongbao')
|
|
163
|
|
-// ->where('status', -1)
|
|
164
|
|
-// ->where('order_id', $online['order_id'])
|
|
165
|
|
-// ->whereIn('type', [1, 2])
|
|
166
|
|
-// ->select()
|
|
167
|
|
-// ->toArray();
|
|
168
|
|
-// foreach ($user_sign_hongbao_list as $user_sign_hongbao) {
|
|
169
|
|
-// // 修改红包
|
|
170
|
|
-// Db::name('user')
|
|
171
|
|
-// ->where('uid', $user_sign_hongbao['uid'])
|
|
172
|
|
-// ->inc('hongbao', (float)$user_sign_hongbao['number'])
|
|
173
|
|
-// ->update();
|
|
174
|
|
-// Db::name('user_sign_hongbao')
|
|
175
|
|
-// ->where('status', -1)
|
|
176
|
|
-// ->where('id', $user_sign_hongbao['id'])
|
|
177
|
|
-// ->update([
|
|
178
|
|
-// 'status' => 1,
|
|
179
|
|
-// 'settlement_time' => date('Y-m-d H:i:s')
|
|
180
|
|
-// ]);
|
|
181
|
|
-// }
|
|
182
|
|
-//
|
|
183
|
|
-//
|
|
184
|
|
-// // 结算京豆
|
|
185
|
|
-// $user_sign_jingdou_list = Db::name('user_sign_jingdou')
|
|
186
|
|
-// ->where('status', -1)
|
|
187
|
|
-// ->where('order_id', $online['order_id'])
|
|
188
|
|
-// ->whereIn('type', [1, 2])
|
|
189
|
|
-// ->select()
|
|
190
|
|
-// ->toArray();
|
|
191
|
|
-// foreach ($user_sign_jingdou_list as $user_sign_jingdou) {
|
|
192
|
|
-// // 修改京豆
|
|
193
|
|
-// Db::name('user')
|
|
194
|
|
-// ->where('uid', $user_sign_jingdou['uid'])
|
|
195
|
|
-// ->inc('jingdou', (float)$user_sign_jingdou['number'])
|
|
196
|
|
-// ->update();
|
|
197
|
|
-// Db::name('user_sign_jingdou')
|
|
198
|
|
-// ->where('status', -1)
|
|
199
|
|
-// ->where('id', $user_sign_jingdou['id'])
|
|
200
|
|
-// ->update([
|
|
201
|
|
-// 'status' => 1,
|
|
202
|
|
-// 'settlement_time' => date('Y-m-d H:i:s')
|
|
203
|
|
-// ]);
|
|
204
|
|
-// }
|
|
205
|
|
-//
|
|
206
|
|
-//
|
|
207
|
|
-//
|
|
208
|
|
-// // 结算复购金
|
|
209
|
|
-// $user_sign_fugou_list = Db::name('user_sign_fugou')
|
|
210
|
|
-// ->where('status', -1)
|
|
211
|
|
-// ->where('order_id', $online['order_id'])
|
|
212
|
|
-// ->whereIn('type', [1, 2])
|
|
213
|
|
-// ->select()
|
|
214
|
|
-// ->toArray();
|
|
215
|
|
-// foreach ($user_sign_fugou_list as $user_sign_fugou) {
|
|
216
|
|
-// // 修改复购金
|
|
217
|
|
-// Db::name('user')
|
|
218
|
|
-// ->where('uid', $user_sign_fugou['uid'])
|
|
219
|
|
-// ->inc('fugou', (float)$user_sign_fugou['number'])
|
|
220
|
|
-// ->update();
|
|
221
|
|
-// Db::name('user_sign_fugou')
|
|
222
|
|
-// ->where('status', -1)
|
|
223
|
|
-// ->where('id', $user_sign_fugou['id'])
|
|
224
|
|
-// ->update([
|
|
225
|
|
-// 'status' => 1,
|
|
226
|
|
-// 'settlement_time' => date('Y-m-d H:i:s')
|
|
227
|
|
-// ]);
|
|
228
|
|
-// }
|
|
229
|
|
-//
|
|
230
|
|
-//
|
|
231
|
|
-// // 结算贡献值
|
|
232
|
|
-// $user_sign_gongxian_list = Db::name('user_sign_gongxian')
|
|
233
|
|
-// ->where('status', -1)
|
|
234
|
|
-// ->where('order_id', $online['order_id'])
|
|
235
|
|
-// ->whereIn('type', [1, 2])
|
|
236
|
|
-// ->select()
|
|
237
|
|
-// ->toArray();
|
|
238
|
|
-// foreach ($user_sign_gongxian_list as $user_sign_gongxian) {
|
|
239
|
|
-// // 修改贡献值
|
|
240
|
|
-// Db::name('user')
|
|
241
|
|
-// ->where('uid', $user_sign_gongxian['uid'])
|
|
242
|
|
-// ->inc('contribute', (float)$user_sign_gongxian['number'])
|
|
243
|
|
-// ->update();
|
|
244
|
|
-// Db::name('user_sign_gongxian')
|
|
245
|
|
-// ->where('status', -1)
|
|
246
|
|
-// ->where('id', $user_sign_gongxian['id'])
|
|
247
|
|
-// ->update([
|
|
248
|
|
-// 'status' => 1,
|
|
249
|
|
-// 'settlement_time' => date('Y-m-d H:i:s')
|
|
250
|
|
-// ]);
|
|
251
|
|
-// }
|
|
252
|
|
-//
|
|
253
|
|
-//
|
|
254
|
|
-// // 结算佣金
|
|
255
|
|
-// $user_bill_list = Db::name('user_bill')
|
|
256
|
|
-// ->where('status', 0)
|
|
257
|
|
-// ->where('commission_type','<>', 5)
|
|
258
|
|
-// ->where([ 'link_id' => $online['order_id'], 'order_sn' => $online['order_sn']])
|
|
259
|
|
-// ->select()
|
|
260
|
|
-// ->toArray();
|
|
261
|
|
-// foreach ($user_bill_list as $user_bill) {
|
|
262
|
|
-// if ($user_bill['commission_type'] != 5) {
|
|
263
|
|
-// if (in_array($user_bill['commission_type'], [7,12,19])) {
|
|
264
|
|
-// Db::name("merchant")
|
|
265
|
|
-// ->where("mer_id", $user_bill['mer_id'])
|
|
266
|
|
-// ->inc('brokerage_price', (float)$user_bill['number'])
|
|
267
|
|
-// ->update();
|
|
268
|
|
-// } else {
|
|
269
|
|
-// Db::name('user')
|
|
270
|
|
-// ->where('uid', $user_bill['uid'])
|
|
271
|
|
-// ->inc('brokerage_price', (float)$user_bill['number'])
|
|
272
|
|
-// ->update();
|
|
273
|
|
-// }
|
|
274
|
|
-// }
|
|
275
|
|
-// if ($online['pay_type'] == 0 && $user_bill['commission_type'] == 5) {
|
|
276
|
|
-// } else {
|
|
277
|
|
-// // 虚拟支付的养老金不修改不结算
|
|
278
|
|
-// Db::name('user_bill')
|
|
279
|
|
-// ->where('status', 0)
|
|
280
|
|
-// ->where('bill_id', $user_bill['bill_id'])
|
|
281
|
|
-// ->update([
|
|
282
|
|
-// 'status' => 1,
|
|
283
|
|
-// 'take_time' => time()
|
|
284
|
|
-// ]);
|
|
285
|
|
-// }
|
|
286
|
|
-// if ($online['pay_type'] == 0 && $user_bill['commission_type'] == 5) {
|
|
287
|
|
-// } else {
|
|
288
|
|
-// // 虚拟支付的养老金不修改不结算
|
|
289
|
|
-// Db::name('user_bill')
|
|
290
|
|
-// ->where('status', 0)
|
|
291
|
|
-// ->where('bill_id', $user_bill['bill_id'])
|
|
292
|
|
-// ->update([
|
|
293
|
|
-// 'status' => 1,
|
|
294
|
|
-// 'take_time' => time()
|
|
295
|
|
-// ]);
|
|
296
|
|
-// }
|
|
297
|
|
-// }
|
|
298
|
|
-// //按角色结算
|
|
299
|
|
-// $StoreOrderRepository->close_order($online['order_id']);
|
|
300
|
|
-// });
|
|
301
|
|
-// }
|
|
302
|
77
|
}
|
|
303
|
78
|
|
|
304
|
79
|
}
|