浏览代码

呵呵商城优惠券part2

Aslee 3 年之前
父节点
当前提交
278b967e03
共有 67 个文件被更改,包括 1886 次插入214 次删除
  1. 68 6
      pom.xml
  2. 18 0
      src/main/java/com/caimei/modules/archive/entity/CmOrderArchive.java
  3. 36 0
      src/main/java/com/caimei/modules/archive/entity/CmProductArchiveContent.java
  4. 57 3
      src/main/java/com/caimei/modules/archive/service/CmProductArchiveContentService.java
  5. 577 0
      src/main/java/com/caimei/modules/archive/utils/WaterMarkUtils.java
  6. 12 0
      src/main/java/com/caimei/modules/archive/web/CmProductArchiveContentController.java
  7. 71 68
      src/main/java/com/caimei/modules/common/utils/PoiExcelUtil.java
  8. 48 0
      src/main/java/com/caimei/modules/coupon/entity/CmCoupon.java
  9. 13 0
      src/main/java/com/caimei/modules/coupon/service/CmCouponService.java
  10. 13 0
      src/main/java/com/caimei/modules/coupon/web/CmCouponController.java
  11. 2 0
      src/main/java/com/caimei/modules/hehe/dao/CmHeheCouponDao.java
  12. 8 0
      src/main/java/com/caimei/modules/hehe/dao/HeHeNewOrderDao.java
  13. 9 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheCoupon.java
  14. 96 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheCouponOrderRecord.java
  15. 31 8
      src/main/java/com/caimei/modules/hehe/service/CmHeheCouponService.java
  16. 2 1
      src/main/java/com/caimei/modules/hehe/service/CmHeheDiscountService.java
  17. 1 0
      src/main/java/com/caimei/modules/hehe/service/CmHeheFloorProductService.java
  18. 10 0
      src/main/java/com/caimei/modules/hehe/service/HeHeNewOrderService.java
  19. 2 1
      src/main/java/com/caimei/modules/hehe/web/CmHeheCouponController.java
  20. 15 0
      src/main/java/com/caimei/modules/hehe/web/CmHeheProductController.java
  21. 23 0
      src/main/java/com/caimei/modules/order/entity/NewOrder.java
  22. 9 0
      src/main/java/com/caimei/modules/order/service/NewOrderService.java
  23. 4 2
      src/main/java/com/caimei/modules/order/web/CmDiscernReceiptController.java
  24. 4 2
      src/main/java/com/caimei/modules/order/web/NewOrderController.java
  25. 30 0
      src/main/java/com/caimei/modules/oss/utils/OSSUtils.java
  26. 13 0
      src/main/java/com/caimei/modules/product/entity/Product.java
  27. 16 24
      src/main/java/com/thinkgem/jeesite/common/utils/excel/ExportExcel.java
  28. 1 1
      src/main/resources/config/beta/caimei.properties
  29. 1 1
      src/main/resources/config/dev/caimei.properties
  30. 6 3
      src/main/resources/mappings/modules/archive/CmOrderArchiveMapper.xml
  31. 6 1
      src/main/resources/mappings/modules/archive/CmProductArchiveContentMapper.xml
  32. 15 2
      src/main/resources/mappings/modules/coupon/CmCouponMapper.xml
  33. 15 7
      src/main/resources/mappings/modules/hehe/CmHeheCouponMapper.xml
  34. 4 4
      src/main/resources/mappings/modules/hehe/CmHeheDiscountMapper.xml
  35. 8 1
      src/main/resources/mappings/modules/hehe/CmHeheFloorProductMapper.xml
  36. 14 0
      src/main/resources/mappings/modules/hehe/HeHeNewOrderMapper.xml
  37. 3 1
      src/main/webapp/WEB-INF/views/modules/archive/addFileForm.jsp
  38. 17 3
      src/main/webapp/WEB-INF/views/modules/archive/cmOrderArchiveList.jsp
  39. 31 0
      src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveContentList.jsp
  40. 12 0
      src/main/webapp/WEB-INF/views/modules/archive/previewFilePage.jsp
  41. 7 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/applyRefoundForm.jsp
  42. 7 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderConfirmReturnRecord.jsp
  43. 7 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReturnRecord.jsp
  44. 7 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReviewReturnRecord.jsp
  45. 7 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/refundRecord.jsp
  46. 70 1
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponForm.jsp
  47. 13 8
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponList.jsp
  48. 71 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponCategoryForm.jsp
  49. 13 8
      src/main/webapp/WEB-INF/views/modules/coupon/couponCategoryList.jsp
  50. 71 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponNewUserForm.jsp
  51. 13 8
      src/main/webapp/WEB-INF/views/modules/coupon/couponNewUserList.jsp
  52. 68 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponShopForm.jsp
  53. 13 8
      src/main/webapp/WEB-INF/views/modules/coupon/couponShopList.jsp
  54. 68 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponUserExclusiveForm.jsp
  55. 13 8
      src/main/webapp/WEB-INF/views/modules/coupon/couponUserExclusiveList.jsp
  56. 1 1
      src/main/webapp/WEB-INF/views/modules/coupon/productCouponDetails.jsp
  57. 6 0
      src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeCouponForm.jsp
  58. 7 2
      src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeCouponList.jsp
  59. 54 19
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCouponForm.jsp
  60. 8 3
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCouponList.jsp
  61. 9 1
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheDiscountForm.jsp
  62. 0 3
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheDiscountList.jsp
  63. 18 0
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheProductForm.jsp
  64. 10 1
      src/main/webapp/WEB-INF/views/modules/hehe/heheNewOrderDetail.jsp
  65. 2 2
      src/main/webapp/WEB-INF/views/modules/hehe/toAddCouponUser.jsp
  66. 1 1
      src/main/webapp/WEB-INF/views/modules/hehe/toAddDiscountUser.jsp
  67. 1 1
      src/main/webapp/static/modules/bulkpurchase/orderForm.js

+ 68 - 6
pom.xml

@@ -499,7 +499,7 @@
 		</dependency>
 
 		<!-- poi office -->
-		<dependency>
+		<!--<dependency>
 			<groupId>org.apache.poi</groupId>
 			<artifactId>poi</artifactId>
 			<version>${poi.version}</version>
@@ -513,7 +513,7 @@
 			<groupId>org.apache.poi</groupId>
 			<artifactId>poi-ooxml-schemas</artifactId>
 			<version>${poi.version}</version>
-		</dependency>
+		</dependency>-->
 
 		<!-- image util -->
 		<dependency>
@@ -659,11 +659,73 @@
 			<version>3.10.2</version>
 		</dependency>
 
-		<!--<dependency>
-			<groupId>caimei</groupId>
-			<artifactId>ueditor</artifactId>
+
+		<dependency>
+			<groupId>org.apache.poi</groupId>
+			<artifactId>poi</artifactId>
+			<version>3.17</version>
+		</dependency>
+		<!--2007 docx文件读取,需要导入poi-ooxml-->
+		<dependency>
+			<groupId>org.apache.poi</groupId>
+			<artifactId>poi-ooxml</artifactId>
+			<version>3.17</version>
+		</dependency>
+		<!--2003 doc文件的读取,需要导入poi-scratchpad-->
+		<dependency>
+			<groupId>org.apache.poi</groupId>
+			<artifactId>poi-scratchpad</artifactId>
+			<version>3.8</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.poi</groupId>
+			<artifactId>ooxml-schemas</artifactId>
 			<version>1.0</version>
-		</dependency>-->
+			<exclusions>
+				<!--解决含嵌入文件ppt转换报错 ArrayStoreException-->
+				<exclusion>
+					<artifactId>xmlbeans</artifactId>
+					<groupId>org.apache.xmlbeans</groupId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+
+		<dependency>
+			<groupId>com.itextpdf</groupId>
+			<artifactId>itext-asian</artifactId>
+			<version>5.2.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.pdfbox</groupId>
+			<artifactId>pdfbox</artifactId>
+			<version>2.0.16</version>
+		</dependency>
+		<dependency>
+			<groupId>com.itextpdf</groupId>
+			<artifactId>itextpdf</artifactId>
+			<version>5.5.13</version>
+		</dependency>
+		<!--twelvemonkeys图片处理-->
+		<dependency>
+			<groupId>com.twelvemonkeys.imageio</groupId>
+			<artifactId>imageio-jpeg</artifactId>
+			<version>3.6</version>
+		</dependency>
+		<dependency>
+			<groupId>com.twelvemonkeys.imageio</groupId>
+			<artifactId>imageio-tiff</artifactId>
+			<version>3.6</version>
+		</dependency>
+
+		<!--
+        Optional dependency. Needed only if you deploy `ImageIO` plugins as part of a web app.
+        Make sure you add the `IIOProviderContextListener` to your `web.xml`, see above.
+        -->
+		<dependency>
+			<groupId>com.twelvemonkeys.servlet</groupId>
+			<artifactId>servlet</artifactId>
+			<version>3.6</version>
+		</dependency>
 
 	</dependencies>
 

+ 18 - 0
src/main/java/com/caimei/modules/archive/entity/CmOrderArchive.java

@@ -27,6 +27,8 @@ public class CmOrderArchive extends DataEntity<CmOrderArchive> {
 	private Date addTime;		// 添加时间
 
 	private Integer orderId;	// 主订单id
+	private Integer orderStatus;	// 主订单状态:0待确认,11待收待发,12待收部发,13待收全发,21部收待发,22部收部发,23部收全发,31已收待发,32已收部发,33已收全发,4交易完成,5订单完成,6已关闭,7交易全退
+	private Integer fileNum;		//文件数量
 
 	/**
 	 * 上传文件id,以","隔开
@@ -135,4 +137,20 @@ public class CmOrderArchive extends DataEntity<CmOrderArchive> {
 	public void setFileIds(String fileIds) {
 		this.fileIds = fileIds;
 	}
+
+	public Integer getOrderStatus() {
+		return orderStatus;
+	}
+
+	public void setOrderStatus(Integer orderStatus) {
+		this.orderStatus = orderStatus;
+	}
+
+	public Integer getFileNum() {
+		return fileNum;
+	}
+
+	public void setFileNum(Integer fileNum) {
+		this.fileNum = fileNum;
+	}
 }

+ 36 - 0
src/main/java/com/caimei/modules/archive/entity/CmProductArchiveContent.java

@@ -23,6 +23,10 @@ public class CmProductArchiveContent extends DataEntity<CmProductArchiveContent>
 
 	private List<CmProductArchiveFile> fileList;	//图片列表
     private Integer fileId;                 //上传的文件id
+	private String ossName;			//oss名称
+	private String fileName;		//文件名称
+	private Date uploadTime;		//上传时间
+	private String fileUrl;			//文件链接
 
 	public CmProductArchiveContent() {
 		super();
@@ -81,4 +85,36 @@ public class CmProductArchiveContent extends DataEntity<CmProductArchiveContent>
 	public void setFileList(List<CmProductArchiveFile> fileList) {
 		this.fileList = fileList;
 	}
+
+	public String getOssName() {
+		return ossName;
+	}
+
+	public void setOssName(String ossName) {
+		this.ossName = ossName;
+	}
+
+	public String getFileName() {
+		return fileName;
+	}
+
+	public void setFileName(String fileName) {
+		this.fileName = fileName;
+	}
+
+	public String getFileUrl() {
+		return fileUrl;
+	}
+
+	public void setFileUrl(String fileUrl) {
+		this.fileUrl = fileUrl;
+	}
+
+	public Date getUploadTime() {
+		return uploadTime;
+	}
+
+	public void setUploadTime(Date uploadTime) {
+		this.uploadTime = uploadTime;
+	}
 }

+ 57 - 3
src/main/java/com/caimei/modules/archive/service/CmProductArchiveContentService.java

@@ -3,13 +3,19 @@ package com.caimei.modules.archive.service;
 import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.URL;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.List;
 
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
 import com.caimei.dfs.image.beens.ImageUploadInfo;
 import com.caimei.modules.archive.entity.CmProductArchiveFile;
 import com.caimei.modules.archive.utils.OssArchiveUtil;
+import com.caimei.modules.archive.utils.WaterMarkUtils;
 import com.caimei.modules.common.utils.UploadUtils;
+import com.caimei.modules.oss.utils.OSSUtils;
 import com.caimei.modules.sys.utils.UploadImageUtils;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.utils.Encodes;
@@ -41,16 +47,23 @@ public class CmProductArchiveContentService extends CrudService<CmProductArchive
 		return super.get(id);
 	}
 
-	private final String htmlTempPath = Global.getConfig("archive.htmlTempPath");
+	private final String tempPath = Global.getConfig("archive.tempPath");
 
 	public List<CmProductArchiveContent> findList(CmProductArchiveContent cmProductArchiveContent) {
 		return super.findList(cmProductArchiveContent);
 	}
 	
 	public Page<CmProductArchiveContent> findPage(Page<CmProductArchiveContent> page, CmProductArchiveContent cmProductArchiveContent) {
-		return super.findPage(page, cmProductArchiveContent);
+		Page<CmProductArchiveContent> archivePage = super.findPage(page, cmProductArchiveContent);
+		List<CmProductArchiveContent> archiveList = archivePage.getList();
+		archiveList.forEach(archive->{
+			if (cmProductArchiveContent.getType() != 1) {
+				archive.setFileUrl(OSSUtils.generateProductArchiveUrl(archive));
+			}
+		});
+		return archivePage;
 	}
-	
+
 	@Transactional(readOnly = false)
 	public void save(CmProductArchiveContent cmProductArchiveContent) {
 		super.save(cmProductArchiveContent);
@@ -156,4 +169,45 @@ public class CmProductArchiveContentService extends CrudService<CmProductArchive
         }
         return map;
     }
+
+
+	@Transactional(readOnly = false)
+	public Map<String, Object> addWaterMark(MultipartFile multipartFile, String fileName) {
+		Map<String, Object> map = new HashMap<>();
+		String fileAllName = multipartFile.getOriginalFilename();
+		String fileType = fileAllName.substring(fileAllName.lastIndexOf(".") + 1);
+		String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+		String filePath = uuid + "." + fileType;
+		String contentType = OssArchiveUtil.getContentType(fileAllName);
+		try {
+			//保存本地
+			File file = OssArchiveUtil.ossUpload(multipartFile);
+			logger.info("默认路径>>>" + file.getAbsolutePath());
+			WaterMarkUtils.addWaterMark(file, "采美365网", filePath, fileType);
+			File waterMarkFile = new File(tempPath + filePath);
+			String contentDispositon = "pdf".equals(fileType) ? "inline" : "attachment";
+			//上传oss
+//			String url = OssArchiveUtil.ossUpload(filePath, "archiveFile/", file, contentType, contentDispositon);
+			String url = OssArchiveUtil.ossUpload(filePath, "archiveFile/", waterMarkFile, contentType, contentDispositon);
+			//删除本地文件
+			OssArchiveUtil.deleteFile(file);
+			OssArchiveUtil.deleteFile(waterMarkFile);
+			//保存关联关系
+			CmProductArchiveFile archiveFile = new CmProductArchiveFile();
+			archiveFile.setFileName(fileName);
+			archiveFile.setOssName(filePath);
+			archiveFile.setOssUrl(url);
+			archiveFile.setUploadTime(new Date());
+			cmProductArchiveContentDao.insertFile(archiveFile);
+			map.put("success", true);
+			map.put("msg", "操作成功");
+			map.put("archiveFile", archiveFile);
+		} catch (Exception e) {
+			e.printStackTrace();
+			map.put("success", false);
+			map.put("msg", "操作失败");
+			logger.info("上传异常!!!");
+		}
+		return map;
+	}
 }

+ 577 - 0
src/main/java/com/caimei/modules/archive/utils/WaterMarkUtils.java

@@ -0,0 +1,577 @@
+package com.caimei.modules.archive.utils;
+
+import com.itextpdf.text.*;
+import com.itextpdf.text.Rectangle;
+import com.itextpdf.text.pdf.*;
+import com.thinkgem.jeesite.common.config.Global;
+import groovy.util.logging.Slf4j;
+import org.apache.poi.POIXMLDocument;
+import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.sl.usermodel.PictureData;
+import org.apache.poi.sl.usermodel.PictureData.PictureType;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xslf.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFRelation;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.apache.poi.xwpf.usermodel.XWPFHeader;
+import org.apache.poi.xwpf.usermodel.XWPFParagraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import schemasMicrosoftComVml.CTShape;
+
+import javax.imageio.ImageIO;
+import javax.swing.*;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.*;
+import java.awt.Image;
+import java.awt.font.FontRenderContext;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.lang.reflect.Field;
+
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/9/18
+ */
+public class WaterMarkUtils {
+
+    private final static String outPath = Global.getConfig("archive.tempPath");
+    /**
+     * 日志对象
+     */
+    private static Logger log = LoggerFactory.getLogger(WaterMarkUtils.class);
+
+    // 水印透明度
+    private static float alpha = 0.5f;
+    // 水印之间的间隔
+    private static final int XMOVE = 200;
+    // 水印之间的间隔
+    private static final int YMOVE = 200;
+
+    public static void main(String[] args) {
+        /*addPictureWaterMark("D:\\WorkSpace\\file\\img.jpg", "D:\\WorkSpace\\file\\temp\\img1.jpg", "我是水印");
+        setPictureWatermark("D:\\WorkSpace\\file\\img.jpg", "D:\\WorkSpace\\file\\temp\\img2.jpg", Color.GRAY, "我是水印");
+//        setWordWaterMark("D:\\WorkSpace\\file\\test.doc", "D:\\WorkSpace\\file\\temp\\test.doc", "我是水印", "doc");
+        setWordWaterMark("D:\\WorkSpace\\file\\test.docx", "D:\\WorkSpace\\file\\temp\\test.docx", "我是水印", "docx");
+        setPdfWatermark("D:\\WorkSpace\\file\\test.pdf", "D:\\WorkSpace\\file\\temp\\test.pdf", "我是水印");
+//        setExcelWaterMark("D:\\WorkSpace\\file\\test.xls", "D:\\WorkSpace\\file\\temp\\test.xls", "我是水印");
+//        setPPTWaterMark("D:\\WorkSpace\\file\\test.ppt", "D:\\WorkSpace\\file\\temp\\test.ppt", "我是水印");
+        setPPTWaterMark("D:\\WorkSpace\\file\\test.pptx", "D:\\WorkSpace\\file\\temp\\test.pptx", "我是水印");
+    */}
+
+    /**
+     * @param srcImgPath       源图片路径
+     * @param tarImgPath       保存的图片路径
+     * @param waterMarkContent 水印内容
+     */
+    public static void addPictureWaterMark(String srcImgPath, String tarImgPath,
+                                           String waterMarkContent) {
+        FileOutputStream outImgStream = null;
+        try {
+            // 读取原图片信息
+            File srcImgFile = new File(srcImgPath);// 得到文件
+            Image srcImg = ImageIO.read(srcImgFile);// 文件转化为图片
+            int srcImgWidth = srcImg.getWidth(null);// 获取图片的宽
+            int srcImgHeight = srcImg.getHeight(null);// 获取图片的高
+            // 加水印
+            BufferedImage bufImg = new BufferedImage(srcImgWidth, srcImgHeight,
+                    BufferedImage.TYPE_INT_RGB);
+            Graphics2D g = bufImg.createGraphics();
+            // 设置对线段的锯齿状边缘处理
+            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+                    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+            g.drawImage(srcImg, 0, 0, srcImgWidth, srcImgHeight, null);
+            // 设置水印旋转
+            g.rotate(Math.toRadians(-40),
+                    (double) bufImg.getWidth() / 2,
+                    (double) bufImg.getHeight() / 2);
+            g.setColor(new Color(107, 109, 106)); // 根据图片的背景设置水印颜色
+            Font font = new Font("宋体", Font.PLAIN, 20);
+            g.setFont(font); // 设置字体
+            // 设置水印文字透明度
+//			g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,alpha));
+
+            //根据不同的像素判断多个水印还是单个水印300*300
+            if (srcImgWidth > 300 && srcImgHeight > 300) {
+                //多个水印
+                // 设置水印的坐标
+                int x = -srcImgWidth / 2;
+                int y = -srcImgHeight / 2;
+                int markWidth = font.getSize() * getTextLength(waterMarkContent);// 字体长度
+                int markHeight = font.getSize();// 字体高度
+                // 循环添加水印
+                while (x < srcImgWidth * 1.5) {
+                    y = -srcImgHeight / 2;
+                    while (y < srcImgHeight * 1.5) {
+                        g.drawString(waterMarkContent, x, y);
+                        y += markHeight + YMOVE;
+                    }
+                    x += markWidth + XMOVE;
+                }
+            } else {
+                //单个水印
+                int x = (srcImgWidth - getWatermarkLength(waterMarkContent, g)) / 2;
+                int y = srcImgHeight / 2;
+                g.drawString(waterMarkContent, x, y);
+            }
+            g.dispose();
+            // 输出图片
+            outImgStream = new FileOutputStream(tarImgPath);
+            String formatName = srcImgPath.substring(srcImgPath.lastIndexOf(".") + 1, srcImgPath.length());
+            ImageIO.write(bufImg, formatName, outImgStream);
+            outImgStream.flush();
+        } catch (Exception e) {
+            log.error("addPictureWatermark fail", e);
+            // throw new MyException(ResultCode.FAILURE, "addPictureWatermark fail");
+        } finally {
+            if (outImgStream != null) {
+                try {
+                    outImgStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * 图片添加水印
+     *
+     * @param srcImgPath       需要添加水印的图片的路径
+     * @param outImgPath       添加水印后图片输出路径
+     * @param markContentColor 水印文字的颜色
+     * @param waterMarkContent 水印的文字
+     */
+    public static void setPictureWatermark(String srcImgPath, String outImgPath, Color markContentColor, String waterMarkContent) {
+        FileOutputStream outImgStream = null;
+        try {
+            // 读取原图片信息
+            File srcImgFile = new File(srcImgPath);
+            Image srcImg = ImageIO.read(srcImgFile);
+            int srcImgWidth = srcImg.getWidth(null);
+            int srcImgHeight = srcImg.getHeight(null);
+            // 加水印
+            BufferedImage bufImg = new BufferedImage(srcImgWidth, srcImgHeight, BufferedImage.TYPE_INT_RGB);
+            Graphics2D g = bufImg.createGraphics();
+            g.drawImage(srcImg, 0, 0, srcImgWidth, srcImgHeight, null);
+            Font font = new Font("宋体", Font.BOLD, srcImgHeight / 6);
+            //根据图片的背景设置水印颜色
+            g.setColor(markContentColor);
+            //设置旋转角度
+            g.rotate(Math.toRadians(-45), (double) bufImg.getWidth() / 2, (double) bufImg.getHeight() / 2);
+            //设置水印透明度
+            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.2F));
+
+            g.setFont(font);
+            int x = (srcImgWidth - getWatermarkLength(waterMarkContent, g)) / 2;
+            int y = srcImgHeight / 2;
+            g.drawString(waterMarkContent, x, y);
+            g.dispose();
+            // 输出图片
+            outImgStream = new FileOutputStream(outImgPath);
+            ImageIO.write(bufImg, "jpg", outImgStream);
+            outImgStream.flush();
+            outImgStream.close();
+        } catch (Exception e) {
+            log.error("setPictureWatermark fail", e);
+            // throw new MyException(ResultCode.FAILURE, "setPictureWatermark fail");
+        } finally {
+            if (outImgStream != null) {
+                try {
+                    outImgStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * word文字水印
+     *
+     * @param markStr
+     */
+    public static void setWordWaterMark(File inputFile, String markStr,String filePath, String fileType) {
+        if ("docx".equals(fileType)) {
+            //2003doc 用HWPFDocument  ; 2007doc 用 XWPFDocument
+            XWPFDocument doc = null;
+            try {
+//                OPCPackage pack = POIXMLDocument.openPackage(inputPath);
+//                doc = new XWPFDocument(pack);
+                doc = new XWPFDocument(new FileInputStream(inputFile));
+//                doc = new XWPFDocument(new FileInputStream(inputFile));
+            } catch (FileNotFoundException e) {
+                log.error("setWordWaterMark fail: 源文件不存在", e);
+                // throw new MyException(ResultCode.FAILURE, "setWordWaterMark fail: 源文件不存在");
+            } catch (IOException e) {
+                log.error("setWordWaterMark fail: 读取源文件IO异常", e);
+                // throw new MyException(ResultCode.FAILURE, "setWordWaterMark fail: 读取源文件IO异常");
+            } catch (Exception e) {
+                log.error("setWordWaterMark fail: 不支持的文档格式", e);
+                // throw new MyException(ResultCode.FAILURE, "setWordWaterMark fail: 不支持的文档格式");
+            }
+            XWPFParagraph paragraph = doc.createParagraph();
+            XWPFHeaderFooterPolicy headerFooterPolicy = doc.getHeaderFooterPolicy();
+            if (headerFooterPolicy == null) {
+                headerFooterPolicy = doc.createHeaderFooterPolicy();
+            }
+            // create default Watermark - fill color black and not rotated
+            headerFooterPolicy.createWatermark(markStr);
+            // get the default header
+            // Note: createWatermark also sets FIRST and EVEN headers
+            // but this code does not updating those other headers
+            XWPFHeader header = headerFooterPolicy.getHeader(XWPFHeaderFooterPolicy.DEFAULT);
+            paragraph = header.getParagraphArray(0);
+//            // get com.microsoft.schemas.vml.CTShape where fill color and rotation is set
+//            paragraph.getCTP().newCursor();
+//            System.out.println(paragraph.getCTP().getRArray(0));
+//            System.out.println(paragraph.getCTP().getRArray(0).getPictArray(0));
+            org.apache.xmlbeans.XmlObject[] xmlobjects = paragraph.getCTP().getRArray(0).getPictArray(0).selectChildren(
+                    new javax.xml.namespace.QName("urn:schemas-microsoft-com:vml", "shape"));
+            if (xmlobjects.length > 0) {
+                com.microsoft.schemas.vml.CTShape ctshape = (com.microsoft.schemas.vml.CTShape) xmlobjects[0];
+                ctshape.setFillcolor("#D3D3D3");
+                ctshape.setStyle(ctshape.getStyle() + ";rotation:315" + ";height:60pt;width:360pt");
+            }
+            File file = new File(outPath + filePath);
+            if (!file.exists()) {
+                try {
+                    file.createNewFile();
+                } catch (IOException e) {
+                    log.error("setWordWaterMark fail: 创建输出文件IO异常", e);
+                    // throw new MyException(ResultCode.FAILURE, "setWordWaterMark fail: 创建输出文件失败");
+                }
+            }
+            try {
+                doc.write(new FileOutputStream(outPath + filePath));
+            } catch (FileNotFoundException e) {
+                log.error("setWordWaterMark fail: 输出文件不存在", e);
+                // throw new MyException(ResultCode.FAILURE, "setWordWaterMark fail: 创建输出文件失败");
+            } catch (IOException e) {
+                log.error("setWordWaterMark fail: ", e);
+                // throw new MyException(ResultCode.FAILURE, "setWordWaterMark fail");
+            } finally {
+                if (doc != null) {
+                    try {
+                        doc.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * pdf设置文字水印
+     *
+     * @param inputPath
+     * @param outPath
+     * @param markStr
+     */
+    public static void setPdfWatermark(String inputPath, String outPath, String markStr) {
+        File file = new File(outPath);
+        if (!file.exists()) {
+            try {
+                file.createNewFile();
+            } catch (IOException e) {
+                log.error("setPdfWatermark fail: 创建输出文件IO异常", e);
+                // throw new MyException(ResultCode.FAILURE, "setPdfWatermark fail: 创建输出文件IO异常");
+            }
+        }
+        BufferedOutputStream bufferOut = null;
+        try {
+            bufferOut = new BufferedOutputStream(new FileOutputStream(file));
+        } catch (FileNotFoundException e) {
+            log.error("setPdfWatermark fail: 源文件不存在", e);
+            // throw new MyException(ResultCode.FAILURE, "setPdfWatermark fail: 源文件不存在");
+        }
+        PdfStamper stamper = null;
+        int total = 0;
+        PdfContentByte content;
+        Rectangle pageSizeWithRotation = null;
+        BaseFont base = null;
+        PdfReader reader = null;
+        try {
+            reader = new PdfReader(inputPath);
+            //解决PdfReader not opened with owner password
+            Field f = PdfReader.class.getDeclaredField("ownerPasswordUsed");
+            f.setAccessible(true);
+            f.set(reader, Boolean.TRUE);
+            stamper = new PdfStamper(reader, bufferOut);
+            total = reader.getNumberOfPages() + 1;
+            base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED);
+        } catch (IOException e) {
+            log.error("setPdfWatermark fail:", e);
+            // throw new MyException(ResultCode.FAILURE, "setPdfWatermark fail");
+        } catch (DocumentException e) {
+            log.error("setPdfWatermark fail:", e);
+            // throw new MyException(ResultCode.FAILURE, "setPdfWatermark fail");
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        } catch (NoSuchFieldException e) {
+            e.printStackTrace();
+        }
+        // 获取水印文字的高度和宽度
+        int textH = 0, textW = 0;
+        JLabel label = new JLabel();
+        label.setText(markStr);
+        FontMetrics metrics = label.getFontMetrics(label.getFont());
+        textH = metrics.getHeight();
+        textW = metrics.stringWidth(label.getText());
+        PdfGState gs = new PdfGState();
+        for (int i = 1; i < total; i++) {
+            //在内容上方加水印
+            content = stamper.getOverContent(i);
+            gs.setFillOpacity(0.5f);
+            content.saveState();
+            content.setGState(gs);
+            content.beginText();
+//            content.setRGBColorFill(0, 0, 0);
+            content.setFontAndSize(base, 20);
+            // 获取每一页的高度、宽度
+            pageSizeWithRotation = reader.getPageSizeWithRotation(i);
+            float pageHeight = pageSizeWithRotation.getHeight();
+            float pageWidth = pageSizeWithRotation.getWidth();
+
+            // 根据纸张大小多次添加, 水印文字成30度角倾斜
+            for (int height = -5 + textH; height < pageHeight; height = height + YMOVE) {
+                for (int width = -5 + textW; width < pageWidth + textW; width = width + XMOVE) {
+                    content.showTextAligned(Element.ALIGN_LEFT, markStr, width - textW, height - textH, 30);
+                }
+            }
+            content.endText();
+        }
+        try {
+            stamper.close();
+            bufferOut.flush();
+            bufferOut.close();
+            reader.close();
+        } catch (IOException e) {
+            log.error("setPdfWatermark fail:", e);
+            // throw new MyException(ResultCode.FAILURE, "setPdfWatermark fail");
+        } catch (DocumentException e) {
+            log.error("setPdfWatermark fail:", e);
+            // throw new MyException(ResultCode.FAILURE, "setPdfWatermark fail");
+        }
+    }
+
+
+    /**
+     * excel设置水印
+     *
+     * @param inputPath
+     * @param outPath
+     * @param markStr
+     */
+    public static void setExcelWaterMark(String inputPath, String outPath, String markStr) {
+        //读取excel文件
+        XSSFWorkbook workbook = null;
+        try {
+            workbook = new XSSFWorkbook(new FileInputStream(inputPath));
+        } catch (FileNotFoundException e) {
+            log.error("setExcelWaterMark fail: 源文件不存在", e);
+            // throw new MyException(ResultCode.FAILURE, "setExcelWaterMark fail: 源文件不存在");
+        } catch (IOException e) {
+            log.error("setExcelWaterMark fail: 读取源文件IO异常", e);
+            //throw new MyException(ResultCode.FAILURE, "setExcelWaterMark fail: 读取源文件IO异常");
+        }
+        OutputStream fos = null;
+        ByteArrayOutputStream os = null;
+        try {
+            //获取水印
+            os = getImage(markStr);
+            int pictureIdx = workbook.addPicture(os.toByteArray(), Workbook.PICTURE_TYPE_PNG);
+            for (int i = 0; i < workbook.getNumberOfSheets(); i++) {//获取每个Sheet表
+                XSSFSheet sheet1 = workbook.getSheetAt(i);
+                String rID = sheet1.addRelation(null, XSSFRelation.IMAGES, workbook.getAllPictures().get(pictureIdx)).getRelationship().getId();
+                //set background picture to sheet
+                sheet1.getCTWorksheet().addNewPicture().setId(rID);
+            }
+            // Excel文件生成后存储的位置。
+            File file = new File(outPath);
+            fos = new FileOutputStream(file);
+            workbook.write(fos);
+        } catch (Exception e) {
+            log.error("setExcelWaterMark fail: 创建输出文件IO异常", e);
+            // throw new MyException(ResultCode.FAILURE, "setExcelWaterMark fail: 创建输出文件IO异常");
+        } finally {
+            if (os != null) {
+                try {
+                    os.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (workbook != null) {
+                try {
+                    workbook.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * PPT设置水印
+     *
+     * @param path
+     * @param targetpath
+     * @param markStr
+     * @throws IOException
+     */
+    public static void setPPTWaterMark(String path, String targetpath, String markStr) {
+        XMLSlideShow slideShow = null;
+        try {
+            slideShow = new XMLSlideShow(new FileInputStream(path));
+        } catch (IOException e) {
+            log.error("setPPTWaterMark fail:", e);
+            // throw new MyException(ResultCode.FAILURE, "setPPTWaterMark fail:获取PPT文件失败");
+        }
+        ByteArrayOutputStream os = null;
+        FileOutputStream out = null;
+        try {
+            //获取水印
+            os = getImage(markStr);
+            PictureData pictureData1 = slideShow.addPicture(os.toByteArray(), PictureType.PNG);
+            for (XSLFSlide slide : slideShow.getSlides()) {
+                XSLFPictureShape pictureShape = slide.createPicture(pictureData1);
+//                pictureShape.setAnchor(new java.awt.Rectangle(250, 0, 500, 500));
+                pictureShape.setAnchor(pictureShape.getAnchor());
+            }
+            out = new FileOutputStream(targetpath);
+            slideShow.write(out);
+        } catch (IOException e) {
+            log.error("setPPTWaterMark fail:" + e);
+            // throw new MyException(ResultCode.FAILURE, "setPPTWaterMark fail:生成ppt文件失败");
+        } finally {
+            if (slideShow != null) {
+                try {
+                    slideShow.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (out != null) {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (os != null) {
+                try {
+                    os.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * 获取水印文字总长度
+     *
+     * @param waterMarkContent 水印的文字
+     * @param g
+     * @return 水印文字总长度
+     */
+    public static int getWatermarkLength(String waterMarkContent, Graphics2D g) {
+        return g.getFontMetrics(g.getFont()).charsWidth(waterMarkContent.toCharArray(), 0, waterMarkContent.length());
+    }
+
+    /**
+     * 获取文本长度。汉字为1:1,英文和数字为2:1
+     */
+    private static int getTextLength(String text) {
+        int length = text.length();
+        for (int i = 0; i < text.length(); i++) {
+            String s = String.valueOf(text.charAt(i));
+            if (s.getBytes().length > 1) {
+                length++;
+            }
+        }
+        length = length % 2 == 0 ? length / 2 : length / 2 + 1;
+        return length;
+    }
+
+    /**
+     * 获取水印文字图片流
+     *
+     * @param text
+     * @return
+     */
+    private static ByteArrayOutputStream getImage(String text) {
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        try {
+            // 导出到字节流B
+            BufferedImage image = createWaterMarkImageBig(text);
+            ImageIO.write(image, "png", os);
+        } catch (IOException e) {
+            log.error("getImage fail: 创建水印图片IO异常", e);
+            // throw new MyException(ResultCode.FAILURE, "getImage fail: 创建水印图片IO异常");
+        }
+        return os;
+    }
+
+    /**
+     * 根据文字生成水印图片(大号 平铺)
+     *
+     * @param text
+     * @return
+     */
+    public static BufferedImage createWaterMarkImageBig(String text) {
+        Integer width = 1000;
+        Integer height = 800;
+        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);// 获取bufferedImage对象
+        Font font = new Font("宋体", Font.PLAIN, 70);
+        Graphics2D g2d = image.createGraphics();
+        image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT);
+        g2d.dispose();
+        g2d = image.createGraphics();
+        //设置字体颜色和透明度
+        g2d.setColor(new Color(0, 0, 0, 60));
+        //设置字体
+        g2d.setStroke(new BasicStroke(1));
+        //设置字体类型  加粗 大小
+        g2d.setFont(font);
+        //设置倾斜度
+        g2d.rotate(Math.toRadians(-30), (double) image.getWidth() / 2, (double) image.getHeight() / 2);
+        FontRenderContext context = g2d.getFontRenderContext();
+        Rectangle2D bounds = font.getStringBounds(text, context);
+        double x = (width - bounds.getWidth()) / 2;
+        double y = (height - bounds.getHeight()) / 2;
+        double ascent = -bounds.getY();
+        double baseY = y + ascent;
+        //写入水印文字原定高度过小,所以累计写水印,增加高度
+        g2d.drawString(text, (int) x, (int) baseY);
+        //设置透明度
+        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
+        //释放对象
+        g2d.dispose();
+        return image;
+    }
+
+    public static void addWaterMark(File inputFile, String markStr, String filePath, String fileType) {
+        if (fileType.contains("doc")) {
+            setWordWaterMark(inputFile, markStr, filePath, fileType);
+        }
+    }
+}

+ 12 - 0
src/main/java/com/caimei/modules/archive/web/CmProductArchiveContentController.java

@@ -96,4 +96,16 @@ public class CmProductArchiveContentController extends BaseController {
     public Map<String, Object> upload(@RequestParam("file") MultipartFile file, @RequestParam("fileName") String fileName) {
         return cmProductArchiveContentService.upload(file, fileName);
     }
+
+    @RequestMapping(value = "preview")
+	public String preview(String url,Model model){
+		model.addAttribute("url", url);
+		return "modules/archive/previewFilePage";
+	}
+
+    @ResponseBody
+    @RequestMapping(value = "addWaterMark")
+    public Map<String, Object> addWaterMark(@RequestParam("file") MultipartFile file, @RequestParam("fileName") String fileName) {
+        return cmProductArchiveContentService.addWaterMark(file, fileName);
+    }
 }

+ 71 - 68
src/main/java/com/caimei/modules/common/utils/PoiExcelUtil.java

@@ -9,6 +9,9 @@ import com.caimei.utils.MathUtil;
 import com.thinkgem.jeesite.common.utils.DateUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,8 +54,8 @@ public class PoiExcelUtil {
         headfont.setFontHeightInPoints((short) 22);// 字体大小
         HSSFCellStyle headstyle = workbook.createCellStyle();
         headstyle.setFont(headfont);
-        headstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        headstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        headstyle.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        headstyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         headstyle.setLocked(true);
         // 表头客户名 订单号 客户电话 客户地址 样式
         HSSFFont datefont = workbook.createFont();
@@ -60,35 +63,35 @@ public class PoiExcelUtil {
         datefont.setFontHeightInPoints((short) 12);// 字体大小
         HSSFCellStyle datestyle = workbook.createCellStyle();
         datestyle.setFont(datefont);
-        datestyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        datestyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        datestyle.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        datestyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         datestyle.setLocked(true);
         // 列名样式
         HSSFFont font = workbook.createFont();
         font.setFontName("黑体");
         font.setFontHeightInPoints((short) 12);// 字体大小
         HSSFCellStyle style = workbook.createCellStyle();
-        style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
-        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
-        style.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
-        style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
+        style.setBorderBottom(BorderStyle.THIN); //下边框
+        style.setBorderLeft(BorderStyle.THIN);//左边框
+        style.setBorderTop(BorderStyle.THIN);//上边框
+        style.setBorderRight(BorderStyle.THIN);//右边框
         style.setFont(font);
-        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        style.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        style.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         style.setLocked(true);
         // 普通单元格样式(中文)
         HSSFFont font2 = workbook.createFont();
         font2.setFontName("宋体");
         font2.setFontHeightInPoints((short) 12);
         HSSFCellStyle style2 = workbook.createCellStyle();
-        style2.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
-        style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
-        style2.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
-        style2.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
+        style2.setBorderBottom(BorderStyle.THIN); //下边框
+        style2.setBorderLeft(BorderStyle.THIN);//左边框
+        style2.setBorderTop(BorderStyle.THIN);//上边框
+        style2.setBorderRight(BorderStyle.THIN);//右边框
         style2.setFont(font2);
-        style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
+        style2.setAlignment(HorizontalAlignment.CENTER);// 左右居中
         style2.setWrapText(true); // 换行
-        style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        style2.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
 
         // 应付 带颜色单元格样式
         HSSFCellStyle yfstyle = workbook.createCellStyle();
@@ -97,12 +100,12 @@ public class PoiExcelUtil {
         yffont.setFontHeightInPoints((short) 12);
         yffont.setColor(HSSFColor.RED.index);
         yfstyle.setFont(yffont);
-        yfstyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
-        yfstyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
-        yfstyle.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
-        yfstyle.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
-        yfstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        yfstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        yfstyle.setBorderBottom(BorderStyle.THIN); //下边框
+        yfstyle.setBorderLeft(BorderStyle.THIN);//左边框
+        yfstyle.setBorderTop(BorderStyle.THIN);//上边框
+        yfstyle.setBorderRight(BorderStyle.THIN);//右边框
+        yfstyle.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        yfstyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         yfstyle.setWrapText(true); // 换行
 
         // 合计 带颜色单元格样式
@@ -112,12 +115,12 @@ public class PoiExcelUtil {
         hjfont.setFontHeightInPoints((short) 12);
         hjfont.setColor(HSSFColor.BLUE.index);
         hjstyle.setFont(hjfont);
-        hjstyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
-        hjstyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
-        hjstyle.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
-        hjstyle.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
-        hjstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        hjstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        hjstyle.setBorderBottom(BorderStyle.THIN); //下边框
+        hjstyle.setBorderLeft(BorderStyle.THIN);//左边框
+        hjstyle.setBorderTop(BorderStyle.THIN);//上边框
+        hjstyle.setBorderRight(BorderStyle.THIN);//右边框
+        hjstyle.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        hjstyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         hjstyle.setWrapText(true); // 换行
 
         // 已收
@@ -127,12 +130,12 @@ public class PoiExcelUtil {
         ysfont.setFontHeightInPoints((short) 12);
         ysfont.setColor(HSSFColor.GREEN.index);
         ysstyle.setFont(ysfont);
-        ysstyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
-        ysstyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
-        ysstyle.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
-        ysstyle.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
-        ysstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        ysstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        ysstyle.setBorderBottom(BorderStyle.THIN); //下边框
+        ysstyle.setBorderLeft(BorderStyle.THIN);//左边框
+        ysstyle.setBorderTop(BorderStyle.THIN);//上边框
+        ysstyle.setBorderRight(BorderStyle.THIN);//右边框
+        ysstyle.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        ysstyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         ysstyle.setWrapText(true); // 换行
 
         //列宽度  设为自适应
@@ -500,8 +503,8 @@ public class PoiExcelUtil {
         headfont.setFontHeightInPoints((short) 22);// 字体大小
         HSSFCellStyle headstyle = workbook.createCellStyle();
         headstyle.setFont(headfont);
-        headstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        headstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        headstyle.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        headstyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         headstyle.setLocked(true);
         // 表头客户名 订单号 客户电话 客户地址 样式
         HSSFFont datefont = workbook.createFont();
@@ -509,35 +512,35 @@ public class PoiExcelUtil {
         datefont.setFontHeightInPoints((short) 12);// 字体大小
         HSSFCellStyle datestyle = workbook.createCellStyle();
         datestyle.setFont(datefont);
-        datestyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        datestyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        datestyle.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        datestyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         datestyle.setLocked(true);
         // 列名样式
         HSSFFont font = workbook.createFont();
         font.setFontName("黑体");
         font.setFontHeightInPoints((short) 12);// 字体大小
         HSSFCellStyle style = workbook.createCellStyle();
-        style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
-        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
-        style.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
-        style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
+        style.setBorderBottom(BorderStyle.THIN); //下边框
+        style.setBorderLeft(BorderStyle.THIN);//左边框
+        style.setBorderTop(BorderStyle.THIN);//上边框
+        style.setBorderRight(BorderStyle.THIN);//右边框
         style.setFont(font);
-        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        style.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        style.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         style.setLocked(true);
         // 普通单元格样式(中文)
         HSSFFont font2 = workbook.createFont();
         font2.setFontName("宋体");
         font2.setFontHeightInPoints((short) 12);
         HSSFCellStyle style2 = workbook.createCellStyle();
-        style2.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
-        style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
-        style2.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
-        style2.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
+        style2.setBorderBottom(BorderStyle.THIN); //下边框
+        style2.setBorderLeft(BorderStyle.THIN);//左边框
+        style2.setBorderTop(BorderStyle.THIN);//上边框
+        style2.setBorderRight(BorderStyle.THIN);//右边框
         style2.setFont(font2);
-        style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
+        style2.setAlignment(HorizontalAlignment.CENTER);// 左右居中
         style2.setWrapText(true); // 换行
-        style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        style2.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
 
         // 应付 带颜色单元格样式
         HSSFCellStyle yfstyle = workbook.createCellStyle();
@@ -546,12 +549,12 @@ public class PoiExcelUtil {
         yffont.setFontHeightInPoints((short) 12);
         yffont.setColor(HSSFColor.RED.index);
         yfstyle.setFont(yffont);
-        yfstyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
-        yfstyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
-        yfstyle.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
-        yfstyle.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
-        yfstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        yfstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        yfstyle.setBorderBottom(BorderStyle.THIN); //下边框
+        yfstyle.setBorderLeft(BorderStyle.THIN);//左边框
+        yfstyle.setBorderTop(BorderStyle.THIN);//上边框
+        yfstyle.setBorderRight(BorderStyle.THIN);//右边框
+        yfstyle.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        yfstyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         yfstyle.setWrapText(true); // 换行
 
         // 合计 带颜色单元格样式
@@ -561,12 +564,12 @@ public class PoiExcelUtil {
         hjfont.setFontHeightInPoints((short) 12);
         hjfont.setColor(HSSFColor.BLUE.index);
         hjstyle.setFont(hjfont);
-        hjstyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
-        hjstyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
-        hjstyle.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
-        hjstyle.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
-        hjstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        hjstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        hjstyle.setBorderBottom(BorderStyle.THIN); //下边框
+        hjstyle.setBorderLeft(BorderStyle.THIN);//左边框
+        hjstyle.setBorderTop(BorderStyle.THIN);//上边框
+        hjstyle.setBorderRight(BorderStyle.THIN);//右边框
+        hjstyle.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        hjstyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         hjstyle.setWrapText(true); // 换行
         
         // 已收
@@ -576,12 +579,12 @@ public class PoiExcelUtil {
         ysfont.setFontHeightInPoints((short) 12);
         ysfont.setColor(HSSFColor.GREEN.index);
         ysstyle.setFont(ysfont);
-        ysstyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
-        ysstyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
-        ysstyle.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
-        ysstyle.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
-        ysstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 左右居中
-        ysstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
+        ysstyle.setBorderBottom(BorderStyle.THIN); //下边框
+        ysstyle.setBorderLeft(BorderStyle.THIN);//左边框
+        ysstyle.setBorderTop(BorderStyle.THIN);//上边框
+        ysstyle.setBorderRight(BorderStyle.THIN);//右边框
+        ysstyle.setAlignment(HorizontalAlignment.CENTER);// 左右居中
+        ysstyle.setVerticalAlignment(VerticalAlignment.CENTER);// 上下居中
         ysstyle.setWrapText(true); // 换行
 
         //列宽度  设为自适应

+ 48 - 0
src/main/java/com/caimei/modules/coupon/entity/CmCoupon.java

@@ -23,6 +23,9 @@ public class CmCoupon extends DataEntity<CmCoupon> {
     private BigDecimal touchPrice;        // 优惠满减条件金额
     private Date startDate;        // 使用开始时间(有效期)
     private Date endDate;        // 使用结束时间(有效期)
+    private Integer receivePeriod;		// 领取期限(天)
+    private Integer receiveFlag;		// 领取期限同开始-结束时间
+    private Integer usePeriod;		// 使用期限(天)
     private String status;        // 状态 0未生效 1已生效 2已关闭 3已失效
     private Integer couponType;        // 劵类型 0活动券 1品类券 2用户专享券 3店铺券 4新用户券
     private Integer vipFlag;        // 超级会员专享优惠券标志:0否,1是
@@ -48,6 +51,9 @@ public class CmCoupon extends DataEntity<CmCoupon> {
     private NewCmShop shop;
     private List<Integer> productIdList;
 
+    private Date receiveDate;   // 领取时间
+    private Date useEndDate;    // 使用截止时间
+
     public CmCoupon() {
         super();
     }
@@ -294,4 +300,46 @@ public class CmCoupon extends DataEntity<CmCoupon> {
     public void setRedemptionCode(String redemptionCode) {
         this.redemptionCode = redemptionCode;
     }
+
+    public Integer getReceivePeriod() {
+        return receivePeriod;
+    }
+
+    public void setReceivePeriod(Integer receivePeriod) {
+        this.receivePeriod = receivePeriod;
+    }
+
+    public Integer getReceiveFlag() {
+        return receiveFlag;
+    }
+
+    public void setReceiveFlag(Integer receiveFlag) {
+        this.receiveFlag = receiveFlag;
+    }
+
+    public Integer getUsePeriod() {
+        return usePeriod;
+    }
+
+    public void setUsePeriod(Integer usePeriod) {
+        this.usePeriod = usePeriod;
+    }
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    public Date getReceiveDate() {
+        return receiveDate;
+    }
+
+    public void setReceiveDate(Date receiveDate) {
+        this.receiveDate = receiveDate;
+    }
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    public Date getUseEndDate() {
+        return useEndDate;
+    }
+
+    public void setUseEndDate(Date useEndDate) {
+        this.useEndDate = useEndDate;
+    }
 }

+ 13 - 0
src/main/java/com/caimei/modules/coupon/service/CmCouponService.java

@@ -215,6 +215,19 @@ public class CmCouponService extends CrudService<CmCouponDao, CmCoupon> {
         cmCouponDao.update(cmCoupon);
     }
 
+    @Transactional(readOnly = false)
+    public void open(CmCoupon cmCoupon) {
+        Date date = new Date();
+        if (date.compareTo(cmCoupon.getStartDate()) < 0) {
+            cmCoupon.setStatus("0");
+        } else if (date.compareTo(cmCoupon.getEndDate()) > 0) {
+            cmCoupon.setStatus("3");
+        } else {
+            cmCoupon.setStatus("1");
+        }
+        cmCouponDao.update(cmCoupon);
+    }
+
     public Page<CmUser> findUserList(Page<CmUser> userPage, CmUser cmUser) {
         cmUser.setPage(userPage);
         List<CmUser> userList = cmCouponDao.findUserList(cmUser);

+ 13 - 0
src/main/java/com/caimei/modules/coupon/web/CmCouponController.java

@@ -160,6 +160,19 @@ public class CmCouponController extends BaseController {
         return "redirect:" + Global.getAdminPath() + "/coupon/cmCoupon/list?couponType=" + cmCoupon.getCouponType();
     }
 
+    /**
+     *  开启优惠券
+     */
+    @RequestMapping("open")
+    public String open(CmCoupon cmCoupon, RedirectAttributes redirectAttributes) {
+        cmCouponService.open(cmCoupon);
+        addMessage(redirectAttributes, "开启优惠券成功");
+        if ("1".equals(cmCoupon.getCouponsMode())) {
+            return "redirect:" + Global.getAdminPath() + "/coupon/cmCoupon/codeCouponList";
+        }
+        return "redirect:" + Global.getAdminPath() + "/coupon/cmCoupon/list?couponType=" + cmCoupon.getCouponType();
+    }
+
     /**
      * 选择机构页面
      */

+ 2 - 0
src/main/java/com/caimei/modules/hehe/dao/CmHeheCouponDao.java

@@ -43,4 +43,6 @@ public interface CmHeheCouponDao extends CrudDao<CmHeheCoupon> {
     List<CmHeheReceiveUser> receiveUserList(CmHeheReceiveUser cmHeheReceiveUser);
 
     List<CmHeheCoupon> receiveCouponList(CmHeheCoupon cmHeheCoupon);
+
+    void deleteCoupon(String cmHeheCoupon);
 }

+ 8 - 0
src/main/java/com/caimei/modules/hehe/dao/HeHeNewOrderDao.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.hehe.dao;
 
+import com.caimei.modules.hehe.entity.CmHeheCouponOrderRecord;
 import com.caimei.modules.order.entity.NewOrder;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
@@ -19,4 +20,11 @@ public interface HeHeNewOrderDao extends CrudDao<NewOrder> {
      * @return
      */
     String findHeUser(Integer heUserId);
+
+    /**
+     * 查询订单优惠记录
+     * @param orderID
+     * @return
+     */
+    CmHeheCouponOrderRecord findOrderCouponRecord(Integer orderID);
 }

+ 9 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheCoupon.java

@@ -39,6 +39,7 @@ public class CmHeheCoupon extends DataEntity<CmHeheCoupon> {
 	private String orderNo;			//订单号
 	private Integer orderId;		//订单id
 	private Integer userId;			//呵呵商城用户id
+	private Integer cmUserId;		//采美用户id
 
 
 
@@ -244,4 +245,12 @@ public class CmHeheCoupon extends DataEntity<CmHeheCoupon> {
 	public void setValidFlag(Integer validFlag) {
 		this.validFlag = validFlag;
 	}
+
+	public Integer getCmUserId() {
+		return cmUserId;
+	}
+
+	public void setCmUserId(Integer cmUserId) {
+		this.cmUserId = cmUserId;
+	}
 }

+ 96 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheCouponOrderRecord.java

@@ -0,0 +1,96 @@
+package com.caimei.modules.hehe.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/8/20
+ */
+public class CmHeheCouponOrderRecord implements Serializable {
+    private Integer id;
+
+    /**
+     * 订单id
+     */
+    private Integer orderId;
+    /**
+     * 用户领券id(对应cm_receive_coupon)
+     */
+    private Integer receiveCouponId;
+    /**
+     * 劵类型 1活动券 2专享券 3新人券 4好友分享券 5好友消费券
+     */
+    private Integer couponType;
+    /**
+     * 优惠券金额(面值)
+     */
+    private BigDecimal couponAmount;
+    /**
+     * 优惠满减条件金额
+     */
+    private BigDecimal touchPrice;
+    /**
+     * 创建时间
+     */
+    private Date createDate;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getReceiveCouponId() {
+        return receiveCouponId;
+    }
+
+    public void setReceiveCouponId(Integer receiveCouponId) {
+        this.receiveCouponId = receiveCouponId;
+    }
+
+    public Integer getCouponType() {
+        return couponType;
+    }
+
+    public void setCouponType(Integer couponType) {
+        this.couponType = couponType;
+    }
+
+    public BigDecimal getCouponAmount() {
+        return couponAmount;
+    }
+
+    public void setCouponAmount(BigDecimal couponAmount) {
+        this.couponAmount = couponAmount;
+    }
+
+    public BigDecimal getTouchPrice() {
+        return touchPrice;
+    }
+
+    public void setTouchPrice(BigDecimal touchPrice) {
+        this.touchPrice = touchPrice;
+    }
+
+    public Date getCreateDate() {
+        return createDate;
+    }
+
+    public void setCreateDate(Date createDate) {
+        this.createDate = createDate;
+    }
+}

+ 31 - 8
src/main/java/com/caimei/modules/hehe/service/CmHeheCouponService.java

@@ -59,6 +59,18 @@ public class CmHeheCouponService extends CrudService<CmHeheCouponDao, CmHeheCoup
 
 	@Transactional(readOnly = false)
 	public void save(CmHeheCoupon cmHeheCoupon) {
+		if (cmHeheCoupon.getIsNewRecord()) {
+			if (1 == cmHeheCoupon.getStartNowFlag()) {
+				// 新增且立即上架,需要将上架时间更改为当前时间
+				cmHeheCoupon.setStartTime(new Date());
+			}
+		} else {
+			CmHeheCoupon dbCoupon = get(cmHeheCoupon.getId());
+			if (0 == dbCoupon.getStartNowFlag() && 1 == cmHeheCoupon.getStartNowFlag() && new Date().compareTo(dbCoupon.getStartTime()) > 0) {
+				// 原来不是立即上架,修改后是,且当前时间比原上架时间晚,需要将上架时间更改为当前时间
+				cmHeheCoupon.setStartTime(new Date());
+			}
+		}
 		super.save(cmHeheCoupon);
 		Date date = new Date();
 		List<Integer> productIds = cmHeheCouponDao.findCouponProductIds(cmHeheCoupon.getId());
@@ -106,25 +118,36 @@ public class CmHeheCouponService extends CrudService<CmHeheCouponDao, CmHeheCoup
 
 	@Transactional(readOnly = false)
 	public void delete(CmHeheCoupon cmHeheCoupon) {
-		super.delete(cmHeheCoupon);
+		cmHeheCouponDao.deleteCoupon(cmHeheCoupon.getId());
 	}
 
 
 	public void setCouponStatus(CmHeheCoupon cmHeheCoupon) {
 		Date date = new Date();
 		if (cmHeheCoupon != null) {
-			if (date.compareTo(cmHeheCoupon.getStartTime()) < 0) {
-				cmHeheCoupon.setStatus(1);
-			} else if (date.compareTo(cmHeheCoupon.getEndTime()) > 0) {
-				cmHeheCoupon.setStatus(3);
-			} else {
-				cmHeheCoupon.setStatus(2);
+			// 立即开始
+			if (1 == cmHeheCoupon.getStartNowFlag()) {
+				cmHeheCoupon.setStartTime(date);
+			}
+			// 永久有效
+			if (1 == cmHeheCoupon.getPermanentFlag()) {
+				// 只要活动已开始,那就是上架状态
+				cmHeheCoupon.setStatus(date.compareTo(cmHeheCoupon.getStartTime()) < 0 ? 1 : 2);
+			}else {
+				if (date.compareTo(cmHeheCoupon.getStartTime()) < 0) {
+					cmHeheCoupon.setStatus(1);
+				} else if (date.compareTo(cmHeheCoupon.getEndTime()) > 0) {
+					cmHeheCoupon.setStatus(3);
+				} else {
+					cmHeheCoupon.setStatus(2);
+				}
 			}
 		}
 	}
 
 	public Page<Product> findProductList(Page<Product> productPage, Product product) {
 		product.setPage(productPage);
+		product.setSearchType(1);
 		List<Product> productList = cmHeheFloorProductDao.findAllProduct(product);
 		if (productList != null && productList.size() > 0) {
 			productList.forEach(item -> {
@@ -155,7 +178,7 @@ public class CmHeheCouponService extends CrudService<CmHeheCouponDao, CmHeheCoup
 		if (userList != null && userList.size() > 0) {
 			userList.forEach(item -> {
 				item.setUserIds(user.getUserIds());
-				if (StringUtils.isNotBlank(user.getUserIds()) && user.getUserIds().contains(item.getId())) {
+				if (StringUtils.isNotBlank(user.getUserIds()) && user.getUserIds().contains(item.getUserID().toString())) {
 					item.setStoreStatus(true);
 				}
 			});

+ 2 - 1
src/main/java/com/caimei/modules/hehe/service/CmHeheDiscountService.java

@@ -112,6 +112,7 @@ public class CmHeheDiscountService extends CrudService<CmHeheDiscountDao, CmHehe
 
 	public Page<Product> findProductList(Page<Product> productPage, Product product) {
 		product.setPage(productPage);
+		product.setSearchType(1);
 		List<Product> productList = cmHeheFloorProductDao.findAllProduct(product);
 		if (productList != null && productList.size() > 0) {
 			productList.forEach(item -> {
@@ -132,7 +133,7 @@ public class CmHeheDiscountService extends CrudService<CmHeheDiscountDao, CmHehe
 		if (userList != null && userList.size() > 0) {
 			userList.forEach(item -> {
 				item.setUserIds(user.getUserIds());
-				if (StringUtils.isNotBlank(user.getUserIds()) && user.getUserIds().contains(item.getId())) {
+				if (StringUtils.isNotBlank(user.getUserIds()) && user.getUserIds().contains(item.getUserID().toString())) {
 					item.setStoreStatus(true);
 				}
 			});

+ 1 - 0
src/main/java/com/caimei/modules/hehe/service/CmHeheFloorProductService.java

@@ -71,6 +71,7 @@ public class CmHeheFloorProductService extends CrudService<CmHeheFloorProductDao
 		List<Integer> ids = cmHeheFloorProductDao.findFloorProductId(product.getFloorId());
 		product.setIds(ids);
 		product.setPage(productPage);
+		product.setSearchType(2);
 		List<Product> productList = cmHeheFloorProductDao.findAllProduct(product);
 		String wwwServer = Global.getConfig("wwwServer");
 		productList.forEach(item -> {

+ 10 - 0
src/main/java/com/caimei/modules/hehe/service/HeHeNewOrderService.java

@@ -1,6 +1,8 @@
 package com.caimei.modules.hehe.service;
 
+import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
 import com.caimei.modules.hehe.dao.HeHeNewOrderDao;
+import com.caimei.modules.hehe.entity.CmHeheCouponOrderRecord;
 import com.caimei.modules.order.dao.*;
 import com.caimei.modules.order.entity.*;
 import com.caimei.modules.order.service.CmReceiptOrderRelationService;
@@ -77,6 +79,14 @@ public class HeHeNewOrderService extends CrudService<HeHeNewOrderDao, NewOrder>
         else
             newOrder.setRebateOrder("0");
         if (null != newOrder) {
+            // 获取订单优惠记录
+            if (newOrder.getCouponAmount() != null && newOrder.getCouponAmount() > 0) {
+                CmHeheCouponOrderRecord couponRecord = heHeNewOrderDao.findOrderCouponRecord(newOrder.getOrderID());
+                if (couponRecord != null) {
+                    newOrder.setReceiveCouponId(couponRecord.getReceiveCouponId());
+                    newOrder.setHeheCouponRecord(couponRecord);
+                }
+            }
             //获取订单客户
             OrderUserInfo orderUserInfo = orderUserInfoService.findByOrderID(newOrder.getOrderID());
             if (null != orderUserInfo) {

+ 2 - 1
src/main/java/com/caimei/modules/hehe/web/CmHeheCouponController.java

@@ -22,6 +22,7 @@ import com.thinkgem.jeesite.common.utils.StringUtils;
 import com.caimei.modules.hehe.service.CmHeheCouponService;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 呵呵商城优惠券Controller
@@ -82,7 +83,7 @@ public class CmHeheCouponController extends BaseController {
 	public String delete(CmHeheCoupon cmHeheCoupon, RedirectAttributes redirectAttributes) {
 		cmHeheCouponService.delete(cmHeheCoupon);
 		addMessage(redirectAttributes, "删除优惠券成功");
-		return "redirect:"+Global.getAdminPath()+"/hehe/cmHeheCoupon/?repage";
+        return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheCoupon/?repage&couponType=" + cmHeheCoupon.getCouponType();
 	}
 
 	/**

+ 15 - 0
src/main/java/com/caimei/modules/hehe/web/CmHeheProductController.java

@@ -3,6 +3,10 @@ package com.caimei.modules.hehe.web;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.caimei.modules.hehe.entity.CmHeheActivity;
+import com.caimei.modules.hehe.entity.CmHeheFloor;
+import com.caimei.modules.hehe.service.CmHeheActivityService;
+import com.caimei.modules.hehe.service.CmHeheFloorService;
 import com.caimei.modules.product.entity.Product;
 import com.google.common.collect.Maps;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -22,6 +26,7 @@ import com.thinkgem.jeesite.common.utils.StringUtils;
 import com.caimei.modules.hehe.entity.CmHeheProduct;
 import com.caimei.modules.hehe.service.CmHeheProductService;
 
+import java.util.List;
 import java.util.Map;
 
 import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.isInteger;
@@ -39,6 +44,12 @@ public class CmHeheProductController extends BaseController {
     @Autowired
     private CmHeheProductService cmHeheProductService;
 
+    @Autowired
+    private CmHeheFloorService cmHeheFloorService;
+
+    @Autowired
+    private CmHeheActivityService cmHeheActivityService;
+
     @ModelAttribute
     public CmHeheProduct get(@RequestParam(required = false) String id) {
         CmHeheProduct entity = null;
@@ -61,6 +72,10 @@ public class CmHeheProductController extends BaseController {
     @RequestMapping(value = "form")
     public String form(CmHeheProduct cmHeheProduct, Model model) {
         model.addAttribute("cmHeheProduct", cmHeheProduct);
+        List<CmHeheFloor> floorList = cmHeheFloorService.findList(null);
+        model.addAttribute("floorList", floorList);
+        List<CmHeheActivity> activityList = cmHeheActivityService.findList(null);
+        model.addAttribute("activityList", activityList);
         return "modules/hehe/cmHeheProductForm";
     }
 

+ 23 - 0
src/main/java/com/caimei/modules/order/entity/NewOrder.java

@@ -2,6 +2,7 @@ package com.caimei.modules.order.entity;
 
 import com.caimei.modules.bulkpurchase.entity.OrderInvoice;
 import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
+import com.caimei.modules.hehe.entity.CmHeheCouponOrderRecord;
 import com.caimei.modules.product.entity.CmPromotion;
 import com.thinkgem.jeesite.common.persistence.DataEntity;
 
@@ -141,6 +142,12 @@ public class NewOrder extends DataEntity<NewOrder> {
     private CmCouponOrderRecord couponOrderRecord;    //优惠券信息
     private Double svipFullReduction;   //超级会员优惠
 
+    /**
+     * 呵呵商城优惠券
+     */
+    private Integer receiveCouponId;
+    private CmHeheCouponOrderRecord heheCouponRecord;   //优惠券信息
+
     public Integer getClubCouponId() {
         return clubCouponId;
     }
@@ -1059,5 +1066,21 @@ public class NewOrder extends DataEntity<NewOrder> {
     public void setSvipFullReduction(Double svipFullReduction) {
         this.svipFullReduction = svipFullReduction;
     }
+
+    public Integer getReceiveCouponId() {
+        return receiveCouponId;
+    }
+
+    public void setReceiveCouponId(Integer receiveCouponId) {
+        this.receiveCouponId = receiveCouponId;
+    }
+
+    public CmHeheCouponOrderRecord getHeheCouponRecord() {
+        return heheCouponRecord;
+    }
+
+    public void setHeheCouponRecord(CmHeheCouponOrderRecord heheCouponRecord) {
+        this.heheCouponRecord = heheCouponRecord;
+    }
 }
 

+ 9 - 0
src/main/java/com/caimei/modules/order/service/NewOrderService.java

@@ -14,6 +14,8 @@ import com.caimei.modules.coupon.entity.CmCouponClub;
 import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
 import com.caimei.modules.coupon.entity.CmCouponRedemptionCode;
 import com.caimei.modules.coupon.service.CmCouponService;
+import com.caimei.modules.hehe.dao.HeHeNewOrderDao;
+import com.caimei.modules.hehe.entity.CmHeheCouponOrderRecord;
 import com.caimei.modules.miniprogram.utils.UploadPicUtils;
 import com.caimei.modules.order.dao.*;
 import com.caimei.modules.order.entity.*;
@@ -120,6 +122,8 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
     private CmCouponService cmCouponService;
     @Autowired
     private CmCouponClubDao cmCouponClubDao;
+    @Autowired
+    private HeHeNewOrderDao heHeNewOrderDao;
 
     @Transactional(readOnly = false)
     public void updateClauseContent(NewOrder newOrder) {
@@ -1023,6 +1027,11 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                     newOrder.setClubCouponId(couponRecord.getClubCouponId());
                     newOrder.setCouponOrderRecord(couponRecord);
                 }
+                CmHeheCouponOrderRecord heheCouponRecord = heHeNewOrderDao.findOrderCouponRecord(newOrder.getOrderID());
+                if (heheCouponRecord != null) {
+                    newOrder.setReceiveCouponId(heheCouponRecord.getReceiveCouponId());
+                    newOrder.setHeheCouponRecord(heheCouponRecord);
+                }
             }
             //获取订单客户
             OrderUserInfo orderUserInfo = orderUserInfoService.findByOrderID(newOrder.getOrderID());

+ 4 - 2
src/main/java/com/caimei/modules/order/web/CmDiscernReceiptController.java

@@ -21,6 +21,8 @@ import com.thinkgem.jeesite.common.web.BaseController;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -1152,8 +1154,8 @@ public class CmDiscernReceiptController extends BaseController {
 
         //创建单元格,并设置值表头 设置表头居中
         HSSFCellStyle style = wb.createCellStyle();
-        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直
-        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平
+        style.setVerticalAlignment(VerticalAlignment.CENTER);//垂直
+        style.setAlignment(HorizontalAlignment.CENTER);//水平
         style.setFillForegroundColor(HSSFColor.ORANGE.index);
 
         HSSFCellStyle textStyle = wb.createCellStyle();

+ 4 - 2
src/main/java/com/caimei/modules/order/web/NewOrderController.java

@@ -50,6 +50,8 @@ import com.thinkgem.jeesite.common.web.BaseController;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -1640,8 +1642,8 @@ public class NewOrderController extends BaseController {
 
         //创建单元格,并设置值表头 设置表头居中
         HSSFCellStyle style = wb.createCellStyle();
-        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直
-        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平
+        style.setVerticalAlignment(VerticalAlignment.CENTER);//垂直
+        style.setAlignment(HorizontalAlignment.CENTER);//水平
         style.setFillForegroundColor(HSSFColor.ORANGE.index);
 
 

+ 30 - 0
src/main/java/com/caimei/modules/oss/utils/OSSUtils.java

@@ -5,11 +5,14 @@ import com.aliyun.oss.OSSClientBuilder;
 import com.aliyun.oss.model.GetObjectRequest;
 import com.aliyun.oss.model.ObjectMetadata;
 import com.aliyun.oss.model.UploadFileRequest;
+import com.caimei.modules.archive.entity.CmProductArchiveContent;
 import com.thinkgem.jeesite.common.config.Global;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.UUID;
 
@@ -150,6 +153,33 @@ public class OSSUtils {
         return url;
     }
 
+    /**
+     * 生成商品资料库链接
+     * @param archiveFile
+     * @return
+     */
+    public static String generateProductArchiveUrl(CmProductArchiveContent archiveFile) {
+        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+        String ossName = archiveFile.getOssName();
+        // 设置URL过期时间为1个小时
+        Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000);
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            Date dateOne = format.parse("2021-06-01 00:00:00");
+            Date dateTwo = format.parse("2021-09-17 18:00:00");
+            String active = "product".equals(config) ? "prod" : config;
+            if (archiveFile.getUploadTime() != null && archiveFile.getUploadTime().compareTo(dateOne) > 0 && archiveFile.getUploadTime().compareTo(dateTwo) < 0) {
+                ossName = active + "/" + ossName;
+            } else if (archiveFile.getUploadTime() != null && archiveFile.getUploadTime().compareTo(dateTwo)>0){
+                ossName = active + "/archiveFile/" + ossName;
+            }
+        } catch (ParseException e) {
+        }
+        String url = ossClient.generatePresignedUrl(privateBucket, ossName, expiration).toString();
+        ossClient.shutdown();
+        return url;
+    }
+
     /**
      * oss单个文件删除
      *

+ 13 - 0
src/main/java/com/caimei/modules/product/entity/Product.java

@@ -299,6 +299,11 @@ public class Product extends DataEntity<Product> {
      */
     private List<ProductLadderPrice> ladderPriceList;
 
+    /**
+     * 搜索类型:1采美商品,2呵呵商城商品
+     */
+    private Integer searchType;
+
     public List<ProductLadderPrice> getLadderPriceList() {
         return ladderPriceList;
     }
@@ -1891,4 +1896,12 @@ public class Product extends DataEntity<Product> {
     public void setSvipFlag(Integer svipFlag) {
         this.svipFlag = svipFlag;
     }
+
+    public Integer getSearchType() {
+        return searchType;
+    }
+
+    public void setSearchType(Integer searchType) {
+        this.searchType = searchType;
+    }
 }

+ 16 - 24
src/main/java/com/thinkgem/jeesite/common/utils/excel/ExportExcel.java

@@ -19,15 +19,7 @@ import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Comment;
-import org.apache.poi.ss.usermodel.DataFormat;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
@@ -235,26 +227,26 @@ public class ExportExcel {
 	 */
 	private Map<String, CellStyle> createStyles(Workbook wb) {
 		Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
-		
+
 		CellStyle style = wb.createCellStyle();
-		style.setAlignment(CellStyle.ALIGN_CENTER);
-		style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+		style.setAlignment(HorizontalAlignment.CENTER);
+		style.setVerticalAlignment(VerticalAlignment.CENTER);
 		Font titleFont = wb.createFont();
 		titleFont.setFontName("Arial");
 		titleFont.setFontHeightInPoints((short) 16);
-		titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
+		titleFont.setBold(true);
 		style.setFont(titleFont);
 		styles.put("title", style);
 
 		style = wb.createCellStyle();
-		style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
-		style.setBorderRight(CellStyle.BORDER_THIN);
+		style.setVerticalAlignment(VerticalAlignment.CENTER);
+		style.setBorderRight(BorderStyle.THIN);
 		style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
-		style.setBorderLeft(CellStyle.BORDER_THIN);
+		style.setBorderLeft(BorderStyle.THIN);
 		style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
-		style.setBorderTop(CellStyle.BORDER_THIN);
+		style.setBorderTop(BorderStyle.THIN);
 		style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
-		style.setBorderBottom(CellStyle.BORDER_THIN);
+		style.setBorderBottom(BorderStyle.THIN);
 		style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
 		Font dataFont = wb.createFont();
 		dataFont.setFontName("Arial");
@@ -264,29 +256,29 @@ public class ExportExcel {
 		
 		style = wb.createCellStyle();
 		style.cloneStyleFrom(styles.get("data"));
-		style.setAlignment(CellStyle.ALIGN_LEFT);
+		style.setAlignment(HorizontalAlignment.LEFT);
 		styles.put("data1", style);
 
 		style = wb.createCellStyle();
 		style.cloneStyleFrom(styles.get("data"));
-		style.setAlignment(CellStyle.ALIGN_CENTER);
+		style.setAlignment(HorizontalAlignment.CENTER);
 		styles.put("data2", style);
 
 		style = wb.createCellStyle();
 		style.cloneStyleFrom(styles.get("data"));
-		style.setAlignment(CellStyle.ALIGN_RIGHT);
+		style.setAlignment(HorizontalAlignment.RIGHT);
 		styles.put("data3", style);
 		
 		style = wb.createCellStyle();
 		style.cloneStyleFrom(styles.get("data"));
 //		style.setWrapText(true);
-		style.setAlignment(CellStyle.ALIGN_CENTER);
+		style.setAlignment(HorizontalAlignment.CENTER);
 		style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
-		style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+		style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
 		Font headerFont = wb.createFont();
 		headerFont.setFontName("Arial");
 		headerFont.setFontHeightInPoints((short) 10);
-		headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
+		headerFont.setBold(true);
 		headerFont.setColor(IndexedColors.WHITE.getIndex());
 		style.setFont(headerFont);
 		styles.put("header", style);

+ 1 - 1
src/main/resources/config/beta/caimei.properties

@@ -183,4 +183,4 @@ aliyun.bucketName=caimei-oss
 aliyun.endpoint=https://oss-cn-shenzhen.aliyuncs.com
 
 #商品资料库html文件临时路径
-archive.htmlTempPath=/mnt/newdatadrive/data/runtime/tomcat-instance/manager/temphtml/
+archive.tempPath=/mnt/newdatadrive/data/runtime/tomcat-instance/manager/tempFile/

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

@@ -196,5 +196,5 @@ aliyun.bucketName=caimei-oss
 aliyun.endpoint=https://oss-cn-shenzhen.aliyuncs.com
 
 #商品资料库html文件临时路径
-archive.htmlTempPath=D:\\poi-test\\wordToHtml\\
+archive.tempPath=D:\\poi-test\\tempFile\\
 

+ 6 - 3
src/main/resources/mappings/modules/archive/CmOrderArchiveMapper.xml

@@ -13,11 +13,13 @@
 		a.rebateFlag AS "rebateFlag",
 		a.remark AS "remark",
 		a.addTime AS "addTime",
-		so.orderID AS "orderId"
+		so.orderID AS "orderId",
+        co.status AS "orderStatus"
     </sql>
 
     <sql id="cmOrderArchiveJoins">
         left join cm_shop_order so on a.shopOrderId = so.shopOrderID
+        left join cm_order co on so.orderID = co.orderID
     </sql>
 
     <select id="get" resultType="CmOrderArchive">
@@ -30,11 +32,11 @@
 
     <select id="findList" resultType="CmOrderArchive">
         SELECT
-        <include refid="cmOrderArchiveColumns"/>
+        <include refid="cmOrderArchiveColumns"/>,count(*) as fileNum
         FROM cm_order_archive a
         <include refid="cmOrderArchiveJoins"/>
+        left join cm_order_archive_file coaf on a.id = coaf.orderArchiveId
         <where>
-
             <if test="archiveNo != null and archiveNo != ''">
                 AND a.archiveNo LIKE
                 <if test="dbName == 'oracle'">'%'||#{archiveNo}||'%'</if>
@@ -72,6 +74,7 @@
                 AND a.rebateFlag = #{rebateFlag}
             </if>
         </where>
+        group by a.id
         <choose>
             <when test="page !=null and page.orderBy != null and page.orderBy != ''">
                 ORDER BY ${page.orderBy}

+ 6 - 1
src/main/resources/mappings/modules/archive/CmProductArchiveContentMapper.xml

@@ -7,10 +7,15 @@
 		a.productArchiveId AS "productArchiveId",
 		a.title AS "title",
 		a.type AS "type",
-		a.addTime AS "addTime"
+		a.addTime AS "addTime",
+		cf.ossName,
+		cf.fileName,
+		cf.uploadTime,
+		cf.ossUrl
 	</sql>
 	
 	<sql id="cmProductArchiveContentJoins">
+		left join cm_product_archive_file cf on a.id = cf.archiveContentId and a.type != 1
 	</sql>
     
 	<select id="get" resultType="CmProductArchiveContent">

+ 15 - 2
src/main/resources/mappings/modules/coupon/CmCouponMapper.xml

@@ -9,6 +9,9 @@
 		a.touchPrice AS "touchPrice",
 		a.startDate AS "startDate",
 		a.endDate AS "endDate",
+		a.receivePeriod,
+		a.receiveFlag,
+		a.usePeriod,
 		a.status AS "status",
 		a.couponType AS "couponType",
 		a.vipFlag AS "vipFlag",
@@ -135,6 +138,9 @@
 			touchPrice,
 			startDate,
 			endDate,
+			receivePeriod,
+		    receiveFlag,
+			usePeriod,
 			status,
 			couponType,
 			vipFlag,
@@ -153,6 +159,9 @@
 			#{touchPrice},
 			#{startDate},
 			#{endDate},
+			#{receivePeriod},
+			#{receiveFlag},
+			#{usePeriod},
 			#{status},
 			#{couponType},
 		    #{vipFlag},
@@ -175,6 +184,9 @@
 			touchPrice = #{touchPrice},
 			startDate = #{startDate},
 			endDate = #{endDate},
+			receivePeriod = #{receivePeriod},
+			receiveFlag = #{receiveFlag},
+			usePeriod = #{usePeriod},
 			status = #{status},
 			couponType = #{couponType},
 			vipFlag = #{vipFlag},
@@ -408,6 +420,8 @@
 		  cc.`touchPrice`,
 		  cc.`startDate`,
 		  cc.`endDate`,
+		  a.`createDate` as `receiveDate`,
+		  date_add(a.createDate,interval cc.usePeriod DAY) as `useEndDate`,
 		  cc.`status`,
 		  cc.`couponType`,
 		  cc.`userId`,
@@ -430,8 +444,7 @@
 		  AND a.delFlag = 0
 		  AND a.userId = #{userId}
 		  AND a.status = 1
-		  AND NOW() BETWEEN cc.startDate
-		  AND cc.endDate
+		  AND NOW() <![CDATA[ < ]]> date_add(a.createDate,interval cc.usePeriod DAY)
 		  AND cc.status != 2
 		ORDER BY
 		  a.createDate DESC

+ 15 - 7
src/main/resources/mappings/modules/hehe/CmHeheCouponMapper.xml

@@ -100,7 +100,7 @@
 			p.mainImage AS image
 		FROM
 			cm_hehe_coupon_product cca
-			    left join cm_hehe_product chp on cca.productId = chp.id
+			    left join cm_hehe_product chp on cca.productId = chp.productId
 				LEFT JOIN product p ON chp.productId = p.productID
 				LEFT JOIN shop s ON p.shopID = s.shopID
 		WHERE
@@ -109,7 +109,7 @@
 			- sort DESC
 	</select>
 	<select id="findAllUser" resultType="com.caimei.modules.user.entity.CmUser">
-		select id, nickName,mobile,userIdentity,openId as openID
+		select userId as userID, nickName,mobile,userIdentity,openId as openID
 		from cm_hehe_user
 		<where>
 			<if test="mobile != null and mobile != ''">
@@ -130,14 +130,14 @@
 	<select id="findCouponUserList" resultType="com.caimei.modules.hehe.entity.CmHeheCouponUser">
 		select chu.id, chu.userId, chu.couponId, chu.addTime, u.nickName, u.mobile, u.userIdentity
 		from cm_hehe_coupon_user chu
-				 left join cm_hehe_user u on chu.userId = u.id
+				 left join cm_hehe_user u on chu.userId = u.userId
 		where chu.couponId = #{id}
 		order by chu.addTime desc
 	</select>
 	<select id="allUserList" resultType="com.caimei.modules.hehe.entity.CmHeheReceiveUser">
-		select u.id as userId,u.nickName,u.mobile,u.userIdentity,count(rc.id) as receiveNum, count(chc.id) as ableNum
+		select u.userId as userId,u.nickName,u.mobile,u.userIdentity,count(rc.id) as receiveNum, count(chc.id) as ableNum
 		from cm_hehe_user u
-		    left join cm_hehe_receive_coupon rc on u.id = rc.userId and rc.delFlag = 0
+		    left join cm_hehe_receive_coupon rc on u.userId = rc.userId and rc.delFlag = 0
 			left join cm_hehe_coupon chc on rc.couponId = chc.id
 			and NOW() <![CDATA[ < ]]> DATE_ADD(rc.receiveTime ,interval chc.usePeriod DAY)
 			and chc.delFlag = 0
@@ -168,7 +168,7 @@
 		       chrc.useTime,
 		       chrc.orderId
 		from cm_hehe_user chu
-				 left join cm_hehe_receive_coupon chrc on chu.id = chrc.userId
+				 left join cm_hehe_receive_coupon chrc on chu.userId = chrc.userId
 				 left join cm_hehe_coupon chc on chrc.couponId = chc.id
 		<where>
 			chrc.couponId = #{couponId}
@@ -199,9 +199,14 @@
 				chrc.useTime,co.orderNo,co.orderID as orderId
 		from cm_hehe_coupon chc
 		left join cm_hehe_receive_coupon chrc on chc.id = chrc.couponId
+		left join cm_hehe_user chu on chrc.userId = chu.userId
 		left join cm_order co on chrc.orderId = co.orderID
 		<where>
-			chrc.userId = #{userId}
+			<if test="userId != null">
+				chrc.userId = #{userId}
+			</if>
+			and chrc.delFlag = 0
+			and chc.delFlag = 0
 			<if test="name != null and name !=''">
 				and chc.name like concat('%',#{name},'%')
 			</if>
@@ -314,5 +319,8 @@
 	<delete id="deleteCouponUser">
 		delete from cm_hehe_coupon_user where id = #{id}
 	</delete>
+	<update id="deleteCoupon">
+		update cm_hehe_coupon set delFlag = 1 where id = #{id}
+	</update>
 
 </mapper>

+ 4 - 4
src/main/resources/mappings/modules/hehe/CmHeheDiscountMapper.xml

@@ -77,7 +77,7 @@
 			#{discount},
 			#{status},
 			#{productType},
-			#{addTime}
+			NOW()
 		)
 	</insert>
 	
@@ -117,7 +117,7 @@
 		VALUES
 		(
 			#{discountId}, #{productId}, #{status},
-			#{sort}, NOW()
+			#{sort}, #{addTime}
 		)
 	</insert>
 	<insert id="insertDiscountUser">
@@ -158,7 +158,7 @@
 			p.mainImage AS image
 		FROM
 			cm_hehe_discount_product cca
-				left join cm_hehe_product chp on cca.productId = chp.id
+				left join cm_hehe_product chp on cca.productId = chp.productId
 				LEFT JOIN product p ON chp.productId = p.productID
 				LEFT JOIN shop s ON p.shopID = s.shopID
 		WHERE
@@ -169,7 +169,7 @@
 	<select id="findDiscountUserList" resultType="com.caimei.modules.hehe.entity.CmHeheDiscountUser">
 		select chu.id, chu.userId, chu.discountId, chu.addTime, u.nickName, u.mobile, u.userIdentity
 		from cm_hehe_discount_user chu
-				 left join cm_hehe_user u on chu.userId = u.id
+				 left join cm_hehe_user u on chu.userId = u.userId
 		where chu.discountId = #{id}
 		order by chu.addTime desc
 	</select>

+ 8 - 1
src/main/resources/mappings/modules/hehe/CmHeheFloorProductMapper.xml

@@ -88,7 +88,14 @@
 		select productId from cm_hehe_floor_product where floorId = #{floorId}
 	</select>
 	<select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
-		select hp.id as productID,p.mainImage,p.name,s.name as shopName
+		select
+		       <if test="searchType == 1">
+				   hp.productId as productID,
+			   </if>
+		       <if test="searchType != 1">
+				   hp.id as productID,
+			   </if>
+		       p.mainImage,p.name,s.name as shopName
 		       from cm_hehe_product hp left join product p on hp.productId = p.productID
 				left join shop s on p.shopID = s.shopID
 		<where>

+ 14 - 0
src/main/resources/mappings/modules/hehe/HeHeNewOrderMapper.xml

@@ -249,5 +249,19 @@
     <select id="findHeUser" resultType="string">
         SELECT IFNULL(name,nickName) FROM cm_hehe_user WHERE userId = #{heUserId}
     </select>
+    <select id="findOrderCouponRecord" resultType="com.caimei.modules.hehe.entity.CmHeheCouponOrderRecord">
+        SELECT
+            `id`,
+            `orderId`,
+            `receiveCouponId`,
+            `couponType`,
+            `couponAmount`,
+            `touchPrice`,
+            `createDate`
+        FROM
+            cm_hehe_coupon_order_record
+        WHERE
+            orderId = #{orderID}
+    </select>
 
 </mapper>

+ 3 - 1
src/main/webapp/WEB-INF/views/modules/archive/addFileForm.jsp

@@ -224,6 +224,7 @@
 
         //点击上传按钮后上传文件
         $('#addSubmit').click(function () {
+            debugger
             var filesById = document.getElementById('archiveFile');
             var files = $('#archiveFile');
             var fileList = files.prop('files');
@@ -237,7 +238,8 @@
             data.append('fileName', fileName);
             $('.upload-loading').css("display", "inline");
             $.ajax({
-                url: "${ctx}/archive/cmProductArchiveContent/upload",
+                url: "${ctx}/archive/cmProductArchiveContent/addWaterMark",
+                <%--url: "${ctx}/archive/cmProductArchiveContent/upload",--%>
                 data: data,
                 type: "POST",
                 processData: false,

+ 17 - 3
src/main/webapp/WEB-INF/views/modules/archive/cmOrderArchiveList.jsp

@@ -73,6 +73,12 @@
         <form:input path="clubName" htmlEscape="false" maxlength="55" class="input-medium"/>
         <label>商品标签:</label>
         <form:input path="tag" htmlEscape="false" class="input-medium"/>
+        <label>订单状态:</label>
+        <form:select path="orderStatus" class="select-ele input-medium required">
+            <form:option value="" label="所有"/>
+            <form:options items="${fns:getDictList('order_status')}" itemLabel="label" itemValue="value"
+                          htmlEscape="false"/>
+        </form:select>
         <label>返佣订单:</label>
         <form:select path="rebateFlag" class="input-medium">
             <form:option value="" label="请选择"/>
@@ -92,7 +98,8 @@
         <th>序号</th>
         <th>订单资料编号</th>
         <th>订单资料标题</th>
-        <th>子订单ID</th>
+        <th>子订单ID/母订单ID</th>
+        <th>母订单状态</th>
         <th>供应商名称</th>
         <th>机构名称</th>
         <th>商品标签</th>
@@ -113,9 +120,16 @@
             </td>
             <td>
                 <a href="${ctx}/order/detail?id=${cmOrderArchive.orderId}">
-                        ${cmOrderArchive.shopOrderId}
+                        ${cmOrderArchive.shopOrderId}/${cmOrderArchive.orderId}
                 </a>
             </td>
+            <td>
+                <c:if test="${cmOrderArchive.orderStatus eq 11 || cmOrderArchive.orderStatus eq 12 || cmOrderArchive.orderStatus eq 13 ||cmOrderArchive.orderStatus eq 21 ||cmOrderArchive.orderStatus eq 22 ||
+				cmOrderArchive.orderStatus eq 23 || cmOrderArchive.orderStatus eq 31 ||cmOrderArchive.orderStatus eq 32 ||cmOrderArchive.orderStatus eq 33}">
+                    交易中<br>(${fns:getDictLabel(cmOrderArchive.orderStatus,"order_detail_status","" )})
+                </c:if>
+                <c:if test="${cmOrderArchive.orderStatus eq 0 || cmOrderArchive.orderStatus eq 4 || cmOrderArchive.orderStatus eq 5 || cmOrderArchive.orderStatus eq 6 || cmOrderArchive.orderStatus eq 7}">${fns:getDictLabel(cmOrderArchive.orderStatus,"order_detail_status","" )}</c:if>
+            </td>
             <td>
                     ${cmOrderArchive.shopName}
             </td>
@@ -135,7 +149,7 @@
                 <a href="${ctx}/archive/cmOrderArchive/form?id=${cmOrderArchive.id}">编辑</a>
                 <a href="${ctx}/archive/cmOrderArchive/delete?id=${cmOrderArchive.id}"
                    onclick="return confirmx('确认要删除该数据吗?', this.href)">删除</a>
-                <a href="JavaScript:;" onclick="showArchiveList(${cmOrderArchive.id})">资料列表</a>
+                <a href="JavaScript:;" onclick="showArchiveList(${cmOrderArchive.id})">资料列表(${cmOrderArchive.fileNum})</a>
             </td>
         </tr>
     </c:forEach>

+ 31 - 0
src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveContentList.jsp

@@ -62,6 +62,12 @@
 				<td>
     				<a onclick="showAddForm(${cmProductArchiveContent.id},${cmProductArchiveContent.type},${cmProductArchiveContent.productArchiveId})">编辑</a>
 					<a href="${ctx}/archive/cmProductArchiveContent/delete?id=${cmProductArchiveContent.id}" onclick="return confirmx('确认要删除该资料吗?', this.href)">删除</a>
+					<c:if test="${cmProductArchiveContent.type eq 2}">
+						<a href="javascript:;" onclick="previewVideo('${cmProductArchiveContent.fileUrl}')">播放</a>
+					</c:if>
+					<c:if test="${cmProductArchiveContent.type eq 3}">
+						<a href="javascript:;" onclick="previewFile('${cmProductArchiveContent.fileUrl}')">预览</a>
+					</c:if>
 				</td>
 			</tr>
 		</c:forEach>
@@ -120,6 +126,31 @@
 			});
 		}
 	}
+
+
+	function previewFile(url) {
+		var index = url.lastIndexOf(".");
+		var suffix = url.substring(index);
+		if (suffix.startsWith(".png") || suffix.startsWith(".jpg") || suffix.startsWith(".pdf")) {
+			window.open(url, '_blank');
+		} else {
+			var previewUrl = "https://view.officeapps.live.com/op/view.aspx?src="+encodeURIComponent(url);
+			window.open(previewUrl, '_blank');
+		}
+	}
+
+	function previewVideo(url) {
+		var url = "${ctx}/archive/cmProductArchiveContent/preview?url=" + url;
+		var title = "视频播放";
+		top.$.jBox("iframe:" + url, {
+			iframeScrolling: 'yes',
+			width: 800,
+			height: 300,
+			persistent: true,
+			title: title,
+			buttons: {"关闭": '-1'}
+		});
+	}
 </script>
 </body>
 </html>

+ 12 - 0
src/main/webapp/WEB-INF/views/modules/archive/previewFilePage.jsp

@@ -0,0 +1,12 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>预览文件页面</title>
+    <meta name="decorator" content="default"/>
+</head>
+<body>
+<video src="${url}"/>
+</body>
+</html>
+

+ 7 - 0
src/main/webapp/WEB-INF/views/modules/bulkpurchase/applyRefoundForm.jsp

@@ -361,6 +361,13 @@
                         <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(新用户券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
                     </c:if>
                 </c:if>
+                <c:if test="${not empty order.heheCouponRecord}">
+                    <a href="${ctx}/hehe/coupon/receiveDetails?userId=${order.userID}">
+                        <font color="red">
+                            (${order.heheCouponRecord.couponType eq 1 ? '活动':order.heheCouponRecord.couponType eq 2?'专享':order.heheCouponRecord.couponType eq 3?'新人':order.heheCouponRecord.couponType eq 4?'好友分享':'好友消费'}券抵扣¥${order.heheCouponRecord.couponAmount},满${order.heheCouponRecord.touchPrice}减${order.heheCouponRecord.couponAmount})
+                        </font>
+                    </a>
+                </c:if>
             </td>
             <td>
                 应收总额:¥<fmt:formatNumber type="number" value="${order.payableAmount}" pattern="0.00" maxFractionDigits="2" />(账户余额抵扣:${order.balancePayFee})

+ 7 - 0
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderConfirmReturnRecord.jsp

@@ -262,6 +262,13 @@
                     <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(新用户券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
                 </c:if>
             </c:if>
+            <c:if test="${not empty order.heheCouponRecord}">
+                <a href="${ctx}/hehe/coupon/receiveDetails?userId=${order.userID}">
+                    <font color="red">
+                        (${order.heheCouponRecord.couponType eq 1 ? '活动':order.heheCouponRecord.couponType eq 2?'专享':order.heheCouponRecord.couponType eq 3?'新人':order.heheCouponRecord.couponType eq 4?'好友分享':'好友消费'}券抵扣¥${order.heheCouponRecord.couponAmount},满${order.heheCouponRecord.touchPrice}减${order.heheCouponRecord.couponAmount})
+                    </font>
+                </a>
+            </c:if>
         </td>
         <td>
             应收总额:¥<fmt:formatNumber type="number" value="${order.payableAmount}" pattern="0.00" maxFractionDigits="2"/>(账户余额抵扣:${order.balancePayFee})

+ 7 - 0
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReturnRecord.jsp

@@ -372,6 +372,13 @@
                             <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(新用户券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
                         </c:if>
                     </c:if>
+                    <c:if test="${not empty order.heheCouponRecord}">
+                        <a href="${ctx}/hehe/coupon/receiveDetails?userId=${order.userID}">
+                            <font color="red">
+                                (${order.heheCouponRecord.couponType eq 1 ? '活动':order.heheCouponRecord.couponType eq 2?'专享':order.heheCouponRecord.couponType eq 3?'新人':order.heheCouponRecord.couponType eq 4?'好友分享':'好友消费'}券抵扣¥${order.heheCouponRecord.couponAmount},满${order.heheCouponRecord.touchPrice}减${order.heheCouponRecord.couponAmount})
+                            </font>
+                        </a>
+                    </c:if>
                 </td>
                 <td>
                     应收总额:¥<fmt:formatNumber type="number" value="${order.payableAmount}" pattern="0.00" maxFractionDigits="2" />(账户余额抵扣:${order.balancePayFee})

+ 7 - 0
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReviewReturnRecord.jsp

@@ -342,6 +342,13 @@
                     <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(新用户券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
                 </c:if>
             </c:if>
+            <c:if test="${not empty order.heheCouponRecord}">
+                <a href="${ctx}/hehe/coupon/receiveDetails?userId=${order.userID}">
+                    <font color="red">
+                        (${order.heheCouponRecord.couponType eq 1 ? '活动':order.heheCouponRecord.couponType eq 2?'专享':order.heheCouponRecord.couponType eq 3?'新人':order.heheCouponRecord.couponType eq 4?'好友分享':'好友消费'}券抵扣¥${order.heheCouponRecord.couponAmount},满${order.heheCouponRecord.touchPrice}减${order.heheCouponRecord.couponAmount})
+                    </font>
+                </a>
+            </c:if>
         </td>
         <td>
             应收总额:¥<fmt:formatNumber type="number" value="${order.payableAmount}" pattern="0.00" maxFractionDigits="2" />(账户余额抵扣:${order.balancePayFee})

+ 7 - 0
src/main/webapp/WEB-INF/views/modules/bulkpurchase/refundRecord.jsp

@@ -186,6 +186,13 @@
                     <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${order.userID}"><font color="red">(新用户券抵扣¥${order.couponOrderRecord.couponAmount},满${order.couponOrderRecord.touchPrice}减${order.couponOrderRecord.couponAmount})</font></a>
                 </c:if>
             </c:if>
+            <c:if test="${not empty order.heheCouponRecord}">
+                <a href="${ctx}/hehe/coupon/receiveDetails?userId=${order.userID}">
+                    <font color="red">
+                        (${order.heheCouponRecord.couponType eq 1 ? '活动':order.heheCouponRecord.couponType eq 2?'专享':order.heheCouponRecord.couponType eq 3?'新人':order.heheCouponRecord.couponType eq 4?'好友分享':'好友消费'}券抵扣¥${order.heheCouponRecord.couponAmount},满${order.heheCouponRecord.touchPrice}减${order.heheCouponRecord.couponAmount})
+                    </font>
+                </a>
+            </c:if>
         </td>
         <td>
             应收总额:¥${order.payableAmount}

+ 70 - 1
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponForm.jsp

@@ -120,6 +120,7 @@
 		<form:hidden path="productInfo" id="productInfo"/>
 		<input type="hidden" name="couponType" value="0"/>
 		<sys:message content="${message}"/>
+		<form:hidden path="receiveFlag"/>
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>活动主题:</label>
 			<div class="controls">
@@ -154,6 +155,21 @@
 					onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});" onblur="dateShow()"/>
 			</div>
 		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>领取期限:</label>
+			<div class="controls">
+				<input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmCoupon.receivePeriod}" min="1" required> 天
+				<input type="checkbox" id="receiveFlag" name="receiveFlag" style="margin-left:20px !important" value="${cmCoupon.receiveFlag eq 1?1:0}"
+					${cmCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition('receiveFlag','receivePeriod')" />同活动开始-结束时间
+				<input id="receivePeriodTemp" type="hidden" value="${cmCoupon.receivePeriod}">
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>使用期限:</label>
+			<div class="controls">
+				<input type="number" id="usePeriod" name="usePeriod" value="${cmCoupon.usePeriod}" min="1" required> 天
+			</div>
+		</div>
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>优惠状态:</label>
 			<div class="controls">
@@ -302,7 +318,9 @@
 				}
 			}, 500);
 		});
-		productShow()
+		productShow();
+
+		initInputDisplay();
 	});
 
 	var productIds = '';
@@ -561,6 +579,57 @@
 	function onlynum(obj) {
 		obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
 	}
+
+	function changeCondition(flag, name) {
+		var obj = $("#" + flag);
+		var val = obj.val();
+		if (val === '1') {
+			obj.val(0);
+			val = '0';
+		} else {
+			obj.val(1);
+			val = '1';
+		}
+		var inputObj = $("#" + name);
+		// 临时数据
+		var tempObj = $("#" + name + "Temp");
+		if (name.indexOf("Time") !== -1) {
+			//修改时间
+			if (val === '1') {
+				inputObj.attr('onclick', '');
+				inputObj.removeClass('required');
+			} else {
+				inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
+				inputObj.addClass('required');
+			}
+		}else {
+			if (val === '1') {
+				inputObj.attr('readonly', true);
+				inputObj.attr('required', false);
+			} else {
+				inputObj.attr('readonly', false);
+				inputObj.attr('required', true);
+			}
+		}
+		if (val === '1') {
+			tempObj.val(inputObj.val());
+			inputObj.val('');
+		} else {
+			inputObj.val(tempObj.val());
+			tempObj.val('');
+		}
+	}
+
+	function initInputDisplay() {
+		var receiveFlag = $("#receiveFlag").val();
+		if (receiveFlag === '1') {
+			$("#receivePeriod").attr('readonly', true);
+			$("#receivePeriod").attr('required', false);
+		} else {
+			$("#receivePeriod").attr('readonly', false);
+			$("#receivePeriod").attr('required', true);
+		}
+	}
 </script>
 </body>
 </html>

+ 13 - 8
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponList.jsp

@@ -38,10 +38,10 @@
 			<label>优惠状态:</label>
 			<form:select path="status" class="input-medium required">
 				<form:option value="" label="所有"/>
-				<form:option value="0" label="未生效"/>
-				<form:option value="1" label="已生效"/>
+				<form:option value="0" label="待上架"/>
+				<form:option value="1" label="已上架"/>
+				<form:option value="3" label="已下架"/>
 				<form:option value="2" label="已关闭"/>
-				<form:option value="3" label="已失效"/>
 			</form:select>
 			 <label>优惠时间:</label>
 				<input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
@@ -87,16 +87,16 @@
 				</td>
 				<td>
 					<c:if test="${cmCoupon.status eq 0}">
-						<font color="#800080">未生效</font>
+						<font color="#800080">待上架</font>
 					</c:if>
 					<c:if test="${cmCoupon.status eq 1}">
-						<font color="#00CC66">已生效</font>
+						<font color="#00CC66">已上架</font>
 					</c:if>
 					<c:if test="${cmCoupon.status eq 2}">
 						<font color="red">已关闭</font>
 					</c:if>
 					<c:if test="${cmCoupon.status eq 3}">
-						<font color="#FF6600">已失效</font>
+						<font color="#FF6600">已下架</font>
 					</c:if>
 				</td>
 				<td>
@@ -110,8 +110,13 @@
 				</td>
 				<td>
     				<a href="${ctx}/coupon/cmCoupon/form?id=${cmCoupon.id}">编辑</a>
-					<a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该优惠券吗?', this.href)">关闭</a>
-					<a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该优惠券吗?', this.href)">删除</a>
+					<c:if test="${cmCoupon.status eq 2}">
+						<a href="${ctx}/coupon/cmCoupon/open?id=${cmCoupon.id}" onclick="return confirmx('确定开启该活动吗?', this.href)">开启</a>
+					</c:if>
+					<c:if test="${cmCoupon.status ne 2}">
+						<a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该活动吗?', this.href)">关闭</a>
+					</c:if>
+					<a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该活动吗?', this.href)">删除</a>
 					<a href="${ctx}/coupon/cmCouponClub/list?couponId=${cmCoupon.id}&couponType=0">领取用户</a>
 				</td>
 			</tr>

+ 71 - 0
src/main/webapp/WEB-INF/views/modules/coupon/couponCategoryForm.jsp

@@ -49,6 +49,7 @@
     <form:hidden path="productInfo" id="productInfo"/>
     <input type="hidden" name="couponType" value="1"/>
     <sys:message content="${message}"/>
+    <form:hidden path="receiveFlag"/>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>活动主题:</label>
         <div class="controls">
@@ -90,6 +91,21 @@
                    onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});" onblur="dateShow()"/>
         </div>
     </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>领取期限:</label>
+        <div class="controls">
+            <input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmCoupon.receivePeriod}" min="1" required> 天
+            <input type="checkbox" id="receiveFlag" name="receiveFlag" style="margin-left:20px !important" value="${cmCoupon.receiveFlag eq 1?1:0}"
+                ${cmCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition('receiveFlag','receivePeriod')" />同活动开始-结束时间
+            <input id="receivePeriodTemp" type="hidden" value="${cmCoupon.receivePeriod}">
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>使用期限:</label>
+        <div class="controls">
+            <input type="number" id="usePeriod" name="usePeriod" value="${cmCoupon.usePeriod}" min="1" required> 天
+        </div>
+    </div>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>优惠状态:</label>
         <div class="controls">
@@ -120,6 +136,10 @@
     </div>
 </form:form>
 <script>
+    $(function () {
+        initInputDisplay();
+    })
+
     function statusShow() {
         var status = $("input[name='status']:checked").val();
         if (status == 2) {
@@ -154,6 +174,57 @@
     function onlynum(obj) {
         obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
     }
+
+    function changeCondition(flag, name) {
+        var obj = $("#" + flag);
+        var val = obj.val();
+        if (val === '1') {
+            obj.val(0);
+            val = '0';
+        } else {
+            obj.val(1);
+            val = '1';
+        }
+        var inputObj = $("#" + name);
+        // 临时数据
+        var tempObj = $("#" + name + "Temp");
+        if (name.indexOf("Time") !== -1) {
+            //修改时间
+            if (val === '1') {
+                inputObj.attr('onclick', '');
+                inputObj.removeClass('required');
+            } else {
+                inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
+                inputObj.addClass('required');
+            }
+        }else {
+            if (val === '1') {
+                inputObj.attr('readonly', true);
+                inputObj.attr('required', false);
+            } else {
+                inputObj.attr('readonly', false);
+                inputObj.attr('required', true);
+            }
+        }
+        if (val === '1') {
+            tempObj.val(inputObj.val());
+            inputObj.val('');
+        } else {
+            inputObj.val(tempObj.val());
+            tempObj.val('');
+        }
+    }
+
+    function initInputDisplay() {
+        var receiveFlag = $("#receiveFlag").val();
+        if (receiveFlag === '1') {
+            $("#receivePeriod").attr('readonly', true);
+            $("#receivePeriod").attr('required', false);
+        } else {
+            $("#receivePeriod").attr('readonly', false);
+            $("#receivePeriod").attr('required', true);
+        }
+    }
 </script>
 </body>
 </html>

+ 13 - 8
src/main/webapp/WEB-INF/views/modules/coupon/couponCategoryList.jsp

@@ -38,10 +38,10 @@
         <label>优惠状态:</label>
         <form:select path="status" class="input-medium required">
             <form:option value="" label="所有"/>
-            <form:option value="0" label="未生效"/>
-            <form:option value="1" label="已生效"/>
+            <form:option value="0" label="待上架"/>
+            <form:option value="1" label="已上架"/>
+            <form:option value="3" label="已下架"/>
             <form:option value="2" label="已关闭"/>
-            <form:option value="3" label="已失效"/>
         </form:select>
         <label>优惠时间:</label>
         <input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
@@ -88,16 +88,16 @@
             </td>
             <td>
                 <c:if test="${cmCoupon.status eq 0}">
-                    <font color="#800080">未生效</font>
+                    <font color="#800080">待上架</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 1}">
-                    <font color="#00CC66">已生效</font>
+                    <font color="#00CC66">已上架</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 2}">
                     <font color="red">已关闭</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 3}">
-                    <font color="#FF6600">已失效</font>
+                    <font color="#FF6600">已下架</font>
                 </c:if>
             </td>
             <td>${cmCoupon.categoryType eq 1 ? "产品":"仪器"}</td>
@@ -112,8 +112,13 @@
             </td>
             <td>
                 <a href="${ctx}/coupon/cmCoupon/form?id=${cmCoupon.id}">编辑</a>
-                <a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该优惠券吗?', this.href)">关闭</a>
-                <a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该优惠券吗?', this.href)">删除</a>
+                <c:if test="${cmCoupon.status eq 2}">
+                    <a href="${ctx}/coupon/cmCoupon/open?id=${cmCoupon.id}" onclick="return confirmx('确定开启该活动吗?', this.href)">开启</a>
+                </c:if>
+                <c:if test="${cmCoupon.status ne 2}">
+                    <a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该活动吗?', this.href)">关闭</a>
+                </c:if>
+                <a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该活动吗?', this.href)">删除</a>
                 <a href="${ctx}/coupon/cmCouponClub/list?couponId=${cmCoupon.id}&couponType=1">领取用户</a>
             </td>
         </tr>

+ 71 - 0
src/main/webapp/WEB-INF/views/modules/coupon/couponNewUserForm.jsp

@@ -49,6 +49,7 @@
     <form:hidden path="productInfo" id="productInfo"/>
     <input type="hidden" name="couponType" value="4"/>
     <sys:message content="${message}"/>
+    <form:hidden path="receiveFlag"/>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>优惠券金额:</label>
         <div class="controls">
@@ -77,6 +78,21 @@
                    onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});" onblur="dateShow()"/>
         </div>
     </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>领取期限:</label>
+        <div class="controls">
+            <input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmCoupon.receivePeriod}" min="1" required> 天
+            <input type="checkbox" id="receiveFlag" name="receiveFlag" style="margin-left:20px !important" value="${cmCoupon.receiveFlag eq 1?1:0}"
+                ${cmCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition('receiveFlag','receivePeriod')" />同活动开始-结束时间
+            <input id="receivePeriodTemp" type="hidden" value="${cmCoupon.receivePeriod}">
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>使用期限:</label>
+        <div class="controls">
+            <input type="number" id="usePeriod" name="usePeriod" value="${cmCoupon.usePeriod}" min="1" required> 天
+        </div>
+    </div>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>优惠状态:</label>
         <div class="controls">
@@ -107,6 +123,10 @@
     </div>
 </form:form>
 <script>
+    $(function () {
+        initInputDisplay();
+    })
+
     function statusShow() {
         var status = $("input[name='status']:checked").val();
         if (status == 2) {
@@ -141,6 +161,57 @@
     function onlynum(obj) {
         obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
     }
+
+    function changeCondition(flag, name) {
+        var obj = $("#" + flag);
+        var val = obj.val();
+        if (val === '1') {
+            obj.val(0);
+            val = '0';
+        } else {
+            obj.val(1);
+            val = '1';
+        }
+        var inputObj = $("#" + name);
+        // 临时数据
+        var tempObj = $("#" + name + "Temp");
+        if (name.indexOf("Time") !== -1) {
+            //修改时间
+            if (val === '1') {
+                inputObj.attr('onclick', '');
+                inputObj.removeClass('required');
+            } else {
+                inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
+                inputObj.addClass('required');
+            }
+        }else {
+            if (val === '1') {
+                inputObj.attr('readonly', true);
+                inputObj.attr('required', false);
+            } else {
+                inputObj.attr('readonly', false);
+                inputObj.attr('required', true);
+            }
+        }
+        if (val === '1') {
+            tempObj.val(inputObj.val());
+            inputObj.val('');
+        } else {
+            inputObj.val(tempObj.val());
+            tempObj.val('');
+        }
+    }
+
+    function initInputDisplay() {
+        var receiveFlag = $("#receiveFlag").val();
+        if (receiveFlag === '1') {
+            $("#receivePeriod").attr('readonly', true);
+            $("#receivePeriod").attr('required', false);
+        } else {
+            $("#receivePeriod").attr('readonly', false);
+            $("#receivePeriod").attr('required', true);
+        }
+    }
 </script>
 </body>
 </html>

+ 13 - 8
src/main/webapp/WEB-INF/views/modules/coupon/couponNewUserList.jsp

@@ -36,10 +36,10 @@
         <label>优惠状态:</label>
         <form:select path="status" class="input-medium required">
             <form:option value="" label="所有"/>
-            <form:option value="0" label="未生效"/>
-            <form:option value="1" label="已生效"/>
+            <form:option value="0" label="待上架"/>
+            <form:option value="1" label="已上架"/>
+            <form:option value="3" label="已下架"/>
             <form:option value="2" label="已关闭"/>
-            <form:option value="3" label="已失效"/>
         </form:select>
         <label>优惠时间:</label>
         <input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
@@ -81,16 +81,16 @@
             </td>
             <td>
                 <c:if test="${cmCoupon.status eq 0}">
-                    <font color="#800080">未生效</font>
+                    <font color="#800080">待上架</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 1}">
-                    <font color="#00CC66">已生效</font>
+                    <font color="#00CC66">已上架</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 2}">
                     <font color="red">已关闭</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 3}">
-                    <font color="#FF6600">已失效</font>
+                    <font color="#FF6600">已下架</font>
                 </c:if>
             </td>
             <td>
@@ -104,8 +104,13 @@
             </td>
             <td>
                 <a href="${ctx}/coupon/cmCoupon/form?id=${cmCoupon.id}">编辑</a>
-                <a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该优惠券吗?', this.href)">关闭</a>
-                <a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该优惠券吗?', this.href)">删除</a>
+                <c:if test="${cmCoupon.status eq 2}">
+                    <a href="${ctx}/coupon/cmCoupon/open?id=${cmCoupon.id}" onclick="return confirmx('确定开启该活动吗?', this.href)">开启</a>
+                </c:if>
+                <c:if test="${cmCoupon.status ne 2}">
+                    <a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该活动吗?', this.href)">关闭</a>
+                </c:if>
+                <a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该活动吗?', this.href)">删除</a>
                 <a href="${ctx}/coupon/cmCouponClub/list?couponId=${cmCoupon.id}&couponType=4">领取用户</a>
             </td>
         </tr>

+ 68 - 0
src/main/webapp/WEB-INF/views/modules/coupon/couponShopForm.jsp

@@ -55,6 +55,7 @@
     <form:hidden path="shopId" id="shopId"/>
     <input type="hidden" name="couponType" value="3"/>
     <sys:message content="${message}"/>
+    <form:hidden path="receiveFlag"/>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>活动主题:</label>
         <div class="controls">
@@ -111,6 +112,21 @@
                    onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});" onblur="dateShow()"/>
         </div>
     </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>领取期限:</label>
+        <div class="controls">
+            <input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmCoupon.receivePeriod}" min="1" required> 天
+            <input type="checkbox" id="receiveFlag" name="receiveFlag" style="margin-left:20px !important" value="${cmCoupon.receiveFlag eq 1?1:0}"
+                ${cmCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition('receiveFlag','receivePeriod')" />同活动开始-结束时间
+            <input id="receivePeriodTemp" type="hidden" value="${cmCoupon.receivePeriod}">
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>使用期限:</label>
+        <div class="controls">
+            <input type="number" id="usePeriod" name="usePeriod" value="${cmCoupon.usePeriod}" min="1" required> 天
+        </div>
+    </div>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>优惠状态:</label>
         <div class="controls">
@@ -153,6 +169,7 @@
             }
             appendShopOrderHead(shop);
         }
+        initInputDisplay();
     });
 
 
@@ -252,6 +269,57 @@
     function onlynum(obj) {
         obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
     }
+
+    function changeCondition(flag, name) {
+        var obj = $("#" + flag);
+        var val = obj.val();
+        if (val === '1') {
+            obj.val(0);
+            val = '0';
+        } else {
+            obj.val(1);
+            val = '1';
+        }
+        var inputObj = $("#" + name);
+        // 临时数据
+        var tempObj = $("#" + name + "Temp");
+        if (name.indexOf("Time") !== -1) {
+            //修改时间
+            if (val === '1') {
+                inputObj.attr('onclick', '');
+                inputObj.removeClass('required');
+            } else {
+                inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
+                inputObj.addClass('required');
+            }
+        }else {
+            if (val === '1') {
+                inputObj.attr('readonly', true);
+                inputObj.attr('required', false);
+            } else {
+                inputObj.attr('readonly', false);
+                inputObj.attr('required', true);
+            }
+        }
+        if (val === '1') {
+            tempObj.val(inputObj.val());
+            inputObj.val('');
+        } else {
+            inputObj.val(tempObj.val());
+            tempObj.val('');
+        }
+    }
+
+    function initInputDisplay() {
+        var receiveFlag = $("#receiveFlag").val();
+        if (receiveFlag === '1') {
+            $("#receivePeriod").attr('readonly', true);
+            $("#receivePeriod").attr('required', false);
+        } else {
+            $("#receivePeriod").attr('readonly', false);
+            $("#receivePeriod").attr('required', true);
+        }
+    }
 </script>
 </body>
 </html>

+ 13 - 8
src/main/webapp/WEB-INF/views/modules/coupon/couponShopList.jsp

@@ -40,10 +40,10 @@
         <label>优惠状态:</label>
         <form:select path="status" class="input-medium required">
             <form:option value="" label="所有"/>
-            <form:option value="0" label="未生效"/>
-            <form:option value="1" label="已生效"/>
+            <form:option value="0" label="待上架"/>
+            <form:option value="1" label="已上架"/>
+            <form:option value="3" label="已下架"/>
             <form:option value="2" label="已关闭"/>
-            <form:option value="3" label="已失效"/>
         </form:select><br><br>
         <label>优惠时间:</label>
         <input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
@@ -93,16 +93,16 @@
             </td>
             <td>
                 <c:if test="${cmCoupon.status eq 0}">
-                    <font color="#800080">未生效</font>
+                    <font color="#800080">待上架</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 1}">
-                    <font color="#00CC66">已生效</font>
+                    <font color="#00CC66">已上架</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 2}">
                     <font color="red">已关闭</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 3}">
-                    <font color="#FF6600">已失效</font>
+                    <font color="#FF6600">已下架</font>
                 </c:if>
             </td>
             <td>
@@ -116,8 +116,13 @@
             </td>
             <td>
                 <a href="${ctx}/coupon/cmCoupon/form?id=${cmCoupon.id}">编辑</a>
-                <a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该优惠券吗?', this.href)">关闭</a>
-                <a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该优惠券吗?', this.href)">删除</a>
+                <c:if test="${cmCoupon.status eq 2}">
+                    <a href="${ctx}/coupon/cmCoupon/open?id=${cmCoupon.id}" onclick="return confirmx('确定开启该活动吗?', this.href)">开启</a>
+                </c:if>
+                <c:if test="${cmCoupon.status ne 2}">
+                    <a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该活动吗?', this.href)">关闭</a>
+                </c:if>
+                <a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该活动吗?', this.href)">删除</a>
                 <a href="${ctx}/coupon/cmCouponClub/list?couponId=${cmCoupon.id}&couponType=3">领取用户</a>
             </td>
         </tr>

+ 68 - 0
src/main/webapp/WEB-INF/views/modules/coupon/couponUserExclusiveForm.jsp

@@ -57,6 +57,7 @@
     <form:hidden path="productInfo" id="productInfo"/>
     <input type="hidden" name="couponType" value="2"/>
     <sys:message content="${message}"/>
+    <form:hidden path="receiveFlag"/>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>机构:</label>
         <div class="controls">
@@ -108,6 +109,21 @@
                    onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});" onblur="dateShow()"/>
         </div>
     </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>领取期限:</label>
+        <div class="controls">
+            <input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmCoupon.receivePeriod}" min="1" required> 天
+            <input type="checkbox" id="receiveFlag" name="receiveFlag" style="margin-left:20px !important" value="${cmCoupon.receiveFlag eq 1?1:0}"
+                ${cmCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition('receiveFlag','receivePeriod')" />同活动开始-结束时间
+            <input id="receivePeriodTemp" type="hidden" value="${cmCoupon.receivePeriod}">
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>使用期限:</label>
+        <div class="controls">
+            <input type="number" id="usePeriod" name="usePeriod" value="${cmCoupon.usePeriod}" min="1" required> 天
+        </div>
+    </div>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>优惠状态:</label>
         <div class="controls">
@@ -164,6 +180,7 @@
             };
             insertHtml(items);
         }
+        initInputDisplay();
     });
 
     function insertHtml(data) {
@@ -257,6 +274,57 @@
     function onlynum(obj) {
         obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
     }
+
+    function changeCondition(flag, name) {
+        var obj = $("#" + flag);
+        var val = obj.val();
+        if (val === '1') {
+            obj.val(0);
+            val = '0';
+        } else {
+            obj.val(1);
+            val = '1';
+        }
+        var inputObj = $("#" + name);
+        // 临时数据
+        var tempObj = $("#" + name + "Temp");
+        if (name.indexOf("Time") !== -1) {
+            //修改时间
+            if (val === '1') {
+                inputObj.attr('onclick', '');
+                inputObj.removeClass('required');
+            } else {
+                inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
+                inputObj.addClass('required');
+            }
+        }else {
+            if (val === '1') {
+                inputObj.attr('readonly', true);
+                inputObj.attr('required', false);
+            } else {
+                inputObj.attr('readonly', false);
+                inputObj.attr('required', true);
+            }
+        }
+        if (val === '1') {
+            tempObj.val(inputObj.val());
+            inputObj.val('');
+        } else {
+            inputObj.val(tempObj.val());
+            tempObj.val('');
+        }
+    }
+
+    function initInputDisplay() {
+        var receiveFlag = $("#receiveFlag").val();
+        if (receiveFlag === '1') {
+            $("#receivePeriod").attr('readonly', true);
+            $("#receivePeriod").attr('required', false);
+        } else {
+            $("#receivePeriod").attr('readonly', false);
+            $("#receivePeriod").attr('required', true);
+        }
+    }
 </script>
 </body>
 </html>

+ 13 - 8
src/main/webapp/WEB-INF/views/modules/coupon/couponUserExclusiveList.jsp

@@ -38,10 +38,10 @@
         <label>优惠状态:</label>
         <form:select path="status" class="input-medium required">
             <form:option value="" label="全部"/>
-            <form:option value="0" label="未生效"/>
-            <form:option value="1" label="已生效"/>
+            <form:option value="0" label="待上架"/>
+            <form:option value="1" label="已上架"/>
+            <form:option value="3" label="已下架"/>
             <form:option value="2" label="已关闭"/>
-            <form:option value="3" label="已失效"/>
         </form:select>
         <label>领取状态:</label>
         <form:select path="claimStatus" class="input-medium required">
@@ -111,16 +111,16 @@
             </td>
             <td>
                 <c:if test="${cmCoupon.status eq 0}">
-                    <font color="#800080">未生效</font>
+                    <font color="#800080">待上架</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 1}">
-                    <font color="#00CC66">已生效</font>
+                    <font color="#00CC66">已上架</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 2}">
                     <font color="red">已关闭</font>
                 </c:if>
                 <c:if test="${cmCoupon.status eq 3}">
-                    <font color="#FF6600">已失效</font>
+                    <font color="#FF6600">已下架</font>
                 </c:if>
             </td>
             <td>
@@ -174,8 +174,13 @@
             </td>
             <td>
                 <a href="${ctx}/coupon/cmCoupon/form?id=${cmCoupon.id}">编辑</a>
-                <a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该优惠券吗?', this.href)">关闭</a>
-                <a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该优惠券吗?', this.href)">删除</a>
+                <c:if test="${cmCoupon.status eq 2}">
+                    <a href="${ctx}/coupon/cmCoupon/open?id=${cmCoupon.id}" onclick="return confirmx('确定开启该活动吗?', this.href)">开启</a>
+                </c:if>
+                <c:if test="${cmCoupon.status ne 2}">
+                    <a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该活动吗?', this.href)">关闭</a>
+                </c:if>
+                <a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该活动吗?', this.href)">删除</a>
             </td>
         </tr>
     </c:forEach>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/coupon/productCouponDetails.jsp

@@ -43,7 +43,7 @@
                         <span>兑换码:${coupon.redemptionCode}</span>
                     </c:if>
                     <span>${coupon.couponDesc}</span>
-                    <span>有效期:<fmt:formatDate value="${coupon.startDate}" pattern="yyyy-MM-dd"/>-<fmt:formatDate value="${coupon.endDate}" pattern="yyyy-MM-dd"/></span>
+                    <span>有效期:<fmt:formatDate value="${coupon.receiveDate}" pattern="yyyy-MM-dd"/>-<fmt:formatDate value="${coupon.useEndDate}" pattern="yyyy-MM-dd"/></span>
                 </span></li>
             </c:forEach>
         </ul>

+ 6 - 0
src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeCouponForm.jsp

@@ -151,6 +151,12 @@
                    onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});" onblur="dateShow()"/>
         </div>
     </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>使用期限:</label>
+        <div class="controls">
+            <input type="number" id="usePeriod" name="usePeriod" value="${cmCoupon.usePeriod}" min="1" required> 天
+        </div>
+    </div>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>优惠状态:</label>
         <div class="controls">

+ 7 - 2
src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeCouponList.jsp

@@ -109,8 +109,13 @@
             </td>
             <td>
                 <a href="${ctx}/coupon/cmCoupon/codeCouponForm?id=${cmCoupon.id}">编辑</a>
-                <a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该优惠券吗?', this.href)">关闭</a>
-                <a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该优惠券吗?', this.href)">删除</a>
+                <c:if test="${cmCoupon.status eq 2}">
+                    <a href="${ctx}/coupon/cmCoupon/open?id=${cmCoupon.id}" onclick="return confirmx('确定开启该活动吗?', this.href)">开启</a>
+                </c:if>
+                <c:if test="${cmCoupon.status ne 2}">
+                    <a href="${ctx}/coupon/cmCoupon/close?id=${cmCoupon.id}" onclick="return confirmx('确定关闭该活动吗?', this.href)">关闭</a>
+                </c:if>
+                <a href="${ctx}/coupon/cmCoupon/delete?id=${cmCoupon.id}" onclick="return confirmx('确定删除该活动吗?', this.href)">删除</a>
                 <a href="javascript:void(0);" onclick="showSelect(${cmCoupon.id})">查看兑换码</a>
             </td>
         </tr>

+ 54 - 19
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCouponForm.jsp

@@ -25,10 +25,11 @@
 					}
 					var couponAmount = $("#couponAmount").val()*1;
 					var touchPrice = $("#touchPrice").val()*1;
-					if (couponAmount >= touchPrice) {
-						alertx("优惠券金额必须小于优惠条件金额");
-						return false;
-					}
+                    var noThresholdFlag = $("#noThresholdFlag").val() * 1;
+                    if (noThresholdFlag === 0 && couponAmount >= touchPrice) {
+                        alertx("优惠券金额必须小于优惠条件金额");
+                        return false;
+                    }
 					var startNowFlag = $("#startNowFlag").val();
 					var permanentFlag = $("#permanentFlag").val();
 					var startTime = $("#startTime").val();
@@ -75,6 +76,10 @@
 		<form:hidden path="userInfo"/>
 		<form:hidden path="couponType"/>
 		<sys:message content="${message}"/>
+		<form:hidden path="noThresholdFlag"/>
+		<form:hidden path="startNowFlag"/>
+		<form:hidden path="permanentFlag"/>
+		<form:hidden path="receiveFlag"/>
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>优惠券名称:</label>
 			<div class="controls">
@@ -92,9 +97,10 @@
 			<div class="controls">
 				订单商品总额满
 				<input type="number" id="touchPrice" name="touchPrice" value="${cmHeheCoupon.touchPrice}" min="0" required> 元
-<%--				<form:checkbox path="noThresholdFlag" label="无门槛" onclick="changeCondition(this,'touchPrice')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.noThresholdFlag eq null?0:cmHeheCoupon.noThresholdFlag}"/>--%>
-				<input type="checkbox" id="noThresholdFlag" name="noThresholdFlag" class="formCheck" value="${cmHeheCoupon.noThresholdFlag eq 1?1:0}" ${cmHeheCoupon.noThresholdFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'touchPrice')" />无门槛
-			</div>
+				<input type="checkbox" id="noThresholdFlag" name="noThresholdFlag" class="formCheck" value="${cmHeheCoupon.noThresholdFlag eq 1?1:0}"
+					${cmHeheCoupon.noThresholdFlag eq 1 ? "checked" : ""} onclick="changeCondition('noThresholdFlag','touchPrice')" />无门槛
+                <input id="touchPriceTemp" type="hidden" value="${cmHeheCoupon.touchPrice}">
+            </div>
 		</div>
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>上架时间:</label>
@@ -102,8 +108,8 @@
 				<input id="startTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
 					value="<fmt:formatDate value="${cmHeheCoupon.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
 					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
-<%--				<form:checkbox path="startNowFlag" label="立即上架" onclick="changeCondition(this,'startTime')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.startNowFlag eq null?0:cmHeheCoupon.startNowFlag}"/>--%>
-				<input type="checkbox" id="startNowFlag" name="startNowFlag" class="formCheck" value="${cmHeheCoupon.startNowFlag eq 1?1:0}" ${cmHeheCoupon.startNowFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'startTime')" />立即上架
+				<input type="checkbox" id="startNowFlag" name="startNowFlag" class="formCheck" value="${cmHeheCoupon.startNowFlag eq 1?1:0}" ${cmHeheCoupon.startNowFlag eq 1 ? "checked" : ""} onclick="changeCondition('startNowFlag','startTime')" />立即上架
+                <input id="startTimeTemp" type="hidden" value="${cmHeheCoupon.startTime}">
 			</div>
 		</div>
 		<div class="control-group">
@@ -112,17 +118,18 @@
 				<input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
 					value="<fmt:formatDate value="${cmHeheCoupon.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
 					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
-<%--				<form:checkbox path="permanentFlag" label="永久" onclick="changeCondition(this,'endTime')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.permanentFlag eq null?0:cmHeheCoupon.permanentFlag}"/>--%>
-				<input type="checkbox" id="permanentFlag" name="permanentFlag" class="formCheck" value="${cmHeheCoupon.permanentFlag eq 1?1:0}" ${cmHeheCoupon.permanentFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'endTime')" />永久
-			</div>
+				<input type="checkbox" id="permanentFlag" name="permanentFlag" class="formCheck" value="${cmHeheCoupon.permanentFlag eq 1?1:0}" ${cmHeheCoupon.permanentFlag eq 1 ? "checked" : ""}
+					   onclick="changeCondition('permanentFlag','endTime')" />永久
+                <input id="endTimeTemp" type="hidden" value="${cmHeheCoupon.endTime}">
+            </div>
 		</div>
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>领取期限:</label>
 			<div class="controls">
 				<input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmHeheCoupon.receivePeriod}" min="1" required> 天
-<%--				<form:checkbox path="receiveFlag" label="同上下架时间" onclick="changeCondition(this,'receivePeriod')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.receiveFlag eq null?0:cmHeheCoupon.receiveFlag}"/>--%>
-				<input type="checkbox" id="receiveFlag" name="receiveFlag" class="formCheck" value="${cmHeheCoupon.receiveFlag eq 1?1:0}" ${cmHeheCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'receivePeriod')" />同上下架时间
-			</div>
+				<input type="checkbox" id="receiveFlag" name="receiveFlag" class="formCheck" value="${cmHeheCoupon.receiveFlag eq 1?1:0}" ${cmHeheCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition('receiveFlag','receivePeriod')" />同上下架时间
+                <input id="receivePeriodTemp" type="hidden" value="${cmHeheCoupon.receivePeriod}">
+            </div>
 		</div>
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>使用期限:</label>
@@ -196,16 +203,19 @@
 
 <script>
 
-	function changeCondition(obj, name) {
-		var val = obj.value;
+	function changeCondition(flag, name) {
+		var obj = $("#" + flag);
+		var val = obj.val();
 		if (val === '1') {
-			obj.value = '0';
+			obj.val(0);
 			val = '0';
 		} else {
-			obj.value = '1';
+			obj.val(1);
 			val = '1';
 		}
 		var inputObj = $("#" + name);
+		// 临时数据
+        var tempObj = $("#" + name + "Temp");
 		if (name.indexOf("Time") !== -1) {
 			//修改时间
 			if (val === '1') {
@@ -224,6 +234,13 @@
 				inputObj.attr('required', true);
 			}
 		}
+        if (val === '1') {
+            tempObj.val(inputObj.val());
+            inputObj.val('');
+        } else {
+            inputObj.val(tempObj.val());
+            tempObj.val('');
+        }
 	}
 
 	var productIds = '';
@@ -335,11 +352,29 @@
 	}
 
 	function initInputDisplay() {
+		debugger
 		var noThresholdFlag = $("#noThresholdFlag").val();
 		var startNowFlag = $("#startNowFlag").val();
 		var permanentFlag = $("#permanentFlag").val();
 		var receiveFlag = $("#receiveFlag").val();
 
+		if (noThresholdFlag === '') {
+			$("#noThresholdFlag").val(0);
+			noThresholdFlag = '0';
+		}
+		if (startNowFlag === '') {
+			$("#startNowFlag").val(0);
+			startNowFlag = '0';
+		}
+		if (permanentFlag === '') {
+			$("#permanentFlag").val(0);
+			permanentFlag = '0';
+		}
+		if (receiveFlag === '') {
+			$("#receiveFlag").val(0);
+			receiveFlag = '0';
+		}
+
 		if (noThresholdFlag === '1') {
 			$("#touchPrice").attr('readonly', true);
 			$("#touchPrice").attr('required', false);

+ 8 - 3
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCouponList.jsp

@@ -10,7 +10,7 @@
 	</style>
 	<script type="text/javascript">
 		$(document).ready(function() {
-			
+
 		});
 		function page(n,s){
 			$("#pageNo").val(n);
@@ -78,7 +78,12 @@
 					${cmHeheCoupon.couponAmount}
 				</td>
 				<td>
-					${cmHeheCoupon.touchPrice}
+					<c:if test="${cmHeheCoupon.noThresholdFlag eq 1}">
+						无门槛
+					</c:if>
+					<c:if test="${cmHeheCoupon.noThresholdFlag ne 1}">
+						满${cmHeheCoupon.touchPrice}
+					</c:if>
 				</td>
 				<td>
 					<fmt:formatDate value="${cmHeheCoupon.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
@@ -106,7 +111,7 @@
 				</td>
 				<td>
     				<a href="${ctx}/hehe/cmHeheCoupon/form?id=${cmHeheCoupon.id}">编辑</a>
-					<a href="${ctx}/hehe/cmHeheCoupon/delete?id=${cmHeheCoupon.id}" onclick="return confirmx('确认要删除该优惠券吗?', this.href)">删除</a>
+					<a href="${ctx}/hehe/cmHeheCoupon/delete?id=${cmHeheCoupon.id}&couponType=${cmHeheCoupon.couponType}" onclick="return confirmx('确认要删除该优惠券吗?', this.href)">删除</a>
 					<a href="${ctx}/hehe/cmHeheCoupon/receive/user/list?couponId=${cmHeheCoupon.id}&couponType=${cmHeheCoupon.couponType}">领取用户</a>
 				</td>
 			</tr>

+ 9 - 1
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheDiscountForm.jsp

@@ -40,6 +40,14 @@
 		function onlynum(obj) {
 			obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
 		}
+
+		function changeDiscount(){
+            var discount = Number($("#discount").val()).toFixed(2);
+            if (discount > 100 || discount <= 0) {
+                $.jBox.tip("请输入0-100之间的数字", 'info');
+                $("#discount").val('');
+            }
+        }
 	</script>
 </head>
 <body>
@@ -61,7 +69,7 @@
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>折扣率:</label>
 			<div class="controls">
-				<form:input path="discount" htmlEscape="false" onkeyup="onlynum(this)" class="input-xlarge  digits required"/> %
+				<form:input path="discount" htmlEscape="false" onkeyup="onlynum(this)" onchange="changeDiscount()" class="input-xlarge  digits required"/> %
 			</div>
 		</div>
 		<div class="control-group">

+ 0 - 3
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheDiscountList.jsp

@@ -38,9 +38,6 @@
 					<form:option value="2" label="已停用"/>
 				</form:select>
 			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
-			<a class="btn btn-primary" href="${ctx}/hehe/cmHeheDiscount/form" style="margin-left: 15px">
-				添加内部优惠
-			</a>
 			<div class="clearfix"></div>
 		</div>
 	</form:form>

+ 18 - 0
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheProductForm.jsp

@@ -124,6 +124,24 @@
 				</form:select>
 			</div>
 		</div>
+		<%--<div class="control-group">
+			<label class="control-label">首页楼层:</label>
+			<div class="controls">
+				<form:select path="floorId" class="input-small">
+					<form:option value="" label="请选择"/>
+					<form:options items="${floorList}" itemLabel="title" itemValue="id" htmlEscape="false"/>
+				</form:select>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label">商城活动:</label>
+			<div class="controls">
+				<form:select path="activityId" class="input-small">
+					<form:option value="" label="请选择"/>
+					<form:options items="${activityList}" itemLabel="name" itemValue="id" htmlEscape="false"/>
+				</form:select>
+			</div>
+		</div>--%>
 		<div class="form-actions">
 			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
 			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>

+ 10 - 1
src/main/webapp/WEB-INF/views/modules/hehe/heheNewOrderDetail.jsp

@@ -192,7 +192,16 @@
         <td>
             地址: ${fns:appendLast(fns:appendLast1(order.bpOrderUserinfo.province,order.bpOrderUserinfo.city,order.bpOrderUserinfo.town), order.bpOrderUserinfo.address)}</td>
         <fmt:setLocale value="zh_CN" scope="session"/>
-        <td>订单金额:<fmt:formatNumber value="${order.payTotalFee}" type="currency"/></td>
+        <td>
+            订单金额:<fmt:formatNumber value="${order.payTotalFee}" type="currency"/>
+            <c:if test="${not empty order.heheCouponRecord}">
+                <a href="${ctx}/hehe/coupon/receiveDetails?userId=${order.userID}">
+                    <font color="red">
+                        (${order.heheCouponRecord.couponType eq 1 ? '活动':order.heheCouponRecord.couponType eq 2?'专享':order.heheCouponRecord.couponType eq 3?'新人':order.heheCouponRecord.couponType eq 4?'好友分享':'好友消费'}券抵扣¥${order.heheCouponRecord.couponAmount},满${order.heheCouponRecord.touchPrice}减${order.heheCouponRecord.couponAmount})
+                    </font>
+                </a>
+            </c:if>
+        </td>
     </tr>
     <tr>
         <td>

+ 2 - 2
src/main/webapp/WEB-INF/views/modules/hehe/toAddCouponUser.jsp

@@ -41,7 +41,7 @@
                 var user = JSON.parse($(this).val());
                 items.push({
                     "id": '',
-                    "userId": user.id,
+                    "userId": user.userID,
                     "nickName": user.nickName,
                     "mobile": user.mobile,
                     "userIdentity": user.userIdentity,
@@ -115,7 +115,7 @@
     <tbody>
     <c:if test="${not empty page.list}">
         <c:forEach items="${page.list}" var="item">
-            <tr id="${item.id}" class="itemtr">
+            <tr id="${item.userID}" class="itemtr">
                     <%--已过滤添加过的商品和未上架的商品--%>
                 <th>
                     <input class="check-item" ${item.storeStatus ? "disabled" : ""}  type="checkbox" name="info" value='${fns:toJson(item)}'/>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/hehe/toAddDiscountUser.jsp

@@ -41,7 +41,7 @@
                 var user = JSON.parse($(this).val());
                 items.push({
                     "id": '',
-                    "userId": user.id,
+                    "userId": user.userID,
                     "nickName": user.nickName,
                     "mobile": user.mobile,
                     "userIdentity": user.userIdentity,

+ 1 - 1
src/main/webapp/static/modules/bulkpurchase/orderForm.js

@@ -467,7 +467,7 @@ function setPageCoupon() {
         html += '            <span>'+item.couponName+'</span>';
         html += redemptionCode;
         html += '            <span>'+item.couponDesc+'</span>';
-        html += '            <span>有效期:'+item.startDate+' - '+item.endDate+'</span>';
+        html += '            <span>有效期:'+item.receiveDate+' - '+item.useEndDate+'</span>';
         html += '</span></label></li>';
     });
     $("#couponBox").find(".couponContent").html(html);