|
@@ -733,6 +733,59 @@ public class WmTaxHelperController {
|
|
|
return R.failed("该结算主体信息不全,不支持税邦云操作");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 结算回调操作
|
|
|
+ *
|
|
|
+ * @param userId 用户id
|
|
|
+ * @param body 回调内容(加密)
|
|
|
+ * @return 回调结果
|
|
|
+ */
|
|
|
+ @Inner(value = false)
|
|
|
+ @PostMapping(value = "/{user_id}/settlementNotify")
|
|
|
+ public TaxHelperResponse taxHelperSettlementNotify(@PathVariable(value = "user_id") String userId,
|
|
|
+ @RequestBody String body) {
|
|
|
+ try {
|
|
|
+ // 获取税邦云账号
|
|
|
+ SysSocialDetails condition = new SysSocialDetails();
|
|
|
+ condition.setType(LoginTypeEnum.TAX_HELPER.getType());
|
|
|
+ SysSocialDetails socialDetails = sysSocialDetailsMapper.selectOne(new QueryWrapper<>(condition));
|
|
|
+ String randomKey = socialDetails.getRandomKey();
|
|
|
+
|
|
|
+ //解密回调信息
|
|
|
+ String resInfo = taxHelperService.decryptResp(body, randomKey);
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(resInfo);
|
|
|
+ String code = jsonObject.getStr("code");
|
|
|
+
|
|
|
+ // 回调成功操作
|
|
|
+ if ("2000".equals(code)) {
|
|
|
+ String streamId = jsonObject.getStr("streamId");
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(streamId)) {
|
|
|
+ log.info("streamId获取失败,{}", userId);
|
|
|
+ } else {
|
|
|
+ // 判断当前用户是否已经存在回调操作,避免多次回调
|
|
|
+ String cacheKey = CacheConstants.TAX_HELPER_SETTLEMENT_NOTIFY_KEY + userId;
|
|
|
+
|
|
|
+ boolean absent = redisTemplate.opsForValue().setIfAbsent(cacheKey, userId, 3, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ if (!absent) {
|
|
|
+ log.error("当前用户:{},正在处理结算回调操作。", userId);
|
|
|
+ return new TaxHelperResponse("4000", "结算通知回调重复");
|
|
|
+ }
|
|
|
+
|
|
|
+ settleNoteService.settleNotify(streamId, true);
|
|
|
+ }
|
|
|
+ return new TaxHelperResponse("2000", "结算通知回调成功");
|
|
|
+ } else {
|
|
|
+ return new TaxHelperResponse("4000", "结算通知回调失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("税邦云解密失败");
|
|
|
+ return new TaxHelperResponse("4000", "回调信息解密失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 结算回调操作
|
|
@@ -744,7 +797,7 @@ public class WmTaxHelperController {
|
|
|
*/
|
|
|
@Inner(value = false)
|
|
|
@PostMapping(value = "/{user_id}/{version}/settlementNotify")
|
|
|
- public TaxHelperResponse taxHelperSettlementNotify(@PathVariable(value = "user_id") String userId,
|
|
|
+ public TaxHelperResponse taxHelperSettlementNotifyV2(@PathVariable(value = "user_id") String userId,
|
|
|
@PathVariable(value = "version") String version,
|
|
|
@RequestBody String body) {
|
|
|
|