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); } }