zouxuan 4 年之前
父节点
当前提交
13862b2749

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentGoodsSellDto.java

@@ -12,9 +12,9 @@ public class StudentGoodsSellDto extends StudentPaymentOrder {
 
     private Integer authorUser;
 
-    private BigDecimal totalAmount;
+    private BigDecimal totalAmount = BigDecimal.ZERO;
 
-    private BigDecimal marketAmount;
+    private BigDecimal marketAmount = BigDecimal.ZERO;
 
     public Integer getAuthorUser() {
         return authorUser;

+ 9 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -684,8 +684,10 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             rechargeDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
             rechargeDetail.setUserId(userId);
             rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-            rechargeDetail.setComAmount(studentPaymentOrder.getComAmount());
-            rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount());
+            if (studentPaymentOrder.getComAmount() != null) {
+                rechargeDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+                rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
+            }
             sysUserCashAccountDetailService.insert(rechargeDetail);
             //缴费
             SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
@@ -696,11 +698,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             paymentDetail.setTransNo(studentPaymentOrder.getTransNo());
             paymentDetail.setType(PlatformCashAccountDetailTypeEnum.GOODS_SELL);
             paymentDetail.setUserId(userId);
-            rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-            if (studentPaymentOrder.getComAmount() != null) {
-                rechargeDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
-                rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
-            }
+            sysUserCashAccountDetailService.insert(paymentDetail);
             saveSellOrder(studentPaymentOrder.getOrderNo());
         } else if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
             if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
@@ -751,8 +749,9 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         BigDecimal marketAmount = studentGoodsSell.getMarketAmount();
         //可用减免金额
         BigDecimal usableMarketAmount = marketAmount;
-
+        //包含减免余额的总金额
         BigDecimal totalAmount = goodsSellDtos.stream().map(e -> e.getTotalGoodsPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal subtract = totalAmount.subtract(marketAmount);
         for (int i = 0; i < goodsId.size(); i++) {
             Integer e = goodsId.get(i);
             GoodsSellDto goodsSellDto = collect.get(e).get(0);
@@ -767,7 +766,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             sellOrder.setTransNo(orderByOrderNo.getTransNo());
             sellOrder.setOrderId(orderByOrderNo.getId());
             sellOrder.setOrderNo(orderByOrderNo.getOrderNo());
-            //如果有减免金额
+            //如果有减免金额
             if(marketAmount.doubleValue() > 0l){
                 //如果是最后一件商品
                 if(i == goodsId.size() - 1){
@@ -779,7 +778,6 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                     usableMarketAmount = usableMarketAmount.subtract(multiply);
                 }
             }
-            totalAmount = totalAmount.subtract(marketAmount);
 
             sellOrder.setExpectAmount(goodsSellDto.getTotalGoodsPrice());
             //如果没有使用余额,那么实际金额和预计金额一致
@@ -793,7 +791,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                     sellOrder.setBalanceAmount(usableBalance);
                 }else {
                     //获取分配的余额
-                    BigDecimal multiply = balancePaymentAmount.multiply(goodsSellDto.getTotalGoodsPrice().divide(totalAmount, 2, BigDecimal.ROUND_HALF_UP));
+                    BigDecimal multiply = balancePaymentAmount.multiply(goodsSellDto.getTotalGoodsPrice().divide(subtract, 2, BigDecimal.ROUND_HALF_UP));
                     //余额大于等于商品总价
                     sellOrder.setActualAmount(goodsSellDto.getTotalGoodsPrice().subtract(multiply));
                     sellOrder.setBalanceAmount(multiply);

+ 9 - 6
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -46,6 +46,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
@@ -117,7 +118,7 @@ public class RoomServiceImpl implements RoomService {
         return Integer.parseInt(roomId);
     }
 
-    @Transactional(rollbackFor = Exception.class, isolation = Isolation.SERIALIZABLE)
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     @Override
     public RoomResult joinRoom(String roomId) throws Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
@@ -235,7 +236,8 @@ public class RoomServiceImpl implements RoomService {
         return roomResult;
     }
 
-    @Transactional(rollbackFor = Exception.class, isolation = Isolation.SERIALIZABLE)
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    @Override
     public void joinRoomSuccess(String roomId,String userId) throws Exception {
         RoomMember roomMember = roomMemberDao.findByRidAndUid(roomId, userId);
         if(roomMember == null){
@@ -341,7 +343,8 @@ public class RoomServiceImpl implements RoomService {
         return roomMember;
     }
 
-    @Transactional(rollbackFor = Exception.class, isolation = Isolation.SERIALIZABLE)
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    @Override
     public void leaveRoomSuccess(String roomId,String userId) throws Exception {
         RoomMember roomMember = roomMemberDao.findByRidAndUid(roomId, userId);
         if(roomMember == null){
@@ -395,7 +398,7 @@ public class RoomServiceImpl implements RoomService {
         }
     }
 
-    @Transactional(rollbackFor = Exception.class)
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     @Override
     public void destroyRoom(String roomId) {
         whiteboardDao.deleteByRid(roomId);
@@ -415,7 +418,7 @@ public class RoomServiceImpl implements RoomService {
         }
     }
 
-    @Transactional(rollbackFor = Exception.class)
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     @Override
     public Boolean downgrade(String roomId, List<ReqChangeUserRoleData.ChangedUser> users) throws Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
@@ -468,7 +471,7 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public Boolean kickMember(String roomId) throws Exception {
         SysUser authUser = sysUserFeignService.queryUserInfo();
         String userId = authUser.getId().toString();