Browse Source

呵呵-轮播图跳转/内部优惠折扣价

Aslee 2 năm trước cách đây
mục cha
commit
3ccc0b42c0

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

@@ -15,6 +15,7 @@ public class CmHeheDiscountProduct implements Serializable {
     private Integer productId;      //商品id
     private Integer status;        //状态 0停用 1启用
     private Integer shopId;     //供应商id(对应店铺券)
+    private Double discountPrice;   //折扣价,若设置了折扣价则以折扣价购买,否则按优惠折扣率计算价格
     private Integer sort;       //排序值
     private Date addTime;       //添加时间
 
@@ -101,4 +102,12 @@ public class CmHeheDiscountProduct implements Serializable {
     public void setShopName(String shopName) {
         this.shopName = shopName;
     }
+
+    public Double getDiscountPrice() {
+        return discountPrice;
+    }
+
+    public void setDiscountPrice(Double discountPrice) {
+        this.discountPrice = discountPrice;
+    }
 }

+ 32 - 5
src/main/java/com/caimei/modules/hehe/entity/CmHeheImage.java

@@ -16,7 +16,10 @@ public class CmHeheImage extends DataEntity<CmHeheImage> {
 	private static final long serialVersionUID = 1L;
 	private String topic;		// 主题
 	private String image;		// 图片
-	private String link;		// 跳转链接
+	private Integer jumpType;		// 跳转类型:1链接,2商品,3图片
+	private String jumpLink;		// 跳转链接
+	private Integer jumpProductId;		// 跳转链接
+	private String jumpImage;		// 跳转链接
 	private String sort;		// 排序值
 	private String status;		// 小程序状态:1启用,2停用
 	private Date addTime;		// 添加时间
@@ -72,11 +75,35 @@ public class CmHeheImage extends DataEntity<CmHeheImage> {
 		this.addTime = addTime;
 	}
 
-	public String getLink() {
-		return link;
+	public String getJumpLink() {
+		return jumpLink;
 	}
 
-	public void setLink(String link) {
-		this.link = link;
+	public void setJumpLink(String jumpLink) {
+		this.jumpLink = jumpLink;
+	}
+
+	public Integer getJumpProductId() {
+		return jumpProductId;
+	}
+
+	public void setJumpProductId(Integer jumpProductId) {
+		this.jumpProductId = jumpProductId;
+	}
+
+	public String getJumpImage() {
+		return jumpImage;
+	}
+
+	public void setJumpImage(String jumpImage) {
+		this.jumpImage = jumpImage;
+	}
+
+	public Integer getJumpType() {
+		return jumpType;
+	}
+
+	public void setJumpType(Integer jumpType) {
+		this.jumpType = jumpType;
 	}
 }

+ 9 - 0
src/main/java/com/caimei/modules/hehe/web/CmHeheImageController.java

@@ -1,8 +1,11 @@
 package com.caimei.modules.hehe.web;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.caimei.modules.hehe.dao.CmHeheProductDao;
+import com.caimei.modules.hehe.entity.CmHeheProduct;
 import com.google.common.collect.Maps;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +24,7 @@ import com.thinkgem.jeesite.common.utils.StringUtils;
 import com.caimei.modules.hehe.entity.CmHeheImage;
 import com.caimei.modules.hehe.service.CmHeheImageService;
 
+import java.util.List;
 import java.util.Map;
 
 import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.isInteger;
@@ -38,6 +42,9 @@ public class CmHeheImageController extends BaseController {
     @Autowired
     private CmHeheImageService cmHeheImageService;
 
+    @Resource
+    private CmHeheProductDao cmHeheProductDao;
+
     @ModelAttribute
     public CmHeheImage get(@RequestParam(required = false) String id) {
         CmHeheImage entity = null;
@@ -60,6 +67,8 @@ public class CmHeheImageController extends BaseController {
     @RequestMapping(value = "form")
     public String form(CmHeheImage cmHeheImage, Model model) {
         model.addAttribute("cmHeheImage", cmHeheImage);
+        List<CmHeheProduct> productList = cmHeheProductDao.findList(new CmHeheProduct());
+        model.addAttribute("productList", productList);
         return "modules/hehe/cmHeheImageForm";
     }
 

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

@@ -112,12 +112,12 @@
 
 	<insert id="insertDiscountProduct">
 		INSERT INTO `cm_hehe_discount_product` (
-			`discountId`, `productId`, `status`,
+			`discountId`, `productId`, discountPrice, `status`,
 			`sort`, `addTime`
 		)
 		VALUES
 		(
-			#{discountId}, #{productId}, #{status},
+			#{discountId}, #{productId}, #{discountPrice}, #{status},
 			#{sort}, #{addTime}
 		)
 	</insert>
@@ -135,6 +135,7 @@
 			<if test="sort != null">
 				`sort` = #{sort},
 			</if>
+			discountPrice = #{discountPrice}
 		</set>
 		WHERE
 		`id` = #{id}
@@ -154,6 +155,7 @@
 			cca.id,
 			cca.discountId,
 			cca.productId,
+            cca.discountPrice,
 			cca.status,
 			cca.sort,
 			cca.addTime,

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

@@ -6,7 +6,10 @@
 		a.id AS "id",
 		a.topic AS "topic",
 		a.image AS "image",
-		a.link,
+		a.jumpType,
+		a.jumpLink,
+		a.jumpProductId,
+		a.jumpImage,
 		a.sort AS "sort",
 		a.status AS "status",
 		a.addTime AS "addTime"
@@ -71,14 +74,20 @@
 		INSERT INTO cm_hehe_image(
 			topic,
 			image,
-		    link,
+		    jumpType,
+		    jumpLink,
+		    jumpProductId,
+		    jumpImage,
 			sort,
 			status,
 			addTime
 		) VALUES (
 			#{topic},
 			#{image},
-			#{link},
+		    #{jumpType},
+			#{jumpLink},
+			#{jumpProductId},
+			#{jumpImage},
 			#{sort},
 			#{status},
 			NOW()
@@ -89,7 +98,10 @@
 		UPDATE cm_hehe_image SET 	
 			topic = #{topic},
 			image = #{image},
-			link = #{link},
+			jumpType = #{jumpType},
+			jumpLink = #{jumpLink},
+			jumpProductId = #{jumpProductId},
+			jumpImage = #{jumpImage},
 			sort = #{sort},
 			status = #{status},
 			addTime = #{addTime}

+ 12 - 4
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheDiscountForm.jsp

@@ -112,6 +112,7 @@
 						<th>商品名称</th>
 						<th>供应商</th>
 						<th>状态</th>
+						<th>折扣价</th>
 						<th>排序</th>
 						<th>添加时间</th>
 						<th>操作</th>
@@ -165,6 +166,7 @@
 			image: "${product.image}",
 			productName: "${product.productName}",
 			shopName: "${product.shopName}",
+			discountPrice: "${product.discountPrice}",
 			sort: "${product.sort}",
 			status: "${product.status}",
 			addTime: "<fmt:formatDate value="${product.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
@@ -228,7 +230,6 @@
 
 	//用户添加
 	function userShowSelect() {
-		debugger
 		var url = "${ctx}/hehe/cmHeheDiscount/toAddUser?userIds=" + userIds;
 		var title = '';
 		title = "选择用户";
@@ -308,6 +309,9 @@
 				'</td>' +
 				'</td>' +
 				'<td>' +
+				'<input type="number" name="discountPrice" style="width:80px;" value="' + data.discountPrice + '" onchange="changeDiscountPrice(' + index + ',this)"></td>' +
+				'</td>' +
+				'<td>' +
 				'<input name="sort" style="width:50px;" value="' + data.sort + '"  onkeyup="onlynum(this)"  onchange="changeSort(' + index + ',this)"></td>' +
 				'</td>' +
 				'<td>' +
@@ -375,13 +379,17 @@
 
 	function changeSort(index, sortThis) {
 		var sort = sortThis.value;
-		if (sort <= 0) {
-
-		}
 		var image = imageList[index];
 		image.sort = sort;
 	}
 
+	function changeDiscountPrice(index, sortThis) {
+		debugger
+		var discountPrice = sortThis.value;
+		var image = imageList[index];
+		image.discountPrice = discountPrice;
+	}
+
 	function updateStatus(status, index) {
 		var image = imageList[index];
 		confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {

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

@@ -66,6 +66,19 @@
 			//$("#name").focus();
 			$("#inputForm").validate({
 				submitHandler: function(form){
+					var image = $("#image").val();
+					if (image == '') {
+						alertx("请上传轮播图");
+						return false;
+					}
+					var jumpType = $("input[name='jumpType']:checked").val();
+					if (3 == jumpType) {
+						var jumpImage = $("#jumpImage").val();
+						if (jumpImage == '') {
+							alertx("请上传跳转图片");
+							return false;
+						}
+					}
 					loading('正在提交,请稍等...');
 					form.submit();
 				},
@@ -108,9 +121,27 @@
 			</div>
 		</div>
 		<div class="control-group">
-			<label class="control-label">链接:</label>
+			<label class="control-label">跳转方式:</label>
 			<div class="controls">
-				<form:input path="link" htmlEscape="false" class="input-xxlarge"/>
+				<input type="radio" name="jumpType" value="1" onchange="changeJumpType()" ${(cmHeheImage.jumpType eq null || cmHeheImage.jumpType eq 1 )? "checked" : ""} />链接:
+				<form:input path="jumpLink" htmlEscape="false" class="input-xxlarge"/>
+			</div>
+			<div class="controls" style="margin-top: 10px">
+				<input type="radio" name="jumpType" value="2" onchange="changeJumpType()" ${cmHeheImage.jumpType eq 2 ? "checked" : ""} />产品:
+				<form:select path="jumpProductId" class="select-ele input-xlarge">
+					<form:option value="" label="请选择"/>
+					<form:options items="${productList}" itemLabel="name" itemValue="productId"
+								  htmlEscape="false"/>
+				</form:select>
+			</div>
+			<div class="controls upload-content" id="jumpImageBox">
+				<input type="radio" name="jumpType" value="3" onchange="changeJumpType()" ${cmHeheImage.jumpType eq 3 ? "checked" : ""} />图片:
+				<div class="conList iconBox">
+					<form:hidden id="jumpImage" path="jumpImage" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
+					<sys:ckfinder input="jumpImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+					<br>
+					<label style="margin-left: 20px">建议图片分辨率750px*1624px</label>
+				</div>
 			</div>
 		</div>
 		<div class="control-group">
@@ -140,6 +171,7 @@
 		$('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
 		$('.upload-content .conList').find('.cancel-upload').hide();
 		var observeEle = document.getElementsByClassName('upload-content')[0];
+		var observeEle1 = document.getElementsByClassName('upload-content')[1];
 		var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
 		var MutationObserverConfig = {
 			childList: true,
@@ -162,6 +194,7 @@
 			})
 		});
 		observer.observe(observeEle, MutationObserverConfig);
+		observer.observe(observeEle1, MutationObserverConfig);
 
 		$('body').on('click', '.cancel-upload', function () {
 			var wrapper = $(this).closest('.conList');
@@ -186,8 +219,17 @@
 						$(ele).parents(".conList").next().removeClass("hide-pic")
 					}
 				})
+				$("#jumpImageBox").find("input.input-xlarge").each(function (i, ele) {
+					if ($(ele).val()) {
+						$(ele).next().find("li").css("z-index", "99");
+						$(ele).parents(".conList").find(".cancel-upload").show();
+						$(ele).parents(".conList").next().removeClass("hide-pic")
+					}
+				})
 			}, 200);
 		});
+
+		changeJumpType();
 	});
 
 	/**
@@ -197,6 +239,22 @@
 	function onlynum(obj) {
 		obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
 	}
+
+	function changeJumpType() {
+		var jumpType = $("input[name='jumpType']:checked").val();
+		var jumpLink = $("#jumpLink");
+		var jumpProductId = $("#jumpProductId");
+		if (1 == jumpType) {
+			jumpLink.addClass("required");
+			jumpProductId.removeClass("required");
+		}else if (2 == jumpType) {
+			jumpProductId.addClass("required");
+			jumpLink.removeClass("required");
+		} else {
+			jumpProductId.removeClass("required");
+			jumpLink.removeClass("required");
+		}
+	}
 </script>
 </body>
 </html>

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

@@ -47,7 +47,8 @@
                     "shopName": product.shopName,
                     "sort": 1,
                     "status": "1",
-                    "addTime": ""
+                    "addTime": "",
+                    "discountPrice": ""
                 })
             });
             return items;