ShopAddress.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\model\shop;
  11. use think\facade\Cache;
  12. use app\model\BaseModel;
  13. /**
  14. * 店铺地址库
  15. */
  16. class ShopAddress extends BaseModel
  17. {
  18. /**
  19. * 添加店铺地址库
  20. * @param array $data
  21. */
  22. public function addAddress($data)
  23. {
  24. $data["update_time"] = time();
  25. $res = model('shop_address')->add($data);
  26. Cache::tag("shop_address")->clear();
  27. return $this->success($res);
  28. }
  29. /**
  30. * 修改店铺地址库
  31. * @param array $data
  32. */
  33. public function editAddress($data, $condition)
  34. {
  35. $res = model('shop_address')->update($data, $condition);
  36. //修改对应店铺
  37. Cache::tag("shop_address")->clear();
  38. return $this->success($res);
  39. }
  40. /**
  41. * 删除店铺地址库
  42. * @param unknown $condition
  43. */
  44. public function deleteAddress($condition)
  45. {
  46. $res = model('shop_address')->delete($condition);
  47. Cache::tag("shop_address")->clear();
  48. return $this->success($res);
  49. }
  50. /**
  51. * 获取店铺地址库信息
  52. * @param unknown $condition
  53. * @param string $field
  54. */
  55. public function getAddressInfo($condition, $field = 'id, site_id, contact_name, mobile, postcode, province_id, city_id, district_id, community_id, address, full_address, is_return, is_return_default, is_delivery, update_time')
  56. {
  57. $data = json_encode([$condition, $field]);
  58. $cache = Cache::get("shop_address_getAddressInfo_" . $data);
  59. if (!empty($cache)) {
  60. return $this->success($cache);
  61. }
  62. $res = model('shop_address')->getInfo($condition, $field);
  63. Cache::tag("shop_address")->set("shop_address_getAddressInfo_" . $data, $res);
  64. return $this->success($res);
  65. }
  66. /**
  67. * 获取店铺地址库列表
  68. * @param array $condition
  69. * @param string $field
  70. * @param string $order
  71. * @param string $limit
  72. */
  73. public function getAddressList($condition = [], $field = 'id, site_id, contact_name, mobile, postcode, province_id, city_id, district_id, community_id, address, full_address, is_return, is_return_default, is_delivery, update_time', $order = '', $limit = null)
  74. {
  75. $data = json_encode([$condition, $field, $order, $limit]);
  76. $cache = Cache::get("shop_address_getAddressList_" . $data);
  77. if (!empty($cache)) {
  78. return $this->success($cache);
  79. }
  80. $list = model('shop_address')->getList($condition, $field, $order, '', '', '', $limit);
  81. Cache::tag("shop_address")->set("shop_address_getAddressList_" . $data, $list);
  82. return $this->success($list);
  83. }
  84. /**
  85. * 获取店铺地址库分页列表
  86. * @param array $condition
  87. * @param number $page
  88. * @param string $page_size
  89. * @param string $order
  90. * @param string $field
  91. */
  92. public function getAddressPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = 'id, site_id, contact_name, mobile, postcode, province_id, city_id, district_id, community_id, address, full_address, is_return, is_return_default, is_delivery, update_time')
  93. {
  94. $data = json_encode([$condition, $field, $order, $page, $page_size]);
  95. $cache = Cache::get("shop_address_getAddressPageList_" . $data);
  96. if (!empty($cache)) {
  97. return $this->success($cache);
  98. }
  99. $list = model('shop_address')->pageList($condition, $field, $order, $page, $page_size);
  100. Cache::tag("shop_address")->set("shop_address_getAddressPageList_" . $data, $list);
  101. return $this->success($list);
  102. }
  103. }