luodangjia
2024-09-18 a96c5eddcd63fa6f09e4cdce9e28c7b846068f0c
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserVipDetailController.java
@@ -5,12 +5,14 @@
import com.ruoyi.account.api.vo.GetAppUserVipDetail;
import com.ruoyi.account.service.TAppUserVipDetailService;
import com.ruoyi.common.core.domain.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.other.api.domain.TVip;
import com.ruoyi.other.api.feignClient.VipClient;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
 * @author zhibing.pu
@@ -22,6 +24,8 @@
   
   @Resource
   private TAppUserVipDetailService appUserVipDetailService;
   @Resource
   private TokenService tokenService;
   
   /**
    * 获取用户当前有效的vip明细
@@ -36,6 +40,33 @@
            .last(" and now() between start_time and end_time"));
      return R.ok(one);
   }
   @Resource
   private VipClient vipClient;
   @GetMapping("/getVipUseDetail")
   @ApiOperation(value = "生效会员列表", tags = {"小程序-个人中心"})
   public R<List<TAppUserVipDetail>> getVipUseDetail(){
        Long userId = tokenService.getLoginUserApplet().getUserId();
        List<TAppUserVipDetail> list = appUserVipDetailService.lambdaQuery().eq(TAppUserVipDetail::getAppUserId, userId).last(" and now() between start_time and end_time order by start_time desc").list();
      for (TAppUserVipDetail tAppUserVipDetail : list) {
            if(null != tAppUserVipDetail.getVipId()){
                TVip data = vipClient.getInfo1(tAppUserVipDetail.getVipId()).getData();
                tAppUserVipDetail.setVipName(data.getName());
            }
        }
        return R.ok(list);
   }
   
   
   /**
    * 修改会员明细
    * @param appUserVipDetail
    */
   @PostMapping("/updateAppUserVipDetail")
   public void updateAppUserVipDetail(@RequestBody TAppUserVipDetail appUserVipDetail){
      appUserVipDetailService.updateById(appUserVipDetail);
   }
}