vip查询

master
zcx 2023-10-18 17:34:43 +08:00
parent 74d8f55541
commit c4692e2d75
9 changed files with 239 additions and 6 deletions

View File

@ -29,7 +29,8 @@ public class CorsConfig implements WebMvcConfigurer {
"/error",
"/webjars/**",
"/doc.html",
"/tdQuestion/duima/*");
"/tdQuestion/duima/*",
"/tdSysUserMember/duima/**");
}

View File

@ -1,10 +1,35 @@
package com.jwl.driver.server.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jwl.driver.server.dto.MemberQueryDto;
import com.jwl.driver.server.dto.UserMemberDto;
import com.jwl.driver.server.entity.TdSysUser;
import com.jwl.driver.server.entity.TdSysUserMember;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.response.BaseResponse;
import com.jwl.driver.server.service.ITdCarService;
import com.jwl.driver.server.service.ITdMemberService;
import com.jwl.driver.server.service.ITdSysUserMemberService;
import com.jwl.driver.server.service.ITdSysUserService;
import com.jwl.driver.server.vo.MemberVo;
import com.jwl.driver.server.vo.UserMemberVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.User;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
* ;
@ -13,8 +38,87 @@ import org.springframework.stereotype.Controller;
* @author Automated procedures
* @since 2023-08-10
*/
@Controller
@RequestMapping("//tdSysUserMember")
@RestController
@RequestMapping("/tdSysUserMember")
@Slf4j
@Api(tags = "用户会员")
public class TdSysUserMemberController {
@Resource
private ITdMemberService memberService;
@Resource
private ITdSysUserMemberService userMemberService;
@Resource
private ITdCarService tdCarService;
@Resource
private ITdSysUserService userService;
/**
*
* */
@ApiOperation("查询车型列表")
@GetMapping("/duima/car/list")
public Map getCarList(){
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("data", tdCarService.list());
return result;
}
/**
*
* */
@ApiOperation("查询会员类型列表")
@GetMapping("/duima/member/list")
public Map getMemberList(MemberQueryDto memberQueryDto){
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("data", memberService.queryMember(memberQueryDto));
return result;
}
//查询用户会员列表
@ApiOperation("查询会员用户列表")
@GetMapping("/duima/user/member/list")
public Map getUserMemberList(UserMemberDto userMemberDto){
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("data", userMemberService.queryUserMemberList(userMemberDto));
return result;
}
//新增会员
@ApiOperation("新增用户会员")
@PostMapping("/duima/user/member")
public Map addUserMember(@RequestBody UserMemberVo userMemberVo){
Map<String, Object> result = new HashMap<>();
final LocalDateTime nowTime = LocalDateTime.now();
//跟进手机号查询用户
LambdaQueryWrapper<TdSysUser> cond = new LambdaQueryWrapper<TdSysUser>()
.eq(TdSysUser::getPhone,userMemberVo.getPhone());
TdSysUser user = userService.getOne(cond);
if(user == null){
result.put("code", 500);
result.put("msg", "用户不存在");
return result;
}
TdSysUserMember userMember = new TdSysUserMember()
.setMemberId(userMemberVo.getMemberId())
.setUserId(user.getUserId())
.setCreateTime(nowTime)
.setUpdateTime(nowTime)
.setStartDate(LocalDateTime.of(LocalDate.now(), LocalTime.MIN))
.setEndDate(LocalDateTime.of(LocalDate.now(), LocalTime.MIN).plusDays(1).minusSeconds(1));
result.put("code", 200);
result.put("data", userMemberService.saveOrUpdate(userMember));
return result;
}
}

View File

@ -0,0 +1,9 @@
package com.jwl.driver.server.dto;
import lombok.Data;
@Data
public class UserMemberDto {
private String phone;
private Integer memberId;
}

View File

@ -1,7 +1,12 @@
package com.jwl.driver.server.mapper;
import com.jwl.driver.server.dto.UserMemberDto;
import com.jwl.driver.server.entity.TdSysUserMember;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jwl.driver.server.vo.UserMemberVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
@ -13,4 +18,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface TdSysUserMemberMapper extends BaseMapper<TdSysUserMember> {
List<UserMemberVo> queryUserMemberList(@Param("userMemberDto") UserMemberDto userMemberDto);
}

View File

@ -1,8 +1,12 @@
package com.jwl.driver.server.service;
import com.jwl.driver.server.dto.UserMemberDto;
import com.jwl.driver.server.entity.OrderPayInfo;
import com.jwl.driver.server.entity.TdSysUserMember;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jwl.driver.server.vo.UserMemberVo;
import java.util.List;
/**
* <p>
@ -20,4 +24,6 @@ public interface ITdSysUserMemberService extends IService<TdSysUserMember> {
* @return
*/
Boolean purchaseMember(OrderPayInfo payInfo);
List<UserMemberVo> queryUserMemberList(UserMemberDto userMemberDto);
}

View File

@ -2,6 +2,7 @@ package com.jwl.driver.server.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jwl.driver.server.dto.UserMemberDto;
import com.jwl.driver.server.entity.OrderPayInfo;
import com.jwl.driver.server.entity.TdMember;
import com.jwl.driver.server.entity.TdSysUserMember;
@ -12,6 +13,7 @@ import com.jwl.driver.server.service.ITdMemberService;
import com.jwl.driver.server.service.ITdSysUserMemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwl.driver.server.service.ITdSysUserService;
import com.jwl.driver.server.vo.UserMemberVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -19,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Objects;
/**
@ -92,4 +95,9 @@ public class TdSysUserMemberServiceImpl extends ServiceImpl<TdSysUserMemberMappe
}
return Boolean.TRUE;
}
@Override
public List<UserMemberVo> queryUserMemberList(UserMemberDto userMemberDto) {
return getBaseMapper().queryUserMemberList(userMemberDto);
}
}

View File

@ -0,0 +1,70 @@
package com.jwl.driver.server.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@Accessors(chain = true)
@ApiModel("用户学员")
public class UserMemberVo {
@ApiModelProperty("用户标识")
private Long userId;
@ApiModelProperty("手机号")
private String phone;
/**
*
*/
@ApiModelProperty("会员结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDate;
/**
*
*/
@ApiModelProperty("会员开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDate;
/**
*
*/
@ApiModelProperty("会员标识")
private Integer memberId;
/**
*
*/
@ApiModelProperty("会员名称")
private String memberName;
/**
*
*/
@ApiModelProperty("车型标识")
private Integer carTypeId;
@ApiModelProperty("车型")
private String carName;
/**
*
*/
@ApiModelProperty("科目")
private String subjects;
/**
*
*/
@ApiModelProperty("会员价格,单位元")
private BigDecimal price;
}

View File

@ -1,7 +1,7 @@
spring:
# redis 配置
redis:
host: 127.0.0.1
host: 118.31.23.45
port: 6973
database: 8
timeout: 5000
@ -9,6 +9,6 @@ spring:
# 数据库 配置
datasource:
url: jdbc:mysql://127.0.0.1:3306/driver_server?characterEncoding=utf-8&autoReconnect=true&maxReconnects=2&useSSL=false&allowPublicKeyRetrieval=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://118.31.23.45:3306/driver_server?characterEncoding=utf-8&autoReconnect=true&maxReconnects=2&useSSL=false&allowPublicKeyRetrieval=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai
username: root
password: admin231280

View File

@ -2,4 +2,33 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jwl.driver.server.mapper.TdSysUserMemberMapper">
<select id="queryUserMemberList" resultType="com.jwl.driver.server.vo.UserMemberVo">
select
tm.MEMBER_ID,
tm.MEMBER_NAME,
tm.CAR_TYPE_ID,
tm.PRICE,
tm.SUBJECTS,
su.USER_ID,
su.PHONE,
c.CAR_NAME,
um.START_DATE,
um.END_DATE
from
td_sys_user_member um
left join td_member tm on um.MEMBER_ID = tm.MEMBER_ID
left join td_sys_user su on su.USER_ID = um.USER_ID
left join td_car c on c.CAR_TYPE_ID = TM.CAR_TYPE_ID
<where>
<if test="userMemberDto.phone !=null">
and su.PHONE like concat("%" + #{userMemberDto.phone} + "%")
</if>
<if test="userMemberDto.memberId !=null">
and tm.MEMBER_ID = #{userMemberDto.memberId}
</if>
</where>
order by um.CREATE_TIME
</select>
</mapper>