/** * 添加日志 * @param array $log */ public function saveLog($log = []) { $this->uid = $log['uid']; $this->login_time = time(); $this->login_ip = PublicLibrary::get_ip(); return $this->save(); }
/** * @发短信 *免申模板 'content' => '您的账号123,密码是987,欢迎您注册i代言。【i代言】', */ public function HttpSend() { if (is_array($this->mobile)) { $phone = implode(',', $mobile); } else { $phone = $this->mobile; //检测 发送频率 if (!$this->checkRate($phone)) { return '发送频率太高'; } } $sendcontent = array('name' => Sms::CHUANGRUI_NAME, 'pwd' => Sms::CHUANGRUI_PWD, 'content' => $this->content, 'mobile' => $phone, 'stime' => $this->stime, 'sign' => '', 'type' => Sms::CHUANGRUI_TYPE, 'extno' => ''); $result = PublicLibrary::do_request(Sms::CHUANGRUI_URL, $sendcontent); $result = explode(',', $result); //写入日志 $smslog_model = new SmsLog(); $log = array('mobile' => $phone, 'status' => $result[0] == 0 ? 0 : 1, 'errorcode' => $result[0], 'errorinfo' => $result[0] != 0 ? $result[1] : '', 'sendmessage' => $this->content, 'from' => $this->from, 'client_info' => $this->client_info); $logreturn = $smslog_model->saveLog($log); return $result[0]; }
use common\widgets\MyPager; use frontend\models\PublicLibrary; //公用函数库 use frontend\models\ProductImage; $session = Yii::$app->session; $session->open(); $this->registerCssFile(Yii::$app->params['idaiyan-static'] . "static/modules/home/css/prodlist.css"); $this->registerCssFile(Yii::$app->params['idaiyan-static'] . "static/modules/home/css/founderlist.css"); ?> <!-- <link rel="stylesheet" href="http://static.idaiyan.cn/website/static/modules/home/css/prodlist.css"> <link rel="stylesheet" href="http://static.idaiyan.cn/website/static/modules/home/css/founderlist.css"> --> <div class="slogan respons_wp"> <div class="main"><?php echo isset($membercount) ? PublicLibrary::avgueNUm($membercount) : 0; ?> 产品的创始人与您分享</div> <div class="sub">全中国的产品创新动力与成果</div> </div> <div class="founder_wrap"> <!-- <div class="filterbox"> <div class="filterstatus "> <div class="respons_wp cf"> <div class="leftlabel">您已选择:</div> <a href="#">最近更新</a> <a href="#">影音娱乐</a> </div> </div> <div class="filteritems">
/** * 用户产品列表 * * 个人中心产品列表显示 * * @param int $uid 用户的id号 * * @return array 个人中心产品列表页渲染所有数据 */ public function actionLists() { // print_r($_GET);exit; $uid = Yii::$app->request->get('uid'); $uid = intval($uid); $self = false; //表示身份 $login = PublicLibrary::is_login() ? PublicLibrary::is_login() : ''; //异常默认uid if (empty($uid) && PublicLibrary::is_login()) { $uid = $login['uid']; } //判断是否登录 if ($login !== '' && $login['uid'] == $uid) { $self = true; } //用户信息 $member = new Member(); $user = $member->getByUid($uid); // print_r($user);exit; //完善用户信息 if (!$user) { //是否存在该用户 return $this->redirect(['product/index']); } else { $user['renqi'] = isset($user['memberstar']) && is_array($user['memberstar']) ? array_sum($user['memberstar']) : 0; //用户位置信息 $dist = new District(); if (!empty($user['city'])) { $user['address'] = $dist->getByCity($user['city']['id']); } else { // $user['address'] = $dist->getByCity(40); $user['address'] = ['name' => '不详', 'province' => '地址']; } //获取用户头像 $user['avatar'] = PublicLibrary::getBigAvatar($user['avatar']); //获取用户发布产品个数数据 $iProductBase = new IProductBase(); $user['pub_num'] = $iProductBase->getCountByUid($uid); } //筛选map $activeMap = ['0' => '全部', '1' => '即将开始', '2' => '预定中', '3' => '已结束']; //游客和自己可以看的map是不同的 if ($self) { //筛选参数处理 $statusMap = ['0' => '全部', '2' => '待发布', '3' => '审核中', '4' => '发布中', '6' => '审核未通过']; $orderMap = ['0' => '全部', '1' => '最新发布', '2' => '支持最多', '3' => '最新更新']; } else { //筛选参数处理 $statusMap = ['0' => '全部', '2' => '待发布']; $orderMap = ['0' => '默认', '1' => '最新发布', '2' => '支持最多', '3' => '最新更新']; } $params = []; $type = Yii::$app->request->get('type') ? Yii::$app->request->get('type') : 0; $type = intval($type); in_array($type, array_keys($statusMap)) ? $params['type'] = $type : ($params['type'] = 0); $stat = Yii::$app->request->get('stat') ? Yii::$app->request->get('stat') : 0; $stat = intval($stat); in_array($stat, array_keys($activeMap)) ? $params['stat'] = $stat : ($params['stat'] = 0); $order = Yii::$app->request->get('order') ? Yii::$app->request->get('order') : 0; $order = intval($order); in_array($order, array_keys($orderMap)) ? $params['order'] = $order : ($params['order'] = 0); $iProductBase = new IProductBase(); $list = $iProductBase->choose($uid, $type, $stat, $order); //获取用户没有删除的产品总数 $user['count'] = $iProductBase->hasCountByUid($uid); // print_r($user['count']);exit; //修该 $list便于模板展示 //未填第二步发布信息,提示信息map $map = ['roles' => ['1' => '创始人', '2' => '合伙人', '3' => '分销推广代表', '4' => '投资人', '5' => '股东', '6' => '企业法人', '7' => '继承人', '8' => '投资人', '9' => '股东', '10' => '企业法人', '11' => '继承人'], 'ages' => ['1' => '0-15周岁', '10' => '16-30周岁', '100' => '30-60周岁', '1000' => '60周岁以上'], 'gender' => ['0' => '全部', '1' => '男', '2' => '女']]; //活动map $activityBase = new ActivityBase(); $activesMap = $activityBase->getActivityMap(); //休整$list——便于显示 // print_r($list);exit; foreach ($list as $k => $v) { if ($v['status'] == IProductBase::STATUS_VERIFEND) { //产品都是发布成功的——状态为4 //功能判断标志 $rendMark = ['del' => 1, 'update' => 1, 'apply' => 1]; //产品发布天数 $days = floor((time() - $v['create_time']) / 86400); $list[$k]['days'] = $days; if (!empty($v['aproduct'])) { //有活动 //到期时间——默认为true到期 $endTime = true; //活动计数 $num = 0; foreach ($v['aproduct'] as $ki => $vi) { // print_r(!$self);exit; //当游客看时 取出不合格的活动信息 if ($self) { if ($vi['acti_id'] == ActivityBase::FANS_FESTIVAL) { unset($list[$k]['aproduct'][$ki]); continue; } } else { if ($vi['acti_id'] == ActivityBase::FANS_FESTIVAL || $vi['status'] != ActivityProduct::STATUS_VERIFY_THROUGH) { unset($list[$k]['aproduct'][$ki]); continue; } } $num++; if ($vi['end_time'] > time()) { $endTime = false; } //删除功能 if ($vi['status'] == ActivityProduct::STATUS_VERIFYING || $vi['status'] == ActivityProduct::STATUS_VERIFY_THROUGH) { //审核中或有通过审核的 $rendMark['del'] = 0; } //编辑功能 if ($vi['status'] == ActivityProduct::STATUS_VERIFYING) { $rendMark['update'] = 0; } //活动申请 if ($num == 4 || $vi['status'] == ActivityProduct::STATUS_VERIFYING || $vi['status'] == ActivityProduct::STATUS_VERIFY_NOTTHROUGH || $vi['status'] == ActivityProduct::STATUS_SAVE) { $rendMark['apply'] = 0; } //状态显示 $map1 = ['flow' => '', 'now' => time()]; if ($vi['status'] == ActivityProduct::STATUS_SAVE) { $map1['flow'] = '保存中'; } else { if ($vi['status'] == ActivityProduct::STATUS_VERIFYING) { $map1['flow'] = '审核中'; } else { if ($vi['status'] == ActivityProduct::STATUS_VERIFY_NOTTHROUGH) { $map1['flow'] = '审核未通过'; } else { if ($vi['status'] == ActivityProduct::STATUS_VERIFY_THROUGH) { if (!empty($vi['start_time']) || !empty($vi['end_time'])) { $start = $vi['start_time']; $end = $vi['end_time']; } else { $start = $activesMap[$vi['acti_id']]['start_time']; $end = $activesMap[$vi['acti_id']]['end_time']; } // $start = $vi['start_time']; // $end = $vi['end_time']; $now = time(); if ($now < $start) { $map1['flow'] = '即将开始'; } else { if ($end > $now && $now >= $start) { $map1['flow'] = '进行中'; } else { if ($now >= $end) { $map1['flow'] = '已结束'; } } } } } } } $list[$k]['aproduct'][$ki]['map'] = $map1; //页面只显示四个活动 多的数据清除掉 if ($num > 4) { unset($list[$k]['aproduct'][$ki]); } } if ($endTime) { $rendMark['del'] = 1; } } $list[$k]['rendMark'] = $rendMark; } else { if ($v['status'] == IProductBase::STATUS_FIRST || $v['status'] == IProductBase::STATUS_INVALID) { //状态为5 只发布第一步 或状态为99 预览 显示信息拼凑 $list[$k]['apply_role'] = $map['roles'][$v['apply_role']]; $rand = str_split(str_pad($v['user_oriented_age'], 4, 0, STR_PAD_LEFT)); $ages = ''; $rand[3] ? $ages .= $map['ages']['1'] . ' 、' : ($ages = $ages); $rand[2] ? $ages .= $map['ages']['10'] . ' 、' : ($ages = $ages); $rand[1] ? $ages .= $map['ages']['100'] . ' 、' : ($ages = $ages); $rand[0] ? $ages .= $map['ages']['1000'] . ' 、' : ($ages = $ages); $list[$k]['user_oriented_age'] = trim($ages, '、'); $list[$k]['user_oriented_gender'] = $map['gender'][$v['user_oriented_gender']]; $iProductType = new IProductType(); $typeMap = $iProductType->getTypeMap(); $list[$k]['type'] = $typeMap[$v['type']]; } } } // print_r($list);exit; // //活动map // $activityBase = new ActivityBase(); // $activesMap = $activityBase->getActivityMap(); // print_r($activesMap);exit; //调用个人中心的布局 $this->layout = '@app/views/layouts/main.php'; // return $this->render( // 'index', // [ // 'list' => $list, // 'user' => $user, // 'self' => $self, // 'activesMap' => $activesMap // ] // ); // print_r($list);exit; //user 数据添加 $mMerberStat = new MemberStat(); $user['stat'] = $mMerberStat->getByUid($uid); // print_r($list);exit; $refresh = isset($_GET['pid']) ? $_GET['pid'] : ''; return $this->render('homepage', ['user' => $user, 'self' => $self, 'list' => $list, 'params' => $params, 'statusMap' => $statusMap, 'orderMap' => $orderMap, 'activesMap' => $activesMap, 'activeMap' => $activeMap, 'refresh' => $refresh]); }
/** * [一呼百应活动宣传主题页 查询该用户的可以参加一呼百应活动的产品的接口] * @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; } } }
/** * 好产品投票接口 */ public function actionGoodPoll() { $params = Yii::$app->request->post(); $tmp = $params['method']; $params = array_map('intval', $params); $params['method'] = $tmp; if (!Yii::$app->util->isAjax()) { echo Yii::$app->util->formatResEncode('1000', '不是ajax请求'); return; } //验证参数 if (!isset($params['mobile']) || !Yii::$app->util->checkMobileType($params['mobile']) || !isset($params['authcode']) || !$params['authcode'] || !isset($params['poll_id']) || !$params['poll_id'] || !isset($params['method']) || !$params['method']) { echo Yii::$app->util->formatResEncode('1001', '参数错误'); return; } $mMember = new Member(); if ($params['method'] == 'pwd') { $userone = $mMember->getByUserName($params['mobile']); if (!$userone) { echo Yii::$app->util->formatResEncode('1002', '不存在该用户'); return; } else { $passmd = PublicLibrary::password_encode($params['authcode'], $userone['random']); if ($passmd != $userone['password']) { echo Yii::$app->util->formatResEncode('1003', '密码错误'); return; } } } else { if ($params['method'] == 'authcode') { //获取验证码 $session = Yii::$app->session; $session->isActive ? '' : $session->open(); $authcode = $session->get('authcode'); $mobile = $session->get('mobile'); $session->close(); //验证手机验证码 if (!isset($params['authcode'])) { echo Yii::$app->util->formatResEncode('1004', '验证码错误'); return; } else { if ($authcode != $params['authcode']) { echo Yii::$app->util->formatResEncode('1004', '验证码错误'); return; } else { if ($mobile != $params['mobile']) { echo Yii::$app->util->formatResEncode('1004', '验证码错误'); return; } } } } else { echo Yii::$app->util->formatResEncode('1001', '参数错误'); return; } } $exist = $mMember->isRegistByConditons(['mobile' => $params['mobile']]); //新用户注册 if (!$exist) { if ($mMember->regist(['mobile' => $params['mobile']])) { //发送注册用户密码提示信息 Yii::$app->sms->send($params['mobile'], '欢迎注册idaiyan用户,你的首次用户密码为手机号后六位'); } } else { $uId = $exist['uid']; //获取rel_id $mActivityProduct = new ActivityProduct(); $conditions = ['user_id' => $uId, 'acti_id' => ActivityBase::GOOD_PRODUCT]; $one = $mActivityProduct->getOenByConditions($conditions); $relId = isset($one) && $one ? $one['id'] : 0; if ($relId) { //取分享人数据 $conditions = ['poll_id' => $params['poll_id'], 'owner_id' => $relId]; $mPollOption = new PollOption(); $row = $mPollOption->TopNum($conditions); if ($row) { $data = ['img' => $row[0]['act']['product']['album'], 'name' => $row[0]['act']['product']['name'], 'poll_votes' => $row[0]['option_votes'], 'option_id' => $row[0]['option_id']]; } } } //登陆session if (!$exist) { $exist = $mMember->isRegistByConditons(['mobile' => $params['mobile']]); } $user = ['uid' => $exist['uid'], 'mobile' => $exist['mobile']]; $session = Yii::$app->session; $session->isActive ? '' : $session->open(); $authcode = $session->set('user', $user); $session->close(); echo Yii::$app->util->formatResEncode('0', '成功', ['data' => isset($data) ? $data : '']); return; }
"><?php echo $p['stat']['follow_num'] ? $p['stat']['follow_num'] : 0; ?> </b> </div> </div> <div class="prodmate"> <div class="add_icon fr"> <div class="inner_div"></div> <div class="inner_div"></div> <div class="inner_div"></div> </div> <div class="publish-day"> <span><?php echo PublicLibrary::leftTime($p['create_time']); ?> </span><span>发布</span> </div> </div> </li> <!--游客,没收藏,没活动--> <!-- <li class="proditem"> <div class="activity noactivity"> <div class="con-wrap"> <div class="tabitem"></div> <div class="product-intro">此产品未参加任何活动</div> </div>
/** * 运营后台 设置365活动中 产品开始日期 * * * */ public function actionSetproductdate() { $user = PublicLibrary::is_login(); if (isset($user['uid'])) { $uid = $user['uid']; } else { return $this->redirect(['product/index']); exit; } $form = Yii::$app->request->get(); $form = array_map('trim', $form); $form = array_map('strip_tags', $form); $form = array_map('htmlspecialchars', $form); $page = isset($form['page']) ? intval($form['page']) : 1; $data['product_name'] = isset($form['product_name']) ? $form['product_name'] : ''; $data['username'] = isset($form['username']) ? $form['username'] : ''; $data['mobile'] = isset($form['mobile']) ? $form['mobile'] : ''; $data['status'] = isset($form['status']) ? $form['status'] : ''; $data['start_time'] = isset($form['start_time']) ? strtotime($form['start_time']) : ''; $mactpro = new ActivityProduct(); $date = $mactpro->get365Listpage($page, false, 3, $data); $pages = new Pagination(['totalCount' => $date->count(), 'pageSize' => 3]); // echo '<pre>'; // var_dump($pages); $productlist = $date->asArray()->all(); $mapattrval = new ActivityProductAttrVal(); if ($productlist) { foreach ($productlist as $pl => $st) { $acprattr = $mapattrval->getRealAttrVals($st['id'], ActivityBase::GENERAL_ACTIVITY); $productlist[$pl]['attr'] = $acprattr; } } // echo '<pre>'; // print_r($productlist); // exit; $this->layout = false; return $this->render('setproductdate', ['productlist' => $productlist, 'data' => $data, 'pages' => $pages]); }
<div class="choose_img"> <input type="file" id="choose" name="avatarfile" /> <div class="text">选择图片</div> <?php echo !empty($member['avatar_cut']) ? $member['avatar_cut'] : ''; ?> </div> <div class="tips"> 支持 JPG, JPEG, PNG 格式的图片, 尺寸为<span>180x180</span>. </div> </div> <div class="img_zone cf"> <div class="viewDivwrap"> <div id="viewDiv"> <img src="<?php echo PublicLibrary::getBigAvatar($member['avatar']); ?> " width="130" height="130"> </div> <span class="por_text"> 大头像</span> </div> <div class="viewDiv1wrap"> <div id="viewDiv1"> <img src="<?php echo empty($member['avatar']) ? 'http://static.idaiyan.cn/website/static/modules/home/images/temp/avatar.jpg' : Yii::$app->params['idaiyan'] . '/' . $member['avatar']; ?> " width="70" height="70"> </div> <span class="por_text"> 小头像</span> </div> </div>
public function actionBuysuccess() { $user = PublicLibrary::is_login(); if ($user && $user['uid'] != 'weixin') { $uid = isset($user['uid']) ? $user['uid'] : ''; } else { $this->redirect(['baiying/index']); } $parr = Yii::$app->request->get(); //获取地址栏中get过来的信息 // echo '<pre>'; // print_r($parr); $orderno = strip_tags($parr['orderno']) ? strip_tags($parr['orderno']) : ''; $model_order = new Order(); $res = $model_order->Paysuccess($orderno); $this->layout = false; $rel_id = $res['rel_id']; $acti_id = $res['acti_id']; $mactpro = new ActivityProduct(); $productattr = $mactpro->getDetailBypk($rel_id); $mapattrval = new ActivityProductAttrVal(); $acprattr = $mapattrval->getRealAttrVals($rel_id, $acti_id); return $this->render('buysuccess', ['acprattr' => $acprattr, 'productattr' => $productattr]); }
/** * 第三方登陆,完善信息第一步 * 完善用户名,判断该用户名是否注册,已注册,跳转到验证密码绑定账号,未注册跳转到设置密码页,注册新用户 */ public function actionPerfectOne() { //判断登陆 if ($user = PublicLibrary::is_login()) { if ($user['uid'] !== UserThirdPartyLogin::NOT_BOUND_USERID) { $this->redirect(['main/index']); } } $tplType = $user['third_party_login']['type'] ? $user['third_party_login']['type'] : ''; $avatar = $user['third_party_login']['profile']['avatar']; if (Yii::$app->request->isPost) { $session = Yii::$app->session; $session->isActive ? '' : $session->open(); $username = Yii::$app->request->Post('username'); $verification = Yii::$app->request->Post('verification'); if ($verification == $session->get('__captcha/user/perfectcode')) { $member_model = new Member(); $userone = $member_model->getByUserName($username); if ($userone) { return $this->redirect(['perfect-third', 'username' => $username]); //该用户已存在,进入第三步 } else { return $this->redirect(['perfect-two', 'username' => $username]); //该用户不存在,进入第二步 } } else { echo "<script>alert('验证码不正确!'),window.location.href='" . Url::toRoute('user/perfect-one') . "';</script>"; } } $key = Yii::$app->request->Get('key'); return $this->render('perfectone', ['tplType' => $tplType, 'avatar' => $avatar]); }
/** * @author hongye * * @param int $supportid 支持人id * 测试地址:http://dev.idaiyan.cn/baiying/support?sid=2598 * @return array * */ public function actionSupport() { $user = PublicLibrary::is_login(); if ($user && isset($user['uid']) && $user['uid'] != 'weixin') { $uid = isset($user['uid']) ? $user['uid'] : ''; } else { return $this->redirect(['baiying/productlist']); } $shareid = Yii::$app->request->get('sid'); $shareid = intval($shareid); $models = new BaiyingSupport(); $res = $models->Supportme($shareid); $mbshare = new BaiyingShare(); $shareone = $mbshare->pk($shareid); if ($shareone['uid'] != $uid) { return $this->redirect(['baiying/userproduct']); } $rel_id = $shareone['rel_id']; $acti_id = $shareone['acti_id']; $product_id = $shareone['product_id']; $uid = $shareone['uid']; $share_num = $shareone['share_num']; //支持数 $pmodels = new IProductBase(); $temp = $pmodels->pk($product_id); $name = $temp['name']; // $mshare = new BaiyingShare(); $slist = $mbshare->getShareone($rel_id, $uid, ActivityBase::APPLY_BAIYING); // print_r($slist); // echo '<pre>'; // print_r($slist); // exit; // $acprattr_model = new ActivityProductAttrVal(); // $acprattr = $acprattr_model->getRealAttrVals($rel_id,ActivityBase::APPLY_BAIYING); // echo '<pre>'; // print_r($acprattr); // $supply_num = isset($acprattr['supply_num']['val'])?$acprattr['supply_num']['val']:'30';//商品提供 // echo '<pre>'; // print_r($supply_num); $this->layout = false; return $this->render('supportme', ['res' => $res, 'name' => $name, 'share_num' => $share_num, 'slist' => $slist]); }
/** * goodProduct 注册 * @param array $options i_member中的某些键值对 * [ * 'mobile' => '手机号,为必填字段', * 'truename' => '真名', * 'email' => '邮件地址', * ~~~ * ] * @return int|boolean 成功反回对应uid 失败返回 FALSE * */ public function regist($options = []) { //手机号必填 if (!isset($options['mobile']) || !PublicLibrary::checkMobileType($options['mobile'])) { return FALSE; } $now = time(); $user = self::findOne(['mobile' => $options['mobile']]); if ($user) { return $user->uid; } else { //注册新用户 $options['random'] = mt_rand(1000, 9999); $options['password'] = PublicLibrary::password_encode(substr($options['mobile'], 5, 6), $options['random']); $options['create_at'] = $now; $options['update_at'] = $now; foreach ($options as $key => $value) { $this[$key] = $value; } return $this->save() ? $this->uid : FALSE; } }
/** * 图片上传接口(备用) * @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 格式 } }
/** * 一呼百应 属性接口 * @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'); } }
echo '0'; } ?> </b> </div> <div class="icon icon-love fl"> <b data-tip="关注人数<br><?php if (!empty($product['stat']['follow_num'])) { echo PublicLibrary::strcut($product['stat']['follow_num']); } else { echo '0'; } ?> "><?php if (!empty($product['stat']['follow_num'])) { echo PublicLibrary::strcut($product['stat']['follow_num']); } else { echo '0'; } ?> </b> </div> </div> <div class="prodrate cf"> <div class="axis" style="width:0%"> <div class="guide fr"></div> </div> </div> <div class="prodmate"> <div class="add_icon fr"> <div class="inner_div"></div>
/** * 收货地址管理 * * * * */ public function actionHarvest() { $user = PublicLibrary::is_login(); if (isset($user['uid'])) { $uid = $user['uid']; } else { return $this->redirect(['product/index']); exit; } //收货地址 $mharaddr = new HarvestAddress(); $addresslist = $mharaddr->getByUid($uid); $mDistrict = new District(); $prolist = $mDistrict->getByLevel(); // echo 'Mmm'; // exit; $this->layout_data = 'uc'; return $this->render('harvest', ['addresslist' => $addresslist, 'prolist' => $prolist]); }
/** * 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'); } }
/** * 设置验证key */ public static function setKey() { $checkcode = mt_rand(1000, 9999); $thisdata = date("YmdH"); $checkkey = PublicLibrary::password_encode($thisdata, $checkcode); $session = Yii::$app->session; $session->isActive ? '' : $session->open(); $session->set('checkkey', $checkkey); //$session->close(); //$session->setTimeout('1800');//有效期30分钟 return $checkkey; //<input type="hidden" name="checkkey" value="<{$checkkey}>"> }