255], [['SupplierSetting_setting'], 'safe'], ]; } public function attributeLabels() { return [ 'id' => 'ID', 'store_id' => 'Store ID', 'mch_id' => '入驻商id', 'address' => '平台供货收货地址', 'name' => '收货人名字', 'mobile' => '收货人电话', 'repertory_warning' => '库存警告', 'repertory_purchase' => '采购库存', 'province' => '省id', 'city' => '市id', 'district' => '区id', 'longitude' => '经度', 'latitude' => '纬度', ]; } /** * 保存运费规则 * @return array */ public function save() { if(!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } $SupplierSetting = SupplierSetting::findOne($this->id) ?: new SupplierSetting(); $SupplierSetting->store_id = get_store_id(); $SupplierSetting->mch_id = $this->mch_id; $SupplierSetting->name = $this->name; $SupplierSetting->SupplierSetting_setting = Json::encode($this->SupplierSetting_setting); $SupplierSetting->SupplierSetting_type = $this->SupplierSetting_type; if ($SupplierSetting->save()) { return [ 'code' => 0, 'msg' => '保存成功' ]; } else { return [ 'code' => 1, 'msg' => '保存失败', 'err' => $SupplierSetting->errors ]; } } }