Authored by gemingdan

推手后台

... ... @@ -5,7 +5,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.7.4-SNAPSHOT</version>
<version>1.7.6-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf</groupId>
<artifactId>yoho-unions</artifactId>
... ...
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;
}
}
... ...
... ... @@ -127,6 +127,7 @@
<entry key="userRegisterBuyInfoserviceImpl" value-ref="userRegisterBuyInfoserviceImpl"/>
<entry key="activeClickExportImpl" value-ref="unionServiceImpl"/>
<entry key="unionRebateExportImpl" value-ref="unionShareRebateExportImpl"/>
<entry key="unionRebateBrandExportImpl" value-ref="unionShareBrandRebateExportImpl"/>
</util:map>
</beans>
... ...
... ... @@ -14,9 +14,11 @@
<div style="margin-left: 15px;margin-top: 10px">
<input class="easyui-combobox" id="brand" style="width: 200px;" >
<input class="easyui-combobox" id="type" style="width:150px;" data-options="editable:false"/>
<input class="easyui-combobox" id="state" style="width:150px;" data-options="editable:false"/>
<a id="searchBtn" class="easyui-linkbutton btn-info">查询</a>
<a id="addBtn" class="easyui-linkbutton btn-primary" style="margin-left: 10px">新增</a>
<a id="exportBtn" class="easyui-linkbutton btn-primary" style="margin-left: 10px">导出</a>
<a id="batchImportBtn" class="easyui-linkbutton btn-primary" style="margin-left: 10px">批量导入</a>
</div>
</div>
... ... @@ -35,6 +37,7 @@
onClick : function() {
$("#shareRebateBrandTable").datagrid("load", {
brand : $("#brand").combobox("getValue"),
type : $("#type").combobox("getValue"),
state : $("#state").combobox("getValue")
});
}
... ... @@ -48,6 +51,18 @@
}
});
//1-默认比例,2-自定义
$("#type").myCombobox({
prompt: "返佣比例",
width: 200,
panelHeight : 90,
data: [
{"id":"1", "text":"默认比例"},
{"id":"2", "text":"自定义"}
],
valueField: "id",
textField: "text"
});
$("#state").myCombobox({
prompt: "状态",
width: 200,
... ... @@ -247,5 +262,27 @@
}
});
$("#exportBtn").linkbutton({
onClick: function () {
window.open(contextPath + "/batch/export.do?type=unionRebateBrandExportImpl&queryConf=" + JSON.stringify(getParams()));
}
});
function getParams() {
var params = {};
var brand = $("#brand").combobox("getValue");
if (brand != "") {
params["brand"] = brand;
}
var type = $("#type").combobox("getValue");
if (type != "") {
params["type"] = type;
}
var state = $("#state").combobox("getValue");
if (state != "") {
params["state"] = state;
}
return params;
}
</script>
\ No newline at end of file
... ...