/** * 改变中国好产品 状态,并添加进投票项 * @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', '更改失败!'); } }
/** * 365活动生成专题页 * @param $rel_id int 产品活动ID * @测试地址:http://test.idaiyan.cn/activity/generationh5?rel_id=32837 * @测试地址:http://dev.idaiyan.cn/activity/generationh5?rel_id=32821 */ public function actionGenerationh5() { $parr = Yii::$app->request->get(); $rel_id = isset($parr['rel_id']) && $parr['rel_id'] && is_numeric($parr['rel_id']) ? intval($parr['rel_id']) : $this->redirect(['product/index']); $session = Yii::$app->session; $session->isActive ? '' : $session->open(); if (!empty($_SESSION['user']['uid'])) { $uid = $_SESSION['user']['uid']; //查询用户有没有购买该商品 $model_order = new Order(); $res = $model_order->Mycheckpay($uid, $rel_id); if ($res) { if ($res['ispay'] == 1) { //订单完成 ,已经购买 $isready = 1; } else { $isready = 2; //下过订单,还没有支付 } } else { $isready = 0; } $user = $_SESSION['user']; } else { $uid = 0; $isready = 0; $user = array(); } // print_r($user);exit; $status = ActivityProduct::STATUS_VERIFY_THROUGH; $activityproduct_model = new ActivityProduct(); $actdetail = $activityproduct_model->getDetailBypk($rel_id); if (!$actdetail) { return $this->redirect(['product']); exit; } $actdetail['product']['user_oriented_age'] = str_pad($actdetail['product']['user_oriented_age'], 4, '0', STR_PAD_LEFT); $acprattr_model = new ActivityProductAttrVal(); $acprattr = $acprattr_model->getRealAttrVals($rel_id, 7); if (isset($acprattr['end_time']['val'])) { $acprattr['end_time']['val'] = explode('-', $acprattr['end_time']['val']); } if (!empty($acprattr['video']['val']['video_url'])) { if (substr($acprattr['video']['val']['video_url'], 0, 4) == 'http') { $acprattr['video']['val']['video_url'] = Yii::$app->util->generalVideo($acprattr['video']['val']['video_url']); } } $_SESSION['activityProduct']['price'] = isset($acprattr['discount_price']['val']['price']) ? $acprattr['discount_price']['val']['price'] : '1'; // echo "<pre>"; // print_r($actdetail); // exit; //查询该产品 type=4 的 图片 用在 首屏背景图那里 $mpimg = new ProductImage(); $fourimg = $mpimg->getByTypeAndPid(ProductImage::TYPE_CATIONFIRST, $actdetail['product_id']); $this->layout = false; return $this->render('generationh5', ['actdetail' => $actdetail, 'acprattr' => $acprattr, 'fourimg' => $fourimg, 'uid' => $uid, 'user' => $user, 'isready' => $isready]); }
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]); }
/** * 好产品详细页 * @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]); } }
/** * @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; } }