Address.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace app\supplier\controller\setting;
  3. use app\supplier\controller\Controller;
  4. use app\supplier\model\settings\ReturnAddress as ReturnAddressModel;
  5. /**
  6. * 地址控制器
  7. */
  8. class Address extends Controller
  9. {
  10. /**
  11. * 地址首页
  12. */
  13. public function index()
  14. {
  15. $model = new ReturnAddressModel;
  16. $list = $model->getList($this->postData(),$this->getSupplierId());
  17. return $this->renderSuccess('', compact('list'));
  18. }
  19. /**
  20. * 添加退货地址
  21. */
  22. public function add()
  23. {
  24. // 新增记录
  25. $model = new ReturnAddressModel;
  26. $data = $this->postData();
  27. $data['shop_supplier_id'] = $this->getSupplierId();
  28. if ($model->add($data)) {
  29. return $this->renderSuccess('添加成功');
  30. }
  31. return $this->renderError($model->getError() ?: '添加失败');
  32. }
  33. /**
  34. * 退货地址详情
  35. */
  36. public function detail($address_id)
  37. {
  38. // 物流公司详情
  39. $detail = ReturnAddressModel::detail($address_id);
  40. return $this->renderSuccess('', compact('detail'));
  41. }
  42. /**
  43. * 修改
  44. * @param $address_id
  45. * @return \think\response\Json
  46. */
  47. public function edit($address_id)
  48. {
  49. if($this->request->isGet()){
  50. return $this->detail($address_id);
  51. }
  52. $model = ReturnAddressModel::detail($address_id);
  53. // 更新记录
  54. if ($model->edit($this->postData())) {
  55. return $this->renderSuccess('更新成功');
  56. }
  57. return $this->renderError($model->getError() ?: '更新失败');
  58. }
  59. /**
  60. * 删除记录
  61. */
  62. public function delete($address_id)
  63. {
  64. $model = ReturnAddressModel::detail($address_id);
  65. if ($model->remove()) {
  66. return $this->renderSuccess('删除成功');
  67. }
  68. return $this->renderError($model->getError() ?:'删除失败');
  69. }
  70. }