参数校验
This commit is contained in:
@@ -3,6 +3,7 @@ package com.czg.service.market.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkCouponGiftDTO;
|
||||
import com.czg.market.dto.MkShopConsumerCouponDTO;
|
||||
import com.czg.market.dto.MkShopCouponGiftDTO;
|
||||
@@ -115,7 +116,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
||||
@Transactional
|
||||
public void addConsumerCoupon(MkShopConsumerCouponDTO param) {
|
||||
if (CollUtil.isEmpty(param.getCouponGiftList())) {
|
||||
throw new ValidateException("优惠券信息不能为空");
|
||||
throw new CzgException("优惠券信息不能为空");
|
||||
}
|
||||
MkShopConsumerCoupon bean = BeanUtil.toBean(param, MkShopConsumerCoupon.class);
|
||||
save(bean);
|
||||
@@ -132,7 +133,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
||||
param.setLeftNum(-10086);
|
||||
} else {
|
||||
if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||
} else {
|
||||
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
|
||||
}
|
||||
@@ -142,7 +143,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
||||
param.setLeftNum(-10086);
|
||||
} else {
|
||||
if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||
} else {
|
||||
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.vo.ShopInfoCouponVO;
|
||||
import com.czg.account.vo.UserCouponFoodVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkShopCouponGiftDTO;
|
||||
import com.czg.market.dto.ShopCouponDTO;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
@@ -191,7 +192,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
||||
if (tbShopCoupon.getGiveNum() == -10086) {
|
||||
if (param.getGiveNum() != -10086) {
|
||||
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||
} else {
|
||||
param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum());
|
||||
}
|
||||
@@ -201,7 +202,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
||||
param.setLeftNum(-10086);
|
||||
} else {
|
||||
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
|
||||
throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
|
||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||
} else {
|
||||
param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum());
|
||||
}
|
||||
|
||||
@@ -221,10 +221,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
@Override
|
||||
public HistoryOrderVo historyOrder(Long orderId, String tableCode) {
|
||||
if (orderId == null && StrUtil.isBlank(tableCode)) {
|
||||
throw new ValidateException("订单id或台桌码不可为空");
|
||||
throw new CzgException("订单id或台桌码不可为空");
|
||||
}
|
||||
if (orderId == null && ("null".equals(tableCode) || "undefined".equals(tableCode))) {
|
||||
throw new ValidateException("台桌码不可用");
|
||||
throw new CzgException("台桌码不可用");
|
||||
}
|
||||
HistoryOrderVo historyOrderVo;
|
||||
if (orderId == null) {
|
||||
@@ -267,7 +267,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
ShopInfo shopInfo = shopInfoService.getById(param.getShopId());
|
||||
AssertUtil.isNull(shopInfo, "生成订单失败,店铺信息不存在");
|
||||
if (!shopInfo.getEatModel().contains(param.getDineMode())) {
|
||||
throw new ValidateException("生成订单失败,店铺不支持该用餐模式");
|
||||
throw new CzgException("生成订单失败,店铺不支持该用餐模式");
|
||||
}
|
||||
if (param.getUserId() != null) {
|
||||
UserInfo userInfo = userInfoService.getById(param.getUserId());
|
||||
@@ -545,11 +545,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
@Override
|
||||
public CzgResult<Object> mergeOrder(MergeOrderDTO param) {
|
||||
if (param.getTargetOrderId() == null && StrUtil.isBlank(param.getTargetTableCode())) {
|
||||
throw new ValidateException("转台失败,请选择目标台桌后转台");
|
||||
throw new CzgException("转台失败,请选择目标台桌后转台");
|
||||
}
|
||||
OrderInfo sourceOrder = getById(param.getSourceOrderId());
|
||||
if (sourceOrder == null || !sourceOrder.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
||||
throw new ValidateException("转台失败,无可转订单");
|
||||
throw new CzgException("转台失败,无可转订单");
|
||||
}
|
||||
OrderInfo targetOrder = queryChain()
|
||||
.eq(OrderInfo::getId, param.getTargetOrderId())
|
||||
@@ -578,7 +578,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
if (CollUtil.isEmpty(param.getDetailIds())) {
|
||||
long count = orderDetailService.queryChain().eq(OrderDetail::getOrderId, sourceOrder.getId()).count();
|
||||
if (count < 1) {
|
||||
throw new ValidateException("转台失败,该订单无可转商品");
|
||||
throw new CzgException("转台失败,该订单无可转商品");
|
||||
}
|
||||
orderDetailService.updateChain()
|
||||
.eq(OrderDetail::getOrderId, sourceOrder.getId())
|
||||
@@ -699,7 +699,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
ShopCoupon coupon = couponService.getById(record.getCouponId());
|
||||
AssertUtil.isNull(coupon, "生成支付订单失败,券信息不存在");
|
||||
// if (isVipPrice && coupon.getVipPriceShare() != 1) {
|
||||
// throw new ValidateException("生成支付订单失败,券:" + coupon.getTitle() + "与会员价不共享");
|
||||
// throw new CzgException("生成支付订单失败,券:" + coupon.getTitle() + "与会员价不共享");
|
||||
// }
|
||||
isUseLimit(coupon, record);
|
||||
// isUseTime(coupon);
|
||||
@@ -719,7 +719,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
.between(MkShopCouponRecord::getUseTime, LocalDateTime.now().with(LocalTime.MIN), LocalDateTime.now().with(LocalTime.MAX))
|
||||
);
|
||||
if (useNum >= coupon.getUseLimit()) {
|
||||
throw new ValidateException("优惠券:" + coupon.getTitle() + " 已达到今日使用限量");
|
||||
throw new CzgException("优惠券:" + coupon.getTitle() + " 已达到今日使用限量");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -729,7 +729,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
*/
|
||||
private void isUseTime(ShopCoupon coupon) {
|
||||
if (!coupon.getUseDays().contains(CzgStrUtils.getStrWeek())) {
|
||||
throw new ValidateException("生成支付订单失败," + coupon.getTitle() + " 今天不可用");
|
||||
throw new CzgException("生成支付订单失败," + coupon.getTitle() + " 今天不可用");
|
||||
}
|
||||
if (!"all".equals(coupon.getUseTimeType())) {
|
||||
// 获取当前时间(仅包含时分秒)
|
||||
@@ -738,13 +738,13 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
LocalTime endTime = coupon.getUseEndTime().toLocalTime();
|
||||
if (currentTime.isBefore(startTime)) {
|
||||
if (startTime.isBefore(endTime)) {
|
||||
throw new ValidateException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用");
|
||||
throw new CzgException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用");
|
||||
} else if (currentTime.isAfter(endTime)) {
|
||||
throw new ValidateException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用");
|
||||
throw new CzgException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用");
|
||||
}
|
||||
} else if (startTime.isBefore(endTime)) {
|
||||
if (currentTime.isAfter(endTime)) {
|
||||
throw new ValidateException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用");
|
||||
throw new CzgException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -784,7 +784,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
}
|
||||
}
|
||||
if (calculationAmount.compareTo(fullAmount) < 0) {
|
||||
throw new ValidateException("生成支付订单失败," + title + "优惠券门槛金额不足");
|
||||
throw new CzgException("生成支付订单失败," + title + "优惠券门槛金额不足");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,7 +890,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
}
|
||||
}
|
||||
if (foodsAmount.compareTo(thresholdAmount) < 0) {
|
||||
throw new ValidateException("优惠券未达到门槛金额");
|
||||
throw new CzgException("优惠券未达到门槛金额");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1393,7 +1393,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
if (param.getOrderId() != null) {
|
||||
orderInfo = getById(param.getOrderId());
|
||||
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
|
||||
throw new ValidateException("生成订单失败,订单已结束,请重新下单");
|
||||
throw new CzgException("生成订单失败,订单已结束,请重新下单");
|
||||
}
|
||||
} else {
|
||||
orderInfo.setOrderNo(param.getPlatformType() + IdUtil.getSnowflakeNextId());
|
||||
|
||||
@@ -140,7 +140,7 @@ public class PayServiceImpl implements PayService {
|
||||
private boolean checkPayVip(VipPayParamDTO payParam) {
|
||||
|
||||
if (payParam.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new ValidateException("充值金额不正确");
|
||||
throw new CzgException("充值金额不正确");
|
||||
}
|
||||
if (payParam.getOrderId() != null) {
|
||||
FreeDineConfig freeConfig = freeConfigService.getById(shopInfoService.getMainIdByShopId(payParam.getShopId()));
|
||||
@@ -691,7 +691,7 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
orderInfo.setRefundAmount(orderInfo.getRefundAmount().add(param.getRefundAmount()));
|
||||
if (orderInfo.getRefundAmount().compareTo(orderInfo.getPayAmount()) > 0) {
|
||||
throw new ValidateException("退单失败,可退金额不足");
|
||||
throw new CzgException("退单失败,可退金额不足");
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(param.getRefundDetails())) {
|
||||
@@ -703,7 +703,7 @@ public class PayServiceImpl implements PayService {
|
||||
//可退数量=订单数量-退单数量-退菜数量
|
||||
BigDecimal returnNum = orderDetail.getNum().subtract(orderDetail.getRefundNum()).subtract(orderDetail.getReturnNum());
|
||||
if (returnNum.compareTo(BigDecimal.ZERO) <= 0 || returnNum.compareTo(refundDetail.getNum()) < 0) {
|
||||
throw new ValidateException("退单失败," + orderDetail.getProductName() + "可退数量不足");
|
||||
throw new CzgException("退单失败," + orderDetail.getProductName() + "可退数量不足");
|
||||
}
|
||||
if (isPay) {
|
||||
orderDetail.setRefundNum(orderDetail.getRefundNum().add(refNum));
|
||||
@@ -916,7 +916,7 @@ public class PayServiceImpl implements PayService {
|
||||
//支付宝支付
|
||||
bizData.setSubAppid(shopMerchant.getAlipaySmallAppid());
|
||||
} else {
|
||||
throw new ValidateException("扫描码非法或暂不支持");
|
||||
throw new CzgException("扫描码非法或暂不支持");
|
||||
}
|
||||
CzgResult<CzgMicroPayResp> czgScanPayResult = czgPayService.microPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user