|
|
package com.yoho.unions.server.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONException;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.service.model.union.bo.UnionShareRebateExportBo;
|
|
|
import com.yoho.service.model.union.request.UnionShareRebateReqBo;
|
|
|
import com.yoho.unions.common.service.IBusinessExportService;
|
|
|
import com.yoho.unions.dal.UnionShareRebateBrandMapper;
|
|
|
import com.yoho.unions.dal.model.UnionShareRebateBrand;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class UnionShareBrandRebateExportImpl implements IBusinessExportService {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(UnionShareBrandRebateExportImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
private UnionShareRebateBrandMapper unionShareRebateBrandMapper;
|
|
|
|
|
|
@Override
|
|
|
public Class getDataClass() {
|
|
|
return UnionShareRebateExportBo.class;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<? extends Object> batchExport(String confStr) {
|
|
|
try {
|
|
|
UnionShareRebateReqBo reqBo = JSONObject.parseObject(confStr, UnionShareRebateReqBo.class);
|
|
|
List<?> resultList = getList(reqBo);
|
|
|
if(CollectionUtils.isEmpty(resultList)){
|
|
|
log.warn("UnionRebateExportImpl::result is empty. confStr {}", confStr);
|
|
|
throw new ServiceException(201, "该筛选条件下查询结果为空");
|
|
|
}
|
|
|
return resultList;
|
|
|
}catch (JSONException e) {
|
|
|
log.warn("UnionRebateExportImpl::parse confStr error. confStr {}, e {}", confStr, e);
|
|
|
throw new ServiceException(400, "传入数据格式错误");
|
|
|
} catch (ServiceException e) {
|
|
|
log.warn("UnionRebateExportImpl::export fail. confStr {}, e {}", confStr, e);
|
|
|
throw new ServiceException(e.getCode(), e.getErrorMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private List<UnionShareRebateExportBo> getList(UnionShareRebateReqBo reqBo){
|
|
|
reqBo.setSize(2500);
|
|
|
List<UnionShareRebateBrand> list= unionShareRebateBrandMapper.selectListByCon(reqBo);
|
|
|
if(CollectionUtils.isEmpty(list)){
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
List<UnionShareRebateExportBo> results = new ArrayList<>();
|
|
|
list.forEach(l->{
|
|
|
UnionShareRebateExportBo bo = new UnionShareRebateExportBo();
|
|
|
BeanUtils.copyProperties(l,bo);
|
|
|
bo.setRebatePercentStr(l.getType() == 1 ? "默认":l.getRebate()/100 + "%") ;
|
|
|
bo.setStateStr(l.getState() == 1 ? "品牌状态" : l.getState() == 2 ? "开启" : "关闭");
|
|
|
results.add(bo);
|
|
|
});
|
|
|
return results;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|