zhijiezhao 7 mesi fa
parent
commit
402d5d3190

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

@@ -101,6 +101,7 @@ public class SecondHandApi {
      *                  ,"checkCode" : 验证码
      *                  ,"authenticationBackImage" : 身份证背面照片
      *                  ,"cardNumber" : 收款卡号
+     *                  ,"userId" : userId
      *                  }
      * @param headers   HttpHeaders
      */

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

@@ -99,4 +99,6 @@ public interface SecondHandMapper {
     void insertShop(ShopVo shopVo);
 
     void insertProductValidFlag(Integer productId, Integer validFlag);
+
+    List<Integer> getNewAddProductIds(Integer secondHandType);
 }

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

@@ -16,6 +16,9 @@ import java.io.Serializable;
 @Data
 public class SecondDto implements Serializable {
     private static final long serialVersionUID = 1L;
+
+    private Integer userId;
+
     @ApiModelProperty("收款卡号")
     private String cardNumber;
     /**

+ 3 - 0
src/main/java/com/caimei365/commodity/model/po/ProductSecondPo.java

@@ -15,6 +15,9 @@ import java.util.Date;
 @Data
 public class ProductSecondPo implements Serializable {
     private static final long serialVersionUID = 1L;
+
+    private Integer userId;
+
     /** 主键id */
     private Integer id;
     /** 商品productID */

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

@@ -120,6 +120,10 @@ 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();
+        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) {
@@ -397,30 +401,32 @@ public class SecondHandServiceImpl implements SecondHandService {
     }
 
     private ResponseJson saveSecondHandProduct(SecondDto secondDto) {
-        //根据银行卡判断是否注册过特殊二手供应商,有则挂在之前的供应商名下,否则注册新供应商
-        Integer shopId = secondHandMapper.findSecondShop(secondDto.getCardNumber());
-        if (null == shopId || shopId <= 0) {
-            //保存为特殊二手供应商
-            ShopVo shopVo = new ShopVo();
-            //1个人,2公司
-            String name = 1 == secondDto.getPublishIdentity() ? secondDto.getContactName() : secondDto.getCompanyName();
-            shopVo.setName(name);
-            shopVo.setLinkMan(secondDto.getContactName());
-            shopVo.setContractMobile(secondDto.getContactMobile());
-            shopVo.setCardNumber(secondDto.getCardNumber());
-            if (secondDto.getBanOfDeposit() != null) {
-                shopVo.setBanOfDeposit(secondDto.getBanOfDeposit());
-            }
-            if (secondDto.getAccountName() != null) {
-                shopVo.setAccountName(secondDto.getAccountName());
-            }
+        /**
+         *  当前版本二手商品作为黄页性质,不参与交易,shopId不需要
+         //根据银行卡判断是否注册过特殊二手供应商,有则挂在之前的供应商名下,否则注册新供应商
+         Integer shopId = secondHandMapper.findSecondShop(secondDto.getCardNumber());
+         if (null == shopId || shopId <= 0) {
+         //保存为特殊二手供应商
+         ShopVo shopVo = new ShopVo();
+         //1个人,2公司
+         String name = 1 == secondDto.getPublishIdentity() ? secondDto.getContactName() : secondDto.getCompanyName();
+         shopVo.setName(name);
+         shopVo.setLinkMan(secondDto.getContactName());
+         shopVo.setContractMobile(secondDto.getContactMobile());
+         shopVo.setCardNumber(secondDto.getCardNumber());
+         if (secondDto.getBanOfDeposit() != null) {
+         shopVo.setBanOfDeposit(secondDto.getBanOfDeposit());
+         }
+         if (secondDto.getAccountName() != null) {
+         shopVo.setAccountName(secondDto.getAccountName());
+         }
 
-            if (secondDto.getAccountType() != null) {
-                shopVo.setAccountType(secondDto.getAccountType());
-            }
-            secondHandMapper.insertShop(shopVo);
-            shopId = shopVo.getShopId();
-        }
+         if (secondDto.getAccountType() != null) {
+         shopVo.setAccountType(secondDto.getAccountType());
+         }
+         secondHandMapper.insertShop(shopVo);
+         shopId = shopVo.getShopId();
+         }*/
         // 设置日期时间格式
         Date date = new Date();
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -437,7 +443,7 @@ public class SecondHandServiceImpl implements SecondHandService {
         product.setProductCategory(2);
         product.setPreferredFlag(0);
         // 默认发布到二手供应商
-        product.setShopId(shopId);
+        product.setShopId(0);
         product.setSellNumber(secondDto.getStock());
         product.setHasSkuFlag(1);
         // 商品状态默认待审核
@@ -516,6 +522,7 @@ public class SecondHandServiceImpl implements SecondHandService {
         } else {
             secondPo.setPublisher(secondDto.getContactName());
         }
+        secondPo.setUserId(secondDto.getUserId());
         secondPo.setSecondHandType(secondDto.getSecondHandType());
         secondPo.setInstrumentType(secondDto.getInstrumentType());
         secondPo.setFixedYears(secondDto.getFixedYears());

+ 16 - 2
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)
+                                          authenticationBackImage,userId)
         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})
+                #{licenseImage}, #{authenticationBackImage},#{userId})
     </insert>
     <insert id="insertProductImage" parameterType="com.caimei365.commodity.model.po.ProductImagePo">
         insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
@@ -252,4 +252,18 @@
         where shopType = 3
           AND cardNumber = #{cardNumber}
     </select>
+    <select id="getNewAddProductIds" resultType="java.lang.Integer">
+        select
+        p.productID as productId
+        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
+        where p.productCategory = 2 and copi.validFlag = 2 and cs.organizeId = 0
+        <if test="secondHandType != null and secondHandType != ''">
+            and cshd.secondHandType = #{secondHandType}
+        </if>
+        order by cshd.onLineDate desc
+        limit 10
+    </select>
 </mapper>