Browse Source

Merge remote-tracking branch 'remotes/origin/developer' into developerC

Aslee 3 years ago
parent
commit
08e05262bf
96 changed files with 8268 additions and 5591 deletions
  1. 4 0
      src/main/java/com/caimei/modules/archive/dao/CmOrderArchiveDao.java
  2. 36 30
      src/main/java/com/caimei/modules/archive/service/CmOrderArchiveService.java
  3. 457 464
      src/main/java/com/caimei/modules/brand/web/CmBrandController.java
  4. 352 332
      src/main/java/com/caimei/modules/bulkpurchase/entity/PurchaseProduct.java
  5. 0 23
      src/main/java/com/caimei/modules/bulkpurchase/web/CmClubController.java
  6. 9 0
      src/main/java/com/caimei/modules/bulkpurchase/web/CmRefundsProductController.java
  7. 20 13
      src/main/java/com/caimei/modules/bulkpurchase/web/PurchaseProductController.java
  8. 48 8
      src/main/java/com/caimei/modules/coupon/dao/CmCouponClubDao.java
  9. 71 9
      src/main/java/com/caimei/modules/coupon/dao/CmCouponDao.java
  10. 0 18
      src/main/java/com/caimei/modules/coupon/dao/CmCouponOrderRecordDao.java
  11. 0 15
      src/main/java/com/caimei/modules/coupon/dao/CmCouponRecordDao.java
  12. 0 19
      src/main/java/com/caimei/modules/coupon/dao/CmCouponRecordScanDao.java
  13. 278 197
      src/main/java/com/caimei/modules/coupon/entity/CmCoupon.java
  14. 121 0
      src/main/java/com/caimei/modules/coupon/entity/CmCouponAssociate.java
  15. 165 112
      src/main/java/com/caimei/modules/coupon/entity/CmCouponClub.java
  16. 95 221
      src/main/java/com/caimei/modules/coupon/entity/CmCouponOrderRecord.java
  17. 0 199
      src/main/java/com/caimei/modules/coupon/entity/CmCouponRecord.java
  18. 0 188
      src/main/java/com/caimei/modules/coupon/entity/CmCouponRecordScan.java
  19. 77 0
      src/main/java/com/caimei/modules/coupon/entity/CmCouponRedemptionCode.java
  20. 0 218
      src/main/java/com/caimei/modules/coupon/entity/ReadExcel.java
  21. 127 51
      src/main/java/com/caimei/modules/coupon/service/CmCouponClubService.java
  22. 0 52
      src/main/java/com/caimei/modules/coupon/service/CmCouponOrderRecordService.java
  23. 0 54
      src/main/java/com/caimei/modules/coupon/service/CmCouponRecordScanService.java
  24. 0 44
      src/main/java/com/caimei/modules/coupon/service/CmCouponRecordService.java
  25. 366 62
      src/main/java/com/caimei/modules/coupon/service/CmCouponService.java
  26. 80 194
      src/main/java/com/caimei/modules/coupon/web/CmCouponClubController.java
  27. 233 98
      src/main/java/com/caimei/modules/coupon/web/CmCouponController.java
  28. 0 173
      src/main/java/com/caimei/modules/coupon/web/CmCouponOrderRecordController.java
  29. 0 139
      src/main/java/com/caimei/modules/coupon/web/CmCouponRecordController.java
  30. 0 153
      src/main/java/com/caimei/modules/coupon/web/CmCouponRecordScanController.java
  31. 39 0
      src/main/java/com/caimei/modules/order/dao/NewOrderDao.java
  32. 18 0
      src/main/java/com/caimei/modules/order/entity/CmMainReceiptExport.java
  33. 31 0
      src/main/java/com/caimei/modules/order/entity/NewOrder.java
  34. 18 0
      src/main/java/com/caimei/modules/order/entity/NewOrderProduct.java
  35. 26 1
      src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java
  36. 116 1
      src/main/java/com/caimei/modules/order/service/NewOrderService.java
  37. 3 0
      src/main/java/com/caimei/modules/order/utils/OrderUtil.java
  38. 12 5
      src/main/java/com/caimei/modules/order/web/CmDiscernReceiptController.java
  39. 41 4
      src/main/java/com/caimei/modules/order/web/NewOrderController.java
  40. 46 44
      src/main/java/com/caimei/modules/product/service/CmIkDictService.java
  41. 9 0
      src/main/java/com/caimei/modules/user/entity/CmUser.java
  42. 1 1
      src/main/java/com/caimei/modules/user/entity/NewCmShop.java
  43. 13 1
      src/main/java/com/caimei/modules/user/service/NewCmShopService.java
  44. BIN
      src/main/resources/export/discern_receipt_export.xls
  45. 194 158
      src/main/resources/mappings/modules/archive/CmOrderArchiveMapper.xml
  46. 1 29
      src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml
  47. 182 107
      src/main/resources/mappings/modules/coupon/CmCouponClubMapper.xml
  48. 401 142
      src/main/resources/mappings/modules/coupon/CmCouponMapper.xml
  49. 0 167
      src/main/resources/mappings/modules/coupon/CmCouponOrderRecordMapper.xml
  50. 0 170
      src/main/resources/mappings/modules/coupon/CmCouponRecordMapper.xml
  51. 0 195
      src/main/resources/mappings/modules/coupon/CmCouponRecordScanMapper.xml
  52. 1 0
      src/main/resources/mappings/modules/order/CmDiscernReceiptMapper.xml
  53. 80 4
      src/main/resources/mappings/modules/order/OrderMapper.xml
  54. 3 2
      src/main/resources/mappings/modules/product/ProductMapper.xml
  55. 28 13
      src/main/webapp/WEB-INF/views/modules/archive/cmOrderArchiveForm.jsp
  56. 1 1
      src/main/webapp/WEB-INF/views/modules/archive/cmOrderArchiveList.jsp
  57. 17 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/applyRefoundForm.jsp
  58. 18 1
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderConfirmReturnRecord.jsp
  59. 24 9
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductForm.jsp
  60. 25 29
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductList.jsp
  61. 17 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReturnRecord.jsp
  62. 17 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReviewReturnRecord.jsp
  63. 17 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/refundRecord.jsp
  64. 3 3
      src/main/webapp/WEB-INF/views/modules/cmpage/cmPageBeautyForm.jsp
  65. 126 0
      src/main/webapp/WEB-INF/views/modules/coupon/clubCouponDetails.jsp
  66. 0 105
      src/main/webapp/WEB-INF/views/modules/coupon/cmClubListBox.jsp
  67. 57 218
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponClubList.jsp
  68. 566 0
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponForm.jsp
  69. 123 0
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponList.jsp
  70. 0 116
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponListBox.jsp
  71. 0 101
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponOrderRecordList.jsp
  72. 0 295
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponRecordList.jsp
  73. 0 329
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponRecordScanList.jsp
  74. 159 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponCategoryForm.jsp
  75. 125 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponCategoryList.jsp
  76. 146 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponNewUserForm.jsp
  77. 117 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponNewUserList.jsp
  78. 257 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponShopForm.jsp
  79. 129 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponShopList.jsp
  80. 262 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponUserExclusiveForm.jsp
  81. 186 0
      src/main/webapp/WEB-INF/views/modules/coupon/couponUserExclusiveList.jsp
  82. 68 0
      src/main/webapp/WEB-INF/views/modules/coupon/productCouponDetails.jsp
  83. 819 0
      src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeCouponForm.jsp
  84. 137 0
      src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeCouponList.jsp
  85. 96 0
      src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeList.jsp
  86. 119 0
      src/main/webapp/WEB-INF/views/modules/coupon/toAddClub.jsp
  87. 130 0
      src/main/webapp/WEB-INF/views/modules/coupon/toAddProduct.jsp
  88. 107 0
      src/main/webapp/WEB-INF/views/modules/coupon/toAddShop.jsp
  89. 68 0
      src/main/webapp/WEB-INF/views/modules/coupon/userCouponList.jsp
  90. 18 18
      src/main/webapp/WEB-INF/views/modules/newhome/beautyFloorContentForm.jsp
  91. 3 3
      src/main/webapp/WEB-INF/views/modules/order/cmPayShopDetail.jsp
  92. 1 1
      src/main/webapp/WEB-INF/views/modules/order/newOrderList.jsp
  93. 21 2
      src/main/webapp/WEB-INF/views/modules/order/orderDetail.jsp
  94. 39 8
      src/main/webapp/WEB-INF/views/modules/order/orderForm.jsp
  95. 2 2
      src/main/webapp/WEB-INF/views/modules/product/cmSecondHandDetailForm.jsp
  96. 446 220
      src/main/webapp/static/modules/bulkpurchase/orderForm.js

+ 4 - 0
src/main/java/com/caimei/modules/archive/dao/CmOrderArchiveDao.java

@@ -33,4 +33,8 @@ public interface CmOrderArchiveDao extends CrudDao<CmOrderArchive> {
     Integer checkShopOrderIdExist(Integer shopOrderId);
 
     Integer checkShopOrderIdAble(Integer shopOrderId);
+
+    String getShopNameByShopOrderId(Integer shopOrderId);
+
+    String getClubNameByShopOrderId(Integer shopOrderId);
 }

+ 36 - 30
src/main/java/com/caimei/modules/archive/service/CmOrderArchiveService.java

@@ -20,6 +20,7 @@ import com.caimei.utils.StringUtil;
 import com.thinkgem.jeesite.common.config.Global;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.RandomUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -60,15 +61,12 @@ public class CmOrderArchiveService extends CrudService<CmOrderArchiveDao, CmOrde
 	@Transactional(readOnly = false)
 	public void saveArchive(CmOrderArchive cmOrderArchive) {
         if (cmOrderArchive.getIsNewRecord()) {
-            SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
-            StringBuilder orderArchiveNo = new StringBuilder(format.format(new Date()));
-            Random random = new Random();
-            for (int i = 0; i < 8; i++) {
-                orderArchiveNo.append(random.nextInt(10));
-            }
-            cmOrderArchive.setArchiveNo(orderArchiveNo.toString());
             cmOrderArchive.setAddTime(new Date());
         }
+        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
+        String date = format.format(new Date());
+        String orderArchiveNo = "CM-" + date + cmOrderArchive.getShopOrderId();
+        cmOrderArchive.setArchiveNo(orderArchiveNo);
 		super.save(cmOrderArchive);
         String fileIds = cmOrderArchive.getFileIds();
         if (StringUtil.isNotEmpty(fileIds)) {
@@ -92,11 +90,13 @@ public class CmOrderArchiveService extends CrudService<CmOrderArchiveDao, CmOrde
     @Transactional(readOnly = false)
     public Map<String, Object> upload(MultipartFile multipartFile, String fileName, Integer orderArchiveId, String fileIds) {
         Map<String, Object> map = new HashMap<>();
-        Integer fileIdByFileName = cmOrderArchiveDao.checkFileName(fileName, orderArchiveId, fileIds);
-        if (null != fileIdByFileName) {
-            map.put("success", false);
-            map.put("msg", "文件已存在");
-            return map;
+        if (null != orderArchiveId || StringUtils.isNotEmpty(fileIds)) {
+            Integer fileIdByFileName = cmOrderArchiveDao.checkFileName(fileName, orderArchiveId, fileIds);
+            if (null != fileIdByFileName) {
+                map.put("success", false);
+                map.put("msg", "文件已存在");
+                return map;
+            }
         }
         String fileAllName = multipartFile.getOriginalFilename();
         String fileType = fileAllName.substring(fileAllName.lastIndexOf(".") + 1);
@@ -203,32 +203,38 @@ public class CmOrderArchiveService extends CrudService<CmOrderArchiveDao, CmOrde
 
     public Map<String, Object> checkShopOrderId(CmOrderArchive cmOrderArchive) {
         HashMap<String, Object> result = new HashMap<>(2);
-        if (StringUtil.isEmpty(cmOrderArchive.getId())) {
-            result.put("code", -1);
-            result.put("msg", "请输入资料id");
+        // 检查子订单id是否存在
+        Integer existId = cmOrderArchiveDao.checkShopOrderIdExist(cmOrderArchive.getShopOrderId());
+        if (null == existId) {
+            result.put("code", -2);
+            result.put("msg", "该子订单ID无效");
             return result;
-        }
-        // 当新的子订单id和数据库中的子订单id不同时,校验新的子订单id是否可用
-        CmOrderArchive dbArchive = cmOrderArchiveDao.get(cmOrderArchive.getId());
-        if (!cmOrderArchive.getShopOrderId().equals(dbArchive.getShopOrderId())) {
-            // 检查子订单id是否存在
-            Integer existId = cmOrderArchiveDao.checkShopOrderIdExist(cmOrderArchive.getShopOrderId());
-            if (null == existId) {
-                result.put("code", -2);
-                result.put("msg", "子订单id不存在");
-                return result;
-            } else {
-                // 检查子订单是否已被使用
-                Integer ableId = cmOrderArchiveDao.checkShopOrderIdAble(cmOrderArchive.getShopOrderId());
-                if (null == ableId) {
+        } else {
+            // 检查子订单id是否已被使用
+            Integer ableId = cmOrderArchiveDao.checkShopOrderIdAble(cmOrderArchive.getShopOrderId());
+            if (null == ableId) {
+                if (StringUtils.isNotEmpty(cmOrderArchive.getId())) {
+                    // 当新的子订单id不可用时,判断新的子订单id和数据库中的子订单id是否相同
+                    CmOrderArchive dbArchive = cmOrderArchiveDao.get(cmOrderArchive.getId());
+                    if (!cmOrderArchive.getShopOrderId().equals(dbArchive.getShopOrderId())) {
+                        result.put("code", -3);
+                        result.put("msg", "该子订单ID已存在");
+                        return result;
+                    }
+                } else {
                     result.put("code", -3);
-                    result.put("msg", "该子订单id已使用");
+                    result.put("msg", "该子订单ID已存在");
                     return result;
                 }
             }
         }
+        // 获取子订单对应的供应商和机构名称
+        String shopName = cmOrderArchiveDao.getShopNameByShopOrderId(cmOrderArchive.getShopOrderId());
+        String clubName = cmOrderArchiveDao.getClubNameByShopOrderId(cmOrderArchive.getShopOrderId());
         result.put("code", 0);
         result.put("msg", "该子订单id可以使用");
+        result.put("shopName", shopName);
+        result.put("clubName", clubName);
         return result;
     }
 }

+ 457 - 464
src/main/java/com/caimei/modules/brand/web/CmBrandController.java

@@ -1,15 +1,15 @@
 package com.caimei.modules.brand.web;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import com.caimei.modules.brand.entity.BrandAndProductType;
-import com.caimei.modules.coupon.entity.CmCoupon;
-import com.caimei.modules.coupon.entity.ReadExcel;
-import com.caimei.modules.miniprogram.utils.UploadPicUtils;
+import com.caimei.modules.brand.entity.CmBrand;
+import com.caimei.modules.brand.service.CmBrandService;
 import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.entity.Product;
 import com.caimei.modules.sys.utils.SMSUtils;
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.thinkgem.jeesite.common.web.BaseController;
 import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.map.HashedMap;
@@ -30,15 +30,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
-import com.thinkgem.jeesite.common.config.Global;
-import com.thinkgem.jeesite.common.persistence.Page;
-import com.thinkgem.jeesite.common.web.BaseController;
-import com.thinkgem.jeesite.common.utils.StringUtils;
-import com.caimei.modules.brand.entity.CmBrand;
-import com.caimei.modules.brand.service.CmBrandService;
-
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -46,6 +39,7 @@ import java.util.Map;
 
 /**
  * 采美品牌Controller
+ *
  * @author Lijun
  * @version 2019-04-19
  */
@@ -53,460 +47,459 @@ import java.util.Map;
 @RequestMapping(value = "${adminPath}/brand/cmBrand")
 public class CmBrandController extends BaseController {
 
-	//总行数
-	private int totalRows = 0;
-	//总条数
-	private int totalCells = 0;
-	//错误信息接收器
-	private String errorMsg;
-
-
-	@Autowired
-	private CmBrandService cmBrandService;
-	@Autowired
-	private ProductDao productDao;
-	
-	@ModelAttribute
-	public CmBrand get(@RequestParam(required=false) String id) {
-		CmBrand entity = null;
-		if (StringUtils.isNotBlank(id)){
-			entity = cmBrandService.get(id);
-		}
-		if (entity == null){
-			entity = new CmBrand();
-		}
-		return entity;
-	}
-	
-	@RequiresPermissions("brand:cmBrand:view")
-	@RequestMapping(value = {"list", ""})
-	public String list(CmBrand cmBrand, HttpServletRequest request, HttpServletResponse response, Model model) {
-		Page<CmBrand> page = cmBrandService.findPage(new Page<CmBrand>(request, response), cmBrand); 
-		model.addAttribute("page", page);
-		return "modules/brand/cmBrandList";
-	}
-
-	@RequiresPermissions("brand:cmBrand:view")
-	@RequestMapping(value = "form")
-	public String form(CmBrand cmBrand, Model model) {
-		model.addAttribute("cmBrand", cmBrand);
-		String auditNote = cmBrand.getAuditNote();
-		if(StringUtils.isNotEmpty(auditNote)){
-			if(StringUtils.equals("填写错误",auditNote)){
-				cmBrand.setAuditStatus("1");
-			}else{
-				cmBrand.setAuditStatus("2");
-			}
-		}else{
-			cmBrand.setAuditStatus("0");
-		}
-		return "modules/brand/cmBrandForm";
-	}
-
-	@RequiresPermissions("brand:cmBrand:edit")
-	@RequestMapping(value = "save")
-	public String save(CmBrand cmBrand, Model model, RedirectAttributes redirectAttributes,HttpServletRequest request) {
-		if (!beanValidator(model, cmBrand)){
-			return form(cmBrand, model);
-		}
-		//判断输入的名字是否已存在
-		CmBrand cmBrandByName = cmBrandService.findBradByName(cmBrand);
+    //总行数
+    private int totalRows = 0;
+    //总条数
+    private int totalCells = 0;
+    //错误信息接收器
+    private String errorMsg;
+
+
+    @Autowired
+    private CmBrandService cmBrandService;
+    @Autowired
+    private ProductDao productDao;
+
+    @ModelAttribute
+    public CmBrand get(@RequestParam(required = false) String id) {
+        CmBrand entity = null;
+        if (StringUtils.isNotBlank(id)) {
+            entity = cmBrandService.get(id);
+        }
+        if (entity == null) {
+            entity = new CmBrand();
+        }
+        return entity;
+    }
+
+    @RequiresPermissions("brand:cmBrand:view")
+    @RequestMapping(value = {"list", ""})
+    public String list(CmBrand cmBrand, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<CmBrand> page = cmBrandService.findPage(new Page<CmBrand>(request, response), cmBrand);
+        model.addAttribute("page", page);
+        return "modules/brand/cmBrandList";
+    }
+
+    @RequiresPermissions("brand:cmBrand:view")
+    @RequestMapping(value = "form")
+    public String form(CmBrand cmBrand, Model model) {
+        model.addAttribute("cmBrand", cmBrand);
+        String auditNote = cmBrand.getAuditNote();
+        if (StringUtils.isNotEmpty(auditNote)) {
+            if (StringUtils.equals("填写错误", auditNote)) {
+                cmBrand.setAuditStatus("1");
+            } else {
+                cmBrand.setAuditStatus("2");
+            }
+        } else {
+            cmBrand.setAuditStatus("0");
+        }
+        return "modules/brand/cmBrandForm";
+    }
+
+    @RequiresPermissions("brand:cmBrand:edit")
+    @RequestMapping(value = "save")
+    public String save(CmBrand cmBrand, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
+        if (!beanValidator(model, cmBrand)) {
+            return form(cmBrand, model);
+        }
+        //判断输入的名字是否已存在
+        CmBrand cmBrandByName = cmBrandService.findBradByName(cmBrand);
 //		if (StringUtils.isNotBlank(cmBrand.getLogo())) {
 //			String img = UploadPicUtils.saveImageToServer(cmBrand.getLogo(), request);
 //			cmBrand.setLogo(img);
 //		}
-		if(null != cmBrandByName){
-			addMessage(redirectAttributes, "该品牌已存在");
-		}else{
-			//判断是新增加还是修改
-			if(StringUtils.isEmpty(cmBrand.getId())){//新增
-				cmBrand.setCreateDate(new Date());
-				cmBrand.setStatus("1");//采美添加默认通过--品牌状态 0:待审核,1:审核通过,2:审核失败
-				cmBrand.setSource("0");//添加来源 0:后台添加 ,1:供应商添加
-				cmBrand.setSort("0");
-				cmBrand.setUserID(UserUtils.getUser()+"");
-			}else{//修改
-				String status = cmBrand.getStatus();
-				CmBrand oldBrand = cmBrandService.get(cmBrand.getId());//获取修改前的品牌信息
-				String oldStatus = oldBrand.getStatus();//老的状态
-				if(!StringUtils.equals(status,oldStatus)){//重新修改状态才发送短信提示(防止重复编辑重复发送短信)
-					if(StringUtils.equals("1",status)){
-						String mobile = cmBrand.getShopMobile();
-						if (StringUtils.isNotEmpty(mobile)) {
-							SMSUtils.sendSms(mobile, "您提交的["+cmBrand.getName()+"]品牌申请,已审核成功");
-						}
-					}
-					if(StringUtils.equals("2",status)){
-						String auditNote = cmBrand.getAuditNote();
-						if(StringUtils.isEmpty(auditNote)){
-							addMessage(model, "请输入失败原因!!");
-							return form(cmBrand, model);
-						}
-						String mobile = cmBrand.getShopMobile();
-						if (StringUtils.isNotEmpty(mobile)) {
-							SMSUtils.sendSms(mobile, "抱歉,您提交的["+cmBrand.getName()+"]品牌申请,由于"+cmBrand.getAuditNote()+"审核失败,请重新修改提交!");
-						}
-					}
-				}else{
-					if(StringUtils.equals("2",status)){
-						String auditNote = cmBrand.getAuditNote();
-						if(StringUtils.isEmpty(auditNote)){
-							addMessage(model, "请输入失败原因!!");
-							return form(cmBrand, model);
-						}
-					}
-				}
-
-			}
-
-
-			cmBrand.setUpdateDate(new Date());
-			cmBrandService.save(cmBrand);
-			addMessage(redirectAttributes, "保存品牌成功");
-		}
-		return "redirect:"+Global.getAdminPath()+"/brand/cmBrand/";
-	}
-	
-	@RequiresPermissions("brand:cmBrand:delete")
-	@RequestMapping(value = "delete")
-	public String delete(CmBrand cmBrand, RedirectAttributes redirectAttributes) {
-		Date date = new Date();
-		cmBrand.setUpdateDate(date);
-		cmBrand.setDelFlag(date.getTime()+"");
-		//删除品牌表格内容
-		cmBrandService.delete(cmBrand);
-		//清理对应品牌商品信息(标记品牌为null)
-		productDao.updateProductByBrandId(Integer.parseInt(cmBrand.getId()));
-		addMessage(redirectAttributes, "删除品牌成功");
-		return "redirect:"+Global.getAdminPath()+"/brand/cmBrand/?repage";
-	}
-
-	@RequiresPermissions("brand:cmBrand:view")
-	@RequestMapping(value = {"uploadList"})
-	public String uploadList() {
-		return "modules/brand/brandUpload";
-	}
-
-	@ResponseBody
-	@RequestMapping(value = "import")
-	public Map<String,Object> cibeShopImport(@RequestParam(value="file",required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response, Model model){
-		Map<String,Object> map = new HashedMap();
-		try{
-			try {
-				//xls  2003版本
-				Workbook wb = new HSSFWorkbook(file.getInputStream());
-				// 得到第一个shell
-				Sheet sheet = wb.getSheetAt(0);
-				// 得到Excel的行数
-				this.totalRows = sheet.getPhysicalNumberOfRows();
-				// 得到Excel的列数(前提是有行数)
-				if (totalRows > 1 && sheet.getRow(0) != null) {
-					this.totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
-				}
-				List<BrandAndProductType> brandAndProductType = new ArrayList<>();
-				// 循环Excel行数
-				for (int r = 1; r < totalRows; r++) {
-					Row row = sheet.getRow(r);
-					if (row == null){
-						continue;
-					}
-					BrandAndProductType brandAndProduct = new BrandAndProductType();
-					// 循环Excel的列
-					for (int c = 0; c < this.totalCells; c++) {
-						Cell cell = row.getCell(c);
-						if (null != cell) {
-							String value = getFieldValue(cell);
-							switch (c){
-								case 0:
-									brandAndProduct.setBrandName(value); //品牌名字
-									break;
-								case 1:
-									break;
-								case 2:
-									break;
-								case 3:
-									break;
-								case 4:
-									break;
-								case 5:
-									break;
-								case 6:
-									break;
-								default:
-									break;
-							}
-						}
-					}
-					// 添加到list
-					brandAndProductType.add(brandAndProduct);
-				}
-
-				//将转化对象插入品牌库
-				if(CollectionUtils.isNotEmpty(brandAndProductType)){
-					for(BrandAndProductType b:brandAndProductType){
-						String brandName = b.getBrandName();
-						CmBrand cmBrand  = new CmBrand();
-						cmBrand.setName(brandName);
-						cmBrand.setSource("0");
-						cmBrand.setUserID("1");
-						cmBrand.setStatus("1");
-						cmBrand.setSort("0");
-						cmBrand.setDelFlag("0");
-						cmBrand.setCreateDate(new Date());
-						cmBrand.setUpdateDate(new Date());
-						cmBrandService.save(cmBrand);
-					}
-				}
-
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-			map.put("success",true);
-			map.put("msg", "上传成功");
-		}catch (Exception e){
-			e.printStackTrace();
-			logger.error(e.getMessage());
-			map.put("success",false);
-			map.put("msg", "上传失败");
-		}
-		return map;
-	}
-
-	@ResponseBody
-	@RequestMapping(value = "import1")
-	public Map<String,Object> import1(@RequestParam(value="file",required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response, Model model){
-		Map<String,Object> map = new HashedMap();
-		try{
-			try {
-				Workbook wb = new HSSFWorkbook(file.getInputStream());
-				// 得到第一个shell
-				Sheet sheet = wb.getSheetAt(0);
-				// 得到Excel的行数
-				this.totalRows = sheet.getPhysicalNumberOfRows();
-				// 得到Excel的列数(前提是有行数)
-				if (totalRows > 1 && sheet.getRow(0) != null) {
-					this.totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
-				}
-				List<BrandAndProductType> brandAndProductType = new ArrayList<>();
-				// 循环Excel行数
-				for (int r = 1; r < totalRows; r++) {
-					Row row = sheet.getRow(r);
-					if (row == null){
-						continue;
-					}
-					BrandAndProductType brandAndProduct = new BrandAndProductType();
-					// 循环Excel的列
-					for (int c = 0; c < this.totalCells; c++) {
-						Cell cell = row.getCell(c);
-						if (null != cell) {
-							String value = getFieldValue(cell);
-							switch (c){
-								case 0:
-									brandAndProduct.setProductId((int)Double.parseDouble(value));
-									break;
-								case 1:
-									break;
-								case 2:
-									break;
-								case 3:
-									brandAndProduct.setBrandName(value);
-									break;
-								case 4:
-									break;
-								case 5:
-									break;
-								case 6:
-									break;
-								default:
-									break;
-							}
-						}
-					}
-					// 添加到list
-					brandAndProductType.add(brandAndProduct);
-				}
-
-				//将转化对象更新到商品表
-				if(CollectionUtils.isNotEmpty(brandAndProductType)){
-					for(BrandAndProductType b:brandAndProductType){
-						//通过名字查询品牌
-						String brandName = b.getBrandName();
-						CmBrand cmBrand = new CmBrand();
-						cmBrand.setName(brandName);
-						CmBrand bradByName = cmBrandService.findBradByName(cmBrand);
-						if(null != bradByName){
-							String id = bradByName.getId();
-							Integer productId = b.getProductId();
-							Product product = new Product();
-							product.setBrandID(Integer.parseInt(id));
-							product.setProductID(productId);
-							productDao.updateBrnadId(product);
-						}else{
-							logger.info("---------------------商品不存在该品牌productId"+b.getProductId());
-						}
-					}
-				}
-
-			} catch (Exception e) {
-				logger.info(">>>>>>>>>>>>>>>>>>>>>>>>上次异常");
-				e.printStackTrace();
-			}
-			map.put("success",true);
-			map.put("msg", "上传成功");
-		}catch (Exception e){
-			e.printStackTrace();
-			logger.error(e.getMessage());
-			map.put("success",false);
-			map.put("msg", "上传失败");
-		}
-		return map;
-	}
-
-
-	@ResponseBody
-	@RequestMapping(value = "import2")
-	public Map<String,Object> import2(@RequestParam(value="file",required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response, Model model){
-		Map<String,Object> map = new HashedMap();
-		try{
-			try {
-				Workbook wb = new HSSFWorkbook(file.getInputStream());
-				// 得到第一个shell
-				Sheet sheet = wb.getSheetAt(0);
-				// 得到Excel的行数
-				this.totalRows = sheet.getPhysicalNumberOfRows();
-				// 得到Excel的列数(前提是有行数)
-				if (totalRows > 1 && sheet.getRow(0) != null) {
-					this.totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
-				}
-				List<BrandAndProductType> brandAndProductType = new ArrayList<>();
-				// 循环Excel行数
-				for (int r = 1; r < totalRows; r++) {
-					Row row = sheet.getRow(r);
-					if (row == null){
-						continue;
-					}
-					BrandAndProductType brandAndProduct = new BrandAndProductType();
-					// 循环Excel的列
-					for (int c = 0; c < this.totalCells; c++) {
-						Cell cell = row.getCell(c);
-						if (null != cell) {
-							String value = getFieldValue(cell);
-							switch (c){
-								case 0:
-									brandAndProduct.setProductId((int)Double.parseDouble(value)); //商品ID
-									logger.info("__________________________product"+value);
-									break;
-								case 1:
-									break;
-								case 2:
-									break;
-								case 3:
-									break;
-								case 4:
+        if (null != cmBrandByName) {
+            addMessage(redirectAttributes, "该品牌已存在");
+        } else {
+            //判断是新增加还是修改
+            if (StringUtils.isEmpty(cmBrand.getId())) {//新增
+                cmBrand.setCreateDate(new Date());
+                cmBrand.setStatus("1");//采美添加默认通过--品牌状态 0:待审核,1:审核通过,2:审核失败
+                cmBrand.setSource("0");//添加来源 0:后台添加 ,1:供应商添加
+                cmBrand.setSort("0");
+                cmBrand.setUserID(UserUtils.getUser() + "");
+            } else {//修改
+                String status = cmBrand.getStatus();
+                CmBrand oldBrand = cmBrandService.get(cmBrand.getId());//获取修改前的品牌信息
+                String oldStatus = oldBrand.getStatus();//老的状态
+                if (!StringUtils.equals(status, oldStatus)) {//重新修改状态才发送短信提示(防止重复编辑重复发送短信)
+                    if (StringUtils.equals("1", status)) {
+                        String mobile = cmBrand.getShopMobile();
+                        if (StringUtils.isNotEmpty(mobile)) {
+                            SMSUtils.sendSms(mobile, "您提交的[" + cmBrand.getName() + "]品牌申请,已审核成功");
+                        }
+                    }
+                    if (StringUtils.equals("2", status)) {
+                        String auditNote = cmBrand.getAuditNote();
+                        if (StringUtils.isEmpty(auditNote)) {
+                            addMessage(model, "请输入失败原因!!");
+                            return form(cmBrand, model);
+                        }
+                        String mobile = cmBrand.getShopMobile();
+                        if (StringUtils.isNotEmpty(mobile)) {
+                            SMSUtils.sendSms(mobile, "抱歉,您提交的[" + cmBrand.getName() + "]品牌申请,由于" + cmBrand.getAuditNote() + "审核失败,请重新修改提交!");
+                        }
+                    }
+                } else {
+                    if (StringUtils.equals("2", status)) {
+                        String auditNote = cmBrand.getAuditNote();
+                        if (StringUtils.isEmpty(auditNote)) {
+                            addMessage(model, "请输入失败原因!!");
+                            return form(cmBrand, model);
+                        }
+                    }
+                }
+
+            }
+
+
+            cmBrand.setUpdateDate(new Date());
+            cmBrandService.save(cmBrand);
+            addMessage(redirectAttributes, "保存品牌成功");
+        }
+        return "redirect:" + Global.getAdminPath() + "/brand/cmBrand/";
+    }
+
+    @RequiresPermissions("brand:cmBrand:delete")
+    @RequestMapping(value = "delete")
+    public String delete(CmBrand cmBrand, RedirectAttributes redirectAttributes) {
+        Date date = new Date();
+        cmBrand.setUpdateDate(date);
+        cmBrand.setDelFlag(date.getTime() + "");
+        //删除品牌表格内容
+        cmBrandService.delete(cmBrand);
+        //清理对应品牌商品信息(标记品牌为null)
+        productDao.updateProductByBrandId(Integer.parseInt(cmBrand.getId()));
+        addMessage(redirectAttributes, "删除品牌成功");
+        return "redirect:" + Global.getAdminPath() + "/brand/cmBrand/?repage";
+    }
+
+    @RequiresPermissions("brand:cmBrand:view")
+    @RequestMapping(value = {"uploadList"})
+    public String uploadList() {
+        return "modules/brand/brandUpload";
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "import")
+    public Map<String, Object> cibeShopImport(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Map<String, Object> map = new HashedMap();
+        try {
+            try {
+                //xls  2003版本
+                Workbook wb = new HSSFWorkbook(file.getInputStream());
+                // 得到第一个shell
+                Sheet sheet = wb.getSheetAt(0);
+                // 得到Excel的行数
+                this.totalRows = sheet.getPhysicalNumberOfRows();
+                // 得到Excel的列数(前提是有行数)
+                if (totalRows > 1 && sheet.getRow(0) != null) {
+                    this.totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
+                }
+                List<BrandAndProductType> brandAndProductType = new ArrayList<>();
+                // 循环Excel行数
+                for (int r = 1; r < totalRows; r++) {
+                    Row row = sheet.getRow(r);
+                    if (row == null) {
+                        continue;
+                    }
+                    BrandAndProductType brandAndProduct = new BrandAndProductType();
+                    // 循环Excel的列
+                    for (int c = 0; c < this.totalCells; c++) {
+                        Cell cell = row.getCell(c);
+                        if (null != cell) {
+                            String value = getFieldValue(cell);
+                            switch (c) {
+                                case 0:
+                                    brandAndProduct.setBrandName(value); //品牌名字
+                                    break;
+                                case 1:
+                                    break;
+                                case 2:
+                                    break;
+                                case 3:
+                                    break;
+                                case 4:
+                                    break;
+                                case 5:
+                                    break;
+                                case 6:
+                                    break;
+                                default:
+                                    break;
+                            }
+                        }
+                    }
+                    // 添加到list
+                    brandAndProductType.add(brandAndProduct);
+                }
+
+                //将转化对象插入品牌库
+                if (CollectionUtils.isNotEmpty(brandAndProductType)) {
+                    for (BrandAndProductType b : brandAndProductType) {
+                        String brandName = b.getBrandName();
+                        CmBrand cmBrand = new CmBrand();
+                        cmBrand.setName(brandName);
+                        cmBrand.setSource("0");
+                        cmBrand.setUserID("1");
+                        cmBrand.setStatus("1");
+                        cmBrand.setSort("0");
+                        cmBrand.setDelFlag("0");
+                        cmBrand.setCreateDate(new Date());
+                        cmBrand.setUpdateDate(new Date());
+                        cmBrandService.save(cmBrand);
+                    }
+                }
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            map.put("success", true);
+            map.put("msg", "上传成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error(e.getMessage());
+            map.put("success", false);
+            map.put("msg", "上传失败");
+        }
+        return map;
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "import1")
+    public Map<String, Object> import1(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Map<String, Object> map = new HashedMap();
+        try {
+            try {
+                Workbook wb = new HSSFWorkbook(file.getInputStream());
+                // 得到第一个shell
+                Sheet sheet = wb.getSheetAt(0);
+                // 得到Excel的行数
+                this.totalRows = sheet.getPhysicalNumberOfRows();
+                // 得到Excel的列数(前提是有行数)
+                if (totalRows > 1 && sheet.getRow(0) != null) {
+                    this.totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
+                }
+                List<BrandAndProductType> brandAndProductType = new ArrayList<>();
+                // 循环Excel行数
+                for (int r = 1; r < totalRows; r++) {
+                    Row row = sheet.getRow(r);
+                    if (row == null) {
+                        continue;
+                    }
+                    BrandAndProductType brandAndProduct = new BrandAndProductType();
+                    // 循环Excel的列
+                    for (int c = 0; c < this.totalCells; c++) {
+                        Cell cell = row.getCell(c);
+                        if (null != cell) {
+                            String value = getFieldValue(cell);
+                            switch (c) {
+                                case 0:
+                                    brandAndProduct.setProductId((int) Double.parseDouble(value));
+                                    break;
+                                case 1:
+                                    break;
+                                case 2:
+                                    break;
+                                case 3:
+                                    brandAndProduct.setBrandName(value);
+                                    break;
+                                case 4:
+                                    break;
+                                case 5:
+                                    break;
+                                case 6:
+                                    break;
+                                default:
+                                    break;
+                            }
+                        }
+                    }
+                    // 添加到list
+                    brandAndProductType.add(brandAndProduct);
+                }
+
+                //将转化对象更新到商品表
+                if (CollectionUtils.isNotEmpty(brandAndProductType)) {
+                    for (BrandAndProductType b : brandAndProductType) {
+                        //通过名字查询品牌
+                        String brandName = b.getBrandName();
+                        CmBrand cmBrand = new CmBrand();
+                        cmBrand.setName(brandName);
+                        CmBrand bradByName = cmBrandService.findBradByName(cmBrand);
+                        if (null != bradByName) {
+                            String id = bradByName.getId();
+                            Integer productId = b.getProductId();
+                            Product product = new Product();
+                            product.setBrandID(Integer.parseInt(id));
+                            product.setProductID(productId);
+                            productDao.updateBrnadId(product);
+                        } else {
+                            logger.info("---------------------商品不存在该品牌productId" + b.getProductId());
+                        }
+                    }
+                }
+
+            } catch (Exception e) {
+                logger.info(">>>>>>>>>>>>>>>>>>>>>>>>上次异常");
+                e.printStackTrace();
+            }
+            map.put("success", true);
+            map.put("msg", "上传成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error(e.getMessage());
+            map.put("success", false);
+            map.put("msg", "上传失败");
+        }
+        return map;
+    }
+
+
+    @ResponseBody
+    @RequestMapping(value = "import2")
+    public Map<String, Object> import2(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Map<String, Object> map = new HashedMap();
+        try {
+            try {
+                Workbook wb = new HSSFWorkbook(file.getInputStream());
+                // 得到第一个shell
+                Sheet sheet = wb.getSheetAt(0);
+                // 得到Excel的行数
+                this.totalRows = sheet.getPhysicalNumberOfRows();
+                // 得到Excel的列数(前提是有行数)
+                if (totalRows > 1 && sheet.getRow(0) != null) {
+                    this.totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
+                }
+                List<BrandAndProductType> brandAndProductType = new ArrayList<>();
+                // 循环Excel行数
+                for (int r = 1; r < totalRows; r++) {
+                    Row row = sheet.getRow(r);
+                    if (row == null) {
+                        continue;
+                    }
+                    BrandAndProductType brandAndProduct = new BrandAndProductType();
+                    // 循环Excel的列
+                    for (int c = 0; c < this.totalCells; c++) {
+                        Cell cell = row.getCell(c);
+                        if (null != cell) {
+                            String value = getFieldValue(cell);
+                            switch (c) {
+                                case 0:
+                                    brandAndProduct.setProductId((int) Double.parseDouble(value)); //商品ID
+                                    logger.info("__________________________product" + value);
+                                    break;
+                                case 1:
+                                    break;
+                                case 2:
+                                    break;
+                                case 3:
+                                    break;
+                                case 4:
 //									会所常用品(HSCY)-美容工具(MRGJ)-小工具(XGJ)
 
-									//去掉value中的括号以及括号里内容
-									String[] split = value.split("-");
-									int length = split.length;
-									if(length == 3){
-										String s = split[0];
-										String s1 = split[1];
-										String s2 = split[2];
-										int i = s.indexOf("(");
-										String substring = s.substring(0, i);
-
-										int i1 = s1.indexOf("(");
-										String substring1 = s1.substring(0, i1);
-
-										int i2 = s2.indexOf("(");
-										String substring2 = s2.substring(0, i2);
-
-										brandAndProduct.setBigTypeName(substring);//大分类
-										brandAndProduct.setSmallTypeName(substring1);//二级分类
-										brandAndProduct.setTinyTypeName(substring2);//小分类名字
-									}
-									break;
-								case 5:
-									break;
-								case 6:
-									break;
-								default:
-									break;
-							}
-						}
-					}
-					// 添加到list
-					brandAndProductType.add(brandAndProduct);
-				}
-
-				//将转化对象插入品牌库
-				if(CollectionUtils.isNotEmpty(brandAndProductType)){
-					for(BrandAndProductType b:brandAndProductType){
-						String bigTypeName = b.getBigTypeName();
-						String smallTypeName = b.getSmallTypeName();
-						String tinyTypeName = b.getTinyTypeName();
-
-						List<BrandAndProductType> productByTypeName = productDao.getProductByTypeName(bigTypeName, smallTypeName, tinyTypeName);
-						if(CollectionUtils.isNotEmpty(productByTypeName) && productByTypeName.size() == 1){
-							BrandAndProductType brandAndProductType1 = productByTypeName.get(0);
-							Integer tinyTypeID = brandAndProductType1.getTinyTypeID();
-							Product product = new Product();
-							product.setProductID(b.getProductId());
-							product.setTinyTypeID(tinyTypeID);
-							productDao.updateTinyType(product);
-						}
-						else{
-							logger.info("----------------------商品分类异常ProductId"+b.getProductId());
-						}
-					}
-				}
-			} catch (Exception e) {
-				logger.info(">>>>>>>>>>>>>>>>>>>>>>>>上次异常");
-				e.printStackTrace();
-			}
-			map.put("success",true);
-			map.put("msg", "上传成功");
-		}catch (Exception e){
-			e.printStackTrace();
-			logger.error(e.getMessage());
-			map.put("success",false);
-			map.put("msg", "上传失败");
-		}
-		return map;
-	}
-
-	public String getFieldValue(Cell cell){
-		String value = null;
-		if(cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC){
-			value = String.valueOf(cell.getNumericCellValue());
-		}else {
-			value = cell.getStringCellValue();
-		}
-		return value;
-	}
-
-	public int getTotalRows() {
-		return totalRows;
-	}
-
-	public void setTotalRows(int totalRows) {
-		this.totalRows = totalRows;
-	}
-
-	public int getTotalCells() {
-		return totalCells;
-	}
-
-	public void setTotalCells(int totalCells) {
-		this.totalCells = totalCells;
-	}
-
-	public String getErrorMsg() {
-		return errorMsg;
-	}
-
-	public void setErrorMsg(String errorMsg) {
-		this.errorMsg = errorMsg;
-	}
+                                    //去掉value中的括号以及括号里内容
+                                    String[] split = value.split("-");
+                                    int length = split.length;
+                                    if (length == 3) {
+                                        String s = split[0];
+                                        String s1 = split[1];
+                                        String s2 = split[2];
+                                        int i = s.indexOf("(");
+                                        String substring = s.substring(0, i);
+
+                                        int i1 = s1.indexOf("(");
+                                        String substring1 = s1.substring(0, i1);
+
+                                        int i2 = s2.indexOf("(");
+                                        String substring2 = s2.substring(0, i2);
+
+                                        brandAndProduct.setBigTypeName(substring);//大分类
+                                        brandAndProduct.setSmallTypeName(substring1);//二级分类
+                                        brandAndProduct.setTinyTypeName(substring2);//小分类名字
+                                    }
+                                    break;
+                                case 5:
+                                    break;
+                                case 6:
+                                    break;
+                                default:
+                                    break;
+                            }
+                        }
+                    }
+                    // 添加到list
+                    brandAndProductType.add(brandAndProduct);
+                }
+
+                //将转化对象插入品牌库
+                if (CollectionUtils.isNotEmpty(brandAndProductType)) {
+                    for (BrandAndProductType b : brandAndProductType) {
+                        String bigTypeName = b.getBigTypeName();
+                        String smallTypeName = b.getSmallTypeName();
+                        String tinyTypeName = b.getTinyTypeName();
+
+                        List<BrandAndProductType> productByTypeName = productDao.getProductByTypeName(bigTypeName, smallTypeName, tinyTypeName);
+                        if (CollectionUtils.isNotEmpty(productByTypeName) && productByTypeName.size() == 1) {
+                            BrandAndProductType brandAndProductType1 = productByTypeName.get(0);
+                            Integer tinyTypeID = brandAndProductType1.getTinyTypeID();
+                            Product product = new Product();
+                            product.setProductID(b.getProductId());
+                            product.setTinyTypeID(tinyTypeID);
+                            productDao.updateTinyType(product);
+                        } else {
+                            logger.info("----------------------商品分类异常ProductId" + b.getProductId());
+                        }
+                    }
+                }
+            } catch (Exception e) {
+                logger.info(">>>>>>>>>>>>>>>>>>>>>>>>上次异常");
+                e.printStackTrace();
+            }
+            map.put("success", true);
+            map.put("msg", "上传成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error(e.getMessage());
+            map.put("success", false);
+            map.put("msg", "上传失败");
+        }
+        return map;
+    }
+
+    public String getFieldValue(Cell cell) {
+        String value = null;
+        if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
+            value = String.valueOf(cell.getNumericCellValue());
+        } else {
+            value = cell.getStringCellValue();
+        }
+        return value;
+    }
+
+    public int getTotalRows() {
+        return totalRows;
+    }
+
+    public void setTotalRows(int totalRows) {
+        this.totalRows = totalRows;
+    }
+
+    public int getTotalCells() {
+        return totalCells;
+    }
+
+    public void setTotalCells(int totalCells) {
+        this.totalCells = totalCells;
+    }
+
+    public String getErrorMsg() {
+        return errorMsg;
+    }
+
+    public void setErrorMsg(String errorMsg) {
+        this.errorMsg = errorMsg;
+    }
 
 }

+ 352 - 332
src/main/java/com/caimei/modules/bulkpurchase/entity/PurchaseProduct.java

@@ -2,72 +2,77 @@ package com.caimei.modules.bulkpurchase.entity;
 
 import com.caimei.modules.product.entity.CmPromotion;
 import com.caimei.po.ProductLadderPrice;
-import org.hibernate.validator.constraints.Length;
-
 import com.thinkgem.jeesite.common.persistence.DataEntity;
+import org.hibernate.validator.constraints.Length;
 
 import java.util.List;
 
 /**
  * 大宗采购商品信息Entity
+ *
  * @author jiangjunwen
  * @version 2017-03-28
  */
 public class PurchaseProduct extends DataEntity<PurchaseProduct> {
 
-	private static final long serialVersionUID = 1L;
-	private String purchaseProductName;		// 商品名称
-	private String name;		// 商品名称
-	private String image;//商品图片
-	private Long contractId;		// 采购id
-	private String productNo;		// 商品编号
-	private Long productId;		// 商品ID
-	private String shopName;		// 供应商名称
-	private String price;		// 当前单价
-	private String discount;		// 折扣
-	private String discountPrice;		// 折后单价
-	private String includedTax;		//是否含税 0不含税 1含税 2未知
-	private String invoiceType;		//发票类型(基于是否含税基础) 1增值税专用发票 2增值税普通发票 3不能开票
-	private String taxRate;		// 机构税率
-	private String supplierTaxRate; // 供应商税率
-	private String addedValueTax;		// 机构税费(单)
-	private String singleShouldPayTotalTax;		// 供应商税费(单)
-	private String stipulateFlag;		// 是否是规定商品 0否 1是
-	private String shopId;
-	private String shopFee;  // 应付供应商金额
-	private String cmFee;  // 应付采美金额
-	private String otherFee;  // 应付第三方金额
-	private String shopFee1;  // 应付供应商金额(单个)
-	private String cmFee1;  // 应付采美金额(单个)
-	private String otherFee1;  // 应付第三方金额(单个)
-	private List<ProductPrivilege>  productPrivilege;
-	private String flag;//区分选择商品页面,flag=1:直接生成订单中添加商品使用,没有值表示合同中添加商品使用
-
-	private String num;//购买数量
-	private String giveNum;//手动输入赠品数
-	private String totalAddedValueTax;//总机构税费
-	private String shouldPayTotalTax;//总供应商税费
-	private String totalFee;//总费用
-	private String buyAgainFlag;//订单商品再次购买标识 0否 1是
-	private String costCheckFlag;//成本价选中标志:1固定成本 2比例成
-	private String costPrice;//成本价
-	private String costProportional;//比例成本百分比90%
-	private String priceType;  // 虚拟字段  协销帮个人用户下单的时候  priceType = normal 取普通用户价格
-	private String normalPrice; //普通用户的价格
-	private Integer userId;//用户Id
-	private String buyAgainPriceFlag;  // 商品是否使用复购价格购买标识 0否 1是
-	private String productCategory;//商品的类别:1正常商品(默认),2二手商品
-	private String secondHandType;//二手商品分类,1二手仪器,2临期产品,3其他
-	private CmPromotion cmPromotion;//参与的促销活动
-	private Integer ladderPriceFlag;        // 启用阶梯价格标识 0否 1是
+    private static final long serialVersionUID = 1L;
+    private String purchaseProductName;        // 商品名称
+    private String name;        // 商品名称
+    private String image;//商品图片
+    private Long contractId;        // 采购id
+    private String productNo;        // 商品编号
+    private Long productId;        // 商品ID
+    private String shopName;        // 供应商名称
+    private String price;        // 当前单价
+    private String discount;        // 折扣
+    private String discountPrice;        // 折后单价
+    private String includedTax;        //是否含税 0不含税 1含税 2未知
+    private String invoiceType;        //发票类型(基于是否含税基础) 1增值税专用发票 2增值税普通发票 3不能开票
+    private String taxRate;        // 机构税率
+    private String supplierTaxRate; // 供应商税率
+    private String addedValueTax;        // 机构税费(单)
+    private String singleShouldPayTotalTax;        // 供应商税费(单)
+    private String stipulateFlag;        // 是否是规定商品 0否 1是
+    private String shopId;
+    private String shopFee;  // 应付供应商金额
+    private String cmFee;  // 应付采美金额
+    private String otherFee;  // 应付第三方金额
+    private String shopFee1;  // 应付供应商金额(单个)
+    private String cmFee1;  // 应付采美金额(单个)
+    private String otherFee1;  // 应付第三方金额(单个)
+    private List<ProductPrivilege> productPrivilege;
+    private String flag;//区分选择商品页面,flag=1:直接生成订单中添加商品使用,没有值表示合同中添加商品使用
+
+    private String num;//购买数量
+    private String giveNum;//手动输入赠品数
+    private String totalAddedValueTax;//总机构税费
+    private String shouldPayTotalTax;//总供应商税费
+    private String totalFee;//总费用
+    private String buyAgainFlag;//订单商品再次购买标识 0否 1是
+    private String costCheckFlag;//成本价选中标志:1固定成本 2比例成
+    private String costPrice;//成本价
+    private String costProportional;//比例成本百分比90%
+    private String priceType;  // 虚拟字段  协销帮个人用户下单的时候  priceType = normal 取普通用户价格
+    private String normalPrice; //普通用户的价格
+    private Integer userId;//用户Id
+    private String buyAgainPriceFlag;  // 商品是否使用复购价格购买标识 0否 1是
+    private String productCategory;//商品的类别:1正常商品(默认),2二手商品
+    private String secondHandType;//二手商品分类,1二手仪器,2临期产品,3其他
+    private CmPromotion cmPromotion;//参与的促销活动
+    private Integer ladderPriceFlag;        // 启用阶梯价格标识 0否 1是
     private List<ProductLadderPrice> ladderPriceList;//阶梯价格列表
-	private String oldProductFlag;//是否是旧商品 0否 1是
-	public Integer getLadderPriceFlag() {
-		return ladderPriceFlag;
-	}
-	public void setLadderPriceFlag(Integer ladderPriceFlag) {
-		this.ladderPriceFlag = ladderPriceFlag;
-	}
+    private String oldProductFlag;//是否是旧商品 0否 1是
+    private String commodityType; //商品属性:1产品,2仪器
+    private Integer couponsLogo;    //显示优惠券查看: 1不显示 2显示
+
+    public Integer getLadderPriceFlag() {
+        return ladderPriceFlag;
+    }
+
+    public void setLadderPriceFlag(Integer ladderPriceFlag) {
+        this.ladderPriceFlag = ladderPriceFlag;
+    }
+
     public List<ProductLadderPrice> getLadderPriceList() {
         return ladderPriceList;
     }
@@ -76,366 +81,381 @@ public class PurchaseProduct extends DataEntity<PurchaseProduct> {
         this.ladderPriceList = ladderPriceList;
     }
 
-	public String getName() {
-		return name;
-	}
+    public String getName() {
+        return name;
+    }
 
-	public void setName(String name) {
-		this.name = name;
-	}
+    public void setName(String name) {
+        this.name = name;
+    }
 
-	public String getNum() {
-		return num;
-	}
+    public String getNum() {
+        return num;
+    }
 
-	public void setNum(String num) {
-		this.num = num;
-	}
+    public void setNum(String num) {
+        this.num = num;
+    }
 
-	public String getTotalFee() {
-		return totalFee;
-	}
+    public String getTotalFee() {
+        return totalFee;
+    }
 
-	public void setTotalFee(String totalFee) {
-		this.totalFee = totalFee;
-	}
+    public void setTotalFee(String totalFee) {
+        this.totalFee = totalFee;
+    }
 
-	public String getGiveNum() {
-		return giveNum;
-	}
+    public String getGiveNum() {
+        return giveNum;
+    }
 
-	public void setGiveNum(String giveNum) {
-		this.giveNum = giveNum;
-	}
+    public void setGiveNum(String giveNum) {
+        this.giveNum = giveNum;
+    }
 
-	public String getTotalAddedValueTax() {
-		return totalAddedValueTax;
-	}
+    public String getTotalAddedValueTax() {
+        return totalAddedValueTax;
+    }
 
-	public void setTotalAddedValueTax(String totalAddedValueTax) {
-		this.totalAddedValueTax = totalAddedValueTax;
-	}
+    public void setTotalAddedValueTax(String totalAddedValueTax) {
+        this.totalAddedValueTax = totalAddedValueTax;
+    }
 
-	public String getFlag() {
-		return flag;
-	}
+    public String getFlag() {
+        return flag;
+    }
 
-	public void setFlag(String flag) {
-		this.flag = flag;
-	}
+    public void setFlag(String flag) {
+        this.flag = flag;
+    }
 
-	public String getShopFee() {
-		return shopFee;
-	}
+    public String getShopFee() {
+        return shopFee;
+    }
 
-	public void setShopFee(String shopFee) {
-		this.shopFee = shopFee;
-	}
+    public void setShopFee(String shopFee) {
+        this.shopFee = shopFee;
+    }
 
-	public String getCmFee() {
-		return cmFee;
-	}
+    public String getCmFee() {
+        return cmFee;
+    }
 
-	public void setCmFee(String cmFee) {
-		this.cmFee = cmFee;
-	}
+    public void setCmFee(String cmFee) {
+        this.cmFee = cmFee;
+    }
 
-	public String getOtherFee() {
-		return otherFee;
-	}
+    public String getOtherFee() {
+        return otherFee;
+    }
 
-	public void setOtherFee(String otherFee) {
-		this.otherFee = otherFee;
-	}
+    public void setOtherFee(String otherFee) {
+        this.otherFee = otherFee;
+    }
 
 
-	public PurchaseProduct() {
-		super();
-	}
+    public PurchaseProduct() {
+        super();
+    }
 
-	public PurchaseProduct(String id){
-		super(id);
-	}
+    public PurchaseProduct(String id) {
+        super(id);
+    }
 
-	@Length(min=1, max=30, message="商品名称长度必须介于 1 和 30 之间")
-	public String getPurchaseProductName() {
-		return purchaseProductName;
-	}
+    @Length(min = 1, max = 30, message = "商品名称长度必须介于 1 和 30 之间")
+    public String getPurchaseProductName() {
+        return purchaseProductName;
+    }
 
-	public String getShopId() {
-		return shopId;
-	}
+    public String getShopId() {
+        return shopId;
+    }
 
-	public void setShopId(String shopId) {
-		this.shopId = shopId;
-	}
+    public void setShopId(String shopId) {
+        this.shopId = shopId;
+    }
 
-	public static long getSerialVersionUID() {
-		return serialVersionUID;
-	}
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
 
-	public List<ProductPrivilege> getProductPrivilege() {
-		return productPrivilege;
-	}
+    public List<ProductPrivilege> getProductPrivilege() {
+        return productPrivilege;
+    }
 
-	public void setProductPrivilege(List<ProductPrivilege> productPrivilege) {
-		this.productPrivilege = productPrivilege;
-	}
+    public void setProductPrivilege(List<ProductPrivilege> productPrivilege) {
+        this.productPrivilege = productPrivilege;
+    }
 
-	public void setPurchaseProductName(String purchaseProductName) {
-		this.purchaseProductName = purchaseProductName;
-	}
+    public void setPurchaseProductName(String purchaseProductName) {
+        this.purchaseProductName = purchaseProductName;
+    }
 
 
+    public Long getContractId() {
+        return contractId;
+    }
 
-	public Long getContractId() {
-		return contractId;
-	}
+    public void setContractId(Long contractId) {
+        this.contractId = contractId;
+    }
 
-	public void setContractId(Long contractId) {
-		this.contractId = contractId;
-	}
+    @Length(min = 0, max = 30, message = "商品编号长度必须介于 0 和 30 之间")
+    public String getProductNo() {
+        return productNo;
+    }
 
-	@Length(min=0, max=30, message="商品编号长度必须介于 0 和 30 之间")
-	public String getProductNo() {
-		return productNo;
-	}
+    public void setProductNo(String productNo) {
+        this.productNo = productNo;
+    }
 
-	public void setProductNo(String productNo) {
-		this.productNo = productNo;
-	}
+    public Long getProductId() {
+        return productId;
+    }
 
-	public Long getProductId() {
-		return productId;
-	}
+    public void setProductId(Long productId) {
+        this.productId = productId;
+    }
 
-	public void setProductId(Long productId) {
-		this.productId = productId;
-	}
+    @Length(min = 0, max = 20, message = "供应商名称长度必须介于 0 和 20 之间")
+    public String getShopName() {
+        return shopName;
+    }
 
-	@Length(min=0, max=20, message="供应商名称长度必须介于 0 和 20 之间")
-	public String getShopName() {
-		return shopName;
-	}
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
 
-	public void setShopName(String shopName) {
-		this.shopName = shopName;
-	}
+    public String getPrice() {
+        return price;
+    }
 
-	public String getPrice() {
-		return price;
-	}
+    public void setPrice(String price) {
+        this.price = price;
+    }
 
-	public void setPrice(String price) {
-		this.price = price;
-	}
+    public String getDiscount() {
+        return discount;
+    }
 
-	public String getDiscount() {
-		return discount;
-	}
+    public void setDiscount(String discount) {
+        this.discount = discount;
+    }
 
-	public void setDiscount(String discount) {
-		this.discount = discount;
-	}
+    public String getDiscountPrice() {
+        return discountPrice;
+    }
 
-	public String getDiscountPrice() {
-		return discountPrice;
-	}
+    public void setDiscountPrice(String discountPrice) {
+        this.discountPrice = discountPrice;
+    }
 
-	public void setDiscountPrice(String discountPrice) {
-		this.discountPrice = discountPrice;
-	}
+    public String getTaxRate() {
+        return taxRate;
+    }
 
-	public String getTaxRate() {
-		return taxRate;
-	}
+    public void setTaxRate(String taxRate) {
+        this.taxRate = taxRate;
+    }
 
-	public void setTaxRate(String taxRate) {
-		this.taxRate = taxRate;
-	}
+    public String getAddedValueTax() {
+        return addedValueTax;
+    }
 
-	public String getAddedValueTax() {
-		return addedValueTax;
-	}
+    public void setAddedValueTax(String addedValueTax) {
+        this.addedValueTax = addedValueTax;
+    }
 
-	public void setAddedValueTax(String addedValueTax) {
-		this.addedValueTax = addedValueTax;
-	}
+    @Length(min = 0, max = 1, message = "是否是规定商品 0否 1是长度必须介于 0 和 1 之间")
+    public String getStipulateFlag() {
+        return stipulateFlag;
+    }
 
-	@Length(min=0, max=1, message="是否是规定商品 0否 1是长度必须介于 0 和 1 之间")
-	public String getStipulateFlag() {
-		return stipulateFlag;
-	}
+    public void setStipulateFlag(String stipulateFlag) {
+        this.stipulateFlag = stipulateFlag;
+    }
 
-	public void setStipulateFlag(String stipulateFlag) {
-		this.stipulateFlag = stipulateFlag;
-	}
+    public String getImage() {
+        return image;
+    }
 
-	public String getImage() {
-		return image;
-	}
+    public void setImage(String image) {
+        this.image = image;
+    }
 
-	public void setImage(String image) {
-		this.image = image;
-	}
+    public String getBuyAgainFlag() {
+        return buyAgainFlag;
+    }
 
-	public String getBuyAgainFlag() {
-		return buyAgainFlag;
-	}
+    public void setBuyAgainFlag(String buyAgainFlag) {
+        this.buyAgainFlag = buyAgainFlag;
+    }
 
-	public void setBuyAgainFlag(String buyAgainFlag) {
-		this.buyAgainFlag = buyAgainFlag;
-	}
+    public String getCostCheckFlag() {
+        return costCheckFlag;
+    }
 
-	public String getCostCheckFlag() {
-		return costCheckFlag;
-	}
+    public void setCostCheckFlag(String costCheckFlag) {
+        this.costCheckFlag = costCheckFlag;
+    }
 
-	public void setCostCheckFlag(String costCheckFlag) {
-		this.costCheckFlag = costCheckFlag;
-	}
+    public String getCostPrice() {
+        return costPrice;
+    }
 
-	public String getCostPrice() {
-		return costPrice;
-	}
+    public void setCostPrice(String costPrice) {
+        this.costPrice = costPrice;
+    }
 
-	public void setCostPrice(String costPrice) {
-		this.costPrice = costPrice;
-	}
+    public String getCostProportional() {
+        return costProportional;
+    }
 
-	public String getCostProportional() {
-		return costProportional;
-	}
+    public void setCostProportional(String costProportional) {
+        this.costProportional = costProportional;
+    }
 
-	public void setCostProportional(String costProportional) {
-		this.costProportional = costProportional;
-	}
+    public String getShopFee1() {
+        return shopFee1;
+    }
 
-	public String getShopFee1() {
-		return shopFee1;
-	}
+    public void setShopFee1(String shopFee1) {
+        this.shopFee1 = shopFee1;
+    }
 
-	public void setShopFee1(String shopFee1) {
-		this.shopFee1 = shopFee1;
-	}
+    public String getCmFee1() {
+        return cmFee1;
+    }
 
-	public String getCmFee1() {
-		return cmFee1;
-	}
+    public void setCmFee1(String cmFee1) {
+        this.cmFee1 = cmFee1;
+    }
 
-	public void setCmFee1(String cmFee1) {
-		this.cmFee1 = cmFee1;
-	}
+    public String getOtherFee1() {
+        return otherFee1;
+    }
 
-	public String getOtherFee1() {
-		return otherFee1;
-	}
+    public void setOtherFee1(String otherFee1) {
+        this.otherFee1 = otherFee1;
+    }
 
-	public void setOtherFee1(String otherFee1) {
-		this.otherFee1 = otherFee1;
-	}
+    public String getPriceType() {
+        return priceType;
+    }
 
-	public String getPriceType() {
-		return priceType;
-	}
-
-	public void setPriceType(String priceType) {
-		this.priceType = priceType;
-	}
-
-	public String getNormalPrice() {
-		return normalPrice;
-	}
-
-	public void setNormalPrice(String normalPrice) {
-		this.normalPrice = normalPrice;
-	}
-
-	public Integer getUserId() {
-		return userId;
-	}
-
-	public void setUserId(Integer userId) {
-		this.userId = userId;
-	}
-
-	public String getBuyAgainPriceFlag() {
-		return buyAgainPriceFlag;
-	}
-
-	public void setBuyAgainPriceFlag(String buyAgainPriceFlag) {
-		this.buyAgainPriceFlag = buyAgainPriceFlag;
-	}
+    public void setPriceType(String priceType) {
+        this.priceType = priceType;
+    }
 
-	public String getProductCategory() {
-		return productCategory;
-	}
+    public String getNormalPrice() {
+        return normalPrice;
+    }
 
-	public void setProductCategory(String productCategory) {
-		this.productCategory = productCategory;
-	}
+    public void setNormalPrice(String normalPrice) {
+        this.normalPrice = normalPrice;
+    }
 
-	public String getSecondHandType() {
-		return secondHandType;
-	}
+    public Integer getUserId() {
+        return userId;
+    }
 
-	public void setSecondHandType(String secondHandType) {
-		this.secondHandType = secondHandType;
-	}
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
 
-	public CmPromotion getCmPromotion() {
-		return cmPromotion;
-	}
+    public String getBuyAgainPriceFlag() {
+        return buyAgainPriceFlag;
+    }
 
-	public void setCmPromotion(CmPromotion cmPromotion) {
-		this.cmPromotion = cmPromotion;
-	}
+    public void setBuyAgainPriceFlag(String buyAgainPriceFlag) {
+        this.buyAgainPriceFlag = buyAgainPriceFlag;
+    }
 
-	public String getIncludedTax() {
-		return includedTax;
-	}
+    public String getProductCategory() {
+        return productCategory;
+    }
 
-	public void setIncludedTax(String includedTax) {
-		this.includedTax = includedTax;
-	}
+    public void setProductCategory(String productCategory) {
+        this.productCategory = productCategory;
+    }
 
-	public String getInvoiceType() {
-		return invoiceType;
-	}
+    public String getSecondHandType() {
+        return secondHandType;
+    }
 
-	public void setInvoiceType(String invoiceType) {
-		this.invoiceType = invoiceType;
-	}
+    public void setSecondHandType(String secondHandType) {
+        this.secondHandType = secondHandType;
+    }
 
-	public String getSupplierTaxRate() {
-		return supplierTaxRate;
-	}
+    public CmPromotion getCmPromotion() {
+        return cmPromotion;
+    }
 
-	public void setSupplierTaxRate(String supplierTaxRate) {
-		this.supplierTaxRate = supplierTaxRate;
-	}
+    public void setCmPromotion(CmPromotion cmPromotion) {
+        this.cmPromotion = cmPromotion;
+    }
+
+    public String getIncludedTax() {
+        return includedTax;
+    }
+
+    public void setIncludedTax(String includedTax) {
+        this.includedTax = includedTax;
+    }
+
+    public String getInvoiceType() {
+        return invoiceType;
+    }
 
-	public String getShouldPayTotalTax() {
-		return shouldPayTotalTax;
-	}
+    public void setInvoiceType(String invoiceType) {
+        this.invoiceType = invoiceType;
+    }
 
-	public void setShouldPayTotalTax(String shouldPayTotalTax) {
-		this.shouldPayTotalTax = shouldPayTotalTax;
-	}
+    public String getSupplierTaxRate() {
+        return supplierTaxRate;
+    }
 
-	public String getSingleShouldPayTotalTax() {
-		return singleShouldPayTotalTax;
-	}
+    public void setSupplierTaxRate(String supplierTaxRate) {
+        this.supplierTaxRate = supplierTaxRate;
+    }
 
-	public void setSingleShouldPayTotalTax(String singleShouldPayTotalTax) {
-		this.singleShouldPayTotalTax = singleShouldPayTotalTax;
-	}
+    public String getShouldPayTotalTax() {
+        return shouldPayTotalTax;
+    }
 
-	public String getOldProductFlag() {
-		return oldProductFlag;
-	}
+    public void setShouldPayTotalTax(String shouldPayTotalTax) {
+        this.shouldPayTotalTax = shouldPayTotalTax;
+    }
+
+    public String getSingleShouldPayTotalTax() {
+        return singleShouldPayTotalTax;
+    }
 
-	public void setOldProductFlag(String oldProductFlag) {
-		this.oldProductFlag = oldProductFlag;
-	}
+    public void setSingleShouldPayTotalTax(String singleShouldPayTotalTax) {
+        this.singleShouldPayTotalTax = singleShouldPayTotalTax;
+    }
+
+    public String getOldProductFlag() {
+        return oldProductFlag;
+    }
+
+    public void setOldProductFlag(String oldProductFlag) {
+        this.oldProductFlag = oldProductFlag;
+    }
+
+    public String getCommodityType() {
+        return commodityType;
+    }
+
+    public void setCommodityType(String commodityType) {
+        this.commodityType = commodityType;
+    }
+
+    public Integer getCouponsLogo() {
+        return couponsLogo;
+    }
+
+    public void setCouponsLogo(Integer couponsLogo) {
+        this.couponsLogo = couponsLogo;
+    }
 }

+ 0 - 23
src/main/java/com/caimei/modules/bulkpurchase/web/CmClubController.java

@@ -57,29 +57,6 @@ public class CmClubController extends BaseController {
 				club.setAddress(newAddress);
 			}
 		}
-       /* List<CmClub> list = page.getList();
-        for (CmClub club : list) {
-            StringBuilder builder =new StringBuilder();
-            String address = club.getAddress();
-            String recAddress = club.getRecAddress();
-            String city = club.getCity();
-            String town = club.getTown();
-            String province = club.getProvince();
-            if (null!=province){
-                builder.append(province);
-            } if (null!=province){
-                builder.append(city);
-            } if (null!=town){
-                builder.append(town);
-            } if (null!=address){
-                builder.append(address);
-            }else{
-                if(null!=recAddress){
-                    builder.append(recAddress);
-                }
-            }
-            club.setAddress(builder.toString());
-         }*/
         model.addAttribute("page", page);
 		return "modules/bulkpurchase/cmClubListBox";
 	}

+ 9 - 0
src/main/java/com/caimei/modules/bulkpurchase/web/CmRefundsProductController.java

@@ -239,6 +239,11 @@ public class CmRefundsProductController extends BaseController {
                     }
                 }
             }
+            //使用优惠券只能全退
+            if (newOrder.getCouponAmount() > 0) {
+                isPromotions = true;
+                returnedPurchaseFee = MathUtil.sub(returnedPurchaseFee, newOrder.getCouponAmount()).doubleValue();
+            }
             returnedPurchaseFee = returnedPurchaseFee - newOrder.getPromotionFullReduction();
             refundFee += getRefundFee(newOrder, returnedPurchaseFee, 1);//运费默认是退的
             cmReturnedPurchase.setRefundFee(refundFee);
@@ -389,6 +394,10 @@ public class CmRefundsProductController extends BaseController {
                     //减去促销满减金额
                     returnedPurchaseFee = returnedPurchaseFee - newOrder.getPromotionFullReduction();
                 }
+                if (newOrder.getCouponAmount() > 0) {
+                    //减去优惠券金额
+                    returnedPurchaseFee = MathUtil.sub(returnedPurchaseFee, newOrder.getCouponAmount()).doubleValue();
+                }
                 refundFee += getRefundFee(newOrder, returnedPurchaseFee, freightNum);
             }
 

+ 20 - 13
src/main/java/com/caimei/modules/bulkpurchase/web/PurchaseProductController.java

@@ -5,10 +5,10 @@ import com.alibaba.fastjson.JSONObject;
 import com.caimei.modules.bulkpurchase.entity.OrderProduct;
 import com.caimei.modules.bulkpurchase.entity.ProductPrivilege;
 import com.caimei.modules.bulkpurchase.entity.PurchaseProduct;
-import com.caimei.modules.bulkpurchase.service.ContractOrderService;
 import com.caimei.modules.bulkpurchase.service.OrderProductService;
 import com.caimei.modules.bulkpurchase.service.PurchaseProductService;
 import com.caimei.modules.cibe.entity.Shop;
+import com.caimei.modules.coupon.service.CmCouponService;
 import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.entity.*;
 import com.caimei.modules.product.service.BuyerProductHistoryPriceService;
@@ -61,8 +61,6 @@ public class PurchaseProductController extends BaseController {
     @Autowired
     private OrderProductService orderProductService;
     @Autowired
-    private ContractOrderService contractOrderService;
-    @Autowired
     private ClubDao clubDao;
     @Autowired
     private ProductDao productDao;
@@ -72,6 +70,8 @@ public class PurchaseProductController extends BaseController {
     private BuyerProductHistoryPriceService buyerProductHistoryPriceService;
     @Autowired
     private CmPromotionService cmPromotionService;
+    @Autowired
+    private CmCouponService cmCouponService;
 
     @ModelAttribute
     public PurchaseProduct get(@RequestParam(required = false) String id) {
@@ -118,7 +118,7 @@ public class PurchaseProductController extends BaseController {
                 //查询该商品的促销活动
                 CmPromotion cmPromotion = cmPromotionService.findProductPromotion(p.getShopId(), p.getProductId());
                 //设置商品的税率
-                if ("2".equals(p.getIncludedTax()) || StringUtils.isEmpty(p.getIncludedTax()) || ("0".equals(p.getIncludedTax()) && "3".equals(p.getInvoiceType())) ) {
+                if ("2".equals(p.getIncludedTax()) || StringUtils.isEmpty(p.getIncludedTax()) || ("0".equals(p.getIncludedTax()) && "3".equals(p.getInvoiceType()))) {
                     p.setTaxRate("0");
                     p.setSupplierTaxRate("0");
                 }
@@ -133,10 +133,10 @@ public class PurchaseProductController extends BaseController {
                     p.setCmPromotion(cmPromotion);
                     p.setLadderPriceFlag(0);
                 } else {
-                    if (p.getLadderPriceFlag().equals(1)){
+                    if (p.getLadderPriceFlag().equals(1)) {
                         // 查询阶梯价格
                         List<ProductLadderPrice> ladderPriceList = purchaseProductService.findLadderPriceList(p.getProductId());
-                        if (null != ladderPriceList && ladderPriceList.size()>0) {
+                        if (null != ladderPriceList && ladderPriceList.size() > 0) {
                             p.setPrice(ladderPriceList.get(0).getBuyPrice().toString());
                             p.setNum(ladderPriceList.get(0).getBuyNum().toString());
                             IntStream.range(0, ladderPriceList.size()).forEach(i -> {
@@ -166,7 +166,7 @@ public class PurchaseProductController extends BaseController {
                                     discountPrice = lastBuyPrice.getCurrentPrice();
                                     p.setDiscountPrice(discountPrice);
                                     // 计算折扣(折扣=折后单价/单价)[取值1-100]---四舍五入保留6位百分比小数,例如12.341234%
-                                    BigDecimal discount = MathUtil.round((MathUtil.mul((MathUtil.div(discountPrice, p.getPrice(),8)), 100)), 6);
+                                    BigDecimal discount = MathUtil.round((MathUtil.mul((MathUtil.div(discountPrice, p.getPrice(), 8)), 100)), 6);
                                     p.setDiscount(String.valueOf(discount));
                                 }
                             }
@@ -174,6 +174,15 @@ public class PurchaseProductController extends BaseController {
                     }
                 }
             }
+            if (p != null) {
+                //是否有优惠券可以查看
+                Boolean couponsLogo = cmCouponService.setCouponsLogo(userId, p.getProductId().intValue(), Integer.valueOf(p.getShopId()), p.getCommodityType());
+                if (couponsLogo) {
+                    p.setCouponsLogo(2);
+                } else {
+                    p.setCouponsLogo(1);
+                }
+            }
         }
         model.addAttribute("page", page);
         if (StringUtils.equals(purchaseProduct.getFlag(), "1")) {
@@ -299,8 +308,6 @@ public class PurchaseProductController extends BaseController {
 
     @RequestMapping(value = "formOrderProduct")
     public String formOrderProduct(PurchaseProduct purchaseProduct, Model model) {
-//		JSONObject object = JSONObject.parseObject(product);
-//		PurchaseProduct purchaseProduct = JSONObject.toJavaObject(object, PurchaseProduct.class);
         if (purchaseProduct != null) {
             purchaseProduct.setLadderPriceFlag(0);
             Product product = productDao.get(purchaseProduct.getProductId().toString());
@@ -309,11 +316,11 @@ public class PurchaseProductController extends BaseController {
                 if (productPromotion != null) {
                     purchaseProduct.setCmPromotion(productPromotion);
                 } else {
-                    if ("1".equals(product.getLadderPriceFlag())){
+                    if ("1".equals(product.getLadderPriceFlag())) {
                         purchaseProduct.setLadderPriceFlag(1);
                         // 查询阶梯价格
                         List<ProductLadderPrice> ladderPriceList = purchaseProductService.findLadderPriceList(purchaseProduct.getProductId());
-                        if (null != ladderPriceList && ladderPriceList.size()>0) {
+                        if (null != ladderPriceList && ladderPriceList.size() > 0) {
                             purchaseProduct.setPrice(ladderPriceList.get(0).getBuyPrice().toString());
                             purchaseProduct.setNum(ladderPriceList.get(0).getBuyNum().toString());
                             IntStream.range(0, ladderPriceList.size()).forEach(i -> {
@@ -479,7 +486,7 @@ public class PurchaseProductController extends BaseController {
 
     @RequiresPermissions("orderproduct:orderProduct:edit")
     @RequestMapping(value = "promotionDetail")
-    public String formShopFee(@RequestParam("promotionId") String promotionId,Model model) {
+    public String formShopFee(@RequestParam("promotionId") String promotionId, Model model) {
         CmPromotion cmPromotion = cmPromotionService.get(promotionId);
         List<Product> promotionProducts = new ArrayList<>();
         List<Product> giftProducts = new ArrayList<>();
@@ -497,7 +504,7 @@ public class PurchaseProductController extends BaseController {
             cmPromotion.setGiftProducts(giftProducts);
             cmPromotion.setPromotionShops(promotionShops);
         }
-        model.addAttribute("cmPromotion",cmPromotion);
+        model.addAttribute("cmPromotion", cmPromotion);
         return "modules/bulkpurchase/productPromotionDetail";
     }
 }

+ 48 - 8
src/main/java/com/caimei/modules/coupon/dao/CmCouponClubDao.java

@@ -1,23 +1,63 @@
 package com.caimei.modules.coupon.dao;
 
-import com.caimei.modules.user.entity.NewCmClub;
+import com.caimei.modules.coupon.entity.CmCoupon;
+import com.caimei.modules.coupon.entity.CmCouponClub;
+import com.caimei.modules.coupon.entity.CmCouponRedemptionCode;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
-import com.caimei.modules.coupon.entity.CmCouponClub;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 /**
- * 采美优惠券活动签约会所DAO接口
- * @author lwt
- * @version 2018-09-29
+ * 优惠券管理DAO接口
+ *
+ * @author plf
+ * @version 2021-08-10
  */
 @MyBatisDao
 public interface CmCouponClubDao extends CrudDao<CmCouponClub> {
 
-    void deleteCmCouponClub(CmCouponClub cmCouponClub);
+    List<CmCouponClub> receivingUserList(CmCouponClub cmCouponClub);
+
+    List<CmCouponClub> findClubCoupon(CmCouponClub couponClub);
+
+    /**
+     * 查询兑换码是否有效
+     *
+     * @param redemptionCode 兑换码
+     * @return
+     */
+    CmCouponRedemptionCode findCouponRedemptionCode(String redemptionCode);
+
+    /**
+     * 查询优惠券信息
+     *
+     * @param couponId 优惠券id
+     * @return
+     */
+    CmCoupon getCoupons(Integer couponId);
+
+    /**
+     * 更新兑换码使用状态
+     *
+     * @param id           兑换码id
+     * @param clubCouponId 用户关联优惠券id
+     */
+    void updateRedemptionCode(@Param("id") String id, @Param("clubCouponId") String clubCouponId);
 
-    List<Integer> getAllClubID();
+    /**
+     * 逻辑删除订单退回
+     *
+     * @param returnedId
+     */
+    void deleteByReturnedId(int returnedId);
 
-    List<NewCmClub> getClubList(NewCmClub cmClub);
+    /**
+     * 查询一张未使用兑换码券
+     *
+     * @param couponId
+     * @return
+     */
+    CmCouponRedemptionCode findRedemptionCode(int couponId);
 }

+ 71 - 9
src/main/java/com/caimei/modules/coupon/dao/CmCouponDao.java

@@ -1,27 +1,89 @@
 package com.caimei.modules.coupon.dao;
 
+import com.caimei.modules.coupon.entity.CmCoupon;
+import com.caimei.modules.coupon.entity.CmCouponAssociate;
+import com.caimei.modules.coupon.entity.CmCouponClub;
+import com.caimei.modules.coupon.entity.CmCouponRedemptionCode;
+import com.caimei.modules.user.entity.CmUser;
+import com.caimei.modules.user.entity.NewCmShop;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
-import com.caimei.modules.coupon.entity.CmCoupon;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 /**
- * 采美优惠券表(优惠券基本信息来自华熙提供)DAO接口
- * @author lwt
- * @version 2018-09-30
+ * 优惠券管理DAO接口
+ *
+ * @author plf
+ * @version 2021-08-02
  */
 @MyBatisDao
 public interface CmCouponDao extends CrudDao<CmCoupon> {
 
-    List<CmCoupon> statisticsCoupon();
+    List<CmCouponAssociate> findByProductType(String couponId);
+
+    void insertCouponAssociate(CmCouponAssociate associate);
+
+    List<Integer> findByCouponId(String couponId);
+
+    void updateCouponAssociate(CmCouponAssociate a);
+
+    void logicDeleteCouponAssociate(Integer id);
+
+    void updateByDelFlag(String couponId);
+
+    void updateAssociateByDelFlag(String couponId);
+
+    CmCouponClub findCouponClub(String couponId);
+
+    List<CmUser> findUserList(CmUser cmUser);
+
+    List<NewCmShop> findShopList(NewCmShop newCmShop);
+
+    Integer findRedemptionCodeNum(String couponId);
+
+    CmCouponRedemptionCode findByRedemptionCode(String redemptionCode);
+
+    void insertRedemptionCode(CmCouponRedemptionCode code);
+
+    List<CmCouponRedemptionCode> findRedemptionCode(CmCouponRedemptionCode redemptionCode);
+
+    /**
+     * 查询已兑换数量
+     *
+     * @param couponId
+     * @return
+     */
+    Integer findQuantityRedeemed(String couponId);
 
-    List<CmCoupon> findByCouponCode(@Param("couponCode") String couponCode);
+    /**
+     * 查询机构下所有优惠券
+     *
+     * @param userId
+     * @return
+     */
+    List<CmCoupon> findClubCouponList(Integer userId);
 
-    List<CmCoupon> getSendCoupon (CmCoupon cmCoupon);
+    /**
+     * 查询活动券-指定商品
+     *
+     * @param couponId
+     * @return
+     */
+    List<Integer> findAllProductId(String couponId);
 
-    List<CmCoupon> findCouponList(CmCoupon cmCoupon);
+    /**
+     * 查询所有未兑换且有效的优惠券
+     *
+     * @return
+     */
+    List<CmCoupon> findNotRedeemedCoupon();
 
-    void updateStatus(CmCoupon cmCoupon);
+    /**
+     * 修改优惠券使用状态
+     *
+     * @param clubCouponId
+     */
+    void updateClubCoupon(@Param("clubCouponId") Integer clubCouponId, @Param("orderId") Integer orderId);
 }

+ 0 - 18
src/main/java/com/caimei/modules/coupon/dao/CmCouponOrderRecordDao.java

@@ -1,18 +0,0 @@
-package com.caimei.modules.coupon.dao;
-
-import com.thinkgem.jeesite.common.persistence.CrudDao;
-import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
-import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * 采美优惠券订单DAO接口
- * @author Lijun
- * @version 2018-10-10
- */
-@MyBatisDao
-public interface CmCouponOrderRecordDao extends CrudDao<CmCouponOrderRecord> {
-    List<CmCouponOrderRecord> findListBuyAgain(@Param("customerMobile") String customerMobile);
-}

+ 0 - 15
src/main/java/com/caimei/modules/coupon/dao/CmCouponRecordDao.java

@@ -1,15 +0,0 @@
-package com.caimei.modules.coupon.dao;
-
-import com.thinkgem.jeesite.common.persistence.CrudDao;
-import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
-import com.caimei.modules.coupon.entity.CmCouponRecord;
-
-/**
- * 采美优惠券使用记录表DAO接口
- * @author lwt
- * @version 2018-09-29
- */
-@MyBatisDao
-public interface CmCouponRecordDao extends CrudDao<CmCouponRecord> {
-
-}

+ 0 - 19
src/main/java/com/caimei/modules/coupon/dao/CmCouponRecordScanDao.java

@@ -1,19 +0,0 @@
-package com.caimei.modules.coupon.dao;
-
-import com.thinkgem.jeesite.common.persistence.CrudDao;
-import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
-import com.caimei.modules.coupon.entity.CmCouponRecordScan;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * 扫码推送优惠券DAO接口
- * @author LiJun
- * @version 2018-11-22
- */
-@MyBatisDao
-public interface CmCouponRecordScanDao extends CrudDao<CmCouponRecordScan> {
-    void updateEnabledStatus(@Param("enabledStatus") String enabledStatus);
-
-    CmCouponRecordScan getEnabledStatus();
-
-}

+ 278 - 197
src/main/java/com/caimei/modules/coupon/entity/CmCoupon.java

@@ -1,207 +1,288 @@
 package com.caimei.modules.coupon.entity;
 
+import com.caimei.modules.user.entity.NewCmShop;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.thinkgem.jeesite.common.persistence.DataEntity;
 import org.hibernate.validator.constraints.Length;
 
-import java.beans.Transient;
+import java.math.BigDecimal;
 import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import com.thinkgem.jeesite.common.persistence.DataEntity;
+import java.util.List;
 
 /**
- * 采美优惠券表(优惠券基本信息来自华熙提供)Entity
- * @author lwt
- * @version 2018-09-30
+ * 优惠券管理Entity
+ *
+ * @author plf
+ * @version 2021-08-02
  */
 public class CmCoupon extends DataEntity<CmCoupon> {
-	
-	private static final long serialVersionUID = 1L;
-	private String couponCode;		// 优惠券码
-	private String couponAmount;		// 优惠券金额(面值)
-	private String discount;		//优惠券折扣率
-	private Date useStartDate;		// 使用开始时间(有效期)
-	private Date useEndDate;		// 使用结束时间(有效期)
-	private String status;		// 0未派发(可分发给会所) 1已发放 2已分享 3已使用
-	private String couponType;		// 劵类型 0满减劵 1折扣劵
-	private String threshold;		// 使用门槛(满多少使用等)
-	private String useDescription;		// 使用说明(通用还是指定商品可用)
-	private String couponlimit;//优惠券限制(每个用户限制兑换次数)
-
-	//  --------   虚拟字段   -----------------
-	private Integer lastAmount;                  //剩余数量
-	private Integer shareAmount;                  //已分享数量
-	private Integer usedAmount;                  //已使用数量
-	private Integer timeOutAmount;                  //已过期数量
-	private Integer laveNum;                  //统计分类剩余数量
-	private Integer unReceiveNum;				//未领取数量(目前仅适用于公众号扫码输入手机号码领取)
-	private Integer num;//优惠卷数量
-	private Integer userID;//用户ID
-
-	public String getCouponlimit() {
-		return couponlimit;
-	}
-
-	public void setCouponlimit(String couponlimit) {
-		this.couponlimit = couponlimit;
-	}
-
-	public Integer getUserID() {
-		return userID;
-	}
-
-	public void setUserID(Integer userID) {
-		this.userID = userID;
-	}
-
-	public Integer getUnReceiveNum() {
-		return unReceiveNum;
-	}
-
-	public void setUnReceiveNum(Integer unReceiveNum) {
-		this.unReceiveNum = unReceiveNum;
-	}
-
-	public CmCoupon() {
-		super();
-	}
-
-	public CmCoupon(String id){
-		super(id);
-	}
-
-	public Integer getLaveNum() {
-		return laveNum;
-	}
-
-	public void setLaveNum(Integer laveNum) {
-		this.laveNum = laveNum;
-	}
-
-	@Length(min=0, max=64, message="优惠券码长度必须介于 0 和 64 之间")
-	public String getCouponCode() {
-		return couponCode;
-	}
-
-	public void setCouponCode(String couponCode) {
-		this.couponCode = couponCode;
-	}
-	
-	public String getCouponAmount() {
-		return couponAmount;
-	}
-
-	public void setCouponAmount(String couponAmount) {
-		this.couponAmount = couponAmount;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getUseStartDate() {
-		return useStartDate;
-	}
-
-	public void setUseStartDate(Date useStartDate) {
-		this.useStartDate = useStartDate;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getUseEndDate() {
-		return useEndDate;
-	}
-
-	public void setUseEndDate(Date useEndDate) {
-		this.useEndDate = useEndDate;
-	}
-	
-	@Length(min=0, max=10, message="状态 0未派发(可分发给会所) 1已发放未领取 2已领取 3已使用长度必须介于 0 和 10 之间")
-	public String getStatus() {
-		return status;
-	}
-
-	public void setStatus(String status) {
-		this.status = status;
-	}
-	
-	@Length(min=0, max=11, message="劵类型 0满减劵 1折扣劵长度必须介于 0 和 11 之间")
-	public String getCouponType() {
-		return couponType;
-	}
-
-	public void setCouponType(String couponType) {
-		this.couponType = couponType;
-	}
-	
-	@Length(min=0, max=255, message="使用门槛(满多少使用等)长度必须介于 0 和 255 之间")
-	public String getThreshold() {
-		return threshold;
-	}
-
-	public void setThreshold(String threshold) {
-		this.threshold = threshold;
-	}
-	
-	@Length(min=0, max=255, message="使用说明(通用还是指定商品可用)长度必须介于 0 和 255 之间")
-	public String getUseDescription() {
-		return useDescription;
-	}
-
-	public void setUseDescription(String useDescription) {
-		this.useDescription = useDescription;
-	}
-
-
-	public static long getSerialVersionUID() {
-		return serialVersionUID;
-	}
-
-	@Transient
-	public Integer getLastAmount() {
-		return lastAmount;
-	}
-
-	public void setLastAmount(Integer lastAmount) {
-		this.lastAmount = lastAmount;
-	}
-
-	@Transient
-	public Integer getShareAmount() {
-		return shareAmount;
-	}
-
-	public void setShareAmount(Integer shareAmount) {
-		this.shareAmount = shareAmount;
-	}
-
-	@Transient
-	public Integer getUsedAmount() {
-		return usedAmount;
-	}
-
-	public void setUsedAmount(Integer usedAmount) {
-		this.usedAmount = usedAmount;
-	}
-	@Transient
-	public Integer getTimeOutAmount() {
-		return timeOutAmount;
-	}
-
-	public void setTimeOutAmount(Integer timeOutAmount) {
-		this.timeOutAmount = timeOutAmount;
-	}
-
-	@Transient
-	public Integer getNum() {
-		return num;
-	}
-
-	public void setNum(Integer num) {
-		this.num = num;
-	}
-
-	public String getDiscount() {
-		return discount;
-	}
-
-	public void setDiscount(String discount) {
-		this.discount = discount;
-	}
+
+    private static final long serialVersionUID = 1L;
+    private String name;        // 活动主题
+    private BigDecimal couponAmount;        // 优惠券金额(面值)
+    private BigDecimal touchPrice;        // 优惠满减条件金额
+    private Date startDate;        // 使用开始时间(有效期)
+    private Date endDate;        // 使用结束时间(有效期)
+    private String status;        // 状态 0未生效 1已生效 2已关闭 3已失效
+    private Integer couponType;        // 劵类型 0活动券 1品类券 2用户专享券 3店铺券 4新用户券
+    private Integer userId;     //机构用户id(用户专享券有效)
+    private Integer shopId;     //供应商id(店铺券有效)
+    private String productType;        // 优惠商品:1全商城商品 2指定商品(活动券有效)
+    private String pcBanner;        //网站活动页banner
+    private String appletsBanner;       //小程序活动页banner
+    private String categoryType;        // 优惠品类:1产品 2仪器(品类券有效)
+    private String couponsMode;        // 领券方式:0正常 1使用兑换码
+    private String productInfo;        //商品json数据
+    private String clubName;           //机构名称
+    private String claimStatus;         //领取状态:1未领取 2已领取
+    private String useStatus;       //使用状态 1未使用 2已使用
+    private String source;      //领取渠道:1小程序 2网站 3订单退回
+    private String shopName;        //供应商名称
+    private Integer codeNum;       //兑换码数量
+    private Integer clubCouponId;      //机构领券id
+    private String couponName;          //优惠券名称
+    private String couponDesc;        //描述
+    private String redemptionCode;      //兑换码
+    private CmCouponClub couponClub;
+    private NewCmShop shop;
+    private List<Integer> productIdList;
+
+    public CmCoupon() {
+        super();
+    }
+
+    public CmCoupon(String id) {
+        super(id);
+    }
+
+    @Length(min = 0, max = 50, message = "活动主题长度必须介于 0 和 50 之间")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    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;
+    }
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    public Date getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
+    }
+
+    @Length(min = 0, max = 2, message = "状态 0未生效 1已生效 2已关闭长度必须介于 0 和 2 之间")
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public Integer getCouponType() {
+        return couponType;
+    }
+
+    public void setCouponType(Integer couponType) {
+        this.couponType = couponType;
+    }
+
+    @Length(min = 0, max = 2, message = "优惠商品:1全商城商品 2指定商品(活动券有效)长度必须介于 0 和 2 之间")
+    public String getProductType() {
+        return productType;
+    }
+
+    public void setProductType(String productType) {
+        this.productType = productType;
+    }
+
+    public String getPcBanner() {
+        return pcBanner;
+    }
+
+    public void setPcBanner(String pcBanner) {
+        this.pcBanner = pcBanner;
+    }
+
+    public String getAppletsBanner() {
+        return appletsBanner;
+    }
+
+    public void setAppletsBanner(String appletsBanner) {
+        this.appletsBanner = appletsBanner;
+    }
+
+    @Length(min = 0, max = 2, message = "优惠品类:1产品 2仪器(品类券有效)长度必须介于 0 和 2 之间")
+    public String getCategoryType() {
+        return categoryType;
+    }
+
+    public void setCategoryType(String categoryType) {
+        this.categoryType = categoryType;
+    }
+
+    @Length(min = 0, max = 2, message = "领券方式:0正常 1使用兑换码长度必须介于 0 和 2 之间")
+    public String getCouponsMode() {
+        return couponsMode;
+    }
+
+    public void setCouponsMode(String couponsMode) {
+        this.couponsMode = couponsMode;
+    }
+
+    public String getProductInfo() {
+        return productInfo;
+    }
+
+    public void setProductInfo(String productInfo) {
+        this.productInfo = productInfo;
+    }
+
+    public String getClubName() {
+        return clubName;
+    }
+
+    public void setClubName(String clubName) {
+        this.clubName = clubName;
+    }
+
+    public String getClaimStatus() {
+        return claimStatus;
+    }
+
+    public void setClaimStatus(String claimStatus) {
+        this.claimStatus = claimStatus;
+    }
+
+    public String getUseStatus() {
+        return useStatus;
+    }
+
+    public void setUseStatus(String useStatus) {
+        this.useStatus = useStatus;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public CmCouponClub getCouponClub() {
+        return couponClub;
+    }
+
+    public void setCouponClub(CmCouponClub couponClub) {
+        this.couponClub = couponClub;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
+
+    public Integer getCodeNum() {
+        return codeNum;
+    }
+
+    public void setCodeNum(Integer codeNum) {
+        this.codeNum = codeNum;
+    }
+
+    public Integer getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(Integer shopId) {
+        this.shopId = shopId;
+    }
+
+    public NewCmShop getShop() {
+        return shop;
+    }
+
+    public void setShop(NewCmShop shop) {
+        this.shop = shop;
+    }
+
+    public Integer getClubCouponId() {
+        return clubCouponId;
+    }
+
+    public void setClubCouponId(Integer clubCouponId) {
+        this.clubCouponId = clubCouponId;
+    }
+
+    public List<Integer> getProductIdList() {
+        return productIdList;
+    }
+
+    public void setProductIdList(List<Integer> productIdList) {
+        this.productIdList = productIdList;
+    }
+
+    public String getCouponName() {
+        return couponName;
+    }
+
+    public void setCouponName(String couponName) {
+        this.couponName = couponName;
+    }
+
+    public String getCouponDesc() {
+        return couponDesc;
+    }
+
+    public void setCouponDesc(String couponDesc) {
+        this.couponDesc = couponDesc;
+    }
+
+    public String getRedemptionCode() {
+        return redemptionCode;
+    }
+
+    public void setRedemptionCode(String redemptionCode) {
+        this.redemptionCode = redemptionCode;
+    }
 }

+ 121 - 0
src/main/java/com/caimei/modules/coupon/entity/CmCouponAssociate.java

@@ -0,0 +1,121 @@
+package com.caimei.modules.coupon.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/8/4
+ */
+public class CmCouponAssociate implements Serializable {
+    private Integer id;
+    private Integer couponId;       //优惠券id
+    private Integer productId;      //商品id(对应活动券)
+    private String pcStatus;        //pc状态 0停用 1启用
+    private String appletsStatus;       //小程序状态 0停用 1启用
+    private Integer shopId;     //供应商id(对应店铺券)
+    private Integer sort;       //排序值
+    private Date addTime;       //添加时间
+    private String delFlag;     //删除标记 0否 其余是
+    private String productName;     //商品名称
+    private String image;       //商品图片
+    private String shopName;        //供应商名称
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getCouponId() {
+        return couponId;
+    }
+
+    public void setCouponId(Integer couponId) {
+        this.couponId = couponId;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public String getPcStatus() {
+        return pcStatus;
+    }
+
+    public void setPcStatus(String pcStatus) {
+        this.pcStatus = pcStatus;
+    }
+
+    public String getAppletsStatus() {
+        return appletsStatus;
+    }
+
+    public void setAppletsStatus(String appletsStatus) {
+        this.appletsStatus = appletsStatus;
+    }
+
+    public Integer getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(Integer shopId) {
+        this.shopId = shopId;
+    }
+
+    public Integer getSort() {
+        return sort;
+    }
+
+    public void setSort(Integer sort) {
+        this.sort = sort;
+    }
+
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    public String getDelFlag() {
+        return delFlag;
+    }
+
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
+}

+ 165 - 112
src/main/java/com/caimei/modules/coupon/entity/CmCouponClub.java

@@ -1,121 +1,174 @@
 package com.caimei.modules.coupon.entity;
 
-import org.hibernate.validator.constraints.Length;
-import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
-
 import com.thinkgem.jeesite.common.persistence.DataEntity;
+import org.hibernate.validator.constraints.Length;
+
+import java.math.BigDecimal;
+import java.util.Date;
 
 /**
- * 采美优惠券活动签约会所Entity
- * @author lwt
- * @version 2018-09-29
+ * 优惠券管理Entity
+ *
+ * @author plf
+ * @version 2021-08-10
  */
 public class CmCouponClub extends DataEntity<CmCouponClub> {
-	
-	private static final long serialVersionUID = 1L;
-	private Long clubId;		// 会所ID
-	private Integer userID;		//用户ID
-	private String name;		// 会所名称
-	private String sname;		// 会所简称
-	private String linkMan;		// 联系人
-	private String contractMobile;		// 联系手机
-	private Date signDate;		// 签约时间
-	private String status;		// 签约状态 1已签约 2未签约
-	private String startTime;     //注册时间开始 查询条件
-	private String endTime;		//注册时间结束  查询条件
-	
-	public CmCouponClub() {
-		super();
-	}
-
-	public CmCouponClub(String id){
-		super(id);
-	}
-
-	public Integer getUserID() {
-		return userID;
-	}
-
-	public void setUserID(Integer userID) {
-		this.userID = userID;
-	}
-
-	public Long getClubId() {
-		return clubId;
-	}
-
-	public void setClubId(Long clubId) {
-		this.clubId = clubId;
-	}
-	
-	@Length(min=0, max=20, message="会所名称长度必须介于 0 和 20 之间")
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-	
-	@Length(min=0, max=20, message="会所简称长度必须介于 0 和 20 之间")
-	public String getSname() {
-		return sname;
-	}
-
-	public void setSname(String sname) {
-		this.sname = sname;
-	}
-	
-	@Length(min=0, max=50, message="联系人长度必须介于 0 和 50 之间")
-	public String getLinkMan() {
-		return linkMan;
-	}
-
-	public void setLinkMan(String linkMan) {
-		this.linkMan = linkMan;
-	}
-	
-	@Length(min=0, max=20, message="联系手机长度必须介于 0 和 20 之间")
-	public String getContractMobile() {
-		return contractMobile;
-	}
-
-	public void setContractMobile(String contractMobile) {
-		this.contractMobile = contractMobile;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getSignDate() {
-		return signDate;
-	}
-
-	public void setSignDate(Date signDate) {
-		this.signDate = signDate;
-	}
-	
-	@Length(min=0, max=10, message="签约状态 1已签约 2未签约长度必须介于 0 和 10 之间")
-	public String getStatus() {
-		return status;
-	}
-
-	public void setStatus(String status) {
-		this.status = status;
-	}
-
-	public String getStartTime() {
-		return startTime;
-	}
-
-	public void setStartTime(String startTime) {
-		this.startTime = startTime;
-	}
-
-	public String getEndTime() {
-		return endTime;
-	}
-
-	public void setEndTime(String endTime) {
-		this.endTime = endTime;
-	}
+
+    private static final long serialVersionUID = 1L;
+    private Integer userId;        // 机构用户Id
+    private Integer couponId;        // 优惠券id
+    private Integer orderId;        // 订单id
+    private Integer returnedId;     //退款id,订单退回时有效
+    private String source;        // 领取渠道:1小程序 2网站 3订单退回
+    private String status;        // 使用状态 1未使用 2已使用
+    private Date useDate;        // 使用时间
+    private String clubName;    //机构名称
+    private Integer couponType;        // 劵类型 0活动券 1品类券 2用户专享券 3店铺券 4新用户券
+    private Integer num;        //可用券的数量
+    private BigDecimal couponAmount;        // 优惠券金额(面值)
+    private BigDecimal touchPrice;        // 优惠满减条件金额
+    private String couponStatus;    // 状态 0未生效 1已生效 2已关闭 3已失效
+    private Date startDate;        // 使用开始时间(有效期)
+    private Date endDate;        // 使用结束时间(有效期)
+    private String orderNo;     //订单编号
+
+    public CmCouponClub() {
+        super();
+    }
+
+    public CmCouponClub(String id) {
+        super(id);
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Integer getCouponId() {
+        return couponId;
+    }
+
+    public void setCouponId(Integer couponId) {
+        this.couponId = couponId;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getReturnedId() {
+        return returnedId;
+    }
+
+    public void setReturnedId(Integer returnedId) {
+        this.returnedId = returnedId;
+    }
+
+    @Length(min = 0, max = 1, message = "领取渠道:1小程序 2网站 3订单退回长度必须介于 0 和 1 之间")
+    public String getSource() {
+        return source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    @Length(min = 0, max = 10, message = "使用状态 1未使用 2已使用长度必须介于 0 和 10 之间")
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    public Date getUseDate() {
+        return useDate;
+    }
+
+    public void setUseDate(Date useDate) {
+        this.useDate = useDate;
+    }
+
+    public String getClubName() {
+        return clubName;
+    }
+
+    public void setClubName(String clubName) {
+        this.clubName = clubName;
+    }
+
+    public Integer getCouponType() {
+        return couponType;
+    }
+
+    public void setCouponType(Integer couponType) {
+        this.couponType = couponType;
+    }
+
+    public Integer getNum() {
+        return num;
+    }
+
+    public void setNum(Integer num) {
+        this.num = num;
+    }
+
+    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 String getCouponStatus() {
+        return couponStatus;
+    }
+
+    public void setCouponStatus(String couponStatus) {
+        this.couponStatus = couponStatus;
+    }
+
+    public Date getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
+    }
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
 }

+ 95 - 221
src/main/java/com/caimei/modules/coupon/entity/CmCouponOrderRecord.java

@@ -1,227 +1,101 @@
 package com.caimei.modules.coupon.entity;
 
-import org.hibernate.validator.constraints.Length;
+import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.Date;
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import com.thinkgem.jeesite.common.persistence.DataEntity;
 
 /**
- * 采美优惠券订单Entity
- * @author Lijun
- * @version 2018-10-10
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/8/20
  */
-public class CmCouponOrderRecord extends DataEntity<CmCouponOrderRecord> {
-	
-	private static final long serialVersionUID = 1L;
-	private String orderCode;		// 订单编号
-	private Double totalAmount;		// 订单金额(实付金额)
-	private Double refundAmount;		// 退款金额
-	private Date paymentTime;		// 订单支付时间
-	private Date refundTime;		// 订单退款时间
-	private String couponCode;		// 优惠券码
-	private Double discountAmount;		// 优惠金额
-	private String status;		// 订单状态 1等待付款、2付款成功、3已发货、4已收货、5退款中、6退款成功、7交易完成、8交易关闭--华熙提供的只有6和2
-	private String customerCode;//客户code
-	private String customerName;		// 客户名称
-	private String customerMobile;		// 客户手机号
-	private String refundFlag;		// 是否退款单:0正常单NO、1退款单YES
-	private Date createTime;		// 创建时间
-	private Date updateTime;		// 更新时间
-
-	private String clubName;//会所名字
-	private String companyName;//企业名字
-	private String couponMobile;//领劵人手机号(适用于扫码领优惠券)
-	private String rebateName;//返利人名字,谁分享的就是谁的名字
-	private String startTime;     //时间开始 查询条件
-	private String endTime;		//时间结束  查询条件
-	private String searchflag;//0搜索,1导出
-
-
-	public String getCompanyName() {
-		return companyName;
-	}
-
-	public void setCompanyName(String companyName) {
-		this.companyName = companyName;
-	}
-
-	public String getRebateName() {
-		return rebateName;
-	}
-
-	public void setRebateName(String rebateName) {
-		this.rebateName = rebateName;
-	}
-
-	public String getCouponMobile() {
-		return couponMobile;
-	}
-
-	public void setCouponMobile(String couponMobile) {
-		this.couponMobile = couponMobile;
-	}
-
-	public String getSearchflag() {
-		return searchflag;
-	}
-
-	public void setSearchflag(String searchflag) {
-		this.searchflag = searchflag;
-	}
-
-	public String getStartTime() {
-		return startTime;
-	}
-
-	public void setStartTime(String startTime) {
-		this.startTime = startTime;
-	}
-
-	public String getEndTime() {
-		return endTime;
-	}
-
-	public void setEndTime(String endTime) {
-		this.endTime = endTime;
-	}
-
-	public String getClubName() {
-		return clubName;
-	}
-
-	public void setClubName(String clubName) {
-		this.clubName = clubName;
-	}
-
-	public CmCouponOrderRecord() {
-		super();
-	}
-
-	public CmCouponOrderRecord(String id){
-		super(id);
-	}
-
-	public String getCustomerCode() {
-		return customerCode;
-	}
-
-	public void setCustomerCode(String customerCode) {
-		this.customerCode = customerCode;
-	}
-
-	@Length(min=0, max=64, message="订单编号长度必须介于 0 和 64 之间")
-	public String getOrderCode() {
-		return orderCode;
-	}
-
-	public void setOrderCode(String orderCode) {
-		this.orderCode = orderCode;
-	}
-	
-	public Double getTotalAmount() {
-		return totalAmount;
-	}
-
-	public void setTotalAmount(Double totalAmount) {
-		this.totalAmount = totalAmount;
-	}
-	
-	public Double getRefundAmount() {
-		return refundAmount;
-	}
-
-	public void setRefundAmount(Double refundAmount) {
-		this.refundAmount = refundAmount;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getPaymentTime() {
-		return paymentTime;
-	}
-
-	public void setPaymentTime(Date paymentTime) {
-		this.paymentTime = paymentTime;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getRefundTime() {
-		return refundTime;
-	}
-
-	public void setRefundTime(Date refundTime) {
-		this.refundTime = refundTime;
-	}
-	
-	@Length(min=0, max=64, message="优惠券码长度必须介于 0 和 64 之间")
-	public String getCouponCode() {
-		return couponCode;
-	}
-
-	public void setCouponCode(String couponCode) {
-		this.couponCode = couponCode;
-	}
-	
-	public Double getDiscountAmount() {
-		return discountAmount;
-	}
-
-	public void setDiscountAmount(Double discountAmount) {
-		this.discountAmount = discountAmount;
-	}
-	
-	@Length(min=0, max=10, message="订单状态 1等待付款、2付款成功、3已发货、4已收货、5退款中、6退款成功、7交易完成、8交易关闭长度必须介于 0 和 10 之间")
-	public String getStatus() {
-		return status;
-	}
-
-	public void setStatus(String status) {
-		this.status = status;
-	}
-	
-	@Length(min=0, max=50, message="客户名称长度必须介于 0 和 50 之间")
-	public String getCustomerName() {
-		return customerName;
-	}
-
-	public void setCustomerName(String customerName) {
-		this.customerName = customerName;
-	}
-	
-	@Length(min=0, max=20, message="客户手机号长度必须介于 0 和 20 之间")
-	public String getCustomerMobile() {
-		return customerMobile;
-	}
-
-	public void setCustomerMobile(String customerMobile) {
-		this.customerMobile = customerMobile;
-	}
-	
-	@Length(min=0, max=255, message="是否退款单:0正常单NO、1退款单YES长度必须介于 0 和 255 之间")
-	public String getRefundFlag() {
-		return refundFlag;
-	}
-
-	public void setRefundFlag(String refundFlag) {
-		this.refundFlag = refundFlag;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getCreateTime() {
-		return createTime;
-	}
-
-	public void setCreateTime(Date createTime) {
-		this.createTime = createTime;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getUpdateTime() {
-		return updateTime;
-	}
-
-	public void setUpdateTime(Date updateTime) {
-		this.updateTime = updateTime;
-	}
-	
-}
+public class CmCouponOrderRecord implements Serializable {
+    private Integer id;
+
+    /**
+     * 订单id
+     */
+    private Integer orderId;
+
+    /**
+     * 用户领券id(对应cm_coupon_club)
+     */
+    private Integer clubCouponId;
+
+    /**
+     * 劵类型 0活动券 1品类券 2用户专享券 3店铺券 4新用户券
+     */
+    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 getClubCouponId() {
+        return clubCouponId;
+    }
+
+    public void setClubCouponId(Integer clubCouponId) {
+        this.clubCouponId = clubCouponId;
+    }
+
+    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;
+    }
+}

+ 0 - 199
src/main/java/com/caimei/modules/coupon/entity/CmCouponRecord.java

@@ -1,199 +0,0 @@
-package com.caimei.modules.coupon.entity;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.thinkgem.jeesite.common.persistence.DataEntity;
-import org.hibernate.validator.constraints.Length;
-import java.util.Date;
-
-/**
- * 采美优惠券使用记录表Entity
- * @author lwt
- * @version 2018-09-29
- */
-public class CmCouponRecord extends DataEntity<CmCouponRecord> {
-	
-	private static final long serialVersionUID = 1L;
-	private String couponCode;		// 优惠券码
-	private String couponAmount;		// 优惠券金额
-	private Date useStartDate;		// 使用开始时间(有效期)
-	private Date useEndDate;		// 使用结束时间(有效期)
-	private String status;		// 状态 1已发放 2已分享 3已使用 【第一版扫码获劵的2是已领取】
-	private String couponType;		// 劵类型 0满减劵 1折扣劵
-	private String threshold;		// 使用门槛(满多少使用等)
-	private String useDescription;		// 使用说明(通用还是指定商品可用)
-	private String relatedOrderCode;		// 在华熙下单的订单ID
-	private Integer userId;//ID系统发放接受卷的用户ID
-	private Integer sharerUserId;//分享者用户ID(可能是接受卷的用户,也可能是其子用户)
-	private String openid;//分享者的openid
-	private String companyName;		// 企业会所名称
-	private String staffName;		// 会所员工姓名(分享劵的人,如果是企业自己分享这里直接是企业名字)
-	private Date receiveDate;		// 领取时间
-	private Date useDate;		// 使用时间
-
-	private String couponOrderCode;//优惠券订单编号
-	private String clubName;//会所名字(优惠券的接收者)
-
-	public String getClubName() {
-		return clubName;
-	}
-
-	public void setClubName(String clubName) {
-		this.clubName = clubName;
-	}
-
-	public String getCouponOrderCode() {
-		return couponOrderCode;
-	}
-
-	public void setCouponOrderCode(String couponOrderCode) {
-		this.couponOrderCode = couponOrderCode;
-	}
-
-	public CmCouponRecord() {
-		super();
-	}
-
-	public CmCouponRecord(String id){
-		super(id);
-	}
-
-	@Length(min=0, max=64, message="优惠券码长度必须介于 0 和 64 之间")
-	public String getCouponCode() {
-		return couponCode;
-	}
-
-	public void setCouponCode(String couponCode) {
-		this.couponCode = couponCode;
-	}
-	
-	public String getCouponAmount() {
-		return couponAmount;
-	}
-
-	public void setCouponAmount(String couponAmount) {
-		this.couponAmount = couponAmount;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getUseStartDate() {
-		return useStartDate;
-	}
-
-	public void setUseStartDate(Date useStartDate) {
-		this.useStartDate = useStartDate;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getUseEndDate() {
-		return useEndDate;
-	}
-
-	public void setUseEndDate(Date useEndDate) {
-		this.useEndDate = useEndDate;
-	}
-	
-	@Length(min=0, max=10, message="状态 1已发放未领取 2已领取 3已使用长度必须介于 0 和 10 之间")
-	public String getStatus() {
-		return status;
-	}
-
-	public void setStatus(String status) {
-		this.status = status;
-	}
-	
-	@Length(min=0, max=11, message="劵类型 0满减劵 1折扣劵长度必须介于 0 和 11 之间")
-	public String getCouponType() {
-		return couponType;
-	}
-
-	public void setCouponType(String couponType) {
-		this.couponType = couponType;
-	}
-	
-	@Length(min=0, max=255, message="使用门槛(满多少使用等)长度必须介于 0 和 255 之间")
-	public String getThreshold() {
-		return threshold;
-	}
-
-	public void setThreshold(String threshold) {
-		this.threshold = threshold;
-	}
-	
-	@Length(min=0, max=255, message="使用说明(通用还是指定商品可用)长度必须介于 0 和 255 之间")
-	public String getUseDescription() {
-		return useDescription;
-	}
-
-	public void setUseDescription(String useDescription) {
-		this.useDescription = useDescription;
-	}
-
-	public String getRelatedOrderCode() {
-		return relatedOrderCode;
-	}
-
-	public void setRelatedOrderCode(String relatedOrderCode) {
-		this.relatedOrderCode = relatedOrderCode;
-	}
-
-	@Length(min=0, max=20, message="企业会所名称长度必须介于 0 和 20 之间")
-	public String getCompanyName() {
-		return companyName;
-	}
-
-	public void setCompanyName(String companyName) {
-		this.companyName = companyName;
-	}
-
-	public Integer getUserId() {
-		return userId;
-	}
-
-	public void setUserId(Integer userId) {
-		this.userId = userId;
-	}
-
-	public Integer getSharerUserId() {
-		return sharerUserId;
-	}
-
-	public void setSharerUserId(Integer sharerUserId) {
-		this.sharerUserId = sharerUserId;
-	}
-
-	public String getOpenid() {
-		return openid;
-	}
-
-	public void setOpenid(String openid) {
-		this.openid = openid;
-	}
-
-	@Length(min=0, max=20, message="会所员工姓名(分享劵的人,如果是企业自己分享这里直接是企业名字)长度必须介于 0 和 20 之间")
-	public String getStaffName() {
-		return staffName;
-	}
-
-	public void setStaffName(String staffName) {
-		this.staffName = staffName;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getReceiveDate() {
-		return receiveDate;
-	}
-
-	public void setReceiveDate(Date receiveDate) {
-		this.receiveDate = receiveDate;
-	}
-	
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getUseDate() {
-		return useDate;
-	}
-
-	public void setUseDate(Date useDate) {
-		this.useDate = useDate;
-	}
-	
-}

+ 0 - 188
src/main/java/com/caimei/modules/coupon/entity/CmCouponRecordScan.java

@@ -1,188 +0,0 @@
-package com.caimei.modules.coupon.entity;
-
-import java.util.Date;
-import com.thinkgem.jeesite.common.persistence.DataEntity;
-
-/**
- * 扫码推送优惠券Entity
- * @author LiJun
- * @version 2018-11-22
- */
-public class CmCouponRecordScan extends DataEntity<CmCouponRecordScan> {
-	
-	private static final long serialVersionUID = 1L;
-	private String couponCode;		// 优惠券码
-	private String couponAmount;		// 优惠券金额
-	private String discount;		// 优惠券折扣85,示例8.5
-	private Date useStartDate;		// 使用开始时间(有效期)
-	private Date useEndDate;		// 使用结束时间(有效期)
-	private String status;		// 状态 1未领取(已推送) 2已领取(输入手机号) 3已分享(可多次分享 ) 4已使用
-	private String couponType;		// 劵类型 0满减劵 1折扣劵
-	private String threshold;		// 使用门槛(满多少使用等)
-	private String useDescription;		// 使用说明(通用还是指定商品可用)
-	private String relatedOrderCode;		// 在华熙下单的订单ID
-	private Long sharerUserId;		// 分享者用户ID(采美公众号推送用户,可能只有openid不存在用户ID)
-	private String openid;		// 保存分享着的openid(采美公众号推送用户,新关注用户只能通过这个唯一确认)
-	private String mobile;		// 领劵人手机号码(分享者)
-	private Date receiveDate;		// 已分享时间
-	private Date useDate;		// 使用时间
-	private String syncFlag;		// 同步给华熙异常存档标记 0未同步 1已同步
-	private String enabledStatus;//开关状态:0:启动,1:关闭
-
-	private String couponOrderCode;//优惠券订单编号
-
-	@Override
-	public String getEnabledStatus() {
-		return enabledStatus;
-	}
-
-	@Override
-	public void setEnabledStatus(String enabledStatus) {
-		this.enabledStatus = enabledStatus;
-	}
-
-	public CmCouponRecordScan() {
-		super();
-	}
-
-	public CmCouponRecordScan(String id){
-		super(id);
-	}
-
-	public String getCouponCode() {
-		return couponCode;
-	}
-
-	public void setCouponCode(String couponCode) {
-		this.couponCode = couponCode;
-	}
-
-	public String getCouponAmount() {
-		return couponAmount;
-	}
-
-	public void setCouponAmount(String couponAmount) {
-		this.couponAmount = couponAmount;
-	}
-
-	public String getDiscount() {
-		return discount;
-	}
-
-	public void setDiscount(String discount) {
-		this.discount = discount;
-	}
-
-	public Date getUseStartDate() {
-		return useStartDate;
-	}
-
-	public void setUseStartDate(Date useStartDate) {
-		this.useStartDate = useStartDate;
-	}
-
-	public Date getUseEndDate() {
-		return useEndDate;
-	}
-
-	public void setUseEndDate(Date useEndDate) {
-		this.useEndDate = useEndDate;
-	}
-
-	public String getStatus() {
-		return status;
-	}
-
-	public void setStatus(String status) {
-		this.status = status;
-	}
-
-	public String getCouponType() {
-		return couponType;
-	}
-
-	public void setCouponType(String couponType) {
-		this.couponType = couponType;
-	}
-
-	public String getThreshold() {
-		return threshold;
-	}
-
-	public void setThreshold(String threshold) {
-		this.threshold = threshold;
-	}
-
-	public String getUseDescription() {
-		return useDescription;
-	}
-
-	public void setUseDescription(String useDescription) {
-		this.useDescription = useDescription;
-	}
-
-	public String getRelatedOrderCode() {
-		return relatedOrderCode;
-	}
-
-	public void setRelatedOrderCode(String relatedOrderCode) {
-		this.relatedOrderCode = relatedOrderCode;
-	}
-
-	public Long getSharerUserId() {
-		return sharerUserId;
-	}
-
-	public void setSharerUserId(Long sharerUserId) {
-		this.sharerUserId = sharerUserId;
-	}
-
-	public String getOpenid() {
-		return openid;
-	}
-
-	public void setOpenid(String openid) {
-		this.openid = openid;
-	}
-
-	public String getMobile() {
-		return mobile;
-	}
-
-	public void setMobile(String mobile) {
-		this.mobile = mobile;
-	}
-
-	public Date getReceiveDate() {
-		return receiveDate;
-	}
-
-	public void setReceiveDate(Date receiveDate) {
-		this.receiveDate = receiveDate;
-	}
-
-	public Date getUseDate() {
-		return useDate;
-	}
-
-	public void setUseDate(Date useDate) {
-		this.useDate = useDate;
-	}
-
-	public String getSyncFlag() {
-		return syncFlag;
-	}
-
-	public void setSyncFlag(String syncFlag) {
-		this.syncFlag = syncFlag;
-	}
-
-	public String getCouponOrderCode() {
-		return couponOrderCode;
-	}
-
-	public void setCouponOrderCode(String couponOrderCode) {
-		this.couponOrderCode = couponOrderCode;
-	}
-
-}

+ 77 - 0
src/main/java/com/caimei/modules/coupon/entity/CmCouponRedemptionCode.java

@@ -0,0 +1,77 @@
+package com.caimei.modules.coupon.entity;
+
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+
+import java.util.Date;
+
+/**
+ * cm_coupon_redemption_code
+ *
+ * @author : plf
+ * @date : 2021/8/11
+ */
+public class CmCouponRedemptionCode extends DataEntity<CmCouponRedemptionCode> {
+    private Integer couponId;       //优惠券id
+    private Integer clubCouponId;         //用户关联优惠券id(对应cm_coupon_club)
+    private String redemptionCode;      //兑换码(16位)
+    private String status;      //兑换状态:1未兑换 2已兑换
+    private Date redemptionTime;     //兑换时间
+    private Date addTime;        //添加时间
+    private Integer userId;     //机构用户id
+
+    public Integer getCouponId() {
+        return couponId;
+    }
+
+    public void setCouponId(Integer couponId) {
+        this.couponId = couponId;
+    }
+
+    public Integer getClubCouponId() {
+        return clubCouponId;
+    }
+
+    public void setClubCouponId(Integer clubCouponId) {
+        this.clubCouponId = clubCouponId;
+    }
+
+    public String getRedemptionCode() {
+        return redemptionCode;
+    }
+
+    public void setRedemptionCode(String redemptionCode) {
+        this.redemptionCode = redemptionCode;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public Date getRedemptionTime() {
+        return redemptionTime;
+    }
+
+    public void setRedemptionTime(Date redemptionTime) {
+        this.redemptionTime = redemptionTime;
+    }
+
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+}

+ 0 - 218
src/main/java/com/caimei/modules/coupon/entity/ReadExcel.java

@@ -1,218 +0,0 @@
-package com.caimei.modules.coupon.entity;
-
-import com.caimei.modules.cibe.entity.CibeShop;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Cell;
-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.xssf.usermodel.XSSFWorkbook;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author zcp
- * @description
- * @date 2018/1/23
- * @time 15:56
- **/
-public class ReadExcel {
-    //总行数
-    private int totalRows = 0;
-    //总条数
-    private int totalCells = 0;
-    //错误信息接收器
-    private String errorMsg;
-    //构造方法
-    public ReadExcel(){}
-    //获取总行数
-    public int getTotalRows()  { return totalRows;}
-    //获取总列数
-    public int getTotalCells() {  return totalCells;}
-    //获取错误信息
-    public String getErrorInfo() { return errorMsg; }
-
-    /**
-     * 读EXCEL文件,获取信息集合
-     * @param mFile
-     * @return
-     */
-    public List<CmCoupon> getExcelInfo(MultipartFile mFile) {
-        String fileName = mFile.getOriginalFilename();//获取文件名
-        List<CmCoupon> cmCoupons = new ArrayList<>();
-        try {
-            if (!validateExcel(fileName)) {// 验证文件名是否合格
-                return null;
-            }
-            boolean isExcel2003 = true;// 根据文件名判断文件是2003版本还是2007版本
-            if (isExcel2007(fileName)) {
-                isExcel2003 = false;
-            }
-            cmCoupons = createExcel(mFile.getInputStream(), isExcel2003);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return cmCoupons;
-    }
-
-    /**
-     * 根据excel里面的内容读取客户信息
-     * @param is 输入流
-     * @param isExcel2003 excel是2003还是2007版本
-     * @return
-     * @throws IOException
-     */
-    public List<CmCoupon> createExcel(InputStream is, boolean isExcel2003) throws ParseException {
-        List<CmCoupon> cmCoupons = new ArrayList<>();
-        try{
-            Workbook wb = null;
-            if (isExcel2003) {// 当excel是2003时,创建excel2003
-                wb = new HSSFWorkbook(is);
-            } else {// 当excel是2007时,创建excel2007
-                wb = new XSSFWorkbook(is);
-            }
-            cmCoupons = readExcelValue(wb);// 读取Excel里面客户的信息
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return cmCoupons;
-    }
-
-    /**
-     * 读取Excel里面客户的信息
-     * @param wb
-     * @return
-     */
-    private List<CmCoupon> readExcelValue(Workbook wb) throws ParseException {
-        // 得到第一个shell
-        Sheet sheet = wb.getSheetAt(0);
-        // 得到Excel的行数
-        this.totalRows = sheet.getPhysicalNumberOfRows();
-        // 得到Excel的列数(前提是有行数)
-        if (totalRows > 1 && sheet.getRow(0) != null) {
-            this.totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
-        }
-        List<CmCoupon> cmCoupons = new ArrayList<>();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        // 循环Excel行数
-        for (int r = 1; r < totalRows; r++) {
-            Row row = sheet.getRow(r);
-            if (row == null){
-                continue;
-            }
-            CmCoupon cmCoupon = new CmCoupon();
-            // 循环Excel的列
-            for (int c = 0; c < this.totalCells; c++) {
-                Cell cell = row.getCell(c);
-                if (null != cell) {
-                    String value = getFieldValue(cell);
-                    switch (c){
-                        case 0:
-                            //如果是纯数字,比如你写的是25,cell.getNumericCellValue()获得是25.0,通过截取字符串去掉.0获得25
-                            //如果是科学计数法转化为整数
-                            if(null != value && value.indexOf("E") > 0){
-                                BigDecimal bd = new BigDecimal(value);
-                                value = bd.toPlainString();
-                            }
-                            cmCoupon.setCouponCode(value); //优惠券码
-                            break;
-                        case 1:
-                            //优惠券名称(由于后期新增,本系统也未使用暂不做处理)
-                            break;
-                        case 2:
-                            if ("代金劵".equals(value.trim()) || "代金券".equals(value.trim()))  //劵和券不是同一个字,容易混淆
-                                cmCoupon.setCouponType("0");//劵类型
-                            if ("折扣劵".equals(value.trim()) || "折扣券".equals(value.trim()))
-                                cmCoupon.setCouponType("1");//劵类型
-                            if(!"折扣劵".equals(value.trim()) && !"代金劵".equals(value.trim()))
-                                cmCoupon.setCouponType("0");//默认代金劵
-                            break;
-                        case 3:
-                            if(null != value){
-                                boolean isContains = value.contains("元");
-                                if(isContains){
-                                    value = value.replace("元","");
-                                }
-                            }
-                            cmCoupon.setCouponAmount(value); //满减金额(面值格式50元)
-                            break;
-                        case 4:
-                            cmCoupon.setUseStartDate(sdf.parse(value));//有效起始时间
-                            break;
-                        case 5:
-                            cmCoupon.setUseEndDate(sdf.parse(value));//有效结束时间
-                            break;
-                        case 6:
-                            cmCoupon.setThreshold(value);//使用门槛
-                            break;
-                        case 7:
-                            cmCoupon.setCouponlimit(value);//优惠券限制(每个用户限制兑换次数)每人限领张数
-                            break;
-                        case 8:
-                            cmCoupon.setUseDescription(value);//使用说明
-                            break;
-                        default:
-                            break;
-                    }
-                }
-            }
-            cmCoupon.setDelFlag("0");
-            cmCoupon.setCreateDate(new Date());
-            cmCoupon.setUpdateDate(new Date());
-            cmCoupon.setStatus("0"); //默认未派发
-            // 添加到list
-            cmCoupons.add(cmCoupon);
-        }
-        return cmCoupons;
-    }
-
-    /**
-     * 获取
-     * @param cell
-     * @return
-     */
-    public String getFieldValue(Cell cell){
-        String value = null;
-        if(cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC){
-//            String str = String.valueOf(cell.getNumericCellValue());
-//            value = str.substring(0, str.length()-2>0?str.length()-2:1);
-            value = String.valueOf(cell.getNumericCellValue());
-        }else {
-            value = cell.getStringCellValue();
-        }
-        return value;
-    }
-
-    /**
-     * 验证EXCEL文件
-     *
-     * @param filePath
-     * @return
-     */
-    public boolean validateExcel(String filePath) {
-        if (filePath == null || !(isExcel2003(filePath) || isExcel2007(filePath))) {
-            errorMsg = "文件名不是excel格式";
-            return false;
-        }
-        return true;
-    }
-
-    // @描述:是否是2003的excel,返回true是2003
-    public static boolean isExcel2003(String filePath)  {
-        return filePath.matches("^.+\\.(?i)(xls)$");
-    }
-
-    //@描述:是否是2007的excel,返回true是2007
-    public static boolean isExcel2007(String filePath)  {
-        return filePath.matches("^.+\\.(?i)(xlsx)$");
-    }
-}

+ 127 - 51
src/main/java/com/caimei/modules/coupon/service/CmCouponClubService.java

@@ -1,69 +1,145 @@
 package com.caimei.modules.coupon.service;
 
-import java.util.List;
-
-import com.caimei.modules.user.entity.NewCmClub;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
+import com.caimei.modules.coupon.dao.CmCouponClubDao;
+import com.caimei.modules.coupon.entity.CmCoupon;
+import com.caimei.modules.coupon.entity.CmCouponClub;
+import com.caimei.modules.coupon.entity.CmCouponRedemptionCode;
+import com.caimei.modules.user.dao.CmUserDao;
+import com.caimei.modules.user.entity.CmUser;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.service.CrudService;
-import com.caimei.modules.coupon.entity.CmCouponClub;
-import com.caimei.modules.coupon.dao.CmCouponClubDao;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
-import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
- * 采美优惠券活动签约会所Service
- * @author lwt
- * @version 2018-09-29
+ * 优惠券管理Service
+ *
+ * @author plf
+ * @version 2021-08-10
  */
 @Service
 @Transactional(readOnly = true)
 public class CmCouponClubService extends CrudService<CmCouponClubDao, CmCouponClub> {
+    @Autowired
+    private CmCouponClubDao cmCouponClubDao;
+    @Autowired
+    private CmUserDao cmUserDao;
+
+    public CmCouponClub get(String id) {
+        return super.get(id);
+    }
 
-	@Resource
-	private CmCouponClubDao cmCouponClubDao;
+    public List<CmCouponClub> findList(CmCouponClub cmCouponClub) {
+        return super.findList(cmCouponClub);
+    }
 
-	public CmCouponClub get(String id) {
-		return super.get(id);
-	}
-	
-	public List<CmCouponClub> findList(CmCouponClub cmCouponClub) {
-		return super.findList(cmCouponClub);
-	}
-	
-	public Page<CmCouponClub> findPage(Page<CmCouponClub> page, CmCouponClub cmCouponClub) {
-		return super.findPage(page, cmCouponClub);
-	}
-	
-	@Transactional(readOnly = false)
-	public void save(CmCouponClub cmCouponClub) {
-		super.save(cmCouponClub);
-	}
-	
-	@Transactional(readOnly = false)
-	public void delete(CmCouponClub cmCouponClub) {
-		super.delete(cmCouponClub);
-	}
+    public Page<CmCouponClub> findPage(Page<CmCouponClub> page, CmCouponClub cmCouponClub) {
+        return super.findPage(page, cmCouponClub);
+    }
 
-	@Transactional(readOnly = false)
-	public void update(CmCouponClub cmCouponClub) {
-		cmCouponClubDao.update(cmCouponClub);
-	}
+    @Transactional(readOnly = false)
+    public void save(CmCouponClub cmCouponClub) {
+        super.save(cmCouponClub);
+    }
 
-	@Transactional(readOnly = false)
-	public void deleteCmCouponClub(CmCouponClub cmCouponClub) {
-		cmCouponClubDao.deleteCmCouponClub(cmCouponClub);
-	}
+    public Page<CmCouponClub> receivingUserList(Page<CmCouponClub> cmCouponClubPage, CmCouponClub cmCouponClub) {
+        cmCouponClub.setPage(cmCouponClubPage);
+        List<CmCouponClub> couponClubList = cmCouponClubDao.receivingUserList(cmCouponClub);
+        cmCouponClubPage.setList(couponClubList);
+        return cmCouponClubPage;
+    }
 
-	public List<Integer> getAllClubID(){
-		return cmCouponClubDao.getAllClubID();
-	}
+    public Page<CmCouponClub> findCouponDetails(Page<CmCouponClub> couponClubPage, CmCouponClub cmCouponClub) {
+        cmCouponClub.setPage(couponClubPage);
+        List<CmCouponClub> couponList = cmCouponClubDao.findClubCoupon(cmCouponClub);
+        if (couponList != null && couponList.size() > 0) {
+            Date date = new Date();
+            couponList.forEach(couponClub -> {
+                if (!"2".equals(couponClub.getCouponStatus())) {
+                    if (date.compareTo(couponClub.getStartDate()) < 0) {
+                        couponClub.setCouponStatus("0");
+                    } else if (date.compareTo(couponClub.getEndDate()) > 0) {
+                        couponClub.setCouponStatus("3");
+                    } else {
+                        couponClub.setCouponStatus("1");
+                    }
+                }
+            });
+        }
+        couponClubPage.setList(couponList);
+        return couponClubPage;
+    }
 
-	public Page<NewCmClub> getClubList(Page<NewCmClub> page, NewCmClub cmClub) {
-		cmClub.setPage(page);
-		page.setList(cmCouponClubDao.getClubList(cmClub));
-		return page;
-	}
+    @Transactional(readOnly = false)
+    public Map<String, Object> redeemCoupons(CmCouponRedemptionCode redemptionCode) {
+        Map<String, Object> map = new HashMap<>();
+        CmCouponRedemptionCode cmCouponRedemptionCode = cmCouponClubDao.findCouponRedemptionCode(redemptionCode.getRedemptionCode());
+        if (cmCouponRedemptionCode == null) {
+            map.put("code", -1);
+            map.put("msg", "请输入正确的兑换码");
+            return map;
+        }
+        if ("2".equals(cmCouponRedemptionCode.getStatus())) {
+            map.put("code", -1);
+            map.put("msg", "兑换码已使用,请更换兑换码进行兑换");
+            return map;
+        }
+        CmCoupon coupon = cmCouponClubDao.getCoupons(cmCouponRedemptionCode.getCouponId());
+        Date date = new Date();
+        if (coupon == null || date.compareTo(coupon.getStartDate()) < 0 || date.compareTo(coupon.getEndDate()) > 0) {
+            map.put("code", -1);
+            map.put("msg", "兑换的优惠券已失效");
+            return map;
+        }
+        if (coupon.getCouponType() == 2 && !redemptionCode.getUserId().equals(coupon.getUserId())) {
+            map.put("code", -1);
+            map.put("msg", "该优惠券属于其他用户,您不能兑换");
+            return map;
+        }
+        if (coupon.getCouponType() == 4) {
+            CmUser cmUser = cmUserDao.get(redemptionCode.getUserId().toString());
+            if (cmUser != null && StringUtils.isNotBlank(cmUser.getRegisterTime())) {
+                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+                Date registerTime = null;
+                try {
+                    registerTime = format.parse(cmUser.getRegisterTime());
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                    map.put("code", -1);
+                    map.put("msg", "该优惠券只供新用户使用,您不能兑换");
+                    return map;
+                }
+                if (registerTime.compareTo(coupon.getStartDate()) < 0) {
+                    map.put("code", -1);
+                    map.put("msg", "该优惠券只供新用户使用,您不能兑换");
+                    return map;
+                }
+            } else {
+                map.put("code", -1);
+                map.put("msg", "该优惠券只供新用户使用,您不能兑换");
+                return map;
+            }
+        }
+        CmCouponClub couponClub = new CmCouponClub();
+        couponClub.setCouponId(cmCouponRedemptionCode.getCouponId());
+        couponClub.setUserId(redemptionCode.getUserId());
+        couponClub.setSource("4");
+        couponClub.setStatus("1");
+        couponClub.setCreateDate(new Date());
+        couponClub.setDelFlag("0");
+        cmCouponClubDao.insert(couponClub);
+        cmCouponClubDao.updateRedemptionCode(cmCouponRedemptionCode.getId(), couponClub.getId());
+        map.put("code", 0);
+        map.put("msg", "优惠券兑换成功");
+        return map;
+    }
 }

+ 0 - 52
src/main/java/com/caimei/modules/coupon/service/CmCouponOrderRecordService.java

@@ -1,52 +0,0 @@
-package com.caimei.modules.coupon.service;
-
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.thinkgem.jeesite.common.persistence.Page;
-import com.thinkgem.jeesite.common.service.CrudService;
-import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
-import com.caimei.modules.coupon.dao.CmCouponOrderRecordDao;
-
-/**
- * 采美优惠券订单Service
- * @author Lijun
- * @version 2018-10-10
- */
-@Service
-@Transactional(readOnly = true)
-public class CmCouponOrderRecordService extends CrudService<CmCouponOrderRecordDao, CmCouponOrderRecord> {
-
-	@Autowired
-	CmCouponOrderRecordDao cmCouponOrderRecordDao;
-
-	public CmCouponOrderRecord get(String id) {
-		return super.get(id);
-	}
-	
-	public List<CmCouponOrderRecord> findList(CmCouponOrderRecord cmCouponOrderRecord) {
-		return super.findList(cmCouponOrderRecord);
-	}
-
-	public List<CmCouponOrderRecord> findListBuyAgain(String customerMobile) {
-		return cmCouponOrderRecordDao.findListBuyAgain(customerMobile);
-	}
-
-	public Page<CmCouponOrderRecord> findPage(Page<CmCouponOrderRecord> page, CmCouponOrderRecord cmCouponOrderRecord) {
-		return super.findPage(page, cmCouponOrderRecord);
-	}
-	
-	@Transactional(readOnly = false)
-	public void save(CmCouponOrderRecord cmCouponOrderRecord) {
-		super.save(cmCouponOrderRecord);
-	}
-	
-	@Transactional(readOnly = false)
-	public void delete(CmCouponOrderRecord cmCouponOrderRecord) {
-		super.delete(cmCouponOrderRecord);
-	}
-	
-}

+ 0 - 54
src/main/java/com/caimei/modules/coupon/service/CmCouponRecordScanService.java

@@ -1,54 +0,0 @@
-package com.caimei.modules.coupon.service;
-
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.thinkgem.jeesite.common.persistence.Page;
-import com.thinkgem.jeesite.common.service.CrudService;
-import com.caimei.modules.coupon.entity.CmCouponRecordScan;
-import com.caimei.modules.coupon.dao.CmCouponRecordScanDao;
-
-/**
- * 扫码推送优惠券Service
- * @author LiJun
- * @version 2018-11-22
- */
-@Service
-@Transactional(readOnly = false)
-public class CmCouponRecordScanService extends CrudService<CmCouponRecordScanDao, CmCouponRecordScan> {
-	@Autowired
-	CmCouponRecordScanDao cmCouponRecordScanDao;
-
-	public CmCouponRecordScan get(String id) {
-		return super.get(id);
-	}
-	
-	public List<CmCouponRecordScan> findList(CmCouponRecordScan cmCouponRecordScan) {
-		return super.findList(cmCouponRecordScan);
-	}
-	
-	public Page<CmCouponRecordScan> findPage(Page<CmCouponRecordScan> page, CmCouponRecordScan cmCouponRecordScan) {
-		return super.findPage(page, cmCouponRecordScan);
-	}
-	
-	@Transactional(readOnly = false)
-	public void save(CmCouponRecordScan cmCouponRecordScan) {
-		super.save(cmCouponRecordScan);
-	}
-	
-	@Transactional(readOnly = false)
-	public void delete(CmCouponRecordScan cmCouponRecordScan) {
-		super.delete(cmCouponRecordScan);
-	}
-
-	public void updateEnabledStatus(String enabledStatus){
-		cmCouponRecordScanDao.updateEnabledStatus(enabledStatus);
-	}
-
-	public CmCouponRecordScan getEnabledStatus(){
-		return  cmCouponRecordScanDao.getEnabledStatus();
-	}
-}

+ 0 - 44
src/main/java/com/caimei/modules/coupon/service/CmCouponRecordService.java

@@ -1,44 +0,0 @@
-package com.caimei.modules.coupon.service;
-
-import java.util.List;
-
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.thinkgem.jeesite.common.persistence.Page;
-import com.thinkgem.jeesite.common.service.CrudService;
-import com.caimei.modules.coupon.entity.CmCouponRecord;
-import com.caimei.modules.coupon.dao.CmCouponRecordDao;
-
-/**
- * 采美优惠券使用记录表Service
- * @author lwt
- * @version 2018-09-29
- */
-@Service
-@Transactional(readOnly = true)
-public class CmCouponRecordService extends CrudService<CmCouponRecordDao, CmCouponRecord> {
-
-	public CmCouponRecord get(String id) {
-		return super.get(id);
-	}
-	
-	public List<CmCouponRecord> findList(CmCouponRecord cmCouponRecord) {
-		return super.findList(cmCouponRecord);
-	}
-	
-	public Page<CmCouponRecord> findPage(Page<CmCouponRecord> page, CmCouponRecord cmCouponRecord) {
-		return super.findPage(page, cmCouponRecord);
-	}
-	
-	@Transactional(readOnly = false)
-	public void save(CmCouponRecord cmCouponRecord) {
-		super.save(cmCouponRecord);
-	}
-	
-	@Transactional(readOnly = false)
-	public void delete(CmCouponRecord cmCouponRecord) {
-		super.delete(cmCouponRecord);
-	}
-	
-}

+ 366 - 62
src/main/java/com/caimei/modules/coupon/service/CmCouponService.java

@@ -1,74 +1,378 @@
 package com.caimei.modules.coupon.service;
 
-import java.util.List;
-
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
+import com.alibaba.fastjson.JSON;
+import com.caimei.modules.coupon.dao.CmCouponDao;
+import com.caimei.modules.coupon.entity.CmCoupon;
+import com.caimei.modules.coupon.entity.CmCouponAssociate;
+import com.caimei.modules.coupon.entity.CmCouponClub;
+import com.caimei.modules.coupon.entity.CmCouponRedemptionCode;
+import com.caimei.modules.miniprogram.utils.UploadPicUtils;
+import com.caimei.modules.order.utils.RandomCode;
+import com.caimei.modules.product.dao.ProductDao;
+import com.caimei.modules.product.entity.Product;
+import com.caimei.modules.user.dao.NewCmShopDao;
+import com.caimei.modules.user.entity.CmUser;
+import com.caimei.modules.user.entity.NewCmShop;
+import com.caimei.utils.AppUtils;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.service.CrudService;
-import com.caimei.modules.coupon.entity.CmCoupon;
-import com.caimei.modules.coupon.dao.CmCouponDao;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
-import javax.annotation.Resource;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
 
 /**
- * 采美优惠券表(优惠券基本信息来自华熙提供)Service
- * @author lwt
- * @version 2018-09-30
+ * 优惠券管理Service
+ *
+ * @author plf
+ * @version 2021-08-02
  */
 @Service
-@Transactional(readOnly = false)
+@Transactional(readOnly = true)
 public class CmCouponService extends CrudService<CmCouponDao, CmCoupon> {
+    @Autowired
+    private CmCouponDao cmCouponDao;
+    @Autowired
+    private ProductDao productDao;
+    @Autowired
+    private NewCmShopDao newCmShopDao;
+
+    public CmCoupon get(String id) {
+        CmCoupon coupon = super.get(id);
+        setCouponStatus(coupon, new Date());
+        if (coupon.getCouponType() == 3 && coupon.getShopId() != null) {
+            //店铺券
+            NewCmShop shop = newCmShopDao.get(coupon.getShopId().toString());
+            coupon.setShop(shop);
+        }
+        if ("1".equals(coupon.getCouponsMode())) {
+            Integer codeNum = cmCouponDao.findRedemptionCodeNum(coupon.getId());
+            coupon.setCodeNum(codeNum);
+        }
+        return coupon;
+    }
+
+    public List<CmCoupon> findList(CmCoupon cmCoupon) {
+        return super.findList(cmCoupon);
+    }
+
+    public Page<CmCoupon> findPage(Page<CmCoupon> page, CmCoupon cmCoupon) {
+        Page<CmCoupon> couponPage = super.findPage(page, cmCoupon);
+        List<CmCoupon> couponList = couponPage.getList();
+        Date date = new Date();
+        couponList.forEach(coupon -> {
+            setCouponStatus(coupon, date);
+            if ("1".equals(coupon.getCouponsMode())) {
+                //兑换码券
+                Integer num = cmCouponDao.findQuantityRedeemed(coupon.getId());
+                coupon.setCodeNum(num);
+            } else {
+                if (2 == coupon.getCouponType()) {
+                    //用户专享劵
+                    CmCouponClub couponClub = cmCouponDao.findCouponClub(coupon.getId());
+                    if (couponClub == null) {
+                        coupon.setClaimStatus("1");
+                    } else {
+                        coupon.setClaimStatus("2");
+                    }
+                    coupon.setCouponClub(couponClub);
+                }
+            }
+        });
+        return couponPage;
+    }
+
+    private void setCouponStatus(CmCoupon cmCoupon, Date date) {
+        if (cmCoupon != null) {
+            if (!cmCoupon.getStatus().contains("2")) {
+                if (date.compareTo(cmCoupon.getStartDate()) < 0) {
+                    cmCoupon.setStatus("0");
+                } else if (date.compareTo(cmCoupon.getEndDate()) > 0) {
+                    cmCoupon.setStatus("3");
+                } else {
+                    cmCoupon.setStatus("1");
+                }
+            } else {
+                cmCoupon.setStatus("2");
+            }
+        }
+    }
+
+    @Transactional(readOnly = false)
+    public void save(CmCoupon cmCoupon) {
+        if (StringUtils.isNotBlank(cmCoupon.getPcBanner())) {
+            String image = UploadPicUtils.saveImageToServer(cmCoupon.getPcBanner());
+            cmCoupon.setPcBanner(image);
+        }
+        if (StringUtils.isNotBlank(cmCoupon.getAppletsBanner())) {
+            String image = UploadPicUtils.saveImageToServer(cmCoupon.getAppletsBanner());
+            cmCoupon.setAppletsBanner(image);
+        }
+        Date date = new Date();
+        cmCoupon.setCreateDate(date);
+        setCouponStatus(cmCoupon, date);
+        if (StringUtils.isBlank(cmCoupon.getCouponsMode())) {
+            cmCoupon.setCouponsMode("0");
+        }
+        super.save(cmCoupon);
+        List<Integer> associateIds = cmCouponDao.findByCouponId(cmCoupon.getId());
+        if (0 == cmCoupon.getCouponType()) {
+            //活动券
+            if (StringUtils.isNotBlank(cmCoupon.getProductInfo())) {
+                List<CmCouponAssociate> associateList = JSON.parseArray(cmCoupon.getProductInfo(), CmCouponAssociate.class);
+                associateList.forEach(a -> {
+                    if (a.getId() == null) {
+                        a.setDelFlag("0");
+                        a.setCouponId(Integer.valueOf(cmCoupon.getId()));
+                        a.setAddTime(date);
+                        cmCouponDao.insertCouponAssociate(a);
+                    } else {
+                        associateIds.removeIf(id -> id.equals(a.getId()));
+                        cmCouponDao.updateCouponAssociate(a);
+                    }
+                });
+            }
+        }
+        if (associateIds != null && associateIds.size() > 0) {
+            associateIds.forEach(id -> {
+                cmCouponDao.logicDeleteCouponAssociate(id);
+            });
+        }
+    }
+
+    @Transactional(readOnly = false)
+    public void delete(CmCoupon cmCoupon) {
+        cmCouponDao.updateByDelFlag(cmCoupon.getId());
+        cmCouponDao.updateAssociateByDelFlag(cmCoupon.getId());
+    }
+
+    public Page<Product> findProductList(Page<Product> productPage, Product product) {
+        product.setPage(productPage);
+        product.setValidFlag("2");
+        product.setProductCategory("1");
+        List<Product> productList = productDao.findProductImage(product);
+        if (productList != null && productList.size() > 0) {
+            productList.forEach(item -> {
+                item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, "https://www.caimei365.com/"));
+                item.setProductIds(product.getProductIds());
+                if (StringUtils.isNotBlank(product.getProductIds()) && product.getProductIds().contains(item.getProductID().toString())) {
+                    item.setStoreStatus(true);
+                }
+            });
+        }
+        productPage.setList(productList);
+        return productPage;
+    }
+
+    public List<CmCouponAssociate> findByProductType(CmCoupon cmCoupon) {
+        List<CmCouponAssociate> associateList = cmCouponDao.findByProductType(cmCoupon.getId());
+        if (associateList != null && associateList.size() > 0) {
+            associateList.forEach(item -> {
+                item.setImage(AppUtils.getImageURL("product", item.getImage(), 0, "https://www.caimei365.com/"));
+            });
+        }
+        return associateList;
+    }
+
+    @Transactional(readOnly = false)
+    public void close(CmCoupon cmCoupon) {
+        cmCoupon.setStatus("2");
+        cmCouponDao.update(cmCoupon);
+    }
+
+    public Page<CmUser> findUserList(Page<CmUser> userPage, CmUser cmUser) {
+        cmUser.setPage(userPage);
+        List<CmUser> userList = cmCouponDao.findUserList(cmUser);
+        userPage.setList(userList);
+        return userPage;
+    }
+
+    public Page<NewCmShop> findShopList(Page<NewCmShop> newCmShopPage, NewCmShop newCmShop) {
+        newCmShop.setPage(newCmShopPage);
+        List<NewCmShop> shopList = cmCouponDao.findShopList(newCmShop);
+        newCmShopPage.setList(shopList);
+        return newCmShopPage;
+    }
+
+    @Transactional(readOnly = false)
+    public void redemptionCodeCouponSave(CmCoupon cmCoupon) {
+        cmCoupon.setCouponsMode("1");
+        save(cmCoupon);
+        if (cmCoupon.getCodeNum() != null && cmCoupon.getCodeNum() > 0) {
+            Integer codeNum = cmCouponDao.findRedemptionCodeNum(cmCoupon.getId());
+            int num = cmCoupon.getCodeNum() - codeNum;
+            CmCouponRedemptionCode code = new CmCouponRedemptionCode();
+            code.setAddTime(new Date());
+            code.setCouponId(Integer.valueOf(cmCoupon.getId()));
+            code.setStatus("1");
+            for (int i = 0; i < num; i++) {
+                //生成对应数量兑换码
+                String redemptionCode = generateRedemptionCode();
+                code.setRedemptionCode(redemptionCode);
+                cmCouponDao.insertRedemptionCode(code);
+            }
+        }
+    }
+
+    /**
+     * 生成不重复的兑换码
+     */
+    public String generateRedemptionCode() {
+        String redemptionCode = RandomCode.generateShortLink(16);
+        CmCouponRedemptionCode code = cmCouponDao.findByRedemptionCode(redemptionCode);
+        if (code != null) {
+            generateRedemptionCode();
+        }
+        return redemptionCode;
+    }
+
+    public Page<CmCouponRedemptionCode> redemptionCodeList(Page<CmCouponRedemptionCode> codePage, CmCouponRedemptionCode redemptionCode) {
+        redemptionCode.setPage(codePage);
+        List<CmCouponRedemptionCode> redemptionCodeList = cmCouponDao.findRedemptionCode(redemptionCode);
+        codePage.setList(redemptionCodeList);
+        return codePage;
+    }
+
+    /**
+     * 判断此商品是否有优惠
+     *
+     * @param userId        机构用户id
+     * @param productId     商品id
+     * @param shopId        供应商id
+     * @param commodityType 商品属性:1产品,2仪器
+     */
+    public Boolean setCouponsLogo(Integer userId, Integer productId, Integer shopId, String commodityType) {
+        boolean couponsLogo = false;
+        List<CmCoupon> couponList = cmCouponDao.findClubCouponList(userId);
+        if (couponList != null && couponList.size() > 0) {
+            for (CmCoupon coupon : couponList) {
+                if (coupon.getCouponType() == 4 || coupon.getCouponType() == 2) {
+                    //用户券与用户专享券
+                    couponsLogo = true;
+                    break;
+                }
+                if (coupon.getCouponType() == 0) {
+                    if ("1".equals(coupon.getProductType())) {
+                        //活动券-全商城商品
+                        couponsLogo = true;
+                        break;
+                    } else {
+                        //活动券-指定商品
+                        List<Integer> productIds = cmCouponDao.findAllProductId(coupon.getId());
+                        if (productIds.contains(productId)) {
+                            couponsLogo = true;
+                            break;
+                        }
+                    }
+                }
+                if (coupon.getCouponType() == 3 && shopId.equals(coupon.getShopId())) {
+                    //店铺券
+                    couponsLogo = true;
+                    break;
+                }
+                if (coupon.getCouponType() == 1) {
+                    //品类券
+                    if (coupon.getCategoryType().equals(commodityType)) {
+                        couponsLogo = true;
+                        break;
+                    }
+                }
+            }
+        }
+        return couponsLogo;
+    }
+
+    public List<CmCoupon> findClubCouponList(Product product, Integer userId) {
+        List<CmCoupon> couponList = cmCouponDao.findClubCouponList(userId);
+        filterCoupon(product, couponList);
+        setCouponCopywriting(couponList);
+        return couponList;
+    }
+
+    /**
+     * 过滤与商品不能使用优惠券
+     *
+     * @param product    商品数据
+     * @param couponList 优惠券集合
+     */
+    private void filterCoupon(Product product, List<CmCoupon> couponList) {
+        if (couponList != null && couponList.size() > 0) {
+            Iterator<CmCoupon> iterator = couponList.iterator();
+            while (iterator.hasNext()) {
+                CmCoupon coupon = iterator.next();
+                if (coupon.getCouponType() == 0 && "2".equals(coupon.getProductType())) {
+                    //活动券
+                    List<Integer> productIds = cmCouponDao.findAllProductId(coupon.getId());
+                    if (!productIds.contains(product.getProductID())) {
+                        iterator.remove();
+                        continue;
+                    }
+                }
+                if (coupon.getCouponType() == 1 && !coupon.getCategoryType().equals(product.getCommodityType())) {
+                    iterator.remove();
+                    continue;
+                }
+                if (coupon.getCouponType() == 3 && !coupon.getShopId().equals(product.getShopID())) {
+                    iterator.remove();
+                }
+            }
+        }
+    }
+
+    public List<CmCoupon> findNotRedeemedCoupon(Product product) {
+        List<CmCoupon> couponList = cmCouponDao.findNotRedeemedCoupon();
+        filterCoupon(product, couponList);
+        setCouponCopywriting(couponList);
+        return couponList;
+    }
 
-	@Resource
-	private CmCouponDao cmCouponDao;
-
-	public CmCoupon get(String id) {
-		return super.get(id);
-	}
-	
-	public List<CmCoupon> findList(CmCoupon cmCoupon) {
-		return super.findList(cmCoupon);
-	}
-
-	public List<CmCoupon> findCouponList(CmCoupon cmCoupon) {
-		return cmCouponDao.findCouponList(cmCoupon);
-	}
-
-	public Page<CmCoupon> findPage(Page<CmCoupon> page, CmCoupon cmCoupon) {
-		return super.findPage(page, cmCoupon);
-	}
-	
-	@Transactional(readOnly = false)
-	public void save(CmCoupon cmCoupon) {
-		super.save(cmCoupon);
-	}
-
-	@Transactional(readOnly = false)
-	public void update(CmCoupon cmCoupon) {
-		cmCouponDao.update(cmCoupon);
-	}
-
-	public void updateStatus(CmCoupon cmCoupon) {
-		cmCouponDao.updateStatus(cmCoupon);
-	}
-
-
-	@Transactional(readOnly = false)
-	public void delete(CmCoupon cmCoupon) {
-		super.delete(cmCoupon);
-	}
-
-	public List<CmCoupon> statisticsCoupon(){
-		return cmCouponDao.statisticsCoupon();
-	}
-
-	public List<CmCoupon> findByCouponCode(String couponCode){
-		return cmCouponDao.findByCouponCode(couponCode);
-	}
-
-	public List<CmCoupon> getSendCoupon (CmCoupon cmCoupon) {
-		return cmCouponDao.getSendCoupon(cmCoupon);
-	}
+    /**
+     * 设置优惠券文案相关
+     *
+     * @param couponList
+     */
+    public void setCouponCopywriting(List<CmCoupon> couponList) {
+        if (couponList != null && couponList.size() > 0) {
+            couponList.forEach(coupon -> {
+                String couponName = "¥" + coupon.getCouponAmount() + " 满" + coupon.getTouchPrice() + "可用";
+                if (coupon.getCouponType() == 0) {
+                    coupon.setCouponName("活动券" + couponName);
+                    if ("2".equals(coupon.getProductType())) {
+                        List<Integer> productIdList = cmCouponDao.findAllProductId(coupon.getId());
+                        coupon.setProductIdList(productIdList);
+                        coupon.setCouponDesc("仅可购买指定商品");
+                    } else {
+                        coupon.setCouponDesc("全商城商品通用");
+                    }
+                } else if (coupon.getCouponType() == 1) {
+                    coupon.setCouponName("品类券" + couponName);
+                    if ("1".equals(coupon.getCategoryType())) {
+                        coupon.setCouponDesc("仅可购买产品类商品");
+                    } else {
+                        coupon.setCouponDesc("仅可购买仪器类商品");
+                    }
+                } else if (coupon.getCouponType() == 2) {
+                    coupon.setCouponName("用户专享券" + couponName);
+                    coupon.setCouponDesc("全商城商品通用");
+                } else if (coupon.getCouponType() == 3) {
+                    NewCmShop cmShop = newCmShopDao.get(coupon.getShopId().toString());
+                    if (cmShop != null) {
+                        String shopName = cmShop.getName();
+                        if (shopName.length() > 10) {
+                            shopName = shopName.substring(0, 9) + "...";
+                        }
+                        coupon.setCouponName("店铺券" + couponName);
+                        coupon.setCouponDesc("仅可购买店铺【" + shopName + "】的商品");
+                    }
+                } else if (coupon.getCouponType() == 4) {
+                    coupon.setCouponName("新用户券" + couponName);
+                    coupon.setCouponDesc("全商城商品通用");
+                }
+            });
+        }
+    }
 }

+ 80 - 194
src/main/java/com/caimei/modules/coupon/web/CmCouponClubController.java

@@ -1,217 +1,103 @@
 package com.caimei.modules.coupon.web;
 
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import com.caimei.modules.coupon.entity.CmCoupon;
-import com.caimei.modules.coupon.entity.CmCouponRecord;
-import com.caimei.modules.coupon.service.CmCouponRecordService;
-import com.caimei.modules.coupon.service.CmCouponService;
-import com.caimei.modules.sys.utils.SMSUtils;
-import com.caimei.modules.user.entity.NewCmClub;
-import com.caimei.modules.user.service.NewCmClubService;
-import com.yeepay.shade.org.apache.commons.collections4.CollectionUtils;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
+import com.caimei.modules.coupon.dao.CmCouponClubDao;
+import com.caimei.modules.coupon.entity.CmCouponClub;
+import com.caimei.modules.coupon.entity.CmCouponRedemptionCode;
+import com.caimei.modules.coupon.service.CmCouponClubService;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.thinkgem.jeesite.common.web.BaseController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.servlet.mvc.support.RedirectAttributes;
-import com.thinkgem.jeesite.common.config.Global;
-import com.thinkgem.jeesite.common.persistence.Page;
-import com.thinkgem.jeesite.common.web.BaseController;
-import com.thinkgem.jeesite.common.utils.StringUtils;
-import com.caimei.modules.coupon.entity.CmCouponClub;
-import com.caimei.modules.coupon.service.CmCouponClubService;
-import java.util.Date;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
- * 采美优惠券活动签约会所Controller
- * @author lwt
- * @version 2018-09-29
+ * 优惠券管理Controller
+ *
+ * @author plf
+ * @version 2021-08-10
  */
 @Controller
 @RequestMapping(value = "${adminPath}/coupon/cmCouponClub")
 public class CmCouponClubController extends BaseController {
 
-	@Autowired
-	private CmCouponClubService cmCouponClubService;
-	@Autowired
-	private CmCouponRecordService cmCouponRecordService;
-	@Resource
-	private NewCmClubService newCmClubService;
-	@Autowired
-	private CmCouponService cmCouponService;
-	
-	@ModelAttribute
-	public CmCouponClub get(@RequestParam(required=false) String id) {
-		CmCouponClub entity = null;
-		if (StringUtils.isNotBlank(id)){
-			entity = cmCouponClubService.get(id);
-		}
-		if (entity == null){
-			entity = new CmCouponClub();
-		}
-		return entity;
-	}
-	
-	@RequiresPermissions("coupon:cmCouponClub:view")
-	@RequestMapping(value = {"list", ""})
-	public String list(CmCouponClub cmCouponClub, HttpServletRequest request, HttpServletResponse response, Model model) {
-		if (null != cmCouponClub.getStartTime() && !"".equals(cmCouponClub.getStartTime()) && !cmCouponClub.getStartTime().endsWith("00:00:00")) {
-			model.addAttribute("startTime", cmCouponClub.getStartTime());
-			cmCouponClub.setStartTime(cmCouponClub.getStartTime() + " 00:00:00");
-		}
-		if (null != cmCouponClub.getEndTime() && !"".equals(cmCouponClub.getEndTime()) && !cmCouponClub.getEndTime().endsWith("23:59:59")) {
-			model.addAttribute("endTime", cmCouponClub.getEndTime());
-			cmCouponClub.setEndTime(cmCouponClub.getEndTime() + " 23:59:59");
-		}
-		Page<CmCouponClub> page = cmCouponClubService.findPage(new Page<CmCouponClub>(request, response), cmCouponClub); 
-		model.addAttribute("page", page);
-		return "modules/coupon/cmCouponClubList";
-	}
-
-	@RequiresPermissions("coupon:cmCouponClub:view")
-	@RequestMapping(value = "form")
-	public String form(CmCouponClub cmCouponClub, Model model) {
-		model.addAttribute("cmCouponClub", cmCouponClub);
-		return "modules/coupon/cmCouponClubForm";
-	}
-
-	@RequiresPermissions("coupon:cmCouponClub:edit")
-	@RequestMapping(value = "save")
-	public String save(CmCouponClub cmCouponClub, Model model, RedirectAttributes redirectAttributes) {
-		if (!beanValidator(model, cmCouponClub)){
-			return form(cmCouponClub, model);
-		}
-		cmCouponClubService.save(cmCouponClub);
-		addMessage(redirectAttributes, "保存采美优惠券活动签约会所成功");
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponClub/?repage";
-	}
-	
-	@RequiresPermissions("coupon:cmCouponClub:delete")
-	@RequestMapping(value = "delete")
-	public String delete(CmCouponClub cmCouponClub, RedirectAttributes redirectAttributes) {
-		cmCouponClubService.deleteCmCouponClub(cmCouponClub);
-		addMessage(redirectAttributes, "删除采美优惠券活动签约会所成功");
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponClub/?repage";
-	}
-
-	@RequestMapping("showClubList")
-	public String showClubList(NewCmClub cmClub, HttpServletRequest request, HttpServletResponse response, Model model) {
-		Page<NewCmClub> page = cmCouponClubService.getClubList(new Page<>(request, response), cmClub);
-		model.addAttribute("page", page);
-		return "modules/coupon/cmClubListBox";
-	}
-
-	/**
-	 * 显示发送优惠券
-	 * @param request
-	 * @param response
-	 * @param model
-	 * @return
-	 */
-	@RequestMapping("showCouponList")
-	public String showCouponList(Integer userID,Integer pageSize,Integer pageNo,CmCoupon cmCoupon,HttpServletRequest request, HttpServletResponse response, Model model) {
-		Page<CmCoupon> page = cmCoupon.getPage();
-		if(null==pageNo)pageNo=1;
-		if(null==pageSize)pageSize=10;
-		if(null != page){
-			page.setPageSize(pageSize);
-			page.setPageNo(pageNo);
-		}else{
-			page = new Page<CmCoupon>();
-			page.setPageSize(pageSize);
-			page.setPageNo(pageNo);
-		}
-		cmCoupon.setPage(page);
-		List<CmCoupon> cmCouponList = cmCouponService.findCouponList(cmCoupon);
-		if(CollectionUtils.isNotEmpty(cmCouponList)){
-			for(CmCoupon c:cmCouponList){
-				c.setUserID(userID);
-			}
-		}
-		page.setList(cmCouponList);
-		model.addAttribute("userID", userID);
-		model.addAttribute("page", page);
-		return "modules/coupon/cmCouponListBox";
-	}
-
-	@RequestMapping("addClub")
-	public String addClub(Integer clubID, CmCouponClub couponClub){
-		NewCmClub club = newCmClubService.findClubById(clubID);
-		couponClub.setClubId(club.getClubID().longValue());
-		couponClub.setUserID(club.getUserID());
-		couponClub.setName(club.getName());
-		couponClub.setSname(club.getSname());
-		couponClub.setLinkMan(club.getLinkMan());
-		couponClub.setContractMobile(club.getContractMobile());
-		couponClub.setStatus("2");
-		cmCouponClubService.save(couponClub);
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponClub/?repage";
-	}
+    @Autowired
+    private CmCouponClubService cmCouponClubService;
+    @Autowired
+    private CmCouponClubDao cmCouponClubDao;
 
+    @ModelAttribute
+    public CmCouponClub get(@RequestParam(required = false) String id) {
+        CmCouponClub entity = null;
+        if (StringUtils.isNotBlank(id)) {
+            entity = cmCouponClubService.get(id);
+        }
+        if (entity == null) {
+            entity = new CmCouponClub();
+        }
+        return entity;
+    }
 
-	@RequestMapping("addCoupon")
-	public String addCoupon(CmCoupon cmCoupon){
-		Integer userID = cmCoupon.getUserID();//派送给哪个会所
-		NewCmClub newCmClub = newCmClubService.getclubByUserId(userID);
-		//获取同类型的优惠卷
-		List<CmCoupon> sendCoupon = cmCouponService.getSendCoupon(cmCoupon);
-		if(CollectionUtils.isNotEmpty(sendCoupon)){
-			for(CmCoupon c:sendCoupon){
-				CmCouponRecord cmCouponRecord  = new CmCouponRecord();
-				cmCouponRecord.setCouponCode(c.getCouponCode());
-				cmCouponRecord.setCouponAmount(c.getCouponAmount());
-				cmCouponRecord.setUseStartDate(c.getUseStartDate());
-				cmCouponRecord.setUseEndDate(c.getUseEndDate());
-				cmCouponRecord.setStatus("1");//已派送给会所
-				cmCouponRecord.setCouponType(c.getCouponType());
-				cmCouponRecord.setThreshold(c.getThreshold());
-				cmCouponRecord.setUseDescription(c.getUseDescription());
-				cmCouponRecord.setUserId(userID);
-				cmCouponRecordService.save(cmCouponRecord);
+    @RequestMapping(value = {"list", ""})
+    public String list(CmCouponClub cmCouponClub, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<CmCouponClub> page = cmCouponClubService.findPage(new Page<CmCouponClub>(request, response), cmCouponClub);
+        model.addAttribute("page", page);
+        model.addAttribute("cmCouponClub", cmCouponClub);
+        return "modules/coupon/cmCouponClubList";
+    }
 
-				//更新劵为已使用
-				CmCoupon coupon = new CmCoupon();
-				coupon.setCouponCode(c.getCouponCode());
-				coupon.setStatus("1");//已发送
-				coupon.setUpdateDate(new Date());
-				cmCouponService.updateStatus(coupon);
-			}
-		}
-		//发送短信通知
-		if(null != newCmClub){
-			String contractMobile = newCmClub.getContractMobile();
-			if(StringUtils.isNotEmpty(contractMobile)){
-				String content = "活动优惠券已放置您的账户,快分享给用户赚取返利吧,优惠券入口:进入微信商城>>点击我的优惠券,如有问题请致电采美0755-22907771";
-				SMSUtils.sendSms(contractMobile,content);
-			}
-		}
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponClub/?repage";
-	}
+    /**
+     * 领取用户列表
+     */
+    @RequestMapping("userList")
+    public String receivingUserList(CmCouponClub cmCouponClub, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<CmCouponClub> page = cmCouponClubService.receivingUserList(new Page<CmCouponClub>(request, response), cmCouponClub);
+        model.addAttribute("page", page);
+        return "modules/coupon/userCouponList";
+    }
 
-	@RequestMapping("dismissal")
-	public String dismissal(CmCouponClub couponClub){
-		if (couponClub != null) {
-			couponClub.setStatus("2");//解除签约
-			couponClub.setSignDate(null);
-			cmCouponClubService.update(couponClub);
-		}
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponClub/?repage";
-	}
+    /**
+     * 机构用户下优惠券
+     */
+    @RequestMapping("couponDetails")
+    public String clubCouponDetails(CmCouponClub cmCouponClub, HttpServletRequest request, HttpServletResponse response, Model model) {
+        List<CmCouponClub> couponClubList = cmCouponClubDao.receivingUserList(cmCouponClub);
+        cmCouponClub.setNum(couponClubList.get(0).getNum());
+        cmCouponClub.setClubName(couponClubList.get(0).getClubName());
+        Page<CmCouponClub> page = cmCouponClubService.findCouponDetails(new Page<CmCouponClub>(request, response), cmCouponClub);
+        model.addAttribute("page", page);
+        model.addAttribute("cmCouponClub", cmCouponClub);
+        return "modules/coupon/clubCouponDetails";
+    }
 
-	@RequestMapping("signing")
-	public String signing(CmCouponClub couponClub){
-		if (couponClub != null) {
-			couponClub.setStatus("1");//签约
-			couponClub.setSignDate(new Date());
-			cmCouponClubService.update(couponClub);
-		}
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponClub/?repage";
-	}
+    /**
+     * 兑换优惠券
+     */
+    @ResponseBody
+    @RequestMapping("/redeem")
+    public Map<String, Object> redeemCoupons(CmCouponRedemptionCode redemptionCode) {
+        Map<String, Object> map = new HashMap<>();
+        if (redemptionCode.getUserId() == null) {
+            map.put("code", -1);
+            map.put("msg", "参数异常");
+            return map;
+        }
+        if (StringUtils.isBlank(redemptionCode.getRedemptionCode())) {
+            map.put("code", -1);
+            map.put("msg", "请输入兑换码");
+            return map;
+        }
+        return cmCouponClubService.redeemCoupons(redemptionCode);
+    }
 
 }

+ 233 - 98
src/main/java/com/caimei/modules/coupon/web/CmCouponController.java

@@ -1,11 +1,21 @@
 package com.caimei.modules.coupon.web;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.caimei.modules.coupon.entity.ReadExcel;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.map.HashedMap;
+import com.caimei.modules.coupon.entity.CmCoupon;
+import com.caimei.modules.coupon.entity.CmCouponAssociate;
+import com.caimei.modules.coupon.entity.CmCouponRedemptionCode;
+import com.caimei.modules.coupon.service.CmCouponService;
+import com.caimei.modules.product.entity.Product;
+import com.caimei.modules.product.service.ProductService;
+import com.caimei.modules.user.dao.CmUserDao;
+import com.caimei.modules.user.dao.NewCmClubDao;
+import com.caimei.modules.user.entity.CmUser;
+import com.caimei.modules.user.entity.NewCmClub;
+import com.caimei.modules.user.entity.NewCmShop;
+import com.caimei.utils.AppUtils;
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.thinkgem.jeesite.common.web.BaseController;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -13,107 +23,232 @@ import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
-import com.thinkgem.jeesite.common.config.Global;
-import com.thinkgem.jeesite.common.persistence.Page;
-import com.thinkgem.jeesite.common.web.BaseController;
-import com.thinkgem.jeesite.common.utils.StringUtils;
-import com.caimei.modules.coupon.entity.CmCoupon;
-import com.caimei.modules.coupon.service.CmCouponService;
-
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 /**
- * 采美优惠券表(优惠券基本信息来自华熙提供)Controller
- * @author lwt
- * @version 2018-09-30
+ * 优惠券管理Controller
+ *
+ * @author plf
+ * @version 2021-08-02
  */
 @Controller
 @RequestMapping(value = "${adminPath}/coupon/cmCoupon")
 public class CmCouponController extends BaseController {
 
-	@Autowired
-	private CmCouponService cmCouponService;
-	
-	@ModelAttribute
-	public CmCoupon get(@RequestParam(required=false) String id) {
-		CmCoupon entity = null;
-		if (StringUtils.isNotBlank(id)){
-			entity = cmCouponService.get(id);
-		}
-		if (entity == null){
-			entity = new CmCoupon();
-		}
-		return entity;
-	}
-	
-	@RequiresPermissions("coupon:cmCoupon:view")
-	@RequestMapping(value = {"list", ""})
-	public String list(CmCoupon cmCoupon, HttpServletRequest request, HttpServletResponse response, Model model) {
-		Page<CmCoupon> page = cmCouponService.findPage(new Page<CmCoupon>(request, response), cmCoupon); 
-		model.addAttribute("page", page);
-		return "modules/coupon/cmCouponList";
-	}
-
-	@RequiresPermissions("coupon:cmCoupon:view")
-	@RequestMapping(value = "form")
-	public String form(CmCoupon cmCoupon, Model model) {
-		model.addAttribute("cmCoupon", cmCoupon);
-		return "modules/coupon/cmCouponForm";
-	}
-
-	@RequiresPermissions("coupon:cmCoupon:edit")
-	@RequestMapping(value = "save")
-	public String save(CmCoupon cmCoupon, Model model, RedirectAttributes redirectAttributes) {
-		if (!beanValidator(model, cmCoupon)){
-			return form(cmCoupon, model);
-		}
-		cmCouponService.save(cmCoupon);
-		addMessage(redirectAttributes, "保存成功");
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCoupon/?repage";
-	}
-	
-	@RequiresPermissions("coupon:cmCoupon:delete")
-	@RequestMapping(value = "delete")
-	public String delete(CmCoupon cmCoupon, RedirectAttributes redirectAttributes) {
-		cmCouponService.delete(cmCoupon);
-		addMessage(redirectAttributes, "删除成功");
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCoupon/?repage";
-	}
-
-
-	@ResponseBody
-	@RequestMapping(value = "import")
-	public Map<String,Object> cibeShopImport(@RequestParam(value="file",required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response, Model model){
-		Map<String,Object> map = new HashedMap();
-		try{
-			//创建处理EXCEL的类
-			ReadExcel readExcel = new ReadExcel();
-			List<CmCoupon> cmCoupons = readExcel.getExcelInfo(file);
-			for (CmCoupon cmCoupon : cmCoupons){
-				List<CmCoupon> cs = cmCouponService.findByCouponCode(cmCoupon.getCouponCode());
-				if(CollectionUtils.isEmpty(cs)) {
-					//优惠码在数据库中不存在,  直接插入优惠券信息
-					cmCouponService.save(cmCoupon);
-				} else {
-					//优惠码在数据库中存在,  更新优惠券信息
-					cmCoupon.setId(cs.get(0).getId());
-					cmCouponService.update(cmCoupon);
-				}
-			}
-			map.put("success",true);
-			map.put("msg", "上传成功");
-		}catch (Exception e){
-			e.printStackTrace();
-			logger.error(e.getMessage());
-			map.put("success",false);
-			map.put("msg", "上传失败");
-		}
-		return map;
-	}
+    @Autowired
+    private CmCouponService cmCouponService;
+    @Autowired
+    private CmUserDao cmUserDao;
+    @Autowired
+    private NewCmClubDao newCmClubDao;
+    @Autowired
+    private ProductService productService;
+
+    @ModelAttribute
+    public CmCoupon get(@RequestParam(required = false) String id) {
+        CmCoupon entity = null;
+        if (StringUtils.isNotBlank(id)) {
+            entity = cmCouponService.get(id);
+        }
+        if (entity == null) {
+            entity = new CmCoupon();
+        }
+        return entity;
+    }
+
+    @RequiresPermissions("coupon:cmCoupon:view")
+    @RequestMapping(value = {"list", ""})
+    public String list(CmCoupon cmCoupon, HttpServletRequest request, HttpServletResponse response, Model model) {
+        cmCoupon.setCouponsMode("0");
+        Page<CmCoupon> page = cmCouponService.findPage(new Page<CmCoupon>(request, response), cmCoupon);
+        model.addAttribute("page", page);
+        if (0 == cmCoupon.getCouponType()) {
+            //活动券
+            return "modules/coupon/cmCouponList";
+        } else if (1 == cmCoupon.getCouponType()) {
+            //品类券
+            return "modules/coupon/couponCategoryList";
+        } else if (2 == cmCoupon.getCouponType()) {
+            //用户专享券
+            return "modules/coupon/couponUserExclusiveList";
+        } else if (3 == cmCoupon.getCouponType()) {
+            //店铺券
+            return "modules/coupon/couponShopList";
+        } else {
+            //新用户券
+            return "modules/coupon/couponNewUserList";
+        }
+    }
+
+    @RequiresPermissions("coupon:cmCoupon:view")
+    @RequestMapping(value = "form")
+    public String form(CmCoupon cmCoupon, Model model) {
+        model.addAttribute("cmCoupon", cmCoupon);
+        if (0 == cmCoupon.getCouponType()) {
+            List<CmCouponAssociate> associateList = new ArrayList<>();
+            if (StringUtils.isNotBlank(cmCoupon.getId()) && "2".equals(cmCoupon.getProductType())) {
+                associateList = cmCouponService.findByProductType(cmCoupon);
+            }
+            model.addAttribute("associateList", associateList);
+            return "modules/coupon/cmCouponForm";
+        } else if (1 == cmCoupon.getCouponType()) {
+            return "modules/coupon/couponCategoryForm";
+        } else if (2 == cmCoupon.getCouponType()) {
+            CmUser cmUser = null;
+            if (cmCoupon.getUserId() != null) {
+                cmUser = cmUserDao.get(cmCoupon.getUserId().toString());
+                NewCmClub club = newCmClubDao.getclubByUserId(cmCoupon.getUserId());
+                cmUser.setShortName(club.getSname());
+            }
+            model.addAttribute("cmUser", cmUser);
+            return "modules/coupon/couponUserExclusiveForm";
+        } else if (3 == cmCoupon.getCouponType()) {
+            return "modules/coupon/couponShopForm";
+        } else {
+            return "modules/coupon/couponNewUserForm";
+        }
+    }
+
+    @RequestMapping(value = "save")
+    public String save(CmCoupon cmCoupon, Model model, RedirectAttributes redirectAttributes) {
+        if (!beanValidator(model, cmCoupon)) {
+            return form(cmCoupon, model);
+        }
+        cmCouponService.save(cmCoupon);
+        addMessage(redirectAttributes, "保存优惠券成功");
+        return "redirect:" + Global.getAdminPath() + "/coupon/cmCoupon/list?couponType=" + cmCoupon.getCouponType();
+    }
+
+    @RequestMapping(value = "delete")
+    public String delete(CmCoupon cmCoupon, RedirectAttributes redirectAttributes) {
+        cmCouponService.delete(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();
+    }
+
+    /**
+     * 选择商品页面
+     */
+    @RequestMapping(value = "toAddProduct")
+    public String toAddProduct(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
+        Page<Product> page = cmCouponService.findProductList(new Page<Product>(request, response), product);
+        model.addAttribute("page", page);
+        model.addAttribute("productIds", product.getProductIds());
+        return "/modules/coupon/toAddProduct";
+    }
+
+    /**
+     * 关闭优惠券
+     */
+    @RequestMapping("close")
+    public String close(CmCoupon cmCoupon, RedirectAttributes redirectAttributes) {
+        cmCouponService.close(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();
+    }
+
+    /**
+     * 选择机构页面
+     */
+    @RequestMapping("toAddClub")
+    public String toAddClub(CmUser cmUser, Model model, HttpServletRequest request, HttpServletResponse response) {
+        Page<CmUser> page = cmCouponService.findUserList(new Page<CmUser>(request, response), cmUser);
+        model.addAttribute("page", page);
+        return "/modules/coupon/toAddClub";
+    }
+
+    /**
+     * 选择供应商页面
+     */
+    @RequestMapping("toAddShop")
+    public String toAddShop(NewCmShop newCmShop, Model model, HttpServletRequest request, HttpServletResponse response) {
+        Page<NewCmShop> page = cmCouponService.findShopList(new Page<NewCmShop>(request, response), newCmShop);
+        model.addAttribute("page", page);
+        return "/modules/coupon/toAddShop";
+    }
+
+    /**
+     * 兑换码优惠券列表
+     */
+    @RequestMapping("codeCouponList")
+    public String redemptionCodeCouponList(CmCoupon cmCoupon, HttpServletRequest request, HttpServletResponse response, Model model) {
+        cmCoupon.setCouponsMode("1");
+        Page<CmCoupon> page = cmCouponService.findPage(new Page<CmCoupon>(request, response), cmCoupon);
+        model.addAttribute("page", page);
+        return "/modules/coupon/redemptionCodeCouponList";
+    }
+
+    /**
+     * 兑换码优惠券-添加编辑页面
+     */
+    @RequestMapping("codeCouponForm")
+    public String redemptionCodeCouponForm(CmCoupon cmCoupon, Model model) {
+        model.addAttribute("cmCoupon", cmCoupon);
+        if (cmCoupon != null && cmCoupon.getCouponType() != null) {
+            if (0 == cmCoupon.getCouponType()) {
+                List<CmCouponAssociate> associateList = new ArrayList<>();
+                if (StringUtils.isNotBlank(cmCoupon.getId()) && "2".equals(cmCoupon.getProductType())) {
+                    associateList = cmCouponService.findByProductType(cmCoupon);
+                }
+                model.addAttribute("associateList", associateList);
+            } else if (2 == cmCoupon.getCouponType()) {
+                CmUser cmUser = null;
+                if (cmCoupon.getUserId() != null) {
+                    cmUser = cmUserDao.get(cmCoupon.getUserId().toString());
+                    NewCmClub club = newCmClubDao.getclubByUserId(cmCoupon.getUserId());
+                    cmUser.setShortName(club.getSname());
+                }
+                model.addAttribute("cmUser", cmUser);
+            }
+        }
+        return "/modules/coupon/redemptionCodeCouponForm";
+    }
+
+    /**
+     * 兑换码优惠券-保存
+     */
+    @RequestMapping("codeCouponSave")
+    public String redemptionCodeCouponSave(CmCoupon cmCoupon, RedirectAttributes redirectAttributes) {
+        cmCouponService.redemptionCodeCouponSave(cmCoupon);
+        addMessage(redirectAttributes, "保存兑换优惠券成功");
+        return "redirect:" + Global.getAdminPath() + "/coupon/cmCoupon/codeCouponList";
+    }
+
+    /**
+     * 查看兑换码页面
+     */
+    @RequestMapping("redemptionCode")
+    public String redemptionCodeList(CmCouponRedemptionCode redemptionCode, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<CmCouponRedemptionCode> page = cmCouponService.redemptionCodeList(new Page<CmCouponRedemptionCode>(request, response), redemptionCode);
+        model.addAttribute("page", page);
+        model.addAttribute("redemptionCode", redemptionCode);
+        return "/modules/coupon/redemptionCodeList";
+    }
 
+    /**
+     * 查看商品优惠券详情
+     */
+    @RequestMapping("productDetails")
+    public String productCouponDetails(Integer productId, Integer userId, Model model) {
+        Product product = productService.get(productId.toString());
+        String wwwServer = Global.getConfig("wwwServer");
+        product.setMainImage(AppUtils.getImageURL("product", product.getMainImage(), 0, wwwServer));
+        List<CmCoupon> ordinaryCoupons = cmCouponService.findClubCouponList(product, userId);
+        List<CmCoupon> redeemCoupons = cmCouponService.findNotRedeemedCoupon(product);
+        model.addAttribute("product", product);
+        model.addAttribute("ordinaryCoupons", ordinaryCoupons);
+        model.addAttribute("redeemCoupons", redeemCoupons);
+        return "/modules/coupon/productCouponDetails";
+    }
 }

+ 0 - 173
src/main/java/com/caimei/modules/coupon/web/CmCouponOrderRecordController.java

@@ -1,173 +0,0 @@
-package com.caimei.modules.coupon.web;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.caimei.modules.common.utils.ExcelUtil;
-import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
-import com.caimei.modules.coupon.service.CmCouponOrderRecordService;
-import com.caimei.modules.order.entity.NewReceiptList;
-import com.thinkgem.jeesite.common.persistence.Page;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.servlet.mvc.support.RedirectAttributes;
-import com.thinkgem.jeesite.common.config.Global;
-import com.thinkgem.jeesite.common.web.BaseController;
-import com.thinkgem.jeesite.common.utils.StringUtils;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * 采美优惠券订单Controller
- * @author Lijun
- * @version 2018-10-09
- */
-@Controller
-@RequestMapping(value = "${adminPath}/coupon/cmCouponOrderRecord")
-public class CmCouponOrderRecordController extends BaseController {
-
-	@Autowired
-	private CmCouponOrderRecordService cmCouponOrderRecordService;
-	
-	@ModelAttribute
-	public CmCouponOrderRecord get(@RequestParam(required=false) String id) {
-		CmCouponOrderRecord entity = null;
-		if (StringUtils.isNotBlank(id)){
-			entity = cmCouponOrderRecordService.get(id);
-		}
-		if (entity == null){
-			entity = new CmCouponOrderRecord();
-		}
-		return entity;
-	}
-	
-	@RequiresPermissions("coupon:cmCouponOrderRecord:view")
-	@RequestMapping(value = {"list", ""})
-	public String list(CmCouponOrderRecord cmCouponOrderRecord,RedirectAttributes redirectAttributes, HttpServletRequest request, HttpServletResponse response, Model model) {
-		if (null != cmCouponOrderRecord.getStartTime() && !"".equals(cmCouponOrderRecord.getStartTime()) && !cmCouponOrderRecord.getStartTime().endsWith("00:00:00")) {
-			model.addAttribute("startTime", cmCouponOrderRecord.getStartTime());
-			cmCouponOrderRecord.setStartTime(cmCouponOrderRecord.getStartTime() + " 00:00:00");
-		}
-		if (null != cmCouponOrderRecord.getEndTime() && !"".equals(cmCouponOrderRecord.getEndTime()) && !cmCouponOrderRecord.getEndTime().endsWith("23:59:59")) {
-			model.addAttribute("endTime", cmCouponOrderRecord.getEndTime());
-			cmCouponOrderRecord.setEndTime(cmCouponOrderRecord.getEndTime() + " 23:59:59");
-		}
-
-		String searchflag = cmCouponOrderRecord.getSearchflag();
-		if(StringUtils.isNotEmpty(searchflag) && searchflag.length() != 2){//导出操作
-			cmCouponOrderRecord.setPage(null);
-			List<CmCouponOrderRecord> list = cmCouponOrderRecordService.findList(cmCouponOrderRecord);
-			if(CollectionUtils.isNotEmpty(list)){
-				for(CmCouponOrderRecord c:list){
-					c = setName(c);
-					String status = c.getStatus();
-					Date refundTime = c.getRefundTime();
-					if(StringUtils.equals("2",status)){
-						c.setStatus("付款成功");
-					}else if(StringUtils.equals("6",status)){
-						c.setStatus("退款成功");
-					}else{
-						c.setStatus("____");
-					}
-				}
-			}
-			//获取订单数据
-			StringBuffer sb = new StringBuffer();
-			sb.append("优惠券订单列表.xls");
-			String fileName = sb.toString();
-			String template = Global.getConfig("export.template");
-			String templateFileName = template+"/couponOrderList_template.xls";
-			// 导出订单列表
-			cmCouponOrderRecord.setStartTime(cmCouponOrderRecord.getStartTime() + " 00:00:00");
-			cmCouponOrderRecord.setEndTime(cmCouponOrderRecord.getEndTime() + " 23:59:59");
-			try {
-				new ExcelUtil().createExcel(templateFileName, list, fileName, response);
-			} catch (Exception e) {
-				addMessage(redirectAttributes, "优惠券订单导出异常!" + e.getMessage());
-				e.printStackTrace();
-			}
-		}
-		Page<CmCouponOrderRecord> page = cmCouponOrderRecordService.findPage(new Page<CmCouponOrderRecord>(request, response), cmCouponOrderRecord);
-		List<CmCouponOrderRecord> list = page.getList();
-		if(CollectionUtils.isNotEmpty(list) && list.size() > 0){
-			for(CmCouponOrderRecord cor : list){
-				setName(cor);
-			}
-		}
-
-		model.addAttribute("page", page);
-		return "modules/coupon/cmCouponOrderRecordList";
-	}
-
-	/**
-	 * 设置分享着名字(返利者)
-	 * @param c
-	 * @return
-	 */
-	public CmCouponOrderRecord setName(CmCouponOrderRecord c){
-		String clubName = c.getClubName();//分享劵人名字
-		String couponMobile = c.getCouponMobile();//分享劵人手机
-		//设置分享者名字
-		if(StringUtils.isEmpty(clubName)){
-			if(StringUtils.isEmpty(couponMobile)){//老用户自己不使用优惠券自己直接购买
-				//通过本次购买的订单客户的手机号,查找这个手机号之前使用本系统优惠券下单过的分享者
-				String customerMobile = c.getCustomerMobile();
-				List<CmCouponOrderRecord> listBuyAgain = cmCouponOrderRecordService.findListBuyAgain(customerMobile);
-				if(CollectionUtils.isNotEmpty(listBuyAgain)){//如果不存在则提示用户不存在
-					String name = "";
-					for(CmCouponOrderRecord cc:listBuyAgain){
-						String companyName = cc.getCompanyName();
-						if(StringUtils.isEmpty(companyName)){
-							name = cc.getCouponMobile();
-						}else{
-							name = companyName;
-							break;//优先使用名字其次号码
-						}
-					}
-					c.setRebateName(name);
-				}else{
-					c.setRebateName("无名氏");
-				}
-			}else{//扫码领取劵分享购买订单
-				c.setRebateName(couponMobile);
-			}
-		}else{//后台推送劵分享购买订单
-			c.setRebateName(clubName);
-		}
-		return c;
-	}
-
-	@RequiresPermissions("coupon:cmCouponOrderRecord:view")
-	@RequestMapping(value = "form")
-	public String form(CmCouponOrderRecord cmCouponOrderRecord, Model model) {
-		model.addAttribute("cmCouponOrderRecord", cmCouponOrderRecord);
-		return "modules/coupon/cmCouponOrderRecordForm";
-	}
-
-	@RequiresPermissions("coupon:cmCouponOrderRecord:edit")
-	@RequestMapping(value = "save")
-	public String save(CmCouponOrderRecord cmCouponOrderRecord, Model model, RedirectAttributes redirectAttributes) {
-		if (!beanValidator(model, cmCouponOrderRecord)){
-			return form(cmCouponOrderRecord, model);
-		}
-		cmCouponOrderRecordService.save(cmCouponOrderRecord);
-		addMessage(redirectAttributes, "保存采美优惠券订单成功");
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponOrderRecord/?repage";
-	}
-	
-	@RequiresPermissions("coupon:cmCouponOrderRecord:delete")
-	@RequestMapping(value = "delete")
-	public String delete(CmCouponOrderRecord cmCouponOrderRecord, RedirectAttributes redirectAttributes) {
-		cmCouponOrderRecordService.delete(cmCouponOrderRecord);
-		addMessage(redirectAttributes, "删除采美优惠券订单成功");
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponOrderRecord/?repage";
-	}
-
-}

+ 0 - 139
src/main/java/com/caimei/modules/coupon/web/CmCouponRecordController.java

@@ -1,139 +0,0 @@
-package com.caimei.modules.coupon.web;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-
-import com.caimei.modules.coupon.entity.CmCoupon;
-import com.caimei.modules.coupon.service.CmCouponService;
-import com.caimei.modules.user.dao.CmUserDao;
-import com.caimei.modules.user.entity.CmUser;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.servlet.mvc.support.RedirectAttributes;
-
-import com.thinkgem.jeesite.common.config.Global;
-import com.thinkgem.jeesite.common.persistence.Page;
-import com.thinkgem.jeesite.common.web.BaseController;
-import com.thinkgem.jeesite.common.utils.StringUtils;
-import com.caimei.modules.coupon.entity.CmCouponRecord;
-import com.caimei.modules.coupon.service.CmCouponRecordService;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * 采美优惠券使用记录表Controller
- * @author lwt
- * @version 2018-09-29
- */
-@Controller
-@RequestMapping(value = "${adminPath}/coupon/cmCouponRecord")
-public class CmCouponRecordController extends BaseController {
-
-	@Autowired
-	private CmCouponRecordService cmCouponRecordService;
-
-	@Resource
-	private CmCouponService cmCouponService;
-	@Autowired
-	private CmUserDao cmUserDao;
-	
-	@ModelAttribute
-	public CmCouponRecord get(@RequestParam(required=false) String id) {
-		CmCouponRecord entity = null;
-		if (StringUtils.isNotBlank(id)){
-			entity = cmCouponRecordService.get(id);
-		}
-		if (entity == null){
-			entity = new CmCouponRecord();
-		}
-		return entity;
-	}
-	
-	@RequiresPermissions("coupon:cmCouponRecord:view")
-	@RequestMapping(value = {"list", ""})
-	public String list(CmCouponRecord cmCouponRecord, HttpServletRequest request, HttpServletResponse response, Model model) {
-		Page<CmCouponRecord> page = cmCouponRecordService.findPage(new Page<CmCouponRecord>(request, response), cmCouponRecord);
-		List<CmCouponRecord> list = page.getList();
-		if(CollectionUtils.isNotEmpty(list) && list.size() > 0){
-			for(CmCouponRecord c:list){
-				//获取分享者名字
-				Integer userId = c.getUserId();
-				CmUser user = cmUserDao.get(String.valueOf(userId));
-				if(null != user){
-					c.setClubName(user.getUserName());
-				}
-
-				Integer sharerUserId = c.getSharerUserId();
-				if(null != sharerUserId){//该优惠券已被分享
-					CmUser cmUser = cmUserDao.get(String.valueOf(sharerUserId));
-					if(null != cmUser){
-						//企业和员工只存在一个人分享,二选一
-						String registerUserTypeID = cmUser.getRegisterUserTypeID();//注册用户类型3会所企业,23会所经理,33会所员工
-						if("3".equals(registerUserTypeID)){//3会所企业
-							c.setCompanyName(cmUser.getUserName());
-						}else{//员工(如果是员工则设置员工名字和企业名字)
-							String nick = cmUser.getNick();
-							if(StringUtils.isEmpty(nick)){
-								nick = cmUser.getUserName();
-								if(StringUtils.isEmpty(nick)){
-									nick = cmUser.getName();
-								}
-							}
-							c.setStaffName(nick);
-						}
-					}
-				}
-
-				//判断除已使用状态外是否存在过期优惠券(状态 1已发放 2已分享 3已使用)
-				String status = c.getStatus();
-				if(!StringUtils.equals("3",status)){
-					Date useEndDate = c.getUseEndDate();
-					int res = useEndDate.compareTo(new Date());//相等则返回0,useEndDate大返回1,否则返回-1;
-					if(res < 0){
-						c.setStatus("4");//显示状态4已过期
-					}
-				}
-			}
-		}
-		List<CmCoupon> cmCoupons = cmCouponService.statisticsCoupon();
-		model.addAttribute("page", page);
-		model.addAttribute("cmCoupons", cmCoupons);
-		return "modules/coupon/cmCouponRecordList";
-	}
-
-	@RequiresPermissions("coupon:cmCouponRecord:view")
-	@RequestMapping(value = "form")
-	public String form(CmCouponRecord cmCouponRecord, Model model) {
-		model.addAttribute("cmCouponRecord", cmCouponRecord);
-		return "modules/coupon/cmCouponRecordForm";
-	}
-
-	@RequiresPermissions("coupon:cmCouponRecord:edit")
-	@RequestMapping(value = "save")
-	public String save(CmCouponRecord cmCouponRecord, Model model, RedirectAttributes redirectAttributes) {
-		if (!beanValidator(model, cmCouponRecord)){
-			return form(cmCouponRecord, model);
-		}
-		cmCouponRecordService.save(cmCouponRecord);
-		addMessage(redirectAttributes, "保存采美优惠券使用记录表成功");
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponRecord/?repage";
-	}
-	
-	@RequiresPermissions("coupon:cmCouponRecord:delete")
-	@RequestMapping(value = "delete")
-	public String delete(CmCouponRecord cmCouponRecord, RedirectAttributes redirectAttributes) {
-		cmCouponRecordService.delete(cmCouponRecord);
-		addMessage(redirectAttributes, "删除采美优惠券使用记录表成功");
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponRecord/?repage";
-	}
-
-}

+ 0 - 153
src/main/java/com/caimei/modules/coupon/web/CmCouponRecordScanController.java

@@ -1,153 +0,0 @@
-package com.caimei.modules.coupon.web;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import com.caimei.modules.coupon.entity.CmCoupon;
-import com.caimei.modules.coupon.service.CmCouponService;
-import com.caimei.modules.user.dao.CmUserDao;
-import com.google.common.collect.Maps;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.servlet.mvc.support.RedirectAttributes;
-import com.thinkgem.jeesite.common.config.Global;
-import com.thinkgem.jeesite.common.persistence.Page;
-import com.thinkgem.jeesite.common.web.BaseController;
-import com.thinkgem.jeesite.common.utils.StringUtils;
-import com.caimei.modules.coupon.entity.CmCouponRecordScan;
-import com.caimei.modules.coupon.service.CmCouponRecordScanService;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 扫码推送优惠券Controller
- * @author LiJun
- * @version 2018-11-22
- */
-@Controller
-@RequestMapping(value = "${adminPath}/coupon/cmCouponRecordScan")
-public class CmCouponRecordScanController extends BaseController {
-
-	@Autowired
-	private CmCouponRecordScanService cmCouponRecordScanService;
-	@Autowired
-	private CmUserDao cmUserDao;
-	@Resource
-	private CmCouponService cmCouponService;
-	
-	@ModelAttribute
-	public CmCouponRecordScan get(@RequestParam(required=false) String id) {
-		CmCouponRecordScan entity = null;
-		if (StringUtils.isNotBlank(id)){
-			entity = cmCouponRecordScanService.get(id);
-		}
-		if (entity == null){
-			entity = new CmCouponRecordScan();
-		}
-		return entity;
-	}
-	
-	@RequiresPermissions("coupon:cmCouponRecordScan:view")
-	@RequestMapping(value = {"list", ""})
-	public String list(CmCouponRecordScan cmCouponRecordScan, HttpServletRequest request, HttpServletResponse response, Model model) {
-		Page<CmCouponRecordScan> page = cmCouponRecordScanService.findPage(new Page<CmCouponRecordScan>(request, response), cmCouponRecordScan); 
-		model.addAttribute("page", page);
-		return "modules/coupon/cmCouponRecordScanList";
-	}
-
-	/**
-	 * 公众号扫码优惠券列表
-	 * @param cmCouponRecordScan
-	 * @param request
-	 * @param response
-	 * @param model
-	 * @return
-	 */
-	@RequiresPermissions("coupon:cmCouponRecordScan:view")
-	@RequestMapping(value = {"scanCouponRecordList"})
-	public String scanCouponRecordList(CmCouponRecordScan cmCouponRecordScan, HttpServletRequest request, HttpServletResponse response, Model model) {
-		Page<CmCouponRecordScan> page = cmCouponRecordScanService.findPage(new Page<CmCouponRecordScan>(request, response), cmCouponRecordScan);
-		List<CmCouponRecordScan> list = page.getList();
-		if(CollectionUtils.isNotEmpty(list) && list.size() > 0){
-			for(CmCouponRecordScan c:list){
-				//判断除已使用状态外是否存在过期优惠券(状态 1未领取(已推送) 2已领取(输入手机号) 3已分享(可多次分享 ) 4已使用)
-				String status = c.getStatus();
-				if(!StringUtils.equals("4",status)){
-					Date useEndDate = c.getUseEndDate();
-					int res = useEndDate.compareTo(new Date());//相等则返回0,useEndDate大返回1,否则返回-1;
-					if(res < 0){
-						c.setStatus("5");//显示状态5已过期
-					}
-				}
-			}
-		}
-		List<CmCoupon> cmCoupons = cmCouponService.statisticsCoupon();
-		CmCouponRecordScan enabled = cmCouponRecordScanService.getEnabledStatus();
-
-		model.addAttribute("page", page);
-		model.addAttribute("cmCoupons", cmCoupons);
-		model.addAttribute("enabled", enabled);
-		return "modules/coupon/cmCouponRecordScanList";
-	}
-
-
-	@RequiresPermissions("coupon:cmCouponRecordScan:view")
-	@RequestMapping(value = "form")
-	public String form(CmCouponRecordScan cmCouponRecordScan, Model model) {
-		model.addAttribute("cmCouponRecordScan", cmCouponRecordScan);
-		return "modules/coupon/cmCouponRecordScanForm";
-	}
-
-	@RequiresPermissions("coupon:cmCouponRecordScan:edit")
-	@RequestMapping(value = "save")
-	public String save(CmCouponRecordScan cmCouponRecordScan, Model model, RedirectAttributes redirectAttributes) {
-		if (!beanValidator(model, cmCouponRecordScan)){
-			return form(cmCouponRecordScan, model);
-		}
-		cmCouponRecordScanService.save(cmCouponRecordScan);
-		addMessage(redirectAttributes, "保存成功");
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponRecordScan/?repage";
-	}
-	
-	@RequiresPermissions("coupon:cmCouponRecordScan:delete")
-	@RequestMapping(value = "delete")
-	public String delete(CmCouponRecordScan cmCouponRecordScan, RedirectAttributes redirectAttributes) {
-		cmCouponRecordScanService.delete(cmCouponRecordScan);
-		addMessage(redirectAttributes, "删除成功");
-		return "redirect:"+Global.getAdminPath()+"/coupon/cmCouponRecordScan/?repage";
-	}
-
-	/**
-	 * 批量修改启用、停用状态
-	 * @param enabledStatus
-	 * @param request
-	 * @param response
-	 * @return
-	 */
-	@RequiresPermissions("coupon:cmCouponRecordScan:edit")
-	@ResponseBody
-	@RequestMapping(value="updateEnabledStatus")
-	public Map<String, Object> updateEnabledStatus(String enabledStatus, HttpServletRequest request, HttpServletResponse response){
-		Map<String, Object> map = Maps.newLinkedHashMap();
-		try {
-			cmCouponRecordScanService.updateEnabledStatus(enabledStatus);//开关状态:0:启动,1:关闭
-			map.put("success",true);
-			map.put("msg", "修改成功");
-		} catch (Exception e) {
-			logger.debug(e.toString(),e);
-			map.put("success",false);
-			map.put("msg", "修改失败");
-		}
-		return map;
-	}
-
-}

+ 39 - 0
src/main/java/com/caimei/modules/order/dao/NewOrderDao.java

@@ -1,5 +1,7 @@
 package com.caimei.modules.order.dao;
 
+import com.caimei.modules.coupon.entity.CmCoupon;
+import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
 import com.caimei.modules.order.entity.CmFile;
 import com.caimei.modules.order.entity.NewOrder;
 import com.caimei.modules.order.entity.NewOrderProduct;
@@ -148,4 +150,41 @@ public interface NewOrderDao extends CrudDao<NewOrder> {
      * 定金商品撤销收款,用户余额扣除
      */
     void updateUserMoneyByUserId(Double payTotalFee, Integer userID);
+
+    /**
+     * 查询订单优惠券信息
+     *
+     * @param orderID
+     * @return
+     */
+    CmCouponOrderRecord findOrderCouponRecord(Integer orderID);
+
+    /**
+     * 查询优惠券信息
+     *
+     * @param clubCouponId
+     * @return
+     */
+    CmCoupon findClubCouponById(Integer clubCouponId);
+
+    /**
+     * 保存优惠券与订单关联信息
+     *
+     * @param orderRecord
+     */
+    void insertCouponOrderRecord(CmCouponOrderRecord orderRecord);
+
+    /**
+     * 更新优惠券与订单关联信息
+     *
+     * @param orderRecord
+     */
+    void updateCouponOrderRecord(CmCouponOrderRecord orderRecord);
+
+    /**
+     * 删除优惠券与订单关联信息
+     *
+     * @param id
+     */
+    void deleteCouponOrderRecord(Integer id);
 }

+ 18 - 0
src/main/java/com/caimei/modules/order/entity/CmMainReceiptExport.java

@@ -4,6 +4,7 @@ public class CmMainReceiptExport {
 	private String orderID;		// 主订单ID
 
 	private String userName;	//客户名
+	private String productNames; //商品名称
 	private String receiptDate;	//收款时间
 	private String payType;		//收款账号
 	private Double associateAmount;	//收款金额
@@ -11,6 +12,7 @@ public class CmMainReceiptExport {
 	private String status;      //订单状态
 	private String relationType; //关系类型:1返佣订单(返佣款)、2非返佣订单(订单款或者非订单款)
 	private String receiptAmount; //返佣订单收款金额
+	private String receiptType;		// 收款类型
 
 	public String getReceiptAmount() {
 		return receiptAmount;
@@ -83,4 +85,20 @@ public class CmMainReceiptExport {
 	public void setShopOrderID(String shopOrderID) {
 		this.shopOrderID = shopOrderID;
 	}
+
+	public String getProductNames() {
+		return productNames;
+	}
+
+	public void setProductNames(String productNames) {
+		this.productNames = productNames;
+	}
+
+	public String getReceiptType() {
+		return receiptType;
+	}
+
+	public void setReceiptType(String receiptType) {
+		this.receiptType = receiptType;
+	}
 }

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

@@ -1,6 +1,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.product.entity.CmPromotion;
 import com.thinkgem.jeesite.common.persistence.DataEntity;
 
@@ -132,6 +133,20 @@ public class NewOrder extends DataEntity<NewOrder> {
     private String associationType;//订单关联方式: 1手动 2自动
     private Double ableUserMoney; //当前下单用户可用余额
     private String organizeStoreName;//组织门店名称
+    /**
+     * 优惠券机构关联ID
+     */
+    private Integer clubCouponId;
+    private Double couponAmount;    //优惠券抵扣金额
+    private CmCouponOrderRecord couponOrderRecord;    //优惠券信息
+
+    public Integer getClubCouponId() {
+        return clubCouponId;
+    }
+
+    public void setClubCouponId(Integer clubCouponId) {
+        this.clubCouponId = clubCouponId;
+    }
 
     public List<CmPromotion> getPromotions() {
         return promotions;
@@ -1019,5 +1034,21 @@ public class NewOrder extends DataEntity<NewOrder> {
     public void setOrganizeStoreName(String organizeStoreName) {
         this.organizeStoreName = organizeStoreName;
     }
+
+    public Double getCouponAmount() {
+        return couponAmount;
+    }
+
+    public void setCouponAmount(Double couponAmount) {
+        this.couponAmount = couponAmount;
+    }
+
+    public CmCouponOrderRecord getCouponOrderRecord() {
+        return couponOrderRecord;
+    }
+
+    public void setCouponOrderRecord(CmCouponOrderRecord couponOrderRecord) {
+        this.couponOrderRecord = couponOrderRecord;
+    }
 }
 

+ 18 - 0
src/main/java/com/caimei/modules/order/entity/NewOrderProduct.java

@@ -111,6 +111,8 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private String secondHandType;//二手商品分类,1二手仪器,2临期产品,3其他
     private CmPromotion productPromotion; //下单时商品对应的促销活动
     private Integer ladderPriceFlag;        // 启用阶梯价格标识 0否 1是
+    private Integer couponsLogo;        //显示优惠券查看: 1不显示 2显示
+    private String commodityType;//商品属性:1产品,2仪器
 
     public Integer getLadderPriceFlag() {
         return ladderPriceFlag;
@@ -944,4 +946,20 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     public void setHeUserName(String heUserName) {
         this.heUserName = heUserName;
     }
+
+    public Integer getCouponsLogo() {
+        return couponsLogo;
+    }
+
+    public void setCouponsLogo(Integer couponsLogo) {
+        this.couponsLogo = couponsLogo;
+    }
+
+    public String getCommodityType() {
+        return commodityType;
+    }
+
+    public void setCommodityType(String commodityType) {
+        this.commodityType = commodityType;
+    }
 }

+ 26 - 1
src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java

@@ -1,6 +1,9 @@
 package com.caimei.modules.order.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.modules.coupon.dao.CmCouponClubDao;
+import com.caimei.modules.coupon.entity.CmCouponClub;
+import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
 import com.caimei.modules.miniprogram.utils.DateUtils;
 import com.caimei.modules.order.dao.*;
 import com.caimei.modules.order.entity.*;
@@ -83,6 +86,8 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
     private NewCmClubDao newCmClubDao;
     @Autowired
     private CmUserbeanshistoryDao cmUserbeanshistoryDao;
+    @Autowired
+    private CmCouponClubDao cmCouponClubDao;
 
 
     public CmReturnedPurchase get(String id) {
@@ -214,6 +219,10 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
             //减去促销满减金额
             returnedPurchaseFee = returnedPurchaseFee - newOrder.getPromotionFullReduction();
         }
+        if (newOrder.getCouponAmount() > 0) {
+            //减去优惠券金额
+            returnedPurchaseFee = MathUtil.sub(returnedPurchaseFee, newOrder.getCouponAmount()).doubleValue();
+        }
         cmReturnedPurchase.setReturnedPurchaseFee(returnedPurchaseFee);
         refundFee += getRefundFee(newOrder, cmReturnedPurchase, freightNum);
         //充值或缴纳订金订单
@@ -618,6 +627,19 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
                     cmUserDao.updateUserBeans(newOrder.getUserID(), userBeans);
                 }
             }
+            //优惠券退回
+            CmCouponOrderRecord couponOrderRecord = newOrder.getCouponOrderRecord();
+            if (newOrder.getCouponAmount() > 0 && couponOrderRecord != null) {
+                CmCouponClub couponClub = cmCouponClubDao.get(couponOrderRecord.getClubCouponId().toString());
+                couponClub.setOrderId(null);
+                couponClub.setReturnedId(Integer.valueOf(cmReturnedPurchase.getId()));
+                couponClub.setSource("3");
+                couponClub.setStatus("1");
+                couponClub.setCreateDate(new Date());
+                couponClub.setUseDate(null);
+                couponClub.setDelFlag("0");
+                cmCouponClubDao.insert(couponClub);
+            }
             //退款短信推送
             try {
                 if (user != null && StringUtils.isNotBlank(user.getBindMobile()) && "0".equals(newOrder.getRebateFlag())) {
@@ -751,7 +773,6 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
 
     @Transactional(readOnly = false)
     public void revokeApply(CmReturnedPurchase cmReturnedPurchase, HttpServletRequest request) {
-
         try {
             //1.撤销退款退货表审核通过信息
             cmReturnedPurchase.setConfirmReturnTime(null);
@@ -845,6 +866,10 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
             }
             cmUserbeanshistoryDao.updateBeansHistoryByReturned(newOrder.getOrderID());
             cmUserDao.updateUserBeans(newOrder.getUserID(), userBeans);
+            //撤销优惠券退款
+            if (newOrder.getCouponAmount() > 0) {
+                cmCouponClubDao.deleteByReturnedId(Integer.parseInt(cmReturnedPurchase.getId()));
+            }
             //修改子订单信息
             updateShopOrderAmount(newOrder.getOrderID());
         } catch (Exception e) {

+ 116 - 1
src/main/java/com/caimei/modules/order/service/NewOrderService.java

@@ -7,6 +7,13 @@ import com.caimei.exception.BusinessException;
 import com.caimei.modules.bulkpurchase.dao.OrderInvoiceDao;
 import com.caimei.modules.bulkpurchase.entity.OrderInvoice;
 import com.caimei.modules.bulkpurchase.service.OrderInvoiceService;
+import com.caimei.modules.coupon.dao.CmCouponClubDao;
+import com.caimei.modules.coupon.dao.CmCouponDao;
+import com.caimei.modules.coupon.entity.CmCoupon;
+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.miniprogram.utils.UploadPicUtils;
 import com.caimei.modules.order.dao.*;
 import com.caimei.modules.order.entity.*;
@@ -28,6 +35,8 @@ import com.caimei.modules.user.service.CmUserBalanceRecordService;
 import com.caimei.modules.user.service.CmUserService;
 import com.caimei.modules.user.utils.ReturnedPurchaseStatus;
 import com.caimei.modules.user.utils.UserUtils;
+import com.caimei.po.CouponClub;
+import com.caimei.po.CouponRedemptionCode;
 import com.caimei.po.ProductLadderPrice;
 import com.caimei.po.neworder.CmShopOrder;
 import com.caimei.utils.*;
@@ -105,6 +114,12 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
     private CmPromotionDao cmPromotionDao;
     @Autowired
     private CmSecondHandDetailDao cmSecondHandDetailDao;
+    @Autowired
+    private CmCouponDao cmCouponDao;
+    @Autowired
+    private CmCouponService cmCouponService;
+    @Autowired
+    private CmCouponClubDao cmCouponClubDao;
 
     @Transactional(readOnly = false)
     public void updateClauseContent(NewOrder newOrder) {
@@ -225,6 +240,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
             }
             newOrder.setPayStatus("1");
             newOrder.setZeroCostFlag(0);
+            newOrder.setCouponAmount(newOrder.getCouponAmount() == null ? 0d : newOrder.getCouponAmount());
             if (flag) {
                 // 新增
                 newOrderDao.insert(newOrder);
@@ -232,6 +248,33 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                 // 修改
                 newOrderDao.update(newOrder);
             }
+            //优惠券相关
+            CmCouponOrderRecord orderRecord = newOrderDao.findOrderCouponRecord(newOrder.getOrderID());
+            if (orderRecord != null && newOrder.getClubCouponId() == null) {
+                //修改订单时,不使用优惠券
+                newOrderDao.deleteCouponOrderRecord(orderRecord.getId());
+            }
+            if (newOrder.getClubCouponId() != null && newOrder.getClubCouponId() > 0) {
+                CmCoupon coupon = newOrderDao.findClubCouponById(newOrder.getClubCouponId());
+                if (coupon != null) {
+                    if (orderRecord == null) {
+                        orderRecord = new CmCouponOrderRecord();
+                        orderRecord.setCouponAmount(coupon.getCouponAmount());
+                        orderRecord.setTouchPrice(coupon.getTouchPrice());
+                        orderRecord.setClubCouponId(newOrder.getClubCouponId());
+                        orderRecord.setOrderId(newOrder.getOrderID());
+                        orderRecord.setCreateDate(new Date());
+                        orderRecord.setCouponType(coupon.getCouponType());
+                        newOrderDao.insertCouponOrderRecord(orderRecord);
+                    } else {
+                        orderRecord.setClubCouponId(newOrder.getClubCouponId());
+                        orderRecord.setCouponAmount(coupon.getCouponAmount());
+                        orderRecord.setTouchPrice(coupon.getTouchPrice());
+                        orderRecord.setCouponType(coupon.getCouponType());
+                        newOrderDao.updateCouponOrderRecord(orderRecord);
+                    }
+                }
+            }
             // 促销订单
             List<CmPromotion> promotionsList = new ArrayList<>();
             if (promotionsIds.size() > 0) {
@@ -966,6 +1009,13 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
         else
             newOrder.setRebateOrder("0");
         if (null != newOrder) {
+            if (newOrder.getCouponAmount() > 0) {
+                CmCouponOrderRecord couponRecord = newOrderDao.findOrderCouponRecord(newOrder.getOrderID());
+                if (couponRecord != null) {
+                    newOrder.setClubCouponId(couponRecord.getClubCouponId());
+                    newOrder.setCouponOrderRecord(couponRecord);
+                }
+            }
             //获取订单客户
             OrderUserInfo orderUserInfo = orderUserInfoService.findByOrderID(newOrder.getOrderID());
             NewCmClub club = newCmClubDao.getclubByUserId(newOrder.getUserID());
@@ -1074,6 +1124,13 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
         NewOrder newOrder = new NewOrder();
         if (null != cmReturnedPurchase) {
             newOrder = newOrderDao.get(cmReturnedPurchase.getOrderID().toString());
+            if (newOrder.getCouponAmount() > 0) {
+                CmCouponOrderRecord couponRecord = newOrderDao.findOrderCouponRecord(newOrder.getOrderID());
+                if (couponRecord != null) {
+                    newOrder.setClubCouponId(couponRecord.getClubCouponId());
+                    newOrder.setCouponOrderRecord(couponRecord);
+                }
+            }
             //获取订单客户
             OrderUserInfo orderUserInfo = orderUserInfoService.findByOrderID(cmReturnedPurchase.getOrderID());
             NewCmClub club = newCmClubDao.getclubByUserId(newOrder.getUserID());
@@ -1171,6 +1228,30 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
         order.setConfirmTime(curDateStr);
         if (order.getBalancePayFee() != null && order.getBalancePayFee() > 0) {
             saveDiscernReceipt(order.getBalancePayFee(), orderID);
+            //针对商品productId:6898,做兑换券操作(couponId:15)
+            if ("3".equals(order.getReceiptStatus())) {
+                List<NewOrderProduct> orderProducts = newOrderProductDao.findListByOrderID(orderID);
+                for (NewOrderProduct orderProduct : orderProducts) {
+                    if (orderProduct.getProductID().equals(6898)) {
+                        Integer num = orderProduct.getNum();
+                        for (int i = 0; i < num; i++) {
+                            CmCouponRedemptionCode redemptionCode = cmCouponClubDao.findRedemptionCode(15);
+                            if (redemptionCode != null) {
+                                CmCouponClub couponClub = new CmCouponClub();
+                                couponClub.setCouponId(redemptionCode.getCouponId());
+                                couponClub.setUserId(order.getUserID());
+                                couponClub.setSource("5");
+                                couponClub.setStatus("1");
+                                couponClub.setCreateDate(new Date());
+                                couponClub.setDelFlag("0");
+                                cmCouponClubDao.insert(couponClub);
+                                cmCouponClubDao.updateRedemptionCode(redemptionCode.getId(), couponClub.getId());
+                            }
+                        }
+                        break;
+                    }
+                }
+            }
         }
         newOrderDao.update(order);
     }
@@ -1276,6 +1357,21 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                 }
             }
         }
+        //优惠券退回
+        if (order.getCouponAmount() > 0 && !"0".equals(order.getStatus())) {
+            CmCouponOrderRecord couponRecord = newOrderDao.findOrderCouponRecord(order.getOrderID());
+            if (couponRecord != null) {
+                CmCouponClub couponClub = cmCouponClubDao.get(couponRecord.getClubCouponId().toString());
+                couponClub.setOrderId(null);
+                couponClub.setReturnedId(0);
+                couponClub.setSource("3");
+                couponClub.setStatus("1");
+                couponClub.setCreateDate(new Date());
+                couponClub.setUseDate(null);
+                couponClub.setDelFlag("0");
+                cmCouponClubDao.insert(couponClub);
+            }
+        }
     }
 
     /**
@@ -1972,7 +2068,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
         try {
             JSONObject paramJson = new JSONObject();
             paramJson.put("scene", shopOrderId);
-            paramJson.put("page", "supplier/pages/login/share-info");
+            paramJson.put("page", "pages/supplier/login/share-info");
             paramJson.put("width", "280px");
             byte[] bytes = HttpClientUtils.post(requestUrl, paramJson.toJSONString());
             String encode = DatatypeConverter.printBase64Binary(bytes);
@@ -2180,5 +2276,24 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
         }
         return logisticsRecords;
     }
+
+    public Map<String, Object> clubCouponList(Integer userId) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("code", 0);
+        List<CmCoupon> couponList = cmCouponDao.findClubCouponList(userId);
+        cmCouponService.setCouponCopywriting(couponList);
+        map.put("couponList", couponList);
+        return map;
+    }
+
+    @Transactional(readOnly = false)
+    public Boolean updateClubCoupon(Integer clubCouponId, Integer orderId) {
+        CmCoupon coupon = newOrderDao.findClubCouponById(clubCouponId);
+        if (coupon == null) {
+            return false;
+        }
+        cmCouponDao.updateClubCoupon(clubCouponId, orderId);
+        return true;
+    }
 }
 

+ 3 - 0
src/main/java/com/caimei/modules/order/utils/OrderUtil.java

@@ -303,6 +303,9 @@ public class OrderUtil {
         if ("17".equals(payType)) {
             return "个人网银";
         }
+        if ("18".equals(payType)) {
+            return "建设银行1854";
+        }
         return "";
     }
 

+ 12 - 5
src/main/java/com/caimei/modules/order/web/CmDiscernReceiptController.java

@@ -246,13 +246,20 @@ public class CmDiscernReceiptController extends BaseController {
 
             List<CmMainReceiptExport> list = cmDiscernReceiptService.exportTest(cmDiscernReceipt);
             for (CmMainReceiptExport bean : list) {
+                String productNames = bean.getProductNames();
+                String[] productNameArr = productNames.split(",");
+                for (int i = 0; i < productNameArr.length; i++) {
+                    productNameArr[i] = (i + 1) + "." + productNameArr[i] + "\r\n";
+                    productNames = i==0?productNameArr[i]:productNames + productNameArr[i];
+                }
+                bean.setProductNames(productNames);
                 bean.setPayType(OrderUtil.getPayTypeStr(bean.getPayType()));
             }
             //返佣数据
             List<CmMainReceiptExport> list1 = cmDiscernReceiptService.exportRebate(cmDiscernReceipt);
             for (CmMainReceiptExport export : list1) {
                 export.setPayType(OrderUtil.getPayTypeStr(export.getPayType()));
-                export.setOrderID(export.getOrderID() + "(返佣订单)");
+                export.setOrderID(export.getOrderID() + ("5".equals(export.getReceiptType())?"(供应商退款订单)":"(返佣订单)"));
                 list.add(export);
             }
             //非订单款
@@ -291,15 +298,15 @@ public class CmDiscernReceiptController extends BaseController {
             List<CmReceiptExportData> ListExportData2 = getListExportData(cmDiscernReceipt);
 
             objects.add(list);
-            objects.add(ListExportData1);
+            /*objects.add(ListExportData1);
             objects.add(ListExportData2);
             objects.add(getListOrderPayment(cmDiscernReceipt));
-            objects.add(purchases);
+            objects.add(purchases);*/
             listSheetNames.add("收款表");
-            listSheetNames.add("部分收款");
+            /*listSheetNames.add("部分收款");
             listSheetNames.add("已收款");
             listSheetNames.add("返佣订单");
-            listSheetNames.add("退款记录表");
+            listSheetNames.add("退款记录表");*/
 
             new ExcelUtil().createMultipleSheetsExcel(templateFileName, fileName, listSheetNames, objects, response);
         } catch (Exception e) {

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

@@ -10,7 +10,12 @@ import com.caimei.modules.bulkpurchase.service.CmFinanceChargeService;
 import com.caimei.modules.bulkpurchase.service.PurchaseProductService;
 import com.caimei.modules.common.utils.ExcelUtil;
 import com.caimei.modules.common.utils.UploadUtils;
-import com.caimei.modules.order.dao.*;
+import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
+import com.caimei.modules.coupon.service.CmCouponService;
+import com.caimei.modules.order.dao.CmDiscernReceiptDao;
+import com.caimei.modules.order.dao.CmReceiptOrderRelationDao;
+import com.caimei.modules.order.dao.CmReturnedPurchaseDao;
+import com.caimei.modules.order.dao.NewOrderProductDao;
 import com.caimei.modules.order.entity.*;
 import com.caimei.modules.order.service.*;
 import com.caimei.modules.order.utils.OrderUtil;
@@ -132,7 +137,7 @@ public class NewOrderController extends BaseController {
     @Autowired
     private PurchaseProductService purchaseProductService;
     @Autowired
-    private LogisticsRecordDao logisticsRecordDao;
+    private CmCouponService cmCouponService;
 
     @ModelAttribute
     public NewOrder get(@RequestParam(required = false) String id) {
@@ -236,8 +241,9 @@ public class NewOrderController extends BaseController {
                             orderProduct.setLadderPriceFlag(0);
                         }
                     }
+                    Product product = productDao.get(orderProduct.getProductID().toString());
+                    orderProduct.setCommodityType(product.getCommodityType());
                     if (null == orderPromotions) {
-                        Product product = productDao.get(orderProduct.getProductID().toString());
                         if (1 == orderProduct.getLadderPriceFlag() && "1".equals(product.getLadderPriceFlag())) {
                             // 查询商品当前阶梯价格
                             List<ProductLadderPrice> ladderPriceList = purchaseProductService.findLadderPriceList(orderProduct.getProductID().longValue());
@@ -257,6 +263,13 @@ public class NewOrderController extends BaseController {
                             orderProduct.setIsActProduct("0");
                         }
                     }
+                    //是否有优惠券可以查看
+                    Boolean couponsLogo = cmCouponService.setCouponsLogo(newOrder.getUserID(), orderProduct.getProductID(), orderProduct.getShopID(), product.getCommodityType());
+                    if (couponsLogo) {
+                        orderProduct.setCouponsLogo(2);
+                    } else {
+                        orderProduct.setCouponsLogo(1);
+                    }
                 }
             }
             if (null != newOrder.getOrderID() && null != newOrder.getClauseName()) {
@@ -534,6 +547,15 @@ public class NewOrderController extends BaseController {
     @RequestMapping("confirmOrder")
     public String confirmOrder(Integer orderID, Model model, RedirectAttributes redirectAttributes) {
         NewOrder order = newOrderService.get(orderID + "");
+        //优惠券确认消耗
+        CmCouponOrderRecord orderRecord = order.getCouponOrderRecord();
+        if (order.getCouponAmount() > 0 && orderRecord != null) {
+            Boolean isCoupon = newOrderService.updateClubCoupon(orderRecord.getClubCouponId(), orderID);
+            if (!isCoupon) {
+                addMessage(redirectAttributes, "订单内优惠券已被使用");
+                return "redirect:" + Global.getAdminPath() + "/order/detail/?id=" + orderID;
+            }
+        }
         //————————————————————————————-----
         //确认订单时处理买家商品价格库信息
         final Integer userID;
@@ -675,7 +697,7 @@ public class NewOrderController extends BaseController {
                 u.setUserMoney(userMoney - balancePayFee);
                 cmUserDao.updateMoney(u);
             }
-        }//
+        }
         addMessage(redirectAttributes, "确认订单成功");
         return "redirect:" + Global.getAdminPath() + "/order/detail/?id=" + orderID;
     }
@@ -2116,4 +2138,19 @@ public class NewOrderController extends BaseController {
         model.addAttribute("orderId", orderId);
         return "modules/order/qualificationInfo";
     }
+
+    /**
+     * 获取当前机构下所有已领取优惠券
+     */
+    @ResponseBody
+    @RequestMapping("clubCouponList")
+    public Map<String, Object> clubCouponList(Integer userId) {
+        Map<String, Object> map = new HashMap<>();
+        if (null == userId) {
+            map.put("code", -1);
+            map.put("msg", "参数异常");
+            return map;
+        }
+        return newOrderService.clubCouponList(userId);
+    }
 }

+ 46 - 44
src/main/java/com/caimei/modules/product/service/CmIkDictService.java

@@ -1,20 +1,19 @@
 package com.caimei.modules.product.service;
 
-import java.util.Date;
-import java.util.List;
-
-import com.caimei.modules.coupon.entity.CmCouponRecordScan;
+import com.caimei.modules.product.dao.CmIkDictDao;
+import com.caimei.modules.product.entity.CmIkDict;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.service.CrudService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.thinkgem.jeesite.common.persistence.Page;
-import com.thinkgem.jeesite.common.service.CrudService;
-import com.caimei.modules.product.entity.CmIkDict;
-import com.caimei.modules.product.dao.CmIkDictDao;
+import java.util.Date;
+import java.util.List;
 
 /**
  * IK扩展字典信息Service
+ *
  * @author zcp
  * @version 2017-11-22
  */
@@ -22,43 +21,46 @@ import com.caimei.modules.product.dao.CmIkDictDao;
 @Transactional(readOnly = false)
 public class CmIkDictService extends CrudService<CmIkDictDao, CmIkDict> {
 
-	@Autowired
-	CmIkDictDao cmIkDictDao;
-	public CmIkDict get(String id) {
-		return super.get(id);
-	}
-	
-	public List<CmIkDict> findList(CmIkDict cmIkDict) {
-		return super.findList(cmIkDict);
-	}
-	
-	public Page<CmIkDict> findPage(Page<CmIkDict> page, CmIkDict cmIkDict) {
-		return super.findPage(page, cmIkDict);
-	}
-	
-	@Transactional(readOnly = false)
-	public void save(CmIkDict cmIkDict) {
-		super.save(cmIkDict);
-	}
-	@Transactional(readOnly = false)
-	public void update(CmIkDict cmIkDict) {
-		cmIkDictDao.update(cmIkDict);
-	}
-	@Transactional(readOnly = false)
-	public void delete(CmIkDict cmIkDict) {
-		super.delete(cmIkDict);
-	}
+    @Autowired
+    CmIkDictDao cmIkDictDao;
+
+    public CmIkDict get(String id) {
+        return super.get(id);
+    }
+
+    public List<CmIkDict> findList(CmIkDict cmIkDict) {
+        return super.findList(cmIkDict);
+    }
+
+    public Page<CmIkDict> findPage(Page<CmIkDict> page, CmIkDict cmIkDict) {
+        return super.findPage(page, cmIkDict);
+    }
+
+    @Transactional(readOnly = false)
+    public void save(CmIkDict cmIkDict) {
+        super.save(cmIkDict);
+    }
+
+    @Transactional(readOnly = false)
+    public void update(CmIkDict cmIkDict) {
+        cmIkDictDao.update(cmIkDict);
+    }
+
+    @Transactional(readOnly = false)
+    public void delete(CmIkDict cmIkDict) {
+        super.delete(cmIkDict);
+    }
+
+    public void updateEnabledStatus(String enabledStatus) {
+        cmIkDictDao.updateEnabledStatus(enabledStatus);
+    }
 
-	public void updateEnabledStatus(String enabledStatus){
-		cmIkDictDao.updateEnabledStatus(enabledStatus);
-	}
+    public Integer getEnabledStatus() {
+        return cmIkDictDao.getEnabledStatus();
+    }
 
-	public Integer getEnabledStatus(){
-		return  cmIkDictDao.getEnabledStatus();
-	}
+    public Date getEnabledTime() {
+        return cmIkDictDao.getEnabledTime();
+    }
 
-	public Date getEnabledTime(){
-		return  cmIkDictDao.getEnabledTime();
-	}
-	
 }

+ 9 - 0
src/main/java/com/caimei/modules/user/entity/CmUser.java

@@ -107,6 +107,7 @@ public class CmUser extends DataEntity<CmUser> {
     private String province; //省
     private String address;        // 详细地址
     private boolean pending = false; //是否有待审核提现
+    private String shortName;   //机构简称
 
     public CmUser() {
         super();
@@ -834,4 +835,12 @@ public class CmUser extends DataEntity<CmUser> {
     public void setPending(boolean pending) {
         this.pending = pending;
     }
+
+    public String getShortName() {
+        return shortName;
+    }
+
+    public void setShortName(String shortName) {
+        this.shortName = shortName;
+    }
 }

+ 1 - 1
src/main/java/com/caimei/modules/user/entity/NewCmShop.java

@@ -112,7 +112,7 @@ public class NewCmShop extends DataEntity<NewCmShop> {
     private String productionLicense;//生产许可
     private String sanitationPermit;//卫生许可
     private String taxPermit;//税务许可
-	private String commercialCode; //分账方,子商户商编
+    private String commercialCode; //分账方,子商户商编
     private String socialCreditCode; //统一社会信用代码
 
     /**

+ 13 - 1
src/main/java/com/caimei/modules/user/service/NewCmShopService.java

@@ -119,7 +119,19 @@ public class NewCmShopService extends CrudService<NewCmShopDao, NewCmShop> {
 
 	@Transactional(readOnly = false)
 	public void update(NewCmShop newCmShop){
-		// 供应商基础信息保存
+	    // 供应商logo
+		String logo = newCmShop.getLogo();
+		if(StringUtils.isNotEmpty(logo)){
+			logo = getImageUrl(logo);
+			newCmShop.setLogo(logo);
+		}
+		// 营业执照
+        String businessLicenseImage = newCmShop.getBusinessLicenseImage();
+        if (StringUtils.isNotEmpty(businessLicenseImage)) {
+			businessLicenseImage = getImageUrl(businessLicenseImage);
+            newCmShop.setBusinessLicenseImage(businessLicenseImage);
+        }
+        // 供应商基础信息保存
 		newCmShopDao.update(newCmShop);
 		//清除所有供应商证书再保存
 		newCmShopDao.deleteCert(newCmShop.getShopID());

BIN
src/main/resources/export/discern_receipt_export.xls


+ 194 - 158
src/main/resources/mappings/modules/archive/CmOrderArchiveMapper.xml

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.modules.archive.dao.CmOrderArchiveDao">
-    
-	<sql id="cmOrderArchiveColumns">
-		a.id AS "id",
+
+    <sql id="cmOrderArchiveColumns">
+        a.id AS "id",
 		a.archiveNo AS "archiveNo",
 		a.title AS "title",
 		a.shopOrderId AS "shopOrderId",
@@ -14,171 +14,207 @@
 		a.remark AS "remark",
 		a.addTime AS "addTime",
 		so.orderID AS "orderId"
-	</sql>
-	
-	<sql id="cmOrderArchiveJoins">
-		left join cm_shop_order so on a.shopOrderId = so.shopOrderID
-	</sql>
-    
-	<select id="get" resultType="CmOrderArchive">
-		SELECT 
-			<include refid="cmOrderArchiveColumns"/>
-		FROM cm_order_archive a
-		<include refid="cmOrderArchiveJoins"/>
-		WHERE a.id = #{id}
-	</select>
-	
-	<select id="findList" resultType="CmOrderArchive">
-		SELECT 
-			<include refid="cmOrderArchiveColumns"/>
-		FROM cm_order_archive a
-		<include refid="cmOrderArchiveJoins"/>
-		<where>
-			
-			<if test="archiveNo != null and archiveNo != ''">
-				AND a.archiveNo LIKE 
-					<if test="dbName == 'oracle'">'%'||#{archiveNo}||'%'</if>
-					<if test="dbName == 'mssql'">'%'+#{archiveNo}+'%'</if>
-					<if test="dbName == 'mysql'">concat('%',#{archiveNo},'%')</if>
-			</if>
-			<if test="title != null and title != ''">
-				AND a.title LIKE 
-					<if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
-					<if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
-					<if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
-			</if>
-			<if test="shopOrderId != null and shopOrderId != ''">
-				AND a.shopOrderId = #{shopOrderId}
-			</if>
-			<if test="shopName != null and shopName != ''">
-				AND a.shopName LIKE 
-					<if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
-					<if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
-					<if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
-			</if>
-			<if test="clubName != null and clubName != ''">
-				AND a.clubName LIKE 
-					<if test="dbName == 'oracle'">'%'||#{clubName}||'%'</if>
-					<if test="dbName == 'mssql'">'%'+#{clubName}+'%'</if>
-					<if test="dbName == 'mysql'">concat('%',#{clubName},'%')</if>
-			</if>
-			<if test="tag != null and tag != ''">
-				AND a.tag LIKE 
-					<if test="dbName == 'oracle'">'%'||#{tag}||'%'</if>
-					<if test="dbName == 'mssql'">'%'+#{tag}+'%'</if>
-					<if test="dbName == 'mysql'">concat('%',#{tag},'%')</if>
-			</if>
-			<if test="rebateFlag != null">
-				AND a.rebateFlag = #{rebateFlag}
-			</if>
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
+    </sql>
+
+    <sql id="cmOrderArchiveJoins">
+        left join cm_shop_order so on a.shopOrderId = so.shopOrderID
+    </sql>
+
+    <select id="get" resultType="CmOrderArchive">
+        SELECT
+        <include refid="cmOrderArchiveColumns"/>
+        FROM cm_order_archive a
+        <include refid="cmOrderArchiveJoins"/>
+        WHERE a.id = #{id}
+    </select>
+
+    <select id="findList" resultType="CmOrderArchive">
+        SELECT
+        <include refid="cmOrderArchiveColumns"/>
+        FROM cm_order_archive a
+        <include refid="cmOrderArchiveJoins"/>
+        <where>
+
+            <if test="archiveNo != null and archiveNo != ''">
+                AND a.archiveNo LIKE
+                <if test="dbName == 'oracle'">'%'||#{archiveNo}||'%'</if>
+                <if test="dbName == 'mssql'">'%'+#{archiveNo}+'%'</if>
+                <if test="dbName == 'mysql'">concat('%',#{archiveNo},'%')</if>
+            </if>
+            <if test="title != null and title != ''">
+                AND a.title LIKE
+                <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
+                <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
+                <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
+            </if>
+            <if test="shopOrderId != null and shopOrderId != ''">
+                AND a.shopOrderId = #{shopOrderId}
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND a.shopName LIKE
+                <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
+                <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
+                <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
+            </if>
+            <if test="clubName != null and clubName != ''">
+                AND a.clubName LIKE
+                <if test="dbName == 'oracle'">'%'||#{clubName}||'%'</if>
+                <if test="dbName == 'mssql'">'%'+#{clubName}+'%'</if>
+                <if test="dbName == 'mysql'">concat('%',#{clubName},'%')</if>
+            </if>
+            <if test="tag != null and tag != ''">
+                AND a.tag LIKE
+                <if test="dbName == 'oracle'">'%'||#{tag}||'%'</if>
+                <if test="dbName == 'mssql'">'%'+#{tag}+'%'</if>
+                <if test="dbName == 'mysql'">concat('%',#{tag},'%')</if>
+            </if>
+            <if test="rebateFlag != null">
+                AND a.rebateFlag = #{rebateFlag}
+            </if>
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
                 order by a.id desc
-			</otherwise>
-		</choose>
-	</select>
-	
-	<select id="findAllList" resultType="CmOrderArchive">
-		SELECT 
-			<include refid="cmOrderArchiveColumns"/>
-		FROM cm_order_archive a
-		<include refid="cmOrderArchiveJoins"/>
-		<where>
-			
-		</where>		
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	<select id="getArchiveFileList" resultType="com.caimei.modules.archive.entity.CmOrderArchiveFile">
-		select id, fileName, ossName, ossUrl
-		from cm_order_archive_file
-		where orderArchiveId = #{archiveId}
-	</select>
-	<select id="getArchiveFileById" resultType="com.caimei.modules.archive.entity.CmOrderArchiveFile">
-		select id, fileName, ossName
-		from cm_order_archive_file
-		where id = #{fileId}
-	</select>
-	<select id="getAllFileIds" resultType="java.lang.String">
-		select GROUP_CONCAT(id) from cm_order_archive_file where orderArchiveId = #{orderArchiveId} group by orderArchiveId
-	</select>
-	<select id="checkFileName" resultType="java.lang.Integer">
-		select id from cm_order_archive_file
-		<where>
-			fileName = #{fileName} and (
-			<if test="orderArchiveId != null">
-				orderArchiveId = #{orderArchiveId}
-			</if>
-			<if test="fileIds != null and fileIds != ''">
-				or id in
-				<foreach collection="fileIds.split(',')" item="fileId" index="index" open="(" separator="," close=")" >
-					#{fileId}
-				</foreach>
-			</if>
-			)
-		</where>
-	</select>
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findAllList" resultType="CmOrderArchive">
+        SELECT
+        <include refid="cmOrderArchiveColumns"/>
+        FROM cm_order_archive a
+        <include refid="cmOrderArchiveJoins"/>
+        <where>
+
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
+    <select id="getArchiveFileList" resultType="com.caimei.modules.archive.entity.CmOrderArchiveFile">
+        select id, fileName, ossName, ossUrl
+        from cm_order_archive_file
+        where orderArchiveId = #{archiveId}
+    </select>
+    <select id="getArchiveFileById" resultType="com.caimei.modules.archive.entity.CmOrderArchiveFile">
+        select id, fileName, ossName
+        from cm_order_archive_file
+        where id = #{fileId}
+    </select>
+    <select id="getAllFileIds" resultType="java.lang.String">
+        select GROUP_CONCAT(id)
+        from cm_order_archive_file
+        where orderArchiveId = #{orderArchiveId}
+        group by orderArchiveId
+    </select>
+    <select id="checkFileName" resultType="java.lang.Integer">
+        select id from cm_order_archive_file
+        <where>
+            fileName = #{fileName}
+            <if test="orderArchiveId != null || (fileIds != null and fileIds != '')">
+                and(
+                <if test="orderArchiveId != null || (fileIds != null and fileIds != '')">
+                    orderArchiveId = #{orderArchiveId}
+                </if>
+                <if test="fileIds != null and fileIds != ''">
+                    or id in
+                    <foreach collection="fileIds.split(',')" item="fileId" index="index" open="(" separator=","
+                             close=")">
+                        #{fileId}
+                    </foreach>
+                </if>
+                )
+            </if>
+        </where>
+    </select>
     <select id="checkShopOrderIdExist" resultType="java.lang.Integer">
-        select so.shopOrderID from cm_shop_order so
+        select so.shopOrderID
+        from cm_shop_order so
         where so.shopOrderID = #{shopOrderId}
     </select>
 
     <select id="checkShopOrderIdAble" resultType="java.lang.Integer">
-        select so.shopOrderID from cm_shop_order so
+        select so.shopOrderID
+        from cm_shop_order so
         where so.shopOrderID = #{shopOrderId}
-        and so.shopOrderID not in
-        (select a.shopOrderId from cm_order_archive a
-        where a.shopOrderId is not null) limit 1
+          and so.shopOrderID not in
+              (select a.shopOrderId
+               from cm_order_archive a
+               where a.shopOrderId is not null)
+        limit 1
+    </select>
+    <select id="getShopNameByShopOrderId" resultType="java.lang.String">
+        select s.name
+        from cm_shop_order cso
+                 left join shop s on cso.shopID = s.shopID
+        where cso.shopOrderID = #{shopOrderId}
+    </select>
+    <select id="getClubNameByShopOrderId" resultType="java.lang.String">
+        select c.name
+        from cm_shop_order cso
+                 left join club c on cso.clubID = c.clubID
+        where cso.shopOrderID = #{shopOrderId}
     </select>
 
-    <insert id="insert" parameterType="CmOrderArchive"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO cm_order_archive(
-			archiveNo,
-			addTime
-		) VALUES (
-			#{archiveNo},
-			#{addTime}
-		)
-	</insert>
-	<insert id="insertArchiveFile" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
-		insert into cm_order_archive_file(fileName, ossName, ossUrl, uploadTime)
-		values (#{fileName}, #{ossName}, #{ossUrl}, #{uploadTime})
-	</insert>
+    <insert id="insert" parameterType="CmOrderArchive" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO cm_order_archive(archiveNo,
+                                     title,
+                                     shopOrderId,
+                                     shopName,
+                                     clubName,
+                                     tag,
+                                     rebateFlag,
+                                     remark,
+                                     addTime)
+        VALUES (#{archiveNo},
+                #{title},
+                #{shopOrderId},
+                #{shopName},
+                #{clubName},
+                #{tag},
+                #{rebateFlag},
+                #{remark},
+                #{addTime})
+    </insert>
+    <insert id="insertArchiveFile" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
+        insert into cm_order_archive_file(fileName, ossName, ossUrl, uploadTime)
+        values (#{fileName}, #{ossName}, #{ossUrl}, #{uploadTime})
+    </insert>
 
-	<update id="update">
-		UPDATE cm_order_archive SET 	
-			title = #{title},
-			shopOrderId = #{shopOrderId},
-			shopName = #{shopName},
-			clubName = #{clubName},
-			tag = #{tag},
-			rebateFlag = #{rebateFlag},
-			remark = #{remark}
-		WHERE id = #{id}
-	</update>
-	<update id="updateArchiveFile">
-		update cm_order_archive_file
-		set orderArchiveId = #{orderArchiveId}
-		where id = #{fileId}
-	</update>
+    <update id="update">
+        UPDATE cm_order_archive
+        SET archiveNo   = #{archiveNo},
+            title       = #{title},
+            shopOrderId = #{shopOrderId},
+            shopName    = #{shopName},
+            clubName    = #{clubName},
+            tag         = #{tag},
+            rebateFlag  = #{rebateFlag},
+            remark      = #{remark}
+        WHERE id = #{id}
+    </update>
+    <update id="updateArchiveFile">
+        update cm_order_archive_file
+        set orderArchiveId = #{orderArchiveId}
+        where id = #{fileId}
+    </update>
 
-	<delete id="delete">
-		DELETE FROM cm_order_archive
-		WHERE id = #{id}
-	</delete>
-	<delete id="deleteArchiveFile">
-		delete
-		from cm_order_archive_file
-		where id = #{fileId}
-	</delete>
+    <delete id="delete">
+        DELETE
+        FROM cm_order_archive
+        WHERE id = #{id}
+    </delete>
+    <delete id="deleteArchiveFile">
+        delete
+        from cm_order_archive_file
+        where id = #{fileId}
+    </delete>
 
 </mapper>

+ 1 - 29
src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml

@@ -40,42 +40,14 @@
 	<select id="findProductList" resultType="PurchaseProduct">
 
 	</select>
-	<!--<select id="findList" resultType="PurchaseProduct">
-		SELECT
-			<include refid="purchaseProductColumns"/>
-		FROM bp_product a
-		<include refid="purchaseProductJoins"/>
-		<where>
 
-			<if test="name != null and name != ''">
-				AND a.name LIKE
-					<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
-					<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
-					<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
-			</if>
-			<if test="productId != null and productId != ''">
-				AND a.productId = #{productId}
-			</if>
-			<if test="shopName != null and shopName != ''">
-				AND a.shopName = #{shopName}
-			</if>
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	-->
 	<select id="findList" resultType="PurchaseProduct" >
 		SELECT b.name shopName ,b.`shopID` shopId,a.name purchaseProductName,
 		a.`price1` price,a.`productID` productId,a.productCode productNo,a.mainImage image
 		,a.costCheckFlag costCheckFlag,a.costPrice costPrice,a.costProportional costProportional, a.price0 AS normalPrice
 		,a.ladderPriceFlag as ladderPriceFlag
 		,a.includedTax AS includedTax, a.invoiceType AS invoiceType, a.taxPoint AS taxRate, a.supplierTaxPoint AS supplierTaxRate,
-		a.minBuyNumber AS num
+		a.minBuyNumber AS num, a.commodityType
 		FROM product a LEFT JOIN shop b ON b.shopID=a.shopID
 		<where>
 			<if test="purchaseProductName != null and purchaseProductName != ''">

+ 182 - 107
src/main/resources/mappings/modules/coupon/CmCouponClubMapper.xml

@@ -4,21 +4,19 @@
     
 	<sql id="cmCouponClubColumns">
 		a.id AS "id",
-		a.clubId AS "clubId",
-		a.name AS "name",
-		a.sname AS "sname",
-		a.linkMan AS "linkMan",
-		a.contractMobile AS "contractMobile",
-		a.signDate AS "signDate",
+		a.userId AS "userId",
+		a.couponId AS "couponId",
+		a.orderId AS "orderId",
+		a.source AS "source",
 		a.status AS "status",
-		a.createBy AS "createBy.id",
 		a.createDate AS "createDate",
-		a.updateBy AS "updateBy.id",
-		a.updateDate AS "updateDate",
-		a.delFlag AS "delFlag"
+		a.useDate AS "useDate",
+		a.delFlag AS "delFlag",
+		u.name AS "clubName"
 	</sql>
 	
 	<sql id="cmCouponClubJoins">
+		LEFT JOIN user u ON u.userID = a.userId
 	</sql>
     
 	<select id="get" resultType="CmCouponClub">
@@ -30,29 +28,32 @@
 	</select>
 	
 	<select id="findList" resultType="CmCouponClub">
-		SELECT
+		SELECT 
 			<include refid="cmCouponClubColumns"/>
-		,u.userID AS "userID"
 		FROM cm_coupon_club a
-		LEFT JOIN user u ON u.userID = a.userID
 		<include refid="cmCouponClubJoins"/>
 		<where>
+			<if test="couponId != null">
+				AND a.couponId = #{couponId}
+			</if>
+			<if test="userId != null">
+				AND a.userId = #{userId}
+			</if>
+			<if test="source != null and source != ''">
+				AND a.source = #{source}
+			</if>
 			<if test="status != null and status != ''">
 				AND a.status = #{status}
 			</if>
-			<if test="name != null and name != ''">
-				AND a.name LIKE 
-					<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
-					<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
-					<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
+			<if test="createDate != null and createDate != ''">
+				AND a.createDate > #{createDate}
 			</if>
-			<if test="startTime != null and startTime != ''">
-				AND (a.signDate &gt; #{startTime} OR a.signDate = #{startTime})
+			<if test="useDate != null and useDate != ''">
+				AND a.useDate > #{useDate}
 			</if>
-			<if test="endTime != null and endTime != ''">
-				AND (a.signDate &lt; #{endTime} OR  a.signDate = #{endTime})
+			<if test="clubName != null and clubName != ''">
+				AND u.name LIKE CONCAT('%',#{clubName},'%')
 			</if>
-			AND a.delFlag = 0
 		</where>
 		<choose>
 			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
@@ -83,109 +84,183 @@
 	
 	<insert id="insert" parameterType="CmCouponClub"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO cm_coupon_club(
-			id,
-			clubId,
-			userID,
-			name,
-			sname,
-			linkMan,
-			contractMobile,
-			signDate,
+			userId,
+			couponId,
+			orderId,
+			returnedId,
+			source,
 			status,
-			createBy,
 			createDate,
-			updateBy,
-			updateDate,
+			useDate,
 			delFlag
 		) VALUES (
-			#{id},
-			#{clubId},
-			#{userID},
-			#{name},
-			#{sname},
-			#{linkMan},
-			#{contractMobile},
-			#{signDate},
+			#{userId},
+			#{couponId},
+			#{orderId},
+			#{returnedId},
+			#{source},
 			#{status},
-			#{createBy.id},
 			#{createDate},
-			#{updateBy.id},
-			#{updateDate},
+			#{useDate},
 			#{delFlag}
 		)
 	</insert>
 	
 	<update id="update">
 		UPDATE cm_coupon_club SET 	
-			clubId = #{clubId},
-		<if test="userID != null and userID != ''">
-			userID = #{userID},
-		</if>
-		<if test="name != null and name != ''">
-			name = #{name},
+			userId = #{userId},
+			couponId = #{couponId},
+			orderId = #{orderId},
+			source = #{source},
+			status = #{status},
+			createDate = #{createDate},
+			useDate = #{useDate},
+			delFlag = #{delFlag}
+		WHERE id = #{id}
+	</update>
+
+	<select id="receivingUserList" resultType="com.caimei.modules.coupon.entity.CmCouponClub">
+		SELECT
+		  c.userID AS "userId",
+		  c.name AS "clubName",
+		  COUNT(cc.id) AS "num"
+		FROM
+		  club c
+		  LEFT JOIN cm_coupon_club ccc ON c.userID = ccc.userId
+		  AND ccc.delFlag = 0
+		  AND ccc.status = 1
+		  LEFT JOIN cm_coupon cc ON ccc.couponId = cc.id
+		  AND cc.delFlag = 0
+		  AND NOW() BETWEEN cc.startDate
+		  AND cc.endDate
+		  AND cc.status != 2
+		WHERE
+		  c.status IN (1, 90)
+		  <if test="clubName != null and clubName != ''">
+			  AND c.name LIKE CONCAT('%',#{clubName},'%')
+		  </if>
+		  <if test="userId != null">
+			  AND c.userID = #{userId}
+		  </if>
+		GROUP BY
+		  c.userID
+		ORDER BY
+		  COUNT(cc.id) DESC
+	</select>
+
+	<select id="findClubCoupon" resultType="com.caimei.modules.coupon.entity.CmCouponClub">
+		SELECT
+			<include refid="cmCouponClubColumns"/>,
+			cc.couponAmount,
+			cc.touchPrice,
+			cc.couponType,
+			cc.status AS "couponStatus",
+			cc.startDate,
+			cc.endDate,
+			co.orderNo
+		FROM
+		  cm_coupon_club a
+			<include refid="cmCouponClubJoins"/>
+		  LEFT JOIN cm_coupon cc ON a.couponId = cc.id
+		  LEFT JOIN cm_order co ON co.orderID = a.orderId
+		WHERE
+		  a.delFlag = 0
+		  AND cc.delFlag = 0
+		  AND a.userId = #{userId}
+		<if test="couponType != null">
+			  AND cc.couponType = #{couponType}
 		</if>
-		<if test="sname != null and sname != ''">
-			sname = #{sname},
+		<if test="status != null and status != ''">
+			AND a.status = #{status}
 		</if>
-		<if test="linkMan != null and linkMan != ''">
-			linkMan = #{linkMan},
+		<if test='couponStatus == "0"'>
+			AND cc.startDate <![CDATA[ > ]]> NOW()
+			AND cc.status != '2'
 		</if>
-		<if test="contractMobile != null and contractMobile != ''">
-			contractMobile = #{contractMobile},
+		<if test='couponStatus == "1"'>
+			AND cc.startDate <![CDATA[ <= ]]> NOW()
+			AND cc.endDate <![CDATA[ >= ]]> NOW()
+			AND cc.status != '2'
 		</if>
-		<if test="signDate != null and signDate != ''">
-			signDate = #{signDate},
+		<if test='couponStatus == "2"'>
+			AND cc.status = '2'
 		</if>
-		<if test="status != null and status != ''">
-			status = #{status},
+		<if test='couponStatus == "3"'>
+			AND cc.endDate <![CDATA[ < ]]> NOW()
+			AND cc.status != '2'
 		</if>
-        <if test="delFlag != null and delFlag != ''">
-            delFlag = #{delFlag},
-        </if>
-			createBy = #{createBy.id},
-			createDate = #{createDate},
-			updateBy = #{updateBy.id},
-		updateDate = #{updateDate}
-		WHERE id = #{id}
-	</update>
-	
-	<delete id="delete">
-		DELETE FROM cm_coupon_club
-		WHERE id = #{id}
-	</delete>
+		ORDER BY
+		  a.createDate DESC
+	</select>
 
-	<update id="deleteCmCouponClub">
-		UPDATE cm_coupon_club SET
-			delFlag = 1
-		WHERE id = #{id}
-	</update>
+	<select id="findCouponRedemptionCode" resultType="com.caimei.modules.coupon.entity.CmCouponRedemptionCode">
+        SELECT
+          `id`,
+          `couponId`,
+          `clubCouponId`,
+          `redemptionCode`,
+          `status`,
+          `redemptionTime`,
+          `addTime`
+        FROM
+          `cm_coupon_redemption_code`
+        WHERE
+          redemptionCode = #{redemptionCode}
+    </select>
 
-	<select id="getAllClubID" resultType="int">
-		select clubId from cm_coupon_club where delFlag = 0
-	</select>
+	<select id="getCoupons" resultType="com.caimei.modules.coupon.entity.CmCoupon">
+        SELECT
+          `id` AS "couponId",
+          `couponAmount`,
+          `touchPrice`,
+          `startDate`,
+          `endDate`,
+          `couponType`,
+          `userId`,
+          `shopId`,
+          `productType`,
+          `categoryType`
+        FROM
+          cm_coupon
+        WHERE
+          delFlag = 0
+          AND status != 2
+          AND id = #{couponId}
+    </select>
 
-	<!--只查询企业会所-->
-	<select id="getClubList" resultType="NewCmClub">
-		SELECT c.clubID, c.name, c.sname, c.linkMan, c.contractMobile
-		From user u  LEFT JOIN club c ON c.clubID = u.clubID
-		<where>
-			<if test="clubID != null and clubID != ''">
-				AND c.clubID = #{clubID}
-			</if>
-			<if test="name != null and name != ''">
-				AND c.name LIKE concat('%',#{name},'%')
-			</if>
-			AND not exists(select cc.clubId from cm_coupon_club cc where cc.delFlag = 0 and cc.clubId = c.clubID)
-			AND c.status = 90
-			AND u.registerUserTypeID=3
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				ORDER BY c.clubID DESC
-			</otherwise>
-		</choose>
-	</select>
+	<update id="updateRedemptionCode">
+		UPDATE
+		  cm_coupon_redemption_code
+		SET
+		  status = 2,
+		  redemptionTime = NOW(),
+		  clubCouponId = #{clubCouponId}
+		WHERE
+		  id = #{id}
+    </update>
+
+	<update id="deleteByReturnedId">
+		UPDATE cm_coupon_club SET delFlag = 1 WHERE returnedId = #{returnedId} AND status = 1 AND source = 3
+	</update>
+
+	<select id="findRedemptionCode" resultType="com.caimei.modules.coupon.entity.CmCouponRedemptionCode">
+        SELECT
+          `id`,
+          `couponId`,
+          `clubCouponId`,
+          `redemptionCode`,
+          `status`,
+          `redemptionTime`,
+          `addTime`
+        FROM
+          cm_coupon_redemption_code
+        WHERE
+          couponId = #{couponId}
+          AND STATUS = 1
+        ORDER BY
+          id
+        LIMIT
+          1
+    </select>
+	
 </mapper>

+ 401 - 142
src/main/resources/mappings/modules/coupon/CmCouponMapper.xml

@@ -4,20 +4,21 @@
     
 	<sql id="cmCouponColumns">
 		a.id AS "id",
-		a.couponCode AS "couponCode",
+		a.name AS "name",
 		a.couponAmount AS "couponAmount",
-		a.useStartDate AS "useStartDate",
-		a.useEndDate AS "useEndDate",
+		a.touchPrice AS "touchPrice",
+		a.startDate AS "startDate",
+		a.endDate AS "endDate",
 		a.status AS "status",
-		a.discount AS "discount",
 		a.couponType AS "couponType",
-		a.couponlimit AS "couponlimit",
-		a.threshold AS "threshold",
-		a.useDescription AS "useDescription",
-		a.createBy AS "createBy.id",
+		a.userId AS "userId",
+		a.shopId AS "shopId",
+		a.productType AS "productType",
+		a.pcBanner AS "pcBanner",
+		a.appletsBanner AS "appletsBanner",
+		a.categoryType AS "categoryType",
+		a.couponsMode AS "couponsMode",
 		a.createDate AS "createDate",
-		a.updateBy AS "updateBy.id",
-		a.updateDate AS "updateDate",
 		a.delFlag AS "delFlag"
 	</sql>
 	
@@ -34,60 +35,80 @@
 	
 	<select id="findList" resultType="CmCoupon">
 		SELECT 
-			<include refid="cmCouponColumns"/>
+			<include refid="cmCouponColumns"/>,
+			u.name AS "clubName",
+			s.name AS "shopName"
 		FROM cm_coupon a
+		LEFT JOIN cm_coupon_club ccc ON ccc.couponId = a.id
+		LEFT JOIN USER u ON u.userID = a.userId
+		LEFT JOIN shop s ON s.shopID = a.shopId
 		<include refid="cmCouponJoins"/>
 		<where>
-			
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-
-
-	<select id="findCouponList" resultType="CmCoupon">
-		SELECT
-		<include refid="cmCouponColumns"/>
-		,count(*) AS "laveNum"
-		FROM cm_coupon a
-		<include refid="cmCouponJoins"/>
-		<where>
-			AND status = 0
-			AND a.useEndDate <![CDATA[  >  ]]> NOW()
-			GROUP BY couponAmount,threshold,couponType
+			AND a.delFlag = 0
+			<if test="couponType != null">
+				AND a.couponType = #{couponType}
+			</if>
+			<if test="name != null and name != ''">
+				AND a.name LIKE 
+					<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
+					<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
+					<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
+			</if>
+			<if test="startDate != null and startDate != ''">
+				AND a.startDate <![CDATA[ >= ]]> #{startDate}
+			</if>
+			<if test="endDate != null and endDate != ''">
+				AND a.endDate <![CDATA[ <= ]]> #{endDate}
+			</if>
+			<if test='status == "0"'>
+				AND a.startDate <![CDATA[ > ]]> NOW()
+			</if>
+			<if test='status == "1"'>
+				AND a.startDate <![CDATA[ <= ]]> NOW()
+				AND a.endDate <![CDATA[ >= ]]> NOW()
+				AND a.status != '2'
+			</if>
+			<if test='status == "2"'>
+				AND a.status = '2'
+			</if>
+			<if test='status == "3"'>
+				AND a.endDate <![CDATA[ < ]]> NOW()
+			</if>
+			<if test="clubName != null and clubName != ''">
+				AND u.name LIKE concat('%',#{clubName},'%')
+			</if>
+			<if test='claimStatus == "1"'>
+				AND ccc.id IS NULL
+			</if>
+			<if test='claimStatus == "2"'>
+				AND ccc.id IS NOT NULL
+			</if>
+			<if test='useStatus == "1"'>
+				AND (ccc.status IS NULL OR ccc.status = #{useStatus})
+			</if>
+			<if test='useStatus == "2"'>
+				AND ccc.status = #{useStatus}
+			</if>
+			<if test="source != null and source != ''">
+				AND ccc.source = #{source}
+			</if>
+			<if test="shopName != null and shopName != ''">
+				AND s.name LIKE concat('%',#{shopName},'%')
+			</if>
+			<if test="couponsMode != null and couponsMode != ''">
+				AND a.couponsMode = #{couponsMode}
+			</if>
 		</where>
+			GROUP BY a.id
 		<choose>
 			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
 				ORDER BY ${page.orderBy}
 			</when>
 			<otherwise>
+				ORDER BY createDate DESC
 			</otherwise>
 		</choose>
 	</select>
-
-
-	<select id="getSendCoupon" resultType="CmCoupon">
-		SELECT
-		<include refid="cmCouponColumns"/>
-		FROM cm_coupon a
-		<include refid="cmCouponJoins"/>
-		<where>
-			AND status = 0
-			AND a.useEndDate <![CDATA[  >  ]]> NOW()
-			AND a.couponAmount = #{couponAmount}
-			AND a.couponType = #{couponType}
-			<if test="threshold != null and threshold != ''">
-				AND a.threshold = #{threshold}
-			</if>
-			LIMIT #{num}
-		</where>
-	</select>
-
 	
 	<select id="findAllList" resultType="CmCoupon">
 		SELECT 
@@ -108,126 +129,364 @@
 	
 	<insert id="insert" parameterType="CmCoupon"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO cm_coupon(
-			id,
-			couponCode,
+			name,
 			couponAmount,
-			useStartDate,
-			useEndDate,
+			touchPrice,
+			startDate,
+			endDate,
 			status,
-			discount,
 			couponType,
-			couponlimit,
-			threshold,
-			useDescription,
-			createBy,
+			userId,
+			shopId,
+			productType,
+			pcBanner,
+			appletsBanner,
+			categoryType,
+			couponsMode,
 			createDate,
-			updateBy,
-			updateDate,
 			delFlag
 		) VALUES (
-			#{id},
-			#{couponCode},
+			#{name},
 			#{couponAmount},
-			#{useStartDate},
-			#{useEndDate},
+			#{touchPrice},
+			#{startDate},
+			#{endDate},
 			#{status},
-			#{discount},
 			#{couponType},
-			#{couponlimit},
-			#{threshold},
-			#{useDescription},
-			#{createBy.id},
+			#{userId},
+			#{shopId},
+			#{productType},
+			#{pcBanner},
+			#{appletsBanner},
+			#{categoryType},
+			#{couponsMode},
 			#{createDate},
-			#{updateBy.id},
-			#{updateDate},
 			#{delFlag}
 		)
 	</insert>
 	
 	<update id="update">
-		UPDATE cm_coupon SET
-		<if test="couponCode != null and couponCode != ''">
-			couponCode = #{couponCode},
-		</if>
-		<if test="couponAmount != null and couponAmount != ''">
+		UPDATE cm_coupon SET 	
+			name = #{name},
 			couponAmount = #{couponAmount},
-		</if>
-		<if test="useStartDate != null and useStartDate != ''">
-			useStartDate = #{useStartDate},
-		</if>
-		<if test="useEndDate != null and useEndDate != ''">
-			useEndDate = #{useEndDate},
-		</if>
-		<if test="status != null and status != ''">
+			touchPrice = #{touchPrice},
+			startDate = #{startDate},
+			endDate = #{endDate},
 			status = #{status},
-		</if>
-		<if test="discount != null and discount != ''">
-			discount = #{discount},
-		</if>
-		<if test="couponType != null and couponType != ''">
 			couponType = #{couponType},
-		</if>
-		<if test="couponlimit != null and couponlimit != ''">
-			couponlimit = #{couponlimit},
-		</if>
-		<if test="threshold != null and threshold != ''">
-			threshold = #{threshold},
-		</if>
-		<if test="useDescription != null and useDescription != ''">
-			useDescription = #{useDescription},
-		</if>
-		<if test="createBy != null and createBy != ''">
-			createBy = #{createBy.id},
-		</if>
-		<if test="createDate != null and createDate != ''">
-			createDate = #{createDate},
-		</if>
-		<if test="updateBy != null and updateBy != ''">
-			updateBy = #{updateBy.id},
-		</if>
-		<if test="updateDate != null and updateDate != ''">
-			updateDate = #{updateDate},
-		</if>
-		<if test="delFlag != null and delFlag != ''">
-			delFlag = #{delFlag}
-		</if>
+			userId = #{userId},
+			shopId = #{shopId},
+			productType = #{productType},
+			pcBanner = #{pcBanner},
+			appletsBanner = #{appletsBanner},
+			categoryType = #{categoryType},
+			couponsMode = #{couponsMode}
 		WHERE id = #{id}
 	</update>
-
-	<update id="updateStatus">
-		UPDATE cm_coupon SET
-		status = #{status},
-		updateDate = #{updateDate}
-		WHERE couponCode = #{couponCode}
-	</update>
 	
 	<delete id="delete">
 		DELETE FROM cm_coupon
 		WHERE id = #{id}
 	</delete>
 
-	<!--状态: 0未派发 1已发放 2已分享 3已使用 4已领取[0/1/2/3状态公众号推送劵,后台派发劵两种方式共用 4公众号推送使用-->
-	<!--1.过期值存在于已分享或者已发放状态,已使用不能计算过期、2.剩余优惠券数量只能是有效的-->
-	<select id="statisticsCoupon" resultType="CmCoupon">
+	<select id="findByProductType" resultType="com.caimei.modules.coupon.entity.CmCouponAssociate">
 		SELECT
-		c.couponType AS couponType,
-		c.couponAmount AS couponAmount,
-		sum((CASE WHEN c.status = '0' AND (c.useEndDate <![CDATA[  >  ]]> NOW()) then 1 else 0 END)) AS lastAmount,
-		sum((CASE WHEN c.status = '2' then 1 else 0 END)) AS shareAmount,
-		sum((CASE WHEN c.status = '3' then 1 else 0 END)) AS usedAmount,
-		sum(if(c.status != 3,(CASE WHEN c.useEndDate <![CDATA[  <  ]]> NOW() then 1 else 0 END ),0)) AS timeOutAmount,
-		sum((CASE WHEN ccrs.status = '1' then 1 else 0 END)) AS unReceiveNum
+		  cca.id,
+		  cca.couponId,
+		  cca.productId,
+		  cca.pcStatus,
+		  cca.appletsStatus,
+		  cca.sort,
+		  cca.addTime,
+		  cca.delFlag,
+		  s.name AS shopName,
+		  p.name AS productName,
+		  p.mainImage AS image
 		FROM
-		cm_coupon c
-		LEFT JOIN cm_coupon_record_scan ccrs ON ccrs.couponCode = c.couponCode
-		GROUP BY
-		c.couponType,
-		c.couponAmount;
+		  cm_coupon_product cca
+		  LEFT JOIN product p ON cca.productId = p.productID
+		  LEFT JOIN shop s ON p.shopID = s.shopID
+		WHERE
+		  cca.couponId = #{couponId}
+		  AND delFlag = 0
+		ORDER BY
+		  - sort DESC
 	</select>
 
-	<select id="findByCouponCode" resultType="CmCoupon">
-		select <include refid="cmCouponColumns"/>
-		from cm_coupon a where a.couponCode = #{couponCode}
+	<insert id="insertCouponAssociate">
+		INSERT INTO `cm_coupon_product` (
+		  `couponId`, `productId`, `pcStatus`,
+		  `appletsStatus`,
+		  `sort`, `addTime`, `delFlag`
+		)
+		VALUES
+		  (
+			#{couponId}, #{productId}, #{pcStatus},
+			#{appletsStatus},
+			#{sort}, #{addTime}, #{delFlag}
+		  )
+	</insert>
+
+	<select id="findByCouponId" resultType="integer">
+		SELECT id FROM cm_coupon_product WHERE couponId = #{couponId} AND delFlag = 0
 	</select>
+
+	<update id="updateCouponAssociate">
+		UPDATE
+		  `cm_coupon_product`
+		<set>
+		  <if test="pcStatus != null and pcStatus != ''">
+				`pcStatus` = #{pcStatus},
+		  </if>
+		  <if test="appletsStatus != null and appletsStatus != ''">
+			  `appletsStatus` = #{appletsStatus},
+		  </if>
+		  <if test="sort != null">
+			  `sort` = #{sort},
+		  </if>
+		</set>
+		WHERE
+		  `id` = #{id}
+	</update>
+
+	<update id="logicDeleteCouponAssociate">
+		UPDATE cm_coupon_product SET delFlag = 1 WHERE id = #{id}
+	</update>
+
+	<update id="updateByDelFlag">
+		UPDATE cm_coupon SET delFlag = 1 WHERE id = #{couponId}
+	</update>
+
+	<update id="updateAssociateByDelFlag">
+		UPDATE cm_coupon_product SET delFlag = 1 WHERE couponId = #{couponId}
+	</update>
+
+	<select id="findCouponClub" resultType="com.caimei.modules.coupon.entity.CmCouponClub">
+		SELECT
+		  `userId`,
+		  `couponId`,
+		  orderId,
+		  `source`,
+		  `status`,
+		  `createDate`,
+		  `useDate`,
+		  `delFlag`
+		FROM
+		  `cm_coupon_club`
+		WHERE
+		  couponId = #{couponId}
+		  AND delFlag = 0
+		LIMIT
+		  1
+	</select>
+
+	<select id="findUserList" resultType="com.caimei.modules.user.entity.CmUser">
+		SELECT
+			u.clubID,
+			u.userID,
+			u.userName,
+			u.bindMobile,
+			u.name,
+			u.userIdentity,
+			c.sname AS shortName
+		FROM
+			club c
+		LEFT JOIN USER u ON c.userID = u.userID
+		WHERE
+		  c.status IN (1, 90)
+		  <if test="userID != null">
+			  AND u.userID = #{userID}
+		  </if>
+		  <if test="name != null and name != ''">
+			  AND u.name LIKE CONCAT('%',#{name},'%')
+		  </if>
+		  <if test="shortName != null and shortName != ''">
+			AND c.sname LIKE CONCAT('%',#{shortName},'%')
+		  </if>
+		ORDER BY
+		  userID ASC
+	</select>
+
+	<select id="findShopList" resultType="com.caimei.modules.user.entity.NewCmShop">
+		SELECT
+		  s.shopID,
+		  s.userID,
+		  IFNULL(s.name, u.name) AS name,
+		  IFNULL(s.sname, u.realName) AS sname,
+		  IFNULL(s.contractMobile, u.bindMobile) AS contractMobile,
+		  IFNULL(s.linkMan, u.userName) AS linkMan
+		FROM
+		  shop s
+		  LEFT JOIN USER u ON u.`shopID` = s.`shopID`
+		WHERE
+		  s.status = 90
+		  <if test="shopID != null">
+			AND s.shopID = #{shopID}
+		  </if>
+		  <if test="name != null and name != ''">
+			AND (s.name LIKE CONCAT('%',#{name},'%') OR	u.name LIKE CONCAT('%',#{name},'%'))
+		  </if>
+		  <if test="sname != null and sname != ''">
+			AND (s.sname LIKE CONCAT('%',#{sname},'%') OR u.realName LIKE CONCAT('%',#{sname},'%'))
+		  </if>
+		ORDER BY
+		  s.shopID
+	</select>
+
+	<select id="findRedemptionCodeNum" resultType="integer">
+		SELECT COUNT(id) FROM cm_coupon_redemption_code WHERE couponId = #{couponId}
+	</select>
+	
+	<select id="findByRedemptionCode" resultType="com.caimei.modules.coupon.entity.CmCouponRedemptionCode">
+		SELECT
+		  `id`,
+		  `couponId`,
+		  `clubCouponId`,
+		  `redemptionCode`,
+		  `status`,
+		  `redemptionTime`,
+		  `addTime`
+		FROM
+		  cm_coupon_redemption_code
+		WHERE
+		  redemptionCode =	#{redemptionCode}
+	</select>
+
+	<insert id="insertRedemptionCode">
+		INSERT INTO `cm_coupon_redemption_code` (
+		  `couponId`,
+		  `clubCouponId`,
+		  `redemptionCode`,
+		  `status`,
+		  `redemptionTime`,
+		  `addTime`
+		)
+		VALUES
+		  (
+			#{couponId},
+			#{clubCouponId},
+			#{redemptionCode},
+			#{status},
+			#{redemptionTime},
+			#{addTime}
+		  )
+	</insert>
+
+	<select id="findRedemptionCode" resultType="com.caimei.modules.coupon.entity.CmCouponRedemptionCode">
+		SELECT
+		  `id`,
+		  `couponId`,
+		  `clubCouponId`,
+		  `redemptionCode`,
+		  `status`,
+		  `redemptionTime`,
+		  `addTime`
+		FROM
+		  cm_coupon_redemption_code
+		WHERE
+		  couponId = #{couponId}
+		  <if test="status != null and status != ''">
+			  AND status = #{status}
+		  </if>
+		ORDER BY
+		  addTime DESC
+	</select>
+
+	<select id="findQuantityRedeemed" resultType="integer">
+		SELECT COUNT(id) FROM cm_coupon_redemption_code WHERE couponId = #{couponId} AND status = 2
+	</select>
+
+	<select id="findClubCouponList" resultType="com.caimei.modules.coupon.entity.CmCoupon">
+		SELECT
+		  cc.`id`,
+		  cc.`name`,
+		  cc.`couponAmount`,
+		  cc.`touchPrice`,
+		  cc.`startDate`,
+		  cc.`endDate`,
+		  cc.`status`,
+		  cc.`couponType`,
+		  cc.`userId`,
+		  cc.`shopId`,
+		  cc.`productType`,
+		  cc.`pcBanner`,
+		  cc.`appletsBanner`,
+		  cc.`categoryType`,
+		  cc.`couponsMode`,
+		  cc.`createDate`,
+		  cc.`delFlag`,
+		  a.id AS clubCouponId,
+		  ccrc.redemptionCode
+		FROM
+		  cm_coupon_club a
+		  LEFT JOIN cm_coupon cc ON a.couponId = cc.id
+		  LEFT JOIN cm_coupon_redemption_code ccrc ON a.id = ccrc.clubCouponId
+		WHERE
+		  cc.delFlag = 0
+		  AND a.delFlag = 0
+		  AND a.userId = #{userId}
+		  AND a.status = 1
+		  AND NOW() BETWEEN cc.startDate
+		  AND cc.endDate
+		  AND cc.status != 2
+		ORDER BY
+		  a.createDate DESC
+	</select>
+
+	<select id="findAllProductId" resultType="integer">
+		SELECT
+		  productId
+		FROM
+		  cm_coupon_product
+		WHERE
+		  couponId = #{couponId}
+		  AND (
+			pcStatus = 1
+			OR appletsStatus = 1
+		  )
+	</select>
+
+	<select id="findNotRedeemedCoupon" resultType="com.caimei.modules.coupon.entity.CmCoupon">
+		SELECT
+		  a.`id`,
+		  a.`name`,
+		  a.`couponAmount`,
+		  a.`touchPrice`,
+		  a.`startDate`,
+		  a.`endDate`,
+		  a.`status`,
+		  a.`couponType`,
+		  a.`userId`,
+		  a.`shopId`,
+		  a.`productType`,
+		  a.`pcBanner`,
+		  a.`appletsBanner`,
+		  a.`categoryType`,
+		  a.`couponsMode`,
+		  a.`createDate`,
+		  a.`delFlag`,
+		  ccrc.redemptionCode
+		FROM
+		  cm_coupon a
+		  LEFT JOIN cm_coupon_redemption_code ccrc ON a.id = ccrc.couponId
+		WHERE
+		  a.status != 2
+		  AND a.delFlag = 0
+		  AND NOW() BETWEEN a.startDate
+		  AND a.endDate
+		  AND a.couponsMode = 1
+		  AND ccrc.status = 1
+	</select>
+
+	<update id="updateClubCoupon">
+		UPDATE
+		  cm_coupon_club
+		SET
+		  STATUS = 2,
+		  orderId = #{orderId},
+		  useDate = NOW()
+		WHERE
+		  id = #{clubCouponId}
+	</update>
 	
 </mapper>

+ 0 - 167
src/main/resources/mappings/modules/coupon/CmCouponOrderRecordMapper.xml

@@ -1,167 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.caimei.modules.coupon.dao.CmCouponOrderRecordDao">
-    
-	<sql id="cmCouponOrderRecordColumns">
-		a.id AS "id",
-		a.orderCode AS "orderCode",
-		a.totalAmount AS "totalAmount",
-		a.refundAmount AS "refundAmount",
-		a.paymentTime AS "paymentTime",
-		a.refundTime AS "refundTime",
-		a.couponCode AS "couponCode",
-		a.discountAmount AS "discountAmount",
-		a.status AS "status",
-		a.customerCode AS "customerCode",
-		a.customerName AS "customerName",
-		a.customerMobile AS "customerMobile",
-		a.refundFlag AS "refundFlag",
-		a.createTime AS "createTime",
-		a.updateTime AS "updateTime",
-		a.delFlag AS "delFlag",
-		u.userName AS "clubName",
-		ccrs.mobile AS "couponMobile"
-	</sql>
-	
-	<sql id="cmCouponOrderRecordJoins">
-		LEFT JOIN cm_coupon_record ccr ON ccr.couponCode = a.couponCode
-		LEFT JOIN cm_coupon_record_scan ccrs ON ccrs.couponCode = a.couponCode
-		LEFT JOIN user u ON u.userID = ccr.userID
-		LEFT JOIN club c on c.userID = u.companyUserID
-	</sql>
-    
-	<select id="get" resultType="CmCouponOrderRecord">
-		SELECT 
-			<include refid="cmCouponOrderRecordColumns"/>
-		FROM cm_coupon_order_record a
-		<include refid="cmCouponOrderRecordJoins"/>
-		WHERE a.id = #{id}
-	</select>
-	
-	<select id="findList" resultType="CmCouponOrderRecord">
-		SELECT 
-			<include refid="cmCouponOrderRecordColumns"/>
-		FROM cm_coupon_order_record a
-		<include refid="cmCouponOrderRecordJoins"/>
-		<where>
-			
-			<if test="orderCode != null and orderCode != ''">
-				AND a.orderCode = #{orderCode}
-			</if>
-			<if test="clubName != null and clubName != ''">
-				AND (u.userName LIKE concat('%',#{clubName},'%') OR ccrs.mobile = #{clubName} OR  c.name LIKE concat('%',#{clubName},'%'))
-			</if>
-			<if test="startTime != null and startTime != ''">
-				AND a.paymentTime <![CDATA[  >=  ]]> #{startTime}
-			</if>
-			<if test="endTime != null and endTime != ''">
-				AND a.paymentTime <![CDATA[   <=  ]]> #{endTime}
-			</if>
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				ORDER BY a.paymentTime DESC
-			</otherwise>
-		</choose>
-	</select>
-
-	<select id="findListBuyAgain" resultType="CmCouponOrderRecord">
-		SELECT
-		a.*,
-		u.username AS "clubName",
-		c.name AS "companyName",
-		ccrs.mobile AS "couponMobile"
-		FROM cm_coupon_order_record a
-		LEFT JOIN cm_coupon_record ccr ON ccr.couponCode = a.couponCode
-		LEFT JOIN cm_coupon_record_scan ccrs ON ccrs.couponCode = a.couponCode
-		LEFT JOIN user u ON u.userID = ccr.sharerUserId
-		LEFT JOIN club c on c.userID = u.companyUserID
-		WHERE
-		a.customerMobile = #{customerMobile}
-		AND ( c.name is NOT NULL OR  ccrs.mobile is NOT NULL )
-	</select>
-	
-	<select id="findAllList" resultType="CmCouponOrderRecord">
-		SELECT 
-			<include refid="cmCouponOrderRecordColumns"/>
-		FROM cm_coupon_order_record a
-		<include refid="cmCouponOrderRecordJoins"/>
-		<where>
-			
-		</where>		
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	
-	<insert id="insert" parameterType="CmCouponOrderRecord"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO cm_coupon_order_record(
-			id,
-			orderCode,
-			totalAmount,
-			refundAmount,
-			paymentTime,
-			refundTime,
-			couponCode,
-			discountAmount,
-			status,
-			customerCode,
-			customerName,
-			customerMobile,
-			refundFlag,
-			createTime,
-			updateTime,
-			delFlag
-		) VALUES (
-			#{id},
-			#{orderCode},
-			#{totalAmount},
-			#{refundAmount},
-			#{paymentTime},
-			#{refundTime},
-			#{couponCode},
-			#{discountAmount},
-			#{status},
-			#{customerCode},
-			#{customerName},
-			#{customerMobile},
-			#{refundFlag},
-			#{createTime},
-			#{updateTime},
-			#{delFlag}
-		)
-	</insert>
-	
-	<update id="update">
-		UPDATE cm_coupon_order_record SET 	
-			orderCode = #{orderCode},
-			totalAmount = #{totalAmount},
-			refundAmount = #{refundAmount},
-			paymentTime = #{paymentTime},
-			refundTime = #{refundTime},
-			couponCode = #{couponCode},
-			discountAmount = #{discountAmount},
-			status = #{status},
-			customerCode = #{customerCode},
-			customerName = #{customerName},
-			customerMobile = #{customerMobile},
-			refundFlag = #{refundFlag},
-			createTime = #{createTime},
-			updateTime = #{updateTime},
-			delFlag = #{delFlag}
-		WHERE id = #{id}
-	</update>
-	
-	<delete id="delete">
-		DELETE FROM cm_coupon_order_record
-		WHERE id = #{id}
-	</delete>
-	
-</mapper>

+ 0 - 170
src/main/resources/mappings/modules/coupon/CmCouponRecordMapper.xml

@@ -1,170 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.caimei.modules.coupon.dao.CmCouponRecordDao">
-    
-	<sql id="cmCouponRecordColumns">
-		a.id AS "id",
-		a.couponCode AS "couponCode",
-		a.couponAmount AS "couponAmount",
-		a.useStartDate AS "useStartDate",
-		a.useEndDate AS "useEndDate",
-		a.status AS "status",
-		a.couponType AS "couponType",
-		a.threshold AS "threshold",
-		a.useDescription AS "useDescription",
-		a.relatedOrderCode AS "relatedOrderCode",
-		a.userId AS "userId",
-		a.sharerUserId AS "sharerUserId",
-		a.openid AS "openid",
-		a.receiveDate AS "receiveDate",
-		a.useDate AS "useDate",
-		a.createBy AS "createBy.id",
-		a.createDate AS "createDate",
-		a.updateBy AS "updateBy.id",
-		a.updateDate AS "updateDate",
-		a.delFlag AS "delFlag"
-	</sql>
-	
-	<sql id="cmCouponRecordJoins">
-	</sql>
-    
-	<select id="get" resultType="CmCouponRecord">
-		SELECT 
-			<include refid="cmCouponRecordColumns"/>
-		FROM cm_coupon_record a
-		<include refid="cmCouponRecordJoins"/>
-		WHERE a.id = #{id}
-	</select>
-
-	
-<!--存在处理显示已过期的状态4-->
-	<select id="findList" resultType="CmCouponRecord">
-		SELECT 
-			<include refid="cmCouponRecordColumns"/>
-		,ccro.orderCode AS "couponOrderCode"
-		FROM cm_coupon_record a
-		LEFT JOIN user u ON u.userID = a.userId
-		LEFT JOIN cm_coupon_order_record ccro ON ccro.couponCode = a.couponCode
-		<include refid="cmCouponRecordJoins"/>
-		<where>
-			<if test="status != null and status != ''">
-				<if test="status != 4 and status != 3">
-					AND a.status = #{status}
-					AND a.useEndDate <![CDATA[  >  ]]> NOW()
-				</if>
-				<if test="status == 3">
-					AND a.status = #{status}
-				</if>
-				<if test="status == 4">
-					AND a.status != 3
-					AND a.useEndDate <![CDATA[  <  ]]> NOW()
-				</if>
-			</if>
-			<if test="couponCode != null and couponCode != ''">
-				AND a.couponCode = #{couponCode}
-			</if>
-			<if test="id != null and id != ''">
-				AND a.id = #{id}
-			</if>
-			<if test="companyName != null and companyName != ''">
-				AND u.userName LIKE concat('%',#{companyName},'%')
-			</if>
-		</where>
-		GROUP BY a.couponCode
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				ORDER BY a.createDate DESC
-			</otherwise>
-		</choose>
-	</select>
-	
-	<select id="findAllList" resultType="CmCouponRecord">
-		SELECT 
-			<include refid="cmCouponRecordColumns"/>
-		FROM cm_coupon_record a
-		<include refid="cmCouponRecordJoins"/>
-		<where>
-			
-		</where>		
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	
-	<insert id="insert" parameterType="CmCouponRecord"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO cm_coupon_record(
-			id,
-			couponCode,
-			couponAmount,
-			useStartDate,
-			useEndDate,
-			status,
-			couponType,
-			threshold,
-			useDescription,
-			relatedOrderCode,
-			userId,
-			receiveDate,
-			useDate,
-			createBy,
-			createDate,
-			updateBy,
-			updateDate,
-			delFlag
-		) VALUES (
-			#{id},
-			#{couponCode},
-			#{couponAmount},
-			#{useStartDate},
-			#{useEndDate},
-			#{status},
-			#{couponType},
-			#{threshold},
-			#{useDescription},
-			#{relatedOrderCode},
-			#{userId},
-			#{receiveDate},
-			#{useDate},
-			#{createBy.id},
-			#{createDate},
-			#{updateBy.id},
-			#{updateDate},
-			#{delFlag}
-		)
-	</insert>
-	
-	<update id="update">
-		UPDATE cm_coupon_record SET 	
-			couponCode = #{couponCode},
-			couponAmount = #{couponAmount},
-			useStartDate = #{useStartDate},
-			useEndDate = #{useEndDate},
-			status = #{status},
-			couponType = #{couponType},
-			threshold = #{threshold},
-			useDescription = #{useDescription},
-			relatedOrderCode = #{relatedOrderCode},
-			userId = #{userId},
-			receiveDate = #{receiveDate},
-			useDate = #{useDate},
-			createBy = #{createBy.id},
-			createDate = #{createDate},
-			updateBy = #{updateBy.id},
-			updateDate = #{updateDate},
-			delFlag = #{delFlag}
-		WHERE id = #{id}
-	</update>
-	
-	<delete id="delete">
-		DELETE FROM cm_coupon_record
-		WHERE id = #{id}
-	</delete>
-	
-</mapper>

+ 0 - 195
src/main/resources/mappings/modules/coupon/CmCouponRecordScanMapper.xml

@@ -1,195 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.caimei.modules.coupon.dao.CmCouponRecordScanDao">
-    
-	<sql id="cmCouponRecordScanColumns">
-		a.id AS "id",
-		a.couponCode AS "couponCode",
-		a.couponAmount AS "couponAmount",
-		a.discount AS "discount",
-		a.useStartDate AS "useStartDate",
-		a.useEndDate AS "useEndDate",
-		a.status AS "status",
-		a.couponType AS "couponType",
-		a.threshold AS "threshold",
-		a.useDescription AS "useDescription",
-		a.relatedOrderCode AS "relatedOrderCode",
-		a.sharerUserId AS "sharerUserId",
-		a.openid AS "openid",
-		a.mobile AS "mobile",
-		a.receiveDate AS "receiveDate",
-		a.useDate AS "useDate",
-		a.createBy AS "createBy.id",
-		a.createDate AS "createDate",
-		a.updateBy AS "updateBy.id",
-		a.updateDate AS "updateDate",
-		a.delFlag AS "delFlag",
-		a.syncFlag AS "syncFlag"
-	</sql>
-	
-	<sql id="cmCouponRecordScanJoins">
-	</sql>
-    
-	<select id="get" resultType="CmCouponRecordScan">
-		SELECT 
-			<include refid="cmCouponRecordScanColumns"/>
-		FROM cm_coupon_record_scan a
-		<include refid="cmCouponRecordScanJoins"/>
-		WHERE a.id = #{id}
-	</select>
-
-	<!--存在处理显示已过期的状态5-->
-	<select id="findList" resultType="CmCouponRecordScan">
-		SELECT 
-			<include refid="cmCouponRecordScanColumns"/>
-		,ccro.orderCode AS "couponOrderCode"
-		FROM cm_coupon_record_scan a
-		LEFT JOIN cm_coupon_order_record ccro ON ccro.couponCode = a.couponCode
-		<include refid="cmCouponRecordScanJoins"/>
-		<where>
-			<if test="status != null and status != ''">
-				<if test="status != 5 and status != 4">
-					AND a.status = #{status}
-					AND a.useEndDate <![CDATA[  >  ]]> NOW()
-				</if>
-				<if test="status == 4">
-					AND a.status = #{status}
-				</if>
-				<if test="status == 5">
-					AND a.status != 4
-					AND a.useEndDate <![CDATA[  <  ]]> NOW()
-				</if>
-			</if>
-
-			<if test="couponCode != null and couponCode != ''">
-				AND a.couponCode = #{couponCode}
-			</if>
-			<if test="mobile != null and mobile != ''">
-				AND a.mobile = #{mobile}
-			</if>
-			<if test="id != null and id != ''">
-				AND a.id = #{id}
-			</if>
-		</where>
-		GROUP BY a.couponCode
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				ORDER BY a.createDate DESC
-			</otherwise>
-		</choose>
-	</select>
-	
-	<select id="findAllList" resultType="CmCouponRecordScan">
-		SELECT 
-			<include refid="cmCouponRecordScanColumns"/>
-		FROM cm_coupon_record_scan a
-		<include refid="cmCouponRecordScanJoins"/>
-		<where>
-			
-		</where>		
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	
-	<insert id="insert" parameterType="CmCouponRecordScan"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO cm_coupon_record_scan(
-			id,
-			couponCode,
-			couponAmount,
-			discount,
-			useStartDate,
-			useEndDate,
-			status,
-			couponType,
-			threshold,
-			useDescription,
-			relatedOrderCode,
-			sharerUserId,
-			openid,
-			mobile,
-			receiveDate,
-			useDate,
-			createBy,
-			createDate,
-			updateBy,
-			updateDate,
-			delFlag,
-			syncFlag
-		) VALUES (
-			#{id},
-			#{couponCode},
-			#{couponAmount},
-			#{discount},
-			#{useStartDate},
-			#{useEndDate},
-			#{status},
-			#{couponType},
-			#{threshold},
-			#{useDescription},
-			#{relatedOrderCode},
-			#{sharerUserId},
-			#{openid},
-			#{mobile},
-			#{receiveDate},
-			#{useDate},
-			#{createBy.id},
-			#{createDate},
-			#{updateBy.id},
-			#{updateDate},
-			#{delFlag},
-			#{syncFlag}
-		)
-	</insert>
-	
-	<update id="update">
-		UPDATE cm_coupon_record_scan SET 	
-			couponCode = #{couponCode},
-			couponAmount = #{couponAmount},
-			discount = #{discount},
-			useStartDate = #{useStartDate},
-			useEndDate = #{useEndDate},
-			status = #{status},
-			couponType = #{couponType},
-			threshold = #{threshold},
-			useDescription = #{useDescription},
-			relatedOrderCode = #{relatedOrderCode},
-			sharerUserId = #{sharerUserId},
-			openid = #{openid},
-			mobile = #{mobile},
-			receiveDate = #{receiveDate},
-			useDate = #{useDate},
-			createBy = #{createBy.id},
-			createDate = #{createDate},
-			updateBy = #{updateBy.id},
-			updateDate = #{updateDate},
-			delFlag = #{delFlag},
-			syncFlag = #{syncFlag}
-		WHERE id = #{id}
-	</update>
-	
-	<delete id="delete">
-		DELETE FROM cm_coupon_record_scan
-		WHERE id = #{id}
-	</delete>
-
-	<update id="updateEnabledStatus">
-		UPDATE cm_coupon_scan_switch SET
-		status = #{enabledStatus}
-	</update>
-
-	<select id="getEnabledStatus" resultType="CmCouponRecordScan">
-		SELECT
-		*
-		FROM cm_coupon_scan_switch
-		WHERE id = 1
-	</select>
-
-</mapper>

+ 1 - 0
src/main/resources/mappings/modules/order/CmDiscernReceiptMapper.xml

@@ -163,6 +163,7 @@
     <select id="exportTest" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
         SELECT
         r.orderID,
+        (select group_concat(distinct p.name) from product p left join cm_order_product cop on p.productID = cop.productID where cop.orderID = o.orderID group by cop.orderID) as productNames,
         IF(u.userIdentity = 2,u.name,u.userName) AS userName,
         d.receiptDate,
         d.payType,

+ 80 - 4
src/main/resources/mappings/modules/order/OrderMapper.xml

@@ -58,7 +58,8 @@
 		a.affirmPaymentFlag AS affirmPaymentFlag,
 		a.rebateFlag AS rebateFlag,
 		a.zeroCostFlag AS zeroCostFlag,
-		a.organizeStoreId as organizeStoreId
+		a.organizeStoreId as organizeStoreId,
+		a.couponAmount as couponAmount
 	</sql>
 
     <select id="get" resultType="newOrder">
@@ -373,7 +374,8 @@
 			affirmPaymentFlag,
 			rebateFlag,
 			payStatus,
-			zeroCostFlag
+			zeroCostFlag,
+			couponAmount
 		) VALUES (
 			#{orderNo},
 			#{userID},
@@ -423,7 +425,8 @@
 			#{affirmPaymentFlag},
 			#{rebateFlag},
 			#{payStatus},
-			#{zeroCostFlag}
+			#{zeroCostFlag},
+			#{couponAmount}
 		)
 	</insert>
 
@@ -590,7 +593,10 @@
 				rebateFlag = #{rebateFlag},
 			</if>
 			<if test="zeroCostFlag != null">
-				zeroCostFlag = #{zeroCostFlag}
+				zeroCostFlag = #{zeroCostFlag},
+			</if>
+			<if test="couponAmount != null">
+				couponAmount = #{couponAmount}
 			</if>
 		</set>
 		where orderID = #{orderID,jdbcType=BIGINT}
@@ -866,4 +872,74 @@
 		UPDATE USER SET userMoney=(userMoney-#{payTotalFee}), ableUserMoney = (ableUserMoney-#{payTotalFee})
 		WHERE userID = #{userID}
 	</update>
+
+	<select id="findOrderCouponRecord" resultType="com.caimei.modules.coupon.entity.CmCouponOrderRecord">
+		SELECT
+		  `id`,
+		  `orderId`,
+		  `clubCouponId`,
+		  `couponType`,
+		  `couponAmount`,
+		  `touchPrice`,
+		  `createDate`
+		FROM
+		  cm_coupon_order_record
+		WHERE
+		  orderId = #{orderID}
+	</select>
+
+	<select id="findClubCouponById" resultType="com.caimei.modules.coupon.entity.CmCoupon">
+		SELECT
+		  cc.`id`,
+		  cc.`couponAmount`,
+		  cc.`touchPrice`,
+		  cc.`couponType`,
+		  cc.`userId`,
+		  cc.`shopId`,
+		  cc.`productType`,
+		  cc.`categoryType`,
+		  cc.`couponsMode`
+		FROM
+		  cm_coupon_club a
+		  LEFT JOIN cm_coupon cc ON a.couponId = cc.id
+		WHERE
+		  a.id = #{clubCouponId}
+		  AND a.status = 1
+	</select>
+
+	<insert id="insertCouponOrderRecord">
+        INSERT INTO `cm_coupon_order_record` (
+          `orderId`,
+          `clubCouponId`,
+          `couponType`,
+          `couponAmount`,
+          `touchPrice`,
+          `createDate`
+        )
+        VALUES
+          (
+            #{orderId},
+            #{clubCouponId},
+            #{couponType},
+            #{couponAmount},
+            #{touchPrice},
+            #{createDate}
+          )
+	</insert>
+
+	<update id="updateCouponOrderRecord">
+		UPDATE
+		  `cm_coupon_order_record`
+		SET
+		  `clubCouponId` = #{clubCouponId},
+		  `couponType` = #{couponType},
+		  `couponAmount` = #{couponAmount},
+		  `touchPrice` = #{touchPrice}
+		WHERE
+		  orderId = #{orderId}
+	</update>
+
+	<delete id="deleteCouponOrderRecord">
+		DELETE FROM cm_coupon_order_record WHERE id = #{id}
+	</delete>
 </mapper>

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

@@ -144,7 +144,8 @@
 		a.machineType as "machineType",
 		a.trainingMethod as "trainingMethod",
 		a.trainingType as "trainingType",
-		a.trainingFee as "trainingFee"
+		a.trainingFee as "trainingFee",
+		a.commodityType as "commodityType"
 	</sql>
 
 	<sql id="productJoins">
@@ -2362,7 +2363,7 @@
 			<if test="productCategory !=null and productCategory !=''">
 				AND a.productCategory=#{productCategory}
 			</if>
-			<if test="ids.size() > 0">
+			<if test="ids != null and ids.size() > 0">
 				AND a.productID NOT IN
 				<foreach collection="ids" close=")" separator="," open="(" item="id">
 					#{id}

+ 28 - 13
src/main/webapp/WEB-INF/views/modules/archive/cmOrderArchiveForm.jsp

@@ -11,15 +11,19 @@
 				submitHandler: function(form){
 					var orderArchiveId = $("#id").val();
 					var shopOrderId = $("#shopOrderId").val();
-					$.post("${ctx}/archive/cmOrderArchive/checkShopOrderId",{"id":orderArchiveId,"shopOrderId":shopOrderId},function (result) {
-						if (result.code != 0) {
-							var errorMsg = result.msg;
-							jBox.tip(errorMsg, "error");
-						} else {
-							loading('正在提交,请稍等...');
-							form.submit();
-						}
-					})
+					if (isNaN(shopOrderId)) {
+						jBox.tip("请输入正确的子订单ID", "error");
+					} else {
+						$.post("${ctx}/archive/cmOrderArchive/checkShopOrderId",{"id":orderArchiveId,"shopOrderId":shopOrderId},function (result) {
+							if (result.code != 0) {
+								var errorMsg = result.msg;
+								jBox.tip(errorMsg, "error");
+							} else {
+								loading('正在提交,请稍等...');
+								form.submit();
+							}
+						});
+					}
 				},
 				errorContainer: "#messageBox",
 				errorPlacement: function(error, element) {
@@ -38,7 +42,18 @@
          * jquery控制input只能输入数字
          */
         function onlynum(obj) {
+            debugger
             obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+			var orderArchiveId = $("#id").val();
+			var shopOrderId = $("#shopOrderId").val();
+			if (shopOrderId.length >= 3) {
+				$.post("${ctx}/archive/cmOrderArchive/checkShopOrderId",{"id":orderArchiveId,"shopOrderId":shopOrderId},function (result) {
+					if (result.code == 0) {
+						$("#clubName").val(result.clubName);
+						$("#shopName").val(result.shopName);
+					}
+				});
+			}
         }
 	</script>
 	<style>
@@ -204,15 +219,15 @@
             </div>
 		</div>
 		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>供应商名称:</label>
+			<label class="control-label">供应商名称:</label>
 			<div class="controls">
-				<form:input path="shopName" htmlEscape="false" maxlength="50" class="input-xlarge required"/>
+				<form:input path="shopName" htmlEscape="false" maxlength="50" class="input-xlarge"/>
 			</div>
 		</div>
 		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>机构名称:</label>
+			<label class="control-label">机构名称:</label>
 			<div class="controls">
-				<form:input path="clubName" htmlEscape="false" maxlength="50" class="input-xlarge required"/>
+				<form:input path="clubName" htmlEscape="false" maxlength="50" class="input-xlarge"/>
 			</div>
 		</div>
 		<div class="control-group">

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

@@ -81,7 +81,7 @@
         </form:select>
         &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
         &nbsp;&nbsp;<input class="btn btn-primary" style="width: 120px"
-                           onclick="window.location='${ctx}/archive/cmOrderArchive/save'" value="生成订单资料编号"/>
+                           onclick="window.location='${ctx}/archive/cmOrderArchive/form'" value="添加"/>
         <div class="clearfix"></div>
     </div>
 </form:form>

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

@@ -344,6 +344,23 @@
         <tr>
             <td>
                 订单金额:¥<fmt:formatNumber type="number" value="${order.payTotalFee}" pattern="0.00" maxFractionDigits="2" />
+                <c:if test="${not empty order.couponOrderRecord}">
+                    <c:if test="${order.couponOrderRecord.couponType eq 0}">
+                        <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 test="${order.couponOrderRecord.couponType eq 1}">
+                        <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 test="${order.couponOrderRecord.couponType eq 2}">
+                        <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 test="${order.couponOrderRecord.couponType eq 3}">
+                        <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 test="${order.couponOrderRecord.couponType eq 4}">
+                        <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>
             </td>
             <td>
                 应收总额:¥<fmt:formatNumber type="number" value="${order.payableAmount}" pattern="0.00" maxFractionDigits="2" />(账户余额抵扣:${order.balancePayFee})

+ 18 - 1
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderConfirmReturnRecord.jsp

@@ -244,7 +244,24 @@
     </tr>
     <tr>
         <td>
-            订单金额:¥<fmt:formatNumber type="number" value="${order.payTotalFee}" pattern="0.00" maxFractionDigits="2"/>
+            订单金额:¥<fmt:formatNumber type="number" value="${order.payTotalFee}" pattern="0.00" maxFractionDigits="2"/>&nbsp;
+            <c:if test="${not empty order.couponOrderRecord}">
+                <c:if test="${order.couponOrderRecord.couponType eq 0}">
+                    <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 test="${order.couponOrderRecord.couponType eq 1}">
+                    <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 test="${order.couponOrderRecord.couponType eq 2}">
+                    <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 test="${order.couponOrderRecord.couponType eq 3}">
+                    <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 test="${order.couponOrderRecord.couponType eq 4}">
+                    <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>
         </td>
         <td>
             应收总额:¥<fmt:formatNumber type="number" value="${order.payableAmount}" pattern="0.00" maxFractionDigits="2"/>(账户余额抵扣:${order.balancePayFee})

+ 24 - 9
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductForm.jsp

@@ -104,6 +104,7 @@
             <th>总价</th>
             <th>能否复购</th>
             <th>促销活动</th>
+            <th>优惠券</th>
             <%--以下三个应付不显示,但是内容值参与计算并保存---关闭控制入口移动到财务管理中控制20181201--%>
             <%--<th>应付供应商</th>--%>
             <%--<th>应付第三方</th>--%>
@@ -188,7 +189,6 @@
                 <input type="hidden" name="addedValueTax" id="addedValueTax0"
                        value="${empty purchaseProduct.addedValueTax ?0:(purchaseProduct.addedValueTax)}" readonly
                        style="width: 80px">
-                <%--<input hidden id="addedValueTax0" value="${orderProduct.addedValueTax}">--%>
             </td>
             <td>
                 <input name="totalAddedValueTaxLabel" id="totalAddedValueTaxLabel"
@@ -197,7 +197,6 @@
                 <input type="hidden" name="totalAddedValueTax" id="totalAddedValueTax0"
                        value="${empty purchaseProduct.totalAddedValueTax ?0:(purchaseProduct.totalAddedValueTax)}"
                        readonly style="width: 80px">
-                <%--<input hidden id="totalAddedValueTax0" value="">--%>
             </td>
             <td>
                 <input name="totalFee" id="totalFee0"
@@ -205,7 +204,6 @@
                        readonly style="width: 80px">
                 <%--            <input name="totalFee" id="totalFee0" value="${empty purchaseProduct.totalFee ?0:(purchaseProduct.totalFee)}" readonly  style="width: 80px">--%>
                 <input hidden id="totalFee0" value="">
-                <%--<span id="totalFee0">0.00</span>--%>
             </td>
             <td>
 
@@ -249,6 +247,14 @@
                         <label>满${purchaseProduct.cmPromotion.touchPrice},赠送商品</label></a></label>
                 </c:if>
             </td>
+            <td>
+                <c:if test="${purchaseProduct.couponsLogo eq 1}">
+                    ----
+                </c:if>
+                <c:if test="${purchaseProduct.couponsLogo eq 2}">
+                    <a href="javascript:;" onclick="showSelect(${purchaseProduct.userId},${purchaseProduct.productId})">查看</a>
+                </c:if>
+            </td>
 
         <%--以下三个应付不显示,但是内容值参与计算并保存---关闭控制入口移动到财务管理中控制20181201--%>
         <td style="display: none"><input type="text" name="shopFee1" id="shopFee10" value= "${purchaseProduct.shopFee}" class="required1 " onchange="shopFee(0)"  style="width: 50px">
@@ -309,12 +315,6 @@
         });
         //初始化数据
         initData();
-//            $('.tr-item').each(function(index,element){
-//                var $discount = $("#discount" + index).val();
-//                if(null != $discount && "" != $discount){
-//                    discountPriceVal(index);
-//                }
-//            });
         changenum(0);
     });
 
@@ -388,6 +388,21 @@
         $num.val(1);
         alertx("二手仪器购买数量只能为1");
     }
+
+    // 展示优惠券列表
+    function showSelect(userId, productId) {
+        var url = "${ctx}/coupon/cmCoupon/productDetails?userId=" + userId + "&productId=" + productId;
+        var title = '';
+        title = "查看优惠券";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 600,
+            height: $(top.document).height() - 250,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1'}
+        });
+    }
 </script>
 </body>
 </html>

+ 25 - 29
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductList.jsp

@@ -222,34 +222,6 @@
                 return false;
             }
             items.push(json);
-            <%--if (null!=test&&typeof (test)!="undefined" &&test!="" ){//如果有赠送情况--%>
-            <%--$.ajax({--%>
-            <%--url: "${ctx}/bulkpurchase/purchaseProduct/returnProduct",--%>
-            <%--data: {"product": product, "test": "[" + test + "]"},--%>
-            <%--async: false,--%>
-            <%--type:"POST",--%>
-            <%--success: function (data) {--%>
-            <%--$items.each(function(){--%>
-            <%--items.push(data.purchaseProduct);--%>
-            <%--});--%>
-
-            <%--}--%>
-            <%--})--%>
-            <%--}else{--%>
-            <%--$.ajax({--%>
-            <%--url: "${ctx}/bulkpurchase/purchaseProduct/returnProduct",--%>
-            <%--data: {"product": product},--%>
-            <%--async: false,--%>
-            <%--type:"POST",--%>
-            <%--success: function (data) {--%>
-            <%--$items.each(function(){--%>
-            <%--items.push(data.purchaseProduct);--%>
-            <%--});--%>
-
-            <%--}--%>
-            <%--}--%>
-            <%--)--%>
-            <%--}--%>
             return items;
         }
         function onlynum(obj) {
@@ -305,7 +277,7 @@
             <th>总价</th>
             <th>能否复购</th>
             <th>促销活动</th>
-
+            <th>优惠券</th>
         </tr>
         </thead>
         <tbody>
@@ -500,6 +472,14 @@
                 <td style="display: none">
                     <input name="oldProductFlag"  id="oldProductFlag${state.index}" value="${purchaseProduct.oldProductFlag}" readonly  style="width: 80px">
                 </td>
+                <td>
+                    <c:if test="${purchaseProduct.couponsLogo eq 1}">
+                        ----
+                    </c:if>
+                    <c:if test="${purchaseProduct.couponsLogo eq 2}">
+                        <a href="javascript:;" onclick="showSelect(${userId},${purchaseProduct.productId})">查看</a>
+                    </c:if>
+                </td>
             </tr>
         </c:forEach>
         </tbody>
@@ -507,5 +487,21 @@
 </div>
 <div class="pagination">${page}</div>
 <script type="text/javascript" src="${ctxStatic}/modules/bulkpurchase/orderForm.js?<%=Math.random()%>"></script>
+<script>
+    // 展示商品选择框
+    function showSelect(userId, productId) {
+        var url = "${ctx}/coupon/cmCoupon/productDetails?userId=" + userId + "&productId=" + productId;
+        var title = '';
+        title = "查看优惠券";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 600,
+            height: $(top.document).height() - 250,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1'}
+        });
+    }
+</script>
 </body>
 </html>

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

@@ -355,6 +355,23 @@
             <tr>
                 <td>
                     订单金额:¥<fmt:formatNumber type="number" value="${order.payTotalFee}" pattern="0.00" maxFractionDigits="2" />
+                    <c:if test="${not empty order.couponOrderRecord}">
+                        <c:if test="${order.couponOrderRecord.couponType eq 0}">
+                            <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 test="${order.couponOrderRecord.couponType eq 1}">
+                            <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 test="${order.couponOrderRecord.couponType eq 2}">
+                            <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 test="${order.couponOrderRecord.couponType eq 3}">
+                            <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 test="${order.couponOrderRecord.couponType eq 4}">
+                            <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>
                 </td>
                 <td>
                     应收总额:¥<fmt:formatNumber type="number" value="${order.payableAmount}" pattern="0.00" maxFractionDigits="2" />(账户余额抵扣:${order.balancePayFee})

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

@@ -325,6 +325,23 @@
     <tr>
         <td>
             订单金额:¥<fmt:formatNumber type="number" value="${order.payTotalFee}" pattern="0.00" maxFractionDigits="2" />
+            <c:if test="${not empty order.couponOrderRecord}">
+                <c:if test="${order.couponOrderRecord.couponType eq 0}">
+                    <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 test="${order.couponOrderRecord.couponType eq 1}">
+                    <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 test="${order.couponOrderRecord.couponType eq 2}">
+                    <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 test="${order.couponOrderRecord.couponType eq 3}">
+                    <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 test="${order.couponOrderRecord.couponType eq 4}">
+                    <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>
         </td>
         <td>
             应收总额:¥<fmt:formatNumber type="number" value="${order.payableAmount}" pattern="0.00" maxFractionDigits="2" />(账户余额抵扣:${order.balancePayFee})

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

@@ -169,6 +169,23 @@
     <tr>
         <td>
             订单金额:¥${order.payTotalFee}
+            <c:if test="${not empty order.couponOrderRecord}">
+                <c:if test="${order.couponOrderRecord.couponType eq 0}">
+                    <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 test="${order.couponOrderRecord.couponType eq 1}">
+                    <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 test="${order.couponOrderRecord.couponType eq 2}">
+                    <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 test="${order.couponOrderRecord.couponType eq 3}">
+                    <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 test="${order.couponOrderRecord.couponType eq 4}">
+                    <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>
         </td>
         <td>
             应收总额:¥${order.payableAmount}

+ 3 - 3
src/main/webapp/WEB-INF/views/modules/cmpage/cmPageBeautyForm.jsp

@@ -79,7 +79,7 @@
             <sys:ckfinder input="headImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
         </div>
         <div class="controls" style="padding-top: 20px;">
-        <label style="color:#D0D0D0 ;">建议图片尺寸1920*510px</label>
+        <label style="color:#D0D0D0 ;">建议图片尺寸1920*480px</label>
         </div>
     </div>
     <div class="control-group">
@@ -89,7 +89,7 @@
             <sys:ckfinder input="crmHeadImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
         </div>
         <div class="controls" style="padding-top: 20px;">
-            <label style="color:#D0D0D0 ;">建议图片尺寸750px*366px</label>
+            <label style="color:#D0D0D0 ;">建议图片尺寸1000px*450px</label>
         </div>
     </div>
     <div class="control-group">
@@ -116,8 +116,8 @@
         <label class="control-label">咨询浮窗:</label>
         <div class="controls">
             <form:select path="infoBarStatus" class="input-xlarge ">
-                <form:option value="0" label="停用"/>
                 <form:option value="1" label="启用"/>
+                <form:option value="0" label="停用"/>
             </form:select>
         </div>
     </div>

+ 126 - 0
src/main/webapp/WEB-INF/views/modules/coupon/clubCouponDetails.jsp

@@ -0,0 +1,126 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>优惠券详情</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th{text-align: center;}
+        .table td{text-align: center;}
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function() {
+
+        });
+        function page(n,s){
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/coupon/cmCouponClub/userList">领取用户列表</a></li>
+    <li class="active"><a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${cmCouponClub.userId}">优惠券详情</a></li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmCouponClub" action="${ctx}/coupon/cmCouponClub/couponDetails" method="post" class="breadcrumb form-search">
+    <input type="hidden" name="userId" value="${cmCouponClub.userId}">
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>机构名称:</label>
+            ${cmCouponClub.clubName}
+        <label style="margin-left: 80px">剩余优惠券数量:</label>
+            ${cmCouponClub.num}
+        <br>
+        <label>优惠券类型:</label>
+        <form:select path="couponType" class="input-medium">
+            <form:option value="" label="全部"/>
+            <form:option value="0" label="活动券"/>
+            <form:option value="1" label="品类券"/>
+            <form:option value="2" label="用户专享券"/>
+            <form:option value="3" label="店铺券"/>
+            <form:option value="4" label="新用户券"/>
+        </form:select>
+        <label>优惠状态:</label>
+        <form:select path="couponStatus" class="input-medium">
+            <form:option value="" label="全部"/>
+            <form:option value="1" label="已生效"/>
+            <form:option value="2" label="已关闭"/>
+            <form:option value="3" label="已失效"/>
+        </form:select>
+        <label>使用状态:</label>
+        <form:select path="status" class="input-medium">
+            <form:option value="" label="全部"/>
+            <form:option value="1" label="未使用"/>
+            <form:option value="2" label="已使用"/>
+        </form:select>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>优惠券类型</th>
+        <th>优惠券金额</th>
+        <th>优惠条件</th>
+        <th>领取时间</th>
+        <th>优惠状态</th>
+        <th>使用状态</th>
+        <th>使用时间</th>
+        <th>关联订单</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="cmCoupon">
+        <tr>
+            <td>
+                    ${cmCoupon.couponType eq 0 ? "活动券":cmCoupon.couponType eq 1 ? "品类券":cmCoupon.couponType eq 2 ? "用户专享券":cmCoupon.couponType eq 3 ? "店铺券":"新用户券"}
+            </td>
+            <td>
+                    ${cmCoupon.couponAmount}
+            </td>
+            <td>
+                满${cmCoupon.touchPrice}
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <c:if test="${cmCoupon.couponStatus eq 1}">
+                    <font color="#00CC66">已生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.couponStatus eq 2}">
+                    <font color="red">已关闭</font>
+                </c:if>
+                <c:if test="${cmCoupon.couponStatus eq 3}">
+                    <font color="#FF6600">已失效</font>
+                </c:if>
+            </td>
+            <td>
+               ${cmCoupon.status eq 1 ? "未使用" : "已使用"}
+            </td>
+            <td>
+                <c:if test="${cmCoupon.status eq 1}">
+                    ----
+                </c:if>
+                <c:if test="${cmCoupon.status eq 2}">
+                    <fmt:formatDate value="${cmCoupon.useDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+                </c:if>
+            </td>
+            <td>
+                <c:if test="${not empty cmCoupon.orderId}">
+                    <a href="${ctx}/order/detail?id=${cmCoupon.orderId}">${cmCoupon.orderNo}(${cmCoupon.orderId})</a>
+                </c:if>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+</body>
+</html>

+ 0 - 105
src/main/webapp/WEB-INF/views/modules/coupon/cmClubListBox.jsp

@@ -1,105 +0,0 @@
-<%@ page contentType="text/html;charset=UTF-8" %>
-<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
-<html>
-<head>
-	<title>会所信息管理</title>
-	<meta name="decorator" content="default"/>
-	<style type="text/css">
-		.table th{text-align: center;}
-		.table td{text-align: center;}
-	</style>
-	<script type="text/javascript">
-		$(document).ready(function() {
-			
-		});
-		function page(n,s){
-			$("#pageNo").val(n);
-			$("#pageSize").val(s);
-			$("#searchForm").submit();
-        	return false;
-        }
-
-        function checkNum() {
-            var clubID = $("#clubID").val();
-		    if(isNaN(clubID)){//如果不是数字则清空
-                $("#clubID").val("");
-			}
-        }
-
-        function allCkbfun(ckb){
-            var isChecked = ckb.checked;
-            $(".check-item").attr('checked', isChecked);
-        }
-        function getCheckedItems(){
-            var items = new Array();
-            var $items = $('.check-item:checked');
-            $items.each(function(){
-                items.push($(this).val());
-            });
-            return items;
-        }
-	</script>
-</head>
-<body>
-
-	<form:form id="searchForm" modelAttribute="newCmClub" action="${ctx}/coupon/cmCouponClub/showClubList" method="post" class="breadcrumb form-search">
-		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
-		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
-		<div class="ul-form">
-			 <label>会所ID:</label>
-			<form:input path="clubID" id="clubID" htmlEscape="false" maxlength="8" class="input-mini" onchange="checkNum()"/>
-			 <label>会所名称:</label>
-				<form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
-			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
-			<div class="clearfix"></div>
-		</div>
-	</form:form>
-	<sys:message content="${message}"/>
-	<table id="contentTable" class="table table-striped table-bordered table-condensed">
-		<thead>
-			<tr>
-				<th style="width:20px;"></th>
-				<th>会所ID</th>
-				<th>会所名称</th>
-				<th>会所简称</th>
-				<th>联系人</th>
-				<th>手机号</th>
-			</tr>
-		</thead>
-		<tbody>
-		<c:forEach items="${page.list}" var="cmClub">
-			<tr id="${cmClub.clubID}">
-				<th><input class="check-item" type="radio" name="cmClub"
-							   value='${fns:toJson(cmClub)}'/></th>
-				<td>
-					${cmClub.clubID}
-				</td>
-				<td>
-					${cmClub.name}
-				</td>
-				<td>
-					<c:if test="${empty cmClub.sname}">
-						------
-					</c:if>
-					<c:if test="${not empty cmClub.sname}">
-					${cmClub.sname}
-					</c:if>
-				</td>
-				<td>
-					<c:if test="${empty cmClub.linkMan}">
-						------
-					</c:if>
-					<c:if test="${not empty cmClub.linkMan}">
-					${cmClub.linkMan}
-					</c:if>
-				</td>
-				<td>
-					${cmClub.contractMobile}
-				</td>
-			</tr>
-		</c:forEach>
-		</tbody>
-	</table>
-	<div class="pagination">${page}</div>
-</body>
-</html>

+ 57 - 218
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponClubList.jsp

@@ -2,7 +2,7 @@
 <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
 <html>
 <head>
-	<title>采美优惠券活动签约会所管理</title>
+	<title>优惠券管理</title>
 	<meta name="decorator" content="default"/>
 	<style type="text/css">
 		.table th{text-align: center;}
@@ -18,252 +18,91 @@
 			$("#searchForm").submit();
         	return false;
         }
-        /**
-         * 展示会所选择框
-         * @param iframe
-         */
-        function addClub(iframe) {
-            top.$.jBox(iframe, {
-                iframeScrolling: 'yes',
-                width: $(top.document).width() - 400,
-                height: $(top.document).height() - 160,
-                persistent: true,
-                showScrolling: false,
-                title: "选择会所",
-                bottomText: '请从可供选择的项目中选择一个',
-                buttons: {"确定": '1', "关闭": '-1'},
-                submit: function (v, h, f) {
-                    //确定
-                    var $jboxFrame = top.$('#jbox-iframe');
-                    var $mainFrame = top.$('#mainFrame');
-                    if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
-                        var items = $jboxFrame[0].contentWindow.getCheckedItems();
-                        if (items.length > 0) {
-                            var id = JSON.parse(items[0]).clubID;
-                            window.location.href ="${ctx}/coupon/cmCouponClub/addClub?clubID=" + id;
-                            return true;
-                        } else {
-                            top.$.jBox.tip("请选择...");
-                            return false;
-                        }
-                    }
-                    return true;
-                }
-            });
-        }
-
-        /**
-		 * 发送优惠券
-         * @param iframe
-         */
-        function sendCoupon(iframe) {
-            top.$.jBox(iframe, {
-                iframeScrolling: 'yes',
-                width: $(top.document).width() - 800,
-                height: $(top.document).height() - 200 ,
-                persistent: true,
-                showScrolling: false,
-                title: "选择优惠券",
-                bottomText: '请选择一类优惠券并填写数量',
-                buttons: {"确定": '1', "关闭": '-1'},
-                submit: function (v, h, f) {
-                    //确定
-                    var $jboxFrame = top.$('#jbox-iframe');
-                    var $mainFrame = top.$('#mainFrame');
-                    if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
-                        var items = $jboxFrame[0].contentWindow.getCheckedItems();
-                        if (items.length > 0) {
-                            var couponCode = JSON.parse(items[0]).couponCode;
-                            var laveNum = JSON.parse(items[0]).laveNum;
-                            var num = JSON.parse(items[0]).num;
-                            if (!(/(^[1-9]\d*$)/.test(num))) {
-                                top.$.jBox.tip("输入的不是正整数");
-                                return false;
-                            }
-                            if(null == num || "" == num){
-                                top.$.jBox.tip("请输入该劵的派送数量");
-                                return false;
-							}
-                            if(num >laveNum){
-                                top.$.jBox.tip("派送数量不能超过剩余数量");
-                                return false;
-							}
-                            var couponAmount = JSON.parse(items[0]).couponAmount;
-                            var threshold = JSON.parse(items[0]).threshold;
-                            var couponType = JSON.parse(items[0]).couponType;
-                            var userID = JSON.parse(items[0]).userID;
-                            window.location.href ="${ctx}/coupon/cmCouponClub/addCoupon?couponCode="+couponCode+"&num="+num+"&couponAmount="+couponAmount+"&threshold="+threshold+"&couponType="+couponType+"&userID="+userID;
-                            return true;
-                        } else {
-                            top.$.jBox.tip("请选择...");
-                            return false;
-                        }
-                    }
-                    return true;
-                }
-            });
-        }
-
-
-        // 解除签约
-        function modifyWin(id){
-            var html = "<div style='font-size:20px;text-align: center;padding-top: 20px'>确认解除签约?</div>";
-            top.$.jBox(html, {
-                title:"解除签约",
-                top:150,
-                width: 300,
-                height: 150,
-                persistent: true,
-                buttons:{"解除签约":'1',"取消":'-1'},
-                submit:function(v, h, f){
-                    //修改
-                    if('1'==v){
-                        $.post("${ctx}/coupon/cmCouponClub/dismissal",{'id':id}, function(data) {
-                            if(true==data.success){
-                                refresh();
-                                $.jBox.tip(data.msg, 'info');
-                            } else {
-                                $.jBox.tip(data.msg,'error');
-                            }
-                        },"JSON");//这里返回的类型有:json,html,xml,text
-                        refresh();
-                    }
-                    return true;
-                }
-            });
-
-        }
-
-
-        // 解除签约
-        function signing(id){
-            var html = "<div style='font-size:20px;text-align: center;padding-top: 20px'>确认置为已签约?</div>";
-            top.$.jBox(html, {
-                title:"置为已签约",
-                top:150,
-                width: 300,
-                height: 150,
-                persistent: true,
-                buttons:{"置为已签约":'1',"取消":'-1'},
-                submit:function(v, h, f){
-                    //修改
-                    if('1'==v){
-                        $.post("${ctx}/coupon/cmCouponClub/signing",{'id':id}, function(data) {
-                            if(true==data.success){
-                                refresh();
-                                $.jBox.tip(data.msg, 'info');
-                            } else {
-                                $.jBox.tip(data.msg,'error');
-                            }
-                        },"JSON");//这里返回的类型有:json,html,xml,text
-                        refresh();
-                    }
-                    return true;
-                }
-            });
-
-        }
-        function refresh(){
-            window.location.href="${ctx}/coupon/cmCouponClub/";
-        }
 	</script>
 </head>
 <body>
 	<ul class="nav nav-tabs">
-		<li class="active"><a href="${ctx}/coupon/cmCouponClub/">会所列表</a></li>
+		<c:if test="${cmCouponClub.couponType eq 0}">
+			<li><a href="${ctx}/coupon/cmCoupon/list?couponType=0">活动券</a></li>
+		</c:if>
+		<c:if test="${cmCouponClub.couponType eq 1}">
+			<li><a href="${ctx}/coupon/cmCoupon/list?couponType=1">品类券</a></li>
+		</c:if>
+		<c:if test="${cmCouponClub.couponType eq 3}">
+			<li><a href="${ctx}/coupon/cmCoupon/list?couponType=3">店铺券</a></li>
+		</c:if>
+		<c:if test="${cmCouponClub.couponType eq 4}">
+			<li><a href="${ctx}/coupon/cmCoupon/list?couponType=4">新用户券</a></li>
+		</c:if>
+		<li class="active"><a href="${ctx}/coupon/cmCouponClub/list?couponId=${cmCouponClub.couponId}&couponType=${cmCouponClub.couponType}">领取用户列表</a></li>
 	</ul>
 	<form:form id="searchForm" modelAttribute="cmCouponClub" action="${ctx}/coupon/cmCouponClub/" method="post" class="breadcrumb form-search">
+		<input type="hidden" name="couponId" value="${cmCouponClub.couponId}">
+		<input type="hidden" name="couponType" value="${cmCouponClub.couponType}">
 		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
 		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
 		<div class="ul-form">
-			<label>会所名称:</label>
-				<form:input path="name" htmlEscape="false" maxlength="15" class="input-mini"/>
-			<label>会所状态:</label>
-			<form:select path="status" class="input-small">
-				<form:option value="" label="请选择"/>
-				<form:options items="${fns:getDictList('cm_coupon_club_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
-			</form:select>
-			<label>签约时间:</label>
-			<form:input path="startTime" type="text" maxlength="20" class="input-mini Wdate" value="${startTime}"
-						onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
-			-
-			<form:input path="endTime" type="text" maxlength="20" class="input-mini Wdate" value="${endTime}"
-						onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
-			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="筛选会所"/>
+			 <label>机构名称:</label>
+				<form:input path="clubName" htmlEscape="false" class="input-medium"/>
+			 <label>领取渠道:  :</label>
+				<form:select path="source" class="input-medium">
+					<form:option value="" label="全部"/>
+					<form:option value="1" label="小程序"/>
+					<form:option value="2" label="网站"/>
+					<form:option value="3" label="订单退回"/>
+				</form:select>
+			 <label>使用状态:</label>
+				<form:select path="status" class="input-medium">
+					<form:option value="" label="全部"/>
+					<form:option value="1" label="未使用"/>
+					<form:option value="2" label="已使用"/>
+				</form:select>
+			 <label>领取时间:</label>
+				<input name="createDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+					value="<fmt:formatDate value="${cmCouponClub.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
+			 <label>使用时间:</label>
+				<input name="useDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+					value="<fmt:formatDate value="${cmCouponClub.useDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
+			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
 			<div class="clearfix"></div>
 		</div>
 	</form:form>
 	<sys:message content="${message}"/>
-	<div class="breadcrumb">数据列表 &nbsp;&nbsp<input id="CmclubSelected" class="btn btn-primary" type="button" value="添加会所" onclick="addClub('iframe:${ctx}/coupon/cmCouponClub/showClubList')"/></div>
-	<div style="padding-left: 30px;">
-		<img src="/static/images/warning.png" style="display: inline-block;vertical-align: top;width: 18px;height: 18px;">
-		<div style="display: inline-block;">
-			<p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">1、本次添加会所均为会所企业账号,会所员工/经理不存在此列表</p>
-		</div>
-	</div>
-
 	<table id="contentTable" class="table table-striped table-bordered table-condensed">
 		<thead>
 			<tr>
-				<th>
-					会所ID
-				</th>
-				<th>会所名称</th>
-				<th>会所简称</th>
-				<th>联系人</th>
-				<th>手机号</th>
-				<th>签约时间</th>
-				<th>会所状态</th>
-				<th>累计返现</th>
-				<shiro:hasPermission name="coupon:cmCouponClub:edit"><th>操作</th></shiro:hasPermission>
+				<th>机构名称</th>
+				<th>领取渠道</th>
+				<th>使用状态</th>
+				<th>领取时间</th>
+				<th>使用时间</th>
 			</tr>
 		</thead>
 		<tbody>
 		<c:forEach items="${page.list}" var="cmCouponClub">
 			<tr>
-				<td>${cmCouponClub.clubId}</td>
-				<td>${cmCouponClub.name}</td>
 				<td>
-					<c:if test="${empty cmCouponClub.sname}">
-						------
-					</c:if>
-					<c:if test="${not empty cmCouponClub.sname}">
-						${cmCouponClub.sname}
-					</c:if>
+					${cmCouponClub.clubName}
 				</td>
 				<td>
-					<c:if test="${empty cmCouponClub.linkMan}">
-						------
-					</c:if>
-					<c:if test="${not empty cmCouponClub.linkMan}">
-						${cmCouponClub.linkMan}
-					</c:if>
+					${cmCouponClub.source eq "1" ? "网站": cmCouponClub.source eq "2" ? "小程序" : "订单退回"}
 				</td>
-				<td>${cmCouponClub.contractMobile}</td>
 				<td>
-					<c:if test="${empty cmCouponClub.signDate}">
-						------
+					<c:if test="${cmCouponClub.status eq '1'}">
+						<font color="red">未使用</font>
 					</c:if>
-					<c:if test="${not empty cmCouponClub.signDate}">
-						<fmt:formatDate value="${cmCouponClub.signDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+					<c:if test="${cmCouponClub.status eq '2'}">
+						<font color="#00CC66">已使用</font>
 					</c:if>
 				</td>
-				<td>${fns:getDictLabel(cmCouponClub.status,"cm_coupon_club_status","" )}</td>
-				<td>------</td>
-				<shiro:hasPermission name="coupon:cmCouponClub:edit"><td>
-					<c:if test="${cmCouponClub.status == 1}">
-						<a href="javascript:void(0);" onclick="modifyWin(${cmCouponClub.id})">解除签约</a>
-						<%--发送优惠券--%>
-						<a href="javascript:void(0);" onclick="sendCoupon('iframe:${ctx}/coupon/cmCouponClub/showCouponList?userID='+${cmCouponClub.userID})"/>发送优惠券</a>
-					</c:if>
-					<c:if test="${cmCouponClub.status == 2}">
-						<a href="javascript:void(0);" onclick="signing(${cmCouponClub.id})">置为已签约</a>
-						<%--<a href="${ctx}/coupon/cmCouponClub/signing?id=${cmCouponClub.id}" >置为已签约</a>--%>
-					</c:if>
-						<shiro:hasPermission name="coupon:cmCouponClub:delete">
-						<a href="${ctx}/coupon/cmCouponClub/delete?id=${cmCouponClub.id}" onclick="return confirmx('确认要删除吗?', this.href)">删除</a>
-						</shiro:hasPermission>
-				</td></shiro:hasPermission>
+				<td>
+					<fmt:formatDate value="${cmCouponClub.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+					<fmt:formatDate value="${cmCouponClub.useDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
 			</tr>
 		</c:forEach>
 		</tbody>

+ 566 - 0
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponForm.jsp

@@ -0,0 +1,566 @@
+<%@ page import="java.util.Date" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+	<title>优惠券管理</title>
+	<meta name="decorator" content="default"/>
+	<script type="text/javascript">
+		$(document).ready(function() {
+			//$("#name").focus();
+			$("#inputForm").validate({
+				submitHandler: function(form){
+					if (imageList.length > 0) {
+						var productInfo = JSON.stringify(imageList);
+						$('#productInfo').val(productInfo);
+					}
+					var  productType = $("input[name='productType']:checked").val();
+					if (productType == 2){
+						var pcBanner = $('#pcBanner').val();
+						var appletsBanner = $('#appletsBanner').val();
+						if (pcBanner == '' || appletsBanner == '') {
+							alertx("请上传Banner图");
+							return false;
+						}
+					}
+					var couponAmount = $("#couponAmount").val()*1;
+					var touchPrice = $("#touchPrice").val()*1;
+					if (couponAmount >= touchPrice) {
+						alertx("优惠券金额必须小于优惠条件金额");
+						return false;
+					}
+					var startDate = $("#startDate").val();
+					var endDate = $("#endDate").val();
+					if (startDate >= endDate) {
+						alertx("结束时间不能早于开始时间");
+						return false;
+					}
+					loading('正在提交,请稍等...');
+					form.submit();
+				},
+				errorContainer: "#messageBox",
+				errorPlacement: function(error, element) {
+					$("#messageBox").text("输入有误,请先更正。");
+					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
+						error.appendTo(element.parent().parent());
+					} else {
+						error.insertAfter(element);
+					}
+				}
+			});
+		});
+	</script>
+
+	<style>
+		.iconBox {
+			font-size: 0;
+		}
+		.conList .btn:nth-of-type(1){
+			margin-left: 25px;
+		}
+		.upload-content-image {
+			margin-top: -70px;
+		}
+
+		.upload-content-image .conList .btn:nth-of-type(1) {
+			width: 90px;
+			height: 100px;
+			border: 2px solid #eee;
+			background: #fff;
+			position: relative;
+		}
+
+		.upload-content-image .conList .btn:nth-of-type(1) > div {
+			position: absolute;
+			top: 50%;
+			left: 50%;
+			transform: translate(-50%, -50%);
+			color: #666;
+		}
+
+		.upload-content-image .conList .btn:nth-of-type(1) span {
+			font-size: 35px;
+		}
+
+		.upload-content-image .conList .btn:nth-of-type(1) h5 {
+			color: #666;
+		}
+		.upload-content-image .conList ol li {
+			width: 114px;
+			min-height: 80px;
+			text-align: center;
+			background: #fff;
+			position: relative;
+			top: 120px;
+			margin-left: 2px;
+		}
+		.cancel-upload-image {
+			background: transparent;
+			border: none;
+			box-shadow: none;
+			position: relative;
+			top: -38px;
+			left: -25px;
+			cursor: pointer;
+			z-index: 100;
+		}
+		.hide-pic-image {
+			display: none !important;
+		}
+	</style>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=0">活动券</a></li>
+		<li class="active"><a href="${ctx}/coupon/cmCoupon/form?couponType=0&id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a></li>
+	</ul><br/>
+	<font style="color: red;margin-left: 20px">活动券适合在某些节日或者主题活动时创建,并且适用于全部客户以及商城全部商品或指定商品(不包括二手商品)。</font><br><br>
+	<form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/save" method="post" class="form-horizontal">
+		<form:hidden path="id"/>
+		<form:hidden path="productInfo" id="productInfo"/>
+		<input type="hidden" name="couponType" value="0"/>
+		<sys:message content="${message}"/>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>活动主题:</label>
+			<div class="controls">
+				<form:input path="name" htmlEscape="false" maxlength="30" placeholder="30个汉字以内" class="input-xlarge required"/>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>优惠券金额:</label>
+			<div class="controls">
+				<input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0" required>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>优惠条件:</label>
+			<div class="controls">
+				订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice" value="${cmCoupon.touchPrice}" min="0" required>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>开始时间:</label>
+			<div class="controls">
+				<input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
+					value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});" onblur="dateShow()">
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>结束时间:</label>
+			<div class="controls">
+				<input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
+					value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
+					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">
+				<label id="initializeShow">
+					<c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
+						<font color="#800080">未生效</font>
+					</c:if>
+					<c:if test="${cmCoupon.status eq 1}">
+						<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>
+					</c:if>
+				</label>
+				<label id="closeShow" style="display: none">
+					<font color="red">已关闭</font>
+				</label>
+				<input type="hidden" id="hiddenStatus" name="status" value="">
+				<input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""} onclick="statusShow()" />关闭
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>优惠商品:</label>
+			<div class="controls">
+				<form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked ="${empty cmCoupon.productType ? true:false}"/>
+				<form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()"/>
+			</div>
+		</div>
+		<div class="productData" hidden="hidden">
+			<div class="control-group">
+				<label class="control-label"><font color="red">*</font>网站活动页banner:</label>
+				<div class="controls upload-content-image iconBox">
+					<div class="conList">
+						<form:hidden id="pcBanner" path="pcBanner" htmlEscape="false" maxlength="255" class="input-xlarge"/>
+						<sys:ckfinder input="pcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+						<br>
+					</div>
+				</div>
+			</div>
+			<div class="control-group">
+				<label class="control-label"><font color="red">*</font>小程序活动页banner:</label>
+				<div class="controls upload-content-image iconBox">
+					<div class="conList">
+						<form:hidden id="appletsBanner" path="appletsBanner" htmlEscape="false" maxlength="255" class="input-xlarge"/>
+						<sys:ckfinder input="appletsBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+						<br>
+					</div>
+				</div>
+			</div>
+			<div class="control-group">
+				<input class="btn" id="del" style="width: 50px" onclick="batchDeletion()" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
+				<input class="btn btn-primary" style="width: 70px" onclick="batchSaveSort()" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;
+				<input class="btn btn-primary" style="width: 50px" onclick="showSelect()" value="添加"/>
+				<br><br>
+				<table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
+					<thead>
+					<tr>
+						<th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/> 全选
+						</th>
+						<th>商品图片</th>
+						<th>商品名称</th>
+						<th>供应商</th>
+						<th>网站状态</th>
+						<th>小程序状态</th>
+						<th>排序</th>
+						<th>添加时间</th>
+						<th>操作</th>
+					</tr>
+					</thead>
+					<tbody id="hotSearch"></tbody>
+				</table>
+			</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)"/>
+		</div>
+	</form:form>
+<script>
+	//图片初始化
+	$(function () {
+		$('.upload-content-image .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
+		$('.upload-content-image .conList .btn:nth-of-type(2)').after('<img class="cancel-upload-image" src="/static/images/close-btn1.png">').remove();
+		$('.upload-content-image .conList').find('.cancel-upload-image').hide();
+		var observeEleImage = document.getElementsByClassName('upload-content-image')[0];
+		var observeEleImage1 = document.getElementsByClassName('upload-content-image')[1];
+		var MutationObserverImage = window.MutationObserver || window.WebKitMutationObserver;
+		var MutationObserverConfigImage = {
+			childList: true,
+			subtree: true,
+			characterData: true
+		};
+		var observerImage = new MutationObserverImage(function (mutations) {
+			$.each(mutations, function (index, item) {
+				if (item.type === 'childList') {
+					// 在创建新的 element 时调用
+					var target = $(item.target),
+							thisWrapper = target.closest('.conList'),
+							nextEle = thisWrapper.next();
+					thisWrapper.find('li').css('z-index', 99);
+					thisWrapper.find('.cancel-upload-image').show();
+					if (nextEle.hasClass('hide-pic-image')) {
+						nextEle.removeClass('hide-pic-image');
+					}
+				}
+			})
+		});
+		observerImage.observe(observeEleImage, MutationObserverConfigImage);
+		observerImage.observe(observeEleImage1, MutationObserverConfigImage);
+
+		$('body').on('click', '.upload-content-image li', function () {
+			var index = $(this).closest('.conList').index() + 1,
+					str = 'remarkImage' + index + 'FinderOpen';
+			eval(str + '()');
+		});
+		$('body').on('click', '.cancel-upload-image', function () {
+			var wrapper = $(this).closest('.conList');
+			wrapper.find('li').css('z-index', '-1');
+			wrapper.find('input').val('');
+			$(this).hide();
+			wrapper.removeClass("hide-pic-image");
+			wrapper.parent().append(wrapper.clone());
+			wrapper.remove();
+			$(".conList").each(function (i, ele) {
+				if ($(ele).find("input.input-xlarge").val()) {
+					$(ele).next().removeClass("hide-pic-image")
+				}
+			})
+		});
+		$(window).on("load", function () {
+			setTimeout(function () {
+				var input = $("#pcBanner");
+				if (input.val()) {
+					input.next().find("li").css("z-index", "99");
+					input.parents(".conList").find(".cancel-upload-image").show();
+					input.parents(".conList").next().removeClass("hide-pic-image")
+				}
+				input = $("#appletsBanner");
+				if (input.val()) {
+					input.next().find("li").css("z-index", "99");
+					input.parents(".conList").find(".cancel-upload-image").show();
+					input.parents(".conList").next().removeClass("hide-pic-image")
+				}
+			}, 500);
+		});
+		productShow()
+	});
+
+	var productIds = '';
+	var imageList = [];
+
+	$(function () {
+		<c:forEach items="${associateList}" var="associate" varStatus="index">
+		imageList.push({
+			id: "${associate.id}",
+			productId: "${empty associate.productId ? "":associate.productId}",
+			image: "${associate.image}",
+			productName: "${associate.productName}",
+			shopName: "${associate.shopName}",
+			sort: "${associate.sort}",
+			pcStatus: "${associate.pcStatus}",
+			appletsStatus: "${associate.appletsStatus}",
+			addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+		});
+		</c:forEach>
+
+		if (imageList.length > 0) {
+			$('#contentTable').show();
+			batchSaveSort();
+		}
+	});
+
+	//点击添加
+	function showSelect() {
+		var url = "${ctx}/coupon/cmCoupon/toAddProduct?productIds=" + productIds;
+		var title = '';
+		title = "选择商品";
+		top.$.jBox("iframe:" + url, {
+			iframeScrolling: 'yes',
+			width: $(top.document).width() - 400,
+			height: $(top.document).height() - 160,
+			persistent: true,
+			title: title,
+			buttons: {"确定": '1', "取消": '-1'},
+			submit: function (v, h, f) {
+				//确定
+				var $jboxFrame = top.$('#jbox-iframe');
+				var $mainFrame = top.$('#mainFrame');
+				if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+					var items = $jboxFrame[0].contentWindow.getCheckedItems();
+					console.log(items);
+					console.log(items[0]);
+					for (var i = 0; i < items.length; i++) {
+						console.log(items[i]);
+						imageList.push(items[i]);
+						$('#contentTable').show();
+						$("#del").removeAttr("disabled");
+						batchSaveSort();
+					};
+				}
+				return true;
+			}
+		});
+	}
+
+	/**
+	 * 一键排序
+	 */
+	function batchSaveSort() {
+		imageList.sort(sort);
+		insertHtml(imageList);
+	}
+
+	//根据sort值 从小到大排序
+	function sort(a, b) {
+		return a.sort - b.sort;
+	}
+
+	//相关图片列表数据
+	function appendShopOrderHead(data, index) {
+		var html = '<tr id ="ai' + index + '">' +
+				'<td>' +
+				'<input class="check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
+				'</td>' +
+				'<td>' +
+				'<img src="' + data.image + '" width="60px" border="none" title="启用">' +
+				'</td>' +
+				'<td>' +
+				data.productName +
+				'</td>' +
+				'<td>' +
+				data.shopName +
+				'</td>' +
+				'<td>' +
+				(data.pcStatus == 1 ? (
+						'<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
+						'<a href="javascript:void(0);" onclick="updatePcStatus(0,' + index + ');" >' +
+						'停用</a>'
+				) : (
+						'<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
+						'<a href="javascript:void(0)" onclick="updatePcStatus(1,' + index + ');">' +
+						'启用</a>'
+				)) +
+				'</td>' +
+				'<td>' +
+				(data.appletsStatus == 1 ? (
+						'<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
+						'<a href="javascript:void(0);" onclick="updateAppletsStatus(0,' + index + ');" >' +
+						'停用</a>'
+				) : (
+						'<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
+						'<a href="javascript:void(0)" onclick="updateAppletsStatus(1,' + index + ');">' +
+						'启用</a>'
+				)) +
+				'</td>' +
+				'<td>' +
+				'<input name="sort" style="width:50px;" value="' + data.sort + '"  onkeyup="onlynum(this)"  onchange="changeSort(' + index + ',this)"></td>' +
+				'</td>' +
+				'<td>' +
+				(data.addTime == '' ? (
+						'<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
+				) : (
+						data.addTime
+				)) +
+				'</td>' +
+				'<td>' +
+				'<a href="javascript:;" onclick="delect(' + index + ')">删除</a>' +
+				'</td>' +
+				'</tr>';
+		return html;
+	}
+
+	function insertHtml(list) {
+		var html = '';
+		productIds = '';
+		list.forEach(function (item, index) {
+			html += appendShopOrderHead(item, index);
+			productIds += "," + item.productId;
+		});
+		$("#hotSearch").html(html);
+	}
+
+	function changeSort(index, sortThis) {
+		var sort = sortThis.value;
+		if (sort <= 0) {
+
+		}
+		var image = imageList[index];
+		image.sort = sort;
+	}
+
+	function updatePcStatus(status, index) {
+		var image = imageList[index];
+		confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
+			image.pcStatus = status;
+			batchSaveSort();
+		})
+	}
+
+	function updateAppletsStatus(status, index) {
+		var image = imageList[index];
+		confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
+			image.appletsStatus = status;
+			batchSaveSort();
+		})
+	}
+
+	function clickAllSelect(ckb) {
+		var isChecked = ckb.checked;
+		$(".check-item").attr('checked', isChecked);
+	}
+
+	/**
+	 * 删除操作
+	 */
+	function delect(index) {
+		return confirmx("确定删除吗?", function () {
+			var image = imageList[index];
+			if (image.productId != '') {
+				productIds = productIds.replace(image.productId,"");
+			}
+			imageList.splice(index, 1);
+			insertHtml(imageList);
+			if (imageList.length == 0) {
+				$('#contentTable').hide();
+				$("#del").attr("disabled", "disabled");
+			}
+		});
+	}
+
+
+	/**
+	 * 批量删除
+	 */
+	function batchDeletion() {
+		var index = -1;
+		var i = 1;
+		return confirmx("确定删除吗?", function () {
+			$('input[name="info"]:checked').each(function () {
+				var thisIndex = $(this).val();
+				if (index >= 0 && index < thisIndex) {
+					thisIndex = thisIndex - i;
+					i++;
+				} else {
+					index = thisIndex;
+				}
+				var image = imageList[thisIndex];
+				if (image.productId != '') {
+					productIds = productIds.replace(image.productId, "");
+				}
+				imageList.splice(thisIndex, 1);
+				insertHtml(imageList);
+				if (imageList.length == 0) {
+					$('#contentTable').hide();
+					$("#del").attr("disabled", "disabled");
+				}
+			});
+		});
+	}
+
+	function productShow() {
+		var  productType = $("input[name='productType']:checked").val();
+		if (productType == 2){
+			$(".productData").show();
+		}else {
+			$(".productData").hide();
+		}
+	}
+
+	function statusShow() {
+		var status = $("input[name='status']:checked").val();
+		if (status == 2) {
+			$("#initializeShow").hide();
+			$("#closeShow").show();
+		} else {
+			$("#initializeShow").show();
+			$("#closeShow").hide();
+			$("#hiddenStatus").val(0);
+		}
+	}
+
+	function dateShow() {
+		var startDate = $("#startDate").val();
+		var startMs = new Date(startDate).getTime();
+		var endDate = $("#endDate").val();
+		var endMs = new Date(endDate).getTime();
+		var nowMs = new Date().getTime();
+		if (nowMs < startMs) {
+			$("#initializeShow").html("<font color=\"#800080\">未生效</font>");
+		} else if (nowMs > endMs) {
+			$("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
+		} else {
+			$("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
+		}
+	}
+
+
+	/**
+	 * @param obj
+	 * jquery控制input只能输入数字
+	 */
+	function onlynum(obj) {
+		obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+	}
+</script>
+</body>
+</html>

+ 123 - 0
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponList.jsp

@@ -0,0 +1,123 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+	<title>优惠券管理列表</title>
+	<meta name="decorator" content="default"/>
+	<style type="text/css">
+		.table th{text-align: center;}
+		.table td{text-align: center;}
+	</style>
+	<script type="text/javascript">
+		$(document).ready(function() {
+			
+		});
+		function page(n,s){
+			$("#pageNo").val(n);
+			$("#pageSize").val(s);
+			$("#searchForm").submit();
+        	return false;
+        }
+	</script>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li class="active"><a href="${ctx}/coupon/cmCoupon/list?couponType=0">活动券</a></li>
+		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=1">品类券</a></li>
+		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=2">用户专享券</a></li>
+		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=3">店铺券</a></li>
+		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=4">新用户券</a></li>
+	</ul>
+	<form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/" method="post" class="breadcrumb form-search">
+		<input type="hidden" name="couponType" value="0"/>
+		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+		<div class="ul-form">
+			 <label>活动主题:</label>
+				<form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
+			<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="2" label="已关闭"/>
+				<form:option value="3" label="已失效"/>
+			</form:select>
+			 <label>优惠时间:</label>
+				<input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+					value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/> -
+				<input name="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+					value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
+			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+			<input class="btn btn-primary" style="width: 80px" onclick="window.location='${ctx}/coupon/cmCoupon/form?couponType=0'" value="添加活动券"/>
+			<div class="clearfix"></div>
+		</div>
+	</form:form>
+	<sys:message content="${message}"/>
+	<table id="contentTable" class="table table-striped table-bordered table-condensed">
+		<thead>
+			<tr>
+				<th>ID</th>
+				<th>活动主题</th>
+				<th>优惠券金额</th>
+				<th>优惠条件</th>
+				<th>优惠状态</th>
+				<th>开始时间</th>
+				<th>结束时间</th>
+				<th>添加时间</th>
+				<th>操作</th>
+			</tr>
+		</thead>
+		<tbody>
+		<c:forEach items="${page.list}" var="cmCoupon">
+			<tr>
+				<td>
+					${cmCoupon.id}
+				</td>
+				<td>
+					${cmCoupon.name}
+				</td>
+				<td>
+					${cmCoupon.couponAmount}
+				</td>
+				<td>
+					满${cmCoupon.touchPrice}
+				</td>
+				<td>
+					<c:if test="${cmCoupon.status eq 0}">
+						<font color="#800080">未生效</font>
+					</c:if>
+					<c:if test="${cmCoupon.status eq 1}">
+						<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>
+					</c:if>
+				</td>
+				<td>
+					<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+					<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+					<fmt:formatDate value="${cmCoupon.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</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>
+					<a href="${ctx}/coupon/cmCouponClub/list?couponId=${cmCoupon.id}&couponType=0">领取用户</a>
+				</td>
+			</tr>
+		</c:forEach>
+		</tbody>
+	</table>
+	<div class="pagination">${page}</div>
+</body>
+</html>

+ 0 - 116
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponListBox.jsp

@@ -1,116 +0,0 @@
-<%@ page contentType="text/html;charset=UTF-8" %>
-<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
-<html>
-<head>
-	<title>优惠券管理</title>
-	<meta name="decorator" content="default"/>
-	<style type="text/css">
-		.table th{text-align: center;}
-		.table td{text-align: center;}
-	</style>
-	<script type="text/javascript">
-		$(document).ready(function() {
-			
-		});
-		function page(n,s){
-			$("#pageNo").val(n);
-			$("#pageSize").val(s);
-			$("#searchForm").submit();
-        	return false;
-        }
-
-        function allCkbfun(ckb){
-            var isChecked = ckb.checked;
-            $(".check-item").attr('checked', isChecked);
-        }
-
-        function checkNum(index) {
-			var $id = "num" + index;
-            var $laveNumID = "laveNum" + index;
-			var $num = document.getElementById($id);
-            var $laveNum = document.getElementById($laveNumID);
-            var num = $($num).val();
-            var laveNum = $($laveNum).val();
-            if(!isNaN(num)){
-                if (num <= 0) {
-                    $($num).val("");
-                    alertx("请输入正确的数量");
-                }
-                if (parseInt(num)>parseInt(laveNum)) {
-                    $($num).val("");
-                    alertx("输入数字超过剩余数量");
-                }
-            }else{
-                $($num).val("");
-                alertx("请输入正确的数量");
-            }
-
-
-//            obj["num"] = count;
-        }
-
-        function getCheckedItems(){
-            var items = new Array();
-            var $items = $('.check-item:checked');
-            $items.each(function(){
-               var num = $(this).parent().parent().find('td').last().find('input').val();
-				var va = JSON.parse($(this).val());
-				va.num = num;
-                items.push(JSON.stringify(va));
-            });
-            return items;
-        }
-	</script>
-</head>
-<body>
-	<form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCouponClub/showCouponList" method="post" class="breadcrumb form-search">
-		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
-		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
-		<input id="userID" name="userID" type="hidden" value="${userID}"/>
-	</form:form>
-	<sys:message content="${message}"/>
-	<table id="contentTable" class="table table-striped table-bordered table-condensed">
-		<thead>
-			<tr>
-				<th style="width:20px;"></th>
-				<th>券类型</th>
-				<th>优惠金额</th>
-				<th>使用门槛</th>
-				<th>剩余数量</th>
-				<th>发送数量</th>
-			</tr>
-		</thead>
-		<tbody>
-		<c:forEach items="${page.list}" var="cmCoupon" varStatus="state" >
-			<tr id="${cmCoupon.couponType}">
-				<th><input class="check-item" type="radio" name="cmCoupon" value='${fns:toJson(cmCoupon)}'/></th>
-				<td>
-					<%--类型 0满减劵 1折扣劵--%>
-					<c:if test="${cmCoupon.couponType eq 0}">
-						满减劵
-					</c:if>
-					<c:if test="${cmCoupon.couponType eq 1}">
-						折扣劵
-					</c:if>
-				</td>
-				<td>
-					${cmCoupon.couponAmount}
-				</td>
-				<td>
-					${cmCoupon.threshold}
-				</td>
-				<td>
-					${cmCoupon.laveNum}
-				</td>
-				<td>
-				<input type="text" name="num${state.index}" id="num${state.index}" value= ""  placeholder="请输入" onchange="checkNum(${state.index})" style="width: 50px">
-				</td>
-                <input type="hidden" name="userID" id="userID" value="${cmCoupon.userID}">
-				<input type="hidden" name="laveNum${state.index}" id="laveNum${state.index}" value="${cmCoupon.laveNum}">
-			</tr>
-		</c:forEach>
-		</tbody>
-	</table>
-	<div class="pagination">${page}</div>
-</body>
-</html>

+ 0 - 101
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponOrderRecordList.jsp

@@ -1,101 +0,0 @@
-<%@ page contentType="text/html;charset=UTF-8" %>
-<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
-<html>
-<head>
-	<title>优惠券订单</title>
-	<meta name="decorator" content="default"/>
-	<style type="text/css">
-		.table th{text-align: center;}
-		.table td{text-align: center;}
-	</style>
-	<script type="text/javascript">
-		$(document).ready(function() {
-			
-		});
-		function page(n,s){
-			$("#pageNo").val(n);
-			$("#pageSize").val(s);
-			$("#searchForm").submit();
-        	return false;
-        }
-	</script>
-</head>
-<body>
-	<ul class="nav nav-tabs">
-		<li class="active"><a href="${ctx}/coupon/cmCouponOrderRecord/">优惠券订单</a></li>
-	</ul>
-	<form:form id="searchForm" modelAttribute="cmCouponOrderRecord" action="${ctx}/coupon/cmCouponOrderRecord/" method="post" class="breadcrumb form-search">
-		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
-		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
-		<div class="ul-form">
-			<label>订单编号:</label>
-			<form:input path="orderCode" htmlEscape="false" maxlength="35" class="input-mini"/>
-			<label>会所名称:</label>
-			<form:input path="clubName" htmlEscape="false" maxlength="15" class="input-medium"/>
-			<label>下单时间:</label>
-			<form:input path="startTime" type="text" maxlength="20" class="input-mini Wdate" value="${startTime}"
-						onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
-			-
-			<form:input path="endTime" type="text" maxlength="20" class="input-mini Wdate" value="${endTime}"
-						onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
-			<%--&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="筛选查询"/>--%>
-			&nbsp;&nbsp;<form:input id="btnSubmit" class="btn btn-primary" type="submit"  path="searchflag" value="搜索"></form:input>
-			&nbsp;&nbsp;<form:input id="btnSubmit" class="btn btn-primary" type="submit"  path="searchflag" value="导出筛选结果"></form:input>
-			<div class="clearfix"></div>
-		</div>
-	</form:form>
-	<div class="breadcrumb">数据列表</div>
-	<div style="padding-left: 30px;">
-		<img src="/static/images/warning.png" style="display: inline-block;vertical-align: top;width: 18px;height: 18px;">
-		<div style="display: inline-block;">
-			<p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">1、一个订单可能存在多条记录(付款成功、退款成功等)</p>
-		</div>
-	</div>
-	<sys:message content="${message}"/>
-	<table id="contentTable" class="table table-striped table-bordered table-condensed">
-		<thead>
-			<tr>
-				<th>订单编号</th>
-				<th>下单时间</th>
-				<th>退款时间</th>
-				<th>订单金额</th>
-				<th>退款金额</th>
-				<th>优惠券码</th>
-				<th>优惠金额</th>
-				<th>订单状态</th>
-				<th>客户名称</th>
-				<th>客户手机号</th>
-				<th>会所名称</th>
-			</tr>
-		</thead>
-		<tbody>
-		<c:forEach items="${page.list}" var="cmCouponOrderRecord">
-			<tr>
-				<td>${cmCouponOrderRecord.orderCode}</td>
-				<td><fmt:formatDate value="${cmCouponOrderRecord.paymentTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
-				<td><fmt:formatDate value="${cmCouponOrderRecord.refundTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
-				<td>${cmCouponOrderRecord.totalAmount}</td>
-				<td>${cmCouponOrderRecord.refundAmount}</td>
-				<td>${cmCouponOrderRecord.couponCode}</td>
-				<td>${cmCouponOrderRecord.discountAmount}</td>
-				<td>
-					<%--2付款成功 6退款成功--%>
-					<c:if test="${cmCouponOrderRecord.status eq 2}">
-						付款成功
-					</c:if>
-					<c:if test="${cmCouponOrderRecord.status eq 6}">
-						退款成功
-					</c:if>
-				</td>
-				<td>${cmCouponOrderRecord.customerName}</td>
-				<td>${cmCouponOrderRecord.customerMobile}</td>
-				<td>
-					${cmCouponOrderRecord.rebateName}
-				</td>
-			</tr>
-		</c:forEach>
-		</tbody>
-	</table>
-	<div class="pagination">${page}</div>
-</body>
-</html>

+ 0 - 295
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponRecordList.jsp

@@ -1,295 +0,0 @@
-<%@ page contentType="text/html;charset=UTF-8" %>
-<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
-<html>
-<head>
-	<title>采美优惠券使用记录表管理</title>
-	<meta name="decorator" content="default"/>
-	<style type="text/css">
-		.table th{text-align: center;}
-		.table td{text-align: center;}
-		.main{margin: 20px 30px;}
-		.h3{margin-bottom: 10px;}
-		.mar-h3{margin: 20px 0;}
-		.p_messg{margin: 10px 0; color: #317eac}
-		.p_messg span{display: inline-block;width: 15px;height: 15px;border: 1px solid #317eac;border-radius: 50px;
-		text-align: center;line-height: 15px;margin-right: 5px; color: #317eac}
-		.search{width: 100%;height: 35px;line-height: 35px; background-color: #999; color: #fff;padding-left: 20px;box-sizing: border-box}
-		.table-div{margin-top: 30px;}
-	</style>
-	<script type="text/javascript">
-		$(document).ready(function() {
-			
-		});
-		function page(n,s){
-			$("#pageNo").val(n);
-			$("#pageSize").val(s);
-			$("#searchForm").submit();
-        	return false;
-        }
-	</script>
-</head>
-<body>
-<form enctype="multipart/form-data" id="batchUpload" action="${ctx}" method="post"
-	  class="form-horizontal">
-    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp<button class="btn btn-success btn-xs" id="uploadEventBtn" style="height:32px;" type="button">选择优惠券Excel文件</button>
-	<input type="file" name="file" style="width:0px;height:0px;" id="uploadEventFile">
-	<input id="uploadEventPath" disabled="disabled" type="text" placeholder="请选择excel表"
-		   style="border: 1px solid #e6e6e6; height: 32px;width: auto;">
-	<button type="button" class="btn btn-success btn-sm" onclick="user.uploadBtn()">上传提交</button>
-</form>
-<div class="main">
-	<div class="breadcrumb">基本数据</div>
-    <div style="padding-left: 30px;">
-        <img src="/static/images/warning.png" style="display: inline-block;vertical-align: top;width: 18px;height: 18px;">
-        <div style="display: inline-block;">
-            <p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">1、剩余数量:还没派送给会所的有效期内优惠券数量</p>
-            <p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">2、已分享数量:会所分享出去的优惠券数量</p>
-            <p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">3、已过期数量:分享出去但是客户未使用过期的或者是还未派发给会所就过期的优惠券数量</p>
-			<p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">4、导入Excel表格要求:1.时间格式:2018-10-10 12:59:59、2.门槛.去掉订单字眼显示:满50元可用</p>
-        </div>
-    </div>
-	<div>
-		<table class="table table-striped table-bordered table-condensed">
-			<thead>
-			<th>优惠券类型</th>
-			<th>优惠券金额</th>
-			<th>剩余数量</th>
-				<th>已分享数量</th>
-			<th>已使用数量</th>
-			<th>已过期数量</th>
-			</thead>
-                <c:if test="${not empty cmCoupons}">
-			<tbody>
-				<c:forEach items="${cmCoupons}" var="coupon">
-					<tr>
-						<td>
-                                <c:if test="${coupon.couponType == 0}">
-                                    满减劵
-                                </c:if>
-                                <c:if test="${coupon.couponType == 1}">
-                                    折扣劵
-                                </c:if>
-                        </td>
-						<td>${coupon.couponAmount}</td>
-						<td>${coupon.lastAmount}</td>
-						<td>${coupon.shareAmount}</td>
-						<td>${coupon.usedAmount}</td>
-						<td>${coupon.timeOutAmount}</td>
-					</tr>
-				</c:forEach>
-			</tbody>
-                </c:if>
-		</table>
-            <c:if test="${empty cmCoupons}">
-                <text style="color:dodgerblue;display:block;text-align:center">暂无信息</text>
-            </c:if>
-		</div>
-
-	<div class="breadcrumb">优惠券使用记录</div>
-	<div style="padding-left: 30px;">
-		<img src="/static/images/warning.png" style="display: inline-block;vertical-align: top;width: 18px;height: 18px;">
-		<div style="display: inline-block;">
-			<p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">1、数据来源已发送给会所的优惠券</p>
-			<p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">2、会所名称:表示优惠券派送给了哪个企业 </p>
-			<p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">3、员工/企业名称:如果是会所员工分享的显示员工名称,会所分享则显示对应的企业名称</p>
-		</div>
-	</div>
-	<form:form id="searchForm" modelAttribute="cmCouponRecord" action="${ctx}/coupon/cmCouponRecord/" method="post" class="breadcrumb form-search">
-		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
-		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
-		<div class="ul-form">
-			<label>
-			ID:</label>
-			<form:input path="id" htmlEscape="false" maxlength="12" class="input-mini"/>
-            优惠码:</label>
-            <form:input path="couponCode" htmlEscape="false" maxlength="15" class="input-mini"/>
-			<label>
-			优惠码状态:</label>
-			<form:select path="status" class="input-mini">
-				<form:option value="" label="请选择"/>
-				<form:options items="${fns:getDictList('cm_coupon_record_status')}" itemLabel="label" itemValue="value"
-							  htmlEscape="false"/>
-			</form:select>
-			<label>
-			会所名称:</label>
-			<form:input path="companyName" htmlEscape="false" maxlength="20" class="input-medium"/>
-			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="筛选查询"/>
-			<div class="clearfix"></div>
-		</div>
-	</form:form>
-	<sys:message content="${message}"/>
-	<div class="table-div">
-	<table id="contentTable" class="table table-striped table-bordered table-condensed">
-		<thead>
-			<th>
-				ID
-			</th>
-			<th>
-				优惠码
-			</th>
-			<th>
-				优惠金额
-			</th>
-			<th>
-				相关订单ID
-			</th>
-			<th>
-				会所名称
-			</th>
-			<th>
-				员工/企业名称
-			</th>
-			<th>
-				分享时间
-			</th>
-			<th>
-				使用时间
-			</th>
-			<th>
-				过期时间
-			</th>
-			<th>
-				状态
-			</th>
-		</thead>
-		<tbody>
-		<c:forEach items="${page.list}" var="cmCouponRecord">
-			<tr>
-				<td>${cmCouponRecord.id}</td>
-				<td>${cmCouponRecord.couponCode}</td>
-				<td>${cmCouponRecord.couponAmount}</td>
-				<td>
-					<c:if test="${not empty cmCouponRecord.couponOrderCode}">
-						${cmCouponRecord.couponOrderCode}
-					</c:if>
-					<c:if test="${empty cmCouponRecord.couponOrderCode}">
-						暂无关联订单
-					</c:if>
-				</td>
-				<td>
-					<%--会所名字(优惠券的接收者)--%>
-					<c:if test="${not empty cmCouponRecord.clubName}">
-						${cmCouponRecord.clubName}
-					</c:if>
-					<c:if test="${empty cmCouponRecord.clubName}">
-						------
-					</c:if>
-				</td>
-				<td>
-				<%--企业和员工只存在一个人分享,二选一--%>
-					<%--1.员工--%>
-					<c:if test="${not empty cmCouponRecord.staffName}">
-						${cmCouponRecord.staffName}(员工)
-					</c:if>
-					<%--2.企业--%>
-					<c:if test="${not empty cmCouponRecord.companyName}">
-						${cmCouponRecord.companyName}(企业)
-					</c:if>
-					<c:if test="${empty cmCouponRecord.companyName && empty cmCouponRecord.staffName}">
-						------
-					</c:if>
-				</td>
-				<td>
-					<c:if test="${not empty cmCouponRecord.receiveDate}">
-						<fmt:formatDate value="${cmCouponRecord.receiveDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
-					</c:if>
-					<c:if test="${empty cmCouponRecord.receiveDate}">
-						暂未分享
-					</c:if>
-				</td>
-				<td>
-					<c:if test="${not empty cmCouponRecord.useDate}">
-						<fmt:formatDate value="${cmCouponRecord.useDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
-					</c:if>
-					<c:if test="${empty cmCouponRecord.useDate}">
-						暂未使用
-					</c:if>
-				</td>
-				<td>
-					<c:if test="${not empty cmCouponRecord.useEndDate}">
-						<fmt:formatDate value="${cmCouponRecord.useEndDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
-					</c:if>
-					<c:if test="${empty cmCouponRecord.useEndDate}">
-						--------
-					</c:if>
-				</td>
-				<td>
-					<%--状态 1已发放 2已分享 3已使用--%>
-					<c:if test="${cmCouponRecord.status eq 1}">
-						未分享
-					</c:if>
-					<c:if test="${cmCouponRecord.status eq 2}">
-						已分享
-					</c:if>
-					<c:if test="${cmCouponRecord.status eq 3}">
-						已使用
-					</c:if>
-					<c:if test="${cmCouponRecord.status eq 4}">
-						已过期
-					</c:if>
-				</td>
-			</tr>
-		</c:forEach>
-		</tbody>
-	</table>
-	</div>
-	<div class="pagination">${page}</div>
-</div>
-<script>
-    var User = function () {
-        this.init = function () {
-            //模拟上传excel
-            $("#uploadEventBtn").unbind("click").bind("click", function () {
-                $("#uploadEventFile").click();
-            });
-            $("#uploadEventFile").bind("change", function () {
-                $("#uploadEventPath").attr("value", $("#uploadEventFile").val());
-            });
-        };
-        //点击上传按钮
-        this.uploadBtn = function () {
-            var uploadEventFile = $("#uploadEventFile").val();
-            if (uploadEventFile == '') {
-                alert("请选择excel,再上传");
-            } else if (uploadEventFile.lastIndexOf(".xls") < 0) {//可判断以.xls和.xlsx结尾的excel
-                alert("只能上传Excel文件");
-            } else {
-                var url = '${ctx}/coupon/cmCoupon/import/';
-                var formData = new FormData($('form')[0]);
-                user.sendAjaxRequest(url, 'POST', formData);
-                window.location.reload();
-            }
-        };
-
-        this.sendAjaxRequest = function (url, type, data) {
-            $.ajax({
-                url: url,
-                type: type,
-                data: data,
-                dataType: "JSON",
-                success: function (res) {
-                    console.log(res)
-                    if (res.success) {
-                        window.location.reload();
-                    } else {
-                        alertx(res.msg);
-                    }
-                },
-                error: function (res) {
-                    console.log(res);
-                },
-                cache: false,
-                contentType: false,
-                processData: false
-            });
-        }
-    }
-
-    var user;
-    $(function () {
-        user = new User();
-        user.init();
-    });
-</script>
-</body>
-</html>

+ 0 - 329
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponRecordScanList.jsp

@@ -1,329 +0,0 @@
-<%@ page contentType="text/html;charset=UTF-8" %>
-<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
-<html>
-<head>
-	<title>采美优惠券使用记录表管理</title>
-	<meta name="decorator" content="default"/>
-	<style type="text/css">
-		.table th{text-align: center;}
-		.table td{text-align: center;}
-		.main{margin: 20px 30px;}
-		.h3{margin-bottom: 10px;}
-		.mar-h3{margin: 20px 0;}
-		.p_messg{margin: 10px 0; color: #317eac}
-		.p_messg span{display: inline-block;width: 15px;height: 15px;border: 1px solid #317eac;border-radius: 50px;
-		text-align: center;line-height: 15px;margin-right: 5px; color: #317eac}
-		.search{width: 100%;height: 35px;line-height: 35px; background-color: #999; color: #fff;padding-left: 20px;box-sizing: border-box}
-		.table-div{margin-top: 30px;}
-	</style>
-	<script type="text/javascript">
-		$(document).ready(function() {
-			
-		});
-		function page(n,s){
-			$("#pageNo").val(n);
-			$("#pageSize").val(s);
-			$("#searchForm").submit();
-        	return false;
-        }
-
-        //状态修改
-        function updateEnabledStatus(status){
-            var msg='确定开启?';
-            if('1'==status){
-                msg='确定停用?';
-            }
-            top.$.jBox.confirm(msg,'系统提示',function(v,h,f){
-                if(v=='ok'){
-                    $.post("${ctx}/coupon/cmCouponRecordScan/updateEnabledStatus",{'enabledStatus':status}, function(data) {
-                        if(true==data.success){
-                            $.jBox.tip(data.msg, 'info');
-                        } else {
-                            $.jBox.tip(data.msg,'error');
-                        }
-                        $("#searchForm").submit();
-                    },"JSON");//这里返回的类型有:json,html,xml,text
-                }
-                return;
-            },{buttonsFocus:1,persistent: true});
-        }
-	</script>
-</head>
-<body>
-<%--<form enctype="multipart/form-data" id="batchUpload" action="${ctx}" method="post"
-	  class="form-horizontal">
-    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp<button class="btn btn-success btn-xs" id="uploadEventBtn" style="height:32px;" type="button">上传优惠券Excel文件</button>
-	<input type="file" name="file" style="width:0px;height:0px;" id="uploadEventFile">
-	<input id="uploadEventPath" disabled="disabled" type="text" placeholder="请选择excel表"
-		   style="border: 1px solid #e6e6e6; height: 32px;width: auto;">
-	<button type="button" class="btn btn-success btn-sm" onclick="user.uploadBtn()">提交</button>
-</form>--%>
-<div class="main">
-	<div class="breadcrumb">基本数据</div>
-    <div style="padding-left: 30px;">
-        <img src="/static/images/warning.png" style="display: inline-block;vertical-align: top;width: 18px;height: 18px;">
-        <div style="display: inline-block;">
-            <p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">1、剩余数量:还没派送给会所的有效期内优惠券数量</p>
-            <p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">2、已分享数量:会所分享出去的优惠券数量</p>
-			<p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">3、未领取数量:扫码推送给用户但未填手机号领取的优惠券数量</p>
-            <p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">4、已过期数量:分享出去但是客户未使用过期的或者是还未派发给会所就过期的优惠券数量</p>
-        </div>
-    </div>
-	<div>
-		<table class="table table-striped table-bordered table-condensed">
-			<thead>
-			<th>扫码推劵功能开关</th>
-			</thead>
-				<tbody>
-					<tr>
-						<td>
-							<shiro:hasPermission name="coupon:cmCouponRecordScan:edit">
-								<c:if test="${enabled.status eq 0 }">
-									<a href="javascript:void(0);" onclick="updateEnabledStatus('1');" >
-										<img alt="启用" src="/static/images/yes.gif" width="15px" border="none" title="启用">
-									</a>
-								</c:if>
-								<c:if test="${enabled.status ne 0 }">
-									<a href="javascript:void(0)" onclick="updateEnabledStatus('0');">
-										<img alt="停用" src="/static/images/no.gif" width="15px" border="none" title="停用">
-									</a>
-								</c:if>
-							</shiro:hasPermission>
-						</td>
-					</tr>
-				</tbody>
-		</table>
-	</div>
-		<div>
-			<table class="table table-striped table-bordered table-condensed">
-				<thead>
-				<th>优惠券类型</th>
-				<th>优惠券金额</th>
-				<th>剩余数量</th>
-				<th>未领取数量</th>
-				<th>已分享数量</th>
-				<th>已使用数量</th>
-				<th>已过期数量</th>
-				</thead>
-                <c:if test="${not empty cmCoupons}">
-				<tbody>
-				<c:forEach items="${cmCoupons}" var="coupon">
-					<tr>
-						<td>
-                                <c:if test="${coupon.couponType == 0}">
-                                    满减劵
-                                </c:if>
-                                <c:if test="${coupon.couponType == 1}">
-                                    折扣劵
-                                </c:if>
-                        </td>
-						<td>${coupon.couponAmount}</td>
-						<td>${coupon.lastAmount}</td>
-						<td>${coupon.unReceiveNum}</td>
-						<td>${coupon.shareAmount}</td>
-						<td>${coupon.usedAmount}</td>
-						<td>${coupon.timeOutAmount}</td>
-					</tr>
-				</c:forEach>
-				</tbody>
-                </c:if>
-			</table>
-            <c:if test="${empty cmCoupons}">
-                <text style="color:dodgerblue;display:block;text-align:center">暂无信息</text>
-            </c:if>
-		</div>
-
-	<div class="breadcrumb">优惠券使用记录</div>
-	<div style="padding-left: 30px;">
-		<img src="/static/images/warning.png" style="display: inline-block;vertical-align: top;width: 18px;height: 18px;">
-		<div style="display: inline-block;">
-			<p style="padding-bottom: 1px;margin-bottom: 0;color:#a9a9a9 ">1、数据来源公众号扫码已推送用户的优惠券</p>
-		</div>
-	</div>
-	<form:form id="searchForm" modelAttribute="cmCouponRecordScan" action="${ctx}/coupon/cmCouponRecordScan/scanCouponRecordList" method="post" class="breadcrumb form-search">
-		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
-		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
-		<div class="ul-form">
-			<label>
-			ID:</label>
-			<form:input path="id" htmlEscape="false" maxlength="12" class="input-mini"/>
-			<label>
-            优惠码:</label>
-            <form:input path="couponCode" htmlEscape="false" maxlength="15" class="input-mini"/>
-			<label>
-			优惠码状态:</label>
-			<form:select path="status" class="input-mini">
-				<form:option value="" label="请选择"/>
-				<form:options items="${fns:getDictList('cm_coupon_record_scan_status')}" itemLabel="label" itemValue="value"
-							  htmlEscape="false"/>
-			</form:select>
-			<label>
-			发劵人手机号:</label>
-			<form:input path="mobile" htmlEscape="false" maxlength="11" class="input-medium"/>
-			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="筛选查询"/>
-			<div class="clearfix"></div>
-		</div>
-	</form:form>
-	<sys:message content="${message}"/>
-	<div class="table-div">
-	<table id="contentTable" class="table table-striped table-bordered table-condensed">
-		<thead>
-			<th>
-				ID
-			</th>
-			<th>
-				优惠码
-			</th>
-			<th>
-				优惠金额
-			</th>
-			<th>
-				相关订单ID
-			</th>
-			<th>
-				发劵人手机
-			</th>
-			<th>
-				领取时间
-			</th>
-			<th>
-				使用时间
-			</th>
-			<th>
-				过期时间
-			</th>
-			<th>
-				状态
-			</th>
-		</thead>
-		<tbody>
-		<c:forEach items="${page.list}" var="cmCouponRecord">
-			<tr>
-				<td>${cmCouponRecord.id}</td>
-				<td>${cmCouponRecord.couponCode}</td>
-				<td>${cmCouponRecord.couponAmount}</td>
-				<td>
-					<c:if test="${not empty cmCouponRecord.couponOrderCode}">
-						${cmCouponRecord.couponOrderCode}
-					</c:if>
-					<c:if test="${empty cmCouponRecord.couponOrderCode}">
-						暂无关联订单
-					</c:if>
-				</td>
-				<td>
-					<%--发劵人手机号(优惠券的领取者)--%>
-					<c:if test="${not empty cmCouponRecord.mobile}">
-						${cmCouponRecord.mobile}
-					</c:if>
-					<c:if test="${empty cmCouponRecord.mobile}">
-						------
-					</c:if>
-				</td>
-				<td>
-					<c:if test="${not empty cmCouponRecord.receiveDate}">
-						<fmt:formatDate value="${cmCouponRecord.receiveDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
-					</c:if>
-					<c:if test="${empty cmCouponRecord.receiveDate}">
-						暂未领取
-					</c:if>
-				</td>
-				<td>
-					<c:if test="${not empty cmCouponRecord.useDate}">
-						<fmt:formatDate value="${cmCouponRecord.useDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
-					</c:if>
-					<c:if test="${empty cmCouponRecord.useDate}">
-						暂未使用
-					</c:if>
-				</td>
-				<td>
-					<c:if test="${not empty cmCouponRecord.useEndDate}">
-						<fmt:formatDate value="${cmCouponRecord.useEndDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
-					</c:if>
-					<c:if test="${empty cmCouponRecord.useEndDate}">
-						--------
-					</c:if>
-				</td>
-				<td>
-					<%--状态 1未领取(已推送) 2已领取(输入手机号) 3已分享(可多次分享 ) 4已使用--%>
-					<c:if test="${cmCouponRecord.status eq 1}">
-						未领取
-					</c:if>
-					<c:if test="${cmCouponRecord.status eq 2}">
-						已领取
-					</c:if>
-					<c:if test="${cmCouponRecord.status eq 3}">
-						已分享
-					</c:if>
-					<c:if test="${cmCouponRecord.status eq 4}">
-						已使用
-					</c:if>
-						<%--实际无该状态,过滤数据--%>
-					<c:if test="${cmCouponRecord.status eq 5}">
-						已过期
-					</c:if>
-				</td>
-			</tr>
-		</c:forEach>
-		</tbody>
-	</table>
-	</div>
-	<div class="pagination">${page}</div>
-</div>
-<script>
-    var User = function () {
-        this.init = function () {
-            //模拟上传excel
-            $("#uploadEventBtn").unbind("click").bind("click", function () {
-                $("#uploadEventFile").click();
-            });
-            $("#uploadEventFile").bind("change", function () {
-                $("#uploadEventPath").attr("value", $("#uploadEventFile").val());
-            });
-        };
-        //点击上传按钮
-        this.uploadBtn = function () {
-            var uploadEventFile = $("#uploadEventFile").val();
-            if (uploadEventFile == '') {
-                alert("请选择excel,再上传");
-            } else if (uploadEventFile.lastIndexOf(".xls") < 0) {//可判断以.xls和.xlsx结尾的excel
-                alert("只能上传Excel文件");
-            } else {
-                var url = '${ctx}/coupon/cmCoupon/import/';
-                var formData = new FormData($('form')[0]);
-                user.sendAjaxRequest(url, 'POST', formData);
-                window.location.reload();
-            }
-        };
-
-        this.sendAjaxRequest = function (url, type, data) {
-            $.ajax({
-                url: url,
-                type: type,
-                data: data,
-                dataType: "JSON",
-                success: function (res) {
-                    console.log(res)
-                    if (res.success) {
-                        window.location.reload();
-                    } else {
-                        alertx(res.msg);
-                    }
-                },
-                error: function (res) {
-                    console.log(res);
-                },
-                cache: false,
-                contentType: false,
-                processData: false
-            });
-        }
-    }
-
-    var user;
-    $(function () {
-        user = new User();
-        user.init();
-    });
-</script>
-</body>
-</html>

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

@@ -0,0 +1,159 @@
+<%@ page import="java.util.Date" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>优惠券管理</title>
+    <meta name="decorator" content="default"/>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            //$("#name").focus();
+            $("#inputForm").validate({
+                submitHandler: function(form){
+                    var couponAmount = $("#couponAmount").val()*1;
+                    var touchPrice = $("#touchPrice").val()*1;
+                    if (couponAmount >= touchPrice) {
+                        alertx("优惠券金额必须小于优惠条件金额");
+                        return false;
+                    }
+                    var startDate = $("#startDate").val();
+                    var endDate = $("#endDate").val();
+                    if (startDate >= endDate) {
+                        alertx("结束时间不能早于开始时间");
+                        return false;
+                    }
+                    loading('正在提交,请稍等...');
+                    form.submit();
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function(error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+        });
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=1">品类券</a></li>
+    <li class="active"><a href="${ctx}/coupon/cmCoupon/form?couponType=1&id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a></li>
+</ul><br/>
+<font style="color: red;margin-left: 20px">品类券只适合在某种品类需要优惠时创建,适用于该品类商品和全部客户。</font><br><br>
+<form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/save" method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <form:hidden path="productInfo" id="productInfo"/>
+    <input type="hidden" name="couponType" value="1"/>
+    <sys:message content="${message}"/>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>活动主题:</label>
+        <div class="controls">
+            <form:input path="name" htmlEscape="false" maxlength="30" placeholder="30个汉字以内" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠券金额:</label>
+        <div class="controls">
+            <input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0" required>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠条件:</label>
+        <div class="controls">
+            订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice" value="${cmCoupon.touchPrice}" min="0" required>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠品类:</label>
+        <div class="controls">
+            <form:radiobutton path="categoryType" value="1" label="产品" checked ="${empty cmCoupon.categoryType ? true:false}"/>
+            <form:radiobutton path="categoryType" value="2" label="仪器"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>开始时间:</label>
+        <div class="controls">
+            <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
+                   value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
+                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});" onblur="dateShow()"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>结束时间:</label>
+        <div class="controls">
+            <input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
+                   value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
+                   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">
+            <label id="initializeShow">
+                <c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <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>
+                </c:if>
+            </label>
+            <label id="closeShow" style="display: none">
+                <font color="red">已关闭</font>
+            </label>
+            <input type="hidden" id="hiddenStatus" name="status" value="">
+            <input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""} onclick="statusShow()" />关闭
+        </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)"/>
+    </div>
+</form:form>
+<script>
+    function statusShow() {
+        var status = $("input[name='status']:checked").val();
+        if (status == 2) {
+            $("#initializeShow").hide();
+            $("#closeShow").show();
+        } else {
+            $("#initializeShow").show();
+            $("#closeShow").hide();
+            $("#hiddenStatus").val(0);
+        }
+    }
+
+    function dateShow() {
+        var startDate = $("#startDate").val();
+        var startMs = new Date(startDate).getTime();
+        var endDate = $("#endDate").val();
+        var endMs = new Date(endDate).getTime();
+        var nowMs = new Date().getTime();
+        if (nowMs < startMs) {
+            $("#initializeShow").html("<font color=\"#800080\">未生效</font>");
+        } else if (nowMs > endMs) {
+            $("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
+        } else {
+            $("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
+        }
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+</script>
+</body>
+</html>

+ 125 - 0
src/main/webapp/WEB-INF/views/modules/coupon/couponCategoryList.jsp

@@ -0,0 +1,125 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>优惠券管理列表</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th{text-align: center;}
+        .table td{text-align: center;}
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function() {
+
+        });
+        function page(n,s){
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=0">活动券</a></li>
+    <li class="active"><a href="${ctx}/coupon/cmCoupon/list?couponType=1">品类券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=2">用户专享券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=3">店铺券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=4">新用户券</a></li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/" method="post" class="breadcrumb form-search">
+    <input type="hidden" name="couponType" value="1"/>
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>活动主题:</label>
+        <form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
+        <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="2" label="已关闭"/>
+            <form:option value="3" label="已失效"/>
+        </form:select>
+        <label>优惠时间:</label>
+        <input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+               value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+               onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/> -
+        <input name="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+               value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+               onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        <input class="btn btn-primary" style="width: 80px" onclick="window.location='${ctx}/coupon/cmCoupon/form?couponType=1'" value="添加品类券"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>ID</th>
+        <th>活动主题</th>
+        <th>优惠券金额</th>
+        <th>优惠条件</th>
+        <th>优惠状态</th>
+        <th>优惠品类</th>
+        <th>开始时间</th>
+        <th>结束时间</th>
+        <th>添加时间</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="cmCoupon">
+        <tr>
+            <td>
+                    ${cmCoupon.id}
+            </td>
+            <td>
+                    ${cmCoupon.name}
+            </td>
+            <td>
+                    ${cmCoupon.couponAmount}
+            </td>
+            <td>
+                满${cmCoupon.touchPrice}
+            </td>
+            <td>
+                <c:if test="${cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <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>
+                </c:if>
+            </td>
+            <td>${cmCoupon.categoryType eq 1 ? "产品":"仪器"}</td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </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>
+                <a href="${ctx}/coupon/cmCouponClub/list?couponId=${cmCoupon.id}&couponType=1">领取用户</a>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+</body>
+</html>

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

@@ -0,0 +1,146 @@
+<%@ page import="java.util.Date" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>优惠券管理</title>
+    <meta name="decorator" content="default"/>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            //$("#name").focus();
+            $("#inputForm").validate({
+                submitHandler: function(form){
+                    var couponAmount = $("#couponAmount").val()*1;
+                    var touchPrice = $("#touchPrice").val()*1;
+                    if (couponAmount >= touchPrice) {
+                        alertx("优惠券金额必须小于优惠条件金额");
+                        return false;
+                    }
+                    var startDate = $("#startDate").val();
+                    var endDate = $("#endDate").val();
+                    if (startDate >= endDate) {
+                        alertx("结束时间不能早于开始时间");
+                        return false;
+                    }
+                    loading('正在提交,请稍等...');
+                    form.submit();
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function(error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+        });
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=4">新用户券</a></li>
+    <li class="active"><a href="${ctx}/coupon/cmCoupon/form?couponType=4&id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a></li>
+</ul><br/>
+<font style="color: red;margin-left: 20px">新用户券适合新注册的机构,并且适用于商城全部商品(不包括二手商品)。</font><br><br>
+<form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/save" method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <form:hidden path="productInfo" id="productInfo"/>
+    <input type="hidden" name="couponType" value="4"/>
+    <sys:message content="${message}"/>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠券金额:</label>
+        <div class="controls">
+            <input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0" required>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠条件:</label>
+        <div class="controls">
+            订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice" value="${cmCoupon.touchPrice}" min="0" required>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>开始时间:</label>
+        <div class="controls">
+            <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
+                   value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
+                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});" onblur="dateShow()"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>结束时间:</label>
+        <div class="controls">
+            <input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
+                   value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
+                   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">
+            <label id="initializeShow">
+                <c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <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>
+                </c:if>
+            </label>
+            <label id="closeShow" style="display: none">
+                <font color="red">已关闭</font>
+            </label>
+            <input type="hidden" id="hiddenStatus" name="status" value="">
+            <input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""} onclick="statusShow()" />关闭
+        </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)"/>
+    </div>
+</form:form>
+<script>
+    function statusShow() {
+        var status = $("input[name='status']:checked").val();
+        if (status == 2) {
+            $("#initializeShow").hide();
+            $("#closeShow").show();
+        } else {
+            $("#initializeShow").show();
+            $("#closeShow").hide();
+            $("#hiddenStatus").val(0);
+        }
+    }
+
+    function dateShow() {
+        var startDate = $("#startDate").val();
+        var startMs = new Date(startDate).getTime();
+        var endDate = $("#endDate").val();
+        var endMs = new Date(endDate).getTime();
+        var nowMs = new Date().getTime();
+        if (nowMs < startMs) {
+            $("#initializeShow").html("<font color=\"#800080\">未生效</font>");
+        } else if (nowMs > endMs) {
+            $("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
+        } else {
+            $("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
+        }
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+</script>
+</body>
+</html>

+ 117 - 0
src/main/webapp/WEB-INF/views/modules/coupon/couponNewUserList.jsp

@@ -0,0 +1,117 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>优惠券管理列表</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th{text-align: center;}
+        .table td{text-align: center;}
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function() {
+
+        });
+        function page(n,s){
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=0">活动券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=1">品类券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=2">用户专享券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=3">店铺券</a></li>
+    <li class="active"><a href="${ctx}/coupon/cmCoupon/list?couponType=4">新用户券</a></li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/" method="post" class="breadcrumb form-search">
+    <input type="hidden" name="couponType" value="4"/>
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <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="2" label="已关闭"/>
+            <form:option value="3" label="已失效"/>
+        </form:select>
+        <label>优惠时间:</label>
+        <input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+               value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+               onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/> -
+        <input name="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+               value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+               onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        <input class="btn btn-primary" style="width: 90px" onclick="window.location='${ctx}/coupon/cmCoupon/form?couponType=4'" value="添加新用户券"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>ID</th>
+        <th>优惠券金额</th>
+        <th>优惠条件</th>
+        <th>优惠状态</th>
+        <th>开始时间</th>
+        <th>结束时间</th>
+        <th>添加时间</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="cmCoupon">
+        <tr>
+            <td>
+                    ${cmCoupon.id}
+            </td>
+            <td>
+                    ${cmCoupon.couponAmount}
+            </td>
+            <td>
+                满${cmCoupon.touchPrice}
+            </td>
+            <td>
+                <c:if test="${cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <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>
+                </c:if>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </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>
+                <a href="${ctx}/coupon/cmCouponClub/list?couponId=${cmCoupon.id}&couponType=4">领取用户</a>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+</body>
+</html>

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

@@ -0,0 +1,257 @@
+<%@ page import="java.util.Date" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>优惠券管理</title>
+    <meta name="decorator" content="default"/>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+                    if ($("#shopId").val() == ''){
+                        alertx("请选择供应商");
+                        return false;
+                    }
+                    var couponAmount = $("#couponAmount").val()*1;
+                    var touchPrice = $("#touchPrice").val()*1;
+                    if (couponAmount >= touchPrice) {
+                        alertx("优惠券金额必须小于优惠条件金额");
+                        return false;
+                    }
+                    var startDate = $("#startDate").val();
+                    var endDate = $("#endDate").val();
+                    if (startDate >= endDate) {
+                        alertx("结束时间不能早于开始时间");
+                        return false;
+                    }
+                    loading('正在提交,请稍等...');
+                    form.submit();
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function (error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+        });
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=3">店铺券</a></li>
+    <li class="active"><a
+            href="${ctx}/coupon/cmCoupon/form?couponType=3&id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a>
+    </li>
+</ul>
+<br/>
+<font style="color: red;margin-left: 20px">店铺券适合给特定的供应商做活动时创建,并且适用于供应商的全部商品。</font><br><br>
+<form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/save" method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <form:hidden path="shopId" id="shopId"/>
+    <input type="hidden" name="couponType" value="3"/>
+    <sys:message content="${message}"/>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>活动主题:</label>
+        <div class="controls">
+            <form:input path="name" htmlEscape="false" maxlength="30" placeholder="30个汉字以内" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>供应商:</label>
+        <div class="controls">
+            <a href="javascript:void(0);" onclick="showSelect()" id="chooseShop">请选择供应商</a>
+            <table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
+                <thead>
+                <tr>
+                    <th>机构名称</th>
+                    <th>机构简称</th>
+                    <th>联系人</th>
+                    <th>手机号</th>
+                    <th>操作</th>
+                </tr>
+                </thead>
+                <tbody id="hotSearch"></tbody>
+            </table>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠券金额:</label>
+        <div class="controls">
+            <input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0"
+                   required>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠条件:</label>
+        <div class="controls">
+            订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice"
+                                                  value="${cmCoupon.touchPrice}" min="0" required>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>开始时间:</label>
+        <div class="controls">
+            <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20"
+                   class="input-medium Wdate "
+                   value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
+                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});" onblur="dateShow()"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>结束时间:</label>
+        <div class="controls">
+            <input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20"
+                   class="input-medium Wdate "
+                   value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
+                   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">
+            <label id="initializeShow">
+                <c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <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>
+                </c:if>
+            </label>
+            <label id="closeShow" style="display: none">
+                <font color="red">已关闭</font>
+            </label>
+            <input type="hidden" id="hiddenStatus" name="status" value="">
+            <input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""}
+                   onclick="statusShow()"/>关闭
+        </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)"/>
+    </div>
+</form:form>
+<script>
+    $(function () {
+        if (${not empty cmCoupon.shop}) {
+            var shop = {
+                "shopId": "${cmCoupon.shop.shopID}",
+                "name": "${cmCoupon.shop.name}",
+                "sname": "${cmCoupon.shop.sname}",
+                "linkMan": "${cmCoupon.shop.linkMan}",
+                "contractMobile": "${cmCoupon.shop.contractMobile}"
+            }
+            appendShopOrderHead(shop);
+        }
+    });
+
+
+    function appendShopOrderHead(data) {
+        var html = '<tr>' +
+            '<td>' +
+            data.name +
+            '</td>' +
+            '<td>' +
+            data.sname +
+            '</td>' +
+            '<td>' +
+            data.linkMan +
+            '</td>' +
+            '<td>' +
+            data.contractMobile +
+            '</td>' +
+            '<td>' +
+            '<a href="javascript:;" onclick="delect()">删除</a>' +
+            '</td>' +
+            '</tr>';
+        $("#hotSearch").html(html);
+        $("#chooseShop").hide();
+        $('#contentTable').show();
+        $("#shopId").val(data.shopId);
+    }
+
+
+    function statusShow() {
+        var status = $("input[name='status']:checked").val();
+        if (status == 2) {
+            $("#initializeShow").hide();
+            $("#closeShow").show();
+        } else {
+            $("#initializeShow").show();
+            $("#closeShow").hide();
+            $("#hiddenStatus").val(0);
+        }
+    }
+
+    function dateShow() {
+        var startDate = $("#startDate").val();
+        var startMs = new Date(startDate).getTime();
+        var endDate = $("#endDate").val();
+        var endMs = new Date(endDate).getTime();
+        var nowMs = new Date().getTime();
+        if (nowMs < startMs) {
+            $("#initializeShow").html("<font color=\"#800080\">未生效</font>");
+        } else if (nowMs > endMs) {
+            $("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
+        } else {
+            $("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
+        }
+    }
+
+    //点击添加
+    function showSelect() {
+        var url = "${ctx}/coupon/cmCoupon/toAddShop";
+        var title = '';
+        title = "选择供应商";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 400,
+            height: $(top.document).height() - 160,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1', "取消": '-1'},
+            submit: function (v, h, f) {
+                //确定
+                var $jboxFrame = top.$('#jbox-iframe');
+                var $mainFrame = top.$('#mainFrame');
+                if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                    var items = $jboxFrame[0].contentWindow.getCheckedItems();
+                    console.log(items);
+                    appendShopOrderHead(items);
+                }
+                return true;
+            }
+        });
+    }
+
+    /**
+     * 删除操作
+     */
+    function delect() {
+        return confirmx("确定删除吗?", function () {
+            $("#chooseShop").show();
+            $('#contentTable').hide();
+            $("#shopId").val("");
+        });
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+</script>
+</body>
+</html>

+ 129 - 0
src/main/webapp/WEB-INF/views/modules/coupon/couponShopList.jsp

@@ -0,0 +1,129 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>优惠券管理列表</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th{text-align: center;}
+        .table td{text-align: center;}
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function() {
+
+        });
+        function page(n,s){
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=0">活动券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=1">品类券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=2">用户专享券</a></li>
+    <li class="active"><a href="${ctx}/coupon/cmCoupon/list?couponType=3">店铺券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=4">新用户券</a></li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/" method="post" class="breadcrumb form-search">
+    <input type="hidden" name="couponType" value="3"/>
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>活动主题:</label>
+        <form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
+        <label>供应商名称:</label>
+        <form:input path="shopName" htmlEscape="false" maxlength="50" class="input-medium"/>
+        <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="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"
+               value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+               onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/> -
+        <input name="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+               value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+               onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        <input class="btn btn-primary" style="width: 80px" onclick="window.location='${ctx}/coupon/cmCoupon/form?couponType=3'" value="添加店铺券"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>ID</th>
+        <th>活动主题</th>
+        <th>供应商</th>
+        <th>优惠券金额</th>
+        <th>优惠条件</th>
+        <th>优惠状态</th>
+        <th>开始时间</th>
+        <th>结束时间</th>
+        <th>添加时间</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="cmCoupon">
+        <tr>
+            <td>
+                    ${cmCoupon.id}
+            </td>
+            <td>
+                    ${cmCoupon.name}
+            </td>
+            <td>
+                    ${cmCoupon.shopName}
+            </td>
+            <td>
+                    ${cmCoupon.couponAmount}
+            </td>
+            <td>
+                满${cmCoupon.touchPrice}
+            </td>
+            <td>
+                <c:if test="${cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <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>
+                </c:if>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </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>
+                <a href="${ctx}/coupon/cmCouponClub/list?couponId=${cmCoupon.id}&couponType=3">领取用户</a>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+</body>
+</html>

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

@@ -0,0 +1,262 @@
+<%@ page import="java.util.Date" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>优惠券管理</title>
+    <meta name="decorator" content="default"/>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //$("#name").focus();
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+                    var couponAmount = $("#couponAmount").val()*1;
+                    var touchPrice = $("#touchPrice").val()*1;
+                    if (couponAmount >= touchPrice) {
+                        alertx("优惠券金额必须小于优惠条件金额");
+                        return false;
+                    }
+                    var startDate = $("#startDate").val();
+                    var endDate = $("#endDate").val();
+                    if (startDate >= endDate) {
+                        alertx("结束时间不能早于开始时间");
+                        return false;
+                    }
+                    var userId = $("#userId").val();
+                    if (userId == null || userId == "") {
+                        alertx("请选择机构");
+                        return false;
+                    }
+                    loading('正在提交,请稍等...');
+                    form.submit();
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function (error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+        });
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=2">用户专享券</a></li>
+    <li class="active"><a
+            href="${ctx}/coupon/cmCoupon/form?couponType=2&id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a>
+    </li>
+</ul>
+<br/>
+<font style="color: red;margin-left: 20px">用户专享券适合在需要给特定客户返利时创建,并且适用于商城全部商品(不包括二手商品)。</font><br><br>
+<form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/save" method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <form:hidden path="productInfo" id="productInfo"/>
+    <input type="hidden" name="couponType" value="2"/>
+    <sys:message content="${message}"/>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>机构:</label>
+        <div class="controls">
+            <a href="javascript:void(0);" onclick="showSelect()" id="chooseClub">请选择机构</a>
+            <input type="hidden" name="userId" id="userId" value="${cmCoupon.userId}">
+            <table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
+                <thead>
+                <tr>
+                    <th>机构名称</th>
+                    <th>机构简称</th>
+                    <th>联系人</th>
+                    <th>手机号</th>
+                    <th>操作</th>
+                </tr>
+                </thead>
+                <tbody id="hotSearch"></tbody>
+            </table>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠券金额:</label>
+        <div class="controls">
+            <input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0"
+                   required>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠条件:</label>
+        <div class="controls">
+            订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice"
+                                                  value="${cmCoupon.touchPrice}" min="0" required>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>开始时间:</label>
+        <div class="controls">
+            <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20"
+                   class="input-medium Wdate "
+                   value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
+                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});" onblur="dateShow()"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>结束时间:</label>
+        <div class="controls">
+            <input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20"
+                   class="input-medium Wdate "
+                   value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
+                   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">
+            <label id="initializeShow">
+                <c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <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>
+                </c:if>
+            </label>
+            <label id="closeShow" style="display: none">
+                <font color="red">已关闭</font>
+            </label>
+            <input type="hidden" id="hiddenStatus" name="status" value="">
+            <input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""}
+                   onclick="statusShow()"/>关闭
+        </div>
+    </div>
+    <c:if test="${not empty cmCoupon.id}">
+        <div class="control-group">
+            <label class="control-label">领取状态:</label>
+            <div class="controls">
+
+            </div>
+        </div>
+        <div class="control-group">
+            <label class="control-label">使用状态:</label>
+            <div class="controls">
+
+            </div>
+        </div>
+    </c:if>
+    <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)"/>
+    </div>
+</form:form>
+<script>
+    $(function () {
+        if (${not empty cmUser}){
+            var items = {
+                "userID": "${cmUser.userID}",
+                "name": "${cmUser.name}",
+                "shortName": "${cmUser.shortName}",
+                "linkMan": "${empty cmUser.userName ? '':cmUser.userName}",
+                "contractMobile": "${empty cmUser.bindMobile ? '':cmUser.bindMobile}"
+            };
+            insertHtml(items);
+        }
+    });
+
+    function insertHtml(data) {
+        var html = '<tr>' +
+            '<td>' +
+            data.name +
+            '</td>' +
+            '<td>' +
+            data.shortName +
+            '</td>' +
+            '<td>' +
+            data.linkMan +
+            '</td>' +
+            '<td>' +
+            data.contractMobile +
+            '</td>' +
+            '<td>' +
+            '<a href="javascript:;" onclick="deleteClub()">删除</a>' +
+            '</td>' +
+            '</tr>';
+        $("#contentTable").show();
+        $("#chooseClub").hide();
+        $("#hotSearch").html(html);
+        $("#userId").val(data.userID);
+    }
+
+    function deleteClub() {
+        $("#hotSearch").html("");
+        $("#contentTable").hide();
+        $("#chooseClub").show();
+        $("#userId").val("");
+    }
+
+    function statusShow() {
+        var status = $("input[name='status']:checked").val();
+        if (status == 2) {
+            $("#initializeShow").hide();
+            $("#closeShow").show();
+        } else {
+            $("#initializeShow").show();
+            $("#closeShow").hide();
+            $("#hiddenStatus").val(0);
+        }
+    }
+
+    function dateShow() {
+        var startDate = $("#startDate").val();
+        var startMs = new Date(startDate).getTime();
+        var endDate = $("#endDate").val();
+        var endMs = new Date(endDate).getTime();
+        var nowMs = new Date().getTime();
+        if (nowMs < startMs) {
+            $("#initializeShow").html("<font color=\"#800080\">未生效</font>");
+        } else if (nowMs > endMs) {
+            $("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
+        } else {
+            $("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
+        }
+    }
+
+    //点击添加
+    function showSelect() {
+        var url = "${ctx}/coupon/cmCoupon/toAddClub";
+        var title = '';
+        title = "选择机构";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 400,
+            height: $(top.document).height() - 160,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1', "取消": '-1'},
+            submit: function (v, h, f) {
+                //确定
+                var $jboxFrame = top.$('#jbox-iframe');
+                var $mainFrame = top.$('#mainFrame');
+                if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                    var items = $jboxFrame[0].contentWindow.getCheckedItems();
+                    console.log(items);
+                    insertHtml(items);
+                }
+                return true;
+            }
+        });
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+</script>
+</body>
+</html>

+ 186 - 0
src/main/webapp/WEB-INF/views/modules/coupon/couponUserExclusiveList.jsp

@@ -0,0 +1,186 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>优惠券管理列表</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th{text-align: center;}
+        .table td{text-align: center;}
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function() {
+
+        });
+        function page(n,s){
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=0">活动券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=1">品类券</a></li>
+    <li class="active"><a href="${ctx}/coupon/cmCoupon/list?couponType=2">用户专享券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=3">店铺券</a></li>
+    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=4">新用户券</a></li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/" method="post" class="breadcrumb form-search">
+    <input type="hidden" name="couponType" value="2"/>
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>机构名称:</label>
+        <form:input path="clubName" htmlEscape="false" maxlength="100" class="input-medium"/>
+        <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="2" label="已关闭"/>
+            <form:option value="3" label="已失效"/>
+        </form:select>
+        <label>领取状态:</label>
+        <form:select path="claimStatus" class="input-medium required">
+            <form:option value="" label="全部"/>
+            <form:option value="1" label="未领取"/>
+            <form:option value="2" label="已领取"/>
+        </form:select>
+        <label>使用状态:</label>
+        <form:select path="useStatus" class="input-medium required">
+            <form:option value="" label="全部"/>
+            <form:option value="1" label="未使用"/>
+            <form:option value="2" label="已使用"/>
+        </form:select>
+        <label>领取渠道:</label>
+        <form:select path="source" class="input-medium required">
+            <form:option value="" label="全部"/>
+            <form:option value="1" 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"
+               value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+               onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/> -
+        <input name="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+               value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+               onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        <input class="btn btn-primary" style="width: 100px" onclick="window.location='${ctx}/coupon/cmCoupon/form?couponType=2'" value="添加用户专享券"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>ID</th>
+        <th>机构名称</th>
+        <th>优惠券金额</th>
+        <th>优惠条件</th>
+        <th>优惠状态</th>
+        <th>领取状态</th>
+        <th>领取渠道</th>
+        <th>使用状态</th>
+        <th>领取时间</th>
+        <th>使用时间</th>
+        <th>开始时间</th>
+        <th>结束时间</th>
+        <th>添加时间</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="cmCoupon">
+        <tr>
+            <td>
+                    ${cmCoupon.id}
+            </td>
+            <td>
+                    ${cmCoupon.clubName}
+            </td>
+            <td>
+                    ${cmCoupon.couponAmount}
+            </td>
+            <td>
+                满${cmCoupon.touchPrice}
+            </td>
+            <td>
+                <c:if test="${cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <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>
+                </c:if>
+            </td>
+            <td>
+                <c:if test="${cmCoupon.claimStatus eq 1}">
+                    <font color="red">未领取</font>
+                </c:if>
+                <c:if test="${cmCoupon.claimStatus eq 2}">
+                    <font color="#FF6600">已领取</font>
+                </c:if>
+            </td>
+            <td>
+                <c:if test="${cmCoupon.claimStatus eq 1}">
+                    ----
+                </c:if>
+                <c:if test="${cmCoupon.claimStatus eq 2}">
+                    ${cmCoupon.couponClub.source eq 1 ? "小程序":cmCoupon.couponClub.source eq 2 ? "网站":"订单退回"}
+                </c:if>
+            </td>
+            <td>
+                <c:if test="${cmCoupon.claimStatus eq 1 ||cmCoupon.couponClub.status eq 1}">
+                    <font color="red">未使用</font>
+                </c:if>
+                <c:if test="${cmCoupon.claimStatus eq 2 && cmCoupon.couponClub.status eq 2}">
+                    <font color="#FF6600">已使用</font>
+                </c:if>
+            </td>
+            <td>
+                <c:if test="${cmCoupon.claimStatus eq 1}">
+                    ----
+                </c:if>
+                <c:if test="${cmCoupon.claimStatus eq 2}">
+                    <fmt:formatDate value="${cmCoupon.couponClub.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+                </c:if>
+            </td>
+            <td>
+                <c:if test="${cmCoupon.claimStatus eq 1}">
+                    ----
+                </c:if>
+                <c:if test="${cmCoupon.claimStatus eq 2}">
+                    <fmt:formatDate value="${cmCoupon.couponClub.useDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+                </c:if>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </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>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+</body>
+</html>

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

@@ -0,0 +1,68 @@
+<%@ taglib prefix="from" uri="http://www.springframework.org/tags/form" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>查看优惠券</title>
+    <meta name="decorator" content="default"/>
+    <style>
+    ul,li{list-style:none;margin:0;padding:0;}
+        .controller{padding:20px;max-width:880px;margin:0 auto;}
+        .productDetail{display:flex;align-items:center;border:1px solid #eee;padding:12px;margin:0 auto 30px;}
+        .productDetail .img{width:60px;height:60px;margin-right:20px;background:eee;}
+        .productDetail .img img{height:100%;}
+        .productDetail p{margin:0;line-height:22px;}
+        .couponList{margin:20px auto;}
+        .couponList h4{margin-bottom:10px;}
+        .couponList ul{display:flex;flex-wrap:wrap;}
+        .couponList ul:after{content:"";display:table;clear:both}
+        .couponList ul li{list-style:none;list-style-position:inside;border:1px solid #eee;margin:0 20px 20px 0;width:250px;padding:10px}
+        .couponList ul span{display:inline-block;width:100%;padding:2px}
+        .couponList ul span.couponDesc{min-height:72px;}
+    </style>
+</head>
+<body>
+<input type="hidden" id="ctx" value="${ctx}">
+<input type="hidden" id="productId" value="${product.productID}">
+<div class="controller">
+    <div class="productDetail">
+        <div class="img"><img src="${product.mainImage}" alt=""></div>
+        <div class="detail">
+            <p>商品名称:<a href="https://www.caimei365.com/product-${product.productID}.html">${product.name}</a></p>
+            <p>供应商:<span>${product.shopName}</span></p>
+            <p>机构价:<span>${product.price1}</span></p>
+        </div>
+    </div>
+    <div class="couponList">
+        <h4>普通优惠券(${ordinaryCoupons.size()})</h4>
+        <ul>
+            <c:forEach items="${ordinaryCoupons}" var="coupon">
+                <li><span class="couponDesc">
+                    <span>${coupon.couponName}</span>
+                    <c:if test="${not empty coupon.redemptionCode}">
+                        <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></li>
+            </c:forEach>
+        </ul>
+    </div>
+    <div class="couponList">
+        <h4>兑换优惠券(${redeemCoupons.size()})</h4>
+        <ul>
+            <c:forEach items="${redeemCoupons}" var="coupon">
+                <li><span class="couponDesc">
+                    <span>${coupon.couponName}</span>
+                    <c:if test="${not empty coupon.redemptionCode}">
+                        <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></li>
+            </c:forEach>
+        </ul>
+    </div>
+</div>
+</body>
+</html>

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

@@ -0,0 +1,819 @@
+<%@ page import="java.util.Date" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>优惠券管理</title>
+    <meta name="decorator" content="default"/>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("#inputForm").validate({
+                submitHandler: function(form){
+                    if (imageList.length > 0) {
+                        var productInfo = JSON.stringify(imageList);
+                        $('#productInfo').val(productInfo);
+                    }
+                    var couponType = $("input[name='couponType']:checked").val();
+                    var productType = $("input[name='productType']:checked").val();
+                    if (couponType == 0 && productType == 2) {
+                        var pcBanner = $('#pcBanner').val();
+                        var appletsBanner = $('#appletsBanner').val();
+                        if (pcBanner == '' || appletsBanner == '') {
+                            alertx("请上传Banner图");
+                            return false;
+                        }
+                    }
+                    var couponAmount = $("#couponAmount").val()*1;
+                    var touchPrice = $("#touchPrice").val()*1;
+                    if (couponAmount >= touchPrice) {
+                        alertx("优惠券金额必须小于优惠条件金额");
+                        return false;
+                    }
+                    var startDate = $("#startDate").val();
+                    var endDate = $("#endDate").val();
+                    if (startDate >= endDate) {
+                        alertx("结束时间不能早于开始时间");
+                        return false;
+                    }
+                    loading('正在提交,请稍等...');
+                    form.submit();
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function(error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+        });
+    </script>
+    <style>
+        .iconBox {
+            font-size: 0;
+        }
+        .conList .btn:nth-of-type(1){
+            margin-left: 25px;
+        }
+        .upload-content-image {
+            margin-top: -70px;
+        }
+
+        .upload-content-image .conList .btn:nth-of-type(1) {
+            width: 90px;
+            height: 100px;
+            border: 2px solid #eee;
+            background: #fff;
+            position: relative;
+        }
+
+        .upload-content-image .conList .btn:nth-of-type(1) > div {
+            position: absolute;
+            top: 50%;
+            left: 50%;
+            transform: translate(-50%, -50%);
+            color: #666;
+        }
+
+        .upload-content-image .conList .btn:nth-of-type(1) span {
+            font-size: 35px;
+        }
+
+        .upload-content-image .conList .btn:nth-of-type(1) h5 {
+            color: #666;
+        }
+        .upload-content-image .conList ol li {
+            width: 114px;
+            min-height: 80px;
+            text-align: center;
+            background: #fff;
+            position: relative;
+            top: 120px;
+            margin-left: 2px;
+        }
+        .cancel-upload-image {
+            background: transparent;
+            border: none;
+            box-shadow: none;
+            position: relative;
+            top: -38px;
+            left: -25px;
+            cursor: pointer;
+            z-index: 100;
+        }
+        .hide-pic-image {
+            display: none !important;
+        }
+    </style>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/coupon/cmCoupon/codeCouponList">兑换码优惠券</a></li>
+    <li class="active"><a href="${ctx}/coupon/cmCoupon/codeCouponForm?id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a></li>
+</ul><br/>
+<form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/codeCouponSave" method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <form:hidden path="productInfo" id="productInfo"/>
+    <sys:message content="${message}"/>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>活动主题:</label>
+        <div class="controls">
+            <form:input path="name" htmlEscape="false" maxlength="30" placeholder="30个汉字以内" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠券金额:</label>
+        <div class="controls">
+            <input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0" required>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠条件:</label>
+        <div class="controls">
+            订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice" value="${cmCoupon.touchPrice}" min="0" required>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>开始时间:</label>
+        <div class="controls">
+            <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
+                   value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
+                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});" onblur="dateShow()"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>结束时间:</label>
+        <div class="controls">
+            <input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
+                   value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
+                   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">
+            <label id="initializeShow">
+                <c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <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>
+                </c:if>
+            </label>
+            <label id="closeShow" style="display: none">
+                <font color="red">已关闭</font>
+            </label>
+            <input type="hidden" id="hiddenStatus" name="status" value="">
+            <input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""} onclick="statusShow()" />关闭
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>兑换码数量:</label>
+        <div class="controls">
+            <input type="number" name="codeNum" value="${cmCoupon.codeNum}" min="${empty cmCoupon.codeNum ? 0:cmCoupon.codeNum}" required>
+            &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="showSelect(${cmCoupon.id})">查看兑换码</a>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠券类型:</label>
+        <div class="controls">
+            <form:radiobutton path="couponType" value="0" label="活动券" class="required" onclick="couponShow()"/>
+            <form:radiobutton path="couponType" value="1" label="品类券" class="required" onclick="couponShow()"/>
+            <form:radiobutton path="couponType" value="2" label="用户专享券" class="required" onclick="couponShow()"/>
+            <form:radiobutton path="couponType" value="3" label="店铺券" class="required" onclick="couponShow()"/>
+            <form:radiobutton path="couponType" value="4" label="新用户券" class="required" onclick="couponShow()"/>
+        </div>
+    </div>
+    <div id="eventVoucher" hidden="hidden">
+        <div class="control-group">
+            <label class="control-label"><font color="red">*</font>优惠商品:</label>
+            <div class="controls">
+                <form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked ="${empty cmCoupon.productType ? true:false}"/>
+                <form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()"/>
+            </div>
+        </div>
+        <div class="productData" hidden="hidden">
+            <div class="control-group">
+                <label class="control-label"><font color="red">*</font>网站活动页banner:</label>
+                <div class="controls upload-content-image iconBox">
+                    <div class="conList">
+                        <form:hidden id="pcBanner" path="pcBanner" htmlEscape="false" maxlength="255" class="input-xlarge"/>
+                        <sys:ckfinder input="pcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                        <br>
+                    </div>
+                </div>
+            </div>
+            <div class="control-group">
+                <label class="control-label"><font color="red">*</font>小程序活动页banner:</label>
+                <div class="controls upload-content-image iconBox">
+                    <div class="conList">
+                        <form:hidden id="appletsBanner" path="appletsBanner" htmlEscape="false" maxlength="255" class="input-xlarge"/>
+                        <sys:ckfinder input="appletsBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+                        <br>
+                    </div>
+                </div>
+            </div>
+            <div class="control-group">
+                <input class="btn" id="del" style="width: 50px" onclick="batchDeletion()" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
+                <input class="btn btn-primary" style="width: 70px" onclick="batchSaveSort()" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;
+                <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct()" value="添加"/>
+                <br><br>
+                <table id="contentTableProduct" class="table table-striped table-bordered table-condensed" hidden="hidden">
+                    <thead>
+                    <tr>
+                        <th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/> 全选
+                        </th>
+                        <th>商品图片</th>
+                        <th>商品名称</th>
+                        <th>供应商</th>
+                        <th>网站状态</th>
+                        <th>小程序状态</th>
+                        <th>排序</th>
+                        <th>添加时间</th>
+                        <th>操作</th>
+                    </tr>
+                    </thead>
+                    <tbody id="hotSearchProduct"></tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+    <div class="control-group" id="couponCategory" hidden="hidden">
+        <label class="control-label"><font color="red">*</font>优惠品类:</label>
+        <div class="controls">
+            <form:radiobutton path="categoryType" value="1" label="产品" checked ="${empty cmCoupon.categoryType ? true:false}"/>
+            <form:radiobutton path="categoryType" value="2" label="仪器"/>
+        </div>
+    </div>
+    <div class="control-group" id="couponClub" hidden="hidden">
+        <label class="control-label"><font color="red">*</font>机构:</label>
+        <div class="controls">
+            <a href="javascript:void(0);" onclick="showSelectClub()" id="chooseClub">请选择机构</a>
+            <input type="hidden" name="userId" id="userId" value="${cmCoupon.userId}">
+            <table id="contentTableClub" class="table table-striped table-bordered table-condensed" hidden="hidden">
+                <thead>
+                <tr>
+                    <th>机构名称</th>
+                    <th>机构简称</th>
+                    <th>联系人</th>
+                    <th>手机号</th>
+                    <th>操作</th>
+                </tr>
+                </thead>
+                <tbody id="hotSearchClub"></tbody>
+            </table>
+        </div>
+    </div>
+    <div class="control-group" id="couponShop" hidden="hidden">
+        <label class="control-label"><font color="red">*</font>供应商:</label>
+        <div class="controls">
+            <a href="javascript:void(0);" onclick="showSelectShop()" id="chooseShop">请选择供应商</a>
+            <form:hidden path="shopId" id="shopId"/>
+            <table id="contentTableShop" class="table table-striped table-bordered table-condensed" hidden="hidden">
+                <thead>
+                <tr>
+                    <th>机构名称</th>
+                    <th>机构简称</th>
+                    <th>联系人</th>
+                    <th>手机号</th>
+                    <th>操作</th>
+                </tr>
+                </thead>
+                <tbody id="hotSearchShop"></tbody>
+            </table>
+        </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)"/>
+    </div>
+</form:form>
+<script>
+    //图片初始化
+    $(function () {
+        $('.upload-content-image .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
+        $('.upload-content-image .conList .btn:nth-of-type(2)').after('<img class="cancel-upload-image" src="/static/images/close-btn1.png">').remove();
+        $('.upload-content-image .conList').find('.cancel-upload-image').hide();
+        var observeEleImage = document.getElementsByClassName('upload-content-image')[0];
+        var observeEleImage1 = document.getElementsByClassName('upload-content-image')[1];
+        var MutationObserverImage = window.MutationObserver || window.WebKitMutationObserver;
+        var MutationObserverConfigImage = {
+            childList: true,
+            subtree: true,
+            characterData: true
+        };
+        var observerImage = new MutationObserverImage(function (mutations) {
+            $.each(mutations, function (index, item) {
+                if (item.type === 'childList') {
+                    // 在创建新的 element 时调用
+                    var target = $(item.target),
+                        thisWrapper = target.closest('.conList'),
+                        nextEle = thisWrapper.next();
+                    thisWrapper.find('li').css('z-index', 99);
+                    thisWrapper.find('.cancel-upload-image').show();
+                    if (nextEle.hasClass('hide-pic-image')) {
+                        nextEle.removeClass('hide-pic-image');
+                    }
+                }
+            })
+        });
+        observerImage.observe(observeEleImage, MutationObserverConfigImage);
+        observerImage.observe(observeEleImage1, MutationObserverConfigImage);
+
+        $('body').on('click', '.upload-content-image li', function () {
+            var index = $(this).closest('.conList').index() + 1,
+                str = 'remarkImage' + index + 'FinderOpen';
+            eval(str + '()');
+        });
+        $('body').on('click', '.cancel-upload-image', function () {
+            var wrapper = $(this).closest('.conList');
+            wrapper.find('li').css('z-index', '-1');
+            wrapper.find('input').val('');
+            $(this).hide();
+            wrapper.removeClass("hide-pic-image");
+            wrapper.parent().append(wrapper.clone());
+            wrapper.remove();
+            $(".conList").each(function (i, ele) {
+                if ($(ele).find("input.input-xlarge").val()) {
+                    $(ele).next().removeClass("hide-pic-image")
+                }
+            })
+        });
+        $(window).on("load", function () {
+            setTimeout(function () {
+                var input = $("#pcBanner");
+                if (input.val()) {
+                    input.next().find("li").css("z-index", "99");
+                    input.parents(".conList").find(".cancel-upload-image").show();
+                    input.parents(".conList").next().removeClass("hide-pic-image")
+                }
+                input = $("#appletsBanner");
+                if (input.val()) {
+                    input.next().find("li").css("z-index", "99");
+                    input.parents(".conList").find(".cancel-upload-image").show();
+                    input.parents(".conList").next().removeClass("hide-pic-image")
+                }
+            }, 500);
+        });
+        productShow()
+    });
+
+    var productIds = '';
+    var imageList = [];
+
+    $(function () {
+        //活动券商品回显
+        <c:forEach items="${associateList}" var="associate" varStatus="index">
+        imageList.push({
+            id: "${associate.id}",
+            productId: "${empty associate.productId ? "":associate.productId}",
+            image: "${associate.image}",
+            productName: "${associate.productName}",
+            shopName: "${associate.shopName}",
+            sort: "${associate.sort}",
+            pcStatus: "${associate.pcStatus}",
+            appletsStatus: "${associate.appletsStatus}",
+            addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+        });
+        </c:forEach>
+
+        if (imageList.length > 0) {
+            $('#contentTableProduct').show();
+            batchSaveSort();
+        }
+
+        //用户专享券机构回显
+        if (${not empty cmUser}){
+            var items = {
+                "userID": "${cmUser.userID}",
+                "name": "${cmUser.name}",
+                "shortName": "${cmUser.shortName}",
+                "linkMan": "${empty cmUser.userName ? '':cmUser.userName}",
+                "contractMobile": "${empty cmUser.bindMobile ? '':cmUser.bindMobile}"
+            };
+            insertHtmlClub(items);
+        }
+
+        //店铺券供应商回显
+        if (${not empty cmCoupon.shop}) {
+            var shop = {
+                "shopId": "${cmCoupon.shop.shopID}",
+                "name": "${cmCoupon.shop.name}",
+                "sname": "${cmCoupon.shop.sname}",
+                "linkMan": "${cmCoupon.shop.linkMan}",
+                "contractMobile": "${cmCoupon.shop.contractMobile}"
+            }
+            appendShopOrderHead(shop);
+        }
+
+        couponShow();
+    });
+
+    //点击添加商品
+    function showSelectProduct() {
+        var url = "${ctx}/coupon/cmCoupon/toAddProduct?productIds=" + productIds;
+        var title = '';
+        title = "选择商品";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 400,
+            height: $(top.document).height() - 160,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1', "取消": '-1'},
+            submit: function (v, h, f) {
+                //确定
+                var $jboxFrame = top.$('#jbox-iframe');
+                var $mainFrame = top.$('#mainFrame');
+                if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                    var items = $jboxFrame[0].contentWindow.getCheckedItems();
+                    console.log(items);
+                    console.log(items[0]);
+                    for (var i = 0; i < items.length; i++) {
+                        console.log(items[i]);
+                        imageList.push(items[i]);
+                        $('#contentTableProduct').show();
+                        $("#del").removeAttr("disabled");
+                        batchSaveSort();
+                    };
+                }
+                return true;
+            }
+        });
+    }
+
+    /**
+     * 一键排序
+     */
+    function batchSaveSort() {
+        imageList.sort(sort);
+        insertHtmlProduct(imageList);
+    }
+
+    //根据sort值 从小到大排序
+    function sort(a, b) {
+        return a.sort - b.sort;
+    }
+
+    //相关图片列表数据
+    function appendProductOrderHead(data, index) {
+        var html = '<tr id ="ai' + index + '">' +
+            '<td>' +
+            '<input class="check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
+            '</td>' +
+            '<td>' +
+            '<img src="' + data.image + '" width="60px" border="none" title="启用">' +
+            '</td>' +
+            '<td>' +
+            data.productName +
+            '</td>' +
+            '<td>' +
+            data.shopName +
+            '</td>' +
+            '<td>' +
+            (data.pcStatus == 1 ? (
+                '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
+                '<a href="javascript:void(0);" onclick="updatePcStatus(0,' + index + ');" >' +
+                '停用</a>'
+            ) : (
+                '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
+                '<a href="javascript:void(0)" onclick="updatePcStatus(1,' + index + ');">' +
+                '启用</a>'
+            )) +
+            '</td>' +
+            '<td>' +
+            (data.appletsStatus == 1 ? (
+                '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
+                '<a href="javascript:void(0);" onclick="updateAppletsStatus(0,' + index + ');" >' +
+                '停用</a>'
+            ) : (
+                '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
+                '<a href="javascript:void(0)" onclick="updateAppletsStatus(1,' + index + ');">' +
+                '启用</a>'
+            )) +
+            '</td>' +
+            '<td>' +
+            '<input name="sort" style="width:50px;" value="' + data.sort + '"  onkeyup="onlynum(this)"  onchange="changeSort(' + index + ',this)"></td>' +
+            '</td>' +
+            '<td>' +
+            (data.addTime == '' ? (
+                '<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
+            ) : (
+                data.addTime
+            )) +
+            '</td>' +
+            '<td>' +
+            '<a href="javascript:;" onclick="delect(' + index + ')">删除</a>' +
+            '</td>' +
+            '</tr>';
+        return html;
+    }
+
+    function insertHtmlProduct(list) {
+        var html = '';
+        productIds = '';
+        list.forEach(function (item, index) {
+            html += appendProductOrderHead(item, index);
+            productIds += "," + item.productId;
+        });
+        $("#hotSearchProduct").html(html);
+    }
+
+    function changeSort(index, sortThis) {
+        var sort = sortThis.value;
+        if (sort <= 0) {
+
+        }
+        var image = imageList[index];
+        image.sort = sort;
+    }
+
+    function updatePcStatus(status, index) {
+        var image = imageList[index];
+        confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
+            image.pcStatus = status;
+            batchSaveSort();
+        })
+    }
+
+    function updateAppletsStatus(status, index) {
+        var image = imageList[index];
+        confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
+            image.appletsStatus = status;
+            batchSaveSort();
+        })
+    }
+
+    function clickAllSelect(ckb) {
+        var isChecked = ckb.checked;
+        $(".check-item").attr('checked', isChecked);
+    }
+
+    /**
+     * 删除操作
+     */
+    function delect(index) {
+        return confirmx("确定删除吗?", function () {
+            var image = imageList[index];
+            if (image.productId != '') {
+                productIds = productIds.replace(image.productId,"");
+            }
+            imageList.splice(index, 1);
+            insertHtmlProduct(imageList);
+            if (imageList.length == 0) {
+                $('#contentTableProduct').hide();
+                $("#del").attr("disabled", "disabled");
+            }
+        });
+    }
+
+
+    /**
+     * 批量删除
+     */
+    function batchDeletion() {
+        var index = -1;
+        var i = 1;
+        return confirmx("确定删除吗?", function () {
+            $('input[name="info"]:checked').each(function () {
+                var thisIndex = $(this).val();
+                if (index >= 0 && index < thisIndex) {
+                    thisIndex = thisIndex - i;
+                    i++;
+                } else {
+                    index = thisIndex;
+                }
+                var image = imageList[thisIndex];
+                if (image.productId != '') {
+                    productIds = productIds.replace(image.productId, "");
+                }
+                imageList.splice(thisIndex, 1);
+                insertHtmlProduct(imageList);
+                if (imageList.length == 0) {
+                    $('#contentTableProduct').hide();
+                    $("#del").attr("disabled", "disabled");
+                }
+            });
+        });
+    }
+
+    function productShow() {
+        var  productType = $("input[name='productType']:checked").val();
+        if (productType == 2){
+            $(".productData").show();
+        }else {
+            $(".productData").hide();
+        }
+    }
+
+    function insertHtmlClub(data) {
+        var html = '<tr>' +
+            '<td>' +
+            data.name +
+            '</td>' +
+            '<td>' +
+            data.shortName +
+            '</td>' +
+            '<td>' +
+            data.linkMan +
+            '</td>' +
+            '<td>' +
+            data.contractMobile +
+            '</td>' +
+            '<td>' +
+            '<a href="javascript:;" onclick="deleteClub()">删除</a>' +
+            '</td>' +
+            '</tr>';
+        $("#contentTableClub").show();
+        $("#chooseClub").hide();
+        $("#hotSearchClub").html(html);
+        $("#userId").val(data.userID);
+    }
+
+    function deleteClub() {
+        $("#hotSearchClub").html("");
+        $("#contentTableClub").hide();
+        $("#chooseClub").show();
+        $("#userId").val("");
+    }
+
+    function statusShow() {
+        var status = $("input[name='status']:checked").val();
+        if (status == 2) {
+            $("#initializeShow").hide();
+            $("#closeShow").show();
+        } else {
+            $("#initializeShow").show();
+            $("#closeShow").hide();
+            $("#hiddenStatus").val(0);
+        }
+    }
+
+    function dateShow() {
+        var startDate = $("#startDate").val();
+        var startMs = new Date(startDate).getTime();
+        var endDate = $("#endDate").val();
+        var endMs = new Date(endDate).getTime();
+        var nowMs = new Date().getTime();
+        if (nowMs < startMs) {
+            $("#initializeShow").html("<font color=\"#800080\">未生效</font>");
+        } else if (nowMs > endMs) {
+            $("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
+        } else {
+            $("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
+        }
+    }
+
+    function showSelect(couponId) {
+        if (couponId == null){
+            alertx("暂未生成兑换码");
+            return false;
+        }
+        var url = "${ctx}/coupon/cmCoupon/redemptionCode?couponId=" + couponId;
+        var title = '';
+        title = "查看兑换码";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 750,
+            height: $(top.document).height() - 300,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1'}
+        });
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+
+    //点击添加机构
+    function showSelectClub() {
+        var url = "${ctx}/coupon/cmCoupon/toAddClub";
+        var title = '';
+        title = "选择机构";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 400,
+            height: $(top.document).height() - 160,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1', "取消": '-1'},
+            submit: function (v, h, f) {
+                //确定
+                var $jboxFrame = top.$('#jbox-iframe');
+                var $mainFrame = top.$('#mainFrame');
+                if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                    var items = $jboxFrame[0].contentWindow.getCheckedItems();
+                    console.log(items);
+                    insertHtmlClub(items);
+                }
+                return true;
+            }
+        });
+    }
+
+    function appendShopOrderHead(data) {
+        var html = '<tr>' +
+            '<td>' +
+            data.name +
+            '</td>' +
+            '<td>' +
+            data.sname +
+            '</td>' +
+            '<td>' +
+            data.linkMan +
+            '</td>' +
+            '<td>' +
+            data.contractMobile +
+            '</td>' +
+            '<td>' +
+            '<a href="javascript:;" onclick="delectShop()">删除</a>' +
+            '</td>' +
+            '</tr>';
+        $("#hotSearchShop").html(html);
+        $("#chooseShop").hide();
+        $('#contentTableShop').show();
+        $("#shopId").val(data.shopId);
+    }
+
+    //点击添加
+    function showSelectShop() {
+        var url = "${ctx}/coupon/cmCoupon/toAddShop";
+        var title = '';
+        title = "选择供应商";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 400,
+            height: $(top.document).height() - 160,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1', "取消": '-1'},
+            submit: function (v, h, f) {
+                //确定
+                var $jboxFrame = top.$('#jbox-iframe');
+                var $mainFrame = top.$('#mainFrame');
+                if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                    var items = $jboxFrame[0].contentWindow.getCheckedItems();
+                    console.log(items);
+                    appendShopOrderHead(items);
+                }
+                return true;
+            }
+        });
+    }
+
+    /**
+     * 删除操作
+     */
+    function delectShop() {
+        return confirmx("确定删除吗?", function () {
+            $("#chooseShop").show();
+            $('#contentTableShop').hide();
+            $("#shopId").val("");
+        });
+    }
+
+    function couponShow() {
+        var couponType = $("input[name='couponType']:checked").val();
+        if (couponType == 0) {
+            $("#eventVoucher").show();
+            $("#couponCategory").hide();
+            $("#couponClub").hide();
+            $("#couponShop").hide();
+        } else if (couponType == 1) {
+            $("#eventVoucher").hide();
+            $("#couponCategory").show();
+            $("#couponClub").hide();
+            $("#couponShop").hide();
+        } else if (couponType == 2) {
+            $("#eventVoucher").hide();
+            $("#couponCategory").hide();
+            $("#couponClub").show();
+            $("#couponShop").hide();
+        } else if (couponType == 3) {
+            $("#eventVoucher").hide();
+            $("#couponCategory").hide();
+            $("#couponClub").hide();
+            $("#couponShop").show();
+        } else {
+            $("#eventVoucher").hide();
+            $("#couponCategory").hide();
+            $("#couponClub").hide();
+            $("#couponShop").hide();
+        }
+    }
+</script>
+</body>
+</html>

+ 137 - 0
src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeCouponList.jsp

@@ -0,0 +1,137 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>兑换码优惠券</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th{text-align: center;}
+        .table td{text-align: center;}
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function() {
+
+        });
+        function page(n,s){
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li class="active"><a href="${ctx}/coupon/cmCoupon/codeCouponList">兑换码优惠券</a></li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/codeCouponList" method="post" class="breadcrumb form-search">
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>活动主题:</label>
+        <form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
+        <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="2" label="已关闭"/>
+            <form:option value="3" label="已失效"/>
+        </form:select>
+        <label>优惠时间:</label>
+        <input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+               value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+               onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/> -
+        <input name="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+               value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+               onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        <input class="btn btn-primary" style="width: 120px" onclick="window.location='${ctx}/coupon/cmCoupon/codeCouponForm'" value="添加兑换码优惠券"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>ID</th>
+        <th>活动主题</th>
+        <th>优惠券金额</th>
+        <th>优惠条件</th>
+        <th>优惠状态</th>
+        <th>已兑换数量</th>
+        <th>开始时间</th>
+        <th>结束时间</th>
+        <th>添加时间</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="cmCoupon">
+        <tr>
+            <td>
+                    ${cmCoupon.id}
+            </td>
+            <td>
+                    ${cmCoupon.name}
+            </td>
+            <td>
+                    ${cmCoupon.couponAmount}
+            </td>
+            <td>
+                满${cmCoupon.touchPrice}
+            </td>
+            <td>
+                <c:if test="${cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <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>
+                </c:if>
+            </td>
+            <td>
+                ${cmCoupon.codeNum}
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </td>
+            <td>
+                <fmt:formatDate value="${cmCoupon.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+            </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>
+                <a href="javascript:void(0);" onclick="showSelect(${cmCoupon.id})">查看兑换码</a>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<script>
+    function showSelect(couponId) {
+        var url = "${ctx}/coupon/cmCoupon/redemptionCode?couponId=" + couponId;
+        var title = '';
+        title = "查看兑换码";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 750,
+            height: $(top.document).height() - 300,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1'}
+        });
+    }
+</script>
+<div class="pagination">${page}</div>
+</body>
+</html>

+ 96 - 0
src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeList.jsp

@@ -0,0 +1,96 @@
+<%--
+  Created by IntelliJ IDEA.
+  User: Administrator
+  Date: 2020/4/9
+  Time: 19:54
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>查看兑换码</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table td i {
+            margin: 0 2px;
+        }
+    </style>
+
+    <script type="text/javascript">
+        $(document).ready(function () {
+            $("#searchForm").validate({
+                submitHandler: function (form) {
+                    form.submit();
+                }
+            })
+        });
+    </script>
+</head>
+<body>
+<br/>
+<form:form id="searchForm" modelAttribute="cmCouponRedemptionCode" action="${ctx}/coupon/cmCoupon/redemptionCode" method="post" class="breadcrumb form-search">
+    <input name="couponId" type="hidden" value="${redemptionCode.couponId}"/>
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>兑换状态:</label>
+        <form:select path="status" class="input-medium">
+            <form:option value="" label="全部"/>
+            <form:option value="1" label="未兑换"/>
+            <form:option value="2" label="已兑换"/>
+        </form:select>
+        &nbsp;&nbsp; <input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table class="table table-striped table-bordered table-condensed table-hover">
+    <tr>
+        <th>序号</th>
+        <th>兑换码</th>
+        <th>兑换状态</th>
+        <th>兑换时间</th>
+    </tr>
+    <tbody>
+    <c:if test="${not empty page.list}">
+        <c:forEach items="${page.list}" var="item" varStatus="index">
+            <tr>
+                <td>${(page.pageNo-1)*page.pageSize+index.index+1}</td>
+                <td>${item.redemptionCode}</td>
+                <td>${item.status eq '1' ? "未兑换" : "已兑换"}</td>
+                <td><fmt:formatDate value="${item.redemptionTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
+            </tr>
+        </c:forEach>
+    </c:if>
+    </tbody>
+</table>
+<c:if test="${empty  page.list}">
+    <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
+</c:if>
+<div class="pagination">${page}</div>
+<script type="text/javascript">
+    $(document).ready(function () {
+        //弹出框去滚动条
+        top.$('#jbox-content').css("overflow-y", "hidden");
+        show_title(30);
+    });
+
+    function page(n, s) {
+        $("#pageNo").val(n);
+        $("#pageSize").val(s);
+        $("#searchForm").submit();
+        return false;
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+</script>
+</body>
+</html>
+

+ 119 - 0
src/main/webapp/WEB-INF/views/modules/coupon/toAddClub.jsp

@@ -0,0 +1,119 @@
+<%--
+  Created by IntelliJ IDEA.
+  User: Administrator
+  Date: 2020/4/9
+  Time: 19:54
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>选择机构</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table td i {
+            margin: 0 2px;
+        }
+    </style>
+
+    <script type="text/javascript">
+        $(document).ready(function () {
+            $("#searchForm").validate({
+                submitHandler: function (form) {
+                    form.submit();
+                }
+            })
+        });
+    </script>
+</head>
+<body>
+<br/>
+<form:form id="searchForm" modelAttribute="cmUser" action="${ctx}/coupon/cmCoupon/toAddClub" method="post" class="breadcrumb form-search">
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>机构ID:</label>
+        <form:input path="userID" id="userID" htmlEscape="false" maxlength="8" class="input-mini" onkeyup="onlynum(this)"/>
+        <label>机构名称:</label>
+        <form:input path="name" htmlEscape="false" class="input-medium" maxlength="20"/>
+        <label>机构简称:</label>
+        <form:input path="shortName" htmlEscape="false" class="input-medium" maxlength="20"/>
+        &nbsp;&nbsp; <input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table class="table table-striped table-bordered table-condensed table-hover">
+    <tr>
+        <th style="width:20px;"></th>
+        <th>机构ID</th>
+        <th>机构名称</th>
+        <th>机构简称</th>
+        <th>联系人</th>
+        <th>手机号</th>
+    </tr>
+    <tbody>
+    <c:if test="${not empty page.list}">
+        <c:forEach items="${page.list}" var="item">
+            <tr id="${item.userID}" class="itemtr">
+                <th>
+                    <input class="check-item" type="radio" name="info" value='${fns:toJson(item)}'/>
+                </th>
+                <td>${item.userID}</td>
+                <td>${item.name}</td>
+                <td>${item.shortName}</td>
+                <td>${item.userName}</td>
+                <td>${item.bindMobile}</td>
+            </tr>
+        </c:forEach>
+    </c:if>
+    </tbody>
+</table>
+<c:if test="${empty  page.list}">
+    <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
+</c:if>
+<div class="pagination">${page}</div>
+<script type="text/javascript">
+    $(document).ready(function () {
+        //弹出框去滚动条
+        top.$('#jbox-content').css("overflow-y", "hidden");
+        show_title(30);
+    });
+
+    function page(n, s) {
+        $("#pageNo").val(n);
+        $("#pageSize").val(s);
+        $("#searchForm").submit();
+        return false;
+    }
+
+    function getCheckedItems() {
+        var item = $('.check-item:checked').val();
+        var club = JSON.parse(item);
+        var items = {
+            "userID": club.userID,
+            "name": club.name,
+            "shortName": club.shortName,
+            "linkMan": club.userName,
+            "contractMobile": club.bindMobile
+        };
+        return items;
+    }
+
+    function clickAllSelect(ckb) {
+        var isChecked = ckb.checked;
+        $(".check-item").attr('checked', isChecked);
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+</script>
+</body>
+</html>
+

+ 130 - 0
src/main/webapp/WEB-INF/views/modules/coupon/toAddProduct.jsp

@@ -0,0 +1,130 @@
+<%@ page import="java.util.Date" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>选择商品</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table td i{margin:0 2px;}
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            //弹出框去滚动条
+            top.$('#jbox-content').css("overflow-y","hidden");
+            show_title(30);
+
+//			反选
+            $('body').on('click','input[name="info"]',function() {
+                var allInputLength = $('input[name="info"]').length - $('input[name="info"]:disabled').length,
+                    allInputCheckedLength = $('input[name="info"]:checked').length,
+                    checkAllEle= $('.check-all');
+//			    判断选中长度和总长度,如果相等就是全选否则取消全选
+                if(allInputLength === allInputCheckedLength) {
+                    checkAllEle.attr('checked', true);
+                } else {
+                    checkAllEle.attr('checked', false);
+                }
+            })
+        });
+        function page(n,s){
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+
+        function getCheckedItems(){
+            var items = [];
+            var $items = $('.check-item:checked');
+            $items.each(function(){
+                var product = JSON.parse($(this).val());
+                items.push({
+                    "id": "",
+                    "productId": product.productID,
+                    "image": product.mainImage,
+                    "productName": product.name,
+                    "shopName": product.shopName,
+                    "sort": 1,
+                    "pcStatus": "1",
+                    "appletsStatus": "1",
+                    "addTime": ""
+                })
+            });
+            return items;
+        }
+
+        function allCkbfun(ckb){
+            var isChecked = ckb.checked;
+            $(".check-item").attr('checked', isChecked);
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字和两位小数(金额)
+         */
+        function num(obj) {
+            obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
+            obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
+            obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
+            obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
+            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
+        }
+
+    </script>
+</head>
+<body>
+<form:form id="searchForm" modelAttribute="product" action="${ctx}/coupon/cmCoupon/toAddProduct?productIds=${productIds}" method="post" class="breadcrumb form-search">
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>商品ID:</label>
+        <form:input path="productID" htmlEscape="false"  maxlength="10" class="input-mini" onchange="onlynum(this)"/>
+        <label>商品名称:</label>
+        <form:input path="name" htmlEscape="false" class="input-medium" maxlength="20"/>
+        <label>供应商:</label>
+        <form:input path="shopName" htmlEscape="false" class="input-medium" maxlength="20"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table class="table table-striped table-bordered table-condensed table-hover">
+    <tr>
+        <th style="width:20px;"><input class="check-all" type="checkbox" onclick="allCkbfun(this);"/></th>
+        <th>商品ID</th>
+        <th>商品图片</th>
+        <th>商品名称</th>
+        <th>供应商</th>
+    </tr>
+    <tbody>
+    <c:if test="${not empty page.list}">
+        <c:forEach items="${page.list}" var="item">
+            <tr id="${item.productID}" class="itemtr">
+                    <%--已过滤添加过的商品和未上架的商品--%>
+                <th>
+                    <input class="check-item" ${item.storeStatus ? "disabled" : ""}  type="checkbox" name="info" value='${fns:toJson(item)}'/>
+                </th>
+                <td>${item.productID}</td>
+                <td><img src="${item.mainImage}" width="50px" height="50px"></td>
+                <td>${item.name}</td>
+                <td>${item.shopName}</td>
+            </tr>
+        </c:forEach>
+    </c:if>
+    </tbody>
+</table>
+<c:if test="${empty page.list}">
+    <p style="text-align: center;"><font  color="#1e90ff">暂无数据……</font></p>
+</c:if>
+<div class="pagination">${page}</div>
+</body>
+</html>

+ 107 - 0
src/main/webapp/WEB-INF/views/modules/coupon/toAddShop.jsp

@@ -0,0 +1,107 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>选择供应商</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table td i{margin:0 2px;}
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            //弹出框去滚动条
+            top.$('#jbox-content').css("overflow-y","hidden");
+            show_title(30);
+        });
+        function page(n,s){
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+
+        function getCheckedItems() {
+            var item = $('.check-item:checked').val();
+            var shop = JSON.parse(item);
+            var items = {
+                "shopId": shop.shopID,
+                "name": shop.name,
+                "sname": shop.sname,
+                "linkMan": shop.linkMan,
+                "contractMobile": shop.contractMobile
+            };
+            return items;
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字和两位小数(金额)
+         */
+        function num(obj) {
+            obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
+            obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
+            obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
+            obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
+            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
+        }
+
+    </script>
+</head>
+<body>
+<form:form id="searchForm" modelAttribute="newCmShop" action="${ctx}/coupon/cmCoupon/toAddShop" method="post" class="breadcrumb form-search">
+    <input type="hidden" name="shopIds" value="${shopIds}">
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>供应商ID:</label>
+        <form:input path="shopID" htmlEscape="false"  maxlength="10" class="input-mini" onchange="onlynum(this)"/>
+        <label>供应商名称:</label>
+        <form:input path="name" htmlEscape="false" class="input-medium" maxlength="20"/>
+        <label>供应商简称:</label>
+        <form:input path="sname" htmlEscape="false" class="input-medium" maxlength="20"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table class="table table-striped table-bordered table-condensed table-hover">
+    <tr>
+        <th style="width:20px;"></th>
+        <th>供应商ID</th>
+        <th>供应商名称</th>
+        <th>供应商简称</th>
+        <th>联系人</th>
+        <th>手机号</th>
+    </tr>
+    <tbody>
+    <c:if test="${not empty page.list}">
+        <c:forEach items="${page.list}" var="item">
+            <tr id="${item.shopID}" class="itemtr">
+                    <%--已过滤添加过的商品和未上架的商品--%>
+                <th>
+                    <input class="check-item" type="radio" name="info" value='${fns:toJson(item)}'/>
+                </th>
+                <td>${item.shopID}</td>
+                <td>${item.name}</td>
+                <td>${item.sname}</td>
+                <td>${item.linkMan}</td>
+                <td>${item.contractMobile}</td>
+            </tr>
+        </c:forEach>
+    </c:if>
+    </tbody>
+</table>
+<c:if test="${empty page.list}">
+    <p style="text-align: center;"><font  color="#1e90ff">暂无数据……</font></p>
+</c:if>
+<div class="pagination">${page}</div>
+</body>
+</html>

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

@@ -0,0 +1,68 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+    <title>领取用户列表</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th{text-align: center;}
+        .table td{text-align: center;}
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function() {
+
+        });
+        function page(n,s){
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li class="active"><a href="${ctx}/coupon/cmCouponClub/userList">领取用户列表</a></li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmCouponClub" action="${ctx}/coupon/cmCouponClub/userList" method="post" class="breadcrumb form-search">
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>机构名称:</label>
+        <form:input path="clubName" htmlEscape="false" maxlength="20" class="input-medium"/>
+        <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed" >
+    <thead>
+    <tr>
+        <th>序号</th>
+        <th>机构名称</th>
+        <th>可用优惠券数量</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="club" varStatus="index">
+        <tr>
+            <td>
+                    ${(page.pageNo-1)*page.pageSize+index.index+1}
+            </td>
+            <td>
+                    ${club.clubName}
+            </td>
+            <td>
+                    ${club.num}
+            </td>
+            <td>
+                <a href="${ctx}/coupon/cmCouponClub/couponDetails?userId=${club.userId}" >查看详情</a>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+</body>
+</html>

+ 18 - 18
src/main/webapp/WEB-INF/views/modules/newhome/beautyFloorContentForm.jsp

@@ -847,7 +847,7 @@
                                     <img src="/static/template/beauty/pc/21.png">
                                 </div>
                             </div>
-                            <div id="pcTemplate22" class="mallTemplate">
+                            <div id="pcTemplate22" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="22" label="模板22" id="templateType22"
                                                   cssClass="templateButton"
                                                   onclick="showContent('pc')"/>
@@ -857,7 +857,7 @@
                                     <img src="/static/template/beauty/pc/22.png">
                                 </div>
                             </div>
-                            <div id="pcTemplate23" class="mallTemplate">
+                            <div id="pcTemplate23" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="23" label="模板23" id="templateType23"
                                                   cssClass="templateButton"
                                                   onclick="showContent('pc')"/>
@@ -867,7 +867,7 @@
                                     <img src="/static/template/beauty/pc/23.png">
                                 </div>
                             </div>
-                            <div id="pcTemplate24" class="mallTemplate">
+                            <div id="pcTemplate24" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="24" label="模板24" id="templateType24"
                                                   cssClass="templateButton"
                                                   onclick="showContent('pc')"/>
@@ -877,7 +877,7 @@
                                     <img src="/static/template/beauty/pc/24.png">
                                 </div>
                             </div>
-                            <div id="pcTemplate25" class="mallTemplate">
+                            <div id="pcTemplate25" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="25" label="模板25" id="templateType25"
                                                   cssClass="templateButton"
                                                   onclick="showContent('pc')"/>
@@ -887,7 +887,7 @@
                                     <img src="/static/template/beauty/pc/25.png">
                                 </div>
                             </div>
-                            <div id="pcTemplate26" class="mallTemplate">
+                            <div id="pcTemplate26" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="26" label="模板26" id="templateType26"
                                                   cssClass="templateButton"
                                                   onclick="showContent('pc')"/>
@@ -897,17 +897,17 @@
                                     <img src="/static/template/beauty/pc/26.png">
                                 </div>
                             </div>
-                            <div id="pcTemplate27" class="mallTemplate">
+                            <div id="pcTemplate27" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="27" label="模板27" id="templateType27"
                                                   cssClass="templateButton"
                                                   onclick="showContent('pc')"/>
-                                <em class="middleEm">偏商城活动</em>
+                                <em class="middleEm">偏展会活动</em>
                                 <em class="rightEm">PC端</em>
                                 <div class="templateImageDiv">
                                     <img src="/static/template/beauty/pc/27.png">
                                 </div>
                             </div>
-                            <div id="pcTemplate28" class="mallTemplate">
+                            <div id="pcTemplate28" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="28" label="模板28" id="templateType28"
                                                   cssClass="templateButton"
                                                   onclick="showContent('pc')"/>
@@ -917,7 +917,7 @@
                                     <img src="/static/template/beauty/pc/28.png">
                                 </div>
                             </div>
-                            <div id="pcTemplate29" class="mallTemplate">
+                            <div id="pcTemplate29" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="29" label="模板29" id="templateType29"
                                                   cssClass="templateButton"
                                                   onclick="showContent('pc')"/>
@@ -1139,7 +1139,7 @@
                                     <img src="/static/template/beauty/applets/21.png">
                                 </div>
                             </div>
-                            <div id="appletsTemplate22" class="mallTemplate">
+                            <div id="appletsTemplate22" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="72" label="模板22" id="templateType72"
                                                   cssClass="templateButton"
                                                   onclick="showContent('applets')"/>
@@ -1150,7 +1150,7 @@
                                     <img src="/static/template/beauty/applets/22.png">
                                 </div>
                             </div>
-                            <div id="appletsTemplate23" class="mallTemplate">
+                            <div id="appletsTemplate23" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="73" label="模板23" id="templateType73"
                                                   cssClass="templateButton"
                                                   onclick="showContent('applets')"/>
@@ -1160,7 +1160,7 @@
                                     <img src="/static/template/beauty/applets/23.png">
                                 </div>
                             </div>
-                            <div id="appletsTemplate24" class="mallTemplate">
+                            <div id="appletsTemplate24" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="74" label="模板24" id="templateType74"
                                                   cssClass="templateButton"
                                                   onclick="showContent('applets')"/>
@@ -1170,7 +1170,7 @@
                                     <img src="/static/template/beauty/applets/24.png">
                                 </div>
                             </div>
-                            <div id="appletsTemplate25" class="mallTemplate">
+                            <div id="appletsTemplate25" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="75" label="模板25" id="templateType75"
                                                   cssClass="templateButton"
                                                   onclick="showContent('applets')"/>
@@ -1180,7 +1180,7 @@
                                     <img src="/static/template/beauty/applets/25.png">
                                 </div>
                             </div>
-                            <div id="appletsTemplate26" class="mallTemplate">
+                            <div id="appletsTemplate26" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="76" label="模板26" id="templateType76"
                                                   cssClass="templateButton"
                                                   onclick="showContent('applets')"/>
@@ -1190,7 +1190,7 @@
                                     <img src="/static/template/beauty/applets/26.png">
                                 </div>
                             </div>
-                            <div id="appletsTemplate27" class="mallTemplate">
+                            <div id="appletsTemplate27" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="77" label="模板27" id="templateType77"
                                                   cssClass="templateButton"
                                                   onclick="showContent('applets')"/>
@@ -1200,7 +1200,7 @@
                                     <img src="/static/template/beauty/applets/27.png">
                                 </div>
                             </div>
-                            <div id="appletsTemplate28" class="mallTemplate">
+                            <div id="appletsTemplate28" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="78" label="模板28" id="templateType78"
                                                   cssClass="templateButton"
                                                   onclick="showContent('applets')"/>
@@ -1210,7 +1210,7 @@
                                     <img src="/static/template/beauty/applets/28.png">
                                 </div>
                             </div>
-                            <div id="appletsTemplate29" class="mallTemplate">
+                            <div id="appletsTemplate29" class="displayTemplate">
                                 <form:radiobutton path="templateType" name="templateType" value="79" label="模板29" id="templateType79"
                                                   cssClass="templateButton"
                                                   onclick="showContent('applets')"/>
@@ -1419,7 +1419,7 @@
             //展示模板内容表单
             $("#infoLabel").hide();
             $(".templateImageTable").show();
-            // $("#displayDateDiv").css('display', 'none');
+            $("#displayDateDiv").css('display', 'none');
             $("#adsImageTable").hide();
             $("#infoImageTable").hide();
             $("#productImageTable").hide();

+ 3 - 3
src/main/webapp/WEB-INF/views/modules/order/cmPayShopDetail.jsp

@@ -297,10 +297,10 @@
 			</c:if>
 			<div>
 				<label>欠款抵扣:</label>
-				总欠款:<span id="rebateAmount">${empty cmPayShop.rebateAmount ? 0 : cmPayShop.rebateAmount}</span>,
-				可抵扣欠款:<span id="ableRebateAmount">${empty cmPayShop.ableRebateAmount ? 0 : cmPayShop.ableRebateAmount}</span>,
+				总欠款:<span id="rebateAmount">${empty cmPayShop.rebateAmount ? 0 : cmPayShop.rebateAmount }</span>,
+				可抵扣欠款:<span id="ableRebateAmount">${empty cmPayShop.ableRebateAmount ? 0 : cmPayShop.ableRebateAmount }</span>,
 				使用:${cmPayShop.balancePayFee},
-				剩余:<span id="remainingBalance">${(empty cmPayShop.rebateAmount ? 0 : cmPayShop.rebateAmount) - (empty cmPayShop.balancePayFee ? 0 : cmPayShop.balancePayFee)}</span>
+				剩余:<span id="remainingBalance"> ${cmPayShop.status == '2'?((empty cmPayShop.ableRebateAmount ? 0:cmPayShop.ableRebateAmount)-cmPayShop.balancePayFee): (empty cmPayShop.ableRebateAmount ? 0 : cmPayShop.ableRebateAmount)}</span>
 			</div>
 			<c:if test="${cmPayShop.payType ne '6'}">
 				<div>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/order/newOrderList.jsp

@@ -97,7 +97,7 @@
             -webkit-border-radius: 5px;
             -moz-border-radius: 5px;
             border-radius: 5px;
-            z-index: 999;
+            z-index: 100001;
             display: none;
         }
 

+ 21 - 2
src/main/webapp/WEB-INF/views/modules/order/orderDetail.jsp

@@ -47,7 +47,7 @@
         .order-rows .supplier-img{width:100px}
         .operation-wrapper{position:relative}
         .operation-btn{cursor:pointer}
-        .operation-block{background:#fff;width:125px;position:absolute;left:35px;top:30px;padding:10px;border:1px solid #666;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;z-index:999;display:none}
+        .operation-block{background:#fff;width:125px;position:absolute;left:35px;top:30px;padding:10px;border:1px solid #666;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;z-index:100001;display:none}
         .operation-block a{display:block;padding:3px 0}
         .print-wrapper{display:inline-block}
         .supplier-product-name,.supplier-product-alias{width:200px;line-height:20px}
@@ -196,7 +196,26 @@
         <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"/>&nbsp;
+            <c:if test="${not empty order.couponOrderRecord}">
+                <c:if test="${order.couponOrderRecord.couponType eq 0}">
+                    <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 test="${order.couponOrderRecord.couponType eq 1}">
+                    <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 test="${order.couponOrderRecord.couponType eq 2}">
+                    <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 test="${order.couponOrderRecord.couponType eq 3}">
+                    <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 test="${order.couponOrderRecord.couponType eq 4}">
+                    <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>
+        </td>
     </tr>
     <tr>
         <td>

+ 39 - 8
src/main/webapp/WEB-INF/views/modules/order/orderForm.jsp

@@ -23,6 +23,14 @@
         .ladderPrice:hover .list{display:block}
         .ladderPrice .list span{margin:0 20px;width:60px;text-align:center;display:inline-block}
         .ladderPrice .list span.price{color:red}
+        ul.couponContent{display:flex;flex-wrap:wrap;}
+        ul.couponContent:after{content:"";display:table;clear:both}
+        ul.couponContent li{list-style:none;list-style-position:inside;border:1px solid #eee;margin:20px 20px 20px 0;width:300px;padding:10px}
+        ul.couponContent label{display:flex;align-items:center}
+        ul.couponContent span{display:inline-block;width:100%;padding:2px}
+        ul.couponContent span.couponDesc{min-height:72px;}
+        ul.couponContent span.couponDesc.none{height:72px;line-height:72px;vertical-align:middle;}
+    }
     </style>
 </head>
 <body>
@@ -166,7 +174,7 @@
     <input ${empty order.orderID?'style="display:none"':''} id="shopSelected" class="btn btn-primary" type="button" value="添加商品" onclick="showShopSelect('iframe:${ctx}/bulkpurchase/purchaseProduct/list?flag=1${order.orderSubmitType eq 6 ? '&priceType=normal' : ''}')" />
     <input ${empty order.orderID?'':'style="display:none"'}  id="shopSelected1" class="btn btn-primary" type="button" onclick="alertx('请您先选择会所!')" value="添加商品" />
   </c:if>
-    <label style="display: block;margin-top: 20px;font-family: 'Microsoft YaHei';font-size: 15px;font-weight: bold; text-decoration: none;border-bottom: 2px solid #050202">订单商品<label style="color: red;margin-left: 20px">注:如果使用折扣,不能同时享受促销优惠</label></label>
+  <div style="margin-top:20px;font-size:15px;border-bottom:2px solid #050202"><b>订单商品</b><span style="color:red;margin-left:20px">注:如果使用折扣,不能同时享受促销优惠</span></div>
   <%int idx=0 ;%>
     <!-- idx 在页面上记录商品循环时候的index -->
     <c:forEach items="${order.newShopOrders}" var="shopOrder">
@@ -218,6 +226,7 @@
               <%--<th>应付供应商</th>--%>
               <th>能否复购</th>
               <th>促销活动</th>
+              <th>优惠券</th>
               <th>操作</th>
             </tr>
           </thead>
@@ -291,6 +300,12 @@
                       </c:if>
                     </c:if>
                   </td>
+                  <td>
+                      <c:if test="${orderProduct.couponsLogo eq 1}">----</c:if>
+                      <c:if test="${orderProduct.couponsLogo eq 2}">
+                        <a href="javascript:;">查看</a>
+                      </c:if>
+                  </td>
                   <td>
                     <c:if test="${empty order.orderID || order.status eq 0}">
                       <%--已确认订单(0未确认 1已确认) 供应商金额审核未全部通过 --%>
@@ -309,6 +324,19 @@
       </c:if>
     </c:forEach>
     <input type="hidden" id="product_index" value="<%=idx%>">
+    <br>
+    <br>
+    <!-- 优惠券 -->
+  <c:if test="${empty order.orderID || order.status eq 0}">
+    <div id="couponBox">
+        <div style="margin-top:20px;font-size:15px;border-bottom:2px solid #050202"><b>优惠券</b><a id="redeemCoupons" href="javascript:;" class="btn btn-primary" style="padding:1px 10px;margin:2px 30px;">兑换优惠券</a></div>
+        <!-- $('input[name=clubCouponId]:checked').val() -->
+        <ul class="couponContent">
+            <li><label><input type="radio" checked name="clubCouponId" value="0"><span class="couponDesc none">不使用优惠券</span></label></li>
+        </ul>
+        <from:hidden path="clubCouponId" />
+    </div>
+  </c:if>
     <br>
     <br>
     <table id="orderPrice" class="table table-striped table-bordered table-condensed">
@@ -337,6 +365,9 @@
             </span>元
             <from:hidden path="promotionFullReduction" />
         </td>
+        <td style="text-align:right;">优惠券抵扣:</td>
+        <td><span class="couponPrice"><fmt:formatNumber value="${empty order.couponAmount?'0.00':(order.couponAmount)}" pattern="#0.00"/></span>元
+            <from:hidden path="couponAmount"/></td>
         <td>商品总数</td>
         <td><span class="productCount">${empty order.productCount?'0':(order.productCount)}</span>
             <from:hidden path="productCount" />
@@ -357,7 +388,7 @@
           <input type="button" onclick="setProductTotalFee()" value="确认折扣">
         </td>
         <td>运费</td>
-        <td class="freeDesc" id="freeDesc">
+        <td class="freeDesc" id="freeDesc" colspan="3">
           <form:select id="freePostFlag" path="freePostFlag" class="required" onchange="setFreight()" disabled="${empty order.orderID || order.status eq 0? false:true}">
             <form:option value="0" label="包邮" />
             <form:option value="1" label="不包邮" />
@@ -380,7 +411,7 @@
           <from:hidden path="payTotalFee" />
         </td>
         <td>余额</td>
-        <td>
+        <td colspan="3">
           <input id="useBalancePayFee" type="checkbox" ${empty order.orderID || order.status eq 0? '': "disabled='disabled'"} ${empty order.orderID || (order.status eq 0 && order.balancePayFee eq 0)? '': 'checked'} onchange="setProductTotalFee()" />使用账户余额
           <br>(可用余额¥<span id="availableBalance">0.00</span>,当前使用¥<span class="balancePayFee">0.00</span>,剩余¥<span id="surplusBalance">0.00</span>)
           <from:hidden path="balancePayFee" value="${empty order.balancePayFee ?'0.00':(order.balancePayFee)}" cssClass="input-small number" />
@@ -392,10 +423,6 @@
             <fmt:formatNumber value="${empty order.payableAmount?'0.00':(order.payableAmount)}" pattern="#0.00" />
           </span>元</td>
           <from:hidden path="payableAmount" />
-        <td>
-        </td>
-        <td>
-        </td>
       </tr>
     </table>
     <br>
@@ -602,6 +629,7 @@
       <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)" />
     </div>
 </form:form>
+
 <script type="text/javascript">
         $(document).ready(function () {
             $("#name").focus();
@@ -758,7 +786,10 @@
 
     $(function () {
         setBalancePayFee();
-        // setFreight();
+      var orderId = $("#orderID").val()*1;
+      if (orderId && orderId > 0){
+        setFreight();
+      }
         $(".freight").val($("#freight").val());
         var tablehtml = $(".stagesTable1").html();
         var tablehtml2 = $(".stagesTable").html();

+ 2 - 2
src/main/webapp/WEB-INF/views/modules/product/cmSecondHandDetailForm.jsp

@@ -348,9 +348,9 @@
 		<label class="control-label"><font color="red">*</font>商品可见度:</label>
 		<div class="controls">
 			<form:select path="visibility" class="input-large required" id="visibility">
-				<form:option value="3" label="所有人可见"/>
-				<form:option value="2" label="所有机构可见"/>
 				<form:option value="1" label="仅会员机构可见"/>
+				<form:option value="2" label="所有机构可见"/>
+				<form:option value="3" label="所有人可见"/>
 			</form:select>
 		</div>
 	</div>

File diff suppressed because it is too large
+ 446 - 220
src/main/webapp/static/modules/bulkpurchase/orderForm.js


Some files were not shown because too many files changed in this diff