| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import java.net.UnknownHostException; |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private IntegralMapper integralMapper; |
| | | |
| | | |
| | | private final static String GOODS_ORDER_CREATE_LOCK = "goods:order:create:lock:"; |
| | | |
| | | @Override |
| | | public Integer create(Goodsorder goodsorder) { |
| | |
| | | goodsorder.getKdName()+"(单号:"+goodsorder.getKdCode()+")"); |
| | | |
| | | } |
| | | |
| | | //发送发货站内信 |
| | | Notice notice = Notice.getNotice( |
| | | Constants.NoticeType.NOTICE_ORDER_SEND, |
| | | goodsorder.getMemberId(), |
| | | goodsorder.getId() |
| | | ); |
| | | notice.setContent(notice.getContent().replace("{param}",goodsorder.getCode().toString())); |
| | | noticeMapper.insert(notice); |
| | | |
| | | |
| | | /* // TODO 发送微信模板消息 |
| | | Member member=memberMapper.selectById(query.getMemberId()); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public PayResponse orderPay(ShopOrderPayRequest orderPayRequest,MemberCouponServiceImpl memberCouponService){ |
| | | String lockKey = GOODS_ORDER_CREATE_LOCK + orderPayRequest.getMemberId(); |
| | | //判断前端是否在同一页面创建了两次订单 |
| | | if (redisTemplate.hasKey(lockKey)) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"正在创建订单,请勿重复调用!"); |
| | | } else { |
| | | redisTemplate.opsForValue().set(lockKey, "", 5, TimeUnit.SECONDS); |
| | | } |
| | | Member member = memberMapper.selectById(orderPayRequest.getMemberId()); |
| | | |
| | | Goodsorder goodsorder = new Goodsorder(); |
| | |
| | | } |
| | | goodsorder.setPrice(orderPayConfirmResponse.getPayAmount()); |
| | | goodsorder.setTotalPrice(orderPayConfirmResponse.getAmount()); |
| | | goodsorder.setUseIntegral(orderPayConfirmResponse.getDeductIntegral()); |
| | | goodsorder.setIntegral(orderPayConfirmResponse.getIntegralAmount()); |
| | | goodsorder.setUseIntegral(Constants.equalsInteger(orderPayRequest.getUseIntegral(),Constants.ONE)?orderPayConfirmResponse.getDeductIntegral():BigDecimal.ZERO); |
| | | goodsorder.setIntegral(Constants.equalsInteger(orderPayRequest.getUseIntegral(),Constants.ONE)?orderPayConfirmResponse.getIntegralAmount():BigDecimal.ZERO); |
| | | goodsorder.setMailPrice(orderPayConfirmResponse.getMailAmount()); |
| | | goodsorder.setPayMethod(goodsorder.getPrice().compareTo(BigDecimal.ZERO)>Constants.ZERO?Constants.ZERO:Constants.ONE); |
| | | goodsorder.setGoodsNum(orderPayRequest.getPayDetailRequestList().stream().mapToInt(PayDetailRequest::getGoodsNum).sum()); |
| | |
| | | for (OrderGoodsCalculateResponse payDetailRequest:goodsCalculateList) { |
| | | //查询商品 |
| | | GoodsSku goodsSku = goodsSkuMapper.selectById(payDetailRequest.getSkuId()); |
| | | if(Objects.isNull(goodsSku)){ |
| | | if(Objects.isNull(goodsSku)||!Constants.equalsInteger(goodsSku.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到商品SKU信息!"); |
| | | } |
| | | Goods goods = goodsMapper.selectById(goodsSku.getGoodsId()); |
| | | if(Objects.isNull(goods)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到商品信息!"); |
| | | } |
| | | if(goods.getStatus().equals(Constants.ONE)){ |
| | | if(!Constants.equalsInteger(goods.getStatus(),Constants.ZERO)||!Constants.equalsInteger(goods.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"存在商品已删除或已下架,无法下单"); |
| | | } |
| | | if(goodsSku.getStock().compareTo(new BigDecimal(Constants.formatIntegerNum(payDetailRequest.getGoodsNum())))<Constants.ZERO){ |
| | |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"商品价格发生变化,请刷新后重新支付!"); |
| | | } |
| | | |
| | | |
| | | //存在现金支付 |
| | | if(Constants.equalsInteger(goodsorder.getPayMethod(),Constants.ZERO)){ |
| | | return this.wxPay(goodsorder,member); |
| | | PayResponse payResponse = this.wxPay(goodsorder,member); |
| | | payResponse.setLockKey(lockKey); |
| | | return payResponse; |
| | | } |
| | | //无现金支付 |
| | | goodsorderMapper.update(null,new UpdateWrapper<Goodsorder>().lambda() |
| | |
| | | PayResponse payResponse = new PayResponse(); |
| | | payResponse.setOrderId(goodsorder.getId()); |
| | | payResponse.setPayType(Constants.ONE); |
| | | //发送通知 |
| | | if(Objects.nonNull(goodsorder.getPickUpShopId())){ |
| | | //发送站内信 - 经销商 |
| | | noticeService.orderPayNotice(goodsorder.getPickUpShopId(),goodsorder.getId(),goodsorder.getReceiveType()); |
| | | } |
| | | |
| | | payResponse.setLockKey(lockKey); |
| | | // //发送通知 |
| | | // if(Objects.nonNull(goodsorder.getPickUpShopId())){ |
| | | // //发送站内信 - 经销商 |
| | | // noticeService.orderPayNotice(goodsorder.getPickUpShopId(),goodsorder.getId(),goodsorder.getReceiveType()); |
| | | // } |
| | | |
| | | return payResponse; |
| | | } |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到订单信息"); |
| | | } |
| | | if(memberOrderResponse.getOrderStatus().equals(Constants.OrderStatus.WAIT_PAY.getKey())){ |
| | | memberOrderResponse.setCountdown(memberOrderResponse.getCancelDate().getTime()>System.currentTimeMillis()?memberOrderResponse.getCancelDate().getTime()-System.currentTimeMillis():Constants.ZERO); |
| | | memberOrderResponse.setCountdown(memberOrderResponse.getCancelOptDate().getTime()>System.currentTimeMillis()?memberOrderResponse.getCancelOptDate().getTime()-System.currentTimeMillis():Constants.ZERO); |
| | | } |
| | | String fullUrl = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ |
| | | systemDictDataBiz.queryByCode(Constants.OSS,Constants.GOODS_FILE).getCode(); |
| | |
| | | goodsorder.setCancelInfo(cancelInfo); |
| | | goodsorder.setCancelUser(optUserId); |
| | | goodsorderMapper.updateById(goodsorder); |
| | | if(Constants.equalsInteger(goodsorder.getReceiveType(),Constants.ONE)){ |
| | | //释放核销码 |
| | | this.releaseExchangeCode(goodsorder.getExchangeCode()); |
| | | } |
| | | String goodsName = ""; |
| | | List<GoodsorderDetail> goodsorderDetailList = goodsorderDetailMapper.selectList(new QueryWrapper<GoodsorderDetail>().eq("ORDER_ID",goodsorder.getId())); |
| | | if(!Objects.isNull(goodsorderDetailList)&&goodsorderDetailList.size()>Constants.ZERO){ |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void cancelOrderNew(Integer orderId,Integer optUserId,String cancelInfo){ |
| | | if(Objects.isNull(orderId)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Goodsorder goodsorder = goodsorderMapper.selectById(orderId); |
| | | if(Objects.isNull(goodsorder)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!(Constants.equalsInteger(goodsorder.getStatus(),Constants.OrderStatus.WAIT_PAY.getKey()) |
| | | || Constants.equalsInteger(goodsorder.getStatus(),Constants.OrderStatus.PAY_DONE.getKey()) )){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单取消失败:订单状态已流转!"); |
| | | } |
| | | public void cancel(Goodsorder goodsorder,Integer optUserId,String cancelInfo){ |
| | | if(Constants.formatBigdecimal(goodsorder.getPrice()).compareTo(BigDecimal.ZERO)>Constants.ZERO |
| | | && Constants.equalsObject(goodsorder.getPayStatus(),Constants.ONE) ){ |
| | | //微信现金退款 |
| | |
| | | fundMapper.insert(fund); |
| | | } |
| | | //订单已支付状态 , 使用了积分 且积分使用大于0 |
| | | if(goodsorder.getIntegral().compareTo(BigDecimal.ZERO)>Constants.ZERO){ |
| | | if(goodsorder.getUseIntegral().compareTo(BigDecimal.ZERO)>Constants.ZERO){ |
| | | //更新余额信息 添加积分变动记录 |
| | | DealIntegralRequest dealIntegralRequest = new DealIntegralRequest(); |
| | | dealIntegralRequest.setIntegralNum(goodsorder.getIntegral()); |
| | | dealIntegralRequest.setIntegralNum(goodsorder.getUseIntegral()); |
| | | dealIntegralRequest.setDealType(Constants.ZERO); |
| | | dealIntegralRequest.setMemberId(goodsorder.getMemberId()); |
| | | dealIntegralRequest.setObjId(goodsorder.getId()); |
| | |
| | | goodsorder.setCancelInfo(StringUtils.isBlank(cancelInfo)?"用户主动取消":cancelInfo); |
| | | goodsorder.setCancelUser(optUserId); |
| | | goodsorderMapper.updateById(goodsorder); |
| | | if(Constants.equalsInteger(goodsorder.getReceiveType(),Constants.ONE)){ |
| | | //释放核销码 |
| | | this.releaseExchangeCode(goodsorder.getExchangeCode()); |
| | | } |
| | | String goodsName = ""; |
| | | List<GoodsorderDetail> goodsorderDetailList = goodsorderDetailMapper.selectList(new QueryWrapper<GoodsorderDetail>().eq("ORDER_ID",goodsorder.getId())); |
| | | if(!Objects.isNull(goodsorderDetailList)&&goodsorderDetailList.size()>Constants.ZERO){ |
| | |
| | | } |
| | | |
| | | // 用户主动取消 发送经销商站内消息 |
| | | if(Objects.nonNull(goodsorder.getPickUpShopId())&&StringUtils.isBlank(cancelInfo)){ |
| | | noticeService.orderCancelNotice(goodsorder.getPickUpShopId(),goodsorder.getId(),goodsorder.getCode().toString()); |
| | | } |
| | | // if(Objects.nonNull(goodsorder.getPickUpShopId())&&StringUtils.isBlank(cancelInfo)){ |
| | | // noticeService.orderCancelNotice(goodsorder.getPickUpShopId(),goodsorder.getId(),goodsorder.getCode().toString()); |
| | | // } |
| | | |
| | | //查询优惠券信息记录 |
| | | if(!Objects.isNull(goodsorder.getCouponId())){ |
| | |
| | | memberCouponMapper.updateById(memberCoupon); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void cancelOrderNew(Integer orderId,Integer optUserId,String cancelInfo){ |
| | | if(Objects.isNull(orderId)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Goodsorder goodsorder = goodsorderMapper.selectById(orderId); |
| | | if(Objects.isNull(goodsorder)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!(Constants.equalsInteger(goodsorder.getStatus(),Constants.OrderStatus.WAIT_PAY.getKey()) |
| | | || Constants.equalsInteger(goodsorder.getStatus(),Constants.OrderStatus.PAY_DONE.getKey()) )){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单取消失败:订单状态已流转!"); |
| | | } |
| | | this.cancel(goodsorder,optUserId,cancelInfo); |
| | | |
| | | } |
| | | |
| | |
| | | if(Objects.isNull(orderGoodsCalculateResponse.getCouponDeductCash())){ |
| | | orderGoodsCalculateResponse.setCouponDeductCash(BigDecimal.ZERO); |
| | | } |
| | | // orderGoodsCalculateResponse.setIntegralDeductCash(BigDecimal.ZERO); |
| | | } |
| | | //订单总金额 |
| | | BigDecimal amount = BigDecimal.ZERO; |
| | |
| | | List<MemberCoupon> memberCouponList = memberCouponService.getApplyCoupon(request.getPayDetailRequestList(),request.getMemberId()); |
| | | if(CollectionUtils.isNotEmpty(memberCouponList)){ |
| | | orderPayConfirmResponse.setMemberCouponList(memberCouponList); |
| | | if(Objects.nonNull(request.getCouponId())&&Constants.equalsInteger(request.getCouponId(),-Constants.ONE)&&Objects.nonNull(memberCouponList)){ |
| | | request.setCouponId(memberCouponList.get(Constants.ZERO).getId()); |
| | | } |
| | | //如果选择了优惠券,则判断选择的优惠券是否有效 |
| | | if(Objects.nonNull(request.getCouponId())){ |
| | | List<MemberCoupon> memberCoupons = memberCouponList.stream().filter(i->Constants.equalsInteger(i.getId(),request.getCouponId())).collect(Collectors.toList()); |
| | |
| | | //查询用户总积分 |
| | | Member member = memberMapper.selectById(request.getMemberId()); |
| | | //最低可用启用积分 |
| | | BigDecimal minimumIntegral = new BigDecimal(systemDictDataBiz.queryByCode(Constants.SHOP_CONFIG,Constants.MINIMUM_AVAILABLE_INTEGRAL).getCode()); |
| | | BigDecimal minimumIntegral = new BigDecimal(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET,Constants.INTERALSET_MININTEGRALPRICELIMIT).getCode()); |
| | | //积分可使用状态 大于0 大于最小可用配置积分值 |
| | | orderPayConfirmResponse.setIntegralStatus( |
| | | (member.getIntegral().compareTo(BigDecimal.ZERO)<=Constants.ZERO|| |
| | |
| | | orderPayConfirmResponse.setIntegralAmount(integralAmount); |
| | | if(Constants.equalsInteger(orderPayConfirmResponse.getIntegralStatus(),Constants.ZERO)){ |
| | | integralAmount = this.calculateIntegralRata(orderPayConfirmResponse,goodsCalculateList,member.getIntegral()); |
| | | }else{ |
| | | orderPayConfirmResponse.setSurplusIntegral(member.getIntegral()); |
| | | } |
| | | |
| | | //邮费金额 |
| | |
| | | } |
| | | Areas areas = areasMapper.selectOne(new QueryWrapper<Areas>().lambda() |
| | | .eq(Areas::getIsdeleted,Constants.ZERO) |
| | | .eq(Areas::getId,StringUtils.leftPad(addr.getAreaId().toString().substring(0,2),6,"0")) |
| | | .eq(Areas::getId,StringUtils.rightPad(addr.getAreaId().toString().substring(0,2),6,"0")) |
| | | .isNotNull(Areas::getYunFeeId) |
| | | .last(" limit 1 ") |
| | | ); |
| | |
| | | BigDecimal totalWeight = goodsCalculateList.stream().map(i-> |
| | | i.getWeight().multiply(new BigDecimal(i.getGoodsNum().toString())) |
| | | ).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | if(totalWeight.compareTo(mailConfigResponse.getWeight0())>=Constants.ZERO){ |
| | | if(totalWeight.compareTo(mailConfigResponse.getWeight0())<=Constants.ZERO){ |
| | | mailAmount = mailConfigResponse.getFee0(); |
| | | }else{ |
| | | //超重重量 |
| | |
| | | public BigDecimal calculateIntegralRata(OrderPayConfirmResponse orderPayConfirmResponse,List<OrderGoodsCalculateResponse> goodsCalculateList,BigDecimal totalIntegral){ |
| | | //当前选择商品最大可用积分抵扣的金额 |
| | | BigDecimal maxDeductionCash = goodsCalculateList.stream().map(i->i.getSkuAmount().subtract(Objects.isNull(i.getCouponDeductCash())?BigDecimal.ZERO:i.getCouponDeductCash()) |
| | | .multiply(i.getDeductRata()).multiply(new BigDecimal("0.01"))).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | .multiply(i.getDeductRata()).divide(new BigDecimal("100"),2,RoundingMode.DOWN)).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | //积分-现金兑换比例(XXX积分抵扣1元) |
| | | BigDecimal cashToIntegralRata = new BigDecimal(systemDictDataBiz.queryByCode(Constants.SHOP_CONFIG,Constants.INTEGRAL_EXCHANGE_CASH_RATA).getCode()); |
| | | BigDecimal cashToIntegralRata = new BigDecimal(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET,Constants.INTERALSET_DEDUCTINTEGRALLIMIT).getCode()); |
| | | //当前选择商品抵扣需要使用的积分 |
| | | BigDecimal maxDeductionIntegral = maxDeductionCash.multiply(cashToIntegralRata); |
| | | //获取当前需要支付的现金总额 |
| | |
| | | //循环下单商品列表 计算应该使用的积分值 |
| | | BigDecimal realDeductionCash = BigDecimal.ZERO; |
| | | for (int j = 0; j < goodsCalculateList.size(); j++) { |
| | | BigDecimal deductionCash = goodsCalculateList.get(j).getSkuAmount().subtract(goodsCalculateList.get(j).getCouponDeductCash()); |
| | | //获取最大可抵扣金额 |
| | | BigDecimal deductionCash = goodsCalculateList.get(j).getSkuAmount().subtract(goodsCalculateList.get(j).getCouponDeductCash()) |
| | | .multiply(goodsCalculateList.get(j).getDeductRata()).divide(new BigDecimal("100"),2,RoundingMode.DOWN); |
| | | goodsCalculateList.get(j).setIntegralMaxDeductCash(deductionCash); |
| | | //如果剩余积分大于可以使用积分 则直接满额计算 反之 剩余积分不能满足全部抵扣 单独计算每个商品占比 |
| | | if(totalIntegral.compareTo(maxDeductionIntegral)<Constants.ZERO){ |
| | |
| | | this.orderAddMemberIntegral(goodsorder); |
| | | //经销商 结算金额 |
| | | this.orderAddShopCash(goodsorder); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | couponNoticeRequest.setMemberCoupon(memberCoupon); |
| | | couponNoticeRequest.setNum(num); |
| | | requestList.add(couponNoticeRequest); |
| | | |
| | | Notice notice = Notice.getNotice(Constants.NoticeType.COUPON, |
| | | member.getId(),null); |
| | | notice.setContent(notice.getContent().replace("{param}",Constants.getCouponInfo(memberCoupon,num))); |
| | | noticeMapper.insert(notice); |
| | | } |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberCouponList)){ |
| | | memberCouponJoinMapper.insert(memberCouponList); |
| | | } |
| | | if(CollectionUtils.isNotEmpty(requestList)){ |
| | | //发送站内信 |
| | | noticeService.couponNotice(inviteMember.getId(),requestList); |
| | | } |
| | | // if(CollectionUtils.isNotEmpty(requestList)){ |
| | | // //发送站内信 |
| | | // noticeService.couponNotice(inviteMember.getId(),requestList); |
| | | // } |
| | | } |
| | | inviteRecordMapper.update(new UpdateWrapper<InviteRecord>().lambda() |
| | | .set(InviteRecord::getFirstOrderStatus,Constants.ONE) |
| | |
| | | goodsorder.setStatus(Constants.OrderStatus.DONE.getKey()); |
| | | goodsorder.setDoneDate(new Date()); |
| | | goodsorderMapper.updateById(goodsorder); |
| | | //释放核销码 |
| | | this.releaseExchangeCode(goodsorder.getExchangeCode()); |
| | | //存在现金支付 赠送 积分 |
| | | if(Constants.equalsInteger(goodsorder.getPayMethod(),Constants.ZERO)){ |
| | | //赠送消费者积分 |
| | |
| | | //经销商 结算金额 |
| | | this.orderAddShopCash(goodsorder); |
| | | } |
| | | //发送核销通知 |
| | | Notice notice = Notice.getNotice( |
| | | Constants.NoticeType.NOTICE_ORDER_WRITE_OFF, |
| | | goodsorder.getMemberId(), |
| | | goodsorder.getId() |
| | | ); |
| | | notice.setContent(notice.getContent().replace("{param}",goodsorder.getCode().toString())); |
| | | noticeMapper.insert(notice); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | if(!goodsorder.getStatus().equals(Constants.OrderStatus.DONE.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"操作失败:订单未完成,无法退款!"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String createExchangeCode(){ |
| | | List<Goodsorder> goodsorderList = goodsorderMapper.selectList(new QueryWrapper<Goodsorder>().lambda() |
| | | .eq(Goodsorder::getIsdeleted,Constants.ZERO) |
| | | .eq(Goodsorder::getReceiveType,Constants.ONE) |
| | | .in(Goodsorder::getStatus,Constants.OrderStatus.WAIT_RECEIVE.getKey(), |
| | | Constants.OrderStatus.WAIT_PAY.getKey(), |
| | | Constants.OrderStatus.PAY_DONE.getKey()) |
| | | ); |
| | | String exchangeCode = UniqueVerificationCodeGenerator.generateNumericCode(); |
| | | if(CollectionUtils.isNotEmpty(goodsorderList)){ |
| | | Boolean flag = true; |
| | | while (flag){ |
| | | String finalExchangeCode = exchangeCode; |
| | | flag = goodsorderList.stream().filter(i->i.getExchangeCode().equals(finalExchangeCode)).count()>0L?true:false; |
| | | if(flag){ |
| | | exchangeCode = UniqueVerificationCodeGenerator.generateNumericCode(); |
| | | } |
| | | } |
| | | } |
| | | RedisUtil.addObject(redisTemplate,Constants.RedisKeys.EXCHANGE_KEY+exchangeCode,exchangeCode); |
| | | return exchangeCode; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 释放核销码 |
| | | * @param code |
| | | */ |
| | | public void releaseExchangeCode(String code){ |
| | | if(StringUtils.isNotBlank(code)){ |
| | | RedisUtil.deleteObject(redisTemplate,Constants.RedisKeys.EXCHANGE_KEY+code); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单未支付超时自动取消 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void autoCancelOrder(){ |
| | | List<Goodsorder> goodsorderList = goodsorderMapper.selectList(new QueryWrapper<Goodsorder>().lambda() |
| | | .eq(Goodsorder::getIsdeleted, Constants.ZERO) |
| | | .eq(Goodsorder::getStatus, Constants.OrderStatus.WAIT_PAY.getKey()) |
| | | .ge(Goodsorder::getCreateDate, "DATE_SUB(NOW(), INTERVAL 15 MINUTE)") |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(goodsorderList)){ |
| | | for (Goodsorder goodsorder:goodsorderList) { |
| | | this.cancel(goodsorder,null,"订单未支付超时自动取消"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | } |