public function serRefund($job, $data)
 {
     $errCode = 0;
     $refundOrder = RefundModel::find($data['id']);
     $rechargeOrder = RechargeModel::find($refundOrder->recharge_id);
     do {
         if ($rechargeOrder->status != RechargeModel::STATUS_SUCCESS || $refundOrder->ser_notify_status != RefundModel::STATUS_DEFAULT) {
             $errCode = 1;
             break;
         }
         if (!$refundOrder->gateway || !$refundOrder->channel) {
             $errCode = 2;
             break;
         }
         $channel = ChannelUtil::calculateAccountChannel($refundOrder->channel);
         if (false === $channel) {
             $errCode = 3;
             break;
         }
         $gatewayObj = gatewayUtil::getGatewayObj($rechargeOrder->gateway);
         if (!$gatewayObj) {
             $errCode = 4;
             break;
         }
         $orderData = $refundOrder->toArray();
         $queryParams = array('ser_recharge_no' => $rechargeOrder->ser_recharge_no, 'channel' => $channel, 'seller_partner' => $orderData['seller_partner']);
         $queryResult = $gatewayObj->refundQuery($queryParams);
         if ($queryResult->is_success == 'T') {
             /// 第三方已经退过款
             if ($queryResult->is_refund == true) {
                 $errCode = 5;
                 break;
             }
         }
     } while (0);
     if ($errCode == 0) {
         $notifyUrl = PayVars::getNotifyUrl() . "notify/refund/{$channel}/{$rechargeOrder->gateway}";
         $order = array('channel' => $channel, 'gateway' => $rechargeOrder->gateway, 'create_time' => $orderData['create_time'], 'mer_refund_no' => $orderData['mer_refund_no'], 'notify_url' => $notifyUrl, 'ser_recharge_no' => $rechargeOrder->ser_recharge_no, 'recharge_amount' => $rechargeOrder->recharge_amount, 'refund_amount' => $orderData['amount'], 'subject' => $orderData['subject'], 'mer_recharge_no' => $rechargeOrder->mer_recharge_no, 'seller_partner' => $rechargeOrder->seller_partner);
         $ret = $gatewayObj->refund($order);
         if ($ret->is_success == 'F') {
             $data = array('ser_notify_status' => 3, 'ser_notify_log' => $ret->error, 'ser_notify_time' => time());
             RefundBiz::getInstance()->confirmRefundOrderById($refundOrder->id, $data);
         }
         $job->release(60 * 5);
     } else {
         $job->delete();
     }
 }
Esempio n. 2
0
 public function transThirdParty($batchNo)
 {
     $transArr = TransModel::where('batch_no', $batchNo)->get();
     foreach ($transArr as $trans) {
         $fields[] = ['channel' => ChannelUtil::calculateAccountChannel($trans['channel']), 'gateway' => $trans['gateway'], 'mer_trans_no' => $trans['mer_trans_no'], 'batch_no' => $trans['batch_no'], 'bank_code' => $trans['bank_code'], 'timestamp' => $trans['create_time'], 'trans_amount' => $trans['trans_amount'], 'subject' => $trans['subject'], 'user_name' => $trans['person_name'], 'user_account' => $trans['person_account'], 'notify_url' => PayVars::getNotifyUrl() . "notify/trans/{$trans['channel']}/{$trans['gateway']}"];
     }
     $gatewayObj = GatewayUtil::getGatewayObj($fields[0]['gateway']);
     return $gatewayObj->trans($fields);
 }
Esempio n. 3
0
 public function directThirdParty($rechargeOrder)
 {
     $fields['channel'] = Util\ChannelUtil::calculateAccountChannel($rechargeOrder['channel']);
     $fields['gateway'] = $rechargeOrder['gateway'];
     $fields['plat'] = $rechargeOrder['plat'];
     $fields['mer_recharge_no'] = $rechargeOrder['mer_recharge_no'];
     $fields['bank_code'] = $rechargeOrder['bank_code'];
     $fields['timestamp'] = $rechargeOrder['create_time'];
     $fields['amount'] = $rechargeOrder['recharge_amount'];
     $fields['expire_time'] = $rechargeOrder['expire_time'];
     $fields['subject'] = $rechargeOrder['subject'];
     $fields['body'] = $rechargeOrder['body'];
     $fields['open_id'] = $rechargeOrder['gateway_account'];
     $gatewayObj = Util\GatewayUtil::getGatewayObj($fields['gateway']);
     $fields['notify_url'] = PayVars::getNotifyUrl() . "notify/direct/{$fields['channel']}/{$fields['gateway']}";
     $fields['return_url'] = PayVars::getReturnUrl() . 'return/' . $gatewayObj->makeReturnUri($fields);
     return $gatewayObj->direct($fields);
 }