分类 退菜退库存模式
This commit is contained in:
@@ -14,7 +14,6 @@ import com.czg.validator.group.UpdateGroup;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -144,6 +143,19 @@ public class ShopProdCategoryController {
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
@PostMapping("upRefundStock")
|
||||
@OperationLog("商品分类-退菜退库存")
|
||||
public CzgResult<Void> enableShopProdCategory(ShopProdCategoryDTO dto) {
|
||||
//效验数据
|
||||
AssertUtil.isNull(dto, "{}不能为空", "id");
|
||||
shopProdCategoryService.upRefundStock(dto.getId(),dto.getIsRefundStock());
|
||||
asyncToBranchShop(dto.getId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
private void asyncToBranchShop(Long id) {
|
||||
long shopId = StpKit.USER.getShopId(0L);
|
||||
long sysUserId = StpKit.USER.getLoginIdAsLong();
|
||||
|
||||
@@ -84,4 +84,8 @@ public class ShopProdCategoryDTO implements Serializable {
|
||||
* 退菜是否退库存 1退菜退库存 2仅退菜不退库存 3每次询问-退菜后弹窗提示
|
||||
*/
|
||||
private Integer refundMode;
|
||||
/**
|
||||
* 退菜是否退回库存
|
||||
*/
|
||||
private Integer isRefundStock;
|
||||
}
|
||||
@@ -68,6 +68,10 @@ public class ShopProdCategory implements Serializable {
|
||||
* 状态 0-禁用 1-启用
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 退菜是否退回库存
|
||||
*/
|
||||
private Integer isRefundStock;
|
||||
/**
|
||||
* 退菜是否退库存 1退菜退库存 2仅退菜不退库存 3每次询问-退菜后弹窗提示
|
||||
*/
|
||||
|
||||
@@ -83,4 +83,8 @@ public interface ShopProdCategoryService extends IService<ShopProdCategory> {
|
||||
*/
|
||||
void enableShopProdCategory(Long id);
|
||||
|
||||
/**
|
||||
* 编辑店铺商品分类的退款库存开关
|
||||
*/
|
||||
void upRefundStock(Long id,Integer isRefundStock);
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.czg.config.RedisCst;
|
||||
import com.czg.constant.MarketConstants;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.constants.SystemConstants;
|
||||
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
||||
import com.czg.enums.ShopTableStatusEnum;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
@@ -662,7 +663,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
Map<Integer, MkShopCouponRecord> couponRecordMap = list.stream().collect(Collectors.toMap(MkShopCouponRecord::getType, t -> t));
|
||||
AtomicBoolean otherCouponShare = new AtomicBoolean(true);
|
||||
couponRecordMap.forEach((type, record) -> {
|
||||
ShopCoupon coupon = checkCoupon(record, param.isVipPrice());
|
||||
ShopCoupon coupon = checkCoupon(record);
|
||||
boolean isTimeDiscountShare = coupon.getDiscountShare() == 1;
|
||||
boolean isVipShare = coupon.getVipPriceShare() == 1;
|
||||
//1-满减券,2-商品兑换券,3-折扣券,4-第二件半价券, 6-买一送一券,
|
||||
@@ -697,9 +698,9 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
}
|
||||
}
|
||||
if (type == 6) {
|
||||
oneGiftCalculate(orderDetails, isAllFoods, couponFoodIds, isTimeDiscountShare, "price_asc".equals(coupon.getUseRule()), oneGiftAmount);
|
||||
oneGiftCalculate(orderDetails, isAllFoods, couponFoodIds, isTimeDiscountShare, oneGiftAmount);
|
||||
} else {
|
||||
twoHalfCalculate(orderDetails, isAllFoods, couponFoodIds, isTimeDiscountShare, "price_asc".equals(coupon.getUseRule()), twoHalfAmount);
|
||||
twoHalfCalculate(orderDetails, isAllFoods, couponFoodIds, isTimeDiscountShare, twoHalfAmount);
|
||||
}
|
||||
} else if (type == 1 || type == 3) {//1-满减券 3-折扣券
|
||||
if (!otherCouponShare.get()) {
|
||||
@@ -740,16 +741,11 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
/**
|
||||
* 优惠券通用校验规则 不包括门槛校验
|
||||
*
|
||||
* @param isVipPrice 是否使用会员价
|
||||
*/
|
||||
private ShopCoupon checkCoupon(MkShopCouponRecord record, boolean isVipPrice) {
|
||||
private ShopCoupon checkCoupon(MkShopCouponRecord record) {
|
||||
ShopCoupon coupon = couponService.getById(record.getCouponId());
|
||||
AssertUtil.isNull(coupon, "生成支付订单失败,券信息不存在");
|
||||
// if (isVipPrice && coupon.getVipPriceShare() != 1) {
|
||||
// throw new CzgException("生成支付订单失败,券:" + coupon.getTitle() + "与会员价不共享");
|
||||
// }
|
||||
isUseLimit(coupon, record);
|
||||
// isUseTime(coupon);
|
||||
return coupon;
|
||||
}
|
||||
|
||||
@@ -880,15 +876,12 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
* 买一送一优惠券计算
|
||||
*/
|
||||
private void oneGiftCalculate(List<OrderDetail> orderDetails, boolean isAllFoods, List<Long> couponFoodIds,
|
||||
boolean isTimeDiscountShare, boolean isAsc, BigDecimalDTO oneGiftAmount) {
|
||||
boolean isAsc, BigDecimalDTO oneGiftAmount) {
|
||||
orderDetails = getDetailsSort(orderDetails, isAsc);
|
||||
for (OrderDetail detail : orderDetails) {
|
||||
if ((isAllFoods || couponFoodIds.contains(detail.getProductId()))
|
||||
&& detail.getUnitPrice().compareTo(BigDecimal.ZERO) > 0
|
||||
&& detail.getNum().subtract(detail.getReturnNum()).subtract(detail.getCouponNum()).compareTo(BigDecimal.TWO) >= 0) {
|
||||
// if (isTimeDiscountShare && detail.getIsTimeDiscount() == 1) {
|
||||
// continue;
|
||||
// }
|
||||
detail.setCouponNum(detail.getCouponNum().add(BigDecimal.ONE));
|
||||
detail.setDiscountAmount(detail.getDiscountAmount().add(detail.getUnitPrice()));
|
||||
detail.setPayAmount(detail.getPayAmount().subtract(detail.getUnitPrice()));
|
||||
@@ -902,15 +895,13 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
* 第二件半价优惠券计算
|
||||
*/
|
||||
private void twoHalfCalculate(List<OrderDetail> orderDetails, boolean isAllFoods, List<Long> couponFoodIds,
|
||||
boolean isTimeDiscountShare, boolean isAsc, BigDecimalDTO oneGiftAmount) {
|
||||
boolean isAsc, BigDecimalDTO oneGiftAmount) {
|
||||
orderDetails = getDetailsSort(orderDetails, isAsc);
|
||||
for (OrderDetail detail : orderDetails) {
|
||||
if ((isAllFoods || couponFoodIds.contains(detail.getProductId()))
|
||||
&& detail.getUnitPrice().compareTo(BigDecimal.ZERO) > 0
|
||||
&& detail.getNum().subtract(detail.getReturnNum()).subtract(detail.getCouponNum()).compareTo(BigDecimal.TWO) >= 0) {
|
||||
// if (isTimeDiscountShare && detail.getIsTimeDiscount() == 1) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
detail.setHalfPriceCouponNum(BigDecimal.ONE);
|
||||
BigDecimal halfPrice = detail.getUnitPrice().divide(new BigDecimal("2"), 2, RoundingMode.FLOOR);
|
||||
detail.setDiscountAmount(detail.getDiscountAmount().add(halfPrice));
|
||||
@@ -1279,7 +1270,6 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
|
||||
// 保存消息参数(避免闭包中引用的变量被修改)
|
||||
final Long orderId = orderInfo.getId();
|
||||
final boolean isPrint = orderInfo.getIsPrint() == 1;
|
||||
final String payMode = orderInfo.getPayMode();
|
||||
|
||||
// 【关键改造】注册事务同步器,在事务提交后发送消息
|
||||
@@ -1863,14 +1853,22 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
//分类
|
||||
if (!categoryMap.containsKey(product.getCategoryId())) {
|
||||
refundMode = shopProdCategoryService.getOneAs(new QueryWrapper().select(ShopProdCategory::getRefundMode)
|
||||
.eq(ShopProdCategory::getShopId, shopInfo.getId()).eq(ShopProdCategory::getId, product.getCategoryId()), Integer.class);
|
||||
.eq(ShopProdCategory::getShopId, shopInfo.getId()).eq(ShopProdCategory::getIsRefundStock, SystemConstants.OneZero.ONE)
|
||||
.eq(ShopProdCategory::getId, product.getCategoryId()), Integer.class);
|
||||
if (refundMode == null) {
|
||||
refundMode = 2;
|
||||
}
|
||||
categoryMap.put(product.getCategoryId(), refundMode);
|
||||
} else {
|
||||
refundMode = categoryMap.get(product.getCategoryId());
|
||||
}
|
||||
} else if (shopInfo.getRefundMode().equals(2)) {
|
||||
//单商品
|
||||
refundMode = product.getRefundMode();
|
||||
if (product.getIsRefundStock().equals(SystemConstants.OneZero.ONE)) {
|
||||
refundMode = product.getRefundMode();
|
||||
} else {
|
||||
refundMode = 2;
|
||||
}
|
||||
} else {
|
||||
log.error("退菜模式错误 店铺{},退款模式{},商品Id{}分类Id{}", shopInfo.getShopName(), shopInfo.getRefundMode(), product.getId(), product.getCategoryId());
|
||||
throw new CzgException("退菜模式错误");
|
||||
|
||||
@@ -149,4 +149,14 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
|
||||
productService.clearProductCache(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void upRefundStock(Long id, Integer isRefundStock) {
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
ShopProdCategory prodCategory = new ShopProdCategory();
|
||||
prodCategory.setIsRefundStock(isRefundStock);
|
||||
update(prodCategory, query().eq(ShopProdCategory::getId, id).eq(ShopProdCategory::getShopId, shopId));
|
||||
productService.clearProductCache(id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user