diff --git a/归档/moved/order/order-service-impl/src/test/java/cn/iocoder/mall/order/biz/service/OrderCommentJobTest.java b/归档/moved/order/order-service-impl/src/test/java/cn/iocoder/mall/order/biz/service/OrderCommentJobTest.java deleted file mode 100644 index cca14c8b1..000000000 --- a/归档/moved/order/order-service-impl/src/test/java/cn/iocoder/mall/order/biz/service/OrderCommentJobTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.mall.order.biz.service; - -import cn.iocoder.mall.order.api.OrderCommentService; -import cn.iocoder.mall.order.api.bo.OrderCommentTimeOutBO; -import cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO; -import cn.iocoder.mall.order.biz.OrderApplicationTest; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * 订单评论自动好评任务测试 - * - * @author wtz - * @time 2019-06-17 19:09 - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = OrderApplicationTest.class) -@ActiveProfiles("dev") -public class OrderCommentJobTest { - - @Autowired - private OrderCommentService orderCommentService; - - @Test - public void createOrderCommentJob(){ - OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO=new OrderCommentTimeOutPageDTO(); - orderCommentTimeOutPageDTO.setCommentState(0); - orderCommentTimeOutPageDTO.setPageNo(0); - orderCommentTimeOutPageDTO.setPageSize(10); - orderCommentTimeOutPageDTO.setOverDay(7); - List orderCommentTimeOutBOList = orderCommentService.getOrderCommentTimeOutPage(orderCommentTimeOutPageDTO); - - - orderCommentService.updateBatchOrderCommentState(orderCommentTimeOutBOList); - - } - -} diff --git a/归档/moved/pay/pay-application/src/test/java/PayRefundServiceImplTest.java b/归档/moved/pay/pay-application/src/test/java/PayRefundServiceImplTest.java deleted file mode 100644 index 35c18810b..000000000 --- a/归档/moved/pay/pay-application/src/test/java/PayRefundServiceImplTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.mall.pay.biz.service; - -import cn.iocoder.mall.pay.api.PayRefundService; -import cn.iocoder.mall.pay.api.dto.refund.PayRefundSubmitDTO; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) -public class PayRefundServiceImplTest { - - @Autowired - private PayRefundService payRefundService; - - @Test - public void testSubmitRefund() { - PayRefundSubmitDTO payRefundSubmitDTO = new PayRefundSubmitDTO() - .setAppId("POd4RC6a") - .setCreateIp("127.0.0.1") - .setOrderId("13500000") - .setOrderDescription("测试下退款") - .setPrice(1); - payRefundService.submitRefund(payRefundSubmitDTO); - } - -} diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/PromotionErrorCodeConstants.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/PromotionErrorCodeConstants.java index d8834727b..24cfb762e 100644 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/PromotionErrorCodeConstants.java +++ b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/PromotionErrorCodeConstants.java @@ -11,18 +11,12 @@ public interface PromotionErrorCodeConstants { // ========== COUPON TEMPLATE 模块 ========== ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1006002000, "优惠劵模板(码)不存在"); - ErrorCode COUPON_TEMPLATE_NOT_CARD = new ErrorCode(1006002001, "不是优惠劵模板"); - ErrorCode COUPON_TEMPLATE_NOT_CODE = new ErrorCode(1006002002, "不是优惠码模板"); - ErrorCode COUPON_TEMPLATE_TOTAL_CAN_NOT_REDUCE = new ErrorCode(1006002003, "优惠劵(码)模板的发放数量不能减小"); ErrorCode COUPON_TEMPLATE_STATUS_NOT_ENABLE = new ErrorCode(1006002004, "优惠劵模板(码)未开启"); ErrorCode COUPON_TEMPLATE_TOTAL_NOT_ENOUGH = new ErrorCode(1006002005, "优惠劵(码)模板的发放量不足"); ErrorCode COUPON_TEMPLATE_CARD_ADD_EXCEED_QUOTA = new ErrorCode(1006002006, "优惠劵领取到达上限"); // ========== COUPON CARD 模块 ========== ErrorCode COUPON_CARD_NOT_EXISTS = new ErrorCode(1006003000, "优惠劵不存在"); - ErrorCode COUPON_CARD_ERROR_USER = new ErrorCode(1006003001, "优惠劵不属于当前用户"); - ErrorCode COUPON_CARD_NOT_MATCH = new ErrorCode(1006003002, "优惠劵不匹配,无法使用"); - ErrorCode COUPON_CARD_STATUS_NOT_UNUSED = new ErrorCode(1006003003, "优惠劵不处于待使用状态"); ErrorCode COUPON_CARD_STATUS_NOT_USED = new ErrorCode( 1006003004, "优惠劵不处于已使用状态"); } diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityFeign.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityFeign.java deleted file mode 100644 index f7b197b5d..000000000 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/PromotionActivityFeign.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.activity; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; -import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO; -import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -import java.util.List; - -/** - * Title: - * Description: - * - * @author zhuyang - * @version 1.0 2021/10/9 - */ -@FeignClient("promotion-service") -public interface PromotionActivityFeign { - - @PostMapping("/promotion/activity/pagePromotionActivity") - CommonResult> pagePromotionActivity(@RequestBody PromotionActivityPageReqDTO pageReqDTO) ; - @PostMapping("/promotion/activity/listPromotionActivities") - CommonResult> listPromotionActivities(@RequestBody PromotionActivityListReqDTO listReqDTO) ; -} diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/dto/PromotionActivityListReqDTO.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/dto/PromotionActivityListReqDTO.java deleted file mode 100644 index dce76f1d3..000000000 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/activity/dto/PromotionActivityListReqDTO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.activity.dto; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Collection; - -/** - * 促销活动列表查询的 Request DTO - */ -@Data -@Accessors(chain = true) -public class PromotionActivityListReqDTO implements Serializable { - - /** - * 活动编号数组 - */ - private Collection activeIds; - -} diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardFeign.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardFeign.java index 7ff4a14ff..118a4c149 100644 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardFeign.java +++ b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/CouponCardFeign.java @@ -9,27 +9,16 @@ import org.springframework.web.bind.annotation.RequestBody; import java.util.List; -/** - * Title: - * Description: - * - * @author zhuyang - * @version 1.0 2021/10/9 - */ @FeignClient("promotion-service") public interface CouponCardFeign { + @PostMapping("/coupon/card/pageCouponCard") public CommonResult> pageCouponCard(@RequestBody CouponCardPageReqDTO pageReqDTO) ; @PostMapping("/coupon/card/createCouponCard") public CommonResult createCouponCard(@RequestBody CouponCardCreateReqDTO createReqDTO); - @PostMapping("/coupon/card/useCouponCard") - public CommonResult useCouponCard(@RequestBody CouponCardUseReqDTO useReqDTO) ; - @PostMapping("/coupon/card/cancelUseCouponCard") public CommonResult cancelUseCouponCard(@RequestBody CouponCardCancelUseReqDTO cancelUseReqDTO) ; - @PostMapping("/coupon/card/listAvailableCouponCards") - public CommonResult> listAvailableCouponCards(@RequestBody CouponCardAvailableListReqDTO listReqDTO); } diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardAvailableListReqDTO.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardAvailableListReqDTO.java deleted file mode 100644 index a8bc17345..000000000 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardAvailableListReqDTO.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.coupon.dto.card; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.io.Serializable; -import java.util.List; - -/** - * 优惠劵可用信息列表 Request DTO - */ -@Data -@Accessors(chain = true) -public class CouponCardAvailableListReqDTO implements Serializable { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Integer userId; - /** - * 商品数组 - */ - @NotEmpty(message = "商品数组不能为空") - private List items; - - /** - * 商品 - */ - @Data - @Accessors(chain = true) - public static class Item implements Serializable { - - /** - * 商品 SPU 编号 - */ - @NotNull(message = "商品 SPU 编号不能为空") - private Integer spuId; - /** - * 商品 SKU 编号 - */ - @NotNull(message = "商品 SKU 编号不能为空") - private Integer skuId; - /** - * 商品 SKU 编号 - */ - @NotNull(message = "商品 Category 编号不能为空") - private Integer cid; - /** - * 商品数量 - */ - @NotNull(message = "商品数量不能为空") - @Min(value = 1L, message = "最小商品数量 1") - private Integer quantity; - /** - * 商品价格,单位:分 - * - * 为什么需要传递价格?因为商品的价格是经过计算,部署商品原始价格 - */ - @NotNull(message = "商品价格不能为空") - private Integer price; - - } - -} diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardAvailableRespDTO.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardAvailableRespDTO.java deleted file mode 100644 index cd09bbebd..000000000 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardAvailableRespDTO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.coupon.dto.card; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -/** - * 可用优惠劵 BO - * - * 注意,如果优惠劵不可用,标记 available = false ,并写明 unavailableReason 原因 - */ -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class CouponCardAvailableRespDTO extends CouponCardRespDTO { - - /** - * 是否可用 - */ - private Boolean available; - /** - * 不可用原因 - */ - private String unavailableReason; - -} diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardCreateReqDTO.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardCreateReqDTO.java deleted file mode 100644 index 8b7cdf2ab..000000000 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardCreateReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.coupon.dto.card; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -/** - * 优惠劵创建 Request DTO - */ -@Data -@Accessors(chain = true) -public class CouponCardCreateReqDTO implements Serializable { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Integer userId; - /** - * 优惠劵模板编号 - */ - @NotNull(message = "优惠劵模板编号不能为空") - private Integer couponTemplateId; - -} diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardUseReqDTO.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardUseReqDTO.java deleted file mode 100644 index 534b7fc0b..000000000 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/rpc/coupon/dto/card/CouponCardUseReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.mall.promotion.api.rpc.coupon.dto.card; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -/** - * 优惠劵使用 Request DTO - */ -@Data -@Accessors(chain = true) -public class CouponCardUseReqDTO implements Serializable { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Integer userId; - /** - * 优惠劵编号 - */ - @NotNull(message = "优惠劵编号不能为空") - private Integer couponCardId; - -} diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/activity/PromotionActivityMapper.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/activity/PromotionActivityMapper.java deleted file mode 100644 index c23c0be23..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/activity/PromotionActivityMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.mall.promotionservice.dal.mysql.mapper.activity; - -import cn.iocoder.mall.mybatis.core.query.QueryWrapperX; -import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; -import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO; -import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.activity.PromotionActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Repository; - -import java.util.Collection; -import java.util.List; - -@Repository -public interface PromotionActivityMapper extends BaseMapper { - - default List selectListByStatus(Collection statuses) { - return selectList(new QueryWrapper().in("status", statuses)); - } - - default IPage selectPage(PromotionActivityPageReqDTO pageReqDTO) { - return selectPage(new Page<>(pageReqDTO.getPageNo(), pageReqDTO.getPageSize()), - new QueryWrapperX().likeIfPresent("title", pageReqDTO.getTitle()) - .eqIfPresent("activity_type", pageReqDTO.getActivityType()) - .inIfPresent("status", pageReqDTO.getStatuses())); - } - - default List selectList(PromotionActivityListReqDTO listReqDTO) { - return selectList(new QueryWrapperX().inIfPresent("id", listReqDTO.getActiveIds())); - } - -} diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/coupon/CouponCardMapper.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/coupon/CouponCardMapper.java index cea36848b..63158619d 100644 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/coupon/CouponCardMapper.java +++ b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/coupon/CouponCardMapper.java @@ -19,16 +19,6 @@ public interface CouponCardMapper extends BaseMapper { .eq("status", status)); } - default int selectCountByUserIdAndTemplateId(Integer userId, Integer templateId) { - return selectCount(new QueryWrapper().eq("user_id", userId) - .eq("template_id", templateId)); - } - - default int updateByIdAndStatus(Integer id, Integer status, CouponCardDO updateObj) { - return update(updateObj, new QueryWrapper().eq("id", id) - .eq("status", status)); - } - default IPage selectPage(CouponCardPageReqDTO pageReqDTO) { return selectPage(new Page<>(pageReqDTO.getPageNo(), pageReqDTO.getPageSize()), new QueryWrapperX().eqIfPresent("user_id", pageReqDTO.getUserId()) diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/activity/PromotionActivityService.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/activity/PromotionActivityService.java index 7150c6b3e..36d4f9d9c 100644 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/activity/PromotionActivityService.java +++ b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/activity/PromotionActivityService.java @@ -70,11 +70,6 @@ public class PromotionActivityService { return PromotionActivityConvert.INSTANCE.convertList(activityList); } - public PageResult pagePromotionActivity(PromotionActivityPageReqDTO pageReqDTO) { - IPage promotionActivityPage = promotionActivityMapper.selectPage(pageReqDTO); - return PromotionActivityConvert.INSTANCE.convertPage(promotionActivityPage); - } - private boolean isSpuMatchTimeLimitDiscount(Integer spuId, PromotionActivityDO activity) { Assert.isTrue(PromotionActivityTypeEnum.TIME_LIMITED_DISCOUNT.getValue().equals(activity.getActivityType()), "传入的必须的促销活动必须是限时折扣"); diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/coupon/CouponCardService.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/coupon/CouponCardService.java index c95425bc2..e3bddcd5e 100644 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/coupon/CouponCardService.java +++ b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/coupon/CouponCardService.java @@ -37,11 +37,6 @@ import java.util.stream.Collectors; @Validated public class CouponCardService { - @Autowired - private CouponCardMapper couponCardMapper; - @Autowired - private CouponTemplateMapper couponTemplateMapper; - /** * 获得用户的优惠劵 * @@ -127,35 +122,6 @@ public class CouponCardService { return card.getId(); } - /** - * 用户使用优惠劵 - * - * @param userId 用户编号 - * @param couponCardId 优惠劵编号 - */ - public void useCouponCard(Integer userId, Integer couponCardId) { - // 查询优惠劵 - CouponCardDO card = couponCardMapper.selectById(couponCardId); - if (card == null) { - throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_CARD_NOT_EXISTS.getCode()); - } - if (!userId.equals(card.getUserId())) { - throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_CARD_ERROR_USER.getCode()); - } - if (!CouponCardStatusEnum.UNUSED.getValue().equals(card.getStatus())) { - throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_CARD_STATUS_NOT_UNUSED.getCode()); - } - if (DateUtil.isBetween(card.getValidStartTime(), card.getValidEndTime())) { // 为避免定时器没跑,实际优惠劵已经过期 - throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_CARD_STATUS_NOT_UNUSED.getCode()); - } - // 更新优惠劵已使用 - int updateCount = couponCardMapper.updateByIdAndStatus(card.getId(), CouponCardStatusEnum.UNUSED.getValue(), - new CouponCardDO().setStatus(CouponCardStatusEnum.USED.getValue()).setUsedTime(new Date())); - if (updateCount == 0) { - throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_CARD_STATUS_NOT_UNUSED.getCode()); - } - } - /** * 用户取消使用优惠劵 * @@ -168,9 +134,6 @@ public class CouponCardService { if (card == null) { throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_CARD_NOT_EXISTS.getCode()); } - if (!userId.equals(card.getUserId())) { - throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_CARD_ERROR_USER.getCode()); - } if (!CouponCardStatusEnum.USED.getValue().equals(card.getStatus())) { throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_CARD_STATUS_NOT_USED.getCode()); } @@ -183,67 +146,6 @@ public class CouponCardService { // 有一点要注意,更新会未使用时,优惠劵可能已经过期了,直接让定时器跑过期,这里不做处理。 } - /** - * 获得用户优惠劵的可用信息列表 - * - * @param listReqDTO 查询信息 - * @return 优惠劵的可用信息列表 - */ - public List listAvailableCouponCards(CouponCardAvailableListReqDTO listReqDTO) { - // 查询用户未使用的优惠劵列表 - List cards = couponCardMapper.selectListByUserIdAndStatus(listReqDTO.getUserId(), CouponCardStatusEnum.UNUSED.getValue()); - if (cards.isEmpty()) { - return Collections.emptyList(); - } - // 查询优惠劵模板集合 - Map templates = CollectionUtils.convertMap( - couponTemplateMapper.selectBatchIds(CollectionUtils.convertSet(cards, CouponCardDO::getTemplateId)), - CouponTemplateDO::getId); - // 逐个判断是否可用 - return cards.stream().map(card -> { - CouponCardAvailableRespDTO availableCard = CouponCardConvert.INSTANCE.convert01(card); - availableCard.setUnavailableReason(isMatch(card, templates.get(card.getTemplateId()), listReqDTO.getItems())); - availableCard.setAvailable(availableCard.getUnavailableReason() == null); - return availableCard; - }).collect(Collectors.toList()); - } - - /** - * 匹配商品是否可以使用指定优惠劵 - * - * @param card 优惠劵 - * @param template 优惠劵模板 - * @param items 商品 SKU 数组 - * @return 如果不匹配,返回原因 - */ - private String isMatch(CouponCardDO card, CouponTemplateDO template, List items) { - int totalPrice = 0; - if (RangeTypeEnum.ALL.getValue().equals(template.getRangeType())) { - totalPrice = items.stream().mapToInt(spu -> spu.getPrice() * spu.getQuantity()).sum(); - } else if (RangeTypeEnum.PRODUCT_INCLUDE_PART.getValue().equals(template.getRangeType())) { - List spuIds = StringUtils.splitToInt(template.getRangeValues(), ","); - totalPrice = items.stream().mapToInt(spu -> spuIds.contains(spu.getSpuId()) ? spu.getPrice() * spu.getQuantity() : 0).sum(); - } else if (RangeTypeEnum.PRODUCT_EXCLUDE_PART.getValue().equals(template.getRangeType())) { - List spuIds = StringUtils.splitToInt(template.getRangeValues(), ","); - totalPrice = items.stream().mapToInt(spu -> !spuIds.contains(spu.getSpuId()) ? spu.getPrice() * spu.getQuantity() : 0).sum(); - } else if (RangeTypeEnum.CATEGORY_INCLUDE_PART.getValue().equals(template.getRangeType())) { - List spuIds = StringUtils.splitToInt(template.getRangeValues(), ","); - totalPrice = items.stream().mapToInt(spu -> spuIds.contains(spu.getCid()) ? spu.getPrice() * spu.getQuantity() : 0).sum(); - } else if (RangeTypeEnum.CATEGORY_EXCLUDE_PART.getValue().equals(template.getRangeType())) { - List spuIds = StringUtils.splitToInt(template.getRangeValues(), ","); - totalPrice = items.stream().mapToInt(spu -> !spuIds.contains(spu.getCid()) ? spu.getPrice() * spu.getQuantity() : 0).sum(); - } - // 总价为 0 时,说明优惠劵丫根不匹配 - if (totalPrice == 0) { - return "优惠劵不匹配"; - } - // 如果不满足金额 - if (totalPrice < card.getPriceAvailable()) { - return String.format("差 %1$,.2f 元可用优惠劵", (card.getPriceAvailable() - totalPrice) / 100D); - } - return null; - } - private void setCouponCardValidTime(CouponCardDO card, CouponTemplateDO template) { if (CouponTemplateDateTypeEnum.FIXED_DATE.getValue().equals(template.getDateType())) { card.setValidStartTime(template.getValidStartTime()).setValidEndTime(template.getValidEndTime()); diff --git a/归档/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/trade/TradeOrderClient.java b/归档/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/trade/TradeOrderClient.java index 1029f1fa6..9989d82b0 100644 --- a/归档/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/trade/TradeOrderClient.java +++ b/归档/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/trade/TradeOrderClient.java @@ -14,9 +14,9 @@ import java.util.Arrays; @Service public class TradeOrderClient { - @Autowired private TradeOrderFeign tradeOrderFeign; + public Integer createTradeOrder(TradeOrderCreateReqDTO createReqDTO) { CommonResult createTradeOrderResult = tradeOrderFeign.createTradeOrder(createReqDTO); createTradeOrderResult.checkError(); diff --git a/归档/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/dto/TradeOrderCreateReqDTO.java b/归档/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/dto/TradeOrderCreateReqDTO.java deleted file mode 100644 index 78f7f0deb..000000000 --- a/归档/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/dto/TradeOrderCreateReqDTO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.mall.tradeservice.rpc.order.dto; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.io.Serializable; -import java.util.List; - -/** - * 交易订单创建 Request DTO - * - * @author Sin - * @time 2019-03-16 14:42 - */ -@Data -@Accessors(chain = true) -public class TradeOrderCreateReqDTO implements Serializable { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Integer userId; - /** - * 用户 IP - */ - @NotNull(message = "用户 IP 不能为空") - private String ip; - /** - * 收件地址编号 - */ - @NotNull(message = "用户地址不能为空") - private Integer userAddressId; - /** - * 优惠劵编号 - */ - private Integer couponCardId; - /** - * 备注 - */ - private String remark; - - /** - * 订单商品项列表 - */ - @NotNull(message = "必须选择购买的商品") - private List orderItems; - - - @Data - @Accessors(chain = true) - public static class OrderItem implements Serializable { - - /** - * 商品编号 - */ - @NotNull(message = "商品 SKU 编号不能为空") - private Integer skuId; - /** - * 数量 - */ - @NotNull(message = "商品 SKU 购买数量不能为空") - @Min(value = 1, message = "商品 SKU 购买数量必须大于 0") - private Integer quantity; - } - -} diff --git a/归档/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/controller/TradeOrderController.java b/归档/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/controller/TradeOrderController.java index f27e4d35e..98b0fd84b 100644 --- a/归档/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/controller/TradeOrderController.java +++ b/归档/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/controller/TradeOrderController.java @@ -23,8 +23,10 @@ import static cn.iocoder.common.framework.vo.CommonResult.success; @RestController @RequestMapping("/trade/order") public class TradeOrderController { + @Autowired private TradeOrderService tradeOrderService; + /** * 创建交易订单 * @@ -59,8 +61,6 @@ public class TradeOrderController { return success(tradeOrderService.pageTradeOrder(pageDTO)); } - // TODO 芋艿:需要重构成入参是 DTO,方便后续升级;返回是 CommonResult,用于返回失败的原因 - /** * 更新交易订单支付成功 * @@ -75,4 +75,5 @@ public class TradeOrderController { tradeOrderService.updateTradeOrderPaySuccess(Integer.valueOf(tradeOrderId), payAmount); return success(true); } + }