Showing
4 changed files
with
110 additions
and
1 deletions
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | <parent> | 5 | <parent> |
6 | <groupId>com.yoho</groupId> | 6 | <groupId>com.yoho</groupId> |
7 | <artifactId>parent</artifactId> | 7 | <artifactId>parent</artifactId> |
8 | - <version>1.7.4-SNAPSHOT</version> | 8 | + <version>1.7.6-SNAPSHOT</version> |
9 | </parent> | 9 | </parent> |
10 | <groupId>com.yoho.dsf</groupId> | 10 | <groupId>com.yoho.dsf</groupId> |
11 | <artifactId>yoho-unions</artifactId> | 11 | <artifactId>yoho-unions</artifactId> |
server/src/main/java/com/yoho/unions/server/service/impl/UnionShareBrandRebateExportImpl.java
0 → 100644
1 | +package com.yoho.unions.server.service.impl; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONException; | ||
4 | +import com.alibaba.fastjson.JSONObject; | ||
5 | +import com.yoho.error.exception.ServiceException; | ||
6 | +import com.yoho.service.model.union.bo.UnionShareRebateExportBo; | ||
7 | +import com.yoho.service.model.union.request.UnionShareRebateReqBo; | ||
8 | +import com.yoho.unions.common.service.IBusinessExportService; | ||
9 | +import com.yoho.unions.dal.UnionShareRebateBrandMapper; | ||
10 | +import com.yoho.unions.dal.model.UnionShareRebateBrand; | ||
11 | +import org.apache.commons.collections.CollectionUtils; | ||
12 | +import org.slf4j.Logger; | ||
13 | +import org.slf4j.LoggerFactory; | ||
14 | +import org.springframework.beans.BeanUtils; | ||
15 | +import org.springframework.beans.factory.annotation.Autowired; | ||
16 | +import org.springframework.stereotype.Service; | ||
17 | + | ||
18 | +import java.util.*; | ||
19 | + | ||
20 | +@Service | ||
21 | +public class UnionShareBrandRebateExportImpl implements IBusinessExportService { | ||
22 | + | ||
23 | + private static final Logger log = LoggerFactory.getLogger(UnionShareBrandRebateExportImpl.class); | ||
24 | + | ||
25 | + @Autowired | ||
26 | + private UnionShareRebateBrandMapper unionShareRebateBrandMapper; | ||
27 | + | ||
28 | + @Override | ||
29 | + public Class getDataClass() { | ||
30 | + return UnionShareRebateExportBo.class; | ||
31 | + } | ||
32 | + | ||
33 | + @Override | ||
34 | + public List<? extends Object> batchExport(String confStr) { | ||
35 | + try { | ||
36 | + UnionShareRebateReqBo reqBo = JSONObject.parseObject(confStr, UnionShareRebateReqBo.class); | ||
37 | + List<?> resultList = getList(reqBo); | ||
38 | + if(CollectionUtils.isEmpty(resultList)){ | ||
39 | + log.warn("UnionRebateExportImpl::result is empty. confStr {}", confStr); | ||
40 | + throw new ServiceException(201, "该筛选条件下查询结果为空"); | ||
41 | + } | ||
42 | + return resultList; | ||
43 | + }catch (JSONException e) { | ||
44 | + log.warn("UnionRebateExportImpl::parse confStr error. confStr {}, e {}", confStr, e); | ||
45 | + throw new ServiceException(400, "传入数据格式错误"); | ||
46 | + } catch (ServiceException e) { | ||
47 | + log.warn("UnionRebateExportImpl::export fail. confStr {}, e {}", confStr, e); | ||
48 | + throw new ServiceException(e.getCode(), e.getErrorMessage()); | ||
49 | + } | ||
50 | + } | ||
51 | + | ||
52 | + private List<UnionShareRebateExportBo> getList(UnionShareRebateReqBo reqBo){ | ||
53 | + reqBo.setSize(2500); | ||
54 | + List<UnionShareRebateBrand> list= unionShareRebateBrandMapper.selectListByCon(reqBo); | ||
55 | + if(CollectionUtils.isEmpty(list)){ | ||
56 | + return new ArrayList<>(); | ||
57 | + } | ||
58 | + List<UnionShareRebateExportBo> results = new ArrayList<>(); | ||
59 | + list.forEach(l->{ | ||
60 | + UnionShareRebateExportBo bo = new UnionShareRebateExportBo(); | ||
61 | + BeanUtils.copyProperties(l,bo); | ||
62 | + bo.setRebatePercentStr(l.getType() == 1 ? "默认":l.getRebate()/100 + "%") ; | ||
63 | + bo.setStateStr(l.getState() == 1 ? "品牌状态" : l.getState() == 2 ? "开启" : "关闭"); | ||
64 | + results.add(bo); | ||
65 | + }); | ||
66 | + return results; | ||
67 | + | ||
68 | + } | ||
69 | + | ||
70 | + | ||
71 | +} |
@@ -127,6 +127,7 @@ | @@ -127,6 +127,7 @@ | ||
127 | <entry key="userRegisterBuyInfoserviceImpl" value-ref="userRegisterBuyInfoserviceImpl"/> | 127 | <entry key="userRegisterBuyInfoserviceImpl" value-ref="userRegisterBuyInfoserviceImpl"/> |
128 | <entry key="activeClickExportImpl" value-ref="unionServiceImpl"/> | 128 | <entry key="activeClickExportImpl" value-ref="unionServiceImpl"/> |
129 | <entry key="unionRebateExportImpl" value-ref="unionShareRebateExportImpl"/> | 129 | <entry key="unionRebateExportImpl" value-ref="unionShareRebateExportImpl"/> |
130 | + <entry key="unionRebateBrandExportImpl" value-ref="unionShareBrandRebateExportImpl"/> | ||
130 | </util:map> | 131 | </util:map> |
131 | 132 | ||
132 | </beans> | 133 | </beans> |
@@ -14,9 +14,11 @@ | @@ -14,9 +14,11 @@ | ||
14 | 14 | ||
15 | <div style="margin-left: 15px;margin-top: 10px"> | 15 | <div style="margin-left: 15px;margin-top: 10px"> |
16 | <input class="easyui-combobox" id="brand" style="width: 200px;" > | 16 | <input class="easyui-combobox" id="brand" style="width: 200px;" > |
17 | + <input class="easyui-combobox" id="type" style="width:150px;" data-options="editable:false"/> | ||
17 | <input class="easyui-combobox" id="state" style="width:150px;" data-options="editable:false"/> | 18 | <input class="easyui-combobox" id="state" style="width:150px;" data-options="editable:false"/> |
18 | <a id="searchBtn" class="easyui-linkbutton btn-info">查询</a> | 19 | <a id="searchBtn" class="easyui-linkbutton btn-info">查询</a> |
19 | <a id="addBtn" class="easyui-linkbutton btn-primary" style="margin-left: 10px">新增</a> | 20 | <a id="addBtn" class="easyui-linkbutton btn-primary" style="margin-left: 10px">新增</a> |
21 | + <a id="exportBtn" class="easyui-linkbutton btn-primary" style="margin-left: 10px">导出</a> | ||
20 | <a id="batchImportBtn" class="easyui-linkbutton btn-primary" style="margin-left: 10px">批量导入</a> | 22 | <a id="batchImportBtn" class="easyui-linkbutton btn-primary" style="margin-left: 10px">批量导入</a> |
21 | </div> | 23 | </div> |
22 | </div> | 24 | </div> |
@@ -35,6 +37,7 @@ | @@ -35,6 +37,7 @@ | ||
35 | onClick : function() { | 37 | onClick : function() { |
36 | $("#shareRebateBrandTable").datagrid("load", { | 38 | $("#shareRebateBrandTable").datagrid("load", { |
37 | brand : $("#brand").combobox("getValue"), | 39 | brand : $("#brand").combobox("getValue"), |
40 | + type : $("#type").combobox("getValue"), | ||
38 | state : $("#state").combobox("getValue") | 41 | state : $("#state").combobox("getValue") |
39 | }); | 42 | }); |
40 | } | 43 | } |
@@ -48,6 +51,18 @@ | @@ -48,6 +51,18 @@ | ||
48 | } | 51 | } |
49 | }); | 52 | }); |
50 | 53 | ||
54 | + //1-默认比例,2-自定义 | ||
55 | + $("#type").myCombobox({ | ||
56 | + prompt: "返佣比例", | ||
57 | + width: 200, | ||
58 | + panelHeight : 90, | ||
59 | + data: [ | ||
60 | + {"id":"1", "text":"默认比例"}, | ||
61 | + {"id":"2", "text":"自定义"} | ||
62 | + ], | ||
63 | + valueField: "id", | ||
64 | + textField: "text" | ||
65 | + }); | ||
51 | $("#state").myCombobox({ | 66 | $("#state").myCombobox({ |
52 | prompt: "状态", | 67 | prompt: "状态", |
53 | width: 200, | 68 | width: 200, |
@@ -247,5 +262,27 @@ | @@ -247,5 +262,27 @@ | ||
247 | } | 262 | } |
248 | }); | 263 | }); |
249 | 264 | ||
265 | + $("#exportBtn").linkbutton({ | ||
266 | + onClick: function () { | ||
267 | + window.open(contextPath + "/batch/export.do?type=unionRebateBrandExportImpl&queryConf=" + JSON.stringify(getParams())); | ||
268 | + } | ||
269 | + }); | ||
270 | + | ||
271 | + function getParams() { | ||
272 | + var params = {}; | ||
273 | + var brand = $("#brand").combobox("getValue"); | ||
274 | + if (brand != "") { | ||
275 | + params["brand"] = brand; | ||
276 | + } | ||
277 | + var type = $("#type").combobox("getValue"); | ||
278 | + if (type != "") { | ||
279 | + params["type"] = type; | ||
280 | + } | ||
281 | + var state = $("#state").combobox("getValue"); | ||
282 | + if (state != "") { | ||
283 | + params["state"] = state; | ||
284 | + } | ||
285 | + return params; | ||
286 | + } | ||
250 | 287 | ||
251 | </script> | 288 | </script> |
-
Please register or login to post a comment