예제 #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;
 }
예제 #2
0
 public function YiBaoPayFeedback($payResult, $orderId)
 {
     if ($payResult["r1_Code"] == "1") {
         $db = new DB_test();
         $query = "update  tb_transfermoneyglist set fd_tfmglist_payrq ='00' ,fd_tfmglist_paydate = NOW(), fd_tfmglist_bkntno = '" . $payResult['r2_TrxId'] . "'  where fd_tfmglist_bkordernumber = '{$orderId}'";
         $db->query($query);
         $query = "update  tb_agentpaymoneylist set fd_agpm_payrq = '00', fd_agpm_bkntno = '" . $payResult['r2_TrxId'] . "'  where fd_agpm_bkordernumber = '{$orderId}'";
         $db->query($query);
         $query = "select 1 from tb_cus_fenrunglist where 1 and  fd_frlist_bkordernumber = '" . $orderId . "' limit 1";
         if ($db->execute($query)) {
         } else {
             $query = "SELECT fd_tfmglist_authorid AS authorid, fd_author_cusid AS cusid, fd_tfmglist_paycardid AS paycardid, fd_tfmglist_paydate AS paydate, fd_tfmglist_paymoney AS paymoney, fd_tfmglist_payfee AS payfee, fd_tfmglist_sdcrpayfeemoney AS sdcrpayfeemoney, fd_tfmglist_paytype AS paytype, fd_tfmglist_sdcrpayfeemoney FROM tb_transfermoneyglist WHERE fd_tfmglist_bkordernumber = '{$orderId}'";
             if ($db->execute($query)) {
                 $arr_info = $db->get_one($query);
                 $cusfee = 0;
                 $tfbfenrun = 0;
                 $cusfeeResult = getcusfenrun::get_cusfenrun($arr_info['cusid'], $arr_info['paytype'], $arr_info['payMoney'], $arr_info['fd_tfmglist_sdcrpayfeemoney'], $arr_info['fd_tfmglist_payfee'], 0, date("Y-m-d"), null, null);
                 $cusfee = $cusfeeResult["cusfee"];
                 $tfbfenrun = $arr_cusfee['tfbfenrun'];
                 unset($dateArray);
                 $dateArray['fd_frlist_authorid'] = $arr_info['authorid'];
                 $dateArray['fd_frlist_cusid'] = $arr_info['cusid'];
                 $dateArray['fd_frlist_paycardid'] = $arr_info['paycardid'];
                 $dateArray['fd_frlist_paydate'] = $arr_info['paydate'];
                 $dateArray['fd_frlist_paymoney'] = $arr_info['paymoney'];
                 $dateArray['fd_frlist_payfee'] = $arr_info['payfee'];
                 $dateArray['fd_frlist_cusfee'] = $cusfee;
                 $dateArray['fd_frlist_bkordernumber'] = $orderId;
                 $dateArray['fd_frlist_payrq'] = '00';
                 $dateArray['fd_frlist_paytype'] = $arr_info['paytype'];
                 $dateArray['fd_frlist_sdcrid'] = 3;
                 $dateArray['fd_frlist_sdcrpayfeemoney'] = $arr_info['sdcrpayfeemoney'];
                 $dateArray['fd_frlist_tfbfenrun'] = $tfbfenrun;
                 $dateArray['fd_frlist_datetime'] = date("Y-m-d H:i:s");
                 $db->insert("tb_cus_fenrunglist", $dateArray);
             }
         }
     }
 }
 public function bkordernumbertokey($bkordernumber, $transStatus)
 {
     $arr_merinfo = array();
     $arr_merinfo2 = array();
     //通付宝银行卡对银行卡业务
     $query = "select fd_agpm_sdcrid as sdcrid,fd_agpm_authorid as authorid ,fd_agpm_paytype as paytype,\nfd_agpm_paydate as paydate,fd_agpm_cusid as cusid ,fd_agpm_sdcrpayfeemoney as sdcrpayfeemoney,\n        fd_agpm_paycardid as paycardid,fd_agpm_payfee as payfee ,fd_agpm_paymoney as paymoney\n          from tb_agentpaymoneylist where fd_agpm_bkordernumber = '{$bkordernumber}' limit 1";
     if ($this->DB_test->execute($query)) {
         $arr_merinfo = $this->DB_test->get_one($query);
     }
     //订单付款业务
     $query = "select fd_oplist_sdcrid as sdcrid,fd_oplist_authorid as authorid ,fd_oplist_paytype as paytype,\n                fd_oplist_paydate as paydate ,\n        fd_oplist_paycardid as paycardid,fd_oplist_payfee as payfee ,fd_oplist_paymoney as paymoney    from tb_orderpayglist where 1 and  fd_oplist_bkordernumber = '{$bkordernumber}' limit 1";
     $this->DB_test->query($query);
     if ($this->DB_test->execute($query)) {
         $arr_merinfo = $this->DB_test->get_one($query);
     }
     //购买刷卡器业务
     $query = "select fd_orderlist_sdcrid as sdcrid,fd_orderlist_authorid as authorid ,\n                 fd_orderlist_paytype as paytype, fd_orderlist_paydate as paydate ,\n                 fd_orderlist_price as orderprice,fd_orderlist_num as ordernum,fd_orderlist_cusid as cusid,\n                fd_orderlist_paycardid as paycardid,fd_orderlist_payfee as payfee ,fd_orderlist_ordermoney as paymoney  from tb_orderglist where 1 and  fd_orderlist_bkordernumber = '{$bkordernumber}' limit 1";
     if ($this->DB_test->execute($query)) {
         $arr_merinfo = $this->DB_test->get_one($query);
     }
     //手机卡充值业务
     $query = "select fd_mrclist_sdcrid as sdcrid ,fd_mrclist_authorid as authorid ,\n               fd_mrclist_paytype as paytype,fd_mrclist_paydate as paydate ,fd_mrclist_cusid as cusid,\n               fd_mrclist_sdcrpayfeemoney as sdcrpayfeemoney,\n               fd_mrclist_paycardid as paycardid,fd_mrclist_payfee as payfee ,fd_mrclist_paymoney as paymoney\n               from tb_mobilerechargelist where 1  and  fd_mrclist_bkordernumber = '{$bkordernumber}' limit 1";
     if ($this->DB_test->execute($query)) {
         $arr_merinfo = $this->DB_test->get_one($query);
     }
     //qq充值业务
     $query = "select fd_mrclist_sdcrid as sdcrid ,fd_mrclist_authorid as authorid ,\n                 fd_mrclist_paytype as paytype,fd_mrclist_paydate as paydate ,\n\n               fd_mrclist_sdcrpayfeemoney as sdcrpayfeemoney,\n                 fd_mrclist_paycardid as paycardid ,fd_mrclist_payfee as payfee ,fd_mrclist_cusid as cusid,\n                 fd_mrclist_paymoney as paymoney from tb_qqrechargelist where 1 and\n                 fd_mrclist_bkordernumber = '{$bkordernumber}' limit 1";
     if ($this->DB_test->execute($query)) {
         $arr_merinfo = $this->DB_test->get_one($query);
     }
     //代理商购买刷卡器
     $query = "select fd_selt_sdcrid as sdcrid ,fd_selt_authorid as authorid ,\n               fd_selt_paytype as paytype,fd_selt_paydate as paydate ,fd_selt_cusid,\n        fd_selt_paycardid as paycardid ,fd_selt_payfee as payfee ,fd_selt_paymoney as paymoney from tb_salelist\n         where 1 and  fd_selt_bkordernumber = '{$bkordernumber}' limit 1";
     if ($this->DB_test->execute($query)) {
         $arr_merinfo = $this->DB_test->get_one($query);
     }
     //获取第一次刷卡器交易成功时间
     if ($transStatus == '00') {
         $paycardid = $arr_merinfo['paycardid'];
         $paydate = $arr_merinfo['paydate'];
         if ($arr_merinfo['paydate'] == '0000-00-00' or $arr_merinfo['paydate'] == '') {
             $paydate = date("Y-m-d");
             $arr_merinfo['paydate'] = date("Y-m-d");
         }
         $this->paycardfirstactive($paycardid, $paydate);
     }
     $arr_merinfo['bkordernumber'] = $bkordernumber;
     $arr_merinfo['payrq'] = $transStatus;
     //获取分润金额
     $arr_cusfee = getcusfenrun::get_cusfenrun($arr_merinfo['cusid'], $arr_merinfo['paytype'], $arr_merinfo['paymoney'], $arr_merinfo['sdcrpayfeemoney'], $arr_merinfo['payfee'], $arr_merinfo['feelirun'], $paydate, $arr_merinfo['orderprice'], $arr_merinfo['ordernum']);
     $arr_merinfo['cusfee'] = $arr_cusfee['cusfee'];
     $arr_merinfo['tfbfenrun'] = $arr_cusfee['tfbfenrun'];
     $dle = $this->insertintocusfee($arr_merinfo);
     //插入分润金额;
     //获取交易时银联的合约公司KEY
     $query = "select\n\t\t         fd_sdcr_merid as merid,fd_sdcr_securitykey as securitykey,\n\t\t         fd_sdcr_id as sdcrid,fd_sdcr_payfee as sdcrpayfee,fd_sdcr_tradeurl as tradeurl,\n\t\t\t\t fd_sdcr_queryurl as queryurl,fd_sdcr_minpayfee as minsdcrpayfee,fd_sdcr_agentfee as sdcragentfee from tb_sendcenter\n where fd_sdcr_id= '" . $arr_merinfo['sdcrid'] . "'";
     if ($this->DB_test->execute($query)) {
         $arr_merinfo2 = $this->DB_test->get_one($query);
     }
     $arr_retrunmerinfo = array_merge($arr_merinfo, $arr_merinfo2);
     return $arr_retrunmerinfo;
 }