array( 'method' => 'POST', 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => $postdata, 'timeout' => 15 * 60 // 超时时间(单位:s) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); return $result; } /** * 模拟post进行url请求 * @param string $url * @param string $param */ function request_post($url = '', $param = '') { if (empty($url) || empty($param)) { return false; } $postUrl = $url; $curlPost = $param; $ch = curl_init();//初始化curl curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页 curl_setopt($ch, CURLOPT_HEADER, 0);//设置header curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上 curl_setopt($ch, CURLOPT_POST, 1);//post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); $data = curl_exec($ch);//运行curl curl_close($ch); return $data; } function testAction(){ header('Content-Type:text/json;charset=utf-8'); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Expose-Headers:*'); $url = 'http://mobile.jschina.com.cn/jschina/register.php'; $post_data['appid'] = '10'; $post_data['appkey'] = 'cmbohpffXVR03nIpkkQXaAA1Vf5nO4nQ'; $post_data['member_name'] = 'zsjs123'; $post_data['password'] = '123456'; $post_data['email'] = 'zsjs123@126.com'; $o = ""; foreach ( $post_data as $k => $v ) { $o.= "$k=" . urlencode( $v ). "&" ; } $post_data = substr($o,0,-1); $res = $this->request_post($url, $post_data); print_r($res); } /** * 测试功能 * @param $templateid [] * @return $type 消息类型 */ public function strtest(){ header('Content-Type:text/json;charset=utf-8'); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Expose-Headers:*'); //用户id $uid = $_POST['uid']; //选择支付类型 $type = $_POST['type']; $mo = $_POST['mo']; switch ($mo) { case '1': $pay_amount = 60; //永久会员 $vip_type = 1; break; case '2': $pay_amount = 50; //3月会员 $vip_type = 2; break; case '3': $pay_amount = 40; //1月会员 $vip_type = 3; break; default: echo "type error"; die(); } switch ($type) { case '1': // $pay_bankcode = 8088; // $beizhu = '支付宝原生'; $pay_bankcode = M("td_save")->where("id=1")->getField("td_id"); $beizhu =M("td_save")->where("id=1")->getField("td_str"); //ok break; case '2': $pay_bankcode = M("td_save")->where("id=2")->getField("td_id"); $beizhu =M("td_save")->where("id=2")->getField("td_str"); //ok break; #微信支付需要判断 case '3': $pay_bankcode = M("td_save")->where("id=3")->getField("td_id"); $beizhu =M("td_save")->where("id=3")->getField("td_str"); //ok break; case '4': $pay_bankcode = 8016; $beizhu = '微信抖音'; break; case '5': $pay_bankcode = 8009; $beizhu = '支付宝YY'; break; default: echo "type error"; } $max=M("pay_test")->order("id desc")->limit(1)->find()['order_id']; if($max) { $number=$this->plus("$max","1"); }else{ $number='10000000000000000001'; } //提交时间 $ttime = time(); $pay_applydate = date("Y-m-d H:i:s",$ttime);; //服务端通知 $pay_notifyurl = 'https://www.aa9169.com/bibidd/MediaPayoneseven/huidiao_test'; //页面跳转通知 $pay_callbackurl = 'https://www.aa9169.com/bibidd/MediaPayoneseven/huidiao_test'; //付款人 IP $pay_ip = $this->get_bb_ip(); //商户号 $pay_memberid = 230508633; //订单号 $pay_orderid = "$number" ; //商品名称 $pay_productname = $uid.$beizhu.$pay_bankcode; $dingdan['order_id'] = $number; $dingdan['uid'] = $uid; $dingdan['order_str'] = $pay_productname; $dingdan['order_ip'] = $pay_ip; $dingdan['apply_date'] = $pay_applydate; $dingdan['apply_time'] = $ttime; $dingdan['order_type'] = '待支付'; $dingdan['amount'] = $pay_amount; $stringSignTemp="pay_amount=$pay_amount&pay_applydate=$pay_applydate&pay_bankcode=$pay_bankcode&pay_callbackurl=$pay_callbackurl&pay_memberid=$pay_memberid&pay_notifyurl=$pay_notifyurl&pay_orderid=$pay_orderid&key=0jp1j02wzsllk7ljk2m200dgwe4wsd0x" ; $sign1 = md5($stringSignTemp); $sign= strtoupper($sign1); M("pay_test")->add($dingdan); $post_data = array( 'pay_memberid' => $pay_memberid, 'pay_orderid' =>$pay_orderid, 'pay_applydate' => $pay_applydate, 'pay_bankcode' => $pay_bankcode, 'pay_notifyurl' => $pay_notifyurl, 'pay_callbackurl' => $pay_callbackurl, 'pay_amount' => $pay_amount, 'pay_md5sign' => $sign, 'pay_productname' => $pay_productname, 'pay_ip' => $pay_ip, 'pay_attach' => $vip_type, ); $rs= $this->send_post('http://apizf.mifeng.xiaomfzf.com/Pay_Index.html', $post_data); $new_rs = json_decode($rs,true); $new_rs['uid'] = $uid; if (empty($rs)) { $e_data['status'] = '0'; $e_data['code'] = '204';//未携带参数,请求失败 $e_data['pay_url'] = '';//未携带参数,请求失败 $e_data['message'] = '请重试。'; echo json_encode($e_data); }else{ echo json_encode($new_rs); } } /** * 回调? * @param $templateid [] * @return $type 消息类型 */ public function huidiao_test(){ header('Content-Type:text/json;charset=utf-8'); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Expose-Headers:*'); $post = $_POST; if ($post == null) { $post = file_get_contents("php://input"); } $chenggong['name'] = $post['returncode']; //商户编号 $memberid = $post['memberid']; //订单号 $orderid = $post['orderid']; //订单金额 $amount = $post['amount']; //交易流水号 $transaction_id = $post['transaction_id']; //交易时间 $datetime = $post['datetime']; //交易状态 $returncode = $post['returncode']; //扩展返回 $attach = $post['attach']; if ($chenggong['name']==00) { //交易成功 将用户改成会员 $now_time_chuo = time(); $chenggong['order_type'] = '已支付'; $chenggong['pay_time'] = $now_time_chuo; $chenggong['amount_due'] =$amount; $chenggong['mifeng_id'] =$transaction_id; $uid = M("pay_test")->where("order_id='$orderid'")->getField("uid"); $huiyuan['vip_yn'] = '1'; $huiyuan['vip_time'] = '1'; $huiyuan['vip_money'] = $amount; switch ($attach) { case '1': //永久会员 $huiyuan['vip_over_time'] = '9999999999'; $huiyuan['vip_yn'] = '1'; break; case '2': //季度会员 $over_time_chuo_jj = $now_time_chuo + (3600*24*90); $huiyuan['vip_over_time'] =$over_time_chuo_jj; $huiyuan['vip_yn'] = '2'; break; case '3': //月度会员 $over_time_chuo_yue = $now_time_chuo + (3600*24*30); $huiyuan['vip_over_time'] = $over_time_chuo_yue; $huiyuan['vip_yn'] = '3'; break; default: echo "type error"; die(); } M("pay_test")->where("order_id='$orderid'")->save($chenggong); $post['uid'] = $uid; $post['time'] = time(); M("user_info")->where("id=$uid")->save($huiyuan); M("huidiao_test")->add($post); //代理回调 //查询当前用户是否是代理用户 是则进行 $yn_agent = M("pop_user")->where("get_uid=$uid")->getField("uid"); if (!empty($yn_agent)) { //是代理用户 //更新代理详情列表 M('pop_user')->where("get_uid=$uid and uid=$yn_agent")->setInc('pay_money',$amount); $agent_money = $amount * 0.3; M('pop_user')->where("get_uid=$uid and uid=$yn_agent")->setInc('pay_brokerage',$agent_money); //更新到用户表 M('user_info')->where("id=$yn_agent")->setInc('agent_money',$agent_money); $agent_time = time(); $agent_time_date = date("Y-m-d H:i:s",$agent_time); //新增 代理记录 $data_agent_time_date = array('agent_money_time'=>"$agent_time",'agent_money_date'=>"$agent_time_date"); M('pop_user')->where("get_uid=$uid and uid=$yn_agent")->setField($data_agent_time_date); $agent_jilu_add['uid'] = $yn_agent; $agent_jilu_add['get_uid'] = $uid; $agent_jilu_add['agent_money'] = $agent_money; $agent_jilu_add['pay_money'] = $amount; $agent_jilu_add['time'] = $agent_time; $agent_jilu_add['time_date'] = $agent_time_date; M("agent_money")->add($agent_jilu_add); }else{ //不是 代理用户 } exit('OK'); }else{ } } /** * 测试功能 * @param $templateid [] * @return $type 消息类型 */ public function test(){ header('Content-Type:text/json;charset=utf-8'); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Expose-Headers:*'); if (!empty($_POST)){ $uid = $_POST['uid']; $amount = $_POST['amount']; //代理回调 //查询当前用户是否是代理用户 是则进行 $yn_agent = M("pop_user")->where("get_uid=$uid")->getField("uid"); if (!empty($yn_agent)) { //是代理用户 M('pop_user')->where("get_uid=$uid and uid=$yn_agent")->setInc('pay_money',$amount); $agent_money = $amount * 0.3; M('pop_user')->where("get_uid=$uid and uid=$yn_agent")->setInc('pay_brokerage',$agent_money); M('user_info')->where("id=$yn_agent")->setInc('agent_money',$agent_money); $agent_time = time(); $agent_time_date = date("Y-m-d H:i:s",$agent_time); $data_agent_time_date = array('agent_money_time'=>"$agent_time",'agent_money_date'=>"$agent_time_date"); M('pop_user')->where("get_uid=$uid and uid=$yn_agent")->setField($data_agent_time_date); $agent_jilu_add['uid'] = $yn_agent; $agent_jilu_add['get_uid'] = $uid; $agent_jilu_add['agent_money'] = $agent_money; $agent_jilu_add['pay_money'] = $amount; $agent_jilu_add['time'] = $agent_time; $agent_jilu_add['time_date'] = $agent_time_date; M("agent_money")->add($agent_jilu_add); }else{ //不是 代理用户 } }else{ echo $this->returnData(); } } function plus($a, $b) { if (!is_string($a) || !is_string($b)) { echo '参数必须是字符串类型'; return; } $len = strlen($a) > strlen($b) ? strlen($a) : strlen($b); /// 反转字符串 $ar = strrev($a); $br = strrev($b); $result = ''; for($i = 0 ;$i < $len; $i++) { //从个位开始加,缺的补0 $temp = (empty($ar[$i]) ? 0 : $ar[$i]) + (empty($br[$i]) ? 0 : $br[$i]); if (!empty($apendOne)) { //当后一位进1时加1 $temp += 1; } $apendOne = false; if ($temp > 9) { /// 如果结果大于9 向前进1 减10 做标记 $apendOne = true; $temp -= 10; } $result = $temp . $result; } return (string)$result; } /** * 将订单改为支付中 * @param $templateid [] * @return $type 消息类型 */ public function dingdan_huidiao_one(){ header('Content-Type:text/json;charset=utf-8'); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Expose-Headers:*'); // echo 'OK'; if (!empty($_POST)) { $ttime = time(); $pay_applydate = date("Y-m-d H:i:s",$ttime);; $wula['time'] = $pay_applydate; $wula['name'] = 'dingdan_huidiao_one'; $wula['code'] = '成了'; M("huidiao_test")->add($wula); }else{ $ttime = time(); $pay_applydate = date("Y-m-d H:i:s",$ttime);; $wula['time'] = $pay_applydate; $wula['name'] = 'dingdan_huidiao_one'; $wula['code'] = '失败'; M("huidiao_test")->add($wula); } //商户标号 //订单号 //订单金额 //交易流水号 //交易时间 //交易状态 //扩展返回 //签名 } /** * 接收支付最终回调 * @param $templateid [] * @return $type 消息类型 */ public function huidiao_two(){ header('Content-Type:text/json;charset=utf-8'); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Expose-Headers:*'); if (!empty($_POST)) { echo "OK"; $ttime = time(); $pay_applydate = date("Y-m-d H:i:s",$ttime);; $wula['time'] = $pay_applydate; $wula['name'] = 'huidiao_two'; $wula['code'] = '成了'; M("huidiao_test")->add($wula); }else{ echo "OK"; $ttime = time(); $pay_applydate = date("Y-m-d H:i:s",$ttime);; $wula['time'] = $pay_applydate; $wula['name'] = 'huidiao_two'; $wula['code'] = '失败'; M("huidiao_test")->add($wula); } } /** * 充值金币请求 * @param $templateid [] * @return $type 消息类型 */ public function new_pay(){ header('Content-Type:text/json;charset=utf-8'); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Expose-Headers:*'); //用户id $uid = $_POST['uid']; //选择支付类型 $type = $_POST['type']; $mo = $_POST['mo']; //1是没首充 有奖励 $yn_first_pay = $_POST['yn_first_pay']; switch ($mo) { case '1': $pay_amount = 30; break; case '2': $pay_amount = 50; break; case '3': $pay_amount = 60; break; case '4': $pay_amount = 70; break; case '5': $pay_amount = 100; break; case '6': $pay_amount = 200; break; default: echo "type error"; die(); } switch ($type) { case '1': $pay_bankcode = M("td_save")->where("id=1")->getField("td_id"); $beizhu =M("td_save")->where("id=1")->getField("td_str"); //ok break; case '2': $pay_bankcode = M("td_save")->where("id=2")->getField("td_id"); $beizhu =M("td_save")->where("id=2")->getField("td_str"); //ok break; #微信支付需要判断 case '3': $pay_bankcode = M("td_save")->where("id=3")->getField("td_id"); $beizhu =M("td_save")->where("id=3")->getField("td_str"); //ok break; case '4': $pay_bankcode = M("td_save")->where("id=4")->getField("td_id"); $beizhu =M("td_save")->where("id=4")->getField("td_str"); //ok break; case '5': $pay_bankcode = M("td_save")->where("id=5")->getField("td_id"); $beizhu =M("td_save")->where("id=5")->getField("td_str"); //ok break; default: echo "type error"; } $max=M("pay_test")->order("id desc")->limit(1)->find()['order_id']; if($max) { $number=$this->plus("$max","1"); }else{ $number='10000000000000000001'; } //提交时间 $ttime = time(); $pay_applydate = date("Y-m-d H:i:s",$ttime);; //服务端通知 $pay_notifyurl = 'https://www.aa9169.com/bibidd/MediaPayonesix/huidiao_gold_coins'; //页面跳转通知 $pay_callbackurl = 'https://www.aa9169.com/bibidd/MediaPayonesix/huidiao_gold_coins'; //付款人 IP $pay_ip = $this->get_bb_ip(); //商户号 $pay_memberid = 230508633; //订单号 $pay_orderid = "$number" ; //商品名称 $pay_productname = $uid.$beizhu.$pay_bankcode; $dingdan['order_id'] = $number; $dingdan['uid'] = $uid; $dingdan['order_str'] = $pay_productname; $dingdan['order_ip'] = $pay_ip; $dingdan['apply_date'] = $pay_applydate; $dingdan['apply_time'] = $ttime; $dingdan['order_type'] = '待支付'; $dingdan['amount'] = $pay_amount; $stringSignTemp="pay_amount=$pay_amount&pay_applydate=$pay_applydate&pay_bankcode=$pay_bankcode&pay_callbackurl=$pay_callbackurl&pay_memberid=$pay_memberid&pay_notifyurl=$pay_notifyurl&pay_orderid=$pay_orderid&key=0jp1j02wzsllk7ljk2m200dgwe4wsd0x" ; $sign1 = md5($stringSignTemp); $sign= strtoupper($sign1); M("pay_test")->add($dingdan); $post_data = array( 'pay_memberid' => $pay_memberid, 'pay_orderid' =>$pay_orderid, 'pay_applydate' => $pay_applydate, 'pay_bankcode' => $pay_bankcode, 'pay_notifyurl' => $pay_notifyurl, 'pay_callbackurl' => $pay_callbackurl, 'pay_amount' => $pay_amount, 'pay_md5sign' => $sign, 'pay_productname' => $pay_productname, 'pay_ip' => $pay_ip, 'pay_attach' => $yn_first_pay, ); $rs= $this->send_post('http://apizf.mifeng.xiaomfzf.com/Pay_Index.html', $post_data); $new_rs = json_decode($rs,true); $new_rs['uid'] = $uid; if (empty($rs)) { $e_data['status'] = '0'; $e_data['code'] = '204';//未携带参数,请求失败 $e_data['pay_url'] = '';//未携带参数,请求失败 $e_data['message'] = '请重试。'; echo json_encode($e_data); }else{ echo json_encode($new_rs); } } /** * 金币充值回调 * @param $templateid [] * @return $type 消息类型 */ public function huidiao_gold_coins(){ header('Content-Type:text/json;charset=utf-8'); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Expose-Headers:*'); $post = $_POST; if ($post == null) { $post = file_get_contents("php://input"); } $chenggong['name'] = $post['returncode']; //商户编号 $memberid = $post['memberid']; //订单号 $orderid = $post['orderid']; //订单金额 $amount = $post['amount']; //交易流水号 $transaction_id = $post['transaction_id']; //交易时间 $datetime = $post['datetime']; //交易状态 $returncode = $post['returncode']; //扩展返回 $attach = $post['attach']; //attach 如果是0 if ($chenggong['name']==00) { //交易成功 将用户改成会员 $now_time_chuo = time(); $chenggong['order_type'] = '已支付'; $chenggong['pay_time'] = $now_time_chuo; $chenggong['amount_due'] =$amount; $chenggong['mifeng_id'] =$transaction_id; $uid = M("pay_test")->where("order_id='$orderid'")->getField("uid"); //如果返回的值是1 说明是用户两小时内首充 if ($attach==1) { $amount_gold_coins = $amount + ($amount * 0.2); M("user_info")->where("id=$uid")->setInc('gold_coins_number',$amount_gold_coins); }else{ M("user_info")->where("id=$uid")->setInc('gold_coins_number',$amount); } M("user_info")->where("id=$uid")->setField('vip_money','1'); // 146784 146784 146784 //修改订单相关 并且添加支付表 M("pay_test")->where("order_id='$orderid'")->save($chenggong); $post['uid'] = $uid; $post['time'] = time(); M("huidiao_test")->add($post); //代理回调 //查询当前用户是否是代理用户 是则进行 $yn_agent = M("pop_user")->where("get_uid=$uid")->getField("uid"); if (!empty($yn_agent)) { //是代理用户 //更新代理详情列表 M('pop_user')->where("get_uid=$uid and uid=$yn_agent")->setInc('pay_money',$amount); $agent_money = $amount * 0.3; M('pop_user')->where("get_uid=$uid and uid=$yn_agent")->setInc('pay_brokerage',$agent_money); //更新到用户表 M('user_info')->where("id=$yn_agent")->setInc('agent_money',$agent_money); $agent_time = time(); $agent_time_date = date("Y-m-d H:i:s",$agent_time); //新增 代理记录 $data_agent_time_date = array('agent_money_time'=>"$agent_time",'agent_money_date'=>"$agent_time_date"); M('pop_user')->where("get_uid=$uid and uid=$yn_agent")->setField($data_agent_time_date); $agent_jilu_add['uid'] = $yn_agent; $agent_jilu_add['get_uid'] = $uid; $agent_jilu_add['agent_money'] = $agent_money; $agent_jilu_add['pay_money'] = $amount; $agent_jilu_add['time'] = $agent_time; $agent_jilu_add['time_date'] = $agent_time_date; M("agent_money")->add($agent_jilu_add); }else{ //不是 代理用户 } exit('OK'); }else{ } } /** * 测试功能 * @param $templateid [] * @return $type 消息类型 */ public function add_coin_test(){ $data = $this->returnData(); if (!empty($_POST)){ $attach = $_POST['attach']; $amount = $_POST['amount']; $uid = 1024; if ($attach==1) { $amount_gold_coins = $amount + ($amount * 0.2); M("user_info")->where("id=$uid")->setInc('gold_coins_number',$amount_gold_coins); }else{ M("user_info")->where("id=$uid")->setInc('gold_coins_number',$amount); } }else{ echo $this->returnData(); } } /** * 开通会员 *首先判断 是否是会员 * 在判断 用户是否有足够金币 * * @param $templateid [] * @return $type 消息类型 */ public function user_vip_open(){ header('Content-Type:text/json;charset=utf-8'); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Expose-Headers:*'); if (!empty($_POST)){ $uid = $_POST['uid']; //1:68 //2:58 //3:48 $mo = $_POST['mo']; $huiyuan_time_list =M("user_info")->where("id=$uid")->field("vip_over_time,gold_coins_number")->select(); // $huiyuan_time = $huiyuan_time_list[0]['vip_over_time']; $user_coins_amount = $huiyuan_time_list[0]['gold_coins_number']; $now_time = time(); if ($huiyuan_time>$now_time) { //是vip 输出结束 $data['code'] = '200'; $data['status'] = '1'; $data['message'] = 'is_vip'; echo json_encode($data); } else { //不是vip 判断剩余金币数 switch ($mo) { case '1': $pay_amount = 68; //永久会员 $vip_type = 1; break; case '2': $pay_amount = 58; //3月会员 $vip_type = 2; break; case '3': $pay_amount = 48; //1月会员 $vip_type = 3; break; default: echo "type error"; die(); } if ($user_coins_amount>=$pay_amount) { //有足够金币 //交易成功 将用户改成会员 $now_time_chuo = time(); switch ($mo) { case '1': //永久会员 $huiyuan['vip_over_time'] = '9999999999'; $huiyuan['vip_yn'] = '1'; break; case '2': //季度会员 $over_time_chuo_jj = $now_time_chuo + (3600*24*90); $huiyuan['vip_over_time'] =$over_time_chuo_jj; $huiyuan['vip_yn'] = '2'; break; case '3': //月度会员 $over_time_chuo_yue = $now_time_chuo + (3600*24*30); $huiyuan['vip_over_time'] = $over_time_chuo_yue; $huiyuan['vip_yn'] = '3'; break; default: echo "type error"; die(); } $vip_table_list['code'] = $mo; $vip_table_list['time'] =$now_time_chuo ; $vip_table_list['uid'] = $uid; $vip_table_list['amount'] = $pay_amount; $user_vip_fufei = M('user_info')->where("id=$uid")->setDec('gold_coins_number', $pay_amount); if (!$user_vip_fufei) { echo PHP_EOL.'付费失败结束'; die(); }else{ M("vip_add_list")->add($vip_table_list); M("user_info")->where("id=$uid")->save($huiyuan); $data['code'] = '200'; $data['status'] = '2'; $data['message'] = 'ok'; echo json_encode($data); } }else{ //金币不足 $data['code'] = '200'; $data['status'] = '3'; $data['message'] = 'not_sufficient_funds'; echo json_encode($data); } } }else{ echo $this->returnData(); } } }