钱包导出时间不对、第三方扣款
This commit is contained in:
1 parent
8e6d2c6f01
commit
31fe4d3bb4
24 files changed
+369
-121
No files matched your search
+1
-1
@@ -57,7 +57,7 @@ public class PermitAllUrlProperties implements InitializingBean {
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean skipPublicUrl = false;
|
||||
private boolean skipPublicUrl = true;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
|
||||
+4
@@ -27,10 +27,14 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
||||
import org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2022-06-04
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ public enum HardOrderTypeEnum {
|
||||
RESERVE("2", "线上订餐"),
|
||||
FOREIGN_TICKET("3", "外来人员"),
|
||||
STRIDE_DEPT("4", "跨单位"),
|
||||
ZY("5", "正元公务餐"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.bsd.pjcloud.hard.api.constant.third;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardPrintStatusEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum HardCallbackPayStatus {
|
||||
SUCCESS("0", "省平台认为流水交易完成,扣费成功"),
|
||||
REPETITION("0001", "省平台则会每天定时重新发起扣费流程"),
|
||||
ERROR("0002", "省平台则不再扣费,认为是坏账"),
|
||||
NOT_SUFFICIENT_FUNDS("0003", "余额不足返回,省平台将会禁止该账户后续交易权限"),
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
public static HardCallbackPayStatus valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.third;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class HardCallbackPayDto {
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Integer payPrice;
|
||||
|
||||
private LocalDateTime payTime;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.third;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HardCallbackRefundDto {
|
||||
}
|
||||
+7
-2
@@ -1,19 +1,24 @@
|
||||
package com.bsd.pjcloud.hard.api.feign;
|
||||
|
||||
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.hard.api.dto.third.HardCallbackPayDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.third.HardCallbackRefundDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.third.HardCallbackPayVo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(contextId = "remoteHardThirdSelfZyService", value = ServiceNameConstants.HARDWARE_SERVICE)
|
||||
public interface RemoteHardThirdSelfZyService {
|
||||
|
||||
@NoToken
|
||||
@PostMapping("/hard-third-callback/pay")
|
||||
void pay();
|
||||
R<HardCallbackPayVo> pay(@RequestBody HardCallbackPayDto dto);
|
||||
|
||||
@NoToken
|
||||
@PostMapping("/hard-third-callback/refund")
|
||||
void refund();
|
||||
String refund(@RequestBody HardCallbackRefundDto dto);
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.bsd.pjcloud.hard.api.vo.third;
|
||||
|
||||
import com.bsd.pjcloud.hard.api.constant.third.HardCallbackPayStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class HardCallbackPayVo {
|
||||
|
||||
private Long orderId;
|
||||
|
||||
private HardCallbackPayStatus code;
|
||||
|
||||
private LocalDateTime payTime;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String username;
|
||||
}
|
||||
+1
-1
@@ -166,7 +166,7 @@ public class HardOrderController {
|
||||
if (ObjectUtil.isNotEmpty(dto.getPayTimeList())) {
|
||||
map.put("timeSpan", " 到 ");
|
||||
map.put("startTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[1], DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(excelList)) {
|
||||
BigDecimal totalPriceSum = BigDecimal.ZERO;
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ public class HardOrderTotalController {
|
||||
if (ObjectUtil.isNotEmpty(dto.getPayTimeList())) {
|
||||
map.put("timeSpan", " 到 ");
|
||||
map.put("startTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[1], DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
BigDecimal priceTotal = BigDecimal.ZERO;
|
||||
@@ -128,7 +128,7 @@ public class HardOrderTotalController {
|
||||
if (ObjectUtil.isNotEmpty(dto.getPayTimeList())) {
|
||||
map.put("timeSpan", " 到 ");
|
||||
map.put("startTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[1], DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
BigDecimal priceTotal = BigDecimal.ZERO;
|
||||
|
||||
+8
-15
@@ -1,22 +1,17 @@
|
||||
package com.bsd.pjcloud.hard.controller.third;
|
||||
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.hard.api.dto.third.HardCallbackPayDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.third.HardCallbackRefundDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.third.HardCallbackPayVo;
|
||||
import com.bsd.pjcloud.hard.service.HardThirdSelfZyService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -29,20 +24,18 @@ public class HardThirdSelfZyController {
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
|
||||
@Inner(value = false)
|
||||
@PostMapping("/pay")
|
||||
@SysLog("正元支付")
|
||||
@Operation(summary = "正元支付")
|
||||
public void pay() {
|
||||
hardThirdSelfZyService.pay();
|
||||
public R<HardCallbackPayVo> pay(@RequestBody HardCallbackPayDto dto) {
|
||||
return R.ok(hardThirdSelfZyService.pay(dto));
|
||||
}
|
||||
|
||||
@Inner(value = false)
|
||||
@PostMapping("/refund")
|
||||
@SysLog("正元退款")
|
||||
@Operation(summary = "正元退款")
|
||||
public void refund() {
|
||||
hardThirdSelfZyService.refund();
|
||||
public String refund(@RequestBody HardCallbackRefundDto dto) {
|
||||
return hardThirdSelfZyService.refund(dto);
|
||||
}
|
||||
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
+6
-3
@@ -1,16 +1,19 @@
|
||||
package com.bsd.pjcloud.hard.service;
|
||||
|
||||
import java.util.Map;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.hard.api.dto.third.HardCallbackPayDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.third.HardCallbackRefundDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.third.HardCallbackPayVo;
|
||||
|
||||
public interface HardThirdSelfZyService {
|
||||
|
||||
/**
|
||||
* 正元支付
|
||||
*/
|
||||
void pay();
|
||||
HardCallbackPayVo pay(HardCallbackPayDto dto);
|
||||
|
||||
/**
|
||||
* 正元退款
|
||||
*/
|
||||
void refund();
|
||||
String refund(HardCallbackRefundDto dto);
|
||||
}
|
||||
+77
-4
@@ -1,11 +1,28 @@
|
||||
package com.bsd.pjcloud.hard.service.impl.hard;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.third.HardCallbackPayStatus;
|
||||
import com.bsd.pjcloud.hard.api.dto.third.HardCallbackPayDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.third.HardCallbackRefundDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.third.HardCallbackPayVo;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderService;
|
||||
import com.bsd.pjcloud.hard.service.HardThirdSelfZyService;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
@Validated
|
||||
@Slf4j
|
||||
@@ -13,14 +30,70 @@ import org.springframework.validation.annotation.Validated;
|
||||
@Service
|
||||
public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
|
||||
|
||||
@Override
|
||||
public void pay() {
|
||||
private static final String TAG = "硬件正元回调";
|
||||
|
||||
private final RemoteWalletService remoteWalletService;
|
||||
|
||||
private final HardOrderService hardOrderService;
|
||||
|
||||
/**
|
||||
* 正元支付
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public HardCallbackPayVo pay(HardCallbackPayDto dto) {
|
||||
// 钱包
|
||||
try {
|
||||
WalletManageEntity wallet = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.EAT).getData();
|
||||
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
|
||||
Integer balance = wallet.getBalance();
|
||||
int totalPrice = dto.getPayPrice();
|
||||
if (balance < totalPrice) {
|
||||
HardCallbackPayVo res = new HardCallbackPayVo();
|
||||
res.setCode(HardCallbackPayStatus.NOT_SUFFICIENT_FUNDS);
|
||||
return res;
|
||||
}
|
||||
String subject = "正元公务餐扣款";
|
||||
// 添加硬件订单
|
||||
HardOrderEntity orderObj = HardOrderEntity.builder()
|
||||
.userId(dto.getUserId())
|
||||
.parentCarId(null)
|
||||
.sysType(null)
|
||||
.orderStatus(HardOrderStatusEnum.PAY.getType())
|
||||
.merchantId(null)
|
||||
.orderType(HardOrderTypeEnum.ZY.getType())
|
||||
.payType(HardOrderTypeEnum.RESERVE.getType())
|
||||
.orderSourceTypeId(null)
|
||||
.totalPrice(totalPrice)
|
||||
.extraPrice(0)
|
||||
.payPrice(totalPrice)
|
||||
.isOfflineOrder(YesNoEnum.NO.getCode())
|
||||
.productDesc(subject)
|
||||
.walletId(wallet.getId())
|
||||
.build();
|
||||
boolean isCreateOrder = hardOrderService.save(orderObj);
|
||||
if (!isCreateOrder) throw new RuntimeException("创建订单失败");
|
||||
hardOrderService.fastReduceBalance(orderObj);
|
||||
HardCallbackPayVo result = new HardCallbackPayVo();
|
||||
result.setCode(HardCallbackPayStatus.SUCCESS);
|
||||
result.setOrderId(orderObj.getId());
|
||||
result.setPayTime(LocalDateTime.now());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}|意外得错误dto:|{}|", TAG, JSONUtil.toJsonStr(dto), e);
|
||||
HardCallbackPayVo result = new HardCallbackPayVo();
|
||||
result.setCode(HardCallbackPayStatus.REPETITION);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 正元退款
|
||||
*/
|
||||
@Override
|
||||
public void refund() {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String refund(HardCallbackRefundDto dto) {
|
||||
return "-1";
|
||||
}
|
||||
|
||||
}
|
||||
+8
-3
@@ -1,10 +1,10 @@
|
||||
package com.bsd.pjcloud.thirdparty.vo.zy;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class ZyBaseVo {
|
||||
@@ -54,4 +54,9 @@ public class ZyBaseVo {
|
||||
return ObjectUtil.equal(code, ZyBaseVo.successCode);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Map<String, Object> getErrorMap() {
|
||||
return Map.of("code", code, "msg", msg);
|
||||
}
|
||||
|
||||
}
|
||||
+4
-5
@@ -27,7 +27,7 @@ public class ThirdZySelfController {
|
||||
@Inner(value = false)
|
||||
@GetMapping("/checkSystemStatus")
|
||||
@Operation(summary = "第三方url健康探测", description = "第三方url健康探测")
|
||||
@Idempotent(expireTime = 10, info = "请勿重复调用")
|
||||
@Idempotent(expireTime = 3, info = "请勿重复调用")
|
||||
public Map<String, Object> checkSystemStatus() {
|
||||
return zySelfService.checkSystemStatus();
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class ThirdZySelfController {
|
||||
@Inner(value = false)
|
||||
@GetMapping("/getToken")
|
||||
@Operation(summary = "第三方提供获取token", description = "第三方提供获取token")
|
||||
@Idempotent(expireTime = 10, info = "请勿重复调用")
|
||||
@Idempotent(expireTime = 3, info = "请勿重复调用")
|
||||
public ZySelfGetTokenVo getToken(ZySelfGetTokenDto params) {
|
||||
return zySelfService.getToken(params);
|
||||
}
|
||||
@@ -43,15 +43,14 @@ public class ThirdZySelfController {
|
||||
@Inner(value = false)
|
||||
@PostMapping("/correct")
|
||||
@Operation(summary = "第三方一卡通系统提供冲正接口", description = "第三方一卡通系统提供冲正接口")
|
||||
public ZySelfCorrectVo correct(ZySelfCorrectDto params, @RequestParam(value = "access_token", required = false) String accessToken) {
|
||||
public Map<String, Object> correct(ZySelfCorrectDto params, @RequestParam(value = "access_token", required = false) String accessToken) {
|
||||
return zySelfService.correct(params, accessToken);
|
||||
}
|
||||
|
||||
@Inner(value = false)
|
||||
@PostMapping("/pay")
|
||||
@Operation(summary = "第三方一卡通系统提供扣费接口", description = "第三方一卡通系统提供扣费接口")
|
||||
@Idempotent(expireTime = 10, info = "请勿重复调用")
|
||||
public ZySelfPayVo pay(ZySelfPayDto params, @RequestParam(value = "access_token", required = false) String accessToken) {
|
||||
public Map<String, Object> pay(ZySelfPayDto params, @RequestParam(value = "access_token", required = false) String accessToken) {
|
||||
return zySelfService.pay(params, accessToken);
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -28,4 +28,12 @@ public interface ThirdZyIdDictMapper extends PjcloudBaseMapper<ThirdZyIdDictEnti
|
||||
return selectList(wrapper);
|
||||
}
|
||||
|
||||
default ThirdZyIdDictEntity getByZyIds(ThirdZyBizEnumType type, String zyId) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
LambdaQueryWrapper<ThirdZyIdDictEntity> wrapper = new LambdaQueryWrapper<ThirdZyIdDictEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(zyId), ThirdZyIdDictEntity::getZyId, zyId)
|
||||
.eq(ThirdZyIdDictEntity::getBizType, type.getType());
|
||||
return selectOne(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -24,10 +24,10 @@ public interface ThirdZySelfService {
|
||||
/**
|
||||
* 第三方一卡通系统提供冲正接口
|
||||
*/
|
||||
ZySelfCorrectVo correct(ZySelfCorrectDto params, String accessToken);
|
||||
Map<String, Object> correct(ZySelfCorrectDto params, String accessToken);
|
||||
|
||||
/**
|
||||
* 第三方一卡通系统提供扣费接口
|
||||
*/
|
||||
ZySelfPayVo pay(ZySelfPayDto params, String accessToken);
|
||||
Map<String, Object> pay(ZySelfPayDto params, String accessToken);
|
||||
}
|
||||
+1
-3
@@ -23,9 +23,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
@@ -66,7 +64,7 @@ public class ThirdZyForeignServiceImpl implements ThirdZyForeignService {
|
||||
Map<String, Object> encryptionBody = BeanUtil.beanToMap(dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
|
||||
Map<String, Object> body = zyApiTool.getZyEncryptionMap(encryptionBody);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(body));
|
||||
String res = HttpRequest.post(url).form(body).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
|
||||
+8
-16
@@ -55,21 +55,18 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
||||
// 转换商户id
|
||||
List<String> mchList = dto.stream().map(ZyMerSyncDealerInfoDto::getDealerKeyObj).distinct().toList();
|
||||
Map<String, String> mchIdDict = zyApiTool.generateZyId(bizTYpe, mchList);
|
||||
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||
for (ZyMerSyncDealerInfoDto v : dto) {
|
||||
v.setEPID(deptDdDict.get(v.getEPID()));
|
||||
v.setDealerKeyObj(mchIdDict.get(v.getDealerKeyObj()));
|
||||
Map<String, Object> map = zyApiTool.removeEmptyMap(BeanUtil.beanToMap(v));
|
||||
if (ObjectUtil.isNotEmpty(map)) listMap.add(map);
|
||||
}
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_DEALER_INFO;
|
||||
try {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("dealers", listMap);
|
||||
encryptionBody.put("dealers", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
|
||||
Map<String, Object> body = zyApiTool.getZyEncryptionMap(encryptionBody);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(body));
|
||||
String res = HttpRequest.post(url).form(body).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
@@ -103,23 +100,20 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
entity.setBizType(bizType.getType());
|
||||
long startTime = System.currentTimeMillis();
|
||||
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||
// 转换zyId
|
||||
List<String> list = dto.stream().map(ZyMerSyncEnterpriseInfoDto::getEPID).distinct().toList();
|
||||
Map<String, String> idDict = zyApiTool.generateZyId(bizType, list);
|
||||
for (ZyMerSyncEnterpriseInfoDto v : dto) {
|
||||
v.setEPID(idDict.get(v.getEPID()));
|
||||
Map<String, Object> map = zyApiTool.removeEmptyMap(BeanUtil.beanToMap(v));
|
||||
if (ObjectUtil.isNotEmpty(map)) listMap.add(map);
|
||||
}
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ENTERPRISE_INFO;
|
||||
try {
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("enterprises", listMap);
|
||||
encryptionBody.put("enterprises", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
|
||||
Map<String, Object> body = zyApiTool.getZyEncryptionMap(encryptionBody);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(body));
|
||||
String res = HttpRequest.post(url).form(body).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
@@ -164,6 +158,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
||||
Map<String, String> roleIdDict = zyApiTool.generateZyId(bizType, roleList);
|
||||
for (ZyMerSyncAccountInfoDto v : dto) {
|
||||
v.setEPID(deptIdDict.get(v.getEPID()));
|
||||
v.setPerCode(userIdDict.get(v.getPerCode()));
|
||||
v.setAccNum(userIdDict.get(v.getAccNum()));
|
||||
v.setAccClassID(roleIdDict.get(v.getAccClassID()));
|
||||
}
|
||||
@@ -179,7 +174,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
||||
encryptionBody.put("currentMaxFixId", String.valueOf(maxFixId.getAsLong()));
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody, "data", "currentMaxFixId");
|
||||
Map<String, Object> body = zyApiTool.getZyEncryptionMap(encryptionBody, "data", "currentMaxFixId");
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(body));
|
||||
String res = HttpRequest.post(url).form(body).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
@@ -219,21 +214,18 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
||||
long startTime = System.currentTimeMillis();
|
||||
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ACC_CLASS_INFO;
|
||||
try {
|
||||
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||
// 转换zyId
|
||||
List<String> roleList = dto.stream().map(ZyMerSyncAccClassInfoDto::getEPID).distinct().toList();
|
||||
Map<String, String> roleIdDict = zyApiTool.generateZyId(bizType, roleList);
|
||||
for (ZyMerSyncAccClassInfoDto v : dto) {
|
||||
v.setEPID(roleIdDict.get(v.getEPID()));
|
||||
Map<String, Object> map = zyApiTool.removeEmptyMap(BeanUtil.beanToMap(v));
|
||||
if (ObjectUtil.isNotEmpty(map)) listMap.add(map);
|
||||
}
|
||||
url = String.format(url, zyApiTool.getToken());
|
||||
Map<String, Object> encryptionBody = new HashMap<>();
|
||||
encryptionBody.put("accClasses", listMap);
|
||||
encryptionBody.put("accClasses", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
|
||||
Map<String, Object> body = zyApiTool.getZyEncryptionMap(encryptionBody);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(body));
|
||||
String res = HttpRequest.post(url).form(body).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
|
||||
+99
-30
@@ -1,21 +1,31 @@
|
||||
package com.bsd.pjcloud.thirdparty.service.impl.zy;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.hard.api.dto.third.HardCallbackPayDto;
|
||||
import com.bsd.pjcloud.hard.api.feign.RemoteHardThirdSelfZyService;
|
||||
import com.bsd.pjcloud.hard.api.vo.third.HardCallbackPayVo;
|
||||
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
||||
import com.bsd.pjcloud.thirdparty.constant.ThirdZyBizEnumType;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfCorrectDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfGetTokenDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfPayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfTokenDto;
|
||||
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyIdDictEntity;
|
||||
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.mapper.zy.ThirdZyIdDictMapper;
|
||||
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZySelfService;
|
||||
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApi;
|
||||
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApiTool;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.ZyBaseVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfCorrectVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfGetTokenVo;
|
||||
@@ -29,6 +39,8 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -45,9 +57,12 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
private final StringRedisTemplate redisTemplate;
|
||||
|
||||
private final ThirdZyLogServiceImpl thirdZyLogService;
|
||||
private final ThirdZyIdDictMapper thirdZyIdDictMapper;
|
||||
|
||||
private final RemoteHardThirdSelfZyService hardCallback;
|
||||
|
||||
private final ZyApiTool zyApiTool;
|
||||
|
||||
/**
|
||||
* 第三方url健康探测
|
||||
*/
|
||||
@@ -79,13 +94,13 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
* 第三方一卡通系统提供冲正接口
|
||||
*/
|
||||
@Override
|
||||
public ZySelfCorrectVo correct(ZySelfCorrectDto params, String accessToken) {
|
||||
public Map<String, Object> correct(ZySelfCorrectDto params, String accessToken) {
|
||||
ThirdZyBizEnumType bizType = ThirdZyBizEnumType.SELF_CORRECT;
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
entity.setBizType(bizType.getType());
|
||||
long startTime = System.currentTimeMillis();
|
||||
ZySelfCorrectVo result = new ZySelfCorrectVo();
|
||||
try {
|
||||
ZySelfCorrectVo result = new ZySelfCorrectVo();
|
||||
result.setCode(ZyBaseVo.errorCode);
|
||||
boolean isToken = checkIsToken(accessToken);
|
||||
// 判断token
|
||||
@@ -96,19 +111,19 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// 校验加密参数
|
||||
boolean isSign = checkSign(params);
|
||||
if (!isSign) {
|
||||
String resJson = checkSign(params);
|
||||
if (ObjectUtil.isEmpty(resJson)) {
|
||||
String msg = "数据加密认证失败!sign值验证失败";
|
||||
result.setCode(ZyBaseVo.signError);
|
||||
result.setMsg(msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
return null;
|
||||
return BeanUtil.beanToMap(result);
|
||||
} catch (Exception e) {
|
||||
String error = String.format("|%s||correct|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
return null;
|
||||
return result.getErrorMap();
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
@@ -120,7 +135,7 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
* 第三方一卡通系统提供扣费接口
|
||||
*/
|
||||
@Override
|
||||
public ZySelfPayVo pay(ZySelfPayDto params, String accessToken) {
|
||||
public Map<String, Object> pay(ZySelfPayDto params, String accessToken) {
|
||||
ThirdZyBizEnumType bizType = ThirdZyBizEnumType.SELF_PAY;
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
entity.setBizType(bizType.getType());
|
||||
@@ -137,19 +152,57 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// 校验加密参数
|
||||
boolean isSign = checkSign(params);
|
||||
if (!isSign) {
|
||||
String jsonRes = checkSign(params);
|
||||
if (ObjectUtil.isEmpty(jsonRes)) {
|
||||
String msg = "数据加密认证失败!sign值验证失败";
|
||||
result.setCode(ZyBaseVo.signError);
|
||||
result.setMsg(msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
return result;
|
||||
result.setCode(ZyBaseVo.errorCode);
|
||||
result.setMsg(ZyBaseVo.defaultErrorMsg);
|
||||
ZySelfPayDto dto = JSONUtil.toBean(jsonRes, ZySelfPayDto.class);
|
||||
String accNum = dto.getAccNum();
|
||||
ThirdZyIdDictEntity userIdDict = thirdZyIdDictMapper.getByZyIds(bizType, accNum);
|
||||
if (ObjectUtil.isEmpty(userIdDict)) {
|
||||
throw new RuntimeException("用户id不存在");
|
||||
}
|
||||
String amount = dto.getAmount();
|
||||
if (ObjectUtil.isEmpty(amount)) {
|
||||
throw new RuntimeException("金额转换失败");
|
||||
}
|
||||
int payPrice = new BigDecimal(amount).multiply(BigDecimal.valueOf(100)).intValue();
|
||||
String dealTime = dto.getDealTime();
|
||||
LocalDateTime payTime = LocalDateTimeUtil.parse(dealTime, DatePattern.NORM_DATETIME_PATTERN);
|
||||
// 调用硬件接口
|
||||
HardCallbackPayDto payDto = new HardCallbackPayDto();
|
||||
payDto.setUserId(Long.valueOf(userIdDict.getSelfId()));
|
||||
payDto.setPayPrice(payPrice);
|
||||
payDto.setPayTime(payTime);
|
||||
payDto.setOrderNo(dto.getSerialNum());
|
||||
HardCallbackPayVo payRes = hardCallback.pay(payDto).getData();
|
||||
result.setCode(payRes.getCode().getType());
|
||||
switch (payRes.getCode()) {
|
||||
case SUCCESS -> {
|
||||
result.setMsg(ZyBaseVo.selfSuccessMsg);
|
||||
result.setAccNum(payRes.getUserId().toString());
|
||||
result.setAccName(payRes.getUsername());
|
||||
result.setPerCode(payRes.getUserId().toString());
|
||||
result.setPlatformSerialNum(dto.getSerialNum());
|
||||
result.setSerialNum(dto.getSerialNum());
|
||||
result.setAmount(amount);
|
||||
result.setRecDate(LocalDateTimeUtil.format(payRes.getPayTime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
return zyApiTool.getSelfEncryptionMap(BeanUtil.beanToMap(result));
|
||||
}
|
||||
default -> {
|
||||
return result.getErrorMap();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String error = String.format("|%s||pay|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
return result;
|
||||
return result.getErrorMap();
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
@@ -210,46 +263,62 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
log.info("|{}|checkIsToken校验错误,未传入token|{}|", TAG, string);
|
||||
return false;
|
||||
}
|
||||
Claims claims = Jwts.parser()
|
||||
.setSigningKey(zyConfig.getSelfAppSecret())
|
||||
.parseClaimsJws(string)
|
||||
.getBody();
|
||||
String token = (String) claims.get(zyConfig.getSelfTokenKey());
|
||||
String redisKey = CacheConstants.THIRDPARTY_ZY_SELF_TOKEN + token;
|
||||
String json = redisTemplate.opsForValue().get(redisKey);
|
||||
if (ObjectUtil.isEmpty(json)) {
|
||||
log.info("|{}|checkIsToken校验错误token|{}|", TAG, string);
|
||||
try {
|
||||
Claims claims = Jwts.parser()
|
||||
.setSigningKey(zyConfig.getSelfTokenSecret())
|
||||
.parseClaimsJws(string)
|
||||
.getBody();
|
||||
String token = (String) claims.get(zyConfig.getSelfTokenKey());
|
||||
String redisKey = CacheConstants.THIRDPARTY_ZY_SELF_TOKEN + token;
|
||||
String json = redisTemplate.opsForValue().get(redisKey);
|
||||
if (ObjectUtil.isEmpty(json)) {
|
||||
log.error("|{}|checkIsToken校验错误token|{}|", TAG, string);
|
||||
return false;
|
||||
}
|
||||
log.info("|{}|checkIsToken校验成功info|{}|", TAG, json);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}|checkIsToken意外的错误token|{}|", TAG, string);
|
||||
return false;
|
||||
}
|
||||
log.info("|{}|checkIsToken校验成功info|{}|", TAG, json);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数
|
||||
*/
|
||||
private boolean checkSign(Object obj) {
|
||||
if (ObjectUtil.isEmpty(obj)) return false;
|
||||
private String checkSign(Object obj) {
|
||||
if (ObjectUtil.isEmpty(obj)) return null;
|
||||
try {
|
||||
Map<String, Object> map = BeanUtil.beanToMap(obj);
|
||||
if (ObjectUtil.isEmpty(map)) return false;
|
||||
if (ObjectUtil.isEmpty(map)) return null;
|
||||
Map<String, Object> paramsMap = new TreeMap<>(map);
|
||||
paramsMap.remove("sign");
|
||||
String sign = map.getOrDefault("sign", "").toString();
|
||||
if (ObjectUtil.isEmpty(sign)) {
|
||||
log.error("|{}|checkSign意外的错误,sign为空", sign);
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
if (ObjectUtil.isEmpty(paramsMap)) {
|
||||
log.error("|{}|checkSign意外的错误,paramsMap为空", paramsMap);
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof String) {
|
||||
entry.setValue(Base64.decodeStr((String) value));
|
||||
} else {
|
||||
entry.setValue(Base64.decodeStr(value.toString()));
|
||||
}
|
||||
}
|
||||
String string = zyApiTool.getResultSign(paramsMap);
|
||||
if (ObjectUtil.equals(sign, string)) {
|
||||
return JSONUtil.toJsonStr(paramsMap);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("|{}|checkSign意外的错误,加密参数|{}|", TAG, JSONUtil.toJsonStr(obj), e);
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// 生成token
|
||||
|
||||
+3
-3
@@ -51,7 +51,7 @@ public class ThirdZyStrideServiceImpl implements ThirdZyStrideService {
|
||||
encryptionBody.put("dealers", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
|
||||
Map<String, Object> body = zyApiTool.getZyEncryptionMap(encryptionBody);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(body));
|
||||
String res = HttpRequest.post(url).form(body).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
@@ -90,7 +90,7 @@ public class ThirdZyStrideServiceImpl implements ThirdZyStrideService {
|
||||
encryptionBody.put("dealers", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
|
||||
Map<String, Object> body = zyApiTool.getZyEncryptionMap(encryptionBody);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(body));
|
||||
String res = HttpRequest.post(url).form(body).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
@@ -129,7 +129,7 @@ public class ThirdZyStrideServiceImpl implements ThirdZyStrideService {
|
||||
encryptionBody.put("dealers", dto);
|
||||
entity.setApiUrl(url);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
|
||||
Map<String, Object> body = zyApiTool.getZyEncryptionMap(encryptionBody);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(body));
|
||||
String res = HttpRequest.post(url).form(body).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) {
|
||||
|
||||
+40
-21
@@ -6,15 +6,12 @@ import cn.hutool.core.util.RandomUtil;
|
||||
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.constant.ThirdZyBizEnumType;
|
||||
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyIdDictEntity;
|
||||
import com.bsd.pjcloud.thirdparty.mapper.zy.ThirdZyIdDictMapper;
|
||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerGetTokenVo;
|
||||
import io.undertow.security.idm.DigestAlgorithm;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -23,8 +20,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -135,35 +130,59 @@ public class ZyApiTool {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> getEncryptionMap(Map<String, Object> params, String... str) {
|
||||
/**
|
||||
* 获取正元传输的数据
|
||||
*/
|
||||
public Map<String, Object> getZyEncryptionMap(Map<String, Object> params, String... str) {
|
||||
Map<String, Object> body = new LinkedHashMap<>();
|
||||
if (ObjectUtil.isEmpty(str)) return body;
|
||||
for (String v : str) {
|
||||
body.put(v, params.getOrDefault(v, null));
|
||||
}
|
||||
prePost(body);
|
||||
prePost(body, true);
|
||||
return body;
|
||||
}
|
||||
|
||||
public Map<String, Object> getEncryptionMap(Map<String, Object> params) {
|
||||
public Map<String, Object> getZyEncryptionMap(Map<String, Object> params) {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("data", params);
|
||||
prePost(body);
|
||||
prePost(body, true);
|
||||
return body;
|
||||
}
|
||||
|
||||
public Map<String, Object> removeEmptyMap(Map<String, Object> params) {
|
||||
if (ObjectUtil.isEmpty(params)) return null;
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value == null) {
|
||||
params.remove(entry.getKey());
|
||||
}
|
||||
/**
|
||||
* 获取第三方传输的数据
|
||||
*/
|
||||
public Map<String, Object> getSelfEncryptionMap(Map<String, Object> params, String... str) {
|
||||
Map<String, Object> body = new LinkedHashMap<>();
|
||||
if (ObjectUtil.isEmpty(str)) return body;
|
||||
for (String v : str) {
|
||||
body.put(v, params.getOrDefault(v, null));
|
||||
}
|
||||
return params;
|
||||
prePost(body, false);
|
||||
return body;
|
||||
}
|
||||
|
||||
private void prePost(Map<String, Object> params) {
|
||||
public Map<String, Object> getSelfEncryptionMap(Map<String, Object> params) {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("data", params);
|
||||
prePost(body, false);
|
||||
return body;
|
||||
}
|
||||
|
||||
public String getResultSign(Map<String, Object> params) {
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof String) {
|
||||
entry.setValue(Base64.encode((String) value));
|
||||
} else {
|
||||
entry.setValue(Base64.encode(value.toString()));
|
||||
}
|
||||
}
|
||||
return generateSign(params, false);
|
||||
}
|
||||
|
||||
private void prePost(Map<String, Object> params, boolean isZy) {
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof String) {
|
||||
@@ -173,7 +192,7 @@ public class ZyApiTool {
|
||||
entry.setValue(json);
|
||||
}
|
||||
}
|
||||
String sign = generateSign(params);
|
||||
String sign = generateSign(params, isZy);
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof String) {
|
||||
@@ -185,7 +204,7 @@ public class ZyApiTool {
|
||||
params.put("sign", sign);
|
||||
}
|
||||
|
||||
private String generateSign(Map<String, Object> params) {
|
||||
private String generateSign(Map<String, Object> params, boolean isZy) {
|
||||
// 将参数以参数名的字典升序排序
|
||||
Map<String, Object> sortParams = new TreeMap<String, Object>(params);
|
||||
Set<Map.Entry<String, Object>> entrys = sortParams.entrySet();
|
||||
@@ -193,7 +212,7 @@ public class ZyApiTool {
|
||||
for (Map.Entry<String, Object> entry : entrys) {
|
||||
baseString.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
|
||||
}
|
||||
baseString.append("key=").append(zyConfig.getAppId());
|
||||
baseString.append("key=").append(isZy ? zyConfig.getAppId() : zyConfig.getSelfAppId());
|
||||
String signStr = baseString.toString();
|
||||
String digestHex = DigestUtils.md5Hex(signStr);
|
||||
log.info("|{}|加密前的参数为|{}|加密后的参数为|{}|", TAG, signStr, digestHex);
|
||||
|
||||
+1
-1
@@ -119,12 +119,12 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
@Override
|
||||
public void delByIds(ArrayList<Long> list) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
baseMapper.deleteByIds(list);
|
||||
// 删除缓存
|
||||
list.forEach(v -> {
|
||||
redisTemplate.opsForValue().getAndDelete(CacheConstants.WALLET_MCH + v);
|
||||
walletThirdZyService.syncAllMch(v, Boolean.TRUE);
|
||||
});
|
||||
baseMapper.deleteByIds(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+18
-9
@@ -92,8 +92,10 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService {
|
||||
syncList.add(entity);
|
||||
}
|
||||
try {
|
||||
ZyMerSyncDealerInfoVo res = thirdZyService.syncDealerInfo(syncList).getData();
|
||||
if (ObjectUtil.isEmpty(res)) return;
|
||||
if (ObjectUtil.isNotEmpty(syncList)) {
|
||||
ZyMerSyncDealerInfoVo res = thirdZyService.syncDealerInfo(syncList).getData();
|
||||
if (ObjectUtil.isEmpty(res)) return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("|{}syncAllMch 调用第三方接口错误|", TAG);
|
||||
}
|
||||
@@ -135,8 +137,10 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService {
|
||||
syncList.add(entity);
|
||||
}
|
||||
try {
|
||||
ZyMerSyncEnterpriseInfoVo res = thirdZyService.syncEnterpriseInfoApi(syncList).getData();
|
||||
if (ObjectUtil.isEmpty(res)) return;
|
||||
if (ObjectUtil.isNotEmpty(syncList)) {
|
||||
ZyMerSyncEnterpriseInfoVo res = thirdZyService.syncEnterpriseInfoApi(syncList).getData();
|
||||
if (ObjectUtil.isEmpty(res)) return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("|{}syncAllDept 调用第三方接口错误|", TAG);
|
||||
}
|
||||
@@ -171,8 +175,10 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService {
|
||||
syncList.add(entity);
|
||||
}
|
||||
try {
|
||||
ZyMerSyncAccClassInfoVo res = thirdZyService.syncAccClassInfoApi(syncList).getData();
|
||||
if (ObjectUtil.isEmpty(res)) return;
|
||||
if (ObjectUtil.isNotEmpty(syncList)) {
|
||||
ZyMerSyncAccClassInfoVo res = thirdZyService.syncAccClassInfoApi(syncList).getData();
|
||||
if (ObjectUtil.isEmpty(res)) return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("|{}syncAllRole 调用第三方接口错误|", TAG);
|
||||
}
|
||||
@@ -184,7 +190,7 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService {
|
||||
public void syncAllUser(Long userId) {
|
||||
Page page = new Page();
|
||||
page.setCurrent(1);
|
||||
page.setSize(10);
|
||||
page.setSize(100);
|
||||
// 查询身份信息
|
||||
List<SysRole> roleList = remoteRoleService.findRolesByCodes(List.of(DEFAULT_USER_ROLE_CODE)).getData();
|
||||
if (ObjectUtil.isEmpty(roleList)) {
|
||||
@@ -246,14 +252,17 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService {
|
||||
item.setCardSID(v.getCardNumber());
|
||||
item.setCardStatus(getCardStatus(v.getStatus()));
|
||||
item.setEPID(mch.getDeptId().toString());
|
||||
item.setPerCode(v.getUserId().toString());
|
||||
item.setAccClassID(roleId.toString());
|
||||
item.setPhoneNo(v.getUserMobile());
|
||||
item.setFixId(syncAllMchVersion);
|
||||
syncList.add(item);
|
||||
}
|
||||
try {
|
||||
ZyMerSyncAccountInfoVo.DataVo res = thirdZyService.syncAccountInfoApi(syncList).getData();
|
||||
if (ObjectUtil.isEmpty(res)) return false;
|
||||
if (ObjectUtil.isNotEmpty(syncList)) {
|
||||
ZyMerSyncAccountInfoVo.DataVo res = thirdZyService.syncAccountInfoApi(syncList).getData();
|
||||
if (ObjectUtil.isEmpty(res)) return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("|{}syncAllUserGroup 调用第三方接口错误|", TAG);
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user