|
@@ -113,8 +113,12 @@ public class OrderHandler {
|
|
|
OrderPayDto dto = new OrderPayDto();
|
|
|
|
|
|
Member member = WechatUtils.getUserBySession(request);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
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());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- int templateId = systemService.selectOneShopRuleById(114).getRuleNum().intValue();
|
|
|
-
|
|
|
- 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());
|
|
|
-
|
|
|
- userGiftDto = productInfoService.selectUserGift(userGiftDto);
|
|
|
- if (userGiftDto != null) {
|
|
|
- cartDto.setProductPrice(userGiftDto.getUserDiscount());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- 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());
|
|
|
-
|
|
|
- userGiftDto = productInfoService.selectUserGift(userGiftDto);
|
|
|
- if (userGiftDto != null) {
|
|
|
- cartDto.setProductPrice(userGiftDto.getUserDiscount());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
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>();
|
|
|
-
|
|
|
-
|
|
|
- String element = systemService.selectOneShopRuleById(236).getRuleDesc();
|
|
|
- String machine = systemService.selectOneShopRuleById(237).getRuleDesc();
|
|
|
- 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");
|
|
|
-
|
|
|
- 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) {
|
|
|
-
|
|
|
- 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);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
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);
|
|
@@ -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());
|