validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } try { $model = ScanCodePaySetting::findOne(['store_id' => $this->store_id, 'mch' => $this->mch, 'is_delete' => 0]); if (!$model) { $model = new ScanCodePaySetting(); $model->store_id = $this->store_id; $model->is_scan_code_pay = 0; $model->payment_type = json_encode([]); $model->is_share = 0; $model->is_sms = 0; $model->is_mail = 0; $model->is_print = 0; $model->poster = json_encode([]); $model->price_type = 0; $model->first = 0; $model->second = 0; $model->third = 0; $model->mch = $this->mch; } $model->send_integral = $this->send_integral; $res = $model->save(); if (!$res) { throw new \Exception($model->getErrors($model)); } return [ 'code' => 0, 'msg' => "保存成功" ]; } catch (\Exception $e) { return [ 'code' => 1, 'msg' => $e->getMessage() ]; } } }