MShopProject.Class.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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\Cache\SystemCache;
  12. use JinDouYun\Controller\Common\Logger;
  13. use JinDouYun\Dao\Department\DStaff;
  14. use JinDouYun\Dao\GoodsManage\DGoodsBasic;
  15. use JinDouYun\Dao\Shop\DShopProject;
  16. use JinDouYun\Dao\UserCenter\DUserCenter;
  17. use JinDouYun\Model\Common\Location;
  18. use JinDouYun\Model\System\MPaymentSetting;
  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. use Util\WeiXin\Pay;
  38. class MShopProject extends MBaseModel
  39. {
  40. private $objDShopProject;
  41. private $cutTable = 250000;
  42. private $enterpriseId;
  43. private $userCenterId;
  44. private $objMShopPartner;
  45. private $objMStaff;
  46. public function __construct($enterpriseId = '', $userCenterId = '')
  47. {
  48. $this->enterpriseId = $enterpriseId;
  49. $this->userCenterId = $userCenterId;
  50. parent::__construct($this->enterpriseId, $this->userCenterId);
  51. $this->objDShopProject = new DShopProject('default');
  52. }
  53. /**
  54. * 列表
  55. * @param $where
  56. * @return mixed
  57. */
  58. public function list($where)
  59. {
  60. $limit = $where['limit'];
  61. unset($where['limit']);
  62. $offset = $where['offset'];
  63. unset($where['offset']);
  64. $file = ' a.* ';
  65. $sql = 'SELECT'.$file.'FROM qianniao_shop_project AS a
  66. WHERE enterprise_id = '. $this->enterpriseId;
  67. if(isset($where['name'])) {
  68. $sql .= ' AND a.name LIKE "%' . $where['name'] . '%"';
  69. }
  70. if(isset($where['is_show'])) {
  71. $sql .= ' AND a.is_show = '.$where['is_show'];
  72. }
  73. if(isset($where['shop_id'])) {
  74. $sql .= ' AND a.shop_id = '.$where['shop_id'];
  75. }
  76. $total = count((array) $this->objDShopProject->query($sql));
  77. $sql .= ' ORDER BY createTime DESC LIMiT '.$offset.','.$limit;
  78. $dbResult = $this->objDShopProject->query($sql);
  79. if ($dbResult === false) {
  80. return ResultWrapper::fail($this->objDShopProject->error(), ErrorCode::$dberror);
  81. }
  82. $return = [
  83. 'data' => $dbResult,
  84. 'total' => ($total) ? intval($total) : 0,
  85. ];
  86. if($return === false){
  87. return ResultWrapper::fail($this->objDShopProject->error(), ErrorCode::$dberror);
  88. }else{
  89. return ResultWrapper::success($return);
  90. }
  91. }
  92. /**
  93. * 详情
  94. * @param $where
  95. * @return mixed
  96. */
  97. public function details($where)
  98. {
  99. if(empty($where)){
  100. return ResultWrapper::success($where);
  101. }
  102. $dbResult = $this->objDShopProject->get($where);
  103. if($dbResult === false){
  104. return ResultWrapper::fail($this->objDShopProject->error(), ErrorCode::$dberror);
  105. }
  106. return ResultWrapper::success(self::formatInfo($dbResult));
  107. }
  108. /**
  109. * Doc: (des="添加")
  110. * User: XMing
  111. * Date: 2020/7/15
  112. * Time: 10:42 上午
  113. * @throws Exception
  114. * @param array $params
  115. * @return ResultWrapper
  116. */
  117. public function insert(array $params)
  118. {
  119. $params['slider_image'] = json_encode($params['slider_image']);
  120. $res = $this->objDShopProject->insert($params);
  121. if ($res){
  122. return ResultWrapper::success('添加成功');
  123. }else{
  124. return ResultWrapper::fail($this->objDShopProject->error(), ErrorCode::$dberror);
  125. }
  126. }
  127. public function update($params, $id)
  128. {
  129. $data = $this->objDShopProject->get($id);
  130. if (!$data){
  131. return ResultWrapper::fail('数据不存在', ErrorCode::$dberror);
  132. }
  133. if ($params['slider_image']){
  134. $params['slider_image'] = json_encode($params['slider_image']);
  135. }
  136. $dbResult = $this->objDShopProject->update($params,$id);
  137. if($dbResult === false){
  138. return ResultWrapper::fail($this->objDShopProject->error(), ErrorCode::$dberror);
  139. }
  140. return ResultWrapper::success('修改成功');
  141. }
  142. function select($where = null, $fields = '*', $order = null, $limit = null, $offset = null, $data = array(), $multiple = true, $isExport = false)
  143. {
  144. $data = $this->objDShopProject->select($where, $fields, $order, $limit, $offset, $data, $multiple, $isExport);
  145. if ($data){
  146. return $data;
  147. }
  148. return ResultWrapper::fail($this->obj->error(), ErrorCode::$dberror);
  149. }
  150. /**
  151. * 格式数据详情
  152. * @param $data
  153. * @return mixed
  154. */
  155. public function formatInfo($data)
  156. {
  157. $data['slider_image'] = json_decode($data['slider_image']);
  158. $data['result'] = html_entity_decode($data['result']);
  159. return $data;
  160. }
  161. public function delete($id)
  162. {
  163. $res = $this->objDShopProject->delete(['id' => $id]);
  164. if ($res){
  165. return ResultWrapper::success('删除成功');
  166. }
  167. return ResultWrapper::fail($this->objDShopProject->error(), ErrorCode::$dberror);
  168. }
  169. public function get($where)
  170. {
  171. $data = $this->objDShopProject->get($where);
  172. return $data;
  173. }
  174. }