完成商品下单功能

This commit is contained in:
gxwebsoft
2024-05-27 01:23:27 +08:00
parent 35c52b5132
commit f86f00d325
44 changed files with 1845 additions and 63 deletions
@@ -0,0 +1,115 @@
package com.gxwebsoft.booking.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.booking.service.UserCardService;
import com.gxwebsoft.booking.entity.UserCard;
import com.gxwebsoft.booking.param.UserCardParam;
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-05-25 17:20:15
*/
@Api(tags = "会员卡管理")
@RestController
@RequestMapping("/api/booking/user-card")
public class UserCardController extends BaseController {
@Resource
private UserCardService userCardService;
@ApiOperation("分页查询会员卡")
@GetMapping("/page")
public ApiResult<PageResult<UserCard>> page(UserCardParam param) {
// 使用关联查询
return success(userCardService.pageRel(param));
}
@ApiOperation("查询全部会员卡")
@GetMapping()
public ApiResult<List<UserCard>> list(UserCardParam param) {
// 使用关联查询
return success(userCardService.listRel(param));
}
@PreAuthorize("hasAuthority('booking:userCard:list')")
@ApiOperation("根据id查询会员卡")
@GetMapping("/{id}")
public ApiResult<UserCard> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(userCardService.getByIdRel(id));
}
@ApiOperation("添加会员卡")
@PostMapping()
public ApiResult<?> save(@RequestBody UserCard userCard) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
userCard.setUserId(loginUser.getUserId());
}
if (userCardService.save(userCard)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改会员卡")
@PutMapping()
public ApiResult<?> update(@RequestBody UserCard userCard) {
if (userCardService.updateById(userCard)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除会员卡")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (userCardService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加会员卡")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<UserCard> list) {
if (userCardService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改会员卡")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserCard> batchParam) {
if (batchParam.update(userCardService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除会员卡")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (userCardService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -24,7 +24,7 @@ import java.util.List;
* 我的优惠券控制器
*
* @author 科技小王子
* @since 2024-05-22 22:41:17
* @since 2024-05-25 17:20:15
*/
@Api(tags = "我的优惠券管理")
@RestController
@@ -22,7 +22,7 @@ import java.util.List;
* 发票控制器
*
* @author 科技小王子
* @since 2024-05-23 16:27:08
* @since 2024-05-25 17:20:15
*/
@Api(tags = "发票管理")
@RestController
@@ -0,0 +1,150 @@
package com.gxwebsoft.booking.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 会员卡
*
* @author 科技小王子
* @since 2024-05-25 17:20:15
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "UserCard对象", description = "会员卡")
@TableName("booking_user_card")
public class UserCard implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "sid场馆id集合,适用的场馆")
private String sid;
@ApiModelProperty(value = "用户id(旧)")
private Integer uid;
@ApiModelProperty(value = "vip卡id")
private Integer vid;
@ApiModelProperty(value = "开卡人id")
private Integer aid;
@ApiModelProperty(value = "微信订单号")
private String wechatOrder;
@ApiModelProperty(value = "卡号")
private String code;
@ApiModelProperty(value = "会员卡名称")
private String name;
@ApiModelProperty(value = "真实姓名")
private String username;
@ApiModelProperty(value = "手机号码")
private String phone;
@ApiModelProperty(value = "vip购卡价格")
private BigDecimal price;
@ApiModelProperty(value = "会员卡介绍")
private String desc;
@ApiModelProperty(value = "会员卡说明")
private String info;
@ApiModelProperty(value = "vip卡折扣率")
private BigDecimal discount;
@ApiModelProperty(value = "使用次数")
private Integer count;
@ApiModelProperty(value = "每使用一次减少的金额")
private BigDecimal eachMoney;
@ApiModelProperty(value = "剩余金额")
private BigDecimal remainingMoney;
@ApiModelProperty(value = "续费累加次数")
private Integer number;
@ApiModelProperty(value = "剩余次数")
private Integer num;
@ApiModelProperty(value = "付款状态,1已付款,2未付款")
private Integer status;
@ApiModelProperty(value = "会员卡年限")
private Integer term;
@ApiModelProperty(value = "月限")
private Integer month;
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
private Integer type;
@ApiModelProperty(value = "卡类型:1成人卡,2儿童卡")
private Integer cardType;
@ApiModelProperty(value = "vip卡等级类型:1特殊vip卡,2普通vip卡")
private Integer vipType;
@ApiModelProperty(value = "特殊卡开发凭证图")
private String pic;
@ApiModelProperty(value = "价格组")
private String prices;
@ApiModelProperty(value = "1微信支付,2支付宝支付,3现金,4POS机刷卡,15平安健康卡")
private Integer payType;
@ApiModelProperty(value = "是否赠送积分:1赠送,2不赠送")
private Integer isIntegral;
@ApiModelProperty(value = "是否已开具发票:1已开发票,2未开发票")
private Integer isInvoice;
@ApiModelProperty(value = "vip卡到期时间")
private Integer expireTime;
@ApiModelProperty(value = "紧急联系人")
private String urgentName;
@ApiModelProperty(value = "紧急联系人号码")
private String urgentPhone;
@ApiModelProperty(value = "卡号")
private String cardNum;
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "使用时间")
private Integer useTime;
@ApiModelProperty(value = "创建时间")
private Integer createTime;
private Integer updateTime;
@ApiModelProperty(value = "身份证号码")
@TableField("IDCard")
private String idcard;
@ApiModelProperty(value = "备注")
private String remark;
}
@@ -1,6 +1,7 @@
package com.gxwebsoft.booking.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
@@ -17,11 +18,12 @@ import lombok.EqualsAndHashCode;
* 我的优惠券
*
* @author 科技小王子
* @since 2024-05-22 22:41:17
* @since 2024-05-25 17:20:15
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "UserCoupon对象", description = "我的优惠券")
@TableName("booking_user_coupon")
public class UserCoupon implements Serializable {
private static final long serialVersionUID = 1L;
@@ -1,5 +1,6 @@
package com.gxwebsoft.booking.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
@@ -16,11 +17,12 @@ import lombok.EqualsAndHashCode;
* 发票
*
* @author 科技小王子
* @since 2024-05-23 16:27:08
* @since 2024-05-25 17:20:15
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "UserInvoice对象", description = "发票")
@TableName("booking_user_invoice")
public class UserInvoice implements Serializable {
private static final long serialVersionUID = 1L;
@@ -34,7 +36,7 @@ public class UserInvoice implements Serializable {
@ApiModelProperty(value = "发票名称")
private String name;
@ApiModelProperty(value = "开票类型(0铺票 1专票)")
@ApiModelProperty(value = "开票类型(0普票 1专票)")
private Integer invoiceType;
@ApiModelProperty(value = "税号")
@@ -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.UserCard;
import com.gxwebsoft.booking.param.UserCardParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 会员卡Mapper
*
* @author 科技小王子
* @since 2024-05-25 17:20:15
*/
public interface UserCardMapper extends BaseMapper<UserCard> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<UserCard>
*/
List<UserCard> selectPageRel(@Param("page") IPage<UserCard> page,
@Param("param") UserCardParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<UserCard> selectListRel(@Param("param") UserCardParam param);
}
@@ -12,7 +12,7 @@ import java.util.List;
* 我的优惠券Mapper
*
* @author 科技小王子
* @since 2024-05-22 22:41:17
* @since 2024-05-25 17:20:15
*/
public interface UserCouponMapper extends BaseMapper<UserCoupon> {
@@ -12,7 +12,7 @@ import java.util.List;
* 发票Mapper
*
* @author 科技小王子
* @since 2024-05-23 16:27:08
* @since 2024-05-25 17:20:15
*/
public interface UserInvoiceMapper extends BaseMapper<UserInvoice> {
@@ -0,0 +1,150 @@
<?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.booking.mapper.UserCardMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM booking_user_card a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.sid != null">
AND a.sid LIKE CONCAT('%', #{param.sid}, '%')
</if>
<if test="param.uid != null">
AND a.uid = #{param.uid}
</if>
<if test="param.vid != null">
AND a.vid = #{param.vid}
</if>
<if test="param.aid != null">
AND a.aid = #{param.aid}
</if>
<if test="param.wechatOrder != null">
AND a.wechat_order LIKE CONCAT('%', #{param.wechatOrder}, '%')
</if>
<if test="param.code != null">
AND a.code LIKE CONCAT('%', #{param.code}, '%')
</if>
<if test="param.name != null">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if>
<if test="param.username != null">
AND a.username LIKE CONCAT('%', #{param.username}, '%')
</if>
<if test="param.phone != null">
AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
</if>
<if test="param.price != null">
AND a.price = #{param.price}
</if>
<if test="param.desc != null">
AND a.desc LIKE CONCAT('%', #{param.desc}, '%')
</if>
<if test="param.info != null">
AND a.info LIKE CONCAT('%', #{param.info}, '%')
</if>
<if test="param.discount != null">
AND a.discount = #{param.discount}
</if>
<if test="param.count != null">
AND a.count = #{param.count}
</if>
<if test="param.eachMoney != null">
AND a.each_money = #{param.eachMoney}
</if>
<if test="param.remainingMoney != null">
AND a.remaining_money = #{param.remainingMoney}
</if>
<if test="param.number != null">
AND a.number = #{param.number}
</if>
<if test="param.num != null">
AND a.num = #{param.num}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.term != null">
AND a.term = #{param.term}
</if>
<if test="param.month != null">
AND a.month = #{param.month}
</if>
<if test="param.type != null">
AND a.type = #{param.type}
</if>
<if test="param.cardType != null">
AND a.card_type = #{param.cardType}
</if>
<if test="param.vipType != null">
AND a.vip_type = #{param.vipType}
</if>
<if test="param.pic != null">
AND a.pic LIKE CONCAT('%', #{param.pic}, '%')
</if>
<if test="param.prices != null">
AND a.prices LIKE CONCAT('%', #{param.prices}, '%')
</if>
<if test="param.payType != null">
AND a.pay_type = #{param.payType}
</if>
<if test="param.isIntegral != null">
AND a.is_integral = #{param.isIntegral}
</if>
<if test="param.isInvoice != null">
AND a.is_invoice = #{param.isInvoice}
</if>
<if test="param.expireTime != null">
AND a.expire_time = #{param.expireTime}
</if>
<if test="param.urgentName != null">
AND a.urgent_name LIKE CONCAT('%', #{param.urgentName}, '%')
</if>
<if test="param.urgentPhone != null">
AND a.urgent_phone LIKE CONCAT('%', #{param.urgentPhone}, '%')
</if>
<if test="param.cardNum != null">
AND a.card_num LIKE CONCAT('%', #{param.cardNum}, '%')
</if>
<if test="param.password != null">
AND a.password LIKE CONCAT('%', #{param.password}, '%')
</if>
<if test="param.useTime != null">
AND a.use_time = #{param.useTime}
</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>
<if test="param.idcard != null">
AND a.IDCard LIKE CONCAT('%', #{param.idcard}, '%')
</if>
<if test="param.remark != null">
AND a.remark LIKE CONCAT('%', #{param.remark}, '%')
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.booking.entity.UserCard">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.booking.entity.UserCard">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -5,7 +5,7 @@
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM user_invoice a
FROM booking_user_invoice a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
@@ -0,0 +1,165 @@
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-05-25 17:20:15
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "UserCardParam对象", description = "会员卡查询参数")
public class UserCardParam extends BaseParam {
private static final long serialVersionUID = 1L;
@QueryField(type = QueryType.EQ)
private Integer id;
@ApiModelProperty(value = "用户id")
@QueryField(type = QueryType.EQ)
private Integer userId;
@ApiModelProperty(value = "sid场馆id集合,适用的场馆")
private String sid;
@ApiModelProperty(value = "用户id(旧)")
@QueryField(type = QueryType.EQ)
private Integer uid;
@ApiModelProperty(value = "vip卡id")
@QueryField(type = QueryType.EQ)
private Integer vid;
@ApiModelProperty(value = "开卡人id")
@QueryField(type = QueryType.EQ)
private Integer aid;
@ApiModelProperty(value = "微信订单号")
private String wechatOrder;
@ApiModelProperty(value = "卡号")
private String code;
@ApiModelProperty(value = "会员卡名称")
private String name;
@ApiModelProperty(value = "真实姓名")
private String username;
@ApiModelProperty(value = "手机号码")
private String phone;
@ApiModelProperty(value = "vip购卡价格")
@QueryField(type = QueryType.EQ)
private BigDecimal price;
@ApiModelProperty(value = "会员卡介绍")
private String desc;
@ApiModelProperty(value = "会员卡说明")
private String info;
@ApiModelProperty(value = "vip卡折扣率")
@QueryField(type = QueryType.EQ)
private BigDecimal discount;
@ApiModelProperty(value = "使用次数")
@QueryField(type = QueryType.EQ)
private Integer count;
@ApiModelProperty(value = "每使用一次减少的金额")
@QueryField(type = QueryType.EQ)
private BigDecimal eachMoney;
@ApiModelProperty(value = "剩余金额")
@QueryField(type = QueryType.EQ)
private BigDecimal remainingMoney;
@ApiModelProperty(value = "续费累加次数")
@QueryField(type = QueryType.EQ)
private Integer number;
@ApiModelProperty(value = "剩余次数")
@QueryField(type = QueryType.EQ)
private Integer num;
@ApiModelProperty(value = "付款状态,1已付款,2未付款")
@QueryField(type = QueryType.EQ)
private Integer status;
@ApiModelProperty(value = "会员卡年限")
@QueryField(type = QueryType.EQ)
private Integer term;
@ApiModelProperty(value = "月限")
@QueryField(type = QueryType.EQ)
private Integer month;
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
@QueryField(type = QueryType.EQ)
private Integer type;
@ApiModelProperty(value = "卡类型:1成人卡,2儿童卡")
@QueryField(type = QueryType.EQ)
private Integer cardType;
@ApiModelProperty(value = "vip卡等级类型:1特殊vip卡,2普通vip卡")
@QueryField(type = QueryType.EQ)
private Integer vipType;
@ApiModelProperty(value = "特殊卡开发凭证图")
private String pic;
@ApiModelProperty(value = "价格组")
private String prices;
@ApiModelProperty(value = "1微信支付,2支付宝支付,3现金,4POS机刷卡,15平安健康卡")
@QueryField(type = QueryType.EQ)
private Integer payType;
@ApiModelProperty(value = "是否赠送积分:1赠送,2不赠送")
@QueryField(type = QueryType.EQ)
private Integer isIntegral;
@ApiModelProperty(value = "是否已开具发票:1已开发票,2未开发票")
@QueryField(type = QueryType.EQ)
private Integer isInvoice;
@ApiModelProperty(value = "vip卡到期时间")
@QueryField(type = QueryType.EQ)
private Integer expireTime;
@ApiModelProperty(value = "紧急联系人")
private String urgentName;
@ApiModelProperty(value = "紧急联系人号码")
private String urgentPhone;
@ApiModelProperty(value = "卡号")
private String cardNum;
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "使用时间")
@QueryField(type = QueryType.EQ)
private Integer useTime;
@ApiModelProperty(value = "身份证号码")
private String idcard;
@ApiModelProperty(value = "备注")
private String remark;
}
@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
* 我的优惠券查询参数
*
* @author 科技小王子
* @since 2024-05-22 22:41:17
* @since 2024-05-25 17:20:15
*/
@Data
@EqualsAndHashCode(callSuper = false)
@@ -59,12 +59,10 @@ public class UserCouponParam extends BaseParam {
private Integer expireDay;
@ApiModelProperty(value = "有效期开始时间")
@QueryField(type = QueryType.EQ)
private Integer startTime;
private String startTime;
@ApiModelProperty(value = "有效期结束时间")
@QueryField(type = QueryType.EQ)
private Integer endTime;
private String endTime;
@ApiModelProperty(value = "适用范围(10全部商品 20指定商品)")
@QueryField(type = QueryType.EQ)
@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
* 发票查询参数
*
* @author 科技小王子
* @since 2024-05-23 16:27:07
* @since 2024-05-25 17:20:15
*/
@Data
@EqualsAndHashCode(callSuper = false)
@@ -34,7 +34,8 @@ public class UserInvoiceParam extends BaseParam {
@ApiModelProperty(value = "发票名称")
private String name;
@ApiModelProperty(value = "开票类型(0铺票 1专票)")
@ApiModelProperty(value = "开票类型(0普票 1专票)")
@QueryField(type = QueryType.EQ)
private Integer invoiceType;
@ApiModelProperty(value = "税号")
@@ -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.UserCard;
import com.gxwebsoft.booking.param.UserCardParam;
import java.util.List;
/**
* 会员卡Service
*
* @author 科技小王子
* @since 2024-05-25 17:20:15
*/
public interface UserCardService extends IService<UserCard> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<UserCard>
*/
PageResult<UserCard> pageRel(UserCardParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<UserCard>
*/
List<UserCard> listRel(UserCardParam param);
/**
* 根据id查询
*
* @param id
* @return UserCard
*/
UserCard getByIdRel(Integer id);
}
@@ -11,7 +11,7 @@ import java.util.List;
* 我的优惠券Service
*
* @author 科技小王子
* @since 2024-05-22 22:41:17
* @since 2024-05-25 17:20:15
*/
public interface UserCouponService extends IService<UserCoupon> {
@@ -11,7 +11,7 @@ import java.util.List;
* 发票Service
*
* @author 科技小王子
* @since 2024-05-23 16:27:08
* @since 2024-05-25 17:20:15
*/
public interface UserInvoiceService extends IService<UserInvoice> {
@@ -0,0 +1,47 @@
package com.gxwebsoft.booking.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.booking.mapper.UserCardMapper;
import com.gxwebsoft.booking.service.UserCardService;
import com.gxwebsoft.booking.entity.UserCard;
import com.gxwebsoft.booking.param.UserCardParam;
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-05-25 17:20:15
*/
@Service
public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> implements UserCardService {
@Override
public PageResult<UserCard> pageRel(UserCardParam param) {
PageParam<UserCard, UserCardParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<UserCard> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<UserCard> listRel(UserCardParam param) {
List<UserCard> list = baseMapper.selectListRel(param);
// 排序
PageParam<UserCard, UserCardParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public UserCard getByIdRel(Integer id) {
UserCardParam param = new UserCardParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}
@@ -15,7 +15,7 @@ import java.util.List;
* 我的优惠券Service实现
*
* @author 科技小王子
* @since 2024-05-22 22:41:17
* @since 2024-05-25 17:20:15
*/
@Service
public class UserCouponServiceImpl extends ServiceImpl<UserCouponMapper, UserCoupon> implements UserCouponService {
@@ -15,7 +15,7 @@ import java.util.List;
* 发票Service实现
*
* @author 科技小王子
* @since 2024-05-23 16:27:08
* @since 2024-05-25 17:20:15
*/
@Service
public class UserInvoiceServiceImpl extends ServiceImpl<UserInvoiceMapper, UserInvoice> implements UserInvoiceService {
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.entity.OrderInfo;
import com.gxwebsoft.shop.service.OrderGoodsService;
import com.gxwebsoft.shop.service.OrderInfoService;
import com.gxwebsoft.shop.service.OrderService;
import com.gxwebsoft.shop.entity.Order;
@@ -22,6 +23,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.aspectj.weaver.ast.Or;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -42,6 +44,8 @@ public class OrderController extends BaseController {
private OrderService orderService;
@Resource
private OrderInfoService orderInfoService;
@Resource
private OrderGoodsService orderGoodsService;
@ApiOperation("分页查询订单")
@GetMapping("/page")
@@ -112,20 +116,39 @@ public class OrderController extends BaseController {
order.setPhone(loginUser.getPhone());
order.setUserId(loginUser.getUserId());
order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.MINUTE, 10));
// List<Date> collect = order.getOrderInfoList().stream().map(OrderInfo::getStartTime).collect(Collectors.toList());
// OrderInfo orderInfo = order.getOrderInfoList().get(0);
// order.setStartTime(DateUtil.formatTime(orderInfo.getStartTime()));
// order.setVersion(10);
if (order.getOrderInfoList() != null) {
order.setTotalNum(order.getOrderInfoList().size());
}
if (order.getGoodsList() != null) {
order.setTotalNum(order.getGoodsList().size());
}
if (orderService.save(order)) {
order.getOrderInfoList().forEach(d -> {
d.setOrderId(order.getOrderId());
d.setTimeFlag(timeMillis);
d.setVersion(10);
d.setUserId(getLoginUser().getUserId());
d.setDateTime(d.getDateTime());
d.setExpirationTime(order.getExpirationTime());
});
orderInfoService.saveBatch(order.getOrderInfoList());
// 预定订单
if (!CollectionUtils.isEmpty(order.getOrderInfoList())) {
order.getOrderInfoList().forEach(d -> {
d.setOrderId(order.getOrderId());
d.setTimeFlag(timeMillis);
d.setVersion(10);
d.setUserId(getLoginUser().getUserId());
d.setDateTime(d.getDateTime());
d.setExpirationTime(order.getExpirationTime());
});
orderInfoService.saveBatch(order.getOrderInfoList());
}
// 商城订单
if (!CollectionUtils.isEmpty(order.getGoodsList())) {
order.getGoodsList().forEach(d -> {
d.setOrderId(order.getOrderId());
d.setTimeFlag(timeMillis);
d.setVersion(10);
d.setDateTime(DateUtil.date());
d.setUserId(getLoginUser().getUserId());
d.setExpirationTime(order.getExpirationTime());
});
orderGoodsService.saveBatch(order.getGoodsList());
}
// 微信统一下单接口
if (order.getPayType().equals(1)) {
return success("下单成功", orderService.createWxOrder(order));
@@ -0,0 +1,115 @@
package com.gxwebsoft.shop.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.service.OrderGoodsService;
import com.gxwebsoft.shop.entity.OrderGoods;
import com.gxwebsoft.shop.param.OrderGoodsParam;
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-05-26 15:42:03
*/
@Api(tags = "商品信息管理")
@RestController
@RequestMapping("/api/shop/order-goods")
public class OrderGoodsController extends BaseController {
@Resource
private OrderGoodsService orderGoodsService;
@ApiOperation("分页查询商品信息")
@GetMapping("/page")
public ApiResult<PageResult<OrderGoods>> page(OrderGoodsParam param) {
// 使用关联查询
return success(orderGoodsService.pageRel(param));
}
@ApiOperation("查询全部商品信息")
@GetMapping()
public ApiResult<List<OrderGoods>> list(OrderGoodsParam param) {
// 使用关联查询
return success(orderGoodsService.listRel(param));
}
@PreAuthorize("hasAuthority('shop:orderGoods:list')")
@ApiOperation("根据id查询商品信息")
@GetMapping("/{id}")
public ApiResult<OrderGoods> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(orderGoodsService.getByIdRel(id));
}
@ApiOperation("添加商品信息")
@PostMapping()
public ApiResult<?> save(@RequestBody OrderGoods orderGoods) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
orderGoods.setUserId(loginUser.getUserId());
}
if (orderGoodsService.save(orderGoods)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改商品信息")
@PutMapping()
public ApiResult<?> update(@RequestBody OrderGoods orderGoods) {
if (orderGoodsService.updateById(orderGoods)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除商品信息")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (orderGoodsService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加商品信息")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<OrderGoods> list) {
if (orderGoodsService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改商品信息")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<OrderGoods> batchParam) {
if (batchParam.update(orderGoodsService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除商品信息")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (orderGoodsService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -0,0 +1,119 @@
package com.gxwebsoft.shop.controller;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.service.UserAddressService;
import com.gxwebsoft.shop.entity.UserAddress;
import com.gxwebsoft.shop.param.UserAddressParam;
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-05-26 10:58:37
*/
@Api(tags = "收货地址管理")
@RestController
@RequestMapping("/api/shop/user-address")
public class UserAddressController extends BaseController {
@Resource
private UserAddressService userAddressService;
@ApiOperation("分页查询收货地址")
@GetMapping("/page")
public ApiResult<PageResult<UserAddress>> page(UserAddressParam param) {
// 使用关联查询
return success(userAddressService.pageRel(param));
}
@ApiOperation("查询全部收货地址")
@GetMapping()
public ApiResult<List<UserAddress>> list(UserAddressParam param) {
// 使用关联查询
return success(userAddressService.listRel(param));
}
@PreAuthorize("hasAuthority('shop:userAddress:list')")
@ApiOperation("根据id查询收货地址")
@GetMapping("/{id}")
public ApiResult<UserAddress> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(userAddressService.getByIdRel(id));
}
@ApiOperation("添加收货地址")
@PostMapping()
public ApiResult<?> save(@RequestBody UserAddress userAddress) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
userAddress.setUserId(loginUser.getUserId());
}
if (userAddressService.save(userAddress)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改收货地址")
@PutMapping()
public ApiResult<?> update(@RequestBody UserAddress userAddress) {
if (userAddress.getIsDefault() != null && userAddress.getIsDefault().equals(true)) {
final boolean update = userAddressService.update(new LambdaUpdateWrapper<UserAddress>().eq(UserAddress::getUserId, getLoginUserId()).set(UserAddress::getIsDefault, 0));
}
if (userAddressService.updateById(userAddress)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除收货地址")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (userAddressService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加收货地址")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<UserAddress> list) {
if (userAddressService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改收货地址")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserAddress> batchParam) {
if (batchParam.update(userAddressService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除收货地址")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (userAddressService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -37,8 +37,8 @@ public class Goods implements Serializable {
@ApiModelProperty(value = "商品编码")
private String code;
@ApiModelProperty(value = "商品标题")
private String title;
@ApiModelProperty(value = "商品名称")
private String goodsName;
@ApiModelProperty(value = "商品封面图")
private String image;
@@ -100,6 +100,9 @@ public class Goods implements Serializable {
@ApiModelProperty(value = "商户ID")
private Integer merchantId;
@ApiModelProperty(value = "商户名称")
private String merchantName;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@@ -8,6 +8,8 @@ import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -49,7 +51,6 @@ public class Order implements Serializable {
private String merchantCode;
@ApiModelProperty(value = "商户名称")
@TableField(exist = false)
private String merchantName;
@ApiModelProperty(value = "商户图标")
@@ -95,6 +96,10 @@ public class Order implements Serializable {
@ApiModelProperty(value = "退款金额")
private BigDecimal refundMoney;
@ApiModelProperty(value = "共几件")
@QueryField(type = QueryType.EQ)
private Integer totalNum;
@ApiModelProperty(value = "教练价格")
private BigDecimal coachPrice;
@@ -182,8 +187,12 @@ public class Order implements Serializable {
@TableField(exist = false)
private String openid;
@ApiModelProperty(value = "订单详情")
@ApiModelProperty(value = "预定信息")
@TableField(exist = false)
private List<OrderInfo> orderInfoList;
@ApiModelProperty(value = "商品信息")
@TableField(exist = false)
private List<OrderGoods> goodsList;
}
@@ -0,0 +1,107 @@
package com.gxwebsoft.shop.entity;
import java.math.BigDecimal;
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.LocalTime;
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-05-26 15:42:03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "OrderGoods对象", description = "商品信息")
@TableName("shop_order_goods")
public class OrderGoods implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "自增ID")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "关联订单表id")
private Integer orderId;
@ApiModelProperty(value = "订单标识")
private String orderCode;
@ApiModelProperty(value = "关联商户ID")
private Integer merchantId;
@ApiModelProperty(value = "商户名称")
private String merchantName;
@ApiModelProperty(value = "商品封面图")
private String image;
@ApiModelProperty(value = "关联商品id")
private Integer goodsId;
@ApiModelProperty(value = "商品名称")
private String goodsName;
@ApiModelProperty(value = "单价")
private BigDecimal price;
@ApiModelProperty(value = "购买数量")
private Integer totalNum;
@ApiModelProperty(value = "0 未付款 1已付款,2无需付款或占用状态")
private Integer payStatus;
@ApiModelProperty(value = "0未使用,1已完成,2已取消,3取消中,4退款申请中,5退款被拒绝,6退款成功,7客户端申请退款")
private Integer orderStatus;
@ApiModelProperty(value = "是否免费:0收费、1免费")
private Boolean isFree;
@ApiModelProperty(value = "系统版本 0当前版本 其他版本")
private Integer version;
@ApiModelProperty(value = "预约时间段")
private String timePeriod;
@ApiModelProperty(value = "预定日期")
private Date dateTime;
@ApiModelProperty(value = "开场时间")
private Date startTime;
@ApiModelProperty(value = "结束时间")
private Date endTime;
@ApiModelProperty(value = "毫秒时间戳")
private Long timeFlag;
@ApiModelProperty(value = "过期时间")
private Date expirationTime;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "更新时间")
private Date updateTime;
@ApiModelProperty(value = "创建时间")
private Date createTime;
}
@@ -0,0 +1,71 @@
package com.gxwebsoft.shop.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
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-05-26 10:58:37
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "UserAddress对象", description = "收货地址")
@TableName("shop_user_address")
public class UserAddress implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "姓名")
private String name;
@ApiModelProperty(value = "手机号码")
private String phone;
@ApiModelProperty(value = "所在国家")
private String country;
@ApiModelProperty(value = "所在省份")
private String province;
@ApiModelProperty(value = "所在城市")
private String city;
@ApiModelProperty(value = "所在辖区")
private String region;
@ApiModelProperty(value = "收货地址")
private String address;
@ApiModelProperty(value = "1先生 2女士")
private Integer gender;
@ApiModelProperty(value = "家、公司、学校")
private String type;
@ApiModelProperty(value = "默认收货地址")
private Boolean isDefault;
@ApiModelProperty(value = "用户ID")
private Integer userId;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "注册时间")
private Date createTime;
}
@@ -0,0 +1,37 @@
package com.gxwebsoft.shop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.shop.entity.OrderGoods;
import com.gxwebsoft.shop.param.OrderGoodsParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 商品信息Mapper
*
* @author 科技小王子
* @since 2024-05-26 15:42:03
*/
public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<OrderGoods>
*/
List<OrderGoods> selectPageRel(@Param("page") IPage<OrderGoods> page,
@Param("param") OrderGoodsParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<OrderGoods> selectListRel(@Param("param") OrderGoodsParam param);
}
@@ -0,0 +1,37 @@
package com.gxwebsoft.shop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.shop.entity.UserAddress;
import com.gxwebsoft.shop.param.UserAddressParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 收货地址Mapper
*
* @author 科技小王子
* @since 2024-05-26 10:58:37
*/
public interface UserAddressMapper extends BaseMapper<UserAddress> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<UserAddress>
*/
List<UserAddress> selectPageRel(@Param("page") IPage<UserAddress> page,
@Param("param") UserAddressParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<UserAddress> selectListRel(@Param("param") UserAddressParam param);
}
@@ -16,8 +16,8 @@
<if test="param.code != null">
AND a.code LIKE CONCAT('%', #{param.code}, '%')
</if>
<if test="param.title != null">
AND a.title LIKE CONCAT('%', #{param.title}, '%')
<if test="param.goodsName != null">
AND a.goods_name LIKE CONCAT('%', #{param.goodsName}, '%')
</if>
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
@@ -0,0 +1,96 @@
<?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.shop.mapper.OrderGoodsMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM shop_order_goods a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.orderId != null">
AND a.order_id = #{param.orderId}
</if>
<if test="param.orderCode != null">
AND a.order_code LIKE CONCAT('%', #{param.orderCode}, '%')
</if>
<if test="param.merchantId != null">
AND a.merchant_id = #{param.merchantId}
</if>
<if test="param.merchantName != null">
AND a.merchant_name LIKE CONCAT('%', #{param.merchantName}, '%')
</if>
<if test="param.image != null">
AND a.image LIKE CONCAT('%', #{param.image}, '%')
</if>
<if test="param.goodsId != null">
AND a.goods_id = #{param.goodsId}
</if>
<if test="param.goodsName != null">
AND a.goods_name LIKE CONCAT('%', #{param.goodsName}, '%')
</if>
<if test="param.price != null">
AND a.price = #{param.price}
</if>
<if test="param.payStatus != null">
AND a.pay_status = #{param.payStatus}
</if>
<if test="param.orderStatus != null">
AND a.order_status = #{param.orderStatus}
</if>
<if test="param.isFree != null">
AND a.is_free = #{param.isFree}
</if>
<if test="param.version != null">
AND a.version = #{param.version}
</if>
<if test="param.timePeriod != null">
AND a.time_period LIKE CONCAT('%', #{param.timePeriod}, '%')
</if>
<if test="param.dateTime != null">
AND a.date_time LIKE CONCAT('%', #{param.dateTime}, '%')
</if>
<if test="param.startTime != null">
AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
</if>
<if test="param.endTime != null">
AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%')
</if>
<if test="param.timeFlag != null">
AND a.time_flag LIKE CONCAT('%', #{param.timeFlag}, '%')
</if>
<if test="param.expirationTime != null">
AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%')
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</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>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.OrderGoods">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.OrderGoods">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -4,13 +4,16 @@
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*,b.merchant_name,b.image as merchantAvatar
SELECT a.*,b.image as merchantAvatar
FROM shop_order a
LEFT JOIN shop_merchant b ON a.merchant_id = b.merchant_id
<where>
<if test="param.orderId != null">
AND a.order_id = #{param.orderId}
</if>
<if test="param.type != null">
AND a.type = #{param.type}
</if>
<if test="param.orderNo != null">
AND a.order_no LIKE CONCAT('%', #{param.orderNo}, '%')
</if>
@@ -0,0 +1,69 @@
<?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.shop.mapper.UserAddressMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM shop_user_address a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.name != null">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if>
<if test="param.phone != null">
AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
</if>
<if test="param.country != null">
AND a.country LIKE CONCAT('%', #{param.country}, '%')
</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.address != null">
AND a.address LIKE CONCAT('%', #{param.address}, '%')
</if>
<if test="param.gender != null">
AND a.gender = #{param.gender}
</if>
<if test="param.type != null">
AND a.type LIKE CONCAT('%', #{param.type}, '%')
</if>
<if test="param.isDefault != null">
AND a.is_default = #{param.isDefault}
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</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>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.UserAddress">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.UserAddress">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -34,8 +34,8 @@ public class GoodsParam extends BaseParam {
@ApiModelProperty(value = "商品编码")
private String code;
@ApiModelProperty(value = "商品标题")
private String title;
@ApiModelProperty(value = "商品名称")
private String goodsName;
@ApiModelProperty(value = "商品详情")
private String content;
@@ -0,0 +1,103 @@
package com.gxwebsoft.shop.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-05-26 15:42:03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "OrderGoodsParam对象", description = "商品信息查询参数")
public class OrderGoodsParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "自增ID")
@QueryField(type = QueryType.EQ)
private Integer id;
@ApiModelProperty(value = "关联订单表id")
@QueryField(type = QueryType.EQ)
private Integer orderId;
@ApiModelProperty(value = "订单标识")
private String orderCode;
@ApiModelProperty(value = "关联商户ID")
@QueryField(type = QueryType.EQ)
private Integer merchantId;
@ApiModelProperty(value = "商户名称")
private String merchantName;
@ApiModelProperty(value = "商品封面图")
private String image;
@ApiModelProperty(value = "关联商品id")
@QueryField(type = QueryType.EQ)
private Integer goodsId;
@ApiModelProperty(value = "商品名称")
private String goodsName;
@ApiModelProperty(value = "单价")
@QueryField(type = QueryType.EQ)
private BigDecimal price;
@ApiModelProperty(value = "购买数量")
@QueryField(type = QueryType.EQ)
private Integer totalNum;
@ApiModelProperty(value = "0 未付款 1已付款,2无需付款或占用状态")
@QueryField(type = QueryType.EQ)
private Integer payStatus;
@ApiModelProperty(value = "0未使用,1已完成,2已取消,3取消中,4退款申请中,5退款被拒绝,6退款成功,7客户端申请退款")
@QueryField(type = QueryType.EQ)
private Integer orderStatus;
@ApiModelProperty(value = "是否免费:0收费、1免费")
@QueryField(type = QueryType.EQ)
private Boolean isFree;
@ApiModelProperty(value = "系统版本 0当前版本 其他版本")
@QueryField(type = QueryType.EQ)
private Integer version;
@ApiModelProperty(value = "预约时间段")
private String timePeriod;
@ApiModelProperty(value = "预定日期")
private String dateTime;
@ApiModelProperty(value = "开场时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "毫秒时间戳")
private Long timeFlag;
@ApiModelProperty(value = "过期时间")
private String expirationTime;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "用户id")
@QueryField(type = QueryType.EQ)
private Integer userId;
}
@@ -46,6 +46,10 @@ public class OrderParam extends BaseParam {
@QueryField(type = QueryType.EQ)
private Integer merchantId;
@ApiModelProperty(value = "商户名称")
@QueryField(type = QueryType.EQ)
private String merchantName;
@ApiModelProperty(value = "商户编号")
@QueryField(type = QueryType.EQ)
private String merchantCode;
@@ -90,6 +94,10 @@ public class OrderParam extends BaseParam {
@QueryField(type = QueryType.EQ)
private BigDecimal price;
@ApiModelProperty(value = "共几件")
@QueryField(type = QueryType.EQ)
private Integer totalNum;
@ApiModelProperty(value = "价钱,用于积分赠送")
@QueryField(type = QueryType.EQ)
private BigDecimal money;
@@ -0,0 +1,66 @@
package com.gxwebsoft.shop.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-05-26 10:58:37
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "UserAddressParam对象", description = "收货地址查询参数")
public class UserAddressParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
@QueryField(type = QueryType.EQ)
private Integer id;
@ApiModelProperty(value = "姓名")
private String name;
@ApiModelProperty(value = "手机号码")
private String phone;
@ApiModelProperty(value = "所在国家")
private String country;
@ApiModelProperty(value = "所在省份")
private String province;
@ApiModelProperty(value = "所在城市")
private String city;
@ApiModelProperty(value = "所在辖区")
private String region;
@ApiModelProperty(value = "收货地址")
private String address;
@ApiModelProperty(value = "1先生 2女士")
@QueryField(type = QueryType.EQ)
private Integer gender;
@ApiModelProperty(value = "家、公司、学校")
private String type;
@ApiModelProperty(value = "默认收货地址")
@QueryField(type = QueryType.EQ)
private Boolean isDefault;
@ApiModelProperty(value = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
}
@@ -0,0 +1,42 @@
package com.gxwebsoft.shop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.OrderGoods;
import com.gxwebsoft.shop.param.OrderGoodsParam;
import java.util.List;
/**
* 商品信息Service
*
* @author 科技小王子
* @since 2024-05-26 15:42:03
*/
public interface OrderGoodsService extends IService<OrderGoods> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<OrderGoods>
*/
PageResult<OrderGoods> pageRel(OrderGoodsParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<OrderGoods>
*/
List<OrderGoods> listRel(OrderGoodsParam param);
/**
* 根据id查询
*
* @param id 自增ID
* @return OrderGoods
*/
OrderGoods getByIdRel(Integer id);
}
@@ -0,0 +1,42 @@
package com.gxwebsoft.shop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.UserAddress;
import com.gxwebsoft.shop.param.UserAddressParam;
import java.util.List;
/**
* 收货地址Service
*
* @author 科技小王子
* @since 2024-05-26 10:58:37
*/
public interface UserAddressService extends IService<UserAddress> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<UserAddress>
*/
PageResult<UserAddress> pageRel(UserAddressParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<UserAddress>
*/
List<UserAddress> listRel(UserAddressParam param);
/**
* 根据id查询
*
* @param id 主键ID
* @return UserAddress
*/
UserAddress getByIdRel(Integer id);
}
@@ -0,0 +1,47 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.OrderGoodsMapper;
import com.gxwebsoft.shop.service.OrderGoodsService;
import com.gxwebsoft.shop.entity.OrderGoods;
import com.gxwebsoft.shop.param.OrderGoodsParam;
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-05-26 15:42:03
*/
@Service
public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGoods> implements OrderGoodsService {
@Override
public PageResult<OrderGoods> pageRel(OrderGoodsParam param) {
PageParam<OrderGoods, OrderGoodsParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<OrderGoods> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<OrderGoods> listRel(OrderGoodsParam param) {
List<OrderGoods> list = baseMapper.selectListRel(param);
// 排序
PageParam<OrderGoods, OrderGoodsParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public OrderGoods getByIdRel(Integer id) {
OrderGoodsParam param = new OrderGoodsParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}
@@ -9,10 +9,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.config.ConfigProperties;
import com.gxwebsoft.common.core.utils.RedisUtil;
import com.gxwebsoft.common.system.service.SettingService;
import com.gxwebsoft.shop.entity.OrderGoods;
import com.gxwebsoft.shop.entity.OrderInfo;
import com.gxwebsoft.shop.entity.Payment;
import com.gxwebsoft.shop.mapper.OrderMapper;
import com.gxwebsoft.shop.param.OrderInfoParam;
import com.gxwebsoft.shop.service.OrderGoodsService;
import com.gxwebsoft.shop.service.OrderInfoService;
import com.gxwebsoft.shop.service.OrderService;
import com.gxwebsoft.shop.entity.Order;
@@ -51,6 +53,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
@Resource
private OrderInfoService orderInfoService;
@Resource
private OrderGoodsService orderGoodsService;
@Resource
private ConfigProperties config;
@Resource
private SettingService settingService;
@@ -66,23 +70,45 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
PageParam<Order, OrderParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<Order> list = baseMapper.selectPageRel(page, param);
final Set<Integer> orderIds = list.stream().map(Order::getOrderId).collect(Collectors.toSet());
// 查询订单信息表
if (!CollectionUtils.isEmpty(orderIds)) {
final List<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().in(OrderInfo::getOrderId, orderIds));
final Map<Integer, List<OrderInfo>> orderInfo = orderInfoList.stream().collect(Collectors.groupingBy(OrderInfo::getOrderId));
list.forEach(d -> {
final DateTime date = DateUtil.date(d.getExpirationTime());
final DateTime now = DateUtil.date();
d.setTimestamp(date.getTime() - now.getTime());
if (!orderInfo.isEmpty()) {
final List<OrderInfo> orderInfos = orderInfo.get(d.getOrderId());
if (!CollectionUtils.isEmpty(orderInfos)) {
d.setOrderInfoList(orderInfos);
}
if(param.getSceneType() != null){
final Set<Integer> orderIds = list.stream().map(Order::getOrderId).collect(Collectors.toSet());
if (!CollectionUtils.isEmpty(orderIds)) {
// 查询预定订单信息
if (param.getSceneType().equals("showOrderInfo")) {
final List<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().in(OrderInfo::getOrderId, orderIds));
final Map<Integer, List<OrderInfo>> collect = orderInfoList.stream().collect(Collectors.groupingBy(OrderInfo::getOrderId));
list.forEach(d -> {
final DateTime date = DateUtil.date(d.getExpirationTime());
final DateTime now = DateUtil.date();
d.setTimestamp(date.getTime() - now.getTime());
if (!collect.isEmpty()) {
final List<OrderInfo> orderInfos = collect.get(d.getOrderId());
if (!CollectionUtils.isEmpty(orderInfos)) {
d.setOrderInfoList(orderInfos);
}
}
});
}
});
// 查询商品信息
if (param.getSceneType().equals("showOrderGoods")) {
final List<OrderGoods> goodsList = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>().in(OrderGoods::getOrderId, orderIds));
final Map<Integer, List<OrderGoods>> collect = goodsList.stream().collect(Collectors.groupingBy(OrderGoods::getOrderId));
list.forEach(d -> {
final DateTime date = DateUtil.date(d.getExpirationTime());
final DateTime now = DateUtil.date();
d.setTimestamp(date.getTime() - now.getTime());
if (!collect.isEmpty()) {
final List<OrderGoods> goods = collect.get(d.getOrderId());
if (!CollectionUtils.isEmpty(goods)) {
d.setGoodsList(goods);
}
}
});
}
}
}
return new PageResult<>(list, page.getTotal());
}
@@ -0,0 +1,48 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.UserAddressMapper;
import com.gxwebsoft.shop.service.UserAddressService;
import com.gxwebsoft.shop.entity.UserAddress;
import com.gxwebsoft.shop.param.UserAddressParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* 收货地址Service实现
*
* @author 科技小王子
* @since 2024-05-26 10:58:37
*/
@Service
public class UserAddressServiceImpl extends ServiceImpl<UserAddressMapper, UserAddress> implements UserAddressService {
@Override
public PageResult<UserAddress> pageRel(UserAddressParam param) {
PageParam<UserAddress, UserAddressParam> page = new PageParam<>(param);
page.setDefaultOrder("is_default desc");
List<UserAddress> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<UserAddress> listRel(UserAddressParam param) {
List<UserAddress> list = baseMapper.selectListRel(param);
// 排序
PageParam<UserAddress, UserAddressParam> page = new PageParam<>();
page.setDefaultOrder("is_default desc");
return page.sortRecords(list);
}
@Override
public UserAddress getByIdRel(Integer id) {
UserAddressParam param = new UserAddressParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}