Commit 65cae3e5 by 冷斌

fix bug

parent 638a6d3e
......@@ -50,8 +50,65 @@ class RechangeController extends HomebaseController
return new Pay($this->getPayConfig());
}
protected function getOrderId()
{
$uid =I('uid');
$chargeid=I('chargeid');
$rs=array(
'code'=>0,
'data'=>array(),
'msg'=>'',
);
if (empty($uid)) {
$rs['code']=1001;
$rs['msg']='用户ID不能为空';
} else {
$userinfo=M("users")->field("id,user_nicename,avatar_thumb,coin")->where("id='{$uid}'")->find();
if (!$userinfo) {
$rs['code']=1002;
$rs['msg']='用户不存在';
} else {
$charge=M("charge_rules")->where("id={$chargeid}")->find();
if($charge){
$orderid=$uid.'_'.date('YmdHis').rand(100,999);
$orderinfo=array(
"uid"=>$uid,
"touid"=>$uid,
"money"=>$charge['money'],
"coin"=>$charge['coin'],
"coin_give"=>$charge['give'],
"orderno"=>$orderid,
"type"=>'2',
"ambient"=>'1',
"status"=>0,
"addtime"=>time()
);
// $result=M("users_charge")->add($orderinfo);
$result = 1;
if($result){
$rs['data']['uid']=$uid;
$rs['data']['money']=$charge['money'];
$rs['data']['orderid']=$orderid;
}else{
$rs['code']=1003;
$rs['msg']='订单生成失败';
}
}else{
$rs['code']=1004;
$rs['msg']='订单信息错误';
}
}
}
echo json_encode($rs);
exit;
}
public function wx()
{
$order = $this->getOrderId();
var_dump($order);
die;
$data = [
'ulr' => $this->getPay()->driver('wechat')->gateway('wap')->pay([
'out_trade_no' => time(), // 订单号
......
......@@ -113,7 +113,8 @@
url:"/index.php?g=Appapi&m=rechange&a=wx",
dataType:"json",
data: {
chargeid: _this.sel_num,
uid: _this.userId
},
type:"POST",
success:function(data){
......@@ -136,7 +137,8 @@
url:"/index.php?g=Appapi&m=rechange&a=alipay",
dataType:"json",
data: {
chargeid: _this.sel_num,
uid: _this.userId
},
type:"POST",
success:function(data){
......
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