|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+<?php
|
|
|
2
|
+
|
|
|
3
|
+namespace app\command;
|
|
|
4
|
+
|
|
|
5
|
+use app\common\model\store\order\StoreOrder;
|
|
|
6
|
+use app\common\repositories\store\order\StoreOrderRepository;
|
|
|
7
|
+use think\console\Command;
|
|
|
8
|
+use think\console\Input;
|
|
|
9
|
+use think\console\Output;
|
|
|
10
|
+use think\facade\Db;
|
|
|
11
|
+
|
|
|
12
|
+class MemberAreaOrderIndependentAccount extends Command
|
|
|
13
|
+{
|
|
|
14
|
+ protected function configure()
|
|
|
15
|
+ {
|
|
|
16
|
+ // 指令配置
|
|
|
17
|
+ $this->setName('member-area-order-independent-account')
|
|
|
18
|
+ ->setDescription('会员专区订单分账');
|
|
|
19
|
+ }
|
|
|
20
|
+
|
|
|
21
|
+ protected function execute(Input $input, Output $output)
|
|
|
22
|
+ {
|
|
|
23
|
+ // @todo 会员专区订单分账
|
|
|
24
|
+ $this->doMemberAreaOrderIndependentAccount([496]);
|
|
|
25
|
+ }
|
|
|
26
|
+
|
|
|
27
|
+ /**
|
|
|
28
|
+ * 会员专区、会员专区订单分账
|
|
|
29
|
+ *
|
|
|
30
|
+ * @param $merId
|
|
|
31
|
+ * @param $timeLimit
|
|
|
32
|
+ * @return void
|
|
|
33
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
34
|
+ * @throws \think\db\exception\DbException
|
|
|
35
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
36
|
+ */
|
|
|
37
|
+ private function doMemberAreaOrderIndependentAccount($merId = [], $timeLimit = 30)
|
|
|
38
|
+ {
|
|
|
39
|
+ $dst_mer_id = systemConfig('mer_365');
|
|
|
40
|
+
|
|
|
41
|
+ // 商户信息
|
|
|
42
|
+ $merchants = [];
|
|
|
43
|
+
|
|
|
44
|
+ // 已支付、未结算 注意,会员专区之前可能没有去及时 更新结算状态 'is_settlement' => 1,
|
|
|
45
|
+ $where = ['paid' => 1, 'is_del' => 0, 'is_system_del' => 0, 'is_independentaccount' => 0];
|
|
|
46
|
+ // 订单状态(0:待发货;1:待收货;2:待评价;3:已完成;4已申请退款;-1:已退款)5未支付 6已取消'
|
|
|
47
|
+ // $status = [2, 3]; ->whereIn('status', $status)
|
|
|
48
|
+ // 普通订单
|
|
|
49
|
+ $cursor = Db::table('rrx_store_order')->where($where)->where('pay_type', 'in', '1,2,4')
|
|
|
50
|
+ ->where('fzone_pay_price', '>', 0.00)
|
|
|
51
|
+ ->whereIn('mer_id', $merId)->cursor();
|
|
|
52
|
+
|
|
|
53
|
+ /** @var StoreOrderRepository $storeOrderRepository */
|
|
|
54
|
+ $storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
55
|
+
|
|
|
56
|
+ foreach ($cursor as $key => $value) {
|
|
|
57
|
+ if (!isset($merchants[$value['mer_id']])) {
|
|
|
58
|
+ $merchants[$value['mer_id']] = Db::name('merchant')->where('mer_id', $value['mer_id'])->find();
|
|
|
59
|
+ }
|
|
|
60
|
+ $group_order = Db::name('store_group_order')->alias('sgo')->where('sgo.group_order_id', $value['group_order_id'])->find();
|
|
|
61
|
+
|
|
|
62
|
+ // 分账账号 496:表示{会员专区}账户,会员专区分账到{会员专区}账户
|
|
|
63
|
+ $independentAccount = $storeOrderRepository->getIndependentAccount($value, $group_order, $dst_mer_id, $merchants[$value['mer_id']]['hf_member_id']);
|
|
|
64
|
+
|
|
|
65
|
+ // @todo 预分账处理 496:表示{会员专区}账户,会员专区分账到{会员专区}账户,故:hf_platform_member_id 为入账账户
|
|
|
66
|
+ $isSuccessed = $storeOrderRepository->prepareExecuteIndependentAccount(
|
|
|
67
|
+ $value, $group_order, $independentAccount['api_key'], $independentAccount['hf_platform_member_id'], '', $value['fzone_pay_price'], 0
|
|
|
68
|
+ );
|
|
|
69
|
+ if ($isSuccessed) {
|
|
|
70
|
+ Db::name("log")->insert(array('data' => '会员专区-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));// 日志记录
|
|
|
71
|
+
|
|
|
72
|
+ $order = StoreOrder::getInstance()->where('order_id', $value['order_id'])->find();
|
|
|
73
|
+ $order->is_independentaccount = 1;
|
|
|
74
|
+ $order->save();
|
|
|
75
|
+ }
|
|
|
76
|
+ }
|
|
|
77
|
+
|
|
|
78
|
+ }
|
|
|
79
|
+
|
|
|
80
|
+}
|