123
This commit is contained in:
@@ -42,7 +42,7 @@ public class MemberPriceController extends BaseController {
|
||||
@SaCheckPermission("cai:memberPrice:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<MemberPrice> list(MemberPrice bo, PageQuery pageQuery) {
|
||||
Page<MemberPrice> page = memberPriceService.page(pageQuery.build(), Wrappers.lambdaQuery(bo));
|
||||
Page<MemberPrice> page = memberPriceService.page(pageQuery.build(), Wrappers.lambdaQuery(bo).orderByAsc(MemberPrice::getPrice));
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,17 +2,18 @@ package com.ruoyi.cai.controller.admin;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.domain.UserMember;
|
||||
import com.ruoyi.cai.dto.admin.vo.UserMemberAdminVo;
|
||||
import com.ruoyi.cai.service.UserMemberService;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
import com.ruoyi.cai.service.VipOrderService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -35,6 +36,8 @@ import java.util.Arrays;
|
||||
public class UserMemberController extends BaseController {
|
||||
|
||||
private final UserMemberService userMemberService;
|
||||
private final VipOrderService vipOrderService;
|
||||
private final UserService userService;
|
||||
|
||||
/**
|
||||
* 查询会员管理列表
|
||||
@@ -65,32 +68,24 @@ public class UserMemberController extends BaseController {
|
||||
@SaCheckPermission("cai:userMember:add")
|
||||
@Log(title = "会员管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody UserMember bo) {
|
||||
return toAjax(userMemberService.save(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改会员管理
|
||||
*/
|
||||
@SaCheckPermission("cai:userMember:edit")
|
||||
@Log(title = "会员管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody UserMember bo) {
|
||||
return toAjax(userMemberService.updateById(bo));
|
||||
@GetMapping("/addVip")
|
||||
public R<Void> add(Long memberPriceId, String usercode) {
|
||||
User user = userService.getByUserCode(usercode);
|
||||
if(user == null){
|
||||
return R.fail("用户不存在!");
|
||||
}
|
||||
vipOrderService.updateVipOrderAdmin(memberPriceId,user.getId());
|
||||
return toAjax(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员管理
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("cai:userMember:remove")
|
||||
@Log(title = "会员管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Integer[] ids) {
|
||||
return toAjax(userMemberService.removeBatchByIds(Arrays.asList(ids)));
|
||||
@DeleteMapping("/{id}")
|
||||
public R<Void> remove(@NotNull(message = "主键不能为空") @PathVariable Long id) {
|
||||
userMemberService.relieveMember(id);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ package com.ruoyi.cai.controller.admin;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.domain.VipOrder;
|
||||
import com.ruoyi.cai.dto.admin.vo.VipOrderAdminVo;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
import com.ruoyi.cai.service.VipOrderService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
@@ -13,7 +16,9 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.BeanConvertUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -34,14 +39,15 @@ import java.util.Arrays;
|
||||
public class VipOrderController extends BaseController {
|
||||
|
||||
private final VipOrderService vipOrderService;
|
||||
private final UserService userService;
|
||||
|
||||
/**
|
||||
* 查询VIP订单列表
|
||||
*/
|
||||
@SaCheckPermission("cai:vipOrder:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<VipOrder> list(VipOrder bo, PageQuery pageQuery) {
|
||||
Page<VipOrder> page = vipOrderService.page(pageQuery.build());
|
||||
public TableDataInfo<VipOrderAdminVo> list(VipOrderAdminVo bo, PageQuery pageQuery) {
|
||||
Page<VipOrderAdminVo> page = vipOrderService.pageAdmin(pageQuery,bo);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@@ -52,9 +58,15 @@ public class VipOrderController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("cai:vipOrder:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<VipOrder> getInfo(@NotNull(message = "主键不能为空")
|
||||
public R<VipOrderAdminVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(vipOrderService.getById(id));
|
||||
VipOrder vipOrder = vipOrderService.getById(id);
|
||||
VipOrderAdminVo res = BeanConvertUtil.convertTo(vipOrder, VipOrderAdminVo::new);
|
||||
User user = userService.getById(res.getUserId());
|
||||
if(user != null){
|
||||
BeanUtils.copyProperties(user,res);
|
||||
}
|
||||
return R.ok(res);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.cai.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@@ -24,7 +25,7 @@ public class MemberPrice implements Serializable {
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
private Long id;
|
||||
/**
|
||||
* 类型 0 普通 1 超级
|
||||
*/
|
||||
@@ -44,6 +45,7 @@ public class MemberPrice implements Serializable {
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@TableField(value = "`desc`")
|
||||
private String desc;
|
||||
/**
|
||||
* 有效期(天)
|
||||
|
||||
@@ -28,7 +28,7 @@ public class UserMember implements Serializable {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Integer userId;
|
||||
private Long userId;
|
||||
/**
|
||||
* MID
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ public class UserMember implements Serializable {
|
||||
*/
|
||||
private Integer memberType;
|
||||
/**
|
||||
* 过期时间
|
||||
* 过期时间(天)
|
||||
*/
|
||||
private Integer expire;
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ public class UserMember implements Serializable {
|
||||
/**
|
||||
* 状态 0-可用,1-过期,2-不可用
|
||||
*/
|
||||
private Integer status;
|
||||
private Integer memberStatus;
|
||||
/**
|
||||
* 永久状态 0-不是 1-是
|
||||
*/
|
||||
|
||||
@@ -38,6 +38,10 @@ public class VipOrder implements Serializable {
|
||||
* VIP名称
|
||||
*/
|
||||
private String vipName;
|
||||
/**
|
||||
* vip类型
|
||||
*/
|
||||
private Integer vipType;
|
||||
/**
|
||||
* VIP时长
|
||||
*/
|
||||
@@ -81,4 +85,6 @@ public class VipOrder implements Serializable {
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private Long adminId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.cai.dto.admin.vo;
|
||||
|
||||
import com.ruoyi.cai.domain.VipOrder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class VipOrderAdminVo extends VipOrder {
|
||||
/**
|
||||
* 用户号/ID号
|
||||
*/
|
||||
private String usercode;
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private Integer gender;
|
||||
private Integer age;
|
||||
private Integer isAnchor;
|
||||
|
||||
private boolean usedPay;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ruoyi.cai.dto.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AddVipOrderDto {
|
||||
|
||||
private Long userId;
|
||||
private Long memberPriceId;
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.ruoyi.cai.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.VipOrder;
|
||||
import com.ruoyi.cai.dto.admin.vo.VipOrderAdminVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* VIP订单Mapper接口
|
||||
@@ -11,4 +14,5 @@ import com.ruoyi.cai.domain.VipOrder;
|
||||
*/
|
||||
public interface VipOrderMapper extends BaseMapper<VipOrder> {
|
||||
|
||||
Page<VipOrderAdminVo> pageAdmin(@Param("build") Page<Object> build, @Param("bo") VipOrderAdminVo bo);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ruoyi.cai.pay;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum MemberStatusEnum {
|
||||
NORMAL(0,"可用"),
|
||||
EXPIRE(1,"过期"),
|
||||
FAIL(2,"不可用"),
|
||||
;
|
||||
private final Integer code;
|
||||
private final String name;
|
||||
|
||||
MemberStatusEnum(Integer code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
17
ruoyi-cai/src/main/java/com/ruoyi/cai/pay/OrderNoUtil.java
Normal file
17
ruoyi-cai/src/main/java/com/ruoyi/cai/pay/OrderNoUtil.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi.cai.pay;
|
||||
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
|
||||
|
||||
public class OrderNoUtil {
|
||||
|
||||
public static final Snowflake snowflake = IdUtil.getSnowflake(1, 1);
|
||||
|
||||
public static final String VIP_ORDER_SUB = "V";
|
||||
public static final String RECHARGE_ORDER_SUB = "R";
|
||||
|
||||
public static String createOrderNo(String sub){
|
||||
return sub + snowflake.nextIdStr();
|
||||
}
|
||||
}
|
||||
20
ruoyi-cai/src/main/java/com/ruoyi/cai/pay/PayStatusEnum.java
Normal file
20
ruoyi-cai/src/main/java/com/ruoyi/cai/pay/PayStatusEnum.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.cai.pay;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum PayStatusEnum {
|
||||
READY_PAY(0,"待支付"),
|
||||
PAY(1,"已支付"),
|
||||
REFUND(5,"已退款"),
|
||||
NO_PAY(10,"无需支付"),
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
private final String name;
|
||||
|
||||
PayStatusEnum(Integer code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.ruoyi.cai.pay;
|
||||
|
||||
public enum PlatformTypeEnum {
|
||||
ALI,WX,ADMIN
|
||||
}
|
||||
@@ -17,4 +17,6 @@ public interface UserMemberService extends IService<UserMember> {
|
||||
Page<UserMemberAdminVo> pageAdmin(PageQuery pageQuery, UserMemberAdminVo bo);
|
||||
|
||||
UserMember getByUserId(Long userId);
|
||||
|
||||
void relieveMember(Long id);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.ruoyi.cai.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cai.domain.VipOrder;
|
||||
import com.ruoyi.cai.dto.admin.vo.VipOrderAdminVo;
|
||||
import com.ruoyi.cai.dto.dto.AddVipOrderDto;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
|
||||
/**
|
||||
* VIP订单Service接口
|
||||
@@ -11,4 +15,13 @@ import com.ruoyi.cai.domain.VipOrder;
|
||||
*/
|
||||
public interface VipOrderService extends IService<VipOrder> {
|
||||
|
||||
VipOrder updateVipOrderAdmin(Long memberPriceId, Long userId);
|
||||
|
||||
VipOrder addVipOrder(AddVipOrderDto addVipOrder);
|
||||
|
||||
VipOrder getByOrderNo(String orderNo);
|
||||
|
||||
void orderSuccess(String orderNo);
|
||||
|
||||
Page<VipOrderAdminVo> pageAdmin(PageQuery pageQuery, VipOrderAdminVo bo);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,14 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
|
||||
@Autowired
|
||||
private ConsumeLogService consumeLogService;
|
||||
@Autowired
|
||||
private UserInviteService userInviteService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UnionUserService unionUserService;
|
||||
@Autowired
|
||||
private UnionService unionService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -77,15 +85,28 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
consumeLogService.save(consumeLog);
|
||||
return consumeLog;
|
||||
}
|
||||
@Autowired
|
||||
private UserInviteService userInviteService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UnionUserService unionUserService;
|
||||
@Autowired
|
||||
private UnionService unionService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void withdraw(Long userId, Long incomeCoin){
|
||||
Account account = this.getByUserId(userId);
|
||||
if(account == null){
|
||||
throw new ServiceException("无效账号");
|
||||
}
|
||||
if(account.getIncomeCoin() < incomeCoin){
|
||||
throw new ServiceException("需"+incomeCoin+"紫贝才可提现");
|
||||
}
|
||||
long incs = baseMapper.decrIncomeCoin(userId, incomeCoin);
|
||||
if(incs <= 0){
|
||||
throw new ServiceException("需"+incomeCoin+"紫贝才可提现");
|
||||
}
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<AccountAdminVo> pageAdmin(PageQuery pageQuery, AccountAdminVo bo) {
|
||||
return baseMapper.pageAdmin(pageQuery.build(),bo);
|
||||
}
|
||||
|
||||
private void fenxiao(CaiConsumeLog consumeLog){
|
||||
if(ConsumeLogType.PAY.getCode().equals(consumeLog.getType())){
|
||||
@@ -153,25 +174,4 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void withdraw(Long userId, Long incomeCoin){
|
||||
Account account = this.getByUserId(userId);
|
||||
if(account == null){
|
||||
throw new ServiceException("无效账号");
|
||||
}
|
||||
if(account.getIncomeCoin() < incomeCoin){
|
||||
throw new ServiceException("需"+incomeCoin+"紫贝才可提现");
|
||||
}
|
||||
long incs = baseMapper.decrIncomeCoin(userId, incomeCoin);
|
||||
if(incs <= 0){
|
||||
throw new ServiceException("需"+incomeCoin+"紫贝才可提现");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<AccountAdminVo> pageAdmin(PageQuery pageQuery, AccountAdminVo bo) {
|
||||
return baseMapper.pageAdmin(pageQuery.build(),bo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.UserMember;
|
||||
import com.ruoyi.cai.dto.admin.vo.UserMemberAdminVo;
|
||||
import com.ruoyi.cai.mapper.UserMemberMapper;
|
||||
import com.ruoyi.cai.pay.MemberStatusEnum;
|
||||
import com.ruoyi.cai.service.UserMemberService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -28,4 +29,11 @@ public class UserMemberServiceImpl extends ServiceImpl<UserMemberMapper, UserMem
|
||||
public UserMember getByUserId(Long userId) {
|
||||
return this.getOne(Wrappers.lambdaQuery(UserMember.class).eq(UserMember::getUserId,userId).last("limit 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relieveMember(Long id) {
|
||||
this.update(Wrappers.lambdaUpdate(UserMember.class)
|
||||
.eq(UserMember::getId,id)
|
||||
.set(UserMember::getMemberStatus, MemberStatusEnum.FAIL.getCode()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,30 @@
|
||||
package com.ruoyi.cai.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.MemberPrice;
|
||||
import com.ruoyi.cai.domain.UserMember;
|
||||
import com.ruoyi.cai.domain.VipOrder;
|
||||
import com.ruoyi.cai.dto.admin.vo.VipOrderAdminVo;
|
||||
import com.ruoyi.cai.dto.dto.AddVipOrderDto;
|
||||
import com.ruoyi.cai.mapper.VipOrderMapper;
|
||||
import com.ruoyi.cai.service.MemberSkillService;
|
||||
import com.ruoyi.cai.service.VipOrderService;
|
||||
import com.ruoyi.cai.pay.MemberStatusEnum;
|
||||
import com.ruoyi.cai.pay.OrderNoUtil;
|
||||
import com.ruoyi.cai.pay.PayStatusEnum;
|
||||
import com.ruoyi.cai.pay.PlatformTypeEnum;
|
||||
import com.ruoyi.cai.service.*;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* VIP订单Service业务层处理
|
||||
@@ -15,10 +33,145 @@ import org.springframework.stereotype.Service;
|
||||
* @date 2024-01-03
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class VipOrderServiceImpl extends ServiceImpl<VipOrderMapper,VipOrder> implements VipOrderService {
|
||||
|
||||
public void addVipOrder(){
|
||||
@Autowired
|
||||
private MemberPriceService memberPriceService;
|
||||
@Autowired
|
||||
private ConsumeLogService consumeLogService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserMemberService userMemberService;
|
||||
|
||||
/**
|
||||
* 强制修改VIP
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public VipOrder updateVipOrderAdmin(Long memberPriceId, Long userId){
|
||||
MemberPrice memberPrice = memberPriceService.getById(memberPriceId);
|
||||
if(memberPrice == null){
|
||||
throw new ServiceException("VIP价格错误");
|
||||
}
|
||||
VipOrder vipOrder = new VipOrder();
|
||||
vipOrder.setUserId(userId);
|
||||
vipOrder.setVipId(memberPrice.getId());
|
||||
vipOrder.setVipType(memberPrice.getMemberType());
|
||||
vipOrder.setVipName(memberPrice.getName());
|
||||
vipOrder.setVipExpire(memberPrice.getExpires());
|
||||
vipOrder.setVipLongs(memberPrice.getLongs());
|
||||
vipOrder.setPrice(memberPrice.getPrice());
|
||||
vipOrder.setOrderNo(OrderNoUtil.createOrderNo(OrderNoUtil.VIP_ORDER_SUB));
|
||||
vipOrder.setPayStatus(PayStatusEnum.NO_PAY.getCode());
|
||||
vipOrder.setPlatformType(PlatformTypeEnum.ADMIN.name());
|
||||
vipOrder.setOperateIp(ServletUtils.getClientIP());
|
||||
vipOrder.setAdmin(true);
|
||||
vipOrder.setAdminId(LoginHelper.getUserId());
|
||||
this.save(vipOrder);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
UserMember userMember = userMemberService.getByUserId(userId);
|
||||
if(userMember == null){
|
||||
userMember = new UserMember();
|
||||
}
|
||||
userMember.setUserId(userId);
|
||||
userMember.setMemberType(memberPrice.getMemberType());
|
||||
userMember.setExpire(memberPrice.getExpires());
|
||||
userMember.setLongs(memberPrice.getLongs());
|
||||
userMember.setExpireDate(now.plusDays(memberPrice.getExpires()));
|
||||
userMember.setCreateTime(now);
|
||||
userMember.setMemberStatus(MemberStatusEnum.NORMAL.getCode());
|
||||
userMemberService.saveOrUpdate(userMember);
|
||||
return vipOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VipOrder addVipOrder(AddVipOrderDto addVipOrder){
|
||||
Long memberPriceId = addVipOrder.getMemberPriceId();
|
||||
MemberPrice memberPrice = memberPriceService.getById(memberPriceId);
|
||||
if(memberPrice == null){
|
||||
throw new ServiceException("VIP价格错误");
|
||||
}
|
||||
VipOrder vipOrder = new VipOrder();
|
||||
vipOrder.setUserId(addVipOrder.getUserId());
|
||||
vipOrder.setVipId(memberPrice.getId());
|
||||
vipOrder.setVipType(memberPrice.getMemberType());
|
||||
vipOrder.setVipName(memberPrice.getName());
|
||||
vipOrder.setVipExpire(memberPrice.getExpires());
|
||||
vipOrder.setVipLongs(memberPrice.getLongs());
|
||||
vipOrder.setPrice(memberPrice.getPrice());
|
||||
vipOrder.setOrderNo(OrderNoUtil.createOrderNo(OrderNoUtil.VIP_ORDER_SUB));
|
||||
vipOrder.setPayStatus(PayStatusEnum.READY_PAY.getCode());
|
||||
this.save(vipOrder);
|
||||
return vipOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VipOrder getByOrderNo(String orderNo){
|
||||
return this.getOne(Wrappers.lambdaQuery(VipOrder.class).eq(VipOrder::getOrderNo,orderNo)
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void orderSuccess(String orderNo){
|
||||
VipOrder vipOrder = this.getByOrderNo(orderNo);
|
||||
if(vipOrder == null){
|
||||
throw new ServiceException("订单不存在");
|
||||
}
|
||||
if(!PayStatusEnum.READY_PAY.getCode().equals(vipOrder.getPayStatus())){
|
||||
log.error("订单支付状态错误!vipOrder={}", JSON.toJSONString(vipOrder));
|
||||
throw new ServiceException("订单支付状态错误!");
|
||||
}
|
||||
boolean update = this.update(Wrappers.lambdaUpdate(VipOrder.class)
|
||||
.eq(VipOrder::getOrderNo, vipOrder.getOrderNo())
|
||||
.eq(VipOrder::getPayStatus, PayStatusEnum.READY_PAY.getCode())
|
||||
.set(VipOrder::getPayStatus, PayStatusEnum.PAY.getCode()));
|
||||
if(!update){
|
||||
log.error("订单支付状态错误!vipOrder={}", JSON.toJSONString(vipOrder));
|
||||
throw new ServiceException("订单支付状态错误!");
|
||||
}
|
||||
// 新增会员
|
||||
incVip(vipOrder.getUserId(),vipOrder.getVipType(),vipOrder.getVipExpire(),vipOrder.getVipLongs());
|
||||
}
|
||||
|
||||
public boolean incVip(Long userId,Integer memberType,Integer expire,Integer longs){
|
||||
UserMember userMember = userMemberService.getByUserId(userId);
|
||||
LocalDateTime createTime = LocalDateTime.now();
|
||||
// 以前会员失效 , 买了不同的会员等级 不做续费操作
|
||||
if(userMember == null ||
|
||||
!MemberStatusEnum.NORMAL.getCode().equals(userMember.getMemberStatus()) || // 会员不可用
|
||||
userMember.getExpireDate().isBefore(createTime) || // 时间已经失效了 定时任务还没有执行
|
||||
!memberType.equals(userMember.getMemberType()) // 会员类型变更
|
||||
){
|
||||
if(userMember == null){
|
||||
userMember = new UserMember();
|
||||
}
|
||||
userMember.setUserId(userId);
|
||||
userMember.setMemberType(memberType);
|
||||
userMember.setExpire(expire);
|
||||
userMember.setLongs(longs);
|
||||
userMember.setExpireDate(createTime.plusDays(expire));
|
||||
userMember.setCreateTime(createTime);
|
||||
userMember.setMemberStatus(MemberStatusEnum.NORMAL.getCode());
|
||||
userMemberService.saveOrUpdate(userMember);
|
||||
return true;
|
||||
}
|
||||
if(longs == 1){ // 已经是永久会员还买? 什么都不干
|
||||
return true;
|
||||
}
|
||||
userMember.setCreateTime(createTime);
|
||||
userMember.setExpireDate(userMember.getExpireDate().plusDays(expire));
|
||||
userMember.setLongs(longs);
|
||||
userMemberService.saveOrUpdate(userMember);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VipOrderAdminVo> pageAdmin(PageQuery pageQuery, VipOrderAdminVo bo) {
|
||||
return baseMapper.pageAdmin(pageQuery.build(),bo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="expire" column="expire"/>
|
||||
<result property="rankHide" column="rank_hide"/>
|
||||
<result property="noGreet" column="no_greet"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="longs" column="longs"/>
|
||||
<result property="expireDate" column="expire_date"/>
|
||||
@@ -21,7 +20,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select t1.*,t2.age,t2.avatar,t2.usercode,t2.nickname,t2.mobile,t2.gender
|
||||
from cai_user_member t1
|
||||
join cai_user t2 on t1.user_id = t2.id
|
||||
where t1.status = 0
|
||||
<where>
|
||||
<if test="bo.mobile != null and bo.mobile != ''">
|
||||
and t2.mobile = #{bo.mobile}
|
||||
</if>
|
||||
<if test="bo.usercode != null and bo.usercode != ''">
|
||||
and t2.usercode = #{bo.usercode}
|
||||
</if>
|
||||
<if test="bo.memberStatus != null">
|
||||
and t1.member_status = #{bo.memberStatus}
|
||||
</if>
|
||||
</where>
|
||||
order by t1.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
@@ -21,6 +21,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="operateIp" column="operate_ip"/>
|
||||
<result property="admin" column="admin"/>
|
||||
</resultMap>
|
||||
<select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.VipOrderAdminVo">
|
||||
select t1.*,t2.usercode,t2.nickname,t2.mobile,t2.avatar,t2.gender,t2.is_anchor,t2.age
|
||||
from cai_vip_order t1
|
||||
left join cai_user t2 on t1.user_id = t2.id
|
||||
<where>
|
||||
<if test="bo.mobile != null and bo.mobile != ''">
|
||||
and t2.mobile = #{bo.mobile}
|
||||
</if>
|
||||
<if test="bo.usercode != null and bo.usercode != ''">
|
||||
and t2.usercode = #{bo.usercode}
|
||||
</if>
|
||||
<if test="bo.payStatus != null">
|
||||
and t1.pay_status = #{bo.payStatus}
|
||||
</if>
|
||||
<if test="bo.usedPay">
|
||||
and t1.pay_status != 0
|
||||
</if>
|
||||
</where>
|
||||
order by t1.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user