银生宝代付和网关渠道

1、Channels.java

增加银生宝支付通道
UNSPAY(10018,"10018","银生宝");

2、channel-unspay.peoperties

增加url相关配置 代付和网关
MP\:CLOUD\:TRADE\:UNSPAY\:TRADE-ORDERQUERY\:TIME=120000,300000,600000,900000,1800000

cloud.unspay.pay.url=http://180.166.114.155/unspay/

cloud.unspay.withdraw.url=http://180.166.114.155:7181/delegate-pay-front-dp/delegatePay/

cloud.unspay.withdraw.timeout=10000

银生宝查询请求地址
cloud.unspay.gateway.qry.url = http://180.166.114.155/unspay/page/linkbank/netQueryTransStatus.action

银生宝支付请求地址
cloud.unspay.gateway.pay.url = http://180.166.114.155/unspay/page/linkbank/payRequest.do

银生宝退款请求地址
cloud.unspay.gateway.return.url = http://180.166.114.155/unspay/page/netreturn/netReturnRequest.action

3、application-common-beans.xml

加载channel-unspay.peoperties文件
classpath*:/production/channel-unspay.properties
classpath*:/development/channel-unspay.properties
classpath*:/test/channel-unspay.properties

4、UnspayWithdrawService.java

银生宝提现(代付)服务

 @Override 
 public WithdrawResult widthraw(WithdrawParam req, MpWithdrawTradeOrder tradeOrder, JSONObject channelConfig) {
         String cpOrderNo = tradeOrder.getCpOrderNo();
         LogHelper.info(logger, "银生宝-提现申请,提现订单号:{},提现金额(元):{}", cpOrderNo, req.getAmount());
         CommonThirdChannelConfig pinganpayChannelConfig = JSONObject.toJavaObject(channelConfig,
         CommonThirdChannelConfig.class);
         //调用UnspayWithdrawHelper中的requestWithdraw()方法
         WithdrawResult result =  helper.requestWithdraw(tradeOrder, pinganpayChannelConfig);
         LogHelper.info(logger, "银生宝-提现申请,提现订单号:{},代付结果:{}", cpOrderNo, result);
         return result;
 }
@Override
public void updateResult(MpWithdrawTradeOrder tradeOrder, WithdrawResult result) {
}

5、UnspayWithdrawQueryService.java

银生宝代付查询服务

@Override
public WithdrawResult query(MpWithdrawTradeOrder tradeOrder, JSONObject channelConfig) {
    logger.info("银生宝-查询提现结果-代付订单号:{},代付平台单号:{}", tradeOrder.getOutOrderNo(), tradeOrder.getCpOrderNo());
    CommonThirdChannelConfig commonThirdChannelConfig = JSONObject.toJavaObject(channelConfig,CommonThirdChannelConfig.class);
    //调用UnspayWithdrawHelper中的requestWithdrawQuery()
    WithdrawResult result=helper.requestWithdrawQuery(tradeOrder.getCpOrderNo(), commonThirdChannelConfig);
    LogHelper.info(logger, "银生宝-提现结果查询,提现订单号:{},代付结果:{}", tradeOrder.getCpOrderNo(), result);
    return result;
}

6、UnspayWithdrawHelper.java

发起代付请求: requestWithdraw

public WithdrawResult requestWithdraw(MpWithdrawTradeOrder tradeOrder, CommonThirdChannelConfig channelConfig) {
    String respText = cloudPlatformHelper.request(withdrawUrl + "pay", linkText);}

发起代付查询:requestWithdrawQuery

public WithdrawResult requestWithdrawQuery(String cpOrderNo, CommonThirdChannelConfig channelConfig) {}

7、UnspaySignUtil.java

签名工具类

    /**
     * 创建参数文本串 字段值为空则不保存
     */
    public static String createLinkText(Map map) {
        String signText = "";
        for (Map.Entry entry : map.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            if (StringUtils.isNotBlank(value)) {
                signText += key + "=" + value + "&";
            }
        }
        if (StringUtils.isNotBlank(signText)) {
            signText = StringUtils.substringBeforeLast(signText, "&");
        }
        return signText;
    }

     /**
     * 签名
     */
    public static String sign(Map map, String key) {
        if (CollectionUtils.isEmpty(map) || StringUtils.isBlank(key)) throw new NullPointerException();
        String signText = createLinkText(map);
        return Md5SignUtils.createSignInfo(key, signText);
    }

    /**
     * 验签
     */
    public static Boolean verify(Map map, String signInfo, String key) {
        if (CollectionUtils.isEmpty(map) || StringUtils.isBlank(key)) throw new NullPointerException();
        String signText = createLinkText(map);
        return signInfo.equals(Md5SignUtils.createSignInfo(key, signText));
    }
    /**
    * 将values类型的数据转换为key-value类型的map数据
   */
    public static HashMap parseLine(String line, String[] fields, char split)   {
        if (line != null && !"".endsWith(line)) {
            String[] values = line.replaceAll("\\" + split + "\\" + split, split + " " + split + " ").replaceAll("\\" + split + "$", split + " ").split("\\" + split);
            if (values.length != fields.length) {
                throw new NumberFormatException("数据格式有误!");
            } else {
                HashMap map = new HashMap();
                for(int i = 0; i < fields.length; ++i) {
                    map.put(fields[i], values[i] != null ? values[i].trim() : null);
                }
                return map;
            }
        } else {
            return null;
        }
    }
    /**
     * 签名 明文后不加key
     */
    public static String sign2(Map map, String key) {
        if (CollectionUtils.isEmpty(map) || StringUtils.isBlank(key)) throw new NullPointerException();
        String signText = createLinkText2(map);
        return Md5SignUtils.createSignInfo2(key, signText);
    }

    /**
     * 验签 形参类型为map
     */
    public static Boolean verify2(Map map, String signInfo, String key) {
        if (CollectionUtils.isEmpty(map) || StringUtils.isBlank(key)) throw new NullPointerException();
        String signText = createLinkText2(map);
        String mac = SecurityUtils.md5(signText).toUpperCase();
        return signInfo.equals(mac)? true:false;
    }
    /**
     * 验签 形参类型为String
     */
    public static Boolean verify3(String signText ,String signInfo, String key) {
        if ( "null".equals(signText) || StringUtils.isBlank(key)) throw new NullPointerException();
        String mac = SecurityUtils.md5(signText).toUpperCase();
        return signInfo.equals(mac)? true:false;
    }
    /**
     * 创建参数文本串  字段值为空仍然保存
     */
    public static String createLinkText2(Map map) {
        String signText = "";
        for (Map.Entry entry : map.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            signText += key + "=" + value + "&";
        }
        if (StringUtils.isNotBlank(signText)) {
            signText = StringUtils.substringBeforeLast(signText, "&");
        }
        return signText;
    }

8、UnspayWithdrawNotifyExecutor.java

增加银生宝代付结果通知

@Override
   public String parseNotifyResult(String channelCode, String platformTradeNo, HttpServletRequest request) {
       Map resultMap = request.getParameterMap();
       if (resultMap == null || resultMap.isEmpty()) {
           throw new CloudApiException(CloudApiErrorCode.SYSTEM_ERROR, "通知内容为null");
       }

       LogHelper.info(logger, "银生宝-代付后台通知-通知内容:{},订单id:{}, 订单号:{}", resultMap, platformTradeNo, resultMap.get("orderId"));

       MpWithdrawTradeOrder tradeOrder = withdrawTradeOrderDao.queryMpWithdrawTradeOrderByCP(platformTradeNo);

       if (null == tradeOrder || !tradeOrder.getChannelPayId().equals(Channels.UNSPAY.value())) {
           throw new CloudApiException(CloudApiErrorCode.SYSTEM_ERROR, "非法提现订单");
       }

       // 提现流水终态
       if (!TradeStatus.DOING.name().equals(tradeOrder.getStatus())) {
           LogHelper.info(logger, "银生宝-代付后台通知, 订单id:{},订单已完成", platformTradeNo);
           return "SUCCESS";
       }

       JSONObject mchChannelConfig = sysPayChannelMchConfigService
               .findChannelMchConfigBySysMchId(tradeOrder.getSysMchId());
       CommonThirdChannelConfig channelConfig = JSON.toJavaObject(mchChannelConfig, CommonThirdChannelConfig.class);

       //组装签名信息
       Map signMap=new LinkedHashMap<>();
       signMap.put("accountId", channelConfig.getMchNo());
       signMap.put("orderId",resultMap.get("orderId")[0]);
       signMap.put("amount",resultMap.get("amount")[0]);
       signMap.put("result_code",resultMap.get("result_code")[0]);
       signMap.put("result_msg",resultMap.get("result_msg")[0]);
       signMap.put("key",channelConfig.getSignKey());
       String mac = resultMap.get("mac")[0];

       if (!UnspaySignUtil.verify2(signMap, mac, channelConfig.getSignKey())) {
           LogHelper.info(logger, "银生宝-代付后台通知, 订单id:{},验签错误", platformTradeNo);
           throw new CloudApiException(CloudApiErrorCode.SYSTEM_ERROR, "验签错误");
       }

       String status = CloudApiConstants.RESULT_CODE_FAIL;
       String resultCode = signMap.get("result_code");
       String resultMsg = signMap.get("result_msg");
       // 0000:付款成功;其它:付款失败
       if (UnspayWithdrawHelper.RESULT_CODE_SUCCESS.equals(resultCode)) {
           status = CloudApiConstants.RESULT_CODE_SUCCESS;
       }

       MpChannelInfoVO channelInfo = mpChannelInfoService.findById(tradeOrder.getChannelId());
       // 解冻金额
       t0TradeHelpService.dealWithdrawResult(tradeOrder, channelInfo.getAccountNo(), status, resultMsg);

       return "SUCCESS";
   }

处理完通知结果之后,要执行 解冻金额
调用T0TradeHelpService.dealWithdrawResult(),更新提现额度

9、相关配置文件

1.api.properties

相关url配置

2.redis.properties

缓存配置

#------------------Cache  Service config---------------------------------
CacheService=redisCacheService
#------------------redis start---------------------------------
redis.host=127.0.0.1
redis.port=6379
redis.pass=
redis.default.db=6  
redis.timeout=10000
redis.maxTotal=1024
redis.maxIdle=100
redis.maxWaitMillis=1000
redis.testOnBorrow=true
#------------------redis end-----------------------------------

3.jdbc.properties

数据库配置

#dev  链接的是sft-sx-bank数据库
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://192.168.1.10:3306/sft-sx-bank?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&autoReconnect=true
jdbc.username=root
jdbc.password=ENC(0qhNBFW3zM3zrK3V+bWf8URWtl1+ULE8)

4.web.xml

系统配置文件
spring.profiles.default的值,对应service-lts-jobclient-beans.xml

    
    
        spring.profiles.default
            
        development,trade,task
    

5.task-trade.properties task-lts.properties

lts轮询配置文件

task-trade.properties:主要修改ip
lts.tasktracker.cluster-name=test_cluster
lts.tasktracker.registry-address=zookeeper://192.168.1.99:2181
lts.tasktracker.work-threads=12
lts.tasktracker.node-group=cloud_trade_TaskTracker
#lts.tasktracker.dispatch-runner.enable=true
#lts.tasktracker.dispatch-runner.shard-value=taskId
lts.tasktracker.configs.job.fail.store=mapdb

#task setting
cloudTrackerNodeGroup=cloud_trade_TaskTracker
task-lts.properties:主要修改ip,相关对账单下载的配置
lts.jobclient.cluster-name=test_cluster
lts.jobclient.registry-address=zookeeper://192.168.1.99:2181
lts.jobclient.node-group=test_jobClient
lts.jobclient.use-retry-client=true
lts.jobclient.configs.job.fail.store=mapdb

lts.tasktracker.cluster-name=test_cluster
lts.tasktracker.registry-address=zookeeper://192.168.1.99:2181
lts.tasktracker.work-threads=18
lts.tasktracker.node-group=test_trade_TaskTracker
#lts.tasktracker.dispatch-runner.enable=true
#lts.tasktracker.dispatch-runner.shard-value=taskId
lts.tasktracker.configs.job.fail.store=mapdb

#初始化任务提交开关
cron.task.jobs.enabled=false
cron.task.apjobs.enabled=false

#task setting
taskTrackerNodeGroup=test_trade_TaskTracker

10、银生宝网关相关代码

1.UnspayTradeOrder.java

商户->银生宝网关下单Bean,继承了BaseTradeOrder
在创建订单信息的时候,作为入参传入到createTradeOrder中,生成订单主信息

 /**
     * 商户要求银生反馈信息的响应方式
     * 可取值:1-页面响应,2-后台响应,3-两者都需
     */
    private String responseMode = null;
    /**
     * 是否通过银生担保支付
     * false:非担保交易true:担保交易 [空字符串]:由用户在银生页面上选择交易模式v3.0.0 以下(不含)版本只支持false 取值
     * 若取值为 true,则直接进入通过银生账户支付的流程,不能以其它支付方式进行支付
     */
    private String assuredPay = null;

    /**
     * 商户前台响应地址  该字段不参与数字签名。其他同merchantUrl 备注。
     */
    private String frontURL = null;

    /**
     * 是否 B2B 网上银行支付
     */
    private String b2b = null;

2.IMpTradeOrderExtraUnspayDAO.java

Dao层,接口、继承了IBaseEntityDAO
没有子类去实现改接口,主要使用在MpTradeOrderExtraUnspayMapper.xml

 /**
     * 查询cpTradeNo查询订单
     *
     * @param cpTradeOrder
     * @return
     */
    UnspayTradeOrder findTradeOrderByCpOrderNo(String cpTradeOrder);

3.IMpTradeOrderExtraUnspayService.java

Service层,接口、继承了IBaseBusService、ITradeOrderDtlService

/**
     * 生成交易订单流水
     *
     * @param tradeOrder
     */
    void createTradeOrder(UnspayTradeOrder tradeOrder);

    /**
     * 查询cpTradeNo查询订单
     *
     * @param cpTradeNo
     * @return
     */
    UnspayTradeOrder findTradeOrderByCpOrderNo(String cpTradeNo);

4.MpTradeOrderExtraUnspayService.java

继承了BaseBusService、实现了IMpTradeOrderExtraUnspayService接口


    @Autowired
    private IMpTradeOrderExtraUnspayDAO dao;
    @Autowired
    private IMpTradeOrderService tradeOrderService;

    @Override
    public void createTradeOrder(UnspayTradeOrder tradeOrder) {
        MpTradeOrderVO baseTradeOrder = BeanMapper.map(tradeOrder, MpTradeOrderVO.class);
        MpTradeOrderExtraUnspay tradeOrderExtraUnspay = BeanMapper.map(tradeOrder, MpTradeOrderExtraUnspay.class);
        // 保存订单主信息
        tradeOrderService.createTradeOrder(baseTradeOrder);
        // 保存订单扩展信息  
        dao.insert(tradeOrderExtraUnspay);
    }

    /**
     * 查询cpTradeNo查询订单
     *
     * @param cpTradeNo
     * @return
     */
    public UnspayTradeOrder findTradeOrderByCpOrderNo(String cpTradeNo) {
        return dao.findTradeOrderByCpOrderNo(cpTradeNo);
    }

5.MpTradeOrderExtraUnspay.java

拓展表实体类,上面调用到

/**
     * id db_column: ID
     */
    private String id;

    /**
     * 接入类型
     */
    private String accessType;

    private String callbackUrl;
    private String notifyUrl;

6.MpTradeOrderExtraUnspayVO.java

银生宝支付拓展信息

 private Integer mchId;
    private String mchNo;
    private String mchName;
    private String mchOrderNo;
    private String cpOrderNo;
    private Integer paymentTypeId;
    private Date tradeTime;
    private String cur;
    private BigDecimal amt;
    private String status;
    private String chmRefundNo;
    private BigDecimal refundAmt;
    private String refundStatus;
    private String sysMchNo;
    private String cpRefundNo;
    private Integer refundTimes;
    private String rmk;
    private String postscript;
    private String summary;
    /**
     * 手续费类型
     */
    private String chargeRateType;
    /**
     * 费率
     */
    private BigDecimal chargeRate;
    /**
     * 手续费
     */
    private BigDecimal chargeAmt;
    /**
     * 已退款手续费
     */
    private BigDecimal refundChargeAmt;
    private Date channelRefundTime;
    private String handCheckSign;
    private Date channelPayTime;

7.CloudApiUnspayPayParam.java

银生宝网关支付请求内容,在构建订单方法build中,用于构建订单基础信息和订单拓展信息

 private static final long serialVersionUID = 1L;
    /**
     * 版本号
     */
    private String version;
    /**
     * 银生反馈信息的响应方式
     */
    private String responseMode;
    /**
     * 是否通过银生担保支付
     */
    private String assuredPay;
    /**
     * MAC值
     */
    private String mac;
    /**
     * 商户秘钥
     */
    private String merchantKey  ;

8.UnspayGatewayNotifyResult.java

银生宝网关异步通知内容,继承了TradeChannelResult

    /**
     * 订单状态-支付成功
     */
    public final static String TRADE_STATUS_SUCCESS = "0000";
    /**
     * 商户编号
     */
    private String merchantId;
    /**
     * 本次反馈的响应方式
     */
    private String responseMode;
    /**
     * 支付订单号
     */
    private String orderId;
    /**
     * 货币类型
     */
    private String currencyType;
    /**
     * 订单交易金额
     */
    private BigDecimal amount;
    /**
     * 返回码
     */
    private String returnCode;
    /**
     * 返回信息
     */
    private String returnMessage;
    /**
     * 支付银行
     */
    private String bankCode ;

9.UnspayTradeContextInfo.java

title:银生宝

public UnspayTradeContextInfo() {
        super();
        this.title = "银生宝";
    }

    public UnspayTradeContextInfo(String title) {
        super();
        this.title = title;
    }

10.UnspayGatewayOrderExecutor.java

银生宝网关支付处理服务

  protected Logger logger = LoggerFactory.getLogger(UnspayGatewayOrderExecutor.class);

    @Value("${cloud.pay.callback.unencoding.url}")
    private String callbackUrl; // 前台地址
    @Value("${cloud.pay.notify.unencoding.url}")
    private String notifyUrl; // 后台通知地址
    @Value("${cloud.unspay.gateway.pay.url}")
    private String payUrl;

    @Autowired
    private ISysPayChannelMchConfigService sysPayChannelMchConfigService;

    @Override
    protected CloudApiPayResult handleOrder(TradeContextInfo tradeContextInfo) {
        UnspayTradeOrder tradeOrder = (UnspayTradeOrder) tradeContextInfo.getTradeOrder();
        String platformTradeInfoText = cacheService.get(CloudApiConstants.CACHE_KEY_CLOUD_TRADE_PLATFORM_TRADE_INFO_PREFIX + tradeOrder.getId());
        ................
        String responeBody = CommonHelper.createAutoFormHtml(payUrl, paramsMap); // 生成自动跳转的Html表单
        logger.info("银生宝网关支付-生成支付form表单信息:{}", responeBody);
        CloudApiPayResult cloudApiPayResult = new CloudApiPayResult(CloudApiConstants.RESULT_CODE_SUCCESS);
        cloudApiPayResult.setResponseBody(responeBody);
        return cloudApiPayResult;
    }

    @Override
    protected String getTradeType() {
        return "unspayGateway";
    }

    @Override
    protected TradeContextInfo getTradeContextInfo() {
        return new UnspayTradeContextInfo("银生宝网关");
    }

    @Override
    protected Class getTradeOrderClazz() {
        return UnspayTradeOrder.class;
    }

11.CloudUnspayNotifyListener.java

银生宝网关支付后台通知

 @Autowired
    IMpMchPayChannelConfigService mchPayChannelConfigService;

    @Override
    protected CloudApiPayResult getDefaultNotifyResult(String payTypeCode, String platformTradeNo, HttpServletRequest request) {
        CloudApiPayResult cloudApiPayResult = new CloudApiPayResult();
        cloudApiPayResult.setResponseBody("success");
        return cloudApiPayResult;
    }

    @Override
    protected UnspayGatewayNotifyResult parseResult(String notifyType, PlatformTradeNoInfo platformTradeNoInfo, HttpServletRequest request) {
        UnspayGatewayNotifyResult notifyResult = new UnspayGatewayNotifyResult();
        CommonThirdChannelConfig channelConfig = mchPayChannelConfigService.findCommonThirdMchPayChannelConfig(platformTradeNoInfo.getSysMchNo());

        try {

            //  获取银生宝回调的数据
            try {
                request.setCharacterEncoding("UTF-8");
            } catch (UnsupportedEncodingException e) {
                LogHelper.info(logger, "设置Request编码异常:{}", e.getMessage());
            }
            Map params = request.getParameterMap();
            String data = null;
                data = JSON.toJSONString(RequestUtils.getRequestMapValue(params));
            JSONObject jsonObject = JSONObject.parseObject(data);
            //处理json数据

            String retCode = jsonObject.getString("returnCode");
            String retMsg = jsonObject.getString("returnMessage");
            String mac = jsonObject.getString("mac");

      
        return notifyResult;
    }

12.UnspayGatewayNotifyExecutor.java

银生宝网关支付结果后台通知,调用CloudUnspayNotifyListener


    private Logger logger = LoggerFactory.getLogger(UnspayGatewayNotifyExecutor.class);

    @Override
    public CloudApiPayResult execute(PlatformTradeNoInfo platformTradeNoInfo, UnspayGatewayNotifyResult channelResult) {
        logger.info("银生宝网关-后台通知处理-开始, 平台订单号:{}, 通知内容:{}", platformTradeNoInfo.getCpOrderNo(), channelResult);
        UnspayTradeContextInfo tradeContextInfo = new UnspayTradeContextInfo();
        // 解析并验证结果
        TradePlatformResult tradePlatformResult = parsePayResult(tradeContextInfo, platformTradeNoInfo, channelResult);
        logger.info("银生宝网关-后台通知处理, 平台订单号:{}, 转换平台结果:{}", platformTradeNoInfo.getCpOrderNo(), tradePlatformResult);

        tradeContextInfo.setTradePlatformResult(tradePlatformResult);
        // 完成支付
        TradeFinishState tradeFinishState = ApplicationContextHolder.getBean(TradeOrderFinisher.class).execute(tradeContextInfo, UnspayTradeOrder.class);

        CloudApiPayResult cloudApiPayResult = new CloudApiPayResult();
        if (tradeFinishState == TradeFinishState.LOCKED) {
            cloudApiPayResult.setResponseBody("error");
        } else { // 成功
            cloudApiPayResult.setResponseBody("00");
        }
        logger.info("银生宝网关-后台通知处理-结束, 平台订单号:{}, 处理结果:{}", platformTradeNoInfo.getCpOrderNo(), cloudApiPayResult);
        return cloudApiPayResult;
    }

    /**
     * 支付结果转换
     * @param tradeContextInfo
     * @param platformTradeNoInfo
     * @param channelResult
     * @return
     */
    private TradePlatformResult parsePayResult(UnspayTradeContextInfo tradeContextInfo, PlatformTradeNoInfo platformTradeNoInfo, UnspayGatewayNotifyResult channelResult) {
      .....
    }

13.UnspayGatewayCallbackExecutor.java

银生宝网关前端通知处理

@Autowired
    private IMpTradeOrderExtraUnspayService mpTradeOrderExtraUnspayService;

    @Override
    public CloudApiPayResult execute(PlatformTradeNoInfo platformTradeNoInfo, UnspayGatewayNotifyResult channelResult) {
        logger.info("银生宝网关-前台通知处理-开始, 平台订单号:{}, 通知内容:{}", platformTradeNoInfo.getCpOrderNo(), channelResult);
        
        UnspayTradeOrder tradeOrder = mpTradeOrderExtraUnspayService.findTradeOrderByCpOrderNo(platformTradeNoInfo.getCpOrderNo());
        return renderCallback(tradeOrder);
    }

14.UnspaySubmerchantCreateHanlder.java

opp商户入驻处理类

    @Override
    public SubmerchantCreateResult execute(SubmerchantCreateParam param) {
        return null;
    }
    @Override
    protected SubmerchantCreateResult parseMerchantResponse(MpMerchantInfoVO merchantInfo,
    }
    @Override
    protected SubmerchantCreateResult parsePollMerchantResponse(MpUpMerchantInfoRecordVO merchantInfo,
            BasePayChannelConfig basePayChannelConfig, String reponseBody) {
    }
    @Override
    protected Map createMerchantRequestParam(MpMerchantInfoVO merchantInfo, String payTypes,
            BasePayChannelConfig basePayChannelConfig, String subMchId) {
        return null;
    }
    @Override
    protected Map createPollMerchantRequestParam(MpUpMerchantInfoRecordVO upMerchantInfoRecordVO,
            String payTypes, BasePayChannelConfig basePayChannelConfig, String subMchId) {
        return null;
    }
    @Override
    protected String execute(String merchantNo, Map param, BasePayChannelConfig channelConfig) {
        return null;
    }
    @Override
    protected String getTitle() {
        return "银生宝-网关";
    }
    @Override
    protected BasePayChannelConfig getPayChannelConfig(Integer sysMchId, Integer channelPayId) {
        return null;
    }

15.UnspayTradePreOrderExecutor.java

预处理订单,生成订单查询任务

  @Override
    // 生成订单查询任务
    protected void createTradeQueryTask(UnspayTradeContextInfo tradeContextInfo) {
        BaseTradeOrder tradeOrder = tradeContextInfo.getTradeOrder();
        String cpOrderNo = tradeOrder.getCpOrderNo(); //商户号
        LogHelper.info(logger, "{}-生成订单查询任务-平台订单号:{}", tradeContextInfo.getTitle(), cpOrderNo);
        // 生成查询任务
        NotifyInfo notifyInfo = new NotifyInfo();
        notifyInfo.setNotifyContent(tradeOrder.getCpOrderNo());
        notifyInfo.setBusType(CloudApiConstants.TASK_BUS_TYPE_CLOUD_CHANNEL_TRADE_QUERY);
        notifyInfo.setBusKey(tradeOrder.getId());
   notifyInfo.setNotifyQueuePrefix(CloudApiConstants.CLOUD_TRADE_ORDER_UNSPAY_QUERY_QUEUE_PREFIX);
        notifyInfo.setNotifyHookName("tradePreOrderExecutor_10018_gateway");
        supportFacade.submitContinueRepeatJob(notifyInfo);
    }
    @Override
    protected void handlePayment(UnspayTradeContextInfo tradeContextInfo) {
        // 保存订单到db
        tradeOrderExtraUnspayService.createTradeOrder((UnspayTradeOrder) tradeContextInfo.getTradeOrder());
    }

16.UnspayTradeOrderBuilder.java

构建订单时被调用

@Override
    public void buildExtraData(CloudApiUnspayPayParam reqParam, UnspayTradeOrder tradeOrder, TradeContextInfo tradeContextInfo) {
       //  responseMode  商户要求银生反馈信息的响应方式
        // assuredPay  是否通过银生担保支付
        // mac 值
    }
    @Override
    protected UnspayTradeOrder newTradeOrder(CloudApiUnspayPayParam reqParam, TradeContextInfo tradeContextInfo) {
        return new UnspayTradeOrder();
    }

17.UnspayGatewayRequest.java

银生宝网关查询上游支付结果服务

        /**
     * 支付成功
     */
    private static final String STATUS_SUCCESS = "3";
    /**
     * 交易状态-处理中
     */
    private static final String STATUS_PROCCESS = "0";
    /**
     * 交易状态-交易失败
     */
    private static final String STATUS_FAIL = "4";
    @Value("${cloud.unspay.gateway.qry.url}")
    private String qryUrl;
    @Autowired
    private ISysPayChannelMchConfigService sysPayChannelMchConfigService;
    @Autowired
    private CloudPlatformHelper cloudPlatformHelper;
    @Override
    public TradePlatformResult requestRefundOrder(TradeContextInfo tradeContextInfo) {
        // TODO 暂无退款,未实现
        return null;
    }
    @Override
      //查询发送
    public TradePlatformResult requestQueryOrder(TradeContextInfo tradeContextInfo) {
        BaseTradeOrder tradeOrder = tradeContextInfo.getTradeOrder();
        JSONObject mchChannelConfig = sysPayChannelMchConfigService
                .findChannelMchConfigBySysMchId(tradeOrder.getSysMchId());
        CommonThirdChannelConfig channelConfig = JSON.toJa
    }
    /**
     * 查询上游支付结果
     */
    private Map doRequest(UnspayTradeOrder tradeOrder, Map paramsMap,
            CommonThirdChannelConfig channelConfig) {
    }
    /**
     * 上游支付结果转换
     */
    private TradePlatformResult parse2platformResult(Map respMap) {
    }

18.MpTradeOrderExtraUnspayMapper.xml

mybatis文件





    
        
        
        
        
    
    
    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    

11.公共配置

1.CloudPlatformHelper.java

云平台工具类型

        // 新增 银生宝
        tradeTypeNoMapper.put(Channels.UNSPAY.code(), "16");
        logger.info("初始化云平台线程池");
        executor = new ThreadPoolExecutor(notifyPoolCorePoolSize, notifyPoolMaximumPoolSize, notifyPoolKeepAliveTime, TimeUnit.MINUTES, workQueue);

2.UnPaidTradeOrderCleaner.java

        // 新增 银生宝
        queryQueueMapper.put(Channels.UNSPAY.code(), CloudApiConstants.CLOUD_TRADE_ORDER_UNSPAY_QUERY_QUEUE_PREFIX);
         // 新增 银生宝
        queryNotifyHookNameMapper.put(Channels.UNSPAY.code(), "tradePreOrderExecutor_10018_gateway");

3.TradeOrderDtlSupport.java

 @Autowired
        private IMpTradeOrderExtraUnspayService mpTradeOrderExtraUnspayService;
        // 新增 银生宝
        mapper.put(Channels.UNSPAY.code(), mpTradeOrderExtraUnspayService);

4.CloudApiConstants.java

     /**
     * 银生宝交易订单结果查询队列key前缀
     */
    String CLOUD_TRADE_ORDER_UNSPAY_QUERY_QUEUE_PREFIX = "MP:CLOUD:TRADE:UNSPAY:TRADE-ORDER-QUERY:TIME";

5.TradePayTypeHandlerFactory.java

       // 新增 银生宝
        payTypePreOrderMapper.put(Channels.UNSPAY.code(), "unspayTradePreOrderExecutor"); // 预处理订单
        payTypeOrderMapper.put(Channels.UNSPAY.code(), "unspayGatewayOrderExecutor");   // 银生宝网关支付处理服务
        payTypeNotifyMapper.put(Channels.UNSPAY.code(), "unspayGatewayNotifyExecutor"); //后台通知
        payTypeCallbackMapper.put(Channels.UNSPAY.code(), "unspayGatewayCallbackExecutor"); //银生宝网关前端通知处理
        reqParamTypeMapper.put(Channels.UNSPAY.code(), CloudApiUnspayPayParam.class);
        payTypeRefundMapper.put(Channels.UNSPAY.code(),"tfbGatewayTradeRefundExecutor"); //网关退款

12、银生宝退款

暂时不支持退款

1.UnspayGatewayTradeRefundExecutor.java

@Autowired
    private ISysPayChannelMchConfigService sysPayChannelMchConfigService;
    @Override
    protected TradeContextInfo createTradeContextInfo() {
        return new UnspayTradeContextInfo();
    }
    @Override
    protected ITradeRefundRequest getTradeRefundRequest(TradeContextInfo tradeContextInfo) {
       return ApplicationContextHolder.getBean(UnspayGatewayTradeRefundRequest.class);
    }
    @Override
    protected CommonThirdChannelConfig getPayChannelConfig(TradeContextInfo tradeContextInfo) {
        JSONObject mchChannelConfig = sysPayChannelMchConfigService.findChannelMchConfigBySysMchId(tradeContextInfo.getSysMchInfoVO().getId());
        return JSON.toJavaObject(mchChannelConfig, CommonThirdChannelConfig.class);
    }
    @Override
    protected String getTaskNotifyQueuePrefix() {
        return CloudApiConstants.CLOUD_REFUND_ORDER_QUERY_QUEUE_PREFIX;
    }
    @Override
    protected String getTaskNotifyHookName() {
        return "UnspayGatewayTradeRefundExecutor";
    }

2.UnspayGatewayTradeRefundRequest.java

银生宝网关退款请求服务

  private Logger logger = LoggerFactory.getLogger(UnspayGatewayTradeRefundRequest.class);
    private static final String charset = "GBK";
    @Value("${cloud.unspay.gateway.refund.url}")
    private String refundUrl;
    @Value("${cloud.unspay.gateway.qry.url}")
    private String refundQryUrl;
    @Autowired
    private CloudPlatformHelper cloudPlatformHelper;
    @Autowired
    private SysPayChannelMchConfigService sysPayChannelMchConfigService;
    /**
     * 银生宝网关退款申请
     */
    @Override
    public TradePlatformResult requestRefundOrder(TradeContextInfo tradeContextInfo) {
     .............
    }
    /**
     * 银生宝网关退款结果查询
     */
    @Override
    public TradePlatformResult requestQueryOrder(TradeContextInfo tradeContextInfo) {
       return null;
    }

你可能感兴趣的:(银生宝代付和网关渠道)