44323
2023-11-05 9baa55cf4292ad0fe80547f9c840e917775411f4
cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java
@@ -284,8 +284,9 @@
                classInfoVo.setHeight(tStudent.getHeight());
                classInfoVo.setWeight(tStudent.getWeight());
                classInfoVo.setBmi(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<>();
@@ -302,7 +303,6 @@
                        course.setPeriodOfValidity(tCoursePackagePayment.getPeriodOfValidity());
                        courseList.add(course);
                    }
                }
                classInfoVo.setCourseList(courseList);
//                List<ExerciseVideo> stuCourseOfVideoList = voclClient.getStuCourseOfVideoList(coursePackIds);
@@ -799,6 +799,13 @@
                details.add(consumeDetail);
            }
        }
        //8.积分商场
        List<ConsumeDetail> consumeDetails = mcClient.getConsumeDetails(requestVo);
        details.addAll(consumeDetails);
        if (details.size() > 0 ){
            Collections.sort(details, new Comparator<ConsumeDetail>() {
                @Override
@@ -960,7 +967,7 @@
        if (request.getShopId()!=null){
            if (goods.size() > 0 ){
                goods = goods.stream()
                        .filter( merchandise ->(merchandise.getGoodsType() == 4&&merchandise.getUseScope() == 1)||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());
            }
        }
@@ -1198,6 +1205,8 @@
    public ResultUtil productRedemptionOperation(Integer userIdFormRedis, GoodsExchangeVo exchangeType) {
        System.out.println("exchangeType:--->");
        ReturnModel returnModel = new ReturnModel();
        Long returnId = null;
            //如果是兑换优惠卷
        if (exchangeType.getGoodsType()==4){
            //查询优惠卷
@@ -1216,10 +1225,6 @@
            if (usercounts == coupon.getPickUpQuantity()){
                return new ResultUtil<>(0,"限领数量已达最大");
            }
//            userConponClient.queryCouponById(exchangeType.getGoodId());
            UserCoupon userCoupon = new UserCoupon();
            userCoupon.setCouponId(exchangeType.getGoodId());
@@ -1227,19 +1232,33 @@
            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);
            return ResultUtil.success();
            //记录
//            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);
        }
@@ -1250,6 +1269,7 @@
            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("商品不存在");
            }
@@ -1307,13 +1327,16 @@
                    }
                }
                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:
@@ -1367,7 +1390,11 @@
                    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 {
@@ -1381,9 +1408,9 @@
                            }
                        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;
@@ -1403,9 +1430,9 @@
                            }
                        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;
@@ -1415,8 +1442,8 @@
                    break;
            }
            return ResultUtil.success();
        returnModel.setReturnId(returnId);
            return ResultUtil.success(returnModel);
        }catch (Exception e){
            e.printStackTrace();
            return null;
@@ -1447,9 +1474,9 @@
        }
    }
    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() {