Browse Source

二手发布生成供应商

zhijiezhao 3 năm trước cách đây
mục cha
commit
01cff51228

+ 5 - 4
src/main/java/com/caimei365/commodity/mapper/SecondHandMapper.java

@@ -3,10 +3,7 @@ package com.caimei365.commodity.mapper;
 import com.caimei365.commodity.model.po.ProductImagePo;
 import com.caimei365.commodity.model.po.ProductPo;
 import com.caimei365.commodity.model.po.ProductSecondPo;
-import com.caimei365.commodity.model.vo.AddressVo;
-import com.caimei365.commodity.model.vo.BrandVo;
-import com.caimei365.commodity.model.vo.SecondDetailVo;
-import com.caimei365.commodity.model.vo.SecondListVo;
+import com.caimei365.commodity.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -96,4 +93,8 @@ public interface SecondHandMapper {
     List<SecondListVo> getSecondRecommends(Integer productId);
 
     void insertSecondFileType(String fileType,Integer secondId,Integer productId);
+
+    Integer findSecondShop(String cardNumber);
+
+    void insertShop(ShopVo shopVo);
 }

+ 4 - 0
src/main/java/com/caimei365/commodity/model/vo/ShopVo.java

@@ -13,6 +13,10 @@ import java.util.List;
  */
 @Data
 public class ShopVo implements Serializable {
+    /**
+     * 银行卡号
+     */
+    private String cardNumber;
     /**
      * 用户ID
      */

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

@@ -391,6 +391,20 @@ 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());
+            secondHandMapper.insertShop(shopVo);
+            shopId=shopVo.getShopId();
+        }
         // 设置日期时间格式
         Date date = new Date();
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -410,7 +424,7 @@ public class SecondHandServiceImpl implements SecondHandService {
         product.setProductCategory(2);
         product.setPreferredFlag(0);
         // 默认发布到二手供应商
-        product.setShopId(1252);
+        product.setShopId(shopId);
         product.setSellNumber(secondDto.getStock());
         product.setCostPrice(0d);
         product.setCostCheckFlag(2);

+ 9 - 0
src/main/resources/mapper/SecondHandMapper.xml

@@ -40,6 +40,10 @@
         (fileType,secondId,productId)
         values (#{fileType},#{secondId},#{productId})
     </insert>
+    <insert id="insertShop" keyColumn="shopID" keyProperty="shopId" parameterType="com.caimei365.commodity.model.vo.ShopVo" useGeneratedKeys="true">
+        insert into shop (name,linkMan,contractMobile,cardNumber,addTime,status,shopType)
+        values (#{name},#{linkMan},#{contractMobile},#{cardNumber},now(),90,3)
+    </insert>
     <update id="updateSecondHandViews">
         UPDATE cm_second_hand_detail SET viewingNum = #{viewingNum}
         WHERE productID = #{productId}
@@ -213,4 +217,9 @@
         and cshr.secondHandProductID = #{productId}
         order by cshr.sort desc
     </select>
+    <select id="findSecondShop" resultType="java.lang.Integer">
+        select shopId from shop
+        where shopType = 3
+        AND cardNumber = #{cardNumber}
+    </select>
 </mapper>