package com.seamew.lottery.domain.award.service.goods.impl;

import com.seamew.lottery.common.Constants;
import com.seamew.lottery.domain.award.annotation.AwardMode;
import com.seamew.lottery.domain.award.model.req.GoodsReq;
import com.seamew.lottery.domain.award.model.res.DistributionRes;
import com.seamew.lottery.domain.award.service.goods.DistributionBase;
import com.seamew.lottery.domain.award.service.goods.IDistributionGoods;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author: seamew
 * @Title: PhysicalGoods
 * @CreateTime: 2023年02月15日 10:52:00
 * @Description: 实物发货类商品
 * @Version: 1.0
 */
@Component
@Slf4j
@AwardMode(awardMode = Constants.AwardType.PhysicalGoods)
public class PhysicalGoods extends DistributionBase implements IDistributionGoods {
    @Override
    public DistributionRes doDistribution(GoodsReq req) {

        // 模拟调用实物发奖
        log.info("模拟调用实物发奖 uId：{} awardContent：{}", req.getUId(), req.getAwardContent());

        // 更新用户领奖结果
        updateUserAwardState(req.getUId(), req.getOrderId(), req.getAwardId(), Constants.GrantState.COMPLETE.getCode());

        return new DistributionRes(req.getUId(), Constants.AwardState.SUCCESS.getCode(), Constants.AwardState.SUCCESS.getInfo());
    }

    @Override
    public Integer getDistributionGoodsName() {
        return Constants.AwardType.PhysicalGoods.getCode();
    }
}
