liujie
2023-10-31 904cfe3bad14c27857a062849fc92dd85035c524
cloud-server-account/src/main/java/com/dsh/account/service/impl/TAppUserServiceImpl.java
@@ -1179,8 +1179,9 @@
    @Transactional
    public ResultUtil productRedemptionOperation(Integer userIdFormRedis, GoodsExchangeVo exchangeType) {
        System.out.println("exchangeType:--->");
        System.out.println(exchangeType);
        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());
@@ -1188,9 +1189,7 @@
            return ResultUtil.error("商品不存在");
        }
        TAppUser tAppUser = this.baseMapper.selectById(userIdFormRedis);
        if(merchandise.getUserPopulation()==2){
            if(tAppUser.getIsVip()==0){
@@ -1198,15 +1197,12 @@
            }
        }
        if(merchandise.getUserPopulation()==3){
            List<TStudent> students = tsmapper.selectList(new LambdaQueryWrapper<TStudent>().eq(TStudent::getAppUserId, userIdFormRedis));
            if(students.size()==0){
                return ResultUtil.error("该商品只能已有学员用户购买");
            }
        }
        if (ToolUtil.isEmpty(tAppUser)){
            return ResultUtil.error("用户不存在");
@@ -1229,7 +1225,25 @@
            return ResultUtil.error("超过发放数量");
        }
            for (int i = 0; i < goodsNums; i++) {
//            新增积分商品兑换记录
                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);
                mcClient.saveDetailsUserPointMercase(pointsMerchandise);
            }
        switch (exchangeType.getExchangeType()){
//            积分
@@ -1336,26 +1350,14 @@
                break;
        }
        for (int i = 0; i < goodsNums; i++) {
//            新增积分商品兑换记录
            UserPointsMerchandise pointsMerchandise = new UserPointsMerchandise();
            pointsMerchandise.setPointsMerchandiseId(exchangeType.getGoodId());
            pointsMerchandise.setUserId(userIdFormRedis);
            pointsMerchandise.setStatus(1);
            pointsMerchandise.setState(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);
            mcClient.saveDetailsUserPointMercase(pointsMerchandise);
        }
        return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    public boolean dealAppUserIntegral(Integer appUserId,TAppUser appUser,Integer points){
@@ -1382,7 +1384,8 @@
    }
    private ResultUtil AlipayPayment(BigDecimal cash, String code) {
        ResultUtil alipay = payMoneyUtil.alipay("课包续费", "", "", code, cash.toString(),
        System.out.println("金额:"+cash);
        ResultUtil alipay = payMoneyUtil.alipay("课包续费", "课包续费", "", code, cash.toString(),
                "/base/pointMer/exchangeGoodPaymentAliCallback");
        if(alipay.getCode() == 200){
            new Thread(new Runnable() {
@@ -1395,7 +1398,9 @@
                            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;
                            }