Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
17cfaa2a61
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class TbShopSongController {
|
|||
if(redisUtils.hasKey(CacheKey.SONG_URL + criteria.getShopId())){
|
||||
code = (String) redisUtils.get(CacheKey.SONG_URL + criteria.getShopId());
|
||||
}else {
|
||||
code = RandomStringUtils.randomAlphanumeric(8);
|
||||
code = RandomStringUtils.randomAlphanumeric(12);
|
||||
redisUtils.set(CacheKey.SONG_URL + criteria.getShopId(), code);
|
||||
redisUtils.set(CacheKey.SONG_URL + code, criteria.getShopId());
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ public class TbShopSongController {
|
|||
@ApiOperation("更新歌手页地址")
|
||||
@AnonymousPostMapping
|
||||
public ResponseEntity<Object> createUrl(String shopId) {
|
||||
String key = RandomStringUtils.randomAlphanumeric(8);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ public class TbProductSkuDto implements Serializable {
|
|||
/** 进货参考价 */
|
||||
private BigDecimal guidePrice;
|
||||
|
||||
private Integer suit;
|
||||
|
||||
private BigDecimal strategyPrice;
|
||||
|
||||
/** 库存数量 */
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) " +
|
||||
|
|
|
|||
|
|
@ -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())) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue