|
|
@@ -1,7 +1,9 @@
|
|
|
package com.yc.ship.module.ota.service.distributorselfrecharge;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.XML;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.yc.ship.framework.common.pojo.PageResult;
|
|
|
@@ -9,6 +11,8 @@ import com.yc.ship.framework.common.util.object.BeanUtils;
|
|
|
import com.yc.ship.framework.security.core.LoginUser;
|
|
|
import com.yc.ship.framework.tenant.core.util.TenantUtils;
|
|
|
import com.yc.ship.module.infra.api.config.ConfigApi;
|
|
|
+import com.yc.ship.module.ota.api.OtaDistributorApi;
|
|
|
+import com.yc.ship.module.ota.api.dto.DistributorSelfRechargeReqDTO;
|
|
|
import com.yc.ship.module.ota.controller.admin.distributor.vo.LoginTypeRespVO;
|
|
|
import com.yc.ship.module.ota.controller.admin.distributorselfrecharge.vo.DistributorSelfRechargePageReqVO;
|
|
|
import com.yc.ship.module.ota.controller.admin.distributorselfrecharge.vo.DistributorSelfRechargeSaveReqVO;
|
|
|
@@ -30,11 +34,12 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.io.OutputStream;
|
|
|
+import java.io.*;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.net.Socket;
|
|
|
import java.net.SocketTimeoutException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.Date;
|
|
|
import java.util.Random;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
@@ -67,6 +72,9 @@ public class DistributorSelfRechargeServiceImpl implements DistributorSelfRechar
|
|
|
@Resource
|
|
|
private AdminUserApi userApi;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private OtaDistributorApi otaDistributorApi;
|
|
|
+
|
|
|
@Resource
|
|
|
private TradeApi tradeApi;
|
|
|
|
|
|
@@ -253,16 +261,22 @@ public class DistributorSelfRechargeServiceImpl implements DistributorSelfRechar
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void abcRemittance() {
|
|
|
+ public void abcRemittance(DistributorDO distributor) {
|
|
|
+ String cardNo = distributor.getCmbShortNo();
|
|
|
log.info("abc对公转账充值");
|
|
|
String host = configApi.getPlatformConfigValueByKey("dgConfig_ip");
|
|
|
String portStr = configApi.getPlatformConfigValueByKey("dgConfig_port");
|
|
|
- String name = configApi.getPlatformConfigValueByKey("dgConfig_name");
|
|
|
- String yqtNo = configApi.getPlatformConfigValueByKey("dgConfig_no");
|
|
|
- String yqtPro = configApi.getPlatformConfigValueByKey("dgConfig_pro");
|
|
|
String yqtCard = configApi.getPlatformConfigValueByKey("dgConfig_card");
|
|
|
+ String day = configApi.getPlatformConfigValueByKey("dgConfig_day");
|
|
|
+ int ofday = 1;
|
|
|
+ if(StringUtils.isNotBlank(day)){
|
|
|
+ try {
|
|
|
+ ofday = Integer.parseInt(day);
|
|
|
+ }catch (Exception ignored){
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-// String host = "10.1.10.105";
|
|
|
int port = 15999;
|
|
|
if(StringUtils.isNotBlank(portStr)){
|
|
|
try {
|
|
|
@@ -280,12 +294,21 @@ public class DistributorSelfRechargeServiceImpl implements DistributorSelfRechar
|
|
|
Random random = new Random();
|
|
|
int randomNumber2 = random.nextInt(1000) + 1000;
|
|
|
String reqSeqNo = new SimpleDateFormat("yyyyMMddHHmmss").format(now) + ""+randomNumber2+"";
|
|
|
+
|
|
|
+ // 1. 获取当前时间,用于组装公共包头流水与日期
|
|
|
+ Long s1 = System.currentTimeMillis();
|
|
|
+ Long s0 = s1-172800000;
|
|
|
+
|
|
|
+ Date sDate = DateUtil.offsetDay( now,-ofday);
|
|
|
+ String endDate = new SimpleDateFormat("yyyyMMdd").format(now);
|
|
|
+ String startDate = new SimpleDateFormat("yyyyMMdd").format(sDate);
|
|
|
+
|
|
|
// 2. 构造 CMLT40 增加多级账簿 XML 请求报文
|
|
|
String xmlData = "<ap>\n" +
|
|
|
- " <CCTransCode>CQRA10</CCTransCode>\n" +
|
|
|
+ " <CCTransCode>CQRD02</CCTransCode>\n" +
|
|
|
" <ProductID>ICC</ProductID>\n" +
|
|
|
" <ChannelType>ERP</ChannelType>\n" +
|
|
|
- " <CorpNo>"+yqtNo+"</CorpNo>\n" +
|
|
|
+ " <CorpNo></CorpNo>\n" +
|
|
|
" <OpNo></OpNo>\n" +
|
|
|
" <AuthNo></AuthNo>\n" +
|
|
|
" <ReqSeqNo>" + reqSeqNo + "</ReqSeqNo>\n" +
|
|
|
@@ -293,14 +316,16 @@ public class DistributorSelfRechargeServiceImpl implements DistributorSelfRechar
|
|
|
" <ReqTime>" + reqTime + "</ReqTime>\n" +
|
|
|
" <Sign></Sign>\n" +
|
|
|
" <Corp>\n" +
|
|
|
- " <StartDate>0</StartDate>\n" +
|
|
|
- " <EndDate>F</EndDate>\n" +
|
|
|
+ " <StartDate>"+startDate+"</StartDate>\n" +
|
|
|
+ " <EndDate>"+endDate+"</EndDate>\n" +
|
|
|
" </Corp>\n" +
|
|
|
" <Cmp>\n" +
|
|
|
- " <DbProv>"+yqtPro+"</DbProv>\n" +
|
|
|
+ " <DbProv>17</DbProv>\n" +
|
|
|
+ " <StartTime>"+s0+"</StartTime>\n" +
|
|
|
" <DbAccNo>"+yqtCard+"</DbAccNo>\n" +
|
|
|
+ " <DbLogAccNo>"+cardNo+"</DbLogAccNo>\n" +
|
|
|
" <DbCur>01</DbCur>\n" +
|
|
|
- " <StartTime></StartTime>\n" +
|
|
|
+ " <LogAccBkOInd>0</LogAccBkOInd>\n" +
|
|
|
" </Cmp>\n" +
|
|
|
"</ap>";
|
|
|
|
|
|
@@ -361,8 +386,79 @@ public class DistributorSelfRechargeServiceImpl implements DistributorSelfRechar
|
|
|
if(!"0000".equals(respCode)){
|
|
|
System.err.println("交易发送异常,异常信息:"+ap.getStr("RespInfo"));
|
|
|
}else {
|
|
|
- String resultCode = ap.getJSONObject("Cmp").getStr("DbLogAccNo");
|
|
|
- System.err.println("卡号:" + resultCode);
|
|
|
+ System.out.println("交易发送成功");
|
|
|
+
|
|
|
+ // 使用 try-with-resources 自动关闭流 //替换成文件目录
|
|
|
+ try (FileInputStream fis = new FileInputStream("C:\\Users\\90653\\Desktop\\aaa.txt");
|
|
|
+ InputStreamReader isr = new InputStreamReader(fis, "GBK");
|
|
|
+ BufferedReader br = new BufferedReader(isr)) {
|
|
|
+
|
|
|
+ String line;
|
|
|
+ while ((line = br.readLine()) != null) {
|
|
|
+ System.out.println(line);
|
|
|
+ //省市代码|账号|账薄号|货币码|交易日期|日志号|交易时间|户名|账薄名|交易类型|交
|
|
|
+ //易行号|传票号|发生额标识|现转标志|交易金额|账户余额|上笔余额|凭证种类|交易码|
|
|
|
+ //凭证号|对方账号省市代码|对方账号|对方账号货币码|对方账号户名|对方账号开户行|
|
|
|
+ //错账日期|错账传票号|记账柜员|摘要|附言|红蓝字标识|备注 1|备注 2|
|
|
|
+ //17|342101046484369|1203444786|01|20260423|1527670363|20260423112009578611|宜畅式东士煌本孔凰于慊官送|宜畅式东士煌本孔凰于慊官送重庆万友国际旅行社
|
|
|
+ // |0||3|0|1|30.00|30.00|0.00|2|2581|00000000|17|342101046420983||宜常收镐赛坭足克凰幼慊关嗣|中国农业银行股份有限公司枝江市支行||||0199|测试3||||
|
|
|
+ String[] split = line.split("\\|");
|
|
|
+ String refNbr = split[5];
|
|
|
+ String logTime = split[6];
|
|
|
+ String recardNo = split[2];
|
|
|
+ String trsAmt = split[14];
|
|
|
+ System.err.println("日志号:" + refNbr);
|
|
|
+ System.err.println("交易时间:" + logTime);
|
|
|
+ System.err.println("卡号:" + recardNo);
|
|
|
+ System.err.println("金额:" + trsAmt);
|
|
|
+
|
|
|
+
|
|
|
+ LambdaQueryWrapper<DistributorSelfRechargeDO> existCheckWrapper = new LambdaQueryWrapper<>();
|
|
|
+ existCheckWrapper.eq(DistributorSelfRechargeDO::getRechargeNo, refNbr);
|
|
|
+ if (distributorSelfRechargeMapper.selectCount(existCheckWrapper) > 0) {
|
|
|
+ log.warn("refNbr [{}] 已存在,跳过重复插入", refNbr);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ DistributorSelfRechargeDO newRecharge = new DistributorSelfRechargeDO();
|
|
|
+ newRecharge.setId(IdWorker.getId());
|
|
|
+ newRecharge.setDistributorId(distributor.getId());
|
|
|
+ newRecharge.setRechargeNo(refNbr);
|
|
|
+ newRecharge.setMoney(new BigDecimal(trsAmt).setScale(2));
|
|
|
+ newRecharge.setRechargeState(0);
|
|
|
+ newRecharge.setPayType(9);
|
|
|
+ newRecharge.setAccountId(distributor.getAccountTenantId());
|
|
|
+ newRecharge.setAccountName(distributor.getName());
|
|
|
+ newRecharge.setCreator(distributor.getName());
|
|
|
+ newRecharge.setTenantId(distributor.getTenantId());
|
|
|
+ newRecharge.setCreateTime(LocalDateTime.now());
|
|
|
+ newRecharge.setUpdateTime(LocalDateTime.now());
|
|
|
+
|
|
|
+ TenantUtils.execute(distributor.getTenantId(), () -> {
|
|
|
+ distributorSelfRechargeMapper.insert(newRecharge);
|
|
|
+ });
|
|
|
+ log.info("成功插入充值记录 | refNbr:{}", refNbr);
|
|
|
+ DistributorSelfRechargeReqDTO reqDTO = new DistributorSelfRechargeReqDTO();
|
|
|
+ reqDTO.setOrderId(newRecharge.getId());
|
|
|
+ reqDTO.setPayOrderId(refNbr);
|
|
|
+ reqDTO.setPayStatus(1);
|
|
|
+
|
|
|
+ try {
|
|
|
+ otaDistributorApi.distributorCMBRecharge(reqDTO).getCheckedData();
|
|
|
+ log.error("充值通知成功 | orderId:{}", newRecharge.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("充值通知失败 | orderId:{}", newRecharge.getId(), e);
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.error("金额格式错误 | trsamt:{}", trsAmt, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
System.out.println("响应报文异常或为空");
|