package com.tashow.cloud.trade.service.price;

import com.tashow.cloud.trade.controller.app.order.vo.AppTradeProductSettlementRespVO;
import com.tashow.cloud.trade.service.price.bo.TradePriceCalculateReqBO;
import com.tashow.cloud.trade.service.price.bo.TradePriceCalculateRespBO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * 价格计算 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
@Slf4j
public class TradePriceServiceImpl implements TradePriceService {

//    @Resource
//    private ProductSkuApi productSkuApi;
//    @Resource
//    private ProductSpuApi productSpuApi;
//    @Resource
//    private DiscountActivityApi discountActivityApi;
//    @Resource
//    private RewardActivityApi rewardActivityApi;
//
//    @Resource
//    private List<TradePriceCalculator> priceCalculators;
//
//    @Resource
//    private TradeDiscountActivityPriceCalculator discountActivityPriceCalculator;

    @Override
    public TradePriceCalculateRespBO calculateOrderPrice(TradePriceCalculateReqBO calculateReqBO) {
//        // 1.1 获得商品 SKU 数组
//        List<ProductSkuRespDTO> skuList = checkSkuList(calculateReqBO);
//        // 1.2 获得商品 SPU 数组
//        List<ProductSpuRespDTO> spuList = checkSpuList(skuList);
//
//        // 2.1 计算价格
//        TradePriceCalculateRespBO calculateRespBO = TradePriceCalculatorHelper
//                .buildCalculateResp(calculateReqBO, spuList, skuList);
//        priceCalculators.forEach(calculator -> calculator.calculate(calculateReqBO, calculateRespBO));
//        // 2.2  如果最终支付金额小于等于 0，则抛出业务异常
//        if (calculateReqBO.getPointActivityId() == null // 积分订单，允许支付金额为 0
//                && calculateRespBO.getPrice().getPayPrice() <= 0) {
//            log.error("[calculatePrice][价格计算不正确，请求 calculateReqDTO({})，结果 priceCalculate({})]",
//                    calculateReqBO, calculateRespBO);
//            throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL);
//        }
        return null;
    }



    @Override
    public List<AppTradeProductSettlementRespVO> calculateProductPrice(Long userId, List<Long> spuIds) {
        return null;
    }

}
