Merge branch 'refs/heads/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:
GYJ 2024-07-10 17:46:14 +08:00
commit 35312b6137
19 changed files with 216 additions and 151 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.dto.ProskuInfo;
import cn.ysk.cashier.cons.service.dto.TbProskuConQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
@ -13,6 +14,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
/**
@ -44,8 +46,14 @@ public class TbProskuConController {
@PostMapping
@Log("新增商品规格耗材信息")
@ApiOperation("新增商品规格耗材信息")
public ResponseEntity<Object> createTbProskuCon(@Validated @RequestBody ProskuInfo resources) throws Exception {
return new ResponseEntity<>(tbProskuConService.create(resources),HttpStatus.CREATED);
public ResponseEntity<Object> createTbProskuCon(@Validated @RequestBody List<ProskuInfo> resources) throws Exception {
try {
return new ResponseEntity<>(tbProskuConService.create(resources),HttpStatus.CREATED);
} catch (BadRequestException be) {
throw new Exception(be.getMessage());
}catch (Exception e){
throw new Exception("系统异常");
}
}
@PutMapping

View File

@ -43,7 +43,7 @@ public interface TbProskuConService {
* @param resources /
* @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.repository.TbConsInfoRepository;
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.TbProductSku;
import cn.ysk.cashier.repository.product.TbProductRepository;
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.ValidationUtil;
import cn.ysk.cashier.utils.*;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.cons.repository.TbProskuConRepository;
import cn.ysk.cashier.cons.service.TbProskuConService;
import cn.ysk.cashier.cons.service.dto.TbProskuConDto;
import cn.ysk.cashier.cons.service.dto.TbProskuConQueryCriteria;
import cn.ysk.cashier.cons.service.mapstruct.TbProskuConMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
@ -38,6 +37,7 @@ import javax.servlet.http.HttpServletResponse;
**/
@Service
@RequiredArgsConstructor
@Slf4j
public class TbProskuConServiceImpl implements TbProskuConService {
private final TbProskuConRepository tbProskuConRepository;
@ -70,65 +70,85 @@ public class TbProskuConServiceImpl implements TbProskuConService {
@Override
@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(resource.getProductId());
if(Objects.isNull(product)){
throw new BadRequestException("对应的商品信息不存在");
}
List<TbProskuCon> list=new ArrayList<>();
if(product.getIsDistribute().intValue()==1){
TbProduct product= tbProductRepository.getById(resources.getProductId());
if(Objects.isNull(product)){
throw new Exception("对应的商品信息不存在");
}
TbConsInfo tbConsInfo= tbConsInfoRepository.findById(resource.getConsInfoId()).orElseGet(TbConsInfo::new);
TbConsInfo tbConsInfo= tbConsInfoRepository.getById(resources.getConsInfoId());
if(Objects.isNull(tbConsInfo)){
throw new Exception("对应的耗材信息不存在");
}
log.info("product.getIsDistribute().intValue():{}", JSONUtil.toJSONString(tbConsInfo));
if(ObjectUtil.isNull(tbConsInfo)||ObjectUtil.isNull(tbConsInfo.getId())){
throw new BadRequestException("对应的耗材信息不存在");
}
List<TbProskuCon> list=new ArrayList<>();
if(product.getIsDistribute().intValue()==1){
//查询商品对应的所有规格
List<TbProductSku> skuList= tbProductSkuRepository.searchSku(product.getId().toString());
if(Objects.nonNull(skuList)&&skuList.size()>0){
for (TbProductSku tbProductSku : skuList) {
int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resources.getConsInfoId(), tbProductSku.getId(), Integer.valueOf(tbProductSku.getShopId()), Integer.valueOf(tbProductSku.getProductId()));
//查询商品对应的所有规格
List<TbProductSku> skuList= tbProductSkuRepository.searchSku(product.getId().toString());
if(Objects.nonNull(skuList)&&skuList.size()>0){
for (TbProductSku tbProductSku : skuList) {
int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resource.getConsInfoId(), tbProductSku.getId(), Integer.valueOf(tbProductSku.getShopId()), Integer.valueOf(tbProductSku.getProductId()));
if(count<=0){
TbProskuCon tbProskuCon=new TbProskuCon();
tbProskuCon.setShopId(Integer.valueOf(tbProductSku.getShopId()));
tbProskuCon.setConInfoId(tbConsInfo.getId());
tbProskuCon.setProductId(Integer.valueOf(tbProductSku.getProductId()));
tbProskuCon.setProductSkuId(tbProductSku.getId());
tbProskuCon.setSurplusStock(resource.getSurplusStock());
tbProskuCon.setStatus("1");
tbProskuCon.setCreateTime(new Timestamp(System.currentTimeMillis()));
list.add(tbProskuCon);
}else {
throw new BadRequestException(product.getName().concat("对应的耗材信息已存在"));
}
}
}
}else {
for (ProskuInfo.SkuInfo skuInfo : resource.getSkuInfos()) {
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){
TbProskuCon tbProskuCon=new TbProskuCon();
tbProskuCon.setShopId(Integer.valueOf(tbProductSku.getShopId()));
tbProskuCon.setConInfoId(resources.getConsInfoId());
tbProskuCon.setProductId(Integer.valueOf(tbProductSku.getProductId()));
tbProskuCon.setProductSkuId(tbProductSku.getId());
tbProskuCon.setSurplusStock(resources.getSurplusStock());
tbProskuCon.setShopId(Integer.valueOf(skuInfo.getShopId()));
tbProskuCon.setConInfoId(tbConsInfo.getId());
tbProskuCon.setProductId(resource.getProductId());
tbProskuCon.setProductSkuId(skuInfo.getSkuId());
tbProskuCon.setSurplusStock(skuInfo.getSurplusStock());
tbProskuCon.setStatus("1");
tbProskuCon.setCreateTime(new Timestamp(System.currentTimeMillis()));
list.add(tbProskuCon);
}else {
throw new Exception(product.getName().concat("对应的耗材信息已存在"));
TbProductSku sku= tbProductSkuRepository.getById(skuInfo.getSkuId());
throw new BadRequestException(product.getName().concat("商品对应的").concat(Objects.nonNull(sku.getSpecSnap())?sku.getSpecSnap():"").concat("规格已存在"));
}
}
}
}else {
for (ProskuInfo.SkuInfo skuInfo : resources.getSkuInfos()) {
int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resources.getConsInfoId(), skuInfo.getSkuId(), skuInfo.getShopId(), resources.getProductId());
if(count<=0){
TbProskuCon tbProskuCon=new TbProskuCon();
tbProskuCon.setShopId(Integer.valueOf(skuInfo.getShopId()));
tbProskuCon.setConInfoId(skuInfo.getConInfoId());
tbProskuCon.setProductId(resources.getProductId());
tbProskuCon.setProductSkuId(skuInfo.getSkuId());
tbProskuCon.setSurplusStock(skuInfo.getSurplusStock());
tbProskuCon.setStatus("1");
tbProskuCon.setCreateTime(new Timestamp(System.currentTimeMillis()));
list.add(tbProskuCon);
}else {
TbProductSku sku= tbProductSkuRepository.getById(skuInfo.getSkuId());
throw new Exception(product.getName().concat("商品对应的").concat(Objects.nonNull(sku.getSpecSnap())?sku.getSpecSnap():"").concat("规格已存在"));
}
}
if(Objects.nonNull(list)&&list.size()>0){
tbProskuConRepository.saveAll(list);
}
}
}
if(Objects.nonNull(list)&&list.size()>0){
tbProskuConRepository.saveAll(list);
}
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.AnonymousPostMapping;
@ -51,27 +51,9 @@ public class TbShopSongOrderController{
@ApiOperation("获取歌曲列表 分页")
@AnonymousGetMapping
public ResponseEntity<Object> selectAll(TbShopSongOrderQueryCriteria tbShopSongOrder) {
String code = "";
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);
return new ResponseEntity<>(tbShopSongOrderService.queryAll(tbShopSongOrder), 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;
import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.dto.product.TbProductSortCriteria;
import cn.ysk.cashier.vo.TbProductVo;

View File

@ -1,7 +1,5 @@
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.service.SummaryService;
import cn.ysk.cashier.vo.TbOrderPayCountVo;

View File

@ -1,13 +1,17 @@
package cn.ysk.cashier.controller.shop;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.dto.shop.TbShopSongQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.entity.TbShopSong;
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.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -16,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
@RestController
@ -23,12 +28,33 @@ import java.util.List;
@Api(tags = "歌曲管理")
@RequestMapping("/api/tbShopSong")
public class TbShopSongController {
private final RedisUtils redisUtils;
private final TbShopSongService tbShopSongService;
@GetMapping
@ApiOperation("查询歌曲列表")
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

View File

@ -50,6 +50,7 @@ public class TbShopUserController {
@GetMapping("queryAllShopUser")
@ApiOperation("查询商家用户")
@AnonymousGetMapping
public ResponseEntity<Object> queryAllShopUser(TbShopUserQueryCriteria criteria) {
return new ResponseEntity<>(tbShopUserService.queryShopUser(criteria), HttpStatus.OK);
}

View File

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

View File

@ -19,19 +19,18 @@ public interface ShopUserMapper extends BaseMapper<TbShopUser> {
"FROM tb_shop_user su " +
"LEFT JOIN tb_user_info u ON su.user_id = u.id " +
"<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'>" +
"AND su.shop_id = #{param.shopId} " +
"</if>" +
"<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}, '%'))" +
"</if>" +
"<if test='param.isVip != null and param.isVip != &quot;&quot;'>" +
"AND su.is_vip=#{param.isVip}" +
"<if test='isVip != null'>" +
"AND su.is_vip=#{isVip}" +
"</if>" +
"</where>" +
"</script>")
IPage<ShopUserInfoVo> queryUser(TbShopUserQueryCriteria param, Page pageInfo);
IPage<ShopUserInfoVo> queryUser(TbShopUserQueryCriteria param, Integer isVip, Page pageInfo);
@Select("<script> " +
"select " +
@ -47,7 +46,7 @@ public interface ShopUserMapper extends BaseMapper<TbShopUser> {
" 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') " +
"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>")

View File

@ -16,19 +16,23 @@ import java.util.Map;
*/
public interface TbMShopUserMapper extends BaseMapper<TbMShopUser> {
@Select("<script>" +
"SELECT " +
"COUNT(*) userTotal, " +
"ifnull(SUM( " +
"IFNULL( b.charge_amount, 0 )), 0) chageTotal, ifnull(SUM( IFNULL( a.amount, 0 )), 0) balanceTotal " +
"FROM\n" +
"tb_shop_user AS a\n" +
"LEFT JOIN tb_user_info AS b ON a.user_id = b.id\n" +
"WHERE\n" +
" a.shop_id = #{shopId}\n" +
"SELECT \n" +
" COUNT(DISTINCT a.id) AS userTotal, \n" +
" COALESCE(SUM(flow.total_amount), 0) AS chageTotal, \n" +
" COALESCE(SUM(a.amount), 0) AS balanceTotal \n" +
"FROM \n" +
" tb_shop_user AS a\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" +
" a.shop_id = #{shopId} \n" +
"<if test=\"isVip !=null\">\n" +
" and a.is_vip=#{isVip}\n" +
"</if>" +
"</script>")
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 startTime 开始时间
* @param endTime 结束时间
* @param types 流水类型
* @return 用户流水总金额
*/
@Select("<script>" +
"SELECT IFNULL(SUM(uf.amount), 0) FROM tb_shop_user_flow as uf " +
"JOIN tb_shop_user su ON uf.shop_user_id = su.id " +
"WHERE su.shop_id = #{shopId} " +
"AND uf.create_time BETWEEN #{startTime} AND #{endTime} " +
"AND uf.biz_code IN " +
"<foreach collection='types' item='type' open='(' separator=',' close=')'> " +
"#{type} " +
"</foreach> " +
" SELECT \n" +
" COALESCE(SUM(flow.total_amount), 0) AS chageTotal\n" +
"FROM \n" +
" tb_shop_user AS a\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" +
" 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>")
BigDecimal sumUserFlowAmountByConditions(@Param("shopId") Long shopId,
@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("types") List<String> types);
@Param("endTime") String endTime);
}

View File

@ -12,5 +12,5 @@ import java.util.List;
*/
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
public class TbShopUserFlowServiceImpl extends ServiceImpl<TbShopUserFlowMapper, TbShopUserFlow> implements TbShopUserFlowService {
@Override
public BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime, List<String> types) {
return baseMapper.sumUserFlowAmountByConditions(shopId, startTime, endTime, types);
public BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime) {
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;
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.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @website https://eladmin.vip
@ -85,6 +69,9 @@ public class TbProductSku implements Serializable {
@ApiModelProperty(value = "进货参考价")
private BigDecimal guidePrice;
@ApiModelProperty(value = "起售数量 默认为1")
private Integer suit = 1;
@Column(name = "`strategy_price`")
@ApiModelProperty(value = "strategyPrice")
private BigDecimal strategyPrice;
@ -132,13 +119,17 @@ public class TbProductSku implements Serializable {
@Column(name = "`updated_at`")
@ApiModelProperty(value = "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`")
@ApiModelProperty(value = "是否暂停销售")
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> {
@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);
@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);
@Transactional
@ -34,7 +34,12 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
@Query("DELETE FROM TbProductSku sku WHERE sku.productId = :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);
@Query("SELECT new cn.ysk.cashier.vo.StockVo(" +
@ -47,6 +52,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"WHERE " +
"pro.shopId = :shopId " +
"AND pro.status = 1 " +
"AND sku.isDel=0 " +
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
"AND (:num IS NULL OR sku.stockNumber < :num) " +
"AND (:isStock IS NULL OR pro.isStock = :isStock) " +
@ -65,6 +71,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"WHERE " +
"pro.shopId = :shopId " +
"AND pro.status = 1 " +
"AND sku.isDel = 0 " +
"AND (:categoryId IS NULL OR pro.categoryId = :categoryId) " +
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
"AND (:isStock IS NULL OR pro.isStock = :isStock) " +
@ -87,6 +94,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"WHERE " +
"pro.shopId = :shopId " +
"AND pro.status = 1 " +
"AND sku.isDel=0 " +
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
"AND (:isStock IS NULL OR pro.isStock = :isStock) " +
"group by pro.id " +
@ -104,6 +112,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"left join TbShopUnit unit on pro.unitId = unit.id " +
"where " +
"sku.productId = :productId " +
"AND sku.isDel=0 " +
"order by " +
"sku.stockNumber desc "
)
@ -119,6 +128,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"WHERE " +
"pro.shopId = :shopId " +
"AND pro.status = 1 " +
"AND sku.isDel=0 " +
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
"AND (:isStock IS NULL OR pro.isStock = :isStock) " +
"AND (:num IS NULL OR sku.stockNumber < :num) " +

View File

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

View File

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

View File

@ -1,6 +1,7 @@
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;
@ -49,8 +50,21 @@ public class TbShopUserServiceImpl implements TbShopUserService {
@Override
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()));
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() + ""));
}