package com.stylefeng.guns.modular.api;
|
|
import com.stylefeng.guns.core.util.ToolUtil;
|
import com.stylefeng.guns.modular.system.service.IReassignService;
|
import com.stylefeng.guns.modular.system.service.ISystemNoticeService;
|
//import com.stylefeng.guns.modular.system.util.ICBCPayUtil;
|
import com.stylefeng.guns.modular.system.util.PayMoneyUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.PrintWriter;
|
import java.util.Map;
|
|
/**
|
* 第三方支付回调控制器
|
*/
|
@RestController
|
@RequestMapping("/base")
|
public class CallbackController {
|
|
@Autowired
|
private IReassignService reassignService;
|
// @Autowired
|
// private ICBCPayUtil icbcPayUtil;
|
|
@Autowired
|
private PayMoneyUtil payMoneyUtil;
|
|
|
|
|
/**
|
* 订单改派微信回调
|
* @param request
|
*/
|
@ResponseBody
|
@PostMapping("/wxReassign")
|
public void wxReassign(HttpServletRequest request, HttpServletResponse response){
|
try {
|
Map<String, String> map = payMoneyUtil.weixinpayCallback(request);
|
if(null != map){
|
String id = map.get("out_trade_no");
|
String order_id = map.get("transaction_id");
|
String result = map.get("result");
|
if(ToolUtil.isNotEmpty(id) && ToolUtil.isNotEmpty(order_id)){
|
PrintWriter out = response.getWriter();
|
out.write(result);
|
out.flush();
|
out.close();
|
reassignService.payReassign(id, order_id, 1);
|
}
|
}
|
|
// Map<String, String> map = icbcPayUtil.payCallback(request);
|
// if(null != map){
|
// String id = map.get("out_trade_no");
|
// String order_id = map.get("order_id");
|
// //调用查询
|
// String s = icbcPayUtil.queryTransaction("", order_id);
|
// if(s.equals("0")){
|
// icbcPayUtil.answer(response);//回调应答
|
// }
|
// if(ToolUtil.isNotEmpty(id) && ToolUtil.isNotEmpty(order_id) && s.equals("0")){
|
// reassignService.payReassign(id, order_id, 1);
|
// }
|
// }
|
}catch (Exception e){
|
e.printStackTrace();
|
}
|
}
|
|
|
/**
|
* 订单改派支付宝回调
|
* @param request
|
*/
|
@ResponseBody
|
@PostMapping("/aliReassign")
|
public void aliReassign(HttpServletRequest request, HttpServletResponse response){
|
try {
|
Map<String, String> map = payMoneyUtil.alipayCallback(request);
|
if(null != map){
|
String id = map.get("out_trade_no");
|
String order_id = map.get("trade_no");
|
if(ToolUtil.isNotEmpty(id) && ToolUtil.isNotEmpty(order_id)){
|
reassignService.payReassign(id, order_id, 2);
|
}
|
}
|
|
|
// Map<String, String> map = icbcPayUtil.payCallback(request);
|
// if(null != map){
|
// String id = map.get("out_trade_no");
|
// String order_id = map.get("order_id");
|
// //调用查询
|
// String s = icbcPayUtil.queryTransaction("", order_id);
|
// if(s.equals("0")){
|
// icbcPayUtil.answer(response);//回调应答
|
// }
|
// if(ToolUtil.isNotEmpty(id) && ToolUtil.isNotEmpty(order_id) && s.equals("0")){
|
// reassignService.payReassign(id, order_id, 2);
|
// }
|
// }
|
}catch (Exception e){
|
e.printStackTrace();
|
}
|
}
|
}
|