| | |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | |
| | | <!--weixin--> |
| | | <dependency> |
| | | <groupId>com.github.binarywang</groupId> |
| | | <artifactId>weixin-java-mp</artifactId> |
| | | <version>2.6.0</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> |
| | |
| | | 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.exception.GunsException; |
| | | import com.stylefeng.guns.core.exception.ServiceExceptionEnum; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/DGReassign") |
| | | public void DGReassign(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | 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); |
| | | // Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | | |
| | | |
| | | 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)){ |
| | | // TODO 司机云闪付 改派微信回调支付充值 |
| | | // String[] s = id.split("_"); |
| | | // if(Integer.valueOf(s[1]) == 3) {//跨城订单 |
| | | // System.out.println("跨城订单"); |
| | | // String[] split1 = s[0].split(","); |
| | | // List<Reassign> reassigns = reassignService.selectBatchIds(Arrays.asList(split1)); |
| | | // cloudPay(reassigns.get(0).getOriginalDriverId(),map.get("total_fee"),map.get("transaction_id"),1); |
| | | // }else { |
| | | // Reassign reassign = reassignService.selectById(s[0]); |
| | | // cloudPay(reassign.getOriginalDriverId(),map.get("total_fee"),map.get("transaction_id"),1); |
| | | // } |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(200); |
| | | out.flush(); |
| | | out.close(); |
| | | String[] split = out_trade_no.split("_"); |
| | | reassignService.payReassign(split[0], order_id, 1); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 订单改派微信回调 |
| New file |
| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.DriverService; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.chanjar.weixin.common.api.WxConsts; |
| | | import me.chanjar.weixin.common.exception.WxErrorException; |
| | | import me.chanjar.weixin.mp.api.WxMpService; |
| | | import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @RestController |
| | | @Slf4j |
| | | @RequestMapping("") |
| | | public class WinxinController { |
| | | |
| | | @Autowired |
| | | private WxMpService wxMpService; |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/wx/getOpenId") |
| | | @ApiOperation(value = "获取最新版本数据", tags = {"司机端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(value = "code", name = "code", required = true, dataType = "String"), |
| | | }) |
| | | public ResultUtil getOpenId(@RequestParam String code, HttpServletRequest request) { |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if (ToolUtil.isEmpty(code)) { |
| | | return ResultUtil.error("参数为空"); |
| | | } |
| | | //未登录过获取openId进行授权 |
| | | String openID = null; |
| | | WxMpOAuth2AccessToken accessToken = wxMpService.oauth2getAccessToken(code); |
| | | openID = accessToken.getOpenId(); |
| | | Driver driver = driverService.selectById(uid); |
| | | driver.setAppletsOpenId(openID); |
| | | driverService.updateById(driver); |
| | | return ResultUtil.success(); |
| | | } catch (Exception e) { |
| | | // e.printStackTrace(); //尽量不要使用这个打印异常,会造成内存锁,使用log日志就好 |
| | | return ResultUtil.error("获取openID异常"); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | 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.model.TEnterpriseWithdrawal; |
| | | import com.stylefeng.guns.modular.account.service.ITEnterpriseWithdrawalService; |
| | | import com.stylefeng.guns.modular.account.service.UserWithdrawalService; |
| | | import com.stylefeng.guns.modular.account.util.Base64Util; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.DepositExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq; |
| | | import com.stylefeng.guns.modular.cloudPayment.req.DepositReq; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.OrderCrossCityInfoWrapper; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.OrderCrossCityWarpper; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.OrderWarpper; |
| | | import com.stylefeng.guns.modular.enums.PaymentTypeEnum; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.Reassign; |
| | |
| | | import com.stylefeng.guns.modular.system.util.SystemException; |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import com.unionpay.upyzt.resp.AllocationResp; |
| | | import com.unionpay.upyzt.resp.DepositResp; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | if(driver.getAppletsOpenId()==null && payType==1){ |
| | | return ResultUtil.openIdError(); |
| | | } |
| | | switch (orderType){ |
| | | |
| | | case 3: |
| | | return orderCrossCityService.payCrossCityOrder(payType, orderId, couponId, type); |
| | | return orderCrossCityService.payCrossCityOrder(payType, orderId, couponId, type,driver.getAppletsOpenId()); |
| | | } |
| | | return ResultUtil.success(new Object()); |
| | | }catch (Exception e){ |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 完成订单微信支付 斗拱 |
| | | * @param request |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/DGPayCrossCity") |
| | | public void DGPayCrossCity(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | |
| | | 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); |
| | | // Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | | if(verify){ |
| | | JSONObject jsonObject = JSONObject.parseObject(resp_data); |
| | | String transaction_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)){ |
| | | System.out.println("完成订单微信支付回调"+jsonObject); |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(200); |
| | | out.flush(); |
| | | out.close(); |
| | | |
| | | String[] split = out_trade_no.split("_"); |
| | | Integer id = Integer.valueOf(split[0]); |
| | | Integer type = Integer.valueOf(split[1]); |
| | | // TODO 司机云闪付 跨城出行微信回调支付充值 |
| | | // OrderCrossCity orderCrossCity = orderCrossCityService.selectById(id); |
| | | // if(Objects.isNull(orderCrossCity)){ |
| | | // System.out.println("该订单不存在"); |
| | | // throw new RuntimeException("该订单不存在"); |
| | | // } |
| | | // cloudPay(orderCrossCity.getDriverId(),map.get("total_fee"),map.get("transaction_id"),1); |
| | | switch (type){ |
| | | case 3: |
| | | orderCrossCityService.payOrderCrossCityCallback(id, transaction_id, 1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 完成订单微信支付回调 |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil payCrossCityOrder(Integer payType, Integer orderId, Integer couponId, Integer type)throws Exception; |
| | | ResultUtil payCrossCityOrder(Integer payType, Integer orderId, Integer couponId, Integer type, String openId)throws Exception; |
| | | |
| | | |
| | | /** |
| | |
| | | import com.stylefeng.guns.modular.crossCity.server.ILineService; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.OrderCrossCityWarpper; |
| | | import com.stylefeng.guns.modular.huifu.biz.DouGongPayUtil; |
| | | import com.stylefeng.guns.modular.specialTrain.dao.OrderPrivateCarMapper; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil payCrossCityOrder(Integer payType, Integer orderId, Integer couponId, Integer type) throws Exception { |
| | | public ResultUtil payCrossCityOrder(Integer payType, Integer orderId, Integer couponId, Integer type,String openId) throws Exception { |
| | | OrderCrossCity orderCrossCity = this.selectById(orderId); |
| | | if(orderCrossCity.getState() != 7){ |
| | | return ResultUtil.error("订单已被支付,不允许重复支付"); |
| | |
| | | |
| | | String out_trade_no = orderId + "_3_" + UUIDUtil.getRandomCode(5); |
| | | if(payType == 1){//微信支付 |
| | | resultUtil = payMoneyUtil.weixinpay("完成订单", "", out_trade_no, orderMoney.toString(), "/base/wxPayCrossCity", "APP", ""); |
| | | // resultUtil = payMoneyUtil.weixinpay("完成订单", "", out_trade_no, orderMoney.toString(), "/base/wxPayCrossCity", "APP", ""); |
| | | DouGongPayUtil.wxPayOrder(orderMoney.toString(), openId, "完成订单", 3, String.valueOf(orderId), 1); |
| | | paymentRecordService.saveData(1, orderCrossCity.getDriverId(), 2, orderId, 3, 1, orderMoney, "", 1);//添加预支付数据 |
| | | } |
| | | if(payType == 2){//支付宝支付 |
| | | resultUtil = payMoneyUtil.alipay("完成订单", "完成订单", "", out_trade_no, orderMoney.toString(), "/base/aliPayCrossCity"); |
| | | // resultUtil = payMoneyUtil.alipay("完成订单", "完成订单", "", out_trade_no, orderMoney.toString(), "/base/aliPayCrossCity"); |
| | | DouGongPayUtil.aliPayOrder(orderMoney.toString(), openId, "完成订单", 3, String.valueOf(orderId), 1); |
| | | paymentRecordService.saveData(1, orderCrossCity.getDriverId(), 2, orderId, 3, 2, orderMoney, "", 1);//添加预支付数据 |
| | | } |
| | | if(payType == 4){ |
| New file |
| | |
| | | package com.stylefeng.guns.modular.huifu.biz; |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | |
| | | import java.security.KeyFactory; |
| | | import java.security.PrivateKey; |
| | | import java.security.Signature; |
| | | import java.security.spec.PKCS8EncodedKeySpec; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Base64; |
| | | import java.util.Date; |
| | | import java.util.TreeMap; |
| | | |
| | | /** |
| | | * 斗拱支付工具类 |
| | | */ |
| | | public class DouGongPayUtil { |
| | | |
| | | @Autowired |
| | | private HuiFuProperties huiFuProperties; |
| | | |
| | | |
| | | @Value("${callbackPath}") |
| | | private static String callbackPath;//支付回调网关地址 |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | |
| | | HttpRequest post = HttpUtil.createPost("https://api.huifu.com/v4/trade/payment/create"); |
| | | String req_seq_id = System.currentTimeMillis() + ToolUtil.getRandomNumber(10); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); |
| | | String req_date = simpleDateFormat.format(new Date()); |
| | | |
| | | String a = "{\n" + |
| | | " \"req_seq_id\": \"" + req_seq_id + "\",\n" + |
| | | " \"req_date\": \"" + req_date + "\",\n" + |
| | | " \"huifu_id\": \"6666000182995771\",\n" + |
| | | " \"trade_type\": \"A_NATIVE\",\n" + |
| | | " \"trans_amt\": \"0.01\",\n" + |
| | | " \"goods_desc\": \"test\",\n" + |
| | | " \"remark\": \"嘉易行\",\n" + |
| | | " \"notify_url\": \""+"http://221.182.45.100:8006/base/DGCallBack"+"\",\n" + |
| | | " }"; |
| | | // 去掉换行、空格等格式字符 |
| | | a = a.replaceAll("\\s", ""); |
| | | |
| | | |
| | | a = JSON.toJSONString(JSONObject.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cNNj8g5fVsWF769strepQReSug7xgX7ojPvVcAZhDwKBgD57KwP2Er5IIuhQ6NCBS0uTqvurWqV70BDnjtBAaWF+XDq0/HvR63XUTzuIbbrvOqNY1p+jIxFrc+iiQQupxLimrkNkJEs5QKJjqiYahPkhmA68DG9Ip0gqR5QJy5y4UIplGwZOiscyzC72vcC0mJZETSSylzC7JV3vtEUy5ua5AoGAEwlDqjAMIyYBgpa5HV+xLKkrNbtaUL2gy8vMLsmhuHjNkuJMrlb3EyNhbiC/4moyqArehy0Qp1tSvIo7UGotLkzx/69CKBoW+IcNWDyJyXG1trqO7cKoCdqTViM98lIRwyzu9rMydONeN8o0HCT5id4nYDhAsXl1vc+2XY6F1pUCgYEA0dxGHBTKD/WzIvTYGYD6Xx224Y84mO6x2Mu16zFoq/NjuIdKi2O+92yrKDCMMCqaY77fXvWD3eI7QYYlbKAOqdLKVipTbhnBccDyNbtYHVg59t4xS+K6HyD+quVkL9n40UkxSZbKZBQhqt+vlQy0FUgONFii1ACZO0A8Sc/bvn4="); |
| | | System.out.println(a); |
| | | String p = "{\n" + |
| | | " \"sys_id\": \"6666000182995771\",\n" + |
| | | " \"product_id\": \"KAZX\",\n" + |
| | | " \"sign\": \"" + sign + "\",\n" + |
| | | " \"data\": {\n" + |
| | | " \"req_seq_id\": \"" + req_seq_id + "\",\n" + |
| | | " \"req_date\": \"" + req_date + "\",\n" + |
| | | " \"huifu_id\": \"6666000182995771\",\n" + |
| | | " \"trade_type\": \"A_NATIVE\",\n" + |
| | | " \"trans_amt\": \"0.01\",\n" + |
| | | " \"goods_desc\": \"test\",\n" + |
| | | " \"remark\": \"嘉易行\",\n" + |
| | | " \"notify_url\": \""+"http://221.182.45.100:8006/base/DGCallBack"+"\",\n" + |
| | | " }\n" + |
| | | "}\n"; |
| | | System.out.println(p); |
| | | post.body(p); |
| | | |
| | | HttpResponse execute = post.execute(); |
| | | System.out.println(execute.body()); |
| | | String body = execute.body(); |
| | | JSONObject jsonObject = JSONObject.parseObject(body); |
| | | System.out.println(jsonObject); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单支付微信 |
| | | * @param money |
| | | * @param openId |
| | | * @param goodsDesc |
| | | * @param type |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | public static ResultUtil wxPayOrder(String money, String openId, String goodsDesc, int type, String orderId, int callType) { |
| | | HttpRequest post = HttpUtil.createPost("https://api.huifu.com/v4/trade/payment/create"); |
| | | String req_seq_id = orderId + "_" + type + "_" + System.currentTimeMillis() + ToolUtil.getRandomNumber(10); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); |
| | | String req_date = simpleDateFormat.format(new Date()); |
| | | String notifyUrl = ""; |
| | | switch (callType) { |
| | | case 1: |
| | | // 订单支付 |
| | | notifyUrl = callbackPath + "/base/DGPayCrossCity"; |
| | | break; |
| | | case 2: |
| | | // 改派 |
| | | notifyUrl = callbackPath +"/base/DGReassign"; |
| | | break; |
| | | } |
| | | String a = "{\n" + |
| | | " \"req_seq_id\": \"" + req_seq_id + "\",\n" + |
| | | " \"req_date\": \"" + req_date + "\",\n" + |
| | | " \"huifu_id\": \"6666000182995771\",\n" + |
| | | " \"trade_type\": \"T_MINIAPP\",\n" + |
| | | " \"trans_amt\": \"" + money + "\",\n" + |
| | | " \"goods_desc\": \"" + goodsDesc + "\",\n" + |
| | | " \"remark\": \"嘉易行\",\n" + |
| | | " \"notify_url\": \""+notifyUrl+"\",\n" + |
| | | " \"method_expand\": \"{\\\"sub_openid\\\":\\\"" + openId + "\\\"}\"\n" + |
| | | " }"; |
| | | // 去掉换行、空格等格式字符 |
| | | a = a.replaceAll("\\s", ""); |
| | | |
| | | |
| | | a = JSON.toJSONString(JSONObject.parseObject(a, TreeMap.class)); |
| | | String sign = sign(a, "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCR6W3ynQJL7f2C8vFYMcQkcirpkif9ZhLq1374jIlV87nv0T9uIm6DoW8LyNEl9w2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mA68DG9Ip0gqR5QJy5y4UIplGwZOiscyzC72vcC0mJZETSSylzC7JV3vtEUy5ua5AoGAEwlDqjAMIyYBgpa5HV+xLKkrNbtaUL2gy8vMLsmhuHjNkuJMrlb3EyNhbiC/4moyqArehy0Qp1tSvIo7UGotLkzx/69CKBoW+IcNWDyJyXG1trqO7cKoCdqTViM98lIRwyzu9rMydONeN8o0HCT5id4nYDhAsXl1vc+2XY6F1pUCgYEA0dxGHBTKD/WzIvTYGYD6Xx224Y84mO6x2Mu16zFoq/NjuIdKi2O+92yrKDCMMCqaY77fXvWD3eI7QYYlbKAOqdLKVipTbhnBccDyNbtYHVg59t4xS+K6HyD+quVkL9n40UkxSZbKZBQhqt+vlQy0FUgONFii1ACZO0A8Sc/bvn4="); |
| | | System.out.println(a); |
| | | String p = "{\n" + |
| | | " \"sys_id\": \"6666000182995771\",\n" + |
| | | " \"product_id\": \"KAZX\",\n" + |
| | | " \"sign\": \"" + sign + "\",\n" + |
| | | " \"data\": {\n" + |
| | | " \"req_seq_id\": \"" + req_seq_id + "\",\n" + |
| | | " \"req_date\": \"" + req_date + "\",\n" + |
| | | " \"huifu_id\": \"6666000182995771\",\n" + |
| | | " \"trade_type\": \"T_MINIAPP\",\n" + |
| | | " \"trans_amt\": \"" + money + "\",\n" + |
| | | " \"goods_desc\": \"" + goodsDesc + "\",\n" + |
| | | " \"remark\": \"嘉易行\",\n" + |
| | | " \"notify_url\": \""+notifyUrl+"\",\n" + |
| | | " \"method_expand\": \"{\\\"sub_openid\\\":\\\"" + openId + "\\\"}\"\n" + |
| | | " }\n" + |
| | | "}\n"; |
| | | System.out.println(p); |
| | | post.body(p); |
| | | |
| | | HttpResponse execute = post.execute(); |
| | | System.out.println(execute.body()); |
| | | JSONObject jsonObject = JSONObject.parseObject(execute.body()); |
| | | return ResultUtil.success(jsonObject); |
| | | } |
| | | |
| | | /** |
| | | * 订单支付 支付宝 |
| | | * @param money |
| | | * @param buyerId |
| | | * @param goodsDesc |
| | | * @param type |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | public static ResultUtil aliPayOrder(String money, String buyerId, String goodsDesc, int type, String orderId, int callType) { |
| | | HttpRequest post = HttpUtil.createPost("https://api.huifu.com/v4/trade/payment/create"); |
| | | String req_seq_id = orderId + "_" + type + "_" + System.currentTimeMillis() + ToolUtil.getRandomNumber(10); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); |
| | | String req_date = simpleDateFormat.format(new Date()); |
| | | String notifyUrl = ""; |
| | | switch (callType) { |
| | | case 1: |
| | | // 订单支付 |
| | | notifyUrl = callbackPath + "/base/wxPayCrossCity"; |
| | | break; |
| | | case 2: |
| | | // 改派 |
| | | notifyUrl = callbackPath +"/base/wxReassign"; |
| | | break; |
| | | } |
| | | String a = "{\n" + |
| | | " \"req_seq_id\": \"" + req_seq_id + "\",\n" + |
| | | " \"req_date\": \"" + req_date + "\",\n" + |
| | | " \"huifu_id\": \"6666000182995771\",\n" + |
| | | " \"trade_type\": \"A_NATIVE\",\n" + |
| | | " \"trans_amt\": \"" + money + "\",\n" + |
| | | " \"goods_desc\": \"" + goodsDesc + "\",\n" + |
| | | " \"remark\": \"嘉易行\",\n" + |
| | | " \"notify_url\": \""+notifyUrl+"\",\n" + |
| | | " }"; |
| | | // 去掉换行、空格等格式字符 |
| | | a = a.replaceAll("\\s", ""); |
| | | |
| | | |
| | | a = JSON.toJSONString(JSONObject.parseObject(a, TreeMap.class)); |
| | | String sign = sign(a, "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCR6W3ynQJL7f2C8vFYMcQkcirpkif9ZhLq1374jIlV87nv0T9uIm6DoW8LyNEl9w2Yc5qoBv70tt/oVpemA6IZY6NXzE2USNi/sv2qUTtapcIRYxe4acCfY8K+x+p7W2e6wUWIpl9qgZA+UnFmHQ0HT6Ywzq2jJL92JdIs147Ud1aVi3aX8LYItj0z3ZKwZQkaJawZSWQk2+EdPfN059L2qFkPtnT7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69CKBoW+IcNWDyJyXG1trqO7cKoCdqTViM98lIRwyzu9rMydONeN8o0HCT5id4nYDhAsXl1vc+2XY6F1pUCgYEA0dxGHBTKD/WzIvTYGYD6Xx224Y84mO6x2Mu16zFoq/NjuIdKi2O+92yrKDCMMCqaY77fXvWD3eI7QYYlbKAOqdLKVipTbhnBccDyNbtYHVg59t4xS+K6HyD+quVkL9n40UkxSZbKZBQhqt+vlQy0FUgONFii1ACZO0A8Sc/bvn4="); |
| | | System.out.println(a); |
| | | String p = "{\n" + |
| | | " \"sys_id\": \"6666000182995771\",\n" + |
| | | " \"product_id\": \"KAZX\",\n" + |
| | | " \"sign\": \"" + sign + "\",\n" + |
| | | " \"data\": {\n" + |
| | | " \"req_seq_id\": \"" + req_seq_id + "\",\n" + |
| | | " \"req_date\": \"" + req_date + "\",\n" + |
| | | " \"huifu_id\": \"6666000182995771\",\n" + |
| | | " \"trade_type\": \"A_NATIVE\",\n" + |
| | | " \"trans_amt\": \"" + money + "\",\n" + |
| | | " \"goods_desc\": \"" + goodsDesc + "\",\n" + |
| | | " \"remark\": \"嘉易行\",\n" + |
| | | " \"notify_url\": \""+notifyUrl+"\",\n" + |
| | | " }\n" + |
| | | "}\n"; |
| | | System.out.println(p); |
| | | post.body(p); |
| | | |
| | | HttpResponse execute = post.execute(); |
| | | JSONObject jsonObject = JSONObject.parseObject(execute.body()); |
| | | return ResultUtil.success(jsonObject); |
| | | } |
| | | |
| | | |
| | | public static String sign(String data, String privateKeyBase64) { |
| | | // Base64 --> Key |
| | | try { |
| | | byte[] bytes = Base64.getDecoder().decode(privateKeyBase64); |
| | | PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(bytes); |
| | | KeyFactory keyFactory; |
| | | keyFactory = KeyFactory.getInstance("RSA"); |
| | | PrivateKey privateKey = keyFactory.generatePrivate(keySpec); |
| | | // Sign |
| | | Signature signature = Signature.getInstance("SHA256WithRSA"); |
| | | signature.initSign(privateKey); |
| | | signature.update(data.getBytes("UTF-8")); |
| | | return Base64.getEncoder().encodeToString(signature.sign()); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.huifu.biz.DouGongPayUtil; |
| | | import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsSpreadService; |
| | |
| | | reassign.setRemark(content); |
| | | ResultUtil resultUtil = ResultUtil.success(); |
| | | Driver driver = driverService.selectById(uid); |
| | | if(null == driver){ |
| | | return ResultUtil.error("司机不存在"); |
| | | } |
| | | if(driver.getAppletsOpenId()==null && reassign.getPayType() == 1){ |
| | | return ResultUtil.openIdError(); |
| | | } |
| | | // TODO: 2020/11/12 司机端不控制重复提交(如果重复提交且未支付,直接将之前的数据删除) |
| | | // Reassign query = reassignMapper.query(uid, null, null, null, 1); |
| | | // if(null != query){ |
| | |
| | | |
| | | //开始支付 |
| | | if(null != reassign.getPayType()){ |
| | | if(reassign.getPayType() == 1){//微信支付 |
| | | reassign.setState(1); |
| | | |
| | | resultUtil = payMoneyUtil.weixinpay("改派订单", "", reassign.getId() + "_" + reassign.getOrderType() + "_" + UUIDUtil.getRandomCode(5), aDouble.toString(), "/base/wxReassign", "APP", ""); |
| | | if(reassign.getPayType() == 1){//微信支付 |
| | | |
| | | reassign.setState(1); |
| | | // resultUtil = payMoneyUtil.weixinpay("改派订单", "", reassign.getId() + "_" + reassign.getOrderType() + "_" + UUIDUtil.getRandomCode(5), aDouble.toString(), "/base/wxReassign", "APP", ""); |
| | | resultUtil = DouGongPayUtil.wxPayOrder(aDouble.toString(), driver.getAppletsOpenId(), "改派订单", reassign.getOrderType(), String.valueOf(reassign.getId()), 2); |
| | | paymentRecordService.saveData(1, uid, 2, reassign.getOrderId(), reassign.getOrderType(), 1, aDouble, "", 1);//添加预支付数据 |
| | | } |
| | | if(reassign.getPayType() == 2){//支付宝 |
| | | reassign.setState(1); |
| | | resultUtil = payMoneyUtil.alipay("改派订单", "改派订单", "", reassign.getId() + "_" + reassign.getOrderType() + "_" + UUIDUtil.getRandomCode(5), aDouble.toString(), "/base/aliReassign"); |
| | | // resultUtil = payMoneyUtil.alipay("改派订单", "改派订单", "", reassign.getId() + "_" + reassign.getOrderType() + "_" + UUIDUtil.getRandomCode(5), aDouble.toString(), "/base/aliReassign"); |
| | | resultUtil = DouGongPayUtil.aliPayOrder(aDouble.toString(), driver.getAppletsOpenId(), "改派订单", reassign.getOrderType(), String.valueOf(reassign.getId()), 2); |
| | | paymentRecordService.saveData(1, uid, 2, reassign.getOrderId(), reassign.getOrderType(), 2, aDouble, "", 1);//添加预支付数据 |
| | | } |
| | | if(reassign.getPayType() == 3){//余额 |
| | |
| | | |
| | | public static final Integer SIGN_ERROR = 700; |
| | | |
| | | public static final Integer OPENID_ERROR = 800; |
| | | |
| | | public static final String Token = "TOKEN_INVALID"; |
| | | |
| | | public static final String SIGN = "SIGN_INVALID"; |
| | |
| | | } |
| | | |
| | | /** |
| | | * token失效 |
| | | * @return |
| | | */ |
| | | public static ResultUtil tokenErr(){ |
| | | return ResultUtil.getResult(ResultUtil.TOKEN_ERROR, ResultUtil.Token, new JSONObject()); |
| | | } |
| | | |
| | | /** |
| | | * 错误信息 |
| | | * @return |
| | | */ |
| | | public static <T> ResultUtil<T> error(String mag, T obj){ |
| | | return ResultUtil.getResult(ResultUtil.ERROR, mag, obj); |
| | | } |
| | | |
| | | /** |
| | | * token失效 |
| | | * @return |
| | | */ |
| | | public static ResultUtil tokenErr(){ |
| | | return ResultUtil.getResult(ResultUtil.TOKEN_ERROR, ResultUtil.Token, new JSONObject()); |
| | | public static ResultUtil openIdError(){ |
| | | return ResultUtil.getResult(ResultUtil.OPENID_ERROR, "请获取OpenId", new JSONObject()); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | public static String getRandomNumber(int length) { |
| | | String base = "0123456789"; |
| | | Random random = new Random(); |
| | | StringBuffer sb = new StringBuffer(); |
| | | for (int i = 0; i < length; i++) { |
| | | int number = random.nextInt(base.length()); |
| | | sb.append(base.charAt(number)); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 判断一个对象是否是时间类型 |
| | |
| | | // 感谢费支付回调 |
| | | notifyUrl = callbackPath + "/base/DGPayThankYouFee"; |
| | | break; |
| | | case 5: |
| | | // 取消订单 |
| | | notifyUrl = callbackPath + "/base/DGCancelOrderTaxi"; |
| | | break; |
| | | case 6: |
| | | // 充值 |
| | | notifyUrl = callbackPath + "/base/wxCancelUserBalance"; |
| | | break; |
| | | } |
| | | String a = "{\n" + |
| | | " \"req_seq_id\": \"" + req_seq_id + "\",\n" + |