Authored by Lixiaodi

转账上报信息修改

... ... @@ -15,22 +15,27 @@ import java.util.Map;
public enum TransferCase {
APPRAISE_SUCCESS(1),
APPRAISE_FAIL(2),
SELLER_PLAY_BUYER(3),
DELIVER_TIME_OUT(4),
BUYER_CANCEL_BEFORE_SELLER_DELIVER(5),
BUYER_CANCEL_BEFORE_DEPOT_RECEIVE(6);
APPRAISE_SUCCESS(1, "鉴定通过[货款->卖家]"),
APPRAISE_FAIL(2, "鉴定不通过[保证金->买家]"),
SELLER_PLAY_BUYER(3,"有买家时卖家不卖[保证金->买家]"),
DELIVER_TIME_OUT(4,"卖家超时发货[保证金->买家]"),
BUYER_CANCEL_BEFORE_SELLER_DELIVER(5,"卖家未发货时买家取消[部分货款->卖家]"),
BUYER_CANCEL_BEFORE_DEPOT_RECEIVE(6,"卖家已发货时买家取消[部分货款->卖家]");
private int code;
private String info;
TransferCase(int code) {
TransferCase(int code, String info) {
this.code = code;
this.info = info;
}
public int getCode() {
return code;
}
public String getInfo() {
return info;
}
private static Map<Integer, TransferCase> cache;
... ...
... ... @@ -624,11 +624,11 @@ public class PaymentServiceImpl implements IPaymentService {
transfer.setAlipayAccount(account.getAlipayAccount());
}
String alipayAccount = transfer.getAlipayAccount();
JSONObject jsonObject = null;
// 转账
try {
logger.info("transferMon开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", buyerOrderCode, alipayAccount, transferAmount);
JSONObject jsonObject = alipayService.transferMoney(Long.toString(buyerOrderCode), account.getAlipayId(), account.getAlipayAccount(), transferAmount);
jsonObject = alipayService.transferMoney(Long.toString(buyerOrderCode), account.getAlipayId(), account.getAlipayAccount(), transferAmount);
if (jsonObject == null) {
logger.warn("transferMonErr 转账失败 , orderCode is {}", buyerOrderCode);
transfer.setStatus(3);
... ... @@ -651,7 +651,12 @@ public class PaymentServiceImpl implements IPaymentService {
}
} catch (Exception e) {
logger.warn("transferMonErr 转账失败 , orderCode is {}, msg is {}", buyerOrderCode, e.getMessage());
alarm("转账失败", "ufo.order.transferMon", "订单号:" + buyerOrderCode + "操作类型(" + transferType + ")转账失败,msg=" + e.getMessage());
String alarmMsg = "订单号:" + buyerOrderCode + ",操作类型:" + transferCase.getInfo() + ",msg=" + e.getMessage();
if (jsonObject != null) {
alarmMsg += ",阿里返回DETAIL=" + jsonObject.toJSONString();
}
logger.info("transferMonErr 转账失败 , alarmMsg is {}", alarmMsg);
alarm("转账失败", "ufo.order.transferMon", alarmMsg);
transfer.setStatus(3);
if(e instanceof ServiceException) {
throw new ServiceException(((ServiceException) e).getCode(), e.getMessage());
... ... @@ -733,9 +738,10 @@ public class PaymentServiceImpl implements IPaymentService {
logger.info("transAllEarnest参数检查成功!");
// 转账
JSONObject jsonObject = null;
try {
logger.info("transAllEarnest开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", orderCode, alipayAccount, amount);
JSONObject jsonObject = alipayService.transferMoney(Long.toString(orderCode), alipayId, alipayAccount, amount);
jsonObject = alipayService.transferMoney(Long.toString(orderCode), alipayId, alipayAccount, amount);
if (jsonObject == null) {
logger.warn("transAllEarnestErr 转账失败 , orderCode is {}", orderCode);
transfer.setStatus(3);
... ... @@ -759,7 +765,12 @@ public class PaymentServiceImpl implements IPaymentService {
}
} catch (Exception e) {
logger.warn("transAllEarnestErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage());
alarm("转账失败", "ufo.order.transAllEarnest", "订单号:" + orderCode + "操作类型(" + 6 + ")转账失败,msg=" + e.getMessage());
String alarmMsg = "订单号:" + orderCode + ",操作类型(商家退出入驻退保证金),msg=" + e.getMessage();
if (jsonObject != null) {
alarmMsg += ",阿里返回DETAIL=" + jsonObject.toJSONString();
}
logger.info("transAllEarnestErr 转账失败 , alarmMsg is {}", alarmMsg);
alarm("转账失败", "ufo.order.transAllEarnest", alarmMsg);
transfer.setStatus(3);
if(e instanceof ServiceException) {
throw new ServiceException(((ServiceException) e).getCode(), e.getMessage());
... ... @@ -925,12 +936,13 @@ public class PaymentServiceImpl implements IPaymentService {
}
// '1:买家uid; 2:卖家uid','1:保证金;2:货款;3:补偿款', '1:用户收入; 2:用户支出'
PayRefundBo refundBo = null;
try {
if (/* 退货款 */((tradeBills.getUserType() == 1 && tradeBills.getTradeType() == 2 && tradeBills.getIncomeOutcome() == 1)
/* 退保证金(普通用户) */
|| (tradeBills.getUserType() == 2 && tradeBills.getTradeType() == 1 && tradeBills.getIncomeOutcome() == 1 && !isMerchantExit))) {
logger.warn("manualDeal人工退款 , tradeBills is {}", tradeBills);
PayRefundBo refundBo = manualRefund(orderCode, amount);
refundBo = manualRefund(orderCode, amount);
if (refundBo.getRefundStatus() == RefundContant.PAYMENT_REFUND_RESULTCODE_SUCCESS) {
// 加新流水
tradeBills.setDealRelateId(tradeBills.getId());
... ... @@ -945,8 +957,12 @@ public class PaymentServiceImpl implements IPaymentService {
}
} catch (Exception e) {
logger.warn("manualDealErr 退款失败 , tradeBillsId is {}, msg is {}", tradeBillsId, e.getMessage());
alarm("人工处理退款失败", "ufo.order.manualDeal",
"订单号:" + orderCode + "操作类型(退款)转账失败,流水id=" + tradeBillsId + ",msg=" + e.getMessage());
String alarmMsg = "订单号:" + orderCode + ",操作类型(退款),流水id=" + tradeBillsId + ",msg=" + e.getMessage();
if (refundBo != null) {
alarmMsg += ",DETAIL=" + JSON.toJSONString(refundBo);
}
logger.info("manualDealErr 退款失败 , alarmMsg is {}", alarmMsg);
alarm("人工处理退款失败", "ufo.order.manualDeal", alarmMsg );
preSuccess.setDealStatus(0);
tradeBillsMapper.updateToFailByPrimaryKey(preSuccess);
if (e instanceof ServiceException) {
... ... @@ -955,6 +971,7 @@ public class PaymentServiceImpl implements IPaymentService {
throw new ServiceException(500, "退款失败id=" + tradeBillsId);
}
}
JSONObject jsonObject = null;
try {
OrdersPayTransfer transfer = ordersPayTransferMapper.selectByBuyerOrderCode(orderCode);
if (transfer == null) {
... ... @@ -964,7 +981,7 @@ public class PaymentServiceImpl implements IPaymentService {
throw new ServiceException(400, "转账记录已成功转账,流水id=" + tradeBillsId);
}
JSONObject jsonObject = alipayService.transferMoney(Long.toString(orderCode), account.getAlipayId(), account.getAlipayAccount(), amount);
jsonObject = alipayService.transferMoney(Long.toString(orderCode), account.getAlipayId(), account.getAlipayAccount(), amount);
if (jsonObject == null) {
logger.warn("manualDeal 转账失败 , req is {}", req);
throw new ServiceException(500, "转账失败:阿里接口返回null");
... ... @@ -991,8 +1008,12 @@ public class PaymentServiceImpl implements IPaymentService {
}
} catch (Exception e) {
logger.warn("manualDealErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage());
alarm("人工处理转账失败", "ufo.order.manualDeal",
"订单号:" + orderCode + "操作类型(退款)转账失败,流水id=" + tradeBillsId + ",msg=" + e.getMessage());
String alarmMsg = "订单号:" + orderCode + ",操作类型(转账),流水id=" + tradeBillsId + ",msg=" + e.getMessage();
if (jsonObject != null) {
alarmMsg += ",阿里返回DETAIL=" + jsonObject.toJSONString();
}
logger.info("manualDealErr 转账失败 , alarmMsg is {}", alarmMsg);
alarm("人工处理转账失败", "ufo.order.manualDeal", alarmMsg);
preSuccess.setDealStatus(0);
tradeBillsMapper.updateToFailByPrimaryKey(preSuccess);
if (e instanceof ServiceException) {
... ...
... ... @@ -138,11 +138,12 @@ public abstract class AlipayServiceAbstract extends AbstractPayService {
* @param alipayAccount
* @param transferAmount
* @return
* @throws Exception
*/
public JSONObject transferMoney(String transferOrderCode, String alipayUid, String alipayAccount, BigDecimal transferAmount){
public JSONObject transferMoney(String transferOrderCode, String alipayUid, String alipayAccount, BigDecimal transferAmount) throws Exception{
Map<String, String> queryParams = buildTransferParams(transferOrderCode, alipayUid, alipayAccount, transferAmount);
String respTxt = sendOpenApiRequest(transferOrderCode, queryParams);
String respTxt = sendOpenApiRequestWithException(transferOrderCode, queryParams);
JSONObject result = null;
... ... @@ -173,6 +174,13 @@ public abstract class AlipayServiceAbstract extends AbstractPayService {
logger.info("[{}] trade openapi resp: {}", orderCode, response);
return response;
}
private String sendOpenApiRequestWithException(String orderCode, Map<String, String> paramMap) throws Exception {
logger.info("[{}] send openapi request: {}", orderCode, paramMap);
String response = httpClient.postFormData(AlipayConfig.OPENAPI_URL, paramMap);
logger.info("[{}] trade openapi resp: {}", orderCode, response);
return response;
}
private PayQueryBo queryOpenApiConvert(String orderCode, String respText) {
... ...