修复多渠道切换渠道异常问题
This commit is contained in:
parent
3f874513ad
commit
4e5dce1d25
@ -298,23 +298,13 @@ class Core extends Controller
|
||||
$order = $orderService->get($order_id);
|
||||
|
||||
if (!$order) {
|
||||
$oldOrder = OrderLastHistoryService::instance()->get($order_id);
|
||||
if(!$oldOrder){
|
||||
$oldOrder = OrderTwoHistoryService::instance()->get($order_id);
|
||||
}
|
||||
if(!$oldOrder){
|
||||
$oldOrder = OrderHistoryService::instance()->get($order_id);
|
||||
}
|
||||
|
||||
|
||||
if ($oldOrder) {
|
||||
$oldorder = OrderHistoryService::instance()->get($order_id);
|
||||
if ($oldorder) {
|
||||
$channelService = ChannelService::instance();
|
||||
$oldupdate = $channelService->call('notify', $oldOrder['cid'], $request, false, $oldOrder);
|
||||
$merchant = MerchantService::instance()->get($oldOrder['mid']);
|
||||
if ($oldupdate['status'] == 3 && $oldOrder['status'] == 2 && isset($merchant['callback_repeat']) && $merchant['callback_repeat'] > 2) {
|
||||
// # TODO 暂时写死渠道,后续需修改为可以自主选择
|
||||
|
||||
if ($oldOrder['cid'] == '2') {
|
||||
$oldupdate = $channelService->call('notify', $oldorder['cid'], $request, false, $oldorder);
|
||||
$merchant = MerchantService::instance()->get($oldorder['mid']);
|
||||
if ($oldupdate['status'] == 3 && $oldorder['status'] == 2 && isset($merchant['callback_repeat']) && $merchant['callback_repeat'] > 2) {
|
||||
if ($oldorder['cid'] == '2') {
|
||||
OrderHistoryService::instance()->db()->where(array('order_id' => $order_id))->update(['status' => '3', 'buy_back' => '1']);
|
||||
if (isset($oldupdate['yes']) && $oldupdate['yes']) {
|
||||
echo $oldupdate['yes'];
|
||||
@ -324,9 +314,7 @@ class Core extends Controller
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -340,11 +328,14 @@ class Core extends Controller
|
||||
$this->no(-104);
|
||||
}
|
||||
|
||||
// var_dump($order);die;
|
||||
|
||||
#识别是否重复回调
|
||||
// $repeated
|
||||
// if ($order[''])
|
||||
|
||||
if (!$status && $request) {
|
||||
|
||||
$channelService = ChannelService::instance();
|
||||
$update = $channelService->call('notify', $order['cid'], $request, false, $order);
|
||||
$merchant = MerchantService::instance()->get($order['mid']);
|
||||
@ -359,8 +350,6 @@ class Core extends Controller
|
||||
// # TODO 暂时写死渠道,后续需修改为可以自主选择
|
||||
|
||||
if ($order['cid'] == '2') {
|
||||
|
||||
|
||||
$order->db()->where(array('order_id' => $order_id))->update(['status' => '3', 'buy_back' => '1']);
|
||||
if (isset($update['yes']) && $update['yes']) {
|
||||
echo $update['yes'];
|
||||
@ -370,20 +359,23 @@ class Core extends Controller
|
||||
die;
|
||||
}
|
||||
}
|
||||
// echo '123';die;
|
||||
|
||||
|
||||
if (isset($order['merchant_callback_at']) && $order['merchant_callback_at']) {
|
||||
echo 'fail';
|
||||
die;
|
||||
}
|
||||
$where[] = [
|
||||
'order_id', 'like', $order_id
|
||||
];
|
||||
|
||||
$is_lj_order = Db::name('merchant_order_lj')->where($where)->find();
|
||||
if ($is_lj_order) {
|
||||
$is_lj_status = false;
|
||||
} else {
|
||||
$is_lj_status = true;
|
||||
}
|
||||
// $is_lj_order = Db::name('merchant_order_lj')->where($where)->find();
|
||||
// if ($is_lj_order) {
|
||||
// $is_lj_status = false;
|
||||
// } else {
|
||||
// $is_lj_status = true;
|
||||
// }
|
||||
|
||||
|
||||
if ($update['status'] == 3 && isset($merchant['stop']) && $merchant['stop'] > 2) {
|
||||
@ -432,8 +424,11 @@ class Core extends Controller
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} elseif ($update['status'] == 3 && $merchant['callback_auto'] == 2 && $is_lj_status) {
|
||||
} elseif ($update['status'] == 3 && $merchant['callback_auto'] == 2 && !$order['apply_refund']) {
|
||||
# 该渠道下单失败,重新开始找另外一个渠道
|
||||
$num = $order['num'] + 1;
|
||||
$new_order_id = $order['order_id'] . '_' . $num;
|
||||
//
|
||||
$orderAutoService = OrderAutoService::instance();
|
||||
$use = $orderAutoService->get($order['order_id']);
|
||||
$this->use_product[] = $order['pid'];
|
||||
@ -449,8 +444,8 @@ class Core extends Controller
|
||||
if ($new_product && $order['param']) {
|
||||
# 记录失败的订单信息
|
||||
$orderAutoService->up($order);
|
||||
$orderAutoService->upChannelMsg($order_id, $update['status'], $update['data']);
|
||||
$channelService->use($order['mid'], $new_product, $order['param'], false, $order_id, $this->use_product);
|
||||
$orderAutoService->upChannelMsg($order_id, $update['status'], $update['data'], $order['num']);
|
||||
$channelService->use($order['mid'], $new_product, $order['param'], false, $new_order_id, $this->use_product);
|
||||
if ($die) {
|
||||
if (isset($update['yes']) && $update['yes']) {
|
||||
echo $update['yes'];die;
|
||||
@ -470,6 +465,7 @@ class Core extends Controller
|
||||
$update['data'] = $request;
|
||||
}
|
||||
|
||||
|
||||
if ($update && $order['merchant_callback_error'] != 1) {
|
||||
//$update['order'] = $order;
|
||||
$update['project_id'] = false;
|
||||
|
@ -385,12 +385,12 @@ class Core extends Controller
|
||||
'order_id', 'like', $order_id
|
||||
];
|
||||
|
||||
$is_lj_order = Db::name('merchant_order_lj')->where($where)->find();
|
||||
if ($is_lj_order) {
|
||||
$is_lj_status = false;
|
||||
} else {
|
||||
$is_lj_status = true;
|
||||
}
|
||||
// $is_lj_order = Db::name('merchant_order_lj')->where($where)->find();
|
||||
// if ($is_lj_order) {
|
||||
// $is_lj_status = false;
|
||||
// } else {
|
||||
// $is_lj_status = true;
|
||||
// }
|
||||
|
||||
|
||||
if ($update['status'] == 3 && isset($merchant['stop']) && $merchant['stop'] > 2) {
|
||||
@ -439,8 +439,11 @@ class Core extends Controller
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} elseif ($update['status'] == 3 && $merchant['callback_auto'] == 2 && $is_lj_status) {
|
||||
} elseif ($update['status'] == 3 && $merchant['callback_auto'] == 2 && !$order['apply_refund']) {
|
||||
# 该渠道下单失败,重新开始找另外一个渠道
|
||||
$num = $order['num'] + 1;
|
||||
$new_order_id = $order['order_id'] . '_' . $num;
|
||||
//
|
||||
$orderAutoService = OrderAutoService::instance();
|
||||
$use = $orderAutoService->get($order['order_id']);
|
||||
$this->use_product[] = $order['pid'];
|
||||
@ -456,8 +459,8 @@ class Core extends Controller
|
||||
if ($new_product && $order['param']) {
|
||||
# 记录失败的订单信息
|
||||
$orderAutoService->up($order);
|
||||
$orderAutoService->upChannelMsg($order_id, $update['status'], $update['data']);
|
||||
$channelService->use($order['mid'], $new_product, $order['param'], false, $order_id, $this->use_product);
|
||||
$orderAutoService->upChannelMsg($order_id, $update['status'], $update['data'], $order['num']);
|
||||
$channelService->use($order['mid'], $new_product, $order['param'], false, $new_order_id, $this->use_product);
|
||||
if ($die) {
|
||||
if (isset($update['yes']) && $update['yes']) {
|
||||
echo $update['yes'];die;
|
||||
|
Loading…
x
Reference in New Issue
Block a user