package com.neusoft.smart.pos.promotion.service;

import com.neusoft.smart.pos.dto.member.response.DetailedMemberResponse;
import com.neusoft.smart.pos.framework.exception.BusinessCommonException;
import com.neusoft.smart.pos.promotion.constants.PromotionErrorCode;
import com.neusoft.smart.pos.dto.promotion.bean.CalculateBean;
import com.neusoft.smart.pos.promotion.service.remote.RemoteMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * 会员营销
 */
@Service
public class MemberPromotionCalculate implements IPromotionCalculate {
    
    @Autowired
    private RemoteMemberService remoteMemberService;
    
    @Override
    public CalculateBean calculatePrice(CalculateBean calculateBean) {
        //会员卡号不是空 查询一下会员卡 算出折扣
        if (!StringUtils.isEmpty(calculateBean.getMemberCardNum())) {
            //WARN: 计算会员优惠没有依据手机号
            //WARN: 计算会员优惠时不考虑门店会员
            calculateBean = remoteMemberService.calculateByMemberLevelPolicy(null,
                    calculateBean.getMemberCardNum(), calculateBean.getOrgId(), null, calculateBean ).getResult();
        }
        return calculateBean;
    }
    
}
