Chain.php 5.2 KB

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