UserAddressController.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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\logic\AfterSaleLogic;
  18. use app\shopapi\validate\UserAddressValidate;
  19. use app\shopapi\logic\UserAddressLogic;
  20. /**
  21. * 收货地址
  22. * Class UserAddressController
  23. * @package app\shopapi\controller
  24. */
  25. class UserAddressController extends BaseShopController
  26. {
  27. /**
  28. * @notes 列表
  29. * @return \think\response\Json
  30. * @author 段誉
  31. * @date 2021/7/22 11:41
  32. */
  33. public function lists()
  34. {
  35. return $this->data(UserAddressLogic::getLists($this->userId));
  36. }
  37. /**
  38. * @notes 详情
  39. * @return \think\response\Json
  40. * @author 段誉
  41. * @date 2021/7/22 11:41
  42. */
  43. public function detail()
  44. {
  45. $params = (new UserAddressValidate())->goCheck('detail', ['user_id' => $this->userId]);
  46. $result = UserAddressLogic::getDetail($params['id'], $this->userId);
  47. return $this->data($result);
  48. }
  49. /**
  50. * @notes 获取默认地址
  51. * @return \think\response\Json
  52. * @author 段誉
  53. * @date 2021/7/22 11:41
  54. */
  55. public function getDefault()
  56. {
  57. $result = UserAddressLogic::getDefault($this->userId);
  58. return $this->data($result);
  59. }
  60. /**
  61. * @notes 设置默认地址
  62. * @return \think\response\Json
  63. * @author 段誉
  64. * @date 2021/7/22 11:41
  65. */
  66. public function setDefault()
  67. {
  68. $params = (new UserAddressValidate())->post()->goCheck('set', ['user_id' => $this->userId]);
  69. UserAddressLogic::setDefault($params, $this->userId);
  70. return $this->success('设置成功',[],1,1);
  71. }
  72. /**
  73. * @notes 添加收货地址
  74. * @return \think\response\Json
  75. * @author 段誉
  76. * @date 2021/7/22 11:42
  77. */
  78. public function add()
  79. {
  80. $params = (new UserAddressValidate())->post()->goCheck('add');
  81. UserAddressLogic::addAddress($params, $this->userId);
  82. return $this->success();
  83. }
  84. /**
  85. * @notes 编辑收货地址
  86. * @return \think\response\Json
  87. * @author 段誉
  88. * @date 2021/7/22 11:42
  89. */
  90. public function edit()
  91. {
  92. $params = (new UserAddressValidate())->post()->goCheck('', ['user_id' => $this->userId]);
  93. UserAddressLogic::editAddress($params);
  94. return $this->success();
  95. }
  96. /**
  97. * @notes 删除
  98. * @return \think\response\Json
  99. * @author 段誉
  100. * @date 2021/7/22 11:42
  101. */
  102. public function del()
  103. {
  104. $params = (new UserAddressValidate())->post()->goCheck('del', ['user_id' => $this->userId]);
  105. UserAddressLogic::del($params);
  106. return $this->success();
  107. }
  108. /**
  109. * @notes 将省市区名称转为id
  110. * @return \think\response\Json
  111. * @author Tab
  112. * @date 2021/8/12 16:02
  113. */
  114. public function handleRegion()
  115. {
  116. $params = (new UserAddressValidate())->goCheck('handleRegion');
  117. $result = UserAddressLogic::handleRegion($params);
  118. return $this->data($result);
  119. }
  120. /**
  121. * @notes 获取省市区
  122. * @return \think\response\Json
  123. * @throws \think\db\exception\DataNotFoundException
  124. * @throws \think\db\exception\DbException
  125. * @throws \think\db\exception\ModelNotFoundException
  126. * @author cjhao
  127. * @date 2022/11/8 6:43 下午
  128. */
  129. public function getRegion()
  130. {
  131. $id = $this->request->get('id',0);
  132. $lists = UserAddressLogic::getRegion($id);
  133. return $this->data($lists);
  134. }
  135. /**
  136. * 获取特定地区列表信息
  137. *
  138. * */
  139. public function getSpecialAreaList(){
  140. return $this->data(UserAddressLogic::getSpecialAreaLists());
  141. }
  142. /**
  143. * 获取指定地区配送费信息
  144. *
  145. * */
  146. public function getSpecialAreaShipFeeInfo(){
  147. $id = $this->request->get('area_id',0);
  148. if($id == 0) return $this->fail('请传入区iD');
  149. $lists = UserAddressLogic::getSpecialAreaInfo($id);
  150. return $this->data($lists);
  151. }
  152. }