255], [['cloud_setting'], 'safe'], ]; } public function attributeLabels() { return [ 'name' => '名称' ]; } /** * 保存运费规则 * @return array */ public function save() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } $cloud = Cloud::findOne($this->id) ?: new Cloud(); $cloud->store_id = get_store_id(); $cloud->mch_id = $this->mch_id; $cloud->name = $this->name; $cloud->cloud_setting = Json::encode($this->cloud_setting); $cloud->cloud_type = $this->cloud_type; $cloud->is_delete = 0;//有客户添加云打印报错is_delete字段不能为null cache()->delete('admin_cloud_setting_' . get_store_id() . '_' . get_mch_id()); if ($cloud->save()) { return [ 'code' => 0, 'msg' => '保存成功' ]; } else { return [ 'code' => 1, 'msg' => '保存失败', 'err' => $cloud->errors ]; } } }