| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.service.IUserInfoService; |
| | | import com.stylefeng.guns.modular.system.util.PayMoneyUtil; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackRequest; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackResponse; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.Payments; |
| | | import com.stylefeng.guns.modular.system.util.UUIDUtil; |
| | | 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 org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | |
| | | /** |
| | | * 微信余额充值回调函数 |
| | | * @param request |
| | | * @param callbackRequest |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/wxCancelUserBalance") |
| | | public void wxCancelUserBalance(HttpServletRequest request, HttpServletResponse response){ |
| | | public CallbackResponse wxCancelUserBalance(@RequestBody CallbackRequest callbackRequest){ |
| | | CallbackResponse callbackResponse = new CallbackResponse(); |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | | String id = map.get("out_trade_no"); |
| | | String order_id = map.get("out_trade_no"); |
| | | String uid = map.get("attach"); |
| | | userInfoService.payCancelUserBalance(null, order_id, Integer.valueOf(id), 1); |
| | | //icbcPayUtil.answer(response); |
| | | |
| | | response.getOutputStream().print("success"); |
| | | /** |
| | | * 指示服务是否成功或付费的总体请求代码。。 |
| | | * 177-部分付费请求 |
| | | * 178-表明请求已全额支付 |
| | | * 179-表示请求已部分支付但已过期。 |
| | | * 129-请求已过期,未付款。 |
| | | * 180.商户拒绝请求 |
| | | * 183-商户接受请求,我们可以结算资金 |
| | | * 188-商户收到请求。 |
| | | */ |
| | | String request_status_code = callbackRequest.getRequest_status_code(); |
| | | String out_trade_no = callbackRequest.getMerchant_transaction_id(); |
| | | if("177".equals(request_status_code) || "178".equals(request_status_code)){ |
| | | Payments payments = callbackRequest.getPayments().get(0); |
| | | String order_id = payments.getPayer_transaction_id(); |
| | | if(ToolUtil.isNotEmpty(out_trade_no)){ |
| | | Integer language = Integer.valueOf(out_trade_no.substring(17, 18)); |
| | | Integer id = Integer.valueOf(out_trade_no.substring(18)); |
| | | userInfoService.payCancelUserBalance(null, order_id, Integer.valueOf(id), 1, language); |
| | | callbackResponse.setCheckout_request_id(order_id); |
| | | callbackResponse.setMerchant_transaction_id(out_trade_no); |
| | | callbackResponse.setStatus_code("183"); |
| | | callbackResponse.setStatus_description("Payment processed successfully"); |
| | | callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16)); |
| | | } |
| | | }else{ |
| | | callbackResponse.setCheckout_request_id(UUIDUtil.getRandomCode(16)); |
| | | callbackResponse.setMerchant_transaction_id(out_trade_no); |
| | | callbackResponse.setStatus_code("180"); |
| | | callbackResponse.setStatus_description("means payment rejected."); |
| | | callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16)); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return callbackResponse; |
| | | } |
| | | |
| | | |
| | |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | String id = map.get("out_trade_no"); |
| | | String order_id = map.get("out_trade_no"); |
| | | //String uid = map.get("attach"); |
| | | userInfoService.payCancelUserBalance(null, order_id, Integer.valueOf(id), 2); |
| | | //icbcPayUtil.answer(response); |
| | | String[] s = order_id.split("_"); |
| | | Integer language = Integer.valueOf(s[1]); |
| | | userInfoService.payCancelUserBalance(null, s[0], Integer.valueOf(id), 2, language); |
| | | response.setContentType("text/html;charset=UTF-8"); |
| | | PrintWriter out; |
| | | out = response.getWriter(); |