新增:会员卡使用明细
This commit is contained in:
@@ -46,14 +46,12 @@ public class UserCardController extends BaseController {
|
|||||||
LambdaUpdateWrapper<UserCard> wrapper = new LambdaUpdateWrapper<>();
|
LambdaUpdateWrapper<UserCard> wrapper = new LambdaUpdateWrapper<>();
|
||||||
|
|
||||||
wrapper.eq(UserCard::getUserId, loginUser.getUserId())
|
wrapper.eq(UserCard::getUserId, loginUser.getUserId())
|
||||||
.like(UserCard::getSid, param.getSid())
|
|
||||||
.eq(UserCard::getPayStatus,1)
|
.eq(UserCard::getPayStatus,1)
|
||||||
.gt(UserCard::getExpirationTime, DateUtil.date())
|
.like(UserCard::getSid, param.getSid())
|
||||||
|
.lt(UserCard::getExpirationTime, DateUtil.now())
|
||||||
.last("limit 1");
|
.last("limit 1");
|
||||||
|
System.out.println("wrapper = " + wrapper);
|
||||||
final UserCard userCard = userCardService.getOne(wrapper);
|
return success(userCardService.getOne(wrapper));
|
||||||
|
|
||||||
return success(userCard);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("分页查询会员卡")
|
@ApiOperation("分页查询会员卡")
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.util.List;
|
|||||||
* 明细表控制器
|
* 明细表控制器
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-05-31 17:15:10
|
* @since 2024-06-01 12:59:38
|
||||||
*/
|
*/
|
||||||
@Api(tags = "明细表管理")
|
@Api(tags = "明细表管理")
|
||||||
@RestController
|
@RestController
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
package com.gxwebsoft.booking.entity;
|
package com.gxwebsoft.booking.entity;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
* 明细表
|
* 明细表
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-05-31 17:15:10
|
* @since 2024-06-01 12:59:38
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@@ -34,6 +33,12 @@ public class UserCardLog implements Serializable {
|
|||||||
@ApiModelProperty(value = "用户ID")
|
@ApiModelProperty(value = "用户ID")
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "会员卡ID")
|
||||||
|
private Integer userCardId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "会员卡卡号")
|
||||||
|
private String cardNum;
|
||||||
|
|
||||||
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
|
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@@ -43,7 +48,7 @@ public class UserCardLog implements Serializable {
|
|||||||
@ApiModelProperty(value = "变动后余额")
|
@ApiModelProperty(value = "变动后余额")
|
||||||
private BigDecimal balance;
|
private BigDecimal balance;
|
||||||
|
|
||||||
@ApiModelProperty(value = "剩余使用次数")
|
@ApiModelProperty(value = "剩余次数")
|
||||||
private Integer num;
|
private Integer num;
|
||||||
|
|
||||||
@ApiModelProperty(value = "管理员备注")
|
@ApiModelProperty(value = "管理员备注")
|
||||||
@@ -83,4 +88,8 @@ public class UserCardLog implements Serializable {
|
|||||||
@ApiModelProperty(value = "修改时间")
|
@ApiModelProperty(value = "修改时间")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "会员卡名称")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String cardName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
* 明细表Mapper
|
* 明细表Mapper
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-05-31 17:15:10
|
* @since 2024-06-01 12:59:38
|
||||||
*/
|
*/
|
||||||
public interface UserCardLogMapper extends BaseMapper<UserCardLog> {
|
public interface UserCardLogMapper extends BaseMapper<UserCardLog> {
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,12 @@
|
|||||||
<if test="param.userId != null">
|
<if test="param.userId != null">
|
||||||
AND a.user_id = #{param.userId}
|
AND a.user_id = #{param.userId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="param.userCardId != null">
|
||||||
|
AND a.user_card_id = #{param.userCardId}
|
||||||
|
</if>
|
||||||
|
<if test="param.cardNum != null">
|
||||||
|
AND a.card_num LIKE CONCAT('%', #{param.cardNum}, '%')
|
||||||
|
</if>
|
||||||
<if test="param.type != null">
|
<if test="param.type != null">
|
||||||
AND a.type = #{param.type}
|
AND a.type = #{param.type}
|
||||||
</if>
|
</if>
|
||||||
@@ -22,6 +28,9 @@
|
|||||||
<if test="param.balance != null">
|
<if test="param.balance != null">
|
||||||
AND a.balance = #{param.balance}
|
AND a.balance = #{param.balance}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="param.num != null">
|
||||||
|
AND a.num = #{param.num}
|
||||||
|
</if>
|
||||||
<if test="param.remark != null">
|
<if test="param.remark != null">
|
||||||
AND a.remark LIKE CONCAT('%', #{param.remark}, '%')
|
AND a.remark LIKE CONCAT('%', #{param.remark}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -44,6 +44,9 @@
|
|||||||
<if test="param.price != null">
|
<if test="param.price != null">
|
||||||
AND a.price = #{param.price}
|
AND a.price = #{param.price}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="param.payStatus != null">
|
||||||
|
AND a.pay_status = #{param.payStatus}
|
||||||
|
</if>
|
||||||
<if test="param.cardDesc != null">
|
<if test="param.cardDesc != null">
|
||||||
AND a.card_desc LIKE CONCAT('%', #{param.cardDesc}, '%')
|
AND a.card_desc LIKE CONCAT('%', #{param.cardDesc}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
* 明细表查询参数
|
* 明细表查询参数
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-05-31 17:15:09
|
* @since 2024-06-01 12:59:38
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@@ -31,6 +31,13 @@ public class UserCardLogParam extends BaseParam {
|
|||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "会员卡ID")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer userCardId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "会员卡卡号")
|
||||||
|
private String cardNum;
|
||||||
|
|
||||||
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
|
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer type;
|
private Integer type;
|
||||||
@@ -43,6 +50,10 @@ public class UserCardLogParam extends BaseParam {
|
|||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private BigDecimal balance;
|
private BigDecimal balance;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "剩余次数")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer num;
|
||||||
|
|
||||||
@ApiModelProperty(value = "管理员备注")
|
@ApiModelProperty(value = "管理员备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
* 明细表Service
|
* 明细表Service
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-05-31 17:15:10
|
* @since 2024-06-01 12:59:38
|
||||||
*/
|
*/
|
||||||
public interface UserCardLogService extends IService<UserCardLog> {
|
public interface UserCardLogService extends IService<UserCardLog> {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.gxwebsoft.booking.service.impl;
|
package com.gxwebsoft.booking.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.gxwebsoft.booking.entity.UserCard;
|
import com.gxwebsoft.booking.entity.UserCard;
|
||||||
@@ -11,6 +12,7 @@ import com.gxwebsoft.booking.service.UserCardService;
|
|||||||
import com.gxwebsoft.common.core.web.PageParam;
|
import com.gxwebsoft.common.core.web.PageParam;
|
||||||
import com.gxwebsoft.common.core.web.PageResult;
|
import com.gxwebsoft.common.core.web.PageResult;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -37,8 +39,10 @@ public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements Ca
|
|||||||
if(param.getSceneType() != null && param.getSceneType().equals("showCanBuyVipCard")){
|
if(param.getSceneType() != null && param.getSceneType().equals("showCanBuyVipCard")){
|
||||||
final List<UserCard> userCardList = userCardService.list(new LambdaUpdateWrapper<UserCard>().eq(UserCard::getUserId, param.getBuyUserId()));
|
final List<UserCard> userCardList = userCardService.list(new LambdaUpdateWrapper<UserCard>().eq(UserCard::getUserId, param.getBuyUserId()));
|
||||||
final Set<Integer> collect = userCardList.stream().map(UserCard::getCardId).collect(Collectors.toSet());
|
final Set<Integer> collect = userCardList.stream().map(UserCard::getCardId).collect(Collectors.toSet());
|
||||||
|
if (!CollectionUtils.isEmpty(collect)) {
|
||||||
param.setCardIds(collect);
|
param.setCardIds(collect);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<Card> list = baseMapper.selectPageRel(page, param);
|
List<Card> list = baseMapper.selectPageRel(page, param);
|
||||||
return new PageResult<>(list, page.getTotal());
|
return new PageResult<>(list, page.getTotal());
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.gxwebsoft.booking.param.UserCardLogParam;
|
|||||||
import com.gxwebsoft.common.core.web.PageParam;
|
import com.gxwebsoft.common.core.web.PageParam;
|
||||||
import com.gxwebsoft.common.core.web.PageResult;
|
import com.gxwebsoft.common.core.web.PageResult;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ import java.util.List;
|
|||||||
* 明细表Service实现
|
* 明细表Service实现
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-05-31 17:15:10
|
* @since 2024-06-01 12:59:38
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class UserCardLogServiceImpl extends ServiceImpl<UserCardLogMapper, UserCardLog> implements UserCardLogService {
|
public class UserCardLogServiceImpl extends ServiceImpl<UserCardLogMapper, UserCardLog> implements UserCardLogService {
|
||||||
|
|||||||
@@ -193,22 +193,23 @@ public class OrderController extends BaseController {
|
|||||||
userCard.setTenantId(card.getTenantId());
|
userCard.setTenantId(card.getTenantId());
|
||||||
userCard.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.MONTH, card.getMonth()));
|
userCard.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.MONTH, card.getMonth()));
|
||||||
userCardService.save(userCard);
|
userCardService.save(userCard);
|
||||||
|
order.setCardId(userCard.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 余额支付
|
// TODO 余额支付
|
||||||
if (order.getPayType().equals(0)) {
|
if (order.getPayType().equals(0)) {
|
||||||
order.setAccessToken(access_token);
|
order.setAccessToken(access_token);
|
||||||
order.setLoginUser(loginUser);
|
order.setLoginUser(loginUser);
|
||||||
return success("下单成功", orderService.payByBalance(order));
|
return success("下单成功", orderService.payByBalance(order));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 微信统一下单接口
|
// TODO 微信统一下单接口
|
||||||
if (order.getPayType().equals(1)) {
|
if (order.getPayType().equals(1)) {
|
||||||
return success("下单成功", orderService.createWxOrder(order));
|
return success("下单成功", orderService.createWxOrder(order));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 会员卡支付
|
// TODO 会员卡支付
|
||||||
if(order.getPayType().equals(7)){
|
if(order.getPayType().equals(2)){
|
||||||
order.setAccessToken(access_token);
|
order.setAccessToken(access_token);
|
||||||
order.setLoginUser(loginUser);
|
order.setLoginUser(loginUser);
|
||||||
return success("下单成功", orderService.payByUserCard(order));
|
return success("下单成功", orderService.payByUserCard(order));
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import cn.hutool.core.util.NumberUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.gxwebsoft.booking.entity.UserCard;
|
||||||
|
import com.gxwebsoft.booking.service.UserCardService;
|
||||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||||
import com.gxwebsoft.common.core.web.BaseController;
|
import com.gxwebsoft.common.core.web.BaseController;
|
||||||
@@ -46,6 +48,8 @@ public class WxPayNotifyController extends BaseController {
|
|||||||
@Resource
|
@Resource
|
||||||
private OrderInfoService orderInfoService;
|
private OrderInfoService orderInfoService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private UserCardService userCardService;
|
||||||
|
@Resource
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
@Resource
|
@Resource
|
||||||
private ConfigProperties conf;
|
private ConfigProperties conf;
|
||||||
@@ -124,6 +128,12 @@ public class WxPayNotifyController extends BaseController {
|
|||||||
orderService.updateByOutTradeNo(order);
|
orderService.updateByOutTradeNo(order);
|
||||||
// 6. TODO 同步更新订单明细的支付状态
|
// 6. TODO 同步更新订单明细的支付状态
|
||||||
orderInfoService.updateByOutTradeNo(order);
|
orderInfoService.updateByOutTradeNo(order);
|
||||||
|
// 7.同步会员卡状态
|
||||||
|
if(order.getType().equals(2)){
|
||||||
|
final UserCard userCard = userCardService.getById(order.getCardId());
|
||||||
|
userCard.setPayStatus(1);
|
||||||
|
userCardService.updateById(userCard);
|
||||||
|
}
|
||||||
return "SUCCESS";
|
return "SUCCESS";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class Order implements Serializable {
|
|||||||
@TableId(value = "order_id", type = IdType.AUTO)
|
@TableId(value = "order_id", type = IdType.AUTO)
|
||||||
private Integer orderId;
|
private Integer orderId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "订单类型,0商城订单 1客户预定 2俱乐部训练场 3活动订场")
|
@ApiModelProperty(value = "订单类型,0商城订单 1预定订单 2会员卡")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@ApiModelProperty(value = "下单渠道,0普通预定 1俱乐部训练场 3活动订场")
|
@ApiModelProperty(value = "下单渠道,0普通预定 1俱乐部训练场 3活动订场")
|
||||||
@@ -65,7 +65,7 @@ public class Order implements Serializable {
|
|||||||
private Integer couponId;
|
private Integer couponId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "使用的会员卡id")
|
@ApiModelProperty(value = "使用的会员卡id")
|
||||||
private String cardId;
|
private Integer cardId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "关联管理员id")
|
@ApiModelProperty(value = "关联管理员id")
|
||||||
private Integer adminId;
|
private Integer adminId;
|
||||||
|
|||||||
@@ -63,8 +63,13 @@ public class OrderParam extends BaseParam {
|
|||||||
private Integer couponId;
|
private Integer couponId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "使用的会员卡id")
|
@ApiModelProperty(value = "使用的会员卡id")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
private String cardId;
|
private String cardId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户会员卡ID")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer userCardId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "关联管理员id")
|
@ApiModelProperty(value = "关联管理员id")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer adminId;
|
private Integer adminId;
|
||||||
|
|||||||
@@ -292,6 +292,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
order.setPayTime(DateUtil.date());
|
order.setPayTime(DateUtil.date());
|
||||||
order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, 10));
|
order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, 10));
|
||||||
orderService.updateById(order);
|
orderService.updateById(order);
|
||||||
|
// 更新会员卡状态
|
||||||
|
if(order.getType().equals(2)){
|
||||||
|
final UserCard userCard = userCardService.getById(order.getCardId());
|
||||||
|
userCard.setPayStatus(1);
|
||||||
|
userCardService.updateById(userCard);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -329,6 +335,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
|
|
||||||
// 记录明细
|
// 记录明细
|
||||||
userCardLog.setUserId(order.getUserId());
|
userCardLog.setUserId(order.getUserId());
|
||||||
|
userCardLog.setUserCardId(userCard.getId());
|
||||||
|
userCardLog.setCardNum(userCard.getCardNum());
|
||||||
|
userCardLog.setComments(order.getComments());
|
||||||
userCardLog.setType(userCard.getType());
|
userCardLog.setType(userCard.getType());
|
||||||
userCardLog.setMoney(order.getPayPrice());
|
userCardLog.setMoney(order.getPayPrice());
|
||||||
userCardLog.setOrderNo(order.getOrderNo());
|
userCardLog.setOrderNo(order.getOrderNo());
|
||||||
|
|||||||
Reference in New Issue
Block a user