cloudroam
2024-09-30 b14befec1ef345d88a04da3ca1e10a006a7862e5
src/main/java/com/mzl/flower/service/flower/FlowerMarkupSpService.java
@@ -15,6 +15,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
@Slf4j
@@ -26,7 +27,6 @@
    private FlowerMarkupSpMapper spMapper;
    public void saveMarkupSp(FlowerMarkupSpSaveDTO dto){
        FlowerMarkupSp sp = spMapper.selectOne(new QueryWrapper<FlowerMarkupSp>()
                .eq("partner_id", dto.getPartnerId()).eq("flower_id", dto.getFlowerId()));
        if(sp == null){
@@ -45,6 +45,20 @@
        markupCacheClient.addMarkupSp(dto.getPartnerId(), dto.getFlowerId(), sp);
    }
    public void saveMarkupSpBatch(FlowerMarkupSpSaveBatchDTO dto){
        List<Long> flowerIds = dto.getFlowerIds();
        if(flowerIds != null && flowerIds.size() > 0){
            for(Long flowerId : flowerIds){
                FlowerMarkupSpSaveDTO dt = new FlowerMarkupSpSaveDTO();
                dt.setFlowerId(flowerId);
                dt.setPartnerId(dto.getPartnerId());
                dt.setFee(dto.getFee());
                saveMarkupSp(dt);
            }
        }
    }
    public FlowerMarkupSpDTO getMarkupSp(Long flowerId){
        FlowerMarkupSpDTO dto = new FlowerMarkupSpDTO();
        dto.setFlowerId(flowerId);
@@ -59,12 +73,34 @@
        return dto;
    }
    public Page<FlowerMarkupSpListDTO> selectMarkupSpFlowerList(Page page, FlowerMarkupSpQueryDTO dto){
        List<FlowerMarkupSpListDTO> ll = spMapper.selectMarkupSpFlowerList(page, dto.getPartnerId(), dto);
        if(ll != null && ll.size() > 0){
            for(FlowerMarkupSpListDTO ss : ll){
                ss.setPrice(getFinalPriceForPartner(dto.getPartnerId(), ss.getCategory(), ss.getFlowerId(), ss.getPrice(), ss.getLevel()));
                BigDecimal fee = ss.getFee();
                if (fee == null) {
                    fee = BigDecimal.ZERO;
                }
                ss.setSellPrice(ss.getPrice().add(fee));
            }
        }
        page.setRecords(ll);
        return page;
    }
    public Page<FlowerMarkupSpListDTO> selectMarkupSpList(Page page, FlowerMarkupSpQueryDTO dto){
        List<FlowerMarkupSpListDTO> ll = spMapper.selectMarkupSpList(page, dto.getPartnerId(), dto);
        if(ll != null && ll.size() > 0){
            for(FlowerMarkupSpListDTO ss : ll){
                ss.setPrice(getFinalPriceForPartner(dto.getPartnerId(), ss.getCategory(), ss.getFlowerId(), ss.getPrice(), ss.getLevel()));
                BigDecimal fee = ss.getFee();
                if (fee == null) {
                    fee = BigDecimal.ZERO;
                }
                ss.setSellPrice(ss.getPrice().add(fee));
            }
        }