示例#1
0
 /**
  * 定义与ActivityProductAttrVal的关联关系
  */
 public function getAttrvalone()
 {
     return $this->hasOne(ActivityProductAttrVal::className(), ['rel_id' => 'id', 'acti_id' => 'acti_id']);
 }
示例#2
0
 /**
  * 改变中国好产品 状态,并添加进投票项
  * @param int $id 活动产品id
  * @param int $status 活动产品状态
  *
  * @return json
  * */
 public function actionStatus()
 {
     $admin = Yii::$app->util->isAdminLogin();
     if (!$admin && !Yii::$app->util->isAjax()) {
         echo Yii::$app->util->formatResEncode('1001', 'login error');
         exit;
     }
     $params = Yii::$app->request->post();
     $rel_id = isset($params['id']) ? intval($params['id']) : '';
     $status = isset($params['status']) ? intval($params['status']) : '';
     if (empty($rel_id) || empty($status)) {
         echo Yii::$app->util->formatResEncode('1002', 'param error');
         exit;
     }
     $mActivityProduct = new ActivityProduct();
     $actproduct = $mActivityProduct->getDetailBypk($rel_id);
     $product = $actproduct['product']['name'];
     if ($mActivityProduct->changeStatus($rel_id, $status)) {
         $msg = '产品:' . $product . '状态更改成功!';
         //审核通过 增加投票项
         if ($status == ActivityProduct::STATUS_VERIFY_THROUGH) {
             $mapattrval = new ActivityProductAttrVal();
             $attrval = $mapattrval->getRealAttrVals($rel_id, ActivityBase::GOOD_PRODUCT);
             $city = $attrval['division']['val'];
             $poll_type_id = PollType::GOODPRODUCT_TYPE;
             $mpoll = new poll();
             $pollone = $mpoll->getPollByCity($city, $poll_type_id);
             if ($pollone) {
                 $option = ['poll_id' => $pollone['poll_id'], 'owner_id' => $rel_id, 'option_name' => $product, 'option_type_id' => ActivityBase::GOOD_PRODUCT];
                 $mpolloption = new PollOption();
                 //判断该活动产品 是否已经添加进去投票项
                 $isoption = $mpolloption->isOptionRel($option);
                 if (!$isoption) {
                     $option_id = $mpolloption->storeSave($option);
                     if ($option_id) {
                         if (!strpos($pollone['poll_option_ids'], $rel_id)) {
                             $mpoll = new poll();
                             $ids = empty($pollone['poll_option_ids']) ? $rel_id : $pollone['poll_option_ids'] . ',' . $rel_id;
                             $mpoll->storeSave(['poll_id' => $pollone['poll_id'], 'poll_option_ids' => $ids]);
                         }
                         $option_id ? $msg .= ',添加成为投票项' : '';
                     }
                 }
             }
         }
         echo Yii::$app->util->formatResEncode('0', $msg);
     } else {
         echo Yii::$app->util->formatResEncode('1003', '更改失败!');
     }
 }
示例#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
                ?>
" class="tabitem tab1 fl">
                    <div class="tab_img">
                <?php 
                if (isset($val['mark'])) {
                    ?>
                        <?php 
                    if ($val['mark'] == 'baiying') {
                        ?>
                        <?php 
                        $mBaiyingShare = new BaiyingShare();
                        $number = $mBaiyingShare->getShareNum($val['id']);
                        $over = isset($number) ? intval($number) : 0;
                        $rel_id = isset($val['id']) ? $val['id'] : '';
                        $act_id = isset($val['acti_id']) ? $val['acti_id'] : '';
                        $model = new ActivityProductAttrVal();
                        $attr = $model->getRealAttrVals($rel_id, $act_id);
                        // $attr = $model->getRealAttrVals(32831,8);
                        $limit_people_num = isset($attr['limit_people_num']['val']) ? $attr['limit_people_num']['val'] : 0;
                        $supply_num = isset($attr['supply_num']['val']) ? $attr['supply_num']['val'] : 0;
                        $total = $limit_people_num * $supply_num;
                        $step2 = 0;
                        if ($total !== 0) {
                            $tmp = $over / $total;
                            $step2 = 100 * round($tmp, 2);
                        }
                        ?>
                        <div class="text" data-tip="<a href='<?php 
                        echo Yii::$app->getUrlManager()->createUrl(['product/view', 'id' => $product['id']]);
                        ?>
'><?php 
示例#5
0
 /**
  * 通过分享id 去的产品信息和价格属性,
  * @param int $sid  分享id
  *
  * @return array
  * */
 public function getSharebyid($sid)
 {
     $result = false;
     $sid = intval($sid);
     if ($sid) {
         $result = self::find()->where(['id' => $sid])->with(['product' => function ($query) {
             return $query->select(['id', 'name', 'type', 'title', 'album', 'user_oriented_age', 'user_oriented_gender', 'banner_image', 'price']);
         }])->asArray()->one();
         if ($result) {
             $mapattrval = new ActivityProductAttrVal();
             $acprattr = $mapattrval->getRealAttrVals($result['rel_id'], $result['acti_id']);
             $result['attr'] = $acprattr;
         }
     }
     return $result;
 }
 /**
  * [一呼百应活动宣传主题页]
  * @param  [int] $uid [产品id]
  * 本地地址:http://www.idaiyan-website.cn/special-topic/yihubaiying201503
  * 线上地址:http://test.idaiyan.cn/special-topic/yihubaiying201503
  */
 public function actionYihubaiying201503()
 {
     //获取产品列表数据
     $page = Yii::$app->request->get('page', 1);
     $page = intval($page);
     $mactpro = new ActivityProduct();
     $date = $mactpro->getActProductListpage($page, false, ActivityProduct::PAGE_SIZE_SPECIAL);
     $pages = new Pagination(['totalCount' => $date->count(), 'pageSize' => ActivityProduct::PAGE_SIZE_SPECIAL]);
     $productlist = $date->asArray()->all();
     //取得属性
     $mapattrval = new ActivityProductAttrVal();
     if ($productlist) {
         foreach ($productlist as $pl => $st) {
             $acprattr = $mapattrval->getRealAttrVals($st['id'], ActivityBase::APPLY_BAIYING);
             $productlist[$pl]['attr'] = $acprattr;
         }
     }
     // echo "<pre>";
     // var_dump($productlist);die;
     if ($page > 1) {
         $more = '';
         foreach ($productlist as $key => $val) {
             $priceimg = isset($val['attr']['discount_price']['val']['priceimg']) ? Yii::$app->params['idaiyan'] . '/' . $val['attr']['discount_price']['val']['priceimg'] . '.jpg' : Yii::$app->params['idaiyan-static'] . 'static/modules/home/images/nopic.jpg';
             $pname = isset($val['product']['name']) ? $val['product']['name'] : '';
             $url = Url::toRoute(['product/view', 'id' => $val['product_id']]);
             $data_url = Yii::$app->params['idaiyan'] . Url::toRoute(['baiying/productdetial', 'rel_id' => $val['id']]);
             $more .= "<li><a href='{$url}'> ";
             if ($priceimg) {
                 $more .= "<img src='" . $priceimg . "' alt='" . $pname . "'>";
             } else {
                 $more .= "<img src='" . Yii::$app->params['idaiyan-static'] . "static/modules/home/images/nopic.jpg' alt=''>";
             }
             $more .= "<div class='products'><div class='title'>" . $pname . "</div><div class='qrcode_logo'>\r\n                <div class='QR_code' data-url='{$data_url}'><img src= '" . Yii::$app->params['idaiyan-static'] . "static/modules/home/images/temp/QR_code.png'></div>\r\n                        </div>\r\n                    </div></a></li>";
         }
         //$jsmore =  array(
         //  'code' => 0,
         //'msg' => 'success',
         // 'data' => $more,
         // );
         // echo json_encode($jsmore);
         echo PublicLibrary::format_res_encode('0', 'success', $more);
         exit;
     }
     //var_dump($productlist);die;
     $this->layout = false;
     //调用个人中心的布局
     return $this->render('yihubaiying201503', ['productlist' => $productlist]);
     exit;
 }
示例#7
0
 public function actionApav()
 {
     $model = new ActivityProductAttrVal();
     $data = array('rel_id' => 101, 'acti_id' => 1, 'product_id' => 2000, 'attr_id' => 1, 'attr_val' => '你好吗');
     //var_dump($model->store($data));
     // var_dump($model->setStatus(1, ActivityAttrBase::STATUS_DISABLE));
     var_dump($model->getRealAttrVals(28843, 7));
 }
 /**
  * 好产品详细页
  * @author song
  * @param int $rel_id 活动产品id
  *
  * @return
  * */
 public function actionDetail()
 {
     $rel_id = Yii::$app->request->get('rel_id');
     $rel_id = intval($rel_id);
     if ($rel_id > 0) {
         //查询活动产品详细
         $mActivityProduct = new ActivityProduct();
         $actproduct = $mActivityProduct->getDetailBypk($rel_id);
         if (!$actproduct && $actproduct['status'] != 3) {
             Yii::$app->util->msg('审核未通过,请联系管理员!');
             exit;
         }
         //查询活动产品属性
         $mapattrval = new ActivityProductAttrVal();
         $attrval = $mapattrval->getRealAttrVals($rel_id, ActivityBase::GOOD_PRODUCT);
         //投票信息
         $city = isset($attrval['division']['val']) ? $attrval['division']['val'] : '';
         $poll_type_id = PollType::GOODPRODUCT_TYPE;
         $mpoll = new poll();
         $pollone = $mpoll->getPollByCity($city, $poll_type_id);
         //投票项信息
         $moption = new polloption();
         $optione = $moption->getOptionByowner($pollone['poll_id'], $rel_id);
         //var_dump($optione);
         //exit;
         //增加页面访问量
         $ActivityProductStat_model = new ActivityProductStat();
         $ActivityProductStat_model->incr($rel_id, 'page_views');
         //产品类型
         $IProductType = new IProductType();
         $Ptype = $IProductType->product_type_list();
         $Ptype = ArrayHelper::map($Ptype, 'id', 'name');
         $Ptype[6] = "";
         //页面当name为『其他』时,不然显示
         // print_r($Ptype);exit;
         //            echo '<pre>';
         //            print_r($actproduct);
         // print_r($attrval);
         // exit;
         //数据过滤
         if (isset($attrval['pokedex']['val']) && is_array($attrval['pokedex']['val'])) {
             $tmp = [];
             foreach ($attrval['pokedex']['val'] as $v) {
                 if (!empty($v['title']) && !empty($v['desc']) && !empty($v['url'])) {
                     $tmp[] = $v;
                 }
             }
             $attrval['pokedex']['val'] = $tmp;
         }
         $this->layout = false;
         return $this->render('detail', ['attrval' => $attrval, 'product' => $actproduct, 'optione' => $optione, 'type' => $Ptype, 'goodproduct_city' => ActivityBase::GOODPRODUCT_CITY]);
     }
 }
示例#9
0
 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]);
 }
示例#10
0
 /**
  * Action ChooseActivity
  *
  */
 public function actionChooseActivity()
 {
     $user = yii::$app->util->isLogin();
     if (yii::$app->util->isAjax()) {
         $pid = Yii::$app->request->get('pid') ? Yii::$app->request->get('pid') : '';
         $rel_id = Yii::$app->request->get('rel_id') ? Yii::$app->request->get('rel_id') : '';
         if ($user) {
             if ($pid) {
                 $url = '/support/choose-activity?pid=' . $pid;
             } else {
                 $url = '/support/choose-activity?rel_id=' . $rel_id;
             }
             $data['url'] = $url;
             echo yii::$app->util->formatResEncode('0', '该用户已经登录', $data);
             exit;
         } else {
             echo yii::$app->util->formatResEncode('1', '该用户没有登录');
             exit;
         }
     }
     if (Yii::$app->request->get('pid') || Yii::$app->request->get('rel_id')) {
         $rel_id = Yii::$app->request->get('rel_id');
         if ($rel_id) {
             $mActivityProduct = new ActivityProduct();
             $productActivity = $mActivityProduct->getByIdAndStatus($rel_id);
             $pid = intval($productActivity['product_id']);
         } else {
             $pid = Yii::$app->request->get('pid');
         }
         $mProductBase = new IProductBase();
         $myproduct = $mProductBase->isMyProduct($user['uid'], $pid);
         // $myproduct = '';
         if (!$myproduct) {
             $mProductBase = new IProductBase();
             $mActivityBase = new ActivityBase();
             $mActivityProductAttrVal = new ActivityProductAttrVal();
             $result = $mProductBase->getAllById(intval($pid));
             //查询活动
             $activity = $mActivityBase->getByFeature();
             foreach ($activity as $key => $val) {
                 $key = $val['id'];
                 $activity[$key] = $val;
             }
             //var_dump($result['aproduct']);die;
             //产品对应活动和价格
             if (!empty($result['aproduct'])) {
                 foreach ($result['aproduct'] as $key => $value) {
                     $attr[] = $mActivityProductAttrVal->getRealAttrVals($value['id'], $value['acti_id']);
                     // echo "<pre>";
                     // var_dump($attr[$key]['discount_price']['val']['price']);die;
                     $result['aproduct'][$key]['attr'] = isset($attr[$key]['discount_price']['val']) ? $attr[$key]['discount_price']['val'] : 0;
                     $result['aproduct'][$key]['num'] = isset($attr[$key]['supply_num']['val']) ? $attr[$key]['supply_num']['val'] : 0;
                     $price[$value['id']] = isset($attr[$key]['discount_price']['val']['price']) ? $attr[$key]['discount_price']['val']['price'] : 0;
                     // $price[] = array($value['id'] => $attr[$key]['discount_price']['val']['price']);
                     // // $price[$value['id']] = $attr[$key]['discount_price']['val']['price'];
                     //var_dump($price);die;
                     if (!empty($activity[$value['acti_id']])) {
                         $result['aproduct'][$key]['activity'] = $activity[$value['acti_id']];
                     }
                 }
             } else {
                 return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
                 //跳转到完善信息
             }
             $productData = array('pid' => $pid, 'name' => $result['name'], 'summary' => $result['extra']['summary'], 'album' => $result['album'], 'price' => $result['price']);
             $session = Yii::$app->session;
             $session->isActive ? '' : $session->open();
             $session->set('product', $productData);
             if (isset($price)) {
                 $session->set('activityprice', $price);
             }
             //$session->set('activityprice',$price);
             // echo "<pre>";
             // //var_dump($productActivity['acti_id']);
             // var_dump($result);die;
             $this->layout = '@app/views/layouts/main.php';
             //调用个人中心的布局
             if ($result) {
                 return $this->render('chooseactivity', ['data' => isset($result) ? $result : '', 'acti_id' => isset($productActivity) ? $productActivity['acti_id'] : '']);
             }
         } else {
             return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
             //跳转到完善信息
         }
     } else {
         return $this->redirect('/product/index');
         //跳转到完善信息
     }
 }
示例#11
0
 /**
  * @author song
  * 提屁股 成功修改状态接口
  * @param int  $supportid 支持人id
  * @param int $supnum 踢屁股次数
  *
  * @return json
  * */
 public function actionGamesuccess()
 {
     //判断登陆
     $user = PublicLibrary::is_login();
     if ($user && $user['uid'] != 'weixin' && PublicLibrary::is_ajax()) {
         $date = Yii::$app->request->post();
         $supportid = isset($date['supportid']) ? intval($date['supportid']) : 0;
         $supnum = isset($date['supnum']) ? intval($date['supnum']) : 0;
         $msupport = new BaiyingSupport();
         $supportone = $msupport->pk($supportid);
         if ($supportone && $supportone['support_status'] == BaiyingSupport::SUPPORT_STATUS_DEF) {
             if ($supnum > BaiyingSupport::SUPPORT_STATAR) {
                 $mshare = new BaiyingShare();
                 //查询分享人uid
                 $oldres = $mshare->pk($supportone['shareid']);
                 $rel_id = $oldres['rel_id'];
                 //判断活动状态
                 $mactpro = new ActivityProduct();
                 $productattr = $mactpro->getDetailBypk($rel_id);
                 if ($productattr['status'] != ActivityProduct::STATUS_VERIFY_THROUGH) {
                     echo "<script>alert('活动已结束!'),window.location.href='/baiying/userproduct';</script>";
                     exit;
                 }
                 //查询该分享人所有的分享列表
                 $sharelist = $mshare->getSharelistByuid('', $oldres['uid'], ActivityBase::APPLY_BAIYING);
                 foreach ($sharelist as $key => $val) {
                     $sarr[] = $val['id'];
                 }
                 //查询当前用户支持成功的 记录
                 $usersuplist = $msupport->getSupportlist('', $user['uid'], BaiyingSupport::SUPPORT_STATUS_SUCCE);
                 foreach ($usersuplist as $key => $val) {
                     $uresanduser = $mshare->pk($val['shareid']);
                     //当前用户支持的产品的发布用户 等于 要支持订单的发布者
                     if ($uresanduser['uid'] == $oldres['uid']) {
                         $uarr[] = $val['shareid'];
                     }
                 }
                 if (isset($sarr) && isset($uarr)) {
                     $insec = array_intersect($sarr, $uarr);
                 }
                 //                $cc = isset($insec)?$insec:'1';
                 //                echo '<pre>';
                 //                print_r($cc);
                 if (isset($insec) && is_array($insec)) {
                 } else {
                     //增加分享支持统计数
                     $shafu = $mshare->addSharenum($supportone['shareid']);
                 }
                 $shareone = $mshare->pk($supportone['shareid']);
                 //支持数大于标准(30),且状态为1 修改支付状态
                 if ($shareone['share_num'] >= BaiyingShare::SHARE_STANDARD && $shareone['share_status'] == BaiyingShare::SHARE_STATUS_DEF) {
                     $sharecontent['id'] = $supportone['shareid'];
                     //商品剩余不足 状态修改成 售罄
                     //支付成功的分享
                     $succnum = $mshare->getcountnum($shareone['rel_id'], BaiyingShare::SHARE_STATUS_PAY);
                     //商品属性
                     $mapattrval = new ActivityProductAttrVal();
                     $acprattr = $mapattrval->getRealAttrVals($shareone['rel_id'], ActivityBase::APPLY_BAIYING);
                     if ($succnum >= $acprattr['supply_num']['attr_val']) {
                         $sharecontent['share_status'] = BaiyingShare::SHARE_OUT;
                     } else {
                         $sharecontent['share_status'] = BaiyingShare::SHARE_STATUS_SUCCE;
                     }
                     $res = $mshare->store($sharecontent);
                 }
                 $upcontent['support_status'] = BaiyingSupport::SUPPORT_STATUS_SUCCE;
             }
             //更新支持提屁股次数和 状态
             $upcontent['id'] = $supportid;
             $upcontent['uid'] = isset($user['uid']) ? $user['uid'] : '';
             $upcontent['mobile'] = isset($user['mobile']) ? $user['mobile'] : '';
             if ($supnum > $supportone['sup_num']) {
                 $upcontent['sup_num'] = $supnum;
             }
             $supfu = $msupport->store($upcontent);
             if ($supfu) {
                 echo PublicLibrary::format_res_encode('0', 'success', 'f**k');
             } else {
                 echo PublicLibrary::format_res_encode('1001', 'save error!');
             }
         } else {
             $upcontent['id'] = $supportid;
             if ($supnum > $supportone['sup_num']) {
                 $upcontent['sup_num'] = $supnum;
             }
             $upcontent['support_status'] = BaiyingSupport::SUPPORT_STATUS_SUCCE;
             $supfu = $msupport->store($upcontent);
             if ($supfu) {
                 echo PublicLibrary::format_res_encode('01', 'supnum up success!');
             } else {
                 echo PublicLibrary::format_res_encode('1003', 'supnum up error!');
             }
         }
     } else {
         echo PublicLibrary::format_res_encode('1001', 'the user no login or no ajax!');
         exit;
     }
 }
示例#12
0
 /**
  * 数据
  */
 public function val($relid, $attrid)
 {
     $mAttrBase = new ActivityAttrBase();
     $attr = $mAttrBase->pk($attrid);
     $result = false;
     if (!$attr || $attr['status'] == ActivityAttrBase::STATUS_DISABLE) {
         return FALSE;
     }
     $mAttrVal = new ActivityProductAttrVal();
     $attrval = [];
     if (!($attrval = $mAttrVal->getAttrVal($relid, $attrid))) {
         return FALSE;
     }
     $result = $this->parse(['ap_id' => $relid, 'product_id' => $attrval['product_id'], 'acti_id' => $attrval['acti_id'], 'type' => $attr['type'], 'attr_customid' => $attr['custom_id'], 'data_type' => $attr['data_type'], 'attr_val' => $attrval['attr_val']]);
     return $result;
 }
示例#13
0
 /**
  * 获取分组完成度
  *
  * @param int $apid 活动产品ID
  * @return array 分组完成度数据
  * 分组完成度的数据结构如下:
  * ~~~
  *  [
  *      [
  *          'id' => '分组ID',
  *          'acti_id' => '活动ID',
  *          'name' => '名称',
  *          'is_completed' => '是否已完成, 0: 未完成; 1: 已完成',
  *      ],
  *      // 其他分组数据......
  *  ]
  * ~~~
  *
  */
 public function getCompleteStatus($apid)
 {
     $apid = intval($apid);
     $result = [];
     $attrvals = [];
     $mActiProd = new ActivityProduct();
     $actiprod = $mActiProd->pk($apid);
     if (!$actiprod) {
         return false;
     }
     $aid = intval($actiprod['acti_id']);
     $group = $this->getValidGroupsByAid($aid, TRUE);
     $mAttrVal = new ActivityProductAttrVal();
     $result = $mAttrVal->getAttrVal($apid, false, ['attr_id', 'finish_status']);
     // 重新“组织”数据结构,即使用属性ID作为Key
     if ($result && is_array($result)) {
         foreach ($result as $val) {
             $attrvals[$val['attr_id']] = $val['finish_status'];
         }
     }
     // 针对每一个分组的attrs属性进行完成度"检测",并增加is_completed元素
     // is_completed 1: 已完成, 2: 未完成
     if ($group && is_array($group)) {
         foreach ($group as $key => $val) {
             if ($val['attrs'] && is_array($val['attrs'])) {
                 $group[$key]['is_completed'] = true;
                 foreach ($val['attrs'] as $attr) {
                     $attrid = $attr['attr_id'];
                     if (!isset($attrvals[$attrid]) || !$attrvals[$attrid]) {
                         $group[$key]['is_completed'] = false;
                         break;
                     }
                 }
                 unset($group[$key]['attrs']);
             } else {
                 $group[$key]['is_completed'] = false;
             }
         }
     }
     return $group;
 }
示例#14
0
 /**
  * 查询分组属性
  * 活动产品属性完成度接口
  * @param int $relid  活动产品id
  * @param int $actiid  活动id
  * @param int $groupid  属性分组group_id
  *
  * @return boolean
  */
 public function completion($relid, $actiid, $groupid)
 {
     $ids = [];
     $conditions = ['acti_id' => $actiid, 'group_id' => $groupid];
     $res = self::find()->select(['id', 'acti_id', 'group_id', 'attr_id'])->where($conditions)->asArray()->all();
     foreach ($res as $key => $val) {
         $ids[] = $val['attr_id'];
     }
     $defcount = count($res);
     //查询该属性分组的个数
     $res = ActivityProductAttrVal::find()->where(['attr_id' => $ids, 'rel_id' => $relid, 'acti_id' => $actiid])->asArray()->all();
     $realcount = count($res);
     //查询该属性分组的值个数
     if ($defcount == $realcount && $res && is_array($res)) {
         foreach ($res as $key => $value) {
             if ($value['finish_status'] != 1) {
                 return false;
             }
         }
         return true;
     } else {
         return false;
     }
     // return $result;
 }
示例#15
0
 /**
  * 运营后台 设置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]);
 }