新增:会员卡使用明细
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.gxwebsoft.booking.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.booking.service.UserCardService;
|
||||
import com.gxwebsoft.booking.entity.UserCard;
|
||||
@@ -10,6 +12,8 @@ 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 com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -31,6 +35,27 @@ public class UserCardController extends BaseController {
|
||||
@Resource
|
||||
private UserCardService userCardService;
|
||||
|
||||
@ApiOperation("查询可用的会员卡")
|
||||
@GetMapping("/findUseCard")
|
||||
public ApiResult<?> findUseCard(UserCardParam param) {
|
||||
final User loginUser = getLoginUser();
|
||||
if(loginUser == null){
|
||||
return fail("请先登录",null);
|
||||
}
|
||||
// 查询可用的会员卡
|
||||
LambdaUpdateWrapper<UserCard> wrapper = new LambdaUpdateWrapper<>();
|
||||
|
||||
wrapper.eq(UserCard::getUserId, loginUser.getUserId())
|
||||
.like(UserCard::getSid, param.getSid())
|
||||
.eq(UserCard::getPayStatus,1)
|
||||
.gt(UserCard::getExpirationTime, DateUtil.date())
|
||||
.last("limit 1");
|
||||
|
||||
final UserCard userCard = userCardService.getOne(wrapper);
|
||||
|
||||
return success(userCard);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询会员卡")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserCard>> page(UserCardParam param) {
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.gxwebsoft.booking.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.booking.service.UserCardLogService;
|
||||
import com.gxwebsoft.booking.entity.UserCardLog;
|
||||
import com.gxwebsoft.booking.param.UserCardLogParam;
|
||||
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-31 17:15:10
|
||||
*/
|
||||
@Api(tags = "明细表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/booking/user-card-log")
|
||||
public class UserCardLogController extends BaseController {
|
||||
@Resource
|
||||
private UserCardLogService userCardLogService;
|
||||
|
||||
@ApiOperation("分页查询明细表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserCardLog>> page(UserCardLogParam param) {
|
||||
// 使用关联查询
|
||||
return success(userCardLogService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部明细表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserCardLog>> list(UserCardLogParam param) {
|
||||
// 使用关联查询
|
||||
return success(userCardLogService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('booking:userCardLog:list')")
|
||||
@ApiOperation("根据id查询明细表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserCardLog> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userCardLogService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加明细表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserCardLog userCardLog) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userCardLog.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (userCardLogService.save(userCardLog)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改明细表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserCardLog userCardLog) {
|
||||
if (userCardLogService.updateById(userCardLog)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除明细表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userCardLogService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加明细表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserCardLog> list) {
|
||||
if (userCardLogService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改明细表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserCardLog> batchParam) {
|
||||
if (batchParam.update(userCardLogService, "log_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除明细表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userCardLogService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -113,6 +113,9 @@ public class UserCard implements Serializable {
|
||||
@ApiModelProperty(value = "1微信支付,2支付宝支付,3现金,4POS机刷卡,15平安健康卡")
|
||||
private Integer payType;
|
||||
|
||||
@ApiModelProperty(value = "0待支付,1已支付")
|
||||
private Integer payStatus;
|
||||
|
||||
@ApiModelProperty(value = "是否赠送积分:1赠送,2不赠送")
|
||||
private Integer isIntegral;
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
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;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
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-31 17:15:10
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "UserCardLog对象", description = "明细表")
|
||||
@TableName("booking_user_card_log")
|
||||
public class UserCardLog implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@TableId(value = "log_id", type = IdType.AUTO)
|
||||
private Integer logId;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "变动金额")
|
||||
private BigDecimal money;
|
||||
|
||||
@ApiModelProperty(value = "变动后余额")
|
||||
private BigDecimal balance;
|
||||
|
||||
@ApiModelProperty(value = "剩余使用次数")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "管理员备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "订单编号")
|
||||
private String orderNo;
|
||||
|
||||
@ApiModelProperty(value = "操作人ID")
|
||||
private Integer adminId;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@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 merchantId;
|
||||
|
||||
@ApiModelProperty(value = "商户编码")
|
||||
private String merchantCode;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -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.UserCardLog;
|
||||
import com.gxwebsoft.booking.param.UserCardLogParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 明细表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-05-31 17:15:10
|
||||
*/
|
||||
public interface UserCardLogMapper extends BaseMapper<UserCardLog> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<UserCardLog>
|
||||
*/
|
||||
List<UserCardLog> selectPageRel(@Param("page") IPage<UserCardLog> page,
|
||||
@Param("param") UserCardLogParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<UserCardLog> selectListRel(@Param("param") UserCardLogParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?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.UserCardLogMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM booking_user_card_log a
|
||||
<where>
|
||||
<if test="param.logId != null">
|
||||
AND a.log_id = #{param.logId}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</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.balance != null">
|
||||
AND a.balance = #{param.balance}
|
||||
</if>
|
||||
<if test="param.remark != null">
|
||||
AND a.remark LIKE CONCAT('%', #{param.remark}, '%')
|
||||
</if>
|
||||
<if test="param.orderNo != null">
|
||||
AND a.order_no LIKE CONCAT('%', #{param.orderNo}, '%')
|
||||
</if>
|
||||
<if test="param.adminId != null">
|
||||
AND a.admin_id = #{param.adminId}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</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.merchantId != null">
|
||||
AND a.merchant_id = #{param.merchantId}
|
||||
</if>
|
||||
<if test="param.merchantCode != null">
|
||||
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.booking.entity.UserCardLog">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.booking.entity.UserCardLog">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,78 @@
|
||||
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-31 17:15:09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "UserCardLogParam对象", description = "明细表查询参数")
|
||||
public class UserCardLogParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer logId;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "变动金额")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal money;
|
||||
|
||||
@ApiModelProperty(value = "变动后余额")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal balance;
|
||||
|
||||
@ApiModelProperty(value = "管理员备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "订单编号")
|
||||
private String orderNo;
|
||||
|
||||
@ApiModelProperty(value = "操作人ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer adminId;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@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;
|
||||
|
||||
@ApiModelProperty(value = "商户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer merchantId;
|
||||
|
||||
@ApiModelProperty(value = "商户编码")
|
||||
private String merchantCode;
|
||||
|
||||
}
|
||||
@@ -128,6 +128,10 @@ public class UserCardParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer payType;
|
||||
|
||||
@ApiModelProperty(value = "0待支付,1已支付")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer payStatus;
|
||||
|
||||
@ApiModelProperty(value = "是否赠送积分:1赠送,2不赠送")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer isIntegral;
|
||||
|
||||
@@ -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.UserCardLog;
|
||||
import com.gxwebsoft.booking.param.UserCardLogParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 明细表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-05-31 17:15:10
|
||||
*/
|
||||
public interface UserCardLogService extends IService<UserCardLog> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<UserCardLog>
|
||||
*/
|
||||
PageResult<UserCardLog> pageRel(UserCardLogParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<UserCardLog>
|
||||
*/
|
||||
List<UserCardLog> listRel(UserCardLogParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param logId 主键ID
|
||||
* @return UserCardLog
|
||||
*/
|
||||
UserCardLog getByIdRel(Integer logId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.booking.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.booking.mapper.UserCardLogMapper;
|
||||
import com.gxwebsoft.booking.service.UserCardLogService;
|
||||
import com.gxwebsoft.booking.entity.UserCardLog;
|
||||
import com.gxwebsoft.booking.param.UserCardLogParam;
|
||||
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-31 17:15:10
|
||||
*/
|
||||
@Service
|
||||
public class UserCardLogServiceImpl extends ServiceImpl<UserCardLogMapper, UserCardLog> implements UserCardLogService {
|
||||
|
||||
@Override
|
||||
public PageResult<UserCardLog> pageRel(UserCardLogParam param) {
|
||||
PageParam<UserCardLog, UserCardLogParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<UserCardLog> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserCardLog> listRel(UserCardLogParam param) {
|
||||
List<UserCardLog> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<UserCardLog, UserCardLogParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserCardLog getByIdRel(Integer logId) {
|
||||
UserCardLogParam param = new UserCardLogParam();
|
||||
param.setLogId(logId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -129,8 +129,8 @@ public class OrderController extends BaseController {
|
||||
order.setPhone(loginUser.getPhone());
|
||||
order.setUserId(loginUser.getUserId());
|
||||
order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.MINUTE, 10));
|
||||
if (order.getOrderInfoList() != null) {
|
||||
order.setTotalNum(order.getOrderInfoList().size());
|
||||
if (order.getOrderInfo() != null) {
|
||||
order.setTotalNum(order.getOrderInfo().size());
|
||||
}
|
||||
if (order.getGoodsList() != null) {
|
||||
order.setTotalNum(order.getGoodsList().size());
|
||||
@@ -151,7 +151,7 @@ public class OrderController extends BaseController {
|
||||
}
|
||||
// 预定订单
|
||||
if (order.getType().equals(1)) {
|
||||
order.getOrderInfoList().forEach(d -> {
|
||||
order.getOrderInfo().forEach(d -> {
|
||||
d.setOrderId(order.getOrderId());
|
||||
d.setTimeFlag(timeMillis);
|
||||
d.setVersion(10);
|
||||
@@ -159,7 +159,7 @@ public class OrderController extends BaseController {
|
||||
d.setDateTime(d.getDateTime());
|
||||
d.setExpirationTime(order.getExpirationTime());
|
||||
});
|
||||
orderInfoService.saveBatch(order.getOrderInfoList());
|
||||
orderInfoService.saveBatch(order.getOrderInfo());
|
||||
}
|
||||
// 会员卡订单
|
||||
if (order.getType().equals(2)) {
|
||||
@@ -178,6 +178,7 @@ public class OrderController extends BaseController {
|
||||
userCard.setCardDesc(card.getCardDesc());
|
||||
userCard.setInfo(card.getComments());
|
||||
userCard.setUid(loginUser.getUserId());
|
||||
userCard.setRemainingMoney(card.getPrice());
|
||||
userCard.setVid(0);
|
||||
userCard.setAid(0);
|
||||
userCard.setCode(CommonUtil.randomUUID8());
|
||||
@@ -192,17 +193,24 @@ public class OrderController extends BaseController {
|
||||
userCardService.save(userCard);
|
||||
}
|
||||
|
||||
// 微信统一下单接口
|
||||
if (order.getPayType().equals(1)) {
|
||||
return success("下单成功", orderService.createWxOrder(order));
|
||||
}
|
||||
|
||||
// 余额支付
|
||||
if (order.getPayType().equals(0)) {
|
||||
order.setAccessToken(access_token);
|
||||
order.setLoginUser(loginUser);
|
||||
return success("下单成功", orderService.payByBalance(order));
|
||||
}
|
||||
|
||||
// 微信统一下单接口
|
||||
if (order.getPayType().equals(1)) {
|
||||
return success("下单成功", orderService.createWxOrder(order));
|
||||
}
|
||||
|
||||
// 会员卡支付
|
||||
if(!Integer.valueOf(order.getCardId()).equals(0)){
|
||||
order.setAccessToken(access_token);
|
||||
order.setLoginUser(loginUser);
|
||||
return success("下单成功", orderService.payByUserCard(order));
|
||||
}
|
||||
}
|
||||
return fail("下单失败");
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public class Order implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "预定信息")
|
||||
@TableField(exist = false)
|
||||
private List<OrderInfo> orderInfoList;
|
||||
private List<OrderInfo> orderInfo;
|
||||
|
||||
@ApiModelProperty(value = "商品信息")
|
||||
@TableField(exist = false)
|
||||
|
||||
@@ -48,4 +48,6 @@ public interface OrderService extends IService<Order> {
|
||||
void updateByOutTradeNo(Order order);
|
||||
|
||||
Boolean payByBalance(Order order);
|
||||
|
||||
Boolean payByUserCard(Order order);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
@@ -72,6 +77,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private UserCardService userCardService;
|
||||
@Resource
|
||||
private UserCardLogService userCardLogService;
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@@ -100,7 +111,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
if (!collect.isEmpty()) {
|
||||
final List<OrderInfo> orderInfos = collect.get(d.getOrderId());
|
||||
if (!CollectionUtils.isEmpty(orderInfos)) {
|
||||
d.setOrderInfoList(orderInfos);
|
||||
d.setOrderInfo(orderInfos);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -143,7 +154,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
Order order = param.getOne(baseMapper.selectListRel(param));
|
||||
if (order != null) {
|
||||
final List<OrderInfo> list = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderId, orderId));
|
||||
order.setOrderInfoList(list);
|
||||
order.setOrderInfo(list);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
final OrderInfo orderInfo = list.get(0);
|
||||
final int i = orderInfo.getDateTime().compareTo(DateUtil.today());
|
||||
@@ -276,9 +287,57 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
balanceLog.setRemark(order.getComments());
|
||||
balanceLog.setMerchantId(order.getMerchantId());
|
||||
userBalanceLogService.save(balanceLog);
|
||||
// 修改订单状态
|
||||
order.setPayStatus(1);
|
||||
order.setPayTime(DateUtil.date());
|
||||
order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, 10));
|
||||
orderService.updateById(order);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Boolean payByUserCard(Order order) {
|
||||
final User loginUser = order.getLoginUser();
|
||||
final UserCardLog userCardLog = new UserCardLog();
|
||||
// 查询会员卡信息
|
||||
final UserCard userCard = userCardService.getById(order.getCardId());
|
||||
|
||||
// IC卡类型:1年卡,3月卡,5充值卡
|
||||
if (userCard.getType().equals(1) || userCard.getType().equals(3) || userCard.getType().equals(5)) {
|
||||
if (userCard.getRemainingMoney().compareTo(order.getPayPrice()) < 0) {
|
||||
throw new BusinessException("会员卡余额不足");
|
||||
}
|
||||
final BigDecimal subtract = userCard.getRemainingMoney().subtract(order.getPayPrice());
|
||||
userCardLog.setBalance(subtract);
|
||||
userCard.setRemainingMoney(subtract);
|
||||
}
|
||||
|
||||
// IC卡类型:2次卡
|
||||
if (userCard.getType().equals(2)) {
|
||||
if (userCard.getNum() <= 0) {
|
||||
throw new BusinessException("剩余次数不足");
|
||||
}
|
||||
userCardLog.setNum(userCard.getNum()-1);
|
||||
}
|
||||
userCardService.updateById(userCard);
|
||||
|
||||
// 记录明细
|
||||
userCardLog.setUserId(order.getUserId());
|
||||
userCardLog.setType(userCard.getType());
|
||||
userCardLog.setMoney(order.getPayPrice());
|
||||
userCardLog.setOrderNo(order.getOrderNo());
|
||||
userCardLog.setMerchantId(order.getMerchantId());
|
||||
userCardLog.setMerchantCode(order.getMerchantCode());
|
||||
userCardLogService.save(userCardLog);
|
||||
// 修改订单状态
|
||||
order.setPayStatus(1);
|
||||
order.setPayTime(DateUtil.date());
|
||||
order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, 10));
|
||||
orderService.updateById(order);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ public class BookingGenerator {
|
||||
// "booking_emergency",
|
||||
// "booking_user_coupon",
|
||||
// "booking_user_invoice",
|
||||
"booking_user_card",
|
||||
// "booking_user_card",
|
||||
"booking_user_card_log"
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
private static final String[] TABLE_PREFIX = new String[]{
|
||||
|
||||
Reference in New Issue
Block a user