公众号 视频号 商家用户管理 字典标识字段

This commit is contained in:
2024-04-13 15:13:30 +08:00
parent eedc6fe307
commit 78c37b2636
14 changed files with 190 additions and 57 deletions

View File

@@ -23,7 +23,6 @@ import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
@@ -46,7 +45,6 @@ public class TbShopUserController {
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('tbShopUser:list')")
public void exportTbShopUser(HttpServletResponse response, TbShopUserQueryCriteria criteria) throws IOException {
tbShopUserService.download(tbShopUserService.queryAll(criteria), response);
}
@@ -54,15 +52,21 @@ public class TbShopUserController {
@GetMapping
@Log("查询/shop/user")
@ApiOperation("查询/shop/user")
@PreAuthorize("@el.check('tbShopUser:list')")
public ResponseEntity<Object> queryTbShopUser(TbShopUserQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(tbShopUserService.queryAll(criteria,pageable),HttpStatus.OK);
}
@GetMapping("queryAllShopUser")
@Log("查询商家用户")
@ApiOperation("查询商家用户")
public ResponseEntity<Object> queryAllShopUser(TbShopUserQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(tbShopUserService.queryAllShopUser(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增/shop/user")
@ApiOperation("新增/shop/user")
@PreAuthorize("@el.check('tbShopUser:add')")
public ResponseEntity<Object> createTbShopUser(@Validated @RequestBody TbShopUser resources){
return new ResponseEntity<>(tbShopUserService.create(resources),HttpStatus.CREATED);
}
@@ -70,7 +74,6 @@ public class TbShopUserController {
@PutMapping
@Log("修改/shop/user")
@ApiOperation("修改/shop/user")
@PreAuthorize("@el.check('tbShopUser:edit')")
public ResponseEntity<Object> updateTbShopUser(@Validated @RequestBody TbShopUser resources){
tbShopUserService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
@@ -79,7 +82,6 @@ public class TbShopUserController {
@DeleteMapping
@Log("删除/shop/user")
@ApiOperation("删除/shop/user")
@PreAuthorize("@el.check('tbShopUser:del')")
public ResponseEntity<Object> deleteTbShopUser(@RequestBody Integer[] ids) {
tbShopUserService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);

View File

@@ -17,8 +17,8 @@ import io.swagger.annotations.*;
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "商户视频号管理")
@RequestMapping("/api/tbShopVideo")
@Api(tags = "商户视频号/公众号管理")
@RequestMapping("/api/tbShopSource")
public class TbShopVideoController {
private final TbShopVideoService tbShopVideoService;
@@ -27,6 +27,15 @@ public class TbShopVideoController {
@Log("查询商户视频号")
@ApiOperation("查询商户视频号")
public ResponseEntity<Object> queryTbShopVideo(TbShopVideoQueryCriteria criteria){
criteria.setType(3);
return new ResponseEntity<>(tbShopVideoService.queryAllPage(criteria), HttpStatus.OK);
}
@GetMapping("media")
@Log("查询公众号")
@ApiOperation("查询公众号")
public ResponseEntity<Object> queryMediaPlatform(TbShopVideoQueryCriteria criteria){
criteria.setType(1);
return new ResponseEntity<>(tbShopVideoService.queryAllPage(criteria), HttpStatus.OK);
}
@@ -38,10 +47,19 @@ public class TbShopVideoController {
return tbShopVideoService.findById(id);
}
@PostMapping("media")
@Log("新增公众号")
@ApiOperation("新增公众号")
public ResponseEntity<Object> createMediaPlatform(@Validated @RequestBody TbShopVideo resources){
resources.setType(1);
return new ResponseEntity<>(tbShopVideoService.create(resources),HttpStatus.CREATED);
}
@PostMapping
@Log("新增商户视频号")
@ApiOperation("新增商户视频号")
public ResponseEntity<Object> createTbShopVideo(@Validated @RequestBody TbShopVideo resources){
resources.setType(3);
return new ResponseEntity<>(tbShopVideoService.create(resources),HttpStatus.CREATED);
}

View File

@@ -37,5 +37,5 @@ public class TbShopUserQueryCriteria{
@Query
private String shopId;
@Query
private Integer isVip=1;
private Integer isVip;
}

View File

@@ -21,11 +21,17 @@ public class TbShopVideoDto implements Serializable {
/** 视频号id */
private Integer channelId;
/** 视频id */
private Integer videoId;
/** 1-公众号2-小程序3-视频号 */
private Integer type;
/** 视频地址 */
private String videoUrl;
/** 资源Id(视频号id)(公众号id) */
private Integer sourceId;
/** 资源地址 */
private String sourceUrl;
/** 0:关闭1开启 */
private Integer status;
/** 创建时间 */
private Timestamp createdTime;

View File

@@ -8,6 +8,10 @@ public class TbShopVideoQueryCriteria {
@Query
private Integer shopId;
@Query
private Integer type;
@Query
private Integer status;
private Integer pageSize = 10;

View File

@@ -32,16 +32,24 @@ public class TbShopVideo implements Serializable {
private String name;
@Column(name = "`channel_id`")
@ApiModelProperty(value = "视频号id")
@ApiModelProperty(value = "渠道id(视频号id)")
private Integer channelId;
@Column(name = "`video_id`")
@ApiModelProperty(value = "视频id")
private Integer videoId;
@Column(name = "`type`")
@ApiModelProperty(value = "1-公众号2-小程序3-视频号;")
private Integer type;
@Column(name = "`video_url`")
@ApiModelProperty(value = "视频地址")
private String videoUrl;
@Column(name = "`source_id`")
@ApiModelProperty(value = "资源Id(视频号id)(公众号id)")
private Integer sourceId;
@Column(name = "`source_url`")
@ApiModelProperty(value = "资源地址")
private String sourceUrl;
@Column(name = "`status`")
@ApiModelProperty(value = "0:关闭1开启")
private Integer status;
@Column(name = "`created_time`")
@ApiModelProperty(value = "创建时间")

View File

@@ -16,7 +16,10 @@
package cn.ysk.cashier.repository.shop;
import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.vo.ShopUserInfoVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
@@ -32,6 +35,16 @@ import java.util.List;
**/
public interface TbShopUserRepository extends JpaRepository<TbShopUser, Integer>,JpaSpecificationExecutor<TbShopUser> {
@Query("SELECT NEW cn.ysk.cashier.vo.ShopUserInfoVo(su.id, su.isVip, u.nickName, u.headImg, u.telephone, su.updatedAt) " +
"FROM TbShopUser su " +
"LEFT JOIN TbUserInfo u " +
"on su.userId = CAST(u.id AS string) " +
"WHERE su.isVip = IFNULL(:isVip, su.isVip)" +
"AND (u.telephone = IFNULL(:phone, u.telephone))" +
"AND su.shopId = :shopId")
Page<ShopUserInfoVo> findShopUserJoinUserInfo(String shopId,Integer isVip,String phone, Pageable pageable);
@Query("SELECT count(0) from TbShopUser user where user.shopId = :shopId")
Tuple searchByCount(@Param("shopId") String shopId);

View File

@@ -192,8 +192,8 @@ public class TbProductServiceImpl implements TbProductService {
TbProduct tbProduct = tbProductRepository.findById(id).orElseGet(TbProduct::new);
//单位
CompletableFuture<TbShopUnit> tbShopUnits = CompletableFuture.supplyAsync(() ->
tbShopUnitRepository.searchUnit(Integer.valueOf(StringUtils.isEmpty(tbProduct.getUnitId()) ? null : tbProduct.getUnitId())));
// CompletableFuture<TbShopUnit> tbShopUnits = CompletableFuture.supplyAsync(() ->
// tbShopUnitRepository.searchUnit(Integer.valueOf(StringUtils.isEmpty(tbProduct.getUnitId()) ? null : tbProduct.getUnitId())));
//sku
CompletableFuture<List<TbProductSku>> tbProductSkus = CompletableFuture.supplyAsync(() ->
tbProductSkuRepository.searchSku(tbProduct.getId().toString()));
@@ -201,15 +201,16 @@ public class TbProductServiceImpl implements TbProductService {
CompletableFuture<TbProductSpec> tbProductSpec = CompletableFuture.supplyAsync(() ->
tbProductSpecRepository.searchSpec(tbProduct.getSpecId()));
Threads.call(tbShopUnits, tbProductSkus, tbProductSpec);
// Threads.call(tbShopUnits, tbProductSkus, tbProductSpec);
Threads.call(tbProductSkus, tbProductSpec);
//组装
TbProductVo tbProductVo = new TbProductVo();
tbProductVo.setCategoryId(tbProduct.getCategoryId());
//单位
if (tbProduct.getUnitId() == null) {
tbProductVo.setUnitId(null);
tbProductVo.setUnitName(null);
}
// if (tbProduct.getUnitId() == null) {
// tbProductVo.setUnitId(null);
// tbProductVo.setUnitName(null);
// }
//套餐
if (tbProduct.getGroupSnap() == null) {
tbProductVo.setGroupSnap(new JSONArray());

View File

@@ -15,34 +15,36 @@
*/
package cn.ysk.cashier.service.impl.shopimpl;
import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.utils.ValidationUtil;
import cn.ysk.cashier.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
import cn.ysk.cashier.service.shop.TbShopUserService;
import cn.ysk.cashier.dto.shop.TbShopUserDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.mapper.shop.TbShopUserMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
import cn.ysk.cashier.service.shop.TbShopUserService;
import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import cn.ysk.cashier.utils.ValidationUtil;
import cn.ysk.cashier.vo.ShopUserInfoVo;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author lyf
* @date 2024-03-01
**/
* @author lyf
* @website https://eladmin.vip
* @description 服务实现
* @date 2024-03-01
**/
@Service
@RequiredArgsConstructor
public class TbShopUserServiceImpl implements TbShopUserService {
@@ -51,21 +53,33 @@ public class TbShopUserServiceImpl implements TbShopUserService {
private final TbShopUserMapper tbShopUserMapper;
@Override
public Map<String,Object> queryAll(TbShopUserQueryCriteria criteria, Pageable pageable){
Page<TbShopUser> page = tbShopUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
public Map<String, Object> queryAllShopUser(TbShopUserQueryCriteria criteria, Pageable pageable) {
Page<ShopUserInfoVo> shopUserJoinUserInfo =
tbShopUserRepository.findShopUserJoinUserInfo(
criteria.getShopId(),
criteria.getIsVip(),
criteria.getTelephone(),
pageable);
return PageUtil.toPage(shopUserJoinUserInfo);
}
@Override
public Map<String, Object> queryAll(TbShopUserQueryCriteria criteria, Pageable pageable) {
criteria.setIsVip(1);
Page<TbShopUser> page = tbShopUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return PageUtil.toPage(page.map(tbShopUserMapper::toDto));
}
@Override
public List<TbShopUserDto> queryAll(TbShopUserQueryCriteria criteria){
return tbShopUserMapper.toDto(tbShopUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
public List<TbShopUserDto> queryAll(TbShopUserQueryCriteria criteria) {
return tbShopUserMapper.toDto(tbShopUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
}
@Override
@Transactional
public TbShopUserDto findById(Integer id) {
TbShopUser tbShopUser = tbShopUserRepository.findById(id).orElseGet(TbShopUser::new);
ValidationUtil.isNull(tbShopUser.getId(),"TbShopUser","id",id);
ValidationUtil.isNull(tbShopUser.getId(), "TbShopUser", "id", id);
return tbShopUserMapper.toDto(tbShopUser);
}
@@ -79,7 +93,7 @@ public class TbShopUserServiceImpl implements TbShopUserService {
@Transactional(rollbackFor = Exception.class)
public void update(TbShopUser resources) {
TbShopUser tbShopUser = tbShopUserRepository.findById(resources.getId()).orElseGet(TbShopUser::new);
ValidationUtil.isNull( tbShopUser.getId(),"TbShopUser","id",resources.getId());
ValidationUtil.isNull(tbShopUser.getId(), "TbShopUser", "id", resources.getId());
tbShopUser.copy(resources);
tbShopUserRepository.save(tbShopUser);
}
@@ -95,7 +109,7 @@ public class TbShopUserServiceImpl implements TbShopUserService {
public void download(List<TbShopUserDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (TbShopUserDto tbShopUser : all) {
Map<String,Object> map = new LinkedHashMap<>();
Map<String, Object> map = new LinkedHashMap<>();
map.put("钱包余额", tbShopUser.getAmount());
map.put("授权金额", tbShopUser.getCreditAmount());
map.put("消费累计", tbShopUser.getConsumeAmount());
@@ -108,7 +122,7 @@ public class TbShopUserServiceImpl implements TbShopUserService {
map.put("上级Id", tbShopUser.getParentId());
map.put("上级的层级", tbShopUser.getParentLevel());
map.put("真实名字", tbShopUser.getName());
map.put(" headImg", tbShopUser.getHeadImg());
map.put(" headImg", tbShopUser.getHeadImg());
map.put("性别", tbShopUser.getSex());
map.put("生日", tbShopUser.getBirthDay());
map.put("联系电话", tbShopUser.getTelephone());
@@ -120,8 +134,8 @@ public class TbShopUserServiceImpl implements TbShopUserService {
map.put("层级1-顶级 2-次级 3最低", tbShopUser.getLevel());
map.put("分销类型 auto-自动获取 set手动设置 charge充值", tbShopUser.getDistributeType());
map.put("排序", tbShopUser.getSort());
map.put(" createdAt", tbShopUser.getCreatedAt());
map.put(" updatedAt", tbShopUser.getUpdatedAt());
map.put(" createdAt", tbShopUser.getCreatedAt());
map.put(" updatedAt", tbShopUser.getUpdatedAt());
map.put("小程序openId", tbShopUser.getMiniOpenId());
list.add(map);
}

View File

@@ -32,8 +32,17 @@ import javax.servlet.http.HttpServletResponse;
**/
public interface TbShopUserService {
/**
* 查询数据分页
* 商家后台 用户管理
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String, Object> queryAllShopUser(TbShopUserQueryCriteria criteria, Pageable pageable);
/**
* 会员管理
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>

View File

@@ -47,7 +47,11 @@ public class DictDetail extends BaseEntity implements Serializable {
@ApiModelProperty(value = "字典", hidden = true)
private Dict dict;
@ApiModelProperty(value = "字典标签")
@Column(name = "dict_name")
@ApiModelProperty(value = "字典标识")
private String dictName;
@ApiModelProperty(value = "字典名称")
private String label;
@ApiModelProperty(value = "字典值")

View File

@@ -32,6 +32,8 @@ public class DictDetailDto extends BaseDTO implements Serializable {
private DictSmallDto dict;
private String dictName;
private String label;
private String value;

View File

@@ -64,6 +64,7 @@ public class DictDetailServiceImpl implements DictDetailService {
Dict dict = dictRepository.findById(resources.getDict().getId()).orElseGet(Dict::new);
dict.setIsChild(1);
dictRepository.save(dict);
resources.setDictName(dict.getDictName());
// 清理缓存
delCaches(resources);
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2019-6-10 16:32:18
*/
@Data
public class ShopUserInfoVo implements Serializable {
private Integer id;
private Integer isVip;
private String nickName;
private String headImg;
private String telephone;
private Long updatedAt;
public ShopUserInfoVo() {
}
public ShopUserInfoVo(Integer id, Integer isVip, String nickName, String headImg, String telephone, Long updatedAt) {
this.id = id;
this.isVip = isVip;
this.nickName = nickName;
this.headImg = headImg;
this.telephone = telephone;
this.updatedAt = updatedAt;
}
}