Merge branch 'dev' into prod
This commit is contained in:
@@ -20,7 +20,6 @@ import com.czg.entity.notify.CzgPayNotifyDTO;
|
||||
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
||||
import com.czg.enums.ShopTableStatusEnum;
|
||||
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;
|
||||
@@ -222,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) {
|
||||
@@ -268,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());
|
||||
@@ -546,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())
|
||||
@@ -579,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())
|
||||
@@ -700,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);
|
||||
@@ -720,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() + " 已达到今日使用限量");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -730,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())) {
|
||||
// 获取当前时间(仅包含时分秒)
|
||||
@@ -739,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() + " 当前时段不可用");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -785,7 +784,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
}
|
||||
}
|
||||
if (calculationAmount.compareTo(fullAmount) < 0) {
|
||||
throw new ValidateException("生成支付订单失败," + title + "优惠券门槛金额不足");
|
||||
throw new CzgException("生成支付订单失败," + title + "优惠券门槛金额不足");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,7 +890,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
}
|
||||
}
|
||||
if (foodsAmount.compareTo(thresholdAmount) < 0) {
|
||||
throw new ValidateException("优惠券未达到门槛金额");
|
||||
throw new CzgException("优惠券未达到门槛金额");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1391,12 +1390,12 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
/**
|
||||
* 初始化订单信息
|
||||
*/
|
||||
private OrderInfo initOrderInfo(OrderInfoAddDTO param, ShopInfo shopInfo, ShopTable table) {
|
||||
private OrderInfo initOrderInfo(OrderInfoAddDTO param, ShopInfo shopInfo, ShopTable table) throws CzgException {
|
||||
OrderInfo orderInfo = new 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());
|
||||
@@ -1560,7 +1559,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
public Boolean printOrder(Long shopId, OrderInfoPrintDTO orderInfoPrintDTO) {
|
||||
OrderInfo orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getId, orderInfoPrintDTO.getId()));
|
||||
if (orderInfo == null) {
|
||||
throw new ApiNotPrintException("订单信息不存在");
|
||||
throw new CzgException("订单信息不存在");
|
||||
}
|
||||
|
||||
switch (orderInfoPrintDTO.getType()) {
|
||||
@@ -1582,23 +1581,23 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
public Boolean removeOrderDetail(Long shopId, Long orderId, Long detailId) {
|
||||
OrderInfo orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getId, orderId).eq(OrderInfo::getShopId, shopId));
|
||||
if (orderInfo == null) {
|
||||
throw new ApiNotPrintException("订单不存在");
|
||||
throw new CzgException("订单不存在");
|
||||
}
|
||||
|
||||
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
|
||||
throw new ApiNotPrintException("订单不处于待支付状态");
|
||||
throw new CzgException("订单不处于待支付状态");
|
||||
}
|
||||
|
||||
OrderDetail orderDetail = orderDetailService.getOne(new QueryWrapper().eq(OrderDetail::getId, detailId).eq(OrderDetail::getOrderId, orderId));
|
||||
if (orderDetail == null || !orderDetail.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
||||
throw new ApiNotPrintException("不处于待支付或订单详情不存在");
|
||||
throw new CzgException("不处于待支付或订单详情不存在");
|
||||
}
|
||||
|
||||
int i = mapper.decrMoney(orderInfo.getId(), orderDetail.getPayAmount().add(orderDetail.getPackAmount()));
|
||||
if (i > 0) {
|
||||
return orderDetailService.removeById(orderDetail.getId());
|
||||
}
|
||||
throw new ApiNotPrintException("操作失败");
|
||||
throw new CzgException("操作失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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