zoujiajian vor 2 Jahren
Ursprung
Commit
72ac57c5eb

+ 4 - 4
netflix-dao/src/main/java/com/cyksj/mapper/UserMapper.java

@@ -36,8 +36,8 @@ public interface UserMapper extends BaseMapper<User> {
     @Update("update user set points = points - #{deductPoints} where id = #{id} and points = #{originalPoints}")
     Integer subPointsNegative(@Param("id") Long userId, @Param("originalPoints") BigDecimal originalPoints, @Param("deductPoints") BigDecimal deductPoints);
 
-    @Update("update user set balance = balance - #{deduct} where id = #{userId} and balance = #{userBalance} and balance >= #{deduct}")
-    Integer deductBalance(@Param("userId") Long userId, @Param("deduct") BigDecimal deduct, @Param("userBalance") BigDecimal userBalance);
+    @Update("update user set balance = balance - #{deduct} where id = #{userId} and balance >= #{deduct}")
+    Integer deductBalance(@Param("userId") Long userId, @Param("deduct") BigDecimal deduct);
 
     @Update("update user set balance = balance + #{returnBalance} where id = #{userId} and balance = #{userBalance}")
     Integer returnBalance(@Param("userId") Long userId, @Param("returnBalance") BigDecimal returnBalance, @Param("userBalance") BigDecimal userBalance);
@@ -63,8 +63,8 @@ public interface UserMapper extends BaseMapper<User> {
     @Update("update user set yhs_money = yhs_money - #{subMoney} where id = #{shopUserId} and yhs_money >= #{subMoney} and yhs_money > 0")
     Integer subYhsMoney(@Param("shopUserId") Long shopUserId, @Param("subMoney") BigDecimal subMoney);
 
-    @Update("update user set galaxycoin = galaxycoin - (${subGalaxycoin}) where id = #{id} and galaxycoin = #{userGalaxycoin}")
-    Integer deductGalaxycoin(@Param("id") Long id, @Param("subGalaxycoin") BigDecimal subGalaxycoin, @Param("userGalaxycoin") BigDecimal userGalaxycoin);
+    @Update("update user set galaxycoin = galaxycoin - (${subGalaxycoin}) where id = #{id} and galaxycoin >= #{subGalaxycoin}")
+    Integer deductGalaxycoin(@Param("id") Long id, @Param("subGalaxycoin") BigDecimal subGalaxycoin);
 
     @Update("update user set galaxycoin = galaxycoin + (${addGalaxycoin}) where id = #{id} and galaxycoin = #{originalGalaxycoin}")
     Integer updateGalaxycoin(@Param("id") Long id, @Param("originalGalaxycoin") BigDecimal originalGalaxycoin, @Param("addGalaxycoin") BigDecimal addGalaxycoin);

+ 10 - 6
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -910,8 +910,12 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		for (OrderDon orderDon : orderDonList) {
 			pay_money = pay_money.add(orderDon.getMoney());
 			real_money = real_money.add(orderDon.getRealMoney());
-			pay_balance = pay_balance.add(orderDon.getBalance());
-			pay_galaxycoin = pay_galaxycoin.add(orderDon.getGalaxycoin());
+			if (orderDon.getBalance() != null) {
+				pay_balance = pay_balance.add(orderDon.getBalance());
+			}
+			if (orderDon.getGalaxycoin() != null) {
+				pay_galaxycoin = pay_galaxycoin.add(orderDon.getGalaxycoin());
+			}
 			orderIds.add(orderDon.getId());
 		}
 		orderMasterDon.setMoney(pay_money);
@@ -919,6 +923,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		orderMasterDon.setUserId(userId);
 		orderMasterDon.setBalance(pay_balance);
 		orderMasterDon.setGalaxycoin(pay_galaxycoin);
+		//默认支付宝支付
+		orderMasterDon.setType(OrderMasterDon.Type.ALI_PAY);
 		orderMasterDonService.save(orderMasterDon);
 
 		orderDonMapper.update(null, Wrappers.lambdaUpdate(OrderDon.class)
@@ -2484,9 +2490,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				subGalaxycoin = money.multiply(BigDecimal.valueOf(100));
 				orderDon.setType(OrderDon.Type.GALAXYCOIN);
 			}
-			BigDecimal userGalaxycoin = user.getGalaxycoin();
 			//扣除余额 是否成功
-			Integer success = userMapper.deductGalaxycoin(user.getId(), subGalaxycoin, userGalaxycoin);
+			Integer success = userMapper.deductGalaxycoin(user.getId(), subGalaxycoin);
 			if (success != 1) throw BusinessRuntimeException.getInstance("您的银河币不足!");
 			orderDon.setGalaxycoin(subGalaxycoin);
 			userBenefitsService.recordGlaxycoinBySource(user.getId(), BigDecimal.valueOf(-galaxycoin.longValue()), UserGalaxycoinRecord.Source.payment);
@@ -2506,9 +2511,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				subBalance = money;
 				orderDon.setType(OrderDon.Type.BALANCE);
 			}
-			BigDecimal userBalance = user.getBalance();
 			//扣除余额 是否成功
-			Integer success = userMapper.deductBalance(user.getId(), subBalance, userBalance);
+			Integer success = userMapper.deductBalance(user.getId(), subBalance);
 			if (success != 1) throw BusinessRuntimeException.getInstance("您的余额不足!");
 			orderDon.setBalance(subBalance);
 			userBenefitsService.recordBalanceBySource(user.getId(), BigDecimal.valueOf(-subBalance.longValue()), UserBalanceSourceRecord.Source.payment);