Commit ce08c088 by guojuxing

转账审批回调代码修改

parent bb2236bf
......@@ -118,6 +118,11 @@
<artifactId>gic-platform-finance-api</artifactId>
<version>4.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-open-platform-api</artifactId>
<version>4.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
......
......@@ -3,19 +3,16 @@ package com.gic.finance.service.outer.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.alibaba.fastjson.JSONObject;
import com.gic.dubbo.util.DubboContextUtil;
import com.gic.dubbo.util.DubboInvokeUtil;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.utils.ReferenceConfigCache;
import org.apache.dubbo.rpc.service.GenericService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
......@@ -63,6 +60,15 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA
transferAccountsApprovalDTO.setCreateTime(new Date());
transferAccountsApprovalDTO.setUpdateTime(new Date());
transferAccountsApprovalDTO.setApprovalStatus(TransferAccountApprovalStatusEnum.TO_BE_APPROVED.getCode());
if (StringUtils.isBlank(transferAccountsApprovalDTO.getEnterpriseName())) {
transferAccountsApprovalDTO.setEnterpriseName("无商户名称");
}
if (StringUtils.isBlank(transferAccountsApprovalDTO.getCompanyName())) {
transferAccountsApprovalDTO.setCompanyName("无公司名称");
}
if (StringUtils.isBlank(transferAccountsApprovalDTO.getLogo())) {
transferAccountsApprovalDTO.setLogo("无公司logo");
}
//审批流水号生成
String approvalSerialNumber = CreateSerialNumberUtils.createSerialNumber();
LOGGER.info("转账审批-发起审批-审批流水号:{}", approvalSerialNumber);
......@@ -139,7 +145,14 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA
dto.setApprovalTime(new Date());
//todo 审批人等信息获取插入
//callBack(tab, accountAmount, TransferAccountApprovalStatusEnum.AGREE.getCode());
//回调所需参数
tab.setAccountAmount(accountAmount);
tab.setBadAmount(tab.getPlannedAmount() - accountAmount);
tab.setApprovalStatus(TransferAccountApprovalStatusEnum.AGREE.getCode());
tab.setApprovalTime(new Date());
callBack(tab);
transferAccountsApprovalService.updateTransferAccountsApproval(dto);
return ServiceResponse.success();
}
......@@ -156,7 +169,10 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA
dto.setApprovalTime(new Date());
//todo 审批人等信息获取插入
//callBack(tab, null, TransferAccountApprovalStatusEnum.AGREE.getCode());
//回调所需参数
tab.setApprovalStatus(TransferAccountApprovalStatusEnum.REJECT.getCode());
tab.setApprovalTime(new Date());
callBack(tab);
transferAccountsApprovalService.updateTransferAccountsApproval(dto);
return ServiceResponse.success();
}
......@@ -209,45 +225,32 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA
transferAccountsApprovalService.updateTransferAccountsApproval(dto);
}
private void callBack(TabTransferAccountsApproval tab, Double accountAmount, int status) {
LOGGER.info("回调了");
ApplicationConfig applicationConfig = new ApplicationConfig();
applicationConfig.setName("dubbo-job");
RegistryConfig registryConfig = new RegistryConfig();
registryConfig.setAddress("zookeeper://10.105.220.75:2199");
registryConfig.setProtocol("dubbo");
registryConfig.setId("customRegistry");
registryConfig.setTimeout(30000);
private void callBack(TabTransferAccountsApproval tab) {
LOGGER.info("转账审批回调:{}" ,JSONObject.toJSONString(tab));
int orderType = tab.getOrderType().intValue();
boolean isBilling = orderType == OrderTypeEnum.RECHARGE.getCode() ||
orderType == OrderTypeEnum.SHORT_MESSAGE_PACKAGE.getCode();
String interfaceUrl = "";
String method = "";
if (isBilling) {
interfaceUrl = "com.gic.enterprise.service.BillingPayInfoApiService";
method = "offlineCallBack";
} else if (orderType == OrderTypeEnum.SERVICE.getCode()) {
//服务类型
interfaceUrl = "com.gic.open.api.service.market.PayCallbackApiService";
method = "payCallbackTransfer";
}
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
reference.setApplication(applicationConfig);
reference.setRegistry(registryConfig);
reference.setInterface("com.gic.enterprise.service.BillingPayInfoApiService");
reference.setGeneric(true);
reference.setCheck(false);
reference.setAsync(false);
reference.setTimeout(50000);
reference.setRetries(0);
RegistryConfig registry = new RegistryConfig();
registry.setAddress("zookeeper://10.105.220.75:2199");
registry.setCheck(false);
ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
reference.setInterface(interfaceUrl);
reference.setRegistry(registry);
reference.setGeneric(true);
ReferenceConfigCache cache = ReferenceConfigCache.getCache();
GenericService genericService = cache.get(reference);
GenericService genericService = reference.get();
boolean isBilling = tab.getOrderType().intValue() == OrderTypeEnum.RECHARGE.getCode() ||
tab.getOrderType().intValue() == OrderTypeEnum.SHORT_MESSAGE_PACKAGE.getCode();
//回调计费中心、短信套餐包
if (isBilling) {
JSONObject param = new JSONObject();
param.put("orderSerialNumber", tab.getOrderNumber());
param.put("buyType", tab.getOrderType());
param.put("totalFeePaid", accountAmount);
param.put("auditStatus", status);
param.put("timeEnd", new SimpleDateFormat("yyyyMMdd").format(new Date()));
//DubboContextUtil.initRegistryConfig("10.105.220.75", 2199);
Object name = genericService.$invoke("offlineCallBack", new String[]{String.class.getName()}, new String[]{param.toJSONString()});
}
genericService.$invoke(method, new String[]{String.class.getName()}, new String[]{JSONObject.toJSONString(tab)});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment