MShopClock.Class.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. /**
  3. * 商铺管理模块
  4. * Created by PhpStorm.
  5. * User: wxj
  6. * Date: 2019/10/31
  7. * Time: 15:02
  8. */
  9. namespace JinDouYun\Model\Shop;
  10. use Exception;
  11. use JinDouYun\Controller\Common\Logger;
  12. use JinDouYun\Dao\Department\DStaff;
  13. use JinDouYun\Dao\GoodsManage\DGoodsBasic;
  14. use JinDouYun\Dao\Shop\DShopClock;
  15. use JinDouYun\Dao\Shop\DShopProject;
  16. use JinDouYun\Dao\Shop\DShopTemplate;
  17. use JinDouYun\Dao\UserCenter\DUserCenter;
  18. use JinDouYun\Model\Common\Location;
  19. use Mall\Framework\Core\ErrorCode;
  20. use Mall\Framework\Core\StatusCode;
  21. use Mall\Framework\Core\ResultWrapper;
  22. use JinDouYun\Dao\Shop\DShop;
  23. use JinDouYun\Dao\Shop\DEnterpriseBindShop;
  24. use Jindouyun\Cache\EnterpriseCache;
  25. use JinDouYun\Cache\RoleAclCache;
  26. use JinDouYun\Cache\ShopCache;
  27. use JinDouYun\Cache\SysAreaChinaCache;
  28. use JinDouYun\Cache\GoodsBasicRelevant;
  29. use JinDouYun\Model\ShopPartner\MShopPartner;
  30. use JinDouYun\Model\Stock\MWarehouse;
  31. use JinDouYun\Model\SysAreaChina\MSysAreaChina;
  32. use JinDouYun\Model\Customer\MCustomer;
  33. use JinDouYun\Model\Enterprise\MEnterprise;
  34. use JinDouYun\Model\Department\MStaff;
  35. use JinDouYun\Model\MBaseModel;
  36. use Monolog\Handler\IFTTTHandler;
  37. class MShopClock extends MBaseModel
  38. {
  39. private $obj;
  40. private $cutTable = 250000;
  41. private $enterpriseId;
  42. private $userCenterId;
  43. private $objMShopPartner;
  44. private $objMStaff;
  45. public function __construct($enterpriseId, $userCenterId = '')
  46. {
  47. $this->enterpriseId = $enterpriseId;
  48. $this->userCenterId = $userCenterId;
  49. parent::__construct($this->enterpriseId, $this->userCenterId);
  50. $this->obj = new DShopClock('default');
  51. }
  52. /**
  53. * 列表
  54. * @param $where
  55. * @return mixed
  56. */
  57. public function list($where)
  58. {
  59. $limit = $where['limit'];
  60. unset($where['limit']);
  61. $offset = $where['offset'];
  62. unset($where['offset']);
  63. $file = ' a.* ';
  64. $sql = 'SELECT'.$file.'FROM qianniao_shop_clock'.$this->enterpriseId.' AS a WHERE shop_id = '. $where['shop_id'];
  65. if(isset($where['uid'])) {
  66. $sql .= ' AND a.uid = '.$where['uid'];
  67. }
  68. if(isset($where['start_time']) and isset($where['end_time'])) {
  69. $time_field = '';
  70. $time_field .= '"'.$where['start_time'].'",'.'"'.$where['end_time'].'"';
  71. $sql .= ' AND a.time in ('.$time_field.')';
  72. }
  73. $total = count((array) $this->obj->query($sql));
  74. $sql .= ' ORDER BY createTime DESC LIMiT '.$offset.','.$limit;
  75. $dbResult = $this->obj->query($sql);
  76. if ($dbResult === false) {
  77. return ResultWrapper::fail($this->obj->error(), ErrorCode::$dberror);
  78. }
  79. $return = [
  80. 'data' => $dbResult,
  81. 'total' => ($total) ? intval($total) : 0,
  82. ];
  83. if($return === false){
  84. return ResultWrapper::fail($this->obj->error(), ErrorCode::$dberror);
  85. }else{
  86. return ResultWrapper::success($return);
  87. }
  88. }
  89. /**
  90. * 详情
  91. * @param $where
  92. * @return mixed
  93. */
  94. public function details($where)
  95. {
  96. if(empty($where)){
  97. return ResultWrapper::success($where);
  98. }
  99. $dbResult = $this->obj->get($where);
  100. if($dbResult === false){
  101. return ResultWrapper::fail($this->obj->error(), ErrorCode::$dberror);
  102. }
  103. return ResultWrapper::success(self::formatInfo($dbResult));
  104. }
  105. /**
  106. * Doc: (des="添加")
  107. * User: XMing
  108. * Date: 2020/7/15
  109. * Time: 10:42 上午
  110. * @throws Exception
  111. * @param array $params
  112. * @return ResultWrapper
  113. */
  114. public function insert(array $params)
  115. {
  116. $res = $this->obj->insert($params);
  117. if ($res){
  118. return ResultWrapper::success('添加成功');
  119. }else{
  120. return ResultWrapper::fail($this->obj->error(), ErrorCode::$dberror);
  121. }
  122. }
  123. public function update($params, $id)
  124. {
  125. $data = $this->obj->get($id);
  126. if (!$data){
  127. return ResultWrapper::fail('数据不存在', ErrorCode::$dberror);
  128. }
  129. $dbResult = $this->obj->update($params,$id);
  130. if($dbResult === false){
  131. return ResultWrapper::fail($this->obj->error(), ErrorCode::$dberror);
  132. }
  133. return ResultWrapper::success('修改成功');
  134. }
  135. /**
  136. * 格式数据详情
  137. * @param $data
  138. * @return mixed
  139. */
  140. public function formatInfo($data)
  141. {
  142. return $data;
  143. }
  144. public function delete($id)
  145. {
  146. $res = $this->obj->delete(['id' => $id]);
  147. if ($res){
  148. return ResultWrapper::success('删除成功');
  149. }
  150. return ResultWrapper::fail($this->obj->error(), ErrorCode::$dberror);
  151. }
  152. }