|
@@ -3,17 +3,15 @@ package com.caimei365.commodity.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.caimei365.commodity.components.PriceUtilService;
|
|
|
+import com.caimei365.commodity.mapper.PromotionsMapper;
|
|
|
import com.caimei365.commodity.mapper.ShopMapper;
|
|
|
import com.caimei365.commodity.model.ResponseJson;
|
|
|
+import com.caimei365.commodity.model.dto.BrandDto;
|
|
|
+import com.caimei365.commodity.model.dto.FeaturedDto;
|
|
|
import com.caimei365.commodity.model.dto.ProductDto;
|
|
|
-import com.caimei365.commodity.model.po.ProductDetailInfoPo;
|
|
|
-import com.caimei365.commodity.model.po.ProductImagePo;
|
|
|
-import com.caimei365.commodity.model.po.ProductParameterPo;
|
|
|
-import com.caimei365.commodity.model.po.ProductPo;
|
|
|
+import com.caimei365.commodity.model.po.*;
|
|
|
import com.caimei365.commodity.model.search.ProductListVo;
|
|
|
-import com.caimei365.commodity.model.vo.PaginationVo;
|
|
|
-import com.caimei365.commodity.model.vo.ProductFormVo;
|
|
|
-import com.caimei365.commodity.model.vo.ProductItemVo;
|
|
|
+import com.caimei365.commodity.model.vo.*;
|
|
|
import com.caimei365.commodity.service.ShopService;
|
|
|
import com.caimei365.commodity.utils.ImageUtils;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
@@ -38,6 +36,8 @@ public class ShopServiceImpl implements ShopService {
|
|
|
@Resource
|
|
|
private ShopMapper shopMapper;
|
|
|
@Resource
|
|
|
+ private PromotionsMapper promotionsMapper;
|
|
|
+ @Resource
|
|
|
private PriceUtilService priceUtilService;
|
|
|
@Value("${caimei.wwwDomain}")
|
|
|
private String domain;
|
|
@@ -367,4 +367,203 @@ public class ShopServiceImpl implements ShopService {
|
|
|
product.setParametersList(parametersList);
|
|
|
return ResponseJson.success(product);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商-商品编辑-品牌联想
|
|
|
+ *
|
|
|
+ * @param userId 用户Id
|
|
|
+ * @param name 关键词
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<List<BrandVo>> brandAssociation(Integer userId, String name) {
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("参数异常:用户id不能为空!", null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(name)) {
|
|
|
+ return ResponseJson.error("参数异常:联想关键词不能为空!", null);
|
|
|
+ }
|
|
|
+ List<BrandVo> bindList = shopMapper.getBrandAssociation(userId, name);
|
|
|
+ if (null == bindList || bindList.size() == 0) {
|
|
|
+ return ResponseJson.error("品牌名称暂未被采美收录", null);
|
|
|
+ }
|
|
|
+ return ResponseJson.success(bindList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商-商品编辑-品牌检测
|
|
|
+ *
|
|
|
+ * @param name 品牌名称
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<BrandVo> brandDetection(String name) {
|
|
|
+ if (StringUtils.isBlank(name)) {
|
|
|
+ return ResponseJson.error("参数异常:品牌名称不能为空!", null);
|
|
|
+ }
|
|
|
+ BrandVo brand = shopMapper.getBrandByName(name);
|
|
|
+ if (null == brand) {
|
|
|
+ return ResponseJson.error("品牌名称暂未被采美收录", null);
|
|
|
+ }
|
|
|
+ return ResponseJson.success(brand);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商-提交新品牌
|
|
|
+ *
|
|
|
+ * @param brandDto {
|
|
|
+ * name 品牌名字
|
|
|
+ * source 添加来源 0:后台添加,1:供应商添加
|
|
|
+ * userId 添加用户ID,后台则为后台用户ID,供应商则为供应商用户ID
|
|
|
+ * logo 品牌logo
|
|
|
+ * description 品牌描述
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<BrandPo> addBrand(BrandDto brandDto) {
|
|
|
+ if (StringUtils.isBlank(brandDto.getName())) {
|
|
|
+ return ResponseJson.error("参数异常:品牌名称不能为空!", null);
|
|
|
+ }
|
|
|
+ if (null == brandDto.getUserId()) {
|
|
|
+ return ResponseJson.error("参数异常:用户id不能为空!", null);
|
|
|
+ }
|
|
|
+ BrandVo brandVo = shopMapper.getBrandByName(brandDto.getName());
|
|
|
+ if (brandVo != null) {
|
|
|
+ if (null == brandDto.getId()) {
|
|
|
+ return ResponseJson.error("该品牌已存在,无需重复提交", null);
|
|
|
+ } else if (!brandDto.getId().equals(brandVo.getId())) {
|
|
|
+ return ResponseJson.error("该品牌已存在,无需重复提交", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BrandPo brand = new BrandPo();
|
|
|
+ brand.setName(brandDto.getName());
|
|
|
+ brand.setUserId(brandDto.getUserId());
|
|
|
+ brand.setSource(brandDto.getSource());
|
|
|
+ brand.setLogo(brandDto.getLogo());
|
|
|
+ brand.setDescription(brandDto.getDescription());
|
|
|
+ brand.setStatus(0);
|
|
|
+ brand.setDelFlag(0);
|
|
|
+ Date createDate = new Date();
|
|
|
+ brand.setUpdateDate(createDate);
|
|
|
+ if (null == brand.getId()) {
|
|
|
+ brand.setCreateDate(createDate);
|
|
|
+ shopMapper.insertBrand(brand);
|
|
|
+ } else {
|
|
|
+ shopMapper.updateBrand(brand);
|
|
|
+ }
|
|
|
+ return ResponseJson.success(brand);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商-品牌管理
|
|
|
+ *
|
|
|
+ * @param name 品牌名称
|
|
|
+ * @param status 品牌状态 0:待审核,1:审核通过,2:审核失败
|
|
|
+ * @param userId 用户Id
|
|
|
+ * @param pageNum 页码
|
|
|
+ * @param pageSize 每页数量
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<PaginationVo<BrandVo>> brandManagement(String name, Integer status, Integer userId, int pageNum, int pageSize) {
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("参数异常:用户id不能为空!", null);
|
|
|
+ }
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ List<BrandVo> brandList = shopMapper.getShopBrandList(name, status, userId);
|
|
|
+ PaginationVo<BrandVo> brandPage = new PaginationVo<>(brandList);
|
|
|
+ return ResponseJson.success(brandPage);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商-添加,删除主页推荐
|
|
|
+ *
|
|
|
+ * @param featuredDto {
|
|
|
+ * productId 商品Id
|
|
|
+ * featuredFlag 供应商主推商品标志 0删除 1添加
|
|
|
+ * shop 供应商Id
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson switchFeatured(FeaturedDto featuredDto) {
|
|
|
+ if (null == featuredDto.getShopId()) {
|
|
|
+ return ResponseJson.error("参数异常:供应商Id不能为空!");
|
|
|
+ }
|
|
|
+ if (null == featuredDto.getProductId()) {
|
|
|
+ return ResponseJson.error("参数异常:商品Id不能为空!");
|
|
|
+ }
|
|
|
+ if (null == featuredDto.getFeaturedFlag()) {
|
|
|
+ return ResponseJson.error("参数异常:供应商主推商品标志不能为空!");
|
|
|
+ }
|
|
|
+ if (1 == featuredDto.getFeaturedFlag()){
|
|
|
+ int featuredCount = shopMapper.getMainProductsCount(featuredDto.getShopId());
|
|
|
+ if (featuredCount >= 4) {
|
|
|
+ return ResponseJson.error("主推商品已经上限了!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int flag = shopMapper.updateProductFeatured(featuredDto.getProductId(), featuredDto.getShopId(), featuredDto.getFeaturedFlag());
|
|
|
+ if (flag > 0) {
|
|
|
+ return ResponseJson.success();
|
|
|
+ } else{
|
|
|
+ return ResponseJson.error("供应商主推商品标志更新失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商-批量下架商品
|
|
|
+ *
|
|
|
+ * @param productIds 商品id集合,以','隔开
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson soldOutProducts(String productIds) {
|
|
|
+ if (StringUtils.isBlank(productIds)) {
|
|
|
+ return ResponseJson.error("参数异常:请传入商品Id!");
|
|
|
+ }
|
|
|
+ String[] split = productIds.split(",");
|
|
|
+ for (String productId : split) {
|
|
|
+ if (StringUtils.isNotBlank(productId)) {
|
|
|
+ ProductFormVo product = shopMapper.getProductForm(Integer.valueOf(productId));
|
|
|
+ if (2 == product.getValidFlag()) {
|
|
|
+ return ResponseJson.error("只能下架已上架的商品");
|
|
|
+ }
|
|
|
+ PromotionsVo promotions = promotionsMapper.getPromotionsByProductId(product.getProductId());
|
|
|
+ if (null != promotions) {
|
|
|
+ StringBuilder message = new StringBuilder();
|
|
|
+ if (promotions.getType() == 1) {
|
|
|
+ message = new StringBuilder("单品");
|
|
|
+ } else if (promotions.getType() == 2) {
|
|
|
+ message = new StringBuilder("凑单");
|
|
|
+ } else {
|
|
|
+ message = new StringBuilder("店铺");
|
|
|
+ }
|
|
|
+ if (promotions.getMode() == 1) {
|
|
|
+ message.append("优惠");
|
|
|
+ } else if (promotions.getMode() == 2) {
|
|
|
+ message.append("满减");
|
|
|
+ } else {
|
|
|
+ message.append("满赠");
|
|
|
+ }
|
|
|
+ return ResponseJson.error("此商品正在参与" + message + "促销活动,活动期间不能下架,如需强行下架,请联系客服:0755-22907771");
|
|
|
+ }
|
|
|
+ PromotionsVo promotionsGift = promotionsMapper.getPromotionGiftsByProductId(product.getProductId());
|
|
|
+ if (null != promotionsGift) {
|
|
|
+ String message;
|
|
|
+ if (promotionsGift.getType() == 1) {
|
|
|
+ message = "单品满赠";
|
|
|
+ } else if (promotionsGift.getType() == 2) {
|
|
|
+ message = "凑单满赠";
|
|
|
+ } else {
|
|
|
+ message = "店铺满赠";
|
|
|
+ }
|
|
|
+ return ResponseJson.error("此商品是正在进行的" + message + "促销活动的赠品,活动期间不能下架,如需强行下架,请联系客服:0755-22907771");
|
|
|
+ }
|
|
|
+ product.setValidFlag(3);
|
|
|
+ shopMapper.updateProductValidFlag(product.getProductId(), product.getValidFlag());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseJson.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|