Showing
1 changed file
with
49 additions
and
0 deletions
order/src/main/java/com/yohoufo/order/service/handler/transfer/AlipayTransferChancelSelector.java
0 → 100644
1 | +package com.yohoufo.order.service.handler.transfer; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
4 | +import com.yoho.core.config.ConfigReader; | ||
5 | +import com.yohoufo.dal.order.model.OrdersPayTransfer; | ||
6 | +import lombok.extern.slf4j.Slf4j; | ||
7 | +import org.apache.commons.lang3.StringUtils; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.stereotype.Service; | ||
10 | + | ||
11 | +import java.text.SimpleDateFormat; | ||
12 | +import java.util.Date; | ||
13 | + | ||
14 | +@Slf4j | ||
15 | +@Service | ||
16 | +public class AlipayTransferChancelSelector { | ||
17 | + | ||
18 | + private volatile String lastTransferDate = null; | ||
19 | + | ||
20 | + @Autowired | ||
21 | + private ConfigReader configReader; | ||
22 | + | ||
23 | + public boolean isTransferWithAlipayExceedMillionTransfer() { | ||
24 | + boolean value = configReader.getBoolean("ufo.order.pay.exceedSwitch", false); | ||
25 | + if (value) { | ||
26 | + log.info("use exceed million ufo.order.pay.exceedSwitch={}", value); | ||
27 | + return true; | ||
28 | + } | ||
29 | + String nowDate = new SimpleDateFormat("yyyyMMdd").format(new Date()); | ||
30 | + return StringUtils.equals(lastTransferDate, nowDate); | ||
31 | + } | ||
32 | + | ||
33 | + public boolean isExceedMillion(JSONObject jsonObject) { | ||
34 | + // {"msg":"Business Failed","code":"40004","sub_msg":"单日最多可转100万元","sub_code":"EXCEED_LIMIT_DM_MAX_AMOUNT"} | ||
35 | + if (StringUtils.equals("40004", jsonObject.getString("code")) | ||
36 | + && StringUtils.equals("EXCEED_LIMIT_DM_MAX_AMOUNT", jsonObject.getString("sub_code"))) { | ||
37 | + lastTransferDate = new SimpleDateFormat("yyyyMMdd").format(new Date()); | ||
38 | + log.info("transferWhenExceedMillion 转账阿里接口返回 {},进入商家转账模式 lastTransferDate={}", jsonObject, lastTransferDate); | ||
39 | + return true; | ||
40 | + } | ||
41 | + return false; | ||
42 | + } | ||
43 | + | ||
44 | + public boolean isTransferWithAlipayExceedMillionTransfer(Integer interfaceType) { | ||
45 | + return OrdersPayTransfer.INTERFACE_TYPE_TRANSFER_WHEN_EXCEED_MILLION.equals(interfaceType); | ||
46 | + } | ||
47 | + | ||
48 | + | ||
49 | +} |
-
Please register or login to post a comment