diff --git a/src/main/java/com/gxwebsoft/common/system/controller/OrderController.java b/src/main/java/com/gxwebsoft/common/system/controller/OrderController.java new file mode 100644 index 0000000..9abd141 --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/controller/OrderController.java @@ -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> page(OrderParam param) { + // 使用关联查询 + return success(orderService.pageRel(param)); + } + + @PreAuthorize("hasAuthority('sys:order:list')") + @OperationLog + @ApiOperation("查询全部订单") + @GetMapping() + public ApiResult> list(OrderParam param) { + // 使用关联查询 + return success(orderService.listRel(param)); + } + + @PreAuthorize("hasAuthority('sys:order:list')") + @OperationLog + @ApiOperation("根据id查询订单") + @GetMapping("/{id}") + public ApiResult 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 list) { + if (orderService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @PreAuthorize("hasAuthority('sys:order:update')") + @OperationLog + @ApiOperation("批量修改订单") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam 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 ids) { + if (orderService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/common/system/entity/Order.java b/src/main/java/com/gxwebsoft/common/system/entity/Order.java new file mode 100644 index 0000000..f5ee634 --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/entity/Order.java @@ -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; + +} diff --git a/src/main/java/com/gxwebsoft/common/system/mapper/OrderMapper.java b/src/main/java/com/gxwebsoft/common/system/mapper/OrderMapper.java new file mode 100644 index 0000000..cef0bf2 --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/mapper/OrderMapper.java @@ -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 { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") OrderParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") OrderParam param); + +} diff --git a/src/main/java/com/gxwebsoft/common/system/mapper/xml/OrderMapper.xml b/src/main/java/com/gxwebsoft/common/system/mapper/xml/OrderMapper.xml new file mode 100644 index 0000000..80b1bc3 --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/mapper/xml/OrderMapper.xml @@ -0,0 +1,125 @@ + + + + + + + SELECT a.* + FROM sys_order a + + + AND a.order_id = #{param.orderId} + + + AND a.order_no LIKE CONCAT('%', #{param.orderNo}, '%') + + + AND a.type = #{param.type} + + + AND a.money = #{param.money} + + + AND a.pay_price = #{param.payPrice} + + + AND a.plan_id = #{param.planId} + + + AND a.price_id = #{param.priceId} + + + AND a.grade_id = #{param.gradeId} + + + AND a.price_name LIKE CONCAT('%', #{param.priceName}, '%') + + + AND a.user_id = #{param.userId} + + + AND a.member_id = #{param.memberId} + + + AND a.real_name LIKE CONCAT('%', #{param.realName}, '%') + + + AND a.phone LIKE CONCAT('%', #{param.phone}, '%') + + + AND a.pay_time LIKE CONCAT('%', #{param.payTime}, '%') + + + AND a.transaction_id LIKE CONCAT('%', #{param.transactionId}, '%') + + + AND a.pay_status = #{param.payStatus} + + + AND a.pay_method LIKE CONCAT('%', #{param.payMethod}, '%') + + + AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%') + + + AND a.province LIKE CONCAT('%', #{param.province}, '%') + + + AND a.city LIKE CONCAT('%', #{param.city}, '%') + + + AND a.region LIKE CONCAT('%', #{param.region}, '%') + + + AND a.area LIKE CONCAT('%', #{param.area}, '%') + + + AND a.address LIKE CONCAT('%', #{param.address}, '%') + + + AND a.refund_image LIKE CONCAT('%', #{param.refundImage}, '%') + + + AND a.refund_content LIKE CONCAT('%', #{param.refundContent}, '%') + + + AND a.is_settled = #{param.isSettled} + + + AND a.sort_number = #{param.sortNumber} + + + AND a.merchant_id = #{param.merchantId} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.status = #{param.status} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/common/system/param/OrderParam.java b/src/main/java/com/gxwebsoft/common/system/param/OrderParam.java new file mode 100644 index 0000000..3a16c42 --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/param/OrderParam.java @@ -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; + +} diff --git a/src/main/java/com/gxwebsoft/common/system/service/OrderService.java b/src/main/java/com/gxwebsoft/common/system/service/OrderService.java new file mode 100644 index 0000000..6d2c5b5 --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/service/OrderService.java @@ -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 { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(OrderParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(OrderParam param); + + /** + * 根据id查询 + * + * @param orderId ID + * @return Order + */ + Order getByIdRel(Integer orderId); + +} diff --git a/src/main/java/com/gxwebsoft/common/system/service/impl/OrderServiceImpl.java b/src/main/java/com/gxwebsoft/common/system/service/impl/OrderServiceImpl.java new file mode 100644 index 0000000..715c23c --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/service/impl/OrderServiceImpl.java @@ -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 implements OrderService { + + @Override + public PageResult pageRel(OrderParam param) { + PageParam page = new PageParam<>(param); + //page.setDefaultOrder("create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(OrderParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam 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)); + } + +} diff --git a/src/test/java/com/gxwebsoft/generator/SysGenerator.java b/src/test/java/com/gxwebsoft/generator/SysGenerator.java index f3bf5a6..c8ec9f7 100644 --- a/src/test/java/com/gxwebsoft/generator/SysGenerator.java +++ b/src/test/java/com/gxwebsoft/generator/SysGenerator.java @@ -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[]{