Bläddra i källkod

二手小程序

zhijiezhao 2 månader sedan
förälder
incheckning
4f709620c4
23 ändrade filer med 301 tillägg och 97 borttagningar
  1. 3 5
      src/main/java/com/caimei365/commodity/components/PriceUtilService.java
  2. 27 8
      src/main/java/com/caimei365/commodity/controller/MallOrganizeApi.java
  3. 10 0
      src/main/java/com/caimei365/commodity/controller/SecondHandApi.java
  4. 4 3
      src/main/java/com/caimei365/commodity/controller/UserLikeApi.java
  5. 2 0
      src/main/java/com/caimei365/commodity/mapper/MallOrganizeMapper.java
  6. 28 4
      src/main/java/com/caimei365/commodity/mapper/PriceMapper.java
  7. 3 1
      src/main/java/com/caimei365/commodity/mapper/SecondHandMapper.java
  8. 10 3
      src/main/java/com/caimei365/commodity/mapper/UserLikeMapper.java
  9. 3 0
      src/main/java/com/caimei365/commodity/model/dto/SecondDto.java
  10. 31 0
      src/main/java/com/caimei365/commodity/model/vo/CmSecondInfo.java
  11. 2 0
      src/main/java/com/caimei365/commodity/model/vo/ProductItemVo.java
  12. 4 1
      src/main/java/com/caimei365/commodity/service/MallOrganizeService.java
  13. 2 0
      src/main/java/com/caimei365/commodity/service/SecondHandService.java
  14. 5 1
      src/main/java/com/caimei365/commodity/service/UserLikeService.java
  15. 9 2
      src/main/java/com/caimei365/commodity/service/impl/MallOrganizeServiceImpl.java
  16. 1 1
      src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java
  17. 24 9
      src/main/java/com/caimei365/commodity/service/impl/SecondHandServiceImpl.java
  18. 3 3
      src/main/java/com/caimei365/commodity/service/impl/UserLikeServiceImpl.java
  19. 7 0
      src/main/resources/mapper/MallOrganizeMapper.xml
  20. 7 1
      src/main/resources/mapper/PriceMapper.xml
  21. 60 51
      src/main/resources/mapper/SecondHandMapper.xml
  22. 42 3
      src/main/resources/mapper/ShopMapper.xml
  23. 14 1
      src/main/resources/mapper/UserLikeMapper.xml

+ 3 - 5
src/main/java/com/caimei365/commodity/components/PriceUtilService.java

@@ -317,7 +317,7 @@ public class PriceUtilService {
         product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
         // 数据库获取基本价格信息
         PriceVo price = null;
-        if ( StringUtils.isNotBlank(product.getGroundMall()) && product.getGroundMall().contains("0")) {
+        if (StringUtils.isNotBlank(product.getGroundMall()) && product.getGroundMall().contains("0")) {
             price = priceMapper.getMinPrice(product.getProductId());
         } else {
             price = priceMapper.getOrganizeMinPrice(product.getProductId());
@@ -334,13 +334,11 @@ public class PriceUtilService {
      * @param userId  用户Id
      * @param product ProductItemVo
      */
-    public void setOrganizeProductDetails(Integer userId, ProductItemVo product) {
-        Integer organizeId = priceMapper.getOrganize(userId);
-        organizeId = organizeId == null?0:organizeId;
+    public void setOrganizeProductDetails(Integer type, ProductItemVo product) {
         // 设置图片
         product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
         boolean taxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
-        List<Sku> organizeSkus = priceMapper.findOrganizeSkus(product.getProductId());
+        List<Sku> organizeSkus = priceMapper.findOrganizeSkus(type, product.getProductId());
         if (null != organizeSkus) {
             product.setPrice(organizeSkus.get(0).getPrice());
             product.setMinBuyNumber(organizeSkus.get(0).getMinBuyNumber());

+ 27 - 8
src/main/java/com/caimei365/commodity/controller/MallOrganizeApi.java

@@ -1,7 +1,9 @@
 package com.caimei365.commodity.controller;
 
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.vo.CmSecondInfo;
 import com.caimei365.commodity.model.vo.MallOrganizeProductVo;
+import com.caimei365.commodity.model.vo.PaginationVo;
 import com.caimei365.commodity.service.MallOrganizeService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -26,10 +28,12 @@ import java.util.Map;
 @RequestMapping("/commodity/MallOrganize")
 public class MallOrganizeApi {
 
-    @Autowired private MallOrganizeService mallOrganizeService;
+    @Autowired
+    private MallOrganizeService mallOrganizeService;
 
     /**
      * 联合丽格小程序首页
+     *
      * @return
      */
     @ApiOperation("小程序首页")
@@ -39,13 +43,14 @@ public class MallOrganizeApi {
     @GetMapping("/mall/init")
     public ResponseJson<Map<String, Object>> getMallHome(Integer organizeId) {
         if (null == organizeId) {
-            return ResponseJson.error(-1,"商城类型不能为空",null);
+            return ResponseJson.error(-1, "商城类型不能为空", null);
         }
         return mallOrganizeService.getMallHome(organizeId);
     }
 
     /**
      * 活动详情
+     *
      * @param organizeId
      * @param activeId
      * @return
@@ -56,32 +61,34 @@ public class MallOrganizeApi {
             @ApiImplicitParam(readOnly = true, name = "activeId", value = "活动Id")
     })
     @GetMapping("/mall/detail")
-    public ResponseJson<Map<String,Object>> getMenu(Integer organizeId,  Integer activeId) {
+    public ResponseJson<Map<String, Object>> getMenu(Integer organizeId, Integer activeId) {
         if (null == organizeId) {
-            return ResponseJson.error(-1,"商城类型不能为空",null);
+            return ResponseJson.error(-1, "商城类型不能为空", null);
         }
         if (null == activeId) {
-            return ResponseJson.error(-1,"菜单id不能为空",null);
+            return ResponseJson.error(-1, "菜单id不能为空", null);
         }
 
-        return mallOrganizeService.getMenu(organizeId,  activeId);
+        return mallOrganizeService.getMenu(organizeId, activeId);
     }
 
     /**
      * 活动宣传图商品
+     *
      * @param imageId
      * @return
      */
     @GetMapping("/mall/activeProduct")
     public ResponseJson<List<MallOrganizeProductVo>> activeProduct(Integer imageId) {
         if (null == imageId) {
-            return ResponseJson.error(-1,"活动宣传图id不能为空",null);
+            return ResponseJson.error(-1, "活动宣传图id不能为空", null);
         }
         return mallOrganizeService.activeProduct(imageId);
     }
 
     /**
      * 商品楼层详情
+     *
      * @param floorId
      * @return
      */
@@ -92,13 +99,14 @@ public class MallOrganizeApi {
     @GetMapping("/mall/organizeProducts")
     public ResponseJson<List<MallOrganizeProductVo>> getOrganizeProducts(Integer floorId) {
         if (null == floorId) {
-            return ResponseJson.error(-1,"楼层Id不能为空",null);
+            return ResponseJson.error(-1, "楼层Id不能为空", null);
         }
         return mallOrganizeService.getOrganizeProducts(floorId);
     }
 
     /**
      * 专题活动详情 只有一个已启用状态的活动
+     *
      * @return
      */
     @ApiOperation("专题活动详情 只有一个已启用状态的活动")
@@ -106,4 +114,15 @@ public class MallOrganizeApi {
     public ResponseJson<Map<String, Object>> getThemeInfo() {
         return mallOrganizeService.getThemeInfo();
     }
+
+
+    @ApiOperation("二手小程序文章")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+    })
+    @GetMapping("/second/infos")
+    public ResponseJson<PaginationVo<CmSecondInfo>> getCmSecondInfos(Integer pageNum, Integer pageSize) {
+        return mallOrganizeService.getSecondInfos(pageNum, pageSize);
+    }
 }

+ 10 - 0
src/main/java/com/caimei365/commodity/controller/SecondHandApi.java

@@ -225,4 +225,14 @@ public class SecondHandApi {
         }
         return secondHandService.getSecondRecommends(productId);
     }
+
+    @ApiOperation("下架商品")
+    @ApiImplicitParam(required = true, name = "productId", value = "商品Id")
+    @GetMapping("/status")
+    public ResponseJson updateSecondHandStatus(Integer productId) {
+        if (null == productId) {
+            return ResponseJson.error("商品Id不能为空!", null);
+        }
+        return secondHandService.updateSecondHandStatus(productId);
+    }
 }

+ 4 - 3
src/main/java/com/caimei365/commodity/controller/UserLikeApi.java

@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 /**
  * @author zzj 2021/9/17
- *    测试
+ * 测试
  */
 @Api(tags = "用户收藏API")
 @RestController
@@ -51,17 +51,18 @@ public class UserLikeApi {
     @ApiOperation("收藏商品列表")
     @ApiImplicitParams({
             @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = false, name = "type", value = "0/空采美,1二手"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @GetMapping("/likeList")
-    public ResponseJson<PaginationVo<ProductItemVo>> likes(Integer userId,
+    public ResponseJson<PaginationVo<ProductItemVo>> likes(Integer userId, Integer type,
                                                            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
         if (userId == null) {
             return ResponseJson.error("非法参数");
         }
-        return userLikeService.findLikeList(userId, pageNum, pageSize);
+        return userLikeService.findLikeList(userId, type, pageNum, pageSize);
     }
 
     /**

+ 2 - 0
src/main/java/com/caimei365/commodity/mapper/MallOrganizeMapper.java

@@ -132,4 +132,6 @@ public interface MallOrganizeMapper {
     MallThemeVo getThemeInfo();
 
     List<MallOrganizeProductVo> getThemeProduct();
+
+    List<CmSecondInfo> getSecondInfos();
 }

+ 28 - 4
src/main/java/com/caimei365/commodity/mapper/PriceMapper.java

@@ -20,6 +20,7 @@ public interface PriceMapper {
      * 根据用户Id查询用户身份
      */
     Integer getIdentityByUserId(Integer userId);
+
     /**
      * 根据商品id查找价格
      */
@@ -29,8 +30,10 @@ public interface PriceMapper {
      * 根据商品id查找价格
      */
     PriceVo getDistributionDetailPrice(Integer productId);
+
     /**
      * 采美sku最低价
+     *
      * @param productId
      * @return
      */
@@ -38,14 +41,17 @@ public interface PriceMapper {
 
     /**
      * 外部商城sku最低价
+     *
      * @param productId
      * @return
      */
     PriceVo getOrganizeMinPrice(Integer productId);
+
     /**
      * 根据商品id集合查找 价格列表
      */
     List<PriceVo> getListPriceByProductIds(@Param("productIds") List<Integer> productIds);
+
     /**
      * 根据skuId查询阶梯价列表
      */
@@ -53,15 +59,18 @@ public interface PriceMapper {
 
     /**
      * 根据skuId查询阶梯价列表 组织
+     *
      * @param skuId
      * @param organizeId
      * @return
      */
     List<LadderPriceVo> getLadderPricesOrganizeByProductId(@Param("skuId") Integer skuId, @Param("organizeId") Integer organizeId);
+
     /**
      * 获取最低阶梯价(价格最低,阶梯数最大)
      */
     LadderPriceVo findLowerLadderPrice(Integer skuId);
+
     /**
      * 获取最高阶梯价(价格最高,阶梯数最小)
      */
@@ -69,22 +78,27 @@ public interface PriceMapper {
 
     /**
      * 获取最高阶梯价(价格最高,阶梯数最小)联合丽格
+     *
      * @param skuId
      * @return
      */
-    LadderPriceVo findOrganizeMaxLadderPrice(@Param("skuId") Integer skuId,@Param("organizeId") Integer organizeId);
+    LadderPriceVo findOrganizeMaxLadderPrice(@Param("skuId") Integer skuId, @Param("organizeId") Integer organizeId);
+
     /**
      * 根据商品ID和用户ID 查询复购价
      */
     Double getRepurchasePrice(@Param("skuId") Integer skuId, @Param("userId") Integer userId);
+
     /**
      * 根据商品ID含税和发票信息
      */
     TaxVo getTaxByProductId(Integer productId);
+
     /**
      * 根据用户id查询超级会员用户id
      */
     Integer getSvipUserIdByUserId(Integer userId);
+
     /**
      * 获取商品销量信息
      */
@@ -93,10 +107,12 @@ public interface PriceMapper {
     void insertProductSales(ProductSalesVo salesVo);
 
     void updateProductSales(ProductSalesVo salesVo);
+
     /**
      * 会员机构类型:1医美,2生美
      */
     Integer getClubTypeById(Integer userId);
+
     /**
      * 根据用户Id查询供应商Id
      */
@@ -104,19 +120,23 @@ public interface PriceMapper {
 
     /**
      * 组织Id
+     *
      * @param userId
      * @return
      */
     Integer getOrganize(Integer userId);
+
     /**
      * 添加销量记录
+     *
      * @param productId 商品Id
-     * @param sales 销量
+     * @param sales     销量
      */
     void insertProductSalesRecord(Integer productId, Integer sales);
 
     /**
      * skus
+     *
      * @param productId
      * @return
      */
@@ -124,6 +144,7 @@ public interface PriceMapper {
 
     /**
      * 分销人员skus
+     *
      * @param productId
      * @return
      */
@@ -131,6 +152,7 @@ public interface PriceMapper {
 
     /**
      * skus
+     *
      * @param productId
      * @return
      */
@@ -138,13 +160,15 @@ public interface PriceMapper {
 
     /**
      * 外部商城sku
+     *
      * @param productId
      * @return
      */
-    List<Sku> findOrganizeSkus(Integer productId);
+    List<Sku> findOrganizeSkus(Integer type, Integer productId);
 
     /**
      * 查找所有阶梯价中最低价
+     *
      * @param productId
      * @return
      */
@@ -164,5 +188,5 @@ public interface PriceMapper {
 
     VipSkuPriceDto getVipSku(Integer skuId);
 
-    Double getTouchPriceBySku(Integer skuId,Integer promotionId);
+    Double getTouchPriceBySku(Integer skuId, Integer promotionId);
 }

+ 3 - 1
src/main/java/com/caimei365/commodity/mapper/SecondHandMapper.java

@@ -34,7 +34,7 @@ public interface SecondHandMapper {
      *
      * @param productId 商品Id
      */
-    SecondDetailVo getSecondHandDetail(Integer productId);
+    SecondDetailVo getSecondHandDetail(@Param("userId") Integer userId, @Param("productId") Integer productId);
 
     /**
      * 获取二手商品图片
@@ -115,4 +115,6 @@ public interface SecondHandMapper {
     void updateSecondHandProduct(ProductSecondPo secondPo);
 
     void deleteFileTypes(Integer productId);
+
+    void updateSecondHandStatus(Integer productId);
 }

+ 10 - 3
src/main/java/com/caimei365/commodity/mapper/UserLikeMapper.java

@@ -14,30 +14,35 @@ public interface UserLikeMapper {
 
     /**
      * 获取用户组织Id
+     *
      * @param userId
      * @return
      */
     Integer getOrganizeId(Integer userId);
+
     /**
      * 用户收藏
+     *
      * @param userId
      * @param productId
      * @param userLike
      * @return
      */
-    Integer like(Integer userId, Integer productId,Integer userLike);
+    Integer like(Integer userId, Integer productId, Integer userLike);
 
     /**
      * 取消收藏
+     *
      * @param userId
      * @param productId
      * @param userLike
      * @return
      */
-    Integer disLike(Integer userId, Integer productId,Integer userLike);
+    Integer disLike(Integer userId, Integer productId, Integer userLike);
 
     /**
      * 查找用户收藏情况
+     *
      * @param userId
      * @param productId
      * @return
@@ -46,6 +51,7 @@ public interface UserLikeMapper {
 
     /**
      * 新用户收藏
+     *
      * @param userId
      * @param productId
      */
@@ -53,10 +59,11 @@ public interface UserLikeMapper {
 
     /**
      * 用户收藏列表
+     *
      * @param userId
      * @return
      */
-    List<ProductItemVo> findLikeList(@Param("organizeId") Integer organizeId, @Param("userId") Integer userId);
+    List<ProductItemVo> findLikeList(Integer type, @Param("organizeId") Integer organizeId, @Param("userId") Integer userId);
 
 
 }

+ 3 - 0
src/main/java/com/caimei365/commodity/model/dto/SecondDto.java

@@ -67,6 +67,9 @@ public class SecondDto implements Serializable {
      */
     @ApiModelProperty("品牌Id(旧:brandID)")
     private Integer brandId;
+
+    @ApiModelProperty("品牌名称")
+    private String brandName;
     /**
      * 商品名称
      */

+ 31 - 0
src/main/java/com/caimei365/commodity/model/vo/CmSecondInfo.java

@@ -0,0 +1,31 @@
+package com.caimei365.commodity.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 二手小程序信息中心文章(CmSecondInfo)实体类
+ *
+ */
+@Data
+public class CmSecondInfo implements Serializable {
+    private static final long serialVersionUID = -47250179645160397L;
+
+    private Integer id;
+
+    private String title;
+
+    private String link;
+
+    private String image;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date publishTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date addTime;
+}
+

+ 2 - 0
src/main/java/com/caimei365/commodity/model/vo/ProductItemVo.java

@@ -17,6 +17,8 @@ import java.util.List;
 public class ProductItemVo implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    private Integer buyFlag;
+
     private Integer stock;
     /**
      * 展示的sku的价格等级

+ 4 - 1
src/main/java/com/caimei365/commodity/service/MallOrganizeService.java

@@ -1,8 +1,9 @@
 package com.caimei365.commodity.service;
 
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.vo.CmSecondInfo;
 import com.caimei365.commodity.model.vo.MallOrganizeProductVo;
-import com.caimei365.commodity.model.vo.MallThemeVo;
+import com.caimei365.commodity.model.vo.PaginationVo;
 
 import java.util.List;
 import java.util.Map;
@@ -46,4 +47,6 @@ public interface MallOrganizeService {
      * @return
      */
     ResponseJson<Map<String,Object>> getThemeInfo();
+
+    ResponseJson<PaginationVo<CmSecondInfo>> getSecondInfos(Integer pageNum, Integer pageSize);
 }

+ 2 - 0
src/main/java/com/caimei365/commodity/service/SecondHandService.java

@@ -104,4 +104,6 @@ public interface SecondHandService {
     ResponseJson<SecondDetailVo> getSecondProductDetail(Integer userId, Integer productId);
 
     ResponseJson<PaginationVo<SecondListVo>> getAllocateProducts(Integer shopId, int pageNum, int pageSize);
+
+    ResponseJson updateSecondHandStatus(Integer productId);
 }

+ 5 - 1
src/main/java/com/caimei365/commodity/service/UserLikeService.java

@@ -6,11 +6,13 @@ import com.caimei365.commodity.model.vo.ProductItemVo;
 
 /**
  * zzj 2021/9/17
+ *
  * @author zzj
  */
 public interface UserLikeService {
     /**
      * 收藏
+     *
      * @param userId
      * @param productId
      * @return
@@ -19,15 +21,17 @@ public interface UserLikeService {
 
     /**
      * 收藏列表
+     *
      * @param userId
      * @param pageNum
      * @param pageSize
      * @return
      */
-    ResponseJson<PaginationVo<ProductItemVo>> findLikeList(Integer userId, int pageNum, int pageSize);
+    ResponseJson<PaginationVo<ProductItemVo>> findLikeList(Integer userId, Integer type, int pageNum, int pageSize);
 
     /**
      * 批量移除收藏商品
+     *
      * @param userId
      * @param productIds
      * @return

+ 9 - 2
src/main/java/com/caimei365/commodity/service/impl/MallOrganizeServiceImpl.java

@@ -3,17 +3,16 @@ package com.caimei365.commodity.service.impl;
 import com.caimei365.commodity.components.PriceUtilService;
 import com.caimei365.commodity.mapper.MallOrganizeMapper;
 import com.caimei365.commodity.model.ResponseJson;
-import com.caimei365.commodity.model.po.ProcurePo;
 import com.caimei365.commodity.model.vo.*;
 import com.caimei365.commodity.service.MallOrganizeService;
 import com.caimei365.commodity.utils.MathUtil;
+import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -206,4 +205,12 @@ public class MallOrganizeServiceImpl implements MallOrganizeService {
         }
         return ResponseJson.success(map);
     }
+
+    @Override
+    public ResponseJson<PaginationVo<CmSecondInfo>> getSecondInfos(Integer pageNum, Integer pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<CmSecondInfo> cmSecondInfos = mallOrganizeMapper.getSecondInfos();
+        PaginationVo<CmSecondInfo> page = new PaginationVo<>(cmSecondInfos);
+        return ResponseJson.success(page);
+    }
 }

+ 1 - 1
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -784,7 +784,7 @@ public class PageServiceImpl implements PageService {
         }
         // 商品不处于已删除/待审核/审核未通过的状态
         if (0 != product.getValidFlag()) {
-            List<Sku> organizeSkus = priceMapper.findOrganizeSkus(productId);
+            List<Sku> organizeSkus = priceMapper.findOrganizeSkus(null, productId);
             // 设置价格
             if (null != organizeSkus) {
                 product.setPrice(organizeSkus.get(0).getPrice());

+ 24 - 9
src/main/java/com/caimei365/commodity/service/impl/SecondHandServiceImpl.java

@@ -21,6 +21,7 @@ import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
@@ -111,7 +112,7 @@ public class SecondHandServiceImpl implements SecondHandService {
      */
     @Override
     public ResponseJson<SecondDetailVo> getSecondHandDetail(Integer userId, Integer productId) {
-        SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
+        SecondDetailVo second = secondHandMapper.getSecondHandDetail(userId, productId);
         Integer type = null == second.getSecondProductType() ? 0 : second.getSecondProductType();
         List<Integer> ids = secondHandMapper.getNewAddProductIds(type);
         Integer newFlag = ids.contains(second.getProductId()) ? 1 : 0;
@@ -451,15 +452,17 @@ public class SecondHandServiceImpl implements SecondHandService {
             sku.setProductId(product.getProductId());
             shopMapper.insertSku(sku);
         } else {
+            product.setProductId(secondDto.getProductId());
             shopMapper.updateProduct(product);
             shopMapper.deleteProductImageById(product.getProductId());
         }
         if (null != secondDto.getProductImages()) {
             List<String> productImages = secondDto.getProductImages();
+            Integer shopId = newFlag ? 1252 : null;
             productImages.forEach(image -> {
                 ProductImagePo imagePo = new ProductImagePo();
                 imagePo.setProductId(product.getProductId());
-                imagePo.setShopId(1252);
+                imagePo.setShopId(shopId);
                 imagePo.setAddTime(current);
                 imagePo.setImage(image);
                 imagePo.setMainFlag(3);
@@ -468,11 +471,12 @@ public class SecondHandServiceImpl implements SecondHandService {
         }
         if (null != secondDto.getImage()) {
             String[] images = secondDto.getImage().split(",");
+            Integer shopId = newFlag ? 1252 : null;
             /* 保存商品图片信息*/
             for (int i = 0; i < images.length; i++) {
                 ProductImagePo imagePo = new ProductImagePo();
                 imagePo.setProductId(product.getProductId());
-                imagePo.setShopId(1252);
+                imagePo.setShopId(shopId);
                 imagePo.setAddTime(current);
                 imagePo.setImage(images[i]);
                 if (i == 0) {
@@ -527,7 +531,11 @@ public class SecondHandServiceImpl implements SecondHandService {
         secondPo.setCommitmentImage(secondDto.getCommitmentImage());
         secondPo.setPublishMethod(secondDto.getPublishMethod());
         secondPo.setPublishIdentity(secondDto.getPublishIdentity());
-        if(newFlag){
+        secondPo.setBrandId(secondDto.getBrandId());
+        if (null != secondDto.getBrandName()) {
+            secondPo.setBrandName(secondDto.getBrandName());
+        }
+        if (newFlag) {
             // 默认设置未出售
             secondPo.setSold(0);
             // 付款状态1:待支付、2已付款
@@ -538,9 +546,9 @@ public class SecondHandServiceImpl implements SecondHandService {
             secondPo.setViewingNum(0);
             /* 保存商品二手附加详细信息 */
             secondHandMapper.saveSencondHandProduct(secondPo);
-        }else{
+        } else {
             secondHandMapper.updateSecondHandProduct(secondPo);
-            secondHandMapper.deleteFileTypes(product.getProductId());
+            secondHandMapper.deleteFileTypes(secondDto.getProductId());
         }
         //保存商品包含文件
         if (StringUtils.isNotBlank(secondDto.getFileType())) {
@@ -612,7 +620,7 @@ public class SecondHandServiceImpl implements SecondHandService {
      */
     @Override
     public ResponseJson<Integer> updateSecondHandViews(Integer productId) {
-        SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
+        SecondDetailVo second = secondHandMapper.getSecondHandDetail(null, productId);
         Integer viewingNum = 0;
         if (null != second) {
             viewingNum = second.getViewingNum();
@@ -672,7 +680,7 @@ public class SecondHandServiceImpl implements SecondHandService {
         if (result != null) {
             return ResponseJson.error("参数异常:联系方式不正确");
         }
-        if(null == secondDto.getProductId()){
+        if (null == secondDto.getProductId()) {
             //校验验证码
             String checkCode = secondDto.getCheckCode();
             if (StringUtils.isBlank(checkCode)) {
@@ -752,7 +760,7 @@ public class SecondHandServiceImpl implements SecondHandService {
 
     @Override
     public ResponseJson<SecondDetailVo> getSecondProductDetail(Integer userId, Integer productId) {
-        SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
+        SecondDetailVo second = secondHandMapper.getSecondHandDetail(userId, productId);
         Integer type = null == second.getSecondProductType() ? 0 : second.getSecondProductType();
         List<Integer> ids = secondHandMapper.getNewAddProductIds(type);
         Integer newFlag = ids.contains(second.getProductId()) ? 1 : 0;
@@ -836,4 +844,11 @@ public class SecondHandServiceImpl implements SecondHandService {
         PaginationVo<SecondListVo> pageData = new PaginationVo<SecondListVo>(secondList);
         return ResponseJson.success(pageData);
     }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public ResponseJson updateSecondHandStatus(Integer productId) {
+        secondHandMapper.updateSecondHandStatus(productId);
+        return ResponseJson.success();
+    }
 }

+ 3 - 3
src/main/java/com/caimei365/commodity/service/impl/UserLikeServiceImpl.java

@@ -50,13 +50,13 @@ public class UserLikeServiceImpl implements UserLikeService {
     }
 
     @Override
-    public ResponseJson<PaginationVo<ProductItemVo>> findLikeList(Integer userId, int pageNum, int pageSize) {
+    public ResponseJson<PaginationVo<ProductItemVo>> findLikeList(Integer userId, Integer type, int pageNum, int pageSize) {
         if (null == userId) {
             return ResponseJson.error("参数错误:用户Id不能为空!", null);
         }
         Integer organizeId = likeMapper.getOrganizeId(userId);
         PageHelper.startPage(pageNum, pageSize);
-        List<ProductItemVo> productList = likeMapper.findLikeList(organizeId, userId);
+        List<ProductItemVo> productList = likeMapper.findLikeList(type, organizeId, userId);
         productList.forEach(product -> {
             if (0 == organizeId) {
                 // 设置商品主图及价格
@@ -65,7 +65,7 @@ public class UserLikeServiceImpl implements UserLikeService {
                 Boolean couponsLogo = pageService.setCouponsLogo(userId, product.getProductId(), 2);
                 product.setCouponsLogo(couponsLogo);
             } else {
-                priceUtilService.setOrganizeProductDetails(userId, product);
+                priceUtilService.setOrganizeProductDetails(type, product);
             }
         });
         PaginationVo<ProductItemVo> pageData = new PaginationVo<>(productList);

+ 7 - 0
src/main/resources/mapper/MallOrganizeMapper.xml

@@ -294,4 +294,11 @@
             left join cm_organize_product_info copi on copi.productId = p.productID and copi.organizeId = 4
         WHERE p.productId = #{id}
     </select>
+
+    <select id="getSecondInfos" resultType="com.caimei365.commodity.model.vo.CmSecondInfo">
+        select
+        id, title, link, image, publishTime, addTime
+        from cm_second_info
+        order by publishTime desc
+    </select>
 </mapper>

+ 7 - 1
src/main/resources/mapper/PriceMapper.xml

@@ -327,7 +327,13 @@
                shopPercent,
                cmPercent
         FROM cm_sku
-        WHERE  productId = #{productId} and organizeId = 4
+        WHERE  productId = #{productId}
+        <if test="type != null and type == 1">
+            and organizeId in (0,5)
+        </if>
+        <if test="type == null || type == 0">
+          and organizeId = 4
+        </if>
         ORDER BY price ASC
     </select>
     <select id="findLowPrice" resultType="com.caimei365.commodity.model.vo.ProductItemVo">

+ 60 - 51
src/main/resources/mapper/SecondHandMapper.xml

@@ -27,7 +27,7 @@
     </insert>
     <insert id="insertProductImage" parameterType="com.caimei365.commodity.model.po.ProductImagePo">
         insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
-        values (#{productId}, #{shopId}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
+        values (#{productId}, ifnull(#{shopId},(select shopId from product where productId=#{productId})), #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
     </insert>
     <insert id="insertProduct" keyColumn="productID" keyProperty="productId"
             parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
@@ -133,6 +133,10 @@
         </set>
         where productId = #{productId}
     </update>
+    <update id="updateSecondHandStatus">
+        update cm_organize_product_info set validFlag = 3
+        where productId = #{productId}
+    </update>
     <delete id="deleteFileTypes">
         delete from cm_second_file_type
         where productId = #{productId}
@@ -180,56 +184,60 @@
         order by cshd.sold, cshd.onLineDate desc
     </select>
     <select id="getSecondHandDetail" resultType="com.caimei365.commodity.model.vo.SecondDetailVo">
-        select p.productID                                   as productId,
-               p.actStatus,
-               p.`name`                                      as name,
-               p.mainImage                                   as image,
-               cs.price,
-               cs.normalPrice,
-               p.productType,
-               cs.stock,
-               p.shopId,
-               p.brandID                                     as brandId,
-               p.visibility                                  as visibility,
-               IF(p.brandID != 161, cb.name, cshd.brandName) as "brandName",
-               cb.description                                as "brandInfo",
-               cshd.originalPrice,
-               cshd.sold,
-               cshd.detailTalkFlag,
-               cshd.onLineDate,
-               cshd.viewingNum,
-               cshd.provinceCityDistrict,
-               cshd.productDetails,
-               cshd.productQuality,
-               cshd.secondHandType,
-               ifnull(cshd.instrumentType, 0)                as instrumentType,
-               cshd.showContactFlag,
-               cshd.contactMobile,
-               cshd.contactName,
-               cshd.fixedYears,
-               cshd.address,
-               cshd.townId,
-               cshd.maturityYears,
-               cshd.publishIdentity,
-               cshd.publishMethod,
-               cshd.companyName,
-               cshd.submitDate,
-               cshd.secondProductType,
-               cshd.userId                                   as publishUserId,
-               cshd.buyFlag,
-               copi.validFlag,
-               cpl.userLike,
-               GROUP_CONCAT(csft.fileType SEPARATOR ',')     AS fileTypes
+        select p.productID as productId,
+        p.actStatus,
+        p.`name` as name,
+        p.mainImage as image,
+        cs.price,
+        cs.normalPrice,
+        p.productType,
+        cs.stock,
+        p.shopId,
+        p.brandID as brandId,
+        p.visibility as visibility,
+        cshd.brandName as "brandName",
+        cb.description as "brandInfo",
+        cshd.originalPrice,
+        cshd.sold,
+        cshd.detailTalkFlag,
+        cshd.onLineDate,
+        cshd.viewingNum,
+        cshd.provinceCityDistrict,
+        cshd.productDetails,
+        cshd.productQuality,
+        cshd.secondHandType,
+        ifnull(cshd.instrumentType, 0) as instrumentType,
+        cshd.showContactFlag,
+        if(publishMethod=2,s.contractMobile,cshd.contactMobile) as contactMobile,
+        if(publishMethod=2,s.name,cshd.contactName) as contactName,
+        cshd.fixedYears,
+        cshd.address,
+        cshd.townId,
+        cshd.maturityYears,
+        cshd.publishIdentity,
+        cshd.publishMethod,
+        cshd.companyName,
+        cshd.submitDate,
+        cshd.secondProductType,
+        cshd.userId as publishUserId,
+        cshd.buyFlag,
+        copi.validFlag,
+        ifnull(cpl.userLike,0) as userLike,
+        GROUP_CONCAT(csft.fileType SEPARATOR ',') AS fileTypes
         from product p
-                 left join cm_sku cs on p.productID = cs.productId
-                 left join cm_second_hand_detail cshd on p.productID = cshd.productID
-                 left join cm_organize_product_info copi on p.productId = copi.productId
-                 left join cm_brand cb on cb.id = p.brandID
-                 LEFT JOIN cm_product_userlike cpl ON p.productID = cpl.productID
-                 LEFT JOIN cm_second_file_type csft ON cshd.id = csft.secondId
+        left join shop s on p.shopId = s.shopId
+        left join cm_sku cs on p.productID = cs.productId
+        left join cm_second_hand_detail cshd on p.productID = cshd.productID
+        left join cm_organize_product_info copi on p.productId = copi.productId
+        left join cm_brand cb on cb.id = p.brandID
+        LEFT JOIN cm_product_userlike cpl ON p.productID = cpl.productID
+        <if test="userId != null and userId !=''">
+            and cpl.userId = #{userId}
+        </if>
+        LEFT JOIN cm_second_file_type csft ON p.productId = csft.productId
         where p.productCategory = 2
-          and p.productID = #{productId}
-          and cs.organizeId in (0, 5)
+        and p.productID = #{productId}
+        and cs.organizeId in (0, 5)
     </select>
     <select id="getImageByProductId" resultType="java.lang.String">
         select image
@@ -382,6 +390,7 @@
         left join cm_brand cb on cb.id = p.brandID
         where
         p.productCategory = 2 and copi.validFlag in(1,2,3,8)
+        and if(cshd.publishMethod = 1,cshd.payStatus=2,1=1)
         <if test="buyFlag != null and buyFlag != ''">
             and cshd.buyFlag = #{buyFlag}
         </if>
@@ -411,7 +420,7 @@
         cshd.submitDate,
         copi.validFlag
         from product p
-        left join cm_organize_product_info copi on copi.productId = p.productID and copi.organizeId = 0
+        left join cm_organize_product_info copi on copi.productId = p.productID
         left join cm_sku cs on p.productID=cs.productId
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
         left join cm_brand cb on cb.id = p.brandID
@@ -422,7 +431,7 @@
         <if test="shopId != null and shopId != ''">
             and p.shopId = #{shopId}
         </if>
-        order by cshd.sold, cshd.onLineDate desc
+        order by cshd.submitDate desc,cshd.sold
     </select>
 
     <select id="getImagePos" resultType="com.caimei365.commodity.model.po.ProductImagePo">

+ 42 - 3
src/main/resources/mapper/ShopMapper.xml

@@ -189,9 +189,48 @@
     </insert>
     <update id="updateProduct">
         update product set
-        groundMall = #{groundMall}, shopID = #{shopId}, name = #{name}, aliasName = #{aliasName}, commodityType = #{commodityType},
-        bigTypeId = #{bigTypeId}, smallTypeId = #{smallTypeId}, tinyTypeId = #{tinyTypeId}, mainImage = #{mainImage},
-        brandId = #{brandId}, productType = #{productType}, tags = #{tags}, includedTax = #{includedTax},newProductType=#{newProductType},
+        <if test="groundMall !=null and groundMall != ''">
+            groundMall = ifnull(#{groundMall},0),
+        </if>
+        <if test="shopId !=null and shopId != ''">
+            shopID = #{shopId},
+        </if>
+        <if test="name !=null and name != ''">
+            name = #{name},
+        </if>
+        <if test="aliasName !=null and aliasName != ''">
+            aliasName = #{aliasName},
+        </if>
+        <if test="commodityType !=null and commodityType != ''">
+            commodityType = #{commodityType},
+        </if>
+        <if test="bigTypeId !=null and bigTypeId != ''">
+            bigTypeId = #{bigTypeId},
+        </if>
+        <if test="smallTypeId !=null and smallTypeId != ''">
+            smallTypeId = #{smallTypeId},
+        </if>
+        <if test="tinyTypeId !=null and tinyTypeId != ''">
+            tinyTypeId = #{tinyTypeId},
+        </if>
+        <if test="mainImage !=null and mainImage != ''">
+            mainImage = #{mainImage},
+        </if>
+        <if test="brandId !=null and brandId != ''">
+            brandId = #{brandId},
+        </if>
+        <if test="productType !=null and productType != ''">
+            productType = #{productType},
+        </if>
+        <if test="tags !=null and tags != ''">
+            tags = #{tags},
+        </if>
+        <if test="includedTax !=null and includedTax != ''">
+            includedTax =#{includedTax},
+        </if>
+        <if test="includedTax !=null and includedTax != ''">
+            newProductType=#{newProductType},
+        </if>
         <if test="qualificationNo !=null and qualificationNo != ''">
             qualificationNo=#{qualificationNo},
         </if>

+ 14 - 1
src/main/resources/mapper/UserLikeMapper.xml

@@ -59,11 +59,24 @@
                p.tinyTypeID      AS tinyTypeId,
                p.visibility      AS visibility,
                p.productType
+        <if test="type != null and type == 1">
+            ,cshd.buyFlag
+            ,cshd.brandName
+        </if>
         FROM product p
         LEFT JOIN cm_product_userlike cpu ON p.productID = cpu.productID
         left join cm_organize_product_info copi on copi.productId = p.productId
+        <if test="type != null and type == 1">
+        left join cm_second_hand_detail cshd on p.productID = cshd.productID
+        </if>
         WHERE copi.validFlag = '2'
-          and copi.organizeId = #{organizeId}
+          <if test="type != null and type == 1">
+              and copi.organizeId in (0,5)
+              and p.productCategory = 2
+          </if>
+          <if test="type == null || type == 0">
+              and copi.organizeId = #{organizeId}
+          </if>
           AND cpu.userLike = '1'
           AND cpu.userID = #{userId}
         ORDER BY cpu.likeTime DESC