添加了市级或区县级查看入驻商家的信息功能模块

This commit is contained in:
XinYi Song 2021-12-17 10:36:57 +08:00
parent 794b90fb49
commit 7e7fea4ae1
5 changed files with 80 additions and 2 deletions

View File

@ -104,4 +104,17 @@ public class MerchantSettlementController {
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
return merchantSettlementService.findBusinessById(sysUserEntity.getId());
}
/**
* 市级或区县级查看入驻商家的信息
* @param map
* @return
*/
@PostMapping("/selectAllBusiness")
public String selectAllBusiness(@RequestBody Map map){
String businessCity = (String) map.get("businessCity");
String businessCountry = (String) map.get("businessCountry");
String businessName = (String) map.get("businessName");
return merchantSettlementService.selectAllBusiness(businessCity,businessCountry,businessName);
}
}

View File

@ -2,6 +2,7 @@ package com.xkrs.dao;
import com.xkrs.model.entity.BusinessEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
@ -9,7 +10,7 @@ import java.util.List;
* @Author: XinYi Song
* @Date: 2021/12/14 9:37
*/
public interface BusinessDao extends JpaRepository<BusinessEntity,Long> {
public interface BusinessDao extends JpaRepository<BusinessEntity,Long>, JpaSpecificationExecutor<BusinessEntity> {
/**
* 根据商家名称查询商家信息

View File

@ -47,4 +47,13 @@ public interface MerchantSettlementService {
* @return
*/
String findBusinessById(Integer businessId);
/**
* 市区查询商家的信息
* @param businessCity
* @param businessCountry
* @param businessName
* @return
*/
String selectAllBusiness(String businessCity, String businessCountry, String businessName);
}

View File

@ -10,6 +10,7 @@ import com.xkrs.model.qo.BusinessQo;
import com.xkrs.service.MerchantSettlementService;
import com.xkrs.utils.DateTimeUtil;
import com.xkrs.utils.PhotoUtil;
import com.xkrs.utils.Query;
import com.xkrs.utils.VerifyBankCardUtil;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
@ -38,6 +39,9 @@ public class MerchantSettlementServiceImpl implements MerchantSettlementService
@Resource
private BankCardDao bankCardDao;
@Resource
private Query query;
/**
* 商家入驻
* @param businessQo
@ -128,4 +132,21 @@ public class MerchantSettlementServiceImpl implements MerchantSettlementService
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,byBusinessId,locale);
}
/**
* 市区查询商家的信息
* @param businessCity
* @param businessCountry
* @param businessName
* @return
*/
@Override
public String selectAllBusiness(String businessCity, String businessCountry, String businessName) {
Locale locale = LocaleContextHolder.getLocale();
List<BusinessEntity> businessEntities = query.selectAllBusiness(businessCity, businessCountry, businessName);
if(businessEntities == null || businessEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有任何商家的信息!",locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,businessEntities,locale);
}
}

View File

@ -1,6 +1,8 @@
package com.xkrs.utils;
import com.xkrs.dao.BusinessDao;
import com.xkrs.dao.ProductDao;
import com.xkrs.model.entity.BusinessEntity;
import com.xkrs.model.entity.ProductEntity;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
@ -24,9 +26,12 @@ public class Query {
@Resource
private ProductDao productDao;
@Resource
private BusinessDao businessDao;
/**
* 查看要审核的商品信息
* @param businessId
* @param
* @param productCounty
* @param reviewType
* @return
@ -83,5 +88,34 @@ public class Query {
return productDao.findAll(specification);
}
/**
* 各市区县代理商查看商家入驻信息
* @param businessCity
* @param businessCountry
* @param businessName
* @return
*/
public List<BusinessEntity> selectAllBusiness(String businessCity, String businessCountry, String businessName) {
Specification<BusinessEntity> specification = new Specification<BusinessEntity>() {
@Override
public Predicate toPredicate(Root<BusinessEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> list = new ArrayList<>();
if(businessCity != null && !"".equals(businessCity)){
list.add(criteriaBuilder.equal(root.get("businessCity").as(Integer.class), businessCity));
}
if(businessCountry != null && !"".equals(businessCountry)){
list.add(criteriaBuilder.equal(root.get("businessCountry").as(String.class), businessCountry));
}
if(businessName != null && !"".equals(businessName)){
list.add(criteriaBuilder.equal(root.get("businessName").as(String.class), businessName));
}
list.add(criteriaBuilder.equal(root.get("businessType").as(String.class), "1"));
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}
};
return businessDao.findAll(specification);
}
}