RefundAddressController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\controllers\setting;
  8. use app\models\RefundAddress;
  9. use app\modules\admin\controllers\BaseController;
  10. use app\modules\admin\models\RefundAddressForm;
  11. class RefundAddressController extends BaseController
  12. {
  13. /**
  14. * 获取云打印列表
  15. * @return \yii\web\Response
  16. */
  17. public function actionList()
  18. {
  19. return $this->asJson([
  20. 'code' => 0,
  21. 'data' => [
  22. 'list' => RefundAddress::find()
  23. ->where(['is_delete' => 0, 'store_id' => get_store_id(), 'mch_id' => get_mch_id()])
  24. ->orderBy(['id' => SORT_DESC])->all(),
  25. ]
  26. ]);
  27. }
  28. /**
  29. * 获取详情
  30. */
  31. public function actionEdit($id = null)
  32. {
  33. return $this->asJson([
  34. 'code' => 0,
  35. 'data' => [
  36. 'model' => RefundAddress::findOne($id)
  37. ]
  38. ]);
  39. }
  40. /**
  41. * 保存
  42. */
  43. public function actionSave()
  44. {
  45. $form = new RefundAddressForm();
  46. $form->attributes = post_params();
  47. if(get_mch_id()){
  48. $form->mch_id = get_mch_id();
  49. }
  50. return $this->asJson($form->save());
  51. }
  52. /**
  53. * 删除
  54. * @param $id
  55. * @return \yii\web\Response
  56. */
  57. public function actionDel($id)
  58. {
  59. $model = RefundAddress::findOne($id);
  60. if (empty($model)) {
  61. $res = ['code' => 1, 'msg' => '参数错误'];
  62. } else {
  63. $model->is_delete = 1;
  64. $res = $model->save() ? ['code' => 0, 'msg' => '保存成功'] : ['code' => 1, 'msg' => '保存失败'];
  65. }
  66. return $this->asJson($res);
  67. }
  68. }