/** * @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]); }
public function actionAag() { $model = new ActivityAttrGroup(); /* $data = array( 'acti_id' => 1, 'name' => '测试分组2', 'desc' => 'TEST', ); var_dump($model->store($data)); */ // var_dump($model->getValidGroupsByAid(7)); var_dump($model->getCompleteStatus(28843)); }
/** * 中国好产品 活动 发布 * *@param int $id 活动产品id * * @return string $result 返回json数组字符串 * ~~~ * [ * 'code'=>1001, * 'msg'=>'不是Ajax请求', * 'data'=>[], * ] *其它 …… * ~~~ * code 对于 msg如下 * 0 入库成功 * 1001 不是Ajax请求 * 1002 参数异常 * 1003 信息不完善 * 1004 入库失败 */ public function actionPublish() { if (yii::$app->util->isAjax()) { $user = yii::$app->util->isLogin(); $user ? $uid = $user['uid'] : ($uid = 0); $id = Yii::$app->request->post('id'); $id = intval($id); $activityProduct = new ActivityProduct(); $row = $activityProduct->getbypkanduid($id, $uid); if (!empty($row) && $row->acti_id == ActivityBase::GOOD_PRODUCT) { //判断活动信息是否完整 $mActivityAttrGroup = new ActivityAttrGroup(); $tmp = $mActivityAttrGroup->getCompleteStatus($id); $isComplete = 1; foreach ($tmp as $v) { if ($v['type'] == 1) { if ($v['is_completed'] == 0) { $isComplete = 0; break; } } } if ($isComplete) { $model = ActivityProduct::findOne($id); $model->status = ActivityProduct::STATUS_VERIFYING; if ($model->save()) { $result = ['code' => 0, 'msg' => '入库成功', 'data' => ['url' => 'home-page/lists?uid=' . $uid]]; } else { $result = ['code' => 1004, 'msg' => '入库失败', 'data' => []]; } } else { $result = ['code' => 1003, 'msg' => '信息不完善', 'data' => []]; } } else { $result = ['code' => 1002, 'msg' => '参数异常', 'data' => []]; } } else { $result = ['code' => 1001, 'msg' => '不是Ajax请求', 'data' => []]; } $result = json_encode($result); return $result; }
/** * 产品修改判断接口(显示修改页面) * @param [int] $id [产品id] * 测试地址:http://dev.idaiyan.cn/product/editchoose?id=4464 * 测试地址:http://dev.idaiyan.cn/product/editchoose?id=4480 */ public function actionEditchoose() { $form = Yii::$app->request->post(); $id = intval($form['id']); //查询这个产品参加过多少活动 $mactivitypdt = new ActivityProduct(); $res = $mactivitypdt->getActivitydata($id); foreach ($res as $key => $value) { if ($value['acti_id'] == 1) { unset($res[$key]); } } // echo '<pre>'; // print_r($res); $ActivityAttrGroup = new ActivityAttrGroup(); if ($res) { //如果参加了活动 $temp = array(); $result = array(); foreach ($res as $key => $value) { // echo $value['apstat']['rel_id'].'<br />'; //判断完成度 $menu = $ActivityAttrGroup->getCompleteStatus($value['apstat']['rel_id']); $all = 0; $over = 0; // $all = count($menu); //菜单总数 // $done = 0; // $type = 0; // if (!empty($menu)) { // foreach ($menu as $key=>$val){ // $done += $val['is_completed']; // $type += $val['type']; // } // } foreach ($menu as $li) { $status = 'status ignore'; if ($li['type'] == 1) { $all++; if ($li['is_completed'] == 1) { $over++; } } } $step = $all - $over; // echo $all; // echo '<pre>'; // echo $all; // echo '<pre>'; // print_r($menu); $key = intval($key); $temp[$key] = $value['activity']; // $temp[$key]['status'] = $value['status']; if ($value['acti_id'] == 8) { //如果是一呼百应活动 if ($value['status'] == 2) { $temp[$key]['status'] = 0; //审核中的活动产品不可点 灰色 $temp[$key]['url'] = ''; $temp[$key]['step'] = $step; } else { if ($value['status'] == 3) { //审核通过,部分可以编辑(缺少对应的链接) $temp[$key]['status'] = 1; // if ($value['apply_way']) { //diy $temp[$key]['url'] = '/activity/applybaiying?pid=' . $id; //http://dev.idaiyan.cn/activity/productactivity?pid=4465&aid=7 $temp[$key]['step'] = $step; } else { //官方 $temp[$key]['url'] = '/activity/applybaiying-diy?pid=' . $id; //http://dev.idaiyan.cn/activity/productactivity?pid=4465&aid=7 $temp[$key]['step'] = $step; } } else { $temp[$key]['status'] = 1; // if ($value['apply_way']) { //diy $temp[$key]['url'] = '/activity/applybaiying?pid=' . $id; //http://dev.idaiyan.cn/activity/productactivity?pid=4465&aid=7 $temp[$key]['step'] = $step; } else { //官方 $temp[$key]['url'] = '/activity/applybaiying-diy?pid=' . $id; //http://dev.idaiyan.cn/activity/productactivity?pid=4465&aid=7 $temp[$key]['step'] = $step; } } } } else { if ($value['acti_id'] == 9) { if ($value['status'] == 2) { $temp[$key]['status'] = 0; //审核中的活动产品不可点 灰色 $temp[$key]['url'] = ''; } else { if ($value['status'] == 3) { //审核通过,部分可以编辑(缺少对应的链接) $temp[$key]['status'] = 1; // $temp[$key]['url'] = '/goodproduct/good-product?pid=' . $id; //http://dev.idaiyan.cn/activity/productactivity?pid=4465&aid=7 } else { $temp[$key]['status'] = 1; // $temp[$key]['url'] = '/goodproduct/good-product?pid=' . $id; } } $temp[$key]['step'] = $step; } else { if ($value['status'] == 2) { $temp[$key]['status'] = 0; //审核中的活动产品不可点 灰色 $temp[$key]['url'] = ''; } else { if ($value['status'] == 3) { //审核通过,部分可以编辑(缺少对应的链接) $temp[$key]['status'] = 1; // $temp[$key]['url'] = '/activity/productactivityedit?rel_id=' . $value['apstat']['rel_id']; //http://dev.idaiyan.cn/activity/productactivity?pid=4465&aid=7 } else { $temp[$key]['status'] = 1; // $temp[$key]['url'] = '/activity/productactivityedit?rel_id=' . $value['apstat']['rel_id']; } } $temp[$key]['step'] = $step; } } // $temp[$key]['step'] = '3'; $t = array_push($result, $temp[$key]); } // echo '<pre>'; // print_r($result); echo PublicLibrary::format_res_encode('1001', 'applyactivity!', $result); exit; } else { echo PublicLibrary::format_res_encode('1000', 'no applyactivity!'); exit; } }