|
|
package com.yohoufo.order.service.handler.transfer;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.core.config.ConfigReader;
|
|
|
import com.yohoufo.dal.order.model.OrdersPayTransfer;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class AlipayTransferChancelSelector {
|
|
|
|
|
|
private volatile String lastTransferDate = null;
|
|
|
|
|
|
@Autowired
|
|
|
private ConfigReader configReader;
|
|
|
|
|
|
public boolean isTransferWithAlipayExceedMillionTransfer() {
|
|
|
boolean value = configReader.getBoolean("ufo.order.pay.exceedSwitch", false);
|
|
|
if (value) {
|
|
|
log.info("use exceed million ufo.order.pay.exceedSwitch={}", value);
|
|
|
return true;
|
|
|
}
|
|
|
String nowDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
|
|
return StringUtils.equals(lastTransferDate, nowDate);
|
|
|
}
|
|
|
|
|
|
public boolean isExceedMillion(JSONObject jsonObject) {
|
|
|
// {"msg":"Business Failed","code":"40004","sub_msg":"单日最多可转100万元","sub_code":"EXCEED_LIMIT_DM_MAX_AMOUNT"}
|
|
|
if (StringUtils.equals("40004", jsonObject.getString("code"))
|
|
|
&& StringUtils.equals("EXCEED_LIMIT_DM_MAX_AMOUNT", jsonObject.getString("sub_code"))) {
|
|
|
lastTransferDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
|
|
log.info("transferWhenExceedMillion 转账阿里接口返回 {},进入商家转账模式 lastTransferDate={}", jsonObject, lastTransferDate);
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
public boolean isTransferWithAlipayExceedMillionTransfer(Integer interfaceType) {
|
|
|
return OrdersPayTransfer.INTERFACE_TYPE_TRANSFER_WHEN_EXCEED_MILLION.equals(interfaceType);
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|