您的位置:首页 > 编程语言 > Java开发

个人处理结算异步通知接口(被回调对象)

2017-11-13 14:47 369 查看
/**
* 个人处理结算异步通知
*
* @param dto
* @return
*/
@RequestMapping(value = "/personal")
@ResponseBody
public Object personal(HttpServletRequest request, HttpServletResponse response){
Map<String, String> result = new HashMap<String, String>();
result.put("respCode", "N");
try {
String content = this.getRequestBody(request);
logger.info("收到结算系统结果回调:{}", content);

WithdrawCallbackDto dto=JSON.parseObject(content, WithdrawCallbackDto.class);

logger.info("个人:收到结算系统结果回调:{}", dto);
if (!checkSmtSign(dto)) {
result.put("respMsg", "验签失败");
return result;
}

//查询个人提现记录流水
WithdrawPersonalFlowEntity entity=withdrawPersonalFlowService.queryPersonalFlowByFlowNo(dto.getOutTradeNo());

if(entity==null){
result.put("respMsg", "操作失败:个人提现流水不存在");
return result;

}

//校验提现流水状态是否支持退款和更新状态操作
if(entity.getStatus()==WithdrawStatusEnum.ACCEPT.getStatus()){

result.put("respCode", "Y");

// 准备个人提现流水更新参数准备
SettlementResponseDto responseDto = personalParametersPrepare(dto);

// 代表结算成功
if (dto.getRespCode().equals("100005")) {

//更新个人提现流水操作
withdrawPersonalFlowService.updateFlowBySmt(responseDto);

}else{// 代表结算失败

//更新个人提现流水操作
withdrawPersonalFlowService.updateFlowBySmt(responseDto);

//个人退还提现本金参数准备
WithdrawRefundDto  refundDto=personalRefundOfCommissionCharge(dto);

//个人提现,退还本金处理
withdrawPersonalFlowService.refund(refundDto);
}
result.put("respMsg","验签成功,个人退款成功");
}else{
result.put("respMsg", "操作失败:个人提现流水状态有误");
return result;
}

} catch (PaycoreException e) {
logger.error("个人处理结算系统异步回调失败, {}", e);
result.put("respMsg", e.getErrorMsg());
return result;
} catch(Exception e){
logger.error("个人处理结算系统异步回调失败, {}", e);
result.put("respMsg","系统异常" );
return result;
}
return result;
}

回调验签

private boolean checkSmtSign(WithdrawCallbackDto dto){
String[] exceptParams = {"signCode", "signType"};
return SignatureUtil.callBackVerify(dto, exceptParams);

}xml 配置
<bean id="signUtil" class="com.qbao.signature.sign.client.CuratorZookeeperClient"
init-method="init" lazy-init="false">
<property name="connectString" value="${zk.hosts}" />
<property name="needsAll" value="true" />
</bean>

<bean id="verifyUtil" class="com.qbao.signature.verify.client.CuratorZookeeperClient"
init-method="init" lazy-init="false">
<property name="connectString" value="${zk.hosts}"/>
</bean>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java
相关文章推荐