mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-19 04:31:53 +08:00
Merge remote-tracking branch 'yudao/develop' into develop
This commit is contained in:
@@ -33,6 +33,9 @@ public class CouponTemplateBaseVO {
|
||||
@NotNull(message = "优惠劵名不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "优惠券说明", example = "优惠券使用说明")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "发行总量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") // -1 - 则表示不限制发放数量
|
||||
@NotNull(message = "发行总量不能为空")
|
||||
private Integer totalCount;
|
||||
|
@@ -1,8 +1,5 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -20,6 +17,9 @@ public class AppCouponTemplateRespVO {
|
||||
@Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "优惠券说明", example = "优惠券使用说明")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制
|
||||
private Integer takeLimitCount;
|
||||
|
||||
|
@@ -40,6 +40,10 @@ public class CouponTemplateDO extends BaseDO {
|
||||
* 优惠劵名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 优惠券说明
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
@@ -158,9 +162,9 @@ public class CouponTemplateDO extends BaseDO {
|
||||
* 使用优惠券的次数
|
||||
*/
|
||||
private Integer useCount;
|
||||
|
||||
// ========== 统计信息 END ==========
|
||||
|
||||
// TODO 芋艿:领取开始时间、领取结束时间
|
||||
|
||||
// TODO 芋艿:要不要加描述
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.github.yulichang.toolkit.MPJWrappers;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -108,11 +107,4 @@ public interface CouponMapper extends BaseMapperX<CouponDO> {
|
||||
);
|
||||
}
|
||||
|
||||
default List<CouponDO> selectListByIdAndUserIdAndTakeType(Long couponId, Long userId, Integer takeType) {
|
||||
return selectList(new LambdaQueryWrapper<CouponDO>()
|
||||
.eq(CouponDO::getId, couponId)
|
||||
.eq(CouponDO::getUserId, userId)
|
||||
.eq(CouponDO::getTakeType, takeType));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -123,7 +123,7 @@ public interface CouponService {
|
||||
*/
|
||||
int expireCoupon();
|
||||
|
||||
//======================= 查询相关 =======================
|
||||
// ======================= 查询相关 =======================
|
||||
|
||||
/**
|
||||
* 获得未使用的优惠劵数量
|
||||
|
@@ -179,7 +179,7 @@ public class CouponServiceImpl implements CouponService {
|
||||
// 循环收回
|
||||
for (Long couponId : giveCouponIds) {
|
||||
try {
|
||||
getSelf().takeBackCoupon(couponId, userId, CouponTakeTypeEnum.ADMIN);
|
||||
getSelf().invalidateCoupon(couponId, userId);
|
||||
} catch (Exception e) {
|
||||
log.error("[invalidateCouponsByAdmin][couponId({}) 收回优惠券失败]", couponId, e);
|
||||
}
|
||||
@@ -191,10 +191,9 @@ public class CouponServiceImpl implements CouponService {
|
||||
*
|
||||
* @param couponId 模版编号
|
||||
* @param userId 用户编号
|
||||
* @param takeType 领取方式
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void takeBackCoupon(Long couponId, Long userId, CouponTakeTypeEnum takeType) {
|
||||
public void invalidateCoupon(Long couponId, Long userId) {
|
||||
// 1.1 校验优惠券
|
||||
CouponDO coupon = couponMapper.selectByIdAndUserId(couponId, userId);
|
||||
if (coupon == null) {
|
||||
@@ -205,19 +204,15 @@ public class CouponServiceImpl implements CouponService {
|
||||
if (couponTemplate == null) {
|
||||
throw exception(COUPON_TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
// 1.3 校验领取方式
|
||||
if (ObjectUtil.notEqual(couponTemplate.getTakeType(), takeType.getValue())) {
|
||||
throw exception(COUPON_TEMPLATE_CANNOT_TAKE);
|
||||
}
|
||||
|
||||
// 2.1 校验优惠券是否已经使用,如若使用则先不管
|
||||
// 1.3 校验优惠券是否已经使用,如若使用则先不管
|
||||
if (ObjUtil.equal(coupon.getStatus(), CouponStatusEnum.USED.getStatus())) {
|
||||
log.info("[invalidateCoupon][coupon({}) 已经使用,无法作废]", couponId);
|
||||
return;
|
||||
}
|
||||
// 2.2 减少优惠劵模板的领取数量
|
||||
|
||||
// 2.1 减少优惠劵模板的领取数量
|
||||
couponTemplateService.updateCouponTemplateTakeCount(couponTemplate.getId(), -1);
|
||||
// 2.3 批量作废优惠劵
|
||||
// TODO @puhui999:捉摸了下,貌似搞成逻辑删除好了?不然好多地方的 status 都要做一些变动。可能未来加个 invalidateType 来标识,是管理后台删除,还是取消回收。或者优惠劵的 change log 可能更好。
|
||||
// 2.2 作废优惠劵
|
||||
couponMapper.deleteById(couponId);
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.trade.controller.app.aftersale;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO;
|
||||
@@ -12,14 +12,11 @@ import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@@ -35,6 +32,7 @@ public class AppAfterSaleController {
|
||||
|
||||
@GetMapping(value = "/page")
|
||||
@Operation(summary = "获得售后分页")
|
||||
@PreAuthenticated
|
||||
public CommonResult<PageResult<AppAfterSaleRespVO>> getAfterSalePage(PageParam pageParam) {
|
||||
return success(AfterSaleConvert.INSTANCE.convertPage02(
|
||||
afterSaleService.getAfterSalePage(getLoginUserId(), pageParam)));
|
||||
@@ -43,18 +41,21 @@ public class AppAfterSaleController {
|
||||
@GetMapping(value = "/get")
|
||||
@Operation(summary = "获得售后订单")
|
||||
@Parameter(name = "id", description = "售后编号", required = true, example = "1")
|
||||
@PreAuthenticated
|
||||
public CommonResult<AppAfterSaleRespVO> getAfterSale(@RequestParam("id") Long id) {
|
||||
return success(AfterSaleConvert.INSTANCE.convert(afterSaleService.getAfterSale(getLoginUserId(), id)));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/create")
|
||||
@Operation(summary = "申请售后")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> createAfterSale(@RequestBody AppAfterSaleCreateReqVO createReqVO) {
|
||||
return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping(value = "/delivery")
|
||||
@Operation(summary = "退回货物")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> deliveryAfterSale(@RequestBody AppAfterSaleDeliveryReqVO deliveryReqVO) {
|
||||
afterSaleService.deliveryAfterSale(getLoginUserId(), deliveryReqVO);
|
||||
return success(true);
|
||||
@@ -63,6 +64,7 @@ public class AppAfterSaleController {
|
||||
@DeleteMapping(value = "/cancel")
|
||||
@Operation(summary = "取消售后")
|
||||
@Parameter(name = "id", description = "售后编号", required = true, example = "1")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> cancelAfterSale(@RequestParam("id") Long id) {
|
||||
afterSaleService.cancelAfterSale(getLoginUserId(), id);
|
||||
return success(true);
|
||||
|
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.controller.app.aftersale;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.log.AppAfterSaleLogRespVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO;
|
||||
import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService;
|
||||
@@ -33,6 +34,7 @@ public class AppAfterSaleLogController {
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得售后日志列表")
|
||||
@Parameter(name = "afterSaleId", description = "售后编号", required = true, example = "1")
|
||||
@PreAuthenticated
|
||||
public CommonResult<List<AppAfterSaleLogRespVO>> getAfterSaleLogList(
|
||||
@RequestParam("afterSaleId") Long afterSaleId) {
|
||||
List<AfterSaleLogDO> logs = afterSaleLogService.getAfterSaleLogList(afterSaleId);
|
||||
|
@@ -45,6 +45,7 @@ public class AppBrokerageRecordController {
|
||||
|
||||
@GetMapping("/get-product-brokerage-price")
|
||||
@Operation(summary = "获得商品的分销金额")
|
||||
@PreAuthenticated
|
||||
public CommonResult<AppBrokerageProductPriceRespVO> getProductBrokeragePrice(@RequestParam("spuId") Long spuId) {
|
||||
return success(brokerageRecordService.calculateProductBrokeragePrice(getLoginUserId(), spuId));
|
||||
}
|
||||
|
@@ -133,6 +133,7 @@ public class AppBrokerageUserController {
|
||||
@GetMapping("/get-rank-by-price")
|
||||
@Operation(summary = "获得分销用户排行(基于佣金)")
|
||||
@Parameter(name = "times", description = "时间段", required = true)
|
||||
@PreAuthenticated
|
||||
public CommonResult<Integer> getRankByPrice(
|
||||
@RequestParam("times") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) LocalDateTime[] times) {
|
||||
return success(brokerageRecordService.getUserRankByPrice(getLoginUserId(), times));
|
||||
|
@@ -1,27 +0,0 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.app.delivery;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.config.AppDeliveryConfigRespVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - 配送配置")
|
||||
@RestController
|
||||
@RequestMapping("/trade/delivery/config")
|
||||
@Validated
|
||||
public class AppDeliverConfigController {
|
||||
|
||||
// TODO @芋艿:这里后面干掉,合并到 AppTradeConfigController 中
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得配送配置")
|
||||
public CommonResult<AppDeliveryConfigRespVO> getDeliveryConfig() {
|
||||
return success(new AppDeliveryConfigRespVO().setPickUpEnable(true).setTencentLbsKey("123456"));
|
||||
}
|
||||
|
||||
}
|
@@ -80,6 +80,7 @@ public class AppTradeOrderController {
|
||||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得交易订单")
|
||||
@Parameter(name = "id", description = "交易订单编号")
|
||||
@PreAuthenticated
|
||||
public CommonResult<AppTradeOrderDetailRespVO> getOrder(@RequestParam("id") Long id) {
|
||||
// 查询订单
|
||||
TradeOrderDO order = tradeOrderQueryService.getOrder(getLoginUserId(), id);
|
||||
@@ -99,6 +100,7 @@ public class AppTradeOrderController {
|
||||
@GetMapping("/get-express-track-list")
|
||||
@Operation(summary = "获得交易订单的物流轨迹")
|
||||
@Parameter(name = "id", description = "交易订单编号")
|
||||
@PreAuthenticated
|
||||
public CommonResult<List<AppOrderExpressTrackRespDTO>> getOrderExpressTrackList(@RequestParam("id") Long id) {
|
||||
return success(TradeOrderConvert.INSTANCE.convertList02(
|
||||
tradeOrderQueryService.getExpressTrackList(id, getLoginUserId())));
|
||||
@@ -106,6 +108,7 @@ public class AppTradeOrderController {
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得交易订单分页")
|
||||
@PreAuthenticated
|
||||
public CommonResult<PageResult<AppTradeOrderPageItemRespVO>> getOrderPage(AppTradeOrderPageReqVO reqVO) {
|
||||
// 查询订单
|
||||
PageResult<TradeOrderDO> pageResult = tradeOrderQueryService.getOrderPage(getLoginUserId(), reqVO);
|
||||
@@ -118,6 +121,7 @@ public class AppTradeOrderController {
|
||||
|
||||
@GetMapping("/get-count")
|
||||
@Operation(summary = "获得交易订单数量")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Map<String, Long>> getOrderCount() {
|
||||
Map<String, Long> orderCount = Maps.newLinkedHashMapWithExpectedSize(5);
|
||||
// 全部
|
||||
@@ -142,6 +146,7 @@ public class AppTradeOrderController {
|
||||
@PutMapping("/receive")
|
||||
@Operation(summary = "确认交易订单收货")
|
||||
@Parameter(name = "id", description = "交易订单编号")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> receiveOrder(@RequestParam("id") Long id) {
|
||||
tradeOrderUpdateService.receiveOrderByMember(getLoginUserId(), id);
|
||||
return success(true);
|
||||
@@ -150,6 +155,7 @@ public class AppTradeOrderController {
|
||||
@DeleteMapping("/cancel")
|
||||
@Operation(summary = "取消交易订单")
|
||||
@Parameter(name = "id", description = "交易订单编号")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> cancelOrder(@RequestParam("id") Long id) {
|
||||
tradeOrderUpdateService.cancelOrderByMember(getLoginUserId(), id);
|
||||
return success(true);
|
||||
@@ -158,6 +164,7 @@ public class AppTradeOrderController {
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除交易订单")
|
||||
@Parameter(name = "id", description = "交易订单编号")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> deleteOrder(@RequestParam("id") Long id) {
|
||||
tradeOrderUpdateService.deleteOrder(getLoginUserId(), id);
|
||||
return success(true);
|
||||
@@ -168,6 +175,7 @@ public class AppTradeOrderController {
|
||||
@GetMapping("/item/get")
|
||||
@Operation(summary = "获得交易订单项")
|
||||
@Parameter(name = "id", description = "交易订单项编号")
|
||||
@PreAuthenticated
|
||||
public CommonResult<AppTradeOrderItemRespVO> getOrderItem(@RequestParam("id") Long id) {
|
||||
TradeOrderItemDO item = tradeOrderQueryService.getOrderItem(getLoginUserId(), id);
|
||||
return success(TradeOrderConvert.INSTANCE.convert03(item));
|
||||
@@ -175,6 +183,7 @@ public class AppTradeOrderController {
|
||||
|
||||
@PostMapping("/item/create-comment")
|
||||
@Operation(summary = "创建交易订单项的评价")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> createOrderItemComment(@RequestBody AppTradeOrderItemCommentCreateReqVO createReqVO) {
|
||||
return success(tradeOrderUpdateService.createOrderItemCommentByMember(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
@@ -296,10 +296,11 @@ public class TradeOrderDO extends BaseDO {
|
||||
*/
|
||||
private Integer vipPrice;
|
||||
|
||||
// TODO @puhui999:我们要不要把相关的字段,定义的更明确一点?例如说,giveCouponTemplateCounts 赠送的优惠劵模版数量,或者 giveCouponCounts 赠送的优惠劵数量。感受上,Coupons 和 Map 有点点重叠哈。
|
||||
/**
|
||||
* 赠送的优惠劵
|
||||
*
|
||||
* key: 优惠劵编号
|
||||
* key: 优惠劵模版编号
|
||||
* value:对应的优惠券数量
|
||||
*
|
||||
* 目的:用于订单支付后赠送优惠券
|
||||
|
@@ -892,15 +892,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
|
||||
@Override
|
||||
public void updateOrderGiveCouponIds(Long userId, Long orderId, List<Long> giveCouponIds) {
|
||||
// 1.1 检验订单存在
|
||||
// 1. 检验订单存在
|
||||
TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId);
|
||||
if (order == null) {
|
||||
throw exception(ORDER_NOT_FOUND);
|
||||
}
|
||||
// 1.2 校验订单是否支付
|
||||
if (!order.getPayStatus()) {
|
||||
throw exception(ORDER_CANCEL_PAID_FAIL, "已支付");
|
||||
}
|
||||
|
||||
// 2. 更新订单赠送的优惠券编号列表
|
||||
tradeOrderMapper.updateById(new TradeOrderDO().setId(orderId).setGiveCouponIds(giveCouponIds));
|
||||
|
Reference in New Issue
Block a user