From 7e7fea4ae189d840e00870bd978524b68c5f82e1 Mon Sep 17 00:00:00 2001 From: XinYi Song <2037158277@qq.com> Date: Fri, 17 Dec 2021 10:36:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=B8=82=E7=BA=A7?= =?UTF-8?q?=E6=88=96=E5=8C=BA=E5=8E=BF=E7=BA=A7=E6=9F=A5=E7=9C=8B=E5=85=A5?= =?UTF-8?q?=E9=A9=BB=E5=95=86=E5=AE=B6=E7=9A=84=E4=BF=A1=E6=81=AF=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MerchantSettlementController.java | 13 +++++++ src/main/java/com/xkrs/dao/BusinessDao.java | 3 +- .../service/MerchantSettlementService.java | 9 +++++ .../impl/MerchantSettlementServiceImpl.java | 21 +++++++++++ src/main/java/com/xkrs/utils/Query.java | 36 ++++++++++++++++++- 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/xkrs/controller/MerchantSettlementController.java b/src/main/java/com/xkrs/controller/MerchantSettlementController.java index 83555b4..fa0f2e4 100644 --- a/src/main/java/com/xkrs/controller/MerchantSettlementController.java +++ b/src/main/java/com/xkrs/controller/MerchantSettlementController.java @@ -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); + } } diff --git a/src/main/java/com/xkrs/dao/BusinessDao.java b/src/main/java/com/xkrs/dao/BusinessDao.java index 4bde171..a795c16 100644 --- a/src/main/java/com/xkrs/dao/BusinessDao.java +++ b/src/main/java/com/xkrs/dao/BusinessDao.java @@ -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 { +public interface BusinessDao extends JpaRepository, JpaSpecificationExecutor { /** * 根据商家名称查询商家信息 diff --git a/src/main/java/com/xkrs/service/MerchantSettlementService.java b/src/main/java/com/xkrs/service/MerchantSettlementService.java index 1cc0589..ec6d178 100644 --- a/src/main/java/com/xkrs/service/MerchantSettlementService.java +++ b/src/main/java/com/xkrs/service/MerchantSettlementService.java @@ -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); } diff --git a/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java b/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java index d6d4adb..6171e24 100644 --- a/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java @@ -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 businessEntities = query.selectAllBusiness(businessCity, businessCountry, businessName); + if(businessEntities == null || businessEntities.size() == 0){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有任何商家的信息!",locale); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,businessEntities,locale); + } } diff --git a/src/main/java/com/xkrs/utils/Query.java b/src/main/java/com/xkrs/utils/Query.java index 297e48a..eab58f8 100644 --- a/src/main/java/com/xkrs/utils/Query.java +++ b/src/main/java/com/xkrs/utils/Query.java @@ -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 selectAllBusiness(String businessCity, String businessCountry, String businessName) { + Specification specification = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List 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); + } + } \ No newline at end of file