zhijiezhao 3 роки тому
батько
коміт
7428a9177f

+ 9 - 0
src/main/java/com/caimei/modules/cibe/entity/Shop.java

@@ -11,6 +11,7 @@ import java.util.List;
 public class Shop extends DataEntity<Shop> {
 
 	private static final long serialVersionUID = 1L;
+	private String cardNumber;
 	private Integer shopID; //
 	private Integer userID; //
 	private String name; //
@@ -94,6 +95,14 @@ public class Shop extends DataEntity<Shop> {
 		this.shopID = shopID;
 	}
 
+	public String getCardNumber() {
+		return cardNumber;
+	}
+
+	public void setCardNumber(String cardNumber) {
+		this.cardNumber = cardNumber;
+	}
+
 	public Integer getUserID() {
 		return userID;
 	}

+ 5 - 0
src/main/java/com/caimei/modules/product/dao/CmSecondHandDetailDao.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.product.dao;
 
+import com.caimei.modules.cibe.entity.Shop;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import com.caimei.modules.product.entity.CmSecondHandDetail;
@@ -31,4 +32,8 @@ public interface CmSecondHandDetailDao extends CrudDao<CmSecondHandDetail> {
     CmSecondHandDetail findValue(Integer productID);
 
     List<Integer> findFlieTypes(Integer productID);
+
+    Integer findShopId(String cardNumber);
+
+    void insertShop(Shop shopVo);
 }

+ 9 - 0
src/main/java/com/caimei/modules/product/entity/CmSecondHandDetail.java

@@ -54,6 +54,7 @@ public class CmSecondHandDetail extends DataEntity<CmSecondHandDetail> {
     private String url; //文件预览url
     private List<Integer> fileTypes;
     private String splitCode;//商品分账号
+    private String cardNumber; //银行卡号
 
     private String validFlag;//商品状态,见表c_productstatus或枚举ProductStatus,0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已冻结
     private String productCategory;// 商品的类别:1正常商品(默认),2二手商品
@@ -114,6 +115,14 @@ public class CmSecondHandDetail extends DataEntity<CmSecondHandDetail> {
         super(id);
     }
 
+    public String getCardNumber() {
+        return cardNumber;
+    }
+
+    public void setCardNumber(String cardNumber) {
+        this.cardNumber = cardNumber;
+    }
+
     public List<Integer> getFileTypes() {
         return fileTypes;
     }

+ 10 - 0
src/main/java/com/caimei/modules/product/service/CmSecondHandDetailService.java

@@ -3,6 +3,7 @@ package com.caimei.modules.product.service;
 import java.util.Date;
 import java.util.List;
 
+import com.caimei.modules.cibe.entity.Shop;
 import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.entity.Product;
 import com.thinkgem.jeesite.common.utils.StringUtils;
@@ -106,4 +107,13 @@ private ProductDao productDao;
 			}
 		}
 	}
+
+    public Integer findSecondShop(String cardNumber) {
+		return cmSecondHandDetailDao.findShopId(cardNumber);
+    }
+
+	@Transactional(readOnly = false)
+	public void insertShop(Shop shopVo) {
+		cmSecondHandDetailDao.insertShop(shopVo);
+	}
 }

+ 18 - 3
src/main/java/com/caimei/modules/product/web/CmSecondHandDetailController.java

@@ -4,6 +4,7 @@ import com.caimei.dfs.image.beens.ImageUploadInfo;
 import com.caimei.modules.basesetting.entity.Address;
 import com.caimei.modules.brand.entity.CmBrand;
 import com.caimei.modules.brand.service.CmBrandService;
+import com.caimei.modules.cibe.entity.Shop;
 import com.caimei.modules.common.utils.UploadUtils;
 import com.caimei.modules.opensearch.GenerateUtils;
 import com.caimei.modules.oss.utils.OSSUtils;
@@ -196,6 +197,20 @@ public class CmSecondHandDetailController extends BaseController {
         if (!beanValidator(model, cmSecondHandDetail)) {
             return form(cmSecondHandDetail, model);
         }
+        //根据银行卡判断是否注册过特殊二手供应商,有则挂在之前的供应商名下,否则注册新供应商
+        Integer shopId = cmSecondHandDetailService.findSecondShop(cmSecondHandDetail.getCardNumber());
+        if (null == shopId || shopId <= 0) {
+            //保存为特殊二手供应商
+            Shop shopVo = new Shop();
+            //1个人,2公司
+            String name = "1".equals(cmSecondHandDetail.getPublishIdentity()) ? cmSecondHandDetail.getContactName() : cmSecondHandDetail.getCompanyName();
+            shopVo.setName(name);
+            shopVo.setLinkMan(cmSecondHandDetail.getContactName());
+            shopVo.setContractMobile(cmSecondHandDetail.getContactMobile());
+            shopVo.setCardNumber(cmSecondHandDetail.getCardNumber());
+            cmSecondHandDetailService.insertShop(shopVo);
+            shopId = shopVo.getShopID();
+        }
         String[] ids = request.getParameterValues("ids");
         List<String> fileTypes = Arrays.asList(ids);
         String validFlag = cmSecondHandDetail.getValidFlag();
@@ -209,7 +224,7 @@ public class CmSecondHandDetailController extends BaseController {
         product.setProductCategory("2");
         product.setPreferredFlag(0);
         // 默认发布到二手供应商
-        product.setShopID(1252);
+        product.setShopID(shopId);
         product.setName(cmSecondHandDetail.getName());
         product.setAliasName(cmSecondHandDetail.getName());
         product.setVisibility(cmSecondHandDetail.getVisibility());
@@ -322,12 +337,12 @@ public class CmSecondHandDetailController extends BaseController {
             cmSecondHandDetail.setCommitmentImage(imageUrl);
         }
         String authenticationBackImage = cmSecondHandDetail.getAuthenticationBackImage();
-        if(StringUtils.isNotEmpty(authenticationBackImage)){
+        if (StringUtils.isNotEmpty(authenticationBackImage)) {
             String imageUrl = getImageUrl(authenticationBackImage);
             cmSecondHandDetail.setAuthenticationBackImage(imageUrl);
         }
         String licenseImage = cmSecondHandDetail.getLicenseImage();
-        if(StringUtils.isNotEmpty(licenseImage)){
+        if (StringUtils.isNotEmpty(licenseImage)) {
             String imageUrl = getImageUrl(licenseImage);
             cmSecondHandDetail.setLicenseImage(imageUrl);
         }

+ 1 - 0
src/main/java/com/caimei/modules/product/web/ProductNewController.java

@@ -362,6 +362,7 @@ public class ProductNewController extends BaseController {
             }
         }
         product.setSearchKey(searchKeyStr);
+        product.setValidFlag("2");
         productService.save(product);
 
         // 保存商品图片

+ 10 - 1
src/main/resources/mappings/modules/product/CmSecondHandDetailMapper.xml

@@ -114,7 +114,12 @@
 		from cm_second_file_type
 		where productId = #{productID}
 	</select>
-	<insert id="insert" parameterType="CmSecondHandDetail"  keyProperty="id" useGeneratedKeys="true">
+    <select id="findShopId" resultType="java.lang.Integer">
+		select shopId from shop
+		where shopType = 3
+		  AND cardNumber = #{cardNumber}
+	</select>
+    <insert id="insert" parameterType="CmSecondHandDetail"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO cm_second_hand_detail(
 			publishIdentity,
 			authenticationBackImage,
@@ -200,6 +205,10 @@
 			(secondid, productid, filetype)
 		values(#{secondId},#{productId},#{fileType})
 	</insert>
+	<insert id="insertShop" keyColumn="shopID" keyProperty="shopId" useGeneratedKeys="true">
+		insert into shop (name,linkMan,contractMobile,cardNumber,addTime,status,shopType)
+		values (#{name},#{linkMan},#{contractMobile},#{cardNumber},now(),90,3)
+	</insert>
 	<update id="update">
 		UPDATE cm_second_hand_detail SET
 			productID = #{productID},

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/user/cmNewProductShopList.jsp

@@ -245,7 +245,7 @@
             <div class="item">
                 &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
                 <c:if test="${shopType eq 2}">
-                    &nbsp;&nbsp;&nbsp;&nbsp;<input class="btn btn-primary" onclick="window.location='${ctx}/user/newCmShop/special/new/edit'" value="添加新品供应商"/>
+                    &nbsp;&nbsp;&nbsp;&nbsp;<input class="btn btn-primary" onclick="window.location='${ctx}/user/newCmShop/special/new/edit?shopType=2'" value="添加新品供应商"/>
                 </c:if>
             </div>
         </div>