From 9e3ac0a152f35f9532b6d3fdaa235a7a5c3b6223 Mon Sep 17 00:00:00 2001 From: gxwebsoft Date: Sat, 8 Jun 2024 23:38:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../booking/controller/StudentController.java | 115 ++++++++++++++++++ .../com/gxwebsoft/booking/entity/Student.java | 84 +++++++++++++ .../booking/mapper/StudentMapper.java | 37 ++++++ .../booking/mapper/xml/StudentMapper.xml | 81 ++++++++++++ .../gxwebsoft/booking/param/StudentParam.java | 80 ++++++++++++ .../booking/service/StudentService.java | 42 +++++++ .../service/impl/StudentServiceImpl.java | 47 +++++++ .../controller/WxPayNotifyController.java | 4 + .../shop/service/impl/OrderServiceImpl.java | 16 +++ .../gxwebsoft/generator/BookingGenerator.java | 5 +- 10 files changed, 509 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/gxwebsoft/booking/controller/StudentController.java create mode 100644 src/main/java/com/gxwebsoft/booking/entity/Student.java create mode 100644 src/main/java/com/gxwebsoft/booking/mapper/StudentMapper.java create mode 100644 src/main/java/com/gxwebsoft/booking/mapper/xml/StudentMapper.xml create mode 100644 src/main/java/com/gxwebsoft/booking/param/StudentParam.java create mode 100644 src/main/java/com/gxwebsoft/booking/service/StudentService.java create mode 100644 src/main/java/com/gxwebsoft/booking/service/impl/StudentServiceImpl.java diff --git a/src/main/java/com/gxwebsoft/booking/controller/StudentController.java b/src/main/java/com/gxwebsoft/booking/controller/StudentController.java new file mode 100644 index 0000000..c5432fc --- /dev/null +++ b/src/main/java/com/gxwebsoft/booking/controller/StudentController.java @@ -0,0 +1,115 @@ +package com.gxwebsoft.booking.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.booking.service.StudentService; +import com.gxwebsoft.booking.entity.Student; +import com.gxwebsoft.booking.param.StudentParam; +import com.gxwebsoft.common.core.web.ApiResult; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.BatchParam; +import com.gxwebsoft.common.core.annotation.OperationLog; +import com.gxwebsoft.common.system.entity.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 学生管理控制器 + * + * @author 科技小王子 + * @since 2024-06-08 23:37:11 + */ +@Api(tags = "学生管理管理") +@RestController +@RequestMapping("/api/booking/student") +public class StudentController extends BaseController { + @Resource + private StudentService studentService; + + @ApiOperation("分页查询学生管理") + @GetMapping("/page") + public ApiResult> page(StudentParam param) { + // 使用关联查询 + return success(studentService.pageRel(param)); + } + + @ApiOperation("查询全部学生管理") + @GetMapping() + public ApiResult> list(StudentParam param) { + // 使用关联查询 + return success(studentService.listRel(param)); + } + + @PreAuthorize("hasAuthority('booking:student:list')") + @ApiOperation("根据id查询学生管理") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(studentService.getByIdRel(id)); + } + + @ApiOperation("添加学生管理") + @PostMapping() + public ApiResult save(@RequestBody Student student) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + student.setUserId(loginUser.getUserId()); + } + if (studentService.save(student)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改学生管理") + @PutMapping() + public ApiResult update(@RequestBody Student student) { + if (studentService.updateById(student)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除学生管理") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (studentService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加学生管理") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (studentService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改学生管理") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(studentService, "student_id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除学生管理") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (studentService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/booking/entity/Student.java b/src/main/java/com/gxwebsoft/booking/entity/Student.java new file mode 100644 index 0000000..cc15ac2 --- /dev/null +++ b/src/main/java/com/gxwebsoft/booking/entity/Student.java @@ -0,0 +1,84 @@ +package com.gxwebsoft.booking.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import java.time.LocalDate; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import java.io.Serializable; +import java.util.Date; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 学生管理 + * + * @author 科技小王子 + * @since 2024-06-08 23:37:11 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "Student对象", description = "学生管理") +@TableName("booking_student") +public class Student implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "ID") + @TableId(value = "student_id", type = IdType.AUTO) + private Integer studentId; + + @ApiModelProperty(value = "手机号") + private String phone; + + @ApiModelProperty(value = "学生姓名") + private String studentName; + + @ApiModelProperty(value = "学生头像") + private String image; + + @ApiModelProperty(value = "老师介绍") + private String content; + + @ApiModelProperty(value = "性别") + private Integer sex; + + @ApiModelProperty(value = "出生年月") + private LocalDate birthday; + + @ApiModelProperty(value = "证件号码") + private String idCard; + + @ApiModelProperty(value = "服装尺寸") + private String clothingSize; + + @ApiModelProperty(value = "身高") + private String height; + + @ApiModelProperty(value = "体重") + private String weight; + + @ApiModelProperty(value = "关联家长ID") + private Integer userId; + + @ApiModelProperty(value = "商户ID") + private Integer merchantId; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "状态") + private Integer status; + + @ApiModelProperty(value = "排序号") + private Integer sortNumber; + + @ApiModelProperty(value = "租户id") + private Integer tenantId; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + +} diff --git a/src/main/java/com/gxwebsoft/booking/mapper/StudentMapper.java b/src/main/java/com/gxwebsoft/booking/mapper/StudentMapper.java new file mode 100644 index 0000000..f59d911 --- /dev/null +++ b/src/main/java/com/gxwebsoft/booking/mapper/StudentMapper.java @@ -0,0 +1,37 @@ +package com.gxwebsoft.booking.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gxwebsoft.booking.entity.Student; +import com.gxwebsoft.booking.param.StudentParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 学生管理Mapper + * + * @author 科技小王子 + * @since 2024-06-08 23:37:11 + */ +public interface StudentMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") StudentParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") StudentParam param); + +} diff --git a/src/main/java/com/gxwebsoft/booking/mapper/xml/StudentMapper.xml b/src/main/java/com/gxwebsoft/booking/mapper/xml/StudentMapper.xml new file mode 100644 index 0000000..fff62f8 --- /dev/null +++ b/src/main/java/com/gxwebsoft/booking/mapper/xml/StudentMapper.xml @@ -0,0 +1,81 @@ + + + + + + + SELECT a.* + FROM booking_student a + + + AND a.student_id = #{param.studentId} + + + AND a.phone LIKE CONCAT('%', #{param.phone}, '%') + + + AND a.student_name LIKE CONCAT('%', #{param.studentName}, '%') + + + AND a.image LIKE CONCAT('%', #{param.image}, '%') + + + AND a.content LIKE CONCAT('%', #{param.content}, '%') + + + AND a.sex = #{param.sex} + + + AND a.birthday LIKE CONCAT('%', #{param.birthday}, '%') + + + AND a.id_card LIKE CONCAT('%', #{param.idCard}, '%') + + + AND a.clothing_size LIKE CONCAT('%', #{param.clothingSize}, '%') + + + AND a.height LIKE CONCAT('%', #{param.height}, '%') + + + AND a.weight LIKE CONCAT('%', #{param.weight}, '%') + + + AND a.user_id = #{param.userId} + + + AND a.merchant_id = #{param.merchantId} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.status = #{param.status} + + + AND a.sort_number = #{param.sortNumber} + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/booking/param/StudentParam.java b/src/main/java/com/gxwebsoft/booking/param/StudentParam.java new file mode 100644 index 0000000..5d3b127 --- /dev/null +++ b/src/main/java/com/gxwebsoft/booking/param/StudentParam.java @@ -0,0 +1,80 @@ +package com.gxwebsoft.booking.param; + +import java.math.BigDecimal; +import com.gxwebsoft.common.core.annotation.QueryField; +import com.gxwebsoft.common.core.annotation.QueryType; +import com.gxwebsoft.common.core.web.BaseParam; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 学生管理查询参数 + * + * @author 科技小王子 + * @since 2024-06-08 23:37:11 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "StudentParam对象", description = "学生管理查询参数") +public class StudentParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "ID") + @QueryField(type = QueryType.EQ) + private Integer studentId; + + @ApiModelProperty(value = "手机号") + private String phone; + + @ApiModelProperty(value = "学生姓名") + private String studentName; + + @ApiModelProperty(value = "学生头像") + private String image; + + @ApiModelProperty(value = "老师介绍") + private String content; + + @ApiModelProperty(value = "性别") + @QueryField(type = QueryType.EQ) + private Integer sex; + + @ApiModelProperty(value = "出生年月") + private String birthday; + + @ApiModelProperty(value = "证件号码") + private String idCard; + + @ApiModelProperty(value = "服装尺寸") + private String clothingSize; + + @ApiModelProperty(value = "身高") + private String height; + + @ApiModelProperty(value = "体重") + private String weight; + + @ApiModelProperty(value = "关联家长ID") + @QueryField(type = QueryType.EQ) + private Integer userId; + + @ApiModelProperty(value = "商户ID") + @QueryField(type = QueryType.EQ) + private Integer merchantId; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "状态") + @QueryField(type = QueryType.EQ) + private Integer status; + + @ApiModelProperty(value = "排序号") + @QueryField(type = QueryType.EQ) + private Integer sortNumber; + +} diff --git a/src/main/java/com/gxwebsoft/booking/service/StudentService.java b/src/main/java/com/gxwebsoft/booking/service/StudentService.java new file mode 100644 index 0000000..217c4b9 --- /dev/null +++ b/src/main/java/com/gxwebsoft/booking/service/StudentService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.booking.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.booking.entity.Student; +import com.gxwebsoft.booking.param.StudentParam; + +import java.util.List; + +/** + * 学生管理Service + * + * @author 科技小王子 + * @since 2024-06-08 23:37:11 + */ +public interface StudentService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(StudentParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(StudentParam param); + + /** + * 根据id查询 + * + * @param studentId ID + * @return Student + */ + Student getByIdRel(Integer studentId); + +} diff --git a/src/main/java/com/gxwebsoft/booking/service/impl/StudentServiceImpl.java b/src/main/java/com/gxwebsoft/booking/service/impl/StudentServiceImpl.java new file mode 100644 index 0000000..925bcf3 --- /dev/null +++ b/src/main/java/com/gxwebsoft/booking/service/impl/StudentServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.booking.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.booking.mapper.StudentMapper; +import com.gxwebsoft.booking.service.StudentService; +import com.gxwebsoft.booking.entity.Student; +import com.gxwebsoft.booking.param.StudentParam; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.PageResult; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 学生管理Service实现 + * + * @author 科技小王子 + * @since 2024-06-08 23:37:11 + */ +@Service +public class StudentServiceImpl extends ServiceImpl implements StudentService { + + @Override + public PageResult pageRel(StudentParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(StudentParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public Student getByIdRel(Integer studentId) { + StudentParam param = new StudentParam(); + param.setStudentId(studentId); + return param.getOne(baseMapper.selectListRel(param)); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/controller/WxPayNotifyController.java b/src/main/java/com/gxwebsoft/shop/controller/WxPayNotifyController.java index 4ad8425..21f89fe 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/WxPayNotifyController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/WxPayNotifyController.java @@ -4,11 +4,15 @@ import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.gxwebsoft.booking.entity.UserCard; import com.gxwebsoft.booking.service.UserCardService; +import com.gxwebsoft.cms.entity.Website; +import com.gxwebsoft.cms.entity.WebsiteField; import com.gxwebsoft.common.core.config.ConfigProperties; +import com.gxwebsoft.common.core.security.JwtUtil; import com.gxwebsoft.common.core.utils.RedisUtil; import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.shop.entity.Order; diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/OrderServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/OrderServiceImpl.java index b134ae7..4edb3f3 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/OrderServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/OrderServiceImpl.java @@ -12,6 +12,8 @@ import com.gxwebsoft.booking.entity.UserCard; import com.gxwebsoft.booking.entity.UserCardLog; import com.gxwebsoft.booking.service.UserCardLogService; import com.gxwebsoft.booking.service.UserCardService; +import com.gxwebsoft.cms.entity.Website; +import com.gxwebsoft.cms.entity.WebsiteField; import com.gxwebsoft.common.core.config.ConfigProperties; import com.gxwebsoft.common.core.exception.BusinessException; import com.gxwebsoft.common.core.security.JwtUtil; @@ -277,7 +279,21 @@ public class OrderServiceImpl extends ServiceImpl implements requestUtil.setTenantId(order.getTenantId().toString()); String api = "/system/user/updateUserBalance"; // 更新余额接口 final BigDecimal subtract = loginUser.getBalance().subtract(order.getTotalPrice()); + loginUser.setBalance(subtract); + // 累加会员积分 + String key = "SiteInfo:" + order.getTenantId(); + final String siteInfo = redisUtil.get(key); + // 从缓存读取信息 + if(StrUtil.isNotBlank(siteInfo)){ + final Website website = JSONObject.parseObject(siteInfo, Website.class); + final List fields = website.getFields(); + fields.forEach(d -> { + if(d.getName().equals("integral_enabled") && d.getValue().equals("1")){ + loginUser.setPoints(loginUser.getPoints() + order.getPayPrice().intValue()); + } + }); + } final ApiResult apiResult = requestUtil.updateUserBalance(api, loginUser); if (apiResult.getCode().equals(0)) { // 记录余额明细 diff --git a/src/test/java/com/gxwebsoft/generator/BookingGenerator.java b/src/test/java/com/gxwebsoft/generator/BookingGenerator.java index 230f090..a05f78f 100644 --- a/src/test/java/com/gxwebsoft/generator/BookingGenerator.java +++ b/src/test/java/com/gxwebsoft/generator/BookingGenerator.java @@ -62,8 +62,9 @@ public class BookingGenerator { // "booking_user_card", // "booking_user_card_log", // "booking_item", - "booking_course", - "booking_course_category" +// "booking_course", +// "booking_course_category", + "booking_student" }; // 需要去除的表前缀 private static final String[] TABLE_PREFIX = new String[]{