where([ 'store_id' => get_store_id(), 'is_delete' => 0 ]); $is_enable = input_params('is_enable', -1); if($is_enable > -1){ $query->andWhere(['is_enable' => $is_enable]); } $query->select(['id','name','is_enable']); $pagination = pagination_make($query); return $this->asJson([ 'code' => 0, 'data' => $pagination, ]); } public function actionInfo($id = null) { $model = OrderRulesBuyerLocation::findOne([ 'id' => $id, 'store_id' => get_store_id(), 'is_delete' => 0, ]); return $this->asJson([ 'code' => 0, 'data' => [ 'model' => $model, 'district' => District::getAll() ] ]); } /** * 省市区详情 */ public function actionDistrictInfo($id = null) { return $this->asJson([ 'code' => 0, 'data' => [ 'district' => District::getAll() ] ]); } /** * 保存 */ public function actionSave() { $form = new OrderRulesBuyerLocationForm(); $form->rule = post_params('rule'); $form->province_list = post_params('province_list'); $form->store_id = get_store_id(); return $this->asJson($form->save()); } /** * 修改状态 * @return \yii\web\Response */ public function actionStatus() { $data = post_params(); if (empty($data['ids'])) { $res = ['code' => 1, 'msg' => '参数错误']; } else { $ids = explode(',', $data['ids']); if (in_array($data['status'], [0, 1])) { $num = OrderRulesBuyerLocation::updateAll(['is_enable' => $data['status']], ['and', ['in', 'id', $ids], ['store_id' => get_store_id()]]); $res = $num > 0 ? ['code' => 0, 'msg' => '操作成功,修改了:' . $num . '条数据'] : ['code' => 1, 'msg' => '操作失败']; } if ((int)$data['status'] === 2) { $num = OrderRulesBuyerLocation::updateAll(['is_delete' => 1], ['and', ['in', 'id', $ids], ['store_id' => get_store_id()]]); $res = $num > 0 ? ['code' => 0, 'msg' => '操作成功,修改了:' . $num . '条数据'] : ['code' => 1, 'msg' => '操作失败']; } } return $this->asJson($res); } }