From d3fdeef0c3677f71b33f61cefcde666c8485a511 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 19 May 2021 22:16:05 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=A4=9A=E9=80=89=E9=97=AE=E9=A2=98=E5=92=8C?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E5=8F=96=E6=B6=88=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E4=BF=83=E9=94=80=E6=B4=BB=E5=8A=A8=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=88=A0=E9=99=A4es=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E8=BF=87=E6=9C=9F=E4=BF=A1=E6=81=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../promotion/PromotionEverydayExecute.java | 7 ++++ .../serviceimpl/GoodsSkuServiceImpl.java | 2 - .../search/service/EsGoodsIndexService.java | 6 +++ .../serviceimpl/EsGoodsIndexServiceImpl.java | 37 ++++++++++++++++++- .../serviceimpl/EsGoodsSearchServiceImpl.java | 29 ++++++++++++--- 5 files changed, 72 insertions(+), 9 deletions(-) diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java index f0e67719..946931a3 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java @@ -8,6 +8,7 @@ import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum; import cn.lili.modules.promotion.entity.vos.CouponVO; import cn.lili.modules.promotion.entity.vos.PintuanVO; import cn.lili.modules.promotion.service.*; +import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.timetask.handler.EveryDayExecute; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; @@ -34,6 +35,9 @@ public class PromotionEverydayExecute implements EveryDayExecute { //Mongo @Autowired private MongoTemplate mongoTemplate; + //es + @Autowired + private EsGoodsIndexService esGoodsIndexService; //满额活动 @Autowired private FullDiscountService fullDiscountService; @@ -74,6 +78,7 @@ public class PromotionEverydayExecute implements EveryDayExecute { if (vo.getPromotionGoodsList() != null && !vo.getPromotionGoodsList().isEmpty()) { for (PromotionGoods promotionGoods : vo.getPromotionGoodsList()) { promotionGoods.setPromotionStatus(PromotionStatusEnum.END.name()); + esGoodsIndexService.deleteEsGoodsPromotionByPromotionId(promotionGoods.getSkuId(), vo.getId()); } } mongoTemplate.save(vo); @@ -92,6 +97,7 @@ public class PromotionEverydayExecute implements EveryDayExecute { if (vo.getPromotionGoodsList() != null && !vo.getPromotionGoodsList().isEmpty()) { for (PromotionGoods promotionGoods : vo.getPromotionGoodsList()) { promotionGoods.setPromotionStatus(PromotionStatusEnum.END.name()); + esGoodsIndexService.deleteEsGoodsPromotionByPromotionId(promotionGoods.getSkuId(), vo.getId()); } } mongoTemplate.save(vo); @@ -110,6 +116,7 @@ public class PromotionEverydayExecute implements EveryDayExecute { if (vo.getPromotionGoodsList() != null && !vo.getPromotionGoodsList().isEmpty()) { for (PromotionGoods promotionGoods : vo.getPromotionGoodsList()) { promotionGoods.setPromotionStatus(PromotionStatusEnum.END.name()); + esGoodsIndexService.deleteEsGoodsPromotionByPromotionId(promotionGoods.getSkuId(), vo.getId()); } } mongoTemplate.save(vo); diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 6d63599b..311c14ea 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -438,8 +438,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl i goodsIndexService.addIndex(goodsIndex); } else if (goodsSku.getQuantity() > 0 && esGoodsOld != null) { goodsIndexService.updateIndex(goodsIndex); - } else if (goodsSku.getQuantity() <= 0 && esGoodsOld != null) { - goodsIndexService.deleteIndexById(goodsSku.getId()); } //删除sku缓存 cache.remove(GoodsSkuService.getCacheKeys(goodsSku.getId())); diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java index 9ac0ab64..6f737c1d 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsIndexService.java @@ -105,6 +105,12 @@ public interface EsGoodsIndexService { */ void deleteEsGoodsPromotionIndexByList(List skuIds, PromotionTypeEnum promotionType); + /** + * 删除索引中指定的促销活动id的促销活动 + * @param skuId 商品skuId + * @param promotionId 促销活动Id + */ + void deleteEsGoodsPromotionByPromotionId(String skuId, String promotionId); /** * 清除所以商品索引的无效促销活动 */ diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 719e5a75..26c3b1ba 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -203,7 +203,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Override public void updateEsGoodsIndexAllByList(BasePromotion promotion, String key) { List goodsIndices; - //如果storeid不为空,则表示是店铺活动 + //如果storeId不为空,则表示是店铺活动 if (promotion.getStoreId() != null) { EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO(); searchDTO.setStoreId(promotion.getStoreId()); @@ -243,6 +243,41 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } } + @Override + public void deleteEsGoodsPromotionByPromotionId(String skuId, String promotionId) { + if (skuId != null) { + EsGoodsIndex goodsIndex = findById(skuId); + //商品索引不为空 + if (goodsIndex != null) { + this.removePromotionByPromotionId(goodsIndex, promotionId); + } else { + log.error("更新索引商品促销信息失败!skuId 为 【{}】的索引不存在!", skuId); + } + } else { + for (EsGoodsIndex goodsIndex : this.goodsIndexRepository.findAll()) { + this.removePromotionByPromotionId(goodsIndex, promotionId); + } + } + + } + + /** + * 从索引中删除指定促销活动id的促销活动 + * + * @param goodsIndex 索引 + * @param promotionId 促销活动id + */ + private void removePromotionByPromotionId(EsGoodsIndex goodsIndex, String promotionId) { + Map promotionMap = goodsIndex.getPromotionMap(); + if (promotionMap != null && !promotionMap.isEmpty()) { + // 如果存在同类型促销活动删除 + List collect = promotionMap.keySet().stream().filter(i -> i.split("-")[1].equals(promotionId)).collect(Collectors.toList()); + collect.forEach(promotionMap::remove); + goodsIndex.setPromotionMap(promotionMap); + updateIndex(goodsIndex); + } + } + /** * 清除所有商品索引的无效促销活动 */ diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 1542152a..593073e2 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.lucene.search.join.ScoreMode; import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery; import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.NestedQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders; @@ -336,6 +337,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { String[] props = searchDTO.getProp().split("@"); List nameList = new ArrayList<>(); List valueList = new ArrayList<>(); + Map> valueMap = new HashMap<>(); for (String prop : props) { String[] propValues = prop.split("_"); String name = propValues[0]; @@ -346,14 +348,29 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { if (!valueList.contains(value)) { valueList.add(value); } - if (isAggregation) { - filterBuilder.must(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.termQuery(ATTR_NAME, name), ScoreMode.None)); - filterBuilder.should(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.termsQuery(ATTR_VALUE, value), ScoreMode.None)); + // 将同一规格名下的规格值分组 + if (!valueMap.containsKey(name)) { + List values = new ArrayList<>(); + values.add(value); + valueMap.put(name, values); } else { - queryBuilder.must(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.termQuery(ATTR_NAME, name), ScoreMode.None)); - queryBuilder.must(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.wildcardQuery(ATTR_VALUE, "*" + value + "*"), ScoreMode.None)); + valueMap.get(name).add(value); } - + } + BoolQueryBuilder usedQueryBuilder; + if (isAggregation) { + usedQueryBuilder = filterBuilder; + } else { + usedQueryBuilder = queryBuilder; + } + // 遍历所有的规格 + for (Map.Entry> entry : valueMap.entrySet()) { + usedQueryBuilder.must(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.wildcardQuery(ATTR_NAME, "*" + entry.getKey() + "*"), ScoreMode.None)); + BoolQueryBuilder shouldBuilder = QueryBuilders.boolQuery(); + for (String s : entry.getValue()) { + shouldBuilder.should(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.wildcardQuery(ATTR_VALUE, "*" + s + "*"), ScoreMode.None)); + } + usedQueryBuilder.must(shouldBuilder); } searchDTO.getNotShowCol().put(ATTR_NAME_KEY, nameList); searchDTO.getNotShowCol().put(ATTR_VALUE_KEY, valueList); From aa024c87b2159e9c3cb205983309c3066d4fa25d Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 20 May 2021 17:03:08 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BB=B6=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=97=A0=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/delayqueue/AbstractDelayQueueMachineFactory.java | 4 +++- .../java/cn/lili/common/trigger/RocketmqTimerTrigger.java | 2 +- .../cn/lili/common/trigger/delay/PromotionDelayQueue.java | 2 ++ .../lili/modules/promotion/serviceimpl/CouponServiceImpl.java | 2 +- .../modules/promotion/serviceimpl/PintuanServiceImpl.java | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/delayqueue/AbstractDelayQueueMachineFactory.java b/framework/src/main/java/cn/lili/common/delayqueue/AbstractDelayQueueMachineFactory.java index 5189cff0..30298790 100644 --- a/framework/src/main/java/cn/lili/common/delayqueue/AbstractDelayQueueMachineFactory.java +++ b/framework/src/main/java/cn/lili/common/delayqueue/AbstractDelayQueueMachineFactory.java @@ -36,7 +36,9 @@ public abstract class AbstractDelayQueueMachineFactory { Calendar instance = Calendar.getInstance(); instance.add(Calendar.SECOND, time); long delaySeconds = instance.getTimeInMillis() / 1000; - return redisUtil.zadd(setDelayQueueName(), delaySeconds, jobId); + boolean result = redisUtil.zadd(setDelayQueueName(), delaySeconds, jobId); + log.info("redis add delay, key {}, delay time {}", setDelayQueueName(), delaySeconds); + return result; } diff --git a/framework/src/main/java/cn/lili/common/trigger/RocketmqTimerTrigger.java b/framework/src/main/java/cn/lili/common/trigger/RocketmqTimerTrigger.java index 5a78666e..f039ccbd 100644 --- a/framework/src/main/java/cn/lili/common/trigger/RocketmqTimerTrigger.java +++ b/framework/src/main/java/cn/lili/common/trigger/RocketmqTimerTrigger.java @@ -37,7 +37,7 @@ public class RocketmqTimerTrigger implements TimeTrigger { TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(executorName, triggerTime, param, uniqueKey, topic); Message message = MessageBuilder.withPayload(timeTriggerMsg).build(); - + log.info("延时任务发送信息:{}", message); this.rocketMQTemplate.asyncSend(topic, message, RocketmqSendCallbackBuilder.commonCallback()); } diff --git a/framework/src/main/java/cn/lili/common/trigger/delay/PromotionDelayQueue.java b/framework/src/main/java/cn/lili/common/trigger/delay/PromotionDelayQueue.java index 2f7735f7..4e30f9fc 100644 --- a/framework/src/main/java/cn/lili/common/trigger/delay/PromotionDelayQueue.java +++ b/framework/src/main/java/cn/lili/common/trigger/delay/PromotionDelayQueue.java @@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil; import cn.lili.common.delayqueue.AbstractDelayQueueMachineFactory; import cn.lili.common.trigger.interfaces.TimeTrigger; import cn.lili.common.trigger.model.TimeTriggerMsg; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -18,6 +19,7 @@ import org.springframework.stereotype.Component; @Component public class PromotionDelayQueue extends AbstractDelayQueueMachineFactory { + @Autowired private TimeTrigger timeTrigger; @Override diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java index 09b7672d..a4c0542f 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java @@ -118,7 +118,7 @@ public class CouponServiceImpl extends ServiceImpl impleme promotionMessage, coupon.getStartTime().getTime(), couponVO.getStartTime().getTime(), DelayQueueTools.wrapperUniqueKey(DelayQueueType.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())), - DateUtil.getDelayTime(coupon.getStartTime().getTime()), + DateUtil.getDelayTime(couponVO.getStartTime().getTime()), rocketmqCustomProperties.getPromotionTopic()); return couponVO; } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java index 47dfc0c3..3567e332 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PintuanServiceImpl.java @@ -223,7 +223,7 @@ public class PintuanServiceImpl extends ServiceImpl impl pintuanVO.getStartTime().getTime(), pintuan.getStartTime().getTime(), DelayQueueTools.wrapperUniqueKey(DelayQueueType.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())), - DateUtil.getDelayTime(pintuan.getStartTime().getTime()), + DateUtil.getDelayTime(pintuanVO.getStartTime().getTime()), rocketmqCustomProperties.getPromotionTopic()); } From eaf3aa2b2fd937b3302d24c6fe7621b2eae283c4 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 20 May 2021 19:59:10 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E4=BB=B7=E6=A0=BC=E8=AE=A1=E7=AE=97=E5=88=86=E6=91=8A?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/trigger/RocketmqTimerTrigger.java | 2 +- .../cart/render/impl/SkuPromotionRender.java | 37 +++++++++---------- .../order/cart/service/CartServiceImpl.java | 3 ++ .../PromotionPriceServiceImpl.java | 16 ++++---- .../serviceimpl/EsGoodsSearchServiceImpl.java | 6 ++- 5 files changed, 35 insertions(+), 29 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/trigger/RocketmqTimerTrigger.java b/framework/src/main/java/cn/lili/common/trigger/RocketmqTimerTrigger.java index f039ccbd..8dcd7f02 100644 --- a/framework/src/main/java/cn/lili/common/trigger/RocketmqTimerTrigger.java +++ b/framework/src/main/java/cn/lili/common/trigger/RocketmqTimerTrigger.java @@ -58,7 +58,7 @@ public class RocketmqTimerTrigger implements TimeTrigger { log.info("add Redis key {} --------------------------", generateKey); log.info("定时执行在【" + DateUtil.toString(timeTriggerMsg.getTriggerTime(), "yyyy-MM-dd HH:mm:ss") + "】,消费【" + timeTriggerMsg.getParam().toString() + "】"); } else { - log.info("延时任务添加失败!"); + log.error("延时任务添加失败!"); } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java index f3150def..c2683cc8 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java @@ -19,7 +19,6 @@ import cn.lili.modules.promotion.entity.dto.PromotionPriceParamDTO; import cn.lili.modules.promotion.entity.dto.StorePromotionPriceDTO; import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.promotion.service.PromotionPriceService; -import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Service; @@ -27,6 +26,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; /** @@ -151,29 +151,26 @@ public class SkuPromotionRender implements CartRenderStep { for (CartVO cartVO : tradeDTO.getCartList()) { // 根据店铺分配店铺价格计算结果 - List collect = promotionPrice.getStorePromotionPriceList().parallelStream().map(i -> i.getStoreId().equals(cartVO.getStoreId()) ? i : null).collect(Collectors.toList()); - if (!collect.isEmpty() && collect.get(0) != null) { - StorePromotionPriceDTO storePromotionPriceDTO = collect.get(0); + Optional storePromotionPriceDTOOptional = promotionPrice.getStorePromotionPriceList().parallelStream().filter(i -> i.getStoreId().equals(cartVO.getStoreId())).findAny(); + if (storePromotionPriceDTOOptional.isPresent()) { + StorePromotionPriceDTO storePromotionPriceDTO = storePromotionPriceDTOOptional.get(); // 根据商品分配商品结果计算结果 this.distributionSkuPromotionPrice(cartVO.getSkuList(), storePromotionPriceDTO); - if (storePromotionPriceDTO != null) { - PriceDetailDTO sSpd = new PriceDetailDTO(); - PriceDetailVO sPd = new PriceDetailVO(); - sSpd.setGoodsPrice(storePromotionPriceDTO.getTotalOriginPrice()); - sSpd.setDiscountPrice(storePromotionPriceDTO.getTotalDiscountPrice()); - sSpd.setCouponPrice(storePromotionPriceDTO.getTotalCouponPrice()); - sSpd.setPayPoint(storePromotionPriceDTO.getTotalPoints().intValue()); - - sPd.setOriginalPrice(storePromotionPriceDTO.getTotalOriginPrice()); - sPd.setFinalePrice(storePromotionPriceDTO.getTotalFinalePrice()); - sPd.setDiscountPrice(storePromotionPriceDTO.getTotalDiscountPrice()); - sPd.setPayPoint(storePromotionPriceDTO.getTotalPoints().intValue()); - cartVO.setPriceDetailDTO(sSpd); - cartVO.setPriceDetailVO(sPd); - cartVO.setWeight(storePromotionPriceDTO.getTotalWeight()); - } + PriceDetailDTO sSpd = new PriceDetailDTO(); + PriceDetailVO sPd = new PriceDetailVO(); + sSpd.setGoodsPrice(storePromotionPriceDTO.getTotalOriginPrice()); + sSpd.setDiscountPrice(storePromotionPriceDTO.getTotalDiscountPrice()); + sSpd.setCouponPrice(storePromotionPriceDTO.getTotalCouponPrice()); + sSpd.setPayPoint(storePromotionPriceDTO.getTotalPoints().intValue()); + sPd.setOriginalPrice(storePromotionPriceDTO.getTotalOriginPrice()); + sPd.setFinalePrice(storePromotionPriceDTO.getTotalFinalePrice()); + sPd.setDiscountPrice(storePromotionPriceDTO.getTotalDiscountPrice()); + sPd.setPayPoint(storePromotionPriceDTO.getTotalPoints().intValue()); + cartVO.setPriceDetailDTO(sSpd); + cartVO.setPriceDetailVO(sPd); + cartVO.setWeight(storePromotionPriceDTO.getTotalWeight()); } } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 8e1434b8..5ff5d4f3 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -269,6 +269,9 @@ public class CartServiceImpl implements CartService { } } cartSkuVOS.removeAll(deleteVos); + // 清除选择的优惠券 + tradeDTO.setPlatformCoupon(null); + tradeDTO.setStoreCoupons(null); // 清除添加过的备注 tradeDTO.setStoreRemark(null); cache.put(this.getOriginKey(tradeDTO.getCartTypeEnum()), tradeDTO); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionPriceServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionPriceServiceImpl.java index 5bedc4bb..cc4ab245 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionPriceServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionPriceServiceImpl.java @@ -126,6 +126,10 @@ public class PromotionPriceServiceImpl implements PromotionPriceService { if (platformCoupons != null && !platformCoupons.isEmpty()) { // 计算平台优惠券活动 couponTotalPrice = CurrencyUtil.add(couponTotalPrice, this.calculationCoupon(platformCoupons, priceDTOList)); + for (StorePromotionPriceDTO storePromotionPriceDTO : storePromotionPriceList) { + Double couponPrice = storePromotionPriceDTO.getGoodsSkuPromotionPriceList().parallelStream().mapToDouble(GoodsSkuPromotionPriceDTO::getCouponPrice).sum(); + storePromotionPriceDTO.setTotalCouponPrice(couponPrice); + } } promotionPrice.setStorePromotionPriceList(storePromotionPriceList); promotionPrice.setTotalCouponPrice(couponTotalPrice); @@ -290,17 +294,14 @@ public class PromotionPriceServiceImpl implements PromotionPriceService { // 合计优惠券范围内的所有商品的原价 double totalPrice = conformCollect.parallelStream().mapToDouble(GoodsSkuPromotionPriceDTO::getOriginalPrice).sum(); - double discountPrice = 0; // 根据优惠券优惠类型,判断是否满足条件 if (CouponTypeEnum.PRICE.name().equals(coupon.getCouponType()) && coupon.getConsumeThreshold() <= totalPrice) { couponTotalPrice = CurrencyUtil.add(couponTotalPrice, coupon.getPrice()); - discountPrice = coupon.getPrice(); } else if (CouponTypeEnum.DISCOUNT.name().equals(coupon.getCouponType())) { double fullRate = coupon.getDiscount() >= 10 ? coupon.getDiscount() / 100 : coupon.getDiscount() / 10; double discountRatePrice = CurrencyUtil.sub(totalPrice, CurrencyUtil.mul(totalPrice, fullRate)); couponTotalPrice = CurrencyUtil.add(couponTotalPrice, discountRatePrice); - discountPrice = discountRatePrice; // 消费限额判断 // if (coupon.getConsumeThreshold() >= discountRatePrice) { // couponTotalPrice = CurrencyUtil.add(couponTotalPrice, discountRatePrice); @@ -312,14 +313,15 @@ public class PromotionPriceServiceImpl implements PromotionPriceService { } // 分配到每个商品的优惠券金额 - double distributePrice = CurrencyUtil.div(discountPrice, conformCollect.size()); for (GoodsSkuPromotionPriceDTO goodsSkuPromotionPriceDTO : conformCollect) { + double rate = CurrencyUtil.div(goodsSkuPromotionPriceDTO.getFinalePrice(), totalPrice, 5); + double distributeCouponPrice = CurrencyUtil.mul(couponTotalPrice, rate); if (goodsSkuPromotionPriceDTO.getFinalePrice() != null) { - goodsSkuPromotionPriceDTO.setFinalePrice(CurrencyUtil.sub(goodsSkuPromotionPriceDTO.getFinalePrice(), distributePrice)); + goodsSkuPromotionPriceDTO.setFinalePrice(CurrencyUtil.sub(goodsSkuPromotionPriceDTO.getFinalePrice(), distributeCouponPrice)); } else { - goodsSkuPromotionPriceDTO.setFinalePrice(CurrencyUtil.sub(goodsSkuPromotionPriceDTO.getOriginalPrice(), distributePrice)); + goodsSkuPromotionPriceDTO.setFinalePrice(CurrencyUtil.sub(goodsSkuPromotionPriceDTO.getOriginalPrice(), distributeCouponPrice)); } - goodsSkuPromotionPriceDTO.setCouponPrice(distributePrice); + goodsSkuPromotionPriceDTO.setCouponPrice(distributeCouponPrice); goodsSkuPromotionPriceDTO.setTotalFinalePrice(CurrencyUtil.mul(goodsSkuPromotionPriceDTO.getFinalePrice(), goodsSkuPromotionPriceDTO.getNumber())); BasePromotion basePromotion = new BasePromotion(); basePromotion.setId(coupon.getId()); diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 593073e2..b1f65327 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -257,7 +257,11 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { private NativeSearchQueryBuilder createSearchQueryBuilder(EsGoodsSearchDTO searchDTO, PageVO pageVo, boolean isAggregation) { NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder(); if (pageVo != null) { - Pageable pageable = PageRequest.of(pageVo.getPageNumber(), pageVo.getPageSize()); + Integer pageNumber = pageVo.getPageNumber() - 1; + if (pageNumber < 0) { + pageNumber = 0; + } + Pageable pageable = PageRequest.of(pageNumber, pageVo.getPageSize()); //分页 nativeSearchQueryBuilder.withPageable(pageable); } From a16809c77a3b2e206c58ddb12c9aaa65bb0ba121 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Fri, 21 May 2021 09:22:14 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=88=86=E9=94=80?= =?UTF-8?q?=E4=BD=A3=E9=87=91=E8=A7=A3=E5=86=BB=E6=97=B6=E9=97=B4=E4=B8=BA?= =?UTF-8?q?1=E5=A4=A9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/DistributionOrderService.java | 1 - .../DistributionOrderServiceImpl.java | 51 ++----------------- 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/distribution/service/DistributionOrderService.java b/framework/src/main/java/cn/lili/modules/distribution/service/DistributionOrderService.java index 100bc191..894773a6 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/service/DistributionOrderService.java +++ b/framework/src/main/java/cn/lili/modules/distribution/service/DistributionOrderService.java @@ -28,7 +28,6 @@ public interface DistributionOrderService extends IService { * @param orderSn 订单编号 */ void payOrder(String orderSn); - void test(String orderSn); /** * 取消订单 diff --git a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java index 21c2ba1e..e2ec8d07 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionOrderServiceImpl.java @@ -2,7 +2,6 @@ package cn.lili.modules.distribution.serviceimpl; import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateTime; -import cn.hutool.json.JSONUtil; import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.PageUtil; import cn.lili.modules.distribution.entity.dos.Distribution; @@ -16,9 +15,6 @@ import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.StoreFlow; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.StoreFlowService; -import cn.lili.modules.system.entity.dos.Setting; -import cn.lili.modules.system.entity.dto.DistributionSetting; -import cn.lili.modules.system.entity.enums.SettingEnum; import cn.lili.modules.system.service.SettingService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -84,50 +80,12 @@ public class DistributionOrderServiceImpl extends ServiceImpl storeFlowList = storeFlowService.list(new LambdaQueryWrapper() - .eq(StoreFlow::getOrderSn, orderSn) - .isNotNull(StoreFlow::getDistributionRebate)); - Double rebate=0.0; - //循环店铺流水记录判断是否包含分销商品 - //包含分销商品则进行记录分销订单、计算分销总额 - for (StoreFlow storeFlow : storeFlowList) { - rebate=CurrencyUtil.add(rebate,storeFlow.getDistributionRebate()); - DistributionOrder distributionOrder = new DistributionOrder(storeFlow); - distributionOrder.setDistributionId(order.getDistributionId()); - //分销员信息 - Distribution distribution = distributionService.getById(order.getDistributionId()); - distributionOrder.setDistributionName(distribution.getMemberName()); - - //设置结算天数(解冻日期) - Setting setting = settingService.get(SettingEnum.DISTRIBUTION_SETTING.name()); - DistributionSetting distributionSetting = JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class); - DateTime dateTime = new DateTime(); - //默认提现周期一天 + //默认解冻1天 +// dateTime.offsetNew(DateField.DAY_OF_MONTH,distributionSetting.getCashDay()); dateTime.offsetNew(DateField.DAY_OF_MONTH,1); - //dateTime.offsetNew(DateField.DAY_OF_MONTH,distributionSetting.getCashDay()); distributionOrder.setSettleCycle(dateTime); this.save(distributionOrder); } @@ -138,7 +96,6 @@ public class DistributionOrderServiceImpl extends ServiceImpl().eq(DistributionOrder::getOrderSn, orderSn) From 368d02aa1a84ea230f7bd4b302410839e079e1ff Mon Sep 17 00:00:00 2001 From: lifenlong Date: Fri, 21 May 2021 09:42:53 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=AF=84=E4=BB=B7?= =?UTF-8?q?=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/member/entity/dos/MemberEvaluation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberEvaluation.java b/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberEvaluation.java index 0cf904b7..7e9f35c0 100644 --- a/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberEvaluation.java +++ b/framework/src/main/java/cn/lili/modules/member/entity/dos/MemberEvaluation.java @@ -81,7 +81,7 @@ public class MemberEvaluation extends BaseEntity { private String content; @ApiModelProperty(value = "评价图片") - private String image; + private String images; @NotNull @ApiModelProperty(value = "状态 OPEN 正常 ,CLOSE 关闭 ") From 5c01e131d9ac353e105eedf3d8c9930844f9635e Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 May 2021 09:52:18 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E5=BA=93=E5=AD=98=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/common/enums/ResultCode.java | 2 +- .../serviceimpl/NoticeMessageServiceImpl.java | 30 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 8dd3af54..12228041 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -84,7 +84,7 @@ public enum ResultCode { USER_EDIT_SUCCESS(20001, "用户修改成功"), USER_NOT_EXIST(20002, "用户不存在"), USER_NOT_LOGIN(20003, "用户未登录"), - USER_AUTH_EXPIRED(20004, "认证过期"), + USER_AUTH_EXPIRED(20004, "用户已退出,请重新登录"), USER_AUTHORITY_ERROR(20005, "权限不足"), USER_CONNECT_LOGIN_ERROR(20006, "未找到登录信息"), USER_NAME_EXIST(20007, "该用户名已被注册"), diff --git a/framework/src/main/java/cn/lili/modules/message/serviceimpl/NoticeMessageServiceImpl.java b/framework/src/main/java/cn/lili/modules/message/serviceimpl/NoticeMessageServiceImpl.java index 6bde7a03..ab29dc40 100644 --- a/framework/src/main/java/cn/lili/modules/message/serviceimpl/NoticeMessageServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/message/serviceimpl/NoticeMessageServiceImpl.java @@ -51,21 +51,25 @@ public class NoticeMessageServiceImpl extends ServiceImpl().eq(NoticeMessage::getNoticeNode, noticeMessageDTO.getNoticeMessageNodeEnum().getDescription().trim())); - //如果通知类站内信开启的情况下 - if (noticeMessage != null && noticeMessage.getNoticeStatus().equals(SwitchEnum.OPEN.name())) { - MemberNotice memberNotice = new MemberNotice(); - memberNotice.setMemberId(noticeMessageDTO.getMemberId()); - memberNotice.setTitle(noticeMessage.getNoticeTitle()); - memberNotice.setContent(noticeMessage.getNoticeContent()); - //参数不为空,替换内容 - if (noticeMessageDTO.getParameter() != null) { - memberNotice.setContent(replaceNoticeContent(noticeMessage.getNoticeContent(), noticeMessageDTO.getParameter())); - } else { + try { + NoticeMessage noticeMessage = this.getOne(new LambdaQueryWrapper().eq(NoticeMessage::getNoticeNode, noticeMessageDTO.getNoticeMessageNodeEnum().getDescription().trim())); + //如果通知类站内信开启的情况下 + if (noticeMessage != null && noticeMessage.getNoticeStatus().equals(SwitchEnum.OPEN.name())) { + MemberNotice memberNotice = new MemberNotice(); + memberNotice.setMemberId(noticeMessageDTO.getMemberId()); + memberNotice.setTitle(noticeMessage.getNoticeTitle()); memberNotice.setContent(noticeMessage.getNoticeContent()); + //参数不为空,替换内容 + if (noticeMessageDTO.getParameter() != null) { + memberNotice.setContent(replaceNoticeContent(noticeMessage.getNoticeContent(), noticeMessageDTO.getParameter())); + } else { + memberNotice.setContent(noticeMessage.getNoticeContent()); + } + //添加站内信 + memberNoticeService.save(memberNotice); } - //添加站内信 - memberNoticeService.save(memberNotice); + } catch (Exception e) { + log.error("站内信发送失败:", e); } } From 1b5a7156956282798381ddade9afe9a8f34dddd6 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Fri, 21 May 2021 10:43:29 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9readme=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E5=88=97=E8=A1=A8=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 64 +++++++------------ .../sms/impl/SmsUtilAliImplService.java | 13 ++-- 2 files changed, 30 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 6994b0e5..ba1f2c76 100644 --- a/README.md +++ b/README.md @@ -132,54 +132,34 @@ PS:单独部署的话,数据库文件访问这里:https://gitee.com/beijing_ ##### Java后台 -| 说明 | 框架 | -| -------------- | --------------- | -| 基础框架 | Spring Boot | -| MVC框架 | Spring MVC | -| 持久框架 | Mybatis-Plus | -| 程序构建 | Maven | -| 关系型数据库 | MySQL | -| 消息中间件AMQP | RocketMQ | -| 缓存 | Redis +MongoDB | -| 搜索引擎 | Elasticsearch | -| 安全框架 | Spring Security | -| 数据库连接池 | Druid | -| 数据库分库分表 | sharding | -| 定时任务 | xxl-job | -| 负载均衡 | Nginx | -| 静态资源 | 阿里云OSS | -| 短信 | 阿里云短信 | -| 日志处理 | Log4j | -| 接口规范 | RESTful | -| 接口文档 | Swagger | -| 认证 | JWT | +| 说明 | 框架 | 说明 | | +| -------------- | --------------- | -------------- | ------------- | +| 基础框架 | Spring Boot | MVC框架 | Spring MVC | +| 持久框架 | Mybatis-Plus | 程序构建 | Maven | +| 关系型数据库 | MySQL | 消息中间件AMQP | RocketMQ | +| 缓存 | Redis +MongoDB | 搜索引擎 | Elasticsearch | +| 安全框架 | Spring Security | 数据库连接池 | Druid | +| 数据库分库分表 | sharding | 定时任务 | xxl-job | +| 负载均衡 | Nginx | 静态资源 | 阿里云OSS | +| 短信 | 阿里云短信 | 认证 | JWT | +| 日志处理 | Log4j | 接口规范 | RESTful | ##### 前端-运营后台、店铺后台 -| 说明 | 框架 | -| ---------- | ---------- | -| 构建工具 | webpack | -| JS版本 | ES6 | -| 基础JS框架 | Vue.js | -| 视频播放器 | Dplayer | -| 路由管理 | Vue Router | -| 状态管理 | Vuex | -| 基础UI库 | iView | -| UI界面基于 | iView | -| 网络请求 | axios | -| CSS预处理 | scss | -| 代码检查 | ESLint | -| 数据可视化 | AntV g2 | -| 地图引擎 | amap | +| 说明 | 框架 | 说明 | 框架 | +| ---------- | ---------- | ---------- | ------- | +| 构建工具 | webpack | JS版本 | ES6 | +| 基础JS框架 | Vue.js | 视频播放器 | Dplayer | +| 路由管理 | Vue Router | 状态管理 | Vuex | +| 基础UI库 | iView | UI界面基于 | iView | +| 网络请求 | axios | | | ##### 前端-移动端 -| 说明 | 架构 | -| --------- | ------- | -| 基础UI库 | uViewui | -| 基础框架 | uni-app | -| CSS预处理 | scss | -| 地图引擎 | amap | +| 说明 | 架构 | 说明 | 架构 | +| --------- | ------- | -------- | ------- | +| 基础UI库 | uViewui | 基础框架 | uni-app | +| CSS预处理 | scss | 地图引擎 | amap | ### 技术亮点 diff --git a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java index a592bcef..0645be6a 100644 --- a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java +++ b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java @@ -66,7 +66,12 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { Map params = new HashMap<>(); params.put("code", code); cache.put(cacheKey(verificationEnums, mobile, uuid), code, 300L); - this.sendSmsCode("北京宏业汇成科技有限公司", mobile, params, "SMS_205755300"); + Setting setting = settingService.getById(SettingEnum.SMS_SETTING.name()); + if (StrUtil.isBlank(setting.getSettingValue())) { + throw new ServiceException("您还未配置阿里云短信"); + } + SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class); + this.sendSmsCode(smsSetting.getSignName(), mobile, params, "SMS_205755300"); break; } case UPDATE_PASSWORD: { @@ -317,11 +322,9 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { Config config = new Config(); // 您的AccessKey ID - //config.accessKeyId = smsSetting.getAccessKeyId(); - config.accessKeyId = "LTAI4G4deX59EyjpEULaJdsU"; + config.accessKeyId = smsSetting.getAccessKeyId(); // 您的AccessKey Secret - //config.accessKeySecret = smsSetting.getAccessSecret(); - config.accessKeySecret = "BlRBpl7WBman6GYYwLKMiKqMTXFhWf"; + config.accessKeySecret = smsSetting.getAccessSecret(); // 访问的域名 config.endpoint = "dysmsapi.aliyuncs.com"; return new com.aliyun.dysmsapi20170525.Client(config); From 1f1e57645cde2a2bba03ca6f47436fddff946de2 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 May 2021 10:44:33 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/impl/SmsUtilAliImplService.java | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java index a592bcef..ea3b91b7 100644 --- a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java +++ b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java @@ -54,38 +54,54 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { @Override public void sendSmsCode(String mobile, VerificationEnums verificationEnums, String uuid) { + //验证码 String code = CommonUtil.getRandomNum(); - switch (verificationEnums) { - //如果某个模版需要自定义,则在此处进行调整 - case LOGIN: - case REGISTER: - case FIND_USER: { + //准备发送短信参数 + Map params = new HashMap<>(); + // 验证码内容 + params.put("code", code); - //准备发送短信参数 - Map params = new HashMap<>(); - params.put("code", code); - cache.put(cacheKey(verificationEnums, mobile, uuid), code, 300L); - this.sendSmsCode("北京宏业汇成科技有限公司", mobile, params, "SMS_205755300"); + //模版 默认为登录验证 + String templateCode; + + //如果某个模版需要自定义,则在此处进行调整 + switch (verificationEnums) { + //登录 + case LOGIN: { + templateCode = "SMS_205755300"; break; } + //注册 + case REGISTER: { + templateCode = "SMS_205755298"; + break; + } + //找回密码 + case FIND_USER: { + templateCode = "SMS_205755301"; + break; + } + //修改密码 case UPDATE_PASSWORD: { Member member = memberService.getById(UserContext.getCurrentUser().getId()); if (member == null || StringUtil.isEmpty(member.getMobile())) { return; } - String memberMobile = member.getMobile(); - //准备发送短信参数 - Map params = new HashMap<>(); - params.put("code", code); - cache.put(cacheKey(verificationEnums, memberMobile, uuid), code, 300L); - this.sendSmsCode("北京宏业汇成科技有限公司", mobile, params, "SMS_205755297"); + //更新为用户最新手机号 + mobile = member.getMobile(); + templateCode = "SMS_205755297"; break; } //如果不是有效的验证码手段,则此处不进行短信操作 default: return; } + //缓存中写入要验证的信息 + cache.put(cacheKey(verificationEnums, mobile, uuid), code, 300L); + + this.sendSmsCode("北京宏业汇成科技有限公司", mobile, params, templateCode); + } @Override From 3b21fede61d2eb0ccfb1d7aeaac937c53d3a38b6 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 May 2021 11:11:41 +0800 Subject: [PATCH 09/16] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=BC=93=E5=AD=98=E4=BB=A3=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E7=9B=B4=E6=8E=A5=E8=AF=BB=E5=8F=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/controller/common/UploadController.java | 2 +- .../java/cn/lili/common/sms/impl/SmsUtilAliImplService.java | 4 ++-- .../lili/modules/file/plugin/impl/AliFileManagerPlugin.java | 2 +- .../modules/goods/serviceimpl/GoodsGalleryServiceImpl.java | 3 +-- .../lili/modules/system/serviceimpl/LogisticsServiceImpl.java | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/common-api/src/main/java/cn/lili/controller/common/UploadController.java b/common-api/src/main/java/cn/lili/controller/common/UploadController.java index 83d868b4..499e1787 100644 --- a/common-api/src/main/java/cn/lili/controller/common/UploadController.java +++ b/common-api/src/main/java/cn/lili/controller/common/UploadController.java @@ -63,7 +63,7 @@ public class UploadController { if (authUser == null) { throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR); } - Setting setting = settingService.getById(SettingEnum.OSS_SETTING.name()); + Setting setting = settingService.get(SettingEnum.OSS_SETTING.name()); if (setting == null || StrUtil.isBlank(setting.getSettingValue())) { throw new ServiceException(ResultCode.OSS_NOT_EXIST); } diff --git a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java index fd78d5c4..fead89fb 100644 --- a/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java +++ b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java @@ -54,7 +54,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { @Override public void sendSmsCode(String mobile, VerificationEnums verificationEnums, String uuid) { //获取短信配置 - Setting setting = settingService.getById(SettingEnum.SMS_SETTING.name()); + Setting setting = settingService.get(SettingEnum.SMS_SETTING.name()); if (StrUtil.isBlank(setting.getSettingValue())) { throw new ServiceException("您还未配置阿里云短信"); } @@ -331,7 +331,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { */ public com.aliyun.dysmsapi20170525.Client createClient() { try { - Setting setting = settingService.getById(SettingEnum.SMS_SETTING.name()); + Setting setting = settingService.get(SettingEnum.SMS_SETTING.name()); if (StrUtil.isBlank(setting.getSettingValue())) { throw new ServiceException("您还未配置阿里云短信"); } diff --git a/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java b/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java index cc189f17..731454ca 100644 --- a/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java +++ b/framework/src/main/java/cn/lili/modules/file/plugin/impl/AliFileManagerPlugin.java @@ -74,7 +74,7 @@ public class AliFileManagerPlugin implements FileManagerPlugin { private OssSetting getSetting() { //如果没有配置,或者没有下次刷新时间,或者下次刷新时间小于当前时间,则从redis 更新一次 if (ossSetting == null || nextInitSetting == null || nextInitSetting < System.currentTimeMillis()) { - Setting setting = settingService.getById(SettingEnum.OSS_SETTING.name()); + Setting setting = settingService.get(SettingEnum.OSS_SETTING.name()); if (setting == null || StrUtil.isBlank(setting.getSettingValue())) { throw new ServiceException("您还未配置阿里云OSS存储"); } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java index d211d078..d41a96be 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java @@ -12,7 +12,6 @@ import cn.lili.modules.system.service.SettingService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -62,7 +61,7 @@ public class GoodsGalleryServiceImpl extends ServiceImpl Date: Fri, 21 May 2021 11:59:31 +0800 Subject: [PATCH 10/16] =?UTF-8?q?APP=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../other/AppVersionBuyerController.java | 36 +++++++++++++++++++ config/application.yml | 1 + .../{AppVersionDO.java => AppVersion.java} | 2 +- .../system/mapper/AppVersionMapper.java | 8 +++-- .../system/service/AppVersionService.java | 13 ++++--- .../serviceimpl/AppVersionServiceImpl.java | 8 +++-- .../setting/AppVersionManagerController.java | 20 +++++------ 7 files changed, 69 insertions(+), 19 deletions(-) create mode 100644 buyer-api/src/main/java/cn/lili/controller/other/AppVersionBuyerController.java rename framework/src/main/java/cn/lili/modules/system/entity/dos/{AppVersionDO.java => AppVersion.java} (98%) diff --git a/buyer-api/src/main/java/cn/lili/controller/other/AppVersionBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/other/AppVersionBuyerController.java new file mode 100644 index 00000000..7109bc27 --- /dev/null +++ b/buyer-api/src/main/java/cn/lili/controller/other/AppVersionBuyerController.java @@ -0,0 +1,36 @@ +package cn.lili.controller.other; + +import cn.lili.common.enums.ResultUtil; +import cn.lili.common.vo.ResultMessage; +import cn.lili.modules.system.service.AppVersionService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 买家端,APP版本 + * + * @author Bulbasaur + * @date: 2021/5/21 11:15 上午 + */ +@RestController +@Api(tags = "买家端,APP版本") +@RequestMapping("/buyer/appVersion") +public class AppVersionBuyerController { + + @Autowired + private AppVersionService appVersionService; + + + @ApiOperation(value = "获取版本号") + @ApiImplicitParam(name = "appType", value = "app类型", required = true, paramType = "path") + @GetMapping("/{appType}") + public ResultMessage getAppVersion(@PathVariable String appType) { + return ResultUtil.data(appVersionService.getAppVersion(appType)); + } +} diff --git a/config/application.yml b/config/application.yml index aa79004d..56305085 100644 --- a/config/application.yml +++ b/config/application.yml @@ -149,6 +149,7 @@ ignored: - /buyer/promotion/pointsGoods/** - /buyer/memberEvaluation/**/goodsEvaluation - /buyer/memberEvaluation/**/evaluationNumber + - /buyer/appVersion/** - /store/login/** - /manager/user/login - /manager/user/refresh/** diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dos/AppVersionDO.java b/framework/src/main/java/cn/lili/modules/system/entity/dos/AppVersion.java similarity index 98% rename from framework/src/main/java/cn/lili/modules/system/entity/dos/AppVersionDO.java rename to framework/src/main/java/cn/lili/modules/system/entity/dos/AppVersion.java index 7c6d08f6..b4619a59 100755 --- a/framework/src/main/java/cn/lili/modules/system/entity/dos/AppVersionDO.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/dos/AppVersion.java @@ -30,7 +30,7 @@ import java.util.Date; @Table(name = "li_app_version") @TableName("li_app_version") @ApiModel(value = "app版本控制") -public class AppVersionDO{ +public class AppVersion { private static final long serialVersionUID = 3034686331756935L; diff --git a/framework/src/main/java/cn/lili/modules/system/mapper/AppVersionMapper.java b/framework/src/main/java/cn/lili/modules/system/mapper/AppVersionMapper.java index 2f48917c..5aab7101 100644 --- a/framework/src/main/java/cn/lili/modules/system/mapper/AppVersionMapper.java +++ b/framework/src/main/java/cn/lili/modules/system/mapper/AppVersionMapper.java @@ -1,7 +1,8 @@ package cn.lili.modules.system.mapper; -import cn.lili.modules.system.entity.dos.AppVersionDO; +import cn.lili.modules.system.entity.dos.AppVersion; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Select; /** * app版本控制数据处理层 @@ -9,6 +10,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author Chopper * @date 2020/11/17 8:01 下午 */ -public interface AppVersionMapper extends BaseMapper { +public interface AppVersionMapper extends BaseMapper { + + @Select("SELECT * FROM li_app_version WHERE type=#{appType} ORDER BY version_update_date DESC LIMIT 1") + AppVersion getLatestVersion(String appType); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/service/AppVersionService.java b/framework/src/main/java/cn/lili/modules/system/service/AppVersionService.java index 46352afb..bf729275 100644 --- a/framework/src/main/java/cn/lili/modules/system/service/AppVersionService.java +++ b/framework/src/main/java/cn/lili/modules/system/service/AppVersionService.java @@ -1,15 +1,20 @@ package cn.lili.modules.system.service; -import cn.lili.modules.system.entity.dos.AppVersionDO; +import cn.lili.modules.system.entity.dos.AppVersion; import com.baomidou.mybatisplus.extension.service.IService; /** - * 物流公司业务层 + * app版本业务层 * * @author Chopper * @date 2020/11/17 8:02 下午 */ -public interface AppVersionService extends IService { - +public interface AppVersionService extends IService { + /** + * 获取当前最新的APP版本 + * 获取用户的APP类型,返回最新的数据的版本号 + * @return 最新的APP版本号 + */ + AppVersion getAppVersion(String appType); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java index 51ece980..12e0d198 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java @@ -1,6 +1,6 @@ package cn.lili.modules.system.serviceimpl; -import cn.lili.modules.system.entity.dos.AppVersionDO; +import cn.lili.modules.system.entity.dos.AppVersion; import cn.lili.modules.system.mapper.AppVersionMapper; import cn.lili.modules.system.service.AppVersionService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -16,6 +16,10 @@ import org.springframework.transaction.annotation.Transactional; */ @Service @Transactional -public class AppVersionServiceImpl extends ServiceImpl implements AppVersionService { +public class AppVersionServiceImpl extends ServiceImpl implements AppVersionService { + @Override + public AppVersion getAppVersion(String appType) { + return this.baseMapper.getLatestVersion(appType); + } } diff --git a/manager-api/src/main/java/cn/lili/controller/setting/AppVersionManagerController.java b/manager-api/src/main/java/cn/lili/controller/setting/AppVersionManagerController.java index 52f9f3b7..9d28b442 100755 --- a/manager-api/src/main/java/cn/lili/controller/setting/AppVersionManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/setting/AppVersionManagerController.java @@ -7,7 +7,7 @@ import cn.lili.common.enums.ResultUtil; import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; -import cn.lili.modules.system.entity.dos.AppVersionDO; +import cn.lili.modules.system.entity.dos.AppVersion; import cn.lili.modules.system.service.AppVersionService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -34,33 +34,33 @@ public class AppVersionManagerController { private AppVersionService appVersionService; - @ApiOperation(value = "查询app升级消息", response = AppVersionDO.class) + @ApiOperation(value = "查询app升级消息", response = AppVersion.class) @GetMapping @ApiImplicitParams({ @ApiImplicitParam(name = "type", value = "APP类型", required = true, dataType = "type", paramType = "query") }) - public ResultMessage> getByPage(PageVO page, String type) { + public ResultMessage> getByPage(PageVO page, String type) { return ResultUtil.data(this.appVersionService.page(PageUtil.initPage(page), - new QueryWrapper().eq(StringUtils.isNotEmpty(type), "type", type).orderByDesc("create_time"))); + new QueryWrapper().eq(StringUtils.isNotEmpty(type), "type", type).orderByDesc("create_time"))); } - @ApiOperation(value = "添加app版本信息", response = AppVersionDO.class) + @ApiOperation(value = "添加app版本信息", response = AppVersion.class) @PostMapping - public ResultMessage add(@Valid AppVersionDO appVersionDO) { - if(this.appVersionService.save(appVersionDO)){ + public ResultMessage add(@Valid AppVersion appVersion) { + if(this.appVersionService.save(appVersion)){ return ResultUtil.success(); } throw new ServiceException(ResultCode.ERROR); } @PutMapping(value = "/{id}") - @ApiOperation(value = "修改app版本信息", response = AppVersionDO.class) + @ApiOperation(value = "修改app版本信息", response = AppVersion.class) @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "String", paramType = "path") }) - public ResultMessage edit(@Valid AppVersionDO appVersionDO, @PathVariable String id) { - if(this.appVersionService.updateById(appVersionDO)){ + public ResultMessage edit(@Valid AppVersion appVersion, @PathVariable String id) { + if(this.appVersionService.updateById(appVersion)){ return ResultUtil.success(); } throw new ServiceException(ResultCode.ERROR); From 77cbebb1187a5d002595451d82287b8f91058abc Mon Sep 17 00:00:00 2001 From: lifenlong Date: Fri, 21 May 2021 14:07:34 +0800 Subject: [PATCH 11/16] =?UTF-8?q?remdme=E5=A2=9E=E5=8A=A0=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/README.md b/README.md index ba1f2c76..40afe318 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,64 @@ PS:单独部署的话,数据库文件访问这里:https://gitee.com/beijing_ | 基础UI库 | uViewui | 基础框架 | uni-app | | CSS预处理 | scss | 地图引擎 | amap | +### 升级计划 + +时间:2021年6月15日 + +``` +新增功能: +1.微信小程序直播 +2.优惠券活动 +3.新人赠券 +4.准确发券 +5.用户等级 +6.数据导出 +7.订单批量 +8.APP版本升级检测 +9.积分商城 + +功能优化: +1.优惠券有效期增加类型:设置领取后*内有效。 +2.秒杀活动设置为每天开启,需设置秒杀活动开启时间。 +3.店铺配送模板,配送地区如果选择省份则下方的市级地址不展示。 +4.店铺配送模板支持,店铺包邮。 +5.普通商品设置去除卖家承担运费。 + +``` + +时间:2021年7月15日 + +``` +新增功能: +1.会员权益 +2.支持用户升级会员 +3.供求单 +4.IM:腾讯云智服 +5.服务商品 +6.店铺支持订单核销 +7.店铺自提点 +功能优化: +1.用户分享商城、关注店铺、邀请新用户可获取积分、经验值。 +``` + +时间:2021年8月16日 + +``` +新增功能: +1.微淘功能 +2.店铺移动端 +3.店铺发货单 +``` + +时间:2021年9月15日 + +``` +新增功能: +增加供应商功能 +``` + + + ### 技术亮点 From 4c200595a54e571f73c7d1563b9768b6de230d10 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Fri, 21 May 2021 14:18:07 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=20app=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=99=BD=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buyer-api/src/main/resources/application.yml | 4 +--- manager-api/src/main/resources/application.yml | 16 ---------------- seller-api/src/main/resources/application.yml | 17 ----------------- 3 files changed, 1 insertion(+), 36 deletions(-) diff --git a/buyer-api/src/main/resources/application.yml b/buyer-api/src/main/resources/application.yml index 2350e434..8e2617c1 100644 --- a/buyer-api/src/main/resources/application.yml +++ b/buyer-api/src/main/resources/application.yml @@ -152,9 +152,7 @@ ignored: - /buyer/promotion/seckill - /buyer/memberEvaluation/**/goodsEvaluation - /buyer/memberEvaluation/**/evaluationNumber - - /store/login/** - - /manager/user/login - - /manager/user/refresh/** + - /buyer/appVersion/** - /druid/** - /swagger-ui.html - /doc.html diff --git a/manager-api/src/main/resources/application.yml b/manager-api/src/main/resources/application.yml index b04e7d93..f22fefbc 100644 --- a/manager-api/src/main/resources/application.yml +++ b/manager-api/src/main/resources/application.yml @@ -135,22 +135,6 @@ ignored: - /MP_verify_qSyvBPhDsPdxvOhC.txt - /weixin/** - /source/** - - /buyer/mini-program/** - - /buyer/cashier/** - - /buyer/pageData/** - - /buyer/article/** - - /buyer/goods/** - - /buyer/category/** - - /buyer/shop/** - - /buyer/connect/** - - /buyer/members/smsLogin - - /buyer/members/refresh/* - - /buyer/members/refresh** - - /buyer/promotion/pintuan - - /buyer/promotion/seckill - - /buyer/memberEvaluation/**/goodsEvaluation - - /buyer/memberEvaluation/**/evaluationNumber - - /store/login/** - /manager/user/login - /manager/user/refresh/** - /manager/elasticsearch diff --git a/seller-api/src/main/resources/application.yml b/seller-api/src/main/resources/application.yml index b6854c83..661e1f4b 100644 --- a/seller-api/src/main/resources/application.yml +++ b/seller-api/src/main/resources/application.yml @@ -135,24 +135,7 @@ ignored: - /MP_verify_qSyvBPhDsPdxvOhC.txt - /weixin/** - /source/** - - /buyer/mini-program/** - - /buyer/cashier/** - - /buyer/pageData/** - - /buyer/article/** - - /buyer/goods/** - - /buyer/category/** - - /buyer/shop/** - - /buyer/connect/** - - /buyer/members/smsLogin - - /buyer/members/refresh/* - - /buyer/members/refresh** - - /buyer/promotion/pintuan - - /buyer/promotion/seckill - - /buyer/memberEvaluation/**/goodsEvaluation - - /buyer/memberEvaluation/**/evaluationNumber - /store/login/** - - /manager/user/login - - /manager/user/refresh/** - /druid/** - /swagger-ui.html - /doc.html From 559dc0d29f4f033a55e39cf04d98394ca8c07eb8 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 May 2021 16:07:06 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E8=BF=90=E8=B4=B9=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=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 --- .../modules/order/cart/render/impl/SkuFreightRender.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java index 0ef0a395..afadb005 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java @@ -11,6 +11,7 @@ import cn.lili.modules.store.entity.dto.FreightTemplateChildDTO; import cn.lili.modules.store.entity.enums.FreightTemplateEnum; import cn.lili.modules.store.entity.vos.FreightTemplateVO; import cn.lili.modules.store.service.FreightTemplateService; +import com.xkcoding.http.util.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Service; @@ -43,8 +44,8 @@ public class SkuFreightRender implements CartRenderStep { forSku: for (CartSkuVO cartSkuVO : cartSkuVOS) { String freightTemplateId = cartSkuVO.getGoodsSku().getFreightTemplateId(); - //如果商品设置卖家承担运费,则跳出计算 - if (cartSkuVO.getFreightPayer().equals("STORE")) { + //如果商品设置卖家承担运费,或者没设置运费,则跳出此商品运费计算 + if (StringUtil.isEmpty(cartSkuVO.getFreightPayer())||cartSkuVO.getFreightPayer().equals("STORE")) { continue; } From c9eb018abc5b8e408f9ef9a4c24587bfc65a5d6c Mon Sep 17 00:00:00 2001 From: lifenlong Date: Fri, 21 May 2021 16:42:49 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E8=AF=84=E4=BB=B7=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=9A=84=E5=A5=BD=E8=AF=84=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/goods/service/GoodsService.java | 7 +++++ .../goods/serviceimpl/GoodsServiceImpl.java | 29 ++++++++++++++++++- .../serviceimpl/GoodsSkuServiceImpl.java | 9 ++---- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java index c84f0a97..253ebb87 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java @@ -122,4 +122,11 @@ public interface GoodsService extends IService { * @param quantity 库存数量 */ void updateStock(String goodsId, Integer quantity); + + /** + * 更新SKU评价数量 + * + * @param goodsId 商品ID + */ + void updateGoodsCommentNum(String goodsId); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 4d25c382..355d06e0 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -2,6 +2,7 @@ package cn.lili.modules.goods.serviceimpl; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; @@ -23,6 +24,9 @@ import cn.lili.modules.goods.entity.vos.GoodsSkuVO; import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.mapper.GoodsMapper; import cn.lili.modules.goods.service.*; +import cn.lili.modules.member.entity.dos.MemberEvaluation; +import cn.lili.modules.member.entity.enums.EvaluationGradeEnum; +import cn.lili.modules.member.service.MemberEvaluationService; import cn.lili.modules.store.entity.vos.StoreVO; import cn.lili.modules.store.service.StoreService; import cn.lili.modules.system.entity.dos.Setting; @@ -73,6 +77,8 @@ public class GoodsServiceImpl extends ServiceImpl implements //店铺详情 @Autowired private StoreService storeService; + @Autowired + private MemberEvaluationService memberEvaluationService; //rocketMq @Autowired private RocketMQTemplate rocketMQTemplate; @@ -80,6 +86,7 @@ public class GoodsServiceImpl extends ServiceImpl implements @Autowired private RocketmqCustomProperties rocketmqCustomProperties; + @Override public void underStoreGoods(String storeId) { this.baseMapper.underStoreGoods(storeId); @@ -234,7 +241,7 @@ public class GoodsServiceImpl extends ServiceImpl implements public Integer goodsNum(GoodsStatusEnum goodsStatusEnum, GoodsAuthEnum goodsAuthEnum) { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); - queryWrapper.eq(Goods::getDeleteFlag,false); + queryWrapper.eq(Goods::getDeleteFlag, false); if (goodsStatusEnum != null) { queryWrapper.eq(Goods::getMarketEnable, goodsStatusEnum.name()); @@ -313,6 +320,26 @@ public class GoodsServiceImpl extends ServiceImpl implements this.update(lambdaUpdateWrapper); } + @Override + public void updateGoodsCommentNum(String goodsId) { + + //获取商品信息 + Goods goods = this.getById(goodsId); + //修改商品评价数量 + goods.setCommentNum(goods.getCommentNum() + 1); + + //修改商品好评率 + LambdaQueryWrapper goodEvaluationQueryWrapper = new LambdaQueryWrapper<>(); + goodEvaluationQueryWrapper.eq(MemberEvaluation::getId, goodsId); + goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name()); + // 好评数量 + int highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper); + // 好评率 + double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goods.getCommentNum().doubleValue(), 2), 100); + goods.setGrade(grade); + this.updateById(goods); + } + /** * 添加商品默认图片 * diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index f8bf3640..17ca7d27 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -413,18 +413,15 @@ public class GoodsSkuServiceImpl extends ServiceImpl i goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1); // 好评率 - double grade = NumberUtil.div(highPraiseNum, goodsSku.getCommentNum().doubleValue(), 2) * 100; + double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goodsSku.getCommentNum().doubleValue(), 2), 100); goodsSku.setGrade(grade); //修改规格 this.update(goodsSku); //修改规格索引 goodsIndexService.updateIndexCommentNum(goodsSku.getId(), goodsSku.getCommentNum(), (int) highPraiseNum, grade); - //修改商品评价数量 - Goods goods = goodsService.getById(goodsSku.getGoodsId()); - goods.setCommentNum(goods.getCommentNum() + 1); - goodsService.updateById(goods); - + //修改商品的评价数量 + goodsService.updateGoodsCommentNum(goodsSku.getGoodsId()); } /** From 8f9c2621243ad1b0ef7a9e134d9305fdcde3bbd0 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 21 May 2021 17:05:46 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/cart/render/TradeBuilder.java | 6 +++++- .../order/cart/service/CartServiceImpl.java | 21 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java index 4373206c..ba32de5a 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/TradeBuilder.java @@ -92,7 +92,11 @@ public class TradeBuilder { tradeDTO.setSkuList(collect); //按照计划进行渲染 for (int index : defaultRender) { - cartRenderSteps.get(index).render(tradeDTO); + try { + cartRenderSteps.get(index).render(tradeDTO); + } catch (Exception e) { + log.error("购物车渲染异常:", e); + } } List cartVOList = new ArrayList<>(); for (CartVO i : tradeDTO.getCartList()) { diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 5ff5d4f3..4be0fc26 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -294,7 +294,7 @@ public class CartServiceImpl implements CartService { @Override public TradeDTO getCheckedTradeDTO(CartTypeEnum way) { - return tradeBuilder.buildTrade(way); + return this.readDTO(way); } /** @@ -443,7 +443,9 @@ public class CartServiceImpl implements CartService { */ @Override public Long getCartNum(Boolean checked) { + //构建购物车 TradeDTO tradeDTO = this.getCheckedTradeDTO(CartTypeEnum.CART); + //过滤sku列表 List collect = tradeDTO.getSkuList().stream().filter(i -> Boolean.FALSE.equals(i.getInvalid())).collect(Collectors.toList()); long count = 0L; if (!tradeDTO.getSkuList().isEmpty()) { @@ -458,12 +460,17 @@ public class CartServiceImpl implements CartService { @Override public void selectCoupon(String couponId, String way, boolean use) { + //获取购物车,然后重新写入优惠券 CartTypeEnum cartTypeEnum = getCartType(way); - TradeDTO tradeDTO = tradeBuilder.buildTrade(cartTypeEnum); + TradeDTO tradeDTO = this.readDTO(cartTypeEnum); - MemberCoupon memberCoupon = memberCouponService.getOne(new LambdaQueryWrapper().eq(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.NEW.name()).eq(MemberCoupon::getId, couponId)); + MemberCoupon memberCoupon = + memberCouponService.getOne( + new LambdaQueryWrapper() + .eq(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.NEW.name()) + .eq(MemberCoupon::getId, couponId)); if (memberCoupon == null) { - throw new ServiceException("当前优惠券可用数量不足"); + throw new ServiceException(ResultCode.COUPON_EXPIRED); } //使用优惠券 与否 if (use && checkCoupon(memberCoupon, tradeDTO)) { @@ -537,6 +544,12 @@ public class CartServiceImpl implements CartService { } } + /** + * 获取购物车类型 + * + * @param way + * @return + */ private CartTypeEnum getCartType(String way) { //默认购物车 CartTypeEnum cartTypeEnum = CartTypeEnum.CART; From ae69d8a11b0c25025176b76214d92682f0bb62ef Mon Sep 17 00:00:00 2001 From: lifenlong Date: Fri, 21 May 2021 17:24:09 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E6=A3=80=E6=B5=8BAPP=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=8F=AF=E4=BB=A5=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/common/enums/ResultCode.java | 2 +- .../system/service/AppVersionService.java | 7 +++++++ .../serviceimpl/AppVersionServiceImpl.java | 12 ++++++++++++ .../setting/AppVersionManagerController.java | 16 +++++++++++----- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 12228041..bf09e875 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -296,7 +296,7 @@ public enum ResultCode { WECHAT_QRCODE_ERROR(80502, "微信二维码生成异常"), WECHAT_MP_MESSAGE_ERROR(80503, "微信小程序小消息订阅异常"), - + APP_VERSION_EXIST(80600, "APP版本已存在") ; private final Integer code; private final String message; diff --git a/framework/src/main/java/cn/lili/modules/system/service/AppVersionService.java b/framework/src/main/java/cn/lili/modules/system/service/AppVersionService.java index bf729275..a54652c0 100644 --- a/framework/src/main/java/cn/lili/modules/system/service/AppVersionService.java +++ b/framework/src/main/java/cn/lili/modules/system/service/AppVersionService.java @@ -17,4 +17,11 @@ public interface AppVersionService extends IService { * @return 最新的APP版本号 */ AppVersion getAppVersion(String appType); + + /** + * 检测APP版本信息 + * @param appVersion app版本 + * @return 是否可添加 + */ + boolean checkAppVersion(AppVersion appVersion); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java index 12e0d198..8d31b954 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/AppVersionServiceImpl.java @@ -1,8 +1,11 @@ package cn.lili.modules.system.serviceimpl; +import cn.lili.common.enums.ResultCode; +import cn.lili.common.exception.ServiceException; import cn.lili.modules.system.entity.dos.AppVersion; import cn.lili.modules.system.mapper.AppVersionMapper; import cn.lili.modules.system.service.AppVersionService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -22,4 +25,13 @@ public class AppVersionServiceImpl extends ServiceImpl().eq(AppVersion::getVersion,appVersion))){ + throw new ServiceException(ResultCode.APP_VERSION_EXIST); + } + return true; + } } diff --git a/manager-api/src/main/java/cn/lili/controller/setting/AppVersionManagerController.java b/manager-api/src/main/java/cn/lili/controller/setting/AppVersionManagerController.java index 9d28b442..51d180b2 100755 --- a/manager-api/src/main/java/cn/lili/controller/setting/AppVersionManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/setting/AppVersionManagerController.java @@ -48,8 +48,11 @@ public class AppVersionManagerController { @ApiOperation(value = "添加app版本信息", response = AppVersion.class) @PostMapping public ResultMessage add(@Valid AppVersion appVersion) { - if(this.appVersionService.save(appVersion)){ - return ResultUtil.success(); + + if(this.appVersionService.checkAppVersion(appVersion)){ + if(this.appVersionService.save(appVersion)){ + return ResultUtil.success(); + } } throw new ServiceException(ResultCode.ERROR); } @@ -59,9 +62,12 @@ public class AppVersionManagerController { @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "String", paramType = "path") }) - public ResultMessage edit(@Valid AppVersion appVersion, @PathVariable String id) { - if(this.appVersionService.updateById(appVersion)){ - return ResultUtil.success(); + public ResultMessage edit(@Valid AppVersion appVersion, @PathVariable String id) { + + if(this.appVersionService.checkAppVersion(appVersion)){ + if(this.appVersionService.updateById(appVersion)){ + return ResultUtil.success(); + } } throw new ServiceException(ResultCode.ERROR); }