新增订单表

This commit is contained in:
gxwebsoft
2024-04-24 13:51:44 +08:00
parent f6a4d20a73
commit fffb3f97f9
8 changed files with 657 additions and 1 deletions

View File

@@ -0,0 +1,132 @@
package com.gxwebsoft.common.system.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.service.OrderService;
import com.gxwebsoft.common.system.entity.Order;
import com.gxwebsoft.common.system.param.OrderParam;
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 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-04-24 13:46:21
*/
@Api(tags = "订单管理")
@RestController
@RequestMapping("/api/system/order")
public class OrderController extends BaseController {
@Resource
private OrderService orderService;
@PreAuthorize("hasAuthority('sys:order:list')")
@OperationLog
@ApiOperation("分页查询订单")
@GetMapping("/page")
public ApiResult<PageResult<Order>> page(OrderParam param) {
// 使用关联查询
return success(orderService.pageRel(param));
}
@PreAuthorize("hasAuthority('sys:order:list')")
@OperationLog
@ApiOperation("查询全部订单")
@GetMapping()
public ApiResult<List<Order>> list(OrderParam param) {
// 使用关联查询
return success(orderService.listRel(param));
}
@PreAuthorize("hasAuthority('sys:order:list')")
@OperationLog
@ApiOperation("根据id查询订单")
@GetMapping("/{id}")
public ApiResult<Order> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(orderService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('sys:order:save')")
@OperationLog
@ApiOperation("添加订单")
@PostMapping()
public ApiResult<?> save(@RequestBody Order order) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
order.setUserId(loginUser.getUserId());
}
if (orderService.save(order)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('sys:order:update')")
@OperationLog
@ApiOperation("修改订单")
@PutMapping()
public ApiResult<?> update(@RequestBody Order order) {
if (orderService.updateById(order)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:order:remove')")
@OperationLog
@ApiOperation("删除订单")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (orderService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('sys:order:save')")
@OperationLog
@ApiOperation("批量添加订单")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<Order> list) {
if (orderService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('sys:order:update')")
@OperationLog
@ApiOperation("批量修改订单")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<Order> batchParam) {
if (batchParam.update(orderService, "order_id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:order:remove')")
@OperationLog
@ApiOperation("批量删除订单")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (orderService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

View File

@@ -0,0 +1,137 @@
package com.gxwebsoft.common.system.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.*;
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-04-24 13:46:21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "Order对象", description = "订单")
@TableName("sys_order")
public class Order implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@TableId(value = "order_id", type = IdType.AUTO)
private Integer orderId;
@ApiModelProperty(value = "订单号")
private String orderNo;
@ApiModelProperty(value = "类型")
private Integer type;
@ApiModelProperty(value = "订单金额")
private BigDecimal money;
@ApiModelProperty(value = "实际付款金额(包含运费)")
private BigDecimal payPrice;
@ApiModelProperty(value = "套餐ID")
private Integer planId;
@ApiModelProperty(value = "卡ID")
private Integer priceId;
@ApiModelProperty(value = "获得的会员等级")
private Integer gradeId;
@ApiModelProperty(value = "卡名称")
private String priceName;
@ApiModelProperty(value = "用户ID")
private Integer userId;
@ApiModelProperty(value = "持有者ID")
private Integer memberId;
@ApiModelProperty(value = "真实姓名")
private String realName;
@ApiModelProperty(value = "联系电话")
private String phone;
@ApiModelProperty(value = "付款时间")
private LocalDateTime payTime;
@ApiModelProperty(value = "支付流水号")
private String transactionId;
@ApiModelProperty(value = "付款状态(10未付款 20已付款)")
private Integer payStatus;
@ApiModelProperty(value = "支付方式(余额/微信/支付宝)")
private String payMethod;
@ApiModelProperty(value = "到期时间")
private LocalDateTime expirationTime;
@ApiModelProperty(value = "所在省份")
private String province;
@ApiModelProperty(value = "所在城市")
private String city;
@ApiModelProperty(value = "所在辖区")
private String region;
@ApiModelProperty(value = "所在地区")
private String area;
@ApiModelProperty(value = "街道地址")
private String address;
@ApiModelProperty(value = "退款凭证")
private String refundImage;
@ApiModelProperty(value = "退款理由")
private String refundContent;
@ApiModelProperty(value = "订单是否已结算(0未结算 1已结算)")
private Integer isSettled;
@ApiModelProperty(value = "排序(数字越小越靠前)")
private Integer sortNumber;
@ApiModelProperty(value = "商户ID")
private Integer merchantId;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "状态, 0正常, 1冻结")
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "昵称")
@TableField(exist = false)
private String nickname;
}

View File

@@ -0,0 +1,37 @@
package com.gxwebsoft.common.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.common.system.entity.Order;
import com.gxwebsoft.common.system.param.OrderParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 订单Mapper
*
* @author 科技小王子
* @since 2024-04-24 13:46:21
*/
public interface OrderMapper extends BaseMapper<Order> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<Order>
*/
List<Order> selectPageRel(@Param("page") IPage<Order> page,
@Param("param") OrderParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<Order> selectListRel(@Param("param") OrderParam param);
}

View File

@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.common.system.mapper.OrderMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM sys_order a
<where>
<if test="param.orderId != null">
AND a.order_id = #{param.orderId}
</if>
<if test="param.orderNo != null">
AND a.order_no LIKE CONCAT('%', #{param.orderNo}, '%')
</if>
<if test="param.type != null">
AND a.type = #{param.type}
</if>
<if test="param.money != null">
AND a.money = #{param.money}
</if>
<if test="param.payPrice != null">
AND a.pay_price = #{param.payPrice}
</if>
<if test="param.planId != null">
AND a.plan_id = #{param.planId}
</if>
<if test="param.priceId != null">
AND a.price_id = #{param.priceId}
</if>
<if test="param.gradeId != null">
AND a.grade_id = #{param.gradeId}
</if>
<if test="param.priceName != null">
AND a.price_name LIKE CONCAT('%', #{param.priceName}, '%')
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.memberId != null">
AND a.member_id = #{param.memberId}
</if>
<if test="param.realName != null">
AND a.real_name LIKE CONCAT('%', #{param.realName}, '%')
</if>
<if test="param.phone != null">
AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
</if>
<if test="param.payTime != null">
AND a.pay_time LIKE CONCAT('%', #{param.payTime}, '%')
</if>
<if test="param.transactionId != null">
AND a.transaction_id LIKE CONCAT('%', #{param.transactionId}, '%')
</if>
<if test="param.payStatus != null">
AND a.pay_status = #{param.payStatus}
</if>
<if test="param.payMethod != null">
AND a.pay_method LIKE CONCAT('%', #{param.payMethod}, '%')
</if>
<if test="param.expirationTime != null">
AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%')
</if>
<if test="param.province != null">
AND a.province LIKE CONCAT('%', #{param.province}, '%')
</if>
<if test="param.city != null">
AND a.city LIKE CONCAT('%', #{param.city}, '%')
</if>
<if test="param.region != null">
AND a.region LIKE CONCAT('%', #{param.region}, '%')
</if>
<if test="param.area != null">
AND a.area LIKE CONCAT('%', #{param.area}, '%')
</if>
<if test="param.address != null">
AND a.address LIKE CONCAT('%', #{param.address}, '%')
</if>
<if test="param.refundImage != null">
AND a.refund_image LIKE CONCAT('%', #{param.refundImage}, '%')
</if>
<if test="param.refundContent != null">
AND a.refund_content LIKE CONCAT('%', #{param.refundContent}, '%')
</if>
<if test="param.isSettled != null">
AND a.is_settled = #{param.isSettled}
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.merchantId != null">
AND a.merchant_id = #{param.merchantId}
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.common.system.entity.Order">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.common.system.entity.Order">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -0,0 +1,135 @@
package com.gxwebsoft.common.system.param;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 订单查询参数
*
* @author 科技小王子
* @since 2024-04-24 13:46:21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "OrderParam对象", description = "订单查询参数")
public class OrderParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@QueryField(type = QueryType.EQ)
private Integer orderId;
@ApiModelProperty(value = "订单号")
private String orderNo;
@ApiModelProperty(value = "类型")
@QueryField(type = QueryType.EQ)
private Integer type;
@ApiModelProperty(value = "订单金额")
@QueryField(type = QueryType.EQ)
private BigDecimal money;
@ApiModelProperty(value = "实际付款金额(包含运费)")
@QueryField(type = QueryType.EQ)
private BigDecimal payPrice;
@ApiModelProperty(value = "套餐ID")
@QueryField(type = QueryType.EQ)
private Integer planId;
@ApiModelProperty(value = "卡ID")
@QueryField(type = QueryType.EQ)
private Integer priceId;
@ApiModelProperty(value = "获得的会员等级")
@QueryField(type = QueryType.EQ)
private Integer gradeId;
@ApiModelProperty(value = "卡名称")
private String priceName;
@ApiModelProperty(value = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
@ApiModelProperty(value = "持有者ID")
@QueryField(type = QueryType.EQ)
private Integer memberId;
@ApiModelProperty(value = "真实姓名")
private String realName;
@ApiModelProperty(value = "联系电话")
private String phone;
@ApiModelProperty(value = "付款时间")
private String payTime;
@ApiModelProperty(value = "支付流水号")
private String transactionId;
@ApiModelProperty(value = "付款状态(10未付款 20已付款)")
@QueryField(type = QueryType.EQ)
private Integer payStatus;
@ApiModelProperty(value = "支付方式(余额/微信/支付宝)")
private String payMethod;
@ApiModelProperty(value = "到期时间")
private String expirationTime;
@ApiModelProperty(value = "所在省份")
private String province;
@ApiModelProperty(value = "所在城市")
private String city;
@ApiModelProperty(value = "所在辖区")
private String region;
@ApiModelProperty(value = "所在地区")
private String area;
@ApiModelProperty(value = "街道地址")
private String address;
@ApiModelProperty(value = "退款凭证")
private String refundImage;
@ApiModelProperty(value = "退款理由")
private String refundContent;
@ApiModelProperty(value = "订单是否已结算(0未结算 1已结算)")
@QueryField(type = QueryType.EQ)
private Integer isSettled;
@ApiModelProperty(value = "排序(数字越小越靠前)")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@ApiModelProperty(value = "商户ID")
@QueryField(type = QueryType.EQ)
private Integer merchantId;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "状态, 0正常, 1冻结")
@QueryField(type = QueryType.EQ)
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}

View File

@@ -0,0 +1,42 @@
package com.gxwebsoft.common.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Order;
import com.gxwebsoft.common.system.param.OrderParam;
import java.util.List;
/**
* 订单Service
*
* @author 科技小王子
* @since 2024-04-24 13:46:21
*/
public interface OrderService extends IService<Order> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<Order>
*/
PageResult<Order> pageRel(OrderParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<Order>
*/
List<Order> listRel(OrderParam param);
/**
* 根据id查询
*
* @param orderId ID
* @return Order
*/
Order getByIdRel(Integer orderId);
}

View File

@@ -0,0 +1,47 @@
package com.gxwebsoft.common.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.OrderMapper;
import com.gxwebsoft.common.system.service.OrderService;
import com.gxwebsoft.common.system.entity.Order;
import com.gxwebsoft.common.system.param.OrderParam;
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-04-24 13:46:21
*/
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
@Override
public PageResult<Order> pageRel(OrderParam param) {
PageParam<Order, OrderParam> page = new PageParam<>(param);
//page.setDefaultOrder("create_time desc");
List<Order> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<Order> listRel(OrderParam param) {
List<Order> list = baseMapper.selectListRel(param);
// 排序
PageParam<Order, OrderParam> page = new PageParam<>();
//page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}
@Override
public Order getByIdRel(Integer orderId) {
OrderParam param = new OrderParam();
param.setOrderId(orderId);
return param.getOne(baseMapper.selectListRel(param));
}
}

View File

@@ -65,7 +65,8 @@ public class SysGenerator {
// "sys_app_url",
// "sys_app_renew"
// "sys_version",
"sys_white_domain"
// "sys_white_domain"
"sys_order"
};
// 需要去除的表前缀
private static final String[] TABLE_PREFIX = new String[]{