From 9eceda085813417ba9ac225809e59b16cacd6386 Mon Sep 17 00:00:00 2001 From: zhaohengkun Date: Thu, 24 Oct 2024 09:30:33 +0800 Subject: [PATCH] bug --- .../integral/entity/IntegralOrders.java | 4 +- .../impl/IntegralOrdersServiceImpl.java | 61 ++---- .../mapper/xml/CardCouponUserMapper.xml | 4 +- .../cardCoupon/service/CardCouponService.java | 1 + .../service/impl/CardCouponServiceImpl.java | 26 +++ .../CardExchangeRecordController.java | 11 + .../VerificationRecordController.java | 56 +++++ .../entity/VerificationRecord.java | 51 +++++ .../mapper/VerificationRecordMapper.java | 21 ++ .../mapper/xml/VerificationRecordMapper.xml | 49 +++++ .../service/VerificationRecordService.java | 17 ++ .../impl/VerificationRecordServiceImpl.java | 172 +++++++++++++++ fuintCashierWeb/src/api/online.js | 14 +- .../views/cashier/NewComponents/Integral.vue | 171 +++------------ .../views/cashier/NewComponents/WriteOff.vue | 18 +- .../views/cashier/NewComponents/writeList.vue | 206 +++++++++++------- 16 files changed, 603 insertions(+), 279 deletions(-) create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/controller/VerificationRecordController.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/entity/VerificationRecord.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/mapper/VerificationRecordMapper.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/mapper/xml/VerificationRecordMapper.xml create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/service/VerificationRecordService.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/service/impl/VerificationRecordServiceImpl.java diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralOrders.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralOrders.java index a4e5c8e40..da49bc70e 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralOrders.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralOrders.java @@ -14,7 +14,7 @@ import java.io.Serializable; * @since 2023-11-07 13:59:23 */ @Data -public class IntegralOrders extends BaseEntity { +public class IntegralOrders extends BaseEntity { private static final long serialVersionUID = 181605029480746026L; /** * 兑换订单id(主键) @@ -34,7 +34,7 @@ public class IntegralOrders extends BaseEntity { */ private String orderNumber; /** - * 关联商品id + * 积分商城 商品表id */ // @JsonProperty("giftId") private Integer giftId; diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/service/impl/IntegralOrdersServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/service/impl/IntegralOrdersServiceImpl.java index c9f12cad7..d09b86640 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/service/impl/IntegralOrdersServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/service/impl/IntegralOrdersServiceImpl.java @@ -26,6 +26,10 @@ import com.fuint.business.integral.vo.IntegralGiftVO; import com.fuint.business.integral.vo.IntegralOrdersExcel; import com.fuint.business.integral.vo.IntegralOrdersRequest; import com.fuint.business.integral.vo.IntegralOrdersVO; +import com.fuint.business.marketingActivity.cardCoupon.entity.CardCoupon; +import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; +import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponService; +import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponUserService; import com.fuint.business.marketingActivity.cardExchange.entity.CardExchangeRecord; import com.fuint.business.marketingActivity.cardExchange.service.CardExchangeRecordService; import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord; @@ -48,6 +52,7 @@ import com.fuint.business.userManager.vo.LJUserVo; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.RedisLock; import com.fuint.common.util.TokenUtil; +import com.fuint.framework.web.ResponseObject; import com.fuint.system.dept.mapper.SysDeptMapper; import com.fuint.system.dict.entity.SysDictData; import com.fuint.system.dict.entity.SysDictType; @@ -463,15 +468,17 @@ public class IntegralOrdersServiceImpl implements IntegralOrdersService { @Autowired private RedisLock redisLock; + @Autowired + private CardCouponService cardCouponService; + + @Autowired + private CardCouponUserService cardCouponUserService; + @Override @Transactional public IntegralOrders checkTheStatusOfYourPaymentByIntegral(String orderNo) throws Exception { -// AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); - // 查询订单信息 -// List listByOrderNo = integralOrdersDao.getListByOrderNo2(orderNo, nowAccountInfo.getStoreId()); List listByOrderNo = integralOrdersDao.getListByOrderNo2(orderNo); - // 加锁 processing_status String lockKey = "IntegralOrders" + orderNo; Boolean isLock = redisLock.tryLock(lockKey, 5000, TimeUnit.MILLISECONDS); @@ -488,44 +495,19 @@ public class IntegralOrdersServiceImpl implements IntegralOrdersService { totalPoints = totalPoints.add(new BigDecimal(integralOrders.getIntegral())); // 加兑换卷和优惠券判断 IntegralGift integralGift = integralGiftService.queryById(integralOrders.getGiftId()); - if (integralGift.getGiftType().equals("兑换券")) { - // 兑换卷处理 -// integralGift.getVoucherId(); - CardExchangeRecord cardExchangeRecord = new CardExchangeRecord(); - cardExchangeRecord.setCardExchangeId(integralGift.getVoucherId()); - cardExchangeRecord.setStoreId(integralOrders.getStoreId()); - cardExchangeRecord.setMtUserId(integralOrders.getUserId()); - cardExchangeRecord.setName(ljUserVos.getName()); - cardExchangeRecord.setMobile(ljUserVos.getMobile()); - cardExchangeRecord.setPhoto(ljUserVos.getAvatar()); - if (ObjectUtil.isNotEmpty(ljStaff)) { - cardExchangeRecord.setMtStaffId(ljStaff.getId()); - cardExchangeRecord.setRealName(ljStaff.getRealName()); - cardExchangeRecord.setStaffMobile(ljStaff.getMobile()); - } + if (integralGift.getGiftType().equals("电子券")) { + + CardCoupon cardCoupon = cardCouponService.selectOneBuId(integralGift.getCouponId()); + ResponseObject responseObject = cardCouponService.sendCoupon2(new CardCouponUser()); - cardExchangeRecord.setStatus("0"); - cardExchangeRecord.setExchangeFrom("积分兑换"); - cardExchangeRecordService.addCardExchangeRecord(cardExchangeRecord); - } else if (integralGift.getGiftType().equals("优惠券")) { - // 优惠卷处理 - CardFavorableRecord cardFavorableRecord = new CardFavorableRecord(); - cardFavorableRecord.setCardFavorableId(integralGift.getCouponId()); - cardFavorableRecord.setStoreId(integralOrders.getStoreId()); - cardFavorableRecord.setMtUserId(integralOrders.getUserId()); - cardFavorableRecord.setName(ljUserVos.getName()); - cardFavorableRecord.setMobile(ljUserVos.getMobile()); - cardFavorableRecord.setStatus("0"); - cardFavorableRecord.setExchangeFrom("积分兑换"); - cardFavorableRecordService.addCardFavorableRecord(cardFavorableRecord); } else if (integralGift.getGiftType().equals("实物商品")) { // 修改商品库存并增加记录 -// LJGoodsDto goods = new LJGoodsDto(); -// goods.setId(integralGift.getGoodsId()); -// goods.setDocument("积分兑换"); -// goods.setNumberOfChanges(-integralOrders.getExchangeQuantity()); -// goods.setGoodsNo(integralOrders.getOrderNumber()); -// ljGoodsService.editGoodsInventory(goods); + LJGoodsDto goods = new LJGoodsDto(); + goods.setId(integralGift.getGoodsId()); + goods.setDocument("积分兑换"); + goods.setNumberOfChanges(-integralOrders.getExchangeQuantity()); + goods.setGoodsNo(integralOrders.getOrderNumber()); + ljGoodsService.editGoodsInventory(goods); } // 处理积分库存 @@ -690,6 +672,7 @@ public class IntegralOrdersServiceImpl implements IntegralOrdersService { /** * 生成核销码 + * * @return */ public static String generateUniqueRandomNumber() { diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml index b04a3974f..4548ace45 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml @@ -57,9 +57,11 @@ + select * from verification_record + + + and create_time <= #{map.startTime} + + + and create_time >= #{map.endTime} + + + and store_id = #{map.storeId} + + + and mt_user_id = #{map.mtUserId} + + + and card_user_id = #{map.cardUserId} + + + and card_name like concat('%',#{map.cardName},'%') + + + and mobile like concat('%',#{map.mobile},'%') + + + + + \ No newline at end of file diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/service/VerificationRecordService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/service/VerificationRecordService.java new file mode 100644 index 000000000..c87b77ea3 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/service/VerificationRecordService.java @@ -0,0 +1,17 @@ +package com.fuint.business.marketingActivity.cardExchange.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.business.marketingActivity.cardExchange.entity.VerificationRecord; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +public interface VerificationRecordService extends IService { + + + Boolean writeOff(Integer id); + + IPage list(VerificationRecord verificationRecord, Page page); +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/service/impl/VerificationRecordServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/service/impl/VerificationRecordServiceImpl.java new file mode 100644 index 000000000..7a569dc9f --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardExchange/service/impl/VerificationRecordServiceImpl.java @@ -0,0 +1,172 @@ +package com.fuint.business.marketingActivity.cardExchange.service.impl; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.business.marketingActivity.cardCoupon.entity.CardCoupon; +import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; +import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponService; +import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponUserService; +import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO; +import com.fuint.business.marketingActivity.cardExchange.entity.VerificationRecord; +import com.fuint.business.marketingActivity.cardExchange.service.VerificationRecordService; +import com.fuint.business.userManager.entity.UserBalance; +import com.fuint.business.userManager.mapper.UserBalanceMapper; +import com.fuint.business.userManager.service.UserBalanceService; +import com.fuint.common.util.StringUtils; +import com.fuint.pay.util.CheckUtil; +import com.fuint.repository.mapper.MtUserMapper; +import com.fuint.repository.model.MtUser; +import io.sentry.event.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.fuint.business.marketingActivity.cardExchange.mapper.VerificationRecordMapper; +import org.springframework.transaction.annotation.Transactional; + +import java.text.SimpleDateFormat; +import java.util.*; + + +@Service +public class VerificationRecordServiceImpl extends ServiceImpl implements VerificationRecordService { + + @Autowired + private CardCouponUserService cardCouponUserService; + @Autowired + private CardCouponService cardCouponService; + @Autowired + private UserBalanceMapper userBalanceMapper; + @Autowired + private MtUserMapper mtUserMapper; + @Autowired + private CheckUtil checkUtil; + + + /** + * 优惠券适用时间判断前置处理方法 + * + * @param rule 规则对象 + * @param nowDate 当前时间 + * @return java.lang.Boolean + * @author vinjor-M + * @date 13:57 2024/9/25 + **/ + private Boolean checkTimeCouponPrex(CardCoupon rule, Date nowDate) { + + if (StringUtils.isEmpty(rule.getAvailableDay()) && StringUtils.isEmpty(rule.getAvailableWeek())) { + return true; + } + String startTimeStr; + String endTimeStr; + if ("0".equals(rule.getAvailableOrUn())) { + //适用时间 + startTimeStr = checkUtil.getTimeFromDate(rule.getAvailablePeriodStart()); + endTimeStr = checkUtil.getTimeFromDate(rule.getAvailablePeriodEnd()); + Boolean aBoolean = checkUtil.checkTime(rule.getAvailableType(), "1".equals(rule.getAvailableType()) ? rule.getAvailableWeek() : rule.getAvailableDay(), startTimeStr, endTimeStr, nowDate); + return aBoolean; + } else if ("1".equals(rule.getAvailableOrUn())) { + //不适用时间 + startTimeStr = checkUtil.getTimeFromDate(rule.getUnAvailablePeriodStart()); + endTimeStr = checkUtil.getTimeFromDate(rule.getUnAvailablePeriodEnd()); + Boolean aBoolean = checkUtil.checkTimeReverse(rule.getUnAvailableType(), "1".equals(rule.getUnAvailableType()) ? rule.getUnAvailableWeek() : rule.getUnAvailableDay(), startTimeStr, endTimeStr, nowDate); + return aBoolean; + } else { + //超出预设值范围,不可用 + return false; + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean writeOff(Integer id) { + CardCouponUser byId = cardCouponUserService.getById(id); + if (byId == null || byId.getStatus().equals("1")) { + return false; + } +// 查询优惠券相关信息 + CardCoupon cardCoupon = cardCouponService.selectOneBuId(byId.getCardCouponId()); +// 查询被核销用户相关信息 + HashMap m1 = new HashMap<>(); + m1.put("store_id", byId.getStoreId()); + m1.put("mt_user_id", byId.getMtUserId()); + List list = userBalanceMapper.selectByMap(m1); + UserBalance userBalance = list.get(0); +// 查询 mt 用户表 + MtUser mtUser = mtUserMapper.selectById(byId.getMtUserId()); + +// 判断是否符合会员等级 + String[] split = cardCoupon.getMembershipLevel().split(","); + if (!Arrays.asList(split).contains(userBalance.getGradeId().toString())) { + return false; + } +// 判断 适用时间段 / 不可用时间段 + Date date = new Date(); + Boolean aBoolean = this.checkTimeCouponPrex(cardCoupon, date); + if (!aBoolean) { + return false; + } +// 判断 使用次数 + HashMap m2 = new HashMap<>(); + m2.put("cardUserId", byId.getMtUserId()); + m2.put("storeId", byId.getStoreId()); + m2.put("cardUserId", byId.getId()); + +// 日期 要根据 优惠券 设置的 每 * 天 限制适用 * 次数 往前推*天 + // 获取当前日期时间 + Calendar calendar = Calendar.getInstance(); + // 往前推指定天数,例如 7 天 + calendar.add(Calendar.DAY_OF_MONTH, -cardCoupon.getLimitTotalDay()); + // 获取往前推后的日期时间 + Date previousDate = calendar.getTime(); + m2.put("startTime", previousDate); + m2.put("endTime", date); + + List size = super.baseMapper.selectByMapper(m2); + +// 判断 使用次数 是否超过限制 + if (size.size() >= cardCoupon.getLimitTotalNum()) { + return false; + } + +// 以上条件都符合 + VerificationRecord ver = new VerificationRecord(); + ver.setStoreId(byId.getStoreId()); + ver.setCardUserId(byId.getId()); + ver.setMtUserId(byId.getMtUserId()); + ver.setCardName(cardCoupon.getName()); + ver.setCardType(cardCoupon.getType()); + ver.setMobile(mtUser.getMobile()); + + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String startTimeStr = dateFormat.format(byId.getStartTime()); + String endTimeStr = dateFormat.format(byId.getEndTime()); +// 有效期 + ver.setValidity(startTimeStr + " ~ " + endTimeStr); +// 可用时间 (暂时没法做) + +// 兑换内容 + ver.setContent(cardCoupon.getExchangeContent()); +// 适用会员等级 + ver.setMemberLevel(cardCoupon.getMembershipLevel()); + boolean save = super.save(ver); +// 新增核销记录后 要把用户 的优惠券 状态 改掉 并且 优惠券表的 核销数量 +1 + byId.setStatus("1"); + cardCouponUserService.updateById(byId); + cardCoupon.setTfUseNum(cardCoupon.getTfUseNum() + 1); + cardCouponService.updateById(cardCoupon); + + return true; + } + + @Override + public IPage list(VerificationRecord verificationRecord, Page page) { + + + IPage verificationRecordIPage = super.baseMapper.selectPageByMap(page, verificationRecord); + + return verificationRecordIPage; + } + +} diff --git a/fuintCashierWeb/src/api/online.js b/fuintCashierWeb/src/api/online.js index c8d3ec509..26544699a 100644 --- a/fuintCashierWeb/src/api/online.js +++ b/fuintCashierWeb/src/api/online.js @@ -34,11 +34,21 @@ export function updateRecord(data) { data: data }) } + // 核销 export function cardExchangeRecord(data) { return request({ - url: 'business/marketingActivity/cardExchangeRecord', - method: 'put', + url: 'business/marketingActivity/verificationRecord/writeOff', + method: 'get', + params: data + }) +} + +// 查询核销记录 +export function getList(data,queryParams) { + return request({ + url: 'business/marketingActivity/verificationRecord/list?pageNo='+queryParams.pageNo+'&pageSize='+queryParams.pageSize, + method: 'post', data: data }) } diff --git a/fuintCashierWeb/src/views/cashier/NewComponents/Integral.vue b/fuintCashierWeb/src/views/cashier/NewComponents/Integral.vue index a5591a639..ab6e58b8d 100644 --- a/fuintCashierWeb/src/views/cashier/NewComponents/Integral.vue +++ b/fuintCashierWeb/src/views/cashier/NewComponents/Integral.vue @@ -12,7 +12,7 @@
{{ chooseVipUser.name || '匿名' }}
{{ chooseVipUser.mobile }} - 普通会员 + 普通会员
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - // if (!res.data) { - // // data.markPurchases = data.markPurchases-1 - // this.$message.error('该商品库存不足'); - // return - // } - // }) - // } - if (this.shoppingCart.length != 0) { // 只能订购加钱购 let flag = false @@ -663,17 +543,14 @@ export default { flag = true } }) - if (data.exchangeMethod == '积分+加钱购' || flag) { - flag = false - this.shoppingCart.forEach(res => { - if (res.id != data.id) { - flag = true - return - } - }) - } + this.shoppingCart.forEach(res => { + if (res.id != data.id) { + flag = true + return + } + }) if (flag) { - this.$message.error('“加钱购”商品仅支持在单商品结算时支持积分不足情况下使用加钱购进行付款,多个商品结算不支持“加钱够”计算') + this.$message.error('每次只能选择一种商品种类') return } } @@ -800,9 +677,9 @@ export default { this.allMoneyRatio = 0 this.giftList = '' this.getGiftCategory() - await this.getGift() - this.restVipUser() + //暂时不重置 会员 + // this.restVipUser() }, // 打开购物车 shoppingCartMethod() { @@ -1022,6 +899,8 @@ export default { }, // 立即结算 async settlement() { + console.log("购物车列表", this.shoppingCart) + if (this.shoppingCart.length < 1) { this.$message.error('请先选择商品') return @@ -1031,18 +910,18 @@ export default { } this.isPay = true this.dialogVisiblej = true - if (this.paymentType !== 'CASH') { - - console.log("当前应付金额", this.allAmout) - if (this.allAmout != 0) { - console.log("进去了") - // 发送扫码机请求(易联云网络下发) - await this.getSendPrintIndex(this.allAmout) - this.getCode(this.allAmout) - - } - - } + // if (this.paymentType !== 'CASH') { + // + // console.log("当前应付金额", this.allAmout) + // if (this.allAmout != 0) { + // console.log("进去了") + // // 发送扫码机请求(易联云网络下发) + // // await this.getSendPrintIndex(this.allAmout) + // // this.getCode(this.allAmout) + // + // } + // + // } }, // 网络下发之后获取条码 getCode(amount) { diff --git a/fuintCashierWeb/src/views/cashier/NewComponents/WriteOff.vue b/fuintCashierWeb/src/views/cashier/NewComponents/WriteOff.vue index ee5f171de..c530d33be 100644 --- a/fuintCashierWeb/src/views/cashier/NewComponents/WriteOff.vue +++ b/fuintCashierWeb/src/views/cashier/NewComponents/WriteOff.vue @@ -13,7 +13,7 @@
通过手机号查询会员可以核销的卡券或扫码核销(扫码时,请保证输入框有光标闪烁)
- +
搜索 / 核销 @@ -27,6 +27,7 @@
{{item.exchangeName}}
领取人: {{item.mobile || '匿名'}}
核销码: {{item.ticketCode}}
+
兑换内容: {{item.exchangeContent}}
有效期: {{item.exchangeFrom}}
@@ -67,6 +68,10 @@ export default { components:{ writeList }, + mounted() { + this.$refs.mobileRef.focus(); + + }, methods:{ getindex(index) { this.tabindex = index @@ -93,13 +98,15 @@ export default { }).then(() => { let data = { id:id, - status:1 } cardExchangeRecord(data).then(res=>{ if(res.code == 200){ this.$message.success("核销成功") this.getList() } + else { + this.$message.error(res.msg) + } }) }).catch(() => { this.$message({ @@ -107,13 +114,6 @@ export default { message: '已取消核销' }); }); - - - - - - - } } diff --git a/fuintCashierWeb/src/views/cashier/NewComponents/writeList.vue b/fuintCashierWeb/src/views/cashier/NewComponents/writeList.vue index 5270aecd4..ba553111f 100644 --- a/fuintCashierWeb/src/views/cashier/NewComponents/writeList.vue +++ b/fuintCashierWeb/src/views/cashier/NewComponents/writeList.vue @@ -1,119 +1,164 @@ -