Commit c382eab1 by ping.wu

Merge branches 'develop' and 'feature/20200915_购物车添加限制数量_wuping' of…

Merge branches 'develop' and 'feature/20200915_购物车添加限制数量_wuping' of http://gitlab.freemud.com/order-group-application/order-group into develop
parents 7aca2ae9 4259abb4
...@@ -160,7 +160,7 @@ public enum ResponseResult { ...@@ -160,7 +160,7 @@ public enum ResponseResult {
REJECT_ORDER_FAIL("45075", "拒单失败"), REJECT_ORDER_FAIL("45075", "拒单失败"),
AGREE_REFUND_ORDER_FAIL("45076", "同意退款失败"), AGREE_REFUND_ORDER_FAIL("45076", "同意退款失败"),
ORDER_REFUND_NOT_APPLY("45077","用户未申请退款"), ORDER_REFUND_NOT_APPLY("45077","用户未申请退款"),
ORDER_HAD_AFFIRM_CAN_NOT_REFUND("45078","当前订单不允许退款,请前往B端后台设置"), ORDER_HAD_AFFIRM_CAN_NOT_REFUND("45078","当前订单不允许退款,请联系管理员设置"),
ORDER_REJECT_REFUND_REPETITION("45079","重复操作,订单已拒绝退款"), ORDER_REJECT_REFUND_REPETITION("45079","重复操作,订单已拒绝退款"),
ORDER_REJECT_REFUND_STATUS_NOT("45080","订单不是申请退款中,不能操作"), ORDER_REJECT_REFUND_STATUS_NOT("45080","订单不是申请退款中,不能操作"),
ORDER_REJECT_REFUND_STATUS_END("45081","订单未接单或者已取消,不能操作"), ORDER_REJECT_REFUND_STATUS_END("45081","订单未接单或者已取消,不能操作"),
......
package cn.freemud.entities.dto;
import lombok.Data;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: OpenPlatformPartnerWxappConfig
* @Package cn.freemud.entities.dto
* @Description:
* @author: ping1.wu
* @date: 2020/9/15 15:59
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class OpenPlatformPartnerWxappConfig {
private String wxAppid;
private String appKey;
private String appValue;
private Integer state;
}
...@@ -85,7 +85,9 @@ public enum ResponseResult { ...@@ -85,7 +85,9 @@ public enum ResponseResult {
SHOPPING_CART_SHOP_ID_NOT_EMPTY("44019", "门店编号不能为空"), SHOPPING_CART_SHOP_ID_NOT_EMPTY("44019", "门店编号不能为空"),
SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP("44020", "券不适用于该门店"), SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP("44020", "券不适用于该门店"),
SHOPPING_CART_SEAT_EMPTY("44020", "键位为空"), SHOPPING_CART_SEAT_EMPTY("44020", "键位为空"),
SHOPPING_CART_COUPON_USED("44021", "商品券已使用"), SHOPPING_CART_COUPON_USED("44021", "优惠券已加入餐盘"),
SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE("44022", "已加入同样优惠券,第二张暂不可用"),
SHOPPING_CART_LIMIT_ADD("44025", "加购数量超过限制"),
/** /**
* 订单状态码 * 订单状态码
......
...@@ -30,6 +30,7 @@ import cn.freemud.entities.vo.*; ...@@ -30,6 +30,7 @@ import cn.freemud.entities.vo.*;
import cn.freemud.enums.*; import cn.freemud.enums.*;
import cn.freemud.interceptor.ServiceException; import cn.freemud.interceptor.ServiceException;
import cn.freemud.interceptor.BizServiceException; import cn.freemud.interceptor.BizServiceException;
import cn.freemud.redis.RedisCache;
import cn.freemud.service.*; import cn.freemud.service.*;
import cn.freemud.service.thirdparty.*; import cn.freemud.service.thirdparty.*;
import cn.freemud.utils.PromotionFactory; import cn.freemud.utils.PromotionFactory;
...@@ -39,6 +40,7 @@ import com.alibaba.fastjson.JSON; ...@@ -39,6 +40,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerStoreDeliveryConfig; import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerStoreDeliveryConfig;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerWxappConfig;
import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformPartnerStoreDeliveryConfigManager; import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformPartnerStoreDeliveryConfigManager;
import com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager; import com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager;
import com.freemud.application.sdk.api.log.ErrorLog; import com.freemud.application.sdk.api.log.ErrorLog;
...@@ -67,6 +69,8 @@ import org.apache.commons.lang.ObjectUtils; ...@@ -67,6 +69,8 @@ import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
...@@ -254,6 +258,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -254,6 +258,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty(); allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
*/ */
Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods); Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods);
//购物车添加数量限制
limitGoodsQty(checkQty,appId);
//查询多个商品库存信息 //查询多个商品库存信息
queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty); queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty);
String productName = null; String productName = null;
...@@ -345,6 +351,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -345,6 +351,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (cartGoods == null) { if (cartGoods == null) {
throw new ServiceException(ResponseResult.SHOPPING_CART_UPDATE_ERROR); throw new ServiceException(ResponseResult.SHOPPING_CART_UPDATE_ERROR);
} }
//购物车添加数量限制
limitGoodsQty(qty,appId);
// 检查购物车商品库存数量 // 检查购物车商品库存数量
checkUpdateStock(updateShoppingCartGoodsQtyRequestVo, cartGoods); checkUpdateStock(updateShoppingCartGoodsQtyRequestVo, cartGoods);
...@@ -1627,4 +1635,42 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1627,4 +1635,42 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setToastMsg(""); shoppingCartGoodsResponseVo.setToastMsg("");
} }
} }
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private RedisCache redisCache;
/**
* 查询生态配置限制加购开关与限制数量
*/
public void limitGoodsQty(Integer qty,String appid){
String redisKey = "ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_"+appid;
Object value = redisCache.hashGet(redisKey, "2");
List<AssortmentOpenPlatformPartnerWxappConfig> configs = null;
if (value == null) {
return ;
} else {
JSONArray jsonArray = (JSONArray)value;
int cartLimitFlag = 0;
int cartLimitCount = 0;
for (Object object : jsonArray){
JSONObject jsonObject = (JSONObject)object;
HashMap hashMap = JSONObject.parseObject(jsonObject.toJSONString(),HashMap.class);
if("cartLimitFlag".equals(hashMap.get("appKey"))){
cartLimitFlag = Integer.parseInt((String)hashMap.get("appValue"));
}
if("cartLimitCount".equals(hashMap.get("appKey"))){
cartLimitCount = Integer.parseInt((String)hashMap.get("appValue"));
}
}
if(cartLimitFlag == 1 && cartLimitCount != 0 && qty > cartLimitCount){
throw new ServiceException(ResponseResult.SHOPPING_CART_LIMIT_ADD);
}
}
}
} }
...@@ -135,7 +135,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -135,7 +135,7 @@ public class ShoppingCartMCoffeeServiceImpl {
} }
//商品券已添加情况校验 //商品券已添加情况校验
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = checkGoodsCoupon(oldCartGoodsList, operationType, couponCode); List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = checkGoodsCoupon(oldCartGoodsList, operationType, couponCode,goodsId);
CartGoods addCartGoods = convent2CartGoods(addShoppingCartGoodsRequestVo, goodsId); CartGoods addCartGoods = convent2CartGoods(addShoppingCartGoodsRequestVo, goodsId);
setClassificationAndPrice(addCartGoods, productBeanListSpuClass); setClassificationAndPrice(addCartGoods, productBeanListSpuClass);
//查询多个商品库存信息 //查询多个商品库存信息
...@@ -176,7 +176,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -176,7 +176,7 @@ public class ShoppingCartMCoffeeServiceImpl {
} }
private List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> checkGoodsCoupon(List<CartGoods> oldCartGoodsList, Integer operationType, String couponCode) { private List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> checkGoodsCoupon(List<CartGoods> oldCartGoodsList, Integer operationType, String couponCode,String goodsId) {
if (operationType != null && operationType == 1 && StringUtils.isBlank(couponCode)) { if (operationType != null && operationType == 1 && StringUtils.isBlank(couponCode)) {
throw new ServiceException(ResponseResult.PARAMETER_MISSING, "商品券券号为空"); throw new ServiceException(ResponseResult.PARAMETER_MISSING, "商品券券号为空");
} }
...@@ -192,9 +192,13 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -192,9 +192,13 @@ public class ShoppingCartMCoffeeServiceImpl {
calculationDiscountCoupon.setCode(cartGoods.getCouponCode()); calculationDiscountCoupon.setCode(cartGoods.getCouponCode());
coupons.add(calculationDiscountCoupon); coupons.add(calculationDiscountCoupon);
} }
if (couponCode != null && couponCode.equals(cartGoods.getCouponCode())) { if (StringUtils.isNotEmpty(couponCode) && couponCode.equals(cartGoods.getCouponCode())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_USED); throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_USED);
} }
//同样商品券不能使用
if (StringUtils.isNotEmpty(couponCode)&& StringUtils.isNotEmpty(cartGoods.getCouponCode()) && goodsId.equals(cartGoods.getGoodsId())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE);
}
} }
} }
//新增商品券 //新增商品券
...@@ -343,7 +347,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -343,7 +347,7 @@ public class ShoppingCartMCoffeeServiceImpl {
String appId = shoppingCartInfoRequestVo.getAppId(); String appId = shoppingCartInfoRequestVo.getAppId();
//非商品券券号 //非商品券券号
String couponCode = shoppingCartInfoRequestVo.getCouponCode(); String couponCode = shoppingCartInfoRequestVo.getCouponCode();
// String menuType = shoppingCartInfoRequestVo.getMenuType(); String menuType = shoppingCartInfoRequestVo.getMenuType();
Integer orderType = shoppingCartInfoRequestVo.getOrderType(); Integer orderType = shoppingCartInfoRequestVo.getOrderType();
// String receiveId = shoppingCartInfoRequestVo.getReceiveId(); // String receiveId = shoppingCartInfoRequestVo.getReceiveId();
...@@ -353,7 +357,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -353,7 +357,7 @@ public class ShoppingCartMCoffeeServiceImpl {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_INVAILD); return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_INVAILD);
} }
// 获取购物车商品-查询用户券-券码校验可用券 // 获取购物车商品-查询用户券-券码校验可用券
availableCoupon = couponDiscountCalculation.availableCoupon(partnerId, storeId, userId, thirdPartyMemberID, unionId, appId, couponCode, orderType, cartGoodsList); availableCoupon = couponDiscountCalculation.availableCoupon(partnerId, storeId, userId, thirdPartyMemberID, unionId, appId, couponCode, orderType, menuType,cartGoodsList);
return ResponseUtil.success(availableCoupon); return ResponseUtil.success(availableCoupon);
} }
......
...@@ -8,23 +8,19 @@ import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; ...@@ -8,23 +8,19 @@ import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.*;
import cn.freemud.enums.*; import cn.freemud.enums.*;
import cn.freemud.interceptor.ServiceException; import cn.freemud.interceptor.ServiceException;
import cn.freemud.redis.RedisCache;
import cn.freemud.service.CommonService; import cn.freemud.service.CommonService;
import cn.freemud.service.impl.mcoffee.entity.CouponAvailableReq; import cn.freemud.service.impl.mcoffee.entity.CouponAvailableReq;
import cn.freemud.service.impl.mcoffee.entity.CouponAvailableResp; import cn.freemud.service.impl.mcoffee.entity.CouponAvailableResp;
import cn.freemud.service.impl.mcoffee.entity.CouponProductVo; import cn.freemud.service.impl.mcoffee.entity.CouponProductVo;
import cn.freemud.service.impl.mcoffee.entity.CouponState; import cn.freemud.service.impl.mcoffee.entity.CouponState;
import cn.freemud.service.thirdparty.CardBinClient;
import cn.freemud.service.thirdparty.CouponClient; import cn.freemud.service.thirdparty.CouponClient;
import cn.freemud.service.thirdparty.CustomerExtendClient; import cn.freemud.service.thirdparty.CustomerExtendClient;
import cn.freemud.utils.BarcodeUtil; import cn.freemud.utils.BarcodeUtil;
import cn.freemud.utils.LogUtil; import cn.freemud.utils.LogUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -70,6 +66,10 @@ public class CouponDiscountCalculation { ...@@ -70,6 +66,10 @@ public class CouponDiscountCalculation {
private String appid; private String appid;
private static final String mcafe = "mccafe";
private static final String mcafePickup ="mccafe_pickup";
/** /**
* 优惠计算 * 优惠计算
*/ */
...@@ -203,7 +203,7 @@ public class CouponDiscountCalculation { ...@@ -203,7 +203,7 @@ public class CouponDiscountCalculation {
* 可选优惠券 * 可选优惠券
*/ */
public ActivityClassifyCouponBean availableCoupon( String partnerId, String storeId,String userId,String thirdPartyMemberId,String unionId,String appId public ActivityClassifyCouponBean availableCoupon( String partnerId, String storeId,String userId,String thirdPartyMemberId,String unionId,String appId
, String couponCode, Integer orderType,List<CartGoods> cartGoods) { , String couponCode, Integer orderType,String menuType,List<CartGoods> cartGoods) {
// List<CartGoods> tmpCartGoods = cartGoods.parallelStream().filter(k -> StringUtils.isBlank(k.getCouponCode())).collect(Collectors.toList()); // List<CartGoods> tmpCartGoods = cartGoods.parallelStream().filter(k -> StringUtils.isBlank(k.getCouponCode())).collect(Collectors.toList());
boolean hasGoodsCoupon = false; boolean hasGoodsCoupon = false;
...@@ -214,8 +214,11 @@ public class CouponDiscountCalculation { ...@@ -214,8 +214,11 @@ public class CouponDiscountCalculation {
getMemberCouponListRequestDto.setAppId(appId); getMemberCouponListRequestDto.setAppId(appId);
getMemberCouponListRequestDto.setThirdPartyMemberId(thirdPartyMemberId); getMemberCouponListRequestDto.setThirdPartyMemberId(thirdPartyMemberId);
getMemberCouponListRequestDto.setUnionId(unionId); getMemberCouponListRequestDto.setUnionId(unionId);
//麦咖啡固定值 String tag = mcafe;
getMemberCouponListRequestDto.setTag("mccafe"); if("saas".equals(menuType)){
tag = mcafePickup;
}
getMemberCouponListRequestDto.setTag(tag);
getMemberCouponListRequestDto.setPageNum(1); getMemberCouponListRequestDto.setPageNum(1);
getMemberCouponListRequestDto.setPageSize(Integer.MAX_VALUE); getMemberCouponListRequestDto.setPageSize(Integer.MAX_VALUE);
GetMemberCouponListResponseDto.Result result = getMemberCouponList(getMemberCouponListRequestDto); GetMemberCouponListResponseDto.Result result = getMemberCouponList(getMemberCouponListRequestDto);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment