From 8e1ade5423b42b8e43a10f18b2d1be18526e24da Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 20 Jan 2022 09:27:07 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E9=87=8D=E5=A4=8D=E4=BB=A3=E7=A0=81=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kit/plugin/wechat/WechatPlugin.java | 10 ------- .../dto/payment/WechatPaymentSetting.java | 27 ++++++++++++++++++- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java index a6e0972b..e4145c41 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java @@ -258,9 +258,6 @@ public class WechatPlugin implements Payment { WechatPaymentSetting setting = wechatPaymentSetting(); String appid = setting.getAppId(); - if (appid == null) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel() .setAppid(appid) .setMchid(setting.getMchId()) @@ -326,9 +323,6 @@ public class WechatPlugin implements Payment { WechatPaymentSetting setting = wechatPaymentSetting(); String appid = setting.getServiceAppId(); - if (appid == null) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel() .setAppid(appid) .setMchid(setting.getMchId()) @@ -397,10 +391,6 @@ public class WechatPlugin implements Payment { //微信小程序,appid 需要单独获取,这里读取了联合登陆配置的appid ,实际场景小程序自动登录,所以这个appid是最为保险的做法 //如果有2开需求,这里需要调整,修改这个appid的获取途径即可 String appid = wechatPaymentSetting().getMpAppId(); - if (appid == null) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } - String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); WechatPaymentSetting setting = wechatPaymentSetting(); diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java index 9dc4a73d..b3d8e9f9 100644 --- a/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java @@ -1,5 +1,8 @@ package cn.lili.modules.system.entity.dto.payment; +import cn.lili.common.enums.ResultCode; +import cn.lili.common.exception.ServiceException; +import com.alibaba.druid.util.StringUtils; import lombok.Data; import lombok.experimental.Accessors; @@ -14,7 +17,7 @@ import lombok.experimental.Accessors; public class WechatPaymentSetting { /** - * APP应用id + * APP应用id */ private String appId; /** @@ -49,4 +52,26 @@ public class WechatPaymentSetting { * apiv3私钥 */ private String apiKey3; + + public String getAppId() { + + if (StringUtils.isEmpty(appId)) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } + return appId; + } + + public String getMpAppId() { + if (StringUtils.isEmpty(mpAppId)) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } + return mpAppId; + } + + public String getServiceAppId() { + if (StringUtils.isEmpty(serviceAppId)) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } + return serviceAppId; + } } From 4fb170e5c7d7cbea162bb5757180bab249876ee9 Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 20 Jan 2022 11:01:24 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=BB=93=E6=9E=9C=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/payment/kit/plugin/alipay/AliPayPlugin.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java index 15cade4a..95381545 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java @@ -273,7 +273,7 @@ public class AliPayPlugin implements Payment { log.info("支付回调通知:支付失败-参数:{}", map); } - ThreadContextHolder.getHttpResponse().sendRedirect(domainProperties.getWap()+"/pages/order/myOrder?status=0"); + ThreadContextHolder.getHttpResponse().sendRedirect(domainProperties.getWap() + "/pages/order/myOrder?status=0"); } catch (Exception e) { log.error("支付回调同步通知异常", e); } @@ -293,7 +293,10 @@ public class AliPayPlugin implements Payment { log.info("支付回调响应:{}", JSONUtil.toJsonStr(map)); boolean verifyResult = AlipaySignature.rsaCertCheckV1(map, alipayPaymentSetting.getAlipayPublicCertPath(), "UTF-8", "RSA2"); - + //支付完成 + if (!"TRADE_FINISHED".equals(map.get("trade_status"))) { + return; + } String payParamStr = map.get("passback_params"); String payParamJson = URLDecoder.decode(payParamStr, StandardCharsets.UTF_8); PayParam payParam = BeanUtil.formatKeyValuePair(payParamJson, new PayParam()); From 007d69a887fd9db1137f224d1a16876a0fb6164b Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 20 Jan 2022 15:59:26 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java index 95381545..27102b26 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/alipay/AliPayPlugin.java @@ -293,8 +293,9 @@ public class AliPayPlugin implements Payment { log.info("支付回调响应:{}", JSONUtil.toJsonStr(map)); boolean verifyResult = AlipaySignature.rsaCertCheckV1(map, alipayPaymentSetting.getAlipayPublicCertPath(), "UTF-8", "RSA2"); - //支付完成 - if (!"TRADE_FINISHED".equals(map.get("trade_status"))) { + //支付完成判定 + if (!"TRADE_FINISHED".equals(map.get("trade_status")) && + !"TRADE_SUCCESS".equals(map.get("trade_status"))) { return; } String payParamStr = map.get("passback_params"); From 96e779eb28feb50200aa7e55a0461ebd6a72ff5f Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 12:07:16 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=AF=B9=E4=BA=A4=E6=98=93=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=9A=84=E5=88=A4=E5=AE=9A=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/order/order/entity/dos/Trade.java | 2 ++ .../modules/order/order/serviceimpl/OrderServiceImpl.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java index dbde25c5..b8a8aaa8 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/Trade.java @@ -1,5 +1,6 @@ package cn.lili.modules.order.order.entity.dos; +import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.mybatis.BaseEntity; import cn.lili.common.utils.BeanUtil; import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum; @@ -82,6 +83,7 @@ public class Trade extends BaseEntity { } BeanUtil.copyProperties(tradeDTO, this); BeanUtil.copyProperties(tradeDTO.getPriceDetailDTO(), this); + this.setPayStatus(PayStatusEnum.UNPAID.name()); this.setId(originId); } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index e51286fb..6c06126a 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -642,7 +642,9 @@ public class OrderServiceImpl extends ServiceImpl implements public Double getPaymentTotal(String orderSn) { Order order = this.getBySn(orderSn); Trade trade = tradeService.getBySn(order.getTradeSn()); - if (trade.getPayStatus().equals(PayStatusEnum.PAID.name())) { + //如果交易不为空,则返回交易的金额,否则返回订单金额 + if (StringUtils.isNotEmpty(trade.getPayStatus()) + && trade.getPayStatus().equals(PayStatusEnum.PAID.name())) { return trade.getFlowPrice(); } return order.getFlowPrice(); From 7164036d4cf13886e6aa98a5ac06135643b6c7bb Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 14:34:05 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E6=97=B6=EF=BC=8C=E8=AE=A2=E5=8D=95update=20?= =?UTF-8?q?price=E5=AD=97=E6=AE=B5=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/lili/common/utils/CurrencyUtil.java | 4 ++-- .../lili/modules/order/order/entity/dto/PriceDetailDTO.java | 2 +- .../order/order/serviceimpl/OrderPriceServiceImpl.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/utils/CurrencyUtil.java b/framework/src/main/java/cn/lili/common/utils/CurrencyUtil.java index 6b1b9aa2..aa030d6e 100644 --- a/framework/src/main/java/cn/lili/common/utils/CurrencyUtil.java +++ b/framework/src/main/java/cn/lili/common/utils/CurrencyUtil.java @@ -36,9 +36,9 @@ public final class CurrencyUtil { return result.doubleValue(); } /** - * 提供精确的加法运算。 + * 提供精确的减法运算。 * - * @return 累加之和 + * @return 第一个参数为被减数,其余数字为减数 */ public static Double sub(double... params) { BigDecimal result = BigDecimal.valueOf(params[0]); diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java index dcc9ce66..67872901 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java @@ -309,7 +309,7 @@ public class PriceDetailDTO implements Serializable { } public Double getUpdatePrice() { - if (updatePrice == null || updatePrice <= 0) { + if (updatePrice == null) { return 0D; } return updatePrice; diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderPriceServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderPriceServiceImpl.java index dfb0bbd0..0210ffcf 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderPriceServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderPriceServiceImpl.java @@ -16,6 +16,7 @@ import cn.lili.modules.order.order.service.OrderPriceService; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.payment.kit.plugin.bank.BankTransferPlugin; import cn.lili.modules.system.aspect.annotation.SystemLogPoint; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -29,6 +30,7 @@ import java.util.List; * @author Chopper * @since 2020/11/17 7:36 下午 */ +@Slf4j @Service public class OrderPriceServiceImpl implements OrderPriceService { @@ -106,10 +108,8 @@ public class OrderPriceServiceImpl implements OrderPriceService { //订单修改金额=使用订单原始金额-修改后金额 orderPriceDetailDTO.setUpdatePrice(CurrencyUtil.sub(orderPrice, orderPriceDetailDTO.getOriginalPrice())); order.setFlowPrice(orderPriceDetailDTO.getFlowPrice()); - order.setPriceDetail(JSONUtil.toJsonStr(orderPriceDetailDTO)); - //修改订单 - order.setPriceDetail(JSONUtil.toJsonStr(orderPriceDetailDTO)); + order.setPriceDetailDTO(orderPriceDetailDTO); orderService.updateById(order); //修改子订单 From 5051fc7b0be6db94e476d38ced132ba53ef98881 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 15:39:18 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E8=B5=A0=E5=93=81=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=A0=B8=E9=94=80=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/event/impl/FullDiscountExecute.java | 71 +++++++++++++++---- .../order/entity/enums/OrderTypeEnum.java | 7 +- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java b/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java index a1bb9847..a3507d83 100644 --- a/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/FullDiscountExecute.java @@ -10,6 +10,7 @@ import cn.lili.common.utils.SnowFlake; import cn.lili.event.OrderStatusChangeEvent; import cn.lili.event.TradeEvent; import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.enums.GoodsTypeEnum; import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; @@ -34,6 +35,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * 订单状态处理类 @@ -90,6 +92,7 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent { @Override public void orderChange(OrderMessage orderMessage) { + //如果订单已支付 if (orderMessage.getNewStatus().equals(OrderStatusEnum.PAID)) { log.debug("满减活动,订单状态操作 {}", CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()); renderGift(JSONUtil.toBean(cache.getString(CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()), CartVO.class), orderMessage); @@ -142,49 +145,89 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent { * @param originOrder 赠品原订单信息 */ private void generatorGiftOrder(List skuIds, Order originOrder) { + //获取赠品列表 + List goodsSkus = goodsSkuService.getGoodsSkuByIdFromCache(skuIds); + + //赠品判定 + if (goodsSkus == null || goodsSkus.isEmpty()) { + log.error("赠品不存在:{}", skuIds); + return; + } + + //赠品分类,分为实体商品/虚拟商品/电子卡券 + List physicalSkus = goodsSkus.stream().filter(goodsSku -> goodsSku.getGoodsType().equals(GoodsTypeEnum.PHYSICAL_GOODS.name())).collect(Collectors.toList()); + List virtualSkus = goodsSkus.stream().filter(goodsSku -> goodsSku.getGoodsType().equals(GoodsTypeEnum.VIRTUAL_GOODS.name())).collect(Collectors.toList()); + List eCouponSkus = goodsSkus.stream().filter(goodsSku -> goodsSku.getGoodsType().equals(GoodsTypeEnum.E_COUPON.name())).collect(Collectors.toList()); + + //如果赠品不为空,则生成对应的赠品订单 + if (!physicalSkus.isEmpty()) { + giftOrderHandler(physicalSkus, originOrder, OrderTypeEnum.NORMAL); + } + if (!virtualSkus.isEmpty()) { + giftOrderHandler(virtualSkus, originOrder, OrderTypeEnum.VIRTUAL); + } + if (!eCouponSkus.isEmpty()) { + giftOrderHandler(eCouponSkus, originOrder, OrderTypeEnum.E_COUPON); + } + } + + /** + * 赠品订单处理 + * + * @param skuList 赠品列表 + * @param originOrder 原始订单 + * @param orderTypeEnum 订单类型 + */ + private void giftOrderHandler(List skuList, Order originOrder, OrderTypeEnum orderTypeEnum) { + //初始化订单对象/订单日志/自订单 + Order order = new Order(); List orderItems = new ArrayList<>(); List orderLogs = new ArrayList<>(); - Order order = new Order(); + //初始化价格详情 PriceDetailDTO priceDetailDTO = new PriceDetailDTO(); + //复制通用属性 BeanUtil.copyProperties(originOrder, order, "id"); BeanUtil.copyProperties(priceDetailDTO, order, "id"); + //生成订单参数 order.setSn(SnowFlake.createStr("G")); - order.setOrderType(OrderPromotionTypeEnum.GIFT.name()); + order.setOrderPromotionType(OrderPromotionTypeEnum.GIFT.name()); order.setOrderStatus(OrderStatusEnum.UNPAID.name()); order.setPayStatus(PayStatusEnum.PAID.name()); - order.setDeliverStatus(DeliverStatusEnum.UNDELIVERED.name()); + order.setOrderType(orderTypeEnum.name()); order.setNeedReceipt(false); order.setPriceDetailDTO(priceDetailDTO); order.setClientType(originOrder.getClientType()); + //订单日志 String message = "赠品订单[" + order.getSn() + "]创建"; orderLogs.add(new OrderLog(order.getSn(), originOrder.getMemberId(), UserEnums.MEMBER.name(), originOrder.getMemberName(), message)); - for (String skuId : skuIds) { - GoodsSku goodsSkuByIdFromCache = goodsSkuService.getGoodsSkuByIdFromCache(skuId); + //生成子订单 + for (GoodsSku goodsSku : skuList) { OrderItem orderItem = new OrderItem(); - BeanUtil.copyProperties(goodsSkuByIdFromCache, orderItem, "id"); + BeanUtil.copyProperties(goodsSku, orderItem, "id"); BeanUtil.copyProperties(priceDetailDTO, orderItem, "id"); orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.NEW.name()); orderItem.setCommentStatus(CommentStatusEnum.NEW.name()); orderItem.setComplainStatus(OrderComplaintStatusEnum.NEW.name()); orderItem.setNum(1); orderItem.setOrderSn(order.getSn()); - orderItem.setImage(goodsSkuByIdFromCache.getThumbnail()); - orderItem.setGoodsName(goodsSkuByIdFromCache.getGoodsName()); - orderItem.setSkuId(goodsSkuByIdFromCache.getId()); - orderItem.setCategoryId(goodsSkuByIdFromCache.getCategoryPath().substring( - goodsSkuByIdFromCache.getCategoryPath().lastIndexOf(",") + 1 + orderItem.setImage(goodsSku.getThumbnail()); + orderItem.setGoodsName(goodsSku.getGoodsName()); + orderItem.setSkuId(goodsSku.getId()); + orderItem.setCategoryId(goodsSku.getCategoryPath().substring( + goodsSku.getCategoryPath().lastIndexOf(",") + 1 )); - orderItem.setGoodsPrice(goodsSkuByIdFromCache.getPrice()); + orderItem.setGoodsPrice(goodsSku.getPrice()); orderItem.setPriceDetailDTO(priceDetailDTO); orderItems.add(orderItem); } + //保存订单 orderService.save(order); orderItemService.saveBatch(orderItems); orderLogService.saveBatch(orderLogs); - //发送订单已付款消息 + //发送订单已付款消息(PS:不在这里处理逻辑是因为期望加交给消费者统一处理库存等等问题) OrderMessage orderMessage = new OrderMessage(); orderMessage.setOrderSn(order.getSn()); orderMessage.setPaymentMethod(order.getPaymentMethod()); @@ -193,7 +236,5 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent { String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.STATUS_CHANGE.name(); //发送订单变更mq消息 rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(orderMessage), RocketmqSendCallbackBuilder.commonCallback()); - - } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java index 6cd2b9b3..129dce04 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/enums/OrderTypeEnum.java @@ -16,5 +16,10 @@ public enum OrderTypeEnum { /** * 虚拟订单 */ - VIRTUAL + VIRTUAL, + + /** + * 虚拟订单 + */ + E_COUPON, } From a65f0ad38405fada1534a8c909f854246548b905 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 16:18:16 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E7=A7=AF=E5=88=86=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/event/impl/MemberPointExecute.java | 10 +++-- .../system/entity/dto/PointSetting.java | 38 ++++++++++++++++++- .../system/entity/dto/PointSettingItem.java | 11 ++++++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/MemberPointExecute.java b/consumer/src/main/java/cn/lili/event/impl/MemberPointExecute.java index ab4a8d1a..e709ed08 100644 --- a/consumer/src/main/java/cn/lili/event/impl/MemberPointExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/MemberPointExecute.java @@ -103,14 +103,18 @@ public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentComp } case COMPLETED: { Order order = orderService.getBySn(orderMessage.getOrderSn()); - //根据订单编号获取订单数据,如果订单促销类型不为空,并且订单促销类型为积分订单 则直接返回 - if (StringUtils.isNotEmpty(order.getOrderPromotionType()) && order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name())) { + //如果是积分订单 则直接返回 + if (StringUtils.isNotEmpty(order.getOrderPromotionType()) + && order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name())) { return; } //获取积分设置 PointSetting pointSetting = getPointSetting(); + if (pointSetting.getConsumer() == 0) { + return; + } //计算赠送积分数量 - Double point = CurrencyUtil.mul(pointSetting.getMoney(), order.getFlowPrice(), 0); + Double point = CurrencyUtil.mul(pointSetting.getConsumer(), order.getFlowPrice(), 0); //赠送会员积分 memberService.updateMemberPoint(point.longValue(), PointTypeEnum.INCREASE.name(), order.getMemberId(), "会员下单,赠送积分" + point + "分"); break; diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSetting.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSetting.java index 0f32c8a1..6679b454 100644 --- a/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSetting.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSetting.java @@ -20,7 +20,10 @@ public class PointSetting implements Serializable { @ApiModelProperty(value = "注册") private Integer register; - @ApiModelProperty(value = "1元等级*积分") + @ApiModelProperty(value = "消费1元赠送多少积分") + private Integer consumer; + + @ApiModelProperty(value = "积分付款X积分=1元") private Integer money; @ApiModelProperty(value = "每日签到积分") @@ -32,5 +35,38 @@ public class PointSetting implements Serializable { @ApiModelProperty(value = "积分具体设置") private List pointSettingItems = new ArrayList<>(); + public Integer getRegister() { + if (register == null || register < 0) { + return 0; + } + return register; + } + public Integer getMoney() { + if (money == null || money < 0) { + return 0; + } + return money; + } + + public Integer getConsumer() { + if (consumer == null || consumer < 0) { + return 0; + } + return consumer; + } + + public Integer getSignIn() { + if (signIn == null || signIn < 0) { + return 0; + } + return signIn; + } + + public Integer getComment() { + if (comment == null || comment < 0) { + return 0; + } + return comment; + } } diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSettingItem.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSettingItem.java index 31a7b7da..11d061d8 100644 --- a/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSettingItem.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/PointSettingItem.java @@ -20,6 +20,17 @@ public class PointSettingItem implements Comparable { @ApiModelProperty(value = "赠送积分") private Integer point; + public Integer getPoint() { + if (point != null || point < 0) { + return 0; + } + return point; + } + + public void setPoint(Integer point) { + this.point = point; + } + @Override public int compareTo(PointSettingItem pointSettingItem) { return this.day - pointSettingItem.getDay(); From 145406be32d0b0d5b970976dca3b388c9fe4c7c0 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 16:31:06 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E5=AF=B9=E5=95=86=E5=93=81=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=8C=85=E5=90=AB=E9=80=97=E5=8F=B7=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/goods/entity/dto/GoodsOperationDTO.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java index 434948d2..497bc349 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java @@ -103,7 +103,7 @@ public class GoodsOperationDTO implements Serializable { * @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum */ @ApiModelProperty(value = "商品类型") - @EnumValue(strValues = {"PHYSICAL_GOODS","VIRTUAL_GOODS","E_COUPON"},message = "商品类型参数值错误") + @EnumValue(strValues = {"PHYSICAL_GOODS", "VIRTUAL_GOODS", "E_COUPON"}, message = "商品类型参数值错误") private String goodsType; /** @@ -112,6 +112,9 @@ public class GoodsOperationDTO implements Serializable { @ApiModelProperty(value = "商品视频") private String goodsVideo; - - + public String getGoodsName() { + //对商品对名称做一个极限处理。这里没有用xss过滤是因为xss过滤为全局过滤,影响很大。 + // 业务中,全局代码中只有商品名称不能拥有英文逗号,是由于商品名称存在一个数据库联合查询,结果要根据逗号分组 + return goodsName.replace(",", ""); + } } From 576b5b213e5474449dd0f16a47900f9fa5244bdf Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 Jan 2022 17:00:10 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7707fe53..f57e702b 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ PS:手机验证码为 ‘111111’ #### 平台管理端功能 -![平台管理端功能](https://pickmall.cn/assets/imgs/other/managerList.jpg) +![平台管理端功能](https://pickmall.cn/assets/imgs/other/managerList1.jpg)