Esempio n. 1
0
 private function dealDetails($dealDetails, $detailList, $status)
 {
     if (empty($dealDetails) || empty($detailList)) {
         return false;
     }
     foreach ($dealDetails as $val) {
         if ($val['biz_order_no'] && $detailList[$val['biz_order_no']]) {
             $detail = $detailList[$val['biz_order_no']];
             // 查询一次master数据,防止多次处理
             $tmpDetailData = Bll_Fyk_Payment_Transfer::getInstance()->getTransferDetailById($detail->id, Model_Fyk_TransferDetail::STATUS_DEALING, true);
             if (empty($tmpDetailData)) {
                 continue;
             }
             $detail->realPrice = $val['real_amount'] * 100;
             $detail->acOrderNo = $val['order_no'];
             $detail->payOrderNo = $val['alipay_order_no'];
             $detail->payDoneTime = date("Y-m-d H:i:s", strtotime($val['alipay_done_time']));
             if ($status == true) {
                 $detail->status = Model_Fyk_TransferDetail::STATUS_SUCCESS;
                 $detail->save();
             } else {
                 $detail->status = Model_Fyk_TransferDetail::STATUS_ERROR;
                 // 退钱
                 $actionMsg = json_encode(array('msg' => "提现失败,提现detailId=" . $detail->id));
                 $arrQueue = array('userId' => $detail['userId'], 'propId' => 0, 'price' => $detail['price'], 'requestId' => 0, 'actionMsg' => $actionMsg, 'actionCode' => Const_Fyk::THE_THIRD_PARTY_WITHDRAWAL_FAILED, 'status' => Model_Fyk_MoneyActionQueue::STATUS_NODEAL, 'createTime' => time());
                 $detail->save();
                 Bll_Fyk_Payment_MoneyAction::getInstance()->insertQueueData($arrQueue);
             }
         }
     }
 }
Esempio n. 2
0
 public function handle_request_internal()
 {
     $userId = $this->_params['userId'];
     $type = $this->_params['type'];
     $source = $this->_params['source'];
     $price = $this->_params['amount'];
     $transferAccount = $this->_params['transferAccount'];
     $transferName = $this->_params['transferName'];
     /***************查询余额,验证是否在范围之内 *******/
     $transferPriceInfo = APF::get_instance()->get_config('fyk_transfer_price');
     if ($transferPriceInfo['min'] * 100 > $price || $transferPriceInfo['max'] * 100 < $price) {
         return $result = array("status" => "error", "errcode" => Const_APIStatus::E_FYK_USER_TRANSFER_AMOUNT_RANGE_ERROR, "message" => "不在提现范围之内");
     }
     //$price  = 1;
     /***************查询余额,验证是否够提现 **********/
     $userAccoutId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId);
     if (empty($userAccoutId)) {
         return $result = array("status" => "error", "errcode" => Const_APIStatus::E_FYK_PROP_ACTION_ACCOUNT_IS_NULL, "message" => "支付中心账户创建失败");
     }
     $balanceResult = Bll_Fyk_Payment_Amount::getInstance()->getBalance($userId);
     if ($price > $balanceResult['balance']) {
         return $result = array("status" => "error", "errcode" => Const_APIStatus::E_FYK_PROP_ACTION_LACK_OF_BALANCE, "message" => "余额不足");
     }
     /*************创建提现申请 *********************/
     $addArr = array('userId' => $userId, 'accountId' => $userAccoutId, 'transferAccount' => $transferAccount, 'transferName' => $transferName, 'price' => $price, 'payType' => $type, 'chargeStatus' => Model_Fyk_TransferDetail::CHARGESTATUS_NODEAL, 'status' => Model_Fyk_TransferDetail::STATUS_INVALID, 'source' => $source, 'createTime' => time());
     $id = Bll_Fyk_Payment_Transfer::getInstance()->insertTransferDetail($addArr);
     $tmpDetailData = Bll_Fyk_Payment_Transfer::getInstance()->getTransferDetailById($id, "", true);
     if (empty($id) || empty($tmpDetailData)) {
         return array("status" => "error", "errcode" => Const_APIStatus::E_UNKNOWN, "message" => "提现插入数据库失败");
     }
     $detailData = $tmpDetailData[0];
     $requestId = Bll_Fyk_Payment_Common::getInstance()->createRequsetId("transferDetail", $id);
     $orderNo = Bll_Fyk_Payment_Common::getInstance()->createOrderNo("transferDetail", $requestId);
     $this->updateDetailTable($detailData, array('requestId' => $requestId, 'orderNo' => $orderNo));
     /************** 提现扣费 **********************/
     $note = "提现扣费";
     $chargeResult = Bll_Fyk_Payment_Amount::getInstance()->chargeMoney($userId, $price, $userAccoutId, $note, $requestId);
     if ($chargeResult['status'] == false) {
         $this->updateDetailTable($detailData, array('chargeStatus' => Model_Fyk_TransferDetail::CHARGESTATUS_ERROR));
         return array("status" => "error", "errcode" => Const_APIStatus::E_FYK_PROP_TRANSFER_CHARGE_FAILURE, "message" => "提现扣费失败");
     }
     $this->updateDetailTable($detailData, array('chargeStatus' => Model_Fyk_TransferDetail::CHARGESTATUS_SUCCESS, 'status' => Model_Fyk_TransferDetail::STATUS_STRATVALID));
     // 记录账户流水表
     $this->insertBalanceLog($id, $userId, $userAccoutId, $price, $chargeResult['balance'], $requestId);
     // 跳转页面
     $twUrl = APF::get_instance()->get_config('wabTransferSuccessUrl');
     $twUrl .= "?amount=" . $price / 100;
     return array("status" => "ok", "data" => array("twUrl" => $twUrl), "message" => "提现成功");
 }
Esempio n. 3
0
 public function handle_request_internal()
 {
     $detailIds = $this->_params['detailIds'];
     $adminId = $this->_params['adminId'];
     $detailIdArr = explode(',', $detailIds);
     $payType = 1;
     $result = Bll_Fyk_Payment_Transfer::getInstance()->addTransferBatch($detailIdArr, $payType, $adminId);
     if ($result['status'] == false) {
         $callBackUrl = APF::get_instance()->get_config('cmsTransferCallBackUrl');
         $this->redirect($callBackUrl . "?status=error&errMsg=" . $result['msg']);
     } else {
         echo Bll_Fyk_Payment_Transfer::getInstance()->buildForm($result['data']['acBatchData']);
         die;
     }
 }