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;
|
package cn.iocoder.yudao.module.promotion.enums.common;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 营销的商品范围枚举
|
* 营销的商品范围枚举
|
||||||
@ -37,15 +37,15 @@ public enum PromotionProductScopeEnum implements IntArrayValuable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAll(Integer scope) {
|
public static boolean isAll(Integer scope) {
|
||||||
return ObjUtil.equal(scope, ALL.scope);
|
return Objects.equals(scope, ALL.scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSpu(Integer 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) {
|
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;
|
private DiscountActivityService discountActivityService;
|
||||||
@Resource
|
@Resource
|
||||||
private RewardActivityService rewardActivityService;
|
private RewardActivityService rewardActivityService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ProductSpuApi productSpuApi;
|
private ProductSpuApi productSpuApi;
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ public class AppActivityController {
|
|||||||
// 4. 限时折扣活动
|
// 4. 限时折扣活动
|
||||||
getDiscountActivities(spuIds, now, activityList);
|
getDiscountActivities(spuIds, now, activityList);
|
||||||
// 5. 满减送活动
|
// 5. 满减送活动
|
||||||
getRewardActivities(spuIds, now, activityList);
|
getRewardActivityList(spuIds, now, activityList);
|
||||||
return activityList;
|
return activityList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,23 +149,9 @@ public class AppActivityController {
|
|||||||
item.getName(), productMap.get(item.getId()), item.getStartTime(), item.getEndTime())));
|
item.getName(), productMap.get(item.getId()), item.getStartTime(), item.getEndTime())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void buildAppActivityRespVO(RewardActivityDO rewardActivity, Collection<Long> spuIds,
|
private void getRewardActivityList(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||||
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) {
|
|
||||||
// 1.1 获得所有的活动
|
// 1.1 获得所有的活动
|
||||||
List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityByStatusAndDateTimeLt(
|
List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityListByStatusAndDateTimeLt(
|
||||||
CommonStatusEnum.ENABLE.getStatus(), now);
|
CommonStatusEnum.ENABLE.getStatus(), now);
|
||||||
if (CollUtil.isEmpty(rewardActivityList)) {
|
if (CollUtil.isEmpty(rewardActivityList)) {
|
||||||
return;
|
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 当前日期时间
|
* @param dateTime 当前日期时间
|
||||||
* @return 满减送活动列表
|
* @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
|
@Override
|
||||||
public List<RewardActivityDO> getRewardActivityByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime) {
|
public List<RewardActivityDO> getRewardActivityListByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime) {
|
||||||
return rewardActivityMapper.selectListByStatusAndDateTimeLt(status, dateTime);
|
return rewardActivityMapper.selectListByStatusAndDateTimeLt(status, dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,15 +186,14 @@ public interface TradeOrderUpdateService {
|
|||||||
*/
|
*/
|
||||||
void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId);
|
void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId);
|
||||||
|
|
||||||
// TODO 芋艿:拼团取消,不调这个接口哈;
|
// TODO @puhui999:不传递枚举哈。因为 rpc 不好支持。
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消支付订单
|
* 取消支付订单
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param orderId 订单编号
|
* @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
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@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 检验订单存在
|
// 1.1 检验订单存在
|
||||||
TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId);
|
TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId);
|
||||||
if (order == null) {
|
if (order == null) {
|
||||||
@ -875,13 +876,13 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2.1 取消订单
|
// 2.1 取消订单
|
||||||
cancelOrder0(order, cancelTypeEnum);
|
cancelOrder0(order, cancelType);
|
||||||
// 2.2 创建退款单
|
// 2.2 创建退款单
|
||||||
payRefundApi.createRefund(new PayRefundCreateReqDTO()
|
payRefundApi.createRefund(new PayRefundCreateReqDTO()
|
||||||
.setAppKey(tradeOrderProperties.getPayAppKey()).setUserIp(getClientIP()) // 支付应用
|
.setAppKey(tradeOrderProperties.getPayAppKey()).setUserIp(getClientIP()) // 支付应用
|
||||||
.setMerchantOrderId(String.valueOf(order.getId())) // 支付单号
|
.setMerchantOrderId(String.valueOf(order.getId())) // 支付单号
|
||||||
.setMerchantRefundId(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,
|
private void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result,
|
||||||
RewardActivityMatchRespDTO rewardActivity) {
|
RewardActivityMatchRespDTO rewardActivity) {
|
||||||
// 1.1 获得满减送的订单项(商品)列表
|
// 1.1 获得满减送的订单项(商品)列表
|
||||||
List<TradePriceCalculateRespBO.OrderItem> orderItems = filterMatchCouponOrderItems(result, rewardActivity);
|
List<TradePriceCalculateRespBO.OrderItem> orderItems = filterMatchActivityOrderItems(result, rewardActivity);
|
||||||
if (CollUtil.isEmpty(orderItems)) {
|
if (CollUtil.isEmpty(orderItems)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -93,8 +93,9 @@ public class TradeRewardActivityPriceCalculator implements TradePriceCalculator
|
|||||||
* @param rewardActivity 满减送活动
|
* @param rewardActivity 满减送活动
|
||||||
* @return 订单项(商品)列表
|
* @return 订单项(商品)列表
|
||||||
*/
|
*/
|
||||||
private List<TradePriceCalculateRespBO.OrderItem> filterMatchCouponOrderItems(TradePriceCalculateRespBO result,
|
private List<TradePriceCalculateRespBO.OrderItem> filterMatchActivityOrderItems(TradePriceCalculateRespBO result,
|
||||||
RewardActivityMatchRespDTO rewardActivity) {
|
RewardActivityMatchRespDTO rewardActivity) {
|
||||||
|
// TODO @puhui999:是不是得根据类型过滤哈
|
||||||
return filterList(result.getItems(),
|
return filterList(result.getItems(),
|
||||||
orderItem -> CollUtil.contains(rewardActivity.getProductScopeValues(), orderItem.getSpuId()));
|
orderItem -> CollUtil.contains(rewardActivity.getProductScopeValues(), orderItem.getSpuId()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user