Browse Source

【供应商资源】功能接口提交

dongbw 7 years ago
parent
commit
58c3a629cd

+ 183 - 0
src/main/java/com/uas/platform/b2c/common/message/model/MessageModel.java

@@ -0,0 +1,183 @@
+package com.uas.platform.b2c.common.message.model;
+
+/**
+ * 消息公共服务 - 消息实体
+ */
+public class MessageModel {
+    /**
+     * 消息类型
+     */
+    private String type;
+    /**
+     * 消息内容
+     */
+    private String content;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 来源id
+     */
+    private Long sourceId;
+    /**
+     * 消息接收者uu
+     */
+    private Long receiverUu;
+    /**
+     * 消息接收者企业uu
+     */
+    private Long receiverEnuu;
+    /**
+     * 消息发送者
+     */
+    private Long senderUu;
+    /**
+     * 消息发送者企业uu
+     */
+    private Long senderEnuu;
+    /**
+     * 来源应用
+     */
+    private String producerApp;
+    /**
+     * 消费类型(所有应用共享:"PUBLIC",单个应用独享:"SINGLE",多个应用共享:"MULTI")
+     */
+    private String consumerType;
+    /**
+     * 推送方式类型
+     * 邮件、短信、IM:"MAIL_AND_SM_AND_IM"
+     * 邮件、短信:"MAIL_AND_SM"
+     * 邮件、IM:"MAIL_AND_IM"
+     * 短信、IM:"SM_AND_IM"
+     * 邮件:"MAIL"
+     * 短信:"SM"
+     * IM:"IM"
+     * 不发送:"DONT_SEND"
+     */
+    private String smsType;
+    /**
+     * 邮件模板id
+     */
+    private String mailTemplate;
+    /**
+     * 短息模板id
+     */
+    private String smTemplate;
+    /**
+     * 接收应用(以","拼接应用名称)
+     */
+    private String consumerApp;
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public Long getReceiverUu() {
+        return receiverUu;
+    }
+
+    public void setReceiverUu(Long receiverUu) {
+        this.receiverUu = receiverUu;
+    }
+
+    public Long getReceiverEnuu() {
+        return receiverEnuu;
+    }
+
+    public void setReceiverEnuu(Long receiverEnuu) {
+        this.receiverEnuu = receiverEnuu;
+    }
+
+    public Long getSenderUu() {
+        return senderUu;
+    }
+
+    public void setSenderUu(Long senderUu) {
+        this.senderUu = senderUu;
+    }
+
+    public Long getSenderEnuu() {
+        return senderEnuu;
+    }
+
+    public void setSenderEnuu(Long senderEnuu) {
+        this.senderEnuu = senderEnuu;
+    }
+
+    public String getProducerApp() {
+        return producerApp;
+    }
+
+    public void setProducerApp(String producerApp) {
+        this.producerApp = producerApp;
+    }
+
+    public String getConsumerType() {
+        return consumerType;
+    }
+
+    public void setConsumerType(String consumerType) {
+        this.consumerType = consumerType;
+    }
+
+    public String getSmsType() {
+        return smsType;
+    }
+
+    public void setSmsType(String smsType) {
+        this.smsType = smsType;
+    }
+
+    public String getMailTemplate() {
+        return mailTemplate;
+    }
+
+    public void setMailTemplate(String mailTemplate) {
+        this.mailTemplate = mailTemplate;
+    }
+
+    public String getSmTemplate() {
+        return smTemplate;
+    }
+
+    public void setSmTemplate(String smTemplate) {
+        this.smTemplate = smTemplate;
+    }
+
+    public String getConsumerApp() {
+        return consumerApp;
+    }
+
+    public void setConsumerApp(String consumerApp) {
+        this.consumerApp = consumerApp;
+    }
+
+    public Long getSourceId() {
+        return sourceId;
+    }
+
+    public void setSourceId(Long sourceId) {
+        this.sourceId = sourceId;
+    }
+}

+ 32 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/V_ProductPrivate.java

@@ -228,6 +228,22 @@ public class V_ProductPrivate implements Serializable {
     @Column(name = "pr_b2cenabled")
     private Integer b2cEnabled;
 
+    /**
+     * 是否可卖<br>
+     * 1. 可以卖 <br>
+     * 0. 不可
+     */
+    @Column(name = "pr_issale")
+    private Short isSale;
+
+    /**
+     * 是否可买<br>
+     * 1. 可以买<br>
+     * 0. 不可
+     */
+    @Column(name = "pr_ispurchase")
+    private Short isPurchase;
+
     /**
      * 产品建立时间
      */
@@ -563,4 +579,20 @@ public class V_ProductPrivate implements Serializable {
     public void setBatchCount(Integer batchCount) {
         this.batchCount = batchCount;
     }
+
+    public Short getIsSale() {
+        return isSale;
+    }
+
+    public void setIsSale(Short isSale) {
+        this.isSale = isSale;
+    }
+
+    public Short getIsPurchase() {
+        return isPurchase;
+    }
+
+    public void setIsPurchase(Short isPurchase) {
+        this.isPurchase = isPurchase;
+    }
 }

+ 19 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/Readme.md

@@ -0,0 +1,19 @@
+## name
+
+vendor
+
+## 名称
+
+供应商资源模块
+
+## 创建人
+
+董必伟
+
+## 创建时间
+
+2018年4月25日 15:17:25
+
+## 说明
+
+供应商资源查看、对应企业物料列表、针对物料立即询价、ERP引进供应商

+ 109 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/controller/VendorIntroductionController.java

@@ -0,0 +1,109 @@
+package com.uas.platform.b2c.trade.vendor.controller;
+
+import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
+import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
+import com.uas.platform.b2c.trade.vendor.model.InviteVendorHistory;
+import com.uas.platform.b2c.trade.vendor.model.VendorIntroduction;
+import com.uas.platform.b2c.trade.vendor.service.InviteVendorHistoryService;
+import com.uas.platform.b2c.trade.vendor.service.VendorIntroductionService;
+import com.uas.platform.core.logging.BufferedLoggerManager;
+import com.uas.sso.support.Page;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 供应商资源引进模块
+ *
+ * @author dongbw
+ * @time 创建时间 :2018年4月25日 15:20:53
+ */
+@RestController
+@RequestMapping("/vendor/introduction")
+public class VendorIntroductionController {
+
+    @Autowired
+    private VendorIntroductionService vendorIntroductionService;
+
+    @Autowired
+	private InviteVendorHistoryService inviteVendorHistoryService;
+	
+	private static final UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
+
+
+    /**
+     * 根据关键词(非必填)获取供应商资源列表
+     *
+     * @param size  the params 一页的大小
+	 * @param page 第几页
+     * @param keyword the keyword  搜索关键字
+     * @return the Page<VendorIntroduction> 返回一页的数据
+     */
+    @RequestMapping(value = "/vendor/list", method = RequestMethod.GET)
+	public Page<VendorIntroduction> getVendorIntroductionList(int page, int size, String keyword) {
+		logger.log("供应商资源", "获取供应商资源列表");
+		return vendorIntroductionService.getVendorIntroduction(page, size, keyword);
+	}
+
+	/**
+	 * 获取推荐企业物料列表(匹配到的排前面)
+	 * @param page 页数
+	 * @param size 每页条数
+	 * @param vendUU 推荐供应商企业UU
+	 * @param keyword 关键词
+	 * @return venduu企业物料list
+	 */
+	@RequestMapping(value = "/product/list", method = RequestMethod.GET)
+	public Page<V_ProductPrivate> getVendorProductList(int page, int size, Long vendUU, String keyword) {
+		Page<V_ProductPrivate> productPage = vendorIntroductionService.getVendorProductList(page, size, vendUU, keyword);
+        logger.log("供应商资源","获取供应商物料列表:" + vendUU);
+		return productPage;
+	}
+
+	/**
+	 * 获取该物料详情
+	 * @param id 物料id
+	 * @return 物料内容
+	 */
+	@RequestMapping(value = "/product/detail", method = RequestMethod.GET)
+	public V_ProductPrivate getVendorProductDetail(Long id) {
+		V_ProductPrivate product = vendorIntroductionService.getVendorProductDetail(id);
+		logger.log("供应商资源","获取供应商物料详情:" + id);
+		return product;
+	}
+
+	/**
+	 * 获取企业邀请完善信息历史记录
+	 * @param vendUU 供应商企业UU
+	 * @return 邀请历史记录
+	 */
+	@RequestMapping(value = "/invite/history", method = RequestMethod.GET)
+	public InviteVendorHistory getInviteVendorHistoryByVendUU(Long vendUU) {
+		InviteVendorHistory inviteVendorHistory = inviteVendorHistoryService.getInviteVendorHistoryByVendUU(vendUU);
+		logger.log("供应商资源","获取企业邀请完善信息历史记录,vendUU:" + vendUU);
+		return inviteVendorHistory;
+	}
+
+	/**
+	 * 邀请供应商完善信息
+	 * @param vendUU 供应商企业UU
+	 * @return 是否成功
+	 */
+	@RequestMapping(value = "/invite", method = RequestMethod.POST)
+	public ModelMap inviteVendorByVendUU(Long vendUU) {
+		ModelMap map = new ModelMap();
+		try {
+			inviteVendorHistoryService.inviteVendorByVendUU(vendUU);
+			map.put("success", true);
+			logger.log("供应商资源","邀请供应商完善信息成功,vendUU:" + vendUU);
+		} catch (Exception e) {
+			map.put("success", false);
+			map.put("message", e.getMessage());
+			logger.log("供应商资源","邀请供应商完善信息失败,vendUU:" + vendUU + "原因:" + e.getMessage());
+		}
+		return map;
+	}
+
+}

+ 21 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/dao/InviteVendorHistoryDao.java

@@ -0,0 +1,21 @@
+package com.uas.platform.b2c.trade.vendor.dao;
+
+import com.uas.platform.b2c.trade.vendor.model.InviteVendorHistory;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+ * Created by dongbw
+ * 18/04/27 15:01.
+ */
+public interface InviteVendorHistoryDao extends JpaSpecificationExecutor<InviteVendorHistory>,
+        JpaRepository<InviteVendorHistory, Long> {
+
+    /**
+     * 根据邀请企业与被邀请企业获取邀请记录
+     * @param enUU 邀请企业UU
+     * @param vendUU 被邀请企业UU
+     * @return
+     */
+    InviteVendorHistory findByEnUUAndVendUU(Long enUU, Long vendUU);
+}

+ 107 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/model/InviteVendorHistory.java

@@ -0,0 +1,107 @@
+package com.uas.platform.b2c.trade.vendor.model;
+
+import java.util.Date;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Index;
+import javax.persistence.Table;
+
+/**
+ * 邀请供应商完善信息历史
+ *
+ * @author dongbw
+ * @version 2018年4月27日 14:58:12
+ */
+@Entity(name = "trade.inviteVendorHistory")
+@Table(name = "trade$inviteVendorHistory", indexes = {
+        @Index(name = "unique_enuu_venduu", columnList = "in_enuu,in_venduu", unique = true)})
+public class InviteVendorHistory {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "in_id")
+    private Long id;
+
+    /**
+     * 邀请企业uu
+     */
+    @Column(name = "in_enuu")
+    private Long enUU;
+
+    /**
+     * 被邀请企业UU
+     */
+    @Column(name = "in_venduu")
+    private Long vendUU;
+
+    /**
+     * 最近一次邀请时间
+     */
+    @Column(name = "in_date")
+    private Date date;
+
+    /**
+     * 已邀请次数
+     */
+    @Column(name = "in_times")
+    private Integer times;
+
+    public InviteVendorHistory() {
+
+    }
+
+    public InviteVendorHistory(Long enUU, Long vendUU) {
+        this.date = new Date();
+        this.enUU = enUU;
+        this.vendUU = vendUU;
+        this.times = 1;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Long getVendUU() {
+        return vendUU;
+    }
+
+    public void setVendUU(Long vendUU) {
+        this.vendUU = vendUU;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    public Integer getTimes() {
+        return times;
+    }
+
+    public void setTimes(Integer times) {
+        this.times = times;
+    }
+}

+ 204 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/model/VendorIntroduction.java

@@ -0,0 +1,204 @@
+package com.uas.platform.b2c.trade.vendor.model;
+
+/**
+ * 供应商推荐实体
+ * Created by dongbw
+ * 18/01/18 15:40.
+ */
+public class VendorIntroduction {
+
+    /**
+     * 推荐的供应商UU
+     */
+    private Long enUU;
+
+    /**
+     * 推荐的供应商名称
+     */
+    private String enName;
+
+    /**
+     * 推荐的供应商简称
+     */
+    private String enShortname;
+
+    /**
+     * 推荐的供应商地址
+     */
+    private String enAddress;
+
+    /**
+     * 推荐的供应商电话
+     */
+    private String enTel;
+
+    /**
+     * 推荐的供应商邮箱
+     */
+    private String enEmail;
+
+    /**
+     * 公司法人
+     */
+    private String enCorporation;
+
+    /**
+     * 商业登记证号
+     */
+    private String enBusinesscode;
+
+    /**
+     * 行业
+     */
+    private String enProfession;
+
+    /**
+     * 主营业务
+     */
+    private String enTags;
+
+    /**
+     * 联系人
+     */
+    private String enContactman;
+
+    /**
+     * 联系人电话
+     */
+    private String enContacttel;
+
+    /**
+     * 匹配物料信息 名称(品牌)
+     */
+    private String productInfo;
+
+    /**
+     * 是否开店
+     */
+    private Short isStore;
+
+    /**
+     * 是否有有效物料
+     */
+    private Short hasProduct;
+
+    public String getProductInfo() {
+        return productInfo;
+    }
+
+    public void setProductInfo(String productInfo) {
+        this.productInfo = productInfo;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public String getEnName() {
+        return enName;
+    }
+
+    public void setEnName(String enName) {
+        this.enName = enName;
+    }
+
+    public String getEnShortname() {
+        return enShortname;
+    }
+
+    public void setEnShortname(String enShortname) {
+        this.enShortname = enShortname;
+    }
+
+    public String getEnAddress() {
+        return enAddress;
+    }
+
+    public void setEnAddress(String enAddress) {
+        this.enAddress = enAddress;
+    }
+
+    public String getEnTel() {
+        return enTel;
+    }
+
+    public void setEnTel(String enTel) {
+        this.enTel = enTel;
+    }
+
+    public String getEnEmail() {
+        return enEmail;
+    }
+
+    public void setEnEmail(String enEmail) {
+        this.enEmail = enEmail;
+    }
+
+    public String getEnCorporation() {
+        return enCorporation;
+    }
+
+    public void setEnCorporation(String enCorporation) {
+        this.enCorporation = enCorporation;
+    }
+
+    public String getEnBusinesscode() {
+        return enBusinesscode;
+    }
+
+    public void setEnBusinesscode(String enBusinesscode) {
+        this.enBusinesscode = enBusinesscode;
+    }
+
+    public String getEnProfession() {
+        return enProfession;
+    }
+
+    public void setEnProfession(String enProfession) {
+        this.enProfession = enProfession;
+    }
+
+    public String getEnTags() {
+        return enTags;
+    }
+
+    public void setEnTags(String enTags) {
+        this.enTags = enTags;
+    }
+
+    public String getEnContactman() {
+        return enContactman;
+    }
+
+    public void setEnContactman(String enContactman) {
+        this.enContactman = enContactman;
+    }
+
+    public String getEnContacttel() {
+        return enContacttel;
+    }
+
+    public void setEnContacttel(String enContacttel) {
+        this.enContacttel = enContacttel;
+    }
+
+    public Short getIsStore() {
+        return isStore;
+    }
+
+    public void setIsStore(Short isStore) {
+        this.isStore = isStore;
+    }
+
+    public Short getHasProduct() {
+        return hasProduct;
+    }
+
+    public void setHasProduct(Short hasProduct) {
+        this.hasProduct = hasProduct;
+    }
+}

+ 23 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/service/InviteVendorHistoryService.java

@@ -0,0 +1,23 @@
+package com.uas.platform.b2c.trade.vendor.service;
+
+import com.uas.platform.b2c.trade.vendor.model.InviteVendorHistory;
+
+/**
+ * @author dongbw
+ * @version  2018年4月26日 17:24:54
+ */
+public interface InviteVendorHistoryService {
+
+    /**
+     * 获取企业邀请完善信息历史记录
+     * @param vendUU 供应商UU
+     * @return 邀请历史
+     */
+    InviteVendorHistory getInviteVendorHistoryByVendUU(Long vendUU);
+
+    /**
+     * 邀请供应商完善信息
+     * @param vendUU 供应商企业UU
+     */
+    void inviteVendorByVendUU(Long vendUU) throws Exception;
+}

+ 40 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/service/VendorIntroductionService.java

@@ -0,0 +1,40 @@
+package com.uas.platform.b2c.trade.vendor.service;
+
+import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
+import com.uas.platform.b2c.trade.vendor.model.VendorIntroduction;
+import com.uas.sso.support.Page;
+
+/**
+ * The interface VendorIntroduction service.
+ * @version  2018年4月26日 17:24:54
+ */
+public interface VendorIntroductionService {
+
+
+    /**
+     * 获取供应商资源列表
+     * @param page 页码
+     * @param size 每页大小
+     * @param keyword  关键词
+     * @return 供应商资源page
+     */
+    Page<VendorIntroduction> getVendorIntroduction(int page, int size, String keyword);
+
+    /**
+     * 根据vendUU获取企业物料列表
+     * @param page 页码
+     * @param size 每页尺寸
+     * @param vendUU  可开发供应商企业UU
+     * @param keyword 关键词
+     * @return 物料page
+     */
+    Page<V_ProductPrivate> getVendorProductList(int page, int size, Long vendUU, String keyword);
+
+    /**
+     * 根据id获取物料详情
+     * @param id 物料id
+     * @return 物料信息
+     */
+    V_ProductPrivate getVendorProductDetail(Long id);
+
+}

+ 184 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/service/impl/InviteVendorHistoryServiceImpl.java

@@ -0,0 +1,184 @@
+package com.uas.platform.b2c.trade.vendor.service.impl;
+
+import com.uas.message.mail.service.MailService;
+import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
+import com.uas.platform.b2c.common.account.dao.UserDao;
+import com.uas.platform.b2c.common.account.model.Enterprise;
+import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.common.message.model.MessageModel;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.core.utils.DateFormatUtils;
+import com.uas.platform.b2c.fa.payment.utils.StringUtils;
+import com.uas.platform.b2c.trade.vendor.dao.InviteVendorHistoryDao;
+import com.uas.platform.b2c.trade.vendor.model.InviteVendorHistory;
+import com.uas.platform.b2c.trade.vendor.service.InviteVendorHistoryService;
+import com.uas.platform.core.util.HttpUtil;
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
+import org.apache.commons.collections.map.HashedMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The type InviteVendorHistoryService.
+ * @author dongbw
+ * @version  2018年4月26日 17:25:03
+ */
+@Service
+public class InviteVendorHistoryServiceImpl implements InviteVendorHistoryService {
+
+    @Autowired
+    private InviteVendorHistoryDao inviteVendorHistoryDao;
+
+    @Autowired
+    private EnterpriseDao enterpriseDao;
+
+    @Autowired
+    private UserDao userDao;
+
+    @Autowired
+    private MailService mailService;
+
+    /**
+     * 公共消息服务URL
+     */
+    @Value("#{sys.messageServiceUrl}")
+    private String messageServiceUrl;
+
+    /**
+     * 消息推送邮件模板id
+     */
+    @Value("#{message.inviteVendorMailTemplateId}")
+    private String inviteVendorMailTemplateId;
+
+    /**
+     * 消息类型 (在B2B消息中拼接跳转单据详情url请求时需要)
+     */
+    private final String INVITATION_TYPE = "供应商开发";
+
+    /**
+     * 消息推送方式:im
+     * 2018年4月28日 11:25:14 由于这里需要优先给企业邮箱发送短信,但是消息服务只能给个人邮件及短信发送,
+     * 所以这里只产生消息,邮件发送单独进行
+     */
+    private final String SMS_TYPE = "IM";
+
+    /**
+     * 消息推送方式:im和邮件
+     */
+    private final String SMS_TYPE_MAIL = "MAIL_AND_IM";
+
+    /**
+     * 来源应用,ERP
+     */
+    private final String PRODUCERAPP = "B2C";
+
+    /**
+     * 消费类型: 多个,MULTI
+     */
+    private final String CUST_TYPE = "MULTI";
+
+    /**
+     * 接收应用
+     */
+    private final String CONSUMERAPP = "B2B,MALL";
+
+    /**
+     * 获取企业邀请完善信息历史记录
+     *
+     * @param vendUU 供应商UU
+     * @return 邀请历史
+     */
+    @Override
+    public InviteVendorHistory getInviteVendorHistoryByVendUU(Long vendUU) {
+        Long enUU = SystemSession.getUser().getEnterprise().getUu();
+        if (null != enUU) {
+            return inviteVendorHistoryDao.findByEnUUAndVendUU(enUU, vendUU);
+        }
+        return null;
+    }
+
+    /**
+     * 邀请供应商完善信息
+     *
+     * @param vendUU 供应商企业UU
+     */
+    @Override
+    public void inviteVendorByVendUU(Long vendUU) throws Exception {
+        Long enUU = SystemSession.getUser().getEnterprise().getUu();
+        // 保存邀请记录
+        InviteVendorHistory inviteVendorHistory = inviteVendorHistoryDao.findByEnUUAndVendUU(enUU, vendUU);
+        if (null == inviteVendorHistory) {
+            inviteVendorHistory = new InviteVendorHistory(enUU, vendUU);
+        } else {
+            inviteVendorHistory.setDate(new Date());
+            inviteVendorHistory.setTimes(inviteVendorHistory.getTimes() + 1);
+        }
+        inviteVendorHistoryDao.save(inviteVendorHistory);
+        // 发送站内信和邮件
+        sendInvitation(vendUU);
+    }
+
+    /**
+     * 发送邮件
+     * @param vendEnEmail 供应商企业邮箱
+     */
+    private void sendMail(String vendEnEmail) {
+        Map<String, Object> map  = new HashedMap();
+        map.put("vendorname", SystemSession.getUser().getEnterprise().getEnName());
+        map.put("date",  DateFormatUtils.DATETIME_FORMAT.format(new Date()));
+        mailService.send(inviteVendorMailTemplateId, vendEnEmail, map);
+    }
+
+    /**
+     * 发送站内信和邮件
+     * @param vendUU 供应商UU
+     */
+    private void sendInvitation(Long vendUU) throws Exception {
+        Long enUU = SystemSession.getUser().getEnterprise().getUu();
+        Long userUU = SystemSession.getUser().getUserUU();
+        Enterprise enterprise = enterpriseDao.findByUu(vendUU);
+        List<MessageModel> models = new ArrayList<>();
+        if (null != enterprise) {
+            // 给管理员发送站内信
+            if (null != enterprise.getEnAdminuu()) {
+                User admin = userDao.findOne(enterprise.getEnAdminuu());
+                String content = "有客户查看您的信息,请尽快完善缺失的内容,以便获取更多商机";
+                MessageModel model = new MessageModel();
+                model.setType(INVITATION_TYPE);
+                model.setProducerApp(PRODUCERAPP);
+                model.setConsumerType(CUST_TYPE);
+                model.setConsumerApp(CONSUMERAPP);
+                model.setContent(content);
+                model.setReceiverEnuu(enterprise.getUu());
+                model.setReceiverUu(admin.getUserUU());
+                model.setSenderEnuu(enUU);
+                model.setSenderUu(userUU);
+                model.setSmsType(SMS_TYPE);
+                model.setMailTemplate(inviteVendorMailTemplateId);
+                models.add(model);
+                if (!CollectionUtils.isEmpty(models)) {
+                    HttpUtil.doPost(messageServiceUrl + "/messages", FlexJsonUtils.toJsonDeep(models));
+                }
+                // 企业邮箱为空则发管理员邮箱
+                if (StringUtils.isEmpty(enterprise.getEnEmail()) && !StringUtils.isEmpty(admin.getUserEmail())) {
+                    // 发送邮件
+                    sendMail(admin.getUserEmail());
+                }
+            }
+            // 发送通知到企业邮箱
+            if (!StringUtils.isEmpty(enterprise.getEnEmail())) {
+                // 发送邮件
+                sendMail(enterprise.getEnEmail());
+            }
+            // 发送邀请邮件, 优先企业邮箱,为空时发送管理员邮箱
+        }
+    }
+
+}

+ 175 - 0
src/main/java/com/uas/platform/b2c/trade/vendor/service/impl/VendorIntroductionServiceImpl.java

@@ -0,0 +1,175 @@
+package com.uas.platform.b2c.trade.vendor.service.impl;
+
+import com.uas.platform.b2c.common.base.dao.CommonDao;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.prod.commodity.dao.V_ProductPrivateDao;
+import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
+import com.uas.platform.b2c.trade.vendor.model.VendorIntroduction;
+import com.uas.platform.b2c.trade.vendor.service.VendorIntroductionService;
+import com.uas.sso.support.Page;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
+
+/**
+ * The type VendorIntroductionService.
+ * @version  2018年4月26日 17:25:03
+ */
+@Service
+public class VendorIntroductionServiceImpl implements VendorIntroductionService {
+
+	@Autowired
+	private CommonDao commonDao;
+
+	@Autowired
+	private V_ProductPrivateDao v_productPrivateDao;
+
+	/**
+	 * 获取供应商资源列表
+	 * @param page    页码
+	 * @param size    每页大小
+	 * @param keyword 关键词
+	 * @return 供应商资源page
+	 */
+	@Override
+	public Page<VendorIntroduction> getVendorIntroduction(int page, int size, String keyword) {
+		long start = System.currentTimeMillis();
+		Long enUU = SystemSession.getUser().getEnterprise().getUu();
+		// 查询所有物料个数
+		Integer total = getTotalCount(enUU, keyword);
+		// 查询企业
+		List<VendorIntroduction> vendorIntroductions = getEnterpriseWithCondition(enUU, keyword, page, size);
+		System.out.println("查找完企业UU" + (System.currentTimeMillis() - start));
+		return new Page<VendorIntroduction>(page, size, vendorIntroductions, total);
+	}
+
+	/**
+	 * 根据vendUU获取企业物料列表
+	 *
+	 * @param page    页码
+	 * @param size    每页尺寸
+	 * @param vendUU  可开发供应商企业UU
+	 * @param keyword 关键词
+	 * @return 物料page
+	 */
+	@Override
+	public Page<V_ProductPrivate> getVendorProductList(int page, int size, Long vendUU, String keyword) {
+		String whereCondition = " 1 = 1 ";
+		if (!StringUtils.isEmpty(keyword)) {
+			// 物料名称、规格、品牌、原厂型号、单位
+			whereCondition = " (pr_title like '%" + keyword + "%' or pr_spec like '%" + keyword + "%' or pr_brand like '%"
+					+ keyword + "%' or pr_cmpcode like '%" + keyword + "%' or pr_unit like '%" + keyword + "%' or pr_kind like '%"
+					+ keyword + "%') ";
+		}
+		long start = System.currentTimeMillis();
+		String prodSql = "select a.* from (select pr_id id, pr_code prodNum, pr_title prodName, pr_spec spec, pr_cmpcode cmpCode, pr_unit unit, pr_kind kind, "
+				+ " pr_brand brand, pr_standard standard from v$product$private where ifnull(pr_b2cenabled, 1) <> 0  and pr_enuu = "
+				+ vendUU + " and pr_issale = 1 and ifnull(pr_b2cenabled, 1) <> 0 and Pr_Title not like '%测试%' and lower(Pr_Title) not like '%test%' and Pr_code not like '%测试%' and lower(Pr_code) not like '%test%' and "
+				+ whereCondition + " order by pr_issale desc, pr_standard desc, pr_id desc) a limit " + (page - 1) * size + "," + size;
+		System.out.println("prod:" + prodSql);
+		String countSql = "select count(1) from v$product$private where pr_enuu = " + vendUU
+				+ " and pr_issale = 1 and ifnull(pr_b2cenabled, 1) <> 0  and Pr_Title not like '%测试%' and lower(Pr_Title) not like '%test%' and Pr_code not like '%测试%' and lower(Pr_code) not like '%test%' and "
+				+ whereCondition;
+		Integer count = commonDao.queryForObject(countSql, Integer.class);
+		List<V_ProductPrivate> products = commonDao.query(prodSql, V_ProductPrivate.class);
+		System.out.println("耗时" + (System.currentTimeMillis() - start));
+		return new Page<>(page, size, products, count);
+	}
+
+	/**
+	 * 根据id获取物料详情
+	 *
+	 * @param id 物料id
+	 * @return 物料信息
+	 */
+	@Override
+	public V_ProductPrivate getVendorProductDetail(Long id) {
+		return v_productPrivateDao.findOne(id);
+	}
+
+	/**
+	 * 获取供应商资源信息
+	 * @param enUU 本企业UU
+	 * @param keyword 关键词
+	 * @param page 页码
+	 * @param size 尺寸
+	 * @return
+	 */
+	private List<VendorIntroduction> getEnterpriseWithCondition(Long enUU, String keyword, int page, int size) {
+		StringBuilder enterpriseSql = new StringBuilder();
+		// 查询所有符合条件的enUU的语句,按待售物料数量排序
+		String enUUSql = getEnUUGroupByEnUUOrderByCount(enUU, keyword);
+		// 获取企业sql
+		enterpriseSql.append("select en.en_uu enUU, en.en_name enName, en.en_shortname enShortname, en.en_address enAddress, en.en_tel enTel, " +
+				"en.en_email enEmail, en.en_corporation enCorporation, en.en_businesscode enBusinesscode, en.en_profession enProfession, en.en_tags enTags " +
+				" from sec$enterprises en right join (").append(enUUSql)
+				.append(" ) a on en.en_uu = a.en_uu order by en.en_weight desc, counts desc");
+		// rownum 控制
+		String rownumSql = ") s limit " + (page - 1) * size + "," + size ;
+//		// 查询企业简要物料信息语句
+//		String prodInfoSql = "select wm_concat(pr_title || (case when pr_brand is not null then '(' || pr_brand || ')' else ' ' end)) from v$product$private where pr_enuu=en_uu and "
+//				+ " and pr_issale = 1 and pr_b2cenabled = 1 and rownum<5 ";
+		// 查询企业是否开店语句
+		// 查找非供应商的卖当前商品的企业UU
+		String vendorIntroductionUusSql = "select s.*, ( select 1 from store$info where st_enuu = enUU) isStore, " +
+                "(select 1 from v$product$private where ifnull(pr_b2cenabled, 1) = 1 and pr_enuu = enUU) hasProduct from ("
+				+ enterpriseSql + rownumSql;
+//		String vendorIntroductionUusSql = "select s.*,( " + prodInfoSql + ") productInfo, (" + storeSql +
+//				") isStore from (select t.*,rownum as r1 from (" + enterpriseSql + rownumSql;
+		return commonDao.query(vendorIntroductionUusSql, VendorIntroduction.class);
+	}
+
+	/**
+	 * 获取所有符合条件企业数量
+	 * @param enUU  本企业UU
+	 * @param keyword 关键词
+	 * @return
+	 */
+	private Integer getTotalCount(Long enUU, String keyword) {
+		StringBuilder enCountSql = new StringBuilder();
+		// 含名称、地址、、行业、经营范围搜索 物料型号、名称
+		if (!StringUtils.isEmpty(keyword)) {
+			String keywordSql = getKeywordSql(enUU, keyword);
+			enCountSql.append("select count(1) from (select count(1) from ").append(keywordSql);
+		} else {
+			enCountSql.append("select count(1) from (select count(1) from (select * from sec$enterprises where en_name not like '%测试%' " +
+					" and lower(en_name) not like '%test%') en left join products on en.en_uu = pr_enuu where en_uu <> ").append(enUU);
+		}
+		enCountSql.append(" group by en_uu ) a");
+		return commonDao.queryForObject(enCountSql.toString(), Integer.class);
+	}
+
+	/**
+	 * 拼接关键词Sql
+	 * @param enUU
+	 * @param keyword
+	 * @return
+	 */
+	private String getKeywordSql(Long enUU, String keyword) {
+		return "(select * from sec$enterprises where en_name not like '%测试%' and lower(en_name) not like '%test%' and (en_name like '%"
+				+ keyword + "%' or en_address like '%" + keyword + "%' or en_tags like '%" + keyword + "%' or en_profession like '%" + keyword
+				+ "%')) en left join (select * from products where pr_cmpcode like '%" + keyword + "%' or pr_brand like '%" + keyword
+				+ "%') pr on en.en_uu = pr.pr_enuu where en_uu <> " + enUU;
+	}
+
+	/**
+	 * 拼接所有待售物料所属企业UU,按enUU分组,按物料数量倒序
+	 * @param enUU 当前企业UU
+	 * @param keyword 搜索关键词
+	 * @return
+	 */
+	private String getEnUUGroupByEnUUOrderByCount(Long enUU, String keyword) {
+		StringBuilder enUUSql = new StringBuilder();
+		// 含名称、企业执照号、地址、邮箱、电话、行业、经营范围搜索
+		if (!StringUtils.isEmpty(keyword)) {
+			enUUSql.append("select en_uu, count(1) as counts from ").append(getKeywordSql(enUU, keyword));
+		} else {
+			enUUSql.append("select en_uu, count(1) as counts from (select * from sec$enterprises where en_name not like '%测试%' " +
+					" and lower(en_name) not like '%test%') en left join products on en.en_uu = pr_enuu where en.en_uu <> ").append(enUU);
+		}
+		enUUSql.append(" group by en_uu order by count(1) desc ");
+		return enUUSql.toString();
+	}
+}

+ 2 - 1
src/main/resources/dev/message.properties

@@ -4,4 +4,5 @@ plaformB2cBrandApprovedTemplateId=5b5effdf-5562-45f7-9021-18f21e29bec6
 plaformB2cBrandUnproveTemplateId=03b3d658-cd92-43a0-a53f-103492cfc595
 plaformB2cComponentApprovedTemplateId=36812a85-d0f9-4d2a-a7aa-62319f092b6f
 plaformB2cComponentUnproveTemplateId=6228240a-93ba-405f-851c-f874a6c99864
-plaformB2cSupplyChainTemplateId=b28337ba-f115-4f11-b457-15d558443160
+plaformB2cSupplyChainTemplateId=b28337ba-f115-4f11-b457-15d558443160
+inviteVendorMailTemplateId=9028790a-9fc0-4759-a2df-8c26a7f3aa9a

+ 3 - 0
src/main/resources/dev/sys.properties

@@ -49,6 +49,9 @@ kafka-bootstrap-servers=10.10.100.11:9292,10.10.100.12:9292,10.10.100.13:9292,10
 inquiryServiceUrl=http://218.17.158.219:24000
 inquiryServiceInnerUrl=http://218.17.158.219:24000
 
+#public message  service url
+messageServiceUrl=http://192.168.253.12:24000/message/
+
 #b2b
 b2b=http://218.17.158.219/b2b_test
 b2bDomain=218.17.158.219:9000/b2b_test

+ 2 - 1
src/main/resources/prod/message.properties

@@ -4,4 +4,5 @@ plaformB2cBrandApprovedTemplateId=5b5effdf-5562-45f7-9021-18f21e29bec6
 plaformB2cBrandUnproveTemplateId=03b3d658-cd92-43a0-a53f-103492cfc595
 plaformB2cComponentApprovedTemplateId=36812a85-d0f9-4d2a-a7aa-62319f092b6f
 plaformB2cComponentUnproveTemplateId=6228240a-93ba-405f-851c-f874a6c99864
-plaformB2cSupplyChainTemplateId=b28337ba-f115-4f11-b457-15d558443160
+plaformB2cSupplyChainTemplateId=b28337ba-f115-4f11-b457-15d558443160
+inviteVendorMailTemplateId=9028790a-9fc0-4759-a2df-8c26a7f3aa9a

+ 3 - 0
src/main/resources/prod/sys.properties

@@ -51,6 +51,9 @@ kafka-bootstrap-servers=10.10.100.11:9292,10.10.100.12:9292,10.10.100.13:9292,10
 inquiryServiceUrl=https://api-inquiry.usoftmall.com
 inquiryServiceInnerUrl=http://10.10.0.254:8080
 
+#public message  service url
+messageServiceUrl=http://api-message.ubtob.com/
+
 #b2b
 b2b=http://uas.ubtob.com
 b2bDomain=uas.ubtob.com

+ 2 - 1
src/main/resources/test/message.properties

@@ -4,4 +4,5 @@ plaformB2cBrandApprovedTemplateId=5b5effdf-5562-45f7-9021-18f21e29bec6
 plaformB2cBrandUnproveTemplateId=03b3d658-cd92-43a0-a53f-103492cfc595
 plaformB2cComponentApprovedTemplateId=36812a85-d0f9-4d2a-a7aa-62319f092b6f
 plaformB2cComponentUnproveTemplateId=6228240a-93ba-405f-851c-f874a6c99864
-plaformB2cSupplyChainTemplateId=b28337ba-f115-4f11-b457-15d558443160
+plaformB2cSupplyChainTemplateId=b28337ba-f115-4f11-b457-15d558443160
+inviteVendorMailTemplateId=9028790a-9fc0-4759-a2df-8c26a7f3aa9a

+ 3 - 0
src/main/resources/test/sys.properties

@@ -50,6 +50,9 @@ kafka-bootstrap-servers=10.10.100.11:9292,10.10.100.12:9292,10.10.100.13:9292,10
 inquiryServiceUrl=http://218.17.158.219:24000
 inquiryServiceInnerUrl=http://218.17.158.219:24000
 
+#public message  service url
+messageServiceUrl=http://192.168.253.12:24000/message/
+
 #b2b
 b2b=http://218.17.158.219/b2b_test
 b2bDomain=218.17.158.219:9000/b2b_test