Merge remote-tracking branch 'origin/prod' into prod
This commit is contained in:
@@ -3,7 +3,10 @@ package com.czg.controller.user;
|
||||
import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
||||
import com.czg.account.dto.shopuser.ShopUserDetailDTO;
|
||||
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
|
||||
import com.czg.account.entity.*;
|
||||
import com.czg.account.entity.MemberPointsLog;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.entity.ShopUserFlow;
|
||||
import com.czg.account.service.MemberPointsLogService;
|
||||
import com.czg.account.service.ShopUserFlowService;
|
||||
import com.czg.account.service.UShopUserService;
|
||||
@@ -16,7 +19,6 @@ import com.czg.sa.StpKit;
|
||||
import com.czg.utils.MyQueryWrapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryCondition;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
||||
import com.czg.account.dto.shopuser.ShopUserDetailDTO;
|
||||
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
|
||||
import com.czg.account.entity.MemberPointsLog;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.entity.ShopUserFlow;
|
||||
import com.czg.account.service.MemberPointsLogService;
|
||||
import com.czg.account.service.PointsExchangeRecordService;
|
||||
import com.czg.account.service.ShopUserFlowService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
||||
import com.czg.market.service.MkShopConsumeDiscountRecordService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 新客立减相关
|
||||
|
||||
@@ -13,9 +13,9 @@ import com.czg.system.enums.SysParamCodeEnum;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.NonNull;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -142,17 +142,17 @@ public class OrderPayController {
|
||||
/**
|
||||
* 获取店铺订单支付URL
|
||||
*/
|
||||
@GetMapping("/shopPayApi/orderPayUrl")
|
||||
@PostMapping("/shopPayApi/orderPayUrl")
|
||||
@Debounce(value = "#checkOrderPay.orderId")
|
||||
public CzgResult<String> getOrderPayUrl(@RequestHeader Long shopId, @RequestParam(required = false) String extend,
|
||||
CheckOrderPay checkOrderPay) {
|
||||
public CzgResult<String> getOrderPayUrl(@RequestHeader Long shopId,
|
||||
@RequestBody CheckOrderPay checkOrderPay) {
|
||||
AssertUtil.isNull(shopId, "店铺id不能为空");
|
||||
AssertUtil.isNull(checkOrderPay, "订单信息不能为空");
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("shopId", shopId);
|
||||
map.put("orderId", checkOrderPay.getOrderId());
|
||||
map.put("payAmount", checkOrderPay.getOrderAmount());
|
||||
map.put("extend", StrUtil.isEmpty(extend) ? "" : extend);
|
||||
map.put("extend", StrUtil.isEmpty(checkOrderPay.getExtend()) ? "" : checkOrderPay.getExtend());
|
||||
if (checkOrderPay.getOrderId() != null) {
|
||||
OrderInfo orderInfo = orderInfoService.checkOrderPay(checkOrderPay);
|
||||
map.put("payAmount", orderInfo.getOrderAmount());
|
||||
@@ -181,7 +181,7 @@ public class OrderPayController {
|
||||
@GetMapping("/queryOrderStatus")
|
||||
public CzgResult<String> queryOrderStatus(Long orderId) {
|
||||
CzgResult<String> result = CzgResult.success();
|
||||
String status = orderInfoService.queryChain().select(OrderInfo::getStatus).eq(OrderInfo::getId, orderId).oneAs(String.class);
|
||||
String status = orderInfoService.getOneAs(QueryWrapper.create().select(OrderInfo::getStatus).eq(OrderInfo::getId, orderId), String.class);
|
||||
result.setData(status);
|
||||
switch (status) {
|
||||
case "unpaid" -> result.setMsg("等待用户付款");
|
||||
|
||||
@@ -17,7 +17,7 @@ public class MybatisFlexConfig {
|
||||
//设置 SQL 审计收集器
|
||||
AuditManager.setMessageCollector(auditMessage ->
|
||||
log.info("[sql] time: {}, size: {},\n sql:{}",
|
||||
auditMessage.getQueryTime(), auditMessage.getQueryCount(), auditMessage.getFullSql())
|
||||
auditMessage.getElapsedTime(), auditMessage.getQueryCount(), auditMessage.getFullSql())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,14 @@ public class CzgControllerAdvice {
|
||||
return CzgResult.failure(ex.getCode(), ex.getMsg());
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(OrderValidateException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public CzgResult<Object> handleOrderValidateException(OrderValidateException ex) {
|
||||
log.error("订单校验异常:{}", ex.getMessage());
|
||||
return CzgResult.failure(ex.getCode(), ex.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付成功
|
||||
* 支付金额为零的统一处理
|
||||
@@ -127,7 +135,7 @@ public class CzgControllerAdvice {
|
||||
*/
|
||||
@ExceptionHandler(OrderCancelException.class)
|
||||
public CzgResult<Object> handleOrderCancelException() {
|
||||
return CzgResult.failure(701,"订单已过期,请重新下单");
|
||||
return CzgResult.failure(701, "订单已过期,请重新下单");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,6 +163,6 @@ public class CzgControllerAdvice {
|
||||
|
||||
private void setErrorLog(Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
log.error("错误",ex);
|
||||
log.error("错误", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
|
||||
/**
|
||||
* 台桌订单统计表 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-03-03
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_table_order_statistic")
|
||||
public class ShopTableOrderStatistic implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
private Long tableId;
|
||||
|
||||
@Column(ignore = true)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 订单数量
|
||||
*/
|
||||
private Long orderCount;
|
||||
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
private BigDecimal orderAmount;
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private Long refundCount;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 创建日期 年月日
|
||||
*/
|
||||
private Date createDay;
|
||||
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class SmsPushEvent implements Serializable {
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 0待发送 1 发送中 2发送成功 -1失败
|
||||
* 0待发送 1 发送中 2发送完成 -1失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ public class CheckOrderPay implements Serializable {
|
||||
|
||||
private String remark;
|
||||
|
||||
private String extend;
|
||||
|
||||
|
||||
public Integer getSeatNum() {
|
||||
return seatNum == null ? 0 : seatNum;
|
||||
@@ -138,7 +140,7 @@ public class CheckOrderPay implements Serializable {
|
||||
return newCustomerDiscountAmount == null ? BigDecimal.ZERO : newCustomerDiscountAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 满减活动抵扣金额
|
||||
*/
|
||||
public BigDecimal getDiscountActAmount() {
|
||||
@@ -165,7 +167,7 @@ public class CheckOrderPay implements Serializable {
|
||||
return roundAmount == null ? BigDecimal.ZERO : roundAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getVipDiscountAmount(){
|
||||
public BigDecimal getVipDiscountAmount() {
|
||||
return vipDiscountAmount == null ? BigDecimal.ZERO : vipDiscountAmount;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.czg.exception;
|
||||
|
||||
import com.czg.resp.CzgRespCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
public class OrderValidateException extends RuntimeException{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
public OrderValidateException(String msg) {
|
||||
super(msg);
|
||||
this.code = CzgRespCode.FAILURE.getCode();
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopTableOrderStatistic;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 台桌订单统计表 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-03-03
|
||||
*/
|
||||
public interface ShopTableOrderStatisticMapper extends BaseMapper<ShopTableOrderStatistic> {
|
||||
|
||||
List<ShopTableOrderStatistic> selectSummary(@Param("shopId") Long shopId, @Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
|
||||
boolean incrInfo(@Param("shopId") long shopId, @Param("tableId") long tableId, @Param("count") long count, @Param("amount") BigDecimal amount, @Param("date") String date);
|
||||
}
|
||||
@@ -5,9 +5,7 @@ import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.czg.account.entity.ShopUserFlow;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserFlowService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.vo.ShopUserFlowVO;
|
||||
import com.czg.account.vo.SysUserDetailVO;
|
||||
import com.czg.service.account.mapper.ShopUserFlowMapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.exception.OrderCancelException;
|
||||
import com.czg.exception.OrderValidateException;
|
||||
import com.czg.market.dto.MkDiscountActivityDTO;
|
||||
import com.czg.market.entity.MkDiscountThreshold;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
@@ -342,17 +343,17 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
||||
AssertUtil.isNull(shopInfo, "生成订单失败,店铺信息不存在");
|
||||
if (param.isVipPrice() && !shopInfo.getIsMemberPrice().equals(1)) {
|
||||
throw new ValidateException("生成订单失败,该店铺不支持使用会员价");
|
||||
throw new OrderValidateException("生成订单失败,该店铺不支持使用会员价");
|
||||
}
|
||||
if (param.getOrderAmount().compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new ValidateException("生成订单失败,订单金额不能小于0");
|
||||
throw new OrderValidateException("生成订单失败,订单金额不能小于0");
|
||||
}
|
||||
log.info("订单信息:{},优惠信息:{}", JSONObject.toJSONString(orderInfo), JSONObject.toJSONString(param));
|
||||
Long shopId = orderInfo.getShopId();
|
||||
AssertUtil.isNull(shopId, "生成支付订单失败,订单信息异常");
|
||||
//霸王餐不参与满减
|
||||
if (param.isFreeDine() && param.getDiscountActId() != null) {
|
||||
throw new ValidateException("生成订单失败,霸王餐不能享受满减活动");
|
||||
throw new OrderValidateException("生成订单失败,霸王餐不能享受满减活动");
|
||||
}
|
||||
MkDiscountActivityDTO discountAct = null;
|
||||
// 满减活动校验
|
||||
@@ -368,30 +369,30 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
boolean usePointsDeduction = param.getPointsNum() > 0 || param.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0;
|
||||
if (usePointsDeduction) {
|
||||
if (pointSetting == null || !pointSetting.getEnableDeduction().equals(1)) {
|
||||
throw new ValidateException("生成支付订单失败,该店铺未开启积分抵扣");
|
||||
throw new OrderValidateException("生成支付订单失败,该店铺未开启积分抵扣");
|
||||
}
|
||||
if (param.getUserId() == null) {
|
||||
throw new ValidateException("生成支付订单失败,请选择用户后再使用积分抵扣");
|
||||
throw new OrderValidateException("生成支付订单失败,请选择用户后再使用积分抵扣");
|
||||
}
|
||||
//霸王餐
|
||||
if (param.isFreeDine() && !param.isWithPoints()) {
|
||||
throw new ValidateException("生成支付订单失败,霸王餐不支持积分抵扣");
|
||||
throw new OrderValidateException("生成支付订单失败,霸王餐不支持积分抵扣");
|
||||
}
|
||||
} else {
|
||||
if (param.getPointsNum() != 0 || param.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) != 0) {
|
||||
throw new ValidateException("生成支付订单失败,积分抵扣数量或金额不正确");
|
||||
throw new OrderValidateException("生成支付订单失败,积分抵扣数量或金额不正确");
|
||||
}
|
||||
}
|
||||
|
||||
if (param.getPointsNum() > 0 && (!param.isFreeDine() || param.isWithPoints())) {
|
||||
if (pointSetting == null || !pointSetting.getEnableDeduction().equals(1)) {
|
||||
throw new ValidateException("生成支付订单失败,该店铺未开启积分抵扣");
|
||||
throw new OrderValidateException("生成支付订单失败,该店铺未开启积分抵扣");
|
||||
}
|
||||
if (param.getUserId() == null) {
|
||||
throw new ValidateException("生成支付订单失败,请选择用户后再使用积分抵扣");
|
||||
throw new OrderValidateException("生成支付订单失败,请选择用户后再使用积分抵扣");
|
||||
}
|
||||
} else if (param.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
throw new ValidateException("生成支付订单失败,已使用积分抵扣,积分数量不正确");
|
||||
throw new OrderValidateException("生成支付订单失败,已使用积分抵扣,积分数量不正确");
|
||||
}
|
||||
ShopUser shopUser = null;
|
||||
if (param.getUserId() != null) {
|
||||
@@ -399,14 +400,14 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
AssertUtil.isNull(userInfo, "生成支付订单失败,用户信息不存在");
|
||||
shopUser = shopUserService.getShopUserInfo(shopId, param.getUserId());
|
||||
if (param.getPointsNum() > 0 && !shopUser.getIsVip().equals(1) && pointSetting.getDeductionGroup().contains("vip")) {
|
||||
throw new ValidateException("生成支付订单失败,该店铺仅会员可使用积分抵扣");
|
||||
throw new OrderValidateException("生成支付订单失败,该店铺仅会员可使用积分抵扣");
|
||||
}
|
||||
orderInfo.setUserId(userInfo.getId());
|
||||
}
|
||||
//会员价校验
|
||||
if (param.isVipPrice() && (shopUser == null || shopUser.getIsMemberPrice() == null
|
||||
|| shopUser.getIsMemberPrice() == 0 || shopUser.getIsVip().equals(0))) {
|
||||
throw new ValidateException("生成支付订单失败,仅会员可使用会员价");
|
||||
throw new OrderValidateException("生成支付订单失败,仅会员可使用会员价");
|
||||
}
|
||||
|
||||
List<OrderDetail> orderDetails = orderDetailService.queryChain().eq(OrderDetail::getOrderId, param.getOrderId()).select().list();
|
||||
@@ -430,7 +431,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
param.isAllPack(), param.getUserAllPack(), param.isVipPrice());
|
||||
if (totalAmount.getPrice().compareTo(param.getOriginAmount()) != 0) {
|
||||
log.info("订单原价不正确:订单原价:{},传递为:{}", totalAmount.getPrice(), param.getOriginAmount());
|
||||
throw new ValidateException("生成支付订单失败,订单原金额不正确");
|
||||
throw new OrderValidateException("生成支付订单失败,订单原金额不正确");
|
||||
}
|
||||
|
||||
//优惠券部分 目前规则 每个券只能用一张
|
||||
@@ -450,7 +451,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
if (param.getOriginAmount().subtract(param.getProductCouponDiscountAmount()).subtract(param.getOtherCouponDiscountAmount()).compareTo(newTotalAmount) != 0) {
|
||||
log.info("其它优惠券金额不正确:满减金额为:{},折扣金额为:{},买一赠一金额为:{},第二件半价券金额为:{} 传递为:{}",
|
||||
fullReductionAmount.getPrice(), rateAmount.getPrice(), oneGiftAmount.getPrice(), twoHalfAmount.getPrice(), param.getOtherCouponDiscountAmount());
|
||||
throw new ValidateException("生成支付订单失败,其它优惠券金额不正确");
|
||||
throw new OrderValidateException("生成支付订单失败,其它优惠券金额不正确");
|
||||
}
|
||||
if (newTotalAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
newTotalAmount = BigDecimal.ZERO;
|
||||
@@ -477,7 +478,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
BigDecimal discountActAmount = calculateDiscountActAmount(orderDetails, discountAct, packAmount.getPrice(), orderInfo.getSeatAmount());
|
||||
if (discountActAmount.compareTo(param.getDiscountActAmount()) != 0) {
|
||||
log.info("满减活动金额不正确:传递为:{},计算为:{}", param.getDiscountActAmount(), discountActAmount);
|
||||
throw new ValidateException("生成支付订单失败,满减活动金额不正确");
|
||||
throw new OrderValidateException("生成支付订单失败,满减活动金额不正确");
|
||||
}
|
||||
newTotalAmount = newTotalAmount.subtract(discountActAmount);
|
||||
|
||||
@@ -491,7 +492,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
discountAmount = discountAmount.setScale(2, RoundingMode.HALF_UP);
|
||||
if (discountAmount.compareTo(param.getVipDiscountAmount()) != 0) {
|
||||
log.info("会员整单折扣金额不正确:传递为:{},计算为:{}", param.getVipDiscountAmount(), discountAmount);
|
||||
throw new ValidateException("生成支付订单失败,会员整单折扣金额不正确");
|
||||
throw new OrderValidateException("生成支付订单失败,会员整单折扣金额不正确");
|
||||
}
|
||||
newTotalAmount = newTotalAmount.subtract(discountAmount);
|
||||
}
|
||||
@@ -499,14 +500,14 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
//积分抵扣 金额范围校验 抵扣金额校验
|
||||
if (param.getPointsNum() > 0) {
|
||||
if (pointSetting.getMinPaymentAmount().compareTo(newTotalAmount) > 0) {
|
||||
throw new ValidateException("生成支付订单失败,未满足积分抵扣最低门槛");
|
||||
throw new OrderValidateException("生成支付订单失败,未满足积分抵扣最低门槛");
|
||||
}
|
||||
if (pointSetting.getMaxDeductionRatio().multiply(newTotalAmount).compareTo(param.getPointsDiscountAmount()) < 0) {
|
||||
throw new ValidateException("生成支付订单失败,积分抵扣金额已超出最大抵扣金额");
|
||||
throw new OrderValidateException("生成支付订单失败,积分抵扣金额已超出最大抵扣金额");
|
||||
}
|
||||
BigDecimal pointAmount = new BigDecimal(param.getPointsNum()).divide(new BigDecimal(pointSetting.getEquivalentPoints()), 2, RoundingMode.DOWN);
|
||||
if (pointAmount.compareTo(param.getPointsDiscountAmount()) != 0) {
|
||||
throw new ValidateException("生成支付订单失败,积分抵扣金额不正确");
|
||||
throw new OrderValidateException("生成支付订单失败,积分抵扣金额不正确");
|
||||
}
|
||||
newTotalAmount = newTotalAmount.subtract(param.getPointsDiscountAmount());
|
||||
}
|
||||
@@ -529,7 +530,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
orderInfo.getId(), newTotalAmount, totalAmount.getPrice(), tempAmount.getPrice(), packAmount.getPrice(), orderInfo.getSeatAmount(),
|
||||
param.getOrderAmount(), param.getProductCouponDiscountAmount(), param.getOtherCouponDiscountAmount(), param.getNewCustomerDiscountAmount(),
|
||||
discountActAmount, param.getDiscountAmount(), param.getPointsDiscountAmount(), param.getRoundAmount());
|
||||
throw new ValidateException("生成支付订单失败,支付金额不正确");
|
||||
throw new OrderValidateException("生成支付订单失败,支付金额不正确");
|
||||
}
|
||||
orderInfo.setPackFee(packAmount.getPrice());
|
||||
//生成订单 //discount_info 所有折扣 几折 折扣金额 满减金额 优惠券金额 积分抵扣金额 抹零
|
||||
@@ -607,7 +608,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
couponRecordQuery.ne(MkShopCouponRecord::getIsDel, 1);
|
||||
List<MkShopCouponRecord> list = couponRecordService.list(couponRecordQuery);
|
||||
if (CollUtil.isEmpty(list) || param.getCouponList().size() > list.size()) {
|
||||
throw new ValidateException("生成支付订单失败,优惠券不可用");
|
||||
throw new OrderValidateException("生成支付订单失败,优惠券不可用");
|
||||
}
|
||||
Map<Integer, MkShopCouponRecord> couponRecordMap = list.stream().collect(Collectors.toMap(MkShopCouponRecord::getType, t -> t));
|
||||
AtomicBoolean otherCouponShare = new AtomicBoolean(true);
|
||||
@@ -636,7 +637,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
"price_asc".equals(coupon.getUseRule()), prodCouponAmount);
|
||||
} else if (type == 4 || type == 6) {//4-第二件半价券, 6-买一送一券
|
||||
if (!otherCouponShare.get()) {
|
||||
throw new ValidateException("生成支付订单失败,商品券与其它券不可共用");
|
||||
throw new OrderValidateException("生成支付订单失败,商品券与其它券不可共用");
|
||||
}
|
||||
boolean isAllFoods = true;
|
||||
List<Long> couponFoodIds = new ArrayList<>();
|
||||
@@ -653,7 +654,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
}
|
||||
} else if (type == 1 || type == 3) {//1-满减券 3-折扣券
|
||||
if (!otherCouponShare.get()) {
|
||||
throw new ValidateException("生成支付订单失败,商品券与其它券不可共用");
|
||||
throw new OrderValidateException("生成支付订单失败,商品券与其它券不可共用");
|
||||
}
|
||||
//计算门槛
|
||||
boolean isAllFoods = true;
|
||||
@@ -681,7 +682,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
}
|
||||
if (prodCouponAmount.getPrice().compareTo(param.getProductCouponDiscountAmount()) != 0) {
|
||||
log.info("支付计算金额不正确:商品券抵扣金额为:{},传递为:{}", prodCouponAmount.getPrice(), param.getProductCouponDiscountAmount());
|
||||
throw new ValidateException("生成支付订单失败,商品优惠券优惠金额不正确");
|
||||
throw new OrderValidateException("生成支付订单失败,商品优惠券优惠金额不正确");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -939,10 +940,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
} else {
|
||||
if (orderDetail.getIsTimeDiscount() == 1) {
|
||||
if (limitRate == null || (limitRate.getFoodType() == 2 && CollUtil.isEmpty(limitRate.getFoodIds()))) {
|
||||
throw new CzgException("限时折扣使用失败,商品范围不正确");
|
||||
throw new OrderValidateException("限时折扣使用失败,商品范围不正确");
|
||||
}
|
||||
if (limitRate.getFoodType() == 2 && !limitRate.getFoodIds().contains(orderDetail.getProductId())) {
|
||||
throw new CzgException("限时折扣使用失败,商品" + orderDetail.getProductName() + "不享受限时折扣");
|
||||
throw new OrderValidateException("限时折扣使用失败,商品" + orderDetail.getProductName() + "不享受限时折扣");
|
||||
}
|
||||
if (orderDetail.getPrice().compareTo(BigDecimal.ZERO) == 0) {
|
||||
orderDetail.setUnitPrice(orderDetail.getPrice());
|
||||
|
||||
Reference in New Issue
Block a user