1.代客下单 支付折扣
This commit is contained in:
@@ -38,6 +38,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -350,14 +352,15 @@ public class TbPayServiceImpl implements TbPayService {
|
|||||||
throw new BadRequestException("用户不存在或已被禁用");
|
throw new BadRequestException("用户不存在或已被禁用");
|
||||||
}
|
}
|
||||||
|
|
||||||
long flag = shopUserMapper.decrBalance(Integer.valueOf(orderInfo.getUserId()), orderInfo.getOrderAmount());
|
BigDecimal finalAmount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(discount)).setScale(2, RoundingMode.UP);
|
||||||
|
long flag = shopUserMapper.decrBalance(Integer.valueOf(orderInfo.getUserId()), finalAmount);
|
||||||
if (flag < 1) {
|
if (flag < 1) {
|
||||||
throw new BadRequestException("余额不足或扣除余额失败");
|
throw new BadRequestException("余额不足或扣除余额失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
TbShopUserFlow userFlow = new TbShopUserFlow();
|
TbShopUserFlow userFlow = new TbShopUserFlow();
|
||||||
userFlow.setAmount(orderInfo.getOrderAmount());
|
userFlow.setAmount(finalAmount);
|
||||||
userFlow.setBalance(shopUser.getAmount());
|
userFlow.setBalance(shopUser.getAmount().subtract(finalAmount));
|
||||||
userFlow.setShopUserId(shopUser.getId());
|
userFlow.setShopUserId(shopUser.getId());
|
||||||
userFlow.setBizCode("vipCardCash");
|
userFlow.setBizCode("vipCardCash");
|
||||||
userFlow.setBizName("余额支付");
|
userFlow.setBizName("余额支付");
|
||||||
@@ -365,7 +368,7 @@ public class TbPayServiceImpl implements TbPayService {
|
|||||||
userFlow.setType("-");
|
userFlow.setType("-");
|
||||||
shopUserFlowMapper.insert(userFlow);
|
shopUserFlowMapper.insert(userFlow);
|
||||||
|
|
||||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
orderInfo.setPayAmount(finalAmount);
|
||||||
orderInfo.setPayType("cash");
|
orderInfo.setPayType("cash");
|
||||||
orderInfo.setStatus("closed");
|
orderInfo.setStatus("closed");
|
||||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||||
@@ -409,7 +412,7 @@ public class TbPayServiceImpl implements TbPayService {
|
|||||||
// return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
// return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
orderInfo.setPayAmount(orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount()).setScale(2, RoundingMode.UP)));
|
||||||
orderInfo.setPayType("cash");
|
orderInfo.setPayType("cash");
|
||||||
orderInfo.setStatus("closed");
|
orderInfo.setStatus("closed");
|
||||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||||
|
|||||||
Reference in New Issue
Block a user