标签:
@RequestMapping(value = "callbackAlipay", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<?> callbackAlipay(
@RequestParam(value = "discount", required = false) String discount,
@RequestParam(value = "payment_type", required = false) String payment_type,
@RequestParam(value = "subject", required = false) String subject,
@RequestParam(value = "trade_no", required = false) String trade_no,
@RequestParam(value = "buyer_email", required = false) String buyer_email,
@RequestParam(value = "gmt_create", required = false) String gmt_create,
@RequestParam(value = "notify_type", required = false) String notify_type,
@RequestParam(value = "quantity", required = false) String quantity,
@RequestParam(value = "out_trade_no", required = false) String out_trade_no,
@RequestParam(value = "seller_id", required = false) String seller_id,
@RequestParam(value = "notify_time", required = false) String notify_time,
@RequestParam(value = "body", required = false) String body,
@RequestParam(value = "trade_status", required = false) String trade_status,
@RequestParam(value = "is_total_fee_adjust", required = false) String is_total_fee_adjust,
@RequestParam(value = "total_fee", required = false) String total_fee,
@RequestParam(value = "gmt_payment", required = false) String gmt_payment,
@RequestParam(value = "seller_email", required = false) String seller_email,
@RequestParam(value = "price", required = false) String price,
@RequestParam(value = "buyer_id", required = false) String buyer_id,
@RequestParam(value = "notify_id", required = false) String notify_id,
@RequestParam(value = "use_coupon", required = false) String use_coupon,
@RequestParam(value = "sign_type", required = false) String sign_type,
@RequestParam(value = "sign", required = false) String sign) {
logger.warn("trade_no:"+trade_no);
logger.warn("out_trade_no:"+out_trade_no);
logger.warn("trade_status:"+trade_status);
String result = "fail";
if ("TRADE_FINISHED".equals(trade_status) || "TRADE_SUCCESS".equals(trade_status)) {
// 业务逻辑
}
/**
* Callback WeChatPay one Order
*
* @param OrderDTO
* @return HTTP 200
*/
@RequestMapping(value = "callbackWeChatPay", method = RequestMethod.POST, produces = "text/xml; charset=utf-8")
@ResponseBody
public ResponseEntity<?> callbackWeChatPay(
@RequestBody WeChatCallbackDTO weChatCallbackDTO) {
logger.info("*******************Result_code:*************"+weChatCallbackDTO.getResult_code());
logger.info("*******************Out_trade_no*************:"+weChatCallbackDTO.getOut_trade_no());
logger.info("*******************Total_fee***************:"+weChatCallbackDTO.getTotal_fee());
String result= "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[FAIL]]></return_msg></xml> ";
try {
if("SUCCESS".equals(weChatCallbackDTO.getResult_code())){
OrderDTO order = new OrderDTO();
order.setOrderNum(weChatCallbackDTO.getOut_trade_no());
order.setPaymentAmount((int)Double.parseDouble(weChatCallbackDTO.getTotal_fee())/100);
//微信支付方式
order.setPaymentTypeCD(Constants.PaymentTypeDC_D05B02);
// 业务逻辑
if (!orderService.callback(order)) {
return new ResponseEntity<String>(result, HttpStatus.OK);
}
//保存支付记录
WeChatPaymentHistoryDTO weChatPaymentHistoryDTO=new WeChatPaymentHistoryDTO();
weChatPaymentHistoryDTO.setAppid(weChatCallbackDTO.getAppid());
weChatPaymentHistoryDTO.setBank_type(weChatCallbackDTO.getBank_type());
weChatPaymentHistoryDTO.setCash_fee(weChatCallbackDTO.getBank_type());
weChatPaymentHistoryDTO.setFee_type(weChatCallbackDTO.getFee_type());
weChatPaymentHistoryDTO.setIs_subscribe(weChatCallbackDTO.getIs_subscribe());
weChatPaymentHistoryDTO.setMch_id(weChatCallbackDTO.getMch_id());
weChatPaymentHistoryDTO.setNonce_str(weChatCallbackDTO.getNonce_str());
weChatPaymentHistoryDTO.setOpenid(weChatCallbackDTO.getOpenid());
weChatPaymentHistoryDTO.setOut_trade_no(weChatCallbackDTO.getOut_trade_no());
weChatPaymentHistoryDTO.setResult_code(weChatCallbackDTO.getResult_code());
weChatPaymentHistoryDTO.setReturn_code(weChatCallbackDTO.getReturn_code());
weChatPaymentHistoryDTO.setSign(weChatCallbackDTO.getSign());
weChatPaymentHistoryDTO.setTime_end(weChatCallbackDTO.getTime_end());
weChatPaymentHistoryDTO.setTotal_fee(weChatCallbackDTO.getTotal_fee());
weChatPaymentHistoryDTO.setTrade_type(weChatCallbackDTO.getTrade_type());
weChatPaymentHistoryDTO.setTransaction_id(weChatCallbackDTO.getTransaction_id());
weChatPaymentHistoryService.add(weChatPaymentHistoryDTO);
result= "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml> ";
}
} catch (Exception e) {
e.printStackTrace();
}
return new ResponseEntity<String>(result, HttpStatus.OK);
}
标签:
原文地址:http://www.cnblogs.com/yousen/p/4636426.html