예제 #1
0
 /**
  * 365日期属性 可选择日期 接口
  * @auth song
  * @param int $month
  *
  * @return json
  * */
 public function actionChoicedate()
 {
     if (PublicLibrary::is_ajax()) {
         $month = Yii::$app->request->post('month');
         $mactpro = new ActivityProduct();
         $monthproductlist = $mactpro->getMonthlist($month);
         if ($monthproductlist) {
             foreach ($monthproductlist as $key => $val) {
                 $stime = date('Y-m-d', $val['start_time']);
                 $mlpro[] = $stime;
             }
             echo PublicLibrary::format_res_encode('0', 'success', $mlpro);
         } else {
             echo PublicLibrary::format_res_encode('1002', 'search error');
         }
     } else {
         echo PublicLibrary::format_res_encode('1001', 'requst error');
     }
 }
예제 #2
0
 /**
  * [一呼百应活动宣传主题页 查询该用户的可以参加一呼百应活动的产品的接口]
  * @param  [int] $uid [产品id]
  * @return [json_encode]
  * 本地地址:http://www.idaiyan-website.cn/special-topic/applybaiying
  * 线上地址:http://test.idaiyan.cn/special-topic/applybaiying
  */
 public function actionApplybaiying($diy)
 {
     $user = PublicLibrary::is_login();
     //判断是否登陆
     if (!$user) {
         echo PublicLibrary::format_res_encode('1000', 'no login!');
         exit;
     }
     $uid = $user['uid'];
     $models = new IProductBase();
     $res = $models->myProducts($uid);
     //创建一个新数组$new,新数组以元素组的 id 为索引
     $new = array();
     foreach ($res as $key => $value) {
         $new[$value['id']]['id'] = $value['id'];
         $new[$value['id']]['name'] = $value['name'];
         if ($value['album']) {
             $new[$value['id']]['album'] = $value['album'] . ProductImage::THUMB_POSTFIX;
         } else {
             $new[$value['id']]['album'] = '';
         }
     }
     //查询该用户参加过一呼百应活动的产品,把可以参加活动的产品的id放到新数组$res3里
     $mactivitypdt = new ActivityProduct();
     $res2 = $mactivitypdt->applyActivity($uid, ActivityBase::APPLY_BAIYING);
     $res3 = array();
     foreach ($res2 as $key => $val) {
         if ($val['status'] == 0 || $val['status'] == 2 || $val['status'] == 3) {
             //选择出不能参加活动申请的ID
             $res3[$key]['id'] = $val['product_id'];
         }
     }
     if ($res3) {
         //去掉参加该活动还在审核中的产品的id
         foreach ($res3 as $key => $val) {
             unset($new[$val['id']]);
         }
         if ($new) {
             //成功返回产品信息 <!--如果有产品-->
             $str = '<div class="activity-product-choose">';
             $str .= '<div class="title">选择一款产品参与<span>一呼百应</span>活动</div>';
             if (intval($diy) == 1) {
                 $str .= '<form action="/activity/applybaiying-diy" method="GET">';
             } else {
                 $str .= '<form action="/activity/applybaiying" method="GET">';
             }
             $str .= '<div class="input-wrap">';
             $str .= '<select name="pid" class="product" id="product_id">';
             foreach ($new as $key => $val) {
                 $str .= '<option value=' . $val['id'] . '>' . $val['name'] . '</li>';
             }
             $str .= ' </select>';
             $str .= ' <input type="hidden" name = "aid" value = "8">';
             $str .= ' <button class="continue bluebtn">继续</button>';
             $str .= ' </div>';
             $str .= ' </form>';
             $str .= ' <div class="tips">无法确认这款产品?可以去<a href="#">产品详情页</a>确认详细内容。</div>';
             $str .= ' </div>';
             // echo $str;
             echo '{"code":"1001","msg":"applybaiying!","data":"' . addslashes($str) . '"}';
             // echo "{code:'1001','apply365days!',$str}";
             exit;
         } else {
             $str = '<div class="activity-product-choose no-product">';
             $str .= '<div class="title">还没有发布过代言,现在就去发布吧</div>';
             $str .= '<a class="publish bluebtn" href="/product/create">发布代言</a>';
             $str .= '</div>';
             echo '{"code":"1002","msg":"applybaiying!","data":"' . addslashes($str) . '"}';
             // echo "{code:'1001','apply365days!',$str}";
             exit;
         }
     } else {
         if ($new) {
             //成功返回产品信息 <!--如果有产品-->
             $str = '<div class="activity-product-choose">';
             $str .= '<div class="title">选择一款产品参与<span>一呼百应</span>活动</div>';
             if (intval($diy) == 1) {
                 $str .= '<form action="/activity/applybaiying-diy" method="GET">';
             } else {
                 $str .= '<form action="/activity/applybaiying" method="GET">';
             }
             $str .= '<div class="input-wrap">';
             $str .= '<select name="pid" class="product" id="product_id">';
             foreach ($new as $key => $val) {
                 $str .= '<option value=' . $val['id'] . '>' . $val['name'] . '</option>';
             }
             $str .= '</select>';
             $str .= '<input type="hidden" name = "aid" value = "8">';
             $str .= '<button class="continue bluebtn">继续</button>';
             $str .= '</div>';
             $str .= '</form>';
             $str .= '<div class="tips">无法确认这款产品?可以去<a href="#">产品详情页</a>确认详细内容。</div>';
             $str .= '</div>';
             echo '{"code":"1001","msg":"applybaiying!","data":"' . addslashes($str) . '"}';
             // echo "{code:'1001','apply365days!',$str}";
             exit;
         } else {
             $str = '<div class="activity-product-choose no-product">';
             $str .= '<div class="title">还没有发布过代言,现在就去发布吧</div>';
             $str .= '<a class="publish bluebtn" href="/product/create">发布代言</a>';
             $str .= '</div>';
             echo '{"code":"1002","msg":"applybaiying!","data":"' . addslashes($str) . '"}';
             // echo "{code:'1001','apply365days!',$str}";
             exit;
         }
     }
 }
예제 #3
0
 /**
  * 一呼百应 属性接口
  * @param int   $rel_id   活动产品id
  * @param int   $attrid   活动产品属性值ID
  * @param str   $attval   属性值
  *        endtime    结束时间
  *
  * @return json
  * */
 public function actionBaiyingattr()
 {
     //判断登陆
     $user = PublicLibrary::is_login();
     //if ($user && PublicLibrary::is_ajax()) {
     if ($user) {
         $uid = $user['uid'];
     } else {
         echo PublicLibrary::format_res_encode('1001', 'the user no landing or no ajax!');
         exit;
     }
     //$uid = 241661;
     //$rel_id = 32825;
     //$attrid = 3;
     //$priceDis = 456;
     //$date = ['rel_id' => $rel_id, 'attrid' => $attrid, 'priceDis' => '346'];
     $date = Yii::$app->request->post();
     $date = array_map('trim', $date);
     $date = array_map('strip_tags', $date);
     $rel_id = isset($date['rel_id']) ? intval($date['rel_id']) : 0;
     $attrid = isset($date['attrid']) ? intval($date['attrid']) : 0;
     $attval = isset($date['attval']) ? $date['attval'] : '';
     if (isset($date['endtime']) && $date['endtime'] == 1) {
         $attrid = 2;
     }
     //用活动产品id 获取活动id
     $mpactivity = new ActivityProduct();
     $pcone = $mpactivity->pk($rel_id);
     //当前用户和产品活动发布用户不同
     if (empty($pcone) || $uid != $pcone['user_id'] || $pcone['status'] == ActivityProduct::STATUS_VERIFYING || $pcone['status'] == ActivityProduct::STATUS_VERIFY_THROUGH) {
         echo PublicLibrary::format_res_encode('1003', 'user or status error!');
         exit;
     }
     $acti_id = $pcone->acti_id ? $pcone->acti_id : 0;
     $product_id = $pcone->product_id ? $pcone->product_id : 0;
     if (empty($rel_id) || empty($attrid) || empty($acti_id) || empty($product_id)) {
         echo PublicLibrary::format_res_encode('1004', 'params error');
         exit;
     }
     // 查询属性基础信息
     $mattrbase = new ActivityAttrBase();
     $attr = $mattrbase->pk($attrid);
     //价格处理
     if ($attr['type'] == ActivityAttrBase::DATA_TYPE_MODEL_PRICE) {
         //查询价格属性值 以供修改
         $mAttrval = new ActivityProductAttrVal();
         $pattrv = $mAttrval->getAttrVal($rel_id, $attrid);
         $priceval = [];
         if (isset($pattrv['attr_val']) && !empty($pattrv['attr_val'])) {
             $priceval = json_decode($pattrv['attr_val'], true);
         }
         if (isset($priceval) && !is_array($priceval)) {
             $priceval = [];
         }
         //图片上传
         $priceimg = UploadedFile::getInstanceByName('attval');
         if ($priceimg !== null) {
             //判断图片大小是否符合规定
             if ($priceimg->size > ProductImage::MAX_SIZE || $priceimg->error != 0) {
                 echo PublicLibrary::format_res_encode('1005', 'image error');
                 exit;
             }
             $rootpath = 'uploads/' . date('Y/m/d') . '/';
             //图片保存路径
             file_exists($rootpath) or mkdir($rootpath, 0777, true);
             //生成图片路径
             $randname = time() . rand(0, 500);
             //图片公有名
             $setpimage_path = $rootpath . $randname;
             //封面图路径
             move_uploaded_file($priceimg->tempName, $setpimage_path . '.jpg');
             $priceval['priceimg'] = $setpimage_path;
         } else {
             $priceval['price'] = $attval;
         }
         $attval = $priceval;
     }
     $mbaseattr = new BaseAttribute();
     $btas = $mbaseattr->save($rel_id, $uid, $attrid, $attval, false, 1);
     if ($btas) {
         $pimg = isset($setpimage_path) ? $setpimage_path . '.jpg' : '';
         //查询完成度
         $ActivityRelAttrGroup = new ActivityRelAttrGroup();
         //获取group_id
         $group = ActivityRelAttrGroup::find()->select('group_id')->where(['attr_id' => $attrid, 'acti_id' => ActivityBase::APPLY_BAIYING])->asArray()->one();
         $group_id = $group['group_id'];
         $ids = $ActivityRelAttrGroup->completion($rel_id, ActivityBase::APPLY_BAIYING, $group_id);
         if ($ids) {
             echo PublicLibrary::format_res_encode('0', 'success', ['priceImg' => $pimg]);
         } else {
             echo PublicLibrary::format_res_encode('1', 'success', ['priceImg' => $pimg]);
         }
     } else {
         echo PublicLibrary::format_res_encode('1002', 'save error');
     }
 }
예제 #4
0
 /**
  * 修改用户头像
  */
 public function actionEditAvatar()
 {
     //判断登陆
     $user = PublicLibrary::is_login();
     if (empty($user)) {
         echo PublicLibrary::format_res_encode('1002', 'login error');
         exit;
     } else {
         $uid = $user['uid'];
     }
     //$uid = 26;
     if (Yii::$app->request->isPost) {
         $data = Yii::$app->request->post();
         $Member_model = Member::findOne($uid);
         /*图片上传*/
         $images = UploadedFile::getInstanceByName('avatarfile');
         //取得上传文件名
         if ($images) {
             $rootpath = 'uploads/' . date('Ymd') . '/';
             //图片保存路径
             if (!file_exists($rootpath)) {
                 //生成图片路径
                 mkdir($rootpath, 0700, true);
             }
             $ext = $images->getExtension();
             //取得图片扩展名
             $randname = date('YmdHis') . rand(10000, 9999) . '.' . $ext;
             $path_face = $rootpath . $randname;
             //图片路径
             if ($images->saveAs($path_face)) {
                 $Member_model->avatar = $path_face;
                 $imagename = $images->name;
                 $res = $this->Smallimg($rootpath, $randname, $data);
                 $Member_model->avatar = $res;
                 $Member_model->avatar_cut = $data['cutPos'];
                 if ($Member_model->save()) {
                     echo PublicLibrary::format_res_encode('0', 'success');
                 } else {
                     echo PublicLibrary::format_res_encode('1001', 'save error');
                 }
             } else {
                 echo PublicLibrary::format_res_encode('1003', 'upload error');
             }
         } else {
             $avatar = $data['oavatar'];
             if ($avatar) {
                 $arrpath = explode('/', $avatar);
                 $path = $arrpath[1] . '/' . $arrpath['2'] . '/';
                 $res = $this->Smallimg($path, $arrpath['3'], $data);
                 $Member_model->avatar = $res;
                 $Member_model->avatar_cut = $data['cutPos'];
                 if ($Member_model->save()) {
                     echo PublicLibrary::format_res_encode('0', 'success');
                 } else {
                     echo PublicLibrary::format_res_encode('1001', 'save error');
                 }
             }
             //var_dump($Member_model);
             //echo PublicLibrary::format_res_encode('1004','image error');
         }
     } else {
         echo PublicLibrary::format_res_encode('1005', 'request error');
     }
 }
예제 #5
0
 /**
  * [活动属性处理接口]
  * @param array $data 数据
  *  [
  *      'rel_id' => '活动产品关联ID',
  *      'attrid' => '属性ID',
  *      'attrval' => '属性值',
  *      'type' => '活动产品关联ID',
  *      'id' => '图鉴属性ID',
  *      'delid' => '图鉴属性ID',
  *      'title' => '图片标题',
  *      'desc' => '图片描述',
  *      'pimage' => '图片',
  *  ]
  * @return [json_encode]     [0,1001]
  * 00 执行成功,已完成
  * 01 执行成功,未完成
  * 02 删除成功
  * 1001 未登录
  * 1004 参数错误
  * 1005 图片上传错误
  */
 public function actionAttrprocess()
 {
     //判断登陆
     $user = yii::$app->util->isLogin();
     if ($user) {
         $uid = $user['uid'];
     } else {
         echo PublicLibrary::format_res_encode('1001', 'the user no landing or no ajax!');
         exit;
     }
     $date = Yii::$app->request->post();
     $date = array_map('trim', $date);
     $date = array_map('strip_tags', $date);
     $rel_id = isset($date['rel_id']) ? intval($date['rel_id']) : 0;
     $attrid = isset($date['attrid']) ? intval($date['attrid']) : 0;
     $attval = isset($date['attrval']) ? $date['attrval'] : '';
     $type = isset($date['type']) ? $date['type'] : '';
     $delid = isset($date['delid']) ? intval($date['delid']) : '';
     //用活动产品id 获取活动id
     $mpactivity = new ActivityProduct();
     $pcone = $mpactivity->pk($rel_id);
     //当前用户和产品活动发布用户不同
     if (empty($pcone) || $uid != $pcone['user_id'] || $pcone['status'] == ActivityProduct::STATUS_VERIFYING) {
         echo yii::$app->util->formatResEncode('1003', 'user or status error!');
         exit;
     }
     $acti_id = $pcone->acti_id ? $pcone->acti_id : 0;
     $product_id = $pcone->product_id ? $pcone->product_id : 0;
     if (empty($rel_id) || empty($attrid) || empty($acti_id) || empty($product_id)) {
         echo yii::$app->util->formatResEncode('1004', 'params error');
         exit;
     }
     //查询属性基础信息
     $mattrbase = new ActivityAttrBase();
     $attr = $mattrbase->pk($attrid);
     if (!empty($type)) {
         $attribute = [];
         $content = [];
         $sign = false;
         //添加标示
         $comsta = false;
         //完成度标示
         $delstat = false;
         //删除标识
         if ($type == "image") {
             $pimage_model = new ProductImage();
             //删除
             if ($delid) {
                 if ($pimage_model->delBypk($delid)) {
                     $delstat = true;
                 }
             } else {
                 $imgstatus = false;
                 $pos_id = 100;
                 //图片上传
                 $pimage = UploadedFile::getInstanceByName('pimage');
                 if ($pimage !== null) {
                     //判断图片大小是否符合规定
                     if ($pimage->size > ProductImage::MAX_SIZE || $pimage->error != 0) {
                         echo yii::$app->util->formatResEncode('1005', 'image error');
                         exit;
                     }
                     $rootpath = 'uploads/' . date('Y/m/d') . '/';
                     //图片保存路径
                     file_exists($rootpath) or mkdir($rootpath, 0777, true);
                     //生成图片路径
                     $randname = time() . rand(0, 500);
                     //图片公有名
                     $setpimage_path = $rootpath . $randname;
                     //图路径
                     move_uploaded_file($pimage->tempName, $setpimage_path . '.jpg');
                     //生成缩略图
                     $sreturn = $this->smallimg($setpimage_path, 200, 125);
                     //产品详细
                     $pimage_path = $sreturn ? $setpimage_path . ProductImage::THUMB_PDETIAL : $setpimage_path . '.jpg';
                     $content['url'] = $setpimage_path;
                     $imgstatus = true;
                 }
                 //填写描述
                 if (!empty($date['id']) && !empty($date['desc'])) {
                     $content['desc'] = $date['desc'];
                     $imgstatus = true;
                 }
                 //填写标题
                 if (!empty($date['id']) && !empty($date['title'])) {
                     $content['title'] = $date['title'];
                     $imgstatus = true;
                 }
                 if ($imgstatus) {
                     $content['product_id'] = $product_id;
                     $content['type'] = $pos_id;
                     if (isset($date['id']) && !empty($date['id'])) {
                         $content['id'] = intval($date['id']);
                         $imgid = $pimage_model->imageSave($content);
                     } else {
                         $pimid = $pimage_model->getByTypeAndPid($pos_id, $product_id);
                         //详细图文介绍 图片个数不超过9个,超过9个不做新增操作
                         if (count($pimid) < 9 && $pos_id == 100) {
                             // var_dump($date);die;
                             $imgid = $pimage_model->imageSave($content);
                         }
                     }
                     if (isset($imgid) && $imgid > 0) {
                         $sign = $imgid;
                         //判断该条信息是否完整
                         if ($pimage_model->iscomplete($imgid, "title")) {
                             $complete = array('id' => $imgid, 'is_complete' => ProductImage::IS_COMPLETE);
                             if ($pimage_model->imageSave($complete)) {
                                 $comsta = true;
                             }
                         }
                     }
                 }
             }
         }
         if ($type == "video") {
             // var_dump($date);die;
             $pvideo_model = new ProductVideo();
             if (isset($date['video_url'])) {
                 if (!empty($date['video_url'])) {
                     $content['video_url'] = $date['video_url'];
                     //$content['video_url'] = Yii::$app->util->generalVideo($date['video_url']);
                 }
                 $content['uid'] = $uid;
                 $content['product_id'] = $product_id;
                 if (isset($date['id']) && !empty($date['id'])) {
                     $content['id'] = $date['id'];
                     $videoid = $pvideo_model->store($content);
                     // $sign = $videoid;
                 } else {
                     //一个产品的视频属性 只能存在一条,如果已经存在,不做新增操作, 返回存在的id值,
                     $rvid = $pvideo_model->getByPid($product_id, true);
                     if (!$rvid) {
                         $videoid = $pvideo_model->store($content);
                     } else {
                         $videoid = isset($rvid['id']) ? $rvid['id'] : '';
                     }
                 }
                 if ($videoid) {
                     $sign = $videoid;
                     $comsta = true;
                 }
             }
         }
         if ($delstat) {
             //+TOOD 删除 修改 产品属性值 表数据操作
             echo yii::$app->util->formatResEncode('02', 'deletet success');
             exit;
         } else {
             if ($sign) {
                 $baseattr_model = new BaseAttribute();
                 $imgurl = isset($pimage_path) ? $pimage_path : '';
                 $videoid = isset($videoid) ? intval($videoid) : 1;
                 if ($comsta) {
                     $btas = $baseattr_model->save($rel_id, $uid, $attrid, $videoid, false, 1);
                     echo yii::$app->util->formatResEncode('00', 'success', array('id' => $sign, 'imgurl' => $imgurl));
                     exit;
                 } else {
                     $btas = $baseattr_model->save($rel_id, $uid, $attrid, $videoid, false, 0);
                     echo yii::$app->util->formatResEncode('01', 'success', array('id' => $sign, 'imgurl' => $imgurl));
                     exit;
                 }
             }
         }
     } else {
         $mbaseattr = new BaseAttribute();
         $btas = $mbaseattr->save($rel_id, $uid, $attrid, $attval, false, 1);
         echo yii::$app->util->formatResEncode('0', 'success');
         exit;
     }
 }
예제 #6
0
 public function actionCheckcode()
 {
     $params = Yii::$app->request->post();
     // 联调时需要改成post
     $session = Yii::$app->session;
     $session->isActive ? '' : $session->open();
     // print_r($params);
     $output = array();
     if ($params) {
         $mobile = intval($params['mobile']);
         $authcode = isset($params['authcode']) ? strip_tags($params['authcode']) : '';
         $member_model = new Member();
         $userone = $member_model->getByUserName($mobile);
         //通过手机号查询用户信息
         if (!empty($userone)) {
             // echo $authcode;
             // $password = password_encode($authcode,$userone['random']);
             $passmd = PublicLibrary::password_encode($authcode, $userone['random']);
             // echo $passmd;exit;
             if (!empty($_SESSION['authcode'])) {
                 if ($authcode == $_SESSION['authcode'] || $userone['password'] == $passmd) {
                     //设置登录状态
                     $_SESSION['user']['uid'] = $userone['uid'];
                     $_SESSION['user']['mobile'] = $userone['mobile'];
                     $_SESSION['user']['truename'] = $userone['truename'];
                     $_SESSION['user']['admin'] = 0;
                     //普通用户登录
                     //设置登陆日志
                     $MemberLog_model = new MemberLog();
                     $MemberLog_model->saveLog(array('uid' => $userone['uid']));
                     $output['status'] = 1;
                     $output['res'] = $userone;
                     $output['info'] = '验证通过,登录成功!';
                 } else {
                     $output['status'] = 2;
                     $output['res'] = '';
                     $output['info'] = '验证码或密码错误!';
                 }
             } else {
                 // mimacuowu***
                 if ($userone['password'] == $passmd) {
                     //设置登录状态
                     $_SESSION['user']['uid'] = $userone['uid'];
                     $_SESSION['user']['mobile'] = $userone['mobile'];
                     $_SESSION['user']['truename'] = $userone['truename'];
                     $_SESSION['user']['admin'] = 0;
                     //普通用户登录
                     //设置登陆日志
                     $MemberLog_model = new MemberLog();
                     $MemberLog_model->saveLog(array('uid' => $userone['uid']));
                     $output['status'] = 1;
                     $output['res'] = $userone;
                     $output['info'] = '验证通过,登录成功!';
                 } else {
                     $output['status'] = 2;
                     $output['res'] = '';
                     $output['info'] = '密码错误!';
                 }
             }
         } else {
             if (!empty($_SESSION['authcode'])) {
                 if ($authcode == $_SESSION['authcode']) {
                     $_SESSION['user']['mobile'] = $mobile;
                     $output['status'] = 1;
                     $output['res'] = '';
                     $output['info'] = '验证通过,登录成功!';
                 } else {
                     $output['status'] = 3;
                     $output['res'] = '';
                     $output['info'] = '验证码不正确!';
                 }
             } else {
                 $output['status'] = 3;
                 $output['res'] = '';
                 $output['info'] = '验证码不正确1!';
             }
         }
     } else {
         $output['status'] = 3;
         $output['res'] = '';
         $output['info'] = '签名验证出错!';
     }
     $output = PublicLibrary::format_res_encode($output['status'], $output['info'], $output['res']);
     // var_dump($output);
     echo $output;
 }
예제 #7
0
 /**
  * 省市联动
  * @param int $id js获得的省级id
  *
  * @return json
  */
 public function actionProcCity()
 {
     // $id = isset(Yii::$app->request->post('id')) ? Yii::$app->request->post('id') : 0;
     $id = Yii::$app->request->post('id') ? Yii::$app->request->post('id') : 0;
     $id = intval($id);
     if ($id) {
         $district = new District();
         $district = $district->getByLevel($id);
         if ($district) {
             $reg = PublicLibrary::format_res_encode('0', '正确', $district);
         } else {
             $reg = PublicLibrary::format_res_encode('1001', '参数错误', '');
         }
     } else {
         $reg = PublicLibrary::format_res_encode('1001', '参数错误', '');
     }
     echo $reg;
 }
예제 #8
0
 public function actionCheckticode()
 {
     $params = Yii::$app->request->post();
     // 联调时需要改成post
     $sid = isset($params['sid']) ? intval($params['sid']) : '';
     $user = PublicLibrary::is_login();
     if (!$user) {
         $output['status'] = 1000;
         $output['res'] = '';
         $output['info'] = 'no login';
         $backurl = Yii::$app->params['idaiyan'] . "/baiying/gamestar?sid=" . $sid;
         $backurl = Publiclibrary::encode_callback($backurl);
         $output['url'] = '/baiying/auth?backurl=' . $backurl;
         $output = PublicLibrary::format_res_encode($output['status'], $output['info'], $output['url']);
         // var_dump($output);
         echo $output;
         exit;
     }
     $session = Yii::$app->session;
     $session->isActive ? '' : $session->open();
     $output = array();
     if ($params) {
         $mobile = intval($params['mobile']);
         $rel_id = isset($params['rel_id']) ? intval($params['rel_id']) : '';
         $truename = isset($params['truename']) ? strip_tags($params['truename']) : '';
         $openid = $_SESSION['user']['openid'];
         // $openid = 'oKeG4jqOTo-wyqSqXAA4hfTFvtZI';
         if (empty($mobile) || empty($openid)) {
             $output['status'] = 1000;
             $output['res'] = '';
             $output['info'] = 'no login';
             $backurl = Yii::$app->params['idaiyan'] . "/baiying/gamestar?sid=" . $sid;
             $backurl = Publiclibrary::encode_callback($backurl);
             $output['url'] = '/baiying/auth?backurl=' . $backurl;
             $output = PublicLibrary::format_res_encode($output['status'], $output['info'], $output['url']);
             // var_dump($output);
             echo $output;
             exit;
         }
         $mutpl = new UserThirdPartyLogin();
         $thirdone = $mutpl->getByOpenId($openid);
         $member_model = new Member();
         $userone = $member_model->getByUserName($mobile);
         //通过手机号查询用户信息
         if ($thirdone) {
             $userone = $member_model->getByUid($thirdone['user_id']);
         }
         if (!empty($userone)) {
             //ru guo
             $output['status'] = 1001;
             $output['res'] = $userone;
             if ($thirdone) {
                 $output['info'] = '该微信号已被绑定!';
             } else {
                 $output['info'] = '是注册,请输入密码或者验证码';
             }
             $output['url'] = '';
         } else {
             $output['status'] = 1002;
             $output['res'] = '';
             $output['info'] = '验证通过,登录成功!';
             $output['url'] = '';
             //注册
             $usercontent = array("mobile" => $mobile, "truename" => $truename, "address" => '', "comefrom" => '一呼百应');
             $member = new Member();
             $res = $member->registration($usercontent);
             if ($res['userid']) {
                 // $_SESSION['user']['nickname'] = 'hongye';
                 // $_SESSION['user']['headimgurl'] = 'http://wx.qlogo.cn/mmopen/Q3auHgzwzM6LiaSic2iaLbgGGQMadoac3M6g3vfEd7CLQVPyWficA679jxbI2OZwVxxExA8ibKopLO4EHKFvnx6yy8IFP2PmiaL8laJHAtw3wiaWNU/0';
                 //绑定第三方信息
                 $thirdone = $mutpl->getByOpenId($openid);
                 if (!$thirdone) {
                     $wxarr['nickname'] = $_SESSION['user']['nickname'];
                     $wxarr['headimgurl'] = $_SESSION['user']['headimgurl'];
                     $thirdcontent['open_id'] = $openid;
                     $thirdcontent['user_id'] = $res['userid'];
                     $thirdcontent['type'] = 'weixin';
                     $thirdcontent['profile_info'] = json_encode($wxarr);
                     $thirdcontent['status'] = 1;
                     $mutpl->store($thirdcontent);
                 }
                 //设置登录状态
                 $_SESSION['user']['uid'] = $res['userid'];
                 $_SESSION['user']['mobile'] = $mobile;
                 $_SESSION['user']['truename'] = $truename;
                 $_SESSION['user']['admin'] = 0;
                 //普通用户登录
                 // $sms_model = new Sms();
                 // $sms_model->mobile = $mobile;
                 // $sms_model->content = '您的密码是'.$res['password'].',您可以使用手机号:'.$mobile.'登录i代言官网,如非本人操作请及时联系客服人员。【i代言】';
                 // $sms_model->from = 'findpassword';  //调用来源
                 // $return = $sms_model->SoapSend();
                 $sms = Yii::$app->dcSMS;
                 $userID = $res['userid'];
                 $data = ['uid' => $userID, 'mobile' => $mobile, 'business' => 'H_AUTO_REG', 'tplno' => 1, 'password' => $res['password'], 'mobile' => $mobile];
                 $resp = $sms->send($data);
             }
         }
     } else {
         $output['status'] = 1003;
         $output['res'] = '';
         $output['info'] = '签名验证出错!';
         $output['url'] = '';
     }
     $output = PublicLibrary::format_res_encode($output['status'], $output['info'], $output['url']);
     // var_dump($output);
     echo $output;
 }
예제 #9
0
 /**
  * 图片上传接口(备用)
  * @param  int $product_id 产品id
  * @param  string $type    图片类型
  * @param  string $pos_id 图片位置标识
  * @return  string address 图片位置
  */
 public function actionUploadimage()
 {
     //判断登陆
     $user = PublicLibrary::is_login();
     //if ($user && PublicLibrary::is_ajax()) {
     if ($user) {
         $uid = $user['uid'];
     } else {
         echo PublicLibrary::format_res_encode('1001', 'the user no landing or no ajax!');
         exit;
         //json 格式
     }
     $form = Yii::$app->request->post();
     $type = isset($form['type']) ? $form['type'] : '';
     $pos_id = isset($form['pos_id']) ? $form['pos_id'] : '';
     $product_id = isset($form['product_id']) ? $form['product_id'] : '';
     if (!$product_id) {
         echo PublicLibrary::format_res_encode('1002', 'no this product!');
         exit;
         //json 格式
     }
     //album图片上传
     $album = UploadedFile::getInstanceByName('album');
     //获取图片album
     if ($album !== null) {
         //判断图片大小是否符合规定
         if ($album->size > ProductImage::MAX_SIZE || $album->error != 0) {
             echo PublicLibrary::format_res_encode('1003', 'More than size!');
             exit;
             //json 格式
         }
         if ($type == '1') {
             //产品基础表
             $fld = 'album';
             //判断封面图片是否存在,或是修改
             $model = new IProductBase();
             if ($product_id) {
                 $model = IProductBase::findOne(['id' => $form['product_id']]);
                 if (!$model) {
                     $model = new IProductBase();
                 }
             }
             $model->type = $form['type'];
         } elseif ($type == '2') {
             //产品图片表
             $fld = 'url';
             $model = ProductImage::findOne(['product_id' => $form['product_id'], 'pos_id' => $pos_id]);
             //通过产品id和图片位置判断有没有改图片
             if ($model) {
                 $model->update_time = time();
             } else {
                 $model = new ProductImage();
                 $model->create_time = time();
                 $model->update_time = time();
             }
             $model->pos_id = $form['pos_id'];
             $model->type = $form['type'];
             $model->product_id = $form['product_id'];
             //当位置为1时 修改base表的banner字段
         }
         $albumPath = $model->{$fld};
         if (!$albumPath) {
             $rootpath = 'uploads/' . date('Y/m/d') . '/';
             //图片保存路径
             file_exists($rootpath) or mkdir($rootpath, 0700, true);
             //生成图片路径
             $randname = time() . rand(0, 500);
             //图片公有名
             $albumPath = $rootpath . $randname;
             //封面图路径
         }
         if ($type == '1') {
             $thumbPath = $albumPath . ProductImage::THUMB_SIZE_ONE;
             //缩略图路径
             $returnPath = $thumbPath . '.jpg';
             //生成缩略图
             $width = 312;
             $height = 196;
             $thumbPath = '@frontend/web/' . $thumbPath . '.jpg';
             Image::thumbnail($album->tempName, $width, $height)->save(Yii::getAlias($thumbPath), ['quality' => 100]);
         } else {
             $returnPath = $albumPath . '.jpg';
         }
         //原图上传
         $album->saveAs($albumPath . '.jpg');
         $model->{$fld} = $albumPath;
         $model->save();
         echo PublicLibrary::format_res_encode('1000', 'successful!', $returnPath);
         exit;
         //json 格式
     } else {
         echo PublicLibrary::format_res_encode('1004', 'no file!');
         exit;
         //json 格式
     }
 }
예제 #10
0
 /**
  * 收货地址接口
  * @param str $harvest 收获姓名
  * @param str $telephone 电话
  *
  * @param json
  * */
 public function actionAddress()
 {
     $user = PublicLibrary::is_login();
     if (isset($user['uid']) && PublicLibrary::is_ajax()) {
         $uid = $user['uid'];
     } else {
         echo PublicLibrary::format_res_encode('1001', 'login or ajax error');
         exit;
     }
     //$uid = 11;
     $date = Yii::$app->request->post();
     $date = array_map('trim', $date);
     $date = array_map('strip_tags', $date);
     $date = array_map('htmlspecialchars', $date);
     if (empty($date)) {
         echo PublicLibrary::format_res_encode('1002', 'param error');
         exit;
     }
     $date['uid'] = $uid;
     $mharaddr = new HarvestAddress();
     $return = $mharaddr->store($date);
     if ($return) {
         echo PublicLibrary::format_res_encode('0', 'success', $return);
         exit;
     } else {
         echo PublicLibrary::format_res_encode('1003', 'save error');
         exit;
     }
 }