cloudroam
2024-12-04 6c823dd44dbde79f008001a2a11e7bf9bc6bf8cc
src/main/java/com/mzl/flower/service/flower/FlowerMarkupSpService.java
@@ -7,14 +7,19 @@
import com.mzl.flower.dto.response.flower.FlowerMarkupSpDTO;
import com.mzl.flower.dto.response.flower.FlowerMarkupSpListDTO;
import com.mzl.flower.entity.flower.FlowerMarkupSp;
import com.mzl.flower.entity.log.OperationRecord;
import com.mzl.flower.entity.partner.Partner;
import com.mzl.flower.mapper.flower.FlowerMarkupSpMapper;
import com.mzl.flower.mapper.log.OperationRecordMapper;
import com.mzl.flower.service.BaseService;
import com.mzl.flower.utils.IpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
@@ -26,9 +31,14 @@
    @Autowired
    private FlowerMarkupSpMapper spMapper;
    public void saveMarkupSp(FlowerMarkupSpSaveDTO dto){
    @Autowired
    private OperationRecordMapper operationRecordMapper;
    public void saveMarkupSp(FlowerMarkupSpSaveDTO dto, HttpServletRequest request) throws IOException {
        FlowerMarkupSp sp = spMapper.selectOne(new QueryWrapper<FlowerMarkupSp>()
                .eq("partner_id", dto.getPartnerId()).eq("flower_id", dto.getFlowerId()));
        String content = "";
        OperationRecord operationRecord = new OperationRecord();
        if(sp == null){
            sp = new FlowerMarkupSp();
            sp.setFlowerId(dto.getFlowerId());
@@ -36,16 +46,27 @@
            sp.setPartnerId(dto.getPartnerId());
            sp.create(SecurityUtils.getUserId());
            spMapper.insert(sp);
            content = "新增合伙人加价:商品id:【" + dto.getFlowerId() + "】,合伙人id:【"+dto.getPartnerId()+"】,金额:【" + dto.getFee() + "】";
            operationRecord.setFunction("新增合伙人加价");
        } else {
            sp.setFee(dto.getFee());
            sp.update(SecurityUtils.getUserId());
            spMapper.updateById(sp);
            content = "修改合伙人加价:id:【"+sp.getId()+"】,商品id:【" + dto.getFlowerId() + "】,合伙人id:【"+dto.getPartnerId()+"】,金额:【" + dto.getFee() + "】";
            operationRecord.setFunction("修改合伙人加价");
        }
        markupCacheClient.addMarkupSp(dto.getPartnerId(), dto.getFlowerId(), sp);
        operationRecord.create(SecurityUtils.getUserId());
        operationRecord.setStatus("success");
        operationRecord.setModule("markup_s_p");
        operationRecord.setContent(content);
        operationRecord.setIpAddress(IpUtil.getIpAddress(request));
        operationRecordMapper.insert(operationRecord);
    }
    public void saveMarkupSpBatch(FlowerMarkupSpSaveBatchDTO dto){
    public void saveMarkupSpBatch(FlowerMarkupSpSaveBatchDTO dto,HttpServletRequest request) throws IOException {
        List<Long> flowerIds = dto.getFlowerIds();
        if(flowerIds != null && flowerIds.size() > 0){
            for(Long flowerId : flowerIds){
@@ -54,7 +75,7 @@
                dt.setPartnerId(dto.getPartnerId());
                dt.setFee(dto.getFee());
                saveMarkupSp(dt);
                saveMarkupSp(dt,request);
            }
        }
    }