商机线索查询,商品判重,规格判重

main
cheney 10 months ago
parent 9515791a36
commit 0dafc5331f
  1. 37
      nakadai/src/main/java/com/huoran/nakadai/controller/ProductController.java
  2. 7
      nakadai/src/main/java/com/huoran/nakadai/entity/param/ProductParam.java
  3. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/OrderMapper.xml

@ -45,6 +45,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Api(tags = "商品列表、商品发布管理")
@ -125,11 +126,11 @@ public class ProductController {
@PostMapping("/save")
@ApiOperation(value = "保存商品信息")
public ServerResponseEntity<String> save(@Valid @RequestBody ProductParam productParam,HttpServletRequest request) {
productParam.setShopId(TokenUtils.getShopIdByJwtToken(request));
checkParam(productParam);
Product product = BeanUtil.copyProperties(productParam, Product.class);
// product.setDeliveryMode(Json.toJsonString(productParam.getDeliveryModeVo()));
product.setShopId(TokenUtils.getShopIdByJwtToken(request));
// product.setDeliveryMode(Json.toJsonString(productParam.getDeliveryModeVo()));
product.setUpdateTime(new Date());
if (product.getStatus() == 1) {
product.setPutawayTime(new Date());
@ -143,6 +144,7 @@ public class ProductController {
@PostMapping("/update")
@ApiOperation(value = "修改商品信息")
public ServerResponseEntity<String> update(@Valid @RequestBody ProductParam productParam,HttpServletRequest request) {
productParam.setShopId(TokenUtils.getShopIdByJwtToken(request));
checkParam(productParam);
Product dbProduct = productService.getProductByProdId(productParam.getProdId());
if (!Objects.equals(dbProduct.getShopId(), TokenUtils.getShopIdByJwtToken(request))) {
@ -233,6 +235,15 @@ public class ProductController {
}
private void checkParam(ProductParam productParam) {
QueryWrapper<Product> productQueryWrapper = new QueryWrapper<>();
productQueryWrapper.eq("prod_name",productParam.getProdName());
if (productParam.getProdId()!= null){
productQueryWrapper.notIn("prod_id",productParam.getProdId());
}
Product one = productService.getOne(productQueryWrapper);
if (one != null){
throw new YamiShopBindException("商品名称已存在");
}
// if (CollectionUtil.isEmpty(productParam.getTagList())) {
// throw new YamiShopBindException("请选择产品分组");
// }
@ -244,14 +255,20 @@ public class ProductController {
// throw new YamiShopBindException("请选择配送方式");
// }
List<Sku> skuList = productParam.getSkuList();
boolean isAllUnUse = true;
for (Sku sku : skuList) {
if (sku.getStatus() == 1) {
isAllUnUse = false;
}
}
if (isAllUnUse) {
throw new YamiShopBindException("至少要启用一种商品规格");
List<String> stringList = skuList.stream().map(Sku::getSkuName)
.collect(Collectors.toList());
long count = stringList.stream().distinct().count();
if (stringList.size() != count) {
throw new YamiShopBindException("商品规格名称重复");
}
// boolean isAllUnUse = true;
// for (Sku sku : skuList) {
// if (sku.getStatus() == 1) {
// isAllUnUse = false;
// }
// }
// if (isAllUnUse) {
// throw new YamiShopBindException("至少要启用一种商品规格");
// }
}
}

@ -76,7 +76,7 @@ public class ProductParam {
@ApiModelProperty(value = "简要描述,卖点等")
private String brief;
@NotBlank(message = "请选择图片上传")
// @NotBlank(message = "请选择图片上传")
@ApiModelProperty(value = "商品主图")
private String pic;
@ -90,7 +90,7 @@ public class ProductParam {
/**
* 商品分类
*/
@NotNull(message = "请选择商品分类")
// @NotNull(message = "请选择商品分类")
@ApiModelProperty(value = "商品分类")
private Long categoryId;
@ -106,6 +106,9 @@ public class ProductParam {
@ApiModelProperty(value = "商品详情")
private String content;
@ApiModelProperty(value = "店铺id",hidden = true)
private Integer shopId;
/**
* 是否能够用户自提
*/

@ -410,7 +410,7 @@
WHEN o.order_type = 2 THEN
IFNULL( ec.company_name, ua.account )
WHEN o.order_type = 1 THEN
IFNULL( uai.real_name, ua.account )
IFNULL( uai.real_name, avatars.account )
END) LIKE CONCAT('%', #{orderParam.queryCriteria} ,'%'))
</if>
<if test="orderParam.orderType != null">

Loading…
Cancel
Save