From 6c823dd44dbde79f008001a2a11e7bf9bc6bf8cc Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期三, 04 十二月 2024 18:15:44 +0800
Subject: [PATCH] fix:合伙人列表操作日志

---
 src/main/java/com/mzl/flower/service/flower/FlowerMarkupSpService.java |   38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/mzl/flower/service/flower/FlowerMarkupSpService.java b/src/main/java/com/mzl/flower/service/flower/FlowerMarkupSpService.java
index 89b410b..8e54a9c 100644
--- a/src/main/java/com/mzl/flower/service/flower/FlowerMarkupSpService.java
+++ b/src/main/java/com/mzl/flower/service/flower/FlowerMarkupSpService.java
@@ -7,14 +7,20 @@
 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;
 
 @Slf4j
@@ -25,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());
@@ -35,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){
@@ -53,7 +75,7 @@
                 dt.setPartnerId(dto.getPartnerId());
                 dt.setFee(dto.getFee());
 
-                saveMarkupSp(dt);
+                saveMarkupSp(dt,request);
             }
         }
     }
@@ -77,6 +99,11 @@
         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));
             }
         }
 
@@ -90,6 +117,11 @@
         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));
             }
         }
 

--
Gitblit v1.9.3