mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
【代码评审】商城:取消拼团的支付单
This commit is contained in:
parent
c4943e97c7
commit
cccad2c6c1
@ -1,11 +1,11 @@
|
||||
package cn.iocoder.yudao.module.promotion.enums.common;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 营销的商品范围枚举
|
||||
@ -37,15 +37,15 @@ public enum PromotionProductScopeEnum implements IntArrayValuable {
|
||||
}
|
||||
|
||||
public static boolean isAll(Integer scope) {
|
||||
return ObjUtil.equal(scope, ALL.scope);
|
||||
return Objects.equals(scope, ALL.scope);
|
||||
}
|
||||
|
||||
public static boolean isSpu(Integer scope) {
|
||||
return ObjUtil.equal(scope, SPU.scope);
|
||||
return Objects.equals(scope, SPU.scope);
|
||||
}
|
||||
|
||||
public static boolean isCategory(Integer scope) {
|
||||
return ObjUtil.equal(scope, CATEGORY.scope);
|
||||
return Objects.equals(scope, CATEGORY.scope);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ public class AppActivityController {
|
||||
private DiscountActivityService discountActivityService;
|
||||
@Resource
|
||||
private RewardActivityService rewardActivityService;
|
||||
|
||||
@Resource
|
||||
private ProductSpuApi productSpuApi;
|
||||
|
||||
@ -91,7 +92,7 @@ public class AppActivityController {
|
||||
// 4. 限时折扣活动
|
||||
getDiscountActivities(spuIds, now, activityList);
|
||||
// 5. 满减送活动
|
||||
getRewardActivities(spuIds, now, activityList);
|
||||
getRewardActivityList(spuIds, now, activityList);
|
||||
return activityList;
|
||||
}
|
||||
|
||||
@ -148,23 +149,9 @@ public class AppActivityController {
|
||||
item.getName(), productMap.get(item.getId()), item.getStartTime(), item.getEndTime())));
|
||||
}
|
||||
|
||||
private static void buildAppActivityRespVO(RewardActivityDO rewardActivity, Collection<Long> spuIds,
|
||||
List<AppActivityRespVO> activityList) {
|
||||
for (Long spuId : spuIds) {
|
||||
// 校验商品是否已经加入过活动
|
||||
if (anyMatch(activityList, appActivity -> ObjUtil.equal(appActivity.getId(), rewardActivity.getId()) &&
|
||||
ObjUtil.equal(appActivity.getSpuId(), spuId))) {
|
||||
continue;
|
||||
}
|
||||
activityList.add(new AppActivityRespVO(rewardActivity.getId(),
|
||||
PromotionTypeEnum.REWARD_ACTIVITY.getType(), rewardActivity.getName(), spuId,
|
||||
rewardActivity.getStartTime(), rewardActivity.getEndTime()));
|
||||
}
|
||||
}
|
||||
|
||||
private void getRewardActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||
private void getRewardActivityList(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||
// 1.1 获得所有的活动
|
||||
List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityByStatusAndDateTimeLt(
|
||||
List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityListByStatusAndDateTimeLt(
|
||||
CommonStatusEnum.ENABLE.getStatus(), now);
|
||||
if (CollUtil.isEmpty(rewardActivityList)) {
|
||||
return;
|
||||
@ -196,4 +183,18 @@ public class AppActivityController {
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildAppActivityRespVO(RewardActivityDO rewardActivity, Collection<Long> spuIds,
|
||||
List<AppActivityRespVO> activityList) {
|
||||
for (Long spuId : spuIds) {
|
||||
// 校验商品是否已经加入过活动
|
||||
if (anyMatch(activityList, appActivity -> ObjUtil.equal(appActivity.getId(), rewardActivity.getId()) &&
|
||||
ObjUtil.equal(appActivity.getSpuId(), spuId))) {
|
||||
continue;
|
||||
}
|
||||
activityList.add(new AppActivityRespVO(rewardActivity.getId(),
|
||||
PromotionTypeEnum.REWARD_ACTIVITY.getType(), rewardActivity.getName(), spuId,
|
||||
rewardActivity.getStartTime(), rewardActivity.getEndTime()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -79,6 +79,6 @@ public interface RewardActivityService {
|
||||
* @param dateTime 当前日期时间
|
||||
* @return 满减送活动列表
|
||||
*/
|
||||
List<RewardActivityDO> getRewardActivityByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime);
|
||||
List<RewardActivityDO> getRewardActivityListByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime);
|
||||
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ public class RewardActivityServiceImpl implements RewardActivityService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RewardActivityDO> getRewardActivityByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime) {
|
||||
public List<RewardActivityDO> getRewardActivityListByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime) {
|
||||
return rewardActivityMapper.selectListByStatusAndDateTimeLt(status, dateTime);
|
||||
}
|
||||
|
||||
|
@ -186,15 +186,14 @@ public interface TradeOrderUpdateService {
|
||||
*/
|
||||
void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId);
|
||||
|
||||
// TODO 芋艿:拼团取消,不调这个接口哈;
|
||||
|
||||
// TODO @puhui999:不传递枚举哈。因为 rpc 不好支持。
|
||||
/**
|
||||
* 取消支付订单
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param orderId 订单编号
|
||||
* @param cancelTypeEnum 取消类型
|
||||
* @param cancelType 取消类型
|
||||
*/
|
||||
void cancelPaidOrder(Long userId, Long orderId, TradeOrderCancelTypeEnum cancelTypeEnum);
|
||||
void cancelPaidOrder(Long userId, Long orderId, TradeOrderCancelTypeEnum cancelType);
|
||||
|
||||
}
|
||||
|
@ -858,7 +858,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancelPaidOrder(Long userId, Long orderId, TradeOrderCancelTypeEnum cancelTypeEnum) {
|
||||
public void cancelPaidOrder(Long userId, Long orderId, TradeOrderCancelTypeEnum cancelType) {
|
||||
// TODO @puhui999:这里校验下 cancelType 只允许拼团关闭;
|
||||
// 1.1 检验订单存在
|
||||
TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId);
|
||||
if (order == null) {
|
||||
@ -875,13 +876,13 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
}
|
||||
|
||||
// 2.1 取消订单
|
||||
cancelOrder0(order, cancelTypeEnum);
|
||||
cancelOrder0(order, cancelType);
|
||||
// 2.2 创建退款单
|
||||
payRefundApi.createRefund(new PayRefundCreateReqDTO()
|
||||
.setAppKey(tradeOrderProperties.getPayAppKey()).setUserIp(getClientIP()) // 支付应用
|
||||
.setMerchantOrderId(String.valueOf(order.getId())) // 支付单号
|
||||
.setMerchantRefundId(String.valueOf(order.getId()))
|
||||
.setReason(cancelTypeEnum.getName()).setPrice(order.getPayPrice()));// 价格信息
|
||||
.setReason(cancelType.getName()).setPrice(order.getPayPrice()));// 价格信息
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,7 @@ public class TradeRewardActivityPriceCalculator implements TradePriceCalculator
|
||||
private void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result,
|
||||
RewardActivityMatchRespDTO rewardActivity) {
|
||||
// 1.1 获得满减送的订单项(商品)列表
|
||||
List<TradePriceCalculateRespBO.OrderItem> orderItems = filterMatchCouponOrderItems(result, rewardActivity);
|
||||
List<TradePriceCalculateRespBO.OrderItem> orderItems = filterMatchActivityOrderItems(result, rewardActivity);
|
||||
if (CollUtil.isEmpty(orderItems)) {
|
||||
return;
|
||||
}
|
||||
@ -93,8 +93,9 @@ public class TradeRewardActivityPriceCalculator implements TradePriceCalculator
|
||||
* @param rewardActivity 满减送活动
|
||||
* @return 订单项(商品)列表
|
||||
*/
|
||||
private List<TradePriceCalculateRespBO.OrderItem> filterMatchCouponOrderItems(TradePriceCalculateRespBO result,
|
||||
private List<TradePriceCalculateRespBO.OrderItem> filterMatchActivityOrderItems(TradePriceCalculateRespBO result,
|
||||
RewardActivityMatchRespDTO rewardActivity) {
|
||||
// TODO @puhui999:是不是得根据类型过滤哈
|
||||
return filterList(result.getItems(),
|
||||
orderItem -> CollUtil.contains(rewardActivity.getProductScopeValues(), orderItem.getSpuId()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user