123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <?php
- /**
- * 商铺管理模块
- * Created by PhpStorm.
- * User: wxj
- * Date: 2019/10/31
- * Time: 15:02
- */
- namespace JinDouYun\Controller\Shop;
- use JinDouYun\Model\Enterprise\MEnterprise;
- use JinDouYun\Model\Shop\MShopClock;
- use JinDouYun\Model\Shop\MShopProject;
- use JinDouYun\Model\Shop\MShopRostering;
- use JinDouYun\Model\Shop\MShopSubscribe;
- use JinDouYun\Model\Shop\MShopTemplate;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\ResultWrapper;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Cache\ShopCache;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Shop\MShop;
- use JinDouYun\Cache\TempSaveCache;
- class ShopClock extends BaseController
- {
- private $obj;
- private $objShopCache;
- private $objTempSaveCache;
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->obj = new MShopClock($this->onlineEnterpriseId, $this->onlineUserId);
- $this->objShopCache = new ShopCache();
- $this->objTempSaveCache = new TempSaveCache();
- }
- /**
- * 添加和编辑商铺管理公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter(){
- $params = $this->request->getRawJson();
- if( empty($params) ){
- $this->sendOutput('参数为空', ErrorCode::$paramError );
- }
- $shopData = [
- 'uid' => isset($params['uid']) ? $params['uid'] : '',
- 'customer_id' => isset($params['customer_id']) ? $params['customer_id'] : '',
- 'project' => isset($params['project']) ? $params['project'] : '',
- 'to_price' => isset($params['to_price']) ? $params['to_price'] : '',
- 'discount_price' => isset($params['discount_price']) ? $params['discount_price'] : '',
- 'pay_price' => isset($params['pay_price']) ? $params['pay_price'] : '',
- 'duration' => isset($params['duration']) ? $params['duration'] : '',
- 'time' => isset($params['time']) ? $params['time'] : '',
- ];
- //非暂存则验空
- if (!isset($params['tempSave']) || $params['tempSave'] == false) {
- foreach($shopData as $key => $value){
- if(empty($value) && $value !== 0){
- $this->sendOutput($key.'参数错误', ErrorCode::$paramError );
- }
- }
- }
- $shopData['remarks']= isset($params['remarks']) ? $params['remarks'] : false;
- return $shopData;
- }
- /**
- * 列表
- */
- public function list()
- {
- $params = $this->request->getRawJson();
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- $selectParams['shop_id'] = $this->shopId;
- //uid
- if(isset($params['uid']) && !empty($params['uid'])){
- $selectParams['uid'] = $params['uid'];
- }
- // 时间
- if(isset($params['start_time']) && !empty($params['start_time']) and isset($params['end_time']) && !empty($params['end_time'])){
- $selectParams['start_time'] = strtotime($params['start_time']);
- $selectParams['end_time'] = strtotime($params['end_time']);
- }
- $result = $this->obj->list($selectParams);
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- } else {
- parent::sendOutput($result->getData(), ErrorCode::$dberror);
- }
- }
- /**
- * 添加
- * @throws \Exception
- */
- public function add()
- {
- $addStaffData = $this->commonFieldFilter();
- $addStaffData['shop_id'] = $this->shopId;
- $result = $this->obj->insert($addStaffData);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 详情
- * @return void
- */
- public function details()
- {
- $where = [];
- $id = $this->request->param('id');
- if(!empty($id)){
- $where['id'] = $id;
- }
- $result = $this->obj->details($where);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 修改
- * @return void
- */
- public function update()
- {
- $id['id'] = $this->request->param('id');
- if (empty($id['id'])) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $params = $this->commonFieldFilter();
- unset($params['start_time']);
- unset($params['end_time']);
- unset($params['uid']);
- $result = $this->obj->update($params, $id);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- public function delete()
- {
- $id['id'] = $this->request->param('id');
- if (empty($id['id'])) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $result = $this->obj->delete($id);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- }
|