Bläddra i källkod

修改了电动牙刷商城的优惠券功能

liuzhiwei 7 år sedan
förälder
incheckning
20d17062ff

+ 2 - 1
tooth-common-tool/src/main/java/com/iamberry/wechat/tools/loadResultUtil.java

@@ -71,7 +71,8 @@ public class loadResultUtil {
 			ResultInfo.probation_apply_success = prop.getProperty("probation_apply_success");//试用申请成功通知
 			ResultInfo.probation_pay_success = prop.getProperty("probation_pay_success");	//订单支付成功
 			ResultInfo.probation_shut_down = prop.getProperty("probation_shut_down");		//订单关闭通知	 	模版id	TM00984
-			ResultInfo.prize_receive_push = prop.getProperty("prize_receive_push");			//付费代理商支付后推送推荐人通知  	模版id	
+			ResultInfo.prize_receive_push = prop.getProperty("prize_receive_push");			//付费代理商支付后推送推荐人通知  	模版id
+			ResultInfo.update_tooth_hint = prop.getProperty("update_tooth_hint");	//订单支付成功
 			
 		} catch (IOException e) {
 			new RuntimeException(e.getMessage());

+ 7 - 0
tooth-wechat-interface/src/main/java/com/iamberry/wechat/face/order/AdminOrderService.java

@@ -96,6 +96,13 @@ public interface AdminOrderService {
 	Integer addAgentOrderHint(Order order);
 
 	/**
+	 * 批量修改更换刷头提示信息
+	 * @param order
+	 * @return
+	 */
+	Integer updateAgentOrderHint(Order order);
+
+	/**
 	 * 查询状态为待发货的所有订单号
 	 * @return
 	 */

+ 11 - 3
tooth-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/couponTypeMapper.xml

@@ -24,7 +24,9 @@
 		COUPON_UPDATE_DATE couponUpdateDate,
 		COUPON_IS_GIVE couponIsGive,
 		COUPON_PRIORITY_LEVELS couponPriorityLevels,
-		COUPON_REMARK couponRemark
+		COUPON_REMARK couponRemark,
+		COUPON_IS_SOURCE couponIsSource,
+		COUPON_SOURCE_NAME couponSourceName
 	</sql>
  
  	<!-- 查询优惠券类型列表 分页 -->
@@ -78,14 +80,16 @@
 	
 			COUPON_IS_GIVE ,
 			COUPON_PRIORITY_LEVELS ,
-			COUPON_REMARK 
+			COUPON_REMARK ,
+			COUPON_IS_SOURCE,
+			COUPON_SOURCE_NAME
 		)
 		VALUES 
 		(
 			#{couponName},#{couponTotal},#{couponUsedNum},#{couponRemainingNum},#{couponGetLimit},
 			#{couponType},#{couponIsConcern},#{couponIsPurchase},#{couponConsumeEnough},#{couponReduce},
 			#{couponGetDays},#{couponLimitHours},#{couponEndDate},#{couponCreateDate},#{couponUpdateDate},
-			#{couponIsGive},#{couponPriorityLevels},#{couponRemark}
+			#{couponIsGive},#{couponPriorityLevels},#{couponRemark},#{couponIsSource},#{couponSourceName}
 		)
  	</insert>
  	
@@ -168,6 +172,10 @@
  			<if test="couponRemark !=null and couponRemark !=''">
 	 			COUPON_REMARK =#{couponRemark},
  			</if>
+			<if test="couponIsSource != null">
+				COUPON_IS_SOURCE = #{couponIsSource},
+				COUPON_SOURCE_NAME = #{couponSourceName},
+			</if>
  			COUPON_UPDATE_DATE=NOW()
  		</set>
  		WHERE COUPON_ID=#{couponId}

+ 31 - 1
tooth-wechat-service/src/main/java/com/iamberry/wechat/service/order/AdminOrderServiceImpl.java

@@ -128,7 +128,15 @@ public class AdminOrderServiceImpl implements AdminOrderService {
 	
 	public boolean updateOrderStatusByOrderId(Order order) {
 		// TODO Auto-generated method stub
-		return this.adminOrderDao.updateOrderStatusByOrderId(order)>= 1 ? true : false;
+		//修改订单状态
+		int num = this.adminOrderDao.updateOrderStatusByOrderId(order);
+		//修改更换刷头提示信息
+		int count = adminOrderService.updateAgentOrderHint(order);
+		if (num > 0 && count > 0) {
+			return true;
+		} else {
+			return false;
+		}
 	}
 
 	
@@ -186,6 +194,28 @@ public class AdminOrderServiceImpl implements AdminOrderService {
 		return count;
 	}
 
+	@Override
+	public Integer updateAgentOrderHint(Order order) {
+		List<OrderHint> orderList = new ArrayList<OrderHint>();
+		OrderHint orderHint = new OrderHint();
+		orderHint.setOrderId(order.getSalesOrderid());
+		orderHint.setUserOpenId(order.getSalesOpenid());
+		orderHint.setHintStatus(1);
+		//查询更换刷头列表
+		List<OrderHint> hintList = agentPurchaseOrderMapper.listOrderHint(orderHint);
+		if (hintList == null || hintList.size() == 0) {
+			return 1;
+		}
+		for (OrderHint hint : hintList) {
+			hint.setHintStatus(2);
+			hint.setHintNum(null);
+			orderList.add(hint);
+		}
+		//批量修改刷头更换信息状态
+		Integer count = agentPurchaseOrderMapper.updateOrderHintList(orderList);
+		return count;
+	}
+
 	public boolean updateOrderAdminRemarkByOrderId(String remark,
 												   String orderId, Integer remarkColor) {
 		// TODO Auto-generated method stub

+ 9 - 4
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/coupon/CouponTypeHandler.java

@@ -128,13 +128,19 @@ public class CouponTypeHandler {
 				it.remove();
 				continue;
 			}
-			// 当前用户已领取
+			// 当前用户已领取且时间为一个月以内
 			for (CouponItemDto cItem : itemList) {
 				if (cType.getCouponId() != null
 						&& cItem.getCouponId() != null
 						&& cType.getCouponId().intValue() == cItem
 								.getCouponId().intValue()) {
-					it.remove();
+					Date date = new Date();
+					long beginTime = cItem.getCouponReceiveDate().getTime();
+					long endTime2 = date.getTime();
+					long betweenDays = (long)((endTime2 - beginTime) / (1000 * 60 * 60 *24));
+					if (betweenDays < 30) {
+						it.remove();
+					}
 					break;
 				}
 			}
@@ -386,8 +392,7 @@ public class CouponTypeHandler {
 	/**
 	 * 分页查询优惠券类型列表<当前用户可领取的> 2016年7月6日
 	 * 
-	 * @param pageSize
-	 * @param pageNO
+	 * @param req
 	 * @return
 	 */
 	@RequestMapping("/get_coupon_type")

+ 1 - 1
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/mq/MQTask.java

@@ -402,7 +402,7 @@ public class MQTask implements InitializingBean {
 			hint.setHintNum(1);
 			list.add(hint);
 			//更换牙刷刷头提示
-			sendMessageUtil.probationApplyNotice("上朵电动牙刷商城", "上朵电动牙刷","您的牙刷已使用三个月,请及时更换刷头!", "上朵电动牙刷商城", order.getUserOpenId(),null);
+			sendMessageUtil.updateToothHint("上朵电动牙刷商城", "上朵电动牙刷","您的牙刷已使用三个月,请及时更换刷头!", "上朵电动牙刷商城", order.getUserOpenId(),NameUtils.getConfig("WECHAT_UPDATE_TOOTH_HINT")+order.getHintId());
 		}
 		//批量修改更换刷头信息
 		int num = agentPurchaseOrderService.updateOrderHintList(list);

+ 2 - 0
tooth-wechat-web/src/main/resources/platform.properties

@@ -94,6 +94,8 @@ WECHAT_AGENT_TOOT_ACTIVATE=/view/agent_tooth/activate_agent_id.html
 
 WECHAT_AGENT_TOOT_CENTER=/view/agent_tooth/agent_center.html
 
+WECHAT_UPDATE_TOOTH_HINT=http://test.iamberry.com/tooth/view/agent_tooth/replace_point.html?hintId=
+
 # wechat_withdraw_cash_log_list
 WECHAT_WITHDRAW_CASH_LOG_LIST=/WEB-INF/views/wechat/tixian_log_cash.html
 # WECHAT_SHOP_FENXIAO_INDEX !!!

+ 32 - 5
tooth-wechat-web/src/main/webapp/WEB-INF/views/admin/coupon/addCouponType.jsp

@@ -86,14 +86,13 @@
 			<input id="couponLimitHours" type="text" name="couponLimitHours" placeholder="" value="" class="input-text" style="width:90%">
 		</div>
 	</div>
-
-	<%--<div class="row cl">
+	<div class="row cl">
 		<label class="form-label col-2"><span class="c-red">*</span>优惠券截止时间:</label>
 		<div class="formControls col-2">
 			<input type="text" class="input-text" placeholder="" onfocus="WdatePicker({maxDate:'2050-10-01', dateFmt:'yyyy-MM-dd HH:mm:ss'})"
 				   readonly name="couponEndTime" id=couponEndTime datatype="*" nullmsg="请输入截止时间!"  style="width:90%">
 		</div>
-	</div>--%>
+	</div>
 
 
 	<div class="row cl">
@@ -126,6 +125,17 @@
 		<div  class="formControls col-2">
 			<input id="couponConsumeEnough" name="couponConsumeEnough" type="text" class="input-text" style="width:90%" value="" placeholder="消费总金额要求(满足条件才能领券)">
 		</div>
+		<label  class="form-label col-2"><span class="c-red">*</span>是否限制来源:</label>
+		<div  class="formControls col-2">
+			是:<input name="couponIsSource" type="radio" value="1" onclick="checkSource();">
+			否:<input name="couponIsSource" type="radio" value="2" checked onclick="checkSource();">
+		</div>
+	</div>
+	<div class="row cl">
+		<label  class="form-label col-2"><span class="c-red">*</span>限制来源:</label>
+		<div  class="formControls col-2">
+			<input id="couponSourceName" name="couponSourceName" type="text" class="input-text" style="width:90%" value="" placeholder="限制来源" disabled="disabled">
+		</div>
 	</div>
 
 	<div class="row cl">
@@ -172,6 +182,16 @@ $(function(){
 
 });
 
+function checkSource() {
+    var val=$('input:radio[name="couponIsSource"]:checked').val();
+    if (val == 1) {
+        $('#couponSourceName').attr('disabled',false);
+	} else {
+        $('#couponSourceName').val("");
+        $('#couponSourceName').attr('disabled',true);
+	}
+}
+
 function checkForm(){
 	//名称验证
 	if(!commonTypeJdg('couponName',null,null,true)){
@@ -212,10 +232,10 @@ function checkForm(){
 		return false;
 	}
 	//截止时间验证
-	/*if(!commonTypeJdg('couponEndTime',null,null,true)){
+	if(!commonTypeJdg('couponEndTime',null,null,true)){
 		layer.msg("截止时间不能为空",{icon: 2,time:2000});
 		return false;
-	}*/
+	}
 	//有效天数验证
 	if(!commonTypeJdg('couponGetDays','pInteger',null,true)){
 		layer.msg("有效天数不能为空!且只能是数字",{icon: 2,time:2000});
@@ -226,6 +246,13 @@ function checkForm(){
 		layer.msg("领券后有效时长不能为空!且只能是数字",{icon: 2,time:2000});
 		return false;
 	}
+    var val=$('input:radio[name="couponIsSource"]:checked').val();
+	if (val == 1) {
+        if(!commonTypeJdg('couponSourceName',null,null,true)){
+            layer.msg("优惠券限制来源不能为空",{icon: 2,time:2000});
+            return false;
+        }
+	}
 	
 	//减免额不能为空乘100 取整
 	var couponReduce = $("#couponReduce").val();

+ 11 - 0
tooth-wechat-web/src/main/webapp/WEB-INF/views/admin/coupon/couponTypeDetail.jsp

@@ -97,6 +97,17 @@
 				<label  class="form-label col-2">消费总金额:</label>
 				<div  class="formControls col-2"> ${cType.couponConsumeEnough }</div>
 		</div>
+		<label  class="form-label col-2"><span class="c-red">*</span>是否限制来源:</label>
+		<div  class="formControls col-2">
+			<c:if test="${cType.couponIsSource == 1 }">是</c:if>
+			<c:if test="${cType.couponIsSource == 2 }">否</c:if>
+		</div>
+		<div class="row cl">
+			<label  class="form-label col-2"><span class="c-red">*</span>限制来源:</label>
+			<div  class="formControls col-2">
+				${cType.couponSourceName}
+			</div>
+		</div>
 
 		<div class="row cl">
 			<label class="form-label col-2">是否允许赠送别人:</label>

+ 15 - 4
tooth-wechat-web/src/main/webapp/WEB-INF/views/admin/coupon/couponTypeList.jsp

@@ -65,7 +65,7 @@
 	<table class="table table-border table-bordered table-hover table-bg">
 		<thead>
 			<tr class="text-c">
-				<th width="50">id</th>
+				<th width="40">id</th>
 				<th width="150">优惠券名称</th>
 				<th width="50">券总数</th>
 				<!-- <th width="50">已领券数</th> -->
@@ -81,14 +81,16 @@
 				<!-- <th width="100">有效天数</th> -->
 				<!-- <th width="100">有效时间</th> -->
 				<th width="100">券截止时间</th>
+				<th width="50">是否限制来源</th>
+				<th width="100">限制来源</th>
 				<!-- <th width="100">创建时间</th> -->
 				
 				<!-- <th width="100">更新时间</th> -->
 				<!-- <th width="80">可否赠送他人</th>
 				<th width="40">券优先级别</th> -->
-				<th width="200">备注</th>
-				<th width="200">领取地址URL</th>
-				<th width="200">操作</th>
+				<th width="100">备注</th>
+				<th width="140">领取地址URL</th>
+				<th width="150">操作</th>
 			</tr>
 		</thead>
 		
@@ -121,6 +123,15 @@
 					<%-- <td>${cType.couponGetDays }</td> --%>
 					<%-- <td>${cType.couponLimitHours }</td> --%>
 					<td><fmt:formatDate value="${cType.couponEndDate }" pattern="YYYY-MM-dd HH:MM:ss"/></td>
+					<td id="couponIsSource">
+						<c:if test="${cType.couponIsSource == 1 }">
+							是
+						</c:if>
+						<c:if test="${cType.couponIsSource == 2 }">
+							否
+						</c:if>
+					</td>
+					<td id="couponSourceName">${cType.couponSourceName}</td>
 					<%-- <td><fmt:formatDate value="${cType.couponCreateDate }" pattern="YYYY-MM-dd HH:MM:ss"/></td> --%>
 
 					<%-- <td><fmt:formatDate value="${cType.couponUpdateDate }" pattern="YYYY-MM-dd HH:MM:ss"/></td> --%>

+ 37 - 8
tooth-wechat-web/src/main/webapp/WEB-INF/views/admin/coupon/updateCouponType.jsp

@@ -86,7 +86,7 @@
 			<div class="formControls col-2">
 				<input id="couponLimitHours" type="text" name="couponLimitHours" id="couponLimitHours" placeholder="" value="${cType.couponLimitHours }" class="input-text" style="width:90%"></div>
 		</div>
-		<%--<div class="row cl">
+		<div class="row cl">
 
 			<label class="form-label col-2"><span class="c-red">*</span>优惠券截止时间:</label>
 			<div class="formControls col-4">
@@ -94,7 +94,7 @@
 					   readonly name="couponEndTime" id=couponEndTime datatype="*" nullmsg="请输入截止时间!"  style="width:90%"
 					   value="<fmt:formatDate value='${cType.couponEndDate }' pattern='YYYY-MM-dd HH:MM:ss'/>">
 			</div>
-		</div>--%>
+		</div>
 		<div class="row cl">
 			<label class="form-label col-3"><strong>【优惠券领取条件】</strong></label>
 		</div>
@@ -121,11 +121,22 @@
 			</div>
 
 		<div class="row cl">
-		<label  class="form-label col-2"><span class="c-red">*</span>消费总金额:</label>
-		<div  class="formControls col-2">
-			<input id="couponConsumeEnough" name="couponConsumeEnough" type="text" class="input-text" value="${cType.couponConsumeEnough / 100}" placeholder="消费总金额要求(满足条件才能领券)">
+			<label  class="form-label col-2"><span class="c-red">*</span>消费总金额:</label>
+			<div  class="formControls col-2">
+				<input id="couponConsumeEnough" name="couponConsumeEnough" type="text" class="input-text" value="${cType.couponConsumeEnough / 100}" placeholder="消费总金额要求(满足条件才能领券)">
+			</div>
+			<label  class="form-label col-2"><span class="c-red">*</span>是否限制来源:</label>
+			<div  class="formControls col-2">
+				是:<input name="couponIsSource" type="radio" <c:if test="${cType.couponIsSource == 1 }">checked</c:if> value="1" onclick="checkSource();">
+				否:<input name="couponIsSource" type="radio" <c:if test="${cType.couponIsSource == 2 }">checked</c:if> value="2" onclick="checkSource();">
+			</div>
+		</div>
+		<div class="row cl">
+			<label  class="form-label col-2"><span class="c-red">*</span>限制来源:</label>
+			<div  class="formControls col-2">
+				<input id="couponSourceName" name="couponSourceName" type="text" class="input-text" style="width:90%" value="${cType.couponSourceName}" placeholder="限制来源" <c:if test="${cType.couponIsSource == 2 }">disabled="disabled"</c:if>>
+			</div>
 		</div>
-
 
 		<div class="row cl">
 			<label class="form-label col-3"><strong>【其他】</strong></label>
@@ -182,6 +193,17 @@ $(function(){
 		}
 	}); */
 });
+
+function checkSource() {
+    var val=$('input:radio[name="couponIsSource"]:checked').val();
+    if (val == 1) {
+        $('#couponSourceName').attr('disabled',false);
+    } else {
+        $('#couponSourceName').val("");
+        $('#couponSourceName').attr('disabled',true);
+    }
+}
+
 function checkForm(){
     //名称验证
     if(!commonTypeJdg('couponName',null,null,true)){
@@ -222,10 +244,10 @@ function checkForm(){
         return false;
     }
     //截止时间验证
-	/*if(!commonTypeJdg('couponEndTime',null,null,true)){
+	if(!commonTypeJdg('couponEndTime',null,null,true)){
 	 layer.msg("截止时间不能为空",{icon: 2,time:2000});
 	 return false;
-	 }*/
+	 }
     //有效天数验证
     if(!commonTypeJdg('couponGetDays','pInteger',null,true)){
         layer.msg("有效天数不能为空!且只能是数字",{icon: 2,time:2000});
@@ -236,6 +258,13 @@ function checkForm(){
         layer.msg("领券后有效时长不能为空!且只能是数字",{icon: 2,time:2000});
         return false;
     }
+    var val=$('input:radio[name="couponIsSource"]:checked').val();
+    if (val == 1) {
+        if(!commonTypeJdg('couponSourceName',null,null,true)){
+            layer.msg("优惠券限制来源不能为空",{icon: 2,time:2000});
+            return false;
+        }
+    }
 	
 	//减免额不能为空乘100 取整
 	var couponReduce = $("#couponReduce").val();