123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/4/6
- * Time: 下午1:41
- */
- require_once(BASE_ROOT_PATH . '/helper/fcode/operator.php');
- require_once(BASE_ROOT_PATH . '/helper/fcode/mfcode.php');
- class fcodeControl extends mobileControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function indexOp()
- {
- $common_id = intval($_GET['common_id']);
- $batch_code = $_GET['batch_code'];
- $sid = $_SESSION['MPHPSESSID'];
- $status = intval($_GET['status']);
- $mobile = $_GET['mobile'];
- if($common_id <= 0 || empty($batch_code)) {
- return self::outerr(errcode::ErrParamter,"错误的参数","fcode/error");
- }
- $oper = new fcode\operator($common_id,$batch_code);
- if(empty($mobile)) {
- $fcode = $oper->grabed();
- } else {
- $fcode = $oper->grabed($mobile);
- }
- $goods = $this->goods($common_id);
- if($fcode == false)
- {
- if(empty($goods)) {
- return self::outsuccess(array('error' => "商品已经下架,请关注其它F码"),"fcode/error");
- }
- elseif($status < 0) {
- return self::outsuccess(array('error' => "该商品F码已经被抢光~"),"fcode/error");
- }
- else {
- $name = $goods['goods_name'];
- $price = $goods['goods_price'];
- $image = $goods['goods_image'];
- $image = cthumb($image, 1280, 6);
- return self::outsuccess(array('name' => $name,'price' => $price,'image' => $image,
- 'common_id' => $common_id,'batch_code' => $batch_code,'sid' => $sid), "fcode/index",'wap');
- }
- }
- else
- {
- $name = $goods['goods_name'];
- $price = $goods['goods_price'];
- $image = $goods['goods_image'];
- $image = cthumb($image, 1280, 6);
- $fcoder = new \fcode\mfcode($fcode);
- if($fcoder->binded()) {
- return self::outsuccess(array('fcode' => $fcode,'sid' => $sid,'name' => $name,'price' => $price,'image' => $image),"fcode/success");
- } else {
- return self::outsuccess(array('fcode' => $fcode,'sid' => $sid,'name' => $name,'price' => $price,'image' => $image),"fcode/bind");
- }
- }
- }
- private function goods($common_id)
- {
- $goods_id = commonid_helper::instance()->one_goods($common_id);
- $mod = Model('goods');
- $goods = $mod->find($goods_id);
- return $goods;
- }
- public function openOp()
- {
- $common_id = intval($_GET['common_id']);
- $batch_code = $_GET['batch_code'];
- $sid = $_SESSION['MPHPSESSID'];
- if($common_id <= 0 || empty($batch_code)) {
- $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$common_id}&batch_code={$batch_code}&HPHPSESSID={$sid}";
- return self::outsuccess(array('url' => $url));
- }
- $oper = new fcode\operator($common_id,$batch_code);
- $fcode = $oper->grabed();
- if($fcode == false)
- {
- $fcode = $oper->grab();
- if($fcode == false) {
- $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$common_id}&batch_code={$batch_code}&HPHPSESSID={$sid}&status=-1";
- return self::outsuccess(array('url' => $url));
- }
- }
- else {
- $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$common_id}&batch_code={$batch_code}&HPHPSESSID={$sid}";
- return self::outsuccess(array('url' => $url));
- }
- }
- public function bindOp()
- {
- $common_id = intval($_GET['common_id']);
- $batch_code = $_GET['batch_code'];
- if($common_id <= 0 || empty($batch_code)) {
- return self::outerr(errcode::ErrParamter,"错误的参数");
- }
- $mobile = $_GET['mobile'];
- $validator = new Validator();
- $validator->setValidate(Validator::verify_mobile($mobile));
- $err = $validator->validate();
- if ($err != '') {
- return self::outerr(errcode::ErrParamter, $err);
- }
- $oper = new fcode\operator($common_id,$batch_code);
- $fcode = $oper->grabed($mobile);
- if($fcode == false) {
- return self::outerr(errcode::ErrParamter, "您没有该批次商品的F码.");
- }
- $fcoder = new \fcode\mfcode($fcode);
- if($fcoder->binded()) {
- return self::outsuccess(null);
- }
- if(!isset($_GET['code']) || empty($_GET['code'])) {
- return self::outerr(errcode::ErrParamter, "请输入验证码.");
- }
- $code = $_GET['code'];
- $ret = sms_helper::check_code(Sms::getfcode_code,$code,$mobile);
- if(is_array($ret)) {
- return self::outerr($ret['code'], $ret['msg']);
- }
- else
- {
- $oper->bind($fcode,$mobile);
- return self::outsuccess(null);
- }
- }
- }
|