| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.huifu.bspay.sdk.opps.core.utils.RsaUtils; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.account.controller.AppOrderController; |
| | | import com.stylefeng.guns.modular.account.model.TEnterpriseWithdrawal; |
| | |
| | | import com.stylefeng.guns.modular.cloudPayment.example.DepositExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.req.DepositReq; |
| | | import com.stylefeng.guns.modular.enums.PaymentTypeEnum; |
| | | import com.stylefeng.guns.modular.huifu.biz.DouGongPayUtil; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.UserInfo; |
| | | import com.stylefeng.guns.modular.system.model.UserWithdrawal; |
| | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | import static org.bouncycastle.asn1.x500.style.RFC4519Style.uid; |
| | | |
| | | |
| | | /** |
| | | * 支付回调 |
| | |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private UserWithdrawalService userWithdrawalService; |
| | | private UserWithdrawalService userWithdrawalService; |
| | | @Autowired |
| | | private AppOrderController appOrderController; |
| | | |
| | | |
| | | /** |
| | | * 斗拱充值回调函数 |
| | | } |
| | | * @param request |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/DGCancelUserBalance") |
| | | public void DGCancelUserBalance(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.out.println("DG额充值回调函数"); |
| | | String sign = request.getParameter("sign"); |
| | | String resp_data = request.getParameter("resp_data"); |
| | | System.out.println(sign); |
| | | System.out.println(resp_data); |
| | | resp_data = resp_data.replaceAll("& #40;", "(").replaceAll("& #41;", ")"); |
| | | |
| | | |
| | | boolean verify = RsaUtils.verify(resp_data, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsWrruP9JBxrUd8uEX5Z8y7pg/UIr5RNHSgDnHqNI1hbi2MfTzB5vZ275wSFFaLDD9BesgDWqsUepPS/opROlDCg9y6WYH8mkN23NmHL9F8kT48OMmH722am+Hp0XVMMwXqA0oNt4f7oW6kDemjZW8/RT4vIE7cyxoxSsVRvjqSpx9wDgFLPWh3o0pHQaoxLyeUsGBATHFrxEDlosBvsuXjMcgjPKXALrcemzKOhBmBkLgyxNVmh61ZK+FNXd+/X4PeZlnWf54NRQAUKe1308E6IIaszo+CjneKuhj1m/X4f7AIvxAqlhuCV5E/DfKRmGopxaWqdtE960Y/H4SmBh2wIDAQAB", sign); |
| | | |
| | | if (verify) { |
| | | JSONObject jsonObject = JSONObject.parseObject(resp_data); |
| | | String order_id = jsonObject.get("out_trans_id").toString(); |
| | | String out_trade_no = jsonObject.get("req_seq_id").toString(); |
| | | String trans_stat = jsonObject.get("trans_stat").toString(); |
| | | if ("S".equals(trans_stat)) { |
| | | String[] split = out_trade_no.split("_"); |
| | | Integer uid = Integer.valueOf(split[0]); |
| | | Integer id = Integer.valueOf(split[1]); |
| | | String payAmt = jsonObject.get("pay_amt").toString(); |
| | | userInfoService.payCancelUserBalance(Integer.valueOf(uid), order_id, Integer.valueOf(id), 1); |
| | | // appOrderController.createAllocationReqUser(1, Integer.valueOf(uid), 1, new BigDecimal(payAmt).divide(new BigDecimal(100)).doubleValue()); |
| | | // cloudPay(Integer.valueOf(uid),map.get("total_fee"),map.get("transaction_id"),1); |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(200); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | /** |
| | | * 斗拱充值回调函数 |
| | | } |
| | | * @param request |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/DGCancelUserBalanceZfb") |
| | | public void DGCancelUserBalanceZfb(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.out.println("DG额充值回调函数"); |
| | | String sign = request.getParameter("sign"); |
| | | String resp_data = request.getParameter("resp_data"); |
| | | System.out.println(sign); |
| | | System.out.println(resp_data); |
| | | resp_data = resp_data.replaceAll("& #40;", "(").replaceAll("& #41;", ")"); |
| | | |
| | | |
| | | boolean verify = RsaUtils.verify(resp_data, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsWrruP9JBxrUd8uEX5Z8y7pg/UIr5RNHSgDnHqNI1hbi2MfTzB5vZ275wSFFaLDD9BesgDWqsUepPS/opROlDCg9y6WYH8mkN23NmHL9F8kT48OMmH722am+Hp0XVMMwXqA0oNt4f7oW6kDemjZW8/RT4vIE7cyxoxSsVRvjqSpx9wDgFLPWh3o0pHQaoxLyeUsGBATHFrxEDlosBvsuXjMcgjPKXALrcemzKOhBmBkLgyxNVmh61ZK+FNXd+/X4PeZlnWf54NRQAUKe1308E6IIaszo+CjneKuhj1m/X4f7AIvxAqlhuCV5E/DfKRmGopxaWqdtE960Y/H4SmBh2wIDAQAB", sign); |
| | | |
| | | if (verify) { |
| | | JSONObject jsonObject = JSONObject.parseObject(resp_data); |
| | | String order_id = jsonObject.get("out_trans_id").toString(); |
| | | String out_trade_no = jsonObject.get("req_seq_id").toString(); |
| | | String trans_stat = jsonObject.get("trans_stat").toString(); |
| | | if ("S".equals(trans_stat)) { |
| | | String[] split = out_trade_no.split("_"); |
| | | Integer uid = Integer.valueOf(split[0]); |
| | | Integer id = Integer.valueOf(split[1]); |
| | | String payAmt = jsonObject.get("pay_amt").toString(); |
| | | userInfoService.payCancelUserBalance(Integer.valueOf(uid), order_id, Integer.valueOf(id), 2); |
| | | |
| | | // cloudPay(Integer.valueOf(uid),map.get("total_fee"),map.get("transaction_id"),1); |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(200); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 微信余额充值回调函数 |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/wxCancelUserBalance") |
| | | public void wxCancelUserBalance(HttpServletRequest request, HttpServletResponse response){ |
| | | public void wxCancelUserBalance(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.out.println("微信余额充值回调函数"); |
| | | Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | |
| | | String uid = map.get("attach"); |
| | | String result = map.get("result"); |
| | | userInfoService.payCancelUserBalance(Integer.valueOf(uid), order_id, Integer.valueOf(id), 1); |
| | | appOrderController.createAllocationReqUser(1,Integer.valueOf(uid),1,new BigDecimal(map.get("total_fee")).divide(new BigDecimal(100)).doubleValue()); |
| | | // cloudPay(Integer.valueOf(uid),map.get("total_fee"),map.get("transaction_id"),1); |
| | | appOrderController.createAllocationReqUser(1, Integer.valueOf(uid), 1, new BigDecimal(map.get("total_fee")).divide(new BigDecimal(100)).doubleValue()); |
| | | // cloudPay(Integer.valueOf(uid),map.get("total_fee"),map.get("transaction_id"),1); |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(result); |
| | | out.flush(); |
| | | out.close(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/aliCancelUserBalance") |
| | | public void aliCancelUserBalance(HttpServletRequest request, HttpServletResponse response){ |
| | | public void aliCancelUserBalance(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.out.println("支付宝余额充值回调"); |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | |
| | | String order_id = map.get("trade_no"); |
| | | String uid = map.get("passback_params"); |
| | | userInfoService.payCancelUserBalance(Integer.valueOf(uid), order_id, Integer.valueOf(id), 2); |
| | | appOrderController.createAllocationReqUser(1,Integer.valueOf(uid),1,new BigDecimal(map.get("total_amount")).doubleValue()); |
| | | appOrderController.createAllocationReqUser(1, Integer.valueOf(uid), 1, new BigDecimal(map.get("total_amount")).doubleValue()); |
| | | // cloudPay(Integer.valueOf(uid),map.get("total_amount"),map.get("trade_no"),0); |
| | | PrintWriter out = response.getWriter(); |
| | | out.print("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void cloudPay(Integer uid,String total_fee,String transaction_id,int type) { |
| | | if(type==1){ |
| | | public void cloudPay(Integer uid, String total_fee, String transaction_id, int type) { |
| | | if (type == 1) { |
| | | BigDecimal divide = new BigDecimal(total_fee).divide(new BigDecimal(100)); |
| | | total_fee=divide.toString(); |
| | | total_fee = divide.toString(); |
| | | } |
| | | System.out.println("回调参数:"+total_fee+"---"+transaction_id); |
| | | System.out.println("回调参数:" + total_fee + "---" + transaction_id); |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | UserWithdrawal driverWith = userWithdrawalService.selectOne(new EntityWrapper<UserWithdrawal>() |
| | | .eq("phone", userInfo.getPhone()) |