Chain.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 数据层模型
  15. */
  16. class Chain extends BaseModel
  17. {
  18. const STATE1 = 1; // 开启
  19. const STATE0 = 0; // 关闭
  20. const STATE10 = 10; // 等待审核
  21. const STATE20 = 20; // 等待失败
  22. private $state = array(
  23. self::STATE0 => '关闭', self::STATE1 => '开启', self::STATE10 => '等待审核', self::STATE20 => '审核失败'
  24. );
  25. public $page_info;
  26. /**
  27. * 插入数据
  28. * @access public
  29. * @author csdeshang
  30. * @param array $data 数据
  31. * @return boolean
  32. */
  33. public function addChain($data)
  34. {
  35. return Db::name('chain')->insertGetId($data);
  36. }
  37. /**
  38. * 查询门店列表
  39. * @access public
  40. * @author csdeshang
  41. * @param array $condition 检索条件
  42. * @param int $pagesize 分页信息
  43. * @param string $order 排序
  44. * @return array
  45. */
  46. public function getChainList($condition, $pagesize = 0, $order = 'chain_id desc')
  47. {
  48. if($pagesize){
  49. $res = Db::name('chain')->where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  50. $this->page_info=$res;
  51. return $res->items();
  52. }else{
  53. return Db::name('chain')->where($condition)->order($order)->select()->toArray();
  54. }
  55. }
  56. /**
  57. * 等待审核的门店列表
  58. * @access public
  59. * @author csdeshang
  60. * @param unknown $condition 条件
  61. * @param number $pagesize 分页信息
  62. * @param string $order 排序
  63. * @return array
  64. */
  65. public function getChainWaitVerifyList($condition, $pagesize = 0, $order = 'chain_id desc')
  66. {
  67. $condition[]=array('chain_state','=',self::STATE10);
  68. return $this->getChainList($condition, $pagesize, $order);
  69. }
  70. /**
  71. * 等待审核的门店数量
  72. * @access public
  73. * @author csdeshang
  74. * @param array $condition 条件
  75. * @param number $pagesize 分页信息
  76. * @param string $order 排序
  77. * @return int
  78. */
  79. public function getChainWaitVerifyCount($condition)
  80. {
  81. $condition[]=array('chain_state','=',self::STATE10);
  82. return Db::name('chain')->where($condition)->count();
  83. }
  84. /**
  85. * 开启中物流门店列表
  86. * @access public
  87. * @author csdeshang
  88. * @param array $condition 检索条件
  89. * @param number $pagesize 分页信息
  90. * @param string $order 排序
  91. * @return array
  92. */
  93. public function getChainOpenList($condition, $pagesize = 0, $order = 'chain_id desc')
  94. {
  95. $condition[]=array('chain_state','=',self::STATE1);
  96. return $this->getChainList($condition, $pagesize, $order);
  97. }
  98. /**
  99. * 取得门店详细信息
  100. * @access public
  101. * @author csdeshang
  102. * @param array $condition 检索条件
  103. * @param string $field 字段
  104. * @return array
  105. */
  106. public function getChainInfo($condition, $field = '*')
  107. {
  108. return Db::name('chain')->where($condition)->field($field)->find();
  109. }
  110. /**
  111. * 取得开启中物流门店信息
  112. * @access public
  113. * @author csdeshang
  114. * @param array $condition 条件
  115. * @param string $field 字段
  116. * @return array
  117. */
  118. public function getChainOpenInfo($condition, $field = '*')
  119. {
  120. $condition[]=array('chain_state','=',self::STATE1);
  121. return Db::name('chain')->where($condition)->field($field)->find();
  122. }
  123. /**
  124. * 取得开启中物流门店信息
  125. * @access public
  126. * @author csdeshang
  127. * @param array $condition 条件
  128. * @param string $field 字段
  129. * @return array
  130. */
  131. public function getChainFailInfo($condition, $field = '*')
  132. {
  133. $condition[]=array('chain_state','=',self::STATE20);
  134. return Db::name('chain')->where($condition)->field($field)->find();
  135. }
  136. /**
  137. * 门店信息
  138. * @access public
  139. * @author csdeshang
  140. * @param array $update 更新数据
  141. * @param array $condition 条件
  142. * @return bool
  143. */
  144. public function editChain($update, $condition)
  145. {
  146. return Db::name('chain')->where($condition)->update($update);
  147. }
  148. /**
  149. * 删除门店
  150. * @access public
  151. * @author csdeshang
  152. * @param int $condition 记录ID
  153. * @return bool
  154. */
  155. public function delChain($condition) {
  156. return Db::name('chain')->where($condition)->delete();
  157. }
  158. /**
  159. * @access public
  160. * @author csdeshang
  161. * 返回状态数组
  162. * @return array
  163. */
  164. public function getChainState()
  165. {
  166. return $this->state;
  167. }
  168. }