コード例 #1
0
ファイル: FavoritesList.php プロジェクト: fu-tao/meelier_c
 public function run()
 {
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $page = $this->getDataItem('page', 1);
     $limit = 10;
     $offset = ($page - 1) * $limit;
     $userId = $this->getUserAuth()->userId;
     if ($userId == '') {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '参数异常');
     }
     //$userId=1;
     $my_favorites = BpFavorites::query()->where("user_id = {$userId}")->limit($limit, $offset)->execute()->toArray();
     foreach ($my_favorites as $fav) {
         $bp_list[] = BeautyParlor::findFirst(["bp_id = " . $fav['bp_id'], "columns" => ['bp_id as id', 'bp_name as name', 'bp_cover as cover', 'bp_address as address']])->toArray();
     }
     foreach ($bp_list as $k => $v) {
         $bp_list[$k]['cover'] = "http://img.meelier.com/" . $bp_list[$k]['cover'];
         $tagarr = BeautyParlorTag::query()->columns('i.tag_title')->leftJoin('Apps\\Common\\Models\\BeautyParlorTagInfo', 'Apps\\Common\\Models\\BeautyParlorTag.tag_id = i.tag_id', 'i')->where("Apps\\Common\\Models\\BeautyParlorTag.bp_id = " . $bp_list[$k]['id'])->orderby("Apps\\Common\\Models\\BeautyParlorTag.sort asc")->limit(3, 0)->execute()->toArray();
         $newarr = [];
         foreach ($tagarr as $key => $val) {
             $newarr[] = $tagarr[$key]['tag_title'];
         }
         $bp_list[$k]['tags'] = $newarr;
     }
     $this->setResult($bp_list);
 }
コード例 #2
0
ファイル: MyOrder.php プロジェクト: fu-tao/meelier_c2.0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $user_id = $this->getUserAuth()->userId;
     $list = CosOnlineAppointment::query()->columns(['id', 'set_man_id', 'shop_id', 'shop_name', 'online_product_id', 'product_name', 'appointment_time', 'appointment_state', 'set_time', 'type'])->where('appointment_state in(0, 1) and set_man_id = ' . $user_id)->orderBy('appointment_time DESC')->limit($limit, $offset)->execute()->toArray();
     $result = [];
     foreach ($list as $val) {
         $cover = '';
         $price = '';
         // 初始单价
         if ($val['type'] == 1) {
             // 美容院
             if ($BeautyParlorAttr = BeautyParlorAttr::findFirst('beauty_parlor_id = ' . $val['shop_id'])) {
                 $price = $BeautyParlorAttr->low_price . '元';
             }
             if ($BeautyParlor = BeautyParlor::findFirst('bp_id = ' . $val['shop_id'])) {
                 $cover = $BeautyParlor->bp_cover;
             }
             $result[] = ['id' => $val['id'], 'order_id' => $val['shop_id'], 'title' => $val['shop_name'], 'cover' => $cover ? PicUrl::BeautyParlorCover($cover, $this->getDi()) : '', 'price' => $price, 'time' => $val['appointment_time'], 'add_time' => $val['set_time'], 'status' => $val['appointment_state'], 'type' => '1'];
         } elseif ($val['type'] == '2') {
             if ($BeautyParlorService = BeautyParlorService::findFirst('service_id = ' . $val['online_product_id'])) {
                 $price = $BeautyParlorService->service_price . '元' . ($BeautyParlorService->service_unit ? '/' . $BeautyParlorService->service_unit : '');
                 $cover = $BeautyParlorService->service_cover;
             }
             $result[] = ['id' => $val['id'], 'order_id' => $val['online_product_id'], 'title' => $val['product_name'] ?: '', 'cover' => $cover ? PicUrl::BeautyParlorCover($cover, $this->getDi()) : '', 'price' => $price, 'time' => $val['appointment_time'], 'add_time' => $val['set_time'], 'status' => $val['appointment_state'], 'type' => '2'];
         } else {
             continue;
         }
     }
     $this->setResult($result);
 }
コード例 #3
0
ファイル: BpBaseController.php プロジェクト: fu-tao/meelier_c
 /**
  * 美容院信息
  * @param $id
  * @return BeautyParlor
  */
 protected function getBPInfo($id)
 {
     $bpInfo = BeautyParlor::findFirst('bp_id = ' . $id);
     $this->view->setVar('bpInfo', $bpInfo);
     return $bpInfo;
 }
コード例 #4
0
ファイル: SearchASync.php プロジェクト: fu-tao/meelier_c
 private function syncBPS($id)
 {
     $info = BeautyParlorService::findFirst('service_id = ' . $id);
     if (!$info) {
         return false;
     }
     // 删除数据
     if ($info->service_state <= 0) {
         $this->delete(SearchDataType::BeautyParlorService, $info->service_id);
         return true;
     }
     // 店铺数据
     $bpInfo = \Apps\Common\Models\BeautyParlor::findFirst('bp_id = ' . $info->beauty_parlor_id);
     // 同步数据
     // 标题中包含的内容
     $titleArr = [$info->service_name, $info->service_description];
     $title = implode(',', $titleArr);
     $searchContent = \Apps\Common\Libs\BeautyParlor::formatServiceIntro($info->service_intro, $this->getDI());
     $tagInt = $info->service_is_sell;
     $tagStr = '';
     $showData = json_encode(['id' => $info->service_id, 'name' => $info->service_name, 'cover' => $info->service_cover, 'price' => $info->service_price, 'unit' => $info->service_unit, 'description' => $info->service_description, 'bp_id' => $bpInfo->bp_id, 'bp_name' => $bpInfo->bp_name]);
     $this->save(SearchDataType::BeautyParlorService, $id, $showData, $title, $searchContent, $tagInt, $tagStr);
     return true;
 }
コード例 #5
0
ファイル: BpController.php プロジェクト: fu-tao/meelier_c
 /**
  * 更新数据
  * @return ResponseResult
  */
 private function updateSave()
 {
     $req = $this->request;
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     $id = intval($req->getPost('bp_id'));
     if ($id < 1) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     $name = $req->getPost('bp_name');
     $district = intval($req->getPost('bp_district', null, 0));
     $address = $req->getPost('bp_address');
     $coordinate = $req->getPost('bp_coordinate');
     $tel = $req->getPost('bp_tel');
     $isSell = intval($req->getPost('bp_is_sell', null, 0));
     $medalRefund = intval($req->getPost('bp_medal_refund', null, 0));
     $medalVerify = intval($req->getPost('bp_medal_verify', null, 0));
     $tags = $req->getPost('bp_tags');
     $ownerMobile = $req->getPost('bp_owner_mobile');
     $intro = $req->getPost('bp_intro');
     // 判断空数据
     if (empty($name) || $district <= 0 || empty($address) || empty($coordinate) || empty($tel) || empty($tags) || empty($intro) || empty($ownerMobile)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     // 保存封面
     $uploadFile = new UploadPic();
     $uploadFile->request = $req;
     $cover = $uploadFile->beautyParlorCover();
     if ($cover == false || !is_array($cover) || count($cover) == 0 || $cover[0] == false) {
         $bpCover = null;
     } else {
         $bpCover = $cover[0];
     }
     // 保存基础数据
     $coordinate = str_replace(',', ' ', $coordinate);
     $bp = BeautyParlor::findFirst('bp_id = ' . $id);
     $data = [];
     if ($bp->bp_name != $name) {
         $data['bp_name'] = $name;
     }
     if (!!$bpCover) {
         $data['bp_cover'] = $bpCover;
     }
     if ($bp->bp_address != $address) {
         $data['bp_address'] = $address;
     }
     if ($bp->bp_district != $district) {
         $data['bp_district'] = $district;
     }
     $data['bp_coordinate'] = new RawValue("GeomFromText('POINT({$coordinate})')");
     if ($bp->bp_tel != $tel) {
         $data['bp_tel'] = $tel;
     }
     if ($bp->bp_owner_mobile != $ownerMobile) {
         $data['bp_owner_mobile'] = $ownerMobile;
     }
     if ($bp->bp_intro != $intro) {
         $data['bp_intro'] = $intro;
     }
     if ($bp->bp_is_sell != $isSell) {
         $data['bp_is_sell'] = $isSell;
     }
     $data['bp_medal'] = strval($medalRefund) . strval($medalVerify);
     $bp->update($data);
     /*标签排序  */
     $tagsarr = explode(",", $tags);
     $status = BeautyParlorTag::find("bp_id = {$id}")->delete();
     if (!$status) {
         $response->sendError(ResponseResultStatus::PARAM_ERROR, '保存标签失败!');
     }
     foreach ($tagsarr as $k => $tag) {
         $taginfo = BeautyParlorTagInfo::find("tag_id = {$tag} and tag_state = 1")->toArray();
         $count = count($taginfo);
         if ($count < 1) {
             $response->sendError(ResponseResultStatus::PARAM_ERROR, '没有ID为' . $tag . '的标签!');
         }
         $tagDb = new BeautyParlorTag();
         $tagDb->bp_id = $id;
         $tagDb->tag_id = $tag;
         $tagDb->sort = $k + 1;
         if ($tagDb->save() == false) {
             $this->databaseErrorLog($tagDb);
         }
     }
     /* 
             $tagsArr = explode(',', $tags);
            	foreach($tagsArr as $tag) {
                 $tagDb = BeautyParlorTag::query()
                     ->columns('bp_tag_id, bp_id, tag_id')
                     ->where('bp_id = :bid: AND tag_id = :tid:')
                     ->bind(['bid'=>$id, 'tid'=>$tag])
                     ->execute()->getFirst();
                 if(!$tagDb) {
                     $tagDb = new BeautyParlorTag();
                     $tagDb->bp_id = $id;
                     $tagDb->tag_id = $tag;
                     if ($tagDb->save() == false) {
                         $this->databaseErrorLog($tagDb);
                     }
                 }
             } */
     // 获取所有的标签
     /* $tagList = BeautyParlorTag::query()
            ->where('bp_id = :bid:')
            ->bind(['bid'=>$id])
            ->execute();
        foreach($tagList as $t) {
            if(in_array(strval($t->tag_id), $tagsArr) == false) {
                $t->delete();
            }
        } */
     // 保存轮播图片
     // 轮播图片
     $pics = $uploadFile->beautyParlorPics();
     if ($pics) {
         foreach ($pics as $pic) {
             $picDb = new BeautyParlorPhotos();
             $picDb->beauty_parlor_id = $id;
             $picDb->photo_url = $pic;
             if ($picDb->save() == false) {
                 $this->databaseErrorLog($picDb);
             }
         }
     }
     SearchASync::Instance()->noticeSync($id, SearchDataType::BeautyParlors);
     $response->sendResult('ok');
     return $response;
 }
コード例 #6
0
ファイル: BpController.php プロジェクト: fu-tao/meelier_c2.0
 /**
  * 添加首页推荐美容院
  * @date: 2016-1-8 
  * @author: futao
  */
 public function bannerBpAddAction()
 {
     $this->setLeftNav('bannerbp');
     $req = $this->request;
     if (!$req->isPost()) {
         $this->view->setVar('bp_id', $req->getQuery('id', null, 0));
         $this->view->setVar('openCity', $this->openCityList());
         $this->view->pick("bp/bannerBpAdd");
         return;
     }
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     $bp_id = intval($req->getPost('bp_id'));
     $city = $req->getPost('city');
     $addr = $city;
     $sort = $req->getPost('sort');
     $time = $req->getPost('time');
     // 判断空数据
     if (empty($bp_id) || empty($addr) || empty($sort)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     //判断要推荐的美容是否存在
     $bp = BeautyParlor::findFirst(" bp_id = {$bp_id} and bp_state = 1");
     if (empty($bp)) {
         $response->sendError(ResponseResultStatus::BUSINESS, '当前推荐的美容院不存在或未发布或已删除!');
         return $response;
     }
     //保存推荐美容院图片
     $uploadFile = new UploadPic();
     $uploadFile->request = $req;
     $cover = $uploadFile->beautyParlorCover();
     if ($cover == false || !is_array($cover) || count($cover) == 0 || $cover[0] == false) {
         if ($_FILES['bp_cover']['error'] == 1) {
             $response->sendError(ResponseResultStatus::UPLOAD_FILE_ERROR, '文件大小超过了1M!');
         }
         return $response;
     }
     //判断美容院是否已经存在3个
     /* if(CosPointBp::count("addr = $addr") >= 3){
       		$response->sendError(ResponseResultStatus::BUSINESS, '首页推荐美容院只能添加3个!');
       		return $response;
       	} */
     //判断要添加的美容院是否已存在
     /* if(CosPointBp::count('bp_id = ' . $bp_id.' and addr = '.$addr)){
       		$response->sendError(ResponseResultStatus::BUSINESS, '该美容院已经加入首页推荐!');
       		return $response;
       	}elseif(CosPointBp::count('sort = ' . $sort . ' and addr = '.$addr)){
       		$response->sendError(ResponseResultStatus::BUSINESS, '排序已经存在!');
       		return $response;
       	} */
     //实例化Model,组装数据
     $cosPointBp = new CosPointBp();
     $cosPointBp->bp_id = $bp_id;
     $cosPointBp->addr = $addr;
     $cosPointBp->sort = $sort;
     $cosPointBp->img_url = $cover[0];
     if ($time != '') {
         $timeArr = explode("至", $time);
         $show_start_time = trim($timeArr[0]);
         $show_end_time = trim($timeArr[1]);
         $cosPointBp->show_start_time = $show_start_time;
         $cosPointBp->show_end_time = $show_end_time;
     }
     //保存数据
     if ($cosPointBp->save() == false) {
         $this->databaseErrorLog($cosPointBp);
         $response->sendError(ResponseResultStatus::DATABASE_ERROR, '保存数据异常!');
     } else {
         $response->sendResult($cosPointBp->id);
     }
     return $response;
 }
コード例 #7
0
ファイル: CommentAdd.php プロジェクト: fu-tao/meelier_c
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $bp_id = intval($this->getDataItem('beauty_parlor_id', 0));
     $appoint_id = intval($this->getDataItem('appoint_id', 0));
     $comment_info = Keyword::Filter($this->getDataItem('content', ''));
     //关键字替换
     $keyword = CosQKeyword::query()->execute()->toArray();
     foreach ($keyword as $k => $v) {
         $comment_info = str_replace($v['keyword'], '***', $comment_info);
     }
     $comment_info = base64_encode(serialize($comment_info));
     //$type = intval($this -> getDataItem('type'));
     $type = $this->getDataItem('type');
     //评论图片
     $up = new UploadPic();
     $comment_photos = json_encode($up->beautyParlorComment());
     if ($type !== null && $type >= 0 && in_array($type, array(0, 1))) {
         if ($type == 0) {
             //添加美容院评论
             if ($bp_id > 0 && !empty($comment_info)) {
                 // 查询最大楼层
                 $floor = BeautyParlorComment::maximum(["column" => "comment_floor", "conditions" => "beauty_parlor_id = :id: and type = 0", "bind" => ["id" => $bp_id]]);
                 $bpc = new BeautyParlorComment();
                 $bpc->user_id = $this->getUserAuth()->userId;
                 $bpc->comment_floor = ($floor ? $floor : 0) + 1;
                 $bpc->beauty_parlor_id = $bp_id;
                 $bpc->comment_info = $comment_info;
                 $bpc->comment_photos = $comment_photos;
                 $bpc->type = $type;
                 if ($bpc->save()) {
                     $this->id = $bpc->comment_id;
                     $this->success = 1;
                 } else {
                     return $this->databaseErrorLog($bpc);
                 }
             } else {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "");
             }
             //评论成功,推送消息
             $branch = BeautyParlor::findFirst("bp_id = {$bp_id}")->toArray();
             $branchId = $branch['branch_id'];
             if (empty($branchId)) {
                 //没有分店,不推送
                 return $this->setResult(['id' => $this->id, 'success' => $this->success]);
             } else {
                 $num = Branch::query()->columns('s.shop_uid')->leftJoin('Apps\\Common\\Models\\CosShop', 'Apps\\Common\\Models\\Branch.shop_id = s.shop_id', 's')->where('Apps\\Common\\Models\\Branch.branch_id = ' . $branchId)->execute()->toArray();
                 $phoneNum = $num[0]['shop_uid'];
                 $param = array('type' => 7, 'ispushservice' => 0, 'phone' => $phoneNum, 'content' => '有人对您的美容院进行了评论,快去看看吧!', 'shop_id' => 0);
                 $push = new Jpush();
                 $rs = $push->setval($param);
                 if (!empty($rs)) {
                     $data = json_decode($rs, true);
                     $status = $data['status'];
                     if ($status == 400) {
                         //数据错误
                         return $this->setResult(['id' => $this->id, 'success' => $this->success]);
                     }
                 } else {
                     $rs = $push->push();
                     return $this->setResult(['id' => $this->id, 'success' => $this->success]);
                 }
             }
         }
         if ($type == 1) {
             //添加预约评论
             if ($bp_id > 0 && $appoint_id > 0 && !empty($comment_info)) {
                 //判断预约是否已被当前用户评论
                 $is_comment = BeautyParlorComment::count(["conditions" => "appointment_id = :id: and beauty_parlor_id = :bp_id: and user_id = :user_id:", "bind" => ["id" => $appoint_id, "bp_id" => $bp_id, "user_id" => $this->getUserAuth()->userId]]);
                 if ($is_comment > 0) {
                     //已评论
                     return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "预约已评论");
                 } else {
                     //查询最大楼层
                     $floor = BeautyParlorComment::maximum(["column" => "comment_floor", "conditions" => "appointment_id = :id: and beauty_parlor_id = :bp_id:", "bind" => ["id" => $appoint_id, "bp_id" => $bp_id]]);
                     $bpc = new BeautyParlorComment();
                     $query = new CosOnlineAppointment();
                     $appoint = $query->findFirst("id = {$appoint_id}");
                     if ($appoint) {
                         $data['state'] = 1;
                         $rs = $appoint->update($data);
                     } else {
                         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "当前预约不存在");
                     }
                     $bpc->user_id = $this->getUserAuth()->userId;
                     $bpc->comment_floor = ($floor ? $floor : 0) + 1;
                     $bpc->beauty_parlor_id = $bp_id;
                     $bpc->comment_info = $comment_info;
                     $bpc->comment_photos = $comment_photos;
                     $bpc->type = $type;
                     $bpc->appointment_id = $appoint_id;
                     if ($bpc->save() && $rs) {
                         $this->id = $bpc->comment_id;
                         $this->success = 1;
                     } else {
                         return $this->databaseErrorLog($bpc);
                     }
                 }
             } else {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "");
             }
             return $this->setResult(['id' => $this->id, 'success' => $this->success]);
         }
     } else {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "评论类型错误");
     }
     /*  $bp_id = intval($this->getDataItem('beauty_parlor_id',0));
             $comment_info = Keyword::Filter($this->getDataItem('content',''));
             $up = new UploadPic();
             $comment_photos = json_encode($up->beautyParlorComment());
     
             if($bp_id > 0 && !empty($comment_info)) {
                 // 查询最大楼层
                 $floor = BeautyParlorComment::maximum([
                     "column" => "comment_floor",
                     "conditions" => "beauty_parlor_id = :id:",
                     "bind" => [
                         "id" => $bp_id
                     ]
                 ]);
                 //关键字替换
                 $keyword = CosQKeyword::query() -> execute() -> toArray();
                 foreach ($keyword as $k => $v){
                 	
                 	$comment_info = str_replace($v['keyword'], '***', $comment_info);
                 	//$comment_info = str_replace($v['keyword'], str_repeat('*', strlen($v['keyword'])/3), $comment_info);
                 	
                 }
     
                 $bpc = new BeautyParlorComment();
                 $bpc->user_id = $this->getUserAuth()->userId;
                 $bpc->comment_floor = ($floor ? $floor : 0) + 1;
                 $bpc->beauty_parlor_id=$bp_id;
                 $bpc->comment_info=$comment_info;
                 $bpc->comment_photos=$comment_photos;
                 if($bpc->save()){
                     $this->id = $bpc->comment_id;
                     $this->success = 1;
                 }else{
                     return $this->databaseErrorLog($bpc);
                 }
             } else {
                 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "");
             }
     
             $this->setResult([
                 'id'=>$this->id,
                 'success'=>$this->success
             ]);   */
 }