示例#1
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);
 }
示例#2
0
 /**
  * 获取商品信息
  * @param $goods
  * @return array
  */
 private function getGoodsInfo($goods)
 {
     $goodsList = [];
     foreach ($goods as $g) {
         $id = isset($g['id']) ? intval($g['id']) : 0;
         $num = isset($g['number']) ? intval($g['number']) : 0;
         if ($id <= 0 || $num <= 0) {
             continue;
         }
         $info = BeautyParlorService::findFirst("service_id = {$id} AND service_state > 0 AND service_is_sell = 1");
         if ($info) {
             $gi = ['service_id' => $info->service_id, 'beauty_parlor_id' => $info->beauty_parlor_id, 'service_price' => $info->service_price, 'order_number' => $num];
             $goodsList[] = $gi;
         }
     }
     return $goodsList;
 }
示例#3
0
 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;
 }
示例#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, '请求异常');
     }
 }