Authored by csgyoho

Merge branch 'dev_180508_联盟红人推广' of http://git.yoho.cn/yoho30/yohobuy-union into dev_180508_联盟红人推广

@@ -84,6 +84,8 @@ @@ -84,6 +84,8 @@
84 <value>/UnionShareRest/querySettlementRecord</value> 84 <value>/UnionShareRest/querySettlementRecord</value>
85 <value>/UnionShareRest/queryOrderList</value> 85 <value>/UnionShareRest/queryOrderList</value>
86 <value>/UnionShareRest/queryUnionShareOrders</value> 86 <value>/UnionShareRest/queryUnionShareOrders</value>
  87 + <value>/UnionShareRest/mqUnionShareOrder</value>
  88 + <value>/UnionShareRest/mqUnionSettleUpdate</value>
87 89
88 </list> 90 </list>
89 </property> 91 </property>
@@ -54,4 +54,6 @@ public interface UnionShareOrdersMapper { @@ -54,4 +54,6 @@ public interface UnionShareOrdersMapper {
54 List<UnionShareOrders> selectRecentlyOrderLimitTen(@Param("uid") int uid); 54 List<UnionShareOrders> selectRecentlyOrderLimitTen(@Param("uid") int uid);
55 55
56 List<UnionShareOrders> selectOrderList(@Param("params") UnionShareOrderReqBO unionShareOrderReqBO); 56 List<UnionShareOrders> selectOrderList(@Param("params") UnionShareOrderReqBO unionShareOrderReqBO);
  57 +
  58 + Integer selectOrderListCount(@Param("params") UnionShareOrderReqBO unionShareOrderReqBO);
57 } 59 }
@@ -26,4 +26,6 @@ public interface UnionShareSettlementMapper { @@ -26,4 +26,6 @@ public interface UnionShareSettlementMapper {
26 int updateByPrimaryKey(UnionShareSettlement record); 26 int updateByPrimaryKey(UnionShareSettlement record);
27 27
28 List<UnionShareSettlement> selectSettlementRecordByUid(@Param("uid") int uid, @Param("start") Integer start, @Param("size") Integer size); 28 List<UnionShareSettlement> selectSettlementRecordByUid(@Param("uid") int uid, @Param("start") Integer start, @Param("size") Integer size);
  29 +
  30 + Integer selectSettlementRecordCount(@Param("uid") Integer uid);
29 } 31 }
@@ -318,4 +318,38 @@ @@ -318,4 +318,38 @@
318 order by order_time desc 318 order by order_time desc
319 limit #{params.start,jdbcType=INTEGER}, #{params.size,jdbcType=INTEGER} 319 limit #{params.start,jdbcType=INTEGER}, #{params.size,jdbcType=INTEGER}
320 </select> 320 </select>
  321 +
  322 + <select id="selectOrderListCount" resultType="java.lang.Integer">
  323 + select
  324 + count(1)
  325 + from union_share_orders
  326 + where promote_uid = #{params.uid,jdbcType=INTEGER}
  327 + <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 0">
  328 + AND status != 100
  329 + </if>
  330 + <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 1">
  331 + AND status = 10
  332 + </if>
  333 + <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 2">
  334 + AND status = 20
  335 + </if>
  336 + <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 3">
  337 + AND status IN (30,40)
  338 + </if>
  339 + <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 0">
  340 + AND status IN (10,20,30,40)
  341 + </if>
  342 + <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 1">
  343 + AND status = 10
  344 + </if>
  345 + <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 2">
  346 + AND status = 20
  347 + </if>
  348 + <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 3">
  349 + AND status IN (30,40)
  350 + </if>
  351 + <if test="params.tab1 != null and params.tab1 == 3">
  352 + AND status IN (91,92,93)
  353 + </if>
  354 + </select>
321 </mapper> 355 </mapper>
@@ -140,4 +140,11 @@ @@ -140,4 +140,11 @@
140 order by settlement_time desc 140 order by settlement_time desc
141 limit #{start,jdbcType=INTEGER}, #{size,jdbcType=INTEGER} 141 limit #{start,jdbcType=INTEGER}, #{size,jdbcType=INTEGER}
142 </select> 142 </select>
  143 +
  144 + <select id="selectSettlementRecordCount" resultType="java.lang.Integer">
  145 + select
  146 + count(1)
  147 + from union_share_settlement
  148 + where promote_uid = #{uid,jdbcType=INTEGER}
  149 + </select>
143 </mapper> 150 </mapper>
@@ -17,7 +17,7 @@ import java.util.List; @@ -17,7 +17,7 @@ import java.util.List;
17 @Component 17 @Component
18 public class UnionSettleUpdateConsumer implements YhConsumer { 18 public class UnionSettleUpdateConsumer implements YhConsumer {
19 19
20 - private Logger logger = LoggerFactory.getLogger(UnionSettleUpdateConsumer.class); 20 + private Logger logger = LoggerFactory.getLogger("cps_mq");
21 21
22 @Autowired 22 @Autowired
23 private IUnionShareService unionShareService; 23 private IUnionShareService unionShareService;
@@ -17,7 +17,7 @@ import java.util.List; @@ -17,7 +17,7 @@ import java.util.List;
17 @Component 17 @Component
18 public class UnionShareOrderConsumer implements YhConsumer { 18 public class UnionShareOrderConsumer implements YhConsumer {
19 19
20 - private Logger logger = LoggerFactory.getLogger(UnionShareOrderConsumer.class); 20 + private Logger logger = LoggerFactory.getLogger("cps_mq");
21 21
22 @Autowired 22 @Autowired
23 private IUnionShareService unionShareService; 23 private IUnionShareService unionShareService;
1 package com.yoho.unions.server.restapi; 1 package com.yoho.unions.server.restapi;
2 2
  3 +import com.yoho.core.common.utils.JsonUtil;
3 import com.yoho.service.model.union.bo.ShareOrderBo; 4 import com.yoho.service.model.union.bo.ShareOrderBo;
  5 +import com.yoho.service.model.union.bo.ShareSettlementBo;
4 import com.yoho.service.model.union.bo.ShareUserSettlementInfoBo; 6 import com.yoho.service.model.union.bo.ShareUserSettlementInfoBo;
5 import com.yoho.service.model.union.request.UnionShareOrderReqBO; 7 import com.yoho.service.model.union.request.UnionShareOrderReqBO;
6 import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO; 8 import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
  9 +import com.yoho.service.model.union.response.PageResponseBO;
7 import com.yoho.service.model.union.response.PageUnionShareOrderRspBO; 10 import com.yoho.service.model.union.response.PageUnionShareOrderRspBO;
8 import com.yoho.service.model.union.response.UnionResponse; 11 import com.yoho.service.model.union.response.UnionResponse;
9 import com.yoho.unions.common.ApiResponse; 12 import com.yoho.unions.common.ApiResponse;
@@ -32,6 +35,8 @@ public class UnionShareRest { @@ -32,6 +35,8 @@ public class UnionShareRest {
32 35
33 private static Logger log = LoggerFactory.getLogger(UnionShareRest.class); 36 private static Logger log = LoggerFactory.getLogger(UnionShareRest.class);
34 37
  38 + private static Logger mqlog = LoggerFactory.getLogger("cps_mq");
  39 +
35 @Autowired 40 @Autowired
36 IUnionShareService unionShareService; 41 IUnionShareService unionShareService;
37 42
@@ -120,7 +125,7 @@ public class UnionShareRest { @@ -120,7 +125,7 @@ public class UnionShareRest {
120 if (null == unionShareOrderReqBO || null == unionShareOrderReqBO.getUid()){ 125 if (null == unionShareOrderReqBO || null == unionShareOrderReqBO.getUid()){
121 return new UnionResponse(400, "querySettlementRecord params is null"); 126 return new UnionResponse(400, "querySettlementRecord params is null");
122 } 127 }
123 - List<UnionShareSettlement> unionShareSettlement = unionShareService.querySettlementRecord(unionShareOrderReqBO); 128 + PageResponseBO<UnionShareSettlement> unionShareSettlement = unionShareService.querySettlementRecord(unionShareOrderReqBO);
124 return new UnionResponse(200, "querySettlementRecord success",unionShareSettlement); 129 return new UnionResponse(200, "querySettlementRecord success",unionShareSettlement);
125 } 130 }
126 131
@@ -138,7 +143,48 @@ public class UnionShareRest { @@ -138,7 +143,48 @@ public class UnionShareRest {
138 if (null == unionShareOrderReqBO || null == unionShareOrderReqBO.getUid()){ 143 if (null == unionShareOrderReqBO || null == unionShareOrderReqBO.getUid()){
139 return new UnionResponse(400, "queryOrderList params is null"); 144 return new UnionResponse(400, "queryOrderList params is null");
140 } 145 }
141 - List<UnionShareOrders> unionShareOrdersList = unionShareService.queryOrderList(unionShareOrderReqBO); 146 + PageResponseBO<UnionShareOrders> unionShareOrdersList = unionShareService.queryOrderList(unionShareOrderReqBO);
142 return new UnionResponse(200, "queryOrderList success",unionShareOrdersList); 147 return new UnionResponse(200, "queryOrderList success",unionShareOrdersList);
143 } 148 }
  149 +
  150 +
  151 + @RequestMapping("/mqUnionShareOrder")
  152 + @ResponseBody
  153 + public UnionResponse mqUnionShareOrder(@RequestBody List<ShareOrderBo> list){
  154 + mqlog.info("UnionShareRest.mqUnionShareOrder req is {}", JsonUtil.objectToJSON(list));
  155 + try {
  156 + if (null == list) {
  157 + return new UnionResponse(500, "mqUnionShareOrder error,req is null");
  158 + }
  159 +
  160 + list.forEach(l->{
  161 + try {
  162 + //订单插入或更新
  163 + unionShareService.saveOrUpdateOrder(l);
  164 + } catch (Exception e) {
  165 + mqlog.info("UnionShareRest.mqUnionShareOrder fail! bo is {}, e {}", l,e.getMessage());
  166 + }
  167 + });
  168 + } catch (Exception e) {
  169 + mqlog.warn("UnionShareRest.mqUnionShareOrder fail! str is {}, e {}",JsonUtil.objectToJSON(list),e.getMessage());
  170 + }
  171 + return new UnionResponse(200, "mqUnionShareOrder success");
  172 + }
  173 +
  174 + @RequestMapping("/mqUnionSettleUpdate")
  175 + @ResponseBody
  176 + public UnionResponse mqUnionSettleUpdate(@RequestBody ShareSettlementBo bo){
  177 + mqlog.info("UnionShareRest.mqUnionSettleUpdate req is {}", bo);
  178 + try {
  179 + if (null == bo) {
  180 + return new UnionResponse(500, "mqUnionSettleUpdate error,req is null");
  181 + }
  182 + //提现结算单状态变更
  183 + unionShareService.updateSettlementStatus(bo);
  184 +
  185 + } catch (Exception e) {
  186 + mqlog.warn("UnionShareRest.mqUnionSettleUpdate fail! req is {}, e {}", bo,e.getMessage());
  187 + }
  188 + return new UnionResponse(200, "mqUnionSettleUpdate success");
  189 + }
144 } 190 }
@@ -5,6 +5,7 @@ import com.yoho.service.model.union.bo.ShareSettlementBo; @@ -5,6 +5,7 @@ import com.yoho.service.model.union.bo.ShareSettlementBo;
5 import com.yoho.service.model.union.bo.ShareUserSettlementInfoBo; 5 import com.yoho.service.model.union.bo.ShareUserSettlementInfoBo;
6 import com.yoho.service.model.union.request.UnionShareOrderReqBO; 6 import com.yoho.service.model.union.request.UnionShareOrderReqBO;
7 import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO; 7 import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
  8 +import com.yoho.service.model.union.response.PageResponseBO;
8 import com.yoho.service.model.union.response.PageUnionShareOrderRspBO; 9 import com.yoho.service.model.union.response.PageUnionShareOrderRspBO;
9 import com.yoho.unions.dal.model.UnionShareOrders; 10 import com.yoho.unions.dal.model.UnionShareOrders;
10 import com.yoho.unions.dal.model.UnionShareSettlement; 11 import com.yoho.unions.dal.model.UnionShareSettlement;
@@ -66,12 +67,12 @@ public interface IUnionShareService { @@ -66,12 +67,12 @@ public interface IUnionShareService {
66 * @param unionShareOrderReqBO 67 * @param unionShareOrderReqBO
67 * @return 68 * @return
68 */ 69 */
69 - List<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO); 70 + PageResponseBO<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO);
70 71
71 /** 72 /**
72 * 订单列表 73 * 订单列表
73 * @param unionShareOrderReqBO 74 * @param unionShareOrderReqBO
74 * @return 75 * @return
75 */ 76 */
76 - List<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO); 77 + PageResponseBO<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO);
77 } 78 }
@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONException; @@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONException;
4 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
5 import com.yoho.core.config.ConfigReader; 5 import com.yoho.core.config.ConfigReader;
6 import com.yoho.core.rabbitmq.YhProducer; 6 import com.yoho.core.rabbitmq.YhProducer;
  7 +import com.yoho.error.ServiceError;
7 import com.yoho.error.exception.ServiceException; 8 import com.yoho.error.exception.ServiceException;
8 import com.yoho.service.model.union.bo.*; 9 import com.yoho.service.model.union.bo.*;
9 import com.yoho.service.model.union.request.UnionShareOrderReqBO; 10 import com.yoho.service.model.union.request.UnionShareOrderReqBO;
10 import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO; 11 import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
  12 +import com.yoho.service.model.union.response.PageResponseBO;
11 import com.yoho.service.model.union.response.PageUnionShareOrderRspBO; 13 import com.yoho.service.model.union.response.PageUnionShareOrderRspBO;
12 import com.yoho.service.model.union.response.UnionShareOrderRspBO; 14 import com.yoho.service.model.union.response.UnionShareOrderRspBO;
13 import com.yoho.unions.common.enums.OrderStatusEnum; 15 import com.yoho.unions.common.enums.OrderStatusEnum;
@@ -49,6 +51,9 @@ import java.util.concurrent.atomic.AtomicInteger; @@ -49,6 +51,9 @@ import java.util.concurrent.atomic.AtomicInteger;
49 @Service 51 @Service
50 public class UnionShareServiceImpl implements IUnionShareService,IBusinessExportService { 52 public class UnionShareServiceImpl implements IUnionShareService,IBusinessExportService {
51 private Logger logger = LoggerFactory.getLogger(UnionShareServiceImpl.class); 53 private Logger logger = LoggerFactory.getLogger(UnionShareServiceImpl.class);
  54 + private Logger mqLog = LoggerFactory.getLogger("cps_mq");
  55 + private Logger settlementLog = LoggerFactory.getLogger("cps_settlement");
  56 +// private Logger mqLog = LoggerFactory.getLogger("cps_mq");
52 57
53 @Autowired 58 @Autowired
54 private UnionShareOrdersMapper unionShareOrdersMapper; 59 private UnionShareOrdersMapper unionShareOrdersMapper;
@@ -332,16 +337,24 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -332,16 +337,24 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
332 } 337 }
333 338
334 @Override 339 @Override
335 - public List<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO) { 340 + public PageResponseBO<UnionShareSettlement> querySettlementRecord(UnionShareOrderReqBO unionShareOrderReqBO) {
336 //先从缓存获取 341 //先从缓存获取
337 String key = "settlementRecord"; 342 String key = "settlementRecord";
338 - UnionShareSettlementListBO cacheResult = getFromRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST, unionShareOrderReqBO.getUid(),  
339 - UnionShareSettlementListBO.class, key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize())); 343 + PageResponseBO<UnionShareSettlement> cacheResult = getFromRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST, unionShareOrderReqBO.getUid(),
  344 + PageResponseBO.class, key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
340 if (cacheResult != null) { 345 if (cacheResult != null) {
341 logger.debug("UnionShareServiceImpl :: querySettlementRecord get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult); 346 logger.debug("UnionShareServiceImpl :: querySettlementRecord get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult);
342 - return cacheResult.getList(); 347 + return cacheResult;
343 } 348 }
344 //数据库获取 349 //数据库获取
  350 + //获取总数
  351 + PageResponseBO<UnionShareSettlement> response = new PageResponseBO<>();
  352 + Integer count = unionShareSettlementMapper.selectSettlementRecordCount(unionShareOrderReqBO.getUid());
  353 + if (count <= 0){
  354 + logger.info("UnionShareServiceImpl :: querySettlementRecord count is 0");
  355 + return response;
  356 + }
  357 + //分页
345 List<UnionShareSettlement> unionShareSettlementList = unionShareSettlementMapper.selectSettlementRecordByUid(unionShareOrderReqBO.getUid(), 358 List<UnionShareSettlement> unionShareSettlementList = unionShareSettlementMapper.selectSettlementRecordByUid(unionShareOrderReqBO.getUid(),
346 (unionShareOrderReqBO.getPage()-1)*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize()); 359 (unionShareOrderReqBO.getPage()-1)*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize());
347 if (CollectionUtils.isNotEmpty(unionShareSettlementList)){ 360 if (CollectionUtils.isNotEmpty(unionShareSettlementList)){
@@ -351,34 +364,56 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -351,34 +364,56 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
351 unionShareSettlement.setSettlementTimeStr(DateUtils.int2DateStr(unionShareSettlement.getSettlementTime(), DateUtils.POINT_FOMARTPATTER)); 364 unionShareSettlement.setSettlementTimeStr(DateUtils.int2DateStr(unionShareSettlement.getSettlementTime(), DateUtils.POINT_FOMARTPATTER));
352 } 365 }
353 } 366 }
  367 + response.setSize(unionShareOrderReqBO.getSize());
  368 + response.setPage(unionShareOrderReqBO.getPage());
  369 + response.setTotal(count);
  370 + if (count % unionShareOrderReqBO.getSize() == 0) {
  371 + response.setTotalPage(count/unionShareOrderReqBO.getSize());
  372 + } else {
  373 + response.setTotalPage(count/unionShareOrderReqBO.getSize()+1);
  374 + }
  375 + response.setList(unionShareSettlementList);
354 //设置缓存 376 //设置缓存
355 - UnionShareSettlementListBO unionShareSettlementListBO = new UnionShareSettlementListBO();  
356 - unionShareSettlementListBO.setList(unionShareSettlementList);  
357 - addToRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST,unionShareOrderReqBO.getUid(),unionShareSettlementListBO,key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));  
358 - return unionShareSettlementList; 377 + addToRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST,unionShareOrderReqBO.getUid(),response,key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
  378 + return response;
359 } 379 }
360 380
361 @Override 381 @Override
362 - public List<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO) { 382 + public PageResponseBO<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO) {
363 //先从缓存获取 383 //先从缓存获取
364 - UnionShareOrdersListBO cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_LIST, unionShareOrderReqBO.getUid(),UnionShareOrdersListBO.class, unionShareOrderReqBO.getTab1().toString(), 384 + PageResponseBO<UnionShareOrders> cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_LIST, unionShareOrderReqBO.getUid(),PageResponseBO.class, unionShareOrderReqBO.getTab1().toString(),
365 unionShareOrderReqBO.getTab2().toString(), String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize())); 385 unionShareOrderReqBO.getTab2().toString(), String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
366 if (cacheResult != null) { 386 if (cacheResult != null) {
367 logger.debug("UnionShareServiceImpl :: queryOrderList get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult); 387 logger.debug("UnionShareServiceImpl :: queryOrderList get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult);
368 - return cacheResult.getList(); 388 + return cacheResult;
369 } 389 }
370 //数据库获取 390 //数据库获取
  391 + //获取总数
  392 + PageResponseBO<UnionShareOrders> response = new PageResponseBO<>();
  393 + Integer count = unionShareOrdersMapper.selectOrderListCount(unionShareOrderReqBO);
  394 + if (count <= 0){
  395 + logger.info("UnionShareServiceImpl :: queryOrderList count is 0");
  396 + return response;
  397 + }
  398 + //分页
371 //tab1表示1、全部订单;2、有效订单;3、无效订单 tab2表示1、已付款;2、待结算;3、结算中 399 //tab1表示1、全部订单;2、有效订单;3、无效订单 tab2表示1、已付款;2、待结算;3、结算中
372 unionShareOrderReqBO.setStart((unionShareOrderReqBO.getPage()-1)*unionShareOrderReqBO.getSize()); 400 unionShareOrderReqBO.setStart((unionShareOrderReqBO.getPage()-1)*unionShareOrderReqBO.getSize());
373 List<UnionShareOrders> unionShareOrdersList = unionShareOrdersMapper.selectOrderList(unionShareOrderReqBO); 401 List<UnionShareOrders> unionShareOrdersList = unionShareOrdersMapper.selectOrderList(unionShareOrderReqBO);
374 //处理订单列表数据 402 //处理订单列表数据
375 dealShareOrderList(unionShareOrdersList); 403 dealShareOrderList(unionShareOrdersList);
  404 + response.setSize(unionShareOrderReqBO.getSize());
  405 + response.setPage(unionShareOrderReqBO.getPage());
  406 + response.setTotal(count);
  407 + if (count % unionShareOrderReqBO.getSize() == 0) {
  408 + response.setTotalPage(count/unionShareOrderReqBO.getSize());
  409 + } else {
  410 + response.setTotalPage(count/unionShareOrderReqBO.getSize()+1);
  411 + }
  412 + response.setList(unionShareOrdersList);
376 //设置缓存 413 //设置缓存
377 - UnionShareOrdersListBO unionShareOrdersListBO = new UnionShareOrdersListBO();  
378 - unionShareOrdersListBO.setList(unionShareOrdersList);  
379 - addToRedis(ShareOrdersKeyEnum.ORDER_LIST,unionShareOrderReqBO.getUid(),unionShareOrdersListBO,unionShareOrderReqBO.getTab1().toString(), unionShareOrderReqBO.getTab2().toString(), 414 + addToRedis(ShareOrdersKeyEnum.ORDER_LIST,unionShareOrderReqBO.getUid(),response,unionShareOrderReqBO.getTab1().toString(), unionShareOrderReqBO.getTab2().toString(),
380 String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize())); 415 String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
381 - return unionShareOrdersList; 416 + return response;
382 } 417 }
383 418
384 /** 419 /**
@@ -519,34 +554,34 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -519,34 +554,34 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
519 */ 554 */
520 @Override 555 @Override
521 public BigDecimal addSettlement(Integer uid) { 556 public BigDecimal addSettlement(Integer uid) {
522 - logger.info("addSettlement enter,uid is {}",uid); 557 + settlementLog.info("addSettlement enter,uid is {}",uid);
523 if (uid == null ) { 558 if (uid == null ) {
524 - return null; 559 + throw new ServiceException(ServiceError.USER_ID_ERROR);
525 } 560 }
526 //查询该用户是否为特邀用户 561 //查询该用户是否为特邀用户
527 int count = unionShareUserMapper.selectCountByUid(uid); 562 int count = unionShareUserMapper.selectCountByUid(uid);
528 if (count == 0) { 563 if (count == 0) {
529 //不是特邀用户 564 //不是特邀用户
530 - logger.info("addSettlement end,can not find unionType,uid is {}",uid);  
531 - return null; 565 + settlementLog.info("addSettlement end,can not find unionType,uid is {}",uid);
  566 + throw new ServiceException(ServiceError.USER_ID_ERROR);
532 } 567 }
533 //查询是否有处理中的提现 568 //查询是否有处理中的提现
534 if (hasSettlement(uid)) { 569 if (hasSettlement(uid)) {
535 //有处理中的提现单,不可提现 570 //有处理中的提现单,不可提现
536 - logger.info("addSettlement end,hasSettlement,uid is {}",uid);  
537 - return null; 571 + settlementLog.info("addSettlement end,hasSettlement,uid is {}",uid);
  572 + throw new ServiceException(ServiceError.UNION_HASSETTLEMENT_ERROR);
538 } 573 }
539 574
540 //查询当前是否有可提现的订单 575 //查询当前是否有可提现的订单
541 int orderCount = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.CAN_SETTLE.getCode()); 576 int orderCount = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.CAN_SETTLE.getCode());
542 if (orderCount == 0 ) { 577 if (orderCount == 0 ) {
543 //没有可以提现的订单 578 //没有可以提现的订单
544 - logger.info("addSettlement end,has not remaining settlement,uid is {}",uid);  
545 - return null; 579 + settlementLog.info("addSettlement end,has not remaining settlement,uid is {}",uid);
  580 + throw new ServiceException(ServiceError.UNION_HASNOT_REMAINING_SETTLEMENT);
546 } 581 }
547 - //todo 生成取现单,绑定订单,考虑是否异步操作 582 + // 生成取现单,绑定订单
548 BigDecimal amount = relateSettlementAndOrder(uid); 583 BigDecimal amount = relateSettlementAndOrder(uid);
549 - logger.info("addSettlement end,remaining settlement is {},uid is {}",amount,uid); 584 + settlementLog.info("addSettlement end,remaining settlement is {},uid is {}",amount,uid);
550 return amount; 585 return amount;
551 } 586 }
552 587
@@ -635,22 +670,22 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -635,22 +670,22 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
635 * */ 670 * */
636 public BigDecimal relateSettlementAndOrder(int uid) { 671 public BigDecimal relateSettlementAndOrder(int uid) {
637 672
638 - logger.info("relateSettlementAndOrder enter,uid is {}",uid); 673 + settlementLog.info("relateSettlementAndOrder enter,uid is {}",uid);
639 674
640 //生成提现编号 675 //生成提现编号
641 String settlementCode = createSettlementCode(); 676 String settlementCode = createSettlementCode();
642 - logger.info("relateSettlementAndOrder,uid is {},settlementCode is {}",uid,settlementCode); 677 + settlementLog.info("relateSettlementAndOrder,uid is {},settlementCode is {}",uid,settlementCode);
643 678
644 //更新订单状态,由可结算变为打款中 679 //更新订单状态,由可结算变为打款中
645 int updateTime = DateUtil.getCurrentTimeSecond(); 680 int updateTime = DateUtil.getCurrentTimeSecond();
646 int count=unionShareOrdersMapper.updateStatusByUid(uid,settlementCode, ShareOrdersStatusEnum.CAN_SETTLE.getCode(), ShareOrdersStatusEnum.SETTLE.getCode(), updateTime); 681 int count=unionShareOrdersMapper.updateStatusByUid(uid,settlementCode, ShareOrdersStatusEnum.CAN_SETTLE.getCode(), ShareOrdersStatusEnum.SETTLE.getCode(), updateTime);
647 if (count == 0) { 682 if (count == 0) {
648 - logger.info("relateSettlementAndOrder end,uid is {},settlementCode is {},There are no available orders.",uid,settlementCode);  
649 - return null; 683 + settlementLog.info("relateSettlementAndOrder end,uid is {},settlementCode is {},There are no available orders.",uid,settlementCode);
  684 + throw new ServiceException(ServiceError.UNION_SETTLEMENT_UNAVAILABLE_ORDER_ERROR);
650 } 685 }
651 //计算提现金额 686 //计算提现金额
652 BigDecimal totalAmount=unionShareOrdersMapper.selectAmountBySettleCode(uid, settlementCode); 687 BigDecimal totalAmount=unionShareOrdersMapper.selectAmountBySettleCode(uid, settlementCode);
653 - logger.info("relateSettlementAndOrder,uid is {},settlementCode is {},totalAmount is {}",uid,settlementCode,totalAmount); 688 + settlementLog.info("relateSettlementAndOrder,uid is {},settlementCode is {},totalAmount is {}",uid,settlementCode,totalAmount);
654 689
655 //生成提现单 690 //生成提现单
656 UnionShareSettlement insertReq = new UnionShareSettlement(); 691 UnionShareSettlement insertReq = new UnionShareSettlement();
@@ -662,8 +697,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -662,8 +697,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
662 insertReq.setStatus((byte)1);//是否打款成功:1-处理中,2-已打款 697 insertReq.setStatus((byte)1);//是否打款成功:1-处理中,2-已打款
663 int num=unionShareSettlementMapper.insertSelective(insertReq); 698 int num=unionShareSettlementMapper.insertSelective(insertReq);
664 if (num < 1) { 699 if (num < 1) {
665 - //插入失败  
666 - logger.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},insert nothing.",uid,settlementCode,totalAmount); 700 + //插入失败 todo 日志记录
  701 + settlementLog.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},insert nothing.",uid,settlementCode,totalAmount);
667 } 702 }
668 703
669 Set<String> orderCodes = new HashSet<>(); 704 Set<String> orderCodes = new HashSet<>();
@@ -679,20 +714,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -679,20 +714,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
679 } 714 }
680 if (orderCodes.size() == 0) { 715 if (orderCodes.size() == 0) {
681 //不该查不到订单 716 //不该查不到订单
682 - logger.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},can not find orders.",uid,settlementCode,totalAmount);  
683 - return null; 717 + settlementLog.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},can not find orders.",uid,settlementCode,totalAmount);
  718 + throw new ServiceException(ServiceError.UNION_SETTLEMENT_CANNOT_FIND_ORDER_ERROR);
684 } 719 }
685 720
686 721
687 //清缓存 722 //清缓存
688 clearShareOrderRedis(uid); 723 clearShareOrderRedis(uid);
689 724
690 - //todo 发送取现mq给erp SETTLEMENT_TOPIC 725 + // 发送取现mq给erp SETTLEMENT_TOPIC
691 ShareSettlementBo bo = new ShareSettlementBo(); 726 ShareSettlementBo bo = new ShareSettlementBo();
692 BeanUtils.copyProperties(insertReq,bo); 727 BeanUtils.copyProperties(insertReq,bo);
693 bo.setOrderCodes(orderCodes); 728 bo.setOrderCodes(orderCodes);
694 - logger.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo); 729 + mqLog.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
695 yhProducer.send(SETTLEMENT_TOPIC, bo); 730 yhProducer.send(SETTLEMENT_TOPIC, bo);
  731 + settlementLog.info("relateSettlementAndOrder,send mq {} to erp success,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
696 return totalAmount; 732 return totalAmount;
697 } 733 }
698 734
@@ -708,10 +744,17 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -708,10 +744,17 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
708 744
709 //是否打款成功:1-处理中,2-已打款 745 //是否打款成功:1-处理中,2-已打款
710 if (bo.getStatus() == null || bo.getStatus().intValue() != 2) { 746 if (bo.getStatus() == null || bo.getStatus().intValue() != 2) {
  747 + logger.info("updateSettlementStatus end,status error changed,bo is {}",bo);
711 return; 748 return;
712 } 749 }
713 UnionShareSettlement unionShareSettlement = unionShareSettlementMapper.selectByCode(bo.getSettlementCode()); 750 UnionShareSettlement unionShareSettlement = unionShareSettlementMapper.selectByCode(bo.getSettlementCode());
714 if (unionShareSettlement == null) { 751 if (unionShareSettlement == null) {
  752 + logger.info("updateSettlementStatus end,settlementCode doesn't exist,bo is {}",bo);
  753 + return;
  754 + }
  755 + if (unionShareSettlement.getStatus().intValue()==2) {
  756 + //已更新,多余mq略过
  757 + logger.info("updateSettlementStatus end,status is already changed,bo is {}",bo);
715 return; 758 return;
716 } 759 }
717 //更新结算状态 760 //更新结算状态
@@ -207,6 +207,37 @@ @@ -207,6 +207,37 @@
207 </encoder> 207 </encoder>
208 </appender> 208 </appender>
209 209
  210 +
  211 + <!--联盟cps分享相关mq日志-->
  212 + <appender name="CPS_MQ" class="ch.qos.logback.core.rolling.RollingFileAppender">
  213 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  214 + <fileNamePattern>${catalina.home}/logs/%d{yyyy-MM-dd}/cps_mq.log</fileNamePattern>
  215 + <!-- 日志最大的保存天数 -->
  216 + <maxHistory>${maxHistory}</maxHistory>
  217 + </rollingPolicy>
  218 + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
  219 + <maxFileSize>${maxFileSize}</maxFileSize>
  220 + </triggeringPolicy>
  221 + <encoder>
  222 + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
  223 + </encoder>
  224 + </appender>
  225 +
  226 + <!--联盟cps分享提现日志-->
  227 + <appender name="CPS_SETTLEMENT" class="ch.qos.logback.core.rolling.RollingFileAppender">
  228 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  229 + <fileNamePattern>${catalina.home}/logs/%d{yyyy-MM-dd}/cps_settlement.log</fileNamePattern>
  230 + <!-- 日志最大的保存天数 -->
  231 + <maxHistory>${maxHistory}</maxHistory>
  232 + </rollingPolicy>
  233 + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
  234 + <maxFileSize>${maxFileSize}</maxFileSize>
  235 + </triggeringPolicy>
  236 + <encoder>
  237 + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
  238 + </encoder>
  239 + </appender>
  240 +
210 <!-- 数据库操作日志 --> 241 <!-- 数据库操作日志 -->
211 <logger name="java.sql.PreparedStatement" value="DEBUG" /> 242 <logger name="java.sql.PreparedStatement" value="DEBUG" />
212 <logger name="java.sql.Connection" value="DEBUG" /> 243 <logger name="java.sql.Connection" value="DEBUG" />
@@ -271,5 +302,11 @@ @@ -271,5 +302,11 @@
271 <logger name="pinyouPush" level="INFO" additivity="false"> 302 <logger name="pinyouPush" level="INFO" additivity="false">
272 <appender-ref ref="PINYOU_MATCH"/> 303 <appender-ref ref="PINYOU_MATCH"/>
273 </logger> 304 </logger>
  305 + <logger name="cps_mq" level="INFO" additivity="false">
  306 + <appender-ref ref="CPS_MQ"/>
  307 + </logger>
  308 + <logger name="cps_settlement" level="INFO" additivity="false">
  309 + <appender-ref ref="CPS_SETTLEMENT"/>
  310 + </logger>
274 311
275 </configuration> 312 </configuration>
@@ -259,6 +259,43 @@ @@ -259,6 +259,43 @@
259 </encoder> 259 </encoder>
260 </appender> 260 </appender>
261 261
  262 +
  263 + <!--联盟cps分享相关mq日志-->
  264 + <appender name="CPS_MQ" class="ch.qos.logback.core.rolling.RollingFileAppender">
  265 + <file>${yoho.logs.basedir}/${yoho.unions.env.namespace}/cps_mq.log</file>
  266 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  267 + <!-- daily rollover -->
  268 + <fileNamePattern>${yoho.logs.basedir}/${yoho.unions.env.namespace}/archived/cps_mq/cps_mq.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
  269 + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  270 + <!-- or whenever the file size reaches 100MB -->
  271 + <maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
  272 + </timeBasedFileNamingAndTriggeringPolicy>
  273 + <!-- keep 30 days' worth of history -->
  274 + <maxHistory>${yoho.logs.maxHistory}</maxHistory>
  275 + </rollingPolicy>
  276 + <encoder>
  277 + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
  278 + </encoder>
  279 + </appender>
  280 +
  281 + <!--联盟cps分享提现日志-->
  282 + <appender name="CPS_SETTLEMENT" class="ch.qos.logback.core.rolling.RollingFileAppender">
  283 + <file>${yoho.logs.basedir}/${yoho.unions.env.namespace}/cps_settlement.log</file>
  284 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  285 + <!-- daily rollover -->
  286 + <fileNamePattern>${yoho.logs.basedir}/${yoho.unions.env.namespace}/archived/cps_settlement/cps_settlement.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
  287 + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  288 + <!-- or whenever the file size reaches 100MB -->
  289 + <maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
  290 + </timeBasedFileNamingAndTriggeringPolicy>
  291 + <!-- keep 30 days' worth of history -->
  292 + <maxHistory>${yoho.logs.maxHistory}</maxHistory>
  293 + </rollingPolicy>
  294 + <encoder>
  295 + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
  296 + </encoder>
  297 + </appender>
  298 +
262 <!-- 数据库操作日志 --> 299 <!-- 数据库操作日志 -->
263 <logger name="java.sql.PreparedStatement" value="${yoho.logs.level}" /> 300 <logger name="java.sql.PreparedStatement" value="${yoho.logs.level}" />
264 <logger name="java.sql.Connection" value="${yoho.logs.level}" /> 301 <logger name="java.sql.Connection" value="${yoho.logs.level}" />
@@ -338,4 +375,11 @@ @@ -338,4 +375,11 @@
338 <logger name="pinyouPush" level="INFO" additivity="false"> 375 <logger name="pinyouPush" level="INFO" additivity="false">
339 <appender-ref ref="PINYOU_MATCH"/> 376 <appender-ref ref="PINYOU_MATCH"/>
340 </logger> 377 </logger>
  378 +
  379 + <logger name="cps_mq" level="INFO" additivity="false">
  380 + <appender-ref ref="CPS_MQ"/>
  381 + </logger>
  382 + <logger name="cps_settlement" level="INFO" additivity="false">
  383 + <appender-ref ref="CPS_SETTLEMENT"/>
  384 + </logger>
341 </configuration> 385 </configuration>