Authored by mingdan.ge

提现日志+cps相关mq日志

... ... @@ -17,7 +17,7 @@ import java.util.List;
@Component
public class UnionSettleUpdateConsumer implements YhConsumer {
private Logger logger = LoggerFactory.getLogger(UnionSettleUpdateConsumer.class);
private Logger logger = LoggerFactory.getLogger("cps_mq");
@Autowired
private IUnionShareService unionShareService;
... ...
... ... @@ -17,7 +17,7 @@ import java.util.List;
@Component
public class UnionShareOrderConsumer implements YhConsumer {
private Logger logger = LoggerFactory.getLogger(UnionShareOrderConsumer.class);
private Logger logger = LoggerFactory.getLogger("cps_mq");
@Autowired
private IUnionShareService unionShareService;
... ...
... ... @@ -34,6 +34,8 @@ public class UnionShareRest {
private static Logger log = LoggerFactory.getLogger(UnionShareRest.class);
private static Logger mqlog = LoggerFactory.getLogger("cps_mq");
@Autowired
IUnionShareService unionShareService;
... ... @@ -148,7 +150,7 @@ public class UnionShareRest {
@RequestMapping("/mqUnionShareOrder")
@ResponseBody
public UnionResponse mqUnionShareOrder(@RequestBody List<ShareOrderBo> list){
log.info("UnionShareRest.mqUnionShareOrder req is {}", JsonUtil.objectToJSON(list));
mqlog.info("UnionShareRest.mqUnionShareOrder req is {}", JsonUtil.objectToJSON(list));
try {
if (null == list) {
return new UnionResponse(500, "mqUnionShareOrder error,req is null");
... ... @@ -159,11 +161,11 @@ public class UnionShareRest {
//订单插入或更新
unionShareService.saveOrUpdateOrder(l);
} catch (Exception e) {
log.info("UnionShareRest.mqUnionShareOrder fail! bo is {}, e {}", l,e.getMessage());
mqlog.info("UnionShareRest.mqUnionShareOrder fail! bo is {}, e {}", l,e.getMessage());
}
});
} catch (Exception e) {
log.info("UnionShareRest.mqUnionShareOrder fail! str is {}, e {}",JsonUtil.objectToJSON(list),e.getMessage());
mqlog.warn("UnionShareRest.mqUnionShareOrder fail! str is {}, e {}",JsonUtil.objectToJSON(list),e.getMessage());
}
return new UnionResponse(200, "mqUnionShareOrder success");
}
... ... @@ -171,7 +173,7 @@ public class UnionShareRest {
@RequestMapping("/mqUnionSettleUpdate")
@ResponseBody
public UnionResponse mqUnionSettleUpdate(@RequestBody ShareSettlementBo bo){
log.info("UnionShareRest.mqUnionSettleUpdate req is {}", bo);
mqlog.info("UnionShareRest.mqUnionSettleUpdate req is {}", bo);
try {
if (null == bo) {
return new UnionResponse(500, "mqUnionSettleUpdate error,req is null");
... ... @@ -180,7 +182,7 @@ public class UnionShareRest {
unionShareService.updateSettlementStatus(bo);
} catch (Exception e) {
log.info("UnionShareRest.mqUnionSettleUpdate fail! req is {}, e {}", bo,e.getMessage());
mqlog.warn("UnionShareRest.mqUnionSettleUpdate fail! req is {}, e {}", bo,e.getMessage());
}
return new UnionResponse(200, "mqUnionSettleUpdate success");
}
... ...
... ... @@ -50,6 +50,9 @@ import java.util.concurrent.atomic.AtomicInteger;
@Service
public class UnionShareServiceImpl implements IUnionShareService,IBusinessExportService {
private Logger logger = LoggerFactory.getLogger(UnionShareServiceImpl.class);
private Logger mqLog = LoggerFactory.getLogger("cps_mq");
private Logger settlementLog = LoggerFactory.getLogger("cps_settlement");
// private Logger mqLog = LoggerFactory.getLogger("cps_mq");
@Autowired
private UnionShareOrdersMapper unionShareOrdersMapper;
... ... @@ -516,7 +519,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
*/
@Override
public BigDecimal addSettlement(Integer uid) {
logger.info("addSettlement enter,uid is {}",uid);
settlementLog.info("addSettlement enter,uid is {}",uid);
if (uid == null ) {
throw new ServiceException(ServiceError.USER_ID_ERROR);
}
... ... @@ -524,13 +527,13 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
int count = unionShareUserMapper.selectCountByUid(uid);
if (count == 0) {
//不是特邀用户
logger.info("addSettlement end,can not find unionType,uid is {}",uid);
settlementLog.info("addSettlement end,can not find unionType,uid is {}",uid);
throw new ServiceException(ServiceError.USER_ID_ERROR);
}
//查询是否有处理中的提现
if (hasSettlement(uid)) {
//有处理中的提现单,不可提现
logger.info("addSettlement end,hasSettlement,uid is {}",uid);
settlementLog.info("addSettlement end,hasSettlement,uid is {}",uid);
throw new ServiceException(ServiceError.UNION_HASSETTLEMENT_ERROR);
}
... ... @@ -538,12 +541,12 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
int orderCount = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.CAN_SETTLE.getCode());
if (orderCount == 0 ) {
//没有可以提现的订单
logger.info("addSettlement end,has not remaining settlement,uid is {}",uid);
settlementLog.info("addSettlement end,has not remaining settlement,uid is {}",uid);
throw new ServiceException(ServiceError.UNION_HASNOT_REMAINING_SETTLEMENT);
}
// 生成取现单,绑定订单
BigDecimal amount = relateSettlementAndOrder(uid);
logger.info("addSettlement end,remaining settlement is {},uid is {}",amount,uid);
settlementLog.info("addSettlement end,remaining settlement is {},uid is {}",amount,uid);
return amount;
}
... ... @@ -632,22 +635,22 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
* */
public BigDecimal relateSettlementAndOrder(int uid) {
logger.info("relateSettlementAndOrder enter,uid is {}",uid);
settlementLog.info("relateSettlementAndOrder enter,uid is {}",uid);
//生成提现编号
String settlementCode = createSettlementCode();
logger.info("relateSettlementAndOrder,uid is {},settlementCode is {}",uid,settlementCode);
settlementLog.info("relateSettlementAndOrder,uid is {},settlementCode is {}",uid,settlementCode);
//更新订单状态,由可结算变为打款中
int updateTime = DateUtil.getCurrentTimeSecond();
int count=unionShareOrdersMapper.updateStatusByUid(uid,settlementCode, ShareOrdersStatusEnum.CAN_SETTLE.getCode(), ShareOrdersStatusEnum.SETTLE.getCode(), updateTime);
if (count == 0) {
logger.info("relateSettlementAndOrder end,uid is {},settlementCode is {},There are no available orders.",uid,settlementCode);
settlementLog.info("relateSettlementAndOrder end,uid is {},settlementCode is {},There are no available orders.",uid,settlementCode);
throw new ServiceException(ServiceError.UNION_SETTLEMENT_UNAVAILABLE_ORDER_ERROR);
}
//计算提现金额
BigDecimal totalAmount=unionShareOrdersMapper.selectAmountBySettleCode(uid, settlementCode);
logger.info("relateSettlementAndOrder,uid is {},settlementCode is {},totalAmount is {}",uid,settlementCode,totalAmount);
settlementLog.info("relateSettlementAndOrder,uid is {},settlementCode is {},totalAmount is {}",uid,settlementCode,totalAmount);
//生成提现单
UnionShareSettlement insertReq = new UnionShareSettlement();
... ... @@ -660,7 +663,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
int num=unionShareSettlementMapper.insertSelective(insertReq);
if (num < 1) {
//插入失败 todo 日志记录
logger.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},insert nothing.",uid,settlementCode,totalAmount);
settlementLog.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},insert nothing.",uid,settlementCode,totalAmount);
}
Set<String> orderCodes = new HashSet<>();
... ... @@ -676,7 +679,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
if (orderCodes.size() == 0) {
//不该查不到订单
logger.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},can not find orders.",uid,settlementCode,totalAmount);
settlementLog.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},can not find orders.",uid,settlementCode,totalAmount);
throw new ServiceException(ServiceError.UNION_SETTLEMENT_CANNOT_FIND_ORDER_ERROR);
}
... ... @@ -688,8 +691,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
ShareSettlementBo bo = new ShareSettlementBo();
BeanUtils.copyProperties(insertReq,bo);
bo.setOrderCodes(orderCodes);
logger.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
mqLog.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
yhProducer.send(SETTLEMENT_TOPIC, bo);
settlementLog.info("relateSettlementAndOrder,send mq {} to erp success,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
return totalAmount;
}
... ...
... ... @@ -207,6 +207,37 @@
</encoder>
</appender>
<!--联盟cps分享相关mq日志-->
<appender name="CPS_MQ" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${catalina.home}/logs/%d{yyyy-MM-dd}/cps_mq.log</fileNamePattern>
<!-- 日志最大的保存天数 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>${maxFileSize}</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
</encoder>
</appender>
<!--联盟cps分享提现日志-->
<appender name="CPS_SETTLEMENT" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${catalina.home}/logs/%d{yyyy-MM-dd}/cps_settlement.log</fileNamePattern>
<!-- 日志最大的保存天数 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>${maxFileSize}</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- 数据库操作日志 -->
<logger name="java.sql.PreparedStatement" value="DEBUG" />
<logger name="java.sql.Connection" value="DEBUG" />
... ... @@ -271,5 +302,11 @@
<logger name="pinyouPush" level="INFO" additivity="false">
<appender-ref ref="PINYOU_MATCH"/>
</logger>
<logger name="cps_mq" level="INFO" additivity="false">
<appender-ref ref="CPS_MQ"/>
</logger>
<logger name="cps_settlement" level="INFO" additivity="false">
<appender-ref ref="CPS_SETTLEMENT"/>
</logger>
</configuration>
\ No newline at end of file
... ...
... ... @@ -259,6 +259,43 @@
</encoder>
</appender>
<!--联盟cps分享相关mq日志-->
<appender name="CPS_MQ" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${yoho.logs.basedir}/${yoho.unions.env.namespace}/cps_mq.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${yoho.logs.basedir}/${yoho.unions.env.namespace}/archived/cps_mq/cps_mq.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days' worth of history -->
<maxHistory>${yoho.logs.maxHistory}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
</encoder>
</appender>
<!--联盟cps分享提现日志-->
<appender name="CPS_SETTLEMENT" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${yoho.logs.basedir}/${yoho.unions.env.namespace}/cps_settlement.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${yoho.logs.basedir}/${yoho.unions.env.namespace}/archived/cps_settlement/cps_settlement.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days' worth of history -->
<maxHistory>${yoho.logs.maxHistory}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- 数据库操作日志 -->
<logger name="java.sql.PreparedStatement" value="${yoho.logs.level}" />
<logger name="java.sql.Connection" value="${yoho.logs.level}" />
... ... @@ -338,4 +375,11 @@
<logger name="pinyouPush" level="INFO" additivity="false">
<appender-ref ref="PINYOU_MATCH"/>
</logger>
<logger name="cps_mq" level="INFO" additivity="false">
<appender-ref ref="CPS_MQ"/>
</logger>
<logger name="cps_settlement" level="INFO" additivity="false">
<appender-ref ref="CPS_SETTLEMENT"/>
</logger>
</configuration>
\ No newline at end of file
... ...