AddressController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\admin\classes\AddressClass;
  4. use Yii;
  5. use common\components\util;
  6. class AddressController extends BaseController
  7. {
  8. //删除地址 ssh 202201003
  9. public function actionDel()
  10. {
  11. $get = Yii::$app->request->get();
  12. $id = $get['id'] ?? 0;
  13. $address = AddressClass::getById($id, true);
  14. if (empty($address)) {
  15. util::fail('没有找到地址');
  16. }
  17. if ($address->mainId != $this->mainId) {
  18. util::fail('没有权限');
  19. }
  20. $address->delete();
  21. util::complete();
  22. }
  23. //地址列表 ssh 20221003
  24. public function actionList()
  25. {
  26. //$get = Yii::$app->request->get();
  27. $where = ['adminId' => $this->adminId];
  28. $list = AddressClass::getAddressList($where);
  29. util::success($list);
  30. }
  31. //地址列表 ssh 20221003
  32. public function actionAdd()
  33. {
  34. $post = Yii::$app->request->post();
  35. $post['sjId'] = $this->sjId;
  36. $post['mainId'] = $this->mainId;
  37. $post['shopId'] = $this->shopId;
  38. $post['adminId'] = $this->adminId;
  39. AddressClass::addData($post);
  40. util::complete();
  41. }
  42. //修改地址 ssh 20221003
  43. public function actionUpdate()
  44. {
  45. $post = Yii::$app->request->post();
  46. $id = $post['id'] ?? 0;
  47. unset($post['id']);
  48. $address = AddressClass::getById($id, true);
  49. if ($address->mainId != $this->mainId) {
  50. util::fail('没有权限修改');
  51. }
  52. AddressClass::updateById($id, $post);
  53. util::complete();
  54. }
  55. }