Commit e5ef5bac by 冷斌

fix bug

parent 7f2cff31
......@@ -7,24 +7,24 @@ class Api_Charge extends PhalApi_Api {
'getAliOrder' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'changeid' => array('name' => 'changeid', 'type' => 'int', 'require' => true, 'desc' => '充值规则ID'),
'coin' => array('name' => 'coin', 'type' => 'string', 'require' => true, 'desc' => '萌豆'),
'coin' => array('name' => 'coin', 'type' => 'string', 'require' => true, 'desc' => '钻石'),
'money' => array('name' => 'money', 'type' => 'string', 'require' => true, 'desc' => '充值金额'),
),
'getWxOrder' => array(
'getWxOrder' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'changeid' => array('name' => 'changeid', 'type' => 'string', 'require' => true, 'desc' => '充值规则ID'),
'coin' => array('name' => 'coin', 'type' => 'string', 'require' => true, 'desc' => '萌豆'),
'coin' => array('name' => 'coin', 'type' => 'string', 'require' => true, 'desc' => '钻石'),
'money' => array('name' => 'money', 'type' => 'string', 'require' => true, 'desc' => '充值金额'),
),
'getIosOrder' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'changeid' => array('name' => 'changeid', 'type' => 'string', 'require' => true, 'desc' => '充值规则ID'),
'coin' => array('name' => 'coin', 'type' => 'string', 'require' => true, 'desc' => '萌豆'),
'coin' => array('name' => 'coin', 'type' => 'string', 'require' => true, 'desc' => '钻石'),
'money' => array('name' => 'money', 'type' => 'string', 'require' => true, 'desc' => '充值金额'),
),
);
}
/* 获取订单号 */
protected function getOrderid($uid){
$orderid=$uid.'_'.date('YmdHis').rand(100,999);
......@@ -35,13 +35,13 @@ class Api_Charge extends PhalApi_Api {
* 微信支付
* @desc 用于 微信支付 获取订单号
* @return int code 操作码,0表示成功
* @return array info
* @return array info
* @return string info[0] 支付信息
* @return string msg 提示信息
*/
public function getWxOrder() {
$rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid;
$changeid=$this->changeid;
$coin=checkNull($this->coin);
......@@ -49,24 +49,24 @@ class Api_Charge extends PhalApi_Api {
$orderid=$this->getOrderid($uid);
$type=2;
if($coin==0){
$rs['code']=1002;
$rs['msg']='信息错误';
return $rs;
}
$configpri = getConfigPri();
$configpub = getConfigPub();
$rs['msg']='信息错误';
return $rs;
}
$configpri = getConfigPri();
$configpub = getConfigPub();
//配置参数检测
if($configpri['wx_appid']== "" || $configpri['wx_mchid']== "" || $configpri['wx_key']== ""){
$rs['code'] = 1002;
$rs['msg'] = '微信未配置';
return $rs;
return $rs;
}
$orderinfo=array(
"uid"=>$uid,
"touid"=>$uid,
......@@ -78,23 +78,23 @@ class Api_Charge extends PhalApi_Api {
"addtime"=>time()
);
$domain = new Domain_Charge();
$info = $domain->getOrderId($changeid,$orderinfo);
if($info==1003){
$rs['code']=1003;
$rs['msg']='订单信息有误,请重新提交';
return $rs;
return $rs;
}else if(!$info){
$rs['code']=1001;
$rs['msg']='订单生成失败';
return $rs;
return $rs;
}
$noceStr = md5(rand(100,1000).time());//获取随机字符串
$time = time();
$paramarr = array(
"appid" => $configpri['wx_appid'],
"body" => "充值{$coin}虚拟币",
......@@ -102,7 +102,7 @@ class Api_Charge extends PhalApi_Api {
"nonce_str" => $noceStr,
"notify_url" => $configpub['site'].'/Appapi/pay/notify_wx',
"out_trade_no"=> $orderid,
"total_fee" => $money*100,
"total_fee" => $money*100,
"trade_type" => "APP"
);
$sign = $this -> sign($paramarr,$configpri['wx_key']);//生成签名
......@@ -112,10 +112,10 @@ class Api_Charge extends PhalApi_Api {
$paramXml .= "<" . $k . ">" . $v . "</" . $k . ">";
}
$paramXml .= "</xml>";
$ch = curl_init ();
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); // 从证书中检查SSL加密算法是否存在
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); // 从证书中检查SSL加密算法是否存在
@curl_setopt($ch, CURLOPT_URL, "https://api.mch.weixin.qq.com/pay/unifiedorder");
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_POST, 1);
......@@ -128,11 +128,11 @@ class Api_Charge extends PhalApi_Api {
curl_close($ch);
$result2 = $this->xmlToArray($resultXmlStr);
if($result2['return_code']=='FAIL'){
$rs['code']=1005;
$rs['msg']=$result2['return_msg'];
return $rs;
return $rs;
}
$time2 = time();
$prepayid = $result2['prepay_id'];
......@@ -147,11 +147,11 @@ class Api_Charge extends PhalApi_Api {
"timestamp" => $time2
);
$paramarr2["sign"] = $this -> sign($paramarr2,$configpri['wx_key']);//生成签名
$rs['info'][0]=$paramarr2;
return $rs;
}
return $rs;
}
/**
* sign拼装获取
*/
......@@ -163,43 +163,43 @@ class Api_Charge extends PhalApi_Api {
$sign .= "key=".$key;
$sign = strtoupper(md5($sign));
return $sign;
}
/**
* xml转为数组
*/
protected function xmlToArray($xmlStr){
$msg = array();
$postStr = $xmlStr;
$msg = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$msg = array();
$postStr = $xmlStr;
$msg = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
return $msg;
}
}
/**
* 支付宝支付
* @desc 用于支付宝支付 获取订单号
* @return int code 操作码,0表示成功
* @return array info
* @return array info
* @return string info[0].orderid 订单号
* @return string msg 提示信息
*/
public function getAliOrder() {
$rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid;
$changeid=$this->changeid;
$coin=checkNull($this->coin);
$money=checkNull($this->money);
$orderid=$this->getOrderid($uid);
$type=1;
if($coin==0){
$rs['code']=1002;
$rs['msg']='信息错误';
return $rs;
}
$rs['msg']='信息错误';
return $rs;
}
$orderinfo=array(
"uid"=>$uid,
"touid"=>$uid,
......@@ -210,7 +210,7 @@ class Api_Charge extends PhalApi_Api {
"status"=>0,
"addtime"=>time()
);
$domain = new Domain_Charge();
$info = $domain->getOrderId($changeid,$orderinfo);
if($info==1003){
......@@ -220,38 +220,38 @@ class Api_Charge extends PhalApi_Api {
$rs['code']=1001;
$rs['msg']='订单生成失败';
}
$rs['info'][0]['orderid']=$orderid;
return $rs;
}
}
/**
* 苹果支付
* @desc 用于苹果支付 获取订单号
* @return int code 操作码,0表示成功
* @return array info
* @return array info
* @return string info[0].orderid 订单号
* @return string msg 提示信息
*/
public function getIosOrder() {
$rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid;
$changeid=$this->changeid;
$coin=checkNull($this->coin);
$money=checkNull($this->money);
$orderid=$this->getOrderid($uid);
$type=3;
if($coin==0){
$rs['code']=1002;
$rs['msg']='信息错误';
return $rs;
$rs['msg']='信息错误';
return $rs;
}
$configpri = getConfigPri();
$configpri = getConfigPri();
$orderinfo=array(
"uid"=>$uid,
"touid"=>$uid,
......@@ -263,7 +263,7 @@ class Api_Charge extends PhalApi_Api {
"addtime"=>time(),
"ambient"=>$configpri['ios_sandbox']
);
$domain = new Domain_Charge();
$info = $domain->getOrderId($changeid,$orderinfo);
if($info==1003){
......@@ -276,8 +276,8 @@ class Api_Charge extends PhalApi_Api {
$rs['info'][0]['orderid']=$orderid;
return $rs;
}
}
}
......@@ -308,7 +308,7 @@ class Model_Live extends PhalApi_Model_NotORM {
if($islive['type']==1){
$rs['type_msg']=md5($islive['type_val']);
}else if($islive['type']==2){
$rs['type_msg']='本房间为收费房间,需支付'.$islive['type_val'].'萌豆';
$rs['type_msg']='本房间为收费房间,需支付'.$islive['type_val'].'钻石';
$rs['type_val']=$islive['type_val'];
$isexist=DI()->notorm->users_coinrecord
->select('id')
......@@ -321,7 +321,7 @@ class Model_Live extends PhalApi_Model_NotORM {
}
}else if($islive['type']==3){
$rs['type_val']=$islive['type_val'];
$rs['type_msg']='本房间为计时房间,每分钟需支付'.$islive['type_val'].'萌豆';
$rs['type_msg']='本房间为计时房间,每分钟需支付'.$islive['type_val'].'钻石';
}
return $rs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment