|
@@ -1,43 +1,20 @@
|
|
package com.chelvc.cloud.vehicle.server.service.impl;
|
|
package com.chelvc.cloud.vehicle.server.service.impl;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.time.LocalTime;
|
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.chelvc.cloud.uc.api.dto.UserDTO;
|
|
import com.chelvc.cloud.uc.api.dto.UserDTO;
|
|
import com.chelvc.cloud.uc.api.model.Scope;
|
|
import com.chelvc.cloud.uc.api.model.Scope;
|
|
-import com.chelvc.cloud.uc.api.service.EmployeeService;
|
|
|
|
import com.chelvc.cloud.uc.api.service.UserService;
|
|
import com.chelvc.cloud.uc.api.service.UserService;
|
|
import com.chelvc.cloud.vehicle.api.constant.MerchantStatus;
|
|
import com.chelvc.cloud.vehicle.api.constant.MerchantStatus;
|
|
-import com.chelvc.cloud.vehicle.api.dto.CategoryDTO;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.dto.GoodsDTO;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.dto.MerchantDTO;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.dto.MerchantDetailDTO;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.dto.MerchantRankCountDTO;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.dto.MerchantRankDTO;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.param.GoodsQueryParam;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.param.LocationQueryParam;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.param.MerchantModifyParam;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.param.MerchantPagingParam;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.param.MerchantQueryParam;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.param.MerchantRankParam;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.param.OmsCartItemPagingParam;
|
|
|
|
-import com.chelvc.cloud.vehicle.api.param.ReportModifyParam;
|
|
|
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.*;
|
|
|
|
+import com.chelvc.cloud.vehicle.api.param.*;
|
|
import com.chelvc.cloud.vehicle.api.util.DateTimeUtils;
|
|
import com.chelvc.cloud.vehicle.api.util.DateTimeUtils;
|
|
import com.chelvc.cloud.vehicle.server.copier.MerchantCopier;
|
|
import com.chelvc.cloud.vehicle.server.copier.MerchantCopier;
|
|
import com.chelvc.cloud.vehicle.server.dao.MerchantMapper;
|
|
import com.chelvc.cloud.vehicle.server.dao.MerchantMapper;
|
|
import com.chelvc.cloud.vehicle.server.dao.RegionMapper;
|
|
import com.chelvc.cloud.vehicle.server.dao.RegionMapper;
|
|
-import com.chelvc.cloud.vehicle.server.entity.Goods;
|
|
|
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.Category;
|
|
import com.chelvc.cloud.vehicle.server.entity.Merchant;
|
|
import com.chelvc.cloud.vehicle.server.entity.Merchant;
|
|
import com.chelvc.cloud.vehicle.server.entity.Region;
|
|
import com.chelvc.cloud.vehicle.server.entity.Region;
|
|
import com.chelvc.cloud.vehicle.server.service.CategoryService;
|
|
import com.chelvc.cloud.vehicle.server.service.CategoryService;
|
|
@@ -58,7 +35,13 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.time.LocalTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 商家业务操作实现
|
|
* 商家业务操作实现
|
|
@@ -167,6 +150,23 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|
merchant.setSale(0);
|
|
merchant.setSale(0);
|
|
merchant.setStatus(MerchantStatus.ONLINE);
|
|
merchant.setStatus(MerchantStatus.ONLINE);
|
|
this.save(merchant);
|
|
this.save(merchant);
|
|
|
|
+ List<Long> business = param.getAncillaryBusiness();
|
|
|
|
+ if (StringUtils.notEmpty(param.getMainBusiness())){
|
|
|
|
+ business.add(param.getMainBusiness());
|
|
|
|
+ }
|
|
|
|
+// this.categoryService.removeByIds(business);
|
|
|
|
+ List<Category> categories = this.categoryService.getCategories(business);
|
|
|
|
+ if (!CollectionUtils.isEmpty(categories)){
|
|
|
|
+ categories.forEach(item ->{
|
|
|
|
+ item.setSourceId(item.getId());
|
|
|
|
+ item.setId(null);
|
|
|
|
+ item.setMerchantId(merchant.getId());
|
|
|
|
+ item.setType("1");
|
|
|
|
+ item.setParentId(0L);
|
|
|
|
+ this.categoryService.save(item);
|
|
|
|
+ });
|
|
|
|
+ // this.categoryService.saveBatchCategories(categories);
|
|
|
|
+ }
|
|
return merchant.getId();
|
|
return merchant.getId();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -175,6 +175,25 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|
Merchant merchant = AssertUtils.available(this.getById(id), "商家不存在");
|
|
Merchant merchant = AssertUtils.available(this.getById(id), "商家不存在");
|
|
MerchantCopier.INSTANCE.copying(param, merchant);
|
|
MerchantCopier.INSTANCE.copying(param, merchant);
|
|
this.updateById(merchant);
|
|
this.updateById(merchant);
|
|
|
|
+ List<Long> business = param.getAncillaryBusiness();
|
|
|
|
+ if (StringUtils.notEmpty(param.getMainBusiness())){
|
|
|
|
+ business.add(param.getMainBusiness());
|
|
|
|
+ }
|
|
|
|
+// this.categoryService.removeByIds(business);
|
|
|
|
+ this.categoryService.deleteByMerchantId(merchant.getId());
|
|
|
|
+ List<Category> categories = this.categoryService.getCategories(business);
|
|
|
|
+ if (!CollectionUtils.isEmpty(categories)){
|
|
|
|
+ categories.forEach(item ->{
|
|
|
|
+ item.setSourceId(item.getId());
|
|
|
|
+ item.setId(null);
|
|
|
|
+ item.setMerchantId(merchant.getId());
|
|
|
|
+ item.setType("1");
|
|
|
|
+ item.setParentId(0L);
|
|
|
|
+// this.categoryService.save(item);
|
|
|
|
+ });
|
|
|
|
+ this.categoryService.saveBatchCategories(categories);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -244,6 +263,7 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|
public List<MerchantRankDTO> listRankMerchants(MerchantRankParam param, Long userId) {
|
|
public List<MerchantRankDTO> listRankMerchants(MerchantRankParam param, Long userId) {
|
|
List<MerchantRankDTO> result = new ArrayList<>();
|
|
List<MerchantRankDTO> result = new ArrayList<>();
|
|
Integer regionId = param.getRegionId();
|
|
Integer regionId = param.getRegionId();
|
|
|
|
+ Long categoryId = param.getCategoryId();
|
|
Double longitude = (double) 0;
|
|
Double longitude = (double) 0;
|
|
Double latitude = (double) 0;
|
|
Double latitude = (double) 0;
|
|
if (regionId == null) {
|
|
if (regionId == null) {
|
|
@@ -263,21 +283,46 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|
if (region == null) {
|
|
if (region == null) {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
- result = baseMapper.listRankMerchants(DateTimeUtils.getMonthStartLocalTime(), regionId, longitude, latitude,
|
|
|
|
|
|
+ result = baseMapper.listRankMerchants(DateTimeUtils.getMonthStartLocalTime(), categoryId, regionId, longitude, latitude,
|
|
region.getLevel());
|
|
region.getLevel());
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<MerchantRankCountDTO> rankMerchants(Integer regionId, Integer limit, Integer level) {
|
|
|
|
|
|
+ public List<MerchantRankDTO> listRankMerchants(MerchantRankParam param) {
|
|
|
|
+ List<MerchantRankDTO> result = new ArrayList<>();
|
|
|
|
+ Integer regionId = param.getRegionId();
|
|
|
|
+ Long categoryId = param.getCategoryId();
|
|
|
|
+ Double longitude = (double) 0;
|
|
|
|
+ Double latitude = (double) 0;
|
|
|
|
+ if (regionId == null) {
|
|
|
|
+ Address address = locationHandler.ip2address(SessionContextHolder.getHost());
|
|
|
|
+ if (address == null) {
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ regionId = address.getDistrict().getId();
|
|
|
|
+ longitude = address.getLongitude();
|
|
|
|
+ latitude = address.getLatitude();
|
|
|
|
+ }
|
|
|
|
+ Region region = regionMapper.selectById(regionId);
|
|
|
|
+ if (region == null) {
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ result = baseMapper.listRankMerchants(DateTimeUtils.getMonthStartLocalTime(), categoryId, regionId, longitude, latitude,
|
|
|
|
+ region.getLevel());
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<MerchantRankCountDTO> rankMerchants(Integer regionId, Integer limit, Integer level, Long categoryId) {
|
|
return baseMapper.rankMerchants(DateTimeUtils.getLastMonthStartLocalTime(),
|
|
return baseMapper.rankMerchants(DateTimeUtils.getLastMonthStartLocalTime(),
|
|
- DateTimeUtils.getLastMonthEndLocalTime(), regionId, limit, level);
|
|
|
|
|
|
+ DateTimeUtils.getLastMonthEndLocalTime(), regionId, limit, level, categoryId);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public BigDecimal queryTotalCommissionAmountByLastMonth(Integer regionId, Integer level) {
|
|
|
|
|
|
+ public BigDecimal queryTotalCommissionAmountByLastMonth(Integer regionId, Integer level, Long categoryId) {
|
|
return baseMapper.queryTotalCommissionAmountByLastMonth(DateTimeUtils.getLastMonthStartLocalTime(),
|
|
return baseMapper.queryTotalCommissionAmountByLastMonth(DateTimeUtils.getLastMonthStartLocalTime(),
|
|
- DateTimeUtils.getLastMonthEndLocalTime(), regionId, level);
|
|
|
|
|
|
+ DateTimeUtils.getLastMonthEndLocalTime(), regionId, level, categoryId);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -355,6 +400,14 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|
return MerchantCopier.INSTANCE.copying(merchants);
|
|
return MerchantCopier.INSTANCE.copying(merchants);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<MerchantDTO> getMerchantByIds(List<Long> ids) {
|
|
|
|
+ List<MerchantDTO> list = new ArrayList<>();
|
|
|
|
+ for(Long id : ids){
|
|
|
|
+ list.add(getMerchantById(id));
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -407,4 +460,11 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void merchantAudit(Long id, MerchantStatus status){
|
|
|
|
+ Merchant merchant = AssertUtils.available(this.getById(id), "商家不存在");
|
|
|
|
+ merchant.setStatus(status);
|
|
|
|
+ this.updateById(merchant);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|