|
@@ -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());
|