Browse Source

Merge remote-tracking branch 'origin/developerF' into developerA

zhijiezhao 2 years ago
parent
commit
e3ee42f94f

+ 53 - 1
src/main/java/com/caimei/modules/baike/service/CmBaikeProductService.java

@@ -12,7 +12,13 @@ import com.caimei.modules.basesetting.dao.KeywordDao;
 import com.caimei.modules.info.entity.Info;
 import com.caimei.modules.miniprogram.utils.UploadPicUtils;
 import com.caimei.modules.oss.utils.OSSUtils;
+import com.caimei.modules.utils.RequestUtil;
+import com.caimei.modules.utils.message.InsideMessage;
+import com.caimei.modules.utils.message.MessageModel;
+import com.caimei.modules.utils.message.MqInfo;
+import com.caimei.modules.utils.message.enums.MessageType;
 import com.caimei.utils.StringUtil;
+import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.utils.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -142,12 +148,37 @@ public class CmBaikeProductService extends CrudService<CmBaikeProductDao, CmBaik
 
         // 管理员审核百科
         if (null != cmBaikeProduct.getAuditFlag() && 1 == cmBaikeProduct.getAuditFlag()) {
-            cmBaikeProduct.setOnlineStatus(3);
+            //站内信
+            MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+            insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                    .mqInfo(new MqInfo().topic("MessageLine").delay(1).async(0));
             if (null != cmBaikeProduct.getAuditStatus() && 2 == cmBaikeProduct.getAuditStatus()) {
                 // 审核通过
                 cmBaikeProduct.setOnlineStatus(2);
                 cmBaikeProduct.setPublishTime(new Date());
+                insideMessageMessageModel
+                        .info(new InsideMessage()
+                                .shopId(cmBaikeProduct.getShopId())
+                                .userType(2)
+                                .messageType(2)
+                                .shopMessType(6)
+                                .productId(Integer.valueOf(cmBaikeProduct.getId()))
+                                .content(cmBaikeProduct.getName()));
+
+            } else {
+                // 审核不通过
+                cmBaikeProduct.setOnlineStatus(3);
+                insideMessageMessageModel
+                        .info(new InsideMessage()
+                                .shopId(cmBaikeProduct.getShopId())
+                                .userType(2)
+                                .messageType(2)
+                                .shopMessType(7)
+                                .content(cmBaikeProduct.getName())
+                                .reasonContent(cmBaikeProduct.getFailReason()));
+
             }
+            sendExamine(insideMessageMessageModel);
         }
         // 标签
         String[] labelIds = StringUtils.split(cmBaikeProduct.getLabelIds(), ",");
@@ -249,6 +280,27 @@ public class CmBaikeProductService extends CrudService<CmBaikeProductDao, CmBaik
 //		});
     }
 
+    private void sendExamine(MessageModel<InsideMessage> model) {
+        StringBuilder map = new StringBuilder("{ \"code\": \"WEB_INSIDE_MESSAGE\"," +
+                "\"mqInfo\": {\"topic\": \"MessageLine\",\"delay\": 3,\"async\":0}," +
+                "\"info\": ");
+        map.append("{ \"content\": \"" + model.info().content() +
+                "\",\"shopId\": " + model.info().shopId() +
+                ",\"userType\":" + model.info().userType() +
+                ",\"messageType\":" + model.info().messageType());
+        if (null != model.info().shopMessType()) {
+            map.append(",\"shopMessType\":" + model.info().shopMessType());
+        } else {
+            map.append(",\"reasonContent\":\"" + model.info().reasonContent() + "\"");
+        }
+        map.append("}}");
+        try {
+            System.out.println(RequestUtil.httpPost(Global.getConfig("caimei.core")+"/tools/message/send", String.valueOf(map)));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     private void saveTime(CmBaikeProduct cmBaikeProduct) {
         Integer marketYear = cmBaikeProduct.getMarketYear();
         Integer marketMonth = cmBaikeProduct.getMarketMonth();

+ 51 - 1
src/main/java/com/caimei/modules/info/service/InfoService.java

@@ -8,6 +8,11 @@ import javax.servlet.http.HttpServletRequest;
 import com.caimei.modules.basesetting.dao.KeywordDao;
 import com.caimei.modules.live.entity.NewPageLive;
 import com.caimei.modules.sys.utils.UploadImageUtils;
+import com.caimei.modules.utils.RequestUtil;
+import com.caimei.modules.utils.message.InsideMessage;
+import com.caimei.modules.utils.message.MessageModel;
+import com.caimei.modules.utils.message.MqInfo;
+import com.caimei.modules.utils.message.enums.MessageType;
 import org.apache.commons.collections.CollectionUtils;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
@@ -178,12 +183,36 @@ public class InfoService extends CrudService<InfoDao, Info> {
 
         // 管理员审核文章
         if (null != info.getAuditFlag() && 1 == info.getAuditFlag()) {
-            info.setOnlineStatus(3);
+            //站内信
+            MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+            insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                    .mqInfo(new MqInfo().topic("MessageLine").delay(1).async(0));
             if (null != info.getAuditStatus() && 2 == info.getAuditStatus()) {
                 // 审核通过
                 info.setPubdate(new Date());
                 info.setOnlineStatus(2);
+                insideMessageMessageModel
+                        .info(new InsideMessage()
+                                .shopId(info.getShopId())
+                                .userType(2)
+                                .messageType(2)
+                                .shopMessType(8)
+                                .productId(Integer.valueOf(info.getId()))
+                                .content(info.getTitle()));
+            } else {
+                // 审核不通过
+                info.setOnlineStatus(3);
+                insideMessageMessageModel
+                        .info(new InsideMessage()
+                                .shopId(info.getShopId())
+                                .userType(2)
+                                .messageType(2)
+                                .shopMessType(9)
+                                .content(info.getTitle())
+                                .reasonContent(info.getFailReason()));
+
             }
+            sendExamine(insideMessageMessageModel);
         }
         super.save(info);
 
@@ -198,6 +227,27 @@ public class InfoService extends CrudService<InfoDao, Info> {
         infoDao.insertInfoPage(info.getId(), sp);
     }
 
+    private void sendExamine(MessageModel<InsideMessage> model) {
+        StringBuilder map = new StringBuilder("{ \"code\": \"WEB_INSIDE_MESSAGE\"," +
+                "\"mqInfo\": {\"topic\": \"MessageLine\",\"delay\": 3,\"async\":0}," +
+                "\"info\": ");
+        map.append("{ \"content\": \"" + model.info().content() +
+                "\",\"shopId\": " + model.info().shopId() +
+                ",\"userType\":" + model.info().userType() +
+                ",\"messageType\":" + model.info().messageType());
+        if (null != model.info().shopMessType()) {
+            map.append(",\"shopMessType\":" + model.info().shopMessType());
+        } else {
+            map.append(",\"reasonContent\":\"" + model.info().reasonContent() + "\"");
+        }
+        map.append("}}");
+        try {
+            System.out.println(RequestUtil.httpPost(Global.getConfig("caimei.core")+"/tools/message/send", String.valueOf(map)));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     @Transactional(readOnly = false)
     public void delete(Info info) {
 //		super.delete(info);

+ 0 - 1
src/main/java/com/caimei/modules/newhome/entity/Announcementmanagement.java

@@ -4,7 +4,6 @@ package com.caimei.modules.newhome.entity;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.thinkgem.jeesite.common.persistence.DataEntity;
 
-import java.sql.Timestamp;
 import java.util.Date;
 
 

+ 1 - 1
src/main/java/com/caimei/modules/product/dao/ProductDao.java

@@ -166,7 +166,7 @@ public interface ProductDao extends CrudDao<Product> {
 
     void deleteLadderPriceByProductId(Integer productID);
 
-    void deleteLadderPriceById(Integer productId);
+    void deleteLadderPriceById(@Param("skuId") Integer skuId,@Param("productId")Integer productId);
 
     List<Product> findActList(Product product);
 

+ 8 - 2
src/main/java/com/caimei/modules/product/service/ProductService.java

@@ -470,7 +470,6 @@ public class ProductService extends CrudService<ProductDao, Product> {
     private void updateSku(Product product) {
         List<CmSku> skuList = product.getSkuList();
         if (null != skuList && skuList.size() > 0) {
-            productDao.deleteLadderPriceById(product.getProductID());
             List<Integer> skuIds = new ArrayList<>();
             skuList.forEach(s -> {
                 if (null != s.getPrice()) {
@@ -484,6 +483,9 @@ public class ProductService extends CrudService<ProductDao, Product> {
                         productDao.insertSku(s);
                         skuIds.add(s.getSkuId());
                     }
+                    if (s.getLadderPriceFlag()==1) {
+                        productDao.deleteLadderPriceById(s.getSkuId(),s.getProductId());
+                    }
                     if (null != s.ladderPriceFlag() && 1 == s.ladderPriceFlag()) {
                         List<CmLadderPrice> cmLadderPrices = s.ladderPriceList();
                         for (int i = 0; i < cmLadderPrices.size(); i++) {
@@ -504,11 +506,15 @@ public class ProductService extends CrudService<ProductDao, Product> {
         //保存sku
         List<CmSku> skuList = product.getSkuList();
         if (null != skuList && skuList.size() > 0) {
-            productDao.deleteLadderPriceById(product.getProductID());
+//            productDao.deleteLadderPriceById(product.getProductID());
             skuList.forEach(s -> {
+
                 if (null != s.getPrice()) {
                     s.productId(product.getProductID());
                     productDao.insertSku(s);
+                    if (s.getLadderPriceFlag().equals("1")) {
+                        productDao.deleteLadderPriceById(s.getSkuId(),s.getProductId());
+                    }
                     if (null != s.ladderPriceFlag() && 1 == s.ladderPriceFlag()) {
                         List<CmLadderPrice> cmLadderPrices = s.ladderPriceList();
                         for (int i = 0; i < cmLadderPrices.size(); i++) {

+ 58 - 1
src/main/java/com/caimei/modules/utils/RequestUtil.java

@@ -1,5 +1,8 @@
 package com.caimei.modules.utils;
 
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.util.StringUtils;
 
 import javax.net.ssl.HttpsURLConnection;
@@ -7,6 +10,7 @@ import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
 import java.io.*;
+import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
 import java.nio.charset.StandardCharsets;
@@ -20,8 +24,12 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/3/8
  */
-public class RequestUtil {
 
+public class RequestUtil {
+    /**
+     * 日志对象
+     */
+    protected static Logger logger = LoggerFactory.getLogger(RequestUtil.class);
     /**
      * 向指定URL发送GET方法的请求
      *
@@ -62,6 +70,55 @@ public class RequestUtil {
         }
         return result.toString();
     }
+    public static String httpPost(String requestUrl, String requestData)  throws Exception{
+
+        try {
+            URL url = new URL(requestUrl);
+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+            conn.setDoOutput(true);
+            conn.setDoInput(true);
+            conn.setUseCaches(false);
+            conn.setRequestMethod("POST");
+            conn.setRequestProperty("Connection", "Keep-Alive");
+            conn.setRequestProperty("Charset", "UTF-8");
+            conn.setRequestProperty("Accept-Charset", "utf-8");
+            // 这里的数据类型是XML,你可以根据自己的需求去改
+            conn.setRequestProperty("Content-Type", "application/json");
+            conn.setRequestProperty("Content-Length", String.valueOf(requestData.length()));
+            conn.setRequestProperty("Cache-Control", "no-cache");
+            // 设置发起连接的等待时间,3s
+            conn.setConnectTimeout(3000);
+            // 设置数据读取超时的时间,30s
+            conn.setReadTimeout(30000);
+            OutputStream out = conn.getOutputStream();
+            out.write(requestData.getBytes(StandardCharsets.UTF_8));
+
+            out.flush();
+            out.close();
+            // 请求返回的状态
+            int httpStatus200 = 200;
+            if (conn.getResponseCode() == httpStatus200) {
+                logger.error("数据发送成功");
+                // 请求返回的数据
+                InputStream in = conn.getInputStream();
+                try {
+                    byte[] responseData = new byte[in.available()];
+                    in.read(responseData);
+                    return new String(responseData, StandardCharsets.UTF_8);
+                } catch (Exception e) {
+                    logger.error("响应数据解析失败==="+e);
+                    e.printStackTrace();
+                }
+            } else {
+                logger.error("数据发送失败");
+                return null;
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
 
     /**
      * 向指定 URL 发送POST方法的请求

+ 75 - 0
src/main/java/com/caimei/modules/utils/message/EmailMessage.java

@@ -0,0 +1,75 @@
+package com.caimei.modules.utils.message;
+
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Email;
+
+//import javax.validation.constraints.Email;
+import javax.validation.constraints.NotNull;
+
+@Data
+@Accessors(fluent = true)
+@NoArgsConstructor
+@ToString
+public class EmailMessage {
+    /**
+     * 邮件主题
+     */
+    @NotNull
+    private String subject;
+    /**
+     * 收件人地址
+     */
+    @NotNull
+    @Email
+    private String receiverAddress;
+    /**
+     * 内容
+     */
+    @NotNull
+    private String emailMessageContent;
+    /**
+     * 抄送地址
+     */
+    private String[] cc;
+
+    public EmailMessage cc(String cc) {
+        this.cc = new String[]{cc};
+        return this;
+    }
+
+    public String getSubject() {
+        return subject;
+    }
+
+    public void setSubject(String subject) {
+        this.subject = subject;
+    }
+
+    public String getReceiverAddress() {
+        return receiverAddress;
+    }
+
+    public void setReceiverAddress(String receiverAddress) {
+        this.receiverAddress = receiverAddress;
+    }
+
+    public String getEmailMessageContent() {
+        return emailMessageContent;
+    }
+
+    public void setEmailMessageContent(String emailMessageContent) {
+        this.emailMessageContent = emailMessageContent;
+    }
+
+    public String[] getCc() {
+        return cc;
+    }
+
+    public void setCc(String[] cc) {
+        this.cc = cc;
+    }
+}

+ 310 - 0
src/main/java/com/caimei/modules/utils/message/InsideMessage.java

@@ -0,0 +1,310 @@
+package com.caimei.modules.utils.message;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @author Administrator
+ * 站内信model
+ */
+@Data
+@Accessors(fluent = true)
+public class InsideMessage implements Serializable {
+
+    /**
+     * 消息id
+     */
+    private Integer id;
+    /**
+     * 供应商id
+     */
+    private Integer shopId;
+    /**
+     * 机构id
+     */
+    private Integer clubId;
+    /**
+     * 订单ID
+     */
+    private Integer orderId;
+    /**
+     * 用户类型1.机构2.供应商
+     */
+    private Integer userType;
+    /**
+     * 消息类型1.交易物流2.账户通知3.服务通知4.优惠促销
+     */
+    private Integer messageType;
+    /**
+     * 消息内容
+     */
+    private String content;
+    /**
+     * 失败原因
+     */
+    private String reasonContent;
+    /**
+     * 操作完成时间
+     */
+    private String time;
+    /**
+     * 账户通知类型 1.注册成功通知 2.购买超级会员成功 3.超级会员到期提醒 4.超级会员到期提醒 5.升级资质机构成功 6.升级资质机构失败 7.成为机构运营人员通知
+     */
+    private Integer accountType;
+    /**
+     * 优惠券类型 1.优惠券待领取通知 2.优惠券过期通知
+     */
+    private Integer couponType;
+    /**
+     * 优惠券金额
+     */
+    private Double couponFee;
+    /**
+     * 主图
+     */
+    private String mainImage;
+    /**
+     * 是否能走线上支付 0可以 1不可以 只能线下
+     */
+    private Integer onlinePayFlag;
+    /**
+     * 商品名称
+     */
+    private String productName;
+    /**
+     * 供应商消息类型 1,账号审核通知,2.成为公司运营人员通知,3.商品上架审核通知,4.新品展示审核通知,5.上架费到期通知 6.商品资质到期通知
+     */
+    private Integer shopMessType;
+    /**
+     * 供应商服务消息类型 1.上架费
+     */
+    private Integer shopTieredType;
+    /**
+     * 交易物流1.下单成功通知  2.订单支付完成 3.退款/货成功通知 4.订单取消通知 5.订单发货通知 6.自动收货通知
+     */
+    private Integer orderMessageType;
+    /**
+     * 0.未读 , 1.已读
+     */
+    private Integer saved;
+    /**
+     * 优惠券类型 1.优惠券待领取通知 2.优惠券过期通知
+     */
+    private Integer couponMessageType;
+    /**
+     * 商品记录数
+     */
+    private Integer productCount;
+    /**
+     * 退货退款类型:1部分退、2全部退
+     */
+    private Integer refundType;
+
+    /**
+     * 订单状态
+     */
+    private Integer status;
+    /**
+     * 商品ID
+     */
+    private Integer productId;
+
+    /**
+     * 供应商公司名称
+     */
+    private String shopName;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(Integer shopId) {
+        this.shopId = shopId;
+    }
+
+    public Integer getClubId() {
+        return clubId;
+    }
+
+    public void setClubId(Integer clubId) {
+        this.clubId = clubId;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getUserType() {
+        return userType;
+    }
+
+    public void setUserType(Integer userType) {
+        this.userType = userType;
+    }
+
+    public Integer getMessageType() {
+        return messageType;
+    }
+
+    public void setMessageType(Integer messageType) {
+        this.messageType = messageType;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+
+    public Integer getAccountType() {
+        return accountType;
+    }
+
+    public void setAccountType(Integer accountType) {
+        this.accountType = accountType;
+    }
+
+    public Integer getCouponType() {
+        return couponType;
+    }
+
+    public void setCouponType(Integer couponType) {
+        this.couponType = couponType;
+    }
+
+    public Double getCouponFee() {
+        return couponFee;
+    }
+
+    public void setCouponFee(Double couponFee) {
+        this.couponFee = couponFee;
+    }
+
+    public String getMainImage() {
+        return mainImage;
+    }
+
+    public void setMainImage(String mainImage) {
+        this.mainImage = mainImage;
+    }
+
+    public Integer getOnlinePayFlag() {
+        return onlinePayFlag;
+    }
+
+    public void setOnlinePayFlag(Integer onlinePayFlag) {
+        this.onlinePayFlag = onlinePayFlag;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    public Integer getShopMessType() {
+        return shopMessType;
+    }
+
+    public void setShopMessType(Integer shopMessType) {
+        this.shopMessType = shopMessType;
+    }
+
+    public Integer getShopTieredType() {
+        return shopTieredType;
+    }
+
+    public void setShopTieredType(Integer shopTieredType) {
+        this.shopTieredType = shopTieredType;
+    }
+
+    public Integer getOrderMessageType() {
+        return orderMessageType;
+    }
+
+    public void setOrderMessageType(Integer orderMessageType) {
+        this.orderMessageType = orderMessageType;
+    }
+
+    public Integer getSaved() {
+        return saved;
+    }
+
+    public void setSaved(Integer saved) {
+        this.saved = saved;
+    }
+
+    public Integer getCouponMessageType() {
+        return couponMessageType;
+    }
+
+    public void setCouponMessageType(Integer couponMessageType) {
+        this.couponMessageType = couponMessageType;
+    }
+
+    public Integer getProductCount() {
+        return productCount;
+    }
+
+    public void setProductCount(Integer productCount) {
+        this.productCount = productCount;
+    }
+
+    public Integer getRefundType() {
+        return refundType;
+    }
+
+    public void setRefundType(Integer refundType) {
+        this.refundType = refundType;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
+}

+ 44 - 0
src/main/java/com/caimei/modules/utils/message/MessageModel.java

@@ -0,0 +1,44 @@
+package com.caimei.modules.utils.message;
+
+import com.caimei.modules.utils.message.enums.MessageType;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+/**
+ * @author Administrator
+ */
+@Data
+@Accessors(fluent = true)
+@NoArgsConstructor
+public class MessageModel<T> {
+    private MessageType code;
+
+    private MqInfo mqInfo;
+
+    private T info;
+
+    public MessageType getCode() {
+        return code;
+    }
+
+    public void setCode(MessageType code) {
+        this.code = code;
+    }
+
+    public MqInfo getMqInfo() {
+        return mqInfo;
+    }
+
+    public void setMqInfo(MqInfo mqInfo) {
+        this.mqInfo = mqInfo;
+    }
+
+    public T getInfo() {
+        return info;
+    }
+
+    public void setInfo(T info) {
+        this.info = info;
+    }
+}

+ 65 - 0
src/main/java/com/caimei/modules/utils/message/MqInfo.java

@@ -0,0 +1,65 @@
+package com.caimei.modules.utils.message;
+
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Range;
+
+
+@Data
+@Accessors(fluent = true)
+public class MqInfo {
+    /**
+     * 异步消息(可选):1是,0否
+     */
+    @Range(min = 0, max = 1)
+    private Integer async;
+
+    /**
+     * 1-18,0否,对应时间依次:1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
+     */
+    @Range(min = 0, max = 18)
+    private Integer delay;
+
+    /**
+     * 消息主题
+     */
+    private String topic;
+
+    /**
+     * 消息标签(可选)
+     */
+    private String tag;
+
+    public Integer getAsync() {
+        return async;
+    }
+
+    public void setAsync(Integer async) {
+        this.async = async;
+    }
+
+    public Integer getDelay() {
+        return delay;
+    }
+
+    public void setDelay(Integer delay) {
+        this.delay = delay;
+    }
+
+    public String getTopic() {
+        return topic;
+    }
+
+    public void setTopic(String topic) {
+        this.topic = topic;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+}

+ 53 - 0
src/main/java/com/caimei/modules/utils/message/SmsMessage.java

@@ -0,0 +1,53 @@
+package com.caimei.modules.utils.message;
+
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@Accessors(fluent = true)
+@NoArgsConstructor
+public class SmsMessage {
+    /**
+     * 短信类型:1通知短信,2验证码短信,3营销短信
+     */
+    @NotNull
+    private Integer type;
+    /**
+     *  手机号   接收的手机号;多个手机号使用英文逗号间隔,一次不要超过1000个;
+     */
+    @NotNull
+    private String mobile ;
+    /**
+     * 短信内容
+     */
+    @NotNull
+    private String smsMessageContent;
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getSmsMessageContent() {
+        return smsMessageContent;
+    }
+
+    public void setSmsMessageContent(String smsMessageContent) {
+        this.smsMessageContent = smsMessageContent;
+    }
+}

+ 232 - 0
src/main/java/com/caimei/modules/utils/message/WechatTemplateMessage.java

@@ -0,0 +1,232 @@
+package com.caimei.modules.utils.message;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@Accessors(fluent = true)
+@AllArgsConstructor
+@NoArgsConstructor
+public class WechatTemplateMessage {
+    /**
+     *  {
+     *            "touser":"OPENID",
+     *            "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY",
+     *            "url":"http://weixin.qq.com/download",
+     *            "miniprogram":{
+     *              "appid":"xiaochengxuappid12345",
+     *              "pagepath":"index?foo=bar"
+     *            },
+     *            "client_msg_id":"MSG_000001",
+     *            "data":{
+     *                    "first": {
+     *                        "value":"恭喜你购买成功!",
+     *                        "color":"#173177"
+     *                    },
+     *                    "keyword1":{
+     *                        "value":"巧克力",
+     *                        "color":"#173177"
+     *                    },
+     *                    "keyword2": {
+     *                        "value":"39.8元",
+     *                        "color":"#173177"
+     *                    },
+     *                    "keyword3": {
+     *                        "value":"2014年9月22日",
+     *                        "color":"#173177"
+     *                    },
+     *                    "remark":{
+     *                        "value":"欢迎再次购买!",
+     *                        "color":"#173177"
+     *                    }
+     *            }
+     *        }
+     */
+
+    /**
+     * 推送内容抬头
+     */
+    @NotNull
+    private JSONObject first;
+    /**
+     * 推送内容
+     */
+    @NotNull
+    private List<JSONObject> keyWords;
+    /**
+     * 推送内容页尾
+     */
+    @NotNull
+    private JSONObject remark;
+    /**
+     * 所需跳转到的小程序appid(该小程序 appid 必须与发模板消息的公众号是绑定关联关系,暂不支持小游戏)
+     */
+    private String appid;
+
+    /**
+     * 接收者openid
+     */
+    @NotNull
+    private String openId;
+    /**
+     * 模板ID
+     */
+    @NotNull
+    private String templateId;
+    /**
+     * 模板跳转链接
+     */
+    private String url;
+    /**
+     * 所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar),要求该小程序已发布,暂不支持小游戏
+     */
+    private String pagePath;
+
+
+    /**
+     * 跳小程序所需数据,不需跳小程序可不用传该数据
+     */
+    private JSONObject miniProgram;
+    /**
+     * 模板数据
+     */
+    private JSONObject data;
+    private JSONObject json;
+
+    public JSONObject getFirst() {
+        return first;
+    }
+
+    public void setFirst(JSONObject first) {
+        this.first = first;
+    }
+
+    public List<JSONObject> getKeyWords() {
+        return keyWords;
+    }
+
+
+    public JSONObject getRemark() {
+        return remark;
+    }
+
+    public void setRemark(JSONObject remark) {
+        this.remark = remark;
+    }
+
+    public String getAppid() {
+        return appid;
+    }
+
+    public void setAppid(String appid) {
+        this.appid = appid;
+    }
+
+    public String getOpenId() {
+        return openId;
+    }
+
+    public void setOpenId(String openId) {
+        this.openId = openId;
+    }
+
+    public String getTemplateId() {
+        return templateId;
+    }
+
+    public void setTemplateId(String templateId) {
+        this.templateId = templateId;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getPagePath() {
+        return pagePath;
+    }
+
+    public void setPagePath(String pagePath) {
+        this.pagePath = pagePath;
+    }
+
+    public WechatTemplateMessage first(String title) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("value", title);
+        this.setFirst(jsonObject);
+        return this;
+    }
+
+    public WechatTemplateMessage keyWords(List<String> words) {
+        List<JSONObject> collect = new ArrayList<>();
+        words.forEach(w -> {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("value", w);
+            collect.add(jsonObject);
+        });
+        this.setKeyWords(collect);
+        return this;
+    }
+
+    public void setKeyWords(List<JSONObject> keyWords) {
+        this.keyWords = keyWords;
+    }
+
+    public WechatTemplateMessage remark(String r) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("value", r);
+        this.setRemark(jsonObject);
+        return this;
+    }
+
+    public JSONObject getMiniProgram() {
+        return miniProgram;
+    }
+
+    private void setMiniProgram(JSONObject miniProgram) {
+        this.miniProgram = miniProgram;
+    }
+
+    private JSONObject getData() {
+        return data;
+    }
+
+    private void setData(JSONObject data) {
+        this.data = data;
+    }
+
+    public String getJson() {
+        JSONObject json = new JSONObject();
+        json.put("touser", openId);
+        json.put("template_id", templateId);
+        json.put("url", url);
+
+        JSONObject miniProgram = new JSONObject();
+        miniProgram.put("appid", appid);
+        miniProgram.put("pagepath", pagePath);
+        json.put("miniprogram", miniProgram);
+
+        JSONObject data = new JSONObject();
+        data.put("first", first);
+        if (!keyWords.isEmpty()) {
+            for (int i = 0; i < keyWords.size(); i++) {
+                String key = "keyword" + (i + 1);
+                data.put(key, keyWords.get(i));
+            }
+        }
+        data.put("remark", remark);
+        json.put("data", data);
+        return json.toJSONString();
+    }
+}

+ 41 - 0
src/main/java/com/caimei/modules/utils/message/enums/MessageType.java

@@ -0,0 +1,41 @@
+package com.caimei.modules.utils.message.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.ToString;
+
+/**
+ * @author Administrator
+ */
+
+@ToString
+@AllArgsConstructor
+public enum MessageType {
+    /**
+     * 1.微信模板消息
+     * 2.站内消息
+     * 3.邮件
+     * 4.短信
+     */
+    WECHAT_TEMPLATE_MESSAGE(1, "微信模板消息"),
+    WEB_INSIDE_MESSAGE(2, "站内消息"),
+    EMAILS(3, "邮件"),
+    SYS_MESSAGE(4, "短信");
+    private Integer code;
+    private String description;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}

+ 36 - 0
src/main/java/com/caimei/modules/utils/message/enums/SmsMessageType.java

@@ -0,0 +1,36 @@
+package com.caimei.modules.utils.message.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.ToString;
+
+@ToString
+@AllArgsConstructor
+public enum SmsMessageType {
+    /**
+     * 1通知短信
+     * 2验证码短信
+     * 3营销短信
+     */
+    NOTIFICATION_SMS(1, "通知短信"),
+    CHECK_CODE_SMS(2, "验证码短信"),
+    SALES_SMS(3, "营销短信");
+
+    private Integer code;
+    private String description;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}

+ 7 - 7
src/main/resources/config/dev/caimei.properties

@@ -12,15 +12,15 @@
 #mysql database setting
 jdbc.type=mysql
 jdbc.driver=com.mysql.cj.jdbc.Driver
-jdbc.url=jdbc:mysql://120.79.25.27:3306/caimei?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
-jdbc.username=developer
-jdbc.password=J5p3tgOVazNl4ydf
-
-
-#jdbc.url=jdbc:mysql://120.79.25.27:3306/caimei?characterEncoding=UTF8&serverTimezone=Asia/Shanghai
+#jdbc.url=jdbc:mysql://120.79.25.27:3306/caimei?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
 #jdbc.username=developer
 #jdbc.password=J5p3tgOVazNl4ydf
 
+
+jdbc.url=jdbc:mysql://192.168.2.100:3306/caimei?characterEncoding=UTF8&serverTimezone=Asia/Shanghai
+jdbc.username=developer
+jdbc.password=05bZ/OxTB:X+yd%1
+
 #jdbc.url=jdbc:mysql://119.29.0.46:3306/caimei?useUnicode=true&characterEncoding=utf-8
 #jdbc.username=root
 #jdbc.password=caimeiRoot2016
@@ -189,7 +189,7 @@ export.template=export
 
 # SPI-server\uFF08CKEditor5\u56FE\u7247\u4E0A\u4F20API\uFF0C\u641C\u7D22\u66F4\u65B0\u7D22\u5F15\uFF09
 caimei.spi=http://localhost:8008
-caimei.core=https://localhost:18002
+caimei.core=http://localhost:18002
 caimei.manager=http://localhost:9527
 #\u963F\u91CC\u4E91oss\u5B58\u50A8
 aliyun.accessKeyId=LTAI4GBL3o4YkWnbKYgf2Xia

+ 1 - 0
src/main/resources/mappings/modules/info/InfoMapper.xml

@@ -4,6 +4,7 @@
 
 	<sql id="infoColumns">
 		a.id AS "id",
+		a.shopId AS "shopId",
 		a.typeId AS "infoType.id",
 		a.title AS "title",
 		a.label AS "label",

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

@@ -1165,7 +1165,7 @@
     <delete id="deleteLadderPriceById">
         DELETE
         FROM product_ladder_price
-        where productId = #{productId}
+        where productId = #{productId} and skuId = #{skuId}
     </delete>
     <delete id="deleteSkus">
         delete

+ 1 - 0
src/main/webapp/WEB-INF/views/modules/info/auditInfoPage.jsp

@@ -23,6 +23,7 @@
 </ul>
 <form:form id="inputForm" modelAttribute="info" action="${ctx}/info/info/save?ltype=2&publishSource=2&auditFlag=1" method="post" class="form-horizontal">
 	<form:hidden path="id"/>
+	<form:hidden path="shopId"/>
 	<sys:message content="${message}"/>
 	<table border="0" cellspacing="0" cellpadding="0" width="100%">
 		<tr>

+ 8 - 1
src/main/webapp/WEB-INF/views/modules/product-new/productEdit.jsp

@@ -298,7 +298,7 @@
     </c:if>
 </ul>
 <form:form id="inputForm" modelAttribute="product"
-           action="${ctx}/product/new/productSave?searchShopID=${product.searchShopID}&searchShopName=${product.searchShopName}&searchBigTypeID=${product.searchBigTypeID}&searchSmallTypeID=${product.searchSmallTypeID}&searchTinyTypeID=${product.searchTinyTypeID}&searchValidFlag=${product.searchValidFlag}&searchActStatus=${product.searchActStatus}&searchProductType=${product.searchProductType}&searchBrandID=${product.searchBrandID}&searchPreferredFlag=${product.searchPreferredFlag}&searchProductCategory=${product.searchProductCategory}&editFlag=${product.editFlag}&shopType=${product.shopType}"
+           action="${ctx}/product/new/productSave?searchShopID=${product.searchShopID}&searchShopName=${product.searchShopName}&searchBigTypeID=${product.searchBigTypeID}&searchSmallTypeID=${product.searchSmallTypeID}&searchTinyTypeID=${product.searchTinyTypeID}&searchValidFlag=${product.searchValidFlag}&searchActStatus=${product.searchActStatus}&searchProductType=${product.searchProductType}&searchBrandID=${product.searchBrandID}&searchPreferredFlag=${product.searchPreferredFlag}&searchProductCategory=${product.searchProductCategory}&editFlag=${product.editFlag}&shopType=${product.shopType}&ladderPriceFlag=${product.ladderPriceFlag}"
            method="post" class="form-horizontal">
     <form:hidden path="id"/>
     <form:hidden path="searchName"/>
@@ -2018,10 +2018,16 @@
             }
 
             console.log('ladderPrice---', ladderPrice)
+
             // 起订量
             var buyNum = $(item).find('[name$="buyNum"]');
             buyNum.val(ladderPrice.buyNum);
             buyNum.attr('name', 'skuList[' + skuIndex + '].ladderPriceList[' + index + '].buyNum');
+
+            console.log('buyNum---', ladderPrice.buyNum)
+            if(ladderPrice.buyNum!=null){
+                $(this).show()
+            }
             // 价格
             var buyPrice = $(item).find('[name$="buyPrice"]');
             buyPrice.val(ladderPrice.buyPrice);
@@ -2119,6 +2125,7 @@
                 ladderPriceBox.show();
                 minBuyNumber.parent('.sku-minBuyNumber').hide();
                 el.find('input[name$="skuList[' + i + '].ladderPriceList[0].delFlag"]').val(0);
+
             } else {
                 ladderPriceBox.hide();
                 minBuyNumber.parent('.sku-minBuyNumber').show();