Exemple #1
0
 public function run()
 {
     //验证登录
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $userId = $this->getUserAuth()->userId;
     $bc_id = intval($this->getDataItem('bc_id', 0));
     if ($bc_id > 0) {
         $bc_info = CosBeautyCanon::findFirst("id = {$bc_id} and state != 3");
         if ($bc_info) {
             //判断是否已经点过赞
             $bc_assist = CosBeautyCanonAssist::count(["conditions" => "user_id = :sign: AND beauty_canon_id = :bc_id: ", "bind" => ['sign' => $userId, 'bc_id' => $bc_id]]);
             if ($bc_assist > 0) {
                 $query = CosBeautyCanon::findFirst("id = {$bc_id}")->toArray();
                 $this->assist = intval($query['assist']);
                 $this->success = 2;
             } else {
                 //记录点赞
                 $model = new CosBeautyCanonAssist();
                 $model->user_id = $userId;
                 $model->beauty_canon_id = $bc_id;
                 $model->setdate = date("Y-m-d H:i:s", time());
                 if ($model->save()) {
                     $this->updateAssist($bc_id);
                     $query = CosBeautyCanon::findFirst("id = {$bc_id}")->toArray();
                     $this->assist = intval($query['assist']);
                     $this->success = 1;
                 } else {
                     return $this->databaseErrorLog($model);
                 }
             }
             $this->setResult(["success" => $this->success, "assist" => $this->assist]);
         } else {
             return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "该美粒宝典不存在!");
         }
     } else {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "");
     }
 }
Exemple #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);
 }
 /**
  * 首页推荐美粒宝典取消推荐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;
     }
 }