Esempio n. 1
0
 public function run()
 {
     $city_code = $this->getDataItem('city_code', 0);
     //上传手机唯一标识
     $phone_id = $this->getDataItem('phone_id', "");
     $cityId = $this->getCityId($city_code);
     if ($cityId <= 0) {
         //return $this->errorLog(ResultStatus::CITY_NOT_OPEN, '城市未开通');
         $cityId = 2;
     }
     $this->bcanon = CosPointCanon::query()->columns(['bc.id', 'bc.title', 'bc.img_url', 'bc.settime', 'bc.fit', 'summary', 'bc.assist'])->leftJoin('Apps\\Common\\Models\\CosBeautyCanon', 'Apps\\Common\\Models\\CosPointCanon.canon_id=bc.id', 'bc')->where('Apps\\Common\\Models\\CosPointCanon.open_city_id = ' . $cityId . ' and bc.state = 2')->orderBy('Apps\\Common\\Models\\CosPointCanon.sort desc')->execute()->toArray();
     $this->bcanon = $this->bcanon ? $this->bcanon : [];
     for ($i = 0; $i < count($this->bcanon); $i++) {
         //判断是否已经点过赞
         $bc_assist = CosBeautyCanonAssist::count(["conditions" => "mobile_sign = :sign: AND beauty_canon_id = :bc_id: ", "bind" => ['sign' => $phone_id, 'bc_id' => $this->bcanon[$i]['id']]]);
         if ($bc_assist > 0) {
             $this->bcanon[$i]['is_assist'] = true;
         }
         if ($this->bcanon[$i]['summary'] == null) {
             $this->bcanon[$i]['summary'] = '';
         }
         // 			$this->bcanon[$i]['img_url'] = PicUrl::BeautyCanonCover($this->bcanon[$i]['img_url'], $this->getDi());
         $this->bcanon[$i]['img_url'] = "http://img.meelier.com/" . $this->bcanon[$i]['img_url'];
         if ($this->bcanon[$i]['fit'] == null) {
             $this->bcanon[$i]['fit'] = 0;
         }
         if ($this->bcanon[$i]['assist'] == null) {
             $this->bcanon[$i]['assist'] = 0;
         }
     }
     $this->setResult($this->bcanon);
 }
Esempio n. 2
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);
 }
Esempio n. 3
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, "");
     }
 }