商品统计

This commit is contained in:
Tankaikai 2025-03-14 14:18:46 +08:00
parent e08b220bc7
commit 9ad6b7b89c
3 changed files with 41 additions and 6 deletions

View File

@ -3,11 +3,14 @@ package com.czg.controller.admin;
import com.czg.account.dto.msg.ShopMsgEditDTO;
import com.czg.account.dto.msg.ShopPushOpenIdEditDTO;
import com.czg.account.entity.ShopPushOpenId;
import com.czg.account.param.ShopPushConfigParam;
import com.czg.account.service.ShopMsgStateService;
import com.czg.account.service.ShopPushOpenIdService;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.validator.ValidatorUtil;
import com.czg.validator.group.DefaultGroup;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
@ -16,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
/**
* 店铺消息推送相关
*
* @author Administrator
*/
@RestController
@ -37,6 +41,7 @@ public class ShopMsgPushController {
/**
* 店铺推送状态修改
*
* @param shopMsgEditDTO 修改嘻嘻你
* @return 是否成功
*/
@ -48,6 +53,7 @@ public class ShopMsgPushController {
/**
* 订阅用户列表
*
* @return 分页数据
*/
@SaAdminCheckPermission(value = "shopMsgPush:list", name = "订阅用户列表")
@ -58,6 +64,7 @@ public class ShopMsgPushController {
/**
* 订阅解绑
*
* @param openId 唯一推送标识
* @return 是否成功
*/
@ -69,6 +76,7 @@ public class ShopMsgPushController {
/**
* 推送状态修改
*
* @param shopPushOpenIdEditDTO 修改信息
* @return 是否成功
*/
@ -80,6 +88,7 @@ public class ShopMsgPushController {
/**
* 获取订阅二维码
*
* @return 二维码信息
* @throws Exception 异常
*/
@ -88,4 +97,16 @@ public class ShopMsgPushController {
public CzgResult<String> getCoed() throws Exception {
return CzgResult.success(shopMsgStateService.getCode(StpKit.USER.getShopId()));
}
/**
* 配置订阅消息类型
*/
@SaAdminCheckPermission(value = "shopMsgPush:config", name = "配置订阅消息类型")
@PostMapping("/config")
public CzgResult<String> config(@RequestBody ShopPushConfigParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);
shopMsgStateService.modifyConfig(param);
return CzgResult.success();
}
}

View File

@ -1,8 +1,9 @@
package com.czg.account.service;
import com.czg.account.dto.msg.ShopMsgEditDTO;
import com.mybatisflex.core.service.IService;
import com.czg.account.entity.ShopMsgState;
import com.czg.account.param.ShopPushConfigParam;
import com.mybatisflex.core.service.IService;
import java.util.HashMap;
@ -19,4 +20,5 @@ public interface ShopMsgStateService extends IService<ShopMsgState> {
Boolean edit(Long shopId, ShopMsgEditDTO shopMsgEditDTO);
String getCode(Long shopId) throws Exception;
void modifyConfig(ShopPushConfigParam param);
}

View File

@ -1,21 +1,24 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
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.alibaba.fastjson2.JSON;
import com.czg.account.dto.msg.ShopMsgEditDTO;
import com.czg.account.entity.ShopMsgState;
import com.czg.account.entity.ShopPushOpenId;
import com.czg.account.param.ShopPushConfigParam;
import com.czg.account.service.ShopMsgStateService;
import com.czg.service.account.mapper.ShopMsgStateMapper;
import com.czg.service.account.mapper.ShopPushOpenIdMapper;
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;
@ -45,6 +48,8 @@ public class ShopMsgStateServiceImpl extends ServiceImpl<ShopMsgStateMapper, Sho
private ResourceLoader resourceLoader;
@Resource
private AliOssUtil aliOssUtil;
@Resource
private ShopPushOpenIdMapper shopPushOpenIdMapper;
@Override
@ -99,4 +104,11 @@ public class ShopMsgStateServiceImpl extends ServiceImpl<ShopMsgStateMapper, Sho
return aliOssUtil.uploadSuffix(outputStream.toByteArray(), "png");
}
@Override
public void modifyConfig(ShopPushConfigParam param) {
ShopPushOpenId entity = shopPushOpenIdMapper.selectOneById(param.getId());
entity.setTypeInfo(CollUtil.isEmpty(param.getTypeInfo()) ? null : JSON.toJSONString(param.getTypeInfo()));
shopPushOpenIdMapper.update(entity, false);
}
}