Ejemplo n.º 1
0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $question_tag = intval($this->getDataItem('tag_id', 0));
     $question_content = Keyword::Filter($this->getDataItem('content', ''));
     $up = new UploadPic();
     $question_pics = json_encode($up->questionPic());
     if (!empty($question_content)) {
         $q = new Question();
         $q->user_id = $this->getUserAuth()->userId;
         // $q->user_id = 1;
         $q->question_tag = $question_tag;
         //关键字替换
         $keyword = CosQKeyword::query()->execute()->toArray();
         foreach ($keyword as $k => $v) {
             $question_content = str_replace($v['keyword'], '***', $question_content);
         }
         //$question_content = base64_encode(serialize($question_content));
         $q->question_content = $question_content;
         $q->question_pics = $question_pics;
         if ($q->save()) {
             $this->id = $q->question_id;
             $this->success = 1;
             SearchASync::Instance()->noticeSync($q->question_id, SearchDataType::Question);
             //推送消息
             $phoneNum = ['15823522906', '13883156314', '18725873971', '15086691064', '18996156384', '13752904126', '18523066564', '15723278358', '18523989994', '15111992368', '18123640250', '18323868684'];
             foreach ($phoneNum as $k => $v) {
                 $param = array('type' => 8, 'ispushservice' => 0, 'phone' => $v, 'content' => '有新的问题啦:' . mb_substr($question_content, 0, 10, 'utf-8') . ',快去回答吧!', 'shop_id' => 0);
                 $push = new Jpush();
                 $rs = $push->setval($param);
                 if (empty($rs)) {
                     $push->push();
                 }
                 continue;
             }
         } else {
             return $this->databaseErrorLog($q);
         }
     } else {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "");
     }
     $this->setResult(['id' => $this->id, 'success' => $this->success]);
 }
Ejemplo n.º 2
0
 public function tgmAction()
 {
     $this->view->disable();
     SearchASync::Instance()->noticeSync(1, SearchDataType::BeautyParlors);
     echo 'ok';
 }
Ejemplo n.º 3
0
 /**
  * 更新数据
  * @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;
 }
Ejemplo n.º 4
0
 /**
  * 设置美容院状态
  * @return $this|ResponseResult
  */
 public function setStateAction()
 {
     $req = $this->request;
     if ($req->isPost()) {
         $id = intval($req->getPost('id', null, 0));
         $state = intval($req->getPost('state', null, -10000));
         if (!in_array($state, [-1, 0, 1])) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         $info = BeautyParlorService::findFirst('service_id=' . $id);
         if ($info) {
             $info->update(['service_state' => $state]);
         }
         SearchASync::Instance()->noticeSync($id, SearchDataType::BeautyParlorService);
         return (new ResponseResult())->sendResult('ok');
     } else {
         return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }
Ejemplo n.º 5
0
 /**
  * 发布/结束活动
  * @date: 2016年1月5日 
  * @author: chenxiaolin
  */
 public function setStateAction()
 {
     $req = $this->request;
     if (!$req->isPost()) {
         $id = intval($req->getQuery('id', null, 0));
         $state = intval($req->getQuery('state'));
         $this->view->setVar('id', $id);
         $this->view->setVar('state', $state);
         $this->view->setVar("action", '/activity/setState');
         return;
     }
     if ($req->isPost()) {
         $response = new ResponseResult();
         $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
         $response->callbackJavascriptTag = true;
         $id = intval($req->getPost('id', null, 0));
         $state = intval($req->getPost('state', null, -10000));
         $activity_start_time = $req->getPost('activity_start_time');
         $activity_end_time = $req->getPost('activity_end_time');
         //发布时:开始时间不能>=结束时间
         if ($state == 1 && $activity_start_time >= $activity_end_time) {
             $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '开始时间不能大于等于结束时间!');
             return $response;
         }
         if (!in_array($state, [0, 1, 2])) {
             return $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         $info = Activity::findFirst('activity_id = ' . $id);
         //活动存在
         if ($info) {
             if ($state == 1) {
                 //发布活动:修改活动的开始时间,结束时间,状态等信息
                 $info->update(['activity_state' => $state, 'activity_update_time' => date('Y-m-d H:i:s'), 'activity_start_time' => $activity_start_time, 'activity_end_time' => $activity_end_time]);
                 SearchASync::Instance()->noticeSync($id, SearchDataType::Activity);
                 return $response->sendResult('ok');
             } else {
                 //结束活动
                 $info->update(['activity_state' => $state, 'activity_update_time' => date('Y-m-d H:i:s')]);
                 SearchASync::Instance()->noticeSync($id, SearchDataType::Activity);
                 return (new ResponseResult())->sendResult('ok');
                 /* $arr=[
                        'status'=>10000
                    ];
                    echo json_encode($arr);
                    exit; */
             }
         }
     } else {
         return $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }
Ejemplo n.º 6
0
 /**
  * 设置状态
  * 
  * @return $this|ResponseResult
  */
 public function setStateAction()
 {
     $req = $this->request;
     if ($req->isPost()) {
         $id = intval($req->getPost('id', null, 0));
         $state = intval($req->getPost('state', null, -10000));
         if (!in_array($state, [-1, 0, 1, 2])) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         $info = Activity::findFirst('activity_id = ' . $id);
         /* if ($info) {
         				$info->update ( [ 
         						'activity_state' => $state 
         				] );
         			} */
         $end_time = strtotime($info->activity_end_time);
         //活动结束时间
         $current_time = time();
         //当前时间
         $numTime = $end_time - $current_time;
         //活动结束的时候,将活动结束时间设置为当前时间
         if ($info) {
             //判断活动结束时间是否大于当前时间:大于-->活动结束时间设置为当前时间;小于:--> 活动已结束
             if ($state == 2 && $numTime > 0) {
                 $info->update(['activity_state' => $state, 'activity_end_time' => date('Y-m-d H:i:s')]);
             } else {
                 $info->update(['activity_state' => $state]);
             }
         }
         SearchASync::Instance()->noticeSync($id, SearchDataType::Activity);
         return (new ResponseResult())->sendResult('ok');
     } else {
         return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }
Ejemplo n.º 7
0
 /**
  * 更新数据
  * @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');
     ////////////////////////////////////2.0新加参数////2.0新加参数///////2.0新加参数///////2.0新加参数///////////////////////////////
     $low_price = $req->getPost("low_price", null, 0);
     //起步价
     $open_year = $req->getPost("open_year", null, 0);
     //开业年限
     $shop_area = $req->getPost("shop_area", null, 0);
     //店铺面积
     $service_num = $req->getPost("service_num", null, 0);
     //服务项目数量
     $op_cl_time = $req->getPost("time", null, '');
     //营业时间
     $facilities = $req->getPost("facilities", null, '');
     //设备设施
     if ($op_cl_time != '') {
         $op_cl_time_arr = explode("至", $op_cl_time);
         $open_time = trim($op_cl_time_arr[0]);
         $close_time = trim($op_cl_time_arr[1]);
     } else {
         $open_time = '';
         $close_time = '';
     }
     if ($low_price < 0 || $open_year < 0 || $shop_area < 0 || $service_num < 0) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '数据不能为空!');
         return;
     }
     if ($facilities != '') {
         try {
             $facilities_json = json_encode($facilities);
         } catch (\Exception $e) {
             $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '数据错误!');
             return;
         }
     } else {
         $facilities_json = null;
     }
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // 判断空数据
     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);
     /*保存美容院相关数据  */
     $bp_attr = BeautyParlorAttr::findFirst("beauty_parlor_id = {$id}");
     if (!$bp_attr) {
         /* $response->sendError(ResponseResultStatus::ERROR, '修改失败!');
           	return $response; */
         $bp_attr = new BeautyParlorAttr();
     }
     $bp_attr->beauty_parlor_id = $id;
     $bp_attr->close_time = $close_time;
     $bp_attr->open_time = $open_time;
     $bp_attr->low_price = $low_price;
     $bp_attr->open_year = $open_year;
     $bp_attr->facilities = $facilities_json;
     $bp_attr->service_num = $service_num;
     $bp_attr->shop_area = $shop_area;
     if (!$bp_attr->save()) {
         $response->sendError(ResponseResultStatus::ERROR, '添加失败!');
     }
     //处理标签
     $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;
 }