消息中心,打印修改
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopMsgState;
|
||||
|
||||
/**
|
||||
* 店铺消息推送设置 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-03-07
|
||||
*/
|
||||
public interface ShopMsgStateMapper extends BaseMapper<ShopMsgState> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.vo.ShopProdStatisticVO;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopProdStatistic;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-03-06
|
||||
*/
|
||||
public interface ShopProdStatisticMapper extends BaseMapper<ShopProdStatistic> {
|
||||
|
||||
List<ShopProdStatisticVO> pageInfo(@Param("shopId") Long shopId, @Param("name") String name, @Param("classifyId") String classifyId,
|
||||
@Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.vo.ShopPushOpenIdVO;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopPushOpenId;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户推送信息表 映射层。
|
||||
*
|
||||
@@ -11,4 +14,5 @@ import com.czg.account.entity.ShopPushOpenId;
|
||||
*/
|
||||
public interface ShopPushOpenIdMapper extends BaseMapper<ShopPushOpenId> {
|
||||
|
||||
List<ShopPushOpenIdVO> pageInfo(Long shopId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.extra.qrcode.QrConfig;
|
||||
import com.czg.account.dto.msg.ShopMsgEditDTO;
|
||||
import com.czg.service.account.util.AliOssUtil;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopMsgState;
|
||||
import com.czg.account.service.ShopMsgStateService;
|
||||
import com.czg.service.account.mapper.ShopMsgStateMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺消息推送设置 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-03-07
|
||||
*/
|
||||
@Service
|
||||
public class ShopMsgStateServiceImpl extends ServiceImpl<ShopMsgStateMapper, ShopMsgState> implements ShopMsgStateService {
|
||||
private static final HashMap<String, String> MSG_TYPE = new HashMap<>();
|
||||
|
||||
static {
|
||||
MSG_TYPE.put("0", "stockState");
|
||||
MSG_TYPE.put("1", "conState");
|
||||
MSG_TYPE.put("2", "opeState");
|
||||
MSG_TYPE.put("-1", "allState");
|
||||
}
|
||||
|
||||
@Resource
|
||||
private ResourceLoader resourceLoader;
|
||||
@Resource
|
||||
private AliOssUtil aliOssUtil;
|
||||
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getState(Long shopId) {
|
||||
List<ShopMsgState> list = queryChain().eq(ShopMsgState::getShopId, shopId).list();
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
MSG_TYPE.forEach((k, v) -> {
|
||||
ShopMsgState have = null;
|
||||
for (ShopMsgState shopMsgState : list) {
|
||||
if (shopMsgState.getType().equals(Integer.valueOf(k))) {
|
||||
have = shopMsgState;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (have == null) {
|
||||
ShopMsgState msgState = new ShopMsgState();
|
||||
msgState.setShopId(shopId);
|
||||
msgState.setCreateTime(DateUtil.date().toLocalDateTime());
|
||||
msgState.setType(Integer.valueOf(k));
|
||||
msgState.setState(0);
|
||||
save(msgState);
|
||||
}
|
||||
data.put(v, have != null ? have.getState() : 0);
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean edit(Long shopId, ShopMsgEditDTO shopMsgEditDTO) {
|
||||
ShopMsgState msgState = queryChain().eq(ShopMsgState::getShopId, shopId).eq(ShopMsgState::getType, shopMsgEditDTO.getType()).one();
|
||||
if (msgState == null) {
|
||||
msgState = new ShopMsgState();
|
||||
msgState.setShopId(shopId);
|
||||
msgState.setCreateTime(DateUtil.date().toLocalDateTime());
|
||||
msgState.setType(shopMsgEditDTO.getType());
|
||||
msgState.setState(shopMsgEditDTO.getState());
|
||||
return save(msgState);
|
||||
}
|
||||
BeanUtil.copyProperties(shopMsgEditDTO, msgState);
|
||||
return updateById(msgState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode(Long shopId) throws Exception {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:/static/logo.jpg");
|
||||
InputStream inputStream = resource.getInputStream();
|
||||
String url = StrUtil.format("https://invoice.sxczgkj.cn/index/wechat/weuserk?shopId={}", shopId);
|
||||
QrCodeUtil.generate(url, new QrConfig(500, 500).
|
||||
setImg(ImageIO.read(inputStream)).setErrorCorrection(ErrorCorrectionLevel.H).setRatio(4), "png", outputStream);
|
||||
|
||||
return aliOssUtil.uploadSuffix(outputStream.toByteArray(), "png");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopProdStatistic;
|
||||
import com.czg.account.service.ShopProdStatisticService;
|
||||
import com.czg.service.account.mapper.ShopProdStatisticMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-03-06
|
||||
*/
|
||||
@Service
|
||||
public class ShopProdStatisticServiceImpl extends ServiceImpl<ShopProdStatisticMapper, ShopProdStatistic> implements ShopProdStatisticService{
|
||||
@Override
|
||||
public Page<?> pageInfo(Long shopId, String name, String classifyId, String startTime, String endTime) {
|
||||
PageHelper.startPage(PageUtil.buildPageHelp());
|
||||
return PageUtil.convert(new PageInfo<>(mapper.pageInfo(shopId, name, classifyId, startTime, endTime)));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.msg.ShopPushOpenIdEditDTO;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopPushOpenId;
|
||||
import com.czg.account.service.ShopPushOpenIdService;
|
||||
import com.czg.service.account.mapper.ShopPushOpenIdMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户推送信息表 服务层实现。
|
||||
*
|
||||
@@ -15,4 +22,24 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class ShopPushOpenIdServiceImpl extends ServiceImpl<ShopPushOpenIdMapper, ShopPushOpenId> implements ShopPushOpenIdService{
|
||||
|
||||
@Override
|
||||
public List<ShopPushOpenId> pageInfo(Long shopId) {
|
||||
// PageHelper.startPage(PageUtil.buildPageHelp());
|
||||
// return PageUtil.convert(new PageInfo<>(mapper.pageInfo(shopId)));
|
||||
List<ShopPushOpenId> list = list(new QueryWrapper().eq(ShopPushOpenId::getShopId, shopId));
|
||||
list.forEach(item -> item.setTypeInfo(JSONArray.parseArray((String) item.getTypeInfo())));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean edit(Long shopId, ShopPushOpenIdEditDTO shopPushOpenIdEditDTO) {
|
||||
ShopPushOpenId pushOpenId = queryChain().eq(ShopPushOpenId::getShopId, shopId).eq(ShopPushOpenId::getOpenId, shopPushOpenIdEditDTO.getOpenId()).one();
|
||||
if (pushOpenId == null) {
|
||||
throw new ApiNotPrintException("订阅用户不存在");
|
||||
}
|
||||
|
||||
pushOpenId.setTypeInfo(JSONObject.toJSONString(shopPushOpenIdEditDTO.getTypeInfo()));
|
||||
pushOpenId.setStatus(shopPushOpenIdEditDTO.getStatus());
|
||||
return updateById(pushOpenId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.ShopMsgStateMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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.ShopProdStatisticMapper">
|
||||
|
||||
<select id="pageInfo" resultType="com.czg.account.vo.ShopProdStatisticVO">
|
||||
select * from tb_shop_prod_statistic as a
|
||||
left join tb_product as b on a.prod_id=b.id
|
||||
where a.shop_id=#{shopId} and b.name like and b.category_id=
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -4,4 +4,20 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopPushOpenIdMapper">
|
||||
|
||||
<select id="pageInfo" resultType="com.czg.account.vo.ShopPushOpenIdVO">
|
||||
select
|
||||
nickname, avatar,
|
||||
SUM(IF(type = 0, `status`, 0)) AS proState,
|
||||
SUM(IF(type = 1, `status`, 0)) AS conState,
|
||||
SUM(IF(type = 2, `status`, 0)) AS opeState,
|
||||
SUM(IF(type = -1, `status`, 0)) AS allState
|
||||
from tb_shop_push_open_id where shop_id=#{shopId}
|
||||
<if test="nickName !=null and nickName != ''">
|
||||
and nickname like concat('%', #{nickName} '%')
|
||||
</if>
|
||||
<if test="openId !=null and openId != ''">
|
||||
and open_id like concat('%', #{openId} '%')
|
||||
</if>
|
||||
group by shop_id, open_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user