UserAddressController.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LikeShop有特色的全开源社交分销电商系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
  7. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  8. // | 微信公众号:好象科技
  9. // | 访问官网:http://www.likemarket.net
  10. // | 访问社区:http://bbs.likemarket.net
  11. // | 访问手册:http://doc.likemarket.net
  12. // | 好象科技开发团队 版权所有 拥有最终解释权
  13. // +----------------------------------------------------------------------
  14. // | Author: LikeShopTeam-段誉
  15. // +----------------------------------------------------------------------
  16. namespace app\shopapi\controller;
  17. use app\shopapi\validate\UserAddressValidate;
  18. use app\shopapi\logic\UserAddressLogic;
  19. /**
  20. * 收货地址
  21. * Class UserAddressController
  22. * @package app\shopapi\controller
  23. */
  24. class UserAddressController extends BaseShopController
  25. {
  26. /**
  27. * @notes 列表
  28. * @return \think\response\Json
  29. * @author 段誉
  30. * @date 2021/7/22 11:41
  31. */
  32. public function lists()
  33. {
  34. return $this->data(UserAddressLogic::getLists($this->userId));
  35. }
  36. /**
  37. * @notes 详情
  38. * @return \think\response\Json
  39. * @author 段誉
  40. * @date 2021/7/22 11:41
  41. */
  42. public function detail()
  43. {
  44. $params = (new UserAddressValidate())->goCheck('detail', ['user_id' => $this->userId]);
  45. $result = UserAddressLogic::getDetail($params['id'], $this->userId);
  46. return $this->data($result);
  47. }
  48. /**
  49. * @notes 获取默认地址
  50. * @return \think\response\Json
  51. * @author 段誉
  52. * @date 2021/7/22 11:41
  53. */
  54. public function getDefault()
  55. {
  56. $result = UserAddressLogic::getDefault($this->userId);
  57. return $this->data($result);
  58. }
  59. /**
  60. * @notes 设置默认地址
  61. * @return \think\response\Json
  62. * @author 段誉
  63. * @date 2021/7/22 11:41
  64. */
  65. public function setDefault()
  66. {
  67. $params = (new UserAddressValidate())->post()->goCheck('set', ['user_id' => $this->userId]);
  68. UserAddressLogic::setDefault($params, $this->userId);
  69. return $this->success('设置成功',[],1,1);
  70. }
  71. /**
  72. * @notes 添加收货地址
  73. * @return \think\response\Json
  74. * @author 段誉
  75. * @date 2021/7/22 11:42
  76. */
  77. public function add()
  78. {
  79. $params = (new UserAddressValidate())->post()->goCheck('add');
  80. UserAddressLogic::addAddress($params, $this->userId);
  81. return $this->success();
  82. }
  83. /**
  84. * @notes 编辑收货地址
  85. * @return \think\response\Json
  86. * @author 段誉
  87. * @date 2021/7/22 11:42
  88. */
  89. public function edit()
  90. {
  91. $params = (new UserAddressValidate())->post()->goCheck('', ['user_id' => $this->userId]);
  92. UserAddressLogic::editAddress($params);
  93. return $this->success();
  94. }
  95. /**
  96. * @notes 删除
  97. * @return \think\response\Json
  98. * @author 段誉
  99. * @date 2021/7/22 11:42
  100. */
  101. public function del()
  102. {
  103. $params = (new UserAddressValidate())->post()->goCheck('del', ['user_id' => $this->userId]);
  104. UserAddressLogic::del($params);
  105. return $this->success();
  106. }
  107. /**
  108. * @notes 将省市区名称转为id
  109. * @return \think\response\Json
  110. * @author Tab
  111. * @date 2021/8/12 16:02
  112. */
  113. public function handleRegion()
  114. {
  115. $params = (new UserAddressValidate())->goCheck('handleRegion');
  116. $result = UserAddressLogic::handleRegion($params);
  117. return $this->data($result);
  118. }
  119. /**
  120. * @notes 获取省市区
  121. * @return \think\response\Json
  122. * @throws \think\db\exception\DataNotFoundException
  123. * @throws \think\db\exception\DbException
  124. * @throws \think\db\exception\ModelNotFoundException
  125. * @author cjhao
  126. * @date 2022/11/8 6:43 下午
  127. */
  128. public function getRegion()
  129. {
  130. $id = $this->request->get('id',0);
  131. $lists = UserAddressLogic::getRegion($id);
  132. return $this->data($lists);
  133. }
  134. /**
  135. * 获取特定地区列表信息
  136. *
  137. * */
  138. public function getSpecialAreaList(){
  139. return $this->data(UserAddressLogic::getSpecialAreaLists());
  140. }
  141. /**
  142. * 获取指定地区配送费信息
  143. *
  144. * */
  145. public function getSpecialAreaShipFeeInfo(){
  146. $id = $this->request->get('district_id',0);
  147. $lists = UserAddressLogic::getSpecialAreaInfo($id);
  148. return $this->data($lists);
  149. }
  150. }