| | |
| | | import com.alipay.api.request.AlipayTradeOrderSettleRequest; |
| | | import com.alipay.api.request.AlipayTradeRoyaltyRelationBindRequest; |
| | | import com.alipay.api.response.AlipayTradeOrderSettleResponse; |
| | | import com.alipay.api.response.AlipayTradeQueryResponse; |
| | | import com.alipay.api.response.AlipayTradeRoyaltyRelationBindResponse; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | classInfoVo.setHeight(tStudent.getHeight()); |
| | | classInfoVo.setWeight(tStudent.getWeight()); |
| | | classInfoVo.setBmi(tStudent.getBmi()); |
| | | classInfoVo.setBodyStatus(BMIBodyUtil.getBodyStatus(tStudent.getBmi())); |
| | | |
| | | if (tStudent.getBmi()!=null) { |
| | | classInfoVo.setBodyStatus(BMIBodyUtil.getBodyStatus(tStudent.getBmi())); |
| | | } |
| | | List<RegisteredCourse> courseList = new ArrayList<>(); |
| | | List<StuCourseResp> stuCoursePayment = paymentClient.getStuCoursePayment(tStudent.getId()); |
| | | List<Integer> coursePackIds = new ArrayList<>(); |
| | |
| | | course.setPeriodOfValidity(tCoursePackagePayment.getPeriodOfValidity()); |
| | | courseList.add(course); |
| | | } |
| | | |
| | | } |
| | | classInfoVo.setCourseList(courseList); |
| | | // List<ExerciseVideo> stuCourseOfVideoList = voclClient.getStuCourseOfVideoList(coursePackIds); |
| | |
| | | details.add(consumeDetail); |
| | | } |
| | | } |
| | | |
| | | //8.积分商场 |
| | | |
| | | List<ConsumeDetail> consumeDetails = mcClient.getConsumeDetails(requestVo); |
| | | details.addAll(consumeDetails); |
| | | |
| | | |
| | | if (details.size() > 0 ){ |
| | | Collections.sort(details, new Comparator<ConsumeDetail>() { |
| | | @Override |
| | |
| | | commodity.setGoodsType(4); |
| | | commodity.setShopIds(ucponClient.getCouponStoreIds(allCoupon.getId())); |
| | | commodity.setNums(ucponClient.getRedeemedQuantity(allCoupon.getId())); |
| | | commodity.setUseScope(allCoupon.getUseScope()); |
| | | goods.add(commodity); |
| | | } |
| | | } |
| | |
| | | if (request.getShopId()!=null){ |
| | | if (goods.size() > 0 ){ |
| | | goods = goods.stream() |
| | | .filter(merchandise -> merchandise.getShopIds().contains(request.getShopId())) |
| | | .filter( merchandise ->(merchandise.getGoodsType() == 4&&merchandise.getUseScope() == 2)||(merchandise.getGoodsType() == 4&&merchandise.getUseScope() == 1)||merchandise.getShopIds().contains(request.getShopId())) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<QueryAppUserVO> listAll1(QueryAppUser query) { |
| | | return appUserMapper.listAll1(query); |
| | | } |
| | | |
| | | @Override |
| | | public StuAndStoreResponse queryAppUserDefaultStuAndStore(Integer userIdFormRedis,Integer pointsMerId, String lat, String lon,Integer isCourse) { |
| | | StuAndStoreResponse response = new StuAndStoreResponse(); |
| | | if (isCourse == 1){ |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private UserConponClient userConponClient; |
| | | |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public ResultUtil productRedemptionOperation(Integer userIdFormRedis, GoodsExchangeVo exchangeType) { |
| | | System.out.println("exchangeType:--->"); |
| | | |
| | | ReturnModel returnModel = new ReturnModel(); |
| | | Long returnId = null; |
| | | //如果是兑换优惠卷 |
| | | if (exchangeType.getGoodsType()==4){ |
| | | //查询优惠卷 |
| | | Coupon coupon = userConponClient.queryCouponById(exchangeType.getGoodId()); |
| | | //查询该优惠卷的数量够不够 |
| | | List<Integer> queryIds = new ArrayList<>(); |
| | | queryIds.add(coupon.getId()); |
| | | queryIds.add(userIdFormRedis); |
| | | Integer counts = userConponClient.queryCounts(queryIds); |
| | | if (coupon.getQuantityIssued()-counts == 0){ |
| | | return new ResultUtil(0,"当前数量不足"); |
| | | } |
| | | //查询该用户是否超出限领数量 |
| | | Integer usercounts = userConponClient.queryCounts1(queryIds); |
| | | |
| | | if (usercounts == coupon.getPickUpQuantity()){ |
| | | return new ResultUtil<>(0,"限领数量已达最大"); |
| | | } |
| | | // userConponClient.queryCouponById(exchangeType.getGoodId()); |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(exchangeType.getGoodId()); |
| | | userCoupon.setUserId(userIdFormRedis); |
| | | userCoupon.setStatus(1); |
| | | userCoupon.setInsertTime(new Date()); |
| | | userConponClient.insertToAppuserCoupon(userCoupon); |
| | | //扣积分 |
| | | TAppUser user = appUserService.getById(userIdFormRedis); |
| | | if (user.getIntegral()<coupon.getIntegral().intValue()){ |
| | | return new ResultUtil<>(0,"当前用户积分不足"); |
| | | } |
| | | user.setIntegral(user.getIntegral()-coupon.getIntegral().intValue()); |
| | | appUserService.updateById(user); |
| | | |
| | | //记录 |
| | | // UserPointsMerchandise pointsMerchandise = new UserPointsMerchandise(); |
| | | // pointsMerchandise.setPointsMerchandiseId(exchangeType.getGoodId()); |
| | | // pointsMerchandise.setUserId(userIdFormRedis); |
| | | // pointsMerchandise.setStatus(1); |
| | | // pointsMerchandise.setState(1); |
| | | // pointsMerchandise.setPayStatus(1); |
| | | //// if (merchandise.getUseScope() == 3){ |
| | | //// if (exchangeType.getGoodsType() == 2){ |
| | | //// CoursePackage coursePackage = cpageClient.queryCoursePackageById(merchandise.getCoursePackageId()); |
| | | //// pointsMerchandise.setStoreId(coursePackage.getStoreId()); |
| | | //// }else { |
| | | //// pointsMerchandise.setStoreId(exchangeType.getStoreId()); |
| | | //// } |
| | | //// } |
| | | //// pointsMerchandise.setCode(code); |
| | | // returnId = mcClient.saveDetailsUserPointMercase(pointsMerchandise); |
| | | |
| | | return ResultUtil.success(returnId); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | System.out.println(exchangeType); |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | PointsMerchandise merchandise = mcClient.selectPointsMerchandiseById(exchangeType.getGoodId()); |
| | | |
| | | if (ToolUtil.isEmpty(merchandise)){ |
| | | return ResultUtil.error("商品不存在"); |
| | | } |
| | |
| | | } |
| | | } |
| | | pointsMerchandise.setCode(code); |
| | | mcClient.saveDetailsUserPointMercase(pointsMerchandise); |
| | | returnId = mcClient.saveDetailsUserPointMercase(pointsMerchandise); |
| | | } |
| | | |
| | | switch (exchangeType.getExchangeType()){ |
| | | // 积分 |
| | | case 1: |
| | | boolean b = dealAppUserIntegral(userIdFormRedis,tAppUser,merchandise.getIntegral()); |
| | | boolean b =true; |
| | | for (int i = 0; i < goodsNums; i++) { |
| | | b = dealAppUserIntegral(userIdFormRedis,tAppUser,merchandise.getIntegral()); |
| | | } |
| | | if (b){ |
| | | switch (exchangeType.getGoodsType()){ |
| | | case 2: |
| | |
| | | break; |
| | | case 2: |
| | | // 积分+现金 |
| | | boolean dealt = dealAppUserIntegral(userIdFormRedis,tAppUser,merchandise.getIntegral()); |
| | | boolean dealt =true; |
| | | for (int i = 0; i < goodsNums; i++) { |
| | | dealt = dealAppUserIntegral(userIdFormRedis,tAppUser,merchandise.getIntegral()); |
| | | } |
| | | |
| | | switch (exchangeType.getPayType()) { |
| | | case 1: |
| | | try { |
| | |
| | | } |
| | | case 2: |
| | | if (merchandise.getType() == 2) { |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code); |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code,returnId); |
| | | } else { |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(goodsNums)), code); |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(goodsNums)), code,returnId); |
| | | } |
| | | default: |
| | | break; |
| | |
| | | } |
| | | case 2: |
| | | if (merchandise.getType() == 2) { |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code); |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(exchangeType.getStuIds().size())), code,returnId); |
| | | } else { |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(goodsNums)), code); |
| | | return AlipayPayment(merchandise.getCash().multiply(new BigDecimal(goodsNums)), code,returnId); |
| | | } |
| | | default: |
| | | break; |
| | |
| | | break; |
| | | } |
| | | |
| | | |
| | | |
| | | return ResultUtil.success(); |
| | | returnModel.setReturnId(returnId); |
| | | return ResultUtil.success(returnModel); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | |
| | | } |
| | | } |
| | | |
| | | private ResultUtil AlipayPayment(BigDecimal cash, String code) { |
| | | private ResultUtil AlipayPayment(BigDecimal cash, String code,Long returnId) { |
| | | System.out.println("金额:"+cash); |
| | | ResultUtil alipay = payMoneyUtil.alipay("课包续费", "课包续费", "", code, cash.toString(), |
| | | ResultUtil alipay = payMoneyUtil.alipay("课包续费", "课包续费", String.valueOf(returnId), code, cash.toString(), |
| | | "/base/pointMer/exchangeGoodPaymentAliCallback"); |
| | | if(alipay.getCode() == 200){ |
| | | new Thread(new Runnable() { |
| | |
| | | if(userPointsMerchandises.get(0).getPayStatus() == 2){ |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if(resultUtil.getCode() == 200 && userPointsMerchandises.get(0).getPayStatus() == 1){ |
| | | // 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"); |
| | | if("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10){ |
| | | // 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("REFUND".equals(tradeStatus) || "NOTPAY".equals(tradeStatus) || "CLOSED".equals(tradeStatus) || "REVOKED".equals(tradeStatus) || "PAYERROR".equals(tradeStatus) || num == 10){ |
| | | mcClient.deletePaymentRecord(code); |
| | | break; |
| | | } |
| | | if("TRADE_SUCCESS".equals(s)){ |
| | | if("TRADE_SUCCESS".equals(tradeStatus)){ |
| | | for (UserPointsMerchandise userPointsMerchandise : userPointsMerchandises) { |
| | | userPointsMerchandise.setPayStatus(2); |
| | | userPointsMerchandise.setOrderNumber(tradeNo); |
| | |
| | | moneyOut(tradeNo,tradeNo); |
| | | break; |
| | | } |
| | | if("WAIT_BUYER_PAY".equals(s)){ |
| | | if("WAIT_BUYER_PAY".equals(tradeStatus)){ |
| | | num++; |
| | | } |
| | | } |