优惠券发放
This commit is contained in:
parent
6756f35db6
commit
537aeb09a1
|
|
@ -3,9 +3,7 @@ package com.czg.controller.admin;
|
|||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.market.dto.MkCouponGiftDTO;
|
||||
import com.czg.market.dto.MkShopCouponRecordDTO;
|
||||
import com.czg.market.dto.ShopCouponDTO;
|
||||
import com.czg.market.dto.*;
|
||||
import com.czg.market.service.MkCouponGiftService;
|
||||
import com.czg.market.service.MkShopCouponRecordService;
|
||||
import com.czg.market.service.ShopCouponService;
|
||||
|
|
@ -170,4 +168,13 @@ public class ACouponController {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 券发放
|
||||
* @return 是否发放成功
|
||||
*/
|
||||
@PostMapping("/grant")
|
||||
public CzgResult<Boolean> rewardCoupon(@Validated @RequestBody MkRewardCouponDTO rewardCouponDTO) {
|
||||
return CzgResult.success(couponRecordService.grant(rewardCouponDTO.getShopId() != null ? rewardCouponDTO.getShopId() : StpKit.USER.getShopId(), rewardCouponDTO));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||
.notMatch("/notify/**")
|
||||
.notMatch("/admin/auth/**")
|
||||
.notMatch("/admin/shopMsgPush/subscribe/**")
|
||||
.notMatch("/admin/coupon/grant")
|
||||
.check(r -> MyStpLogic.ADMIN_LOGIC.checkLogin());
|
||||
|
||||
})).addPathPatterns("/**");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.czg.market.dto;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class MkRewardCouponDTO implements Serializable {
|
||||
@NotNull(message = "用户ID不能为空")
|
||||
private Long userId;
|
||||
@NotNull(message = "优惠券ID不能为空")
|
||||
private Long couponId;
|
||||
@NotNull(message = "数量不能为空")
|
||||
@Min(value = 1, message = "数量不能小于1")
|
||||
private Integer num;
|
||||
|
||||
private Long shopId;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.market.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
|
@ -11,6 +12,7 @@ import java.io.Serializable;
|
|||
* @description
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class MkShopCouponGiftDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.czg.market.service;
|
|||
import com.czg.account.dto.QueryReceiveDto;
|
||||
import com.czg.account.vo.CouponReceiveVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
import com.czg.market.dto.MkRewardCouponDTO;
|
||||
import com.czg.market.dto.MkShopCouponGiftDTO;
|
||||
import com.czg.market.dto.MkShopCouponRecordDTO;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
|
|
@ -42,8 +43,13 @@ public interface MkShopCouponRecordService extends IService<MkShopCouponRecord>
|
|||
*/
|
||||
void receiveCoupon(MkShopCouponGiftDTO giftDTO, Integer number, boolean isLimit);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用户优惠券 失效/删除
|
||||
*/
|
||||
void deleteRecord(Long id);
|
||||
|
||||
Boolean grant(Long shopId, MkRewardCouponDTO rewardCouponDTO);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.czg.account.service.UserInfoService;
|
|||
import com.czg.account.vo.CouponReceiveVo;
|
||||
import com.czg.account.vo.UserCouponVo;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkRewardCouponDTO;
|
||||
import com.czg.market.dto.MkShopCouponGiftDTO;
|
||||
import com.czg.market.dto.MkShopCouponRecordDTO;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
|
|
@ -199,4 +200,15 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
|||
public void deleteRecord(Long id) {
|
||||
updateById(new MkShopCouponRecord().setId(id).setIsDel(1), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean grant(Long shopId, MkRewardCouponDTO rewardCouponDTO) {
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getUserId, rewardCouponDTO.getUserId()));
|
||||
MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO().setCouponId(rewardCouponDTO.getCouponId())
|
||||
.setShopId(shopId)
|
||||
.setShopUserId(shopUser == null ? null : shopUser.getId())
|
||||
.setSource("后台发放");
|
||||
receiveCoupon(giftDTO, rewardCouponDTO.getNum(), false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue