Browse Source

定时器:修改电话号码
上朵:1:积分获取也已经修改:刷头为1.5倍积分,牙刷为以前的2倍积分,优惠套装为1倍积分,邮费不计算积分;2:优惠套装进入结算页面不能使用优惠券;

wangxiaoming 6 years ago
parent
commit
a24b40ff77

+ 1 - 1
tooth-wechat-interface/src/main/java/com/iamberry/wechat/face/wechat/WeChatService.java

@@ -4,7 +4,7 @@ package com.iamberry.wechat.face.wechat;
 public interface WeChatService {
 	/**
 	 * 处理微信发来的请求
-	 * @param request
+	 * @param
 	 * @return
 	 */
 	public String processRequest(String FromUserName, String ToUserName, String MsgType, String createTime, String Content, String Event, String Ticket, String EventKey);

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

@@ -458,7 +458,7 @@ public class MQTask implements InitializingBean {
 		Integer num = (numberBacklogDto.getExchange()+numberBacklogDto.getReturnGoods()+numberBacklogDto.getReturnRefund()+numberBacklogDto.getSendTheGoods());
 		String text = MessageFormat.format(ImberryConfig.PENDING_ORDER_REMINDER, num);
 		if(num > 0){
-			codeService.informShipping("17621958750", text);
+			codeService.informShipping("18001923600", text);
 			codeService.informShipping("18271840547", text);
 			codeService.informShipping("13922874118", text);
 		}

+ 9 - 1
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/order/OrderHandler.java

@@ -237,8 +237,10 @@ public class OrderHandler {
 		int sum = 0; // 产品数量
 		boolean disable = false;	//标识,是否可以使用(新人券)优惠券,当购买商品需要有牙刷时才能使用优惠券 - 20180316 以前
 		boolean brushFlag = false;	//标识,是否可以使用(新人券)优惠券,只能购买刷头的时候才能使用 - 20180316 以后
+		boolean combinationOffer = false;	//标识,是否有组合优惠套装,购买组合优惠套装不可使用优惠券 - 20181024
 		String element = systemService.selectOneShopRuleById(249).getRuleDesc();
 		String brushelEment = systemService.selectOneShopRuleById(253).getRuleDesc();
+		String combinationOfferColorIds = systemService.selectOneShopRuleById(259).getRuleDesc();
 
 		List<CartDto> tempCarts = new ArrayList<CartDto>();
 		for (CartDto cartDto : cartDtos) {
@@ -268,6 +270,12 @@ public class OrderHandler {
 					brushFlag = true;
 				}
 			}
+			String[] coColorId = combinationOfferColorIds.split("-");
+			for(String colorId : coColorId){
+				if(cartDto.getCartColorId().equals(Integer.valueOf(colorId))){		//判断订单中是否有优惠组合套装
+					combinationOffer = true;
+				}
+			}
 		}
 		if (sum <= 0) {
 			msg.setMessage(ResultInfo.cartEmptyError);
@@ -310,7 +318,7 @@ public class OrderHandler {
 			}
 		}
 		/*插入优惠券*/
-		if(channelType <= 0 && channelId <= 0){
+		if(channelType <= 0 && channelId <= 0 && !combinationOffer){
 			dto.setCouponItems(list);
 		}
 		dto.setCartId(cartIds);// 购物车ID

+ 91 - 62
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/pay/ResponseWechatPayHandler.java

@@ -192,9 +192,9 @@ public class ResponseWechatPayHandler {
 						// 修改订单状态
 						int count = cartService.updateOrderStatus(order);
 
-						/*计算使用优惠券优惠的金额*/
-						Integer couponAmount = 0;
-
+				/*计算使用优惠券优惠的金额*/
+//				Integer couponAmount = 0;
+						Integer couponTypeId = 0;
 						//修改优惠券状态
 						order = cartService.selectOrderInfoById(order);
 						String couponId = order.getCouponId();
@@ -206,47 +206,61 @@ public class ResponseWechatPayHandler {
 							couponItemService.updateCouponItemById(couponItem);
 
 							CouponItemDto couponItemDto = couponItemService.getCouponItemById(couponId);
-							if (couponItemDto.getCouponType() == 1) {  //按照金额
-								couponAmount = couponItemDto.getCouponReduce() / 100;
-							} else if (couponItemDto.getCouponType() == 2) {  ////按照折扣
-								couponAmount = or.getSalesAmount() - or.getSalesAmount() / (couponItemDto.getCouponReduce() / 100) / 100;
-							}
+							couponTypeId = couponItemDto.getCouponId();
+//					if (couponItemDto.getCouponType() == 1) {  //按照金额
+//						couponAmount = couponItemDto.getCouponReduce() / 100;
+//					} else if (couponItemDto.getCouponType() == 2) {  ////按照折扣
+//						couponAmount = or.getSalesAmount() - or.getSalesAmount() / (couponItemDto.getCouponReduce() / 100) / 100;
+//					}
 						}
 
+						//优惠金额
+						Integer offerAmount = (or.getSalesAmount() - or.getSalesYetAmount()) / 100;
+
 						/*-- 计算积分 ----*/
+						//			总积分 		-- 牙刷总金额 --  刷头金额		-- 组合套装优惠,返一倍积分
+						Integer allIntegral = 0, toothbrush = 0, brushHead = 0, combinationOffer = 0;
 						List<OrderItem> orderItemList = adminOrderService.getShopOrderItemByOrderId(orderIdMD5);
-						Integer allIntegral = 0;  //总积分
-						Integer allBrushAmount = 0;		//牙刷总金额与优惠券相减  -- 未乘以3
-
 						for (int i = 0; i < orderItemList.size(); i++) {
 							OrderItem orderItem = orderItemList.get(i);
-							Integer amount = orderItem.getItemProductDiscount() / 100;		//商品优惠价
-							if (orderItem.getItemProductType() == 100) {	//类型为电动牙刷
-								Integer integral = amount * (orderItem.getItemNum() * 3 - orderItem.getItemNum());		//计算牙刷*2的金额
-								allIntegral += integral;
-							} else {
-								//Integer integral = amount * (orderItem.getItemNum() * 3);
-								allBrushAmount += amount * orderItem.getItemNum();		//加的是刷牙总金额
+							Integer amount = orderItem.getItemProductDiscount()*orderItem.getItemNum() / 100;		//商品优惠价
+							if (orderItem.getItemProductType() == 100) {    //类型为电动牙刷
+								toothbrush += amount;
+							}else {
+								if(310 == orderItem.getItemProductId()){
+							/*优惠套装组合*/
+									combinationOffer += amount;
+								}else{
+									brushHead += amount;
+								}
 							}
 						}
-						if (couponAmount > 0) {  //有优惠券减去优惠券的金额 -- 先用牙刷总金额减去优惠券
-							allBrushAmount += -couponAmount;
+						if(20000 == couponTypeId|| 40000 == couponTypeId){
+							//刷头优惠券
+							brushHead -= offerAmount;
+						}else{
+							//牙刷优惠券
+							toothbrush -= offerAmount;
 						}
-
-						/**
-						 * start
-						 * 两种情况:
-						 * 1) 刷头金额低于抵扣金额时:支付金额*2;
-						 * 2) 刷头金额高于等于抵扣金额时:399*2
-						 */
-						if(allBrushAmount < 0){		 //刷头金额低于抵扣金额  ==> 牙刷金额*2 + (刷头金额 - 优惠券)*2
-							allIntegral += allBrushAmount * 2;		//牙刷减去(优惠券减去刷头的金额)
-						}else{		//刷头金额高于等于抵扣金额
-							//allIntegral += allBrushAmount * 3;	//----- 删除
+						if(or.getSalesPostage() > 0){
+							if(brushHead >= 10){
+								brushHead -= or.getSalesPostage()/100;
+							}else if(toothbrush >= 10){
+								toothbrush -= or.getSalesPostage()/100;
+							}
 						}
+						if(brushHead < 0){
+							brushHead = 0;
+						}
+						if(toothbrush < 0){
+							toothbrush = 0;
+						}
+
+						//后面的小数积分直接去掉,不需要四舍五入
+						allIntegral = (int)( toothbrush * 2 + brushHead * 1.5 + combinationOffer * 1);
 						/*-----end-----*/
 
-						ratFWLogger.error(this, "订单:" + orderIdMD5 + "订单使用优惠卷金额:" + couponAmount + "所得积分为:" + allIntegral);
+						ratFWLogger.error(this, "订单:" + orderIdMD5 + "订单使用优惠金额:" + offerAmount + "所得积分为:" + allIntegral);
 						boolean flag = apparatusService.addStayIntegral(or.getSalesOpenid(), 3, allIntegral, or.getSalesOrderid(),null);
 						ratFWLogger.info("积分是否入账:" + flag);
 						/*----------计算积分-----------*/
@@ -385,7 +399,8 @@ public class ResponseWechatPayHandler {
 				int count = cartService.updateOrderStatus(order);
 
 				/*计算使用优惠券优惠的金额*/
-				Integer couponAmount = 0;
+//				Integer couponAmount = 0;
+				Integer couponTypeId = 0;
 				//修改优惠券状态
 				order = cartService.selectOrderInfoById(order);
 				String couponId = order.getCouponId();
@@ -397,47 +412,61 @@ public class ResponseWechatPayHandler {
 					couponItemService.updateCouponItemById(couponItem);
 
 					CouponItemDto couponItemDto = couponItemService.getCouponItemById(couponId);
-					if (couponItemDto.getCouponType() == 1) {  //按照金额
-						couponAmount = couponItemDto.getCouponReduce() / 100;
-					} else if (couponItemDto.getCouponType() == 2) {  ////按照折扣
-						couponAmount = or.getSalesAmount() - or.getSalesAmount() / (couponItemDto.getCouponReduce() / 100) / 100;
-					}
+					couponTypeId = couponItemDto.getCouponId();
+//					if (couponItemDto.getCouponType() == 1) {  //按照金额
+//						couponAmount = couponItemDto.getCouponReduce() / 100;
+//					} else if (couponItemDto.getCouponType() == 2) {  ////按照折扣
+//						couponAmount = or.getSalesAmount() - or.getSalesAmount() / (couponItemDto.getCouponReduce() / 100) / 100;
+//					}
 				}
 
+				//优惠金额
+				Integer offerAmount = (or.getSalesAmount() - or.getSalesYetAmount()) / 100;
+
 				/*-- 计算积分 ----*/
+				//			总积分 		-- 牙刷总金额 --  刷头金额		-- 组合套装优惠,返一倍积分
+				Integer allIntegral = 0, toothbrush = 0, brushHead = 0, combinationOffer = 0;
 				List<OrderItem> orderItemList = adminOrderService.getShopOrderItemByOrderId(orderIdMD5);
-				Integer allIntegral = 0;  //总积分
-				Integer allBrushAmount = 0;		//牙刷总金额与优惠券相减  -- 未乘以3
-
 				for (int i = 0; i < orderItemList.size(); i++) {
 					OrderItem orderItem = orderItemList.get(i);
-					Integer amount = orderItem.getItemProductDiscount() / 100;		//商品优惠价
-					if (orderItem.getItemProductType() == 100) {	//类型为电动牙刷
-						Integer integral = amount * (orderItem.getItemNum() * 3 - orderItem.getItemNum());		//计算牙刷*2的金额
-						allIntegral += integral;
-					} else {
-						//Integer integral = amount * (orderItem.getItemNum() * 3);
-						allBrushAmount += amount * orderItem.getItemNum();		//加的是刷牙总金额
+					Integer amount = orderItem.getItemProductDiscount()*orderItem.getItemNum() / 100;		//商品优惠价
+					if (orderItem.getItemProductType() == 100) {    //类型为电动牙刷
+						toothbrush += amount;
+					}else {
+						if(310 == orderItem.getItemProductId()){
+							/*优惠套装组合*/
+							combinationOffer += amount;
+						}else{
+							brushHead += amount;
+						}
 					}
 				}
-				if (couponAmount > 0) {  //有优惠券减去优惠券的金额 -- 先用牙刷总金额减去优惠券
-					allBrushAmount += -couponAmount;
+				if(20000 == couponTypeId|| 40000 == couponTypeId){
+					//刷头优惠券
+					brushHead -= offerAmount;
+				}else{
+					//牙刷优惠券
+					toothbrush -= offerAmount;
 				}
-
-				/**
-				 * start
-				 * 两种情况:
-				 * 1) 刷头金额低于抵扣金额时:支付金额*2;
-				 * 2) 刷头金额高于等于抵扣金额时:399*2
-				 */
-				if(allBrushAmount < 0){		 //刷头金额低于抵扣金额  ==> 牙刷金额*2 + (刷头金额 - 优惠券)*2
-					allIntegral += allBrushAmount * 2;		//牙刷减去(优惠券减去刷头的金额)
-				}else{		//刷头金额高于等于抵扣金额
-					//allIntegral += allBrushAmount * 3;	//----- 删除
+				if(or.getSalesPostage() > 0){
+					if(brushHead >= 10){
+						brushHead -= or.getSalesPostage()/100;
+					}else if(toothbrush >= 10){
+						toothbrush -= or.getSalesPostage()/100;
+					}
 				}
+				if(brushHead < 0){
+					brushHead = 0;
+				}
+				if(toothbrush < 0){
+					toothbrush = 0;
+				}
+
+				//后面的小数积分直接去掉,不需要四舍五入
+				allIntegral = (int)( toothbrush * 2 + brushHead * 1.5 + combinationOffer * 1);
 				/*-----end-----*/
 
-				ratFWLogger.error(this, "订单:" + orderIdMD5 + "订单使用优惠卷金额:" + couponAmount + "所得积分为:" + allIntegral);
+				ratFWLogger.error(this, "订单:" + orderIdMD5 + "订单使用优惠金额:" + offerAmount + "所得积分为:" + allIntegral);
 				boolean flag = apparatusService.addStayIntegral(or.getSalesOpenid(), 3, allIntegral, or.getSalesOrderid(),null);
 				ratFWLogger.info("积分是否入账:" + flag);
 				/*----------计算积分-----------*/