Browse Source

结算页面

wangxiaoming 7 years ago
parent
commit
9fd86f33cc

+ 51 - 5
tooth-common-core/src/main/java/com/iamberry/wechat/core/entity/coupon/CouponItemDto.java

@@ -16,7 +16,7 @@ public class CouponItemDto implements java.io.Serializable{
 	private Integer couponId; 					//优惠券类型id
 	private String couponName;					//优惠券类型名称
 	private String useropenid;					//领取券的openid
-	private Integer couponUseStatus;			//使用状态
+	private Integer couponUseStatus;			//使用状态 1:未使用; 2:已使用; 3:停用; 7:正在使用中
 	private Integer couponType;                 //优惠券类型
 	
 	private Integer couponReduce;				//减免额/减免率
@@ -35,7 +35,16 @@ public class CouponItemDto implements java.io.Serializable{
 	private Date endDate;						//结束时间
 	private String couponItemRemark;			//优惠券详情备注
 	private PageBean page;						//分页
-	
+
+	private Integer couponIsNewPeople;  //是否为新人券   1:是   2:否
+
+	private String couponItemCurrentUserOpenid;	  //如有转赠,转赠人openid
+	private Integer couponIsDonation; 	//是否已转赠  1:已转赠    2:未转赠   默认为2;
+
+	/*该字段用于返回给前台说明无法使用和无法使用原因*/
+	private Integer couponIsUse;		//1:可以使用   2:无法使用
+	private String couponNoUseReason;	//无法使用原因
+
 	public String getCouponItemId() {
 		return couponItemId;
 	}
@@ -126,7 +135,44 @@ public class CouponItemDto implements java.io.Serializable{
 	public void setCouponType(Integer couponType) {
 		this.couponType = couponType;
 	}
-	
-	
-	
+
+	public String getCouponItemCurrentUserOpenid() {
+		return couponItemCurrentUserOpenid;
+	}
+
+	public void setCouponItemCurrentUserOpenid(String couponItemCurrentUserOpenid) {
+		this.couponItemCurrentUserOpenid = couponItemCurrentUserOpenid;
+	}
+
+	public Integer getCouponIsDonation() {
+		return couponIsDonation;
+	}
+
+	public void setCouponIsDonation(Integer couponIsDonation) {
+		this.couponIsDonation = couponIsDonation;
+	}
+
+	public Integer getCouponIsUse() {
+		return couponIsUse;
+	}
+
+	public void setCouponIsUse(Integer couponIsUse) {
+		this.couponIsUse = couponIsUse;
+	}
+
+	public String getCouponNoUseReason() {
+		return couponNoUseReason;
+	}
+
+	public void setCouponNoUseReason(String couponNoUseReason) {
+		this.couponNoUseReason = couponNoUseReason;
+	}
+
+	public Integer getCouponIsNewPeople() {
+		return couponIsNewPeople;
+	}
+
+	public void setCouponIsNewPeople(Integer couponIsNewPeople) {
+		this.couponIsNewPeople = couponIsNewPeople;
+	}
 }

+ 28 - 0
tooth-common-core/src/main/java/com/iamberry/wechat/core/entity/coupon/CouponType.java

@@ -52,6 +52,10 @@ public class CouponType implements Serializable{
 	private Integer couponIsSource;			//是否限制来源
 	private String couponSourceName;		//限制来源
 
+	private Integer couponIsExchange;  //是否可用积分兑换  1:允许; 2:不允许;
+	private String couponExchangeNum;	//所需积分数
+	private Integer couponIsNewPeople;  //是否为新人优惠券  1:是  2:否
+
 	public Integer getCouponIsSource() {
 		return couponIsSource;
 	}
@@ -188,6 +192,30 @@ public class CouponType implements Serializable{
 	public void setPage(PageBean page) {
 		this.page = page;
 	}
+	public Integer getCouponIsExchange() {
+		return couponIsExchange;
+	}
+
+	public void setCouponIsExchange(Integer couponIsExchange) {
+		this.couponIsExchange = couponIsExchange;
+	}
+
+	public String getCouponExchangeNum() {
+		return couponExchangeNum;
+	}
+
+	public void setCouponExchangeNum(String couponExchangeNum) {
+		this.couponExchangeNum = couponExchangeNum;
+	}
+
+	public Integer getCouponIsNewPeople() {
+		return couponIsNewPeople;
+	}
+
+	public void setCouponIsNewPeople(Integer couponIsNewPeople) {
+		this.couponIsNewPeople = couponIsNewPeople;
+	}
+
 	@Override
 	public String toString() {
 		return "CouponType [couponId=" + couponId + ", couponName="

+ 1 - 1
tooth-common-core/src/main/java/com/iamberry/wechat/core/entity/member/Member.java

@@ -32,7 +32,7 @@ public class Member implements Serializable{
 	private Date userBirthDate;				//生日
 	private Date userCreateDate;			//创建时间
 	
-	private Integer userIdentity;			//会员身份			1:会员   2:微代理
+	private Integer userIdentity;			//会员身份			1:会员   2:微信用户    用于判断是否为上朵会员
 	private Integer userIsFlag;				//关系是否绑定		1:没有2:绑定
 	private String userName;				//姓名
 	private String userPwd;					//用户密码

+ 4 - 2
tooth-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/cartMapper.xml

@@ -233,9 +233,11 @@ PUBLIC
 	<!-- 根据购物车ID数组,批量获取购物车集合 -->
 	<select id="selectCartItemByListId" parameterType="java.util.List" resultType="CartDto">
 		SELECT 
-			C.CART_ID cartId, G.PRODUCT_ID cartProductId, pc.COLOR_ID cartColorId, G.PRODUCT_STATUS productStatus, 
+			C.CART_ID cartId, G.PRODUCT_ID cartProductId, pc.COLOR_ID cartColorId, G.PRODUCT_STATUS productStatus,
 			C.CART_NUM cartNum, G.PRODUCT_NAME productName, pc.COLOR_DISCOUNT productPrice, 
-			G.PRODUCT_INTRODUCE_IMG productIntroduceImg, pc.COLOR_PRICE productDiscount, PC.COLOR_69CODE productRemark, 
+
+			pc.color_img productIntroduceImg,
+			pc.COLOR_PRICE productDiscount, PC.COLOR_69CODE productRemark,
 			pc.COLOR_NAME productColor, G.PRODUCT_TYPE productType 
 		FROM 
 			TB_IAMBERRY_SHOP_CART C 

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

@@ -14,9 +14,9 @@
 		CI.COUPON_USE_STATUS couponUseStatus,
 		CI.COUPON_USE_DATE couponUseDate,
 		CI.COUPON_ITEM_REMARK couponItemRemark,
-
-		CI.ITEM_CURRENT_USER_OPENID itemCurrentUserOpenid,
-		CT.COU coupon_is_give
+		CI.coupon_item_current_user_openid couponItemCurrentUserOpenid,
+		CT.coupon_is_new_people couponIsNewPeople,
+		CT.coupon_is_give couponIsGive,
 		CT.COUPON_NAME couponName,
  		CT.COUPON_REDUCE couponReduce,
  		CT.COUPON_CONSUME_ENOUGH couponConsumeEnough

+ 22 - 187
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/order/OrderHandler.java

@@ -113,8 +113,12 @@ public class OrderHandler {
 		OrderPayDto dto = new OrderPayDto();
 		// 用户信息
 		Member member = WechatUtils.getUserBySession(request);
+//		Member member = new Member();
+//		member.setUserId(14708);
+//		member.setUserOpenid("oZ9pv02WMRQgyDVRY1a_daYecwHI");
+
 		member = memberService.getMemberByUserId(member.getUserId());
-		String cartIds = request.getParameter("cartId");
+		String cartIds = request.getParameter("cartIds");
 		if (cartIds == null) {
 			msg.setMessage(ResultInfo.cartEmptyError);
 			return msg;
@@ -148,215 +152,49 @@ public class OrderHandler {
 			return msg;
 		}
 
-        /*//如果是有二维码的商户,进入后显示优惠价
-        int num = productInfoService.getQrCodeByPlaceOpenId(member.getUserOpenid());
-        if (num > 0) {
-            QrcodeGift gift = new QrcodeGift();
-            List<QrcodeGift> giftList = productInfoService.listQrcodeGift(gift);
-            if (giftList != null && giftList.size() > 0 && cartDtos != null && cartDtos.size() > 0) {
-                for (CartDto cartDto : cartDtos) {
-                    for (QrcodeGift qrcodeGift : giftList) {
-                        if (cartDto.getCartColorId().intValue() == qrcodeGift.getQrcodeColorId()
-                            && qrcodeGift.getQrcodePreDiscount() != null
-                            && qrcodeGift.getQrcodePreDiscount() > 0) {
-                            cartDto.setProductPrice(qrcodeGift.getQrcodePreDiscount());
-                        }
-                    }
-                }
-            }
-        }*/
-
-		//判断是否为金牌会员下线,如果是,则以优惠价显示,如果不是则按原价显示
-		//查询金牌会员模板id
-		int templateId = systemService.selectOneShopRuleById(114).getRuleNum().intValue();
-		//如果模板id等于金牌会模板id,则该用户为金牌会员下线
-		if (member.getUserDealers() != null && member.getTemplateId() != null
-				&& templateId == member.getTemplateId().intValue() && member.getUserResType().intValue() == 3) {
-			//若果是金牌会员下线,产品的价格就以优惠价显示
-			if (cartDtos != null && cartDtos.size() >= 1) {
-				for (CartDto cartDto : cartDtos) {
-					UserGiftDto userGiftDto = new UserGiftDto();
-					userGiftDto.setUserLevel(2);
-					userGiftDto.setUserProductId(cartDto.getCartProductId());
-					userGiftDto.setUserColorId(cartDto.getCartColorId());
-					//根据商品id和会员等级查询礼品信息
-					userGiftDto = productInfoService.selectUserGift(userGiftDto);
-					if (userGiftDto != null) {
-						cartDto.setProductPrice(userGiftDto.getUserDiscount());
-					}
-				}
-			}
-		}
-
-		//根据openid查询该用户是否购买过订单
-		ShopSalesOrderDto shopSalesOrderDto = new ShopSalesOrderDto();
-		shopSalesOrderDto.setSalesOpenid(member.getUserOpenid());
-		shopSalesOrderDto.setSalesStatus("2");
-		int orderNum = cartService.selectOrderCount(shopSalesOrderDto);
-		//如果购买过订单,则滤芯的价格可按折扣价购买
-		if (orderNum > 0) {
-			if (cartDtos != null && cartDtos.size() >= 1) {
-				for (CartDto cartDto : cartDtos) {
-					if (cartDto.getProductType().intValue() == 2) {
-						UserGiftDto userGiftDto = new UserGiftDto();
-						userGiftDto.setUserLevel(3);
-						userGiftDto.setUserProductId(cartDto.getCartProductId());
-						userGiftDto.setUserColorId(cartDto.getCartColorId());
-						//根据商品id和会员等级查询礼品信息
-						userGiftDto = productInfoService.selectUserGift(userGiftDto);
-						if (userGiftDto != null) {
-							cartDto.setProductPrice(userGiftDto.getUserDiscount());
-						}
-					}
-				}
-			}
-		}
-
 		// 判断当前提交的购物车ID,有多少产品在售
 		int total = 0; // 支付金额
 		int sum = 0; // 产品数量
-		int productNum = 0;	//计算商品为滤芯的数量
-		int machineNum = 0;	//计算商品为水机的数量
-		boolean disable = true;	//标识,是否可用优惠券,当购买商品只有滤芯时禁止使用优惠券
+		boolean disable = false;	//标识,是否可以使用(新人券)优惠券,当购买商品需要有牙刷时才能使用优惠券
+		String element = systemService.selectOneShopRuleById(249).getRuleDesc();
 
 		List<CartDto> tempCarts = new ArrayList<CartDto>();
-
-		//查询系统规则表滤芯id信息
-		String element = systemService.selectOneShopRuleById(236).getRuleDesc();//赠送滤芯类型id
-		String machine = systemService.selectOneShopRuleById(237).getRuleDesc();//水机类型id
-		String[]  elements = null;
-		String[]  machines = null;
-		StringBuilder preGift = new StringBuilder();
-		if (element != null) {
-			String rolesStr = element.split(":")[1];
-			elements = rolesStr.split(",");
-		}
-		if (machine != null) {
-			String rolesStr = machine.split(":")[1];
-			machines = rolesStr.split(",");
-		}
-
-		String userQrcodeType = request.getParameter("userQrcodeType");
-		//存在水机时赠送4个滤芯
-		if(userQrcodeType != null && !"".equals(userQrcodeType)){
-
-			//如果是扫描优惠二维码进来,则显示优惠价并赠送滤芯
-			QrcodeGift gift = new QrcodeGift();
-			gift.setQrcodeStatus(1);
-			List<QrcodeGift> giftList = productInfoService.listQrcodeGift(gift);
-			if (giftList != null && giftList.size() > 0 && cartDtos != null && cartDtos.size() > 0) {
-				for (CartDto cartDto : cartDtos) {
-					for (QrcodeGift qrcodeGift : giftList) {
-						if (cartDto.getCartColorId().intValue() == qrcodeGift.getQrcodeColorId()) {
-							switch (userQrcodeType) {
-								case "1":
-									if (qrcodeGift.getQrcodePreDiscount() != null && qrcodeGift.getQrcodePreDiscount() > 0) {
-										cartDto.setProductPrice(qrcodeGift.getQrcodePreDiscount());
-									}
-									if (qrcodeGift.getQrcodePreGiftColor() != null) {
-										for (int i = 0;i < cartDto.getCartNum();i++) {
-											preGift.append(qrcodeGift.getQrcodePreGiftColor());
-											preGift.append(",");
-										}
-									}
-									break;
-								case "2":
-									if (qrcodeGift.getQrcodeSalesDiscount() != null && qrcodeGift.getQrcodeSalesDiscount() > 0) {
-										cartDto.setProductPrice(qrcodeGift.getQrcodeSalesDiscount());
-									}
-									if (qrcodeGift.getQrcodeSalesGiftColor() != null) {
-										for (int i = 0;i < cartDto.getCartNum();i++) {
-											preGift.append(qrcodeGift.getQrcodeSalesGiftColor());
-											preGift.append(",");
-										}
-									}
-									break;
-							}
-						}
-					}
-				}
-			}
-		}
-
 		for (CartDto cartDto : cartDtos) {
 			if (cartDto.getProductStatus() != null && cartDto.getProductStatus().intValue() == 1) {
 				total += cartDto.getCartNum() * cartDto.getProductPrice();
 				sum++;
 				tempCarts.add(cartDto);
 			}
-			for(int i=0,len = elements.length;i < len;i++){
-				//计算商品为滤芯的数量
-				if (cartDto.getProductType().intValue() == Integer.valueOf(elements[i])) {
-					productNum = productNum+cartDto.getCartNum();
-				}
-			}
-			for(int i=0,len = machines.length;i < len;i++){
-				//计算商品为滤芯的数量
-				if (cartDto.getProductType().intValue() == Integer.valueOf(machines[i])) {
-					machineNum = machineNum+cartDto.getCartNum();
-				}
-			}
-		}
-
-		if(preGift.toString() != null && !"".equals(preGift.toString())){
-			String[] giftss = preGift.toString().split(",");
-			ProductColor color = new ProductColor();
-			color.setPage(null);
-			List<ProductColor> colorList = productColorService.selectProductColorList(color);
-			for (int i = 0;i < giftss.length;i++) {
-				boolean cartFlag = false;
-				for (CartDto cart : tempCarts) {
-					//判断是否已经存在该赠品,如果存在则数量加1
-					if (Integer.parseInt(giftss[i]) == cart.getCartColorId() && cart.getTotal() == 0) {
-						cart.setCartNum(cart.getCartNum().intValue() + 1);
-						cartFlag = true;
-					}
-				}
-				//如果不存在,则新增赠品
-				if (!cartFlag) {
-					for (ProductColor productColor : colorList) {
-						if (Integer.parseInt(giftss[i]) == productColor.getColorId()) {
-							CartDto cartDto = new CartDto();
-							cartDto.setCartOpenId(member.getUserOpenid());
-							cartDto.setCartProductId(productColor.getColorProductId());
-							cartDto.setCartColorId(productColor.getColorId());
-							cartDto.setCartNum(1);
-							cartDto.setCartCreateDate(new Date());
-							cartDto.setProductName(productColor.getColorProductName());
-							cartDto.setProductType(productColor.getColorProductType());
-							cartDto.setProductPrice(0);
-							cartDto.setProductIntroduceImg(productColor.getColorProductPic());
-							cartDto.setTotal(0);
-							cartDto.setProductDiscount(0);
-							cartDto.setProductRemark("赠送滤芯");
-							cartDto.setProductColor(productColor.getColorName());
-							tempCarts.add(cartDto);
-						}
-					}
+			String[] els = element.split("-");
+			for(String el : els){
+				if(cartDto.getProductType() == Integer.valueOf(el)){		//订单中没有牙刷的时候,不能使用新人券
+					disable = true;
 				}
 			}
 		}
 
-		//当购买商品只有滤芯时禁止使用优惠券
-		if(productNum == cartDtos.size()) {
-			disable = false;
-		}
-
 		if (sum <= 0) {
 			msg.setMessage(ResultInfo.cartEmptyError);
 			return msg;
 		}
 
-		//未使用的优惠券
+		//查询所有优惠券
 		CouponItemDto cDto = new CouponItemDto();
 		cDto.setUseropenid(member.getUserOpenid());
 		cDto.setCouponUseStatus(1);
 		cDto.setBeginDate(new Date());
-		cDto.setPage(new PageBean());
-		cDto.getPage().setPageSize(12);
+		//cDto.setPage(new PageBean());
+		//cDto.getPage().setPageSize(12);
 		//cDto.getPage().setPageNumber(pageNO);
 		List<CouponItemDto> list = couponItemService.getCouponItemDtoList(cDto);
-
+		for(CouponItemDto couponItemDto : list){
+			if(couponItemDto.getCouponIsNewPeople() == 1 && member.getUserIdentity() != 1){  //当券为新人券,用户为非会员时,需要有牙刷,结算才可以使用该券
+				if(!disable){		//没有牙刷
+					couponItemDto.setCouponIsUse(2);
+					couponItemDto.setCouponNoUseReason("需要购买牙刷才能使用");
+				}
+			}
+		}
 		dto.setCouponItems(list);
 
 		dto.setCartId(cartIds);// 购物车ID
@@ -364,9 +202,6 @@ public class OrderHandler {
 		dto.setCartItems(tempCarts); // 订单项
 		dto.setSuccess(true); // 请求成功
 		dto.setMeonyProportion(0);
-		dto.setBalance(member.getUserIncome());
-
-		dto.setDisable(disable);
 
 		//回显用户支付过的地址信息
 		Order order=cartService.getOrderRecentAddress(member.getUserOpenid());