Ejemplo n.º 1
0
 /**
  * @author shimeixia <*****@*****.**>
  * @param $pid 产品id
  * @param $aid 活动id
  *
  * @return
  */
 public function actionApplybaiyingDiy()
 {
     $user = PublicLibrary::is_login() ? PublicLibrary::is_login() : $this->redirect(['user/login']);
     $parr = Yii::$app->request->get();
     $pid = isset($parr['pid']) ? intval($parr['pid']) : '';
     $aid = intval(ActivityBase::APPLY_BAIYING);
     if (empty($pid) || empty($aid)) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到完善信息
     }
     //判断是否存在该活动
     $mActiBase = new ActivityBase();
     $activity = $mActiBase->pk($aid);
     if (!$activity) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到用户主页
     }
     //查询是不是该用户发布的产品
     $model = new IProductBase();
     $res = $model->isMyProduct($user['uid'], $pid);
     if (!$res) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到用户主页
     }
     //$session->set('acti_config', $activity['config']);
     //查询该商品有没有参加过该活动
     $mactivitypdt = new ActivityProduct();
     $one = $mactivitypdt->isinActivity($user['uid'], $aid, $pid);
     //$one = $mactivitypdt ->applyWay($user['uid'],$aid,$pid,0);
     // echo '<pre>';
     // var_dump($one);die;
     //活动属性map
     $mArag = new ActivityRelAttrGroup();
     $attrMap = $mArag->getAttrMapping($aid);
     if (!$one) {
         //入库
         $apdata = ['product_id' => $pid, 'acti_id' => $aid, 'user_id' => $user['uid'], 'status' => ActivityProduct::STATUS_SAVE, 'apply_way' => 0];
         $rel_id = $mactivitypdt->store($apdata);
         //插入到活动产品统计表
         $apstart = new ActivityProductStat();
         $data = ['rel_id' => $rel_id, 'acti_id' => $aid, 'product_id' => $pid];
         $apstart->store($data);
     } else {
         // //判断是否是官方申请
         // $model = $mactivitypdt->pk($one['id']);
         // $model->apply_way == 1 ? '' : $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         $rel_id = $one['id'];
         if ($one['apply_way'] == 1) {
             $apdata = ['id' => $rel_id, 'apply_way' => 0];
             $mactivitypdt->store($apdata);
         }
         if ($one['status'] == ActivityProduct::STATUS_VERIFYING) {
             //审核中
             return $this->redirect(['home-page/lists', 'uid' => $_SESSION['user']['uid']]);
             //跳转到完善信息
         } else {
             $ActivityProductAttrVal = new ActivityProductAttrVal();
             $attrval = $ActivityProductAttrVal->getRealAttrVals($rel_id, $aid);
             $attrval = array_merge($attrMap, $attrval);
             // echo '<pre>';
             // print_r($attrval);
             if (isset($attrval['album']['val']) && is_array($attrval['album']['val'])) {
                 foreach ($attrval['album']['val'] as $key => $value) {
                     if ($value['type'] == ProductImage::TYPE_CATIONFIRST) {
                         $fourpimag[] = $value;
                     }
                     if ($value['type'] == ProductImage::TYPE_CATIONINDE) {
                         $fivepimag[] = $value;
                     }
                 }
             }
         }
     }
     //查询左侧菜单
     $ActivityAttrGroup = new ActivityAttrGroup();
     $menu = $ActivityAttrGroup->getCompleteStatus($rel_id);
     //echo '<pre>';
     //print_r($attrval);
     // exit;
     $this->layout_data = 'uc';
     return $this->render('applybaiyingdiy', ['price' => $res[0]['price'], 'attrs' => isset($attrval) ? $attrval : '', 'pid' => $pid, 'rel_id' => $rel_id, 'menu' => $menu, 'attrMap' => $attrMap]);
 }
Ejemplo n.º 2
0
 /**
  * @author shimeixia <*****@*****.**>
  * @param $pid 产品id
  *
  * @return
  */
 public function actionGoodProduct()
 {
     $user = yii::$app->util->isLogin() ? yii::$app->util->isLogin() : $this->redirect(['user/login']);
     $parr = Yii::$app->request->get();
     $pid = isset($parr['pid']) ? intval($parr['pid']) : '';
     $aid = ActivityBase::GOOD_PRODUCT;
     if (empty($pid) || empty($aid)) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到完善信息
     }
     //判断是否存在该活动
     $mActiBase = new ActivityBase();
     $activity = $mActiBase->pk($aid);
     if (!$activity) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到用户主页
     }
     //查询是不是该用户发布的产品
     $model = new IProductBase();
     $res = $model->isMyProduct($user['uid'], $pid);
     if (!$res) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到用户主页
     }
     //查询该商品有没有参加过该活动
     $mactivitypdt = new ActivityProduct();
     $one = $mactivitypdt->isinActivity($user['uid'], $aid, $pid);
     //属性Map
     $mArag = new ActivityRelAttrGroup();
     $attrMap = $mArag->getAttrMapping($aid);
     if (!$one) {
         //入库
         $apdata = ['product_id' => $pid, 'acti_id' => $aid, 'user_id' => $user['uid'], 'status' => ActivityProduct::STATUS_SAVE, 'apply_way' => 1];
         $rel_id = $mactivitypdt->store($apdata);
         //插入到活动产品统计表
         $apstart = new ActivityProductStat();
         $data = ['rel_id' => $rel_id, 'acti_id' => $aid, 'product_id' => $pid];
         $apstart->store($data);
         //赛区数据入库
         $mbaseattr = new BaseAttribute();
         $value = $mbaseattr->save($rel_id, $user['uid'], 15, ActivityBase::GOODPRODUCT_CITY, false, 1);
         $value = $mbaseattr->save($rel_id, $user['uid'], 18, time(), false, 1);
     } else {
         $rel_id = $one['id'];
         if ($one['status'] == ActivityProduct::STATUS_VERIFYING) {
             //审核中
             return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
             //跳转到完善信息
         }
     }
     //查询左侧菜单
     $ActivityAttrGroup = new ActivityAttrGroup();
     $menu = $ActivityAttrGroup->getCompleteStatus($rel_id);
     // echo "<pre>";
     // var_dump($menu);die;
     $ActivityProductAttrVal = new ActivityProductAttrVal();
     $attrval = $ActivityProductAttrVal->getRealAttrVals($rel_id, $aid);
     $attrval = array_merge($attrMap, $attrval);
     if (isset($attrval['pokedex']['val']) && is_array($attrval['pokedex']['val'])) {
         foreach ($attrval['pokedex']['val'] as $key => $value) {
             if ($value['type'] == ProductImage::TYPE_GOODPRODUCT) {
                 $image[] = $value;
             }
         }
     }
     $this->layout_data = 'uc';
     return $this->render('goodproduct', ['pid' => $pid, 'rel_id' => $rel_id, 'menu' => $menu, 'attrs' => isset($attrval) ? $attrval : "", 'attrMap' => $attrMap, 'image' => isset($image) ? $image : " ", 'goodproduct_city' => ActivityBase::GOODPRODUCT_CITY]);
 }