|
@@ -53,33 +53,36 @@ class HuafeiOrderIndependentAccount extends Command
|
|
53
|
// 订单状态(0:待发货;1:待收货;2:待评价;3:已完成;4已申请退款;-1:已退款)5未支付 6已取消'
|
53
|
// 订单状态(0:待发货;1:待收货;2:待评价;3:已完成;4已申请退款;-1:已退款)5未支付 6已取消'
|
|
54
|
$status = [2];
|
54
|
$status = [2];
|
|
55
|
// 普通订单
|
55
|
// 普通订单
|
|
56
|
- $cursor = Db::table('rrx_order_huafei')->where('is_independentaccount', 0)->where('gzc',1)->whereIn('status', $status)->cursor();
|
|
|
|
|
|
56
|
+ $cursor = Db::table('rrx_order_huafei')->where('is_independentaccount', 0)->where('gzc',1)->whereIn('status', $status)->select();
|
|
|
|
57
|
+
|
|
57
|
|
58
|
|
|
58
|
/** @var StoreOrderRepository $storeOrderRepository */
|
59
|
/** @var StoreOrderRepository $storeOrderRepository */
|
|
59
|
$storeOrderRepository = app()->make(StoreOrderRepository::class);
|
60
|
$storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
60
|
-
|
|
|
|
|
|
61
|
+ if($cursor) {
|
|
|
|
62
|
+ $cursor = $cursor->toArray();
|
|
|
|
63
|
+ }else {
|
|
|
|
64
|
+ die;
|
|
|
|
65
|
+ }
|
|
61
|
foreach ($cursor as $key => $value) {
|
66
|
foreach ($cursor as $key => $value) {
|
|
62
|
- $settlement_period_time = strtotime($value['create_time']) + $timeLimit * 24 * 3600;
|
|
|
|
63
|
// @todo 下单后第{$timeLimit}天后可分账
|
67
|
// @todo 下单后第{$timeLimit}天后可分账
|
|
64
|
- if ($settlement_period_time >= $time) {
|
|
|
|
65
|
- $merchants['496'] = Db::name('merchant')->where('mer_id', 496)->find();
|
|
|
|
66
|
- $order_huafei_hf = Db::name('order_huafei_hf')->where('order_no', $value['order_sn'])->find();
|
|
|
|
67
|
- if(!$order_huafei_hf) continue;
|
|
|
|
68
|
- $value['mer_id'] = 496;
|
|
|
|
69
|
- $order_huafei_hf['mer_id'] = 496;
|
|
|
|
70
|
-
|
|
|
|
71
|
- // 分账账号 496:表示{会员专区}账户,分账到{会员专区}账户
|
|
|
|
72
|
- $independentAccount = $storeOrderRepository->getIndependentAccountHuafei($order_huafei_hf, $dst_mer_id, $merchants['496']['hf_member_id']);
|
|
|
|
|
|
68
|
+ $merchants['496'] = Db::name('merchant')->where('mer_id', 496)->find();
|
|
|
|
69
|
+ $order_huafei_hf = Db::name('order_huafei_hf')->where('order_no', $value['order_sn'])->find();
|
|
|
|
70
|
+ if(!$order_huafei_hf) continue;
|
|
|
|
71
|
+ $value['mer_id'] = 496;
|
|
|
|
72
|
+ $order_huafei_hf['mer_id'] = 496;
|
|
|
|
73
|
+ $order_huafei_hf['hf_pay_id'] = $order_huafei_hf['payment_id'];
|
|
|
|
74
|
+ $order_huafei_hf['group_order_sn'] = $order_huafei_hf['order_no'];
|
|
|
|
75
|
+ // 分账账号 496:表示{会员专区}账户,分账到{会员专区}账户
|
|
|
|
76
|
+ $independentAccount = $storeOrderRepository->getIndependentAccountHuafei($order_huafei_hf, $dst_mer_id, $merchants['496']['hf_member_id']);
|
|
73
|
|
77
|
|
|
74
|
- // @todo 预分账处理 分账到{会员专区}账户,故:hf_platform_member_id 为入账账户
|
|
|
|
75
|
- $isSuccessed = $storeOrderRepository->prepareExecuteIndependentAccountHuafei(
|
|
|
|
76
|
- $value, $order_huafei_hf, $independentAccount['api_key'], $independentAccount['hf_platform_member_id'], '', $value['pay_price'], 0
|
|
|
|
77
|
- );
|
|
|
|
|
|
78
|
+ // @todo 预分账处理 分账到{会员专区}账户,故:hf_platform_member_id 为入账账户
|
|
|
|
79
|
+ $isSuccessed = $storeOrderRepository->prepareExecuteIndependentAccountHuafei(
|
|
|
|
80
|
+ $value, $order_huafei_hf, $independentAccount['api_key'], $independentAccount['hf_platform_member_id'], '', $value['amount_price'], 0
|
|
|
|
81
|
+ );
|
|
78
|
|
82
|
|
|
79
|
- if ($isSuccessed) {
|
|
|
|
80
|
- Db::name("log")->insert(array('data' => '话费-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));//日志记录
|
|
|
|
81
|
- Db::table('rrx_order_huafei')->where('order_sn', $value['order_sn'])->update(['is_independentaccount' => 1]);
|
|
|
|
82
|
- }
|
|
|
|
|
|
83
|
+ if ($isSuccessed) {
|
|
|
|
84
|
+ Db::name("log")->insert(array('data' => '话费-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));//日志记录
|
|
|
|
85
|
+ Db::table('rrx_order_huafei')->where('order_sn', $value['order_sn'])->update(['is_independentaccount' => 1]);
|
|
83
|
}
|
86
|
}
|
|
84
|
}
|
87
|
}
|
|
85
|
}
|
88
|
}
|