|
|
@@ -3,16 +3,15 @@ package com.izouma.dingdong.service.merchant;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.izouma.dingdong.converter.LongArrayConverter;
|
|
|
import com.izouma.dingdong.domain.MoneyRecord;
|
|
|
import com.izouma.dingdong.domain.OrderInfo;
|
|
|
import com.izouma.dingdong.domain.User;
|
|
|
-import com.izouma.dingdong.domain.backstage.Banner;
|
|
|
-import com.izouma.dingdong.domain.backstage.Category;
|
|
|
-import com.izouma.dingdong.domain.backstage.Promote;
|
|
|
-import com.izouma.dingdong.domain.backstage.TimeTag;
|
|
|
+import com.izouma.dingdong.domain.backstage.*;
|
|
|
import com.izouma.dingdong.domain.merchant.Goods;
|
|
|
import com.izouma.dingdong.domain.merchant.Merchant;
|
|
|
import com.izouma.dingdong.domain.merchant.MerchantSettings;
|
|
|
+import com.izouma.dingdong.domain.merchant.Sales;
|
|
|
import com.izouma.dingdong.domain.user.UserCoupon;
|
|
|
import com.izouma.dingdong.dto.FilterDTO;
|
|
|
import com.izouma.dingdong.dto.MerchantDTO;
|
|
|
@@ -21,10 +20,7 @@ import com.izouma.dingdong.enums.ApplyStatus;
|
|
|
import com.izouma.dingdong.enums.FinancialType;
|
|
|
import com.izouma.dingdong.exception.BusinessException;
|
|
|
import com.izouma.dingdong.repo.*;
|
|
|
-import com.izouma.dingdong.repo.backstage.BannerRepo;
|
|
|
-import com.izouma.dingdong.repo.backstage.CategoryRepo;
|
|
|
-import com.izouma.dingdong.repo.backstage.PromoteRepo;
|
|
|
-import com.izouma.dingdong.repo.backstage.TimeTagRepo;
|
|
|
+import com.izouma.dingdong.repo.backstage.*;
|
|
|
import com.izouma.dingdong.repo.merchant.*;
|
|
|
import com.izouma.dingdong.repo.user.UserCouponRepo;
|
|
|
import com.izouma.dingdong.service.backstage.CategoryService;
|
|
|
@@ -61,13 +57,8 @@ public class MerchantSettingsService {
|
|
|
private MerchantService merchantService;
|
|
|
private CouponRepo couponRepo;
|
|
|
private UserCouponRepo userCouponRepo;
|
|
|
-
|
|
|
- /*
|
|
|
- 显示所有订单
|
|
|
- */
|
|
|
- public List<OrderInfo> allOrder(Long id) {
|
|
|
- return orderInfoRepo.findAllByMerchantId(id);
|
|
|
- }
|
|
|
+ private PriorityRepo priorityRepo;
|
|
|
+ private SalesRepo salesRepo;
|
|
|
|
|
|
/*
|
|
|
时间标签类商家列表
|
|
|
@@ -91,8 +82,14 @@ public class MerchantSettingsService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /*
|
|
|
- 商户叮咚币记录
|
|
|
+ /**
|
|
|
+ * 商户叮咚币记录
|
|
|
+ *
|
|
|
+ * @param merchantId 商户id
|
|
|
+ * @param fromUserId 支出用户
|
|
|
+ * @param amount 金额
|
|
|
+ * @param type 类型
|
|
|
+ * @param remark 备注
|
|
|
*/
|
|
|
public void income(Long merchantId, Long fromUserId, BigDecimal amount, FinancialType type, String remark) {
|
|
|
//按商户Id找出用户
|
|
|
@@ -174,18 +171,6 @@ public class MerchantSettingsService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- 明星商家
|
|
|
- */
|
|
|
- public boolean starMerchant(Merchant merchant) {
|
|
|
- //非新商家
|
|
|
- boolean b = merchant.getEstablishTime().isAfter(LocalDateTime.now().minusMonths(1));
|
|
|
- if (b) {
|
|
|
- return merchant.getMonthSales() >= 10000 && merchant.getBadNum() > 0 && merchant.getGoodNum() > 3000;
|
|
|
- }
|
|
|
- return false;
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
/*
|
|
|
人均消费 月订单
|
|
|
@@ -212,62 +197,20 @@ public class MerchantSettingsService {
|
|
|
//删除商户
|
|
|
merchantRepo.deleteById(merchantId);
|
|
|
merchantSettingsRepo.deleteByMerchantId(merchantId);
|
|
|
-
|
|
|
//删除商品规格
|
|
|
List<Long> collect = goodsRepo.findAllByMerchantId(merchantId).stream().map(Goods::getId).collect(Collectors.toList());
|
|
|
collect.forEach(c -> goodsSpecificationRepo.deleteByGoodsId(c));
|
|
|
-
|
|
|
//删除商品
|
|
|
goodsRepo.deleteAllByMerchantId(merchantId);
|
|
|
-
|
|
|
//删除订单
|
|
|
orderInfoRepo.deleteAllByMerchantId(merchantId);
|
|
|
-
|
|
|
//删除评价
|
|
|
appraisalRepo.deleteAllByMerchantId(merchantId);
|
|
|
-
|
|
|
//删除商家分类
|
|
|
merchantClassificationRepo.findAllByMerchantId(merchantId);
|
|
|
|
|
|
}
|
|
|
|
|
|
- //商家推广语
|
|
|
- //每月一更
|
|
|
- public void merPromo() {
|
|
|
- List<Category> byParent = categoryRepo.findAllByParent(1L);
|
|
|
- byParent.forEach(this::accept);
|
|
|
- }
|
|
|
-
|
|
|
- private void accept(Category c) {
|
|
|
- List<MerchantDTO> list = categoryService.categoryMer(c.getId());
|
|
|
- List<Merchant> merchants = new ArrayList<>();
|
|
|
- list.sort((a, b) -> b.getMonthSales().compareTo(a.getMonthSales()));
|
|
|
-
|
|
|
- for (int i = 0; i < 5; i++) {
|
|
|
- Merchant merchant = merchantRepo.findById(list.get(i).getMid()).orElseThrow(new BusinessException("无商家"));
|
|
|
- String name;
|
|
|
- switch (i) {
|
|
|
- case 0:
|
|
|
- name = "商家月销售冠军";
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- name = "商家月销售亚军";
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- name = "商家月销售季军";
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- name = "商家月销售第四名";
|
|
|
- break;
|
|
|
- default:
|
|
|
- name = "商家月销售第五名";
|
|
|
- }
|
|
|
- merchant.setPromo(c.getName() + name);
|
|
|
- merchants.add(merchant);
|
|
|
- }
|
|
|
- merchantRepo.saveAll(merchants);
|
|
|
- }
|
|
|
-
|
|
|
public MerchantDTO getDTO(Long id) {
|
|
|
Merchant merchant = merchantRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
MerchantSettings merchantSettings = merchantSettingsRepo.findByMerchantId(id).orElseThrow(new BusinessException("无记录"));
|
|
|
@@ -343,118 +286,119 @@ public class MerchantSettingsService {
|
|
|
return conB.compareTo(conA);
|
|
|
});
|
|
|
break;
|
|
|
- case 7:
|
|
|
+ //case 7:
|
|
|
//距离
|
|
|
//dtos.sort(Comparator.comparing(MerchantDTO::getDistance));
|
|
|
case 8:
|
|
|
//月销
|
|
|
dtos.sort((a, b) -> b.getMonthSales().compareTo(a.getMonthSales()));
|
|
|
break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
return dtos;
|
|
|
}
|
|
|
|
|
|
- public List<MerchantDTO> listFilter(List<MerchantDTO> dtos, Integer filter, Long userId) {
|
|
|
- List<MerchantDTO> collect = new ArrayList<>();
|
|
|
-// if (filter != null) {
|
|
|
- switch (filter) {
|
|
|
- case 1:
|
|
|
- //首单立减
|
|
|
+ public List<MerchantDTO> listFilter(List<MerchantDTO> dtos, String filter, Long userId) {
|
|
|
+ Set<MerchantDTO> collect = new HashSet<>();
|
|
|
+ LongArrayConverter converter = new LongArrayConverter();
|
|
|
+ List<Long> longs = converter.convertToEntityAttribute(filter);
|
|
|
+ for (Long l : longs) {
|
|
|
+ if (l == 1) {//首单立减
|
|
|
collect.addAll(dtos.stream()
|
|
|
.filter(d -> d.getFirstOrder() != null && d.getFirstOrder().compareTo(BigDecimal.ZERO) > 0)
|
|
|
- .collect(Collectors.toList()));
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- //满减优惠
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+ } else if (l == 2) {//满减优惠
|
|
|
collect.addAll(dtos.stream()
|
|
|
.filter(d -> CollUtil.isNotEmpty(fullReductionRepo.findAllByMerchantId(d.getMid())))
|
|
|
- .collect(Collectors.toList()));
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- //折扣商家
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+ } else if (l == 3) {//折扣商家
|
|
|
collect.addAll(dtos.stream()
|
|
|
- .filter(d -> StrUtil.isNotEmpty(merchantClassificationRepo.findByMerchantIdAndType(d.getMid(), 2).getGoodsIds()))
|
|
|
- .collect(Collectors.toList()));
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- //下单返红包
|
|
|
+ .filter(d -> StrUtil.isNotEmpty(
|
|
|
+ merchantClassificationRepo.findByMerchantIdAndType(d.getMid(), 2).getGoodsIds()))
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+ } else if (l == 4) {//下单返红包
|
|
|
collect.addAll(dtos.stream()
|
|
|
.filter(d -> CollUtil.isNotEmpty(couponRepo.findAllByMerchantIdAndEnabledTrue(d.getMid())))
|
|
|
- .collect(Collectors.toList()));
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- //可用红包
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+ } else if (l == 5) {//可用红包
|
|
|
List<UserCoupon> coupons = userCouponRepo.findAllByUserIdAndIsUsedFalse(userId);
|
|
|
collect.addAll(dtos.stream()
|
|
|
.filter(d ->
|
|
|
ObjectUtil.isNotEmpty(coupons.stream().filter(c ->
|
|
|
!c.getCoupon().getEndDate().isBefore(LocalDate.now())
|
|
|
&& (c.getCoupon().getMerchantId() == null || c.getCoupon().getMerchantId().equals(d.getMid()))
|
|
|
- ).collect(Collectors.toList()))
|
|
|
+ ).collect(Collectors.toSet()))
|
|
|
)
|
|
|
- .collect(Collectors.toList()));
|
|
|
- break;
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+ }
|
|
|
}
|
|
|
-// }
|
|
|
- return collect;
|
|
|
+ return new ArrayList<>(collect);
|
|
|
}
|
|
|
|
|
|
//其他筛选条件
|
|
|
public List<MerchantDTO> otherFilter(List<MerchantDTO> dtos, FilterDTO filterDto) {
|
|
|
- List<MerchantDTO> collect = new ArrayList<>();
|
|
|
+ Set<MerchantDTO> collect = new HashSet<>();
|
|
|
+ LongArrayConverter converter = new LongArrayConverter();
|
|
|
if (filterDto.getNatureId() != null) {
|
|
|
+ List<Long> natureIds = converter.convertToEntityAttribute(filterDto.getFilter());
|
|
|
//商家性质筛选
|
|
|
- collect.addAll(dtos.stream()
|
|
|
- .filter(d -> d.getMerchantNatureId().equals(filterDto.getNatureId()))
|
|
|
- .collect(Collectors.toList()));
|
|
|
+ natureIds.forEach(n ->
|
|
|
+ collect.addAll(dtos.stream()
|
|
|
+ .filter(d -> d.getMerchantNatureId().equals(n))
|
|
|
+ .collect(Collectors.toSet()))
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
+ //金额区间
|
|
|
if (filterDto.getStartAmount() != null && filterDto.getEndAmount() != null) {
|
|
|
collect.addAll(dtos.stream()
|
|
|
.filter(d -> this.consumption(d.getMid()).compareTo(filterDto.getStartAmount()) >= 0
|
|
|
&& this.consumption(d.getMid()).compareTo(filterDto.getEndAmount()) <= 0
|
|
|
- ).collect(Collectors.toList()));
|
|
|
+ ).collect(Collectors.toSet()));
|
|
|
|
|
|
} else if (filterDto.getStartAmount() != null) {
|
|
|
collect.addAll(dtos.stream()
|
|
|
.filter(d -> this.consumption(d.getMid()).compareTo(filterDto.getStartAmount()) >= 0
|
|
|
- ).collect(Collectors.toList()));
|
|
|
+ ).collect(Collectors.toSet()));
|
|
|
|
|
|
} else if (filterDto.getEndAmount() != null) {
|
|
|
collect.addAll(dtos.stream()
|
|
|
.filter(d -> this.consumption(d.getMid()).compareTo(filterDto.getEndAmount()) <= 0
|
|
|
- ).collect(Collectors.toList()));
|
|
|
+ ).collect(Collectors.toSet()));
|
|
|
} else {
|
|
|
collect.addAll(dtos);
|
|
|
}
|
|
|
|
|
|
+ //标签
|
|
|
if (filterDto.getTag() != null) {
|
|
|
- switch (filterDto.getTag()) {
|
|
|
- case 1:
|
|
|
- //新商家
|
|
|
- LocalDate date = LocalDate.now().minusMonths(1);
|
|
|
- LocalTime time = LocalTime.parse("00:00:00");
|
|
|
- LocalDateTime dateTime = LocalDateTime.of(date, time);
|
|
|
+ List<Long> tags = converter.convertToEntityAttribute(filterDto.getTag());
|
|
|
+ tags.forEach(t -> {
|
|
|
+ if (t == 1) {//新商家
|
|
|
collect.addAll(dtos.stream()
|
|
|
- .filter(d -> d.getEstablishTime().isAfter(dateTime))
|
|
|
- .collect(Collectors.toList()));
|
|
|
- break;
|
|
|
-
|
|
|
- case 2:
|
|
|
- //明星商家
|
|
|
-
|
|
|
- case 3:
|
|
|
+ .filter(d -> d.getTag() == 1)
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+ } else if (t == 2) {//明星商家
|
|
|
+ collect.addAll(dtos.stream()
|
|
|
+ .filter(d -> d.getTag() == 2)
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+ } else if (t == 3) {//口碑联盟
|
|
|
//口碑联盟
|
|
|
collect.addAll(dtos.stream()
|
|
|
.filter(MerchantDTO::getBuyAlliance)
|
|
|
- .collect(Collectors.toList()));
|
|
|
- }
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
}
|
|
|
- return collect;
|
|
|
+ return new ArrayList<>(collect);
|
|
|
}
|
|
|
|
|
|
- public List<MerchantDTO> page(Double longitude, Double latitude, Integer sort, FilterDTO filterDto, Long userId) {
|
|
|
+ /*
|
|
|
+ 推荐商家
|
|
|
+ */
|
|
|
+ public List<MerchantDTO> recommended(Double longitude, Double latitude, Integer sort, FilterDTO filterDto, Long userId) {
|
|
|
List<MerchantDTO> dtoList;
|
|
|
dtoList = this.listSort(longitude, latitude, sort);
|
|
|
if (filterDto.getFilter() != null) {
|
|
|
@@ -464,7 +408,7 @@ public class MerchantSettingsService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<MerchantDTO> showAll(PageQuery pageQuery, Double longitude, Double latitude, Integer popularTag, Long userId) {
|
|
|
+ public List<MerchantDTO> showAll(PageQuery pageQuery, Double longitude, Double latitude, Long popularTag, Long userId) {
|
|
|
|
|
|
List<Merchant> merchantList = merchantRepo.findAll((root, criteriaQuery, criteriaBuilder) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
@@ -497,9 +441,188 @@ public class MerchantSettingsService {
|
|
|
//带距离 且按距离排好序
|
|
|
List<MerchantDTO> dtos = merchantService.withDistance(merchants, longitude, latitude, null);
|
|
|
if (popularTag != null) {
|
|
|
- return this.listFilter(dtos, popularTag, userId);
|
|
|
+ return this.listFilter(dtos, popularTag.toString(), userId);
|
|
|
}
|
|
|
return dtos;
|
|
|
}
|
|
|
|
|
|
+ //月更的东西
|
|
|
+ /*
|
|
|
+ 推广语
|
|
|
+ 优先级
|
|
|
+ 明星商家
|
|
|
+ */
|
|
|
+ public void monthUpdate() {
|
|
|
+ List<Merchant> merchants = merchantRepo.findAll();
|
|
|
+ merchants.forEach(a -> {
|
|
|
+ //明星商家
|
|
|
+ this.starMerchant(a);
|
|
|
+ //优先级
|
|
|
+ this.priority(a.getId(), 0);
|
|
|
+ });
|
|
|
+ List<Goods> goods = goodsRepo.findAll();
|
|
|
+ //优先级
|
|
|
+ goods.forEach(g -> this.priority(g.getId(), 1));
|
|
|
+ this.merPromo();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ 明星商家
|
|
|
+ */
|
|
|
+ public void starMerchant(Merchant merchant) {
|
|
|
+ LocalDate date = LocalDate.now().minusMonths(1);
|
|
|
+ LocalTime time = LocalTime.parse("00:00:00");
|
|
|
+ LocalDateTime dateTime = LocalDateTime.of(date, time);
|
|
|
+ //非新商家
|
|
|
+ boolean b = dateTime.isAfter(merchant.getEstablishTime());
|
|
|
+ if (b) {
|
|
|
+ if (merchant.getMonthSales() >= 10000 && merchant.getBadNum() > 0 && merchant.getGoodNum() > 3000) {
|
|
|
+ //明星商家
|
|
|
+ merchant.setTag(2);
|
|
|
+ } else {
|
|
|
+ //都不是
|
|
|
+ merchant.setTag(0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //新商家
|
|
|
+ merchant.setTag(1);
|
|
|
+ }
|
|
|
+ merchantRepo.save(merchant);
|
|
|
+ }
|
|
|
+
|
|
|
+ //商家推广语
|
|
|
+ //每月一更
|
|
|
+ public void merPromo() {
|
|
|
+ List<Category> byParent = categoryRepo.findAllByParent(1L);
|
|
|
+ byParent.forEach(this::accept);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void accept(Category c) {
|
|
|
+ List<MerchantDTO> list = categoryService.categoryMer(c.getId());
|
|
|
+ List<Merchant> merchants = new ArrayList<>();
|
|
|
+ list.sort((a, b) -> b.getMonthSales().compareTo(a.getMonthSales()));
|
|
|
+
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ Merchant merchant = merchantRepo.findById(list.get(i).getMid()).orElseThrow(new BusinessException("无商家"));
|
|
|
+ String name;
|
|
|
+ switch (i) {
|
|
|
+ case 0:
|
|
|
+ name = "商家月销售冠军";
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ name = "商家月销售亚军";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ name = "商家月销售季军";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ name = "商家月销售第四名";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ name = "商家月销售第五名";
|
|
|
+ }
|
|
|
+ merchant.setPromo(c.getName() + name);
|
|
|
+ merchants.add(merchant);
|
|
|
+ }
|
|
|
+ merchantRepo.saveAll(merchants);
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新商品/商户优先级,每月1日更新
|
|
|
+ public void priority(Long id, Integer type) {
|
|
|
+
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ //上个月日期
|
|
|
+ LocalDate lastMonth = now.minusMonths(1);
|
|
|
+
|
|
|
+ LocalDate day = now.minusDays(1);
|
|
|
+ //月销为0天数
|
|
|
+ int countZeroSales = 0;
|
|
|
+ //点赞数
|
|
|
+ Integer likes = 0;
|
|
|
+ //差评数
|
|
|
+ Integer badReview = 0;
|
|
|
+ //销量
|
|
|
+ Integer sales = 0;
|
|
|
+
|
|
|
+ while (day.isBefore(lastMonth)) {
|
|
|
+ Sales daySales;
|
|
|
+ if (type == 0) {
|
|
|
+ daySales = salesRepo.findByMerchantIdAndDay(id, day);
|
|
|
+ } else {
|
|
|
+ daySales = salesRepo.findByGoodsIdAndDay(id, day);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtil.isNull(daySales)) {
|
|
|
+ //月销为0天数
|
|
|
+ countZeroSales++;
|
|
|
+ } else {
|
|
|
+ likes += daySales.getDayLikes();
|
|
|
+ badReview += daySales.getDayBad();
|
|
|
+ sales += daySales.getDaySales();
|
|
|
+ }
|
|
|
+ day = now.minusDays(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean add = true;
|
|
|
+ boolean plus = false;
|
|
|
+
|
|
|
+ //上一月该商品新增点赞数-新增差评数*10>0
|
|
|
+ if (likes - badReview * 10 < 0) {
|
|
|
+ add = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer p;
|
|
|
+ Priority priority;
|
|
|
+
|
|
|
+ MerchantSettings settings = null;
|
|
|
+ Goods goods = null;
|
|
|
+ if (type == 0) {
|
|
|
+ settings = merchantSettingsRepo.findByMerchantId(id).orElseThrow(new BusinessException("无商户"));
|
|
|
+
|
|
|
+ p = settings.getPriority();
|
|
|
+ priority = priorityRepo.findByTypeAndLevel(0, p);
|
|
|
+ } else {
|
|
|
+ goods = goodsRepo.findById(id).orElseThrow(new BusinessException("无商品"));
|
|
|
+
|
|
|
+ p = goods.getPriority();
|
|
|
+ priority = priorityRepo.findByTypeAndLevel(1, p);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //新增点赞数 月销量
|
|
|
+ if (likes < priority.getLikes() || sales < priority.getMonthSales()) {
|
|
|
+ add = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (countZeroSales < priority.getZeroSalesDay()) {
|
|
|
+ plus = true;
|
|
|
+ } else if (likes - badReview * 3 < 0) {
|
|
|
+ plus = true;
|
|
|
+ } else if (sales < priority.getLessMonthSales()) {
|
|
|
+ plus = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (add) {
|
|
|
+ if (!p.equals(priorityRepo.findByTypeAndLevelMax(1))) {
|
|
|
+ if (type == 0) {
|
|
|
+ settings.setPriority(p + 1);
|
|
|
+ merchantSettingsRepo.save(settings);
|
|
|
+ } else {
|
|
|
+ goods.setPriority(p + 1);
|
|
|
+ goodsRepo.save(goods);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (plus) {
|
|
|
+ if (!p.equals(1)) {
|
|
|
+ if (type == 0) {
|
|
|
+ settings.setPriority(p - 1);
|
|
|
+ merchantSettingsRepo.save(settings);
|
|
|
+ } else {
|
|
|
+ goods.setPriority(p - 1);
|
|
|
+ goodsRepo.save(goods);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|