Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop
This commit is contained in:
commit
f119416a7b
@ -1,6 +1,5 @@
|
|||||||
package cn.lili.controller.goods;
|
package cn.lili.controller.goods;
|
||||||
|
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
|
||||||
import cn.lili.common.enums.ResultUtil;
|
import cn.lili.common.enums.ResultUtil;
|
||||||
import cn.lili.common.vo.PageVO;
|
import cn.lili.common.vo.PageVO;
|
||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
||||||
@ -75,21 +74,16 @@ public class GoodsBuyerController {
|
|||||||
@ApiOperation(value = "通过id获取商品信息")
|
@ApiOperation(value = "通过id获取商品信息")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "path"),
|
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "path"),
|
||||||
@ApiImplicitParam(name = "skuId", value = "skuId", required = true, paramType = "path"),
|
@ApiImplicitParam(name = "skuId", value = "skuId", required = true, paramType = "path")
|
||||||
@ApiImplicitParam(name = "distributionId", value = "分销员ID", dataType = "String", paramType = "query")
|
|
||||||
})
|
})
|
||||||
@GetMapping(value = "/sku/{goodsId}/{skuId}")
|
@GetMapping(value = "/sku/{goodsId}/{skuId}")
|
||||||
@PageViewPoint(type = PageViewEnum.SKU, id = "#id")
|
@PageViewPoint(type = PageViewEnum.SKU, id = "#id")
|
||||||
public ResultMessage<Map<String, Object>> getSku(@NotNull(message = "商品ID不能为空") @PathVariable("goodsId") String goodsId,
|
public ResultMessage<Map<String, Object>> getSku(@NotNull(message = "商品ID不能为空") @PathVariable("goodsId") String goodsId,
|
||||||
@NotNull(message = "SKU ID不能为空") @PathVariable("skuId") String skuId,
|
@NotNull(message = "SKU ID不能为空") @PathVariable("skuId") String skuId) {
|
||||||
String distributionId) {
|
|
||||||
|
|
||||||
Map<String, Object> map = goodsSkuService.getGoodsSkuDetail(goodsId, skuId);
|
Map<String, Object> map = goodsSkuService.getGoodsSkuDetail(goodsId, skuId);
|
||||||
|
|
||||||
//判断如果传递分销员则进行记录
|
|
||||||
if (CharSequenceUtil.isNotEmpty(distributionId)) {
|
|
||||||
distributionService.bindingDistribution(distributionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResultUtil.data(map);
|
return ResultUtil.data(map);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cn.lili.controller.other.distribution;
|
package cn.lili.controller.other.distribution;
|
||||||
|
|
||||||
import cn.lili.common.security.context.UserContext;
|
|
||||||
import cn.lili.common.enums.ResultUtil;
|
import cn.lili.common.enums.ResultUtil;
|
||||||
|
import cn.lili.common.security.context.UserContext;
|
||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
||||||
import cn.lili.modules.distribution.entity.dos.Distribution;
|
import cn.lili.modules.distribution.entity.dos.Distribution;
|
||||||
import cn.lili.modules.distribution.entity.dos.DistributionOrder;
|
import cn.lili.modules.distribution.entity.dos.DistributionOrder;
|
||||||
@ -65,4 +65,13 @@ public class DistributionBuyerController {
|
|||||||
|
|
||||||
return ResultUtil.data(distributionService.getDistribution());
|
return ResultUtil.data(distributionService.getDistribution());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//申请分销员
|
||||||
|
@ApiOperation(value = "绑定分销员")
|
||||||
|
@ApiImplicitParam(name = "distributionId", value = "分销员ID", required = true, paramType = "path")
|
||||||
|
@GetMapping("/bindingDistribution/{distributionId}")
|
||||||
|
public ResultMessage<Object> bindingDistribution(@PathVariable String distributionId){
|
||||||
|
distributionService.bindingDistribution(distributionId);
|
||||||
|
return ResultUtil.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package cn.lili.controller.other.distribution;
|
package cn.lili.controller.other.distribution;
|
||||||
|
|
||||||
|
import cn.lili.common.enums.ResultCode;
|
||||||
import cn.lili.common.enums.ResultUtil;
|
import cn.lili.common.enums.ResultUtil;
|
||||||
|
import cn.lili.common.exception.ServiceException;
|
||||||
import cn.lili.common.vo.PageVO;
|
import cn.lili.common.vo.PageVO;
|
||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
||||||
import cn.lili.modules.distribution.entity.dos.DistributionCash;
|
import cn.lili.modules.distribution.entity.dos.DistributionCash;
|
||||||
@ -48,9 +50,11 @@ public class DistributionCashBuyerController {
|
|||||||
@ApiImplicitParam(name = "price", value = "申请金额", required = true, paramType = "query", dataType = "double")
|
@ApiImplicitParam(name = "price", value = "申请金额", required = true, paramType = "query", dataType = "double")
|
||||||
})
|
})
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ResultMessage<Boolean> cash(@NotNull @ApiIgnore Double price) {
|
public ResultMessage<Object> cash(@NotNull @ApiIgnore Double price) {
|
||||||
Boolean result = distributionCashService.cash(price);
|
if(distributionCashService.cash(price)){
|
||||||
return ResultUtil.data(result);
|
return ResultUtil.success();
|
||||||
|
}
|
||||||
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "分销员提现历史")
|
@ApiOperation(value = "分销员提现历史")
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package cn.lili.controller.other.distribution;
|
package cn.lili.controller.other.distribution;
|
||||||
|
|
||||||
|
import cn.lili.common.enums.ResultCode;
|
||||||
import cn.lili.common.enums.ResultUtil;
|
import cn.lili.common.enums.ResultUtil;
|
||||||
|
import cn.lili.common.exception.ServiceException;
|
||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
||||||
import cn.lili.modules.distribution.entity.dto.DistributionGoodsSearchParams;
|
import cn.lili.modules.distribution.entity.dto.DistributionGoodsSearchParams;
|
||||||
import cn.lili.modules.distribution.entity.vos.DistributionGoodsVO;
|
import cn.lili.modules.distribution.entity.vos.DistributionGoodsVO;
|
||||||
@ -50,9 +52,11 @@ public class DistributionGoodsBuyerController {
|
|||||||
@ApiOperation(value = "选择分销商品")
|
@ApiOperation(value = "选择分销商品")
|
||||||
@ApiImplicitParam(name = "distributionGoodsId", value = "分销ID", required = true, dataType = "String", paramType = "path")
|
@ApiImplicitParam(name = "distributionGoodsId", value = "分销ID", required = true, dataType = "String", paramType = "path")
|
||||||
@GetMapping(value = "/checked/{distributionGoodsId}")
|
@GetMapping(value = "/checked/{distributionGoodsId}")
|
||||||
public ResultMessage<IPage<DistributionGoodsVO>> distributionCheckGoods(
|
public ResultMessage<Object> distributionCheckGoods(
|
||||||
@NotNull(message = "分销商品不能为空") @PathVariable("distributionGoodsId") String distributionGoodsId) {
|
@NotNull(message = "分销商品不能为空") @PathVariable("distributionGoodsId") String distributionGoodsId) {
|
||||||
distributionSelectedGoodsService.add(distributionGoodsId);
|
if(distributionSelectedGoodsService.add(distributionGoodsId)){
|
||||||
return ResultUtil.success();
|
return ResultUtil.success();
|
||||||
|
}
|
||||||
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.CouponVO;
|
||||||
import cn.lili.modules.promotion.entity.vos.PintuanVO;
|
import cn.lili.modules.promotion.entity.vos.PintuanVO;
|
||||||
import cn.lili.modules.promotion.service.*;
|
import cn.lili.modules.promotion.service.*;
|
||||||
|
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||||
import cn.lili.timetask.handler.EveryDayExecute;
|
import cn.lili.timetask.handler.EveryDayExecute;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
@ -34,6 +35,9 @@ public class PromotionEverydayExecute implements EveryDayExecute {
|
|||||||
//Mongo
|
//Mongo
|
||||||
@Autowired
|
@Autowired
|
||||||
private MongoTemplate mongoTemplate;
|
private MongoTemplate mongoTemplate;
|
||||||
|
//es
|
||||||
|
@Autowired
|
||||||
|
private EsGoodsIndexService esGoodsIndexService;
|
||||||
//满额活动
|
//满额活动
|
||||||
@Autowired
|
@Autowired
|
||||||
private FullDiscountService fullDiscountService;
|
private FullDiscountService fullDiscountService;
|
||||||
@ -74,6 +78,7 @@ public class PromotionEverydayExecute implements EveryDayExecute {
|
|||||||
if (vo.getPromotionGoodsList() != null && !vo.getPromotionGoodsList().isEmpty()) {
|
if (vo.getPromotionGoodsList() != null && !vo.getPromotionGoodsList().isEmpty()) {
|
||||||
for (PromotionGoods promotionGoods : vo.getPromotionGoodsList()) {
|
for (PromotionGoods promotionGoods : vo.getPromotionGoodsList()) {
|
||||||
promotionGoods.setPromotionStatus(PromotionStatusEnum.END.name());
|
promotionGoods.setPromotionStatus(PromotionStatusEnum.END.name());
|
||||||
|
esGoodsIndexService.deleteEsGoodsPromotionByPromotionId(promotionGoods.getSkuId(), vo.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mongoTemplate.save(vo);
|
mongoTemplate.save(vo);
|
||||||
@ -92,6 +97,7 @@ public class PromotionEverydayExecute implements EveryDayExecute {
|
|||||||
if (vo.getPromotionGoodsList() != null && !vo.getPromotionGoodsList().isEmpty()) {
|
if (vo.getPromotionGoodsList() != null && !vo.getPromotionGoodsList().isEmpty()) {
|
||||||
for (PromotionGoods promotionGoods : vo.getPromotionGoodsList()) {
|
for (PromotionGoods promotionGoods : vo.getPromotionGoodsList()) {
|
||||||
promotionGoods.setPromotionStatus(PromotionStatusEnum.END.name());
|
promotionGoods.setPromotionStatus(PromotionStatusEnum.END.name());
|
||||||
|
esGoodsIndexService.deleteEsGoodsPromotionByPromotionId(promotionGoods.getSkuId(), vo.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mongoTemplate.save(vo);
|
mongoTemplate.save(vo);
|
||||||
@ -110,6 +116,7 @@ public class PromotionEverydayExecute implements EveryDayExecute {
|
|||||||
if (vo.getPromotionGoodsList() != null && !vo.getPromotionGoodsList().isEmpty()) {
|
if (vo.getPromotionGoodsList() != null && !vo.getPromotionGoodsList().isEmpty()) {
|
||||||
for (PromotionGoods promotionGoods : vo.getPromotionGoodsList()) {
|
for (PromotionGoods promotionGoods : vo.getPromotionGoodsList()) {
|
||||||
promotionGoods.setPromotionStatus(PromotionStatusEnum.END.name());
|
promotionGoods.setPromotionStatus(PromotionStatusEnum.END.name());
|
||||||
|
esGoodsIndexService.deleteEsGoodsPromotionByPromotionId(promotionGoods.getSkuId(), vo.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mongoTemplate.save(vo);
|
mongoTemplate.save(vo);
|
||||||
|
@ -35,7 +35,9 @@ public abstract class AbstractDelayQueueMachineFactory {
|
|||||||
Calendar instance = Calendar.getInstance();
|
Calendar instance = Calendar.getInstance();
|
||||||
instance.add(Calendar.SECOND, time);
|
instance.add(Calendar.SECOND, time);
|
||||||
long delaySeconds = instance.getTimeInMillis() / 1000;
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class RocketmqTimerTrigger implements TimeTrigger {
|
|||||||
|
|
||||||
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(executorName, triggerTime, param, uniqueKey, topic);
|
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(executorName, triggerTime, param, uniqueKey, topic);
|
||||||
Message<TimeTriggerMsg> message = MessageBuilder.withPayload(timeTriggerMsg).build();
|
Message<TimeTriggerMsg> message = MessageBuilder.withPayload(timeTriggerMsg).build();
|
||||||
|
log.info("延时任务发送信息:{}", message);
|
||||||
this.rocketMQTemplate.asyncSend(topic, message, RocketmqSendCallbackBuilder.commonCallback());
|
this.rocketMQTemplate.asyncSend(topic, message, RocketmqSendCallbackBuilder.commonCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil;
|
|||||||
import cn.lili.common.delayqueue.AbstractDelayQueueMachineFactory;
|
import cn.lili.common.delayqueue.AbstractDelayQueueMachineFactory;
|
||||||
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
import cn.lili.common.trigger.interfaces.TimeTrigger;
|
||||||
import cn.lili.common.trigger.model.TimeTriggerMsg;
|
import cn.lili.common.trigger.model.TimeTriggerMsg;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,6 +19,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class PromotionDelayQueue extends AbstractDelayQueueMachineFactory {
|
public class PromotionDelayQueue extends AbstractDelayQueueMachineFactory {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
private TimeTrigger timeTrigger;
|
private TimeTrigger timeTrigger;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,7 +28,6 @@ public interface DistributionOrderService extends IService<DistributionOrder> {
|
|||||||
* @param orderSn 订单编号
|
* @param orderSn 订单编号
|
||||||
*/
|
*/
|
||||||
void payOrder(String orderSn);
|
void payOrder(String orderSn);
|
||||||
void test(String orderSn);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消订单
|
* 取消订单
|
||||||
|
@ -2,7 +2,6 @@ package cn.lili.modules.distribution.serviceimpl;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateField;
|
import cn.hutool.core.date.DateField;
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import cn.lili.common.utils.CurrencyUtil;
|
import cn.lili.common.utils.CurrencyUtil;
|
||||||
import cn.lili.common.utils.PageUtil;
|
import cn.lili.common.utils.PageUtil;
|
||||||
import cn.lili.modules.distribution.entity.dos.Distribution;
|
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.entity.dos.StoreFlow;
|
||||||
import cn.lili.modules.order.order.service.OrderService;
|
import cn.lili.modules.order.order.service.OrderService;
|
||||||
import cn.lili.modules.order.order.service.StoreFlowService;
|
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 cn.lili.modules.system.service.SettingService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
@ -84,50 +80,12 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
|
|||||||
distributionOrder.setDistributionName(distribution.getMemberName());
|
distributionOrder.setDistributionName(distribution.getMemberName());
|
||||||
|
|
||||||
//设置结算天数(解冻日期)
|
//设置结算天数(解冻日期)
|
||||||
Setting setting = settingService.get(SettingEnum.DISTRIBUTION_SETTING.name());
|
// Setting setting = settingService.get(SettingEnum.DISTRIBUTION_SETTING.name());
|
||||||
DistributionSetting distributionSetting = JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class);
|
// DistributionSetting distributionSetting = JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class);
|
||||||
DateTime dateTime = new DateTime();
|
DateTime dateTime = new DateTime();
|
||||||
dateTime.offsetNew(DateField.DAY_OF_MONTH,distributionSetting.getCashDay());
|
//默认解冻1天
|
||||||
distributionOrder.setSettleCycle(dateTime);
|
// dateTime.offsetNew(DateField.DAY_OF_MONTH,distributionSetting.getCashDay());
|
||||||
this.save(distributionOrder);
|
|
||||||
}
|
|
||||||
//如果包含分销商品则记录会员的分销总额
|
|
||||||
if(rebate!=0.0){
|
|
||||||
distributionService.addRebate(rebate,order.getDistributionId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void test(String orderSn) {
|
|
||||||
|
|
||||||
//根据订单编号获取订单数据
|
|
||||||
Order order = orderService.getBySn(orderSn);
|
|
||||||
|
|
||||||
//判断是否为分销订单,如果为分销订单则获取分销佣金
|
|
||||||
if (order.getDistributionId() != null) {
|
|
||||||
//根据订单编号获取有分销金额的店铺流水记录
|
|
||||||
List<StoreFlow> storeFlowList = storeFlowService.list(new LambdaQueryWrapper<StoreFlow>()
|
|
||||||
.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();
|
|
||||||
//默认提现周期一天
|
|
||||||
dateTime.offsetNew(DateField.DAY_OF_MONTH,1);
|
dateTime.offsetNew(DateField.DAY_OF_MONTH,1);
|
||||||
//dateTime.offsetNew(DateField.DAY_OF_MONTH,distributionSetting.getCashDay());
|
|
||||||
distributionOrder.setSettleCycle(dateTime);
|
distributionOrder.setSettleCycle(dateTime);
|
||||||
this.save(distributionOrder);
|
this.save(distributionOrder);
|
||||||
}
|
}
|
||||||
@ -138,7 +96,6 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelOrder(String orderSn) {
|
public void cancelOrder(String orderSn) {
|
||||||
this.update(new LambdaUpdateWrapper<DistributionOrder>().eq(DistributionOrder::getOrderSn, orderSn)
|
this.update(new LambdaUpdateWrapper<DistributionOrder>().eq(DistributionOrder::getOrderSn, orderSn)
|
||||||
|
@ -146,6 +146,11 @@ public class DistributionServiceImpl extends ServiceImpl<DistributionMapper, Dis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindingDistribution(String distributionId) {
|
public void bindingDistribution(String distributionId) {
|
||||||
|
|
||||||
|
//判断用户是否登录,未登录不能进行绑定
|
||||||
|
if(UserContext.getCurrentUser()==null){
|
||||||
|
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||||
|
}
|
||||||
//储存分销关系为3天
|
//储存分销关系为3天
|
||||||
Distribution distribution = this.getById(distributionId);
|
Distribution distribution = this.getById(distributionId);
|
||||||
if (distribution!=null) {
|
if (distribution!=null) {
|
||||||
|
@ -444,8 +444,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
goodsIndexService.addIndex(goodsIndex);
|
goodsIndexService.addIndex(goodsIndex);
|
||||||
} else if (goodsSku.getQuantity() > 0 && esGoodsOld != null) {
|
} else if (goodsSku.getQuantity() > 0 && esGoodsOld != null) {
|
||||||
goodsIndexService.updateIndex(goodsIndex);
|
goodsIndexService.updateIndex(goodsIndex);
|
||||||
} else if (goodsSku.getQuantity() <= 0 && esGoodsOld != null) {
|
|
||||||
goodsIndexService.deleteIndexById(goodsSku.getId());
|
|
||||||
}
|
}
|
||||||
//删除sku缓存
|
//删除sku缓存
|
||||||
cache.remove(GoodsSkuService.getCacheKeys(goodsSku.getId()));
|
cache.remove(GoodsSkuService.getCacheKeys(goodsSku.getId()));
|
||||||
|
@ -81,7 +81,7 @@ public class MemberEvaluation extends BaseEntity {
|
|||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
@ApiModelProperty(value = "评价图片")
|
@ApiModelProperty(value = "评价图片")
|
||||||
private String image;
|
private String images;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ApiModelProperty(value = "状态 OPEN 正常 ,CLOSE 关闭 ")
|
@ApiModelProperty(value = "状态 OPEN 正常 ,CLOSE 关闭 ")
|
||||||
|
@ -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.entity.dto.StorePromotionPriceDTO;
|
||||||
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||||
import cn.lili.modules.promotion.service.PromotionPriceService;
|
import cn.lili.modules.promotion.service.PromotionPriceService;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -27,6 +26,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,29 +151,26 @@ public class SkuPromotionRender implements CartRenderStep {
|
|||||||
|
|
||||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||||
// 根据店铺分配店铺价格计算结果
|
// 根据店铺分配店铺价格计算结果
|
||||||
List<StorePromotionPriceDTO> collect = promotionPrice.getStorePromotionPriceList().parallelStream().map(i -> i.getStoreId().equals(cartVO.getStoreId()) ? i : null).collect(Collectors.toList());
|
Optional<StorePromotionPriceDTO> storePromotionPriceDTOOptional = promotionPrice.getStorePromotionPriceList().parallelStream().filter(i -> i.getStoreId().equals(cartVO.getStoreId())).findAny();
|
||||||
if (!collect.isEmpty() && collect.get(0) != null) {
|
if (storePromotionPriceDTOOptional.isPresent()) {
|
||||||
StorePromotionPriceDTO storePromotionPriceDTO = collect.get(0);
|
StorePromotionPriceDTO storePromotionPriceDTO = storePromotionPriceDTOOptional.get();
|
||||||
// 根据商品分配商品结果计算结果
|
// 根据商品分配商品结果计算结果
|
||||||
this.distributionSkuPromotionPrice(cartVO.getSkuList(), storePromotionPriceDTO);
|
this.distributionSkuPromotionPrice(cartVO.getSkuList(), storePromotionPriceDTO);
|
||||||
|
|
||||||
if (storePromotionPriceDTO != null) {
|
PriceDetailDTO sSpd = new PriceDetailDTO();
|
||||||
PriceDetailDTO sSpd = new PriceDetailDTO();
|
PriceDetailVO sPd = new PriceDetailVO();
|
||||||
PriceDetailVO sPd = new PriceDetailVO();
|
sSpd.setGoodsPrice(storePromotionPriceDTO.getTotalOriginPrice());
|
||||||
sSpd.setGoodsPrice(storePromotionPriceDTO.getTotalOriginPrice());
|
sSpd.setDiscountPrice(storePromotionPriceDTO.getTotalDiscountPrice());
|
||||||
sSpd.setDiscountPrice(storePromotionPriceDTO.getTotalDiscountPrice());
|
sSpd.setCouponPrice(storePromotionPriceDTO.getTotalCouponPrice());
|
||||||
sSpd.setCouponPrice(storePromotionPriceDTO.getTotalCouponPrice());
|
sSpd.setPayPoint(storePromotionPriceDTO.getTotalPoints().intValue());
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +269,9 @@ public class CartServiceImpl implements CartService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cartSkuVOS.removeAll(deleteVos);
|
cartSkuVOS.removeAll(deleteVos);
|
||||||
|
// 清除选择的优惠券
|
||||||
|
tradeDTO.setPlatformCoupon(null);
|
||||||
|
tradeDTO.setStoreCoupons(null);
|
||||||
// 清除添加过的备注
|
// 清除添加过的备注
|
||||||
tradeDTO.setStoreRemark(null);
|
tradeDTO.setStoreRemark(null);
|
||||||
cache.put(this.getOriginKey(tradeDTO.getCartTypeEnum()), tradeDTO);
|
cache.put(this.getOriginKey(tradeDTO.getCartTypeEnum()), tradeDTO);
|
||||||
|
@ -118,7 +118,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
|||||||
promotionMessage,
|
promotionMessage,
|
||||||
coupon.getStartTime().getTime(), couponVO.getStartTime().getTime(),
|
coupon.getStartTime().getTime(), couponVO.getStartTime().getTime(),
|
||||||
DelayQueueTools.wrapperUniqueKey(DelayQueueType.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
DelayQueueTools.wrapperUniqueKey(DelayQueueType.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||||
DateUtil.getDelayTime(coupon.getStartTime().getTime()),
|
DateUtil.getDelayTime(couponVO.getStartTime().getTime()),
|
||||||
rocketmqCustomProperties.getPromotionTopic());
|
rocketmqCustomProperties.getPromotionTopic());
|
||||||
return couponVO;
|
return couponVO;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
|
|||||||
pintuanVO.getStartTime().getTime(),
|
pintuanVO.getStartTime().getTime(),
|
||||||
pintuan.getStartTime().getTime(),
|
pintuan.getStartTime().getTime(),
|
||||||
DelayQueueTools.wrapperUniqueKey(DelayQueueType.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
DelayQueueTools.wrapperUniqueKey(DelayQueueType.PROMOTION, (promotionMessage.getPromotionType() + promotionMessage.getPromotionId())),
|
||||||
DateUtil.getDelayTime(pintuan.getStartTime().getTime()),
|
DateUtil.getDelayTime(pintuanVO.getStartTime().getTime()),
|
||||||
rocketmqCustomProperties.getPromotionTopic());
|
rocketmqCustomProperties.getPromotionTopic());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +126,10 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
|||||||
if (platformCoupons != null && !platformCoupons.isEmpty()) {
|
if (platformCoupons != null && !platformCoupons.isEmpty()) {
|
||||||
// 计算平台优惠券活动
|
// 计算平台优惠券活动
|
||||||
couponTotalPrice = CurrencyUtil.add(couponTotalPrice, this.calculationCoupon(platformCoupons, priceDTOList));
|
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.setStorePromotionPriceList(storePromotionPriceList);
|
||||||
promotionPrice.setTotalCouponPrice(couponTotalPrice);
|
promotionPrice.setTotalCouponPrice(couponTotalPrice);
|
||||||
@ -290,17 +294,14 @@ public class PromotionPriceServiceImpl implements PromotionPriceService {
|
|||||||
// 合计优惠券范围内的所有商品的原价
|
// 合计优惠券范围内的所有商品的原价
|
||||||
double totalPrice = conformCollect.parallelStream().mapToDouble(GoodsSkuPromotionPriceDTO::getOriginalPrice).sum();
|
double totalPrice = conformCollect.parallelStream().mapToDouble(GoodsSkuPromotionPriceDTO::getOriginalPrice).sum();
|
||||||
|
|
||||||
double discountPrice = 0;
|
|
||||||
// 根据优惠券优惠类型,判断是否满足条件
|
// 根据优惠券优惠类型,判断是否满足条件
|
||||||
if (CouponTypeEnum.PRICE.name().equals(coupon.getCouponType()) && coupon.getConsumeThreshold() <= totalPrice) {
|
if (CouponTypeEnum.PRICE.name().equals(coupon.getCouponType()) && coupon.getConsumeThreshold() <= totalPrice) {
|
||||||
couponTotalPrice = CurrencyUtil.add(couponTotalPrice, coupon.getPrice());
|
couponTotalPrice = CurrencyUtil.add(couponTotalPrice, coupon.getPrice());
|
||||||
discountPrice = coupon.getPrice();
|
|
||||||
} else if (CouponTypeEnum.DISCOUNT.name().equals(coupon.getCouponType())) {
|
} else if (CouponTypeEnum.DISCOUNT.name().equals(coupon.getCouponType())) {
|
||||||
double fullRate = coupon.getDiscount() >= 10 ? coupon.getDiscount() / 100 : coupon.getDiscount() / 10;
|
double fullRate = coupon.getDiscount() >= 10 ? coupon.getDiscount() / 100 : coupon.getDiscount() / 10;
|
||||||
double discountRatePrice = CurrencyUtil.sub(totalPrice, CurrencyUtil.mul(totalPrice, fullRate));
|
double discountRatePrice = CurrencyUtil.sub(totalPrice, CurrencyUtil.mul(totalPrice, fullRate));
|
||||||
|
|
||||||
couponTotalPrice = CurrencyUtil.add(couponTotalPrice, discountRatePrice);
|
couponTotalPrice = CurrencyUtil.add(couponTotalPrice, discountRatePrice);
|
||||||
discountPrice = discountRatePrice;
|
|
||||||
// 消费限额判断
|
// 消费限额判断
|
||||||
// if (coupon.getConsumeThreshold() >= discountRatePrice) {
|
// if (coupon.getConsumeThreshold() >= discountRatePrice) {
|
||||||
// couponTotalPrice = CurrencyUtil.add(couponTotalPrice, 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) {
|
for (GoodsSkuPromotionPriceDTO goodsSkuPromotionPriceDTO : conformCollect) {
|
||||||
|
double rate = CurrencyUtil.div(goodsSkuPromotionPriceDTO.getFinalePrice(), totalPrice, 5);
|
||||||
|
double distributeCouponPrice = CurrencyUtil.mul(couponTotalPrice, rate);
|
||||||
if (goodsSkuPromotionPriceDTO.getFinalePrice() != null) {
|
if (goodsSkuPromotionPriceDTO.getFinalePrice() != null) {
|
||||||
goodsSkuPromotionPriceDTO.setFinalePrice(CurrencyUtil.sub(goodsSkuPromotionPriceDTO.getFinalePrice(), distributePrice));
|
goodsSkuPromotionPriceDTO.setFinalePrice(CurrencyUtil.sub(goodsSkuPromotionPriceDTO.getFinalePrice(), distributeCouponPrice));
|
||||||
} else {
|
} 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()));
|
goodsSkuPromotionPriceDTO.setTotalFinalePrice(CurrencyUtil.mul(goodsSkuPromotionPriceDTO.getFinalePrice(), goodsSkuPromotionPriceDTO.getNumber()));
|
||||||
BasePromotion basePromotion = new BasePromotion();
|
BasePromotion basePromotion = new BasePromotion();
|
||||||
basePromotion.setId(coupon.getId());
|
basePromotion.setId(coupon.getId());
|
||||||
|
@ -105,6 +105,12 @@ public interface EsGoodsIndexService {
|
|||||||
*/
|
*/
|
||||||
void deleteEsGoodsPromotionIndexByList(List<String> skuIds, PromotionTypeEnum promotionType);
|
void deleteEsGoodsPromotionIndexByList(List<String> skuIds, PromotionTypeEnum promotionType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除索引中指定的促销活动id的促销活动
|
||||||
|
* @param skuId 商品skuId
|
||||||
|
* @param promotionId 促销活动Id
|
||||||
|
*/
|
||||||
|
void deleteEsGoodsPromotionByPromotionId(String skuId, String promotionId);
|
||||||
/**
|
/**
|
||||||
* 清除所以商品索引的无效促销活动
|
* 清除所以商品索引的无效促销活动
|
||||||
*/
|
*/
|
||||||
|
@ -203,7 +203,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
|||||||
@Override
|
@Override
|
||||||
public void updateEsGoodsIndexAllByList(BasePromotion promotion, String key) {
|
public void updateEsGoodsIndexAllByList(BasePromotion promotion, String key) {
|
||||||
List<EsGoodsIndex> goodsIndices;
|
List<EsGoodsIndex> goodsIndices;
|
||||||
//如果storeid不为空,则表示是店铺活动
|
//如果storeId不为空,则表示是店铺活动
|
||||||
if (promotion.getStoreId() != null) {
|
if (promotion.getStoreId() != null) {
|
||||||
EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO();
|
EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO();
|
||||||
searchDTO.setStoreId(promotion.getStoreId());
|
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<String, Object> promotionMap = goodsIndex.getPromotionMap();
|
||||||
|
if (promotionMap != null && !promotionMap.isEmpty()) {
|
||||||
|
// 如果存在同类型促销活动删除
|
||||||
|
List<String> collect = promotionMap.keySet().stream().filter(i -> i.split("-")[1].equals(promotionId)).collect(Collectors.toList());
|
||||||
|
collect.forEach(promotionMap::remove);
|
||||||
|
goodsIndex.setPromotionMap(promotionMap);
|
||||||
|
updateIndex(goodsIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除所有商品索引的无效促销活动
|
* 清除所有商品索引的无效促销活动
|
||||||
*/
|
*/
|
||||||
|
@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.lucene.search.join.ScoreMode;
|
import org.apache.lucene.search.join.ScoreMode;
|
||||||
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
|
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
|
||||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
|
import org.elasticsearch.index.query.NestedQueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
|
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
|
||||||
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
|
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) {
|
private NativeSearchQueryBuilder createSearchQueryBuilder(EsGoodsSearchDTO searchDTO, PageVO pageVo, boolean isAggregation) {
|
||||||
NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder();
|
NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder();
|
||||||
if (pageVo != null) {
|
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);
|
nativeSearchQueryBuilder.withPageable(pageable);
|
||||||
}
|
}
|
||||||
@ -336,6 +341,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
|||||||
String[] props = searchDTO.getProp().split("@");
|
String[] props = searchDTO.getProp().split("@");
|
||||||
List<String> nameList = new ArrayList<>();
|
List<String> nameList = new ArrayList<>();
|
||||||
List<String> valueList = new ArrayList<>();
|
List<String> valueList = new ArrayList<>();
|
||||||
|
Map<String, List<String>> valueMap = new HashMap<>();
|
||||||
for (String prop : props) {
|
for (String prop : props) {
|
||||||
String[] propValues = prop.split("_");
|
String[] propValues = prop.split("_");
|
||||||
String name = propValues[0];
|
String name = propValues[0];
|
||||||
@ -346,14 +352,29 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
|||||||
if (!valueList.contains(value)) {
|
if (!valueList.contains(value)) {
|
||||||
valueList.add(value);
|
valueList.add(value);
|
||||||
}
|
}
|
||||||
if (isAggregation) {
|
// 将同一规格名下的规格值分组
|
||||||
filterBuilder.must(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.termQuery(ATTR_NAME, name), ScoreMode.None));
|
if (!valueMap.containsKey(name)) {
|
||||||
filterBuilder.should(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.termsQuery(ATTR_VALUE, value), ScoreMode.None));
|
List<String> values = new ArrayList<>();
|
||||||
|
values.add(value);
|
||||||
|
valueMap.put(name, values);
|
||||||
} else {
|
} else {
|
||||||
queryBuilder.must(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.termQuery(ATTR_NAME, name), ScoreMode.None));
|
valueMap.get(name).add(value);
|
||||||
queryBuilder.must(QueryBuilders.nestedQuery(ATTR_PATH, QueryBuilders.wildcardQuery(ATTR_VALUE, "*" + value + "*"), ScoreMode.None));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
BoolQueryBuilder usedQueryBuilder;
|
||||||
|
if (isAggregation) {
|
||||||
|
usedQueryBuilder = filterBuilder;
|
||||||
|
} else {
|
||||||
|
usedQueryBuilder = queryBuilder;
|
||||||
|
}
|
||||||
|
// 遍历所有的规格
|
||||||
|
for (Map.Entry<String, List<String>> 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_NAME_KEY, nameList);
|
||||||
searchDTO.getNotShowCol().put(ATTR_VALUE_KEY, valueList);
|
searchDTO.getNotShowCol().put(ATTR_VALUE_KEY, valueList);
|
||||||
|
@ -59,7 +59,6 @@ public class AppVersionDO{
|
|||||||
@ApiModelProperty(value = "版本名称")
|
@ApiModelProperty(value = "版本名称")
|
||||||
private String versionName;
|
private String versionName;
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "更新内容")
|
@ApiModelProperty(value = "更新内容")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cn.lili.controller.setting;
|
package cn.lili.controller.setting;
|
||||||
|
|
||||||
|
import cn.lili.common.enums.ResultCode;
|
||||||
|
import cn.lili.common.exception.ServiceException;
|
||||||
import cn.lili.common.utils.PageUtil;
|
import cn.lili.common.utils.PageUtil;
|
||||||
import cn.lili.common.enums.ResultUtil;
|
import cn.lili.common.enums.ResultUtil;
|
||||||
import cn.lili.common.utils.StringUtils;
|
import cn.lili.common.utils.StringUtils;
|
||||||
@ -45,8 +47,11 @@ public class AppVersionManagerController {
|
|||||||
|
|
||||||
@ApiOperation(value = "添加app版本信息", response = AppVersionDO.class)
|
@ApiOperation(value = "添加app版本信息", response = AppVersionDO.class)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ResultMessage<Boolean> add(@Valid AppVersionDO appVersionDO) {
|
public ResultMessage<Object> add(@Valid AppVersionDO appVersionDO) {
|
||||||
return ResultUtil.data(this.appVersionService.save(appVersionDO));
|
if(this.appVersionService.save(appVersionDO)){
|
||||||
|
return ResultUtil.success();
|
||||||
|
}
|
||||||
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping(value = "/{id}")
|
@PutMapping(value = "/{id}")
|
||||||
@ -55,10 +60,10 @@ public class AppVersionManagerController {
|
|||||||
@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "String", paramType = "path")
|
@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "String", paramType = "path")
|
||||||
})
|
})
|
||||||
public ResultMessage<Boolean> edit(@Valid AppVersionDO appVersionDO, @PathVariable String id) {
|
public ResultMessage<Boolean> edit(@Valid AppVersionDO appVersionDO, @PathVariable String id) {
|
||||||
if (appVersionService.getById(id) != null) {
|
if(this.appVersionService.updateById(appVersionDO)){
|
||||||
return ResultUtil.data(this.appVersionService.updateById(appVersionDO));
|
return ResultUtil.success();
|
||||||
}
|
}
|
||||||
return ResultUtil.data(false);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
@ -67,10 +72,10 @@ public class AppVersionManagerController {
|
|||||||
@ApiImplicitParam(name = "id", value = "要删除的app版本主键", required = true, dataType = "String", paramType = "path")
|
@ApiImplicitParam(name = "id", value = "要删除的app版本主键", required = true, dataType = "String", paramType = "path")
|
||||||
})
|
})
|
||||||
public ResultMessage<Boolean> delete(@PathVariable String id) {
|
public ResultMessage<Boolean> delete(@PathVariable String id) {
|
||||||
if (appVersionService.getById(id) != null) {
|
if(this.appVersionService.removeById(id)){
|
||||||
return ResultUtil.data(this.appVersionService.removeById(id));
|
return ResultUtil.success();
|
||||||
}
|
}
|
||||||
return ResultUtil.data(true);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user