zhijiezhao 3 недель назад
Родитель
Сommit
a225061758

+ 27 - 9
src/main/java/com/caimei365/commodity/controller/SecondHandApi.java

@@ -39,21 +39,23 @@ public class SecondHandApi {
     @ApiOperation("二手商品列表(旧:/product/getSecondHandProductList)")
     @ApiImplicitParams({
             @ApiImplicitParam(required = false, name = "userId", value = "机构用户id"),
-            @ApiImplicitParam(required = false, name = "secondHandType", value = "二手商品分类,1二手仪器,2临期产品,3其他"),
+            @ApiImplicitParam(required = false, name = "secondHandType", value = "二手商品分类,1二手仪器,2临期产品,3其他/二手小程序 1医美仪器 3生美仪器"),
             @ApiImplicitParam(required = false, name = "instrumentType", value = "二手仪器分类的类型,1轻光电、2重光电、3耗材配件"),
-            @ApiImplicitParam(required = false, name = "name", value = "二手商品名称搜索关键词"),
+            @ApiImplicitParam(required = false, name = "name", value = "设备类型:1医美、2非医美、3生美"),
+            @ApiImplicitParam(required = false, name = "secondProductType", value = "secondProductType"),
+            @ApiImplicitParam(required = false, name = "cityId", value = "cityId"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @IpSave(saveName = "二手商品列表", saveParams = true)
     @GetMapping("/list")
-    public ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer userId, Integer secondHandType, Integer instrumentType, String name,
+    public ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer userId, Integer secondHandType, Integer instrumentType, String name, Integer secondProductType, Integer cityId,
                                                                       @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                                       @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
-        return secondHandService.getSecondHandList(userId, secondHandType, instrumentType, name, pageNum, pageSize);
+        return secondHandService.getSecondHandList(userId, secondHandType, instrumentType, name, secondProductType, cityId, pageNum, pageSize);
     }
 
-    @ApiOperation("二手商品列表(旧:/product/getSecondHandProductList)")
+    @ApiOperation("二手小程序个人中心商品列表")
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "userId", value = "机构用户id"),
             @ApiImplicitParam(required = false, name = "name", value = "二手商品名称搜索关键词"),
@@ -61,7 +63,7 @@ public class SecondHandApi {
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
-    @IpSave(saveName = "二手商品列表", saveParams = true)
+    @IpSave(saveName = "二手小程序个人中心商品列表", saveParams = true)
     @GetMapping("/products")
     public ResponseJson<PaginationVo<SecondListVo>> getSecondHandProducts(Integer buyFlag, Integer userId, String name,
                                                                           @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
@@ -69,16 +71,32 @@ public class SecondHandApi {
         return secondHandService.getSecondHandProducts(buyFlag, userId, name, pageNum, pageSize);
     }
 
-    @ApiOperation("二手商品详情(旧:/product/getSecondHandProductDetail)")
+    @ApiOperation("二手小程序区域经理分配二手列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "shopId", value = "区域经理id"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+    })
+    @IpSave(saveName = "二手小程序区域经理分配二手列表", saveParams = true)
+    @GetMapping("/allocate/list")
+    public ResponseJson<PaginationVo<SecondListVo>> getAllocateProducts(Integer shopId,
+                                                                        @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                        @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        return secondHandService.getAllocateProducts(shopId, pageNum, pageSize);
+    }
+
+
+    @ApiOperation("二手小程序编辑回显")
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "userId", value = "机构用户id"),
             @ApiImplicitParam(required = true, name = "productId", value = "商品Id")
     })
-    @IpSave(saveName = "获取二手商品详情", saveParams = true)
+    @IpSave(saveName = "二手小程序编辑回显", saveParams = true)
     @GetMapping("/second/detail")
     public ResponseJson<SecondDetailVo> getSecondProductDetail(Integer userId, Integer productId) {
         return secondHandService.getSecondProductDetail(userId, productId);
     }
+
     /**
      * 获取二手商品详情
      *
@@ -114,7 +132,7 @@ public class SecondHandApi {
      *                  ,"productQuality" : 商品成色
      *                  ,"contactName" : 联系人名字
      *                  ,"contactMobile" : 联系方式
-     *                  ,"secondProductType" : 设备类型:1医美、2非医美
+     *                  ,"secondProductType" : 设备类型:1医美、2非医美、3生美
      *                  ,"townId" : 县区ID
      *                  ,"address" : 详细地址
      *                  ,"image" : 图片信息

+ 14 - 2
src/main/java/com/caimei365/commodity/mapper/SecondHandMapper.java

@@ -25,7 +25,9 @@ public interface SecondHandMapper {
      * @param instrumentType 二手仪器分类的类型,1轻光电、2重光电、3耗材配件
      * @param name           二手商品名称搜索关键词
      */
-    List<SecondListVo> getSeconHandList(@Param("userIdentity") Integer userIdentity, @Param("secondHandType") Integer secondHandType, @Param("instrumentType") Integer instrumentType, @Param("name") String name);
+    List<SecondListVo> getSeconHandList(@Param("secondHandType") Integer secondHandType,
+                                        @Param("instrumentType") Integer instrumentType, @Param("name") String name,
+                                        @Param("secondProductType") Integer secondProductType, @Param("cityId") Integer cityId);
 
     /**
      * 获取二手商品详情
@@ -78,10 +80,12 @@ public interface SecondHandMapper {
      * @param secondHandType 二手商品分类,1二手仪器,2临期产品,3其他
      */
     List<SecondListVo> getSecondListByLimit(Integer secondHandType);
+
     /**
      * 商品品牌列表
      */
     List<BrandVo> getBrandList();
+
     /**
      * 更新二手商品浏览量
      */
@@ -92,7 +96,7 @@ public interface SecondHandMapper {
      */
     List<SecondListVo> getSecondRecommends(Integer productId);
 
-    void insertSecondFileType(String fileType,Integer secondId,Integer productId);
+    void insertSecondFileType(String fileType, Integer secondId, Integer productId);
 
     Integer findSecondShop(String cardNumber);
 
@@ -103,4 +107,12 @@ public interface SecondHandMapper {
     List<Integer> getNewAddProductIds(Integer secondHandType);
 
     List<SecondListVo> getSecondHandProducts(@Param("buyFlag") Integer buyFlag, @Param("userId") Integer userId, @Param("name") String name);
+
+    List<SecondListVo> getAllocateProducts(Integer shopId);
+
+    List<ProductImagePo> getImagePos(Integer productId);
+
+    void updateSecondHandProduct(ProductSecondPo secondPo);
+
+    void deleteFileTypes(Integer productId);
 }

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

@@ -369,4 +369,6 @@ public interface ShopMapper {
     void deleteSku(List<Integer> skuIds, Integer productId, Integer organizeId);
 
     void insertProductInfo(@Param("organizeId") Integer organizeId, @Param("productId") Integer productId, @Param("validFlag") Integer validFlag);
+
+    void deleteProductImageById(Integer productId);
 }

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

@@ -18,6 +18,8 @@ import java.util.List;
 public class SecondDto implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    private Integer productId;
+
     private Integer buyFlag;
 
     private Integer userId;

+ 0 - 4
src/main/java/com/caimei365/commodity/model/po/ProductPo.java

@@ -279,8 +279,4 @@ public class ProductPo implements Serializable {
      * 库存skus
      */
     public List<Sku> skus;
-    /**
-     * 发布方式 1自行发布 2区域经理发布
-     */
-    private Integer publishMethod;
 }

+ 5 - 1
src/main/java/com/caimei365/commodity/model/po/ProductSecondPo.java

@@ -199,5 +199,9 @@ public class ProductSecondPo implements Serializable {
      */
     @ApiModelProperty("营业执照照片")
     private String licenseImage;
-
+    /**
+     * 发布方式 1自行发布 2区域经理发布
+     */
+    @ApiModelProperty("发布方式")
+    private Integer publishMethod;
 }

+ 23 - 0
src/main/java/com/caimei365/commodity/model/vo/SecondDetailVo.java

@@ -16,6 +16,24 @@ import java.util.List;
 public class SecondDetailVo implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    private Integer publishMethod;
+
+    private String fileTypes;
+
+    private String address;
+
+    private Integer shopId;
+
+    private Integer townId;
+
+    private Integer secondProductType;
+
+    private Date submitDate;
+
+    private Integer publishUserId;
+
+    private Integer userLike;
+
     private Integer buyFlag;
     /**
      * 公司名称
@@ -82,6 +100,10 @@ public class SecondDetailVo implements Serializable {
      * 二手商品列表图片数据集合
      */
     private List<String> imageList;
+    /**
+     * 二手商品资料
+     */
+    private List<String> productImages;
 
     /**
      * 商品类型:0其它类型(默认),1妆字号,2械字号
@@ -156,4 +178,5 @@ public class SecondDetailVo implements Serializable {
      */
     private Integer visibility;
 
+    private Integer validFlag;
 }

+ 3 - 0
src/main/java/com/caimei365/commodity/model/vo/SecondListVo.java

@@ -16,6 +16,9 @@ import java.util.List;
 public class SecondListVo implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    private Date submitDate;
+    private Integer publishMethod;
+    private Integer allocateStatus;
     private Integer buyFlag;
     /** 商品productID */
     private Integer productId;

+ 3 - 1
src/main/java/com/caimei365/commodity/service/SecondHandService.java

@@ -28,7 +28,7 @@ public interface SecondHandService {
      * @param pageSize       每页数量
      * @return List<SecondHandVo>
      */
-    ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer userId, Integer secondHandType, Integer instrumentType, String name, int pageNum, int pageSize);
+    ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer userId, Integer secondHandType, Integer instrumentType, String name, Integer secondProductType, Integer cityId, int pageNum, int pageSize);
 
     /**
      * 获取二手商品详情
@@ -102,4 +102,6 @@ public interface SecondHandService {
     ResponseJson<PaginationVo<SecondListVo>> getSecondHandProducts(Integer buyFlag, Integer userId, String name, int pageNum, int pageSize);
 
     ResponseJson<SecondDetailVo> getSecondProductDetail(Integer userId, Integer productId);
+
+    ResponseJson<PaginationVo<SecondListVo>> getAllocateProducts(Integer shopId, int pageNum, int pageSize);
 }

+ 184 - 121
src/main/java/com/caimei365/commodity/service/impl/SecondHandServiceImpl.java

@@ -26,6 +26,7 @@ import org.springframework.util.CollectionUtils;
 import javax.annotation.Resource;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
@@ -66,21 +67,9 @@ public class SecondHandServiceImpl implements SecondHandService {
      * @return List<SecondHandVo>
      */
     @Override
-    public ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer userId, Integer secondHandType, Integer instrumentType, String name, int pageNum, int pageSize) {
-        //0游客,2会员机构,4普通机构
-        Integer userIdentity = 0;
-        if (userId != null && userId > 0) {
-            userIdentity = priceMapper.getIdentityByUserId(userId);
-            if (null != userIdentity && userIdentity == 2) {
-                // 会员机构类型:1医美,2生美
-                Integer clubType = priceMapper.getClubTypeById(userId);
-                if (null != clubType && clubType == 1) {
-                    userIdentity = 5;
-                }
-            }
-        }
+    public ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer userId, Integer secondHandType, Integer instrumentType, String name, Integer secondProductType, Integer cityId, int pageNum, int pageSize) {
         PageHelper.startPage(pageNum, pageSize);
-        List<SecondListVo> secondList = secondHandMapper.getSeconHandList(userIdentity, secondHandType, instrumentType, name);
+        List<SecondListVo> secondList = secondHandMapper.getSeconHandList(secondHandType, instrumentType, name, secondProductType, cityId);
         if (!CollectionUtils.isEmpty(secondList)) {
             // 初始化商品产品标签
             int initNewNum = 0;
@@ -123,39 +112,39 @@ public class SecondHandServiceImpl implements SecondHandService {
     @Override
     public ResponseJson<SecondDetailVo> getSecondHandDetail(Integer userId, Integer productId) {
         SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
-        Integer type = null == second.getSecondHandType() ? 0 : second.getSecondHandType();
+        Integer type = null == second.getSecondProductType() ? 0 : second.getSecondProductType();
         List<Integer> ids = secondHandMapper.getNewAddProductIds(type);
         Integer newFlag = ids.contains(second.getProductId()) ? 1 : 0;
         second.setNewAdded(newFlag.toString());
-        // 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
-        Integer visibility = second.getVisibility();
-        if (null != userId && userId > 0) {
-            // 用户身份:0个人,1协销,2会员机构,3供应商,4普通机构
-            Integer identity = priceMapper.getIdentityByUserId(userId);
-            // 会员机构类型:1医美,2生美
-            Integer clubType = 0;
-            if (null != identity && identity == 2) {
-                clubType = priceMapper.getClubTypeById(userId);
-            }
-            // 超级会员用户id
-            Integer superVipId = priceMapper.getSvipUserIdByUserId(userId);
-            // 所有人可见
-            boolean pass1 = visibility == 3;
-            // 协销
-            boolean pass2 = null != identity && identity == 1;
-            // 医美机构
-            boolean pass3 = visibility == 4 && (null != clubType && clubType == 1);
-            // 会员机构 | 超级会员
-            boolean pass4 = visibility == 1 && (null != superVipId || (null != identity && identity == 2));
-            // 普通机构
-            boolean pass5 = visibility == 2 && (null != identity && (identity == 4 || identity == 2));
-            // 没有权限查看该商品
-            if (!(pass1 || pass2 || pass3 || pass4 || pass5)) {
-                return ResponseJson.success(1, "没有权限查看该商品", new SecondDetailVo());
-            }
-        } else if (2 == visibility || 1 == visibility || 4 == visibility) {
-            return ResponseJson.success(1, "没有权限查看该商品,userId为空", new SecondDetailVo());
-        }
+//        // 商品可见度:3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
+//        Integer visibility = second.getVisibility();
+//        if (null != userId && userId > 0) {
+//            // 用户身份:0个人,1协销,2会员机构,3供应商,4普通机构
+//            Integer identity = priceMapper.getIdentityByUserId(userId);
+//            // 会员机构类型:1医美,2生美
+//            Integer clubType = 0;
+//            if (null != identity && identity == 2) {
+//                clubType = priceMapper.getClubTypeById(userId);
+//            }
+//            // 超级会员用户id
+//            Integer superVipId = priceMapper.getSvipUserIdByUserId(userId);
+//            // 所有人可见
+//            boolean pass1 = visibility == 3;
+//            // 协销
+//            boolean pass2 = null != identity && identity == 1;
+//            // 医美机构
+//            boolean pass3 = visibility == 4 && (null != clubType && clubType == 1);
+//            // 会员机构 | 超级会员
+//            boolean pass4 = visibility == 1 && (null != superVipId || (null != identity && identity == 2));
+//            // 普通机构
+//            boolean pass5 = visibility == 2 && (null != identity && (identity == 4 || identity == 2));
+//            // 没有权限查看该商品
+//            if (!(pass1 || pass2 || pass3 || pass4 || pass5)) {
+//                return ResponseJson.success(1, "没有权限查看该商品", new SecondDetailVo());
+//            }
+//        } else if (2 == visibility || 1 == visibility || 4 == visibility) {
+//            return ResponseJson.success(1, "没有权限查看该商品,userId为空", new SecondDetailVo());
+//        }
         // 优化地址信息
         String provinceCityDistrict = second.getProvinceCityDistrict();
         provinceCityDistrict = provinceCityDistrict.replace("/", "").replace("市辖区", "");
@@ -404,6 +393,7 @@ public class SecondHandServiceImpl implements SecondHandService {
     }
 
     private ResponseJson saveSecondHandProduct(SecondDto secondDto) {
+        boolean newFlag = null == secondDto.getProductId();
         // 设置日期时间格式
         Date date = new Date();
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -413,45 +403,15 @@ public class SecondHandServiceImpl implements SecondHandService {
         if (null != secondDto.getImage()) {
             String[] images = secondDto.getImage().split(",");
             product.setMainImage(images[0]);
-            /* 保存商品图片信息*/
-            for (int i = 0; i < images.length; i++) {
-                ProductImagePo imagePo = new ProductImagePo();
-                imagePo.setProductId(product.getProductId());
-                imagePo.setShopId(1252);
-                imagePo.setAddTime(current);
-                imagePo.setImage(images[i]);
-                if (i == 0) {
-                    imagePo.setMainFlag(1);
-                } else {
-                    imagePo.setMainFlag(0);
-                }
-                secondHandMapper.insertProductImage(imagePo);
-            }
-        }
-        if (null != secondDto.getProductImages()) {
-            List<String> productImages = secondDto.getProductImages();
-            productImages.forEach(image -> {
-                ProductImagePo imagePo = new ProductImagePo();
-                imagePo.setProductId(product.getProductId());
-                imagePo.setShopId(1252);
-                imagePo.setAddTime(current);
-                imagePo.setImage(image);
-                secondHandMapper.insertProductImage(imagePo);
-            });
         }
-        product.setPublishMethod(secondDto.getPublishMethod());
         product.setBrandId(secondDto.getBrandId());
         product.setName(secondDto.getName());
         product.setAliasName(secondDto.getName());
         // 二手商品类型
         product.setProductCategory(2);
         product.setPreferredFlag(0);
-        // 默认发布到二手供应商
-        product.setShopId(0);
         product.setSellNumber(secondDto.getStock());
         product.setHasSkuFlag(1);
-        // 商品状态默认待审核
-        product.setValidFlag(1);
         product.setSortIndex(1);
         product.setFeaturedFlag(0);
         product.setByFlag(0);
@@ -464,27 +424,65 @@ public class SecondHandServiceImpl implements SecondHandService {
         product.setIncludedTax(0);
         product.setRecommendType(0);
         product.setInvoiceType(0);
-        product.setVisibility(1);
-        product.setAddTime(current);
-        product.setUpdateTime(current);
-        product.setOnlineTime(date);
-        product.setOfflineTime(date);
         product.setAnnounType(secondDto.getAnnounType());
-        /* 保存商品表 */
-        secondHandMapper.insertProduct(product);
-        secondHandMapper.insertProductValidFlag(product.getProductId(), product.getValidFlag());
-        /*保存sku数据*/
-        Sku sku = new Sku();
-        sku.setOrganizeId(5);
-        sku.setPrice(secondDto.getPrice());
-        sku.setStock(secondDto.getStock());
-        sku.setNormalPrice(secondDto.getNormalPrice());
-        sku.setLadderPriceFlag(0);
-        sku.setCostPrice(0d);
-        sku.setCostCheckFlag(2);
-        sku.setCostProportional(95d);
-        sku.setProductId(product.getProductId());
-        shopMapper.insertSku(sku);
+        if (newFlag) {
+            // 默认发布到二手供应商
+            product.setShopId(1252);
+            product.setValidFlag(1);
+            product.setVisibility(1);
+            product.setAddTime(current);
+            product.setUpdateTime(current);
+            product.setOnlineTime(date);
+            product.setOfflineTime(date);
+            /** 保存商品表 */
+            secondHandMapper.insertProduct(product);
+
+            secondHandMapper.insertProductValidFlag(product.getProductId(), product.getValidFlag());
+            /*保存sku数据*/
+            Sku sku = new Sku();
+            sku.setOrganizeId(5);
+            sku.setPrice(0d);
+            sku.setStock(1);
+            sku.setNormalPrice(0d);
+            sku.setLadderPriceFlag(0);
+            sku.setCostPrice(0d);
+            sku.setCostCheckFlag(2);
+            sku.setCostProportional(95d);
+            sku.setProductId(product.getProductId());
+            shopMapper.insertSku(sku);
+        } else {
+            shopMapper.updateProduct(product);
+            shopMapper.deleteProductImageById(product.getProductId());
+        }
+        if (null != secondDto.getProductImages()) {
+            List<String> productImages = secondDto.getProductImages();
+            productImages.forEach(image -> {
+                ProductImagePo imagePo = new ProductImagePo();
+                imagePo.setProductId(product.getProductId());
+                imagePo.setShopId(1252);
+                imagePo.setAddTime(current);
+                imagePo.setImage(image);
+                imagePo.setMainFlag(3);
+                secondHandMapper.insertProductImage(imagePo);
+            });
+        }
+        if (null != secondDto.getImage()) {
+            String[] images = secondDto.getImage().split(",");
+            /* 保存商品图片信息*/
+            for (int i = 0; i < images.length; i++) {
+                ProductImagePo imagePo = new ProductImagePo();
+                imagePo.setProductId(product.getProductId());
+                imagePo.setShopId(1252);
+                imagePo.setAddTime(current);
+                imagePo.setImage(images[i]);
+                if (i == 0) {
+                    imagePo.setMainFlag(1);
+                } else {
+                    imagePo.setMainFlag(0);
+                }
+                secondHandMapper.insertProductImage(imagePo);
+            }
+        }
         ProductSecondPo secondPo = new ProductSecondPo();
         // 保存附赠详细信息关系
         secondPo.setProductId(product.getProductId());
@@ -499,14 +497,6 @@ public class SecondHandServiceImpl implements SecondHandService {
                 secondPo.setProvinceCityDistrict(provinceCityDistrict);
             }
         }
-        // 默认设置未出售
-        secondPo.setSold(0);
-        // 付款状态1:待支付、2已付款
-        secondPo.setPayStatus(1);
-        secondPo.setPayAmount(0d);
-        secondPo.setPayType("");
-        secondPo.setSubmitDate(date);
-        secondPo.setViewingNum(0);
         secondPo.setDockingPeopleName(secondDto.getDockingPeopleName());
         if (StringUtils.isNotBlank(secondDto.getDockingPeopleName())) {
             secondPo.setPublisher(secondDto.getDockingPeopleName());
@@ -535,8 +525,35 @@ public class SecondHandServiceImpl implements SecondHandService {
         secondPo.setOssName(secondDto.getOssName());
         secondPo.setAuthenticationImage(secondDto.getAuthenticationImage());
         secondPo.setCommitmentImage(secondDto.getCommitmentImage());
-        /* 保存商品二手附加详细信息 */
-        secondHandMapper.saveSencondHandProduct(secondPo);
+        secondPo.setPublishMethod(secondDto.getPublishMethod());
+        secondPo.setPublishIdentity(secondDto.getPublishIdentity());
+        if(newFlag){
+            // 默认设置未出售
+            secondPo.setSold(0);
+            // 付款状态1:待支付、2已付款
+            secondPo.setPayStatus(1);
+            secondPo.setPayAmount(0d);
+            secondPo.setPayType("");
+            secondPo.setSubmitDate(date);
+            secondPo.setViewingNum(0);
+            /* 保存商品二手附加详细信息 */
+            secondHandMapper.saveSencondHandProduct(secondPo);
+        }else{
+            secondHandMapper.updateSecondHandProduct(secondPo);
+            secondHandMapper.deleteFileTypes(product.getProductId());
+        }
+        //保存商品包含文件
+        if (StringUtils.isNotBlank(secondDto.getFileType())) {
+            String fileTypes = secondDto.getFileType();
+            if (fileTypes.contains(",")) {
+                String[] split = fileTypes.split(",");
+                for (String fileType : split) {
+                    secondHandMapper.insertSecondFileType(fileType, secondPo.getId(), product.getProductId());
+                }
+            } else {
+                secondHandMapper.insertSecondFileType(fileTypes, secondPo.getId(), product.getProductId());
+            }
+        }
         return ResponseJson.success(product.getProductId());
     }
 
@@ -655,19 +672,21 @@ public class SecondHandServiceImpl implements SecondHandService {
         if (result != null) {
             return ResponseJson.error("参数异常:联系方式不正确");
         }
-        //校验验证码
-        String checkCode = secondDto.getCheckCode();
-        if (StringUtils.isBlank(checkCode)) {
-            return ResponseJson.error("参数异常:请输入验证码");
-        }
-        if (StringUtils.isNotBlank(checkCode)) {
-            String redisSmsCode = stringRedisService.get("code:" + contactMobile);
-            // 开发 和 测试环境 固定短信验证码 666666
-            if ("dev".equals(profile) || "beta".equals(profile)) {
-                redisSmsCode = (null != redisSmsCode && !"null".equals(redisSmsCode) ? redisSmsCode : "666666");
+        if(null == secondDto.getProductId()){
+            //校验验证码
+            String checkCode = secondDto.getCheckCode();
+            if (StringUtils.isBlank(checkCode)) {
+                return ResponseJson.error("参数异常:请输入验证码");
             }
-            if (!checkCode.equals(redisSmsCode)) {
-                return ResponseJson.error("参数异常:手机验证码错误");
+            if (StringUtils.isNotBlank(checkCode)) {
+                String redisSmsCode = stringRedisService.get("code:" + contactMobile);
+                // 开发 和 测试环境 固定短信验证码 666666
+                if ("dev".equals(profile) || "beta".equals(profile)) {
+                    redisSmsCode = (null != redisSmsCode && !"null".equals(redisSmsCode) ? redisSmsCode : "666666");
+                }
+                if (!checkCode.equals(redisSmsCode)) {
+                    return ResponseJson.error("参数异常:手机验证码错误");
+                }
             }
         }
         // 验证传入参数
@@ -698,7 +717,7 @@ public class SecondHandServiceImpl implements SecondHandService {
     @Override
     public ResponseJson<PaginationVo<SecondListVo>> getSecondHandProducts(Integer buyFlag, Integer userId, String name, int pageNum, int pageSize) {
         PageHelper.startPage(pageNum, pageSize);
-        List<SecondListVo> secondList = secondHandMapper.getSecondHandProducts(buyFlag,userId, name);
+        List<SecondListVo> secondList = secondHandMapper.getSecondHandProducts(buyFlag, userId, name);
         if (!CollectionUtils.isEmpty(secondList)) {
             // 初始化商品产品标签
             int initNewNum = 0;
@@ -734,7 +753,7 @@ public class SecondHandServiceImpl implements SecondHandService {
     @Override
     public ResponseJson<SecondDetailVo> getSecondProductDetail(Integer userId, Integer productId) {
         SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
-        Integer type = null == second.getSecondHandType() ? 0 : second.getSecondHandType();
+        Integer type = null == second.getSecondProductType() ? 0 : second.getSecondProductType();
         List<Integer> ids = secondHandMapper.getNewAddProductIds(type);
         Integer newFlag = ids.contains(second.getProductId()) ? 1 : 0;
         second.setNewAdded(newFlag.toString());
@@ -749,12 +768,20 @@ public class SecondHandServiceImpl implements SecondHandService {
         // 处理时间格式化
         second.setOnLineDateStr(dateFormatStr(second.getOnLineDate()));
         // 获取二手商品图片
-        List<String> images = secondHandMapper.getImageByProductId(second.getProductId());
+        List<ProductImagePo> images = secondHandMapper.getImagePos(second.getProductId());
         // 获取二手商品图片(处理老的非全路径图片)
+        List<String> ima = new ArrayList<>();
+        List<String> imb = new ArrayList<>();
         images.forEach(img -> {
-            img = ImageUtils.getImageURL("product", img, 0, domain);
+            String imge = ImageUtils.getImageURL("product", img.getImage(), 0, domain);
+            if (3 == img.getMainFlag()) {
+                imb.add(imge);
+            } else {
+                ima.add(imge);
+            }
         });
-        second.setImageList(images);
+        second.setImageList(ima);
+        second.setProductImages(imb);
         // 初始商品分类
         String typeStr = "";
         Integer secondHandType = second.getSecondHandType();
@@ -773,4 +800,40 @@ public class SecondHandServiceImpl implements SecondHandService {
         second.setTypeStr(typeStr);
         return ResponseJson.success(second);
     }
+
+    @Override
+    public ResponseJson<PaginationVo<SecondListVo>> getAllocateProducts(Integer shopId, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<SecondListVo> secondList = secondHandMapper.getAllocateProducts(shopId);
+        if (!CollectionUtils.isEmpty(secondList)) {
+            // 初始化商品产品标签
+            int initNewNum = 0;
+            for (SecondListVo second : secondList) {
+                initNewNum++;
+                if (initNewNum > 10) {
+                    second.setNewAdded(0);
+                } else {
+                    second.setNewAdded(1);
+                }
+                // 优化地址信息
+                String provinceCityDistrict = second.getProvinceCityDistrict();
+                if (StringUtils.isNotBlank(provinceCityDistrict)) {
+                    provinceCityDistrict = provinceCityDistrict.replace("/", "").replace("市辖区", "");
+                }
+                second.setProvinceCityDistrict(provinceCityDistrict);
+                //价格千分位处理
+                second.setPriceStr(priceFormatStr(second.getPrice()));
+                // 处理时间格式化
+                second.setOnLineDateStr(dateFormatStr(second.getOnLineDate()));
+                // 获取二手商品图片
+                List<String> images = secondHandMapper.getImageByProductId(second.getProductId());
+                images.forEach(img -> {
+                    ImageUtils.getImageURL("product", img, 0, domain);
+                });
+                second.setImageList(images);
+            }
+        }
+        PaginationVo<SecondListVo> pageData = new PaginationVo<SecondListVo>(secondList);
+        return ResponseJson.success(pageData);
+    }
 }

+ 4 - 4
src/main/resources/mapper/PriceMapper.xml

@@ -265,7 +265,7 @@
     </select>
     <select id="findSkus" resultType="com.caimei365.commodity.model.dto.Sku">
         select cs.skuId,
-               price,
+               ifnull(price,0) as price,
                normalPrice,
                costPrice,
                ifnull(ladderPriceFlag, 0)                                                                           as ladderPriceFlag,
@@ -283,12 +283,12 @@
                csps.discount
         from cm_sku cs
         left join cm_svip_product_sku csps on cs.skuId = csps.skuId
-        where cs.productId = #{productId} and cs.organizeId = 0
+        where cs.productId = #{productId} and cs.organizeId in(0,5)
         ORDER BY cs.price ASC
     </select>
     <select id="findDistributionSkus" resultType="com.caimei365.commodity.model.dto.Sku">
         select cds.skuId,
-               cds.price,
+               ifnull(cds.price,0) as price,
                normalPrice,
                cds.costPrice,
                ifnull(ladderPriceFlag, 0)                                                                           as ladderPriceFlag,
@@ -322,7 +322,7 @@
         SELECT skuId,
                unit,
                minBuyNumber,
-               price,
+               ifnull(price,0) as price,
                organizePercent,
                shopPercent,
                cmPercent

+ 149 - 21
src/main/resources/mapper/SecondHandMapper.xml

@@ -12,7 +12,7 @@
                                           payAmount, payFormData, payType, payDate, submitDate, reviewedDate,
                                           onLineDate, source, publisher, authenticationImage,
                                           fileName, ossName, commitmentImage, publishIdentity, licenseImage,
-                                          authenticationBackImage, userId, buyFlag)
+                                          authenticationBackImage, userId, buyFlag, publishMethod, allocateStatus)
         values (#{productId}, #{sold}, #{secondHandType}, #{instrumentType}, #{fixedYears}, #{maturityYears},
                 #{companyName},
                 #{detailTalkFlag}, #{originalPrice}, #{contactName}, #{contactMobile}, #{dockingPeopleName},
@@ -23,7 +23,7 @@
                 #{reviewedDate},
                 #{onLineDate}, #{source}, #{publisher}, #{authenticationImage}, #{fileName}, #{ossName},
                 #{commitmentImage}, #{publishIdentity},
-                #{licenseImage}, #{authenticationBackImage}, #{userId}, #{buyFlag})
+                #{licenseImage}, #{authenticationBackImage}, #{userId}, #{buyFlag}, #{publishMethod}, 1)
     </insert>
     <insert id="insertProductImage" parameterType="com.caimei365.commodity.model.po.ProductImagePo">
         insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
@@ -56,13 +56,88 @@
     </insert>
     <insert id="insertProductValidFlag">
         insert into cm_organize_product_info(organizeId, productId, validFlag)
-        values (0, #{productId}, #{validFlag})
+        values (5, #{productId}, #{validFlag})
     </insert>
     <update id="updateSecondHandViews">
         UPDATE cm_second_hand_detail
         SET viewingNum = #{viewingNum}
         WHERE productID = #{productId}
     </update>
+
+    <update id="updateSecondHandProduct">
+        update cm_second_hand_detail
+        <set>
+            <if test="fixedYears != null and fixedYears !=''">
+                fixedYears =#{fixedYears},
+            </if>
+            <if test="maturityYears != null and maturityYears !=''">
+                maturityYears =#{maturityYears},
+            </if>
+            <if test="companyName != null and companyName !=''">
+                companyName =#{companyName},
+            </if>
+            <if test="detailTalkFlag != null and detailTalkFlag !=''">
+                detailTalkFlag=#{detailTalkFlag},
+            </if>
+            <if test="contactName != null and contactName !=''">
+                contactName=#{contactName},
+            </if>
+            <if test="contactMobile != null and contactMobile !=''">
+                contactMobile=#{contactMobile},
+            </if>
+            <if test="dockingPeopleName != null and dockingPeopleName !=''">
+                dockingPeopleName=#{dockingPeopleName},
+            </if>
+            <if test="dockingPeopleMobile != null and dockingPeopleMobile !=''">
+                dockingPeopleMobile=#{dockingPeopleMobile},
+            </if>
+            <if test="secondProductType != null and secondProductType !=''">
+                secondProductType=#{secondProductType},
+            </if>
+            <if test="townId != null and townId !=''">
+                townId=#{townId},
+            </if>
+            <if test="provinceCityDistrict != null and provinceCityDistrict !=''">
+                provinceCityDistrict=#{provinceCityDistrict},
+            </if>
+            <if test="address != null and address !=''">
+                address=#{address},
+            </if>
+            <if test="productQuality != null and productQuality !=''">
+                productQuality=#{productQuality},
+            </if>
+            <if test="productDetails != null and productDetails !=''">
+                productDetails=#{productDetails},
+            </if>
+            <if test="brandName != null and brandName !=''">
+                brandName=#{brandName},
+            </if>
+            <if test="fileName != null and fileName !=''">
+                fileName=#{fileName},
+            </if>
+            <if test="ossName != null and ossName !=''">
+                ossName=#{ossName},
+            </if>
+            <if test="commitmentImage != null and commitmentImage !=''">
+                commitmentImage=#{commitmentImage},
+            </if>
+            <if test="publishIdentity != null and publishIdentity !=''">
+                publishIdentity=#{publishIdentity},
+            </if>
+            <if test="licenseImage != null and licenseImage !=''">
+                licenseImage=#{licenseImage},
+            </if>
+            <if test="buyFlag != null and buyFlag !=''">
+                buyFlag=#{buyFlag},
+            </if>
+        </set>
+        where productId = #{productId}
+    </update>
+    <delete id="deleteFileTypes">
+        delete from cm_second_file_type
+        where productId = #{productId}
+    </delete>
+
     <select id="getSeconHandList" resultType="com.caimei365.commodity.model.vo.SecondListVo">
         select
         p.productID as productId,
@@ -79,30 +154,29 @@
         cshd.provinceCityDistrict as "provinceCityDistrict",
         cshd.buyFlag
         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 town t on cshd.townId = t.townID
+        left join city c on t.cityID = c.cityID
         left join cm_brand cb on cb.id = p.brandID
         where
-        p.productCategory = 2 and copi.validFlag = 2 and cs.organizeId = 0
+        p.productCategory = 2 and copi.validFlag = 2 and cs.organizeId in(0,5)
         <if test="secondHandType != null and secondHandType != ''">
             and cshd.secondHandType = #{secondHandType}
         </if>
+        <if test="cityId != null and cityId != ''">
+            and c.cityId = #{cityId}
+        </if>
+        <if test="secondProductType != null and secondProductType != ''">
+            and cshd.secondProductType = #{secondProductType}
+        </if>
         <if test="instrumentType != null and instrumentType != '' and instrumentType != '0'  and instrumentType != 0">
             and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
         </if>
         <if test="name != null and name != ''">
             and p.name like CONCAT('%',#{name},'%')
         </if>
-        <if test="userIdentity == null or userIdentity == 0">
-            AND p.visibility = 3
-        </if>
-        <if test="userIdentity == 4">
-            AND p.visibility IN (2,3)
-        </if>
-        <if test="userIdentity == 2">
-            AND p.visibility IN (1,2,3)
-        </if>
         order by cshd.sold, cshd.onLineDate desc
     </select>
     <select id="getSecondHandDetail" resultType="com.caimei365.commodity.model.vo.SecondDetailVo">
@@ -114,6 +188,7 @@
                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",
@@ -132,17 +207,29 @@
                cshd.contactMobile,
                cshd.contactName,
                cshd.fixedYears,
+               cshd.address,
+               cshd.townId,
                cshd.maturityYears,
                cshd.publishIdentity,
+               cshd.publishMethod,
                cshd.companyName,
-               cshd.buyFlag
+               cshd.submitDate,
+               cshd.secondProductType,
+               cshd.userId                                   as publishUserId,
+               cshd.buyFlag,
+               copi.validFlag,
+               cpl.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
         where p.productCategory = 2
           and p.productID = #{productId}
-          and cs.organizeId = 0
+          and cs.organizeId in (0, 5)
     </select>
     <select id="getImageByProductId" resultType="java.lang.String">
         select image
@@ -261,9 +348,9 @@
         left join cm_organize_product_info copi on copi.productId = p.productID and copi.organizeId = 0
         left join cm_sku cs on p.productID=cs.productId
         left join cm_second_hand_detail cshd on p.productID = cshd.productID
-        where p.productCategory = 2 and copi.validFlag = 2 and cs.organizeId = 0
+        where p.productCategory = 2 and copi.validFlag = 2 and cs.organizeId in (0,5)
         <if test="secondHandType != null and secondHandType != ''">
-            and cshd.secondHandType = #{secondHandType}
+            and cshd.secondProductType = #{secondHandType}
         </if>
         order by cshd.onLineDate desc
         limit 10
@@ -284,18 +371,21 @@
         cshd.viewingNum as "viewingNum",
         cshd.provinceCityDistrict as "provinceCityDistrict",
         cshd.buyFlag,
+        cshd.submitDate,
+        cshd.publishMethod,
+        cshd.allocateStatus,
         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
         where
-        p.productCategory = 2
+        p.productCategory = 2 and copi.validFlag in(1,2,3,8)
         <if test="buyFlag != null and buyFlag != ''">
             and cshd.buyFlag = #{buyFlag}
         </if>
-          <if test="userId != null and userId != ''">
+        <if test="userId != null and userId != ''">
             and cshd.userId = #{userId}
         </if>
         <if test="name != null and name != ''">
@@ -303,4 +393,42 @@
         </if>
         order by cshd.sold, cshd.onLineDate desc
     </select>
+    <select id="getAllocateProducts" resultType="com.caimei365.commodity.model.vo.SecondListVo">
+        select
+        p.productID as productId,
+        p.actStatus,
+        p.`name` as name,
+        p.mainImage as image,
+        cs.price,
+        p.brandID as brandId,
+        IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
+        cshd.sold as "sold",
+        cshd.detailTalkFlag as "detailTalkFlag",
+        cshd.onLineDate as "onLineDate",
+        cshd.viewingNum as "viewingNum",
+        cshd.provinceCityDistrict as "provinceCityDistrict",
+        cshd.buyFlag,
+        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_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
+        where p.productCategory = 2
+        and copi.validFlag in(1,2,3,8)
+        and cshd.publishMethod=2
+        and cshd.allocateStatus = 2
+        <if test="shopId != null and shopId != ''">
+            and p.shopId = #{shopId}
+        </if>
+        order by cshd.sold, cshd.onLineDate desc
+    </select>
+
+    <select id="getImagePos" resultType="com.caimei365.commodity.model.po.ProductImagePo">
+        select image, mainFlag
+        from productimage
+        where productID = #{productId}
+        order by mainFlag desc
+    </select>
 </mapper>

+ 4 - 0
src/main/resources/mapper/ShopMapper.xml

@@ -766,6 +766,10 @@
                 </foreach>
             </if>
     </delete>
+    <delete id="deleteProductImageById">
+        delete from productimage
+        where productID = #{productId}
+    </delete>
 
     <select id="getProductNum" resultType="java.lang.Integer">
         select count(productId) from product where freightTemplateId = #{freightTemplateId}