Compare commits
2 Commits
79f038e977
...
59686cdbc7
| Author | SHA1 | Date | |
|---|---|---|---|
| 59686cdbc7 | |||
| 62cbe31346 |
@ -26,7 +26,8 @@ public class ProductTitleUtil {
|
|||||||
"特价", "折扣", "优惠", "促销", "限时", "秒杀", "抢购", "直降", "满减",
|
"特价", "折扣", "优惠", "促销", "限时", "秒杀", "抢购", "直降", "满减",
|
||||||
"赠品", "包邮", "新品", "热卖", "爆款", "推荐", "精选", "特惠", "清仓",
|
"赠品", "包邮", "新品", "热卖", "爆款", "推荐", "精选", "特惠", "清仓",
|
||||||
"正品", "原装", "官方", "正版", "品牌", "优质", "好用", "新款", "老款",
|
"正品", "原装", "官方", "正版", "品牌", "优质", "好用", "新款", "老款",
|
||||||
"【", "】", "(", ")", "[]", "()", "「", "」", "!", "!!", "??", "?","袋装","盒装","约"
|
"【", "】", "(", ")", "[]", "()", "「", "」", "!", "!!", "??", "?",
|
||||||
|
"袋装","盒装","约","精品","加工","新","鲜"
|
||||||
)));
|
)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -7,10 +7,9 @@ import com.suisung.mall.shop.product.service.ShopProductItemService;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import java.util.List;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -87,13 +86,13 @@ public class ShopProductItemController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑库存和价格
|
* 编辑库存和价格
|
||||||
* @param shopProductItem
|
* @param shopProductItemList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "商品表-SKU表 商品名称(产品名称+颜色规格名称) =shop_product_item-编辑", notes = "商品表-SKU表 商品名称(产品名称+颜色规格名称) =shop_product_item-编辑")
|
@ApiOperation(value = "商品表-SKU表 商品名称(产品名称+颜色规格名称) =shop_product_item-编辑", notes = "商品表-SKU表 商品名称(产品名称+颜色规格名称) =shop_product_item-编辑")
|
||||||
@RequestMapping(value = "/editQuantity", method = RequestMethod.POST)
|
@RequestMapping(value = "/editQuantity", method = RequestMethod.POST)
|
||||||
public CommonResult editQuantity(ShopProductItem shopProductItem) {
|
public CommonResult editQuantity(@RequestBody List<ShopProductItem> shopProductItemList) {
|
||||||
return shopProductItemService.editQuantity(shopProductItem);
|
return shopProductItemService.editQuantity(shopProductItemList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,5 +15,5 @@ import org.springframework.stereotype.Repository;
|
|||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ShopProductItemSeqMapper extends BaseMapper<ShopProductItemSeq> {
|
public interface ShopProductItemSeqMapper extends BaseMapper<ShopProductItemSeq> {
|
||||||
|
int updateSeqIdByItemIdAndProductId(ShopProductItemSeq shopProductItemSeq);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,4 +13,5 @@ import com.suisung.mall.core.web.service.IBaseService;
|
|||||||
*/
|
*/
|
||||||
public interface ShopProductItemSeqService extends IBaseService<ShopProductItemSeq> {
|
public interface ShopProductItemSeqService extends IBaseService<ShopProductItemSeq> {
|
||||||
|
|
||||||
|
int updateSeqIdByItemIdAndProductId(ShopProductItemSeq shopProductItemSeq);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,5 +91,5 @@ public interface ShopProductItemService extends IBaseService<ShopProductItem> {
|
|||||||
* 修改item的价格和库存
|
* 修改item的价格和库存
|
||||||
* @param: ShopProductItem
|
* @param: ShopProductItem
|
||||||
*/
|
*/
|
||||||
CommonResult editQuantity(ShopProductItem shopProductItem);
|
CommonResult editQuantity(List<ShopProductItem> shopProductItemList);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1007,6 +1007,19 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
|
|
||||||
//判断是否存在
|
//判断是否存在
|
||||||
ShopProductItemSeq product_item_seq_row = shopProductItemSeqService.get(product_item_seq_id);
|
ShopProductItemSeq product_item_seq_row = shopProductItemSeqService.get(product_item_seq_id);
|
||||||
|
//新增反向校验
|
||||||
|
if(null == product_item_seq_row){
|
||||||
|
QueryWrapper<ShopProductItemSeq> itemSeqQueryWrapper = new QueryWrapper<>();
|
||||||
|
itemSeqQueryWrapper.eq("item_id",item_row.getItem_id());
|
||||||
|
itemSeqQueryWrapper.eq("product_id",item_row.getProduct_id());
|
||||||
|
product_item_seq_row= shopProductItemSeqService.findOne(itemSeqQueryWrapper);
|
||||||
|
if(null!=product_item_seq_row){
|
||||||
|
product_item_seq_row.setProduct_item_seq_id(product_item_seq_id);
|
||||||
|
product_item_seq_row.setProduct_item_seq_val(product_item_seq_val);
|
||||||
|
shopProductItemSeqService.updateSeqIdByItemIdAndProductId(product_item_seq_row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (null != product_item_seq_row) {
|
if (null != product_item_seq_row) {
|
||||||
item_id = product_item_seq_row.getItem_id();
|
item_id = product_item_seq_row.getItem_id();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import com.suisung.mall.common.modules.product.ShopProductItemSeq;
|
|||||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||||
import com.suisung.mall.shop.product.mapper.ShopProductItemSeqMapper;
|
import com.suisung.mall.shop.product.mapper.ShopProductItemSeqMapper;
|
||||||
import com.suisung.mall.shop.product.service.ShopProductItemSeqService;
|
import com.suisung.mall.shop.product.service.ShopProductItemSeqService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
@ -17,4 +18,11 @@ import org.springframework.stereotype.Service;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ShopProductItemSeqServiceImpl extends BaseServiceImpl<ShopProductItemSeqMapper, ShopProductItemSeq> implements ShopProductItemSeqService {
|
public class ShopProductItemSeqServiceImpl extends BaseServiceImpl<ShopProductItemSeqMapper, ShopProductItemSeq> implements ShopProductItemSeqService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ShopProductItemSeqMapper shopProductItemSeqMapper;
|
||||||
|
@Override
|
||||||
|
public int updateSeqIdByItemIdAndProductId(ShopProductItemSeq shopProductItemSeq) {
|
||||||
|
return shopProductItemSeqMapper.updateSeqIdByItemIdAndProductId(shopProductItemSeq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2294,46 +2294,67 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public CommonResult editQuantity(ShopProductItem shopProductItem) {
|
public CommonResult editQuantity(List<ShopProductItem> shopProductItemList) {
|
||||||
|
if(shopProductItemList.isEmpty()){
|
||||||
|
return CommonResult.failed("修改数据不能为空");
|
||||||
|
}
|
||||||
|
if(shopProductItemList.size()>10){
|
||||||
|
return CommonResult.failed("修改数据不能超过10条");
|
||||||
|
}
|
||||||
QueryWrapper<ShopProductItem> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopProductItem> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("product_id",shopProductItem.getProduct_id());
|
List<ShopProductItem> updateShopProductItem=new ArrayList<>();
|
||||||
List<ShopProductItem> oldShopProductItems= shopProductItemService.list(queryWrapper);
|
List<ShopProductBase> updateShopProductBase=new ArrayList<>();
|
||||||
List<ShopProductItem> oldShopProductItemList= oldShopProductItems.stream().filter(s -> s.getItem_id().equals(shopProductItem.getItem_id())).collect(Collectors.toList());
|
List<ShopProductIndex> updateShopProductIndex=new ArrayList<>();
|
||||||
if(CollUtil.isEmpty(oldShopProductItemList)){
|
for (ShopProductItem shopProductItem : shopProductItemList) {
|
||||||
return CommonResult.failed("不存在商品sku");
|
queryWrapper.eq("product_id",shopProductItem.getProduct_id());
|
||||||
}
|
List<ShopProductItem> oldShopProductItems= shopProductItemService.list(queryWrapper);
|
||||||
ShopProductItem oldShopProductItem=oldShopProductItemList.get(0);
|
List<ShopProductItem> oldShopProductItemList= oldShopProductItems.stream().filter(s -> s.getItem_id().equals(shopProductItem.getItem_id())).collect(Collectors.toList());
|
||||||
if(ObjectUtil.isEmpty(shopProductItem.getItem_quantity())){
|
if(CollUtil.isEmpty(oldShopProductItemList)){
|
||||||
return CommonResult.failed("库存不能为空");
|
return CommonResult.failed("不存在商品sku");
|
||||||
}
|
}
|
||||||
if(ObjectUtil.isEmpty(shopProductItem.getItem_unit_price())){
|
ShopProductItem oldShopProductItem=oldShopProductItemList.get(0);
|
||||||
return CommonResult.failed("价格不能为空");
|
if(ObjectUtil.isEmpty(shopProductItem.getItem_quantity())){
|
||||||
}
|
return CommonResult.failed("库存不能为空");
|
||||||
|
}
|
||||||
|
if(ObjectUtil.isEmpty(shopProductItem.getItem_unit_price())){
|
||||||
|
return CommonResult.failed("价格不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
BigDecimal item_unit_price =shopProductItem.getItem_unit_price();
|
BigDecimal item_unit_price =shopProductItem.getItem_unit_price();
|
||||||
BigDecimal item_unit_price_max =shopProductItem.getItem_unit_price();
|
BigDecimal item_unit_price_max =shopProductItem.getItem_unit_price();
|
||||||
|
|
||||||
BigDecimal item_unit_price_old = oldShopProductItems.stream().map(ShopProductItem::getItem_unit_price).min(BigDecimal::compareTo).get();
|
BigDecimal item_unit_price_old = oldShopProductItems.stream().map(ShopProductItem::getItem_unit_price).min(BigDecimal::compareTo).get();
|
||||||
ShopProductIndex shopProductIndex=new ShopProductIndex();
|
ShopProductIndex shopProductIndex=new ShopProductIndex();
|
||||||
if(item_unit_price_old.compareTo(item_unit_price)>0){
|
if(item_unit_price_old.compareTo(item_unit_price)>0){
|
||||||
ShopProductBase shopProductBase=new ShopProductBase();
|
ShopProductBase shopProductBase=new ShopProductBase();
|
||||||
shopProductBase.setProduct_id(shopProductItem.getProduct_id());
|
shopProductBase.setProduct_id(shopProductItem.getProduct_id());
|
||||||
shopProductBase.setProduct_unit_price(item_unit_price);
|
shopProductBase.setProduct_unit_price(item_unit_price);
|
||||||
shopProductIndex.setProduct_unit_price(item_unit_price);
|
shopProductIndex.setProduct_unit_price(item_unit_price);
|
||||||
shopProductIndex.setProduct_id(shopProductItem.getProduct_id());
|
shopProductIndex.setProduct_id(shopProductItem.getProduct_id());
|
||||||
shopProductBaseService.updateById(shopProductBase);
|
updateShopProductBase.add(shopProductBase);
|
||||||
|
// shopProductBaseService.updateById(shopProductBase);
|
||||||
|
}
|
||||||
|
BigDecimal item_unit_price_max_old=oldShopProductItems.stream().map(ShopProductItem::getItem_unit_price).max(BigDecimal::compareTo).get();
|
||||||
|
if(item_unit_price_max.compareTo(item_unit_price_max_old)>0){
|
||||||
|
shopProductIndex.setProduct_id(shopProductItem.getProduct_id());
|
||||||
|
shopProductIndex.setProduct_unit_price_max(item_unit_price_max);
|
||||||
|
}
|
||||||
|
if(ObjectUtil.isNotEmpty(shopProductIndex.getProduct_id())){
|
||||||
|
updateShopProductIndex.add(shopProductIndex);
|
||||||
|
//shopProductIndexService.updateById(shopProductIndex);
|
||||||
|
}
|
||||||
|
oldShopProductItem.setItem_quantity(shopProductItem.getItem_quantity());
|
||||||
|
oldShopProductItem.setItem_unit_price(shopProductItem.getItem_unit_price());
|
||||||
|
updateShopProductItem.add(oldShopProductItem);
|
||||||
|
// shopProductItemService.updateById(oldShopProductItem);
|
||||||
}
|
}
|
||||||
BigDecimal item_unit_price_max_old=oldShopProductItems.stream().map(ShopProductItem::getItem_unit_price).max(BigDecimal::compareTo).get();
|
if(!updateShopProductBase.isEmpty()){
|
||||||
if(item_unit_price_max.compareTo(item_unit_price_max_old)>0){
|
shopProductBaseService.updateBatchById(updateShopProductBase);
|
||||||
shopProductIndex.setProduct_id(shopProductItem.getProduct_id());
|
|
||||||
shopProductIndex.setProduct_unit_price_max(item_unit_price_max);
|
|
||||||
}
|
}
|
||||||
if(ObjectUtil.isNotEmpty(shopProductIndex.getProduct_id())){
|
if(!updateShopProductIndex.isEmpty()){
|
||||||
shopProductIndexService.updateById(shopProductIndex);
|
shopProductIndexService.updateBatchById(updateShopProductIndex);
|
||||||
}
|
}
|
||||||
oldShopProductItem.setItem_quantity(shopProductItem.getItem_quantity());
|
shopProductItemService.updateBatchById(updateShopProductItem);
|
||||||
oldShopProductItem.setItem_unit_price(shopProductItem.getItem_unit_price());
|
|
||||||
shopProductItemService.updateById(oldShopProductItem);
|
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import com.suisung.mall.common.pojo.dto.SameCityDeliveryFeeRespDTO;
|
|||||||
import com.suisung.mall.common.service.MessageService;
|
import com.suisung.mall.common.service.MessageService;
|
||||||
import com.suisung.mall.common.utils.CheckUtil;
|
import com.suisung.mall.common.utils.CheckUtil;
|
||||||
import com.suisung.mall.common.utils.I18nUtil;
|
import com.suisung.mall.common.utils.I18nUtil;
|
||||||
|
import com.suisung.mall.common.utils.StringUtils;
|
||||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||||
import com.suisung.mall.shop.base.service.AccountBaseConfigService;
|
import com.suisung.mall.shop.base.service.AccountBaseConfigService;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseStateCodeService;
|
import com.suisung.mall.shop.base.service.ShopBaseStateCodeService;
|
||||||
@ -413,13 +414,25 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
// 采购判断 先放入此处
|
// 采购判断 先放入此处
|
||||||
String from = getParameter("from");
|
String from = getParameter("from");
|
||||||
Integer item_quantity = Convert.toInt(item_row.get("item_quantity"));
|
Integer item_quantity = Convert.toInt(item_row.get("item_quantity"));
|
||||||
if ("manage".equals(from) && item_quantity < cart_quantity) {
|
if(StringUtils.isNotEmpty(from)){
|
||||||
throw new ApiException(I18nUtil._("当前商品只可购买") + item_quantity + I18nUtil._("件,请确认!"));
|
if ("manage".equals(from) && item_quantity < cart_quantity) {
|
||||||
} else if ("manage".equals(from) && cart_quantity <= 0) {
|
throw new ApiException(I18nUtil._("当前商品只可购买") + item_quantity + I18nUtil._("件,请确认!"));
|
||||||
throw new ApiException(I18nUtil._("最低备货数量 1 件,请确认!"));
|
} else if ("manage".equals(from) && cart_quantity <= 0) {
|
||||||
} else {
|
throw new ApiException(I18nUtil._("最低备货数量 1 件,请确认!"));
|
||||||
if (!addCart(data)) {
|
} else {
|
||||||
throw new ApiException(ResultCode.FAILED);
|
if (!addCart(data)) {
|
||||||
|
throw new ApiException(ResultCode.FAILED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if (item_quantity < cart_quantity) {
|
||||||
|
throw new ApiException(I18nUtil._("当前商品只可购买") + item_quantity + I18nUtil._("件,请确认!"));
|
||||||
|
} else if (cart_quantity <= 0) {
|
||||||
|
throw new ApiException(I18nUtil._("最低备货数量 1 件,请确认!"));
|
||||||
|
} else {
|
||||||
|
if (!addCart(data)) {
|
||||||
|
throw new ApiException(ResultCode.FAILED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.putAll(item_row);
|
data.putAll(item_row);
|
||||||
|
|||||||
@ -7,4 +7,9 @@
|
|||||||
product_item_seq_id, product_item_seq_val, item_id, product_id
|
product_item_seq_id, product_item_seq_val, item_id, product_id
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<update id="updateSeqIdByItemIdAndProductId" parameterType="com.suisung.mall.common.modules.product.ShopProductItemSeq">
|
||||||
|
update shop_product_item_seq set product_item_seq_val=#{product_item_seq_val},
|
||||||
|
product_item_seq_id=#{product_item_seq_id}
|
||||||
|
where item_id=#{item_id} and product_id=#{product_id}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user