Пример #1
0
 public function run()
 {
     //上传用户id
     $user_id = intval($this->getDataItem('user_id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $this->beautyCanons = CosBeautyCanon::query()->columns(['id', 'title', 'img_url', 'settime', 'fit', 'summary', 'assist'])->where("state != 3")->orderBy('settime DESC')->limit($limit, $offset)->execute()->toArray();
     $this->beautyCanons = $this->beautyCanons ? $this->beautyCanons : [];
     for ($i = 0; $i < count($this->beautyCanons); $i++) {
         if ($user_id > 0) {
             //判断是否已经点过赞
             $bc_assist = CosBeautyCanonAssist::count(["conditions" => "user_id = :sign: AND beauty_canon_id = :bc_id: ", "bind" => ['sign' => $user_id, 'bc_id' => $this->beautyCanons[$i]['id']]]);
         } else {
             $bc_assist = 0;
         }
         if ($bc_assist > 0) {
             $this->beautyCanons[$i]['is_assist'] = true;
         } else {
             $this->beautyCanons[$i]['is_assist'] = false;
         }
         if ($this->beautyCanons[$i]['summary'] == null) {
             $this->beautyCanons[$i]['summary'] = '';
         }
         $this->beautyCanons[$i]['img_url'] = "http://img.meelier.com/" . $this->beautyCanons[$i]['img_url'];
         if (empty($this->beautyCanons[$i]['fit'])) {
             $this->beautyCanons[$i]['fit'] = 0;
         }
         if (empty($this->beautyCanons[$i]['assist'])) {
             $this->beautyCanons[$i]['assist'] = 0;
         }
     }
     $this->setResult($this->beautyCanons);
 }
Пример #2
0
 public function run()
 {
     $id = intval($this->getDataItem('id', 0));
     if (0 < $id) {
         $this->bcanonInfo = CosBeautyCanon::query()->columns(['content', 'fit'])->where('state != 3 and id = ' . $id)->execute()->getFirst();
     } else {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '参数异常');
     }
     if ($this->bcanonInfo) {
         if ($this->bcanonInfo->fit == null) {
             $this->bcanonInfo->fit = 0;
         }
         //浏览量加1
         $query = new CosBeautyCanon();
         $model = $query->findFirst(' id = ' . $id);
         $model->fit = $this->bcanonInfo->fit + 1;
         $model->save();
         //循环处理内容中的图片
         $this->bcanonInfo->content = str_replace('src="/ueditor/php/upload/image/', 'src="http://meelier.com/ueditor/php/upload/image/', $this->bcanonInfo->content);
     } else {
         $this->bcanonInfo = null;
     }
     $this->setResult($this->bcanonInfo);
 }
Пример #3
0
 public function run()
 {
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $this->beautyCanons = CosBeautyCanon::query()->columns(['id', 'title', 'img_url', 'settime', 'fit', 'assist'])->where("state != 3")->orderBy('settime DESC')->limit($limit, $offset)->execute()->toArray();
     $this->beautyCanons = $this->beautyCanons ? $this->beautyCanons : [];
     for ($i = 0; $i < count($this->beautyCanons); $i++) {
         $this->beautyCanons[$i]['img_url'] = "http://img.meelier.com/" . $this->beautyCanons[$i]['img_url'];
         if (empty($this->beautyCanons[$i]['fit'])) {
             $this->beautyCanons[$i]['fit'] = 0;
         }
         if (empty($this->beautyCanons[$i]['assist'])) {
             $this->beautyCanons[$i]['assist'] = 0;
         }
     }
     $this->setResult($this->beautyCanons);
 }
Пример #4
0
 /**
  * 首页推荐美粒宝典取消推荐1.0版本
  *
  * @return $this|ResponseResult
  */
 public function undoAction()
 {
     $req = $this->request;
     $id = $req->getQuery("id");
     $status = CosPointCanon::find("canon_id = {$id}")->delete();
     $cosbeautycanon = CosBeautyCanon::findFirst("id = {$id}");
     $cosbeautycanon->state = 1;
     $flg = $cosbeautycanon->save();
     if ($flg == true && $status == true) {
         $arr = array("status" => 10000);
         echo json_encode($arr);
         exit;
     } else {
         $arr = array("status" => 0, "errmsg" => "error");
         echo json_encode($arr);
         exit;
     }
 }
Пример #5
0
 public static function updateAssist($id)
 {
     $sql = 'UPDATE beauty_canon SET assist = assist+1 WHERE id = :bc_id';
     $model = new CosBeautyCanon();
     return $model->getWriteConnection()->execute($sql, ['bc_id' => $id]);
 }
Пример #6
0
 /**
  * 美粒宝典预览
  * @date: 2016年1月4日 
  * @author: chenxiaolin
  */
 public function beautyCanonAction()
 {
     $id = $this->request->getQuery('id');
     if (empty($id)) {
         echo '美粒宝典不存在!';
         $this->view->disable();
         return;
     }
     $canon = CosBeautyCanon::query()->columns(['title', 'content'])->where('id=:id:')->bind(['id' => $id])->execute()->getFirst();
     if (!$canon) {
         echo '美粒宝典不存在!';
         $this->view->disable();
         return;
     }
     $this->view->setVar('canon', $canon);
     //$this->tag->setTitle($data['beauty_parlor']->name);
 }
Пример #7
0
 public static function updateAssist($id)
 {
     $sql = 'UPDATE cos_beauty_canon SET assist = (SELECT COUNT(*) FROM cos_beauty_canon_assist WHERE beauty_canon_id=cos_beauty_canon.id) WHERE id = :bc_id';
     $model = new CosBeautyCanon();
     return $model->getWriteConnection()->execute($sql, ['bc_id' => $id]);
 }