'修复地区查询无数据问题'

dev-discount
199901012 4 years ago
parent d555c2ec3b
commit 8d22528028
  1. 6
      hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java
  2. 6
      hai-cweb/src/main/java/com/cweb/controller/HighMerchantStoreController.java
  3. 2
      hai-service/src/main/java/com/hai/service/CommonService.java
  4. 14
      hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java

@ -77,9 +77,9 @@ public class HighCouponController {
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
SecRegion region = commonService.getRegionsById(Long.parseLong(regionId));
if (region != null && region.getParentId() != null) {
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getParentId().toString());
SecRegion region = commonService.getParentByRegion(Long.parseLong(regionId));
if (region != null) {
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString());
if (bsCompany != null) {
Map<String, Object> map = new HashMap<>();
map.put("companyId", bsCompany.getId());

@ -137,9 +137,9 @@ public class HighMerchantStoreController {
@ApiOperation(value = "查询商户列表")
public ResponseData getMerchantList(@RequestParam(name = "regionId", required = true) String regionId) {
try {
SecRegion region = commonService.getRegionsById(Long.parseLong(regionId));
if (region != null && region.getParentId() != null) {
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getParentId().toString());
SecRegion region = commonService.getParentByRegion(Long.parseLong(regionId));
if (region != null) {
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString());
Map<String, Object> map = new HashMap<>();
map.put("companyId", bsCompany.getId());
map.put("status", 1);

@ -161,5 +161,5 @@ public interface CommonService {
*/
List<SecRegion> findByName(String name);
SecRegion getParentByRegion(Long regionId);
}

@ -391,4 +391,18 @@ public class CommonServiceImpl implements CommonService {
example.createCriteria().andStatusEqualTo(1).andRegionNameEqualTo(name);
return regionMapper.selectByExample(example);
}
@Override
public SecRegion getParentByRegion(Long regionId) {
SecRegion secRegion = getRegionsById(regionId);
if (secRegion != null && secRegion.getParentId() != null) {
while (true) {
secRegion = getRegionsById(secRegion.getParentId());
if (secRegion.getParentId() == null) {
return secRegion;
}
}
}
return secRegion;
}
}

Loading…
Cancel
Save