luodangjia
2024-08-13 f374de49cb7cd1c904c43e6e9c186a415a5e5c31
8.13
3个文件已添加
8个文件已修改
272 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserVipDetail.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/NoticeQueryDto.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/TAppUserVipDetailService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserVipDetailServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/TaskUtil.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/GiveVipUtil.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/THtmlController.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TNoticeController.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TSystemConfigurationController.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserVipDetail.java
@@ -53,5 +53,9 @@
    @TableField("create_time")
    private LocalDateTime createTime;
    @ApiModelProperty(value = "已赠送的月份")
    @TableField("send_month")
    private String sendMonth;
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/NoticeQueryDto.java
New file
@@ -0,0 +1,12 @@
package com.ruoyi.other.api.dto;
import com.ruoyi.common.core.web.page.BasePage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class NoticeQueryDto extends BasePage {
    private String content;
    @ApiModelProperty("0未开始1已开始2已结束")
    private Integer status;
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
@@ -6,6 +6,7 @@
import com.ruoyi.account.api.dto.*;
import com.ruoyi.account.api.model.*;
import com.ruoyi.account.service.*;
import com.ruoyi.account.util.GiveVipUtil;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.bean.BeanUtils;
import com.ruoyi.common.core.web.domain.BasePojo;
@@ -63,6 +64,8 @@
    @Resource
    private ExchangeOrderClient exchangeOrderClient;
    @Resource
    private GiveVipUtil giveVipUtil;
    @ApiOperation(value = "单位管理列表", tags = {"用户管理-单位管理"})
    @PostMapping(value = "/unit/page")
    public R<Page<TCompany>> unitPage(@RequestBody UnitListQueryDto unitListQueryDto) {
@@ -255,31 +258,20 @@
    public R giveVip(@RequestBody GiveVipDto  giveVipDto) {
        TAppUser nowUser = appUserService.getById(giveVipDto.getUserId());
        //如果vipEndTime为空或已过期,直接增加
        if (nowUser.getVipEndTime()==null||nowUser.getVipEndTime().isBefore(LocalDateTime.now())) {
            if (giveVipDto.getType() == 1) {
                nowUser.setVipEndTime(LocalDateTime.now().plusDays(31));
                //直接增加vipDetail
            } else if (giveVipDto.getType() == 2) {
                nowUser.setVipEndTime(LocalDateTime.now().plusDays(93));
            } else if (giveVipDto.getType() == 3) {
                nowUser.setVipEndTime(LocalDateTime.now().plusDays(365));
            }
            //直接赠送优惠卷
        }else {
            if (giveVipDto.getType() == 1) {
                nowUser.setVipEndTime(nowUser.getVipEndTime().plusDays(31));
                //如果有这个类型的vip,累加,没有的话,从entTime新增
            } else if (giveVipDto.getType() == 2) {
                nowUser.setVipEndTime(nowUser.getVipEndTime().plusDays(93));
            } else if (giveVipDto.getType() == 3) {
                nowUser.setVipEndTime(nowUser.getVipEndTime().plusDays(365));
            }
        int plusDay = 0;
        if (giveVipDto.getType() == 1) {
            plusDay = 31;
        } else if (giveVipDto.getType() == 2) {
            plusDay = 93;
        } else if (giveVipDto.getType() == 3) {
            plusDay = 365;
        }
        //增加vipDetail
        giveVipUtil.sendVip(nowUser, giveVipDto.getVipId(),plusDay);
        appUserService.updateById(nowUser);
        //执行一次赠送优惠卷的定时任务
        return R.ok();
    }
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/TAppUserVipDetailService.java
@@ -13,4 +13,5 @@
 */
public interface TAppUserVipDetailService extends IService<TAppUserVipDetail> {
    void giveVipCoupun(Long appUserId, Integer vipId);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/TAppUserVipDetailServiceImpl.java
@@ -18,4 +18,13 @@
@Service
public class TAppUserVipDetailServiceImpl extends ServiceImpl<TAppUserVipDetailMapper, TAppUserVipDetail> implements TAppUserVipDetailService {
    @Override
    public void giveVipCoupun(Long appUserId, Integer vipId) {
        //给这个用户发放对应vip的优惠卷以及充电次数加满
    }
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/TaskUtil.java
New file
@@ -0,0 +1,67 @@
package com.ruoyi.account.task;
import com.ruoyi.account.api.model.TAppUserVipDetail;
import com.ruoyi.account.service.TAppUserVipDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;
/**
 * 定时任务工具类
 */
@Component
public class TaskUtil {
    @Resource
    private TAppUserVipDetailService tAppUserVipDetailService;
    /**
     * 每隔一分钟去处理的定时任务
     */
    @Scheduled(fixedRate = 1000 * 60)
    public void sendVipCoupon(){
        try {
            //首先获取当前的月份,用int类型标识
            LocalDate currentDate = LocalDate.now();
            int monthNum = currentDate.getMonthValue();
            //获取在当前时间内生效的vipDetail
            List<TAppUserVipDetail> recentDetails = tAppUserVipDetailService.lambdaQuery()
                    .ge(TAppUserVipDetail::getStartTime, currentDate)
                    .le(TAppUserVipDetail::getEndTime, currentDate)
                    .orderByDesc(TAppUserVipDetail::getStartTime).list();
            //判断sendNum是否包括当前月份
            for (TAppUserVipDetail recentDetail : recentDetails) {
                if (recentDetail.getSendMonth()!=null&&recentDetail.getSendMonth().contains(monthNum+"")){
                    //如果包含,则不执行操作
                    continue;
                }else {
                    //如果不包含,则更新sendNum,并且赠送优惠卷
                    TAppUserVipDetail byId = tAppUserVipDetailService.getById(recentDetail.getId());
                    if (byId==null){
                        byId.setSendMonth(byId.getSendMonth()+monthNum);
                    }else{
                        byId.setSendMonth(","+byId.getSendMonth()+monthNum);
                    }
                    tAppUserVipDetailService.updateById(byId);
                    //赠送优惠卷
                    tAppUserVipDetailService.giveVipCoupun(recentDetail.getAppUserId(), recentDetail.getVipId());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/GiveVipUtil.java
New file
@@ -0,0 +1,45 @@
package com.ruoyi.account.util;
import com.ruoyi.account.api.model.TAppUser;
import com.ruoyi.account.api.model.TAppUserVipDetail;
import com.ruoyi.account.service.TAppUserVipDetailService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
@Component
public class GiveVipUtil {
    @Resource
    private TAppUserVipDetailService tAppUserVipDetailService;
    public void sendVip(TAppUser nowUser,Integer vipId,Integer plusDay){
        if (nowUser.getVipEndTime()==null||nowUser.getVipEndTime().isBefore(LocalDateTime.now())) {
            nowUser.setVipEndTime(LocalDateTime.now().plusDays(plusDay));
            //直接再detail里新增数据,因为不是续费
            TAppUserVipDetail tAppUserVipDetail = new TAppUserVipDetail();
            tAppUserVipDetail.setAppUserId(nowUser.getId());
            tAppUserVipDetail.setStartTime(LocalDateTime.now());
            tAppUserVipDetail.setEndTime(LocalDateTime.now().plusDays(plusDay));
            tAppUserVipDetail.setVipId(vipId);
            tAppUserVipDetailService.save(tAppUserVipDetail);
            //直接赠送优惠卷
        }else {
            nowUser.setVipEndTime(nowUser.getVipEndTime().plusDays(plusDay));
            //获取detail里结束时间大于当前时间的数据,并将enttime延长
            TAppUserVipDetail tAppUserVipDetail = tAppUserVipDetailService.lambdaQuery().eq(TAppUserVipDetail::getAppUserId, nowUser.getId()).orderByDesc(TAppUserVipDetail::getEndTime).last("limit 1").one();
            TAppUserVipDetail newAppUser = new TAppUserVipDetail();
            newAppUser.setAppUserId(nowUser.getId());
            newAppUser.setStartTime(tAppUserVipDetail.getEndTime());
            newAppUser.setEndTime(tAppUserVipDetail.getEndTime().plusDays(plusDay));
            newAppUser.setVipId(vipId);
            tAppUserVipDetailService.save(newAppUser);
//                tAppUserVipDetail.setEndTime(tAppUserVipDetail.getEndTime().plusDays(plusDay));
//                tAppUserVipDetailService.updateById(tAppUserVipDetail);
        }
    }
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyController.java
@@ -163,10 +163,10 @@
            }
            
        }
        return AjaxResult.ok(accountingStrategyService.pageList(query));
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/THtmlController.java
@@ -1,9 +1,14 @@
package com.ruoyi.other.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.other.api.domain.THtml;
import com.ruoyi.other.api.domain.TNotice;
import com.ruoyi.other.service.THtmlService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * <p>
@@ -16,6 +21,21 @@
@RestController
@RequestMapping("/t-html")
public class THtmlController {
    @Resource
    private THtmlService htmlService;
    @ApiOperation(tags = {"后台-内容设置-协议服务"},value = "新增修改")
    @PostMapping(value = "/saveOrUpdate")
    public AjaxResult saveOrUpdate(@RequestBody THtml tHtml) {
        htmlService.saveOrUpdate(tHtml);
    return AjaxResult.success();
    }
    @ApiOperation(tags = {"后台-内容设置-协议服务"},value = "查询")
    @PostMapping(value = "/selectByType/{type}")
    public AjaxResult selectByType(@PathVariable Integer type) {
        THtml one = htmlService.lambdaQuery().eq(THtml::getType, type).last("limit 1").one();
        return AjaxResult.success(one);
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TNoticeController.java
@@ -1,9 +1,17 @@
package com.ruoyi.other.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.other.api.domain.TNotice;
import com.ruoyi.other.api.dto.NoticeQueryDto;
import com.ruoyi.other.mapper.SysNoticeMapper;
import com.ruoyi.other.service.TNoticeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
 * <p>
@@ -16,6 +24,49 @@
@RestController
@RequestMapping("/t-notice")
public class TNoticeController {
    @Resource
    private TNoticeService noticeService;
    @ApiOperation(tags = {"后台-内容设置-公告管理"},value = "新增修改")
    @PostMapping(value = "/saveOrUpdate")
    public AjaxResult saveOrUpdate(@RequestBody TNotice notice) {
        noticeService.saveOrUpdate(notice);
        return AjaxResult.success();
    }
    @ApiOperation(tags = {"后台-内容设置-公告管理"},value = "删除")
    @PostMapping(value = "/deleteById/{id}")
    public AjaxResult deleteById(@PathVariable Integer id) {
        noticeService.removeById(id);
        return AjaxResult.success();
    }
    @ApiOperation(tags = {"后台-内容设置-公告管理"},value = "查询")
    @PostMapping(value = "/pageList")
    public AjaxResult<Page<TNotice>> authPageList(@RequestBody NoticeQueryDto query) {
            if (query.getStatus()==0){
                return AjaxResult.success(noticeService.lambdaQuery()
                        .le(TNotice::getStartTime, LocalDateTime.now())
                        .like(query.getContent()!=null&&query.getContent()!="",TNotice::getContent,query.getContent())
                        .page(Page.of(query.getPageCurr(),query.getPageSize())));
            }else if (query.getStatus()==1){
                return AjaxResult.success(noticeService.lambdaQuery()
                        .ge(TNotice::getStartTime, LocalDateTime.now()).le(TNotice::getEndTime,LocalDateTime.now())
                        .like(query.getContent()!=null&&query.getContent()!="",TNotice::getContent,query.getContent())
                        .page(Page.of(query.getPageCurr(),query.getPageSize())));
            }else if (query.getStatus()==2){
                return AjaxResult.success(noticeService.lambdaQuery()
                        .ge(TNotice::getEndTime, LocalDateTime.now())
                        .like(query.getContent()!=null&&query.getContent()!="",TNotice::getContent,query.getContent())
                        .page(Page.of(query.getPageCurr(),query.getPageSize())));
            }else{
                return AjaxResult.success(noticeService.lambdaQuery()
                        .like(query.getContent()!=null&&query.getContent()!="",TNotice::getContent,query.getContent())
                        .page(Page.of(query.getPageCurr(),query.getPageSize())));
        }
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TSystemConfigurationController.java
@@ -7,11 +7,7 @@
import com.ruoyi.other.service.TSystemConfigurationService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
 * <p>
@@ -35,12 +31,19 @@
    /**
     * 查看系统设置
     */
    @ApiOperation(tags = {"小程序-系统设置"},value = "联系客服")
    @ApiOperation(tags = {"小程序-系统设置","后台-内容设置"},value = "联系客服,查询设置")
    @GetMapping(value = "/getDetailById")
    public AjaxResult<TSystemConfiguration> getDetailById(@RequestParam(name = "type",value = "1=客服信息,2=系统设置") Integer type) {
        return AjaxResult.ok(systemConfigurationService.getOne(Wrappers.lambdaQuery(TSystemConfiguration.class)
                .eq(TSystemConfiguration::getType, type)));
    }
    @ApiOperation(tags = {"后台-内容设置"},value = "客户信息,系统内容设置")
    @GetMapping(value = "/save")
    public AjaxResult getDetailById(@RequestBody TSystemConfiguration systemConfiguration) {
        systemConfigurationService.saveOrUpdate(systemConfiguration);
        return AjaxResult.success();
    }
}