| | |
| | | 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(); |
| | | } |
| | | |