正元同步

This commit is contained in:
dzc committed 2025-03-04 15:31:52 +08:00
1 parent 00d159c8c0
commit 54a46dd9ee
20 files changed
+474 -137

No files matched your search

@@ -4,6 +4,10 @@ import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncDealerInfoDto;
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncEnterpriseInfoDto;
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideAuthenticationDto;
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideConsumptionDto;
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideCorrectDto;
@@ -19,6 +23,8 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@FeignClient(contextId = "remoterThirdZyService", value = ServiceNameConstants.THIRDPARTY_SERVICE)
public interface RemoterThirdZyService {
@@ -41,28 +47,28 @@ public interface RemoterThirdZyService {
*/
@NoToken
@GetMapping("/third-zy-mer/sync-dealer-info")
R<ZyMerSyncDealerInfoVo> syncDealerInfo(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto);
R<ZyMerSyncDealerInfoVo> syncDealerInfo(@RequestBody List<ZyMerSyncDealerInfoDto> dto);
/**
* 记账单位同步
*/
@NoToken
@GetMapping("/third-zy-mer/sync-enterprise-info")
R<ZyMerSyncEnterpriseInfoVo> syncEnterpriseInfoApi(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto);
R<ZyMerSyncEnterpriseInfoVo> syncEnterpriseInfoApi(@RequestBody List<ZyMerSyncEnterpriseInfoDto> dto);
/**
* 账户信息同步
*/
@NoToken
@GetMapping("/third-zy-mer/sync-account-info")
R<ZyMerSyncAccountInfoVo> syncAccountInfoApi(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto);
R<ZyMerSyncAccountInfoVo> syncAccountInfoApi(@RequestBody List<ZyMerSyncAccountInfoDto> dto);
/**
* 身份信息同步
*/
@NoToken
@GetMapping("/third-zy-mer/sync-acc-class-info")
R<ZyMerSyncAccClassInfoVo> syncAccClassInfoApi(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto);
R<ZyMerSyncAccClassInfoVo> syncAccClassInfoApi(@RequestBody List<ZyMerSyncAccClassInfoDto> dto);
/* ************************************* end 数据同步 end ************************************* */
@@ -15,7 +15,7 @@ public enum ThirdZyBizEnumType {
// 数据同步
SYNC_DEALER_INFO("10", "商户信息同步"),
SYNC_ENTERPRISE_INFO("20", "已打印"),
SYNC_ENTERPRISE_INFO("20", "记账单位同步"),
SYNC_ACCOUNT_INFO("30", "账户信息同步"),
SYNC_ACC_CLASS_INFO("40", "身份信息同步"),
@@ -37,7 +37,7 @@ public class ZyMerSyncAccountInfoDto {
/**
* 卡片状态,0销卡;1有效;2挂失;3冻结;4预销卡;5锁卡,默认1
*/
private String CardStatus;
private Integer CardStatus;
/**
* 该卡在所属接入系统中的所属单位编号
@@ -27,7 +27,7 @@ public class ZyMerSyncEnterpriseInfoDto {
/**
* 记账单位是否有效0:禁用 1:有效
*/
private String IsValid;
private Integer IsValid;
/**
* 每次推送版本号,格式化为14位字符串,如果是数字不足14位的,前面补0。
@@ -53,7 +53,7 @@ public class ThirdZyForeignServiceImpl implements ThirdZyForeignService {
String body = zyApiTool.getEncryptionDto(encryptionBody);
entity.setEncipherReq(body);
String res = HttpRequest.post(url)
.body(body)
.form(body)
.execute()
.body();
if (ObjectUtil.isEmpty(res)) {
@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
import com.bsd.pjcloud.thirdparty.constant.ThirdZyBizEnumType;
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncDealerInfoDto;
@@ -41,6 +42,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
@Override
public ZyMerSyncDealerInfoVo syncDealerInfoApi(List<ZyMerSyncDealerInfoDto> dto) {
ThirdZyLogEntity entity = new ThirdZyLogEntity();
entity.setBizType(ThirdZyBizEnumType.SYNC_DEALER_INFO.getType());
long startTime = System.currentTimeMillis();
if (ObjectUtil.isEmpty(dto)) {
return null;
@@ -57,13 +59,9 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
encryptionBody.put("dealers", listMap);
entity.setApiUrl(url);
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
String body = zyApiTool.getEncryptionDto(encryptionBody);
entity.setEncipherReq(body);
String res = HttpRequest.post(url)
.contentType("application/x-www-form-urlencoded")
.body(body)
.execute()
.body();
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
entity.setEncipherReq(JSONUtil.toJsonStr(body));
String res = HttpRequest.post(url).form(body).execute().body();
if (ObjectUtil.isEmpty(res)) {
throw new RuntimeException("response is empty");
}
@@ -77,6 +75,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
} catch (Exception e) {
String error = String.format("|%s||syncNativeCardTradeInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
log.error(error);
entity.setError(error);
} finally {
long elapsedTime = System.currentTimeMillis() - startTime;
entity.setTimeConsuming(Long.toString(elapsedTime));
@@ -91,6 +90,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
@Override
public ZyMerSyncEnterpriseInfoVo syncEnterpriseInfoApi(List<ZyMerSyncEnterpriseInfoDto> dto) {
ThirdZyLogEntity entity = new ThirdZyLogEntity();
entity.setBizType(ThirdZyBizEnumType.SYNC_ENTERPRISE_INFO.getType());
long startTime = System.currentTimeMillis();
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ENTERPRISE_INFO;
try {
@@ -102,6 +102,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
String body = zyApiTool.getEncryptionDto(encryptionBody);
entity.setEncipherReq(body);
String res = HttpRequest.post(url)
.contentType("application/x-www-form-urlencoded")
.body(body)
.execute()
.body();
@@ -161,7 +162,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
String error = String.format("|%s||syncAccountInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
log.error(error);
entity.setError(error);
}finally {
} finally {
long elapsedTime = System.currentTimeMillis() - startTime;
entity.setTimeConsuming(Long.toString(elapsedTime));
thirdZyLogService.save(entity);
@@ -203,7 +204,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
String error = String.format("|%s||syncAccClassInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
log.error(error);
entity.setError(error);
}finally {
} finally {
long elapsedTime = System.currentTimeMillis() - startTime;
entity.setTimeConsuming(Long.toString(elapsedTime));
thirdZyLogService.save(entity);
@@ -6,6 +6,8 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerGetTokenVo;
@@ -89,7 +91,16 @@ public class ZyApiTool {
Map<String, Object> body = new HashMap<>();
body.put("data", params);
prePost(body);
return JSONUtil.toJsonStr(body);
String jsonString = JSON.toJSONString(body, SerializerFeature.DisableCircularReferenceDetect);
log.error(jsonString);
return jsonString;
}
public Map<String, Object> getEncryptionMap(Map<String, Object> params) {
Map<String, Object> body = new HashMap<>();
body.put("data", params);
prePost(body);
return body;
}
public Map<String, Object> removeEmptyMap(Map<String, Object> params) {
@@ -116,7 +127,7 @@ public class ZyApiTool {
for (Map.Entry<String, Object> entry : params.entrySet()) {
Object value = entry.getValue();
if (value instanceof String) {
entry.setValue(Base64.encode((String) value));
entry.setValue(Base64.encode((String) value).replaceAll("\\s+", ""));
} else {
entry.setValue(Base64.encode(value.toString()));
}
@@ -78,6 +78,10 @@ public class ZyTest {
@Test
public void merSyncEnterpriseInfo() {
ZyMerSyncEnterpriseInfoDto dto = new ZyMerSyncEnterpriseInfoDto();
dto.setEPID("1");
dto.setEPName("测试部门");
dto.setIsValid(1);
dto.setFixId("20190920100101");
ZyMerSyncEnterpriseInfoVo vo = zyMerService.syncEnterpriseInfoApi(List.of(dto));
System.out.println(vo);
}
@@ -88,6 +92,9 @@ public class ZyTest {
@Test
public void merSyncAccountInfoApi() {
ZyMerSyncAccountInfoDto dto = new ZyMerSyncAccountInfoDto();
dto.setEPID("1");
dto.setAccName("测试部门");
dto.setEPID("1");
ZyMerSyncAccountInfoVo vo = zyMerService.syncAccountInfoApi(List.of(dto));
System.out.println(vo);
}