MCashierGuide.Class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace JinDouYun\Model\Cashier;
  3. use JinDouYun\Dao\Cashier\DCashierGuide;
  4. use Mall\Framework\Core\ErrorCode;
  5. use Mall\Framework\Core\ResultWrapper;
  6. use Mall\Framework\Core\StatusCode;
  7. /**
  8. * Description:
  9. * Class MCashierGuide
  10. * @package JinDouYun\Model\Cashier
  11. */
  12. class MCashierGuide
  13. {
  14. /**
  15. * @var DCashierGuide
  16. */
  17. private $objDCashierGuide;
  18. /**
  19. * @var integer
  20. */
  21. private $onlineUserId;
  22. /**
  23. * @var integer
  24. */
  25. private $onlineEnterpriseId;
  26. /**
  27. * MCashierGuide constructor.
  28. * @param $onlineUserId
  29. * @param $onlineEnterpriseId
  30. * @throws \Exception
  31. */
  32. public function __construct($onlineUserId, $onlineEnterpriseId)
  33. {
  34. $this->onlineUserId = $onlineUserId;
  35. $this->onlineEnterpriseId = $onlineEnterpriseId;
  36. $this->objDCashierGuide = new DCashierGuide();
  37. $this->objDCashierGuide->setTable('qianniao_cashier_guide_'.$this->onlineEnterpriseId);
  38. }
  39. /**
  40. * Doc: (des="导购员列表")
  41. * User: XMing
  42. * Date: 2020/8/31
  43. * Time: 3:44 下午
  44. * @param array $selectParams
  45. * @return ResultWrapper
  46. *
  47. */
  48. public function getAll(array $selectParams)
  49. {
  50. $fields = 'id,name,mobile,enableStatus,createTime';
  51. $sql = 'SELECT '.$fields.' FROM qianniao_cashier_guide_'.$this->onlineEnterpriseId.'
  52. WHERE deleteStatus = '.StatusCode::$standard.'
  53. ORDER BY createTime DESC';
  54. $count = count((array)$this->objDCashierGuide->query($sql));
  55. $sql .= ' LIMIT '.$selectParams['offset'].','.$selectParams['limit'];
  56. $list = $this->objDCashierGuide->query($sql);
  57. if ($list === false){
  58. return ResultWrapper::fail($this->objDCashierGuide->error(),ErrorCode::$dberror);
  59. }
  60. $ret = [
  61. 'total' => $count,
  62. 'data' => $list
  63. ];
  64. return ResultWrapper::success($ret);
  65. }
  66. /**
  67. * Doc: (des="添加导购")
  68. * User: XMing
  69. * Date: 2020/8/31
  70. * Time: 4:41 下午
  71. * @param array $params
  72. * @return ResultWrapper
  73. */
  74. public function add(array $params)
  75. {
  76. $guideInfo = $this->objDCashierGuide->get(['mobile' => $params['mobile'],'deleteStatus' => StatusCode::$standard]);
  77. if (!empty($guideInfo)){
  78. return ResultWrapper::fail('手机号码已存在',ErrorCode::$paramError);
  79. }
  80. $insert = [
  81. 'name' => $params['name'],
  82. 'mobile' => $params['mobile'],
  83. 'enableStatus' => $params['enableStatus'],
  84. 'isSetRule' => $params['isSetRule']
  85. ];
  86. $params['isSetRule'] == StatusCode::$standard && $insert['rule'] = $params['rule'];
  87. $result = $this->objDCashierGuide->insert($insert);
  88. if ($result === false){
  89. return ResultWrapper::fail($this->objDCashierGuide->error(),ErrorCode::$paramError);
  90. }
  91. return ResultWrapper::success(true);
  92. }
  93. /**
  94. * Doc: (des="")
  95. * User: XMing
  96. * Date: 2020/9/1
  97. * Time: 9:35 上午
  98. * @param int $id
  99. * @return ResultWrapper
  100. */
  101. public function getInfo(int $id)
  102. {
  103. $this->objDCashierGuide->get(['id'=>$id]);
  104. return ResultWrapper::success([]);
  105. }
  106. }