霸王餐 金额问题
This commit is contained in:
parent
bd36647379
commit
c0eda91329
|
|
@ -4,6 +4,7 @@ import com.mybatisflex.annotation.Column;
|
||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
import com.mybatisflex.annotation.KeyType;
|
import com.mybatisflex.annotation.KeyType;
|
||||||
import com.mybatisflex.annotation.Table;
|
import com.mybatisflex.annotation.Table;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
@ -88,4 +89,7 @@ public class FreeDineConfig implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String childShopIdList;
|
private String childShopIdList;
|
||||||
|
|
||||||
|
public Integer getMultiple() {
|
||||||
|
return rechargeTimes == null ? 2 : rechargeTimes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,8 @@ public class PayServiceImpl implements PayService {
|
||||||
private ShopCouponService couponService;
|
private ShopCouponService couponService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private MemberPointsService pointsService;
|
private MemberPointsService pointsService;
|
||||||
|
@DubboReference
|
||||||
|
private FreeDineConfigService freeConfigService;
|
||||||
@Resource
|
@Resource
|
||||||
private CzgPayService czgPayService;
|
private CzgPayService czgPayService;
|
||||||
@Resource
|
@Resource
|
||||||
|
|
@ -146,6 +148,11 @@ public class PayServiceImpl implements PayService {
|
||||||
throw new ValidateException("充值金额不正确");
|
throw new ValidateException("充值金额不正确");
|
||||||
}
|
}
|
||||||
if (payParam.getOrderId() != null) {
|
if (payParam.getOrderId() != null) {
|
||||||
|
FreeDineConfig freeConfig = freeConfigService.getById(payParam.getShopId());
|
||||||
|
AssertUtil.isNull(freeConfig, "该店铺未启用霸王餐");
|
||||||
|
if (!freeConfig.getEnable()) {
|
||||||
|
throw new CzgException("该店铺未启用霸王餐");
|
||||||
|
}
|
||||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||||
//获取商品信息 计算金额 需要传入优惠券 减去优惠券
|
//获取商品信息 计算金额 需要传入优惠券 减去优惠券
|
||||||
|
|
@ -155,7 +162,12 @@ public class PayServiceImpl implements PayService {
|
||||||
//最终打包费
|
//最终打包费
|
||||||
BigDecimalDTO packAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
BigDecimalDTO packAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
||||||
orderInfoService.processOrderDetails2(orderDetails, null, null, totalAmount, packAmount, payParam.isAllPack(), null, true);
|
orderInfoService.processOrderDetails2(orderDetails, null, null, totalAmount, packAmount, payParam.isAllPack(), null, true);
|
||||||
BigDecimal payAmount = (totalAmount.getPrice().add(packAmount.getPrice())).multiply(BigDecimal.TWO);
|
BigDecimal total = totalAmount.getPrice().add(packAmount.getPrice());
|
||||||
|
if (total.compareTo(freeConfig.getRechargeThreshold()) < 0) {
|
||||||
|
throw new CzgException("霸王餐满" + freeConfig.getRechargeThreshold() + "可用,当前订单金额为" + total);
|
||||||
|
}
|
||||||
|
BigDecimal payAmount = (totalAmount.getPrice().add(packAmount.getPrice())).multiply(new BigDecimal(freeConfig.getMultiple()));
|
||||||
|
log.info("霸王餐应支付金额:{},充值金额为:{}", payAmount, payParam.getAmount());
|
||||||
if (payAmount.compareTo(payParam.getAmount()) != 0) {
|
if (payAmount.compareTo(payParam.getAmount()) != 0) {
|
||||||
throw new ValidateException("霸王餐支付金额不正确");
|
throw new ValidateException("霸王餐支付金额不正确");
|
||||||
}
|
}
|
||||||
|
|
@ -340,7 +352,6 @@ public class PayServiceImpl implements PayService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public CzgResult<Object> cashPayVip(VipPayParamDTO payParam) {
|
public CzgResult<Object> cashPayVip(VipPayParamDTO payParam) {
|
||||||
boolean isFree = checkPayVip(payParam);
|
|
||||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||||
ShopInfo shopInfo = shopInfoService.getById(payParam.getShopId());
|
ShopInfo shopInfo = shopInfoService.getById(payParam.getShopId());
|
||||||
|
|
@ -359,11 +370,6 @@ public class PayServiceImpl implements PayService {
|
||||||
updateInfo.setJoinTime(LocalDateTime.now());
|
updateInfo.setJoinTime(LocalDateTime.now());
|
||||||
updateInfo.setId(payParam.getShopUserId());
|
updateInfo.setId(payParam.getShopUserId());
|
||||||
shopUserService.updateById(updateInfo);
|
shopUserService.updateById(updateInfo);
|
||||||
// UpdateChain.of(ShopUser.class)
|
|
||||||
// .set(ShopUser::getIsVip, 1)
|
|
||||||
// .set(ShopUser::getJoinTime, LocalDateTime.now())
|
|
||||||
// .eq(ShopUser::getId, payParam.getShopUserId())
|
|
||||||
// .update();
|
|
||||||
}
|
}
|
||||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||||
.setId(shopUser.getId())
|
.setId(shopUser.getId())
|
||||||
|
|
@ -371,20 +377,10 @@ public class PayServiceImpl implements PayService {
|
||||||
.setType(1)
|
.setType(1)
|
||||||
.setRemark("现金充值")
|
.setRemark("现金充值")
|
||||||
.setBizEnum(ShopUserFlowBizEnum.CASH_IN);
|
.setBizEnum(ShopUserFlowBizEnum.CASH_IN);
|
||||||
if (isFree) {
|
|
||||||
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.FREE_IN);
|
|
||||||
UpdateChain.of(OrderInfo.class).eq(OrderInfo::getId, payParam.getOrderId())
|
|
||||||
.set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
|
|
||||||
.set(OrderInfo::getIsFreeDine, 1)
|
|
||||||
.set(OrderInfo::getPayAmount, 0)
|
|
||||||
.update();
|
|
||||||
}
|
|
||||||
//更新会员余额 并生成流水
|
//更新会员余额 并生成流水
|
||||||
Long flowId = shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
|
Long flowId = shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
|
||||||
if (!isFree) {
|
|
||||||
//会员活动
|
//会员活动
|
||||||
shopActivateService.giveActivate(shopUser, payParam.getAmount(), payParam.getActivateId(), flowId);
|
shopActivateService.giveActivate(shopUser, payParam.getAmount(), payParam.getActivateId(), flowId);
|
||||||
}
|
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -567,7 +563,7 @@ public class PayServiceImpl implements PayService {
|
||||||
isPay = false;
|
isPay = false;
|
||||||
refPayOrderNo = "";
|
refPayOrderNo = "";
|
||||||
}
|
}
|
||||||
if(isPay){
|
if (isPay) {
|
||||||
if (shopInfo.getIsReturnPwd().equals(1)) {
|
if (shopInfo.getIsReturnPwd().equals(1)) {
|
||||||
AssertUtil.isBlank(shopInfo.getOperationPwd(), "请设置操作密码后使用");
|
AssertUtil.isBlank(shopInfo.getOperationPwd(), "请设置操作密码后使用");
|
||||||
if (!SecureUtil.md5(param.getPwd()).equals(shopInfo.getOperationPwd())) {
|
if (!SecureUtil.md5(param.getPwd()).equals(shopInfo.getOperationPwd())) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue