...
|
...
|
@@ -4,90 +4,63 @@ import com.yohoufo.common.alarm.EventBusPublisher; |
|
|
import com.yohoufo.common.alarm.SmsAlarmEvent;
|
|
|
import com.yohoufo.order.common.TransferCase;
|
|
|
import com.yohoufo.order.constants.AlarmConfig;
|
|
|
import com.yohoufo.order.event.BillLogEvent;
|
|
|
import com.yohoufo.order.model.request.TransferMoneyRequest;
|
|
|
import com.yohoufo.order.service.IPaymentService;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* Created by chenchao on 2018/10/16.
|
|
|
*/
|
|
|
@Service
|
|
|
public class TransferService {
|
|
|
|
|
|
private final Logger closeLogger = LoggerUtils.getOrderCloseLogger();
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
|
private IPaymentService paymentService;
|
|
|
|
|
|
public boolean transfer(TransferMoneyRequest req){
|
|
|
public boolean transfer(TransferMoneyRequest req) {
|
|
|
logger.info("in transfer, req is {}", req);
|
|
|
TransferCase transferCase = req.getTransferCase();
|
|
|
|
|
|
if (transferCase == null){
|
|
|
if (transferCase == null) {
|
|
|
return true;
|
|
|
}
|
|
|
boolean transferFlag=true;
|
|
|
try{
|
|
|
boolean transferFlag = true;
|
|
|
try {
|
|
|
paymentService.transferMon(req);
|
|
|
}catch (Exception ex){
|
|
|
} catch (Exception ex) {
|
|
|
transferFlag = false;
|
|
|
logger.warn("in transfer, transfer fail,req {}", req, ex);
|
|
|
|
|
|
SmsAlarmEvent smsAlarmEvent = getSmsAlarmEvent(req, transferCase);
|
|
|
EventBusPublisher.publishEvent(smsAlarmEvent);
|
|
|
}
|
|
|
return transferFlag;
|
|
|
}
|
|
|
|
|
|
SmsAlarmEvent getSmsAlarmEvent(TransferMoneyRequest req, TransferCase transferCase){
|
|
|
String content;
|
|
|
SmsAlarmEvent smsAlarmEvent;
|
|
|
AlarmConfig alarmConfig ;
|
|
|
switch (transferCase){
|
|
|
case APPRAISE_SUCCESS:
|
|
|
content = "鉴定通过时,订单"+ req.getBuyerOrderCode() + "货款分账失败";
|
|
|
alarmConfig = AlarmConfig.APPRAISE_SUCCESS;
|
|
|
|
|
|
break;
|
|
|
|
|
|
SmsAlarmEvent getSmsAlarmEvent(TransferMoneyRequest req, TransferCase transferCase) {
|
|
|
AlarmConfig alarmConfig = req.getAlarmConfig();
|
|
|
if (Objects.isNull(alarmConfig)) {
|
|
|
switch (transferCase) {
|
|
|
case APPRAISE_FAIL:
|
|
|
content = "鉴定不通过时,订单"+ req.getBuyerOrderCode() + "保证金分账失败";
|
|
|
alarmConfig = AlarmConfig.APPRAISE_FAIL;
|
|
|
break;
|
|
|
|
|
|
case SELLER_PLAY_BUYER:
|
|
|
closeLogger.warn("in cancelAfterPayExistBuyAction , transfer fail,req {}", req);
|
|
|
content = "卖家取消,订单"+ req.getBuyerOrderCode() + "保证金分账失败";
|
|
|
alarmConfig = AlarmConfig.SELLER_PLAY_BUYER;
|
|
|
break;
|
|
|
|
|
|
|
|
|
case DELIVER_TIME_OUT:
|
|
|
closeLogger.warn("in deliver timeout , transfer fail,req {}", req);
|
|
|
content = "卖家发货超时,订单"+ req.getBuyerOrderCode() + "保证金分账失败";
|
|
|
alarmConfig = AlarmConfig.DELIVER_TIME_OUT;
|
|
|
break;
|
|
|
|
|
|
case CS_CANCEL_BEFORE_DEPOT_RECEIVE:
|
|
|
closeLogger.warn("in deliver timeout , transfer fail,req {}", req);
|
|
|
content = "鉴定中心收货前客服取消,订单"+ req.getBuyerOrderCode() + "保证金分账失败";
|
|
|
alarmConfig = AlarmConfig.CS_CANCEL_BEFORE_DEPOT_RECEIVE;
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getTransferName(), alarmConfig.name(), content);
|
|
|
return smsAlarmEvent;
|
|
|
}
|
|
|
|
|
|
if (Objects.nonNull(alarmConfig)) {
|
|
|
String content = alarmConfig.getDesc() + "分账失败,订单" + req.getBuyerOrderCode();
|
|
|
return new SmsAlarmEvent(alarmConfig.getTransferName(), alarmConfig.name(), content);
|
|
|
} else {
|
|
|
String content = "买家订单分账失败,订单" + req.getBuyerOrderCode();
|
|
|
return new SmsAlarmEvent("buyerOrder.transfer", "transfer", content);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|