nickchange
2023-11-24 18b58aaf9bd99cadd0e7f80fe5d80586f2f4831a
cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java
@@ -263,14 +263,35 @@
        return appUserMapper.groupCityInfo(dto);
    }
    @Override
    public ClassInfoVo queryUserOfStus(Integer id) {
        TAppUser tAppUser = this.baseMapper.selectById(id);
    public ClassInfoVo queryUserOfStus(Integer id,Integer uid) {
        TAppUser tAppUser = this.baseMapper.selectById(uid);
        ClassInfoVo classInfoVo = new ClassInfoVo();
        if (ToolUtil.isNotEmpty(tAppUser)){
            List<TStudent> tStudents = tsmapper.selectList(new QueryWrapper<TStudent>()
//        if (ToolUtil.isNotEmpty(tAppUser)){
//
        List<TStudent> tStudents = new ArrayList<>();
        if (id!=null) {
             tStudents = tsmapper.selectList(new QueryWrapper<TStudent>()
                    .eq("id", id).eq("state", 1));
            if (tStudents.size() == 0) {
                tStudents = tsmapper.selectList(new QueryWrapper<TStudent>()
                        .eq("appUserId", tAppUser.getId())
                        .eq("state", 1));
            }
        }else {
                 tStudents = tsmapper.selectList(new QueryWrapper<TStudent>()
                    .eq("appUserId",tAppUser.getId())
                    .eq("state",1)
                    .eq("isDefault",1));
                 if (tStudents.isEmpty()){
                     tStudents = tsmapper.selectList(new QueryWrapper<TStudent>()
                             .eq("appUserId",tAppUser.getId())
                             .eq("state",1))
                             ;
                 }
        }
            if (tStudents.size() > 0 ){
                TStudent tStudent = tStudents.get(0);
                classInfoVo.setStuId(tStudent.getId());
@@ -299,14 +320,16 @@
                        course.setDeductedNums(ToolUtil.isEmpty(tCoursePackagePayment.getDeductionNums()) ? 0 : tCoursePackagePayment.getDeductionNums());
                        course.setRemainingNums(ToolUtil.isEmpty(tCoursePackagePayment.getResidueNums())? 0 : tCoursePackagePayment.getResidueNums());
                        course.setPeriodOfValidity(tCoursePackagePayment.getPeriodOfValidity());
                        course.setIsAble(tCoursePackagePayment.getIsAble());
                        course.setCourseType(tCoursePackagePayment.getCourseType());
                        courseList.add(course);
                    }
                }
                classInfoVo.setCourseList(courseList);
//                List<ExerciseVideo> stuCourseOfVideoList = voclClient.getStuCourseOfVideoList(coursePackIds);
                List<ExerciseVideo> query = voclClient.query(id);
                System.out.println("======queryqueryqueryquery=================="+query);
                classInfoVo.setExerciseVideoList(query);
                List<ExerciseVideo> query = voclClient.query(tStudent.getId());
                    classInfoVo.setExerciseVideoList(query);
            }else {
                classInfoVo.setIsThere(2);
                List<TImgConfig> tImgConfigs = configClient.getNoneStuImgs();
@@ -314,7 +337,7 @@
                    classInfoVo.setImgs(tImgConfigs.get(0).getContent());
                }
            }
        }
//        }
        return classInfoVo;
    }
@@ -397,7 +420,9 @@
     */
    @Override
    public ResultUtil addAppUser(AddAppUserVo addAppUserVo) throws Exception {
        TAppUser tAppUser = this.baseMapper.selectOne(new QueryWrapper<TAppUser>().eq("phone", addAppUserVo.getPhone()).ne("state", 3));
        TAppUser tAppUser = this.baseMapper.selectOne(new QueryWrapper<TAppUser>()
                .eq("phone", addAppUserVo.getPhone())
                .ne("state", 3));
        if(null != tAppUser){
            return ResultUtil.error("账号已存在");
        }
@@ -413,42 +438,58 @@
        tAppUser.setIsVip(0);
        tAppUser.setState(1);
        tAppUser.setInsertTime(new Date());
        // 介绍有礼
        if(addAppUserVo.getReferralUserId()!=null || ToolUtil.isNotEmpty(addAppUserVo.getInvitePhone())){
            if(ToolUtil.isEmpty(addAppUserVo.getLat()) || ToolUtil.isEmpty(addAppUserVo.getLon())){
                return ResultUtil.error("请先开启定位", "");
            }
            Map<String, String> geocode = gdMapGeocodingUtil.geocode(addAppUserVo.getLon(), addAppUserVo.getLat());
            Integer num=0;
            if(null != geocode){
                String province = geocode.get("province");
                String provinceCode = geocode.get("provinceCode");
                String city = geocode.get("city");
                String cityCode = geocode.get("cityCode");
                 num =  introduceRewardsClient.getGiftList(cityCode);
            }
            if(ToolUtil.isNotEmpty(addAppUserVo.getInvitePhone())){
                List<TAppUser> tAppUsers = this.baseMapper.selectList(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getPhone, addAppUserVo.getInvitePhone()));
                if(tAppUsers.size()>0){
                    addAppUserVo.setReferralUserId(tAppUsers.get(0).getId());
        // 注册用户
        int insert = this.baseMapper.insert(tAppUser);
            // 介绍有礼
            if(addAppUserVo.getReferralUserId()!=null || ToolUtil.isNotEmpty(addAppUserVo.getInvitePhone())){
                if(ToolUtil.isEmpty(addAppUserVo.getLat()) || ToolUtil.isEmpty(addAppUserVo.getLon())){
                    return ResultUtil.error("请先开启定位", "");
                }
                Map<String, String> geocode = gdMapGeocodingUtil.geocode(addAppUserVo.getLon(), addAppUserVo.getLat());
                Integer num=0;
                Integer activityId=null;
                if(null != geocode){
                    String province = geocode.get("province");
                    String provinceCode = geocode.get("provinceCode");
                    String city = geocode.get("city");
                    String cityCode = geocode.get("cityCode");
                    // 根据所在市code 查询是否有介绍有礼活动
                    IntroduceRewards res = introduceRewardsClient.getGiftList(cityCode);
                    if (res!=null){
                        num = res.getGiveClass();
                        activityId = res.getId();
                        if(ToolUtil.isNotEmpty(addAppUserVo.getInvitePhone())){
                            List<TAppUser> tAppUsers = this.baseMapper.selectList(new LambdaQueryWrapper<TAppUser>()
                                    .eq(TAppUser::getPhone, addAppUserVo.getInvitePhone()));
                            if(tAppUsers.size()>0){
                                addAppUserVo.setReferralUserId(tAppUsers.get(0).getId());
                            }
                        }
                        if (num!=0){
                            TAppGift tAppGift = new TAppGift();
                            TAppUser phone = appUserService.getOne(new QueryWrapper<TAppUser>()
                                    .eq("phone", addAppUserVo.getInvitePhone()));
                            if (phone == null){
                                return ResultUtil.error("推荐人手机号未注册玩湃会员!");
                            }else{
                                tAppGift.setUserName(phone.getName());
                                tAppGift.setUserPhone(phone.getPhone());
                            }
                            tAppGift.setUserId(addAppUserVo.getReferralUserId());
                            tAppGift.setNum(num);
                            tAppGift.setShareUserId(tAppUser.getId());
                            tAppGift.setShareUserName(tAppUser.getPhone());
                            tAppGift.setShareUserPhone(tAppUser.getPhone());
                            tAppGift.setActivityId(activityId);
                            tAppGift.setInsertTime(new Date());
                            appGiftService.save(tAppGift);
                        }
                    }
                }
            }
            TAppGift one = appGiftService.getOne(new LambdaQueryWrapper<TAppGift>().eq(TAppGift::getUserId, addAppUserVo.getReferralUserId()));
            if(one!=null){
                one.setNum(one.getNum()+num);
                appGiftService.updateById(one);
            }else {
                TAppGift tAppGift = new TAppGift();
                tAppGift.setUserId(addAppUserVo.getReferralUserId());
                tAppGift.setNum(num);
                appGiftService.save(tAppGift);
            }
        }
        this.baseMapper.insert(tAppUser);
        return ResultUtil.success();
    }
@@ -678,7 +719,11 @@
        IndexOfUserBenefirVo benefirVo = new IndexOfUserBenefirVo();
        TAppUser appUser = this.getById(appUserId);
        benefirVo.setUserHeadImg(appUser.getHeadImg());
        if (appUser.getHeadImg()!=null) {
            benefirVo.setUserHeadImg(appUser.getHeadImg());
        }else {
            benefirVo.setUserHeadImg("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/630864764d3c4e98822ff976a2389559.jpg");
        }
        benefirVo.setUserName(appUser.getName());
        benefirVo.setWpCoin(ToolUtil.isEmpty(appUser.getPlayPaiCoins()) ? 0 : appUser.getPlayPaiCoins());
        benefirVo.setUserIntegral(ToolUtil.isEmpty(appUser.getIntegral()) ? 0 : appUser.getIntegral());
@@ -742,17 +787,17 @@
            }
        }
//            3.课包购买
        BillingRequestVo amountPayRecord = paymentClient.getAmountPayRecord(requestVo);
        if (ToolUtil.isNotEmpty(amountPayRecord.getRequests())){
            for (BillingRequest coursePackagePayment : amountPayRecord.getRequests()) {
                ConsumeDetail consumeDetail = new ConsumeDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.COURSE_PACKAGE_PURCHASE.getMsg());
                consumeDetail.setConsumeTime(coursePackagePayment.getTime());
                consumeDetail.setConsumeAmount("-" + coursePackagePayment.getAmount());
                consumeDetail.setType(2);
                details.add(consumeDetail);
            }
        }
//        BillingRequestVo amountPayRecord = paymentClient.getAmountPayRecord(requestVo);
//        if (ToolUtil.isNotEmpty(amountPayRecord.getRequests())){
//            for (BillingRequest coursePackagePayment : amountPayRecord.getRequests()) {
//                ConsumeDetail consumeDetail = new ConsumeDetail();
//                consumeDetail.setConsumeName(RechargeRecordEnum.COURSE_PACKAGE_PURCHASE.getMsg());
//                consumeDetail.setConsumeTime(coursePackagePayment.getTime());
//                consumeDetail.setConsumeAmount("-" + coursePackagePayment.getAmount());
//                consumeDetail.setType(2);
//                details.add(consumeDetail);
//            }
//        }
        //2.0
        List<CourseCounsum> courseCounsums  = paymentClient.getConsumes(requestVo);
@@ -795,7 +840,7 @@
                    consumeDetail2.setConsumeName(RechargeRecordEnum.VENUE_RESERVATION.getMsg());
                    consumeDetail2.setConsumeAmount("-" + booking.getAmount());
                    consumeDetail2.setConsumeTime(booking.getTime1());
                    consumeDetail2.setType(1);
                    consumeDetail2.setType(2);
                    details.add(consumeDetail2);
                }
@@ -827,7 +872,7 @@
        if (rechargeRecords.size() > 0) {
            for (RechargeRecords rechargeRecord : rechargeRecords) {
                ConsumeDetail consumeDetail = new ConsumeDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.RECHARGE.getMsg() + ":" + rechargeRecord.getPlayPaiCoins());
                consumeDetail.setConsumeName(RechargeRecordEnum.RECHARGE.getMsg() + ":" + rechargeRecord.getPlayPaiCoins()+"币");
                consumeDetail.setConsumeTime(simpleDateFormat.format(rechargeRecord.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + rechargeRecord.getAmount());
                consumeDetail.setType(2);
@@ -888,7 +933,7 @@
                RechargeCentVo vo = new RechargeCentVo();
                Double money = (Double) stringObjectMap.get("money");
                vo.setAmount(BigDecimal.valueOf(money) );
                if (tAppUser.getIsVip() == 1){
                if (tAppUser.getIsVip() == 1&&tAppUser.getVipEndTime().after(new Date())){
                    vo.setWpGold((Integer) stringObjectMap.get("MemberCoins"));
                }else {
                    vo.setWpGold((Integer) stringObjectMap.get("usersCoins"));
@@ -924,6 +969,7 @@
                        }
                        commodity.setBelongsType(vicinityGood.getUserPopulation());
                        commodity.setGoodsType(1);
                        commodity.setUseScope(vicinityGood.getUseScope());
                        commodity.setNums(mcClient.getRedeemedQuantity(vicinityGood.getId()));
                        List<Integer> integers = mcsClient.queryPointMerStoreIds(vicinityGood.getId());
                        commodity.setShopIds(integers);
@@ -943,6 +989,8 @@
                        }
                        commodity.setBelongsType(vicinityGood.getUserPopulation());
                        commodity.setGoodsType(2);
                        commodity.setUseScope(vicinityGood.getUseScope());
                        commodity.setNums(mcClient.getRedeemedQuantity(vicinityGood.getId()));
                        commodity.setShopIds(mcsClient.queryPointMerStoreIds(vicinityGood.getId()));
                        break;
@@ -950,6 +998,8 @@
                        commodity.setGoodId(vicinityGood.getId());
                        commodity.setGoodName(vicinityGood.getName());
                        commodity.setGoodImg(vicinityGood.getCover());
                        commodity.setUseScope(vicinityGood.getUseScope());
                        commodity.setCondition(vicinityGood.getRedemptionMethod());
                        if (vicinityGood.getRedemptionMethod() == 1) {
                            commodity.setIntegral(vicinityGood.getIntegral().intValue());
@@ -980,7 +1030,9 @@
                if (allCoupon.getRedemptionMethod() == 1) {
                    commodity.setIntegral(allCoupon.getIntegral().intValue());
                } else {
                    commodity.setIntegral(allCoupon.getIntegral().intValue());
                    if (allCoupon.getIntegral()!=null) {
                        commodity.setIntegral(allCoupon.getIntegral().intValue());
                    }
                    commodity.setAmount(allCoupon.getCash());
                }
                commodity.setBelongsType(allCoupon.getUserPopulation());
@@ -1003,7 +1055,7 @@
        if (request.getShopId()!=null){
            if (goods.size() > 0 ){
                goods = goods.stream()
                        .filter( merchandise ->(merchandise.getGoodsType() == 4&&merchandise.getUseScope() == 2)||(merchandise.getGoodsType() == 4&&merchandise.getUseScope() == 1)||merchandise.getShopIds().contains(request.getShopId()))
                        .filter( merchandise ->(merchandise.getGoodsType() == 1&&merchandise.getUseScope() == 2)||(merchandise.getGoodsType() == 1&&merchandise.getUseScope() == 1)||(merchandise.getGoodsType() == 4&&merchandise.getUseScope() == 2)||(merchandise.getGoodsType() == 4&&merchandise.getUseScope() == 1)||merchandise.getShopIds().contains(request.getShopId()))
                        .collect(Collectors.toList());
            }
        }
@@ -1132,7 +1184,8 @@
                    String provinceCode = geocode.get("provinceCode");
                    String city = geocode.get("city");
                    String cityCode = geocode.get("cityCode");
                    num =  introduceRewardsClient.getGiftList(cityCode);
                    IntroduceRewards giftList = introduceRewardsClient.getGiftList(cityCode);
                    num = giftList.getGiveClass();
                }
                Integer userId=null;
                if(ToolUtil.isNotEmpty(dto.getInvitePhone())){
@@ -1341,10 +1394,12 @@
            }
            TAppUser user = appUserService.getById(userIdFormRedis);
            if (user.getIntegral()<merchandise.getIntegral().intValue()*goodsNums){
                return  new ResultUtil<>(0,"当前用户积分不足");
            }
            if (merchandise.getIntegral()!=null) {
                if (user.getIntegral() < merchandise.getIntegral().intValue() * goodsNums) {
                    return new ResultUtil<>(0, "当前用户积分不足");
                }
            }
            AppUserGoodResp goodResp = new AppUserGoodResp();
            goodResp.setAppUserId(userIdFormRedis);
@@ -1366,7 +1421,12 @@
                UserPointsMerchandise pointsMerchandise = new UserPointsMerchandise();
                pointsMerchandise.setPointsMerchandiseId(exchangeType.getGoodId());
                pointsMerchandise.setUserId(userIdFormRedis);
                pointsMerchandise.setStatus(1);
                if (exchangeType.getGoodsType()==2){
                    pointsMerchandise.setStatus(2);
                    pointsMerchandise.setVerificationTime(new Date());
                }else {
                    pointsMerchandise.setStatus(1);
                }
                pointsMerchandise.setState(1);
                if (exchangeType.getExchangeType()==1) {
                    pointsMerchandise.setPayStatus(2);
@@ -1525,7 +1585,7 @@
            UserIntegralChanges userIntegralChanges = new UserIntegralChanges();
            userIntegralChanges.setAppUserId(appUserId);
            userIntegralChanges.setOldIntegral(appUser.getIntegral());
            userIntegralChanges.setType(5);
            userIntegralChanges.setType(2);
            appUser.setIntegral(null == appUser.getIntegral() ? points : appUser.getIntegral() - points);
            userIntegralChanges.setNewIntegral(appUser.getIntegral());
            userIntegralChanges.setInsertTime(new Date());