|
@@ -24,15 +24,23 @@ class convertControl extends mobileControl
|
|
|
|
|
|
public function fcodeOp()
|
|
|
{
|
|
|
- $fcode_fileds = ['appid','appkey','convert_sn','convert_type','batch_code','commonid','time','mobile','return_url'];
|
|
|
+ $fileds = ['appid','appkey','convert_sn','convert_type','batch_code','commonid','time','mobile','return_url'];
|
|
|
|
|
|
- if($this->check_parmas($_GET) === false) {
|
|
|
- return self::outsuccess(["title" => "请求参数异常","msg"=> "请不要随意修改参数哦"],"convert/error");
|
|
|
+ $fCallBack = true;
|
|
|
+ $appid = $_GET['appid'];
|
|
|
+ $convert_sn = $_GET['convert_sn'];
|
|
|
+ $return_url = $_GET['return_url'];
|
|
|
+
|
|
|
+ if($this->check_parmas($_GET,$fileds) === false) {
|
|
|
+ $errmsg = ["title" => "请求参数异常","msg"=> "请不要随意修改参数哦"];
|
|
|
+ goto ErrorHandle;
|
|
|
}
|
|
|
- $convert = new openapi\Convertor($fcode_fileds);
|
|
|
+
|
|
|
+ $convert = new openapi\Convertor($fileds);
|
|
|
$fSucc = $convert->verify($_GET);
|
|
|
if($fSucc === false) {
|
|
|
- return self::outsuccess(["title" => "请求参数异常","msg"=> "请不要随意修改参数哦"],"convert/error");
|
|
|
+ $errmsg = ["title" => "请求参数异常","msg"=> "请不要随意修改参数哦"];
|
|
|
+ goto ErrorHandle;
|
|
|
}
|
|
|
|
|
|
$convert_type = $_GET['convert_type'];
|
|
@@ -41,50 +49,60 @@ class convertControl extends mobileControl
|
|
|
$batch_code = $_GET['batch_code'];
|
|
|
$common_id = intval($_GET['commonid']);
|
|
|
if(empty($batch_code) || $common_id <= 0) {
|
|
|
- return self::outsuccess(["title" => "商品下架","msg"=> "没有找到要兑换的商品哦"],"convert/error");
|
|
|
+ $errmsg = ["title" => "商品下架","msg"=> "没有找到要兑换的商品哦"];
|
|
|
+ goto ErrorHandle;
|
|
|
}
|
|
|
+
|
|
|
$find = $convert->exist($_GET['convert_sn'],$_GET['appid']);
|
|
|
if($find) {
|
|
|
- return self::outsuccess(["title" => "商品已兑","msg"=> "这个商品已被兑换过拉"],"convert/error");
|
|
|
+ $fCallBack = false;
|
|
|
+ $errmsg = ["title" => "商品下架","msg"=> "没有找到要兑换的商品哦"];
|
|
|
+ goto ErrorHandle;
|
|
|
}
|
|
|
|
|
|
$mobile = $_GET['mobile'];
|
|
|
- $mobile_loginner = new login\mobile_log($mobile);
|
|
|
-
|
|
|
- if($mobile_loginner->ismember()) {
|
|
|
- $mobile_loginner->login();
|
|
|
- } else {
|
|
|
- $mobile_loginner->register('',0,$mobile);
|
|
|
- $mobile_loginner->login();
|
|
|
- }
|
|
|
-
|
|
|
- $oper = new fcode\operator($common_id,$batch_code,$mobile,'');
|
|
|
- $fcode = $oper->grabed();
|
|
|
-
|
|
|
- if($fcode == false)
|
|
|
+ if(!session_helper::logined())
|
|
|
{
|
|
|
- $fcode = $oper->grab();
|
|
|
- if($fcode == false) {
|
|
|
- return self::outsuccess(["title" => "商品下架","msg"=> "这个商品已经被换光拉"],"convert/error");
|
|
|
+ $mobile_loginner = new login\mobile_log($mobile);
|
|
|
+ if($mobile_loginner->ismember()) {
|
|
|
+ $mobile_loginner->login();
|
|
|
} else {
|
|
|
- $convert->add();
|
|
|
- //notice jyc
|
|
|
- return self::outsuccess("","convert/success");
|
|
|
+ $mobile_loginner->register('',0,$mobile);
|
|
|
+ $mobile_loginner->login();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ $oper = new fcode\operator($common_id,$batch_code,$mobile,'');
|
|
|
+ $fcode = $oper->send();
|
|
|
+ if($fcode == false) {
|
|
|
+ $errmsg = ["title" => "兑换失败","msg"=> "这个商品已经被兑换完了"];
|
|
|
+ goto ErrorHandle;
|
|
|
+ }
|
|
|
else {
|
|
|
- return self::outsuccess(["title" => "商品已兑","msg"=> "这个商品已被兑换过拉"],"convert/error");
|
|
|
+ $return_url = $_GET['return_url'];
|
|
|
+ QueueClient::push('OnGoodsConvert',['appid' => $appid,'convert_sn' => $convert_sn,'return_url' => $return_url,'success' => true]);
|
|
|
+ $convert->add_fcode($_GET['appid'],$_GET['convert_sn'],$_GET['batch_code'],$_GET['commonid'],$fcode,$_GET['mobile']);
|
|
|
+
|
|
|
+ return self::outsuccess(["title" => "兑换成功","msg"=> "您已经成功兑换商品"],"convert/success");
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- return self::outsuccess(["title" => "红包兑换","msg"=> "这个业务还没有开启哦"],"convert/error");
|
|
|
+ $errmsg = ["title" => "红包兑换","msg"=> "这个业务还没有开启哦"];
|
|
|
+ goto ErrorHandle;
|
|
|
}
|
|
|
+
|
|
|
+ ErrorHandle:
|
|
|
+ if($fCallBack) {
|
|
|
+ QueueClient::push('OnGoodsConvert',['appid' => $appid,'convert_sn' => $convert_sn,'return_url' => $return_url,'success' => false]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return self::outsuccess($errmsg,"convert/error");
|
|
|
}
|
|
|
|
|
|
- private function check_parmas($input)
|
|
|
+ private function check_parmas($input,$fields)
|
|
|
{
|
|
|
- $fields = ['appid','convert_sn','appkey','mobile','convert_type','signed'];
|
|
|
- foreach ($fields as $key) {
|
|
|
+ foreach ($fields as $key)
|
|
|
+ {
|
|
|
if(!array_key_exists($key,$input)) return false;
|
|
|
else {
|
|
|
if(empty($input[$key])) return false;
|