123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- namespace JInDouYun\Controller\Cashier;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Cashier\MCashierGuide;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- /**
- * Description: 导购员 废弃
- * Class Guide
- * @package JInDouYun\Controller\Cashier
- */
- class Guide extends BaseController
- {
- /**
- * @var MCashierGuide
- */
- private $objMCashierGuide;
- /**
- * Guide constructor.
- * @param bool $isCheckAcl
- * @param bool $isMustLogin
- * @param bool $checkToken
- * @param bool $getAreaCode
- * @throws \Exception
- */
- public function __construct($isCheckAcl = true, $isMustLogin = true, $checkToken = true, $getAreaCode = false)
- {
- parent::__construct($isCheckAcl, $isMustLogin, $checkToken, $getAreaCode);
- $this->objMCashierGuide = new MCashierGuide($this->onlineUserId, $this->onlineEnterpriseId);
- }
- /**
- * Doc: (des="导购员列表")
- * User: XMing
- * Date: 2020/8/31
- * Time: 3:46 下午
- */
- public function getAll()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $params['limit'] = $pageParams['limit'];
- $params['offset'] = $pageParams['offset'];
- $result = $this->objMCashierGuide->getAll($params);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }
- /**
- * Doc: (des="导购员添加")
- * User: XMing
- * Date: 2020/8/31
- * Time: 4:23 下午
- */
- public function add()
- {
- $params = $this->request->getRawJson();
- if (empty($params)){
- parent::sendOutput('参数为空',ErrorCode::$paramError);
- }
- $data = [
- 'name' => isset($params['name']) ? $params['name'] : null,
- 'mobile' => isset($params['mobile']) ? $params['mobile'] : null,
- 'isSetRule' => isset($params['isSetRule']) ? $params['isSetRule'] : null,
- 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : null,
- ];
- foreach ($data as $key => $value){
- if(empty($value)){
- parent::sendOutput($key.'参数错误', ErrorCode::$paramError);
- }
- }
- if($data['isSetRule'] == StatusCode::$standard){
- if (!isset($params['rule']) || empty($params['rule'])){
- parent::sendOutput('rule参数错误',ErrorCode::$paramError);
- }
- $data['rule'] = json_encode($params['rule']);
- }
- $result = $this->objMCashierGuide->add($data);
- if (!$result->isSuccess()){
- parent::sendOutput($result->getData(),$result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- /**
- * Doc: (des="")
- * User: XMing
- * Date: 2020/9/1
- * Time: 9:30 上午
- */
- public function getInfo()
- {
- $id = $this->request->param('request_id');
- if (empty($id)){
- parent::sendOutput('id参数错误',ErrorCode::$paramError);
- }
- $result = $this->objMCashierGuide->getInfo($id);
- if (!$result->isSuccess()){
- parent::sendOutput($result->getData(),$result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- }
|