| | |
| | | } |
| | | String tokenNo = (String) map.get("token_no"); |
| | | userWithdrawal.setTokenNo(tokenNo); |
| | | userWithdrawal.setType(1); |
| | | userWithdrawalService.insert(userWithdrawal); |
| | | |
| | | // 通过司机进件信息封装银行卡信息进行数据库存储 |
| | |
| | | userWithdrawal.setBankCode(bankCode); |
| | | userWithdrawal.setBankBranchCode(bankBranchCode); |
| | | userWithdrawal.setCode(code); |
| | | userWithdrawal.setType(1); |
| | | System.out.println(userWithdrawal); |
| | | Map<String, Object> resultMap = douGongBasicDataBiz.userBasicDataIndvModify(userWithdrawal); |
| | | //CusApplicationResp renew = CusApplicationExample.renew(userWithdrawal); |
| | |
| | | if(Objects.isNull(userWithdrawal)){ |
| | | return ResultUtil.success(new Object()); |
| | | } |
| | | Region province = regionService.getRegionByCode(userWithdrawal.getBankCardProvinceCode()); |
| | | Region city = regionService.getRegionByCode(userWithdrawal.getBankCardCityCode()); |
| | | userWithdrawal.setBankCardProvince(province == null ? "" : province.getName()); |
| | | userWithdrawal.setBankCardCity(city == null ? "" : city.getName()); |
| | | if(userWithdrawal!=null){ |
| | | Region province = regionService.getRegionByCode(userWithdrawal.getBankCardProvinceCode()); |
| | | Region city = regionService.getRegionByCode(userWithdrawal.getBankCardCityCode()); |
| | | userWithdrawal.setBankCardProvince(province == null ? "" : province.getName()); |
| | | userWithdrawal.setBankCardCity(city == null ? "" : city.getName()); |
| | | } |
| | | |
| | | return ResultUtil.success(userWithdrawal); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | if(Objects.isNull(userWithdrawal)){ |
| | | return ResultUtil.error("该司机开户信息为空"); |
| | | } |
| | | BalanceAcctReq balanceAcctReq = new BalanceAcctReq(); |
| | | balanceAcctReq.setCusId(userWithdrawal.getCusId()); |
| | | balanceAcctListResp = BalanceAcctExample.retrieveByUserId(balanceAcctReq); |
| | | System.err.println(balanceAcctListResp); |
| | | BigDecimal bigDecimal = douGongBasicDataBiz.balanceQuery(userWithdrawal.getHuifuId()); |
| | | |
| | | return ResultUtil.success(bigDecimal); |
| | | // BalanceAcctReq balanceAcctReq = new BalanceAcctReq(); |
| | | // balanceAcctReq.setCusId(userWithdrawal.getCusId()); |
| | | // balanceAcctListResp = BalanceAcctExample.retrieveByUserId(balanceAcctReq); |
| | | // |
| | | // |
| | | // |
| | | // System.err.println(balanceAcctListResp); |
| | | } catch (Exception e) { |
| | | log.error("电子账簿可提现余额查询失败:{}",e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | if(Objects.isNull(balanceAcctListResp)){ |
| | | log.error("电子账簿可提现余额查询失败"); |
| | | return ResultUtil.error("电子账簿可提现余额查询失败"); |
| | | } |
| | | log.info("电子账簿可提现余额查询完成=========:{}",balanceAcctListResp); |
| | | List<BalanceAcctItem> balanceAccts = balanceAcctListResp.getBalanceAccts(); |
| | | if(CollectionUtils.isEmpty(balanceAccts)){ |
| | | log.error("电子账簿可提现余额查询失败"); |
| | | return ResultUtil.error("电子账簿可提现余额查询失败"); |
| | | } |
| | | for (BalanceAcctItem balanceAcct : balanceAccts) { |
| | | if(userWithdrawal.getBalanceAcctId().equals(balanceAcct.getBalanceAcctId())){ |
| | | return ResultUtil.success(new BigDecimal(balanceAcct.getSettledAmount()).divide(new BigDecimal(100))); |
| | | } |
| | | } |
| | | // if(Objects.isNull(balanceAcctListResp)){ |
| | | // log.error("电子账簿可提现余额查询失败"); |
| | | // return ResultUtil.error("电子账簿可提现余额查询失败"); |
| | | // } |
| | | // log.info("电子账簿可提现余额查询完成=========:{}",balanceAcctListResp); |
| | | // List<BalanceAcctItem> balanceAccts = balanceAcctListResp.getBalanceAccts(); |
| | | // if(CollectionUtils.isEmpty(balanceAccts)){ |
| | | // log.error("电子账簿可提现余额查询失败"); |
| | | // return ResultUtil.error("电子账簿可提现余额查询失败"); |
| | | // } |
| | | // for (BalanceAcctItem balanceAcct : balanceAccts) { |
| | | // if(userWithdrawal.getBalanceAcctId().equals(balanceAcct.getBalanceAcctId())){ |
| | | // return ResultUtil.success(new BigDecimal(balanceAcct.getSettledAmount()).divide(new BigDecimal(100))); |
| | | // } |
| | | // } |
| | | return ResultUtil.success(BigDecimal.ZERO); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private DouGongPayUtil douGongPayUtil; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | String out_trade_no = orderId + "_3_" + UUIDUtil.getRandomCode(5); |
| | | if(payType == 1){//微信支付 |
| | | // resultUtil = payMoneyUtil.weixinpay("完成订单", "", out_trade_no, orderMoney.toString(), "/base/wxPayCrossCity", "APP", ""); |
| | | DouGongPayUtil.wxPayOrder(orderMoney.toString(), openId, "完成订单", 3, String.valueOf(orderId), 1); |
| | | douGongPayUtil.wxPayOrder(orderMoney.toString(), openId, "完成订单", 3, String.valueOf(orderId), 1); |
| | | paymentRecordService.saveData(1, orderCrossCity.getDriverId(), 2, orderId, 3, 1, orderMoney, "", 1);//添加预支付数据 |
| | | } |
| | | if(payType == 2){//支付宝支付 |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | |
| | | log.info("用户业务入驻修改返回参数:{}", response); |
| | | return response; |
| | | } |
| | | |
| | | /** |
| | | * 电子账户余额查询 |
| | | * |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public BigDecimal balanceQuery(String huifuId) throws Exception { |
| | | // 1. 数据初始化,填入对应的商户配置 |
| | | MerConfig merConfig = new MerConfig(); |
| | | merConfig.setProcutId(huiFuProperties.getProductId()); |
| | | merConfig.setSysId(huiFuProperties.getSysId()); |
| | | merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey()); |
| | | merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey()); |
| | | BasePay.initWithMerConfig(merConfig); |
| | | // 2.组装请求参数 |
| | | Map<String, Object> paramsInfo = new HashMap<>(); |
| | | // 汇付ID |
| | | paramsInfo.put("huifu_id", huifuId); |
| | | // 请求流水号 |
| | | paramsInfo.put("req_seq_id", RequestSeqUtil.generateForHuiFu()); |
| | | // 请求日期 |
| | | paramsInfo.put("req_date", DateUtil.format(new Date(), "yyyyMMdd")); |
| | | log.info("账户余额信息查询返回参数:{}", paramsInfo); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/trade/acctpayment/balance/query", paramsInfo, null, false); |
| | | log.info("账户余额信息查询返回参数:{}", response); |
| | | JSONArray accountList = JSONArray.parseArray(JSONObject.toJSONString(response.get("acctInfo_list"))); |
| | | if (accountList != null && !accountList.isEmpty()) { |
| | | JSONObject acctInfo = accountList.getJSONObject(0); |
| | | log.info("账户余额信息查询返回余额:{}", acctInfo.getString("avail_bal")); |
| | | return acctInfo.getBigDecimal("avl_bal"); |
| | | } |
| | | return BigDecimal.ZERO; |
| | | } |
| | | } |
| | |
| | | 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.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | |
| | | @Value("${callbackPath}") |
| | | private static String callbackPath;//支付回调网关地址 |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | |
| | |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | public static ResultUtil wxPayOrder(String money, String openId, String goodsDesc, int type, String orderId, int callType) { |
| | | public 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"); |
| | |
| | | System.out.println(p); |
| | | post.body(p); |
| | | |
| | | |
| | | HttpResponse execute = post.execute(); |
| | | System.out.println(execute.body()); |
| | | |
| | | String randomString = ToolUtil.getRandomString(18); |
| | | redisUtil.setStrValue("dg_wx_pay:"+randomString,execute.body(),300); |
| | | JSONObject jsonObject = JSONObject.parseObject(execute.body()); |
| | | jsonObject.put("dg_wx_pay","dg_wx_pay:"+randomString); |
| | | return ResultUtil.success(jsonObject); |
| | | } |
| | | |
| | |
| | | private String callbackPath; |
| | | |
| | | |
| | | @Autowired |
| | | private DouGongPayUtil douGongPayUtil; |
| | | |
| | | |
| | | /** |
| | | * 提交改派申请 |
| | |
| | | |
| | | 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); |
| | | 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){//支付宝 |