Exemplo n.º 1
0
 public function CreateOrder($msgBody, $authorId, $payType)
 {
     $now = time();
     $logger = Logger::getLogger('mobilerecharge');
     $logger->debug("开始创建手机充值订单({$now})");
     $arrPayCard = GetPayCalcuInfo::readpaycardid($msgBody['paycardid'], $authorId);
     // ******
     $logger->debug("正在创建手机充值订单({$now}) : paycardid(" . $msgBody['paycardid'] . "),authorId({$authorId} ),arrPayCard(" . print_r($arrPayCard, true) . ")");
     $payCardId = $arrPayCard['paycardid'];
     // 刷卡器ID
     $cusId = $arrPayCard['cusid'];
     // 代理商ID
     $payfee = 0;
     // 利润 = 用户支付给通付宝的钱 - 通付宝从向上的进货价- 支付通道的费率
     $query = "SELECT (fd_recham_paymoney - fd_recham_costmoney) AS payfee \n\t\t\t\tFROM tb_mobilerechamoney WHERE fd_recham_money = '" . $msgBody['rechargeMoney'] . "'";
     $db = new DB_test();
     $dataInDB = $db->get_all($query);
     if (is_array($dataInDB) && count($dataInDB) == 1) {
         $payfee = $dataInDB[0]['payfee'];
         $logger->debug("正在创建手机充值订单({$now}) : 用户支付给通付宝的钱 - 通付宝从向上的进货价 = ({$payfee})");
     } else {
         $logger->error("正在创建手机充值订单({$now}) : 无法获取面额" . $msgBody['rechargeMoney'] . "元所对应的利润值");
     }
     $payTypeFee = 0;
     // 转账费率
     switch ($payType) {
         case "YiBao":
             $payTypeFee = YiBaoPay::GetPayFee($msgBody['payMoney']);
             break;
         case "upmp":
             $payTypeFee = BankPayInfoV3::GetPayFee($msgBody['payMoney']);
             break;
     }
     // ********
     $cusfeeResult = getcusfenrun::get_cusfenrun($cusId, "mobilerecharge", $msgBody['payMoney'], 0, $payfee, 0, date("Y-m-d"), null, null);
     //$cusfeeResult = getcusfenrun :: get_cusfenrun($cusId, "mobilerecharge", $msgBody['payMoney'], $payTypeFee, $payfee, 0, date("Y-m-d"), null, null);
     $logger->debug("正在创建手机充值订单({$now}) : cusId({$cusId} ),cusfeeResult(" . print_r($cusfeeResult, true) . ")");
     $cusfee = $cusfeeResult["cusfee"];
     $cusfee = $cusfee > 0 ? $cusfee : 0;
     $logger->debug("正在创建手机充值订单({$now}) : 通付宝的利润({$payfee}), 代理商的利润({$cusfee})");
     $orderNumber = "tfbmrc" . date("YmdHiss") . mt_rand(1000, 9999);
     // 创建通付宝订单号
     $listno = makeorderno("mobilerechargelist", "mrclist", "mrc");
     // ******
     $sql = "INSERT INTO tb_mobilerechargelist(fd_mrclist_no, fd_mrclist_paycardid, fd_mrclist_cusid, \n\t\t\t\tfd_mrclist_cusfee, fd_mrclist_authorid, fd_mrclist_paydate, \n\t\t\t\tfd_mrclist_bkordernumber, fd_mrclist_sdcrid, fd_mrclist_payrq, fd_mrclist_paytypeid, \n\t\t\t\tfd_mrclist_paytype, fd_mrclist_rechamoney, fd_mrclist_bkmoney, fd_mrclist_rechaphone, \n\t\t\t\tfd_mrclist_paymoney, fd_mrclist_payfee, fd_mrclist_mobileprov, fd_mrclist_bankcardno, \n\t\t\t\tfd_mrclist_state, fd_mrclist_date, fd_mrclist_datetime) VALUES \n\t\t\t\t('{$listno}', '{$payCardId}', '{$cusId}', \n\t\t\t\t'{$cusfee}', '{$authorId}', NOW(), \n\t\t\t\t'{$orderNumber}', 3, '01', '1', \n\t\t\t\t'mobilerecharge', '" . $msgBody['rechargeMoney'] . "', '" . $msgBody['payMoney'] . "', '" . $msgBody['rechargePhone'] . "', \n\t\t\t\t'" . $msgBody['payMoney'] . "', '{$payfee}', '" . $msgBody['mobileProvince'] . "', '" . $msgBody['bankCardId'] . "', \n\t\t\t\t'0', NOW(), NOW());";
     $logger->debug("正在创建手机充值订单({$now}) : ({$sql})");
     $sql = auto_charset($sql, 'utf-8', 'gbk');
     $db->query($sql);
     return $orderNumber;
 }
Exemplo n.º 2
0
 public function CreateOrder($requestBody, $authorId, $payChannel)
 {
     $logger = Logger::getLogger("transfermoney");
     $logger->debug("开始创建转账付款订单");
     // 调用外部函数******
     $logger->debug("正在创建转账付款订单 : 调用函数GetPayCalcuInfo::readpaycardid,传入参数(" . $requestBody["cardReaderId"] . ", " . $authorId . ")");
     $agentInfo = GetPayCalcuInfo::readpaycardid($requestBody["cardReaderId"], $authorId);
     $logger->debug("正在创建转账付款订单 : 调用函数GetPayCalcuInfo::readpaycardid,返回的结果" . print_r($agentInfo, true));
     // ******调用外部函数
     $cardReaderId = $agentInfo["paycardid"];
     // 刷卡器ID
     $agentId = $agentInfo["cusid"];
     // 代理商ID
     $payChannelFee = 0;
     switch ($payChannel) {
         case "YiBao":
             $payChannelFee = YiBaoPay::GetPayFee($requestBody['payMoney']);
             break;
     }
     $orderId = "tfbtfs" . date("YmdHiss") . mt_rand(1000, 9999);
     // 调用外部函数******
     $orderListNumber = makeorderno("transfermoneyglist", "tfmglist", "tfs");
     // ******调用外部函数
     $payDate = date("Y-m-d H:i:s");
     $feeMoney = 0;
     // 调用外部函数******
     $logger->debug("正在创建转账付款订单 : 调用函数getbankid,传入参数(" . $requestBody["receiveBankName"] . ")");
     $receiveBankId = getbankid(u2g($requestBody["receiveBankName"]));
     if ($receiveBankId == "") {
         ErrorReponse::reponError(array("retcode" => "200", "retmsg" => "不支持的银行"));
     }
     $logger->debug("正在创建转账付款订单 : 调用函数getbankid,返回的结果" . $receiveBankId);
     $logger->debug("正在创建转账付款订单 : 调用函数GetPayCalcuInfo :: readPayFee,传入参数({$authorId}, {$receiveBankId}, " . $requestBody['transferMoney'] . ", " . $requestBody['arriveId'] . ", 2, " . $requestBody["payType"] . ")");
     $payChannelFeeInfo = GetPayCalcuInfo::readPayFee($authorId, $receiveBankId, $requestBody['transferMoney'], $requestBody['arriveId'], 2, $requestBody["payType"]);
     $logger->debug("正在创建转账付款订单 : 调用函数GetPayCalcuInfo :: readPayFee,返回的结果" . print_r($payChannelFeeInfo, true));
     if (is_array($payChannelFeeInfo)) {
         $feeMoney = $payChannelFeeInfo["feemoney"];
     }
     $arriveDate = GetPayCalcuInfo::getfeedate($payDate, $payChannelFeeInfo['addday']);
     $logger->debug("正在创建转账付款订单 : 调用函数GetPayCalcuInfo :: getfeedate,返回的结果" . $arriveDate);
     // ******调用外部函数
     $query = "INSERT INTO tb_transfermoneyglist (fd_tfmglist_no, fd_tfmglist_bkordernumber, fd_tfmglist_payrq, fd_tfmglist_paycardid, fd_tfmglist_authorid, fd_tfmglist_sdcrid, fd_tfmglist_sdcrpayfeemoney, fd_tfmglist_sdcragentfeemoney, fd_tfmglist_paytype, fd_tfmglist_paydate, fd_tfmglist_payfeedirct, fd_tfmglist_fucardno, fd_tfmglist_fucardbank, \n\t\tfd_tfmglist_fucardmobile, fd_tfmglist_fucardman, \n\t\tfd_tfmglist_shoucardno, fd_tfmglist_shoucardbank, \n\t\tfd_tfmglist_shoucardman, fd_tfmglist_shoucardmobile, fd_tfmglist_sendsms, fd_tfmglist_shoucardmemo, fd_tfmglist_current, fd_tfmglist_paymoney, fd_tfmglist_payfee, fd_tfmglist_money, fd_tfmglist_feebankid, fd_tfmglist_arrivedate, fd_tfmglist_arriveid, fd_tfmglist_state) VALUES \n\t\t('{$orderListNumber}', '{$orderId}', '01', \n\t\t'{$cardReaderId}', {$authorId}, 3, {$payChannelFee}, \n\t\t0.00, '" . $requestBody["payType"] . "', '{$payDate}', 'f', \n\t\t'" . $requestBody["sendBankCardId"] . "', '" . $requestBody["sendBankName"] . "', \n\t\t'" . $requestBody["sendPhone"] . "', '" . $requestBody["sendPersonName"] . "', \n\t\t'" . $requestBody["receiveBankCardId"] . "', '" . $requestBody["receiveBankName"] . "', \n\t\t'" . $requestBody["receivePersonName"] . "', '" . $requestBody["receivePhone"] . "', 0, '', \n\t\t'RMB', " . $requestBody["transferMoney"] . ", {$feeMoney}, " . $requestBody["payMoney"] . ", {$receiveBankId}, \n\t\t'{$arriveDate}', '" . $requestBody['arriveId'] . "', '0')";
     $logger->debug("新增数据进 tb_transfermoneyglist 的sql" . $query);
     $db = new DB_test();
     $db->query(u2g($query));
     return $orderId;
 }