Authored by mingdan.ge

提现日志+cps相关mq日志

@@ -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;
@@ -34,6 +34,8 @@ public class UnionShareRest { @@ -34,6 +34,8 @@ public class UnionShareRest {
34 34
35 private static Logger log = LoggerFactory.getLogger(UnionShareRest.class); 35 private static Logger log = LoggerFactory.getLogger(UnionShareRest.class);
36 36
  37 + private static Logger mqlog = LoggerFactory.getLogger("cps_mq");
  38 +
37 @Autowired 39 @Autowired
38 IUnionShareService unionShareService; 40 IUnionShareService unionShareService;
39 41
@@ -148,7 +150,7 @@ public class UnionShareRest { @@ -148,7 +150,7 @@ public class UnionShareRest {
148 @RequestMapping("/mqUnionShareOrder") 150 @RequestMapping("/mqUnionShareOrder")
149 @ResponseBody 151 @ResponseBody
150 public UnionResponse mqUnionShareOrder(@RequestBody List<ShareOrderBo> list){ 152 public UnionResponse mqUnionShareOrder(@RequestBody List<ShareOrderBo> list){
151 - log.info("UnionShareRest.mqUnionShareOrder req is {}", JsonUtil.objectToJSON(list)); 153 + mqlog.info("UnionShareRest.mqUnionShareOrder req is {}", JsonUtil.objectToJSON(list));
152 try { 154 try {
153 if (null == list) { 155 if (null == list) {
154 return new UnionResponse(500, "mqUnionShareOrder error,req is null"); 156 return new UnionResponse(500, "mqUnionShareOrder error,req is null");
@@ -159,11 +161,11 @@ public class UnionShareRest { @@ -159,11 +161,11 @@ public class UnionShareRest {
159 //订单插入或更新 161 //订单插入或更新
160 unionShareService.saveOrUpdateOrder(l); 162 unionShareService.saveOrUpdateOrder(l);
161 } catch (Exception e) { 163 } catch (Exception e) {
162 - log.info("UnionShareRest.mqUnionShareOrder fail! bo is {}, e {}", l,e.getMessage()); 164 + mqlog.info("UnionShareRest.mqUnionShareOrder fail! bo is {}, e {}", l,e.getMessage());
163 } 165 }
164 }); 166 });
165 } catch (Exception e) { 167 } catch (Exception e) {
166 - log.info("UnionShareRest.mqUnionShareOrder fail! str is {}, e {}",JsonUtil.objectToJSON(list),e.getMessage()); 168 + mqlog.warn("UnionShareRest.mqUnionShareOrder fail! str is {}, e {}",JsonUtil.objectToJSON(list),e.getMessage());
167 } 169 }
168 return new UnionResponse(200, "mqUnionShareOrder success"); 170 return new UnionResponse(200, "mqUnionShareOrder success");
169 } 171 }
@@ -171,7 +173,7 @@ public class UnionShareRest { @@ -171,7 +173,7 @@ public class UnionShareRest {
171 @RequestMapping("/mqUnionSettleUpdate") 173 @RequestMapping("/mqUnionSettleUpdate")
172 @ResponseBody 174 @ResponseBody
173 public UnionResponse mqUnionSettleUpdate(@RequestBody ShareSettlementBo bo){ 175 public UnionResponse mqUnionSettleUpdate(@RequestBody ShareSettlementBo bo){
174 - log.info("UnionShareRest.mqUnionSettleUpdate req is {}", bo); 176 + mqlog.info("UnionShareRest.mqUnionSettleUpdate req is {}", bo);
175 try { 177 try {
176 if (null == bo) { 178 if (null == bo) {
177 return new UnionResponse(500, "mqUnionSettleUpdate error,req is null"); 179 return new UnionResponse(500, "mqUnionSettleUpdate error,req is null");
@@ -180,7 +182,7 @@ public class UnionShareRest { @@ -180,7 +182,7 @@ public class UnionShareRest {
180 unionShareService.updateSettlementStatus(bo); 182 unionShareService.updateSettlementStatus(bo);
181 183
182 } catch (Exception e) { 184 } catch (Exception e) {
183 - log.info("UnionShareRest.mqUnionSettleUpdate fail! req is {}, e {}", bo,e.getMessage()); 185 + mqlog.warn("UnionShareRest.mqUnionSettleUpdate fail! req is {}, e {}", bo,e.getMessage());
184 } 186 }
185 return new UnionResponse(200, "mqUnionSettleUpdate success"); 187 return new UnionResponse(200, "mqUnionSettleUpdate success");
186 } 188 }
@@ -50,6 +50,9 @@ import java.util.concurrent.atomic.AtomicInteger; @@ -50,6 +50,9 @@ import java.util.concurrent.atomic.AtomicInteger;
50 @Service 50 @Service
51 public class UnionShareServiceImpl implements IUnionShareService,IBusinessExportService { 51 public class UnionShareServiceImpl implements IUnionShareService,IBusinessExportService {
52 private Logger logger = LoggerFactory.getLogger(UnionShareServiceImpl.class); 52 private Logger logger = LoggerFactory.getLogger(UnionShareServiceImpl.class);
  53 + private Logger mqLog = LoggerFactory.getLogger("cps_mq");
  54 + private Logger settlementLog = LoggerFactory.getLogger("cps_settlement");
  55 +// private Logger mqLog = LoggerFactory.getLogger("cps_mq");
53 56
54 @Autowired 57 @Autowired
55 private UnionShareOrdersMapper unionShareOrdersMapper; 58 private UnionShareOrdersMapper unionShareOrdersMapper;
@@ -516,7 +519,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -516,7 +519,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
516 */ 519 */
517 @Override 520 @Override
518 public BigDecimal addSettlement(Integer uid) { 521 public BigDecimal addSettlement(Integer uid) {
519 - logger.info("addSettlement enter,uid is {}",uid); 522 + settlementLog.info("addSettlement enter,uid is {}",uid);
520 if (uid == null ) { 523 if (uid == null ) {
521 throw new ServiceException(ServiceError.USER_ID_ERROR); 524 throw new ServiceException(ServiceError.USER_ID_ERROR);
522 } 525 }
@@ -524,13 +527,13 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -524,13 +527,13 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
524 int count = unionShareUserMapper.selectCountByUid(uid); 527 int count = unionShareUserMapper.selectCountByUid(uid);
525 if (count == 0) { 528 if (count == 0) {
526 //不是特邀用户 529 //不是特邀用户
527 - logger.info("addSettlement end,can not find unionType,uid is {}",uid); 530 + settlementLog.info("addSettlement end,can not find unionType,uid is {}",uid);
528 throw new ServiceException(ServiceError.USER_ID_ERROR); 531 throw new ServiceException(ServiceError.USER_ID_ERROR);
529 } 532 }
530 //查询是否有处理中的提现 533 //查询是否有处理中的提现
531 if (hasSettlement(uid)) { 534 if (hasSettlement(uid)) {
532 //有处理中的提现单,不可提现 535 //有处理中的提现单,不可提现
533 - logger.info("addSettlement end,hasSettlement,uid is {}",uid); 536 + settlementLog.info("addSettlement end,hasSettlement,uid is {}",uid);
534 throw new ServiceException(ServiceError.UNION_HASSETTLEMENT_ERROR); 537 throw new ServiceException(ServiceError.UNION_HASSETTLEMENT_ERROR);
535 } 538 }
536 539
@@ -538,12 +541,12 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -538,12 +541,12 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
538 int orderCount = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.CAN_SETTLE.getCode()); 541 int orderCount = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.CAN_SETTLE.getCode());
539 if (orderCount == 0 ) { 542 if (orderCount == 0 ) {
540 //没有可以提现的订单 543 //没有可以提现的订单
541 - logger.info("addSettlement end,has not remaining settlement,uid is {}",uid); 544 + settlementLog.info("addSettlement end,has not remaining settlement,uid is {}",uid);
542 throw new ServiceException(ServiceError.UNION_HASNOT_REMAINING_SETTLEMENT); 545 throw new ServiceException(ServiceError.UNION_HASNOT_REMAINING_SETTLEMENT);
543 } 546 }
544 // 生成取现单,绑定订单 547 // 生成取现单,绑定订单
545 BigDecimal amount = relateSettlementAndOrder(uid); 548 BigDecimal amount = relateSettlementAndOrder(uid);
546 - logger.info("addSettlement end,remaining settlement is {},uid is {}",amount,uid); 549 + settlementLog.info("addSettlement end,remaining settlement is {},uid is {}",amount,uid);
547 return amount; 550 return amount;
548 } 551 }
549 552
@@ -632,22 +635,22 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -632,22 +635,22 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
632 * */ 635 * */
633 public BigDecimal relateSettlementAndOrder(int uid) { 636 public BigDecimal relateSettlementAndOrder(int uid) {
634 637
635 - logger.info("relateSettlementAndOrder enter,uid is {}",uid); 638 + settlementLog.info("relateSettlementAndOrder enter,uid is {}",uid);
636 639
637 //生成提现编号 640 //生成提现编号
638 String settlementCode = createSettlementCode(); 641 String settlementCode = createSettlementCode();
639 - logger.info("relateSettlementAndOrder,uid is {},settlementCode is {}",uid,settlementCode); 642 + settlementLog.info("relateSettlementAndOrder,uid is {},settlementCode is {}",uid,settlementCode);
640 643
641 //更新订单状态,由可结算变为打款中 644 //更新订单状态,由可结算变为打款中
642 int updateTime = DateUtil.getCurrentTimeSecond(); 645 int updateTime = DateUtil.getCurrentTimeSecond();
643 int count=unionShareOrdersMapper.updateStatusByUid(uid,settlementCode, ShareOrdersStatusEnum.CAN_SETTLE.getCode(), ShareOrdersStatusEnum.SETTLE.getCode(), updateTime); 646 int count=unionShareOrdersMapper.updateStatusByUid(uid,settlementCode, ShareOrdersStatusEnum.CAN_SETTLE.getCode(), ShareOrdersStatusEnum.SETTLE.getCode(), updateTime);
644 if (count == 0) { 647 if (count == 0) {
645 - logger.info("relateSettlementAndOrder end,uid is {},settlementCode is {},There are no available orders.",uid,settlementCode); 648 + settlementLog.info("relateSettlementAndOrder end,uid is {},settlementCode is {},There are no available orders.",uid,settlementCode);
646 throw new ServiceException(ServiceError.UNION_SETTLEMENT_UNAVAILABLE_ORDER_ERROR); 649 throw new ServiceException(ServiceError.UNION_SETTLEMENT_UNAVAILABLE_ORDER_ERROR);
647 } 650 }
648 //计算提现金额 651 //计算提现金额
649 BigDecimal totalAmount=unionShareOrdersMapper.selectAmountBySettleCode(uid, settlementCode); 652 BigDecimal totalAmount=unionShareOrdersMapper.selectAmountBySettleCode(uid, settlementCode);
650 - logger.info("relateSettlementAndOrder,uid is {},settlementCode is {},totalAmount is {}",uid,settlementCode,totalAmount); 653 + settlementLog.info("relateSettlementAndOrder,uid is {},settlementCode is {},totalAmount is {}",uid,settlementCode,totalAmount);
651 654
652 //生成提现单 655 //生成提现单
653 UnionShareSettlement insertReq = new UnionShareSettlement(); 656 UnionShareSettlement insertReq = new UnionShareSettlement();
@@ -660,7 +663,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -660,7 +663,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
660 int num=unionShareSettlementMapper.insertSelective(insertReq); 663 int num=unionShareSettlementMapper.insertSelective(insertReq);
661 if (num < 1) { 664 if (num < 1) {
662 //插入失败 todo 日志记录 665 //插入失败 todo 日志记录
663 - logger.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},insert nothing.",uid,settlementCode,totalAmount); 666 + settlementLog.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},insert nothing.",uid,settlementCode,totalAmount);
664 } 667 }
665 668
666 Set<String> orderCodes = new HashSet<>(); 669 Set<String> orderCodes = new HashSet<>();
@@ -676,7 +679,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -676,7 +679,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
676 } 679 }
677 if (orderCodes.size() == 0) { 680 if (orderCodes.size() == 0) {
678 //不该查不到订单 681 //不该查不到订单
679 - logger.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},can not find orders.",uid,settlementCode,totalAmount); 682 + settlementLog.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},can not find orders.",uid,settlementCode,totalAmount);
680 throw new ServiceException(ServiceError.UNION_SETTLEMENT_CANNOT_FIND_ORDER_ERROR); 683 throw new ServiceException(ServiceError.UNION_SETTLEMENT_CANNOT_FIND_ORDER_ERROR);
681 } 684 }
682 685
@@ -688,8 +691,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -688,8 +691,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
688 ShareSettlementBo bo = new ShareSettlementBo(); 691 ShareSettlementBo bo = new ShareSettlementBo();
689 BeanUtils.copyProperties(insertReq,bo); 692 BeanUtils.copyProperties(insertReq,bo);
690 bo.setOrderCodes(orderCodes); 693 bo.setOrderCodes(orderCodes);
691 - logger.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo); 694 + mqLog.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
692 yhProducer.send(SETTLEMENT_TOPIC, bo); 695 yhProducer.send(SETTLEMENT_TOPIC, bo);
  696 + settlementLog.info("relateSettlementAndOrder,send mq {} to erp success,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
693 return totalAmount; 697 return totalAmount;
694 } 698 }
695 699
@@ -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>