|
@@ -8,30 +8,13 @@ require_once(BASE_HELPER_PATH . '/refill/policy/transfer.php');
|
|
|
|
|
|
class proxy
|
|
|
{
|
|
|
- private function onEerror(refill\order $order,$errmsg)
|
|
|
+ private function onEerror(refill\order $order,$need_callback,$errmsg)
|
|
|
{
|
|
|
- $get_mchamount = function ($mod_refill, $order_id)
|
|
|
- {
|
|
|
- $mod_refill = Model('refill_order');
|
|
|
- $refill_info = $mod_refill->getOrderInfo(['order_id' => $order_id]);
|
|
|
- if(empty($refill_info)) {
|
|
|
- Log::record("onEerror cannot find order_id={$order_id}",Log::ERR);
|
|
|
- return 0.0;
|
|
|
- } else {
|
|
|
- return $refill_info['mch_amount'];
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
$refill_order = Model('refill_order');
|
|
|
$mchid = $order->mchid();
|
|
|
$mch_order = $order->mch_order();
|
|
|
- $commit_times = $order->commit_times();
|
|
|
$last_order_id = $order->last_order_id();
|
|
|
|
|
|
- if($commit_times > 0 && $last_order_id > 0) {
|
|
|
- $mch_amount = $get_mchamount($refill_order, $order->last_order_id());
|
|
|
- }
|
|
|
-
|
|
|
if ($last_order_id === 0) {
|
|
|
$order_id = refill\RefillFactory::instance()->zero_order($order, $errmsg);
|
|
|
$last_order_id = $order_id;
|
|
@@ -42,8 +25,15 @@ class proxy
|
|
|
refill\util::pop_queue_order($mchid, $mch_order);
|
|
|
QueueClient::push("NotifyMerchantComplete", ['order_id' => $last_order_id, 'manual' => false]);
|
|
|
|
|
|
- if($commit_times > 0 && $last_order_id > 0) {
|
|
|
- refill\util::monitor_callback($mchid, $order->spec(), $order->card_type(), $mch_amount, 0, false, $order->order_time());
|
|
|
+ if($need_callback)
|
|
|
+ {
|
|
|
+ Log::record("onEerror monitor_callback",Log::DEBUG);
|
|
|
+ $mch_amount = refill\RefillFactory::instance()->mch_amount($order);
|
|
|
+ if($mch_amount == false) {
|
|
|
+ refill\util::monitor_callback($mchid, $order->spec(), $order->card_type(), 0.0, 0, false, $order->order_time());
|
|
|
+ } else {
|
|
|
+ refill\util::monitor_callback($mchid, $order->spec(), $order->card_type(), $mch_amount, 0, false, $order->order_time());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return true;
|
|
@@ -118,9 +108,10 @@ class proxy
|
|
|
public function add($params)
|
|
|
{
|
|
|
$order = refill\order::from_parameters($params);
|
|
|
+ $need_callback = !$order->first_commit();
|
|
|
|
|
|
if($order->is_black()) {
|
|
|
- return $this->onEerror($order, '黑名单卡号');
|
|
|
+ return $this->onEerror($order, $need_callback,'黑名单卡号');
|
|
|
}
|
|
|
|
|
|
$mchid = $order->mchid();
|
|
@@ -135,13 +126,13 @@ class proxy
|
|
|
|
|
|
if ($this->canceled($mchid, $mch_order)) {
|
|
|
refill\util::del_cancel_order($mchid,$mch_order);
|
|
|
- return $this->onEerror($order, '订单被拦截');
|
|
|
+ return $this->onEerror($order, $need_callback,'订单被拦截');
|
|
|
}
|
|
|
if (!$order->validate()) {
|
|
|
- return $this->onEerror($order, '空号或风险号');
|
|
|
+ return $this->onEerror($order, $need_callback,'空号或风险号');
|
|
|
}
|
|
|
if($this->need_intercept($order)) {
|
|
|
- return $this->onEerror($order, '转网,问题号码,运营商维护被拦截.');
|
|
|
+ return $this->onEerror($order, $need_callback,'转网,问题号码,运营商维护被拦截.');
|
|
|
}
|
|
|
|
|
|
if($this->successed($mchid,$mch_order)) {
|
|
@@ -154,29 +145,29 @@ class proxy
|
|
|
[$org_quality, $quality] = refill\RefillFactory::instance()->find_quality($order, $skip);
|
|
|
$order->set_quality($org_quality,$quality);
|
|
|
if($quality == 0) {
|
|
|
- return $this->onEerror($order, '找不到合适质量的通道');
|
|
|
+ return $this->onEerror($order, $need_callback,'找不到合适质量的通道');
|
|
|
}
|
|
|
|
|
|
if($this->region_intercept($order)) {
|
|
|
- return $this->onEerror($order, '运营商维护被全局拦截.');
|
|
|
+ return $this->onEerror($order, $need_callback,'运营商维护被全局拦截.');
|
|
|
}
|
|
|
|
|
|
if($order->first_commit())
|
|
|
{
|
|
|
if (!$order->match_card_type()) {
|
|
|
- return $this->onEerror($order, '卡类型和产品类型不符.');
|
|
|
+ return $this->onEerror($order, $need_callback,'卡类型和产品类型不符.');
|
|
|
}
|
|
|
|
|
|
if(refill\util::merchant_debt_stoped($mchid)) {
|
|
|
Log::record("merchant_debt_stoped mchid={$mchid} stoped=1",Log::DEBUG);
|
|
|
- return $this->onEerror($order, '米不够了.');
|
|
|
+ return $this->onEerror($order, $need_callback,'米不够了.');
|
|
|
} else {
|
|
|
Log::record("merchant_debt_stoped mchid={$mchid} stoped=0",Log::DEBUG);
|
|
|
}
|
|
|
|
|
|
$mch_amount = refill\RefillFactory::instance()->mch_amount($order);
|
|
|
if($mch_amount === false) {
|
|
|
- return $this->onEerror($order, '没有协商商品购买价格.');
|
|
|
+ return $this->onEerror($order, $need_callback,'没有协商商品购买价格.');
|
|
|
}
|
|
|
else {
|
|
|
refill\util::monitor_submit($order->mchid(), $order->spec(), $order->card_type(), $mch_amount,$order->order_time());
|
|
@@ -217,13 +208,8 @@ class proxy
|
|
|
$fError = true;
|
|
|
}
|
|
|
|
|
|
- if($fError)
|
|
|
- {
|
|
|
- $mch_amount = refill\RefillFactory::instance()->mch_amount($order);
|
|
|
- if($mch_amount !== false) {
|
|
|
- refill\util::monitor_callback($mchid, $order->spec(), $order->card_type(), $mch_amount, 0, false, $order->order_time());
|
|
|
- }
|
|
|
- return $this->onEerror($order, $errmsg);
|
|
|
+ if ($fError) {
|
|
|
+ return $this->onEerror($order,true, $errmsg);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -326,8 +312,10 @@ class proxy
|
|
|
};
|
|
|
|
|
|
$order = refill\order::from_parameters($params);
|
|
|
+ $need_callback = !$order->first_commit();
|
|
|
+
|
|
|
if($is_closed($order->pcode())) {
|
|
|
- return $this->onEerror($order, "{$order->pcode()} has closed.");
|
|
|
+ return $this->onEerror($order, $need_callback,"{$order->pcode()} has closed.");
|
|
|
}
|
|
|
|
|
|
$mchid = $order->mchid();
|
|
@@ -339,7 +327,7 @@ class proxy
|
|
|
|
|
|
$mch_amount = refill\RefillFactory::instance()->mch_amount($order);
|
|
|
if ($mch_amount === false) {
|
|
|
- return $this->onEerror($order, '没有协商商品购买价格.');
|
|
|
+ return $this->onEerror($order, $need_callback,'没有协商商品购买价格.');
|
|
|
} else {
|
|
|
refill\util::monitor_submit($order->mchid(), $order->spec(), $order->card_type(), $mch_amount, $order->order_time());
|
|
|
}
|
|
@@ -350,7 +338,7 @@ class proxy
|
|
|
if ($errcode === refill\errcode::MERCHANT_REFILL_ERROR && $neterr && refill\util::need_check($net_errno)) {
|
|
|
return QueueClient::async_push("QueryOrderNeterr", ['order_id' => $order_id], 15);
|
|
|
} else {
|
|
|
- return $this->onEerror($order, $errmsg);
|
|
|
+ return $this->onEerror($order, $need_callback, $errmsg);
|
|
|
}
|
|
|
}
|
|
|
|