| | |
| | | private GameRecordClient gameRecordClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // 对数据进行分页处理的方法 |
| | | private static Page<Goods> getPage(List<Goods> dataList, Pageable pageable) { |
| | | int start = (int) pageable.getOffset(); |
| | |
| | | |
| | | /** |
| | | * 优惠券微信支付 |
| | | * |
| | | * @param body |
| | | * @param userCouponPayment |
| | | * @return |
| | |
| | | System.err.println("购买优惠券"); |
| | | if (coupon!=null){ |
| | | if (!couponStoreIds.isEmpty()&&!couponStoreIds.contains(-1)){ |
| | | Store store = storeClient.queryStoreById(couponStoreIds.get(0)); |
| | | // 微信商户号 |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(couponStoreIds.get(0)); |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(store.getOperatorId()); |
| | | System.err.println("微信商户号"+s2); |
| | | |
| | | if(!StringUtils.hasLength(s2)){ |
| | |
| | | * @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(); |
| | |
| | | // 门店 向上查询运营商 |
| | | 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()); |
| | |
| | | if(!StringUtils.hasLength(s2)){ |
| | | return ResultUtil.error("运营商未配置支付宝商户号,获取支付失败!"); |
| | | } |
| | | ResultUtil alipay = payMoneyUtil.alipay(s2, body, "",String.valueOf(userCouponPayment.getId()), code, cash.toString(), |
| | | smidRes = s2; |
| | | } |
| | | } |
| | | } |
| | | 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; |
| | | } |
| | | }else { |
| | | // 平台发布 |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid, body, "",String.valueOf(userCouponPayment.getId()), code, cash.toString(), |
| | | "/base/coupon/aliPaymentCouponCallback"); |
| | | return alipay; |
| | | } |
| | | } |
| | | // 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("支付失败"); |
| | | } |
| | | |
| | | /** |
| | | * 支付回调 |
| | | * |
| | | * @param code |
| | | * @param orderNumber |
| | | * @return |
| | |
| | | } |
| | | |
| | | 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); |
| | | List<Integer> integers = mcsClient.queryPointMerStoreIds(pointsMerchandise.getId()); |
| | |
| | | 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(), |
| | | smidRes = s2; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | alipay = payMoneyUtil.alipay(smidRes, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | return alipay; |
| | | 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; |
| | | } |
| | | }else{ |
| | | // 平台门票 |
| | | ResultUtil alipay = payMoneyUtil.alipay(smid, name, name, String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | return alipay; |
| | | } |
| | | } |
| | | return ResultUtil.error("获取支付失败!"); |
| | | // 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 { |
| | |
| | | |
| | | |
| | | @Override |
| | | public ResultUtil exchangeAddPaymentCallback(String code, String orderNumber) { |
| | | public ResultUtil exchangeAddPaymentCallback(String code, String orderNumber) throws AlipayApiException { |
| | | System.err.println("进入回调"+code); |
| | | UserPointsMerchandise userPointsMerchandise = mcClient.queryUserPointMerchaseByCode(code).get(0); |
| | | System.err.println("商品"+userPointsMerchandise); |
| | |
| | | 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(); |
| | | } |
| | | |