liujie
2025-06-09 70d2a5d0f9c6951b2d4cac954041ed73582ff7eb
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/VolunteerCreditsExchangeServiceImpl.java
@@ -7,15 +7,18 @@
import com.panzhihua.common.model.vos.community.VolunteerCreditsExchangeVO;
import com.panzhihua.common.model.vos.community.VolunteerIntegralMerchantVO;
import com.panzhihua.common.model.vos.community.VolunteerIntegralRecordVO;
import com.panzhihua.common.model.vos.community.VolunteerMerchantVO;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.utlis.Snowflake;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_community.dao.VolunteerCreditsExchangeDao;
import com.panzhihua.service_community.entity.VolunteerCreditsExchange;
import com.panzhihua.service_community.entity.VolunteerIntegralMerchant;
import com.panzhihua.service_community.entity.VolunteerMerchant;
import com.panzhihua.service_community.service.VolunteerCreditsExchangeService;
import com.panzhihua.service_community.service.VolunteerIntegralMerchantService;
import com.panzhihua.service_community.service.VolunteerIntegralRecordService;
import com.panzhihua.service_community.service.VolunteerMerchantService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -36,15 +39,18 @@
    @Resource
    private VolunteerIntegralRecordService virService;
    @Resource
    private VolunteerMerchantService vmService;
    @Override
    public R getList(int pageNum, int pageSize, String goodsId, String orderNumber,
                     String goodsName, String condition, String userName,String communityId,
                     String userId,String orderType) {
                     String userId,String orderType,String merchantId) {
        Page page=new Page<VolunteerCreditsExchange>(pageNum,pageSize);
        return R.ok(baseMapper.getList(page,goodsId,orderNumber,goodsName,condition,
                userName,communityId,userId,orderType));
                userName,communityId,userId,orderType,merchantId));
    }
    @Override
@@ -92,25 +98,31 @@
            return R.fail("兑换用户id不能为空");
        }
        if(StringUtils.isEmpty(goods.getGoodNum()))
        {
            return R.fail("商品库存不足");
        }
        else
        {
            int goodNum=Integer.valueOf(goods.getGoodNum());
            if(goodNum<=0)
            {
                return R.fail("商品库存不足");
            }
//        if(StringUtils.isEmpty(goods.getGoodNum()))
//        {
//            return R.fail("商品库存不足");
//        }
//        else
//        {
//            int goodNum=Integer.valueOf(goods.getGoodNum());
//            if(goodNum<=0)
//            {
//                return R.fail("商品库存不足");
//            }
//
//            goodNum--;
//
//            VolunteerIntegralMerchantVO vo=new VolunteerIntegralMerchantVO();
//            vo.setId(goods.getId());
//            vo.setGoodNum(goodNum+"");
//            goodsService.updateById(vo);
//        }
            goodNum--;
        int num1=integral-Integer.valueOf(goods.getIntegral());
        loginUserInfoVOR.setLoveIntegral(num1+"");
        userService.putUser(loginUserInfoVOR);
            VolunteerIntegralMerchantVO vo=new VolunteerIntegralMerchantVO();
            vo.setId(goods.getId());
            vo.setGoodNum(goodNum+"");
            goodsService.updateById(vo);
        }
        item.setPalyIntegral(goods.getIntegral());
        //增加积分明细记录
@@ -122,11 +134,6 @@
        virService.insertVolunteer(virvo);
        int num1=integral-Integer.valueOf(goods.getIntegral());
        loginUserInfoVOR.setLoveIntegral(num1+"");
        userService.putUser(loginUserInfoVOR);
        item.setPalyIntegral(goods.getIntegral());
        //设置订单号
        item.setOrderNumber(Snowflake.getId()+"");
        int num= baseMapper.insertData(item);
@@ -145,24 +152,12 @@
            return R.fail("参数不能为空");
        }
        if(StringUtils.isEmpty(item.getGoodsId()))
        {
            return R.fail("商品id不能为空");
        }
        if(StringUtils.isEmpty(item.getMerchantId()))
        {
            return R.fail("商家id不能为空");
        }
        VolunteerIntegralMerchant goods=goodsService.queryById(item.getGoodsId());
        LoginUserInfoVO loginUserInfoVOR=userService.getUserInfoByUserId(item.getUserId()).getData();
        if(goods==null)
        {
            return R.fail("商品不存在");
        }
        if(StringUtils.isEmpty(item.getPalyIntegral()))
        {
@@ -180,8 +175,6 @@
            return R.fail("剩余积分不足!无法支付");
        }
        item.setNeedScore(goods.getIntegral());
        if(StringUtils.isEmpty(item.getUserId()))
        {
            return R.fail("兑换用户id不能为空");
@@ -195,18 +188,36 @@
        virvo.setCommunityId(item.getCommunityId());
        virService.insertVolunteer(virvo);
        //修改个人积分
        int num1=integral-Integer.valueOf(item.getPalyIntegral());
        loginUserInfoVOR.setLoveIntegral(num1+"");
        userService.putUser(loginUserInfoVOR);
        //修改商家积分
        R<VolunteerMerchant> vm= vmService.getById(item.getMerchantId());
        int vmNum=0;
        if(!StringUtils.isEmpty(vm.getData().getMerchantIntegral()))
        {
            vmNum=Integer.valueOf(vm.getData().getMerchantIntegral());
        }
        vmNum+=Integer.valueOf(item.getPalyIntegral());
        VolunteerMerchantVO vmvo=new VolunteerMerchantVO();
        vmvo.setId(item.getMerchantId());
        vmvo.setMerchantIntegral(vmNum+"");
        vmService.updateVolunteerMerchant(vmvo);
        item.setCondition("3");
        //设置订单号
        item.setOrderNumber(Snowflake.getId()+"");
        String orderNum=Snowflake.getId()+"";
        item.setOrderNumber(orderNum);
        int num= baseMapper.insertData(item);
        if(num>0)
        {
            return R.ok();
            return R.ok(orderNum);
        }
        return R.fail("操作失败");
    }
@@ -219,20 +230,6 @@
            return R.fail("参数不能为空");
        }
        if(StringUtils.isEmpty(item.getGoodsId()))
        {
            return R.fail("商品id不能为空");
        }
        if(StringUtils.isEmpty(item.getNeedScore()))
        {
            return R.fail("所需积分不能为空");
        }
        if(StringUtils.isEmpty(item.getUserId()))
        {
            return R.fail("兑换用户id不能为空");
        }
        int num= baseMapper.update(item);
        if(num>0)
        {