Merge branch 'refs/heads/zs' into gyj

This commit is contained in:
GYJ 2024-07-06 14:37:25 +08:00
commit 26b30519c8
14 changed files with 487 additions and 6 deletions

View File

@ -49,7 +49,7 @@ public interface TbConsInfoService {
* 编辑
* @param resources /
*/
void update(TbConsInfo resources);
void update(TbConsInfo resources) throws Exception;
/**
* 多选删除

View File

@ -30,4 +30,7 @@ public class TbConsInfoQueryCriteria{
/** 精确 */
@Query
private Integer shopId;
@Query
private String status;
}

View File

@ -117,9 +117,21 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbConsInfo resources) {
public void update(TbConsInfo resources) throws Exception {
TbConsInfo tbConsInfo = tbConsInfoRepository.findById(resources.getId()).orElseGet(TbConsInfo::new);
ValidationUtil.isNull( tbConsInfo.getId(),"TbConsInfo","id",resources.getId());
if(Objects.isNull(tbConsInfo)){
throw new Exception("耗材信息不存在");
}
tbConsInfo.setConCode(resources.getConCode());
tbConsInfo.setConName(resources.getConName());
tbConsInfo.setPrice(resources.getPrice());
tbConsInfo.setConUnit(resources.getConUnit());
tbConsInfo.setConWarning(resources.getConWarning());
tbConsInfo.setStatus(resources.getStatus());
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoRepository.save(tbConsInfo);
}

View File

@ -1,5 +1,6 @@
package cn.ysk.cashier.controller.shop;
import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.dto.ShopSummaryDto;
import cn.ysk.cashier.service.SummaryService;

View File

@ -1,6 +1,10 @@
package cn.ysk.cashier.controller.shop;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.service.TbMShopUserService;
import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.service.shop.TbShopUserService;
import io.swagger.annotations.Api;
@ -27,6 +31,7 @@ import java.io.IOException;
public class TbShopUserController {
private final TbShopUserService tbShopUserService;
private final TbMShopUserService tbMShopUserService;
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@ -46,6 +51,16 @@ public class TbShopUserController {
return new ResponseEntity<>(tbShopUserService.queryShopUser(criteria),HttpStatus.OK);
}
@AnonymousAccess
@GetMapping("summary")
@ApiOperation("查询会员概述")
public ResponseEntity<Object> summary(TbShopUserQueryCriteria criteria){
if (StrUtil.isBlank(criteria.getShopId())) {
throw new BadRequestException("店铺id不为空");
}
return new ResponseEntity<>(tbMShopUserService.summary(criteria),HttpStatus.OK);
}
@PostMapping
@ApiOperation("新增/shop/user")
@ -66,4 +81,4 @@ public class TbShopUserController {
tbShopUserService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}
}

View File

@ -0,0 +1,284 @@
package cn.ysk.cashier.mybatis.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
/**
* 商户储值会员
* @TableName tb_shop_user
*/
@Table(name="tb_shop_user")
@Data
public class TbMShopUser implements Serializable {
/**
* (随机)
*/
@Id
private Integer id;
/**
* 钱包余额
*/
private BigDecimal amount;
/**
* 授权金额
*/
private BigDecimal credit_amount;
/**
* 消费累计
*/
private BigDecimal consume_amount;
/**
* 消费数量累计
*/
private Integer consume_number;
/**
* 等级积分
*/
private BigDecimal level_consume;
/**
* 0-不可使用 1可使用
*/
private Integer status;
/**
* 代理Id
*/
private String merchant_id;
/**
* 店铺Id
*/
private String shop_id;
/**
* 用户Id
*/
private String user_id;
/**
* 上级Id
*/
private String parent_id;
/**
* 上级的层级
*/
private String parent_level;
/**
* 真实名字
*/
private String name;
/**
*
*/
private String head_img;
/**
* 性别
*/
private Integer sex;
/**
* 生日
*/
private String birth_day;
/**
* 联系电话
*/
private String telephone;
/**
* 是否会员
*/
private Integer is_vip;
/**
* 会员编号
*/
private String code;
/**
* 是否通过关注而成为会员的此字段固定后不改
*/
private Integer is_attention;
/**
* 关注时间
*/
private Integer attention_at;
/**
* 是否股东分销商
*/
private Integer is_shareholder;
/**
* 层级1-顶级 2-次级 3最低
*/
private Integer level;
/**
* 分销类型 auto-自动获取 set手动设置 charge充值
*/
private String distribute_type;
/**
* 排序
*/
private Integer sort;
/**
*
*/
private Long created_at;
/**
*
*/
private Long updated_at;
/**
* 小程序openId
*/
private String mini_open_id;
/**
* 会员码
*/
private String dynamic_code;
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
TbMShopUser other = (TbMShopUser) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
&& (this.getCredit_amount() == null ? other.getCredit_amount() == null : this.getCredit_amount().equals(other.getCredit_amount()))
&& (this.getConsume_amount() == null ? other.getConsume_amount() == null : this.getConsume_amount().equals(other.getConsume_amount()))
&& (this.getConsume_number() == null ? other.getConsume_number() == null : this.getConsume_number().equals(other.getConsume_number()))
&& (this.getLevel_consume() == null ? other.getLevel_consume() == null : this.getLevel_consume().equals(other.getLevel_consume()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getMerchant_id() == null ? other.getMerchant_id() == null : this.getMerchant_id().equals(other.getMerchant_id()))
&& (this.getShop_id() == null ? other.getShop_id() == null : this.getShop_id().equals(other.getShop_id()))
&& (this.getUser_id() == null ? other.getUser_id() == null : this.getUser_id().equals(other.getUser_id()))
&& (this.getParent_id() == null ? other.getParent_id() == null : this.getParent_id().equals(other.getParent_id()))
&& (this.getParent_level() == null ? other.getParent_level() == null : this.getParent_level().equals(other.getParent_level()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getHead_img() == null ? other.getHead_img() == null : this.getHead_img().equals(other.getHead_img()))
&& (this.getSex() == null ? other.getSex() == null : this.getSex().equals(other.getSex()))
&& (this.getBirth_day() == null ? other.getBirth_day() == null : this.getBirth_day().equals(other.getBirth_day()))
&& (this.getTelephone() == null ? other.getTelephone() == null : this.getTelephone().equals(other.getTelephone()))
&& (this.getIs_vip() == null ? other.getIs_vip() == null : this.getIs_vip().equals(other.getIs_vip()))
&& (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()))
&& (this.getIs_attention() == null ? other.getIs_attention() == null : this.getIs_attention().equals(other.getIs_attention()))
&& (this.getAttention_at() == null ? other.getAttention_at() == null : this.getAttention_at().equals(other.getAttention_at()))
&& (this.getIs_shareholder() == null ? other.getIs_shareholder() == null : this.getIs_shareholder().equals(other.getIs_shareholder()))
&& (this.getLevel() == null ? other.getLevel() == null : this.getLevel().equals(other.getLevel()))
&& (this.getDistribute_type() == null ? other.getDistribute_type() == null : this.getDistribute_type().equals(other.getDistribute_type()))
&& (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort()))
&& (this.getCreated_at() == null ? other.getCreated_at() == null : this.getCreated_at().equals(other.getCreated_at()))
&& (this.getUpdated_at() == null ? other.getUpdated_at() == null : this.getUpdated_at().equals(other.getUpdated_at()))
&& (this.getMini_open_id() == null ? other.getMini_open_id() == null : this.getMini_open_id().equals(other.getMini_open_id()))
&& (this.getDynamic_code() == null ? other.getDynamic_code() == null : this.getDynamic_code().equals(other.getDynamic_code()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
result = prime * result + ((getCredit_amount() == null) ? 0 : getCredit_amount().hashCode());
result = prime * result + ((getConsume_amount() == null) ? 0 : getConsume_amount().hashCode());
result = prime * result + ((getConsume_number() == null) ? 0 : getConsume_number().hashCode());
result = prime * result + ((getLevel_consume() == null) ? 0 : getLevel_consume().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getMerchant_id() == null) ? 0 : getMerchant_id().hashCode());
result = prime * result + ((getShop_id() == null) ? 0 : getShop_id().hashCode());
result = prime * result + ((getUser_id() == null) ? 0 : getUser_id().hashCode());
result = prime * result + ((getParent_id() == null) ? 0 : getParent_id().hashCode());
result = prime * result + ((getParent_level() == null) ? 0 : getParent_level().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getHead_img() == null) ? 0 : getHead_img().hashCode());
result = prime * result + ((getSex() == null) ? 0 : getSex().hashCode());
result = prime * result + ((getBirth_day() == null) ? 0 : getBirth_day().hashCode());
result = prime * result + ((getTelephone() == null) ? 0 : getTelephone().hashCode());
result = prime * result + ((getIs_vip() == null) ? 0 : getIs_vip().hashCode());
result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
result = prime * result + ((getIs_attention() == null) ? 0 : getIs_attention().hashCode());
result = prime * result + ((getAttention_at() == null) ? 0 : getAttention_at().hashCode());
result = prime * result + ((getIs_shareholder() == null) ? 0 : getIs_shareholder().hashCode());
result = prime * result + ((getLevel() == null) ? 0 : getLevel().hashCode());
result = prime * result + ((getDistribute_type() == null) ? 0 : getDistribute_type().hashCode());
result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode());
result = prime * result + ((getCreated_at() == null) ? 0 : getCreated_at().hashCode());
result = prime * result + ((getUpdated_at() == null) ? 0 : getUpdated_at().hashCode());
result = prime * result + ((getMini_open_id() == null) ? 0 : getMini_open_id().hashCode());
result = prime * result + ((getDynamic_code() == null) ? 0 : getDynamic_code().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", amount=").append(amount);
sb.append(", credit_amount=").append(credit_amount);
sb.append(", consume_amount=").append(consume_amount);
sb.append(", consume_number=").append(consume_number);
sb.append(", level_consume=").append(level_consume);
sb.append(", status=").append(status);
sb.append(", merchant_id=").append(merchant_id);
sb.append(", shop_id=").append(shop_id);
sb.append(", user_id=").append(user_id);
sb.append(", parent_id=").append(parent_id);
sb.append(", parent_level=").append(parent_level);
sb.append(", name=").append(name);
sb.append(", head_img=").append(head_img);
sb.append(", sex=").append(sex);
sb.append(", birth_day=").append(birth_day);
sb.append(", telephone=").append(telephone);
sb.append(", is_vip=").append(is_vip);
sb.append(", code=").append(code);
sb.append(", is_attention=").append(is_attention);
sb.append(", attention_at=").append(attention_at);
sb.append(", is_shareholder=").append(is_shareholder);
sb.append(", level=").append(level);
sb.append(", distribute_type=").append(distribute_type);
sb.append(", sort=").append(sort);
sb.append(", created_at=").append(created_at);
sb.append(", updated_at=").append(updated_at);
sb.append(", mini_open_id=").append(mini_open_id);
sb.append(", dynamic_code=").append(dynamic_code);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,39 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.mybatis.entity.TbMShopUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Map;
/**
* @author Administrator
* @description 针对表tb_shop_user(商户储值会员)的数据库操作Mapper
* @createDate 2024-07-06 11:46:46
* @Entity cn.ysk.cashier.mybatis.entity.TbMShopUser
*/
public interface TbMShopUserMapper extends BaseMapper<TbMShopUser> {
@Select("<script>" +
"SELECT " +
"COUNT(*) userTotal, " +
"ifnull(SUM( " +
"IFNULL( b.charge_amount, 0 )), 0) chageTotal\n" +
"FROM\n" +
"tb_shop_user AS a\n" +
"LEFT JOIN tb_user_info AS b ON a.user_id = b.id\n" +
"WHERE\n" +
" a.shop_id = #{shopId}\n" +
"<if test=\"isVip !=null\">\n" +
" and a.is_vip=#{isVip}\n" +
"</if>" +
"</script>")
Map<String, Object> selectUserSummary(@Param("shopId") String shopId, @Param("isVip") Integer isVip);
}

View File

@ -0,0 +1,21 @@
package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.mybatis.entity.TbMShopUser;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author Administrator
* @description 针对表tb_shop_user(商户储值会员)的数据库操作Service
* @createDate 2024-07-06 11:46:46
*/
public interface TbMShopUserService extends IService<TbMShopUser> {
/**
* 查询会员概述信息
* @param criteria 查询
* @return 会员概述
*/
Object summary(TbShopUserQueryCriteria criteria);
}

View File

@ -0,0 +1,33 @@
package cn.ysk.cashier.mybatis.service.impl;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ysk.cashier.mybatis.entity.TbMShopUser;
import cn.ysk.cashier.mybatis.service.TbMShopUserService;
import cn.ysk.cashier.mybatis.mapper.TbMShopUserMapper;
import org.springframework.stereotype.Service;
/**
* @author Administrator
* @description 针对表tb_shop_user(商户储值会员)的数据库操作Service实现
* @createDate 2024-07-06 11:46:46
*/
@Service
public class TbMShopUserServiceImpl extends ServiceImpl<TbMShopUserMapper, TbMShopUser>
implements TbMShopUserService{
private final TbMShopUserMapper shopUserMapper;
public TbMShopUserServiceImpl(TbMShopUserMapper shopUserMapper) {
this.shopUserMapper = shopUserMapper;
}
@Override
public Object summary(TbShopUserQueryCriteria criteria) {
return shopUserMapper.selectUserSummary(criteria.getShopId(), criteria.getIsVip());
}
}

View File

@ -27,6 +27,7 @@ import org.springframework.data.jpa.repository.Query;
import javax.persistence.Tuple;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @website https://eladmin.vip
@ -47,4 +48,6 @@ public interface TbShopUserRepository extends JpaRepository<TbShopUser, Integer>
@Query("SELECT user.userId from TbShopUser user where user.shopId = :shopId")
List<Integer> getUserIdByShopId(String shopId);
}

View File

@ -128,4 +128,5 @@ public class TbShopUserServiceImpl implements TbShopUserService {
}
FileUtil.downloadExcel(list, response);
}
}
}

View File

@ -74,4 +74,5 @@ public interface TbShopUserService {
* @throws IOException /
*/
void download(List<TbShopUserDto> all, HttpServletResponse response) throws IOException;
}
}

View File

@ -38,6 +38,9 @@
<logger name="jdbc.sqlonly" level="ERROR" additivity="false">
<appender-ref ref="console" />
</logger>
<logger name="org.hibernate.SQL" level="DEBUG" >
<!-- <appender-ref ref="console" />-->
</logger>
<logger name="jdbc.resultset" level="ERROR" additivity="false">
<appender-ref ref="console" />

View File

@ -0,0 +1,65 @@
<?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="cn.ysk.cashier.mybatis.mapper.TbMShopUserMapper">
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.entity.TbMShopUser">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="amount" column="amount" jdbcType="DECIMAL"/>
<result property="credit_amount" column="credit_amount" jdbcType="DECIMAL"/>
<result property="consume_amount" column="consume_amount" jdbcType="DECIMAL"/>
<result property="consume_number" column="consume_number" jdbcType="INTEGER"/>
<result property="level_consume" column="level_consume" jdbcType="DECIMAL"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="merchant_id" column="merchant_id" jdbcType="VARCHAR"/>
<result property="shop_id" column="shop_id" jdbcType="VARCHAR"/>
<result property="user_id" column="user_id" jdbcType="VARCHAR"/>
<result property="parent_id" column="parent_id" jdbcType="VARCHAR"/>
<result property="parent_level" column="parent_level" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="head_img" column="head_img" jdbcType="VARCHAR"/>
<result property="sex" column="sex" jdbcType="TINYINT"/>
<result property="birth_day" column="birth_day" jdbcType="VARCHAR"/>
<result property="telephone" column="telephone" jdbcType="VARCHAR"/>
<result property="is_vip" column="is_vip" jdbcType="TINYINT"/>
<result property="code" column="code" jdbcType="VARCHAR"/>
<result property="is_attention" column="is_attention" jdbcType="TINYINT"/>
<result property="attention_at" column="attention_at" jdbcType="INTEGER"/>
<result property="is_shareholder" column="is_shareholder" jdbcType="TINYINT"/>
<result property="level" column="level" jdbcType="TINYINT"/>
<result property="distribute_type" column="distribute_type" jdbcType="VARCHAR"/>
<result property="sort" column="sort" jdbcType="INTEGER"/>
<result property="created_at" column="created_at" jdbcType="BIGINT"/>
<result property="updated_at" column="updated_at" jdbcType="BIGINT"/>
<result property="mini_open_id" column="mini_open_id" jdbcType="VARCHAR"/>
<result property="dynamic_code" column="dynamic_code" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,amount,credit_amount,
consume_amount,consume_number,level_consume,
status,merchant_id,shop_id,
user_id,parent_id,parent_level,
name,head_img,sex,
birth_day,telephone,is_vip,
code,is_attention,attention_at,
is_shareholder,level,distribute_type,
sort,created_at,updated_at,
mini_open_id,dynamic_code
</sql>
<select id="selectUserSummary">
SELECT
COUNT(*) total,
SUM(
IFNULL( b.charge_amount, 0 )) chage_total
FROM
tb_shop_user AS a
LEFT JOIN tb_user_info AS b ON a.user_id = b.id
WHERE
a.shop_id = #{shopId}
<if test="isVip !=null">
and a.is_vip=#{isVip}
</if>
</select>
</mapper>