Commit e057689a by 陶光胜

Merge branch 'developer' into 'master'

Developer

See merge request !18
parents ce4fdfd3 c3faae68
......@@ -45,6 +45,17 @@ public interface StoreApiService {
* @throws
*/
ServiceResponse<Integer> saveStoreForPosMember(Integer enterpriseId, String storeCode, String storeName, Integer regionId, String cardNO);
/**
* @Title: countByOverflowStatus
* @Description:
* @author zhiwj
* @param enterpriseId
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>
* @throws
*/
ServiceResponse<Integer> countByOverflowStatus(Integer enterpriseId);
/**
* @Title: listStore
* @Description: 分页门店列表 查es
......
......@@ -14,6 +14,9 @@ import com.gic.store.entity.TabProvince;
import com.gic.store.service.ProvincesApiService;
import com.gic.store.service.ProvincesService;
import com.gic.store.service.StoreService;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -21,6 +24,7 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
......@@ -31,30 +35,55 @@ import java.util.stream.Collectors;
@Service("provincesApiService")
public class ProvincesApiServiceImpl implements ProvincesApiService {
private static final Logger log = LogManager.getLogger(ProvincesApiServiceImpl.class);
private LoadingCache<String, List<ProvinceDTO>> provinceCache = null;
private LoadingCache<String, List<CityDTO>> cityCache = null;
private LoadingCache<String, List<CountyDTO>> countyCache = null;
private static final int EXPIRE_SECONDS = 7;
@Autowired
private ProvincesService provincesService;
@Autowired
private StoreService storeService;
@PostConstruct
public void init(){
provinceCache = CacheBuilder.newBuilder().maximumSize(10).expireAfterAccess(EXPIRE_SECONDS, TimeUnit.DAYS)
.build(new CacheLoader<String, List<ProvinceDTO>>() {
@Override
public List<ProvinceDTO> load(String key) {
return EntityUtil.changeEntityListByJSON(ProvinceDTO.class, provincesService.selectAllProvince());
}
});
cityCache = CacheBuilder.newBuilder().maximumSize(10).expireAfterAccess(EXPIRE_SECONDS, TimeUnit.DAYS)
.build(new CacheLoader<String, List<CityDTO>>() {
@Override
public List<CityDTO> load(String key) {
return EntityUtil.changeEntityListByJSON(CityDTO.class, provincesService.selectAllCity());
}
});
countyCache = CacheBuilder.newBuilder().maximumSize(10).expireAfterAccess(EXPIRE_SECONDS, TimeUnit.DAYS)
.build(new CacheLoader<String, List<CountyDTO>>() {
@Override
public List<CountyDTO> load(String key) {
return EntityUtil.changeEntityListByJSON(CountyDTO.class, provincesService.selectAllCounty());
}
});
}
@Override
public ServiceResponse<List<ProvinceDTO>> selectAllProvince() {
String key = "enterprise:province";
List<ProvinceDTO> list = (List<ProvinceDTO>)RedisUtil.getCache(key);
if(CollectionUtils.isEmpty(list)){
list = EntityUtil.changeEntityListByJSON(ProvinceDTO.class, this.provincesService.selectAllProvince());
RedisUtil.setCache(key, list, 6*30l, TimeUnit.DAYS);
}
List<ProvinceDTO> list = provinceCache.getUnchecked(key);
return ServiceResponse.success(list);
}
@Override
public ServiceResponse<List<CityDTO>> selectAllCity() {
String key = "enterprise:city";
List<CityDTO> list = (List<CityDTO>)RedisUtil.getCache(key);
if(CollectionUtils.isEmpty(list)){
list = EntityUtil.changeEntityListByJSON(CityDTO.class, this.provincesService.selectAllCity());
RedisUtil.setCache(key, list, 6*30l, TimeUnit.DAYS);
}
List<CityDTO> list = cityCache.getUnchecked(key);
log.info("allcity:{}", list.size());
return ServiceResponse.success(list);
}
......@@ -95,11 +124,7 @@ public class ProvincesApiServiceImpl implements ProvincesApiService {
@Override
public ServiceResponse<List<CountyDTO>> selectAllCounty() {
String key = "enterprise:county";
List<CountyDTO> list = (List<CountyDTO>)RedisUtil.getCache(key);
if(CollectionUtils.isEmpty(list)){
list = EntityUtil.changeEntityListByJSON(CountyDTO.class, this.provincesService.selectAllCounty());
RedisUtil.setCache(key, list, 6*30l, TimeUnit.DAYS);
}
List<CountyDTO> list = countyCache.getUnchecked(key);
return ServiceResponse.success(list);
}
......
......@@ -284,6 +284,12 @@ public class StoreApiServiceImpl implements StoreApiService {
return EnterpriseServiceResponse.failure(ErrorCode.UNKNOWN_ERROR.getCode(), "商户没有门店license");
}
@Override
public ServiceResponse<Integer> countByOverflowStatus(Integer enterpriseId) {
this.storeService.countByOverflowStatus(enterpriseId, 0);
return EnterpriseServiceResponse.success(this.storeService.countByOverflowStatus(enterpriseId, 0));
}
/**
* 修改日志
*/
......@@ -1056,6 +1062,9 @@ public class StoreApiServiceImpl implements StoreApiService {
ServiceResponse<StoreDTO> result = getStoreByStoreCode(enterpriseId, regionId, storeCode);
if (result.isSuccess()) {
StoreDTO storeDTO = result.getResult();
if (storeDTO == null) {
return ServiceResponse.success();
}
List<TabStoreBusinessTime> list = storeBusinessTimeService.listBusinessTime(storeDTO.getStoreInfoId());
List<StoreBusinessTimeDTO> businessTimeDTOList = EntityUtil.changeEntityListByOrika(StoreBusinessTimeDTO.class, list);
storeDTO.setBusinessTimeList(businessTimeDTOList);
......
......@@ -2,6 +2,7 @@ package com.gic.store.service.outer.impl;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.response.EnterpriseServiceResponse;
import com.gic.store.constant.StoreESFieldsEnum;
......@@ -9,7 +10,9 @@ import com.gic.store.dto.StoreBrandDTO;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.StoreSearchDTO;
import com.gic.store.dto.StoreWidgetDTO;
import com.gic.store.entity.TabStoreBrand;
import com.gic.store.service.StoreApiService;
import com.gic.store.service.StoreBrandService;
import com.gic.store.service.StoreWidgetApiService;
import com.gic.store.service.StoreWidgetService;
import org.apache.commons.collections.CollectionUtils;
......@@ -26,6 +29,8 @@ public class StoreWidgetApiServiceImpl implements StoreWidgetApiService {
private StoreWidgetService storeWidgetService;
@Autowired
private StoreApiService storeApiService;
@Autowired
private StoreBrandService storeBrandService;
@Override
public ServiceResponse<Integer> saveStoreWidget(StoreWidgetDTO storeWidgetDTO) {
......@@ -167,13 +172,16 @@ public class StoreWidgetApiServiceImpl implements StoreWidgetApiService {
return EnterpriseServiceResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
List<StoreDTO> list = serviceResponse.getResult().getResult();
List<Integer> brandIdList = new ArrayList<>();
List<StoreBrandDTO> brandList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(list)) {
for (StoreDTO storeDTO : list) {
if (CollectionUtils.isNotEmpty(storeDTO.getBrandList())) {
brandList.addAll(storeDTO.getBrandList());
if (CollectionUtils.isNotEmpty(storeDTO.getStoreBrandIdList())) {
brandIdList.addAll(storeDTO.getStoreBrandIdList());
}
}
List<TabStoreBrand> tabStoreBrands = storeBrandService.listStoreBrandByIds(brandIdList);
brandList = EntityUtil.changeEntityListByJSON(StoreBrandDTO.class, tabStoreBrands);
}
return EnterpriseServiceResponse.success(brandList);
}
......
......@@ -173,7 +173,7 @@ public class StoreController extends DownloadUtils {
String key = StoreRedisKeyUtils.getStoreListSourceKey(enterpriseId, userId);
Object obj = RedisUtil.getCache(key);
String returnFileds = StoreESFieldsEnum.STOREID.getField();
String returnFileds = StoreESFieldsEnum.STOREID.getField()+","+StoreESFieldsEnum.STOREINFOID.getField();
if(obj == null){
List<StoreListSourceVO> list = this.getStoreAllListSource(enterpriseId);
for(StoreListSourceVO vo : list){
......@@ -280,10 +280,12 @@ public class StoreController extends DownloadUtils {
@RequestMapping("store-license-limit")
public RestResponse storeLicenseLimit() {
ServiceResponse<List<EnterpriseLicenseDTO>> listEnterpriseLicense = this.enterpriseApiService.listEnterpriseLicense(UserDetailUtils.getUserDetail().getEnterpriseId());
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
ServiceResponse<List<EnterpriseLicenseDTO>> listEnterpriseLicense = this.enterpriseApiService.listEnterpriseLicense(enterpriseId);
if (listEnterpriseLicense.isSuccess() && CollectionUtils.isNotEmpty(listEnterpriseLicense.getResult())) {
if (listEnterpriseLicense.getResult().size() == 4) {
return RestResponse.success(listEnterpriseLicense.getResult().get(3).getUpperLimit());
Integer result = this.storeApiService.countByOverflowStatus(enterpriseId).getResult();
return RestResponse.success(listEnterpriseLicense.getResult().get(3).getUpperLimit() - result);
}
}
return RestResponse.success();
......@@ -508,7 +510,7 @@ public class StoreController extends DownloadUtils {
List<QrcodeContent> list = new ArrayList<>();
for(StoreDTO dto : result.getResult()){
QrcodeContent qrcodeContent = new QrcodeContent();
qrcodeContent.setCustomParams(dto.getStoreId()+"");
qrcodeContent.setCustomParams(dto.getStoreInfoId()+"");
qrcodeContent.setTitle(dto.getStoreName());
list.add(qrcodeContent);
}
......
......@@ -5,6 +5,7 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.download.utils.log.LogUtils;
import com.gic.enterprise.ano.IgnoreLogin;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.store.constant.StoreImportEnum;
......@@ -68,6 +69,7 @@ public class StoreImportController {
* @return
* @throws Exception
*/
@IgnoreLogin
@RequestMapping("/store-import-template-download")
public Object download(HttpServletRequest request, HttpServletResponse response) throws Exception {
// ClassPathResource res = new ClassPathResource("门店资料导入模板.xlsx");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment