mchid(); $mch_order = $order->mch_order(); $last_order_id = $order->last_order_id(); if ($last_order_id === 0) { $order_id = refill\RefillFactory::instance()->zero_order($order, $errmsg); $last_order_id = $order_id; } else { $refill_order->edit($last_order_id, ['notify_time' => time(), 'notify_state' => 1, 'is_retrying' => 0]); } refill\util::pop_queue_order($mchid,$mch_order); QueueClient::push("NotifyMerchantComplete", ['order_id' => $last_order_id,'manual' => false]); return true; } public function add($params) { $order = refill\order::from_parameters($params); if($order->is_black()) { return $this->onEerror($order, '黑名单卡号'); } $mchid = $order->mchid(); $mch_order = $order->mch_order(); $refill_order = Model('refill_order'); if($order->first_commit()) { refill\util::push_queue_order($mchid,$mch_order,ORDER_STATE_SEND); $refill_order->edit_detail($mchid,$mch_order,['order_state' => ORDER_STATE_SEND]); } Log::record("proxy::add times={$order->commit_times()} mch_order={$mch_order} card_no = {$order->card_no()} regin_no={$order->region_no()} org_quality={$order->org_quality()} quality={$order->cur_quality()}",Log::DEBUG); if ($this->canceled($mchid, $mch_order)) { return $this->onEerror($order, '订单被拦截'); } if (!$order->validate()) { return $this->onEerror($order, '空号或风险号'); } if($this->need_intercept($order)) { return $this->onEerror($order, '转网,问题号码,运营商维护被拦截.'); } [$org_quality,$quality] = refill\RefillFactory::instance()->find_quality($order); $order->set_quality($org_quality,$quality); if($quality == 0) { return $this->onEerror($order, '找不到合适质量的通道'); } if($this->region_intercept($order)) { return $this->onEerror($order, '运营商维护被全局拦截.'); } if($order->first_commit()) { refill\util::incr_user_commit($mchid,$order->card_type(),$order->spec(),$org_quality); } [$errcode, $errmsg, $order_id, $neterr,$net_errno] = refill\RefillFactory::instance()->add($order); if($errcode !== true) { if($errcode === refill\errcode::MERCHANT_REFILL_ERROR && $neterr && refill\util::need_check($net_errno)) { QueueClient::async_push("QueryOrderNeterr",['order_id' => $order_id],15); $fError = false; } elseif(($errcode === refill\errcode::MERCHANT_REFILL_ERROR && $neterr)) // elseif(($errcode === refill\errcode::MERCHANT_REFILL_ERROR) && refill\util::order_errflag($net_errno) === false) { [$org_quality,$quality] = refill\RefillFactory::instance()->find_quality($order,true); $order->set_quality($org_quality,$quality); if ($quality > 0) { $params['order_id'] = $order_id; if($order_id > 0) { $refill_order->edit($order_id, ['is_retrying' => 1]); } $params = $order->queue_params(); if (!refill\util::push_add($params)) { $fError = true; } else { $fError = false; } } } else { $fError = true; } if($fError) { return $this->onEerror($order, $errmsg); } } return true; } private function need_intercept(refill\order $order) { if($order->is_third()) return false; $mchid = $order->mchid(); $card_state = $order->card_state(); $is_transfer = $order->is_transfer(); $card_type = $order->card_type(); return refill\RefillFactory::instance()->need_intercept($mchid,$card_type,$card_state,$is_transfer); } private function region_intercept(refill\order $order) { if($order->is_third() || $order->is_oil()) return false; $quality = $order->cur_quality(); $card_type = $order->card_type(); $reqion = $order->region_no(); return refill\RefillFactory::instance()->region_intercept($quality,$card_type,$reqion); } private function canceled($mchid,$mch_order) { $order_state = refill\util::query_cancel_order($mchid,$mch_order); if($order_state == 1) { return true; } else { return false; } } public function add_zero($params) { $order = refill\order::from_parameters($params); $mchid = $order->mchid(); $mch_order = $order->mch_order(); refill\util::push_queue_order($mchid,$mch_order,ORDER_STATE_SEND); Model('refill_order')->edit_detail($mchid,$mch_order,['order_state' => ORDER_STATE_SEND]); [$org_quality,$quality] = refill\RefillFactory::instance()->find_quality($order); if($order->first_commit()) { refill\util::incr_user_commit($mchid,$order->card_type(),$order->spec(),$org_quality); } Log::record("proxy::add mch_order={$mch_order} card_no = {$order->card_no()} regin_no={$order->region_no()} org_quality={$org_quality} quality={$quality}",Log::DEBUG); $order_id = refill\RefillFactory::instance()->zero_order($order,"手动0元订单"); refill\util::pop_queue_order($mchid, $mch_order); QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => false]); } public function notify($channel,$input) { return refill\RefillFactory::instance()->notify($channel,$input); } public function notify_merchant($order_id,$manual) { return refill\RefillFactory::instance()->notify_merchant($order_id,$manual); } public function query($order_id) { return refill\RefillFactory::instance()->query($order_id); } public function query_net($order_id) { return refill\RefillFactory::instance()->query_net($order_id); } public function manual_success($order_id) { refill\RefillFactory::instance()->manual_success($order_id); } public function manual_cancel($order_id) { refill\RefillFactory::instance()->manual_cancel($order_id); } public function addthird($params) { $order = refill\order::from_parameters($params); $mchid = $order->mchid(); $mch_order = $order->mch_order(); $card_type = $order->card_type(); $spec = $order->spec(); $org_quality = $order->org_quality(); $refill_order = Model('refill_order'); refill\util::push_queue_order($mchid,$mch_order,ORDER_STATE_SEND); $refill_order->edit_detail($mchid,$mch_order,['order_state' => ORDER_STATE_SEND]); refill\util::incr_user_commit($mchid,$card_type,$spec,$org_quality); [$errcode, $errmsg, $order_id, $neterr,$net_errno] = refill\RefillFactory::instance()->add($order); if($errcode !== true) { 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 true; } }