|
@ -2,9 +2,14 @@ package com.yihu.jw.care.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.wechat.pay.java.core.exception.ServiceException;
|
|
|
import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferResponse;
|
|
|
import com.wechat.pay.java.service.transferbatch.model.TransferBatchEntity;
|
|
|
import com.wechat.pay.java.service.transferbatch.model.TransferDetailEntity;
|
|
|
import com.yihu.jw.care.RequestParamUtil;
|
|
|
import com.yihu.jw.care.service.AqgService;
|
|
|
import com.yihu.jw.care.service.TXYSmsService;
|
|
|
import com.yihu.jw.care.service.WeixinMchApi;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
@ -36,8 +41,87 @@ public class TransforController {
|
|
|
private AqgService aqgService;
|
|
|
@Autowired
|
|
|
private TXYSmsService txySmsService;
|
|
|
@Autowired
|
|
|
private WeixinMchApi weixinMchApi;
|
|
|
|
|
|
private static final RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
|
@ApiOperation("批量转账")
|
|
|
@RequestMapping(value = "initiateBatchTransfer", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String initiateBatchTransfer(
|
|
|
@ApiParam(name="outBatchNo",required = true,value="批次no")
|
|
|
@RequestParam(value = "outBatchNo",required = true) String outBatchNo,
|
|
|
@ApiParam(name="batchName",required = true,value="批次名")
|
|
|
@RequestParam(value = "batchName",required = true) String batchName,
|
|
|
@ApiParam(name="batchRemark",required = true,value="批次备注")
|
|
|
@RequestParam(value = "batchRemark",required = true) String batchRemark,
|
|
|
@ApiParam(name="totalAmount",required = true,value="总费用单位分")
|
|
|
@RequestParam(value = "totalAmount",required = true) Long totalAmount,
|
|
|
@ApiParam(name="totalNum",required = true)
|
|
|
@RequestParam(value = "totalNum",required = true) Integer totalNum,
|
|
|
@ApiParam(name="outDetailNo",required = true)
|
|
|
@RequestParam(value = "outDetailNo",required = true) String outDetailNo,
|
|
|
@ApiParam(name="transferAmount",required = true)
|
|
|
@RequestParam(value = "transferAmount",required = true) Long transferAmount,
|
|
|
@ApiParam(name="transferRemark",required = true)
|
|
|
@RequestParam(value = "transferRemark",required = true) String transferRemark,
|
|
|
@ApiParam(name="openid",required = true,value="openid")
|
|
|
@RequestParam(value = "openid",required = true) String openid) {
|
|
|
try {
|
|
|
//String outBatchNo,String batchName,String batchRemark
|
|
|
// ,Long totalAmount,Integer totalNum,String outDetailNo,Long transferAmount,String transferRemark,String openid
|
|
|
InitiateBatchTransferResponse res = weixinMchApi.initiateBatchTransfer(outBatchNo,batchName,batchRemark
|
|
|
,totalAmount,totalNum,outDetailNo,transferAmount,transferRemark,openid);
|
|
|
return write(200,"res","data", res);
|
|
|
}catch (ServiceException se){
|
|
|
return write(-1,se.getErrorMessage(),"data", se.getMessage());
|
|
|
}catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"转账失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("通过微信批次单号查询批次单")
|
|
|
@RequestMapping(value = "getTransferBatchByNo", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String getTransferBatchByNo(
|
|
|
@ApiParam(name="batchId",required = true,value="批次id")
|
|
|
@RequestParam(value = "batchId",required = true) String batchId,
|
|
|
@ApiParam(name="offset",required = true,value="请求资源起始位置")
|
|
|
@RequestParam(value = "offset",required = true) Integer offset,
|
|
|
@ApiParam(name="limit",required = true,value="最大资源条数")
|
|
|
@RequestParam(value = "limit",required = true) Integer limit,
|
|
|
@ApiParam(name="detailStatus",required = true,value="状态")
|
|
|
@RequestParam(value = "detailStatus",required = true) String detailStatus) {
|
|
|
try {
|
|
|
//String batchId,Integer offset,Integer limit,String detailStatus
|
|
|
TransferBatchEntity res = weixinMchApi.getTransferBatchByNo(batchId,offset,limit,detailStatus);
|
|
|
return write(200,"res","data", res);
|
|
|
}catch (ServiceException se){
|
|
|
return write(-1,se.getErrorMessage(),"data", se.getMessage());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"查询失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("通过微信明细单号查询明细单")
|
|
|
@RequestMapping(value = "getTransferDetailByNo", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String getTransferDetailByNo(
|
|
|
@ApiParam(name="batchId",required = true,value="批次id")
|
|
|
@RequestParam(value = "batchId",required = true) String batchId,
|
|
|
@ApiParam(name="detailId",required = true,value="明细id")
|
|
|
@RequestParam(value = "detailId",required = true) String detailId) {
|
|
|
try {
|
|
|
TransferDetailEntity res = weixinMchApi.getTransferDetailByNo(batchId,detailId);
|
|
|
return write(200,"res","data", res);
|
|
|
}catch (ServiceException se){
|
|
|
return write(-1,se.getErrorMessage(),"data", se.getMessage());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"查询失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("腾讯云短信发送")
|
|
|
@RequestMapping(value = "txSendMessage", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String txSendMessage(
|
|
@ -544,4 +628,26 @@ public class TransforController {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 返回接口处理结果
|
|
|
*
|
|
|
* @param code 结果码,成功为200
|
|
|
* @param msg 结果提示信息
|
|
|
* @param value 结果数据
|
|
|
* @return
|
|
|
*/
|
|
|
public String write(int code, String msg, String key, Object value) {
|
|
|
try {
|
|
|
Map<Object, Object> map = new HashMap<Object, Object>();
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
map.put("status", code);
|
|
|
map.put("msg", msg);
|
|
|
map.put(key, value);
|
|
|
return mapper.writeValueAsString(map);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "服务器异常,请稍候再试!");
|
|
|
}
|
|
|
}
|
|
|
}
|