Merge remote-tracking branch 'origin/dev'

# Conflicts:
#	eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMShopUserMapper.java
#	eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopUserFlowMapper.java
This commit is contained in:
SongZhang 2024-07-11 13:37:04 +08:00
commit 98e49a8e30
26 changed files with 382 additions and 171 deletions

View File

@ -5,6 +5,7 @@ import cn.ysk.cashier.cons.domain.TbProskuCon;
import cn.ysk.cashier.cons.service.TbProskuConService; import cn.ysk.cashier.cons.service.TbProskuConService;
import cn.ysk.cashier.cons.service.dto.ProskuInfo; import cn.ysk.cashier.cons.service.dto.ProskuInfo;
import cn.ysk.cashier.cons.service.dto.TbProskuConQueryCriteria; import cn.ysk.cashier.cons.service.dto.TbProskuConQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -13,6 +14,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/** /**
@ -44,8 +46,14 @@ public class TbProskuConController {
@PostMapping @PostMapping
@Log("新增商品规格耗材信息") @Log("新增商品规格耗材信息")
@ApiOperation("新增商品规格耗材信息") @ApiOperation("新增商品规格耗材信息")
public ResponseEntity<Object> createTbProskuCon(@Validated @RequestBody ProskuInfo resources) throws Exception { public ResponseEntity<Object> createTbProskuCon(@Validated @RequestBody List<ProskuInfo> resources) throws Exception {
try {
return new ResponseEntity<>(tbProskuConService.create(resources),HttpStatus.CREATED); return new ResponseEntity<>(tbProskuConService.create(resources),HttpStatus.CREATED);
} catch (BadRequestException be) {
throw new Exception(be.getMessage());
}catch (Exception e){
throw new Exception("系统异常");
}
} }
@PutMapping @PutMapping

View File

@ -43,7 +43,7 @@ public interface TbProskuConService {
* @param resources / * @param resources /
* @return TbProskuConDto * @return TbProskuConDto
*/ */
TbProskuConDto create(ProskuInfo resources) throws Exception; TbProskuConDto create(List<ProskuInfo> resources) throws Exception;
/** /**
* 编辑 * 编辑

View File

@ -6,20 +6,19 @@ import cn.ysk.cashier.cons.domain.TbConsSuppFlow;
import cn.ysk.cashier.cons.domain.TbProskuCon; import cn.ysk.cashier.cons.domain.TbProskuCon;
import cn.ysk.cashier.cons.repository.TbConsInfoRepository; import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
import cn.ysk.cashier.cons.service.dto.ProskuInfo; import cn.ysk.cashier.cons.service.dto.ProskuInfo;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.pojo.product.TbProduct; import cn.ysk.cashier.pojo.product.TbProduct;
import cn.ysk.cashier.pojo.product.TbProductSku; import cn.ysk.cashier.pojo.product.TbProductSku;
import cn.ysk.cashier.repository.product.TbProductRepository; import cn.ysk.cashier.repository.product.TbProductRepository;
import cn.ysk.cashier.repository.product.TbProductSkuRepository; import cn.ysk.cashier.repository.product.TbProductSkuRepository;
import cn.ysk.cashier.utils.FileUtil; import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.ValidationUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.cons.repository.TbProskuConRepository; import cn.ysk.cashier.cons.repository.TbProskuConRepository;
import cn.ysk.cashier.cons.service.TbProskuConService; import cn.ysk.cashier.cons.service.TbProskuConService;
import cn.ysk.cashier.cons.service.dto.TbProskuConDto; import cn.ysk.cashier.cons.service.dto.TbProskuConDto;
import cn.ysk.cashier.cons.service.dto.TbProskuConQueryCriteria; import cn.ysk.cashier.cons.service.dto.TbProskuConQueryCriteria;
import cn.ysk.cashier.cons.service.mapstruct.TbProskuConMapper; import cn.ysk.cashier.cons.service.mapstruct.TbProskuConMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@ -38,6 +37,7 @@ import javax.servlet.http.HttpServletResponse;
**/ **/
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j
public class TbProskuConServiceImpl implements TbProskuConService { public class TbProskuConServiceImpl implements TbProskuConService {
private final TbProskuConRepository tbProskuConRepository; private final TbProskuConRepository tbProskuConRepository;
@ -70,50 +70,67 @@ public class TbProskuConServiceImpl implements TbProskuConService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public TbProskuConDto create(ProskuInfo resources) throws Exception { public TbProskuConDto create(List<ProskuInfo> resources) throws BadRequestException,Exception {
for (ProskuInfo resource : resources) {
TbProduct product= tbProductRepository.getById(resources.getProductId()); TbProduct product= tbProductRepository.getById(resource.getProductId());
if(Objects.isNull(product)){ if(Objects.isNull(product)){
throw new Exception("对应的商品信息不存在"); throw new BadRequestException("对应的商品信息不存在");
} }
TbConsInfo tbConsInfo= tbConsInfoRepository.getById(resources.getConsInfoId());
if(Objects.isNull(tbConsInfo)){
throw new Exception("对应的耗材信息不存在");
}
List<TbProskuCon> list=new ArrayList<>(); List<TbProskuCon> list=new ArrayList<>();
if(product.getIsDistribute().intValue()==1){ if(product.getIsDistribute().intValue()==1){
TbConsInfo tbConsInfo= tbConsInfoRepository.findById(resource.getConsInfoId()).orElseGet(TbConsInfo::new);
log.info("product.getIsDistribute().intValue():{}", JSONUtil.toJSONString(tbConsInfo));
if(ObjectUtil.isNull(tbConsInfo)||ObjectUtil.isNull(tbConsInfo.getId())){
throw new BadRequestException("对应的耗材信息不存在");
}
//查询商品对应的所有规格 //查询商品对应的所有规格
List<TbProductSku> skuList= tbProductSkuRepository.searchSku(product.getId().toString()); List<TbProductSku> skuList= tbProductSkuRepository.searchSku(product.getId().toString());
if(Objects.nonNull(skuList)&&skuList.size()>0){ if(Objects.nonNull(skuList)&&skuList.size()>0){
for (TbProductSku tbProductSku : skuList) { for (TbProductSku tbProductSku : skuList) {
int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resources.getConsInfoId(), tbProductSku.getId(), Integer.valueOf(tbProductSku.getShopId()), Integer.valueOf(tbProductSku.getProductId())); int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resource.getConsInfoId(), tbProductSku.getId(), Integer.valueOf(tbProductSku.getShopId()), Integer.valueOf(tbProductSku.getProductId()));
if(count<=0){ if(count<=0){
TbProskuCon tbProskuCon=new TbProskuCon(); TbProskuCon tbProskuCon=new TbProskuCon();
tbProskuCon.setShopId(Integer.valueOf(tbProductSku.getShopId())); tbProskuCon.setShopId(Integer.valueOf(tbProductSku.getShopId()));
tbProskuCon.setConInfoId(resources.getConsInfoId()); tbProskuCon.setConInfoId(tbConsInfo.getId());
tbProskuCon.setProductId(Integer.valueOf(tbProductSku.getProductId())); tbProskuCon.setProductId(Integer.valueOf(tbProductSku.getProductId()));
tbProskuCon.setProductSkuId(tbProductSku.getId()); tbProskuCon.setProductSkuId(tbProductSku.getId());
tbProskuCon.setSurplusStock(resources.getSurplusStock()); tbProskuCon.setSurplusStock(resource.getSurplusStock());
tbProskuCon.setStatus("1"); tbProskuCon.setStatus("1");
tbProskuCon.setCreateTime(new Timestamp(System.currentTimeMillis())); tbProskuCon.setCreateTime(new Timestamp(System.currentTimeMillis()));
list.add(tbProskuCon); list.add(tbProskuCon);
}else { }else {
throw new Exception(product.getName().concat("对应的耗材信息已存在")); throw new BadRequestException(product.getName().concat("对应的耗材信息已存在"));
} }
} }
} }
}else { }else {
for (ProskuInfo.SkuInfo skuInfo : resources.getSkuInfos()) { for (ProskuInfo.SkuInfo skuInfo : resource.getSkuInfos()) {
int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resources.getConsInfoId(), skuInfo.getSkuId(), skuInfo.getShopId(), resources.getProductId());
TbConsInfo tbConsInfo= tbConsInfoRepository.findById(skuInfo.getConInfoId()).orElseGet(TbConsInfo::new);
log.info("skuInfo:{}", JSONUtil.toJSONString(tbConsInfo));
if(ObjectUtil.isNull(tbConsInfo)||ObjectUtil.isNull(tbConsInfo.getId())){
throw new BadRequestException("对应的耗材信息不存在");
}
TbProductSku tbProductSku= tbProductSkuRepository.findById(skuInfo.getSkuId()).orElseGet(TbProductSku::new);
if(ObjectUtil.isNull(tbProductSku)||ObjectUtil.isNull(tbProductSku.getId())){
throw new BadRequestException("规格信息不存在");
}
int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resource.getConsInfoId(), skuInfo.getSkuId(), skuInfo.getShopId(), resource.getProductId());
if(count<=0){ if(count<=0){
TbProskuCon tbProskuCon=new TbProskuCon(); TbProskuCon tbProskuCon=new TbProskuCon();
tbProskuCon.setShopId(Integer.valueOf(skuInfo.getShopId())); tbProskuCon.setShopId(Integer.valueOf(skuInfo.getShopId()));
tbProskuCon.setConInfoId(skuInfo.getConInfoId()); tbProskuCon.setConInfoId(tbConsInfo.getId());
tbProskuCon.setProductId(resources.getProductId()); tbProskuCon.setProductId(resource.getProductId());
tbProskuCon.setProductSkuId(skuInfo.getSkuId()); tbProskuCon.setProductSkuId(skuInfo.getSkuId());
tbProskuCon.setSurplusStock(skuInfo.getSurplusStock()); tbProskuCon.setSurplusStock(skuInfo.getSurplusStock());
tbProskuCon.setStatus("1"); tbProskuCon.setStatus("1");
@ -121,7 +138,7 @@ public class TbProskuConServiceImpl implements TbProskuConService {
list.add(tbProskuCon); list.add(tbProskuCon);
}else { }else {
TbProductSku sku= tbProductSkuRepository.getById(skuInfo.getSkuId()); TbProductSku sku= tbProductSkuRepository.getById(skuInfo.getSkuId());
throw new Exception(product.getName().concat("商品对应的").concat(Objects.nonNull(sku.getSpecSnap())?sku.getSpecSnap():"").concat("规格已存在")); throw new BadRequestException(product.getName().concat("商品对应的").concat(Objects.nonNull(sku.getSpecSnap())?sku.getSpecSnap():"").concat("规格已存在"));
} }
} }
@ -129,6 +146,9 @@ public class TbProskuConServiceImpl implements TbProskuConService {
if(Objects.nonNull(list)&&list.size()>0){ if(Objects.nonNull(list)&&list.size()>0){
tbProskuConRepository.saveAll(list); tbProskuConRepository.saveAll(list);
} }
}
return new TbProskuConDto(); return new TbProskuConDto();
} }

View File

@ -1,4 +1,4 @@
package cn.ysk.cashier.controller.shop; package cn.ysk.cashier.controller.order;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping; import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
@ -51,26 +51,8 @@ public class TbShopSongOrderController{
@ApiOperation("获取歌曲列表 分页") @ApiOperation("获取歌曲列表 分页")
@AnonymousGetMapping @AnonymousGetMapping
public ResponseEntity<Object> selectAll(TbShopSongOrderQueryCriteria tbShopSongOrder) { public ResponseEntity<Object> selectAll(TbShopSongOrderQueryCriteria tbShopSongOrder) {
String code = ""; return new ResponseEntity<>(tbShopSongOrderService.queryAll(tbShopSongOrder), HttpStatus.OK);
if(redisUtils.hasKey(CacheKey.SONG_URL + tbShopSongOrder.getShopId())){
code = (String) redisUtils.get(CacheKey.SONG_URL + tbShopSongOrder.getShopId());
} }
Map<String, Object> stringObjectMap = tbShopSongOrderService.queryAll(tbShopSongOrder);
stringObjectMap.put("songUrl",code);
return new ResponseEntity<>(stringObjectMap, HttpStatus.OK);
}
@PostMapping("createUrl")
@ApiOperation("更新歌手页地址")
@AnonymousPostMapping
public ResponseEntity<Object> createUrl(String shopId) {
String key = RandomStringUtils.randomAlphanumeric(8);
redisUtils.set(CacheKey.SONG_URL + shopId, key);
redisUtils.set(CacheKey.SONG_URL + key, shopId);
return new ResponseEntity<>(key,HttpStatus.OK);
}
/** /**
* 通过主键查询单条数据 * 通过主键查询单条数据

View File

@ -1,6 +1,5 @@
package cn.ysk.cashier.controller.product; package cn.ysk.cashier.controller.product;
import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.dto.product.TbProductSortCriteria; import cn.ysk.cashier.dto.product.TbProductSortCriteria;
import cn.ysk.cashier.vo.TbProductVo; import cn.ysk.cashier.vo.TbProductVo;

View File

@ -1,7 +1,5 @@
package cn.ysk.cashier.controller.shop; package cn.ysk.cashier.controller.shop;
import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.dto.ShopSummaryDto; import cn.ysk.cashier.dto.ShopSummaryDto;
import cn.ysk.cashier.service.SummaryService; import cn.ysk.cashier.service.SummaryService;
import cn.ysk.cashier.vo.TbOrderPayCountVo; import cn.ysk.cashier.vo.TbOrderPayCountVo;

View File

@ -1,13 +1,17 @@
package cn.ysk.cashier.controller.shop; package cn.ysk.cashier.controller.shop;
import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.dto.shop.TbShopSongQueryCriteria; import cn.ysk.cashier.dto.shop.TbShopSongQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.entity.TbShopSong; import cn.ysk.cashier.mybatis.entity.TbShopSong;
import cn.ysk.cashier.mybatis.service.TbShopSongService; import cn.ysk.cashier.mybatis.service.TbShopSongService;
import cn.ysk.cashier.utils.CacheKey;
import cn.ysk.cashier.utils.RedisUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -16,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
@RestController @RestController
@ -23,12 +28,33 @@ import java.util.List;
@Api(tags = "歌曲管理") @Api(tags = "歌曲管理")
@RequestMapping("/api/tbShopSong") @RequestMapping("/api/tbShopSong")
public class TbShopSongController { public class TbShopSongController {
private final RedisUtils redisUtils;
private final TbShopSongService tbShopSongService; private final TbShopSongService tbShopSongService;
@GetMapping @GetMapping
@ApiOperation("查询歌曲列表") @ApiOperation("查询歌曲列表")
public ResponseEntity<Object> queryTbShopPurveyor(TbShopSongQueryCriteria criteria){ public ResponseEntity<Object> queryTbShopPurveyor(TbShopSongQueryCriteria criteria){
return new ResponseEntity<>(tbShopSongService.queryAll(criteria), HttpStatus.OK); String code = "";
if(redisUtils.hasKey(CacheKey.SONG_URL + criteria.getShopId())){
code = (String) redisUtils.get(CacheKey.SONG_URL + criteria.getShopId());
}else {
code = RandomStringUtils.randomAlphanumeric(12);
redisUtils.set(CacheKey.SONG_URL + criteria.getShopId(), code);
redisUtils.set(CacheKey.SONG_URL + code, criteria.getShopId());
}
Map<String, Object> stringObjectMap = tbShopSongService.queryAll(criteria);
stringObjectMap.put("songUrl",code);
return new ResponseEntity<>(stringObjectMap, HttpStatus.OK);
}
@PostMapping("createUrl")
@ApiOperation("更新歌手页地址")
@AnonymousPostMapping
public ResponseEntity<Object> createUrl(String shopId) {
String key = RandomStringUtils.randomAlphanumeric(12);
redisUtils.set(CacheKey.SONG_URL + shopId, key);
redisUtils.set(CacheKey.SONG_URL + key, shopId);
return new ResponseEntity<>(key,HttpStatus.OK);
} }
@PostMapping @PostMapping

View File

@ -2,6 +2,9 @@ package cn.ysk.cashier.controller.shop;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.annotation.AnonymousAccess; import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria; import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.service.TbMShopUserService; import cn.ysk.cashier.mybatis.service.TbMShopUserService;
@ -20,8 +23,8 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
/** /**
* @website https://eladmin.vip
* @author lyf * @author lyf
* @website https://eladmin.vip
* @date 2024-03-01 * @date 2024-03-01
**/ **/
@RestController @RestController
@ -47,6 +50,7 @@ public class TbShopUserController {
@GetMapping("queryAllShopUser") @GetMapping("queryAllShopUser")
@ApiOperation("查询商家用户") @ApiOperation("查询商家用户")
@AnonymousGetMapping
public ResponseEntity<Object> queryAllShopUser(TbShopUserQueryCriteria criteria) { public ResponseEntity<Object> queryAllShopUser(TbShopUserQueryCriteria criteria) {
return new ResponseEntity<>(tbShopUserService.queryShopUser(criteria), HttpStatus.OK); return new ResponseEntity<>(tbShopUserService.queryShopUser(criteria), HttpStatus.OK);
} }
@ -80,4 +84,16 @@ public class TbShopUserController {
tbShopUserService.deleteAll(ids); tbShopUserService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@GetMapping("/recharge")
@ApiOperation("充值记录")
public ResponseEntity<Object> rechargeList(TbShopRechargeListDto criteria, Pageable pageable) {
return new ResponseEntity<>(tbShopUserService.rechargeList(criteria, pageable), HttpStatus.OK);
}
@PostMapping("/recharge/download")
@ApiOperation("导出充值记录")
public void rechargeListDownload(HttpServletResponse response, @RequestBody TbShopRechargeListDto criteria) throws IOException {
tbShopUserService.rechargeListDownload(response, criteria);
}
} }

View File

@ -56,6 +56,8 @@ public class TbProductSkuDto implements Serializable {
/** 进货参考价 */ /** 进货参考价 */
private BigDecimal guidePrice; private BigDecimal guidePrice;
private Integer suit;
private BigDecimal strategyPrice; private BigDecimal strategyPrice;
/** 库存数量 */ /** 库存数量 */

View File

@ -0,0 +1,18 @@
package cn.ysk.cashier.dto.shop;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author GYJ
*/
@Data
public class TbShopRechargeListDto {
private String shopId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
}

View File

@ -0,0 +1,36 @@
package cn.ysk.cashier.dto.shop;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author GYJ
*/
@Data
public class TbShopRechargeRespDto {
private Integer id;
private String shopId;
private String shopName;
private String userId;
private String userName;
private String userPhone;
private Object rechargeAmount;
private String rechargeType;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date rechargeTime;
public TbShopRechargeRespDto(Integer id, String shopId, String shopName, String userId, String userName, String userPhone,
String rechargeAmount, String rechargeType, Date rechargeTime) {
this.id = id;
this.shopId = shopId;
this.shopName = shopName;
this.userId = userId;
this.userName = userName;
this.userPhone = userPhone;
this.rechargeAmount = rechargeAmount;
this.rechargeType = rechargeType;
this.rechargeTime = rechargeTime;
}
}

View File

@ -5,16 +5,22 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
* @author GYJ * @author GYJ
*/ */
@Entity
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("tb_shop_user_flow") @TableName("tb_shop_user_flow")
@Table(name="tb_shop_user_flow")
public class TbShopUserFlow extends Model<TbShopUserFlow> { public class TbShopUserFlow extends Model<TbShopUserFlow> {
@Id
private Integer id; private Integer id;
private Integer shopUserId; private Integer shopUserId;

View File

@ -1,5 +1,7 @@
package cn.ysk.cashier.mybatis.mapper; package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria; import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.pojo.shop.TbShopUser; import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.vo.ShopUserInfoVo; import cn.ysk.cashier.vo.ShopUserInfoVo;
@ -17,18 +19,38 @@ public interface ShopUserMapper extends BaseMapper<TbShopUser> {
"FROM tb_shop_user su " + "FROM tb_shop_user su " +
"LEFT JOIN tb_user_info u ON su.user_id = u.id " + "LEFT JOIN tb_user_info u ON su.user_id = u.id " +
"<where> " + "<where> " +
"su.user_id is not null and su.user_id != ''" +
"<if test='param.shopId != null and param.shopId != &quot;&quot; and param.shopId != 1'>" + "<if test='param.shopId != null and param.shopId != &quot;&quot; and param.shopId != 1'>" +
"AND su.shop_id = #{param.shopId} " + "AND su.shop_id = #{param.shopId} " +
"</if>" + "</if>" +
"<if test='param.name != null and param.name != &quot;&quot;'>" + "<if test='param.name != null and param.name != &quot;&quot;'>" +
"AND (u.nick_name like concat('%', #{param.name}, '%') or u.telephone like concat('%', #{param.name}, '%'))" + "AND (u.nick_name like concat('%', #{param.name}, '%') or su.name LIKE concat( '%', #{param.name}, '%' ) " +
" or u.telephone like concat('%', #{param.name}, '%') or su.telephone like concat('%', #{param.name}, '%'))" +
"</if>" + "</if>" +
"<if test='param.isVip != null and param.isVip != &quot;&quot;'>" + "<if test='isVip != null'>" +
"AND su.is_vip=#{param.isVip}" + "AND su.is_vip=#{isVip}" +
"</if>" + "</if>" +
"</where>" + "</where>" +
"</script>") "</script>")
IPage<ShopUserInfoVo> queryUser(TbShopUserQueryCriteria param, Page pageInfo); IPage<ShopUserInfoVo> queryUser(TbShopUserQueryCriteria param, Integer isVip, Page pageInfo);
@Select("<script> " +
"select " +
"tsuf.id as id, " +
"tsu.shop_id as shop_id, " +
"tsi.shop_name, " +
"tsu.id as user_id, " +
"tsu.telephone as user_phone, " +
"tsu.`name` as user_name, " +
"tsuf.amount as recharge_amount, " +
"tsuf.biz_name as recharge_type, " +
"tsuf.create_time as recharge_time " +
" from tb_shop_user_flow tsuf " +
" left join tb_shop_user as tsu on tsuf.shop_user_id = tsu.id " +
"left join tb_shop_info as tsi on tsi.id = tsu.shop_id " +
"where tsuf.create_time BETWEEN #{param.startTime} and #{param.endTime} and tsuf.biz_code in ('cashMemberIn', 'scanMemberIn', 'scanMemberAwardIn') " +
" and tsu.shop_id = #{param.shopId} " +
"order by tsuf.create_time desc " +
"</script>")
IPage<TbShopRechargeRespDto> queryRechargeList(TbShopRechargeListDto param, Page pageInfo);
} }

View File

@ -16,19 +16,23 @@ import java.util.Map;
*/ */
public interface TbMShopUserMapper extends BaseMapper<TbMShopUser> { public interface TbMShopUserMapper extends BaseMapper<TbMShopUser> {
@Select("<script>" + @Select("<script>" +
"SELECT " + "SELECT \n" +
"COUNT(*) userTotal, " + " COUNT(DISTINCT a.id) AS userTotal, \n" +
"ifnull(SUM( " + " COALESCE(SUM(flow.total_amount), 0) AS chageTotal, \n" +
"IFNULL( b.charge_amount, 0 )), 0) chageTotal, ifnull(SUM( IFNULL( a.amount, 0 )), 0) balanceTotal " + " COALESCE(SUM(a.amount), 0) AS balanceTotal \n" +
"FROM \n" + "FROM \n" +
" tb_shop_user AS a\n" + " tb_shop_user AS a\n" +
"LEFT JOIN tb_user_info AS b ON a.user_id = b.id\n" + " LEFT JOIN (\n" +
" SELECT shop_user_id, SUM(amount) AS total_amount \n" +
" FROM tb_shop_user_flow \n" +
" WHERE biz_code IN ('cashMemberIn','scanMemberIn', 'scanMemberAwardIn') \n" +
" GROUP BY shop_user_id\n" +
" ) AS flow ON flow.shop_user_id = a.id\n" +
"WHERE \n" + "WHERE \n" +
" a.shop_id = #{shopId} \n" + " a.shop_id = #{shopId} \n" +
"<if test=\"isVip !=null\">\n" + "<if test=\"isVip !=null\">\n" +
" and a.is_vip=#{isVip}\n" + " and a.is_vip=#{isVip}\n" +
"</if>" + "</if>" +
"</script>") "</script>")
Map<String, Object> selectUserSummary(@Param("shopId") String shopId, @Param("isVip") Integer isVip); Map<String, Object> selectUserSummary(@Param("shopId") String shopId, @Param("isVip") Integer isVip);

View File

@ -19,23 +19,26 @@ public interface TbShopUserFlowMapper extends BaseMapper<TbShopUserFlow> {
* @param shopId 店铺ID * @param shopId 店铺ID
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 结束时间 * @param endTime 结束时间
* @param types 流水类型
* @return 用户流水总金额 * @return 用户流水总金额
*/ */
@Select("<script>" + @Select("<script>" +
"SELECT IFNULL(SUM(uf.amount), 0) FROM tb_shop_user_flow as uf " + " SELECT \n" +
"JOIN tb_shop_user su ON uf.shop_user_id = su.id " + " COALESCE(SUM(flow.total_amount), 0) AS chageTotal\n" +
"WHERE su.shop_id = #{shopId} " + "FROM \n" +
"AND uf.create_time BETWEEN #{startTime} AND #{endTime} " + " tb_shop_user AS a\n" +
"AND uf.biz_code IN " + " LEFT JOIN (\n" +
"<foreach collection='types' item='type' open='(' separator=',' close=')'> " + " SELECT shop_user_id, SUM(amount) AS total_amount \n" +
"#{type} " + " FROM tb_shop_user_flow \n" +
"</foreach> " + " WHERE biz_code IN ('cashMemberIn','scanMemberIn', 'scanMemberAwardIn') \n" +
" AND create_time BETWEEN #{startTime} AND #{endTime} \n" +
" GROUP BY shop_user_id\n" +
" ) AS flow ON flow.shop_user_id = a.id\n" +
"WHERE \n" +
" a.shop_id = #{shopId}" +
"</script>") "</script>")
BigDecimal sumUserFlowAmountByConditions(@Param("shopId") Long shopId, BigDecimal sumUserFlowAmountByConditions(@Param("shopId") Long shopId,
@Param("startTime") String startTime, @Param("startTime") String startTime,
@Param("endTime") String endTime, @Param("endTime") String endTime);
@Param("types") List<String> types);
} }

View File

@ -12,5 +12,5 @@ import java.util.List;
*/ */
public interface TbShopUserFlowService extends IService<TbShopUserFlow> { public interface TbShopUserFlowService extends IService<TbShopUserFlow> {
BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime, List<String> types); BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime);
} }

View File

@ -15,7 +15,7 @@ import java.util.List;
@Service @Service
public class TbShopUserFlowServiceImpl extends ServiceImpl<TbShopUserFlowMapper, TbShopUserFlow> implements TbShopUserFlowService { public class TbShopUserFlowServiceImpl extends ServiceImpl<TbShopUserFlowMapper, TbShopUserFlow> implements TbShopUserFlowService {
@Override @Override
public BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime, List<String> types) { public BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime) {
return baseMapper.sumUserFlowAmountByConditions(shopId, startTime, endTime, types); return baseMapper.sumUserFlowAmountByConditions(shopId, startTime, endTime);
} }
} }

View File

@ -1,33 +1,17 @@
/*
* 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.pojo.product; package cn.ysk.cashier.pojo.product;
import cn.hutool.json.JSON; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions; import lombok.Data;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.*; import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
/** /**
* @website https://eladmin.vip * @website https://eladmin.vip
@ -85,6 +69,9 @@ public class TbProductSku implements Serializable {
@ApiModelProperty(value = "进货参考价") @ApiModelProperty(value = "进货参考价")
private BigDecimal guidePrice; private BigDecimal guidePrice;
@ApiModelProperty(value = "起售数量 默认为1")
private Integer suit = 1;
@Column(name = "`strategy_price`") @Column(name = "`strategy_price`")
@ApiModelProperty(value = "strategyPrice") @ApiModelProperty(value = "strategyPrice")
private BigDecimal strategyPrice; private BigDecimal strategyPrice;
@ -132,13 +119,17 @@ public class TbProductSku implements Serializable {
@Column(name = "`updated_at`") @Column(name = "`updated_at`")
@ApiModelProperty(value = "updatedAt") @ApiModelProperty(value = "updatedAt")
private Long updatedAt; private Long updatedAt;
public void copy(TbProductSku source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); @Column(name = "`is_del`")
} private Integer isDel;
@Column(name = "`is_pause_sale`") @Column(name = "`is_pause_sale`")
@ApiModelProperty(value = "是否暂停销售") @ApiModelProperty(value = "是否暂停销售")
private Integer isPauseSale = 0; private Integer isPauseSale = 0;
public void copy(TbProductSku source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
} }

View File

@ -23,10 +23,10 @@ import java.util.List;
**/ **/
public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Integer>, JpaSpecificationExecutor<TbProductSku> { public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Integer>, JpaSpecificationExecutor<TbProductSku> {
@Query("SELECT sku FROM TbProductSku sku WHERE sku.productId IN :productId") @Query("SELECT sku FROM TbProductSku sku WHERE sku.productId IN :productId and sku.isDel=0")
List<TbProductSku> searchSku(@Param("productId")List<String> productId); List<TbProductSku> searchSku(@Param("productId")List<String> productId);
@Query("SELECT sku FROM TbProductSku sku WHERE sku.productId = :productId") @Query("SELECT sku FROM TbProductSku sku WHERE sku.productId = :productId and sku.isDel=0")
List<TbProductSku> searchSku(@Param("productId")String productId); List<TbProductSku> searchSku(@Param("productId")String productId);
@Transactional @Transactional
@ -34,7 +34,12 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
@Query("DELETE FROM TbProductSku sku WHERE sku.productId = :productId") @Query("DELETE FROM TbProductSku sku WHERE sku.productId = :productId")
Integer deleteByProductId(@Param("productId") String productId); Integer deleteByProductId(@Param("productId") String productId);
@Query("SELECT sku FROM TbProductSku sku WHERE sku.barCode = :barCode") @Transactional
@Modifying
@Query("update FROM TbProductSku sku set sku.isDel=1 WHERE sku.id = :skuId")
Integer deleteBySkuId(@Param("skuId") String skuId);
@Query("SELECT sku FROM TbProductSku sku WHERE sku.barCode = :barCode and sku.isDel=0")
TbProductSku searchBarCode(@Param("barCode")String barCode); TbProductSku searchBarCode(@Param("barCode")String barCode);
@Query("SELECT new cn.ysk.cashier.vo.StockVo(" + @Query("SELECT new cn.ysk.cashier.vo.StockVo(" +
@ -47,6 +52,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"WHERE " + "WHERE " +
"pro.shopId = :shopId " + "pro.shopId = :shopId " +
"AND pro.status = 1 " + "AND pro.status = 1 " +
"AND sku.isDel=0 " +
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " + "AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
"AND (:num IS NULL OR sku.stockNumber < :num) " + "AND (:num IS NULL OR sku.stockNumber < :num) " +
"AND (:isStock IS NULL OR pro.isStock = :isStock) " + "AND (:isStock IS NULL OR pro.isStock = :isStock) " +
@ -65,6 +71,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"WHERE " + "WHERE " +
"pro.shopId = :shopId " + "pro.shopId = :shopId " +
"AND pro.status = 1 " + "AND pro.status = 1 " +
"AND sku.isDel = 0 " +
"AND (:categoryId IS NULL OR pro.categoryId = :categoryId) " + "AND (:categoryId IS NULL OR pro.categoryId = :categoryId) " +
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " + "AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
"AND (:isStock IS NULL OR pro.isStock = :isStock) " + "AND (:isStock IS NULL OR pro.isStock = :isStock) " +
@ -87,6 +94,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"WHERE " + "WHERE " +
"pro.shopId = :shopId " + "pro.shopId = :shopId " +
"AND pro.status = 1 " + "AND pro.status = 1 " +
"AND sku.isDel=0 " +
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " + "AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
"AND (:isStock IS NULL OR pro.isStock = :isStock) " + "AND (:isStock IS NULL OR pro.isStock = :isStock) " +
"group by pro.id " + "group by pro.id " +
@ -104,6 +112,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"left join TbShopUnit unit on pro.unitId = unit.id " + "left join TbShopUnit unit on pro.unitId = unit.id " +
"where " + "where " +
"sku.productId = :productId " + "sku.productId = :productId " +
"AND sku.isDel=0 " +
"order by " + "order by " +
"sku.stockNumber desc " "sku.stockNumber desc "
) )
@ -119,6 +128,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"WHERE " + "WHERE " +
"pro.shopId = :shopId " + "pro.shopId = :shopId " +
"AND pro.status = 1 " + "AND pro.status = 1 " +
"AND sku.isDel=0 " +
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " + "AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
"AND (:isStock IS NULL OR pro.isStock = :isStock) " + "AND (:isStock IS NULL OR pro.isStock = :isStock) " +
"AND (:num IS NULL OR sku.stockNumber < :num) " + "AND (:num IS NULL OR sku.stockNumber < :num) " +

View File

@ -16,10 +16,7 @@
package cn.ysk.cashier.repository.shop; package cn.ysk.cashier.repository.shop;
import cn.ysk.cashier.pojo.shop.TbShopUser; import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.vo.ShopUserInfoVo;
import org.apache.ibatis.annotations.Param; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -27,7 +24,6 @@ import org.springframework.data.jpa.repository.Query;
import javax.persistence.Tuple; import javax.persistence.Tuple;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @website https://eladmin.vip * @website https://eladmin.vip
@ -48,6 +44,4 @@ public interface TbShopUserRepository extends JpaRepository<TbShopUser, Integer>
@Query("SELECT user.userId from TbShopUser user where user.shopId = :shopId") @Query("SELECT user.userId from TbShopUser user where user.shopId = :shopId")
List<Integer> getUserIdByShopId(String shopId); List<Integer> getUserIdByShopId(String shopId);
} }

View File

@ -379,8 +379,7 @@ public class SummaryServiceImpl implements SummaryService {
BigDecimal recharge = tbShopUserFlowService.sumUserFlowAmountByConditions(Long.valueOf(summaryDto.getShopId()), BigDecimal recharge = tbShopUserFlowService.sumUserFlowAmountByConditions(Long.valueOf(summaryDto.getShopId()),
tbOrderPayCountByDayVo.getTradeDay() + " 00:00:00", tbOrderPayCountByDayVo.getTradeDay() + " 00:00:00",
tbOrderPayCountByDayVo.getTradeDay() + " 23:59:59", tbOrderPayCountByDayVo.getTradeDay() + " 23:59:59");
Arrays.asList("cashMemberIn", "scanMemberIn"));
tbOrderPayCountByDayVo.setRecharge(recharge); tbOrderPayCountByDayVo.setRecharge(recharge);
BigDecimal decimal = tbOrderInfoRepository.queryRefundOrderAmountByTradeDay(summaryDto.getShopId(), tbOrderPayCountByDayVo.getTradeDay()); BigDecimal decimal = tbOrderInfoRepository.queryRefundOrderAmountByTradeDay(summaryDto.getShopId(), tbOrderPayCountByDayVo.getTradeDay());

View File

@ -126,6 +126,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
detail.setRefundNumber(detail.getNum()); detail.setRefundNumber(detail.getNum());
}); });
} }
orderInfoVo.setTableName(tbOrderInfo.getTableName());
orderInfoVo.setDetailList(details); orderInfoVo.setDetailList(details);
BeanUtils.copyProperties(tbOrderInfo, orderInfoVo); BeanUtils.copyProperties(tbOrderInfo, orderInfoVo);
orderInfoVo.setRefundAmount(refundAmount); orderInfoVo.setRefundAmount(refundAmount);
@ -188,6 +189,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
criteria.setOrderType(null); criteria.setOrderType(null);
} }
} }
List<TbOrderInfoDto> dto = tbOrderInfoMapper.toDto(tbOrderInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder))); List<TbOrderInfoDto> dto = tbOrderInfoMapper.toDto(tbOrderInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
for (TbOrderInfoDto tbOrderInfo : dto) { for (TbOrderInfoDto tbOrderInfo : dto) {
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId()); List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
@ -357,6 +359,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
@Override @Override
public void download(List<TbOrderInfoDto> all, HttpServletResponse response) throws IOException { public void download(List<TbOrderInfoDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
all=all.stream().sorted(Comparator.comparing(TbOrderInfoDto::getId).reversed()).collect(Collectors.toList());
for (TbOrderInfoDto tbOrderInfo : all) { for (TbOrderInfoDto tbOrderInfo : all) {
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put("订单编号", tbOrderInfo.getOrderNo()); map.put("订单编号", tbOrderInfo.getOrderNo());

View File

@ -458,24 +458,33 @@ public class TbProductServiceImpl implements TbProductService {
//sku //sku
if (resources.getSkuList() != null) { if (resources.getSkuList() != null) {
List<TbProductSku> skuList = new ArrayList<>(); // List<TbProductSku> skuList = new ArrayList<>();
for (TbProductSku sku : resources.getSkuList()) { // for (TbProductSku sku : resources.getSkuList()) {
TbProductSku tbProductSku = tbProductSkuRepository.searchBarCode(sku.getBarCode()); // TbProductSku tbProductSku = tbProductSkuRepository.searchBarCode(sku.getBarCode());
if (tbProductSku != null) { // if (tbProductSku != null) {
tbProductSkuRepository.updateByBarCode(sku.getBarCode(), sku.getCostPrice(), sku.getCoverImg(), sku.getFirstShared(), sku.getMemberPrice(), // tbProductSkuRepository.updateByBarCode(sku.getBarCode(), sku.getCostPrice(), sku.getCoverImg(), sku.getFirstShared(), sku.getMemberPrice(),
sku.getOriginPrice(), sku.getSalePrice(), sku.getSpecSnap(), tbProductSku.getId()); // sku.getOriginPrice(), sku.getSalePrice(), sku.getSpecSnap(), tbProductSku.getId());
} else { // } else {
// if ("sku".equals(save.getTypeEnum())) {
// tbProductSkuRepository.deleteByProductId(String.valueOf(save.getId()));
// }
// sku.setProductId(String.valueOf(save.getId()));
// sku.setShopId(save.getShopId());
// sku.setCreatedAt(Instant.now().toEpochMilli());
// sku.setUpdatedAt(Instant.now().toEpochMilli());
// skuList.add(sku);
// }
// }
if ("sku".equals(save.getTypeEnum())) { if ("sku".equals(save.getTypeEnum())) {
tbProductSkuRepository.deleteByProductId(String.valueOf(save.getId())); List<Integer> collect = resources.getSkuList().stream().map(TbProductSku::getId).collect(Collectors.toList());
} List<TbProductSku> tbProductSkus = tbProductSkuRepository.searchSku(resources.getId().toString());
sku.setProductId(String.valueOf(save.getId())); for (TbProductSku productSkus : tbProductSkus) {
sku.setShopId(save.getShopId()); if (!collect.contains(productSkus.getId())) {
sku.setCreatedAt(Instant.now().toEpochMilli()); tbProductSkuRepository.deleteBySkuId(productSkus.getId().toString());
sku.setUpdatedAt(Instant.now().toEpochMilli());
skuList.add(sku);
} }
} }
tbProductSkuRepository.saveAll(skuList); }
tbProductSkuRepository.saveAll(resources.getSkuList());
} }
//保存到sku_result //保存到sku_result
if ("sku".equals(resources.getTypeEnum())) { if ("sku".equals(resources.getTypeEnum())) {

View File

@ -1,5 +1,9 @@
package cn.ysk.cashier.service.impl.shopimpl; package cn.ysk.cashier.service.impl.shopimpl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto;
import cn.ysk.cashier.dto.shop.TbShopUserDto; import cn.ysk.cashier.dto.shop.TbShopUserDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria; import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.mapper.shop.TbShopUserMapper; import cn.ysk.cashier.mapper.shop.TbShopUserMapper;
@ -22,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -45,8 +50,21 @@ public class TbShopUserServiceImpl implements TbShopUserService {
@Override @Override
public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria) { public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria) {
IPage<ShopUserInfoVo> iPage = shopUserMapper.queryUser(criteria, IPage<ShopUserInfoVo> iPage = shopUserMapper.queryUser(criteria, criteria.getIsVip(),
new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize())); new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()));
for (ShopUserInfoVo shopUserInfoVo : iPage.getRecords()) {
if (StrUtil.isBlank(shopUserInfoVo.getNickName())) {
tbShopUserRepository.findById(shopUserInfoVo.getId()).ifPresent(tbShopUser -> {
shopUserInfoVo.setNickName(tbShopUser.getName());
shopUserInfoVo.setBirthDay(tbShopUser.getBirthDay());
shopUserInfoVo.setHeadImg(tbShopUser.getHeadImg());
shopUserInfoVo.setTelephone(tbShopUser.getTelephone());
shopUserInfoVo.setTotalScore(0);
});
}
}
return PageUtil.toPlusPage(iPage.getRecords(), Integer.valueOf(iPage.getTotal() + "")); return PageUtil.toPlusPage(iPage.getRecords(), Integer.valueOf(iPage.getTotal() + ""));
} }
@ -129,4 +147,34 @@ public class TbShopUserServiceImpl implements TbShopUserService {
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
@Override
public IPage<TbShopRechargeRespDto> rechargeList(TbShopRechargeListDto criteria, Pageable pageable) {
if (criteria.getStartTime() == null) {
criteria.setStartTime(DateUtil.parseDate("2024-01-01 00:00:00"));
}
if (criteria.getEndTime() == null) {
criteria.setEndTime(DateUtil.date(Instant.now()));
}
return shopUserMapper.queryRechargeList(criteria,
new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageable == null ? 0 : pageable.getPageNumber(), pageable == null ? 1000000 : pageable.getPageSize()));
}
@Override
public void rechargeListDownload(HttpServletResponse response, TbShopRechargeListDto criteria) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
IPage<TbShopRechargeRespDto> page = rechargeList(criteria, null);
for (TbShopRechargeRespDto tbShopRechargeRespDto : page.getRecords()) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("id", tbShopRechargeRespDto.getId());
map.put("门店", tbShopRechargeRespDto.getShopName());
map.put("用户手机号", tbShopRechargeRespDto.getUserPhone());
map.put("用户名", tbShopRechargeRespDto.getUserName());
map.put("充值金额", tbShopRechargeRespDto.getRechargeAmount());
map.put("充值类型", tbShopRechargeRespDto.getRechargeType());
map.put("充值时间", tbShopRechargeRespDto.getRechargeTime());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
} }

View File

@ -1,8 +1,12 @@
package cn.ysk.cashier.service.shop; package cn.ysk.cashier.service.shop;
import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto;
import cn.ysk.cashier.pojo.shop.TbShopUser; import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.dto.shop.TbShopUserDto; import cn.ysk.cashier.dto.shop.TbShopUserDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria; import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
@ -75,4 +79,14 @@ public interface TbShopUserService {
*/ */
void download(List<TbShopUserDto> all, HttpServletResponse response) throws IOException; void download(List<TbShopUserDto> all, HttpServletResponse response) throws IOException;
/**
* 充值记录
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
IPage<TbShopRechargeRespDto> rechargeList(TbShopRechargeListDto criteria, Pageable pageable);
void rechargeListDownload(HttpServletResponse response, TbShopRechargeListDto criteria) throws IOException;
} }

View File

@ -50,6 +50,8 @@ public class TbOrderInfoVo {
private String tableId; private String tableId;
private String tableName;
private BigDecimal smallChange; private BigDecimal smallChange;
private String sendType; private String sendType;