feat(qywx): 添加获取用户总余额功能
新增了获取企业微信用户总余额的功能,包括在QyUserService、QyUserMapper、QyUserApplicationService和QyUserController中添加相关方法和接口。同时,调整了ShopOrderGoodsMapper中的查询限制条件,并新增了用户VIP信息表和相关SQL脚本。
This commit is contained in:
parent
944a6bc722
commit
9dd57047b5
|
@ -20,18 +20,13 @@ import com.agileboot.domain.qywx.user.db.QyUserEntity;
|
|||
import com.agileboot.domain.qywx.user.dto.QyUserDTO;
|
||||
import com.agileboot.domain.qywx.user.query.SearchQyUserQuery;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/qywx/users")
|
||||
|
@ -108,4 +103,10 @@ public class QyUserController extends BaseController {
|
|||
UserIdResponse response = QywxApiUtil.convertToUserid(accessToken.getAccessToken(), openid);
|
||||
return ResponseDTO.ok(JSONUtil.toJsonStr(response));
|
||||
}
|
||||
|
||||
@GetMapping("/getTotalBalance")
|
||||
public ResponseDTO<BigDecimal> getTotalBalance(@RequestParam(required = false) String corpid) {
|
||||
BigDecimal totalBalance = qyUserApplicationService.selectTotalBalance(corpid);
|
||||
return ResponseDTO.ok(totalBalance);
|
||||
}
|
||||
}
|
|
@ -21,6 +21,8 @@ import com.agileboot.domain.system.user.db.SysUserEntity;
|
|||
import com.agileboot.domain.system.user.db.SysUserService;
|
||||
import com.agileboot.domain.system.user.dto.UserDTO;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -133,4 +135,8 @@ public class QyUserApplicationService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BigDecimal selectTotalBalance(String corpid) {
|
||||
return userService.selectTotalBalance(corpid);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
@ -43,4 +45,14 @@ public interface QyUserMapper extends BaseMapper<QyUserEntity> {
|
|||
"AND sr.role_key = 'admin'")
|
||||
List<String> selectAdminUserIds();
|
||||
|
||||
@Select("SELECT SUM(balance) " +
|
||||
"FROM qy_user " +
|
||||
"WHERE deleted = 0")
|
||||
BigDecimal selectTotalBalance();
|
||||
|
||||
@Select("SELECT SUM(balance) " +
|
||||
"FROM qy_user " +
|
||||
"WHERE deleted = 0 AND corpid = #{corpid}")
|
||||
BigDecimal selectTotalBalanceByCorpid(@Param("corpid") String corpid);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.agileboot.domain.qywx.user.db;
|
|||
import com.agileboot.common.core.page.AbstractPageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -22,4 +24,6 @@ public interface QyUserService extends IService<QyUserEntity> {
|
|||
QyUserEntity getUserByUserId(String userid, String corpid);
|
||||
|
||||
List<String> selectAdminUserIds();
|
||||
|
||||
BigDecimal selectTotalBalance(String corpid);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.agileboot.domain.qywx.user.db;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
@ -14,6 +15,8 @@ import org.springframework.stereotype.Service;
|
|||
import com.agileboot.common.core.page.AbstractPageQuery;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -43,4 +46,13 @@ public class QyUserServiceImpl extends ServiceImpl<QyUserMapper, QyUserEntity> i
|
|||
public List<String> selectAdminUserIds() {
|
||||
return baseMapper.selectAdminUserIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal selectTotalBalance(String corpid) {
|
||||
if (StringUtils.isBlank(corpid)) {
|
||||
return baseMapper.selectTotalBalance();
|
||||
} else {
|
||||
return baseMapper.selectTotalBalanceByCorpid(corpid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.agileboot.domain.qywx.user.query;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.core.page.AbstractPageQuery;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -21,6 +23,8 @@ public class SearchQyUserQuery<T> extends AbstractPageQuery<T> {
|
|||
private Date startTime;
|
||||
private Date endTime;
|
||||
private Long sysRoleId;
|
||||
// 是否查询余额大于0的用户,1为是
|
||||
private Integer balancePage;
|
||||
|
||||
@Override
|
||||
public QueryWrapper<T> addQueryCondition() {
|
||||
|
@ -35,6 +39,7 @@ public class SearchQyUserQuery<T> extends AbstractPageQuery<T> {
|
|||
.eq(StrUtil.isNotBlank(department), "department", department)
|
||||
.eq(StrUtil.isNotBlank(mainDepartment), "main_department", mainDepartment)
|
||||
.eq(StrUtil.isNotBlank(enable), "enable", enable)
|
||||
.gt(balancePage != null && balancePage.equals(1), "balance", BigDecimal.ZERO)
|
||||
.between(startTime != null && endTime != null, "create_time", startTime, endTime)
|
||||
.orderByDesc("id");
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public interface ShopOrderGoodsMapper extends BaseMapper<ShopOrderGoodsEntity> {
|
|||
"WHERE sog.deleted = 0 AND sg.deleted = 0 AND sog.goods_id != 6 " +
|
||||
"GROUP BY sog.goods_id, sg.goods_name, sg.cover_img " +
|
||||
"ORDER BY occurrence_count DESC " +
|
||||
"LIMIT 10")
|
||||
"LIMIT 9")
|
||||
List<TopGoodsDTO> selectTopGoodsByOccurrence();
|
||||
|
||||
@Select("SELECT sog.*, so.name AS buyer_name " +
|
||||
|
@ -39,7 +39,7 @@ public interface ShopOrderGoodsMapper extends BaseMapper<ShopOrderGoodsEntity> {
|
|||
"WHERE sog.deleted = 0 AND so.deleted = 0 " +
|
||||
"AND DATE(sog.create_time) = CURRENT_DATE " +
|
||||
"ORDER BY sog.create_time DESC " +
|
||||
"LIMIT 10")
|
||||
"LIMIT 4")
|
||||
List<TodayLatestOrderGoodsDTO> selectTodayLatestOrderGoods();
|
||||
|
||||
@Select("SELECT og.* " +
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
DROP TABLE IF EXISTS `ab98_user_vip`;
|
||||
|
||||
CREATE TABLE `ab98_user_vip` (
|
||||
`vip_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`ab98_user_id` BIGINT NOT NULL COMMENT '关联用户ID',
|
||||
`vip_level` TINYINT NOT NULL DEFAULT 1 COMMENT 'VIP等级',
|
||||
`start_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '会员开始时间',
|
||||
`end_time` DATETIME NULL COMMENT '会员结束时间',
|
||||
`status` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '状态(1有效 0无效)',
|
||||
`creator_id` BIGINT DEFAULT 0 COMMENT '创建者ID',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater_id` BIGINT DEFAULT 0 COMMENT '更新者ID',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '删除标志(0存在 1删除)',
|
||||
PRIMARY KEY (`vip_id`),
|
||||
KEY `idx_user` (`ab98_user_id`),
|
||||
KEY `idx_level` (`vip_level`),
|
||||
CONSTRAINT `fk_vip_user` FOREIGN KEY (`ab98_user_id`) REFERENCES `ab98_user` (`ab98_user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户VIP信息表';
|
||||
|
||||
DROP TABLE IF EXISTS `ab98_vip_level`;
|
||||
|
||||
CREATE TABLE `ab98_vip_level` (
|
||||
`level_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`level_name` VARCHAR(50) NOT NULL COMMENT '等级名称',
|
||||
`level_value` TINYINT NOT NULL COMMENT '等级值',
|
||||
`discount_rate` DECIMAL(5,2) NOT NULL COMMENT '折扣率',
|
||||
`point_multiplier` DECIMAL(5,2) NOT NULL COMMENT '积分倍数',
|
||||
`free_shipping` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否免邮(0否 1是)',
|
||||
`birthday_benefit` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '生日特权(0无 1有)',
|
||||
`creator_id` BIGINT DEFAULT 0 COMMENT '创建者ID',
|
||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater_id` BIGINT DEFAULT 0 COMMENT '更新者ID',
|
||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '删除标志(0存在 1删除)',
|
||||
PRIMARY KEY (`level_id`),
|
||||
UNIQUE KEY `uk_level` (`level_value`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='VIP等级权限表';
|
Loading…
Reference in New Issue