1
This commit is contained in:
parent
0fd7f53d4f
commit
f9c9647133
@ -51,7 +51,7 @@ public class PayCenterController extends BaseController {
|
||||
return getSuccessResult("查询成功",payCenterService.getCoupon(map));
|
||||
}
|
||||
/**
|
||||
* 收银台支付成功后 消费有礼
|
||||
* 收银台支付成功后 消费有礼 (和小程序通用)
|
||||
* @date 12:01 2024/9/19
|
||||
* @param map 请求参数
|
||||
* @param request
|
||||
@ -64,7 +64,7 @@ public class PayCenterController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序支付成功后 消费有礼
|
||||
* 小程序支付成功前预览 当前用户消费后 能获取 多少 积分 成长值 优惠卷
|
||||
* @param map
|
||||
* @param request
|
||||
* @return
|
||||
|
@ -494,12 +494,6 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
// 订单id
|
||||
// 用户id
|
||||
// 店铺id
|
||||
// 返回 消费者 领取的东西 积分 成长值 优惠卷
|
||||
HashMap<String, Object> resMap = new HashMap<>();
|
||||
resMap.put("points", 0);
|
||||
resMap.put("growthValue", 0);
|
||||
resMap.put("carList", new ArrayList<AppCardVO>());
|
||||
|
||||
// 1.查询当前用户在当前店铺的 会员信息
|
||||
UserBalance userBalance = userBalanceService.selectUserBalanceByStorId(Integer.parseInt(map.get("userId")), Integer.parseInt(map.get("storeId")));
|
||||
// 2.查询出 当前用户 在当前店铺 参与过的活动记录
|
||||
@ -549,7 +543,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
if (order.getShengshu() >= Double.parseDouble(child.getConsumeAmount())) {
|
||||
// 如果以上条件都满足那么用户成功参与了这个活动
|
||||
b1 = false;
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, order,resMap);
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, order);
|
||||
// 奖励发放成功 将此 活动奖励子表 id 拼接
|
||||
if (aBoolean) {
|
||||
str += child.getId() + ",";
|
||||
@ -561,7 +555,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
if (order.getPayMoney() >= Double.parseDouble(child.getConsumeAmount())) {
|
||||
// 如果以上条件都满足那么用户成功参与了这个活动
|
||||
b2 = false;
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, order,resMap);
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, order);
|
||||
// 奖励发放成功 将此 活动奖励子表 id 拼接
|
||||
if (aBoolean) {
|
||||
str += child.getId() + ",";
|
||||
@ -574,7 +568,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
if (order.getGoodsMoney() >= Double.parseDouble(child.getConsumeAmount())) {
|
||||
// 如果以上条件都满足那么用户成功参与了这个活动
|
||||
b3 = false;
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, order,resMap);
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, order);
|
||||
// 奖励发放成功 将此 活动奖励子表 id 拼接
|
||||
if (aBoolean) {
|
||||
str += child.getId() + ",";
|
||||
@ -696,14 +690,14 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
// 此活动上架 收银台可送 且 已领取 + 活动发放数量 < 总数量 且 未超过 总上限 当日上限
|
||||
if (card.getStatus().equals("1") &&
|
||||
card.getSySend().equals("1") &&
|
||||
card.getTfGetNum() + child.getGiftCardTotal() < card.getTfTotal() &&
|
||||
card.getTfGetNum()+child.getGiftCardTotal() < card.getTfTotal() &&
|
||||
list1.size() < card.getGetNumLimit() &&
|
||||
list2.count() < card.getDayGetLimit()) {
|
||||
// 将优惠卷 与 当前用户关联 并且 优惠卷 领取数量 + 方法数量
|
||||
card.setTfGetNum(card.getTfGetNum() + child.getGiftCardTotal());
|
||||
cardCouponService.updateById(card);
|
||||
|
||||
for (int i = 0; i < child.getGiftCardTotal(); i++) {
|
||||
for (int i = 0; i <child.getGiftCardTotal() ; i++) {
|
||||
CardCouponUser cardUser = new CardCouponUser();
|
||||
cardUser.setChainStoreId(invitationBalance.getChainStoreId());
|
||||
cardUser.setStoreId(invitationBalance.getStoreId());
|
||||
@ -808,7 +802,6 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
|
||||
// 然后根据过滤后的 活动主表 再去匹配子表
|
||||
for (ActiveConsumptionVOS active : f1) {
|
||||
|
||||
Boolean b1 = true;
|
||||
Boolean b2 = true;
|
||||
Boolean b3 = true;
|
||||
@ -819,7 +812,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
if (liters >= Double.parseDouble(child.getConsumeAmount())) {
|
||||
// 如果以上条件都满足那么用户成功参与了这个活动
|
||||
b1 = false;
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, null, resMap);
|
||||
Boolean aBoolean = setActiveGiftApp(child, userBalance, null, resMap);
|
||||
// 奖励发放成功 将此 活动奖励子表 id 拼接
|
||||
if (aBoolean) {
|
||||
str += child.getId() + ",";
|
||||
@ -831,7 +824,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
if (payMoney >= Double.parseDouble(child.getConsumeAmount())) {
|
||||
// 如果以上条件都满足那么用户成功参与了这个活动
|
||||
b2 = false;
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, null, resMap);
|
||||
Boolean aBoolean = setActiveGiftApp(child, userBalance, null, resMap);
|
||||
// 奖励发放成功 将此 活动奖励子表 id 拼接
|
||||
if (aBoolean) {
|
||||
str += child.getId() + ",";
|
||||
@ -844,7 +837,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
if (goodsMoney >= Double.parseDouble(child.getConsumeAmount())) {
|
||||
// 如果以上条件都满足那么用户成功参与了这个活动
|
||||
b3 = false;
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, null, resMap);
|
||||
Boolean aBoolean = setActiveGiftApp(child, userBalance, null, resMap);
|
||||
// 奖励发放成功 将此 活动奖励子表 id 拼接
|
||||
if (aBoolean) {
|
||||
str += child.getId() + ",";
|
||||
@ -971,13 +964,6 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
// 将优惠卷 与 当前用户关联 并且 优惠卷 领取数量 + 方法数量
|
||||
card.setTfGetNum(card.getTfGetNum() + child.getGiftCardTotal());
|
||||
cardCouponService.updateById(card);
|
||||
// 累加当前用户获得的优惠卷
|
||||
ArrayList<AppCardVO> carList = (ArrayList<AppCardVO>) resMap.get("carList");
|
||||
AppCardVO appCardVO = new AppCardVO();
|
||||
appCardVO.setType(card.getType());
|
||||
appCardVO.setNum(child.getGiftCardTotal());
|
||||
carList.add(appCardVO);
|
||||
|
||||
for (int i = 0; i < child.getGiftCardTotal(); i++) {
|
||||
CardCouponUser cardUser = new CardCouponUser();
|
||||
cardUser.setChainStoreId(invitationBalance.getChainStoreId());
|
||||
@ -1019,7 +1005,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
}
|
||||
|
||||
// 根据不同的 活动赠送 0:赠送积分1:赠送优惠券 2. 赠送兑换券 3:赠送成长值 4. 赠送实物 处理不同的业务逻辑
|
||||
private Boolean setActiveGift(ActiveConsumptionChild child, UserBalance userBalance, AllOrderActivityVo order, HashMap<String, Object> resMap) {
|
||||
private Boolean setActiveGift(ActiveConsumptionChild child, UserBalance userBalance, AllOrderActivityVo order) {
|
||||
Boolean b1 = false;
|
||||
if (child.getActiveGift().equals("0")) {
|
||||
//
|
||||
@ -1035,8 +1021,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
i.setChangeType("1");
|
||||
i.setChainStoreId(userBalance.getChainStoreId());
|
||||
integralDetailService.insert(i);
|
||||
// 需要计算叠加 转Integer
|
||||
resMap.put("points", Integer.parseInt(resMap.get("points").toString()) + Integer.parseInt(child.getGivePoints()));
|
||||
|
||||
b1 = true;
|
||||
return b1;
|
||||
}
|
||||
@ -1055,10 +1040,72 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
g.setGrowthValue(Integer.parseInt(child.getGiveGrowthValue()));
|
||||
// 成长变化后的值
|
||||
g.setAfterTheChange(userBalance.getGrowthValue());
|
||||
if (order != null) {
|
||||
g.setOrderNo(order.getOrderNo());
|
||||
}
|
||||
g.setOrderNo(order.getOrderNo());
|
||||
int i = growthValueChangeService.insertGrowthValueChangeActive(g);
|
||||
b1 = true;
|
||||
return b1;
|
||||
}
|
||||
if (child.getActiveGift().equals("1")) {
|
||||
// 优惠卷还得判断自身的活动限制 (因为这是 给某个用户 赠送某个优惠卷 只需要判断 每日每人领取上限 每人总领取上限 优惠卷数量不 <=0)
|
||||
HashMap<String, Object> m1 = new HashMap<>();
|
||||
m1.put("card_coupon_id", child.getVouchersId());
|
||||
m1.put("mt_user_id", userBalance.getMtUserId());
|
||||
// 获取当前优惠卷信息
|
||||
CardCoupon card = cardCouponService.getById(child.getVouchersId());
|
||||
|
||||
// 获取 总的 当前用户 领取优惠卷的列表
|
||||
List<CardCouponUser> list1 = cardCouponUserService.selectByMap(m1);
|
||||
// 过滤掉 不是今天的领取次数
|
||||
Stream<CardCouponUser> list2 = list1.stream()
|
||||
.filter(cardCouponUser -> checkUtil.isBetween(cardCouponUser.getCreateTime(), DateUtil.getTodayMidnight(), DateUtil.getTomorrowMidnight()));
|
||||
|
||||
// 此 优惠卷 上架 收银台可送 且 活动发放数量+已领取 < 总数量 且 未超过 总上限 当日上限 先都判断一下不为 null 防止空指针
|
||||
card.setTfGetNum( (card.getTfGetNum() == null) ? 0 : card.getTfGetNum());
|
||||
|
||||
if ( card.getStatus().equals("1") &&
|
||||
card.getSySend().equals("1") &&
|
||||
(child.getGiftCardTotal() + card.getTfGetNum()) < card.getTfTotal() &&
|
||||
list1.size() < card.getGetNumLimit() &&
|
||||
list2.count() < card.getDayGetLimit()
|
||||
) {
|
||||
|
||||
// 将优惠卷 与 当前用户关联 并且 优惠卷 领取数量 + 活动设定赠送优惠卷数量
|
||||
card.setTfGetNum(card.getTfGetNum()+child.getGiftCardTotal());
|
||||
cardCouponService.updateById(card);
|
||||
// 并且 循环 添加多张优惠卷与用户领取记录表
|
||||
for (int i = 0; i < child.getGiftCardTotal(); i++) {
|
||||
CardCouponUser cardUser = new CardCouponUser();
|
||||
cardUser.setChainStoreId(userBalance.getChainStoreId());
|
||||
cardUser.setStoreId(userBalance.getStoreId());
|
||||
cardUser.setMtUserId(userBalance.getMtUserId());
|
||||
// 手机号码 需要连表 空着
|
||||
cardUser.setFromType("3"); // 3代表 消费有礼活动
|
||||
cardUser.setActiveId(child.getActiveConsumptionId());
|
||||
cardUser.setCardCouponId(child.getVouchersId());
|
||||
cardUser.setStartTime(card.getEffectiveDateStart());
|
||||
cardUser.setEndTime(card.getEffectiveDateEnd());
|
||||
cardUser.setStatus("0");
|
||||
cardCouponUserService.save(cardUser);
|
||||
}
|
||||
|
||||
b1 = true;
|
||||
return b1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return b1;
|
||||
}
|
||||
|
||||
private Boolean setActiveGiftApp(ActiveConsumptionChild child, UserBalance userBalance, AllOrderActivityVo order, HashMap<String, Object> resMap) {
|
||||
Boolean b1 = false;
|
||||
if (child.getActiveGift().equals("0")) {
|
||||
// 需要计算叠加 转Integer
|
||||
resMap.put("points", Integer.parseInt(resMap.get("points").toString()) + Integer.parseInt(child.getGivePoints()));
|
||||
b1 = true;
|
||||
return b1;
|
||||
}
|
||||
if (child.getActiveGift().equals("3")) {
|
||||
// 需要计算叠加
|
||||
resMap.put("growthValue", Integer.parseInt(resMap.get("growthValue").toString()) + Integer.parseInt(child.getGiveGrowthValue()));
|
||||
b1 = true;
|
||||
@ -1087,25 +1134,12 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
list1.size() < card.getGetNumLimit() &&
|
||||
list2.count() < card.getDayGetLimit()
|
||||
) {
|
||||
|
||||
// 将优惠卷 与 当前用户关联 并且 优惠卷 领取数量 + 活动设定赠送优惠卷数量
|
||||
card.setTfGetNum(card.getTfGetNum() + child.getGiftCardTotal());
|
||||
cardCouponService.updateById(card);
|
||||
// 并且 循环 添加多张优惠卷与用户领取记录表
|
||||
for (int i = 0; i < child.getGiftCardTotal(); i++) {
|
||||
CardCouponUser cardUser = new CardCouponUser();
|
||||
cardUser.setChainStoreId(userBalance.getChainStoreId());
|
||||
cardUser.setStoreId(userBalance.getStoreId());
|
||||
cardUser.setMtUserId(userBalance.getMtUserId());
|
||||
// 手机号码 需要连表 空着
|
||||
cardUser.setFromType("3"); // 3代表 消费有礼活动
|
||||
cardUser.setActiveId(child.getActiveConsumptionId());
|
||||
cardUser.setCardCouponId(child.getVouchersId());
|
||||
cardUser.setStartTime(card.getEffectiveDateStart());
|
||||
cardUser.setEndTime(card.getEffectiveDateEnd());
|
||||
cardUser.setStatus("0");
|
||||
cardCouponUserService.save(cardUser);
|
||||
}
|
||||
// 累加当前用户获得的优惠卷
|
||||
ArrayList<AppCardVO> carList = (ArrayList<AppCardVO>) resMap.get("carList");
|
||||
AppCardVO appCardVO = new AppCardVO();
|
||||
appCardVO.setType(card.getType());
|
||||
appCardVO.setNum(child.getGiftCardTotal());
|
||||
carList.add(appCardVO);
|
||||
|
||||
b1 = true;
|
||||
return b1;
|
||||
@ -1117,6 +1151,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 推荐消费有礼 活动时间前置处理 0永久有效;1自定义
|
||||
**/
|
||||
|
Loading…
Reference in New Issue
Block a user