Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai
2025-02-20 11:27:00 +08:00
42 changed files with 1658 additions and 2 deletions

View File

@@ -0,0 +1,14 @@
package com.czg.service.account.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.account.entity.PadLayout;
/**
* Pad商品布局版式 映射层。
*
* @author zs
* @since 2025-02-20
*/
public interface PadLayoutMapper extends BaseMapper<PadLayout> {
}

View File

@@ -0,0 +1,17 @@
package com.czg.service.account.mapper;
import com.czg.account.dto.pad.PadProductCategoryDTO;
import com.mybatisflex.core.BaseMapper;
import com.czg.account.entity.PadProductCategoryDetail;
import com.mybatisflex.core.paginate.Page;
/**
* Pad商品自定义分类明细 映射层。
*
* @author zs
* @since 2025-02-20
*/
public interface PadProductCategoryDetailMapper extends BaseMapper<PadProductCategoryDetail> {
Page<PadProductCategoryDTO> selectPageByKeyAndShopId();
Page<PadProductCategoryDTO> selectPageByKeyAndShopId_COUNT();
}

View File

@@ -0,0 +1,14 @@
package com.czg.service.account.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.account.entity.PadProductCategory;
/**
* Pad商品自定义分类 映射层。
*
* @author zs
* @since 2025-02-20
*/
public interface PadProductCategoryMapper extends BaseMapper<PadProductCategory> {
}

View File

@@ -0,0 +1,14 @@
package com.czg.service.account.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.account.entity.Product;
/**
* 商品 映射层。
*
* @author zs
* @since 2025-02-20
*/
public interface ProductMapper extends BaseMapper<Product> {
}

View File

@@ -0,0 +1,14 @@
package com.czg.service.account.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.account.entity.ShopProdCategory;
/**
* 商品分类 映射层。
*
* @author zs
* @since 2025-02-20
*/
public interface ShopProdCategoryMapper extends BaseMapper<ShopProdCategory> {
}

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.PadLayout;
import com.czg.account.service.PadLayoutService;
import com.czg.service.account.mapper.PadLayoutMapper;
import org.springframework.stereotype.Service;
/**
* Pad商品布局版式 服务层实现。
*
* @author zs
* @since 2025-02-20
*/
@Service
public class PadLayoutServiceImpl extends ServiceImpl<PadLayoutMapper, PadLayout> implements PadLayoutService{
}

View File

@@ -0,0 +1,126 @@
package com.czg.service.account.service.impl;
import com.czg.account.dto.pad.*;
import com.czg.account.entity.*;
import com.czg.account.service.*;
import com.czg.enums.StatusEnum;
import com.czg.exception.ApiNotPrintException;
import com.czg.service.account.mapper.PadProductCategoryDetailMapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author Administrator
*/
@Service
public class PadProdServiceImpl implements PadProdService {
@Resource
private PadProductCategoryDetailMapper padProductCategoryDetailMapper;
@Resource
private PadProductCategoryService padProductCategoryService;
@Resource
private ProductService productService;
@Resource
private ShopProdCategoryService shopProdCategoryService;
@Resource
private PadLayoutService padLayoutService;
@Resource
private PadProductCategoryDetailService padProductCategoryDetailService;
@Override
public Page<PadProductCategoryDTO> pageInfo(Page<PadProductCategoryDTO> objectPage, Long productCategoryId, Long shopId) {
QueryWrapper queryWrapper = new QueryWrapper().eq(PadProductCategoryDetail::getPadProductCategoryId, shopId);
if (productCategoryId != null) {
queryWrapper.eq(PadProductCategoryDetail::getPadProductCategoryId, productCategoryId);
}
return padProductCategoryDetailMapper.xmlPaginate("selectPageByKeyAndShopId", objectPage, queryWrapper);
}
@Override
public PadDetailDTO detail(Long shopId, Long padProductCategory) {
PadProductCategory padCategory = padProductCategoryService.getOne(new QueryWrapper().eq(PadProductCategory::getShopId, shopId).eq(PadProductCategory::getId, padProductCategory));
if (padCategory == null) {
throw new ApiNotPrintException("pad商品分类不存在");
}
PadDetailDTO padDetailDTO = new PadDetailDTO();
padDetailDTO.setId(padProductCategory);
padDetailDTO.setPadLayoutId(padCategory.getPadLayoutId());
List<Long> productIds = padProductCategoryDetailMapper.selectListByQuery(new QueryWrapper().eq(PadProductCategoryDetail::getPadProductCategoryId, padProductCategory)).stream().map(PadProductCategoryDetail::getProductId).toList();
padDetailDTO.setProductIdList(productIds);
if (!productIds.isEmpty()) {
List<Product> products = productService.list(new QueryWrapper().in(Product::getId, productIds).eq(Product::getShopId, shopId));
padDetailDTO.setProductList(products);
}
return padDetailDTO;
}
@Override
public Boolean add(Long shopId, PadDetailAddDTO padDetailAddDTO) {
long count = shopProdCategoryService.count(new QueryWrapper().eq(ShopProdCategory::getId, padDetailAddDTO.getProductCategoryId()));
if (count == 0) {
throw new ApiNotPrintException("商品分类不存在");
}
checkInfo(shopId, padDetailAddDTO.getPadLayoutId(), padDetailAddDTO.getProductIdList());
PadProductCategory padProductCategory = new PadProductCategory().setPadLayoutId(padDetailAddDTO.getPadLayoutId()).setProductCategoryId(padDetailAddDTO.getProductCategoryId())
.setShopId(shopId);
padProductCategoryService.save(padProductCategory);
ArrayList<PadProductCategoryDetail> details = new ArrayList<>();
padDetailAddDTO.getProductIdList().forEach(item -> {
details.add(new PadProductCategoryDetail().setPadProductCategoryId(padProductCategory.getId()).setProductId(item));
});
return padProductCategoryDetailService.saveBatch(details);
}
@Override
public Boolean edit(Long shopId, PadDetailEditDTO padDetailEditDTO) {
PadProductCategory category = padProductCategoryService.getOne(new QueryWrapper().eq(PadProductCategory::getShopId, shopId).eq(PadProductCategory::getId, padDetailEditDTO.getId()));
if (category == null) {
throw new ApiNotPrintException("pad商品不存在");
}
checkInfo(shopId, padDetailEditDTO.getPadLayoutId(), padDetailEditDTO.getProductIdList());
padProductCategoryDetailService.remove(new QueryWrapper().eq(PadProductCategoryDetail::getPadProductCategoryId, padDetailEditDTO.getId()));
category.setPadLayoutId(padDetailEditDTO.getPadLayoutId());
padProductCategoryService.updateById(category);
ArrayList<PadProductCategoryDetail> details = new ArrayList<>();
padDetailEditDTO.getProductIdList().forEach(item -> {
details.add(new PadProductCategoryDetail().setPadProductCategoryId(padDetailEditDTO.getId()).setProductId(item));
});
return padProductCategoryDetailService.saveBatch(details);
}
private void checkInfo(Long shopId, Long padLayoutId, List<Long> productIdList) {
long layOutCount = padLayoutService.count(new QueryWrapper().eq(PadLayout::getId, padLayoutId).eq(PadLayout::getIsDel, 0));
if (layOutCount == 0) {
throw new ApiNotPrintException("pad布局不存在");
}
long proCount = productService.count(new QueryWrapper().eq(Product::getShopId, shopId).in(Product::getId, productIdList));
if (proCount != productIdList.size()) {
throw new ApiNotPrintException("存在错误商品id");
}
}
@Override
public Boolean del(Long shopId, PadDetailDelDTO delDTO) {
PadProductCategory category = padProductCategoryService.getOne(new QueryWrapper().eq(PadProductCategory::getShopId, shopId).eq(PadProductCategory::getId, delDTO.getId()));
if (category == null) {
throw new ApiNotPrintException("pad商品不存在");
}
padProductCategoryService.removeById(delDTO.getId());
return padProductCategoryDetailService.remove(new QueryWrapper().eq(PadProductCategoryDetail::getPadProductCategoryId, delDTO.getId()));
}
}

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.PadProductCategoryDetail;
import com.czg.account.service.PadProductCategoryDetailService;
import com.czg.service.account.mapper.PadProductCategoryDetailMapper;
import org.springframework.stereotype.Service;
/**
* Pad商品自定义分类明细 服务层实现。
*
* @author zs
* @since 2025-02-20
*/
@Service
public class PadProductCategoryDetailServiceImpl extends ServiceImpl<PadProductCategoryDetailMapper, PadProductCategoryDetail> implements PadProductCategoryDetailService{
}

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.PadProductCategory;
import com.czg.account.service.PadProductCategoryService;
import com.czg.service.account.mapper.PadProductCategoryMapper;
import org.springframework.stereotype.Service;
/**
* Pad商品自定义分类 服务层实现。
*
* @author zs
* @since 2025-02-20
*/
@Service
public class PadProductCategoryServiceImpl extends ServiceImpl<PadProductCategoryMapper, PadProductCategory> implements PadProductCategoryService{
}

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.Product;
import com.czg.account.service.ProductService;
import com.czg.service.account.mapper.ProductMapper;
import org.springframework.stereotype.Service;
/**
* 商品 服务层实现。
*
* @author zs
* @since 2025-02-20
*/
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService{
}

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.ShopProdCategory;
import com.czg.account.service.ShopProdCategoryService;
import com.czg.service.account.mapper.ShopProdCategoryMapper;
import org.springframework.stereotype.Service;
/**
* 商品分类 服务层实现。
*
* @author zs
* @since 2025-02-20
*/
@Service
public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMapper, ShopProdCategory> implements ShopProdCategoryService{
}

View File

@@ -140,6 +140,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
SysUser sysUser = sysUserService.getById(shopStaff.getId());
shopStaff.setAccountName(StrUtil.subAfter(sysUser.getAccount(), "@", true));
shopStaff.setAccountPwd("*******");
shopStaff.setPhone(sysUser.getPhone());
return shopStaff;
}
}

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.PadLayoutMapper">
</mapper>

View File

@@ -0,0 +1,34 @@
<?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.PadProductCategoryDetailMapper">
<select id="selectPageByKeyAndShopId" resultType="com.czg.account.dto.pad.PadProductCategoryDTO">
SELECT tb_pad_product_category.id,
tb_shop_prod_category.`name` AS productCategoryName,
GROUP_CONCAT(tb_product.NAME) AS productNames,
tb_pad_layout.code AS padLayoutCode,
tb_pad_layout.NAME AS padLayoutName
FROM tb_pad_product_category
LEFT JOIN tb_pad_product_category_detail
ON tb_pad_product_category.id = tb_pad_product_category_detail.pad_product_category_id
LEFT JOIN tb_shop_prod_category
ON tb_pad_product_category.product_category_id = tb_shop_prod_category.id
LEFT JOIN tb_product ON tb_pad_product_category_detail.product_id = tb_product.id
LEFT JOIN tb_pad_layout ON tb_pad_product_category.pad_layout_id = tb_pad_layout.id
${qwSql}
limit ${pageOffset}, ${pageSize}
</select>
<select id="selectPageByKeyAndShopId_COUNT" resultType="com.czg.account.dto.pad.PadProductCategoryDTO">
SELECT count(1)
FROM tb_pad_product_category
LEFT JOIN tb_pad_product_category_detail
ON tb_pad_product_category.id = tb_pad_product_category_detail.pad_product_category_id
LEFT JOIN tb_shop_prod_category
ON tb_pad_product_category.product_category_id = tb_shop_prod_category.id
LEFT JOIN tb_product ON tb_pad_product_category_detail.product_id = tb_product.id
LEFT JOIN tb_pad_layout ON tb_pad_product_category.pad_layout_id = tb_pad_layout.id
${qwSql}
</select>
</mapper>

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.PadProductCategoryMapper">
</mapper>

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.ProductMapper">
</mapper>

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.ShopProdCategoryMapper">
</mapper>

View File

@@ -23,7 +23,7 @@
<select id="selectUserSummary" resultType="com.czg.account.dto.shopuser.ShopUserSummaryDTO">
select count(a.id) userTotal, sum(IFNULL(a.amount, 0)) balanceTotal,sum(IFNULL(b.amount,0)) chargeTotal from
tb_shop_user as a
left join tb_shop_user_flow as b on a.id=b.user_id and b.type='+' and b.biz_code in ('cashIn', 'wechatIn',
left join tb_shop_user_flow as b on a.id=b.user_id and b.biz_code in ('cashIn', 'wechatIn',
'alipayIn')
where a.shop_id = #{shopId}
<if test="isVip !=null">

View File

@@ -28,7 +28,7 @@ public class Main {
// String packageName = "product";
// String packageName = "order";
String tableName = "tb_shop_extend";
String tableName = "tb_product";
String author = "zs";
//是否生成DTO实体 默认生成
boolean isGenerateDto = true;