Ejemplo n.º 1
0
 public function drawcash($bankinfo, $notifyurl)
 {
     $uid = is_login();
     $this->config = C('DRAW_CASH');
     $time = NOW_TIME;
     $tradFlowNo = time_format($time, 'Ymd') . $this->config['MERCHANTID'] . substr(floor(microtime($time) * 1000), -8);
     //head文件
     $head = array('version' => '01', 'type' => '0001', 'channelNo' => 'HM', 'tradDate' => time_format($time, 'Ymd'), 'tradTime' => time_format($time, 'His'), 'tradFlowNo' => $tradFlowNo, 'tradNo' => 'ES0007');
     //交易代码
     //body文件
     $body = array('tranSeqId' => $tradFlowNo, 'merchantNo' => $this->config['MERCHANTID'], 'alias' => $this->config['ALIAS'], 'submitDate' => time_format($time, 'Ymd'), 'isNeedNotify' => '0', 'notifyUrl' => $notifyurl, 'batchUse' => '01', 'bankId' => $bankinfo['bankId'], 'acctNo' => $bankinfo['acctNo'], 'acctName' => $bankinfo['acctName'], 'acctAttribute' => '02', 'bankName' => $bankinfo['bankName'], 'bankProvince' => $bankinfo['bankProvince'], 'bankCity' => $bankinfo['bankCity'], 'cityCode' => '', 'amount' => $bankinfo['amount'], 'currencyType' => 'CNY', 'mobilePhone' => '', 'remark' => '');
     $message = array('head' => $head, 'body' => $body);
     include_once APP_PATH . '/BaoyiPay/BaoyiPay.php';
     $xml = to_xmlstring1($message);
     $mac = md5($xml . $this->config['MERKEY']);
     $para = array('tradNo' => 'ES0007', 'type' => '0001', 'merchantNo' => $this->config['MERCHANTID'], 'data' => $xml, 'mac' => $mac);
     // D('AccountLog')->record($head, $xml, $mac, 7);
     $text = $this->getHttpResponseGet($this->config['DRAW_URL'], $para);
     $para = md5Response($text, $this->config['MERKEY']);
     if (!$para) {
         $this->error('返回信息不正确');
     }
     if ($para['status'] == '000000000') {
         //提现记录
         $drawcashlist = array('pid' => 0, 'bussflowno' => $tradFlowNo, 'amount' => $bankinfo['amount'], 'create_time' => NOW_TIME, 'update_time' => NOW_TIME);
         M('DrawcashList')->add($drawcashlist);
         return $tradFlowNo;
     } else {
         $this->error($para['statusMsg']);
     }
 }
Ejemplo n.º 2
0
 public function drawcash($bankinfo, $notifyurl)
 {
     $uid = is_login();
     $this->config = C('DRAW_CASH');
     $time = NOW_TIME;
     $tradFlowNo = time_format($time, 'Ymd') . $this->config['MERCHANTID'] . substr(floor(microtime($time) * 1000), -8);
     //head文件
     $head = array('version' => '01', 'type' => '0001', 'channelNo' => 'HM', 'tradDate' => time_format($time, 'Ymd'), 'tradTime' => time_format($time, 'His'), 'tradFlowNo' => $tradFlowNo, 'tradNo' => 'ES0007');
     //交易代码
     //body文件
     $body = array('tranSeqId' => $tradFlowNo, 'merchantNo' => $this->config['MERCHANTID'], 'alias' => $this->config['ALIAS'], 'submitDate' => time_format($time, 'Ymd'), 'isNeedNotify' => '0', 'notifyUrl' => $notifyurl, 'batchUse' => '01', 'bankId' => $bankinfo['bankId'], 'acctNo' => $bankinfo['acctNo'], 'acctName' => $bankinfo['acctName'], 'acctAttribute' => '02', 'bankName' => $bankinfo['bankName'], 'bankProvince' => $bankinfo['bankProvince'], 'bankCity' => $bankinfo['bankCity'], 'cityCode' => '', 'amount' => $bankinfo['amount'], 'currencyType' => 'CNY', 'mobilePhone' => '', 'remark' => '');
     $message = array('head' => $head, 'body' => $body);
     include_once APP_PATH . '/BaoyiPay/BaoyiPay.php';
     $xml = to_xmlstring1($message);
     $mac = md5($xml . $this->config['MERKEY']);
     $para = array('tradNo' => 'ES0007', 'type' => '0001', 'merchantNo' => $this->config['MERCHANTID'], 'data' => $xml, 'mac' => $mac);
     //D('AccountLog')->record($head, $xml, $mac, 0);
     $text = $this->getHttpResponseGet($this->config['DRAW_URL'], $para);
     $para = md5Response($text, $this->config['MERKEY']);
     if (!$para) {
         $this->ajaxReturn(array('status' => 0, 'info' => '信息错误'));
         exit;
     }
     //D('AccountLog')->record($head, $para['data'], $para['mac'], 1);
     if ($para['status'] == '000000000') {
         //修改提现金额
         $product = M('Product')->find($bankinfo['pid']);
         if (!$product) {
             $this->error('该项目信息不存在');
         }
         //计算可提金额
         $amount = $product['finish_amount'] - $product['drawcash_amount'];
         //如果余额不足
         if ($amount <= 0) {
             $this->error('可提金额不足');
         }
         //当前时间
         $drawcash_date = date('Ymd', NOW_TIME);
         $drawcash_amount = $product['drawcash_amount'] + $bankinfo['amount'];
         $product = array('id' => $bankinfo['pid'], 'drawcash_date' => $drawcash_date, 'drawcash_amount' => $drawcash_amount);
         M('Product')->save($product);
         //提现记录
         $drawcashlist = array('pid' => $bankinfo['pid'], 'bussflowno' => $tradFlowNo, 'amount' => $bankinfo['amount'], 'create_time' => NOW_TIME, 'update_time' => NOW_TIME);
         M('DrawcashList')->add($drawcashlist);
         $this->success('提现成功,你注意账户变化');
     } else {
         $this->error($para['statusMsg']);
     }
 }