Merge remote-tracking branch 'origin/master'

This commit is contained in:
2025-03-05 15:10:19 +08:00
17 changed files with 659 additions and 6 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

@@ -97,6 +97,8 @@ public class CreditBuyerServiceImpl extends ServiceImpl<CreditBuyerMapper, Credi
@Override
public void addCreditBuyer(CreditBuyerDTO dto) {
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
commonVerify(dto);
try {
Assert.notEmpty(dto.getRepaymentMethod(), "{}({})不能为空", "还款方式", "repaymentMethod");
@@ -118,6 +120,8 @@ public class CreditBuyerServiceImpl extends ServiceImpl<CreditBuyerMapper, Credi
} catch (IllegalArgumentException e) {
throw new CzgException(e.getMessage());
}
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
commonVerify(dto);
CreditBuyer entity = getById(dto.getId());
if (entity == null) {

View File

@@ -5,12 +5,13 @@
<sql id="view_credit_buyer_order_count">
(SELECT
credit_buyer_id AS credit_buyer_id,
status AS status,
tb.credit_buyer_id AS credit_buyer_id,
tb.status AS status,
count( 0 ) AS count
FROM
<include refid="view_credit_buyer_order"/>
GROUP BY credit_buyer_id,status)
tb
GROUP BY tb.credit_buyer_id,tb.status)
</sql>
<sql id="view_credit_buyer_order">
@@ -35,11 +36,12 @@
x3.owed_amount,
x3.accumulate_amount
from tb_credit_buyer x1
left join tb_shop_info t2 on x1.shop_id = x2.id
left join (select credit_buyer_id,ifnull(sum(unpaid_amount),0) as owed_amount,ifnull(sum(pay_amount),0) as
left join tb_shop_info x2 on x1.shop_id = x2.id
left join (select t.credit_buyer_id,ifnull(sum(t.unpaid_amount),0) as owed_amount,ifnull(sum(t.pay_amount),0) as
accumulate_amount from
<include refid="view_credit_buyer_order"/>
group by credit_buyer_id) x3 on x1.id = x3.credit_buyer_id
t
group by t.credit_buyer_id) x3 on x1.id = x3.credit_buyer_id
<where>
and x1.is_del = 0
and x1.shop_id = #{shopId}