|
@@ -67,7 +67,7 @@ import java.util.stream.Collectors;
|
|
|
public class BusinessServiceImpl implements IBusinessService {
|
|
public class BusinessServiceImpl implements IBusinessService {
|
|
|
|
|
|
|
|
private final BusinessMapper baseMapper;
|
|
private final BusinessMapper baseMapper;
|
|
|
- private final ISysDeptService sysDeptService;
|
|
|
|
|
|
|
+ private final ISysDeptService sysDeptService;
|
|
|
private final IProductInnerApi iProductInnerApi;
|
|
private final IProductInnerApi iProductInnerApi;
|
|
|
private final IUserShoppingCartApi iUserShoppingCartApi;
|
|
private final IUserShoppingCartApi iUserShoppingCartApi;
|
|
|
private final IBusinessVerifierService businessVerifierService;
|
|
private final IBusinessVerifierService businessVerifierService;
|
|
@@ -88,8 +88,7 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
@Override
|
|
@Override
|
|
|
public TableDataInfo<BusinessVo> queryPageList(BusinessBo bo, PageQuery pageQuery) {
|
|
public TableDataInfo<BusinessVo> queryPageList(BusinessBo bo, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<Business> lqw = buildQueryWrapper(bo);
|
|
LambdaQueryWrapper<Business> lqw = buildQueryWrapper(bo);
|
|
|
- if(StringUtils.isBlank(pageQuery.getOrderByColumn()))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
|
|
lqw.orderByDesc(Business::getOrderIndex);
|
|
lqw.orderByDesc(Business::getOrderIndex);
|
|
|
lqw.orderByDesc(Business::getCreateTime);
|
|
lqw.orderByDesc(Business::getCreateTime);
|
|
|
}
|
|
}
|
|
@@ -110,20 +109,19 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
// 执行查询并获取商家列表
|
|
// 执行查询并获取商家列表
|
|
|
List<BusinessVo> businessVos = baseMapper.selectVoList(lqw);
|
|
List<BusinessVo> businessVos = baseMapper.selectVoList(lqw);
|
|
|
// 如果用户位置信息存在,则计算并设置商家与用户之间的距离
|
|
// 如果用户位置信息存在,则计算并设置商家与用户之间的距离
|
|
|
- if(ObjectUtil.isNotNull(bo.getUserLatitude()) && ObjectUtil.isNotNull(bo.getUserLongitude()))
|
|
|
|
|
- {
|
|
|
|
|
- businessVos.forEach(e->{
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotNull(bo.getUserLatitude()) && ObjectUtil.isNotNull(bo.getUserLongitude())) {
|
|
|
|
|
+ businessVos.forEach(e -> {
|
|
|
e.setDistance(MapTools.calculate(bo.getUserLongitude(), bo.getUserLatitude(), e.getLongitude(), e.getLatitude()));
|
|
e.setDistance(MapTools.calculate(bo.getUserLongitude(), bo.getUserLatitude(), e.getLongitude(), e.getLatitude()));
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 如果指定了距离范围,则过滤掉超出范围的商家
|
|
// 如果指定了距离范围,则过滤掉超出范围的商家
|
|
|
- if(ObjectUtil.isNotNull(bo.getRangeDistance()))
|
|
|
|
|
- {
|
|
|
|
|
- businessVos = businessVos.stream().filter(e->{ return e.getDistance()<= 1000D * bo.getRangeDistance();}).collect(Collectors.toList());
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotNull(bo.getRangeDistance())) {
|
|
|
|
|
+ businessVos = businessVos.stream().filter(e -> {
|
|
|
|
|
+ return e.getDistance() <= 1000D * bo.getRangeDistance();
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(ObjectUtil.isNotNull(bo.getNearMe()) && bo.getNearMe())
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotNull(bo.getNearMe()) && bo.getNearMe()) {
|
|
|
// 根据距离对商家列表进行排序
|
|
// 根据距离对商家列表进行排序
|
|
|
businessVos = businessVos.stream().sorted(Comparator.comparing(BusinessVo::getDistance)).collect(Collectors.toList());
|
|
businessVos = businessVos.stream().sorted(Comparator.comparing(BusinessVo::getDistance)).collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
@@ -147,7 +145,7 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<BusinessCountByAreaCodeVo> countOfAreaCodeBy(String parentCode) {
|
|
public List<BusinessCountByAreaCodeVo> countOfAreaCodeBy(String parentCode) {
|
|
|
- return this.baseMapper.countOfAreaCodeBy( parentCode);
|
|
|
|
|
|
|
+ return this.baseMapper.countOfAreaCodeBy(parentCode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private LambdaQueryWrapper<Business> buildQueryWrapper(BusinessBo bo) {
|
|
private LambdaQueryWrapper<Business> buildQueryWrapper(BusinessBo bo) {
|
|
@@ -196,7 +194,7 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
* @return 商家
|
|
* @return 商家
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public BusinessVo queryById(Long businessId){
|
|
|
|
|
|
|
+ public BusinessVo queryById(Long businessId) {
|
|
|
return baseMapper.selectVoById(businessId);
|
|
return baseMapper.selectVoById(businessId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -207,9 +205,9 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
* @return 商家
|
|
* @return 商家
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public Business loadById(Long businessId, Boolean tw){
|
|
|
|
|
|
|
+ public Business loadById(Long businessId, Boolean tw) {
|
|
|
Business info = this.baseMapper.selectById(businessId);
|
|
Business info = this.baseMapper.selectById(businessId);
|
|
|
- if(ObjectUtil.isEmpty(info) && tw){
|
|
|
|
|
|
|
+ if (ObjectUtil.isEmpty(info) && tw) {
|
|
|
throw new ServiceException(BusinessExceptionEnum.BUSINESS_IS_NOT_EXISTS);
|
|
throw new ServiceException(BusinessExceptionEnum.BUSINESS_IS_NOT_EXISTS);
|
|
|
}
|
|
}
|
|
|
return info;
|
|
return info;
|
|
@@ -310,20 +308,14 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
String oldName = business.getBusinessName();
|
|
String oldName = business.getBusinessName();
|
|
|
Long relationUserId = business.getRelationUserId();
|
|
Long relationUserId = business.getRelationUserId();
|
|
|
SysDept sysDept = null;
|
|
SysDept sysDept = null;
|
|
|
- if(ObjectUtil.isNull(business.getDeptId()))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (ObjectUtil.isNull(business.getDeptId())) {
|
|
|
sysDept = insertDept(bo);
|
|
sysDept = insertDept(bo);
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else {
|
|
|
sysDept = sysDeptService.selectDeptById(business.getDeptId());
|
|
sysDept = sysDeptService.selectDeptById(business.getDeptId());
|
|
|
- if(ObjectUtil.isNull(sysDept))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (ObjectUtil.isNull(sysDept)) {
|
|
|
|
|
|
|
|
sysDept = insertDept(bo);
|
|
sysDept = insertDept(bo);
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else {
|
|
|
updateDept(bo, sysDept);
|
|
updateDept(bo, sysDept);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -365,14 +357,13 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
*
|
|
*
|
|
|
* @param bo 实体类数据
|
|
* @param bo 实体类数据
|
|
|
*/
|
|
*/
|
|
|
- private void validEntityBeforeSave(BusinessBo bo){
|
|
|
|
|
|
|
+ private void validEntityBeforeSave(BusinessBo bo) {
|
|
|
if (bo == null) {
|
|
if (bo == null) {
|
|
|
throw new ServiceException(ExceptionEnum.BO_IS_NULL);
|
|
throw new ServiceException(ExceptionEnum.BO_IS_NULL);
|
|
|
}
|
|
}
|
|
|
boolean exists = this.baseMapper.exists(new LambdaQueryWrapper<Business>().eq(Business::getBusinessName, bo.getBusinessName())
|
|
boolean exists = this.baseMapper.exists(new LambdaQueryWrapper<Business>().eq(Business::getBusinessName, bo.getBusinessName())
|
|
|
.ne(ObjectUtil.isNotNull(bo.getBusinessId()), Business::getBusinessId, bo.getBusinessId()));
|
|
.ne(ObjectUtil.isNotNull(bo.getBusinessId()), Business::getBusinessId, bo.getBusinessId()));
|
|
|
- if(exists)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (exists) {
|
|
|
throw new ServiceException(BusinessExceptionEnum.BUSINESS_NAME_EXISTS);
|
|
throw new ServiceException(BusinessExceptionEnum.BUSINESS_NAME_EXISTS);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -385,7 +376,7 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
|
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
}
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
@@ -394,7 +385,7 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean deleteWithValidById(Long businessId, Boolean isValid) {
|
|
public Boolean deleteWithValidById(Long businessId, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
|
|
|
|
+ if (isValid) {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
loadById(businessId, true);
|
|
loadById(businessId, true);
|
|
@@ -410,6 +401,7 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 首页头部统计
|
|
* 首页头部统计
|
|
|
|
|
+ *
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
@@ -487,32 +479,29 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
public Long sumPromotionBusinessNum(Long agentId) {
|
|
public Long sumPromotionBusinessNum(Long agentId) {
|
|
|
return baseMapper.selectCount(new LambdaQueryWrapper<Business>().eq(Business::getAgentId, agentId));
|
|
return baseMapper.selectCount(new LambdaQueryWrapper<Business>().eq(Business::getAgentId, agentId));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 改变商家余额
|
|
* 改变商家余额
|
|
|
|
|
+ *
|
|
|
* @param build
|
|
* @param build
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public void changeBalance(BusinessBalanceRecordBo build) {
|
|
public void changeBalance(BusinessBalanceRecordBo build) {
|
|
|
Business business = loadById(build.getBusinessId(), false);
|
|
Business business = loadById(build.getBusinessId(), false);
|
|
|
- if(ObjectUtil.isNull( business))
|
|
|
|
|
- {
|
|
|
|
|
- return ;
|
|
|
|
|
|
|
+ if (ObjectUtil.isNull(business)) {
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
BigDecimal balance = business.getBalance();
|
|
BigDecimal balance = business.getBalance();
|
|
|
- if(BusinessBillType.IN.equals(build.getBillType()))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (BusinessBillType.IN.equals(build.getBillType())) {
|
|
|
business.setBalance(balance.add(build.getEntryValue()));
|
|
business.setBalance(balance.add(build.getEntryValue()));
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- if(!business.balanceEnough(build.getEntryValue()))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (!business.balanceEnough(build.getEntryValue())) {
|
|
|
throw new ServiceException(BusinessExceptionEnum.BUSINESS_BALANCE_NOT_ENOUGH);
|
|
throw new ServiceException(BusinessExceptionEnum.BUSINESS_BALANCE_NOT_ENOUGH);
|
|
|
}
|
|
}
|
|
|
business.setBalance(balance.subtract(build.getEntryValue()));
|
|
business.setBalance(balance.subtract(build.getEntryValue()));
|
|
|
}
|
|
}
|
|
|
this.baseMapper.updateById(business);
|
|
this.baseMapper.updateById(business);
|
|
|
- build.setEntryBeforeBalance( balance);
|
|
|
|
|
|
|
+ build.setEntryBeforeBalance(balance);
|
|
|
build.setEntryAfterBalance(business.getBalance());
|
|
build.setEntryAfterBalance(business.getBalance());
|
|
|
iBusinessBalanceRecordService.insertByBo(build);
|
|
iBusinessBalanceRecordService.insertByBo(build);
|
|
|
}
|
|
}
|