| | |
| | | |
| | | @Override |
| | | public ResultUtil ContinuationOrpaymentCourse(Integer userId, ClasspaymentRequest request) { |
| | | System.err.println("请求参数"+request); |
| | | AppUser appUser = appuClient.queryAppUser(userId); |
| | | CoursePackageOrder coursePackageOrder = coursePackageOrderService.getById(request.getCoursePayId()); |
| | | System.err.println("上次支付记录"+coursePackageOrder); |
| | | String code = ""; |
| | | BigDecimal money = coursePackageOrder.getCashPayment(); |
| | | Integer wpGold = coursePackageOrder.getPlayPaiCoin(); |
| | | BigDecimal money = BigDecimal.valueOf(request.getCash()); |
| | | Integer wpGold = request.getPlayPaiCoin(); |
| | | if (coursePackageOrder.getPayStatus() == 1) { |
| | | code = coursePackageOrder.getCode(); |
| | | coursePackageOrder.setPayType(request.getPayType()); |
| | |
| | | CoursePackagePaymentConfig paymentConfig = cpConfigMapper.selectOne(new QueryWrapper<CoursePackagePaymentConfig>() |
| | | .eq("coursePackageId", request.getLessonId()) |
| | | .eq("classHours", request.getCourseHoursNum())); |
| | | 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); |
| | | if (ToolUtil.isNotEmpty(coursePackageDiscount)) { |
| | | String content = coursePackageDiscount.getContent(); |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | |
| | | newPayment.setAppUserId(appUser.getId()); |
| | | newPayment.setStudentIds(request.getStuId().toString()); |
| | | newPayment.setCoursePackageId(request.getLessonId()); |
| | | newPayment.setClassHours(coursePackageOrder.getClassHours()); |
| | | newPayment.setClassHours(request.getCourseHoursNum()); |
| | | newPayment.setOriginalPrice(coursePackageOrder.getOriginalPrice()); |
| | | if (request.getUseConpon() == 1) { |
| | | newPayment.setUserCouponId(Long.valueOf(request.getUseConpon())); |
| | |
| | | newPayment.setPayType(request.getPayType()); |
| | | newPayment.setState(1); |
| | | newPayment.setInsertTime(new Date()); |
| | | if (request.getCash()!=null && request.getCash()!=0){ |
| | | newPayment.setCashPayment(BigDecimal.valueOf(request.getCash())); |
| | | } |
| | | newPayment.setPlayPaiCoin(request.getPlayPaiCoin()); |
| | | newPayment.setOrderType(1); |
| | | newPayment.setUserCouponId(request.getConponId()); |
| | | coursePackageOrderService.save(newPayment); |
| | | code = newPayment.getCode(); |
| | | } |
| | | System.err.println("选择"); |
| | | switch (request.getPayType()) { |
| | | case 1: |
| | | if (request.getUseConpon() == 1) { |
| | | Coupon coupon = client.queryCouponById(request.getConponId()); |
| | | if (coupon.getType() == 1) { |
| | | Map<String, Object> couponRules = client.getCouponRules(coupon.getId()); |
| | | Double conditionalAmount = (Double) couponRules.get("conditionalAmount"); |
| | | Double deductionAmount = (Double) couponRules.get("deductionAmount"); |
| | | if (money.compareTo(BigDecimal.valueOf(conditionalAmount)) >= 0) { |
| | | money = BigDecimal.valueOf(deductionAmount); |
| | | } |
| | | } |
| | | if (coupon.getType() == 2) { |
| | | Map<String, Object> couponRules = client.getCouponRules(coupon.getId()); |
| | | Object amount = couponRules.get("deductionAmount"); |
| | | money = BigDecimal.valueOf((Double) amount); |
| | | } |
| | | Integer coupon1 = client.queryUserCouponById(request.getConponId()); |
| | | System.err.println("优惠券id"+coupon1); |
| | | Coupon coupon = client.queryCouponById(coupon1); |
| | | System.err.println("优惠券信息"+coupon); |
| | | // if (coupon.getType() == 1) { |
| | | // Map<String, Object> couponRules = client.getCouponRules(coupon.getId()); |
| | | // Double conditionalAmount = (Double) couponRules.get("conditionalAmount"); |
| | | // Double deductionAmount = (Double) couponRules.get("deductionAmount"); |
| | | // if (money.compareTo(BigDecimal.valueOf(conditionalAmount)) >= 0) { |
| | | // money = BigDecimal.valueOf(deductionAmount); |
| | | // } |
| | | // } |
| | | // if (coupon.getType() == 2) { |
| | | // Map<String, Object> couponRules = client.getCouponRules(coupon.getId()); |
| | | // System.err.println("优惠券规则"+couponRules); |
| | | // Object amount = couponRules.get("conditionalAmount"); |
| | | // money = BigDecimal.valueOf((Double) amount); |
| | | // } |
| | | } |
| | | try { |
| | | return WeChatPayment(code, money,request.getLessonId()); |
| | |
| | | } |
| | | case 2: |
| | | if (request.getUseConpon() == 1) { |
| | | Coupon coupon = client.queryCouponById(request.getConponId()); |
| | | Integer coupon1 = client.queryUserCouponById(request.getConponId()); |
| | | Coupon coupon = client.queryCouponById(coupon1); |
| | | if (coupon.getType() == 1) { |
| | | Map<String, Object> couponRules = client.getCouponRules(coupon.getId()); |
| | | Double conditionalAmount = (Double) couponRules.get("conditionalAmount"); |
| | |
| | | money = BigDecimal.valueOf((Double) amount); |
| | | } |
| | | } |
| | | |
| | | return AlipayPayment(code, money); |
| | | case 3: |
| | | System.err.println("选择"); |
| | | PlaypaiGoldPayment(appUser, code, wpGold); |
| | | break; |
| | | default: |
| | |
| | | } |
| | | |
| | | 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); |
| | | Integer storeId = byId.getStoreId(); |
| | | Store store = storeClient.queryStoreById(storeId); |
| | | System.err.println("门店查询"+store); |
| | | // 是否分账 0否1是 |
| | | int isFenZhang= 1; |
| | | String merchantNumber = ""; |
| | |
| | | // 平台 |
| | | isFenZhang = 0; |
| | | } |
| | | System.err.println("拉起支付"); |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("课包续费"+"-"+isFenZhang, "", code, request.toString(), |
| | | "/base/coursePackage/wechatRegisteredCoursesCallback", "APP", ""); |
| | | if (weixinpay.getCode() == 200) { |
| | |
| | | .eq("classHours", coursePackageOrder1.getClassHours()) |
| | | ); |
| | | coursePackageService.addCoursePackageOrderStudent(coursePackageOrder1.getId(), coursePackagePaymentConfig); |
| | | if (store.getOperatorId()!=null && store.getOperatorId()!=0){ |
| | | // 休眠两分钟后再调用分账接口 避免提示订单正在处理中 |
| | | Thread.sleep(120000); |
| | | // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例 |
| | | String proportionByOperatorId = storeClient.getProportionByOperatorId(store.getOperatorId()); |
| | | String[] split = proportionByOperatorId.split(","); |
| | | String s1 = split[0]; |
| | | if (!s1.equals("未设置")){ |
| | | BigDecimal bigDecimal = new BigDecimal(s1); |
| | | // 分账比例 |
| | | BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2); |
| | | // 微信商户号 |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(store.getOperatorId()); |
| | | String nonce_str = UUIDUtil.getRandomCode(16); |
| | | |
| | | ResultUtil fenzhang = payMoneyUtil.fenzhang(transaction_id, request.multiply(bigDecimal1), s2,nonce_str); |
| | | if (!fenzhang.getCode().equals(500)){ |
| | | System.err.println("分账失败 原因是:"+fenzhang.getMsg()); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | if ("USERPAYING".equals(s) || "NOTPAY".equals(s)) { |
| | |
| | | } |
| | | |
| | | public ResultUtil PlaypaiGoldPayment(AppUser appUser, String code, Integer wpGold) { |
| | | TCoursePackagePayment packagePayment = this.baseMapper.selectOne(new QueryWrapper<TCoursePackagePayment>() |
| | | 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); |
| | | if (appUser.getPlayPaiCoins() < wpGold) { |
| | | return ResultUtil.error("玩湃币不足!"); |
| | | } |
| | | packagePayment.setPayStatus(2); |
| | | packagePayment.setPayUserId(appUser.getId()); |
| | | packagePayment.setPlayPaiCoin(wpGold); |
| | | this.baseMapper.updateById(packagePayment); |
| | | System.err.println("扣去玩湃币"); |
| | | try { |
| | | System.err.println("修改"); |
| | | boolean b = coursePackageOrderService.updateById(packagePayment); |
| | | |
| | | }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); |
| | | |
| | | appuClient.updateAppUser(appUser); |
| | | return ResultUtil.success(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil insertVipPaymentCallback(String code, String orderNumber) { |
| | | public ResultUtil insertVipPaymentCallback(String code, String orderNumber) throws Exception { |
| | | CoursePackageOrder coursePackageOrder1 = coursePackageOrderService.getOne(new QueryWrapper<CoursePackageOrder>() |
| | | .eq("code", code).eq("state", 1)); |
| | | if (coursePackageOrder1.getPayStatus() == 2) { |
| | |
| | | .eq("classHours", coursePackageOrder1.getClassHours()) |
| | | ); |
| | | coursePackageService.addCoursePackageOrderStudent(coursePackageOrder1.getId(), coursePackagePaymentConfig); |
| | | try { |
| | | coursePackageService.moneyOut(orderNumber,orderNumber,code); |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | TCoursePackage byId = coursePackageService.getById(coursePackageOrder1.getCoursePackageId()); |
| | | Integer storeId = byId.getStoreId(); |
| | | Store store = storeClient.queryStoreById(storeId); |
| | | |
| | | if (store.getOperatorId()!=null && store.getOperatorId()!=0){ |
| | | // 休眠两分钟后再调用分账接口 避免提示订单正在处理中 |
| | | Thread.sleep(120000); |
| | | // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例 |
| | | String proportionByOperatorId = storeClient.getProportionByOperatorId(store.getOperatorId()); |
| | | String[] split = proportionByOperatorId.split(","); |
| | | String s1 = split[0]; |
| | | if (!s1.equals("未设置")){ |
| | | BigDecimal bigDecimal = new BigDecimal(s1); |
| | | // 分账比例 |
| | | BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2); |
| | | // 微信商户号 |
| | | String s2 = storeClient.getmerchantNumberByOperatorId(store.getOperatorId()); |
| | | String nonce_str = UUIDUtil.getRandomCode(16); |
| | | |
| | | ResultUtil fenzhang = payMoneyUtil.fenzhang(orderNumber, coursePackageOrder1.getCashPayment().multiply(bigDecimal1), s2,nonce_str); |
| | | if (!fenzhang.getCode().equals(200)){ |
| | | System.err.println("分账失败 原因是:"+fenzhang.getData()); |
| | | } |
| | | } |
| | | } |
| | | return ResultUtil.success(); |
| | | } |