Merge remote-tracking branch 'origin/master'

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

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>