micro_store.model.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /**
  3. * 微商城店铺街模型
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class micro_storeModel extends Model{
  11. const TABLE_NAME = 'micro_store';
  12. const PK = 'store_id';
  13. public function __construct(){
  14. parent::__construct('micro_store');
  15. }
  16. /**
  17. * 读取列表
  18. *
  19. */
  20. public function getList($condition,$page=null,$order='',$field='*',$limit=''){
  21. $result = $this->table(self::TABLE_NAME)->field($field)->where($condition)->page($page)->order($order)->limit($limit)->select();
  22. return $result;
  23. }
  24. /**
  25. * 读取列表包含店铺详细信息
  26. *
  27. */
  28. public function getListWithStoreInfo($condition,$page=null,$order='',$field='*',$limit=''){
  29. $store_list = $this->field($field)->where($condition)->page($page)->order($order)->limit($limit)->select();
  30. if(!empty($store_list)) {
  31. $model_store = Model('store');
  32. for ($i = 0, $j = count($store_list); $i < $j ; $i++) {
  33. $store_list[$i]['hot_sales_list'] = $model_store->getHotSalesList($store_list[$i]['shop_store_id'], 5);
  34. $store_info = $model_store->getStoreInfoByID($store_list[$i]['shop_store_id']);
  35. $store_list[$i] = array_merge($store_list[$i], $store_info);
  36. }
  37. }
  38. return $store_list;
  39. }
  40. /**
  41. * 根据编号获取单个内容
  42. *
  43. */
  44. public function getOne($param){
  45. $result = $this->table(self::TABLE_NAME)->where($param)->find();
  46. return $result;
  47. }
  48. /**
  49. * 根据编号获取单个内容
  50. *
  51. */
  52. public function getOneWithStoreInfo($param){
  53. $result = $this->where($param)->find();
  54. if(!empty($result)) {
  55. $model_store = Model('store');
  56. $store_info = $model_store->getStoreInfoByID($result['shop_store_id']);
  57. $result = array_merge($result, $store_info);
  58. }
  59. return $result;
  60. }
  61. /*
  62. * 判断是否存在
  63. * @param array $condition
  64. *
  65. */
  66. public function isExist($param) {
  67. $result = $this->getOne($param);
  68. if(empty($result)) {
  69. return FALSE;
  70. }
  71. else {
  72. return TRUE;
  73. }
  74. }
  75. /*
  76. * 增加
  77. * @param array $param
  78. * @return bool
  79. */
  80. public function save($param){
  81. return $this->table(self::TABLE_NAME)->insert($param);
  82. }
  83. /*
  84. * 批量增加
  85. * @param array $param
  86. * @return bool
  87. */
  88. public function saveAll($param){
  89. return $this->table(self::TABLE_NAME)->insertAll($param);
  90. }
  91. /*
  92. * 更新
  93. * @param array $update_array
  94. * @param array $where_array
  95. * @return bool
  96. */
  97. public function modify($update_array, $where_array){
  98. return $this->table(self::TABLE_NAME)->where($where_array)->update($update_array);
  99. }
  100. /*
  101. * 删除
  102. * @param array $param
  103. * @return bool
  104. */
  105. public function drop($param){
  106. return $this->table(self::TABLE_NAME)->where($param)->delete();
  107. }
  108. }