1.定时任务-待付款-15分钟
2.领券中心:根据领取次数判断是否已领取
3.付款:优惠券自动领取最大优惠券
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | |
| | | @Data |
| | | @ApiModel("App活动优惠券实体类") |
| | |
| | | @ApiModelProperty(value = "状态(coupon_record_status)",hidden = true) |
| | | private String status; |
| | | |
| | | @ApiModelProperty(value = "订单金额",hidden = true) |
| | | private BigDecimal orderAmount; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "优惠券图片") |
| | | private String imageUrl; |
| | | |
| | | /** |
| | | * 已经领取数 |
| | | */ |
| | | @ApiModelProperty(value = "已经领取数") |
| | | private Integer getNum; |
| | | |
| | | @ApiModelProperty(value = "优惠券是否已领取") |
| | | private Boolean getYetFlag; |
| | | |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "优惠券图片") |
| | | private String imageUrl; |
| | | |
| | | @ApiModelProperty(value = "是否已经领取完成,判断最大的领取次数和已经领取次数") |
| | | private Integer receiveFlag; |
| | | |
| | | @ApiModelProperty(value = "优惠券是否已领取") |
| | | private Boolean getYetFlag; |
| | | |
| | | @ApiModelProperty(value = "剩余领取数量") |
| | | private Integer leftNum; |
| | | |
| | | @ApiModelProperty(value = "优惠券领取的最早时间") |
| | | private LocalDateTime recordCreateTime; |
| | | |
| | | } |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | |
| | | @TableField("member_discount_amount") |
| | | private BigDecimal memberDiscountAmount;//优惠金额(每扎) |
| | | |
| | | @TableField("payment_date_sta") |
| | | private LocalDate paymentDateSta;//支付日期 |
| | | |
| | | @TableField("create_date_sta") |
| | | private LocalDate createDateSta;//创建日期 |
| | | |
| | | } |
| | |
| | | void expireHomeActivityCouponTemplate(); |
| | | |
| | | int expireActivityCouponTemplateAll(); |
| | | |
| | | List<CouponTemplateVO> getActivityEffectListWithMine(@Param("param") QueryActivityEffectCouponDTO dto); |
| | | } |
| | |
| | | |
| | | BigDecimal getOrderSaleAmount(@Param("startTime") LocalDateTime startTime |
| | | , @Param("endTime") LocalDateTime endTime); |
| | | |
| | | List<Order> selectAllDateList(); |
| | | |
| | | void updatePaymentCreateDate(@Param("order") Order order); |
| | | } |
| | |
| | | import com.mzl.flower.dto.response.wallet.WalletReduceVO; |
| | | import com.mzl.flower.entity.wallet.WalletDO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | |
| | | List<WalletReduceVO> getPage(Page page,@Param("dto") QueryWalletReduceDTO dto); |
| | | |
| | | BigDecimal getCheckReduceAmount(@Param("dto") QueryWalletAmountDTO queryWalletAmountDTO); |
| | | BigDecimal getCheckLackReplaceAmount(@Param("dto") QueryWalletAmountDTO queryWalletAmountDTO); |
| | | |
| | | BigDecimal getSaleReduceAmount(@Param("dto")QueryWalletAmountDTO queryWalletAmountDTO); |
| | | |
| | | BigDecimal getStationFeeAmount(@Param("dto") QueryWalletAmountDTO queryWalletAmountDTO); |
| | | |
| | | BigDecimal getCheckReduceAmount(@Param("dto") QueryWalletAmountDTO queryWalletAmountDTO); |
| | | } |
| | |
| | | log.info("分类加价缓存结束:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0/5 * * * ?") |
| | | // @Scheduled(cron = "0 0/5 * * * ?") |
| | | @Scheduled(cron = "0 0/15 * * * ?") |
| | | public void checkPrepayOrder() {//五分钟未付款自动取消 |
| | | log.info("未付款确认开始:" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); |
| | | |
| | |
| | | if(ls != null && ls.size() > 0){ |
| | | for(Order o : ls){ |
| | | try { |
| | | LocalDateTime createdTime = o.getCreateTime().plusMinutes(5); |
| | | LocalDateTime createdTime = o.getCreateTime().plusMinutes(15); |
| | | if (createdTime.isBefore(LocalDateTime.now())) { |
| | | boolean f = paymentV3Service.checkOrderStatus(o.getId()); |
| | | if(!f){ |
| | |
| | | |
| | | |
| | | boolean expireCouponRecordAll(); |
| | | |
| | | CouponRecordVO getUnusedFit(QueryMineCouponRecordDTO dto); |
| | | } |
| | |
| | | CouponTemplateVO getHomeActivityEffectAlert(QueryActivityEffectCouponDTO dto); |
| | | |
| | | boolean expireActivityCouponTemplateAll(); |
| | | |
| | | List<CouponTemplateVO> getActivityEffectListWithMine(QueryActivityEffectCouponDTO dto); |
| | | } |
| | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | |
| | | return couponRecordMapperCustom.expireCouponRecordAll(); |
| | | } |
| | | |
| | | @Override |
| | | public CouponRecordVO getUnusedFit(QueryMineCouponRecordDTO dto) { |
| | | |
| | | /** |
| | | * ①.先查询出满足条件的优惠券(满减面值最大) |
| | | * ②.查询面值最大的优惠券(无门槛面值最大) |
| | | * ③查询过期时间早的优惠券④在满足③的条件下,优先使用无门槛优惠券 |
| | | * ④基于以上规则如果还存在相同的优惠券,任意选择一张优惠券即可 |
| | | */ |
| | | |
| | | CouponRecordVO bestCoupon=null; |
| | | // 查出我所有可用优惠券 |
| | | final List<CouponRecordVO> mineCouponRecordList = getMineCouponRecordList(dto); |
| | | |
| | | if(null!=dto.getOrderAmount() && CollectionUtils.isNotEmpty(mineCouponRecordList)){ |
| | | // ①.先查询出满足条件的优惠券 |
| | | // 遍历优惠券列表,找出所有minOrderAmount >= dto.orderAmount ,且couponDiscountValue 最大的优惠券 |
| | | // 筛选符合条件并找出优惠面值最大的优惠券 |
| | | bestCoupon = mineCouponRecordList.stream() |
| | | // 筛选出 minOrderAmount >= dto.orderAmount 的优惠券并且优惠券类型是discount的 |
| | | .filter(coupon -> coupon.getCouponDiscountType().equals(CouponTypeEnum.DISCOUNT.getType())) |
| | | .filter(coupon -> coupon.getMinOrderAmount().compareTo(dto.getOrderAmount()) <= 0) |
| | | // 按 couponDiscountValue 倒序排序 |
| | | .max(Comparator.comparing(CouponRecordVO::getCouponDiscountValue)) |
| | | // 如果没有符合条件的优惠券,使用 Optional.orElse(null) 返回 null |
| | | .orElse(null); |
| | | |
| | | if(null==bestCoupon){ |
| | | // ②.查询面值最大的优惠券(无门槛面值最大) |
| | | // 过滤出discountType 是zero的优惠券,并根据couponDiscountValue倒序排序 |
| | | bestCoupon = mineCouponRecordList.stream() |
| | | .filter(coupon -> coupon.getCouponDiscountType().equals(CouponTypeEnum.ZERO.getType())) |
| | | .max(Comparator.comparing(CouponRecordVO::getCouponDiscountValue)) |
| | | .orElse(null); |
| | | |
| | | // ③查询过期时间早的优惠券 |
| | | if(null!=bestCoupon){ |
| | | final BigDecimal zeroMaxCouponDiscountValue = bestCoupon.getCouponDiscountValue(); |
| | | // 过滤出discountType 是zero的优惠券,且couponDiscountValue与bestCoupon的couponDiscountValue面值一样的优惠券,并根据effectiveEnd正序排,获取第一条数据 |
| | | CouponRecordVO effectiveEndEarlyCoupon= mineCouponRecordList.stream() |
| | | .filter(coupon -> coupon.getCouponDiscountType().equals(CouponTypeEnum.ZERO.getType())) |
| | | .filter(coupon -> coupon.getCouponDiscountValue().compareTo(zeroMaxCouponDiscountValue)==0) |
| | | .min(Comparator.comparing(CouponRecordVO::getEffectiveEnd)) |
| | | .orElse(null); |
| | | if(null!=effectiveEndEarlyCoupon){ |
| | | bestCoupon=effectiveEndEarlyCoupon; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | return bestCoupon; |
| | | |
| | | } |
| | | } |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<CouponTemplateVO> getActivityEffectList(QueryActivityEffectCouponDTO dto) { |
| | | public List<CouponTemplateVO> getActivityEffectListWithMine(QueryActivityEffectCouponDTO dto) { |
| | | // 1.点击领取,优惠券状态变成灰色+已领取(根据web端优惠券限领次数判断) |
| | | //2.把已领取的优惠券按照领取时间排列到最下面 |
| | | List<CouponTemplateVO> list= couponTemplateMapperCustom.getActivityEffectListWithMine(dto); |
| | | |
| | | return couponTemplateMapperCustom.getActivityEffectList(dto); |
| | | // 将列表分为已经领取和未领取的,根据getYetFlag来判断,下面的所有操作都要判空 |
| | | if(CollectionUtils.isNotEmpty(list)){ |
| | | // 遍历列表,查看当前的优惠券是否已经达到领取次数,如果是则为true,不是为false |
| | | list.forEach(item->{ |
| | | if (item != null) { |
| | | item.setGetYetFlag(false); |
| | | if (null != item.getGetNum() && null != item.getGetLimit() && item.getGetNum() >= item.getGetLimit()) { |
| | | item.setGetYetFlag(true); |
| | | } |
| | | } |
| | | }); |
| | | List<CouponTemplateVO> getYetList = list.stream().filter(item->item.getGetYetFlag()).collect(Collectors.toList()); |
| | | List<CouponTemplateVO> getNotYetList = list.stream().filter(item->!item.getGetYetFlag()).collect(Collectors.toList()); |
| | | list.clear(); |
| | | if(CollectionUtils.isNotEmpty(getNotYetList)){ |
| | | // 将未领取的根据create_time 倒序排序 |
| | | getNotYetList.sort(Comparator.comparing(CouponTemplateVO::getCreateTime).reversed()); |
| | | // 将未领取和已领取的合并成新list返回 |
| | | list.addAll(getNotYetList); |
| | | } |
| | | if(CollectionUtils.isNotEmpty(getYetList)){ |
| | | // 将已经领取的根据recordCreateTime 时间正序排 |
| | | getYetList.sort(Comparator.comparing(CouponTemplateVO::getRecordCreateTime)); |
| | | list.addAll(getYetList); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | @Override |
| | | public List<CouponTemplateVO> getActivityEffectList(QueryActivityEffectCouponDTO dto) { |
| | | return couponTemplateMapperCustom.getActivityEffectListWithMine(dto); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.mzl.flower.dto.request.wallet.QueryWalletAmountDTO; |
| | | import com.mzl.flower.dto.request.wallet.QueryWalletReduceDTO; |
| | | import com.mzl.flower.dto.response.wallet.WalletReduceVO; |
| | | import com.mzl.flower.dto.response.wallet.WalletWithdrawRecordVO; |
| | | import com.mzl.flower.mapper.wallet.WalletReduceMapper; |
| | | import com.mzl.flower.service.wallet.WalletReduceService; |
| | | import com.mzl.flower.service.wallet.WalletService; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal getCheckReduceAmount(QueryWalletAmountDTO queryWalletAmountDTO) { |
| | | public BigDecimal getCheckLackReplaceAmount(QueryWalletAmountDTO queryWalletAmountDTO) { |
| | | |
| | | return walletReduceMapper.getCheckReduceAmount(queryWalletAmountDTO); |
| | | return walletReduceMapper.getCheckLackReplaceAmount(queryWalletAmountDTO); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public BigDecimal getSaleReduceAmount(QueryWalletAmountDTO queryWalletAmountDTO) { |
| | |
| | | public BigDecimal getStationFeeAmount(QueryWalletAmountDTO queryWalletAmountDTO) { |
| | | return walletReduceMapper.getStationFeeAmount(queryWalletAmountDTO); |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal getCheckReduceAmount(QueryWalletAmountDTO queryWalletAmountDTO) { |
| | | return walletReduceMapper.getCheckReduceAmount(queryWalletAmountDTO); |
| | | } |
| | | } |
| | |
| | | queryWalletAmountDTO.setStartTime(getWalletOnLineTime()); |
| | | queryWalletAmountDTO.setUserId(walletDO.getUserId()); |
| | | |
| | | // 质检扣款 |
| | | BigDecimal checkDeduceAmount = walletReduceService.getCheckReduceAmount(queryWalletAmountDTO); |
| | | checkDeduceAmount = checkDeduceAmount != null ? checkDeduceAmount : BigDecimal.ZERO; |
| | | // 质检扣款(缺货和补货) |
| | | BigDecimal checkReplaceLockAmount = walletReduceService.getCheckLackReplaceAmount(queryWalletAmountDTO); |
| | | checkReplaceLockAmount = checkReplaceLockAmount != null ? checkReplaceLockAmount : BigDecimal.ZERO; |
| | | |
| | | // 质检扣款(降级) |
| | | BigDecimal checkReduceAmount = walletReduceService.getCheckReduceAmount(queryWalletAmountDTO); |
| | | checkReduceAmount = checkReduceAmount != null ? checkReduceAmount : BigDecimal.ZERO; |
| | | |
| | | // 售后扣款 |
| | | BigDecimal saleDeduceAmount = walletReduceService.getSaleReduceAmount(queryWalletAmountDTO); |
| | | saleDeduceAmount = saleDeduceAmount != null ? saleDeduceAmount : BigDecimal.ZERO; |
| | |
| | | stationFeeAmount = stationFeeAmount != null ? stationFeeAmount : BigDecimal.ZERO; |
| | | |
| | | // 总扣款 |
| | | BigDecimal deduceAmount = checkDeduceAmount.add(saleDeduceAmount).add(stationFeeAmount); |
| | | BigDecimal deduceAmount = checkReplaceLockAmount.add(checkReduceAmount).add(saleDeduceAmount).add(stationFeeAmount); |
| | | |
| | | return deduceAmount; |
| | | } |
| | |
| | | usePointGoods(order.getId(), goodsRecordIdList);//使用积分商品兑换券 |
| | | |
| | | order.create(userId); |
| | | // 根据当前的时间判断,如果时间大于当天的下午17:00 ,那么日期则为下一天的日期,否则为当天日期 |
| | | if(null!=order.getCreateTime()){ |
| | | LocalDateTime createDateTime = order.getCreateTime(); |
| | | LocalDate createDate = createDateTime.toLocalDate(); |
| | | LocalDateTime today1700 = createDateTime.with(LocalTime.of(17, 0)); |
| | | // 比较时间是否大于当天的 17:00 |
| | | if (createDateTime.isAfter(today1700)) { |
| | | // 如果大于 17:00,设置为下一天的日期 |
| | | createDate = createDate.plusDays(1); |
| | | } |
| | | order.setCreateDateSta(createDate); |
| | | } |
| | | // order.setCreateDate(); |
| | | order.setRemarks(dto.getRemarks()); |
| | | order.setSpecialNeeds(dto.getSpecialNeeds()); |
| | | order.setStatusBackend(Constants.ORDER_STATUS_BACKEND.PENDING.name()); |
| | |
| | | exportOrderDetail(response, dto); |
| | | } |
| | | |
| | | public void refreshDate() { |
| | | List<Order> allOrderList= orderMapper.selectAllDateList(); |
| | | |
| | | allOrderList.forEach(order -> { |
| | | orderMapper.updatePaymentCreateDate(order); |
| | | }); |
| | | } |
| | | } |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | |
| | | order.setPaymentAmount(order.getTotalAmount()); |
| | | } |
| | | order.setPaymentTime(up.getPaymentTimeCallback()); |
| | | |
| | | if(null!=order.getPaymentTime()){ |
| | | LocalDateTime paymentTime = order.getPaymentTime(); |
| | | LocalDate paymentDate = paymentTime.toLocalDate(); |
| | | LocalDateTime today1700 = paymentTime.with(LocalTime.of(17, 0)); |
| | | // 比较时间是否大于当天的 17:00 |
| | | if (paymentTime.isAfter(today1700)) { |
| | | // 如果大于 17:00,设置为下一天的日期 |
| | | paymentDate = paymentDate.plusDays(1); |
| | | } |
| | | order.setPaymentDateSta(paymentDate); |
| | | } |
| | | |
| | | order.setStatus(Constants.ORDER_STATUS.SEND.name()); |
| | | } else if (Constants.ORDER_STATUS_BACKEND.CANCEL.name().equals(orderStatus)){ |
| | | order.setStatus(Constants.ORDER_STATUS.CANCEL.name()); |
| | |
| | | import com.mzl.flower.dto.request.payment.UserPaymentDTO; |
| | | import com.mzl.flower.entity.flower.Flower; |
| | | import com.mzl.flower.entity.payment.*; |
| | | import com.mzl.flower.entity.system.UserWechat; |
| | | import com.mzl.flower.mapper.flower.FlowerMapper; |
| | | import com.mzl.flower.mapper.payment.*; |
| | | import com.mzl.flower.mapper.system.UserWechatMapper; |
| | |
| | | import java.io.InputStreamReader; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.ZonedDateTime; |
| | | import java.time.*; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX"); |
| | | |
| | | // 使用formatter格式化ZonedDateTime |
| | | String formattedDateTime = zonedDateTime.plusMinutes(5).format(formatter); |
| | | String formattedDateTime = zonedDateTime.plusMinutes(15).format(formatter); |
| | | |
| | | return formattedDateTime; // 格式化日期 |
| | | } |
| | |
| | | order.setPaymentAmount(order.getTotalAmount()); |
| | | } |
| | | order.setPaymentTime(up.getPaymentTimeCallback()); |
| | | if(null!=order.getPaymentTime()){ |
| | | LocalDateTime paymentTime = order.getPaymentTime(); |
| | | LocalDate paymentDate = paymentTime.toLocalDate(); |
| | | LocalDateTime today1700 = paymentTime.with(LocalTime.of(17, 0)); |
| | | // 比较时间是否大于当天的 17:00 |
| | | if (paymentTime.isAfter(today1700)) { |
| | | // 如果大于 17:00,设置为下一天的日期 |
| | | paymentDate = paymentDate.plusDays(1); |
| | | } |
| | | order.setPaymentDateSta(paymentDate); |
| | | } |
| | | |
| | | order.setStatus(Constants.ORDER_STATUS.SEND.name()); |
| | | } else if (Constants.ORDER_STATUS_BACKEND.CANCEL.name().equals(orderStatus)){ |
| | | order.setStatus(Constants.ORDER_STATUS.CANCEL.name()); |
| | |
| | | package com.mzl.flower.service.wallet; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mzl.flower.dto.request.wallet.QueryWalletAmountDTO; |
| | | import com.mzl.flower.dto.request.wallet.QueryWalletReduceDTO; |
| | | import com.mzl.flower.dto.response.wallet.WalletReduceVO; |
| | | import com.mzl.flower.entity.wallet.WalletDO; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | |
| | | Page<WalletReduceVO> getPage(Page page, QueryWalletReduceDTO dto); |
| | | |
| | | /** |
| | | * 获取质检扣款钱 |
| | | * 获取质检扣款钱(缺货补货) |
| | | * @param queryWalletAmountDTO |
| | | * @return |
| | | */ |
| | | BigDecimal getCheckReduceAmount(QueryWalletAmountDTO queryWalletAmountDTO); |
| | | BigDecimal getCheckLackReplaceAmount(QueryWalletAmountDTO queryWalletAmountDTO); |
| | | |
| | | /** |
| | | * 获取售后质检扣款钱 |
| | |
| | | * @return |
| | | */ |
| | | BigDecimal getStationFeeAmount(QueryWalletAmountDTO queryWalletAmountDTO); |
| | | |
| | | /** |
| | | * 获取质检扣款钱(降级) |
| | | * @param queryWalletAmountDTO |
| | | * @return |
| | | */ |
| | | BigDecimal getCheckReduceAmount(QueryWalletAmountDTO queryWalletAmountDTO); |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | |
| | | public void exportOrderDetail(HttpServletResponse response, OrderQueryDTO queryOrderDTO) { |
| | | orderService.exportOrderDetail(response, queryOrderDTO); |
| | | } |
| | | |
| | | @GetMapping("/time/now") |
| | | @ApiOperation(value = "订单导出") |
| | | public ResponseEntity<Long> getNowTime() { |
| | | return returnData(R.SUCCESS.getCode(),System.currentTimeMillis()); |
| | | } |
| | | |
| | | @GetMapping("/elk/date") |
| | | @ApiOperation(value = "订单日期刷新") |
| | | public ResponseEntity<Long> getElkDate() { |
| | | orderService.refreshDate(); |
| | | return returnData(R.SUCCESS.getCode(),System.currentTimeMillis()); |
| | | } |
| | | |
| | | } |
| | |
| | | // 首页弹窗 |
| | | dto.setGetType(CouponGetTypeEnum.CENTER.getType()); |
| | | |
| | | return returnData(R.SUCCESS.getCode(), ConverterUtil.transList(couponTemplateService.getActivityEffectList(dto), CouponTemplateAppVO.class)); |
| | | dto.setUserId(SecurityUtils.getUserId()); |
| | | |
| | | // return returnData(R.SUCCESS.getCode(), ConverterUtil.transList(couponTemplateService.getActivityEffectListWith(dto), CouponTemplateAppVO.class)); |
| | | |
| | | return returnData(R.SUCCESS.getCode(), ConverterUtil.transList(couponTemplateService.getActivityEffectListWithMine(dto), CouponTemplateAppVO.class)); |
| | | |
| | | } |
| | | |
| | |
| | | return returnData(R.SUCCESS.getCode(), ConverterUtil.transList(couponRecordService.getMineCouponRecordList(dto), CouponTemplateAppVO.class)); |
| | | |
| | | } |
| | | |
| | | @GetMapping("/mine/unused/fit") |
| | | @ApiOperation(value = "我的优惠券-未使用", notes = "我的优惠券-未使用") |
| | | public ResponseEntity<ReturnDataDTO<Page<CouponTemplateVO>>> unusedFit(QueryMineCouponRecordDTO dto) { |
| | | // 未使用 |
| | | dto.setStatus(CouponUsedStatusEnum.UNUSED.getType()); |
| | | dto.setUserId(SecurityUtils.getUserId()); |
| | | |
| | | return returnData(R.SUCCESS.getCode(), ConverterUtil.transObject(couponRecordService.getUnusedFit(dto), CouponTemplateAppVO.class) ); |
| | | |
| | | } |
| | | @GetMapping("/mine/used/list") |
| | | @ApiOperation(value = "我的优惠券-已使用", notes = "我的优惠券-已使用") |
| | | public ResponseEntity<ReturnDataDTO<Page<CouponTemplateVO>>> usedList(QueryMineCouponRecordDTO dto) { |
| | |
| | | ORDER BY t.create_time DESC |
| | | limit 1 |
| | | </select> |
| | | <select id="getActivityEffectListWithMine" |
| | | resultType="com.mzl.flower.dto.response.coupon.CouponTemplateVO"> |
| | | select t2.*,t2.get_limit,IFNULL(t2.get_limit- t2.getNum,0) as left_num from ( |
| | | SELECT |
| | | t.*, |
| | | ( |
| | | SELECT count( 1 ) |
| | | FROM t_coupon_record cr |
| | | WHERE cr.coupon_id = t.id AND cr.deleted = 0 |
| | | <if test="param.userId != null and param.userId != ''"> |
| | | AND cr.user_id = #{param.userId} |
| | | </if> |
| | | |
| | | ) AS getNum, |
| | | ( |
| | | SELECT min( cr.create_time ) |
| | | FROM t_coupon_record cr |
| | | WHERE cr.coupon_id = t.id AND cr.deleted = 0 |
| | | <if test="param.userId != null and param.userId != ''"> |
| | | AND cr.user_id = #{param.userId} |
| | | </if> |
| | | ) AS record_create_time |
| | | FROM |
| | | t_coupon_template t |
| | | WHERE |
| | | t.deleted = FALSE |
| | | <if test="param.category != null and param.category != '' and param.category == 'activity' "> |
| | | AND t.get_start_date <= NOW() |
| | | AND NOW() <= t.get_end_date |
| | | </if> |
| | | |
| | | <if test="param.category != null and param.category != ''"> |
| | | AND category = #{param.category} |
| | | </if> |
| | | <if test="param.status != null and param.status != ''"> |
| | | AND status = #{param.status} |
| | | </if> |
| | | <if test="param.getType != null and param.getType != ''"> |
| | | AND t.get_type = #{param.getType} |
| | | </if> |
| | | |
| | | ) t2 |
| | | |
| | | ORDER BY |
| | | left_num desc, |
| | | create_time DESC, |
| | | record_create_time ASC |
| | | </select> |
| | | |
| | | <sql id="QueryPointSql"> |
| | | select * |
| | |
| | | where status_backend = 'SEND' and partner_id is not null |
| | | </update> |
| | | |
| | | |
| | | <select id="getPartnerOrderReceive" resultType="com.mzl.flower.entity.payment.Order"> |
| | | select * from t_order t where status_backend = 'SEND' and partner_id is not null |
| | | </select> |
| | |
| | | and o.create_time <= #{endTime} |
| | | </if> |
| | | </select> |
| | | |
| | | <!-- 获取所有的订单数据,以及时间数据--> |
| | | <select id="selectAllDateList" resultType="com.mzl.flower.entity.payment.Order"> |
| | | SELECT t.id,t.payment_time, |
| | | CASE |
| | | WHEN t.payment_time > DATE(t.payment_time) + INTERVAL 17 HOUR THEN DATE(t.payment_time) + INTERVAL 1 DAY |
| | | ELSE DATE(t.payment_time) |
| | | END AS payment_date, |
| | | t.create_time, |
| | | CASE |
| | | WHEN t.create_time > DATE(t.create_time) + INTERVAL 17 HOUR THEN DATE(t.create_time) + INTERVAL 1 DAY |
| | | ELSE DATE(t.create_time) |
| | | END AS create_date |
| | | FROM t_order t |
| | | order by t.create_time desc |
| | | </select> |
| | | |
| | | <update id="updatePaymentCreateDate"> |
| | | update t_order set payment_date_sta=#{order.paymentDate}, create_date_sta=#{order.createDate} where id=#{order.id} |
| | | </update> |
| | | </mapper> |
| | |
| | | |
| | | </resultMap> |
| | | <select id="getWaittingSettlementAmount" resultType="java.math.BigDecimal"> |
| | | <!-- <include refid="supplier_settlement_amount"></include>--> |
| | | <include refid="supplier_settlement_amount_timing"></include> |
| | | |
| | | <include refid="supplier_settlement_amount_timing3"></include> |
| | | </select> |
| | | |
| | | <!-- 总交易额--> |
| | |
| | | |
| | | |
| | | <!-- 待结算--> |
| | | <sql id="supplier_settlement_amount"> |
| | | SELECT IFNULL(sum(settlement_amount),0) AS settlement_amount |
| | | FROM t_order_settlement OS |
| | | WHERE OS.DELETED=0 |
| | | AND OS.TYPE='supplier' |
| | | AND OS.status='PENDING' |
| | | AND USER_ID=#{dto.userId} |
| | | </sql> |
| | | |
| | | |
| | | <sql id="supplier_settlement_amount_timing"> |
| | | select |
| | | sum(t2.final_price) as settlement_amount |
| | |
| | | t.order_item_id, |
| | | t.supplier_id, |
| | | t.supplier_price, |
| | | t.num-t.reduce_num-t.replace_num-t.lack_num as final_num, |
| | | t.supplier_price*(t.num-t.reduce_num-t.replace_num-t.lack_num )-t.fee_supplier-t.station_fee as final_price, |
| | | t.supplier_price*(t.num-t.replace_num-t.lack_num )- t.deduct_amount -t.fee_supplier-t.station_fee as final_price, |
| | | t.fee_supplier, |
| | | t.station_fee |
| | | from ( |
| | |
| | | o.payment_time, |
| | | oi.supplier_price, |
| | | oi.num as num, |
| | | IFNULL( (select oic.num from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'reduce' and oic.audit_status='AGREED'),0) as reduce_num, |
| | | IFNULL( (select oic.deduct_amount from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'reduce' and oic.audit_status='AGREED'),0) as deduct_amount, |
| | | IFNULL( (select oic.num from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'replace' and oic.audit_status='AGREED'),0) as replace_num, |
| | | IFNULL( (select oic.num from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'lack' and oic.audit_status='AGREED'),0) as lack_num, |
| | | IFNULL( (select ois.fee_supplier from t_order_item_sales ois where ois.deleted=0 and ois.order_item_id = oi.id and ois.status='AGREED'),0) as fee_supplier, |
| | | IFNULL( (select ois.station_fee from t_order_item_settlement ois where ois.deleted=0 and ois.order_item_id = oi.id ),0) as station_fee |
| | | FROM t_order_item oi |
| | | LEFT JOIN t_order o ON oi.order_id = o.id |
| | | WHERE o.deleted=0 |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND','COMPLETED','EVALUATE') |
| | | and oi.supplier_id = #{dto.supplierId} |
| | | ) t |
| | | ) t2 |
| | | |
| | | |
| | | </sql> |
| | | |
| | | <sql id="supplier_settlement_amount_timing3"> |
| | | select |
| | | sum(t2.final_price) as settlement_amount |
| | | from( |
| | | select |
| | | t.order_item_id, |
| | | t.supplier_id, |
| | | t.supplier_price, |
| | | t.supplier_price*(t.num-t.replace_num-t.lack_num )- t.deduct_amount -t.fee_supplier-t.station_fee as final_price, |
| | | t.fee_supplier, |
| | | t.station_fee |
| | | from ( |
| | | SELECT |
| | | o.order_no, |
| | | oi.id as order_item_id, |
| | | oi.supplier_id, |
| | | o.payment_time, |
| | | oi.supplier_price, |
| | | oi.num as num, |
| | | IFNULL( (select oic.deduct_amount from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'reduce' and oic.audit_status='AGREED'),0) as deduct_amount, |
| | | IFNULL( (select oic.num from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'replace' and oic.audit_status='AGREED'),0) as replace_num, |
| | | IFNULL( (select oic.num from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'lack' and oic.audit_status='AGREED'),0) as lack_num, |
| | | IFNULL( (select ois.fee_supplier from t_order_item_sales ois where ois.deleted=0 and ois.order_item_id = oi.id and ois.status='AGREED'),0) as fee_supplier, |
| | |
| | | and oi.supplier_id = #{dto.supplierId} |
| | | ) t |
| | | ) t2 |
| | | |
| | | </sql> |
| | | |
| | | </mapper> |
| | |
| | | on oi.order_id=o.id |
| | | left join t_code_value check_type |
| | | on check_type.value=oic.type and check_type.type_code='CHECK_TYPE' |
| | | where |
| | | o.deleted=0 |
| | | where o.deleted=0 |
| | | and oic.type in ('lack','replace') |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | and oic.deleted=0 and oic.audit_status='AGREED' and oi.deleted=0 and o.deleted=0 |
| | | and o.payment_time >= #{dto.walletOnlineTime} |
| | |
| | | <if test="dto.endDate != null"> |
| | | and DATE_FORMAT(o.payment_time, '%Y-%m-%d') <= #{dto.endDate} |
| | | </if> |
| | | union |
| | | select oic.id as id , |
| | | oic.deduct_amount AS fee, |
| | | oic.audit_time AS audit_time, |
| | | o.payment_time as payment_time, |
| | | oic.type as type, |
| | | check_type.label as type_name, |
| | | o.order_no as order_no, |
| | | oi.supplier_id as supplier_id |
| | | from t_order_item_check oic |
| | | left join t_order_item oi |
| | | on oic.order_item_id=oi.id |
| | | left join t_order o |
| | | on oi.order_id=o.id |
| | | left join t_code_value check_type |
| | | on check_type.value=oic.type and check_type.type_code='CHECK_TYPE' |
| | | where o.deleted=0 |
| | | and oic.type in ('reduce') |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | and oic.deleted=0 and oic.audit_status='AGREED' and oi.deleted=0 and o.deleted=0 |
| | | and o.payment_time >= #{dto.walletOnlineTime} |
| | | <if test="dto.supplierId != null"> |
| | | and oi.supplier_id = #{dto.supplierId} |
| | | </if> |
| | | <!-- <if test="dto.startDate != null">--> |
| | | <!-- and DATE_FORMAT(oic.audit_time, '%Y-%m-%d') >= #{dto.startDate}--> |
| | | <!-- </if>--> |
| | | <!-- <if test="dto.endDate != null">--> |
| | | <!-- and DATE_FORMAT(oic.audit_time, '%Y-%m-%d') <= #{dto.endDate}--> |
| | | <!-- </if>--> |
| | | <if test="dto.startDate != null"> |
| | | and DATE_FORMAT(o.payment_time, '%Y-%m-%d') >= #{dto.startDate} |
| | | </if> |
| | | <if test="dto.endDate != null"> |
| | | and DATE_FORMAT(o.payment_time, '%Y-%m-%d') <= #{dto.endDate} |
| | | </if> |
| | | |
| | | ) t |
| | | |
| | | order by audit_time desc |
| | | </select> |
| | | <select id="getCheckReduceAmount" resultType="java.math.BigDecimal"> |
| | | <select id="getCheckLackReplaceAmount" resultType="java.math.BigDecimal"> |
| | | select sum(oic.num*oi.supplier_price) |
| | | from t_order_item_check oic |
| | | left join t_order_item oi |
| | |
| | | left join t_code_value check_type |
| | | on check_type.value=oic.type and check_type.type_code='CHECK_TYPE' |
| | | where o.deleted=0 |
| | | and oic.type in ('lack','replace') |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | and oic.deleted=0 and oic.audit_status='AGREED' and oi.deleted=0 and o.deleted=0 |
| | | and oi.supplier_id = #{dto.supplierId} |
| | |
| | | and oi.supplier_id = #{dto.supplierId} |
| | | and o.payment_time >= #{dto.startTime} |
| | | </select> |
| | | |
| | | <select id="getStationFeeAmount" resultType="java.math.BigDecimal"> |
| | | SELECT sum(ois.station_fee) |
| | | FROM t_order_item_settlement ois |
| | | join t_order_item oi on oi.id = ois.order_item_id |
| | | left join t_order o on oi.order_id=o.id |
| | | join t_order_item oi on oi.id = ois.order_item_id |
| | | left join t_order o on oi.order_id=o.id |
| | | where o.deleted=0 |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | and ois.deleted=0 and oi.deleted=0 |
| | | and oi.supplier_id = #{dto.supplierId} |
| | | and o.payment_time >= #{dto.startTime} |
| | | </select> |
| | | <select id="getCheckReduceAmount" resultType="java.math.BigDecimal"> |
| | | select sum(oic.deduct_amount) |
| | | from t_order_item_check oic |
| | | left join t_order_item oi |
| | | on oic.order_item_id=oi.id |
| | | left join t_order o |
| | | on oi.order_id=o.id |
| | | left join t_code_value check_type |
| | | on check_type.value=oic.type and check_type.type_code='CHECK_TYPE' |
| | | where o.deleted=0 |
| | | and oic.type in ('reduce') |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | and oic.deleted=0 and oic.audit_status='AGREED' and oi.deleted=0 and o.deleted=0 |
| | | and oi.supplier_id = #{dto.supplierId} |
| | | and o.payment_time >= #{dto.startTime} |
| | | |
| | | </select> |
| | | </mapper> |