123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace JinDouYun\Model\Cashier;
- use JinDouYun\Dao\Cashier\DCashierGuide;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\ResultWrapper;
- use Mall\Framework\Core\StatusCode;
- /**
- * Description:
- * Class MCashierGuide
- * @package JinDouYun\Model\Cashier
- */
- class MCashierGuide
- {
- /**
- * @var DCashierGuide
- */
- private $objDCashierGuide;
- /**
- * @var integer
- */
- private $onlineUserId;
- /**
- * @var integer
- */
- private $onlineEnterpriseId;
- /**
- * MCashierGuide constructor.
- * @param $onlineUserId
- * @param $onlineEnterpriseId
- * @throws \Exception
- */
- public function __construct($onlineUserId, $onlineEnterpriseId)
- {
- $this->onlineUserId = $onlineUserId;
- $this->onlineEnterpriseId = $onlineEnterpriseId;
- $this->objDCashierGuide = new DCashierGuide();
- $this->objDCashierGuide->setTable('qianniao_cashier_guide_'.$this->onlineEnterpriseId);
- }
- /**
- * Doc: (des="导购员列表")
- * User: XMing
- * Date: 2020/8/31
- * Time: 3:44 下午
- * @param array $selectParams
- * @return ResultWrapper
- *
- */
- public function getAll(array $selectParams)
- {
- $fields = 'id,name,mobile,enableStatus,createTime';
- $sql = 'SELECT '.$fields.' FROM qianniao_cashier_guide_'.$this->onlineEnterpriseId.'
- WHERE deleteStatus = '.StatusCode::$standard.'
- ORDER BY createTime DESC';
- $count = count((array)$this->objDCashierGuide->query($sql));
- $sql .= ' LIMIT '.$selectParams['offset'].','.$selectParams['limit'];
- $list = $this->objDCashierGuide->query($sql);
- if ($list === false){
- return ResultWrapper::fail($this->objDCashierGuide->error(),ErrorCode::$dberror);
- }
- $ret = [
- 'total' => $count,
- 'data' => $list
- ];
- return ResultWrapper::success($ret);
- }
- /**
- * Doc: (des="添加导购")
- * User: XMing
- * Date: 2020/8/31
- * Time: 4:41 下午
- * @param array $params
- * @return ResultWrapper
- */
- public function add(array $params)
- {
- $guideInfo = $this->objDCashierGuide->get(['mobile' => $params['mobile'],'deleteStatus' => StatusCode::$standard]);
- if (!empty($guideInfo)){
- return ResultWrapper::fail('手机号码已存在',ErrorCode::$paramError);
- }
- $insert = [
- 'name' => $params['name'],
- 'mobile' => $params['mobile'],
- 'enableStatus' => $params['enableStatus'],
- 'isSetRule' => $params['isSetRule']
- ];
- $params['isSetRule'] == StatusCode::$standard && $insert['rule'] = $params['rule'];
- $result = $this->objDCashierGuide->insert($insert);
- if ($result === false){
- return ResultWrapper::fail($this->objDCashierGuide->error(),ErrorCode::$paramError);
- }
- return ResultWrapper::success(true);
- }
- /**
- * Doc: (des="")
- * User: XMing
- * Date: 2020/9/1
- * Time: 9:35 上午
- * @param int $id
- * @return ResultWrapper
- */
- public function getInfo(int $id)
- {
- $this->objDCashierGuide->get(['id'=>$id]);
- return ResultWrapper::success([]);
- }
- }
|