Forráskód Böngészése

bugfix-呵呵拼团/分享减免

Aslee 3 éve
szülő
commit
9d48cfd9fe

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

@@ -20,4 +20,6 @@ public interface CmHeheCollageProductDao extends CrudDao<CmHeheCollageProduct> {
     List<Integer> findExistProductIds();
 
     List<Integer> findActivityProductIds();
+
+    Integer getProductId(Integer heheProductId);
 }

+ 3 - 3
src/main/java/com/caimei/modules/hehe/entity/CmHeheReductionUser.java

@@ -15,7 +15,7 @@ public class CmHeheReductionUser extends DataEntity<CmHeheReductionUser> {
 	private Integer reductionId;		// 分享减免id
 	private Integer userId;		// 用户id
 	private Integer shareType;		// 分享类型:1微信好友,2微信朋友圈
-	private Integer shareTime;		// 分享时间
+	private Date shareTime;		// 分享时间
 
 	private String nickName;		// 微信昵称
 	private String mobile;			// 手机号
@@ -44,11 +44,11 @@ public class CmHeheReductionUser extends DataEntity<CmHeheReductionUser> {
 		this.shareType = shareType;
 	}
 
-	public Integer getShareTime() {
+	public Date getShareTime() {
 		return shareTime;
 	}
 
-	public void setShareTime(Integer shareTime) {
+	public void setShareTime(Date shareTime) {
 		this.shareTime = shareTime;
 	}
 

+ 6 - 0
src/main/java/com/caimei/modules/hehe/service/CmHeheCollageProductService.java

@@ -50,6 +50,12 @@ public class CmHeheCollageProductService extends CrudService<CmHeheCollageProduc
 	
 	@Transactional(readOnly = false)
 	public void save(CmHeheCollageProduct cmHeheCollageProduct) {
+		if (!cmHeheCollageProduct.getIsNewRecord()) {
+			CmHeheCollageProduct dbProduct = get(cmHeheCollageProduct.getId());
+			if (!dbProduct.getProductId().equals(cmHeheCollageProduct.getProductId())) {
+				cmHeheCollageProduct.setProductId(cmHeheCollageProductDao.getProductId(cmHeheCollageProduct.getProductId()));
+			}
+		}
 		super.save(cmHeheCollageProduct);
 	}
 	

+ 7 - 1
src/main/java/com/caimei/modules/hehe/web/CmHeheReductionController.java

@@ -111,8 +111,14 @@ public class CmHeheReductionController extends BaseController {
 
 	@RequestMapping(value = "checkTime")
 	@ResponseBody
-	public Map<String, Object> checkTime(String reductionId, Date startTime, Date endTime) {
+	public Map<String, Object> checkTime(String reductionId, Date startTime, Date endTime, Integer type) {
 		HashMap<String, Object> map = new HashMap<>(2);
+		if (null != type && 1 == type) {
+			// 待上架直接上架
+			CmHeheReduction cmHeheReduction = cmHeheReductionService.get(reductionId);
+			startTime = new Date();
+			endTime = cmHeheReduction.getEndTime();
+		}
 		Boolean result = cmHeheReductionService.checkTime(reductionId, startTime, endTime);
 		if (result) {
 			map.put("success", true);

+ 5 - 5
src/main/resources/mappings/modules/hehe/CmHeheActivityProductMapper.xml

@@ -125,17 +125,17 @@
 		<if test="ids != null and ids.size() > 0 ">
 			AND a.productId NOT IN
 			<foreach collection="ids" open="(" close=")" item="id" separator=",">
-				#{id}
+				#{id,jdbcType=INTEGER}
 			</foreach>
 		</if>
 		<if test="productId != null">
-			AND a.productId = #{productId}
+			AND a.productId = #{productId,jdbcType=INTEGER}
 		</if>
 		<if test="name != null and name != ''">
-			AND p.name LIKE CONCAT('%',#{name},'%')
+			AND p.name LIKE CONCAT('%',#{name,jdbcType=VARCHAR},'%')
 		</if>
 		<if test="shopName != null and shopName != ''">
-			AND s.name LIKE CONCAT('%',#{shopName},'%')
+			AND s.name LIKE CONCAT('%',#{shopName,jdbcType=VARCHAR},'%')
 		</if>
 	</select>
 
@@ -180,7 +180,7 @@
 		SELECT activityId FROM cm_hehe_activity_product WHERE productId = #{productId} AND delFlag = 0
 	</select>
     <select id="findCollageProductId" resultType="java.lang.Integer">
-		select chp.productId from cm_hehe_collage_product chcp left join cm_hehe_product chp on chcp.productId = chp.id
+		select chcp.productId from cm_hehe_collage_product chcp
 	</select>
 
     <delete id="deleteUserActivity">

+ 6 - 3
src/main/resources/mappings/modules/hehe/CmHeheCollageProductMapper.xml

@@ -83,13 +83,16 @@
 		select chp.id
 		from cm_hehe_activity_product chap
 				 left join cm_hehe_product chp on chap.productId = chp.productId
-		where chp.id is not null;
+		where chp.id is not null and delFlag = 0;
 	</select>
 	<select id="findReductionProductIds" resultType="java.lang.Integer">
 		select chp.id
 		from cm_hehe_reduction chap
 				 left join cm_hehe_product chp on chap.productId = chp.productId;
 	</select>
+	<select id="getProductId" resultType="java.lang.Integer">
+		select productId from cm_hehe_product where id = #{heheProductId}
+	</select>
 
 	<insert id="insert" parameterType="CmHeheCollageProduct"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO cm_hehe_collage_product(
@@ -101,7 +104,7 @@
 			status,
 			addTime
 		) VALUES (
-			(select productId from cm_hehe_product where id = #{productId}),
+             (select productId from cm_hehe_product where id = #{productId}),
 			#{price},
 			#{limitedNum},
 			#{unlimitedFlag},
@@ -113,7 +116,7 @@
 	
 	<update id="update">
 		UPDATE cm_hehe_collage_product SET 	
-			productId = (select productId from cm_hehe_product where id = #{productId}),
+			productId = #{productId},
 			price = #{price},
 			limitedNum = #{limitedNum},
 			unlimitedFlag = #{unlimitedFlag},

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

@@ -87,11 +87,11 @@
 					<fmt:formatDate value="${cmHeheCollage.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
 				</td>
 				<td>
-					${cmHeheCollage.status eq 2?cmHeheCollage.memberNum:cmHeheCollage.orderIdList.size}
+					${cmHeheCollage.status eq 2?cmHeheCollage.memberNum:cmHeheCollage.orderIdList.size()}
 				</td>
 				<td>
 					<c:forEach items="${cmHeheCollage.orderIdList}" var="orderId" varStatus="index">
-						<a href="${ctx}/hehe/new/order/detail?id=${orderId}">${orderId}${index lt (cmHeheCollage.orderIdList.size-1)?',':''}</a>
+						<a href="${ctx}/hehe/new/order/detail?id=${orderId}">${orderId}${index.index lt (cmHeheCollage.orderIdList.size()-1)?',':''}</a>
 					</c:forEach>
 				</td>
 				<td>
@@ -112,7 +112,7 @@
 					</c:if>
 				</td>
 				<td>
-					<a href="${ctx}/hehe/cmHeheCollage/memberList?id=${cmHeheCollage.id}">拼团成员</a>
+					<a href="${ctx}/hehe/cmHeheCollage/memberList?collageId=${cmHeheCollage.id}">拼团成员</a>
 				</td>
 			</tr>
 		</c:forEach>

+ 3 - 17
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCollageMemberList.jsp

@@ -22,8 +22,8 @@
 </head>
 <body>
 	<ul class="nav nav-tabs">
-		<li class="active"><a href="${ctx}/hehe/cmHeheCollage/">拼团记录</a></li>
-		<li class="active"><a href="${ctx}/hehe/cmHeheCollage/memberList?collageId=${cmHeheCollageMember.collageId}">拼团记录</a></li>
+		<li><a href="${ctx}/hehe/cmHeheCollage/">拼团记录</a></li>
+		<li class="active"><a href="${ctx}/hehe/cmHeheCollage/memberList?collageId=${cmHeheCollageMember.collageId}">拼团成员</a></li>
 	</ul>
 	<form:form id="searchForm" modelAttribute="cmHeheCollageMember" action="${ctx}/hehe/cmHeheCollage/memberList" method="post" class="breadcrumb form-search">
 		<form:hidden path="collageId"/>
@@ -64,25 +64,11 @@
 					${cmHeheCollageMember.userIdentity eq 1 ? "普通用户" : "分销者"}
 				</td>
 				<td>
-					${cmHeheCollageMember.orderTime}
+					<fmt:formatDate value="${cmHeheCollageMember.orderTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
 				</td>
 				<td>
 					<a href="${ctx}/hehe/new/order/detail?id=${cmHeheCollageMember.orderId}">${cmHeheCollageMember.orderNo}(${cmHeheCollageMember.orderId})</a>
 				</td>
-				<td>
-					<fmt:formatDate value="${cmHeheCollageMember.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
-				</td>
-				<td>
-					<fmt:formatDate value="${cmHeheCollageMember.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
-				</td>
-				<td>
-					${cmHeheCollageMember.status eq 2?cmHeheCollageMember.memberNum:cmHeheCollageMember.orderIdList.size}
-				</td>
-				<td>
-					<c:forEach items="${cmHeheCollageMember.orderIdList}" var="orderId" varStatus="index">
-						<a href="${ctx}/hehe/new/order/detail?id=${orderId}">${orderId}${index lt (cmHeheCollageMember.orderIdList.size-1)?',':''}</a>
-					</c:forEach>
-				</td>
 			</tr>
 		</c:forEach>
 		</tbody>

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

@@ -92,7 +92,7 @@
 		</div>
 
 		<div class="control-group">
-			<label class="control-label">商品状态:</label>
+			<label class="control-label"><font color="red">*</font>商品状态:</label>
 			<div class="controls">
 				<form:select path="status" class="input-xlarge ">
 					<form:option value="1" label="已上架"/>

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

@@ -30,7 +30,7 @@
 		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
 		<div class="ul-form">
 			 <label>商品ID:</label>
-				<form:input path="id" htmlEscape="false" class="input-medium"/>
+				<form:input path="id" htmlEscape="false" class="input-medium" onkeyup="onlynum(this)"/>
 			 <label>商品名称:</label>
 				<form:input path="productName" htmlEscape="false" class="input-medium"/>
 			 <label>供应商名称:</label>
@@ -98,7 +98,7 @@
 				</td>
 				<td>
     				<a href="${ctx}/hehe/cmHeheCollageProduct/form?id=${cmHeheCollageProduct.id}">编辑</a>
-					<a href="javascript:;" onclick="updateProductStatus(${cmHeheCollageProduct.id},${cmHeheCollageProduct.status})">${cmHeheCollageProduct.status eq 1?'下架':'架'}</a>
+					<a href="javascript:;" onclick="updateProductStatus(${cmHeheCollageProduct.id},${cmHeheCollageProduct.status})">${cmHeheCollageProduct.status eq 1?'下架':'架'}</a>
 					<a href="${ctx}/hehe/cmHeheCollageProduct/delete?id=${cmHeheCollageProduct.id}" onclick="return confirmx('确认要删除该商品吗?', this.href)">删除</a>
 				</td>
 			</tr>
@@ -131,6 +131,14 @@
 			$.jBox.confirm("确定下架该商品吗?", "提示", submit, { buttons: { '确认': true, '取消': false} });
 		}
 	}
+
+	/**
+	 * @param obj
+	 * jquery控制input只能输入数字
+	 */
+	function onlynum(obj) {
+		obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+	}
 </script>
 </body>
 </html>

+ 7 - 7
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheReductionForm.jsp

@@ -9,8 +9,8 @@
 			//$("#name").focus();
 			$("#inputForm").validate({
 				submitHandler: function(form){
-					var reducedAmount = $("#reducedAmount").val();
-					var touchPrice = $("#touchPrice").val();
+					var reducedAmount = $("#reducedAmount").val() * 1;
+					var touchPrice = $("#touchPrice").val() * 1;
 					if (reducedAmount >= touchPrice) {
 						alertx("减免金额必须小于减免条件金额");
 						return false;
@@ -64,26 +64,26 @@
 			</div>
 		</div>
 		<div class="control-group">
-			<label class="control-label">减免金额:</label>
+			<label class="control-label"><font color="red">*</font>减免金额:</label>
 			<div class="controls">
 				<form:input path="reducedAmount" htmlEscape="false" class="input-xlarge number required"/> 元
 			</div>
 		</div>
 		<div class="control-group">
-			<label class="control-label">减免条件:</label>
+			<label class="control-label"><font color="red">*</font>减免条件:</label>
 			<div class="controls">
 				订单商品总额满
 				<form:input path="touchPrice" htmlEscape="false" class="input-xlarge number required"/> 元
 			</div>
 		</div>
 		<div class="control-group">
-			<label class="control-label">分享次数:</label>
+			<label class="control-label"><font color="red">*</font>分享次数:</label>
 			<div class="controls">
 				<form:input path="shareNum" htmlEscape="false" min="1" class="input-xlarge digits required"/>
 			</div>
 		</div>
 		<div class="control-group">
-			<label class="control-label">上架时间:</label>
+			<label class="control-label"><font color="red">*</font>上架时间:</label>
 			<div class="controls">
 				<input id="startTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
 					value="<fmt:formatDate value="${cmHeheReduction.startTime}" pattern="yyyy-MM-dd HH:mm"/>"
@@ -91,7 +91,7 @@
 			</div>
 		</div>
 		<div class="control-group">
-			<label class="control-label">下架时间:</label>
+			<label class="control-label"><font color="red">*</font>下架时间:</label>
 			<div class="controls">
 				<input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
 					value="<fmt:formatDate value="${cmHeheReduction.endTime}" pattern="yyyy-MM-dd HH:mm"/>"

+ 37 - 18
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheReductionList.jsp

@@ -70,7 +70,7 @@
 					${cmHeheReduction.reducedAmount}
 				</td>
 				<td>
-					${cmHeheReduction.touchPrice}
+					${cmHeheReduction.touchPrice}
 				</td>
 				<td>
 					<fmt:formatDate value="${cmHeheReduction.startTime}" pattern="yyyy-MM-dd HH:mm"/>
@@ -104,24 +104,42 @@
 		if (status !== 3) {
 			if (status === 2) {
 				status = 3;
+				// 已上架活动下架
+				var submit = function (v, h, f) {
+					if (v == true) {
+						$.post("${ctx}/hehe/cmHeheReduction/updateStatus?id="+reductionId+"&status="+status,function (data) {
+							top.$.jBox.tip('下架活动成功');
+							setTimeout(function () {
+								$("#searchForm").submit();
+							}, 1000);
+						});
+					}
+				};
+				$.jBox.confirm("确定下架该活动吗?", "提示", submit, {buttons: {'确认': true, '取消': false}});
 			} else {
+				debugger
 				status = 2;
-			}
-			// 待上架活动上架及已上架活动下架
-			var submit = function (v, h, f) {
-				if (v == true) {
-					$.post("${ctx}/hehe/cmHeheReduction/updateStatus?id="+reductionId+"&status="+status,function (data) {
-						top.$.jBox.tip((2 === status?'上架':'下架')+'活动成功');
-						setTimeout(function () {
-							$("#searchForm").submit();
-						}, 1000);
-					});
-				}
-			};
-			if (2 == status) {
+				// 待上架活动上架
+				var submit = function (v, h, f) {
+					if (v == true) {
+						var startTime = new Date();
+						// 检查时间是否与其他活动时间重叠
+						$.post('${ctx}/hehe/cmHeheReduction/checkTime?reductionId=' + reductionId + "&type=1", function (data) {
+							if (!data.success) {
+								top.$.jBox.tip(data.msg);
+								return false;
+							} else {
+								$.post("${ctx}/hehe/cmHeheReduction/updateStatus?id=" + reductionId + "&status=" + status, function (data) {
+									top.$.jBox.tip('上架活动成功');
+									setTimeout(function () {
+										$("#searchForm").submit();
+									}, 1000);
+								});
+							}
+						});
+					}
+				};
 				$.jBox.confirm("确定上架该活动吗?", "提示", submit, {buttons: {'确认': true, '取消': false}});
-			} else {
-				$.jBox.confirm("确定下架该活动吗?", "提示", submit, {buttons: {'确认': true, '取消': false}});
 			}
 		} else {
 			//已下架活动上架需重新设置上下架时间
@@ -139,6 +157,7 @@
 					var $jboxFrame = top.$('#jbox-iframe');
 					var $mainFrame = top.$('#mainFrame');
 					if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+						debugger
 						var items = $jboxFrame[0].contentWindow.getCheckedItems(0);
 						if (items.length > 0) {
 							var startTime = items[0].startTime;
@@ -152,12 +171,12 @@
 								return false;
 							}
 							// 检查时间是否与其他活动时间重叠
-							$.post('${ctx}/hehe/cmHeheReduction/checkTime?startTime=' + startTime + '&endTime=' + endTime + '&reductionId=' + reductionId,function (data) {
+							$.post('${ctx}/hehe/cmHeheReduction/checkTime?startTime=' + startTime + '&endTime=' + endTime + '&reductionId=' + reductionId + "&type=" + 2, function (data) {
 								if (!data.success) {
 									top.$.jBox.tip(data.msg);
 									return false;
 								} else {
-									$.post("${ctx}/hehe/cmHeheReduction/updateTime?id="+reductionId+"&startTime=" + startTime + "&endTime=" + endTime, function (data) {
+									$.post("${ctx}/hehe/cmHeheReduction/updateTime?id=" + reductionId + "&startTime=" + startTime + "&endTime=" + endTime, function (data) {
 										top.$.jBox.tip("修改成功");
 										setTimeout(function () {
 											$("#searchForm").submit();

+ 6 - 6
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheReductionUserList.jsp

@@ -22,11 +22,11 @@
 </head>
 <body>
 	<ul class="nav nav-tabs">
-		<li class="active"><a href="${ctx}/hehe/cmHeheCollage/">拼团记录</a></li>
-		<li class="active"><a href="${ctx}/hehe/cmHeheCollage/memberList?collageId=${cmHeheReductionUser.collageId}">拼团记录</a></li>
+		<li><a href="${ctx}/hehe/cmHeheReduction">分享减免活动列表</a></li>
+		<li class="active"><a href="${ctx}/hehe/cmHeheReduction/userList?reductionId=${cmHeheReductionUser.reductionId}">领取用户列表</a></li>
 	</ul>
 	<form:form id="searchForm" modelAttribute="cmHeheReductionUser" action="${ctx}/hehe/cmHeheCollage/memberList" method="post" class="breadcrumb form-search">
-		<form:hidden path="collageId"/>
+		<form:hidden path="reductionId"/>
 		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
 		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
 		<div class="ul-form">
@@ -35,7 +35,7 @@
 			 <label>手机号:</label>
 				<form:input path="mobile" htmlEscape="false" class="input-medium"/>
 			 <label>分享渠道:</label>
-				<form:select path="sharePath" class="input-medium">
+				<form:select path="shareType" class="input-medium">
 					<form:option value="" label="全部"/>
 					<form:option value="1" label="微信好友"/>
 					<form:option value="2" label="微信朋友圈"/>
@@ -62,13 +62,13 @@
 					${cmHeheReductionUser.id}
 				</td>
 				<td>
-					${cmHeheReductionUser.nickName}</font>
+					${cmHeheReductionUser.nickName}
 				</td>
 				<td>
 					${cmHeheReductionUser.mobile}
 				</td>
 				<td>
-					${cmHeheReductionUser.sharePath eq 1 ? "微信好友" : "微信朋友圈"}
+					${cmHeheReductionUser.shareType eq 1 ? "微信好友" : "微信朋友圈"}
 				</td>
 				<td>
 					<fmt:formatDate value="${cmHeheReductionUser.shareTime}" pattern="yyyy-MM-dd HH:mm:ss"/>

+ 14 - 12
src/main/webapp/WEB-INF/views/modules/hehe/heheNewOrderDetail.jsp

@@ -100,18 +100,6 @@
                 </c:if>
             </c:if>
         </td>
-        <td>拼团状态:
-            <c:choose>
-                <c:when test="${order.collageFlag eq 1 && (order.status eq 31 || order.status eq 32 || order.status eq 33)}">
-                    <font color="${order.collageStatus eq 1?'#00CC66':(order.collageStatus eq 2?'red':'')}">
-                            ${order.collageStatus eq 1?'拼团中':(order.collageStatus eq 2?'已拼成':'-')}
-                    </font>
-                </c:when>
-                <c:otherwise>
-                    -
-                </c:otherwise>
-            </c:choose>
-        </td>
     </tr>
     <tr>
         <c:if test="${order.status ne 0}">
@@ -361,6 +349,20 @@
             </div>
         </td>
     </tr>
+    <tr>
+        <td>拼团状态:
+            <c:choose>
+                <c:when test="${order.collageFlag eq 1 && (order.status eq 31 || order.status eq 32 || order.status eq 33)}">
+                    <font color="${order.collageStatus eq 1?'#00CC66':(order.collageStatus eq 2?'red':'')}">
+                            ${order.collageStatus eq 1?'拼团中':(order.collageStatus eq 2?'已拼成':'-')}
+                    </font>
+                </c:when>
+                <c:otherwise>
+                    -
+                </c:otherwise>
+            </c:choose>
+        </td>
+    </tr>
     <c:if test="${order.promotionFullReduction gt 0 || order.promotionalGiftsCount gt 0}">
         <tr>
             <c:if test="${order.promotionFullReduction gt 0}">

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

@@ -86,7 +86,7 @@
     </script>
 </head>
 <body>
-<form:form id="searchForm" modelAttribute="product" action="${ctx}/hehe/cmHeheCoupon/toAddProduct?productIds=${productIds}" method="post" class="breadcrumb form-search">
+<form:form id="searchForm" modelAttribute="product" action="${ctx}/hehe/cmHeheCollageProduct/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">