255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城id', 'e_coupon_id' => '电子券id', 'user_id' => '接收者id', 'give_user_id' => '赠送者id', 'e_coupon_name' => '电子券名称', 'amount' => '赠送数量', 'is_proper' => '是否专有者', 'proper_id' => '专有者id', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'status' => '状态[-1:删除;0:禁用;1启用]', ]; } /** * 数据设置 */ public static function setData(array $params) { try{ if (!isset($params['mall_id']) || empty($params['mall_id'])) throw new Exception('缺少商城ID'); $mall_id = $params['mall_id']; if (isset($params['id']) && !empty($params['id'])) { $model = self::findOne(['id' => $params['id'], 'mall_id' => $mall_id, 'status' => StatusEnum::ENABLED]); if(empty($model)) throw new Exception('赠送记录不存在或已删除'); } else { $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; } if (!$model->load($params,'') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; }catch(Exception $e){ self::setStaticError($e->getMessage()); return false; } } }