Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai 2025-03-05 15:12:20 +08:00
commit f5b1d94bbe
19 changed files with 647 additions and 111 deletions

View File

@ -0,0 +1,54 @@
package com.czg.controller.admin;
import com.czg.account.dto.ShopShareDTO;
import com.czg.account.service.ShopShareService;
import com.czg.account.vo.ShopShareRecordVO;
import com.czg.account.vo.ShopShareVO;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 小程序分享奖励管理
* @author Administrator
*/
@RestController
@RequestMapping("/admin/shopShare")
public class ShopShareController {
@Resource
private ShopShareService shopShareService;
/**
* 获取分享奖励配置
*/
@SaAdminCheckPermission(value = "shopShare:list", name = "分享好友信息")
@GetMapping
public CzgResult<ShopShareVO> get() {
return CzgResult.success(shopShareService.get(StpKit.USER.getShopId()));
}
/**
* 修改分享奖励配置
*/
@SaAdminCheckPermission(value = "shopShare:add", name = "分享好友信息添加")
@PostMapping
public CzgResult<Boolean> add(@RequestBody @Validated ShopShareDTO shopShareDTO) {
return CzgResult.success(shopShareService.add(StpKit.USER.getShopId(), shopShareDTO));
}
/**
* 分享奖励记录
* @param key 邀请人/被邀请人手机号或昵称
* @param status 0 非新用户 1 未领取 2 已领取 3 已使用 不传递为全部
* @return 分页数据
*/
@SaAdminCheckPermission(value = "shopShare:record", name = "分享邀请记录")
@GetMapping("/record")
public CzgResult<Page<ShopShareRecordVO>> record(String key, Integer status) {
return CzgResult.success(shopShareService.recordPage(StpKit.USER.getShopId(), key, status));
}
}

View File

@ -1,61 +0,0 @@
package com.czg.config;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @author GYJoker
*/
@Component
public class CzgDubboBean {
private ApplicationConfig applicationConfig;
private ProtocolConfig protocolConfig;
@Value("${dubbo.application.name}")
private String applicationName;
@Value("${dubbo.application.qos-port}")
private Integer qosPort;
@Value("${dubbo.application.qos-enable}")
private Boolean qosEnable;
@Value("${dubbo.registry.address}")
private String registryAddress;
@Value("${dubbo.registry.group}")
private String registryGroup;
@Value("${dubbo.protocol.port}")
private Integer port;
@Value("${dubbo.protocol.threads}")
private Integer threads;
public CzgDubboBean() {
applicationConfig = new ApplicationConfig();
applicationConfig.setName(applicationName);
applicationConfig.setQosPort(qosPort);
applicationConfig.setQosEnable(qosEnable);
RegistryConfig registryConfig = new RegistryConfig();
registryConfig.setAddress(registryAddress);
registryConfig.setGroup(registryGroup);
protocolConfig = new ProtocolConfig();
protocolConfig.setPort(port);
protocolConfig.setThreads(threads);
}
public ApplicationConfig getApplicationConfig() {
return applicationConfig;
}
public ProtocolConfig getProtocolConfig() {
return protocolConfig;
}
}

View File

@ -1,18 +0,0 @@
package com.czg.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
/**
* @author GYJoker
*/
@Configuration
@DependsOn("nacosConfigProperties") // 这里假设 Nacos 的配置属性 Bean 名为 nacosConfigProperties
public class DubboConfig {
// 这里可以添加 Dubbo 相关的配置 Bean
@Bean
public CzgDubboBean czgDubboBean() {
return new CzgDubboBean();
}
}

View File

@ -0,0 +1,93 @@
package com.czg.account.dto;
import java.io.Serializable;
import java.time.LocalDateTime;
import com.alibaba.fastjson2.annotation.JSONField;
import java.io.Serial;
import java.util.List;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 店铺分享 实体类
*
* @author zs
* @since 2025-03-05
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ShopShareDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 标题
*/
@Size(min = 1, message = "标题不为空")
private String title;
/**
* 分享封面图
*/
@Size(min = 1, message = "分享封面图不为空")
private String shareImg;
/**
* 邀请顶部图
*/
@Size(min = 1, message = "邀请顶部图不为空")
private String invitedImg;
/**
* 被邀顶部图
*/
@Size(min = 1, message = "被邀顶部图不为空")
private String beInvitedImg;
/**
* 活动开始时间
*/
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
/**
* 活动结束时间
*/
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
/**
* 新用户获得券
*/
private List<Long> newCouponIdList;
/**
* 邀请人数
*/
private Integer invitedNum;
/**
* 奖励券
*/
private List<Long> rewardCouponIdList;
/**
* 获取方法 get-新用户领取获得 use-新用户使用获得
*/
@Size(min = 1, message = "获取方法不为空")
private String getMethod;
/**
* 0 关闭 1 开启
*/
private Integer status;
}

View File

@ -0,0 +1,77 @@
package com.czg.account.dto;
import java.io.Serializable;
import java.time.LocalDateTime;
import com.alibaba.fastjson2.annotation.JSONField;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 店铺分享记录 实体类
*
* @author zs
* @since 2025-03-05
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ShopShareRecordDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Integer id;
/**
* tb_shop_share 主键Id
*/
private Integer shareId;
/**
* 店铺Id
*/
private Integer shopId;
/**
* 邀请人id
*/
private Integer invitedId;
/**
* 邀请人名称
*/
private String invitedName;
/**
* 被邀请人Id
*/
private Integer beInvitedId;
/**
* 奖励券获得方式 get/use 领取获得/使用获得
*/
private String method;
/**
* 0 非新用户 1 未领取 2 已领取 3 已使用
*/
private Integer status;
/**
* 生效时间/获得奖励的时间
*/
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime rewardTime;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,95 @@
package com.czg.account.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 店铺分享 实体类
*
* @author zs
* @since 2025-03-05
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("tb_shop_share")
public class ShopShare implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 店铺Id
*/
private Long shopId;
/**
* 标题
*/
private String title;
/**
* 分享封面图
*/
private String shareImg;
/**
* 邀请顶部图
*/
private String invitedImg;
/**
* 被邀顶部图
*/
private String beInvitedImg;
/**
* 活动开始时间
*/
private LocalDateTime startTime;
/**
* 活动结束时间
*/
private LocalDateTime endTime;
/**
* 新用户获得券
*/
private String newCoupon;
/**
* 邀请人数
*/
private Integer invitedNum;
/**
* 奖励券
*/
private String rewardCoupon;
/**
* 获取方法 get-新用户领取获得 use-新用户使用获得
*/
private String getMethod;
/**
* 0 关闭 1 开启
*/
private Integer status;
}

View File

@ -0,0 +1,82 @@
package com.czg.account.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 店铺分享记录 实体类
*
* @author zs
* @since 2025-03-05
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("tb_shop_share_record")
public class ShopShareRecord implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Auto)
private Integer id;
/**
* tb_shop_share 主键Id
*/
private Integer shareId;
/**
* 店铺Id
*/
private Integer shopId;
/**
* 邀请人id
*/
private Integer invitedId;
/**
* 邀请人名称
*/
private String invitedName;
/**
* 被邀请人Id
*/
private Integer beInvitedId;
/**
* 奖励券获得方式 get/use 领取获得/使用获得
*/
private String method;
/**
* 0 非新用户 1 未领取 2 已领取 3 已使用
*/
private Integer status;
/**
* 生效时间/获得奖励的时间
*/
private LocalDateTime rewardTime;
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
@Column(onInsertValue = "now()", onUpdateValue = "now()")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,14 @@
package com.czg.account.service;
import com.mybatisflex.core.service.IService;
import com.czg.account.entity.ShopShareRecord;
/**
* 店铺分享记录 服务层
*
* @author zs
* @since 2025-03-05
*/
public interface ShopShareRecordService extends IService<ShopShareRecord> {
}

View File

@ -0,0 +1,23 @@
package com.czg.account.service;
import com.czg.account.dto.ShopShareDTO;
import com.czg.account.vo.ShopShareRecordVO;
import com.czg.account.vo.ShopShareVO;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import com.czg.account.entity.ShopShare;
/**
* 店铺分享 服务层
*
* @author zs
* @since 2025-03-05
*/
public interface ShopShareService extends IService<ShopShare> {
ShopShareVO get(Long shopId);
Boolean add(Long shopId, ShopShareDTO shopShareDTO);
Page<ShopShareRecordVO> recordPage(Long shopId, String key, Integer status);
}

View File

@ -0,0 +1,17 @@
package com.czg.account.vo;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author Administrator
*/
@Data
public class ShopShareRecordVO {
private String invitedName;
private String beInvitedName;
private Integer status;
private LocalDateTime createTime;
private LocalDateTime rewardTime;
}

View File

@ -0,0 +1,25 @@
package com.czg.account.vo;
import com.czg.account.entity.ShopCoupon;
import com.czg.account.entity.ShopShare;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.List;
/**
* @author Administrator
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class ShopShareVO extends ShopShare {
/**
* 新人奖励优惠券信息
*/
private List<ShopCoupon> newCouponList = new ArrayList<>();
/**
* 邀请人奖励优惠券信息
*/
private List<ShopCoupon> rewardCouponList = new ArrayList<>();
}

View File

@ -151,17 +151,6 @@
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo-spring.version}</version>
</dependency>
<!-- Nacos Discovery for Dubbo -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-nacos</artifactId>
<version>${dubbo-registry-nacos.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.seata/seata-spring-boot-starter -->
<dependency>
<groupId>io.seata</groupId>
@ -191,12 +180,6 @@
<version>${fastjson2.version}</version>
</dependency>
<!-- Spring Boot与nacos整合的核心依赖 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${nacos-discovery.version}</version>
</dependency>
<!-- 配置管理依赖,如果你需要配置管理功能 -->
<dependency>

View File

@ -0,0 +1,14 @@
package com.czg.service.account.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.account.entity.ShopShare;
/**
* 店铺分享 映射层
*
* @author zs
* @since 2025-03-05
*/
public interface ShopShareMapper extends BaseMapper<ShopShare> {
}

View File

@ -0,0 +1,20 @@
package com.czg.service.account.mapper;
import com.czg.account.vo.ShopShareRecordVO;
import com.mybatisflex.core.BaseMapper;
import com.czg.account.entity.ShopShareRecord;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 店铺分享记录 映射层
*
* @author zs
* @since 2025-03-05
*/
public interface ShopShareRecordMapper extends BaseMapper<ShopShareRecord> {
List<ShopShareRecordVO> getRecord(@Param("shopId") Long shopId, @Param("key") String key, @Param("status") Integer status);
}

View File

@ -0,0 +1,18 @@
package com.czg.service.account.service.impl;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.ShopShareRecord;
import com.czg.account.service.ShopShareRecordService;
import com.czg.service.account.mapper.ShopShareRecordMapper;
import org.springframework.stereotype.Service;
/**
* 店铺分享记录 服务层实现
*
* @author zs
* @since 2025-03-05
*/
@Service
public class ShopShareRecordServiceImpl extends ServiceImpl<ShopShareRecordMapper, ShopShareRecord> implements ShopShareRecordService{
}

View File

@ -0,0 +1,87 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import com.czg.account.dto.ShopShareDTO;
import com.czg.account.entity.ShopCoupon;
import com.czg.account.service.ShopCouponService;
import com.czg.account.vo.ShopShareRecordVO;
import com.czg.account.vo.ShopShareVO;
import com.czg.exception.ApiNotPrintException;
import com.czg.service.account.mapper.ShopShareRecordMapper;
import com.czg.utils.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.ShopShare;
import com.czg.account.service.ShopShareService;
import com.czg.service.account.mapper.ShopShareMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
/**
* 店铺分享 服务层实现
*
* @author zs
* @since 2025-03-05
*/
@Service
public class ShopShareServiceImpl extends ServiceImpl<ShopShareMapper, ShopShare> implements ShopShareService{
@Resource
private ShopCouponService shopCouponService;
@Resource
private ShopShareRecordMapper shopShareRecordMapper;
@Override
public ShopShareVO get(Long shopId) {
ShopShare shopShare = getOne(new QueryWrapper().eq(ShopShare::getShopId, shopId));
ShopShareVO shopShareVO = new ShopShareVO();
if (shopShare != null) {
BeanUtil.copyProperties(shopShare, shopShareVO);
if (StrUtil.isNotBlank(shopShare.getRewardCoupon())) {
shopShareVO.setRewardCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getRewardCoupon()))));
}
if (StrUtil.isNotBlank(shopShare.getNewCoupon())) {
shopShareVO.setNewCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getNewCoupon()))));
}
}
return shopShareVO;
}
@Override
public Boolean add(Long shopId, ShopShareDTO shopShareDTO) {
if (shopShareDTO.getNewCouponIdList() != null && !shopShareDTO.getRewardCouponIdList().isEmpty()) {
long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getNewCouponIdList()).eq(ShopCoupon::getShopId, shopId));
if (count != shopShareDTO.getNewCouponIdList().size()) {
throw new ApiNotPrintException("优惠券不存在");
}
}
if (shopShareDTO.getRewardCouponIdList() != null && !shopShareDTO.getRewardCouponIdList().isEmpty()) {
long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getRewardCouponIdList()).eq(ShopCoupon::getShopId, shopId));
if (count != shopShareDTO.getRewardCouponIdList().size()) {
throw new ApiNotPrintException("优惠券不存在");
}
}
ShopShare shopShare = getOne(new QueryWrapper().eq(ShopShare::getShopId, shopId));
if (shopShare == null) {
shopShare = new ShopShareVO();
shopShare.setShopId(shopId);
}
shopShare.setRewardCoupon(JSONArray.toJSONString(shopShareDTO.getRewardCouponIdList()));
shopShare.setNewCoupon(JSONArray.toJSONString(shopShareDTO.getNewCouponIdList()));
BeanUtil.copyProperties(shopShareDTO, shopShare);
return saveOrUpdate(shopShare);
}
@Override
public Page<ShopShareRecordVO> recordPage(Long shopId, String key, Integer status) {
Page<Object> page = PageUtil.buildPage();
PageHelper.startPage(Math.toIntExact(page.getPageNumber()), Math.toIntExact(page.getPageSize()));
return PageUtil.convert(new PageInfo<>(shopShareRecordMapper.getRecord(shopId, key, status)));
}
}

View File

@ -0,0 +1,7 @@
<?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.czg.service.account.mapper.ShopShareMapper">
</mapper>

View File

@ -0,0 +1,21 @@
<?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.czg.service.account.mapper.ShopShareRecordMapper">
<select id="getRecord" resultType="com.czg.account.vo.ShopShareRecordVO">
SELECT *
FROM `tb_shop_share_record` as a
left join tb_shop_user as b on a.shop_id = b.shop_id and b.user_id = a.invited_id
left join tb_shop_user as c on a.shop_id = c.shop_id and c.user_id = a.be_invited_id
where a.shop_id=#{shopId}
<if test="key != null and key != ''">
and (b.nick_name like concat('%', #{key}, '%') or c.nick_name like concat('%', #{key}, '%') or b.phone like concat('%', #{key}, '%') or c.phone like concat('%', #{key}, '%'))
</if>
<if test="status != null and status != ''">
and a.status=#{status}
</if>
</select>
</mapper>

View File

@ -71,11 +71,6 @@
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<!-- Spring Boot与nacos整合的核心依赖 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- 配置管理依赖,如果你需要配置管理功能 -->
<dependency>
@ -103,15 +98,5 @@
<artifactId>dubbo-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-nacos</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>
</dependencies>
</project>