## 添加商品加购处理;

This commit is contained in:
cabbage 2025-07-29 15:08:45 +08:00
parent 3153d96c46
commit 37166d8a71
18 changed files with 195 additions and 92 deletions

View File

@ -11,11 +11,7 @@ import java.math.BigDecimal;
import java.util.List;
/**
* @Description: 等级的dto
* @Author: sui q
* @Time: 2022/9/24 15:06
* @Classname: GradeDTO
* @PackageName: com.hzs.system.config.dto
* 等级的dto
*/
@Data
@Builder
@ -95,7 +91,6 @@ public class GradeDTO implements Serializable {
/**
* 图片
*/
private String image;
/**
* 色值
@ -108,18 +103,8 @@ public class GradeDTO implements Serializable {
private String icon;
/**
* 等级数量
* 加购数量
*/
private Integer boxNumber;
/**
* 总数量
*/
private Integer boxTotal;
/**
* 小市场数量
*/
private Integer boxSmallTotal;
}

View File

@ -1,12 +1,13 @@
package com.hzs.sale.order.controller.api;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.hzs.common.core.annotation.RepeatSubmit;
import com.hzs.common.core.constant.CacheConstants;
import com.hzs.common.core.constant.HttpStatus;
import com.hzs.common.core.constant.msg.MemberMsgConstants;
import com.hzs.common.core.constant.msg.SaOrderMsgConstants;
import com.hzs.common.core.enums.EOrderType;
import com.hzs.common.core.enums.*;
import com.hzs.common.core.utils.StringUtils;
import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.domain.member.ext.CuMemberAccountExt;
@ -16,10 +17,24 @@ import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.sale.order.controller.ParentOrderController;
import com.hzs.sale.order.param.OrderParam;
import com.hzs.sale.order.param.OrderReturn;
import com.hzs.sale.order.service.impl.SaOrderHandle;
import com.hzs.sale.order.vo.CheckBeforeConfirmVO;
import com.hzs.sale.shopping.param.CarWaresInfoParam;
import com.hzs.sale.shopping.vo.CarWaresInfoVo;
import com.hzs.sale.shopping.vo.ShoppingCartRedis;
import com.hzs.sale.shopping.vo.ShoppingCartVO;
import com.hzs.sale.shopping.vo.WaresItemVo;
import com.hzs.sale.wares.service.IBdWaresSpecsSkuService;
import com.hzs.system.config.IGradeServiceApi;
import com.hzs.system.config.dto.GradeDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.Map;
/**
* 其他订单升级复购订单
*/
@ -28,6 +43,14 @@ import org.springframework.web.bind.annotation.*;
@Slf4j
public class ApiOthSaOrderController extends ParentOrderController {
@Autowired
private SaOrderHandle saOrderHandle;
@Autowired
private IBdWaresSpecsSkuService iBdWaresSpecsSkuService;
@DubboReference
IGradeServiceApi iGradeServiceApi;
/**
* 提供确认订单的方法
*
@ -180,4 +203,82 @@ public class ApiOthSaOrderController extends ParentOrderController {
return AjaxResult.error(cuMemberAccountExt.getErrorMsg());
}
/**
* 下单前校验
*
* @param param
* @return
*/
@GetMapping("/check-before-confirm")
public AjaxResult checkBeforeConfirm(CarWaresInfoParam param) {
if (null == param.getSpecialArea() || CollectionUtil.isEmpty(param.getShoppingIds())) {
return AjaxResult.error("参数不能为空");
}
CheckBeforeConfirmVO vo = CheckBeforeConfirmVO.builder()
.flag(EYesNo.YES.getIntValue())
.build();
Integer pkCountry = SecurityUtils.getPkCountry();
Long userId = SecurityUtils.getUserId();
if (ESpecialArea.REGISTER_AREA.getValue() == param.getSpecialArea()
|| ESpecialArea.UPGRADE_AREA.getValue() == param.getSpecialArea()) {
// 2025.07.29 注册升级专区需要处理加购
String key = CacheConstants.SHOPPIN_GCART + pkCountry + "_" + userId;
Map<String, Object> shoppingCartRedisMap = redisService.getCacheMap(key);
if (shoppingCartRedisMap.containsKey(key)) {
Map<String, String> innerShopMap = (Map<String, String>) shoppingCartRedisMap.get(key);
if (null != innerShopMap) {
// 业绩
BigDecimal achieveAmount = BigDecimal.ZERO;
// 加购商品数量
Integer addPurchase = 0;
for (String shoppingId : param.getShoppingIds()) {
for (String innkey : innerShopMap.keySet()) {
String value = innerShopMap.get(innkey);
ShoppingCartRedis shoppingCartRedis = JSONUtil.toBean(value, ShoppingCartRedis.class);
if (shoppingCartRedis.getShoppingId().equals(shoppingId)) {
WaresItemVo waresItemVo = iBdWaresSpecsSkuService.listWaresItemsNew(param.getSpecialArea(),
shoppingCartRedis.getWaresCode(), shoppingCartRedis.getProductGroup(), shoppingCartRedis.getNumber());
if (EWaresType.ADD_PURCHASE.getValue().equals(waresItemVo.getIsMakerGift())) {
// 是加购商品需要累计数量
addPurchase += shoppingCartRedis.getNumber();
}
// 累计业绩
achieveAmount = achieveAmount.add(waresItemVo.getAchieveAmount());
}
}
}
GradeDTO gradeDTO = saOrderHandle.getMemberGradeAndAwardByCountry(BigDecimal.ZERO, achieveAmount, pkCountry, EUpgradeWay.COVER.getValue() + "");
if (null != gradeDTO) {
if (EOrderType.REGISTER_ORDER.getValue() == param.getSpecialArea()
|| EOrderType.UPGRADE_ORDER.getValue() == param.getSpecialArea()) {
// 2025.05.13 新添加需求开网初期报单660给1980等级报单1980给9900等级
if (EGrade.YOU_KE.getValue() == gradeDTO.getGradeValue()) {
GradeDTO newGradeDTO = iGradeServiceApi.getGradeByGradeValue(EGrade.MAKER.getValue(), pkCountry).getData();
if (null != newGradeDTO) {
gradeDTO = newGradeDTO;
}
} else if (EGrade.MAKER.getValue() == gradeDTO.getGradeValue()) {
GradeDTO newGradeDTO = iGradeServiceApi.getGradeByGradeValue(EGrade.VIP.getValue(), pkCountry).getData();
if (null != newGradeDTO) {
gradeDTO = newGradeDTO;
}
}
}
// 当前等级可以购买多少加购商品
if (addPurchase > gradeDTO.getBoxNumber()) {
vo.setFlag(EYesNo.NO.getIntValue());
vo.setMsg("当前等级只能购买, " + gradeDTO.getBoxNumber() + " 件加购商品。");
return AjaxResult.success(vo);
}
}
}
}
}
return AjaxResult.success(vo);
}
}

View File

@ -65,13 +65,13 @@ public class ApiRegSaOrderController extends ParentOrderController {
return ajaxResult;
}
if (orderParam.getDeleteList() == null || orderParam.getDeleteList().size() == 0) {
if (null == orderParam.getDeleteList() || orderParam.getDeleteList().size() == 0) {
return AjaxResult.error(SaOrderMsgConstants.SPECIAL_AREA_NOT_EMPTY);
}
initSecurityOrderParam(orderParam);
// 验证必输项
if (source == null
if (null == source
|| validateFieldNotNull(orderParam, orderParam.getValidConfirmField())
|| !checkRecMsgBoolean(orderParam)) {
return AjaxResult.error(MemberMsgConstants.REQUIRED_NOT_EMPTY);

View File

@ -744,7 +744,7 @@ public class SaOrderHandle {
* @param settleOrderPv 订单业绩
* @param pkCountry 国家
*/
GradeDTO getMemberGradeAndAwardByCountry(BigDecimal settleOrderAmount, BigDecimal settleOrderPv, Integer pkCountry, String upgradeWay) {
public GradeDTO getMemberGradeAndAwardByCountry(BigDecimal settleOrderAmount, BigDecimal settleOrderPv, Integer pkCountry, String upgradeWay) {
List<GradeDTO> gradeList = iGradeServiceApi.queryGradeConfigByCondition(pkCountry).getData();
if (gradeList != null && gradeList.size() > 0) {

View File

@ -0,0 +1,29 @@
package com.hzs.sale.order.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 下单前校验返回VO
*/
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
public class CheckBeforeConfirmVO implements Serializable {
/**
* 是否通过0=1=
*/
private Integer flag;
/**
* 错误提示
*/
private String msg;
}

View File

@ -22,8 +22,6 @@ import java.util.*;
/**
* 购物车操作处理
*
* @author hzs
*/
@RestController
@Slf4j
@ -33,9 +31,9 @@ public class ApiShoppingCartController extends BaseController {
@Autowired
private RedisService redisService;
@Autowired
private IShoppingCartService shoppingCartService;
private IShoppingCartService iShoppingCartService;
@Autowired
private IBdWaresSpecsSkuService bdWaresSpecsSkuService;
private IBdWaresSpecsSkuService iBdWaresSpecsSkuService;
/**
* 添加购物车
@ -103,7 +101,7 @@ public class ApiShoppingCartController extends BaseController {
if (shoppingCartRedisMap.containsKey(key)) {
Map<String, String> innerShopMap;
innerShopMap = (Map<String, String>) shoppingCartRedisMap.get(key);
shoppingCartOld = shoppingCartService.getShopping(innerShopMap, shoppingCartVO.getSpecialArea(), shoppingCartVO.getPkCountry());
shoppingCartOld = iShoppingCartService.getShopping(innerShopMap, shoppingCartVO.getSpecialArea(), shoppingCartVO.getPkCountry());
} else {
shoppingCartOld = new ArrayList<>();
}
@ -143,7 +141,7 @@ public class ApiShoppingCartController extends BaseController {
}
if (shoppingCartPkCountry.equals(shoppingCartRedisPkCountry)) {
if (null != shoppingCartRedis.getWaresCode()) {
CuWaresParams cuWaresParams = bdWaresSpecsSkuService.queryWaresSpecsSkuCount(shoppingCartRedisSpecialArea, shoppingCartRedis.getWaresCode(), userId, shoppingCartRedisPkCountry);
CuWaresParams cuWaresParams = iBdWaresSpecsSkuService.queryWaresSpecsSkuCount(shoppingCartRedisSpecialArea, shoppingCartRedis.getWaresCode(), userId, shoppingCartRedisPkCountry);
if (null != cuWaresParams && CollectionUtil.isNotEmpty(cuWaresParams.getProductParams())
&& CollectionUtil.isNotEmpty(cuWaresParams.getProductParams().get(0).getWaresItemsParamsList())) {
count += shoppingCartRedis.getNumber();
@ -196,7 +194,7 @@ public class ApiShoppingCartController extends BaseController {
if (shoppingCartRedisSpecialArea.equals(shoppingCartSpecialArea)
&& shoppingCartPkCountry.equals(shoppingCartRedisPkCountry)) {
if (null != shoppingCartRedis.getWaresCode()) {
CuWaresParams cuWaresParams = bdWaresSpecsSkuService.queryWaresSpecsSkuCount(shoppingCartSpecialArea, shoppingCartRedis.getWaresCode(), userId, shoppingCartPkCountry);
CuWaresParams cuWaresParams = iBdWaresSpecsSkuService.queryWaresSpecsSkuCount(shoppingCartSpecialArea, shoppingCartRedis.getWaresCode(), userId, shoppingCartPkCountry);
if (null != cuWaresParams && CollectionUtil.isNotEmpty(cuWaresParams.getProductParams())
&& CollectionUtil.isNotEmpty(cuWaresParams.getProductParams().get(0).getWaresItemsParamsList())) {
smallCount += shoppingCartRedis.getNumber();
@ -228,7 +226,7 @@ public class ApiShoppingCartController extends BaseController {
*/
@PostMapping("/batchDelShopping")
public AjaxResult batchDelShopping(@RequestBody ShoppingCartVO sop) {
shoppingCartService.batchDelShopping(SecurityUtils.getUserId(), sop);
iShoppingCartService.batchDelShopping(SecurityUtils.getUserId(), sop);
return AjaxResult.success();
}
@ -288,7 +286,7 @@ public class ApiShoppingCartController extends BaseController {
String value = innerShopMap.get(innkey);
ShoppingCartRedis shoppingCartRedis = JSONUtil.toBean(value, ShoppingCartRedis.class);
if (shoppingCartRedis.getShoppingId().equals(shoppingId)) {
WaresItemVo waresItemVo = bdWaresSpecsSkuService.selectWaresItemsVO(SecurityUtils.getUserId(), shoppingCartRedis.getPkCountry(), scr.getSpecialArea(),
WaresItemVo waresItemVo = iBdWaresSpecsSkuService.selectWaresItemsVO(SecurityUtils.getUserId(), shoppingCartRedis.getPkCountry(), scr.getSpecialArea(),
shoppingCartRedis.getWaresCode(), shoppingCartRedis.getProductGroup(), shoppingCartRedis.getNumber());
priceAmount = priceAmount.add(waresItemVo.getPriceAmount());
achieveAmount = achieveAmount.add(waresItemVo.getAchieveAmount());

View File

@ -1,23 +1,9 @@
package com.hzs.sale.shopping.param;/**
* @Description:
* @Author: yuhui
* @Time: 2023/3/20 15:40
* @Classname: CarWaresInfoParam
* @PackageName: com.hzs.sale.shopping.param
*/
package com.hzs.sale.shopping.param;
import lombok.Data;
import java.util.List;
/**
*@BelongsProject: hzs_cloud
*@BelongsPackage: com.hzs.sale.shopping.param
*@Author: yh
*@CreateTime: 2023-03-20 15:40
*@Description: TODO
*@Version: 1.0
*/
@Data
public class CarWaresInfoParam {
@ -31,7 +17,7 @@ public class CarWaresInfoParam {
private Integer pkCountry;
/**
* 购物车项
* 购物车项
*/
private List<String> shoppingIds;
}

View File

@ -1,10 +1,4 @@
package com.hzs.sale.shopping.vo;/**
* @Description:
* @Author: yuhui
* @Time: 2023/3/20 15:36
* @Classname: CarWaresInfo
* @PackageName: com.hzs.sale.shopping.vo
*/
package com.hzs.sale.shopping.vo;
import com.hzs.common.core.annotation.BigDecimalFormat;
import lombok.Data;
@ -13,21 +7,16 @@ import java.math.BigDecimal;
import java.util.List;
/**
*@BelongsProject: hzs_cloud 购物车下单商品展示信息
*@BelongsPackage: com.hzs.sale.shopping.vo
*@Author: yh
*@CreateTime: 2023-03-20 15:36
*@Description: TODO
*@Version: 1.0
* 购物车下单商品展示信息
*/
@Data
public class CarWaresInfoVo {
/**
* 商品信息
*/
private List<WaresItemVo> orderItemsParams;
/**
* 总计金额
*/

View File

@ -5,11 +5,7 @@ import lombok.Data;
import java.io.Serializable;
/**
* @Description: 购物车产品SKU组合缓存实体类
* @Author: zhangjing
* @Time: 2022/9/16 11:11
* @Classname: ShoppingCartVO
* @PackageName: com.hzs.common.domain.sale.ext
* 购物车产品SKU组合缓存实体类
*/
@Data
public class ProductGroup implements Serializable {

View File

@ -78,9 +78,14 @@ public interface IBdWaresSpecsSkuService extends IService<BdWaresSpecsSku> {
*/
List<WaresItemWaresInfo> selectByPkIds(List<Integer> pkWaresSpecsSku);
/*
* 查询商品封装为返回到会员端商品信息
**/
/**
* 查询购物车商品信息
*/
WaresItemVo listWaresItemsNew(Integer specialArea, String waresCode, List<ProductGroup> productGroup, Integer quantity);
/**
* 查询商品封装为返回到会员端商品信息
*/
WaresItemVo selectWaresItemsVO(Long pkMember, Integer pkCountry, Integer specialArea, String waresCode, List<ProductGroup> productGroup, Integer quantity);
/**

View File

@ -390,6 +390,30 @@ public class BdWaresSpecsSkuServiceImpl extends ServiceImpl<BdWaresSpecsSkuMappe
return baseMapper.selectByPkIds(pkWaresSpecsSku);
}
@Override
public WaresItemVo listWaresItemsNew(Integer specialArea, String waresCode, List<ProductGroup> productGroup, Integer quantity) {
WaresItemVo waresItemVo = WaresItemVo.builder().build();
if (CollectionUtil.isNotEmpty(productGroup)) {
waresItemVo = baseMapper.selectWaresItemsVO(specialArea, waresCode, productGroup);
waresItemVo.setQuantity(quantity);
waresItemVo.setSkuQuantity(waresItemVo.getQuantity());
waresItemVo.setPrice(BigDecimal.ZERO);
waresItemVo.setPriceAmount(BigDecimal.ZERO);
waresItemVo.setAchieve(BigDecimal.ZERO);
waresItemVo.setAchieveAmount(BigDecimal.ZERO);
for (WaresItemWaresInfo waresItemWaresInfo : waresItemVo.getWaresItemsParamList()) {
waresItemVo.setPrice(ComputeUtil.computeAdd(waresItemVo.getPrice(), ComputeUtil.computeMultiply(waresItemWaresInfo.getPrice(), waresItemWaresInfo.getQuantity())));
waresItemVo.setAchieve(ComputeUtil.computeAdd(waresItemVo.getAchieve(), ComputeUtil.computeMultiply(waresItemWaresInfo.getAchieve(), waresItemWaresInfo.getQuantity())));
}
waresItemVo.setPriceAmount(ComputeUtil.computeMultiply(waresItemVo.getPrice(), waresItemVo.getQuantity()));
waresItemVo.setAchieveAmount(ComputeUtil.computeMultiply(waresItemVo.getAchieve(), waresItemVo.getQuantity()));
}
return waresItemVo;
}
@Override
public WaresItemVo selectWaresItemsVO(Long pkMember, Integer pkCountry, Integer specialArea, String waresCode, List<ProductGroup> productGroup, Integer quantity) {
WaresItemVo waresItemVo = WaresItemVo.builder().build();

View File

@ -49,7 +49,8 @@
be.pk_air_postage,be.pk_ocean_postage,bw.pk_id pk_wares,be.is_maker_gift,be.pre_sale_status,
be.pk_special_currency,bw.wares_code, bw.wares_name, bd.is_gift is_gift,
bd.pk_product,bs.price,bs.achieve,bp.pk_supplier,bp.shipping_channel,bp.product_code,
bs.ass_achieve,b.specs_name,b.specs_name_id from bd_wares bw
bs.ass_achieve,b.specs_name,b.specs_name_id
from bd_wares bw
inner join bd_wares_extend be
on bw.pk_id = be.pk_wares
inner join bd_wares_detail bd

View File

@ -327,7 +327,8 @@
select bw.wares_code,bw.cover1,bw.WARES_NAME,be.is_maker_gift,
bs.price price,bs.achieve achieve,bs.ass_achieve ass_achieve,
bd.pk_id pk_wares_detail,bs.pk_id pk_wares_specs_sku,bp.product_name,
bs.spec_cover,#{item.quantity} quantity from BD_WARES bw
bs.spec_cover,#{item.quantity} quantity
from BD_WARES bw
inner join bd_wares_extend be
on bw.pk_id = be.pk_wares
inner join bd_wares_detail bd

View File

@ -27,14 +27,4 @@ public class SysConstants {
*/
public static final String SPECIAL_CODE = "BD68880628";
/**
* 血缘累计业绩30万
*/
public static final BigDecimal TOTAL_AREA_PV = new BigDecimal("300000");
/**
* 小区业绩累计10万
*/
public static final BigDecimal SMALL_AREA_PV = new BigDecimal("100000");
}

View File

@ -20,6 +20,11 @@ public enum EWaresType {
*/
PRODUCT_188(2, "188商品"),
/**
* 3=加购商品
*/
ADD_PURCHASE(3, "加购商品"),
;
/**

View File

@ -157,7 +157,7 @@ public class BdWaresExtend extends BaseEntity {
/**
* 商品类型1=普通商品,2=188商品 -- EWaresType
* 商品类型1=普通商品,2=188商品3=加购商品 -- EWaresType
*/
@TableField("IS_MAKER_GIFT")
private Integer isMakerGift;

View File

@ -153,7 +153,7 @@ public class BdGrade extends BaseEntity {
private String icon;
/**
* 等级数量
* 加购数量
*/
@TableField("BOX_NUMBER")
private Integer boxNumber;

View File

@ -1,28 +1,21 @@
package com.hzs.common.domain.system.ext;
import com.hzs.common.core.annotation.Transaction;
import com.hzs.common.core.constant.EnumsPrefixConstants;
import com.hzs.common.domain.system.config.BdGradeScope;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 等级范围
* </p>
*
* @author zhangjing
* @since 2022-10-24
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class BdGradeScopeExt extends BdGradeScope {
private static final long serialVersionUID = 1L;
/**
* 等级名称
*/
private String pkScopeVal;
private String pkScopeVal;
}