diff --git a/README.md b/README.md index 6994b0e5..40afe318 100644 --- a/README.md +++ b/README.md @@ -132,54 +132,92 @@ 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 | + +### 升级计划 + +时间: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日 + +``` +新增功能: +增加供应商功能 +``` + + ### 技术亮点 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/buyer-api/src/main/resources/application.yml b/buyer-api/src/main/resources/application.yml index 28176198..fa22d1d5 100644 --- a/buyer-api/src/main/resources/application.yml +++ b/buyer-api/src/main/resources/application.yml @@ -149,9 +149,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/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/config/application.yml b/config/application.yml index 1580b489..38c732bd 100644 --- a/config/application.yml +++ b/config/application.yml @@ -146,6 +146,7 @@ ignored: - /buyer/promotion/pointsGoods/** - /buyer/memberEvaluation/**/goodsEvaluation - /buyer/memberEvaluation/**/evaluationNumber + - /buyer/appVersion/** - /store/login/** - /manager/user/login - /manager/user/refresh/** 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/common/delayqueue/AbstractDelayQueueMachineFactory.java b/framework/src/main/java/cn/lili/common/delayqueue/AbstractDelayQueueMachineFactory.java index c74aadbd..aa6aebe3 100644 --- a/framework/src/main/java/cn/lili/common/delayqueue/AbstractDelayQueueMachineFactory.java +++ b/framework/src/main/java/cn/lili/common/delayqueue/AbstractDelayQueueMachineFactory.java @@ -35,7 +35,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/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index aad779da..838afc87 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, "该用户名已被注册"), @@ -297,7 +297,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/common/sms/impl/SmsUtilAliImplService.java b/framework/src/main/java/cn/lili/common/sms/impl/SmsUtilAliImplService.java index a592bcef..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 @@ -53,39 +53,61 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil { @Override public void sendSmsCode(String mobile, VerificationEnums verificationEnums, String uuid) { + //获取短信配置 + Setting setting = settingService.get(SettingEnum.SMS_SETTING.name()); + if (StrUtil.isBlank(setting.getSettingValue())) { + throw new ServiceException("您还未配置阿里云短信"); + } + SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class); + //验证码 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(smsSetting.getSignName(), mobile, params, templateCode); + } @Override @@ -309,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("您还未配置阿里云短信"); } @@ -317,11 +339,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); 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 54262022..88e098f2 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/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) 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/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/GoodsGalleryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java index 6cd18533..97bbad2c 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 @@ -59,7 +59,7 @@ public class GoodsGalleryServiceImpl 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 d5d04291..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()); } /** @@ -444,8 +441,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/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 关闭 ") 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); } } 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/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; } 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..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 @@ -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); @@ -291,7 +294,7 @@ public class CartServiceImpl implements CartService { @Override public TradeDTO getCheckedTradeDTO(CartTypeEnum way) { - return tradeBuilder.buildTrade(way); + return this.readDTO(way); } /** @@ -440,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()) { @@ -455,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)) { @@ -534,6 +544,12 @@ public class CartServiceImpl implements CartService { } } + /** + * 获取购物车类型 + * + * @param way + * @return + */ private CartTypeEnum getCartType(String way) { //默认购物车 CartTypeEnum cartTypeEnum = CartTypeEnum.CART; 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 da679bce..bb01624c 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 @@ -117,7 +117,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()); } 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/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..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 @@ -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; @@ -256,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); } @@ -336,6 +341,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 +352,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); 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..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 @@ -1,15 +1,27 @@ 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); + /** + * 检测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 51ece980..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.modules.system.entity.dos.AppVersionDO; +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; @@ -16,6 +19,19 @@ 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); + } + + @Override + public boolean checkAppVersion(AppVersion appVersion) { + //检测版本是否存在 + if(null!=this.getOne(new LambdaQueryWrapper().eq(AppVersion::getVersion,appVersion))){ + throw new ServiceException(ResultCode.APP_VERSION_EXIST); + } + return true; + } } diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java index 1518d878..32e869b3 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java @@ -68,7 +68,7 @@ public class LogisticsServiceImpl extends ServiceImpl> 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)){ - return ResultUtil.success(); + public ResultMessage add(@Valid AppVersion appVersion) { + + if(this.appVersionService.checkAppVersion(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)){ - 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); } diff --git a/manager-api/src/main/resources/application.yml b/manager-api/src/main/resources/application.yml index ea7d0fc5..32a020c0 100644 --- a/manager-api/src/main/resources/application.yml +++ b/manager-api/src/main/resources/application.yml @@ -132,22 +132,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 18f63912..b65c27be 100644 --- a/seller-api/src/main/resources/application.yml +++ b/seller-api/src/main/resources/application.yml @@ -132,24 +132,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