| | |
| | | @PostMapping("/base/pointMer/exchangeGoodPaymentAliCallback") |
| | | public void exchangeGoodPaymentAliCallback(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.err.println("积分商品支付宝回调"); |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | if (null != map) { |
| | | String out_trade_no = map.get("out_trade_no"); |
| | |
| | | package com.dsh.account.service; |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.dsh.account.dto.BindDto; |
| | | import com.dsh.account.dto.SelectDto; |
| | |
| | | |
| | | |
| | | |
| | | ResultUtil exchangeAddPaymentCallback(String code, String orderNumber); |
| | | ResultUtil exchangeAddPaymentCallback(String code, String orderNumber) throws AlipayApiException; |
| | | |
| | | List<StoreResponse> queryStoresOfExchange(Integer goodsType, Integer pointsMerId); |
| | | |
| | |
| | | private GameRecordClient gameRecordClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // 对数据进行分页处理的方法 |
| | | private static Page<Goods> getPage(List<Goods> dataList, Pageable pageable) { |
| | | int start = (int) pageable.getOffset(); |
| | |
| | | List<WorldCupPayment> worldCupPayment = worldCupPaymentClinet.getWorldCupPayment(getWorldCupPayment); |
| | | for (WorldCupPayment cupPayment : worldCupPayment) { |
| | | ConsumeDetail consumeDetail = new ConsumeDetail(); |
| | | if(cupPayment.getPayStatus() != 3){ |
| | | if (cupPayment.getPayStatus() != 3) { |
| | | consumeDetail.setConsumeName(RechargeRecordEnum.WORLD_CIP_PAYMENT.getMsg()); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(cupPayment.getCreateTime())); |
| | | consumeDetail.setConsumeAmount("-" + cupPayment.getAmount()); |
| | | consumeDetail.setType(2); |
| | | consumeDetail.setDateTime(cupPayment.getPayTime().getTime()); |
| | | details.add(consumeDetail); |
| | | }else{ |
| | | } else { |
| | | consumeDetail = new ConsumeDetail(); |
| | | consumeDetail.setConsumeName(RechargeRecordEnum.WORLD_CIP_PAYMENT.getMsg()); |
| | | consumeDetail.setConsumeTime(simpleDateFormat.format(cupPayment.getCreateTime())); |
| | |
| | | } |
| | | TAppUser tAppUser1 = appUserMapper.selectOne(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getPhone, dto.getInvitePhone()).eq(TAppUser::getState, 1)); |
| | | if(null == tAppUser1){ |
| | | if (null == tAppUser1) { |
| | | return ResultUtil.error("邀请人还未注册账号"); |
| | | } |
| | | Map<String, String> geocode = null; |
| | |
| | | userCouponPayment.setInsertTime(new Date()); |
| | | |
| | | //积分兑换 |
| | | if(coupon.getRedemptionMethod() == 1){ |
| | | if (coupon.getRedemptionMethod() == 1) { |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(exchangeType.getGoodId()); |
| | | userCoupon.setUserId(userIdFormRedis); |
| | |
| | | return ResultUtil.success(returnId); |
| | | } |
| | | //积分+现金 |
| | | if(coupon.getRedemptionMethod() == 2){ |
| | | if (coupon.getRedemptionMethod() == 2) { |
| | | userCouponPaymentClient.addUserCouponPayment(userCouponPayment); |
| | | try { |
| | | if(exchangeType.getPayType() == 1){ |
| | | if (exchangeType.getPayType() == 1) { |
| | | return weChatPaymentCoupon("购买优惠券", userCouponPayment); |
| | | } |
| | | if(exchangeType.getPayType() == 2){ |
| | | if (exchangeType.getPayType() == 2) { |
| | | return aliPaymentCoupon("购买优惠券", userCouponPayment); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | } |
| | | System.out.println("兑换积分商品"+exchangeType); |
| | | System.out.println("兑换积分商品" + exchangeType); |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | PointsMerchandise merchandise = new PointsMerchandise(); |
| | | if(exchangeType.getGoodsType() != 4){ |
| | | if (exchangeType.getGoodsType() != 4) { |
| | | merchandise = mcClient.selectPointsMerchandiseById(exchangeType.getGoodId()); |
| | | }else{ |
| | | } else { |
| | | Coupon coupon = ucponClient.queryCouponById(exchangeType.getGoodId()); |
| | | merchandise.setId(coupon.getId()); |
| | | merchandise.setUserPopulation(coupon.getUserPopulation()); |
| | |
| | | pointsMerchandise.setCode(code); |
| | | pointsMerchandise.setInsertTime(new Date()); |
| | | pointsMerchandise.setPayType(exchangeType.getExchangeType()); |
| | | if(null != merchandise.getIntegral()){ |
| | | if (null != merchandise.getIntegral()) { |
| | | pointsMerchandise.setIntegral(merchandise.getIntegral() * goodsNums); |
| | | } |
| | | if(exchangeType.getExchangeType() == 2 || exchangeType.getExchangeType() == 3){ |
| | | if (exchangeType.getExchangeType() == 2 || exchangeType.getExchangeType() == 3) { |
| | | pointsMerchandise.setCash(merchandise.getCash()); |
| | | pointsMerchandise.setCashPayType(exchangeType.getPayType()); |
| | | } |
| | | |
| | | |
| | | Double m = new BigDecimal((merchandise.getIntegral() == null ? 0 : merchandise.getIntegral())).add((merchandise.getCash() == null ? BigDecimal.ZERO : merchandise.getCash())).doubleValue(); |
| | | if((m * goodsNums) == 0) { |
| | | if ((m * goodsNums) == 0) { |
| | | pointsMerchandise.setPayStatus(2); |
| | | pointsMerchandise.setPaymentTime(new Date()); |
| | | } |
| | | returnId = mcClient.saveDetailsUserPointMercase(pointsMerchandise); |
| | | if((m * goodsNums) == 0 && pointsMerchandise.getPayStatus() == 2){ |
| | | if ((m * goodsNums) == 0 && pointsMerchandise.getPayStatus() == 2) { |
| | | returnModel.setReturnId(returnId); |
| | | return ResultUtil.success(returnModel); |
| | | } |
| | | |
| | | System.err.println("兑换方式"+exchangeType); |
| | | System.err.println("兑换方式" + exchangeType); |
| | | switch (exchangeType.getExchangeType()) { |
| | | // 积分 |
| | | case 1: |
| | |
| | | coursePackageOrder.setInsertTime(new Date()); |
| | | coursePackageOrder.setOrderType(2); |
| | | paymentClient.savePaymentCoursePackage(coursePackageOrder); |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code,merchandise.getId()); |
| | | } else if (merchandise.getType() == 1){ |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code,merchandise.getId()); |
| | | }else if(merchandise.getType() == 3){ |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code,merchandise.getId()); |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code, merchandise.getId()); |
| | | } else if (merchandise.getType() == 1) { |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code, merchandise.getId()); |
| | | } else if (merchandise.getType() == 3) { |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code, merchandise.getId()); |
| | | } |
| | | } catch (Exception e) { |
| | | return ResultUtil.runErr(); |
| | |
| | | case 1: |
| | | try { |
| | | if (merchandise.getType() == 2) { |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code,merchandise.getId()); |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code, merchandise.getId()); |
| | | } else { |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code,merchandise.getId()); |
| | | return WechatPayment(merchandise.getType(), merchandise.getCash().multiply(new BigDecimal(goodsNums)), code, merchandise.getId()); |
| | | } |
| | | } catch (Exception e) { |
| | | return ResultUtil.runErr(); |
| | |
| | | |
| | | /** |
| | | * 优惠券微信支付 |
| | | * |
| | | * @param body |
| | | * @param userCouponPayment |
| | | * @return |
| | |
| | | Coupon coupon = userConponClient.queryCouponById(couponId); |
| | | List<Integer> couponStoreIds = userConponClient.getCouponStoreIds(couponId); |
| | | System.err.println("购买优惠券"); |
| | | if (coupon!=null){ |
| | | if (!couponStoreIds.isEmpty()&&!couponStoreIds.contains(-1)){ |
| | | // 微信商户号 |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(couponStoreIds.get(0)); |
| | | System.err.println("微信商户号"+s2); |
| | | if (coupon != null) { |
| | | if (!couponStoreIds.isEmpty() && !couponStoreIds.contains(-1)) { |
| | | Store store = storeClient.queryStoreById(couponStoreIds.get(0)); |
| | | // 微信商户号 |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(store.getOperatorId()); |
| | | System.err.println("微信商户号" + s2); |
| | | |
| | | if(!StringUtils.hasLength(s2)){ |
| | | return ResultUtil.error("运营商未配置微信商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpayV3(s2,"购买优惠券", |
| | | code,"/base/coupon/weChatPaymentCouponCallback1", |
| | | cash.toString()); |
| | | return weixinpay; |
| | | if (!StringUtils.hasLength(s2)) { |
| | | return ResultUtil.error("运营商未配置微信商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpayV3(s2, "购买优惠券", |
| | | code, "/base/coupon/weChatPaymentCouponCallback1", |
| | | cash.toString()); |
| | | return weixinpay; |
| | | |
| | | }else{ |
| | | } else { |
| | | // 平台发布 |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay(body, "", code, cash.toString(), |
| | | "/base/coupon/weChatPaymentCouponCallback", "APP", ""); |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay(body, "", code, cash.toString(), |
| | | "/base/coupon/weChatPaymentCouponCallback", "APP", ""); |
| | | return weixinpay; |
| | | } |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | private String smid = "2088330203191220";//平台支付宝商户号 |
| | | |
| | | public ResultUtil aliPaymentCoupon(String body, UserCouponPayment userCouponPayment) throws Exception { |
| | | ResultUtil alipay= ResultUtil.error(""); |
| | | String smidRes = smid;// 结算资金到商户号 |
| | | String code = userCouponPayment.getCode(); |
| | | Double cash = userCouponPayment.getCash(); |
| | | Integer couponId = userCouponPayment.getCouponId(); |
| | | Coupon coupon = userConponClient.queryCouponById(couponId); |
| | | List<Integer> couponStoreIds = userConponClient.getCouponStoreIds(couponId); |
| | | if (coupon!=null){ |
| | | if (!couponStoreIds.isEmpty()&&!couponStoreIds.contains(-1)){ |
| | | // 门店 向上查询运营商 |
| | | Store store = storeClient.queryStoreById(couponStoreIds.get(0)); |
| | | if (store.getOperatorId()==null || store.getOperatorId()==0){ |
| | | // 平台 |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid, body, "",String.valueOf(userCouponPayment.getId()), code, cash.toString(), |
| | | "/base/coupon/aliPaymentCouponCallback"); |
| | | return alipay; |
| | | }else{ |
| | | // 支付宝商户号 |
| | | String s2 = storeClient.getmerchantNumberAliByOperatorId(store.getOperatorId()); |
| | | System.err.println("支付宝商户号"+s2); |
| | | if (coupon != null) { |
| | | if (!couponStoreIds.isEmpty() && !couponStoreIds.contains(-1)) { |
| | | // 门店 向上查询运营商 |
| | | Store store = storeClient.queryStoreById(couponStoreIds.get(0)); |
| | | if (store.getOperatorId() == null || store.getOperatorId() == 0) { |
| | | |
| | | if(!StringUtils.hasLength(s2)){ |
| | | return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil alipay = payMoneyUtil.alipay(s2, body, "",String.valueOf(userCouponPayment.getId()), code, cash.toString(), |
| | | "/base/coupon/aliPaymentCouponCallback"); |
| | | return alipay; |
| | | } else { |
| | | // 支付宝商户号 |
| | | String s2 = storeClient.getmerchantNumberAliByOperatorId(store.getOperatorId()); |
| | | System.err.println("支付宝商户号" + s2); |
| | | |
| | | if (!StringUtils.hasLength(s2)) { |
| | | return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); |
| | | } |
| | | }else { |
| | | // 平台发布 |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid, body, "",String.valueOf(userCouponPayment.getId()), code, cash.toString(), |
| | | "/base/coupon/aliPaymentCouponCallback"); |
| | | return alipay; |
| | | smidRes = s2; |
| | | } |
| | | } |
| | | } |
| | | // ResultUtil alipay = payMoneyUtil.alipay(smid, body, "",String.valueOf(userCouponPayment.getId()), code, cash.toString(), |
| | | // "/base/coupon/aliPaymentCouponCallback"); |
| | | // if (alipay.getCode() == 200) { |
| | | // new Thread(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // try { |
| | | // Thread.sleep(1000); |
| | | // |
| | | // int num = 1; |
| | | // int wait = 0; |
| | | // while (num <= 10) { |
| | | // int min = 5000; |
| | | // wait += (min * num); |
| | | // Thread.sleep(wait); |
| | | // UserCouponPayment userCouponPayment1 = userCouponPaymentClient.getUserCouponPayment(code); |
| | | // if (userCouponPayment1.getStatus() == 2) { |
| | | // break; |
| | | // } |
| | | // AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(code); |
| | | // if (null != alipayTradeQueryResponse) { |
| | | // /** |
| | | // * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | // * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | // * TRADE_SUCCESS(交易支付成功)、 |
| | | // * TRADE_FINISHED(交易结束,不可退款) |
| | | // */ |
| | | // String s = alipayTradeQueryResponse.getTradeStatus(); |
| | | // |
| | | // String tradeNo = alipayTradeQueryResponse.getTradeNo(); |
| | | // if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | // //有待支付的订单,这里不处理 |
| | | // userCouponPayment1.setStatus(-1); |
| | | // userCouponPaymentClient.updateUserCouponPayment(userCouponPayment1); |
| | | // if ("TRADE_FINISHED".equals(s)) { |
| | | // // todo 资金结算 |
| | | // |
| | | // } |
| | | // break; |
| | | // } |
| | | // if ("TRADE_SUCCESS".equals(s)) { |
| | | // userCouponPayment1.setStatus(2); |
| | | // userCouponPayment1.setPaymentTime(new Date()); |
| | | // userCouponPayment1.setOrderNumber(tradeNo); |
| | | // userCouponPaymentClient.updateUserCouponPayment(userCouponPayment1); |
| | | // UserCoupon userCoupon = new UserCoupon(); |
| | | // userCoupon.setCouponId(userCouponPayment1.getCouponId()); |
| | | // userCoupon.setUserId(userCouponPayment1.getUserId()); |
| | | // userCoupon.setStatus(1); |
| | | // userCoupon.setInsertTime(new Date()); |
| | | // userConponClient.insertToAppuserCoupon(userCoupon); |
| | | // if(null != userCouponPayment1.getIntegral() && 0 != userCouponPayment1.getIntegral()){ |
| | | // //扣积分 |
| | | // TAppUser user = appUserService.getById(userCouponPayment1.getUserId()); |
| | | // user.setIntegral(user.getIntegral() - userCouponPayment1.getIntegral().intValue()); |
| | | // appUserService.updateById(user); |
| | | // } |
| | | //// payMoneyUtil.confirm(smid,code,tradeNo,cash.toString()); |
| | | // break; |
| | | // |
| | | // } |
| | | // |
| | | // if ("WAIT_BUYER_PAY".equals(s)) { |
| | | // num++; |
| | | // } |
| | | // } |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }).start(); |
| | | // } |
| | | return ResultUtil.error("支付失败"); |
| | | alipay = payMoneyUtil.alipay(smidRes, body, "",String.valueOf(userCouponPayment.getId()), code, cash.toString(), |
| | | "/base/coupon/aliPaymentCouponCallback"); |
| | | if (alipay.getCode() == 200) { |
| | | String finalSmidRes = smidRes; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Thread.sleep(1000); |
| | | |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10) { |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | UserCouponPayment userCouponPayment1 = userCouponPaymentClient.getUserCouponPayment(code); |
| | | if (userCouponPayment1.getStatus() == 2) { |
| | | break; |
| | | } |
| | | AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(code); |
| | | if (null != alipayTradeQueryResponse) { |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | String s = alipayTradeQueryResponse.getTradeStatus(); |
| | | |
| | | String tradeNo = alipayTradeQueryResponse.getTradeNo(); |
| | | if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | //有待支付的订单,这里不处理 |
| | | userCouponPayment1.setStatus(-1); |
| | | userCouponPaymentClient.updateUserCouponPayment(userCouponPayment1); |
| | | |
| | | break; |
| | | } |
| | | if ("TRADE_SUCCESS".equals(s)) { |
| | | userCouponPayment1.setStatus(2); |
| | | userCouponPayment1.setPaymentTime(new Date()); |
| | | userCouponPayment1.setOrderNumber(tradeNo); |
| | | userCouponPaymentClient.updateUserCouponPayment(userCouponPayment1); |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(userCouponPayment1.getCouponId()); |
| | | userCoupon.setUserId(userCouponPayment1.getUserId()); |
| | | userCoupon.setStatus(1); |
| | | userCoupon.setInsertTime(new Date()); |
| | | userConponClient.insertToAppuserCoupon(userCoupon); |
| | | if(null != userCouponPayment1.getIntegral() && 0 != userCouponPayment1.getIntegral()){ |
| | | //扣积分 |
| | | TAppUser user = appUserService.getById(userCouponPayment1.getUserId()); |
| | | user.setIntegral(user.getIntegral() - userCouponPayment1.getIntegral().intValue()); |
| | | appUserService.updateById(user); |
| | | } |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(finalSmidRes,code,tradeNo,cash.toString()); |
| | | break; |
| | | } |
| | | |
| | | if ("WAIT_BUYER_PAY".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | return alipay; |
| | | } |
| | | |
| | | /** |
| | | * 支付回调 |
| | | * |
| | | * @param code |
| | | * @param orderNumber |
| | | * @return |
| | |
| | | userCoupon.setInsertTime(new Date()); |
| | | userConponClient.insertToAppuserCoupon(userCoupon); |
| | | |
| | | if(null != userCouponPayment1.getIntegral() && 0 != userCouponPayment1.getIntegral()){ |
| | | if (null != userCouponPayment1.getIntegral() && 0 != userCouponPayment1.getIntegral()) { |
| | | //扣积分 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(userCouponPayment1.getUserId()); |
| | |
| | | } |
| | | |
| | | private ResultUtil AlipayPayment(Integer type, BigDecimal cash, String code, Integer returnId) { |
| | | ResultUtil alipay= ResultUtil.error(""); |
| | | String smidRes = smid;// 结算资金到商户号 |
| | | PointsMerchandise pointsMerchandise = mcClient.selectPointsMerchandiseById(returnId); |
| | | System.err.println("查询积分商品"+pointsMerchandise); |
| | | System.err.println("查询积分商品" + pointsMerchandise); |
| | | List<Integer> integers = mcsClient.queryPointMerStoreIds(pointsMerchandise.getId()); |
| | | String name = (type == 1 ? "购买实体商品" : type == 2 ? "报名运动营": type == 3 ? "购买门票" : "购买优惠券"); |
| | | String name = (type == 1 ? "购买实体商品" : type == 2 ? "报名运动营" : type == 3 ? "购买门票" : "购买优惠券"); |
| | | switch (type) { |
| | | case 1: |
| | | if (!integers.isEmpty()) { |
| | | Store store1 = storeClient.queryStoreById(integers.get(0)); |
| | | if (store1.getOperatorId() == null || store1.getOperatorId() == 0) { |
| | | // 平台门票 |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | return alipay; |
| | | |
| | | } else { |
| | | String s2 = storeClient.getmerchantNumberAliByOperatorId(store1.getOperatorId()); |
| | | System.err.println("支付宝商户号" + s2); |
| | |
| | | if (!StringUtils.hasLength(s2)) { |
| | | return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil alipay = payMoneyUtil.alipay(s2, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | return alipay; |
| | | smidRes = s2; |
| | | } |
| | | }else{ |
| | | // 平台门票 |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | return alipay; |
| | | |
| | | } |
| | | break; |
| | | case 2: |
| | | // 判断课包属于平台还是运营商 |
| | | CoursePackage coursePackage = cpageClient.queryCoursePackageById(pointsMerchandise.getCoursePackageId()); |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | if (store.getOperatorId() == null || store.getOperatorId() == 0) { |
| | | // 平台课包 |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | return alipay; |
| | | } else { |
| | | String s2 = storeClient.getmerchantNumberAliByOperatorId(store.getOperatorId()); |
| | | System.err.println("支付宝商户号" + s2); |
| | |
| | | if (!StringUtils.hasLength(s2)) { |
| | | return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil alipay = payMoneyUtil.alipay(s2, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | return alipay; |
| | | smidRes = s2; |
| | | } |
| | | break; |
| | | case 3: |
| | | if (!integers.isEmpty()) { |
| | | Store store1 = storeClient.queryStoreById(integers.get(0)); |
| | | if (store1.getOperatorId() == null || store1.getOperatorId() == 0) { |
| | | // 平台门票 |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | return alipay; |
| | | |
| | | } else { |
| | | String s2 = storeClient.getmerchantNumberAliByOperatorId(store1.getOperatorId()); |
| | | System.err.println("支付宝商户号" + s2); |
| | | if (!StringUtils.hasLength(s2)) { |
| | | return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil alipay = payMoneyUtil.alipay(s2, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | return alipay; |
| | | } |
| | | }else{ |
| | | // 平台门票 |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | return alipay; |
| | | smidRes = s2; |
| | | } |
| | | } |
| | | } |
| | | return ResultUtil.error("获取支付失败!"); |
| | | break; |
| | | } |
| | | alipay = payMoneyUtil.alipay(smidRes, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | if (alipay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10) { |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | System.out.println("支付宝查询code:" + code); |
| | | List<UserPointsMerchandise> userPointsMerchandises = mcClient.queryUserPointMerchaseByCode(code); |
| | | System.out.println("list-----" + userPointsMerchandises); |
| | | if (userPointsMerchandises.get(0).getPayStatus() == 2) { |
| | | break; |
| | | } |
| | | // ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if (resultUtil.getCode().equals("10000") && userPointsMerchandises.get(0).getPayStatus() == 1) { |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | // Map<String, String> data1 = resultUtil.getData(); |
| | | // String s = data1.get("tradeStatus"); |
| | | // String tradeNo = data1.get("tradeNo"); |
| | | |
| | | String tradeNo = resultUtil.getTradeNo(); |
| | | String tradeStatus = resultUtil.getTradeStatus(); |
| | | System.out.println("ssssss" + tradeStatus); |
| | | |
| | | if ("TRADE_SUCCESS".equals(tradeStatus)) { |
| | | for (UserPointsMerchandise userPointsMerchandise : userPointsMerchandises) { |
| | | userPointsMerchandise.setPayStatus(2); |
| | | userPointsMerchandise.setPaymentTime(new Date()); |
| | | userPointsMerchandise.setOrderNumber(tradeNo); |
| | | userPointsMerchandise.setCashPayType(2); |
| | | userPointsMerchandise.setInsertTime(null); |
| | | userPointsMerchandise.setUserId(null); |
| | | mcClient.updateDetailsUserPointMercase(userPointsMerchandise); |
| | | } |
| | | List<Integer> integers = mcsClient.queryPointMerStoreIds(pointsMerchandise.getId()); |
| | | Store store1 = storeClient.queryStoreById(integers.get(0)); |
| | | if (store1.getOperatorId()!=null && store1.getOperatorId() != 0){ |
| | | String s2 = storeClient.getmerchantNumberAliByOperatorId(store1.getOperatorId()); |
| | | System.err.println("查询支付宝商户号"+s2); |
| | | // todo 资金结算 支付宝推荐30s之后再进行结算 |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(s2,code, tradeNo,cash.toString()); |
| | | } |
| | | break; |
| | | } |
| | | if ("TRADE_FINISHED".equals(tradeStatus)) { |
| | | |
| | | break; |
| | | } |
| | | // if("REFUND".equals(tradeStatus) || "NOTPAY".equals(tradeStatus) || "CLOSED".equals(tradeStatus) || "REVOKED".equals(tradeStatus) || "PAYERROR".equals(tradeStatus) || num == 10){ |
| | | // mcClient.deletePaymentRecord(code); |
| | | // break; |
| | | // } |
| | | |
| | | if ("WAIT_BUYER_PAY".equals(tradeStatus)) { |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | mcClient.deletePaymentRecord(code); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | return alipay; |
| | | } |
| | | |
| | | public void moneyOut(String outNum, String tradeNo) throws AlipayApiException { |
| | |
| | | |
| | | List<UserPointsMerchandise> userPointsMerchandises = merChandiseClient.queryUserPointMerchaseByCode(outNum); |
| | | // PaymentCompetition code = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", outNum)); |
| | | if(userPointsMerchandises.size() > 0){ |
| | | if (userPointsMerchandises.size() > 0) { |
| | | Integer storeId = userPointsMerchandises.get(0).getStoreId(); |
| | | |
| | | // Competition byId1 = competitionService.getById(code.getCompetitionId()); |
| | |
| | | } |
| | | |
| | | |
| | | private ResultUtil WechatPayment(Integer type, BigDecimal cash, String code,Integer id) throws Exception { |
| | | String name = (type == 1 ? "购买实体商品" : type == 2 ? "报名运动营": type == 3 ? "购买门票" : "购买优惠券"); |
| | | System.err.println("微信支付:"+name); |
| | | private ResultUtil WechatPayment(Integer type, BigDecimal cash, String code, Integer id) throws Exception { |
| | | String name = (type == 1 ? "购买实体商品" : type == 2 ? "报名运动营" : type == 3 ? "购买门票" : "购买优惠券"); |
| | | System.err.println("微信支付:" + name); |
| | | |
| | | PointsMerchandise pointsMerchandise = mcClient.selectPointsMerchandiseById(id); |
| | | System.err.println("查询积分商品"+pointsMerchandise); |
| | | System.err.println("查询积分商品" + pointsMerchandise); |
| | | List<Integer> integers = mcsClient.queryPointMerStoreIds(pointsMerchandise.getId()); |
| | | |
| | | switch (type){ |
| | | switch (type) { |
| | | case 1: |
| | | if (!integers.isEmpty()){ |
| | | if (!integers.isEmpty()) { |
| | | Store store1 = storeClient.queryStoreById(integers.get(0)); |
| | | if (store1.getOperatorId() ==null || store1.getOperatorId() == 0){ |
| | | if (store1.getOperatorId() == null || store1.getOperatorId() == 0) { |
| | | // 平台门票 |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay(name, "", code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentWeChatCallback", "APP", ""); |
| | | return weixinpay; |
| | | }else{ |
| | | } else { |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(store1.getOperatorId()); |
| | | System.err.println("微信商户号"+s2); |
| | | System.err.println("微信商户号" + s2); |
| | | |
| | | if(!StringUtils.hasLength(s2)){ |
| | | if (!StringUtils.hasLength(s2)) { |
| | | return ResultUtil.error("运营商未配置微信商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpayV3(s2,name, code, |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpayV3(s2, name, code, |
| | | "/base/pointMer/exchangeGoodPaymentWeChatCallback1", |
| | | cash.toString()); |
| | | return weixinpay; |
| | |
| | | // 判断课包属于平台还是运营商 |
| | | CoursePackage coursePackage = cpageClient.queryCoursePackageById(pointsMerchandise.getCoursePackageId()); |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | if (store.getOperatorId() ==null || store.getOperatorId() == 0){ |
| | | if (store.getOperatorId() == null || store.getOperatorId() == 0) { |
| | | // 平台课包 |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay(name, "", code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentWeChatCallback", "APP", ""); |
| | | return weixinpay; |
| | | }else{ |
| | | } else { |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(store.getOperatorId()); |
| | | System.err.println("微信商户号"+s2); |
| | | System.err.println("微信商户号" + s2); |
| | | |
| | | if(!StringUtils.hasLength(s2)){ |
| | | if (!StringUtils.hasLength(s2)) { |
| | | return ResultUtil.error("运营商未配置微信商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpayV3(s2,name, code, |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpayV3(s2, name, code, |
| | | "/base/pointMer/exchangeGoodPaymentWeChatCallback1", |
| | | cash.toString()); |
| | | return weixinpay; |
| | | } |
| | | case 3: |
| | | if (!integers.isEmpty()){ |
| | | if (!integers.isEmpty()) { |
| | | Store store1 = storeClient.queryStoreById(integers.get(0)); |
| | | if (store1.getOperatorId() ==null || store1.getOperatorId() == 0){ |
| | | if (store1.getOperatorId() == null || store1.getOperatorId() == 0) { |
| | | // 平台门票 |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay(name, "", code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentWeChatCallback", "APP", ""); |
| | | return weixinpay; |
| | | }else{ |
| | | } else { |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(store1.getOperatorId()); |
| | | System.err.println("微信商户号"+s2); |
| | | System.err.println("微信商户号" + s2); |
| | | |
| | | if(!StringUtils.hasLength(s2)){ |
| | | if (!StringUtils.hasLength(s2)) { |
| | | return ResultUtil.error("运营商未配置微信商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpayV3(s2,name, code, |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpayV3(s2, name, code, |
| | | "/base/pointMer/exchangeGoodPaymentWeChatCallback1", |
| | | cash.toString()); |
| | | return weixinpay; |
| | | } |
| | | }else{ |
| | | } else { |
| | | // 平台门票 |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay(name, "", code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentWeChatCallback", "APP", ""); |
| | |
| | | |
| | | |
| | | @Override |
| | | public ResultUtil exchangeAddPaymentCallback(String code, String orderNumber) { |
| | | System.err.println("进入回调"+code); |
| | | public ResultUtil exchangeAddPaymentCallback(String code, String orderNumber) throws AlipayApiException { |
| | | System.err.println("进入回调" + code); |
| | | UserPointsMerchandise userPointsMerchandise = mcClient.queryUserPointMerchaseByCode(code).get(0); |
| | | System.err.println("商品"+userPointsMerchandise); |
| | | System.err.println("商品" + userPointsMerchandise); |
| | | if (userPointsMerchandise.getPayStatus() == 2) { |
| | | return ResultUtil.success(); |
| | | } |
| | |
| | | |
| | | Integer pointsMerchandiseId = userPointsMerchandise.getPointsMerchandiseId(); |
| | | PointsMerchandise pointsMerchandise = mcClient.selectPointsMerchandiseById(pointsMerchandiseId); |
| | | if(pointsMerchandise.getType() == 2){ |
| | | if (pointsMerchandise.getType() == 2) { |
| | | //课程 |
| | | CoursePackageOrder coursePackageOrder1 = paymentClient.getCoursePackageOrderByCode(code); |
| | | if(null != coursePackageOrder1){ |
| | | if (null != coursePackageOrder1) { |
| | | coursePackageOrder1.setPayStatus(2); |
| | | coursePackageOrder1.setOrderNumber(orderNumber); |
| | | coursePackageOrder1.setAppUserId(null); |
| | |
| | | paymentClient.addCoursePackageOrderStudent(addCoursePackageOrderStudent); |
| | | } |
| | | } |
| | | List<Integer> integers = mcsClient.queryPointMerStoreIds(pointsMerchandise.getId()); |
| | | Store store1 = storeClient.queryStoreById(integers.get(0)); |
| | | if (store1.getOperatorId() != null && store1.getOperatorId() != 0) { |
| | | String s2 = storeClient.getmerchantNumberAliByOperatorId(store1.getOperatorId()); |
| | | System.err.println("支付宝商户号" + s2); |
| | | payMoneyUtil.confirm(s2, code, orderNumber, userPointsMerchandise.getCash().toString()); |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid1,"课包续费", "课包续费", "", code, amount.toString(), |
| | | "/base/coursePackage/alipayPaymentCallback"); |
| | | if (alipay.getCode() == 200) { |
| | | String finalSmid = smid1; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | |
| | | coursePackagePayment.setOrderNumber(tradeNo); |
| | | couPayClient.updatePaymentCoursePackage(coursePackagePayment); |
| | | Integer coursePackageId = coursePackagePayment.getCoursePackageId(); |
| | | // 判断这个课包是属于哪个运营商的 |
| | | CoursePackage coursePackage = coursePackageClient.queryCoursePackageById(coursePackageId); |
| | | Integer storeId = coursePackage.getStoreId(); |
| | | Store store = storeClient.queryStoreById(storeId); |
| | | String smid1= ""; |
| | | if (store.getOperatorId()==null || store.getOperatorId() == 0){ |
| | | // 平台 |
| | | smid1 = smid; |
| | | // 属于平台 不做资金冻结 不做分账处理 |
| | | // payMoneyUtil.confirm(smid1,code,tradeNo,amount.toString()); |
| | | }else{ |
| | | String smidByOperatorId = storeClient.getSMIDByOperatorId(store.getOperatorId()); |
| | | smid1 = smidByOperatorId; |
| | | payMoneyUtil.confirm1(smid1,code,tradeNo,amount.toString()); |
| | | // 分账处理 |
| | | extracted(store.getOperatorId(), amount, tradeNo); |
| | | } |
| | | |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(finalSmid,code,tradeNo,amount.toString()); |
| | | break; |
| | | } |
| | | if ("WAIT_BUYER_PAY".equals(tradeStatus)) { |
| | |
| | | // 注册会员送券 先判断是否有注册送券类型的优惠券 判断优惠券状态 审核是否通过 是否删除 是否在有效期内 是否领取数量达上限 |
| | | List<Long> longs = userConponClient.queryCouponByUser(appUser.getId()); |
| | | redisUtil.setStrValue("VIP_P_" + vipPayment1.getAppUserId(), JSON.toJSONString(longs), 3600); |
| | | // 如果交易结束 将当前订单金额分配到商户 |
| | | // payMoneyUtil.confirm(smid,vipPayment.getCode(),tradeNo,amount); |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(smid, code, tradeNo, amount); |
| | | return; |
| | | } |
| | | if ("WAIT_BUYER_PAY".equals(tradeStatus)) { |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.CertAlipayRequest; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.*; |
| | | import com.alipay.api.domain.*; |
| | | import com.alipay.api.request.*; |
| | | import com.alipay.api.response.*; |
| | |
| | | import java.util.*; |
| | | |
| | | import static com.dsh.account.util.akeylogin.Md5Util.byteArrayToHexString; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.AlipayConfig; |
| | | import com.alipay.api.domain.SettleDetailInfo; |
| | | import com.alipay.api.response.AlipayTradeSettleConfirmResponse; |
| | | import com.alipay.api.domain.SettleConfirmExtendParams; |
| | | import com.alipay.api.request.AlipayTradeSettleConfirmRequest; |
| | | import com.alipay.api.domain.AlipayTradeSettleConfirmModel; |
| | | import com.alipay.api.domain.SettleInfo; |
| | | |
| | | import com.alipay.api.FileItem; |
| | | import java.util.Base64; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | /** |
| | | * 第三方支付工具类 |
| | | */ |
| | |
| | | */ |
| | | public ResultUtil alipay(String smid,String body, String subject, |
| | | String passbackParams, String outTradeNo, String amount, String notifyUrl) { |
| | | // //构造client |
| | | // CertAlipayRequest certAlipayRequest = new CertAlipayRequest (); |
| | | // //设置网关地址 |
| | | // certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | // //设置应用Id |
| | | // certAlipayRequest.setAppId(aliAppid); |
| | | // //设置应用私钥 |
| | | // certAlipayRequest.setPrivateKey(appPrivateKey); |
| | | // //设置请求格式,固定值json |
| | | // certAlipayRequest.setFormat("json"); |
| | | // //设置字符集 |
| | | // certAlipayRequest.setCharset("UTF-8"); |
| | | // //设置签名类型 |
| | | // certAlipayRequest.setSignType("RSA2"); |
| | | // //设置应用公钥证书路径 |
| | | // certAlipayRequest.setCertPath(app_cert_path); |
| | | // //设置支付宝公钥证书路径 |
| | | // certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path); |
| | | // //设置支付宝根证书路径 |
| | | // certAlipayRequest.setRootCertPath(alipay_root_cert_path); |
| | | // //构造client |
| | | // AlipayClient alipayClient = null; |
| | | // try { |
| | | // alipayClient = new DefaultAlipayClient(certAlipayRequest); |
| | | // } catch (AlipayApiException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay |
| | | // AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest (); |
| | | // //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 |
| | | // AlipayTradeAppPayModel model = new AlipayTradeAppPayModel (); |
| | | // model.setBody(body); |
| | | // model.setSubject (subject); |
| | | // model.setOutTradeNo (outTradeNo); |
| | | // model.setTimeoutExpress ("30m" ); |
| | | // model.setTotalAmount (amount); |
| | | // model.setProductCode ( "QUICK_MSECURITY_PAY" ); |
| | | // model.setPassbackParams(passbackParams);//自定义参数 |
| | | // request.setBizModel ( model ); |
| | | // request.setNotifyUrl (callbackPath + notifyUrl); |
| | | // try { |
| | | // //这里和普通的接口调用不同,使用的是sdkExecute |
| | | // AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderString", response.getBody()); |
| | | // System.out.println(map);//就是orderString 可以直接给客户端请求,无需再做处理。 |
| | | // return ResultUtil.success(map); |
| | | // } catch (AlipayApiException e ) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | //实例化客户端 |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipay_public_key, "RSA2"); |
| | |
| | | subMerchant.setMerchantId(smid); |
| | | model.setSubMerchant(subMerchant); |
| | | |
| | | if (!smid.equals("2088330203191220")){ |
| | | ExtendParams extendParams = new ExtendParams(); |
| | | extendParams.setRoyaltyFreeze("true"); |
| | | model.setExtendParams(extendParams); |
| | | } |
| | | request.setBizModel(model); |
| | | request.setNotifyUrl(callbackPath + notifyUrl); |
| | | System.err.println("回调地址:"+callbackPath + notifyUrl); |
| | | try { |
| | | //这里和普通的接口调用不同,使用的是sdkExecute |
| | | AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); |
| | |
| | | return ResultUtil.success(alipay_trade_precreate_response.getString("qr_code")); |
| | | } |
| | | // 直付通模式 alipay.trade.settle.confirm(统一收单确认结算接口) |
| | | public ResultUtil confirm(String smid1,String code, String outTradeNo, String amount) { |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", |
| | | aliAppid, |
| | | appPrivateKey, |
| | | "json", |
| | | "GBK", |
| | | alipay_public_key, |
| | | "RSA2"); |
| | | public ResultUtil confirm(String smid1,String code, String outTradeNo, String amount) throws AlipayApiException { |
| | | // 初始化SDK |
| | | AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig()); |
| | | |
| | | // 构造请求参数以调用接口 |
| | | AlipayTradeSettleConfirmRequest request = new AlipayTradeSettleConfirmRequest(); |
| | | request.setBizContent("{" + |
| | | " \"out_request_no\":\""+code+"\"," + |
| | | " \"trade_no\":\""+outTradeNo+"\"," + |
| | | " \"settle_info\":{" + |
| | | " \"settle_detail_infos\":[" + |
| | | " {" + |
| | | " \"trans_in_type\":\"defaultSettle\"," + |
| | | " \"settle_entity_id\":\""+smid1+"\"," + |
| | | " \"settle_entity_type\":\"SecondMerchant\"," + |
| | | " \"amount\":"+amount+"," + |
| | | " }" + |
| | | " ]" + |
| | | " }," + |
| | | " \"extend_params\":{" + |
| | | " \"royalty_freeze\":\"false\"" + |
| | | " }" + |
| | | "}"); |
| | | AlipayTradeSettleConfirmResponse response = null; |
| | | try { |
| | | response = alipayClient.execute(request); |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(response.isSuccess()){ |
| | | AlipayTradeSettleConfirmModel model = new AlipayTradeSettleConfirmModel(); |
| | | |
| | | // 设置确认结算请求流水号 |
| | | model.setOutRequestNo(code); |
| | | |
| | | // 设置支付宝交易号 |
| | | model.setTradeNo(outTradeNo); |
| | | |
| | | // 设置描述结算信息 |
| | | SettleInfo settleInfo = new SettleInfo(); |
| | | List<SettleDetailInfo> settleDetailInfos = new ArrayList<SettleDetailInfo>(); |
| | | SettleDetailInfo settleDetailInfos0 = new SettleDetailInfo(); |
| | | settleDetailInfos0.setAmount(amount); |
| | | settleDetailInfos0.setTransIn(smid1); |
| | | settleDetailInfos0.setSettleEntityType("SecondMerchant"); |
| | | settleDetailInfos0.setSettleEntityId(smid1); |
| | | settleDetailInfos0.setTransInType("defaultSettle"); |
| | | settleDetailInfos.add(settleDetailInfos0); |
| | | settleInfo.setSettleDetailInfos(settleDetailInfos); |
| | | model.setSettleInfo(settleInfo); |
| | | request.setBizModel(model); |
| | | System.err.println("结算金额"+amount); |
| | | // 第三方代调用模式下请设置app_auth_token |
| | | // request.putOtherTextParam("app_auth_token", "<-- 请填写应用授权令牌 -->"); |
| | | |
| | | AlipayTradeSettleConfirmResponse response = alipayClient.execute(request); |
| | | System.out.println("返回体"+response.getBody()); |
| | | |
| | | |
| | | if (response.isSuccess()) { |
| | | System.out.println("调用成功"); |
| | | return ResultUtil.success(); |
| | | } else { |
| | | System.out.println("调用失败"); |
| | | return ResultUtil.error("出现问题啦"); |
| | | // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接 |
| | | // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response); |
| | | // System.out.println(diagnosisUrl); |
| | | } |
| | | return ResultUtil.success(response.getBody()); |
| | | } |
| | | private static AlipayConfig getAlipayConfig() { |
| | | String privateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0QsaPtxeqJUGAOcGdVLllQ7easEznP8DFBvDdHATcmp2SHNQDUEWN6MCVPbMgY06NQVqAXxqjTAYSVh+6TRu6bofPmpYC3TZB003AgMBAAECggEBAJAcR2+PA3NBYUYHeFrqBRMS8uX8ZR19kjZ7IgoSLTFaQsP9opRylPSPXhrPVBKAE5leRQAHn4MCSlESwHvMfxo7KFjFTFAc6dffZZpipYQUOc9bGampwJh58/3e/pyBgVMG6J23CPf/HJQtNFSkjd/V9+ayb/9l2dUEL3bC0fAZ/dbx8HsxdLw8wn3fLlWLj68hOMqa2deCZe3JdSVsPbeWqkh56FFsMLug0Nd+Ar4TgRl9/jnhXF0JWiD0LmPUYLhboY7EfUBzN4w1iYbDi1P+3zvoOYsiVKAXox9GMhQ2VzOO2UcSTuizSza2e98mGpabl/GpKmCz+RDFjtkX6eECgYEA2MyCij65eO3aGIm3FUe93DULRBYTfX8qJQSJq2WOWA3mmQlEW6L3O2B5/lG2h+8WmN6iLEs9eHpgycGYp7vAqgrANEn16ACVcuyx0scFtrZfZ+kmHMzFfiUWxJjVYk/6YngsGVBLdw6ueM42C8TTP67X9tU5TdVGoGWuqEj4W98CgYEAwFqwprXOch5Pqk/RPbb49r0Ou03K/UbciWnWWKzUhFFNS8MdlQPoDvQZbMwHLeWsa2VhaKITK3x5biLQb3U+0GLOn6lTvEyrEUH+ucREyLgVYTRAvwBPtnvlrzpyxPk2HnslQjju8WrvvLLBMKWUjlTrTOzhaHT21gz3pHMiOakCgYEAhLmfaXdBITGshb054sNLDtdCkGpbgEcrzAHdLps769iGxkYQHXHFngpQZUwtTUcoNGqIKknd1jZFrv7gsD+XkgKG7PwimehRlkwmCX5ilxtLiVgJRzRt6+5U5AMVD90a0tHzXYP0z2yjj73fBJF5KtGl0a10KZxaYrQdm1UhB00CgYBZZgzx/k9rtHC8LAqIj1CYhHejT92G53c6Gkl3vyOqN4sgKhfGmSEySfrDGPRBPZxr8ZtbIPCd5mUdberH0osWGMYFaJI1UsCy7aQwvGpniz7MhZeN7dweaOjwDs8mgtjHQ96mL4XGCDhR0BZ/wIURvZ/6iaGdhbbu9unlsWj3uQKBgQCmZYdsbbZkd3ev6f8rwyvMz+DrCQyYpY44cegBYuJgrZiQnL2fJioeN7ixX0UM48SfwsZEIrzshP/LGAwnc2MdjxKUl4jLN8SEe0NAjXOnz9Zaw740+aOmLpXcLWdP4uM2gIhWsvW1tEkQZCXmm7c9s/RsU8Pmzv+YL3+fSijOzA=="; |
| | | String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmu8n/4yTHWbn7VOrNc9OsLtDL1bEQ8gC1dHkj8Wy5z0mkaOsjJRIG/28ze12M0V8jdCKuuDr5Z1OPKiqf+XO3ypguEh+mYUVMBM/cZodDFQfTY1TKLWjvQCuaqlA+QUTCK6f7T7stsgyQ1o9Jj0rXZDz6PM4QHSTzjrLIBaeqM5WIBvH+fy/X+QG5Utd+/UT0kc0JyvuKhZ65yVUd/C9VcwJJAPliRsAQNrqYterwAJ9zvw9tF11wj9W0XgJ8Ccu4x3gR1vrlLRJJo/OA97RmxPQ+5hSacWQZCUd1dwiBq+YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB"; |
| | | AlipayConfig alipayConfig = new AlipayConfig(); |
| | | alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | alipayConfig.setAppId("2021004105665036"); |
| | | alipayConfig.setPrivateKey(privateKey); |
| | | alipayConfig.setFormat("json"); |
| | | alipayConfig.setAlipayPublicKey(alipayPublicKey); |
| | | alipayConfig.setCharset("UTF-8"); |
| | | alipayConfig.setSignType("RSA2"); |
| | | return alipayConfig; |
| | | } |
| | | // 资金冻结 做分账处理 |
| | | public ResultUtil confirm1(String smid,String code, String outTradeNo, String amount) { |
| | |
| | | package com.dsh.communityWorldCup.service; |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.dsh.communityWorldCup.entity.WorldCup; |
| | | import com.dsh.communityWorldCup.model.*; |
| | |
| | | * @param outTradeNo |
| | | * @return |
| | | */ |
| | | ResultUtil paymentWorldCupCallback(String code, String outTradeNo); |
| | | ResultUtil paymentWorldCupCallback(String code, String outTradeNo) throws AlipayApiException; |
| | | |
| | | |
| | | /** |
| | |
| | | return payment; |
| | | } |
| | | |
| | | private String smidVx = "2088330203191220";//平台微信商户号 |
| | | private String smid = "2088330203191220";//平台支付宝商户号 |
| | | |
| | | |
| | | /** |
| | | * 支付逻辑 |
| | |
| | | } |
| | | //支付宝 |
| | | if(payType == 2){ |
| | | String smidRes = smid;// 结算资金到商户号 |
| | | |
| | | worldCupPayment.setAmount(new BigDecimal(num).multiply(worldCup.getCash())); |
| | | worldCupPayment.setUnitPrice(worldCupPayment.getAmount().divide(new BigDecimal(num))); |
| | | worldCupPaymentService.save(worldCupPayment); |
| | | List<WorldCupStore> list = worldCupStoreService.lambdaQuery().eq(WorldCupStore::getWorldCupId, worldCup.getId()).list(); |
| | | |
| | | if (list.isEmpty()){ |
| | | return payMoneyUtil.alipay("2088330203191220", "社区世界杯报名", "世界杯报名", "", worldCupPayment.getCode(), |
| | | worldCupPayment.getAmount().toString(), "/base/worldCup/aliPayWorldCupCallback"); |
| | | }else{ |
| | | Integer storeId = list.get(0).getStoreId(); |
| | | Store store = storeClient.queryStoreById(storeId); |
| | | if (store.getOperatorId()==null||store.getOperatorId()==0){ |
| | | return payMoneyUtil.alipay("2088330203191220", "社区世界杯报名", "世界杯报名", "", worldCupPayment.getCode(), |
| | | worldCupPayment.getAmount().toString(), "/base/worldCup/aliPayWorldCupCallback"); |
| | | }else{ |
| | | String s2 = storeClient.getmerchantNumberAliByOperatorId(store.getOperatorId()); |
| | | System.err.println("支付宝商户号"+s2); |
| | | if(!StringUtils.hasLength(s2)){ |
| | | return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); |
| | | } |
| | | return payMoneyUtil.alipay(s2, "社区世界杯报名", "世界杯报名", "", worldCupPayment.getCode(), |
| | | worldCupPayment.getAmount().toString(), "/base/worldCup/aliPayWorldCupCallback"); |
| | | smidRes=s2; |
| | | } |
| | | } |
| | | return payMoneyUtil.alipay(smidRes, "社区世界杯报名", "世界杯报名", "", worldCupPayment.getCode(), |
| | | worldCupPayment.getAmount().toString(), "/base/worldCup/aliPayWorldCupCallback"); |
| | | } |
| | | //玩湃币 |
| | | if(payType == 3){ |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultUtil paymentWorldCupCallback(String code, String outTradeNo) { |
| | | public ResultUtil paymentWorldCupCallback(String code, String outTradeNo) throws AlipayApiException { |
| | | WorldCupPayment worldCupPayment = worldCupPaymentService.getOne(new QueryWrapper<WorldCupPayment>().eq("code", code)); |
| | | Integer worldCupId = worldCupPayment.getWorldCupId(); |
| | | worldCupPayment.setPayStatus(2); |
| | |
| | | worldCupPaymentParticipant.setCreateTime(new Date()); |
| | | worldCupPaymentParticipantService.save(worldCupPaymentParticipant); |
| | | } |
| | | if (worldCupPayment.getPayType()==2){ |
| | | List<WorldCupStore> list = worldCupStoreService.lambdaQuery().eq(WorldCupStore::getWorldCupId, worldCupPayment.getWorldCupId()).list(); |
| | | String resSmid = smid; |
| | | if (!list.isEmpty()){ |
| | | Integer storeId = list.get(0).getStoreId(); |
| | | Store store = storeClient.queryStoreById(storeId); |
| | | if (store.getOperatorId()==null||store.getOperatorId()==0){ |
| | | }else{ |
| | | String s2 = storeClient.getmerchantNumberAliByOperatorId(store.getOperatorId()); |
| | | System.err.println("支付宝商户号"+s2); |
| | | if(!StringUtils.hasLength(s2)){ |
| | | return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); |
| | | } |
| | | resSmid=s2; |
| | | } |
| | | } |
| | | String finalResSmid = resSmid; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(finalResSmid, code, outTradeNo, worldCupPayment.getAmount().toString()); |
| | | }catch (Exception e){ |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.CertAlipayRequest; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.*; |
| | | import com.alipay.api.domain.*; |
| | | import com.alipay.api.request.*; |
| | | import com.alipay.api.response.*; |
| | |
| | | * 支付宝支付 |
| | | */ |
| | | public ResultUtil alipay(String smid,String body, String subject, String passbackParams, String outTradeNo, String amount, String notifyUrl) { |
| | | // //构造client |
| | | // CertAlipayRequest certAlipayRequest = new CertAlipayRequest (); |
| | | // //设置网关地址 |
| | | // certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | // //设置应用Id |
| | | // certAlipayRequest.setAppId(aliAppid); |
| | | // //设置应用私钥 |
| | | // certAlipayRequest.setPrivateKey(appPrivateKey); |
| | | // //设置请求格式,固定值json |
| | | // certAlipayRequest.setFormat("json"); |
| | | // //设置字符集 |
| | | // certAlipayRequest.setCharset("UTF-8"); |
| | | // //设置签名类型 |
| | | // certAlipayRequest.setSignType("RSA2"); |
| | | // //设置应用公钥证书路径 |
| | | // certAlipayRequest.setCertPath(app_cert_path); |
| | | // //设置支付宝公钥证书路径 |
| | | // certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path); |
| | | // //设置支付宝根证书路径 |
| | | // certAlipayRequest.setRootCertPath(alipay_root_cert_path); |
| | | // //构造client |
| | | // AlipayClient alipayClient = null; |
| | | // try { |
| | | // alipayClient = new DefaultAlipayClient(certAlipayRequest); |
| | | // } catch (AlipayApiException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay |
| | | // AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest (); |
| | | // //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 |
| | | // AlipayTradeAppPayModel model = new AlipayTradeAppPayModel (); |
| | | // model.setBody(body); |
| | | // model.setSubject (subject); |
| | | // model.setOutTradeNo (outTradeNo); |
| | | // model.setTimeoutExpress ("30m" ); |
| | | // model.setTotalAmount (amount); |
| | | // model.setProductCode ( "QUICK_MSECURITY_PAY" ); |
| | | // model.setPassbackParams(passbackParams);//自定义参数 |
| | | // request.setBizModel ( model ); |
| | | // request.setNotifyUrl (callbackPath + notifyUrl); |
| | | // try { |
| | | // //这里和普通的接口调用不同,使用的是sdkExecute |
| | | // AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderString", response.getBody()); |
| | | // System.out.println(map);//就是orderString 可以直接给客户端请求,无需再做处理。 |
| | | // return ResultUtil.success(map); |
| | | // } catch (AlipayApiException e ) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | |
| | | //实例化客户端 |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipay_public_key, "RSA2"); |
| | | //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay |
| | |
| | | SubMerchant subMerchant = new SubMerchant(); |
| | | subMerchant.setMerchantId(smid); |
| | | model.setSubMerchant(subMerchant); |
| | | if (!smid.equals("2088330203191220")){ |
| | | ExtendParams extendParams = new ExtendParams(); |
| | | extendParams.setRoyaltyFreeze("true"); |
| | | model.setExtendParams(extendParams); |
| | | } |
| | | request.setBizModel(model); |
| | | request.setNotifyUrl(callbackPath + notifyUrl); |
| | | |
| | |
| | | |
| | | /** |
| | | * 统一确认结算接口 |
| | | * @param smid |
| | | * @param code |
| | | * @param outTradeNo |
| | | * @param amount |
| | | * @return |
| | | */ |
| | | public ResultUtil confirm(String smid,String code, String outTradeNo, String amount) { |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", |
| | | aliAppid, |
| | | appPrivateKey, |
| | | "json", |
| | | "GBK", |
| | | alipay_public_key, |
| | | "RSA2"); |
| | | public ResultUtil confirm(String smid1,String code, String outTradeNo, String amount) throws AlipayApiException { |
| | | // 初始化SDK |
| | | AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig()); |
| | | |
| | | // 构造请求参数以调用接口 |
| | | AlipayTradeSettleConfirmRequest request = new AlipayTradeSettleConfirmRequest(); |
| | | request.setBizContent("{" + |
| | | " \"out_request_no\":\""+code+"\"," + |
| | | " \"trade_no\":\""+outTradeNo+"\"," + |
| | | " \"settle_info\":{" + |
| | | " \"settle_detail_infos\":[" + |
| | | " {" + |
| | | " \"trans_in_type\":\"defaultSettle\"," + |
| | | " \"settle_entity_id\":\""+smid+"\"," + |
| | | " \"settle_entity_type\":\"SecondMerchant\"," + |
| | | " \"amount\":"+amount+"," + |
| | | " }" + |
| | | " ]" + |
| | | " }," + |
| | | " \"extend_params\":{" + |
| | | " \"royalty_freeze\":\"false\"" + |
| | | " }" + |
| | | "}"); |
| | | AlipayTradeSettleConfirmResponse response = null; |
| | | try { |
| | | response = alipayClient.execute(request); |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(response.isSuccess()){ |
| | | AlipayTradeSettleConfirmModel model = new AlipayTradeSettleConfirmModel(); |
| | | |
| | | // 设置确认结算请求流水号 |
| | | model.setOutRequestNo(code); |
| | | |
| | | // 设置支付宝交易号 |
| | | model.setTradeNo(outTradeNo); |
| | | |
| | | // 设置描述结算信息 |
| | | SettleInfo settleInfo = new SettleInfo(); |
| | | List<SettleDetailInfo> settleDetailInfos = new ArrayList<SettleDetailInfo>(); |
| | | SettleDetailInfo settleDetailInfos0 = new SettleDetailInfo(); |
| | | settleDetailInfos0.setAmount(amount); |
| | | settleDetailInfos0.setTransIn(smid1); |
| | | settleDetailInfos0.setSettleEntityType("SecondMerchant"); |
| | | settleDetailInfos0.setSettleEntityId(smid1); |
| | | settleDetailInfos0.setTransInType("defaultSettle"); |
| | | settleDetailInfos.add(settleDetailInfos0); |
| | | settleInfo.setSettleDetailInfos(settleDetailInfos); |
| | | model.setSettleInfo(settleInfo); |
| | | request.setBizModel(model); |
| | | System.err.println("结算金额"+amount); |
| | | // 第三方代调用模式下请设置app_auth_token |
| | | // request.putOtherTextParam("app_auth_token", "<-- 请填写应用授权令牌 -->"); |
| | | |
| | | AlipayTradeSettleConfirmResponse response = alipayClient.execute(request); |
| | | System.out.println("返回体"+response.getBody()); |
| | | |
| | | |
| | | if (response.isSuccess()) { |
| | | System.out.println("调用成功"); |
| | | return ResultUtil.success(); |
| | | } else { |
| | | System.out.println("调用失败"); |
| | | return ResultUtil.error("出现问题啦"); |
| | | // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接 |
| | | // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response); |
| | | // System.out.println(diagnosisUrl); |
| | | } |
| | | return ResultUtil.success(response.getBody()); |
| | | } |
| | | |
| | | private static AlipayConfig getAlipayConfig() { |
| | | String privateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0QsaPtxeqJUGAOcGdVLllQ7easEznP8DFBvDdHATcmp2SHNQDUEWN6MCVPbMgY06NQVqAXxqjTAYSVh+6TRu6bofPmpYC3TZB003AgMBAAECggEBAJAcR2+PA3NBYUYHeFrqBRMS8uX8ZR19kjZ7IgoSLTFaQsP9opRylPSPXhrPVBKAE5leRQAHn4MCSlESwHvMfxo7KFjFTFAc6dffZZpipYQUOc9bGampwJh58/3e/pyBgVMG6J23CPf/HJQtNFSkjd/V9+ayb/9l2dUEL3bC0fAZ/dbx8HsxdLw8wn3fLlWLj68hOMqa2deCZe3JdSVsPbeWqkh56FFsMLug0Nd+Ar4TgRl9/jnhXF0JWiD0LmPUYLhboY7EfUBzN4w1iYbDi1P+3zvoOYsiVKAXox9GMhQ2VzOO2UcSTuizSza2e98mGpabl/GpKmCz+RDFjtkX6eECgYEA2MyCij65eO3aGIm3FUe93DULRBYTfX8qJQSJq2WOWA3mmQlEW6L3O2B5/lG2h+8WmN6iLEs9eHpgycGYp7vAqgrANEn16ACVcuyx0scFtrZfZ+kmHMzFfiUWxJjVYk/6YngsGVBLdw6ueM42C8TTP67X9tU5TdVGoGWuqEj4W98CgYEAwFqwprXOch5Pqk/RPbb49r0Ou03K/UbciWnWWKzUhFFNS8MdlQPoDvQZbMwHLeWsa2VhaKITK3x5biLQb3U+0GLOn6lTvEyrEUH+ucREyLgVYTRAvwBPtnvlrzpyxPk2HnslQjju8WrvvLLBMKWUjlTrTOzhaHT21gz3pHMiOakCgYEAhLmfaXdBITGshb054sNLDtdCkGpbgEcrzAHdLps769iGxkYQHXHFngpQZUwtTUcoNGqIKknd1jZFrv7gsD+XkgKG7PwimehRlkwmCX5ilxtLiVgJRzRt6+5U5AMVD90a0tHzXYP0z2yjj73fBJF5KtGl0a10KZxaYrQdm1UhB00CgYBZZgzx/k9rtHC8LAqIj1CYhHejT92G53c6Gkl3vyOqN4sgKhfGmSEySfrDGPRBPZxr8ZtbIPCd5mUdberH0osWGMYFaJI1UsCy7aQwvGpniz7MhZeN7dweaOjwDs8mgtjHQ96mL4XGCDhR0BZ/wIURvZ/6iaGdhbbu9unlsWj3uQKBgQCmZYdsbbZkd3ev6f8rwyvMz+DrCQyYpY44cegBYuJgrZiQnL2fJioeN7ixX0UM48SfwsZEIrzshP/LGAwnc2MdjxKUl4jLN8SEe0NAjXOnz9Zaw740+aOmLpXcLWdP4uM2gIhWsvW1tEkQZCXmm7c9s/RsU8Pmzv+YL3+fSijOzA=="; |
| | | String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmu8n/4yTHWbn7VOrNc9OsLtDL1bEQ8gC1dHkj8Wy5z0mkaOsjJRIG/28ze12M0V8jdCKuuDr5Z1OPKiqf+XO3ypguEh+mYUVMBM/cZodDFQfTY1TKLWjvQCuaqlA+QUTCK6f7T7stsgyQ1o9Jj0rXZDz6PM4QHSTzjrLIBaeqM5WIBvH+fy/X+QG5Utd+/UT0kc0JyvuKhZ65yVUd/C9VcwJJAPliRsAQNrqYterwAJ9zvw9tF11wj9W0XgJ8Ccu4x3gR1vrlLRJJo/OA97RmxPQ+5hSacWQZCUd1dwiBq+YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB"; |
| | | AlipayConfig alipayConfig = new AlipayConfig(); |
| | | alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | alipayConfig.setAppId("2021004105665036"); |
| | | alipayConfig.setPrivateKey(privateKey); |
| | | alipayConfig.setFormat("json"); |
| | | alipayConfig.setAlipayPublicKey(alipayPublicKey); |
| | | alipayConfig.setCharset("UTF-8"); |
| | | alipayConfig.setSignType("RSA2"); |
| | | return alipayConfig; |
| | | } |
| | | /** |
| | | * 微信统一下单 |
| | | * |
| | |
| | | } |
| | | |
| | | if (paymentCompetitionVo.getPayType() == 2) {//支付宝 |
| | | String resSmid=smid; |
| | | // 判断当前赛事属于哪个运营商 |
| | | Competition byId = competitionService.getById(paymentCompetitionVo.getId()); |
| | | String[] split = byId.getStoreId().split(","); |
| | |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil aliPaymentCompetition(Integer operatorId,String smid,String code, BigDecimal money) throws Exception { |
| | | String resSmid=smid; |
| | | ResultUtil alipay = payMoneyUtil.alipay |
| | | (smid,"报名赛事", "", "", code, money.toString(), "/base/competition/aliPaymentCompetitionCallback"); |
| | | // if (alipay.getCode() == 200) { |
| | | // new Thread(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // try { |
| | | // int num = 1; |
| | | // int wait = 0; |
| | | // while (num <= 10) { |
| | | // int min = 5000; |
| | | // wait += (min * num); |
| | | // Thread.sleep(wait); |
| | | // PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 2)); |
| | | // if (paymentCompetition.getPayStatus() == 2) { |
| | | // break; |
| | | // } |
| | | // AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | // if (resultUtil.getCode().equals("10000") && paymentCompetition.getPayStatus() == 1) { |
| | | // /** |
| | | // * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | // * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | // * TRADE_SUCCESS(交易支付成功)、 |
| | | // * TRADE_FINISHED(交易结束,不可退款) |
| | | // */ |
| | | //// Map<String, String> data1 = resultUtil.getData(); |
| | | //// String s = data1.get("tradeStatus"); |
| | | //// String tradeNo = data1.get("tradeNo"); |
| | | // String tradeNo = resultUtil.getTradeNo(); |
| | | // String s = resultUtil.getTradeStatus(); |
| | | // |
| | | // if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | // paymentCompetition.setAppUserId(null); |
| | | // paymentCompetition.setState(3); |
| | | // userCompetitionService.remove(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId())); |
| | | // |
| | | // break; |
| | | // } |
| | | // if ("TRADE_SUCCESS".equals(s)) { |
| | | // paymentCompetition.setAppUserId(null); |
| | | // paymentCompetition.setPayStatus(2); |
| | | // paymentCompetition.setPayTime(new Date()); |
| | | // paymentCompetition.setPayOrderNo(tradeNo); |
| | | // paymentCompetitionService.updateById(paymentCompetition); |
| | | // |
| | | // Competition competition = cttService.getById(paymentCompetition.getCompetitionId()); |
| | | // competition.setApplicantsNumber(competition.getApplicantsNumber() + 1); |
| | | // cttService.updateById(competition); |
| | | // |
| | | // // 结算资金到商户账号 |
| | | // payMoneyUtil.confirm(smid,code,tradeNo,money.toString()); |
| | | // if (operatorId == null || operatorId == 0){ |
| | | // // 属于平台的赛事 资金不做冻结 不做分账处理 |
| | | // payMoneyUtil.confirm1(smid,code,tradeNo,money.toString()); |
| | | // }else{ |
| | | // // 资金冻结 |
| | | // payMoneyUtil.confirm(smid,code,tradeNo,money.toString()); |
| | | // // 分账处理 |
| | | // extracted(operatorId, money, tradeNo); |
| | | // } |
| | | // // 结算资金到商户账号 |
| | | // //分账 |
| | | //// moneyOut(tradeNo, tradeNo,code); |
| | | // break; |
| | | // } |
| | | // if ("WAIT_BUYER_PAY".equals(s)) { |
| | | // num++; |
| | | // } |
| | | // } |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }).start(); |
| | | // } |
| | | if (alipay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10) { |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 2)); |
| | | if (paymentCompetition.getPayStatus() == 2) { |
| | | break; |
| | | } |
| | | AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if (resultUtil.getCode().equals("10000") && paymentCompetition.getPayStatus() == 1) { |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | // Map<String, String> data1 = resultUtil.getData(); |
| | | // String s = data1.get("tradeStatus"); |
| | | // String tradeNo = data1.get("tradeNo"); |
| | | String tradeNo = resultUtil.getTradeNo(); |
| | | String s = resultUtil.getTradeStatus(); |
| | | |
| | | if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | paymentCompetition.setAppUserId(null); |
| | | paymentCompetition.setState(3); |
| | | userCompetitionService.remove(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId())); |
| | | |
| | | break; |
| | | } |
| | | if ("TRADE_SUCCESS".equals(s)) { |
| | | paymentCompetition.setAppUserId(null); |
| | | paymentCompetition.setPayStatus(2); |
| | | paymentCompetition.setPayTime(new Date()); |
| | | paymentCompetition.setPayOrderNo(tradeNo); |
| | | paymentCompetitionService.updateById(paymentCompetition); |
| | | Competition competition = cttService.getById(paymentCompetition.getCompetitionId()); |
| | | competition.setApplicantsNumber(competition.getApplicantsNumber() + 1); |
| | | cttService.updateById(competition); |
| | | // 结算资金到商户账号 |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(resSmid,code,tradeNo,money.toString()); |
| | | break; |
| | | } |
| | | if ("WAIT_BUYER_PAY".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | return alipay; |
| | | } |
| | | private void extracted(Integer operatorId, BigDecimal money, String tradeNo) throws Exception { |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.CertAlipayRequest; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.*; |
| | | import com.alipay.api.domain.*; |
| | | import com.alipay.api.request.*; |
| | | import com.alipay.api.response.*; |
| | |
| | | * 支付宝支付 |
| | | */ |
| | | public ResultUtil alipay(String smid,String body, String subject, String passbackParams, String outTradeNo, String amount, String notifyUrl) { |
| | | // //构造client |
| | | // CertAlipayRequest certAlipayRequest = new CertAlipayRequest (); |
| | | // //设置网关地址 |
| | | // certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | // //设置应用Id |
| | | // certAlipayRequest.setAppId(aliAppid); |
| | | // //设置应用私钥 |
| | | // certAlipayRequest.setPrivateKey(appPrivateKey); |
| | | // //设置请求格式,固定值json |
| | | // certAlipayRequest.setFormat("json"); |
| | | // //设置字符集 |
| | | // certAlipayRequest.setCharset("UTF-8"); |
| | | // //设置签名类型 |
| | | // certAlipayRequest.setSignType("RSA2"); |
| | | // //设置应用公钥证书路径 |
| | | // certAlipayRequest.setCertPath(app_cert_path); |
| | | // //设置支付宝公钥证书路径 |
| | | // certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path); |
| | | // //设置支付宝根证书路径 |
| | | // certAlipayRequest.setRootCertPath(alipay_root_cert_path); |
| | | // //构造client |
| | | // AlipayClient alipayClient = null; |
| | | // try { |
| | | // alipayClient = new DefaultAlipayClient(certAlipayRequest); |
| | | // } catch (AlipayApiException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay |
| | | // AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest (); |
| | | // //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 |
| | | // AlipayTradeAppPayModel model = new AlipayTradeAppPayModel (); |
| | | // model.setBody(body); |
| | | // model.setSubject (subject); |
| | | // model.setOutTradeNo (outTradeNo); |
| | | // model.setTimeoutExpress ("30m" ); |
| | | // model.setTotalAmount (amount); |
| | | // model.setProductCode ( "QUICK_MSECURITY_PAY" ); |
| | | // model.setPassbackParams(passbackParams);//自定义参数 |
| | | // request.setBizModel ( model ); |
| | | // request.setNotifyUrl (callbackPath + notifyUrl); |
| | | // try { |
| | | // //这里和普通的接口调用不同,使用的是sdkExecute |
| | | // AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderString", response.getBody()); |
| | | // System.out.println(map);//就是orderString 可以直接给客户端请求,无需再做处理。 |
| | | // return ResultUtil.success(map); |
| | | // } catch (AlipayApiException e ) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | |
| | | //实例化客户端 |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipay_public_key, "RSA2"); |
| | | //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay |
| | |
| | | SubMerchant subMerchant = new SubMerchant(); |
| | | subMerchant.setMerchantId(smid); |
| | | model.setSubMerchant(subMerchant); |
| | | |
| | | if (!smid.equals("2088330203191220")){ |
| | | ExtendParams extendParams = new ExtendParams(); |
| | | extendParams.setRoyaltyFreeze("true"); |
| | | model.setExtendParams(extendParams); |
| | | } |
| | | request.setBizModel(model); |
| | | request.setNotifyUrl(callbackPath + notifyUrl); |
| | | |
| | |
| | | * @param amount |
| | | * @return |
| | | */ |
| | | public ResultUtil confirm(String smid,String code, String outTradeNo, String amount) { |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", |
| | | aliAppid, |
| | | appPrivateKey, |
| | | "json", |
| | | "GBK", |
| | | alipay_public_key, |
| | | "RSA2"); |
| | | public ResultUtil confirm(String smid1,String code, String outTradeNo, String amount) throws AlipayApiException { |
| | | // 初始化SDK |
| | | AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig()); |
| | | |
| | | // 构造请求参数以调用接口 |
| | | AlipayTradeSettleConfirmRequest request = new AlipayTradeSettleConfirmRequest(); |
| | | request.setBizContent("{" + |
| | | " \"out_request_no\":\""+code+"\"," + |
| | | " \"trade_no\":\""+outTradeNo+"\"," + |
| | | " \"settle_info\":{" + |
| | | " \"settle_detail_infos\":[" + |
| | | " {" + |
| | | " \"trans_in_type\":\"defaultSettle\"," + |
| | | " \"settle_entity_id\":\""+smid+"\"," + |
| | | " \"settle_entity_type\":\"SecondMerchant\"," + |
| | | " \"amount\":"+amount+"," + |
| | | " }" + |
| | | " ]" + |
| | | " }," + |
| | | " \"extend_params\":{" + |
| | | " \"royalty_freeze\":\"true\"" + |
| | | " }" + |
| | | "}"); |
| | | AlipayTradeSettleConfirmResponse response = null; |
| | | try { |
| | | response = alipayClient.execute(request); |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(response.isSuccess()){ |
| | | AlipayTradeSettleConfirmModel model = new AlipayTradeSettleConfirmModel(); |
| | | |
| | | // 设置确认结算请求流水号 |
| | | model.setOutRequestNo(code); |
| | | |
| | | // 设置支付宝交易号 |
| | | model.setTradeNo(outTradeNo); |
| | | |
| | | // 设置描述结算信息 |
| | | SettleInfo settleInfo = new SettleInfo(); |
| | | List<SettleDetailInfo> settleDetailInfos = new ArrayList<SettleDetailInfo>(); |
| | | SettleDetailInfo settleDetailInfos0 = new SettleDetailInfo(); |
| | | settleDetailInfos0.setAmount(amount); |
| | | settleDetailInfos0.setTransIn(smid1); |
| | | settleDetailInfos0.setSettleEntityType("SecondMerchant"); |
| | | settleDetailInfos0.setSettleEntityId(smid1); |
| | | settleDetailInfos0.setTransInType("defaultSettle"); |
| | | settleDetailInfos.add(settleDetailInfos0); |
| | | settleInfo.setSettleDetailInfos(settleDetailInfos); |
| | | model.setSettleInfo(settleInfo); |
| | | request.setBizModel(model); |
| | | System.err.println("结算金额"+amount); |
| | | // 第三方代调用模式下请设置app_auth_token |
| | | // request.putOtherTextParam("app_auth_token", "<-- 请填写应用授权令牌 -->"); |
| | | |
| | | AlipayTradeSettleConfirmResponse response = alipayClient.execute(request); |
| | | System.out.println("返回体"+response.getBody()); |
| | | |
| | | |
| | | if (response.isSuccess()) { |
| | | System.out.println("调用成功"); |
| | | return ResultUtil.success(); |
| | | } else { |
| | | System.out.println("调用失败"); |
| | | return ResultUtil.error("出现问题啦"); |
| | | // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接 |
| | | // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response); |
| | | // System.out.println(diagnosisUrl); |
| | | } |
| | | return ResultUtil.success(response.getBody()); |
| | | } |
| | | private static AlipayConfig getAlipayConfig() { |
| | | String privateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0QsaPtxeqJUGAOcGdVLllQ7easEznP8DFBvDdHATcmp2SHNQDUEWN6MCVPbMgY06NQVqAXxqjTAYSVh+6TRu6bofPmpYC3TZB003AgMBAAECggEBAJAcR2+PA3NBYUYHeFrqBRMS8uX8ZR19kjZ7IgoSLTFaQsP9opRylPSPXhrPVBKAE5leRQAHn4MCSlESwHvMfxo7KFjFTFAc6dffZZpipYQUOc9bGampwJh58/3e/pyBgVMG6J23CPf/HJQtNFSkjd/V9+ayb/9l2dUEL3bC0fAZ/dbx8HsxdLw8wn3fLlWLj68hOMqa2deCZe3JdSVsPbeWqkh56FFsMLug0Nd+Ar4TgRl9/jnhXF0JWiD0LmPUYLhboY7EfUBzN4w1iYbDi1P+3zvoOYsiVKAXox9GMhQ2VzOO2UcSTuizSza2e98mGpabl/GpKmCz+RDFjtkX6eECgYEA2MyCij65eO3aGIm3FUe93DULRBYTfX8qJQSJq2WOWA3mmQlEW6L3O2B5/lG2h+8WmN6iLEs9eHpgycGYp7vAqgrANEn16ACVcuyx0scFtrZfZ+kmHMzFfiUWxJjVYk/6YngsGVBLdw6ueM42C8TTP67X9tU5TdVGoGWuqEj4W98CgYEAwFqwprXOch5Pqk/RPbb49r0Ou03K/UbciWnWWKzUhFFNS8MdlQPoDvQZbMwHLeWsa2VhaKITK3x5biLQb3U+0GLOn6lTvEyrEUH+ucREyLgVYTRAvwBPtnvlrzpyxPk2HnslQjju8WrvvLLBMKWUjlTrTOzhaHT21gz3pHMiOakCgYEAhLmfaXdBITGshb054sNLDtdCkGpbgEcrzAHdLps769iGxkYQHXHFngpQZUwtTUcoNGqIKknd1jZFrv7gsD+XkgKG7PwimehRlkwmCX5ilxtLiVgJRzRt6+5U5AMVD90a0tHzXYP0z2yjj73fBJF5KtGl0a10KZxaYrQdm1UhB00CgYBZZgzx/k9rtHC8LAqIj1CYhHejT92G53c6Gkl3vyOqN4sgKhfGmSEySfrDGPRBPZxr8ZtbIPCd5mUdberH0osWGMYFaJI1UsCy7aQwvGpniz7MhZeN7dweaOjwDs8mgtjHQ96mL4XGCDhR0BZ/wIURvZ/6iaGdhbbu9unlsWj3uQKBgQCmZYdsbbZkd3ev6f8rwyvMz+DrCQyYpY44cegBYuJgrZiQnL2fJioeN7ixX0UM48SfwsZEIrzshP/LGAwnc2MdjxKUl4jLN8SEe0NAjXOnz9Zaw740+aOmLpXcLWdP4uM2gIhWsvW1tEkQZCXmm7c9s/RsU8Pmzv+YL3+fSijOzA=="; |
| | | String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmu8n/4yTHWbn7VOrNc9OsLtDL1bEQ8gC1dHkj8Wy5z0mkaOsjJRIG/28ze12M0V8jdCKuuDr5Z1OPKiqf+XO3ypguEh+mYUVMBM/cZodDFQfTY1TKLWjvQCuaqlA+QUTCK6f7T7stsgyQ1o9Jj0rXZDz6PM4QHSTzjrLIBaeqM5WIBvH+fy/X+QG5Utd+/UT0kc0JyvuKhZ65yVUd/C9VcwJJAPliRsAQNrqYterwAJ9zvw9tF11wj9W0XgJ8Ccu4x3gR1vrlLRJJo/OA97RmxPQ+5hSacWQZCUd1dwiBq+YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB"; |
| | | AlipayConfig alipayConfig = new AlipayConfig(); |
| | | alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | alipayConfig.setAppId("2021004105665036"); |
| | | alipayConfig.setPrivateKey(privateKey); |
| | | alipayConfig.setFormat("json"); |
| | | alipayConfig.setAlipayPublicKey(alipayPublicKey); |
| | | alipayConfig.setCharset("UTF-8"); |
| | | alipayConfig.setSignType("RSA2"); |
| | | return alipayConfig; |
| | | } |
| | | // 属于平台的运营商 因为无需分账不冻结资金 |
| | | public ResultUtil confirm1(String smid,String code, String outTradeNo, String amount) { |
| | |
| | | private StudentHonorClient studentHonorClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<CoursePackagePaymentVO> listAll(CoursePackagePaymentQuery query) { |
| | | return cpConfigMapper.listAll(query); |
| | |
| | | String cityCode = studentQeryDto.getCityCode(); |
| | | //获取用户数据 |
| | | List<Integer> appUserIds = null; |
| | | if(ToolUtil.isNotEmpty(cityCode)){ |
| | | if (ToolUtil.isNotEmpty(cityCode)) { |
| | | List<AppUser> appUsers = appuClient.queryAppUserByCityCode(cityCode); |
| | | if(appUsers.size() > 0){ |
| | | if (appUsers.size() > 0) { |
| | | appUserIds = appUsers.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | QueryWrapper<CoursePackageStudent> status = new QueryWrapper<CoursePackageStudent>().eq("payStatus", 2).eq("status", 1); |
| | | if(null != appUserIds){ |
| | | if (null != appUserIds) { |
| | | status.in("appUserId", appUserIds); |
| | | } |
| | | List<Map<String, Object>> maps = this.baseMapper.getStudentTotal(appUserIds, studentQeryDto.getStart(), studentQeryDto.getEnd(),studentQeryDto.getCoursePackageIds()); |
| | | List<Map<String, Object>> maps = this.baseMapper.getStudentTotal(appUserIds, studentQeryDto.getStart(), studentQeryDto.getEnd(), studentQeryDto.getCoursePackageIds()); |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (Map<String, Object> objectMap : maps) { |
| | | if(null == objectMap.get("studentId")){ |
| | | if (null == objectMap.get("studentId")) { |
| | | continue; |
| | | } |
| | | Integer studentId = Integer.valueOf(objectMap.get("studentId").toString()); |
| | |
| | | Integer number = Integer.valueOf(objectMap.get("number").toString()); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Student student = studentClient.queryStudentById(studentId); |
| | | if(null == student){ |
| | | if (null == student) { |
| | | continue; |
| | | } |
| | | map.put("studentName", student.getName()); |
| | | AppUser appUser = appuClient.queryAppUser(appUserId); |
| | | if(null == appUser){ |
| | | if (null == appUser) { |
| | | continue; |
| | | } |
| | | map.put("province", appUser.getProvince()); |
| | |
| | | .eq("coursePackageId", coursePackageId).eq("payStatus", 2).eq("state", 1) |
| | | .gt("cashPayment", 0).last(" and studentIds like '%" + studentId + "%' order by insertTime desc limit 0, 1")); |
| | | Double cashPayment = 0D; |
| | | if(null != coursePackageOrder && coursePackageOrder.getClassHours() > 0){ |
| | | if (null != coursePackageOrder && coursePackageOrder.getClassHours() > 0) { |
| | | cashPayment = coursePackageOrder.getCashPayment().divide(new BigDecimal(coursePackageOrder.getClassHours()), new MathContext(2, RoundingMode.HALF_EVEN)).doubleValue(); |
| | | } |
| | | map.put("cashPayment", cashPayment * number); |
| | |
| | | for (CoursePackageOrder coursePackageOrder : list) { |
| | | p = p.add(coursePackageOrder.getCashPayment()); |
| | | } |
| | | if(list.size() > 0){ |
| | | if (list.size() > 0) { |
| | | cashPayment = p.divide(new BigDecimal(list.size()), new MathContext(2, RoundingMode.HALF_EVEN)).doubleValue(); |
| | | } |
| | | map.put("cashPayment", cashPayment * number); |
| | |
| | | private ALiSendSms aLiSendSms; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public CourseDetailsResponse queryRegisteredCourseDetails(Long coursePayId, Integer appUserId, String lon, String lat) { |
| | | AppUser appUser = appuClient.queryAppUser(appUserId); |
| | | CourseDetailsResponse response = new CourseDetailsResponse(); |
| | | CoursePackageOrder coursePackageOrder = coursePackageOrderService.getById(coursePayId); |
| | | if (coursePackageOrder==null){ |
| | | if (coursePackageOrder == null) { |
| | | // student = coursePackageStudentService.getById(coursePayId); |
| | | CoursePackageOrderStudent student = coursePackageOrderStudentService.getById(coursePayId); |
| | | |
| | |
| | | response.setIntroduceDrawing(coursePackage.getIntroduceDrawing()); |
| | | |
| | | Integer payType = coursePackageOrder.getPayType(); |
| | | if(null == payType){ |
| | | if (null == payType) { |
| | | CoursePackagePaymentConfig config = coursePackagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId", coursePackage.getId()).orderByAsc("classHours")).get(0); |
| | | if (ToolUtil.isNotEmpty(config.getCashPayment()) && config.getCashPayment() > 0 && ToolUtil.isNotEmpty(config.getPlayPaiCoin()) && config.getPlayPaiCoin() > 0) { |
| | | payType = 3; |
| | |
| | | response.setVipAmount(discountMember); |
| | | break; |
| | | case 2: |
| | | if (playPaiCoin!=null) { |
| | | if (playPaiCoin != null) { |
| | | response.setWpGold(playPaiCoin); |
| | | } |
| | | break; |
| | |
| | | |
| | | @Override |
| | | public ResultUtil ContinuationOrpaymentCourse(Integer userId, ClasspaymentRequest request) { |
| | | System.err.println("请求参数"+request); |
| | | System.err.println("请求参数" + request); |
| | | AppUser appUser = appuClient.queryAppUser(userId); |
| | | CoursePackageOrder coursePackageOrder = coursePackageOrderService.getById(request.getCoursePayId()); |
| | | System.err.println("上次支付记录"+coursePackageOrder); |
| | | System.err.println("上次支付记录" + coursePackageOrder); |
| | | String code = ""; |
| | | BigDecimal money = BigDecimal.valueOf(request.getCash()); |
| | | Integer wpGold = request.getPlayPaiCoin(); |
| | |
| | | CoursePackagePaymentConfig paymentConfig = cpConfigMapper.selectOne(new QueryWrapper<CoursePackagePaymentConfig>() |
| | | .eq("coursePackageId", request.getLessonId()) |
| | | .eq("classHours", request.getCourseHoursNum())); |
| | | System.err.println("价格配置"+paymentConfig); |
| | | System.err.println("价格配置" + paymentConfig); |
| | | TCoursePackageDiscount coursePackageDiscount = tcpdMapper.selectOne(new QueryWrapper<TCoursePackageDiscount>() |
| | | .eq("coursePackageId", request.getLessonId()) |
| | | .eq("type", 2) |
| | | .eq("auditStatus", 1) |
| | | .eq("coursePackagePaymentConfigId", paymentConfig.getCoursePackageId())); |
| | | System.err.println("折扣"+coursePackageDiscount); |
| | | System.err.println("折扣" + coursePackageDiscount); |
| | | if (ToolUtil.isNotEmpty(coursePackageDiscount)) { |
| | | String content = coursePackageDiscount.getContent(); |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | |
| | | newPayment.setPayType(request.getPayType()); |
| | | newPayment.setState(1); |
| | | newPayment.setInsertTime(new Date()); |
| | | if (request.getCash()!=null && request.getCash()!=0){ |
| | | if (request.getCash() != null && request.getCash() != 0) { |
| | | newPayment.setCashPayment(BigDecimal.valueOf(request.getCash())); |
| | | } |
| | | newPayment.setPlayPaiCoin(request.getPlayPaiCoin()); |
| | |
| | | case 1: |
| | | if (request.getUseConpon() == 1) { |
| | | Integer coupon1 = client.queryUserCouponById(request.getConponId()); |
| | | System.err.println("优惠券id"+coupon1); |
| | | System.err.println("优惠券id" + coupon1); |
| | | Coupon coupon = client.queryCouponById(coupon1); |
| | | System.err.println("优惠券信息"+coupon); |
| | | System.err.println("优惠券信息" + coupon); |
| | | // if (coupon.getType() == 1) { |
| | | // Map<String, Object> couponRules = client.getCouponRules(coupon.getId()); |
| | | // Double conditionalAmount = (Double) couponRules.get("conditionalAmount"); |
| | |
| | | // } |
| | | } |
| | | try { |
| | | return WeChatPayment(code, money,request.getLessonId()); |
| | | return WeChatPayment(code, money, request.getLessonId()); |
| | | } catch (Exception e) { |
| | | return ResultUtil.runErr(); |
| | | } |
| | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | public ResultUtil WeChatPayment(String code, BigDecimal request,Integer coursePackageId) throws Exception { |
| | | System.err.println("code-------------"+code); |
| | | System.err.println("request---------------"+request); |
| | | System.err.println("coursePackageId-------------"+coursePackageId); |
| | | public ResultUtil WeChatPayment(String code, BigDecimal request, Integer coursePackageId) throws Exception { |
| | | System.err.println("code-------------" + code); |
| | | System.err.println("request---------------" + request); |
| | | System.err.println("coursePackageId-------------" + coursePackageId); |
| | | TCoursePackage byId = coursePackageService.getById(coursePackageId); |
| | | System.err.println("课包"+coursePackageId); |
| | | System.err.println("课包" + coursePackageId); |
| | | Integer storeId = byId.getStoreId(); |
| | | Store store = storeClient.queryStoreById(storeId); |
| | | System.err.println("门店查询"+store); |
| | | if (store.getOperatorId()==null || store.getOperatorId()==0){ |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("课包续费", "", code, request.toString(), |
| | | "/base/coursePackage/wechatRegisteredCoursesCallback", "APP", ""); |
| | | System.err.println("门店查询" + store); |
| | | if (store.getOperatorId() == null || store.getOperatorId() == 0) { |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("课包续费", "", code, request.toString(), |
| | | "/base/coursePackage/wechatRegisteredCoursesCallback", "APP", ""); |
| | | return weixinpay; |
| | | }else{ |
| | | } else { |
| | | String s = storeClient.getmerchantNumberByOperatorId(store.getOperatorId()); |
| | | System.err.println("微信商户号"+s); |
| | | if(!StringUtils.hasLength(s)){ |
| | | System.err.println("微信商户号" + s); |
| | | if (!StringUtils.hasLength(s)) { |
| | | return ResultUtil.error("运营商未配置微信商户号,获取支付失败!"); |
| | | } |
| | | return payMoneyUtil.weixinpayV3(s,"课包续费",code, |
| | | "/base/coursePackage/wechatRegisteredCoursesCallback1",request.toString(),""); |
| | | return payMoneyUtil.weixinpayV3(s, "课包续费", code, |
| | | "/base/coursePackage/wechatRegisteredCoursesCallback1", request.toString(), ""); |
| | | } |
| | | } |
| | | |
| | | private String smid = "2088330203191220";//平台支付宝商户号 |
| | | |
| | | // public static void main(String[] args) { |
| | | // public static void main(String[] args) { |
| | | // BigDecimal bigDecimal = new BigDecimal("100"); |
| | | // |
| | | // |
| | |
| | | Integer coursePackageId = coursePackagePayment.getCoursePackageId(); |
| | | TCoursePackage byId = coursePackageService.getById(coursePackageId); |
| | | Store store = storeClient.queryStoreById(byId.getStoreId()); |
| | | String smid1=""; |
| | | if (store.getOperatorId() == null ){ |
| | | String smid1 = ""; |
| | | if (store.getOperatorId() == null) { |
| | | smid1 = smid; |
| | | }else if (store.getOperatorId() == 0){ |
| | | } else if (store.getOperatorId() == 0) { |
| | | smid1 = smid; |
| | | }else{ |
| | | } else { |
| | | smid1 = storeClient.getmerchantNumberAliByOperatorId(store.getOperatorId()); |
| | | } |
| | | if (!StringUtils.hasLength(smid1)){ |
| | | if (!StringUtils.hasLength(smid1)) { |
| | | return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid1,"课包购买", "课包购买", "", code, request.toString(), |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid1, "课包购买", "课包购买", "", code, request.toString(), |
| | | "/base/coursePackage/alipayRegisteredCoursesCallback"); |
| | | // if (alipay.getCode() == 200) { |
| | | // String finalCode = code; |
| | | // new Thread(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // try { |
| | | // Thread.sleep(1000); |
| | | // int num = 1; |
| | | // int wait = 0; |
| | | // while (num <= 10) { |
| | | // int min = 5000; |
| | | // wait += (min * num); |
| | | // Thread.sleep(wait); |
| | | // CoursePackageOrder coursePackageOrder1 = coursePackageOrderService.getOne(new QueryWrapper<CoursePackageOrder>() |
| | | // .eq("code", finalCode).eq("state", 1)); |
| | | // if (coursePackageOrder1.getPayStatus() == 2) { |
| | | // break; |
| | | // } |
| | | // AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(finalCode); |
| | | // if (null != alipayTradeQueryResponse) { |
| | | // /** |
| | | // * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | // * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | // * TRADE_SUCCESS(交易支付成功)、 |
| | | // * TRADE_FINISHED(交易结束,不可退款) |
| | | // */ |
| | | // String s = alipayTradeQueryResponse.getTradeStatus(); |
| | | // |
| | | // String tradeNo = alipayTradeQueryResponse.getTradeNo(); |
| | | // if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | // //有待支付的订单,这里不处理 |
| | | //// coursePackageOrder1.setState(3); |
| | | //// coursePackageOrderService.updateById(coursePackageOrder1); |
| | | // break; |
| | | // } |
| | | // if ("TRADE_SUCCESS".equals(s)) { |
| | | // coursePackagePayment.setPayStatus(2); |
| | | // coursePackagePayment.setOrderNumber(tradeNo); |
| | | // baseMapper1.updateById(coursePackagePayment); |
| | | // // 判断这个课包属于哪个门店 属于哪个运营商 根据运营商 id 获取对应的商户号 |
| | | // Integer coursePackageId = coursePackagePayment.getCoursePackageId(); |
| | | // TCoursePackage byId = coursePackageService.getById(coursePackageId); |
| | | // Store store = storeClient.queryStoreById(byId.getStoreId()); |
| | | // if (store.getOperatorId() == null ){ |
| | | // // 说明是平台的门店 无需冻结资金 不走分账 |
| | | // payMoneyUtil.confirm1(smid,code,tradeNo,request.toString()); |
| | | // }else if (store.getOperatorId() == 0){ |
| | | // // 说明是平台的门店 |
| | | // payMoneyUtil.confirm1(smid,code,tradeNo,request.toString()); |
| | | // // 发起分账 |
| | | // extracted(store, coursePackageOrder1, tradeNo); |
| | | // }else{ |
| | | // payMoneyUtil.confirm(storeClient.getSMIDByOperatorId(store.getOperatorId()),code,tradeNo,request.toString()); |
| | | // // 发起分账 |
| | | // extracted(store, coursePackageOrder1, tradeNo); |
| | | // } |
| | | // break; |
| | | // } |
| | | // if ("WAIT_BUYER_PAY".equals(s)) { |
| | | // num++; |
| | | // } |
| | | // } |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }).start(); |
| | | // } |
| | | if (alipay.getCode() == 200) { |
| | | String finalCode = code; |
| | | String finalSmid = smid1; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Thread.sleep(1000); |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10) { |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | CoursePackageOrder coursePackageOrder1 = coursePackageOrderService.getOne(new QueryWrapper<CoursePackageOrder>() |
| | | .eq("code", finalCode).eq("state", 1)); |
| | | if (coursePackageOrder1.getPayStatus() == 2) { |
| | | break; |
| | | } |
| | | AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(finalCode); |
| | | if (null != alipayTradeQueryResponse) { |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | String s = alipayTradeQueryResponse.getTradeStatus(); |
| | | |
| | | String tradeNo = alipayTradeQueryResponse.getTradeNo(); |
| | | if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | //有待支付的订单,这里不处理 |
| | | // coursePackageOrder1.setState(3); |
| | | // coursePackageOrderService.updateById(coursePackageOrder1); |
| | | break; |
| | | } |
| | | if ("TRADE_SUCCESS".equals(s)) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setOrderNumber(tradeNo); |
| | | baseMapper1.updateById(coursePackagePayment); |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(finalSmid, code, tradeNo, request.toString()); |
| | | break; |
| | | } |
| | | if ("WAIT_BUYER_PAY".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | return alipay; |
| | | } |
| | | |
| | |
| | | System.err.println("进入玩湃支付"); |
| | | CoursePackageOrder packagePayment = coursePackageOrderService.getOne(new QueryWrapper<CoursePackageOrder>() |
| | | .eq("code", code)); |
| | | System.err.println("支付"+packagePayment); |
| | | System.err.println("用户信息"+appUser); |
| | | System.err.println("code"+code); |
| | | System.err.println("wpGold"+wpGold); |
| | | System.err.println("支付" + packagePayment); |
| | | System.err.println("用户信息" + appUser); |
| | | System.err.println("code" + code); |
| | | System.err.println("wpGold" + wpGold); |
| | | if (appUser.getPlayPaiCoins() < wpGold) { |
| | | return ResultUtil.error("玩湃币不足!"); |
| | | } |
| | |
| | | System.err.println("修改"); |
| | | boolean b = coursePackageOrderService.updateById(packagePayment); |
| | | |
| | | }catch (Exception e){ |
| | | System.err.println("报错"+e.getCause()); |
| | | System.err.println("报错"+e.getMessage()); |
| | | } catch (Exception e) { |
| | | System.err.println("报错" + e.getCause()); |
| | | System.err.println("报错" + e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | appUser.setPlayPaiCoins(ToolUtil.isNotEmpty(appUser.getPlayPaiCoins()) ? appUser.getPlayPaiCoins() - wpGold : wpGold); |
| | |
| | | } else if (start.after(new Date())) { |
| | | //待上课 |
| | | recordVo.setStatus(1); |
| | | } |
| | | else { |
| | | } else { |
| | | CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | .eq("coursePackageSchedulingId", byId.getId()).last("limit 1")); |
| | | if (ToolUtil.isNotEmpty(cancelledClasses)) { |
| | |
| | | |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | |
| | | if (coursePackage.getType()==1){ |
| | | list = this.baseMapper.queryRegistrationRecord(page, coursePackageId, userIds, studentIds); |
| | | }else { |
| | | if (coursePackage.getType() == 1) { |
| | | list = this.baseMapper.queryRegistrationRecord(page, coursePackageId, userIds, studentIds); |
| | | } else { |
| | | list = this.baseMapper.queryRegistrationRecord1(page, coursePackageId, userIds, studentIds); |
| | | } |
| | | |
| | | list.addAll(this.baseMapper.queryRegistrationRecord3(coursePackageId,userIds,studentIds)); |
| | | list.addAll(this.baseMapper.queryRegistrationRecord3(coursePackageId, userIds, studentIds)); |
| | | for (Map<String, Object> map : list) { |
| | | |
| | | |
| | | Long id = Long.valueOf(map.get("id").toString()); |
| | | Integer appUserId = Integer.valueOf(map.get("appUserId").toString()); |
| | | Integer studentId = 0; |
| | | if (coursePackage.getType()==1) { |
| | | if (coursePackage.getType() == 1) { |
| | | studentId = Integer.valueOf(map.get("studentId").toString()); |
| | | }else { |
| | | } else { |
| | | studentId = Integer.valueOf(map.get("studentIds").toString().split(",")[0]); |
| | | } |
| | | |
| | |
| | | Integer integer = cpsMapper.selectCount(new QueryWrapper<CoursePackageStudent>().eq("appUserId", appUserId) |
| | | .eq("studentId", studentId).eq("coursePackagePaymentId", id).eq("signInOrNot", 2)); |
| | | |
| | | int count = coursePackageStudentService.count(new QueryWrapper<CoursePackageStudent>().eq("coursePackageId", coursePackageId).eq("studentId", studentId).eq("signInOrNot",2)); |
| | | int count = coursePackageStudentService.count(new QueryWrapper<CoursePackageStudent>().eq("coursePackageId", coursePackageId).eq("studentId", studentId).eq("signInOrNot", 2)); |
| | | |
| | | map.put("absencesNumber", count); |
| | | |
| | |
| | | //需要购买使用的课时数 |
| | | Integer num = req.getNum(); |
| | | //需要删除多余的排课记录 |
| | | if(num.compareTo(laveClassHours1) > 0){ |
| | | if (num.compareTo(laveClassHours1) > 0) { |
| | | //课时数差额 |
| | | int number1 = num - laveClassHours1; |
| | | double o = number1 % coursePackage.getNeedNum(); |
| | | int l = 0; |
| | | if(0 != o){ |
| | | if (0 != o) { |
| | | l = 1; |
| | | } |
| | | int n = Double.valueOf(number1 / coursePackage.getNeedNum()).intValue() + l; |
| | |
| | | coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() - req.getNum()); |
| | | coursePackageOrderStudentService.updateById(coursePackageOrderStudent); |
| | | Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours(); |
| | | if(3 >= laveClassHours){ |
| | | if (3 >= laveClassHours) { |
| | | AppUser appUser = appuClient.queryAppUser(coursePackageOrderStudent.getAppUserId()); |
| | | //发送短信提醒 |
| | | aLiSendSms.sendSms(appUser.getPhone(), "SMS_463646317", ""); |
| | |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid1,"报名运动营", "报名运动营", |
| | | coursePackagePaymentConfig.getId().toString(), |
| | | code, paymentPrice.toString(), "/base/course/aliPaymentCourseCallback"); |
| | | // if (alipay.getCode() == 200) { |
| | | // String finalCode = code; |
| | | // new Thread(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // try { |
| | | // Thread.sleep(1000); |
| | | // int num = 1; |
| | | // int wait = 0; |
| | | // while (num <= 10) { |
| | | // int min = 5000; |
| | | // wait += (min * num); |
| | | // Thread.sleep(wait); |
| | | // CoursePackageOrder coursePackageOrder1 = coursePackageOrderService.getOne(new QueryWrapper<CoursePackageOrder>() |
| | | // .eq("code", finalCode).eq("state", 1)); |
| | | // if (coursePackageOrder1.getPayStatus() == 2) { |
| | | // break; |
| | | // } |
| | | // AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(finalCode); |
| | | // if (null != alipayTradeQueryResponse) { |
| | | // /** |
| | | // * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | // * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | // * TRADE_SUCCESS(交易支付成功)、 |
| | | // * TRADE_FINISHED(交易结束,不可退款) |
| | | // */ |
| | | // String s = alipayTradeQueryResponse.getTradeStatus(); |
| | | // |
| | | // String tradeNo = alipayTradeQueryResponse.getTradeNo(); |
| | | // if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | // //有待支付的订单,这里不处理 |
| | | //// coursePackageOrder1.setState(3); |
| | | //// coursePackageOrderService.updateById(coursePackageOrder1); |
| | | // break; |
| | | // } |
| | | // if ("TRADE_SUCCESS".equals(s)) { |
| | | // coursePackageOrder1.setPayStatus(2); |
| | | // coursePackageOrder1.setOrderNumber(tradeNo); |
| | | // coursePackageOrder1.setAppUserId(null); |
| | | if (alipay.getCode() == 200) { |
| | | String finalCode = code; |
| | | String finalSmid = smid1; |
| | | String finalCode1 = code; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Thread.sleep(1000); |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10) { |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | CoursePackageOrder coursePackageOrder1 = coursePackageOrderService.getOne(new QueryWrapper<CoursePackageOrder>() |
| | | .eq("code", finalCode).eq("state", 1)); |
| | | if (coursePackageOrder1.getPayStatus() == 2) { |
| | | break; |
| | | } |
| | | AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(finalCode); |
| | | if (null != alipayTradeQueryResponse) { |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | String s = alipayTradeQueryResponse.getTradeStatus(); |
| | | |
| | | String tradeNo = alipayTradeQueryResponse.getTradeNo(); |
| | | if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | | //有待支付的订单,这里不处理 |
| | | // coursePackageOrder1.setState(3); |
| | | // coursePackageOrderService.updateById(coursePackageOrder1); |
| | | // addCoursePackageOrderStudent(coursePackageOrder1.getId(), coursePackagePaymentConfig); |
| | | // moneyOut(tradeNo,tradeNo,finalCode); |
| | | // // 根据课程id 查询这个课程属于哪个门店 属于哪个运营商 |
| | | // Integer id = paymentCourseVo.getId(); |
| | | // TCoursePackage byId = coursePackageService.getById(id); |
| | | // Integer storeId = byId.getStoreId(); |
| | | // Store store = storeClient.queryStoreById(storeId); |
| | | // Integer operatorId = store.getOperatorId(); |
| | | // if (operatorId==null){ |
| | | // String smid ="2088330203191220"; |
| | | // // 说明是平台的 不走分账 |
| | | //// payMoneyUtil.confirm(smid,finalCode,tradeNo,paymentPrice.toString()); |
| | | // payMoneyUtil.confirm1(smid,finalCode,tradeNo,paymentPrice.toString()); |
| | | // break; |
| | | // }else if (operatorId==0){ |
| | | // String smid ="2088330203191220"; |
| | | // // 说明是平台的 |
| | | // payMoneyUtil.confirm1(smid,finalCode,tradeNo,paymentPrice.toString()); |
| | | // break; |
| | | // }else{ |
| | | // // 当前课程不属于门店 查询这个课程属于哪个门店 属于哪个运营商 |
| | | // String smidByOperatorId = storeClient.getSMIDByOperatorId(operatorId); |
| | | // payMoneyUtil.confirm(smidByOperatorId,finalCode,tradeNo,paymentPrice.toString()); |
| | | // // 分账处理 |
| | | // extracted(store, coursePackageOrder1, tradeNo); |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ("WAIT_BUYER_PAY".equals(s)) { |
| | | // num++; |
| | | // } |
| | | // } |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }).start(); |
| | | // } |
| | | break; |
| | | } |
| | | if ("TRADE_SUCCESS".equals(s)) { |
| | | coursePackageOrder1.setPayStatus(2); |
| | | coursePackageOrder1.setOrderNumber(tradeNo); |
| | | coursePackageOrder1.setAppUserId(null); |
| | | coursePackageOrderService.updateById(coursePackageOrder1); |
| | | addCoursePackageOrderStudent(coursePackageOrder1.getId(), coursePackagePaymentConfig); |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(finalSmid, finalCode1, tradeNo, paymentPrice.toString()); |
| | | } |
| | | if ("WAIT_BUYER_PAY".equals(s)) { |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | return alipay; |
| | | } |
| | | |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.CertAlipayRequest; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.*; |
| | | import com.alipay.api.domain.*; |
| | | import com.alipay.api.request.*; |
| | | import com.alipay.api.response.*; |
| | |
| | | |
| | | private String certPath = "/usr/playpai/cert/weixin/apiclient_cert.p12";//微信证书 |
| | | |
| | | public ResultUtil confirm(String smid,String code, String outTradeNo, String amount) { |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", |
| | | aliAppid, |
| | | appPrivateKey, |
| | | "json", |
| | | "GBK", |
| | | alipay_public_key, |
| | | "RSA2"); |
| | | public ResultUtil confirm(String smid1,String code, String outTradeNo, String amount) throws AlipayApiException { |
| | | // 初始化SDK |
| | | AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig()); |
| | | |
| | | // 构造请求参数以调用接口 |
| | | AlipayTradeSettleConfirmRequest request = new AlipayTradeSettleConfirmRequest(); |
| | | request.setBizContent("{" + |
| | | " \"out_request_no\":\""+code+"\"," + |
| | | " \"trade_no\":\""+outTradeNo+"\"," + |
| | | " \"settle_info\":{" + |
| | | " \"settle_detail_infos\":[" + |
| | | " {" + |
| | | " \"trans_in_type\":\"defaultSettle\"," + |
| | | " \"settle_entity_id\":\""+smid+"\"," + |
| | | " \"settle_entity_type\":\"SecondMerchant\"," + |
| | | " \"amount\":"+amount+"," + |
| | | " }" + |
| | | " ]" + |
| | | " }," + |
| | | " \"extend_params\":{" + |
| | | " \"royalty_freeze\":\"true\"" + |
| | | " }" + |
| | | "}"); |
| | | AlipayTradeSettleConfirmResponse response = null; |
| | | try { |
| | | response = alipayClient.execute(request); |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(response.isSuccess()){ |
| | | AlipayTradeSettleConfirmModel model = new AlipayTradeSettleConfirmModel(); |
| | | |
| | | // 设置确认结算请求流水号 |
| | | model.setOutRequestNo(code); |
| | | |
| | | // 设置支付宝交易号 |
| | | model.setTradeNo(outTradeNo); |
| | | |
| | | // 设置描述结算信息 |
| | | SettleInfo settleInfo = new SettleInfo(); |
| | | List<SettleDetailInfo> settleDetailInfos = new ArrayList<SettleDetailInfo>(); |
| | | SettleDetailInfo settleDetailInfos0 = new SettleDetailInfo(); |
| | | settleDetailInfos0.setAmount(amount); |
| | | settleDetailInfos0.setTransIn(smid1); |
| | | settleDetailInfos0.setSettleEntityType("SecondMerchant"); |
| | | settleDetailInfos0.setSettleEntityId(smid1); |
| | | settleDetailInfos0.setTransInType("defaultSettle"); |
| | | settleDetailInfos.add(settleDetailInfos0); |
| | | settleInfo.setSettleDetailInfos(settleDetailInfos); |
| | | model.setSettleInfo(settleInfo); |
| | | request.setBizModel(model); |
| | | System.err.println("结算金额"+amount); |
| | | // 第三方代调用模式下请设置app_auth_token |
| | | // request.putOtherTextParam("app_auth_token", "<-- 请填写应用授权令牌 -->"); |
| | | |
| | | AlipayTradeSettleConfirmResponse response = alipayClient.execute(request); |
| | | System.out.println("返回体"+response.getBody()); |
| | | |
| | | |
| | | if (response.isSuccess()) { |
| | | System.out.println("调用成功"); |
| | | return ResultUtil.success(); |
| | | } else { |
| | | System.out.println("调用失败"); |
| | | return ResultUtil.error("出现问题啦"); |
| | | // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接 |
| | | // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response); |
| | | // System.out.println(diagnosisUrl); |
| | | } |
| | | return ResultUtil.success(response.getBody()); |
| | | } |
| | | private static AlipayConfig getAlipayConfig() { |
| | | String privateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0QsaPtxeqJUGAOcGdVLllQ7easEznP8DFBvDdHATcmp2SHNQDUEWN6MCVPbMgY06NQVqAXxqjTAYSVh+6TRu6bofPmpYC3TZB003AgMBAAECggEBAJAcR2+PA3NBYUYHeFrqBRMS8uX8ZR19kjZ7IgoSLTFaQsP9opRylPSPXhrPVBKAE5leRQAHn4MCSlESwHvMfxo7KFjFTFAc6dffZZpipYQUOc9bGampwJh58/3e/pyBgVMG6J23CPf/HJQtNFSkjd/V9+ayb/9l2dUEL3bC0fAZ/dbx8HsxdLw8wn3fLlWLj68hOMqa2deCZe3JdSVsPbeWqkh56FFsMLug0Nd+Ar4TgRl9/jnhXF0JWiD0LmPUYLhboY7EfUBzN4w1iYbDi1P+3zvoOYsiVKAXox9GMhQ2VzOO2UcSTuizSza2e98mGpabl/GpKmCz+RDFjtkX6eECgYEA2MyCij65eO3aGIm3FUe93DULRBYTfX8qJQSJq2WOWA3mmQlEW6L3O2B5/lG2h+8WmN6iLEs9eHpgycGYp7vAqgrANEn16ACVcuyx0scFtrZfZ+kmHMzFfiUWxJjVYk/6YngsGVBLdw6ueM42C8TTP67X9tU5TdVGoGWuqEj4W98CgYEAwFqwprXOch5Pqk/RPbb49r0Ou03K/UbciWnWWKzUhFFNS8MdlQPoDvQZbMwHLeWsa2VhaKITK3x5biLQb3U+0GLOn6lTvEyrEUH+ucREyLgVYTRAvwBPtnvlrzpyxPk2HnslQjju8WrvvLLBMKWUjlTrTOzhaHT21gz3pHMiOakCgYEAhLmfaXdBITGshb054sNLDtdCkGpbgEcrzAHdLps769iGxkYQHXHFngpQZUwtTUcoNGqIKknd1jZFrv7gsD+XkgKG7PwimehRlkwmCX5ilxtLiVgJRzRt6+5U5AMVD90a0tHzXYP0z2yjj73fBJF5KtGl0a10KZxaYrQdm1UhB00CgYBZZgzx/k9rtHC8LAqIj1CYhHejT92G53c6Gkl3vyOqN4sgKhfGmSEySfrDGPRBPZxr8ZtbIPCd5mUdberH0osWGMYFaJI1UsCy7aQwvGpniz7MhZeN7dweaOjwDs8mgtjHQ96mL4XGCDhR0BZ/wIURvZ/6iaGdhbbu9unlsWj3uQKBgQCmZYdsbbZkd3ev6f8rwyvMz+DrCQyYpY44cegBYuJgrZiQnL2fJioeN7ixX0UM48SfwsZEIrzshP/LGAwnc2MdjxKUl4jLN8SEe0NAjXOnz9Zaw740+aOmLpXcLWdP4uM2gIhWsvW1tEkQZCXmm7c9s/RsU8Pmzv+YL3+fSijOzA=="; |
| | | String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmu8n/4yTHWbn7VOrNc9OsLtDL1bEQ8gC1dHkj8Wy5z0mkaOsjJRIG/28ze12M0V8jdCKuuDr5Z1OPKiqf+XO3ypguEh+mYUVMBM/cZodDFQfTY1TKLWjvQCuaqlA+QUTCK6f7T7stsgyQ1o9Jj0rXZDz6PM4QHSTzjrLIBaeqM5WIBvH+fy/X+QG5Utd+/UT0kc0JyvuKhZ65yVUd/C9VcwJJAPliRsAQNrqYterwAJ9zvw9tF11wj9W0XgJ8Ccu4x3gR1vrlLRJJo/OA97RmxPQ+5hSacWQZCUd1dwiBq+YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB"; |
| | | AlipayConfig alipayConfig = new AlipayConfig(); |
| | | alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | alipayConfig.setAppId("2021004105665036"); |
| | | alipayConfig.setPrivateKey(privateKey); |
| | | alipayConfig.setFormat("json"); |
| | | alipayConfig.setAlipayPublicKey(alipayPublicKey); |
| | | alipayConfig.setCharset("UTF-8"); |
| | | alipayConfig.setSignType("RSA2"); |
| | | return alipayConfig; |
| | | } |
| | | // 属于平台的运营商 因为无需分账不冻结资金 |
| | | public ResultUtil confirm1(String smid,String code, String outTradeNo, String amount) { |
| | |
| | | * 支付宝支付 |
| | | */ |
| | | public ResultUtil alipay(String smid,String body, String subject, String passbackParams, String outTradeNo, String amount, String notifyUrl) { |
| | | // //构造client |
| | | // CertAlipayRequest certAlipayRequest = new CertAlipayRequest (); |
| | | // //设置网关地址 |
| | | // certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | // //设置应用Id |
| | | // certAlipayRequest.setAppId(aliAppid); |
| | | // //设置应用私钥 |
| | | // certAlipayRequest.setPrivateKey(appPrivateKey); |
| | | // //设置请求格式,固定值json |
| | | // certAlipayRequest.setFormat("json"); |
| | | // //设置字符集 |
| | | // certAlipayRequest.setCharset("UTF-8"); |
| | | // //设置签名类型 |
| | | // certAlipayRequest.setSignType("RSA2"); |
| | | // //设置应用公钥证书路径 |
| | | // certAlipayRequest.setCertPath(app_cert_path); |
| | | // //设置支付宝公钥证书路径 |
| | | // certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path); |
| | | // //设置支付宝根证书路径 |
| | | // certAlipayRequest.setRootCertPath(alipay_root_cert_path); |
| | | // //构造client |
| | | // AlipayClient alipayClient = null; |
| | | // try { |
| | | // alipayClient = new DefaultAlipayClient(certAlipayRequest); |
| | | // } catch (AlipayApiException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay |
| | | // AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest (); |
| | | // //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 |
| | | // AlipayTradeAppPayModel model = new AlipayTradeAppPayModel (); |
| | | // model.setBody(body); |
| | | // model.setSubject (subject); |
| | | // model.setOutTradeNo (outTradeNo); |
| | | // model.setTimeoutExpress ("30m" ); |
| | | // model.setTotalAmount (amount); |
| | | // model.setProductCode ( "QUICK_MSECURITY_PAY" ); |
| | | // model.setPassbackParams(passbackParams);//自定义参数 |
| | | // request.setBizModel ( model ); |
| | | // request.setNotifyUrl (callbackPath + notifyUrl); |
| | | // try { |
| | | // //这里和普通的接口调用不同,使用的是sdkExecute |
| | | // AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderString", response.getBody()); |
| | | // System.out.println(map);//就是orderString 可以直接给客户端请求,无需再做处理。 |
| | | // return ResultUtil.success(map); |
| | | // } catch (AlipayApiException e ) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | //实例化客户端 |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipay_public_key, "RSA2"); |
| | | //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay |
| | |
| | | SubMerchant subMerchant = new SubMerchant(); |
| | | subMerchant.setMerchantId(smid); |
| | | model.setSubMerchant(subMerchant); |
| | | if (!smid.equals("2088330203191220")){ |
| | | ExtendParams extendParams = new ExtendParams(); |
| | | extendParams.setRoyaltyFreeze("true"); |
| | | model.setExtendParams(extendParams); |
| | | } |
| | | request.setBizModel(model); |
| | | request.setNotifyUrl(callbackPath + notifyUrl); |
| | | try { |
| | |
| | | /** |
| | | * 获取ztree的节点列表 |
| | | */ |
| | | List<ZTreeNode> tree(@Param("type") Integer type, @Param("id") Integer id); |
| | | List<ZTreeNode> tree(@Param("type") Integer type, @Param("id") Integer id,@Param("storeIds") List<Integer> storeIds); |
| | | |
| | | List<Map<String, Object>> list(@Param("condition") String condition, @Param("objectType") Integer objectType, @Param("objectId") Integer objectId); |
| | | List<Map<String, Object>> list(@Param("condition") String condition, |
| | | @Param("objectType") Integer objectType, |
| | | @Param("objectId") Integer objectId, |
| | | @Param("storeIds") List<Integer> storeIds); |
| | | |
| | | /** |
| | | * 获取所有部门列表 |
| | |
| | | * @return |
| | | * @date 2017年2月18日 上午10:32:04 |
| | | */ |
| | | List<ZTreeNode> roleTreeList(@Param("type") Integer type, @Param("id") Integer id); |
| | | List<ZTreeNode> roleTreeList(@Param("type") Integer type, @Param("id") Integer id, @Param("storeIds") List<Integer> storeIds); |
| | | |
| | | /** |
| | | * 获取角色列表树 |
| | |
| | | game.setOperationId(0); |
| | | } |
| | | System.out.println("============"+game); |
| | | |
| | | TStore tStore = storeService.getById(store); |
| | | game.setOperationId(tStore.getOperatorId()); |
| | | // 判断是新增还是修改 修改不会重新生成sutuId |
| | | if (game.getId()==null) { |
| | | HashMap<String, String> map5 = new HashMap<>(); |
| | |
| | | @ResponseBody |
| | | public Object list(String condition) { |
| | | List<Map<String, Object>> list = this.deptService.list(condition); |
| | | if (UserExt.getUser().getObjectType()==2){ |
| | | List<Map<String, Object>> filteredRoles = list.stream() |
| | | .collect(Collectors.toList()); |
| | | return filteredRoles; |
| | | } |
| | | |
| | | return super.warpObject(new DeptWarpper(list)); |
| | | } |
| | | |
| | |
| | | model.addAttribute("pName", ConstantFactory.me().getSingleRoleName(role.getPid())); |
| | | model.addAttribute("deptName", ConstantFactory.me().getDeptName(role.getDeptid())); |
| | | LogObjectHolder.me().set(role); |
| | | model.addAttribute("language",UserExt.getLanguage()); |
| | | model.addAttribute("language",1); |
| | | return PREFIX + "/role_edit.html"; |
| | | } |
| | | |
| | |
| | | package com.dsh.guns.modular.system.service.impl; |
| | | |
| | | import java.sql.Array; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | |
| | | import com.dsh.course.mapper.DeptMapper; |
| | | import com.dsh.course.model.node.ZTreeNode; |
| | | import com.dsh.guns.config.UserExt; |
| | | import com.dsh.guns.modular.system.model.TStore; |
| | | import com.dsh.guns.modular.system.service.IStoreService; |
| | | import io.swagger.models.auth.In; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private DeptMapper deptMapper; |
| | | @Resource |
| | | private IStoreService storeService; |
| | | |
| | | @Override |
| | | public void deleteDept(Integer deptId) { |
| | |
| | | |
| | | @Override |
| | | public List<ZTreeNode> tree() { |
| | | |
| | | return this.baseMapper.tree(UserExt.getUser().getObjectType(),UserExt.getUser().getObjectId()); |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | List<Integer> storeIds = new ArrayList<>(); |
| | | if (objectType==2){ |
| | | // 查询运营商下的门店ids |
| | | List<Integer> collect = storeService.lambdaQuery().eq(TStore::getOperatorId, objectId).list() |
| | | .stream().map(TStore::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | storeIds.add(-1); |
| | | } |
| | | storeIds.addAll(collect); |
| | | } |
| | | return this.baseMapper.tree(UserExt.getUser().getObjectType(),UserExt.getUser().getObjectId(),storeIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> list(String condition) { |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | return this.baseMapper.list(condition,objectType,objectId); |
| | | List<Integer> storeIds = new ArrayList<>(); |
| | | if (objectType==2){ |
| | | // 查询运营商下的门店ids |
| | | List<Integer> collect = storeService.lambdaQuery().eq(TStore::getOperatorId, objectId).list() |
| | | .stream().map(TStore::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | storeIds.add(-1); |
| | | } |
| | | storeIds.addAll(collect); |
| | | } |
| | | return this.baseMapper.list(condition,objectType,objectId,storeIds); |
| | | } |
| | | } |
| | |
| | | package com.dsh.guns.modular.system.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | |
| | | import com.dsh.course.model.node.ZTreeNode; |
| | | import com.dsh.guns.config.UserExt; |
| | | import com.dsh.guns.modular.system.controller.util.Convert; |
| | | import com.dsh.guns.modular.system.model.TStore; |
| | | import com.dsh.guns.modular.system.service.IStoreService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | public int deleteRolesById(Integer roleId) { |
| | | return this.baseMapper.deleteRolesById(roleId); |
| | | } |
| | | |
| | | @Resource |
| | | private IStoreService storeService; |
| | | @Override |
| | | public List<ZTreeNode> roleTreeList(Integer type,Integer id) { |
| | | return this.baseMapper.roleTreeList(type,id); |
| | | List<Integer> storeIds = new ArrayList<>(); |
| | | if (type==2){ |
| | | // 查询运营商下的门店ids |
| | | List<Integer> collect = storeService.lambdaQuery().eq(TStore::getOperatorId, id).list() |
| | | .stream().map(TStore::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | storeIds.add(-1); |
| | | } |
| | | storeIds.addAll(collect); |
| | | } |
| | | return this.baseMapper.roleTreeList(type,id,storeIds); |
| | | } |
| | | |
| | | @Override |
| | |
| | | 'false' |
| | | END |
| | | ) as isOpen from sys_dept where 1=1 |
| | | and objectType =#{type} and objectId =#{id} |
| | | <if test="type == 3"> |
| | | and objectType = 3 and objectId =#{id} |
| | | </if> |
| | | <if test="type == 2"> |
| | | and (objectType = 2 and objectId =#{id} |
| | | or |
| | | <if test="storeIds != null and storeIds.size()>0"> |
| | | objectId IN |
| | | <foreach collection="storeIds" separator="," item="id" open="(" close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | </select> |
| | | <select id="list" resultType="java.util.Map"> |
| | | select * from sys_dept where 1=1 |
| | |
| | | <if test="objectType == 3"> |
| | | and objectType = 3 and objectId =#{objectId} |
| | | </if> |
| | | <if test="objectType == 1"> |
| | | and objectType = 1 |
| | | <if test="objectType == 2"> |
| | | and (objectType = 2 and objectId =#{objectId} |
| | | or |
| | | <if test="storeIds != null and storeIds.size()>0"> |
| | | objectId IN |
| | | <foreach collection="storeIds" separator="," item="id" open="(" close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | |
| | | |
| | | order by num ASC |
| | | </select> |
| | | |
| | |
| | | <if test="type==3"> |
| | | and objType =3 and objId =#{id} |
| | | </if> |
| | | <if test="type == 2"> |
| | | and (objType = 2 and objId =#{id} |
| | | or |
| | | <if test="storeIds != null and storeIds.size()>0"> |
| | | objId IN |
| | | <foreach collection="storeIds" separator="," item="id" open="(" close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="roleTreeListByRoleId" resultType="com.dsh.course.model.node.ZTreeNode"> |
| | |
| | | <if test="type==3"> |
| | | and objType =3 and objId =#{id} |
| | | </if> |
| | | <if test="type == 2"> |
| | | and (objType = 2 and objId =#{id} |
| | | or |
| | | <if test="storeIds != null and storeIds.size()>0"> |
| | | objId IN |
| | | <foreach collection="storeIds" separator="," item="id" open="(" close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | </if> |
| | | ) r1 ON r.ID = r1.ID |
| | | ORDER BY |
| | | pId, |
| | |
| | | |
| | | @if(objectType==1){ |
| | | <div class="form-group" style=" margin-left: 17%;" > |
| | | <label class="col-sm-1 control-label">场地说明222:</label> |
| | | <label class="col-sm-1 control-label">场地说明:</label> |
| | | <div class="col-sm-5"> |
| | | <textarea type="text/plain" id="editor" style="height: 300px;width: 800px;"></textarea> |
| | | </div> |
| | |
| | | |
| | | var objectType =$("#objectType").val() |
| | | data.halfName= halfName; |
| | | var introduce=""; |
| | | if (objectType==1){ |
| | | introduce = TSiteInfo.editor.getContent(); |
| | | } |
| | | |
| | | console.log(introduce) |
| | | if(introduce==""){ |
| | | Feng.info("请输入公告内容") |
| | | return; |
| | | console.log(introduce) |
| | | if(introduce==""){ |
| | | Feng.info("请输入场地说明") |
| | | return; |
| | | } |
| | | } |
| | | data.introduce= introduce; |
| | | |
| | | |
| | | var goodImgs = TSiteInfo.goodsPicArray; |
| | | |
| | | if(goodImgs.length==0){ |
| | |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid1,"游戏支付", "游戏支付", params, code, config.getCash().toString(), |
| | | "/base/game/aliPaymentGameCallback"); |
| | | if (alipay.getCode() == 200) { |
| | | String finalSmid = smid1; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | |
| | | } |
| | | gameRecordService.updateBatchById(list); |
| | | Integer integer = startGame(uid, gameType, gameId, spaceId, sutuId); |
| | | |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(finalSmid, code, one.getOrderNo(), config.getCash().toString()); |
| | | break; |
| | | } |
| | | if ("WAIT_BUYER_PAY".equals(s)) { |
| | |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid1,"预约场地", "预约场地", id.toString(), code, paymentPrice.toString(), "/base/site/aliPaymentSiteCallback"); |
| | | System.out.println("预约场地----" + alipay.getCode()); |
| | | if (alipay.getCode() == 200) { |
| | | String finalSmid = smid1; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | |
| | | siteBooking.setPayOrderNo(tradeNo); |
| | | siteBookingService.updateById(siteBooking); |
| | | System.err.println("======完成支付"); |
| | | Thread.sleep(30000); |
| | | payMoneyUtil.confirm(finalSmid, code, tradeNo, paymentPrice.toString()); |
| | | break; |
| | | } |
| | | if ("WAIT_BUYER_PAY".equals(s)) { |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.CertAlipayRequest; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.*; |
| | | import com.alipay.api.domain.*; |
| | | import com.alipay.api.msg.AlipayMsgClient; |
| | | import com.alipay.api.msg.MsgHandler; |
| | |
| | | private String certPath = "/usr/playpai/cert/weixin/apiclient_cert.p12";//微信证书 |
| | | |
| | | |
| | | public ResultUtil confirm(String smid, String code, String outTradeNo, String amount) { |
| | | public ResultUtil confirm(String smid1,String code, String outTradeNo, String amount) throws AlipayApiException { |
| | | // 初始化SDK |
| | | AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig()); |
| | | |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", |
| | | aliAppid, |
| | | appPrivateKey, |
| | | "json", |
| | | "GBK", |
| | | alipay_public_key, |
| | | "RSA2"); |
| | | // 构造请求参数以调用接口 |
| | | AlipayTradeSettleConfirmRequest request = new AlipayTradeSettleConfirmRequest(); |
| | | request.setBizContent("{" + |
| | | " \"out_request_no\":\"" + code + "\"," + |
| | | " \"trade_no\":\"" + outTradeNo + "\"," + |
| | | " \"settle_info\":{" + |
| | | " \"settle_detail_infos\":[" + |
| | | " {" + |
| | | " \"trans_in_type\":\"defaultSettle\"," + |
| | | " \"settle_entity_id\":\"" + smid + "\"," + |
| | | " \"settle_entity_type\":\"SecondMerchant\"," + |
| | | " \"amount\":" + amount + "," + |
| | | " }" + |
| | | " ]" + |
| | | " }," + |
| | | " \"extend_params\":{" + |
| | | " \"royalty_freeze\":\"true\"" + |
| | | " }" + |
| | | "}"); |
| | | AlipayTradeSettleConfirmResponse response = null; |
| | | try { |
| | | response = alipayClient.execute(request); |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | AlipayTradeSettleConfirmModel model = new AlipayTradeSettleConfirmModel(); |
| | | |
| | | // 设置确认结算请求流水号 |
| | | model.setOutRequestNo(code); |
| | | |
| | | // 设置支付宝交易号 |
| | | model.setTradeNo(outTradeNo); |
| | | |
| | | // 设置描述结算信息 |
| | | SettleInfo settleInfo = new SettleInfo(); |
| | | List<SettleDetailInfo> settleDetailInfos = new ArrayList<SettleDetailInfo>(); |
| | | SettleDetailInfo settleDetailInfos0 = new SettleDetailInfo(); |
| | | settleDetailInfos0.setAmount(amount); |
| | | settleDetailInfos0.setTransIn(smid1); |
| | | settleDetailInfos0.setSettleEntityType("SecondMerchant"); |
| | | settleDetailInfos0.setSettleEntityId(smid1); |
| | | settleDetailInfos0.setTransInType("defaultSettle"); |
| | | settleDetailInfos.add(settleDetailInfos0); |
| | | settleInfo.setSettleDetailInfos(settleDetailInfos); |
| | | model.setSettleInfo(settleInfo); |
| | | request.setBizModel(model); |
| | | System.err.println("结算金额"+amount); |
| | | // 第三方代调用模式下请设置app_auth_token |
| | | // request.putOtherTextParam("app_auth_token", "<-- 请填写应用授权令牌 -->"); |
| | | |
| | | AlipayTradeSettleConfirmResponse response = alipayClient.execute(request); |
| | | System.out.println("返回体"+response.getBody()); |
| | | |
| | | |
| | | if (response.isSuccess()) { |
| | | System.out.println("调用成功"); |
| | | return ResultUtil.success(); |
| | | } else { |
| | | System.out.println("调用失败"); |
| | | return ResultUtil.error("出现问题啦"); |
| | | // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接 |
| | | // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response); |
| | | // System.out.println(diagnosisUrl); |
| | | } |
| | | return ResultUtil.success(response.getBody()); |
| | | } |
| | | private static AlipayConfig getAlipayConfig() { |
| | | String privateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0QsaPtxeqJUGAOcGdVLllQ7easEznP8DFBvDdHATcmp2SHNQDUEWN6MCVPbMgY06NQVqAXxqjTAYSVh+6TRu6bofPmpYC3TZB003AgMBAAECggEBAJAcR2+PA3NBYUYHeFrqBRMS8uX8ZR19kjZ7IgoSLTFaQsP9opRylPSPXhrPVBKAE5leRQAHn4MCSlESwHvMfxo7KFjFTFAc6dffZZpipYQUOc9bGampwJh58/3e/pyBgVMG6J23CPf/HJQtNFSkjd/V9+ayb/9l2dUEL3bC0fAZ/dbx8HsxdLw8wn3fLlWLj68hOMqa2deCZe3JdSVsPbeWqkh56FFsMLug0Nd+Ar4TgRl9/jnhXF0JWiD0LmPUYLhboY7EfUBzN4w1iYbDi1P+3zvoOYsiVKAXox9GMhQ2VzOO2UcSTuizSza2e98mGpabl/GpKmCz+RDFjtkX6eECgYEA2MyCij65eO3aGIm3FUe93DULRBYTfX8qJQSJq2WOWA3mmQlEW6L3O2B5/lG2h+8WmN6iLEs9eHpgycGYp7vAqgrANEn16ACVcuyx0scFtrZfZ+kmHMzFfiUWxJjVYk/6YngsGVBLdw6ueM42C8TTP67X9tU5TdVGoGWuqEj4W98CgYEAwFqwprXOch5Pqk/RPbb49r0Ou03K/UbciWnWWKzUhFFNS8MdlQPoDvQZbMwHLeWsa2VhaKITK3x5biLQb3U+0GLOn6lTvEyrEUH+ucREyLgVYTRAvwBPtnvlrzpyxPk2HnslQjju8WrvvLLBMKWUjlTrTOzhaHT21gz3pHMiOakCgYEAhLmfaXdBITGshb054sNLDtdCkGpbgEcrzAHdLps769iGxkYQHXHFngpQZUwtTUcoNGqIKknd1jZFrv7gsD+XkgKG7PwimehRlkwmCX5ilxtLiVgJRzRt6+5U5AMVD90a0tHzXYP0z2yjj73fBJF5KtGl0a10KZxaYrQdm1UhB00CgYBZZgzx/k9rtHC8LAqIj1CYhHejT92G53c6Gkl3vyOqN4sgKhfGmSEySfrDGPRBPZxr8ZtbIPCd5mUdberH0osWGMYFaJI1UsCy7aQwvGpniz7MhZeN7dweaOjwDs8mgtjHQ96mL4XGCDhR0BZ/wIURvZ/6iaGdhbbu9unlsWj3uQKBgQCmZYdsbbZkd3ev6f8rwyvMz+DrCQyYpY44cegBYuJgrZiQnL2fJioeN7ixX0UM48SfwsZEIrzshP/LGAwnc2MdjxKUl4jLN8SEe0NAjXOnz9Zaw740+aOmLpXcLWdP4uM2gIhWsvW1tEkQZCXmm7c9s/RsU8Pmzv+YL3+fSijOzA=="; |
| | | String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmu8n/4yTHWbn7VOrNc9OsLtDL1bEQ8gC1dHkj8Wy5z0mkaOsjJRIG/28ze12M0V8jdCKuuDr5Z1OPKiqf+XO3ypguEh+mYUVMBM/cZodDFQfTY1TKLWjvQCuaqlA+QUTCK6f7T7stsgyQ1o9Jj0rXZDz6PM4QHSTzjrLIBaeqM5WIBvH+fy/X+QG5Utd+/UT0kc0JyvuKhZ65yVUd/C9VcwJJAPliRsAQNrqYterwAJ9zvw9tF11wj9W0XgJ8Ccu4x3gR1vrlLRJJo/OA97RmxPQ+5hSacWQZCUd1dwiBq+YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB"; |
| | | AlipayConfig alipayConfig = new AlipayConfig(); |
| | | alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | alipayConfig.setAppId("2021004105665036"); |
| | | alipayConfig.setPrivateKey(privateKey); |
| | | alipayConfig.setFormat("json"); |
| | | alipayConfig.setAlipayPublicKey(alipayPublicKey); |
| | | alipayConfig.setCharset("UTF-8"); |
| | | alipayConfig.setSignType("RSA2"); |
| | | return alipayConfig; |
| | | } |
| | | |
| | | // 属于平台的运营商 因为无需分账不冻结资金 |
| | |
| | | * 支付宝支付 |
| | | */ |
| | | public ResultUtil alipay(String smid, String body, String subject, String passbackParams, String outTradeNo, String amount, String notifyUrl) { |
| | | //// //构造client |
| | | // CertAlipayRequest certAlipayRequest = new CertAlipayRequest (); |
| | | // //设置网关地址 |
| | | // certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | // //设置应用Id |
| | | // certAlipayRequest.setAppId(aliAppid); |
| | | // //设置应用私钥 |
| | | // certAlipayRequest.setPrivateKey(appPrivateKey); |
| | | // //设置请求格式,固定值json |
| | | // certAlipayRequest.setFormat("json"); |
| | | // //设置字符集 |
| | | // certAlipayRequest.setCharset("UTF-8"); |
| | | // //设置签名类型 |
| | | // certAlipayRequest.setSignType("RSA2"); |
| | | // //设置应用公钥证书路径 |
| | | // certAlipayRequest.setCertPath(app_cert_path); |
| | | // //设置支付宝公钥证书路径 |
| | | // certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path); |
| | | // //设置支付宝根证书路径 |
| | | // certAlipayRequest.setRootCertPath(alipay_root_cert_path); |
| | | // //构造client |
| | | // AlipayClient alipayClient = null; |
| | | // try { |
| | | // alipayClient = new DefaultAlipayClient(certAlipayRequest); |
| | | // } catch (AlipayApiException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay |
| | | // AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest (); |
| | | // //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 |
| | | // AlipayTradeAppPayModel model = new AlipayTradeAppPayModel (); |
| | | // model.setBody(body); |
| | | // model.setSubject (subject); |
| | | // model.setOutTradeNo (outTradeNo); |
| | | // model.setTimeoutExpress ("30m" ); |
| | | // model.setTotalAmount (amount); |
| | | // model.setProductCode ( "QUICK_MSECURITY_PAY" ); |
| | | // model.setPassbackParams(passbackParams);//自定义参数 |
| | | // request.setBizModel ( model ); |
| | | // request.setNotifyUrl (callbackPath + notifyUrl); |
| | | // try { |
| | | // //这里和普通的接口调用不同,使用的是sdkExecute |
| | | // AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderString", response.getBody()); |
| | | // System.out.println(map);//就是orderString 可以直接给客户端请求,无需再做处理。 |
| | | // return ResultUtil.success(map); |
| | | // } catch (AlipayApiException e ) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | |
| | | //实例化客户端 |
| | |
| | | SubMerchant subMerchant = new SubMerchant(); |
| | | subMerchant.setMerchantId(smid); |
| | | model.setSubMerchant(subMerchant); |
| | | if (!smid.equals("2088330203191220")){ |
| | | ExtendParams extendParams = new ExtendParams(); |
| | | extendParams.setRoyaltyFreeze("true"); |
| | | model.setExtendParams(extendParams); |
| | | } |
| | | request.setBizModel(model); |
| | | request.setNotifyUrl(callbackPath + notifyUrl); |
| | | |