Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -31,7 +31,7 @@ public class BirthdayGiftTask {
|
|||||||
/**
|
/**
|
||||||
* 生日有礼奖励发放
|
* 生日有礼奖励发放
|
||||||
*/
|
*/
|
||||||
// @Scheduled(cron = "0 0 12 * * ?")
|
@Scheduled(cron = "0 0 0 * * ?")
|
||||||
public void deliver() {
|
public void deliver() {
|
||||||
birthdayGiftService.deliver();
|
birthdayGiftService.deliver();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,21 +73,21 @@ public class MyStpLogic {
|
|||||||
public void switchTo(boolean isMain, Long id, String account, Long shopId, String shopName, LoginType loginType, boolean isAdmin) {
|
public void switchTo(boolean isMain, Long id, String account, Long shopId, String shopName, LoginType loginType, boolean isAdmin) {
|
||||||
StpLogic logic = getLogic();
|
StpLogic logic = getLogic();
|
||||||
long headId = logic.getLoginIdAsLong();
|
long headId = logic.getLoginIdAsLong();
|
||||||
|
// 设置主店id
|
||||||
logic.getSaTokenDao().set(splicingKeyTokenValue(logic.getTokenValue()), id.toString(), logic.getTokenTimeout());
|
Object mainShopId = logic.getSession().get("mainShopId");
|
||||||
SaSession session = logic.getSession();
|
SaSession session = logic.getSession();
|
||||||
|
Object parentId1 = session.get("headShopId");
|
||||||
|
logic.getSaTokenDao().set(splicingKeyTokenValue(logic.getTokenValue()), id.toString(), logic.getTokenTimeout());
|
||||||
|
session = logic.getSession();
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
logic.createLoginSession(id);
|
logic.createLoginSession(id);
|
||||||
session = logic.getSession();
|
session = logic.getSession();
|
||||||
}
|
}
|
||||||
// 主店没有headShopId
|
// 主店没有headShopId
|
||||||
Object parentId1 = session.get("headShopId");
|
|
||||||
if (!isMain && parentId1 == null) {
|
if (!isMain && parentId1 == null) {
|
||||||
session.set("headId", headId);
|
session.set("headId", headId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置主店id
|
|
||||||
Object mainShopId = session.get("mainShopId");
|
|
||||||
session.set("userId", id).set("isAdmin", isAdmin).set("isManager", loginType.equals(LoginType.MANAGER))
|
session.set("userId", id).set("isAdmin", isAdmin).set("isManager", loginType.equals(LoginType.MANAGER))
|
||||||
.set("loginType", loginType).set("account", account).set("shopId", shopId).set("shopName", shopName)
|
.set("loginType", loginType).set("account", account).set("shopId", shopId).set("shopName", shopName)
|
||||||
.set("mainShopId", mainShopId);
|
.set("mainShopId", mainShopId);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import jakarta.validation.constraints.NotNull;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -17,10 +18,16 @@ import java.util.List;
|
|||||||
* @since 2025-02-13
|
* @since 2025-02-13
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class CheckOrderPay implements Serializable {
|
public class CheckOrderPay implements Serializable {
|
||||||
|
/**
|
||||||
|
* 是否霸王餐
|
||||||
|
*/
|
||||||
|
private boolean isFreeDine;
|
||||||
|
private boolean withCoupon = true;
|
||||||
|
private boolean withPoints = true;
|
||||||
|
|
||||||
@NotNull(message = "订单id不可为空")
|
@NotNull(message = "订单id不可为空")
|
||||||
private Long orderId;
|
private Long orderId;
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
redisService.del(RedisCst.LOGIN_CODE + loginDTO.uuid());
|
redisService.del(RedisCst.LOGIN_CODE + loginDTO.uuid());
|
||||||
|
System.out.println(StpKit.USER.getMainShopId());
|
||||||
return new LoginVO(StpKit.USER.getTokenInfo(), promissionList, loginDTO.loginType(), shopInfo, shopStaff);
|
return new LoginVO(StpKit.USER.getTokenInfo(), promissionList, loginDTO.loginType(), shopInfo, shopStaff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -174,9 +174,9 @@ public class MkBirthdayGiftServiceImpl extends ServiceImpl<MkBirthdayGiftMapper,
|
|||||||
TableValueConstant.BirthdayGiftRecord.PushStatus.WAIT_PUSH.getCode() : TableValueConstant.BirthdayGiftRecord.PushStatus.NO_PUSH.getCode())
|
TableValueConstant.BirthdayGiftRecord.PushStatus.WAIT_PUSH.getCode() : TableValueConstant.BirthdayGiftRecord.PushStatus.NO_PUSH.getCode())
|
||||||
.setMainShopId(birthdayGift.getMainShopId()).setBirthday(DateUtil.parseDate(shopUser.getBirthDay()).toLocalDateTime().toLocalDate())
|
.setMainShopId(birthdayGift.getMainShopId()).setBirthday(DateUtil.parseDate(shopUser.getBirthDay()).toLocalDateTime().toLocalDate())
|
||||||
.setSourceId(birthdayGift.getId()).setTemplateCode(shopTemplate.getTemplateCode()).setTemplateContent(JSONObject.toJSONString(Map.of(
|
.setSourceId(birthdayGift.getId()).setTemplateCode(shopTemplate.getTemplateCode()).setTemplateContent(JSONObject.toJSONString(Map.of(
|
||||||
"nickName", shopUser.getNickName(),
|
"用户昵称", shopUser.getNickName(),
|
||||||
"shopName", shopInfo.getShopName(),
|
"店铺名称", shopInfo.getShopName(),
|
||||||
"num", config.getCouponInfoList() != null ? config.getCouponInfoList().stream().map(CouponInfoDTO::getNum).reduce(0, Integer::sum) : 0
|
"数量", config.getCouponInfoList() != null ? config.getCouponInfoList().stream().map(CouponInfoDTO::getNum).reduce(0, Integer::sum) : 0
|
||||||
)));
|
)));
|
||||||
birthdayGiftRecordService.save(giftRecord);
|
birthdayGiftRecordService.save(giftRecord);
|
||||||
rabbitPublisher.sendBirthdayGiftSmsMsg(giftRecord.getId().toString());
|
rabbitPublisher.sendBirthdayGiftSmsMsg(giftRecord.getId().toString());
|
||||||
|
|||||||
@@ -335,7 +335,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
Long shopId = orderInfo.getShopId();
|
Long shopId = orderInfo.getShopId();
|
||||||
AssertUtil.isNull(shopId, "生成支付订单失败,订单信息异常");
|
AssertUtil.isNull(shopId, "生成支付订单失败,订单信息异常");
|
||||||
MkDiscountActivityDTO discountAct = null;
|
MkDiscountActivityDTO discountAct = null;
|
||||||
if (param.getDiscountActAmount().compareTo(BigDecimal.ZERO) > 0) {
|
// 满减活动校验 不为霸王餐 霸王餐不参与满减
|
||||||
|
if (!param.isFreeDine() && param.getDiscountActAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
//检查满减活动是否开启
|
//检查满减活动是否开启
|
||||||
discountAct = discountActService.checkDiscountAct(orderInfo.getShopId(),
|
discountAct = discountActService.checkDiscountAct(orderInfo.getShopId(),
|
||||||
CollUtil.isNotEmpty(param.getCouponList()), param.isVipPrice(),
|
CollUtil.isNotEmpty(param.getCouponList()), param.isVipPrice(),
|
||||||
@@ -347,8 +348,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
} else {
|
} else {
|
||||||
orderInfo.setSeatAmount(BigDecimal.ZERO);
|
orderInfo.setSeatAmount(BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 积分校验
|
||||||
PointsBasicSetting pointSetting = pointsBasicService.getById(shopId);
|
PointsBasicSetting pointSetting = pointsBasicService.getById(shopId);
|
||||||
if (param.getPointsNum() > 0) {
|
if ((param.isFreeDine() && param.isWithPoints()) || (!param.isFreeDine() && param.getPointsNum() > 0)) {
|
||||||
if (pointSetting == null || !pointSetting.getEnableDeduction().equals(1)) {
|
if (pointSetting == null || !pointSetting.getEnableDeduction().equals(1)) {
|
||||||
throw new ValidateException("生成支付订单失败,该店铺未开启积分抵扣");
|
throw new ValidateException("生成支付订单失败,该店铺未开启积分抵扣");
|
||||||
}
|
}
|
||||||
@@ -392,8 +395,9 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||||||
log.info("订单原价不正确:订单原价:{},传递为:{}", totalAmount.getPrice(), param.getOriginAmount());
|
log.info("订单原价不正确:订单原价:{},传递为:{}", totalAmount.getPrice(), param.getOriginAmount());
|
||||||
throw new ValidateException("生成支付订单失败,订单原金额不正确");
|
throw new ValidateException("生成支付订单失败,订单原金额不正确");
|
||||||
}
|
}
|
||||||
|
|
||||||
//优惠券部分 目前规则 每个券只能用一张
|
//优惠券部分 目前规则 每个券只能用一张
|
||||||
if (CollUtil.isNotEmpty(param.getCouponList())) {
|
if ((param.isFreeDine() && param.isWithCoupon()) || (!param.isFreeDine() && CollUtil.isNotEmpty(param.getCouponList()))){
|
||||||
QueryWrapper couponRecordQuery = new QueryWrapper();
|
QueryWrapper couponRecordQuery = new QueryWrapper();
|
||||||
couponRecordQuery.in(MkShopCouponRecord::getId, param.getCouponList());
|
couponRecordQuery.in(MkShopCouponRecord::getId, param.getCouponList());
|
||||||
couponRecordQuery.le(MkShopCouponRecord::getUseStartTime, LocalDateTime.now());
|
couponRecordQuery.le(MkShopCouponRecord::getUseStartTime, LocalDateTime.now());
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.czg.service.order.service.impl;
|
package com.czg.service.order.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.exceptions.ValidateException;
|
import cn.hutool.core.exceptions.ValidateException;
|
||||||
@@ -135,6 +136,7 @@ public class PayServiceImpl implements PayService {
|
|||||||
* @return 是否是霸王餐充值
|
* @return 是否是霸王餐充值
|
||||||
*/
|
*/
|
||||||
private boolean checkPayVip(VipPayParamDTO payParam) {
|
private boolean checkPayVip(VipPayParamDTO payParam) {
|
||||||
|
|
||||||
if (payParam.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
if (payParam.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
throw new ValidateException("充值金额不正确");
|
throw new ValidateException("充值金额不正确");
|
||||||
}
|
}
|
||||||
@@ -144,35 +146,9 @@ public class PayServiceImpl implements PayService {
|
|||||||
if (!freeConfig.getEnable()) {
|
if (!freeConfig.getEnable()) {
|
||||||
throw new CzgException("该店铺未启用霸王餐");
|
throw new CzgException("该店铺未启用霸王餐");
|
||||||
}
|
}
|
||||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
|
||||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
CheckOrderPay checkOrderPay = BeanUtil.copyProperties(payParam, CheckOrderPay.class);
|
||||||
orderInfo.setSeatNum(payParam.getSeatNum());
|
orderInfoService.checkOrderPay(checkOrderPay.setFreeDine(true).setWithCoupon(freeConfig.getWithCoupon()).setWithPoints(freeConfig.getWithPoints()));
|
||||||
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
|
||||||
if (shopInfo.getIsTableFee() != 1 && shopInfo.getTableFee().compareTo(BigDecimal.ZERO) != 0) {
|
|
||||||
orderInfo.setSeatAmount(new BigDecimal(orderInfo.getSeatNum()).multiply(shopInfo.getTableFee()));
|
|
||||||
} else {
|
|
||||||
orderInfo.setSeatAmount(BigDecimal.ZERO);
|
|
||||||
}
|
|
||||||
//获取商品信息 计算金额 需要传入优惠券 减去优惠券
|
|
||||||
List<OrderDetail> orderDetails = orderDetailService.queryChain().eq(OrderDetail::getOrderId, orderInfo.getId()).select().list();
|
|
||||||
//总商品支付金额 不包含打包费 用来计算后续
|
|
||||||
BigDecimalDTO totalAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
|
||||||
//最终打包费
|
|
||||||
BigDecimalDTO packAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
|
||||||
BigDecimalDTO tempAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
|
||||||
orderInfoService.getOrderAmount(orderDetails, totalAmount, packAmount, tempAmount, payParam.isAllPack(), payParam.getUserAllPack(), false);
|
|
||||||
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()).add(orderInfo.getSeatAmount()))
|
|
||||||
.multiply(new BigDecimal(freeConfig.getMultiple())).setScale(2, RoundingMode.HALF_UP);
|
|
||||||
if (payAmount.compareTo(payParam.getAmount()) != 0) {
|
|
||||||
log.info("霸王餐应支付金额:{} 其中 打包费{} 餐位费{},充值金额为:{}",
|
|
||||||
payAmount, packAmount.getPrice(), orderInfo.getSeatAmount(), payParam.getAmount());
|
|
||||||
throw new ValidateException("霸王餐支付金额不正确");
|
|
||||||
}
|
|
||||||
orderDetailService.updateBatch(orderDetails);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -493,6 +469,7 @@ public class PayServiceImpl implements PayService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public CzgResult<Map<String, Object>> ltPayVip(String clintIp, VipPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> ltPayVip(String clintIp, VipPayParamDTO payParam) {
|
||||||
|
// 霸王餐校验
|
||||||
boolean isFree = checkPayVip(payParam);
|
boolean isFree = checkPayVip(payParam);
|
||||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||||
|
|||||||
Reference in New Issue
Block a user