| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers\setting;
- use app\models\District;
- use app\models\FreeDeliveryRules;
- use app\modules\admin\controllers\BaseController;
- use app\modules\admin\models\FreeForm;
- class FreeController extends BaseController
- {
- /**
- * 获取运费规则列表
- * @return \yii\web\Response
- */
- public function actionList()
- {
- return $this->asJson([
- 'code' => 0,
- 'data' => [
- 'list' => FreeDeliveryRules::find()->where([
- 'store_id' => get_store_id(),
- 'mch_id' => get_mch_id(),
- 'is_delete' => 0
- ])->select(['id','name','price'])->all()
- ]
- ]);
- }
- /**
- * 新增、编辑运费规则
- */
- public function actionEdit($id = null)
- {
- $model = FreeDeliveryRules::findOne([
- 'id' => $id,
- 'store_id' => get_store_id(),
- 'mch_id' => get_mch_id(),
- 'is_delete' => 0,
- ]);
- return $this->asJson([
- 'code' => 0,
- 'data' => [
- 'model' => $model,
- 'district' => District::getAll()
- ]
- ]);
- }
- /**
- * 保存
- */
- public function actionSave()
- {
- $form = new FreeForm();
- $form->free = post_params('free');
- $form->city_list = post_params('city_list');
- $form->store_id = get_store_id();
- $form->mch_id = get_mch_id();
- return $this->asJson($form->save());
- }
- /**
- * 修改状态
- * @return \yii\web\Response
- */
- public function actionDel()
- {
- $data = get_params();
- $model = FreeDeliveryRules::findOne(['id' => $data['id'], 'store_id' => get_store_id(), 'mch_id' => get_mch_id()]);
- if (empty($model)) {
- $res = ['code' => 1, 'msg' => '参数错误'];
- } else {
- $model->is_delete = 1;
- $res = $model->save() ? ['code' => 0, 'msg' => '操作成功'] : ['code' => 1, 'msg' => '操作失败'];
- }
- return $this->asJson($res);
- }
- }
|