| | |
| | | package com.xiaopeng.account.controller; |
| | | |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xiaopeng.account.model.dto.ReceiveCouponDto; |
| | | import com.xiaopeng.account.model.dto.SendCouponDto; |
| | | import com.xiaopeng.account.model.query.XpUserCouponListQuery; |
| | |
| | | import com.xiaopeng.account.model.vo.XpAppUserCouponTotalVo; |
| | | import com.xiaopeng.account.model.vo.XpAppUserCouponVo; |
| | | import com.xiaopeng.account.service.IXpAppUserCouponService; |
| | | import com.xiaopeng.account.vo.CouponReceiptRecordDto; |
| | | import com.xiaopeng.account.vo.CouponReceiptRecordVo; |
| | | import com.xiaopeng.account.vo.UserCouponListVo; |
| | | import com.xiaopeng.api.dto.account.GetUserCouponDto; |
| | | import com.xiaopeng.api.dto.account.NavigationCouponPickerRequest; |
| | | import com.xiaopeng.api.vo.account.NavigationCouponPickerVo; |
| | | import com.xiaopeng.api.dto.account.UseUserCouponDto; |
| | | import com.xiaopeng.api.feignClient.account.UserResourcesClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpActicityClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpCouponClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpOpenCityClient; |
| | | import com.xiaopeng.api.model.account.XpAppUserCoupon; |
| | | import com.xiaopeng.api.model.operation.XpCoupon; |
| | | import com.xiaopeng.api.query.account.XpAppUserCouponPageListQuery; |
| | | import com.xiaopeng.api.vo.account.NavigationCouponPickerVo; |
| | | import com.xiaopeng.api.vo.account.UserCouponVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.unifiedverification.interceptor.XpClientCheck; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.validation.Valid; |
| | | import java.math.BigDecimal; |
| | |
| | | private final UserResourcesClient userResourcesClient; |
| | | private final XpCouponClient xpCouponClient; |
| | | |
| | | @Resource |
| | | private XpActicityClient xpActicityClient; |
| | | |
| | | |
| | | public XpAppUserCouponController(IXpAppUserCouponService xpAppUserCouponService, XpOpenCityClient xpOpenCityClient, UserResourcesClient userResourcesClient, XpCouponClient xpCouponClient) { |
| | | this.xpAppUserCouponService = xpAppUserCouponService; |
| | |
| | | this.xpCouponClient = xpCouponClient; |
| | | } |
| | | |
| | | @PostMapping("/v1/api/appUserCoupon/pageList") |
| | | @ApiOperation(value = "白名单用户优惠券列表",tags = {"管理后台-白名单-用户优惠券列表"},response = XpAppUserCouponListVo.class) |
| | | public R<PageInfo<XpAppUserCouponListVo>> pageList(@RequestBody XpAppUserCouponPageListQuery query) { |
| | | |
| | | if(StrUtil.isNotBlank(query.getActicityName()) ){ |
| | | List<String> acticityIds = xpActicityClient.findListToIds(query.getActicityName()).getData(); |
| | | query.setActicityIds(acticityIds); |
| | | } |
| | | |
| | | PageInfo<XpAppUserCouponListVo> pageList = xpAppUserCouponService.pageList(query); |
| | | return R.ok(pageList); |
| | | } |
| | | |
| | | @PostMapping("/v1/api/appUserCoupon/deleteByIds") |
| | | @ApiOperation(value = "根据ids删除用户优惠券", tags = {"管理后台-白名单-删除用户优惠券"}) |
| | | public R<Boolean> deleteByIds(@RequestBody XpAppUserCouponPageListQuery query ) { |
| | | if (query.getIds() == null || query.getIds().isEmpty()) { |
| | | return R.fail("ID列表不能为空"); |
| | | } |
| | | boolean result = xpAppUserCouponService.removeByIds(query.getIds()); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @PostMapping("/logan/inner/appUserCoupon/getUserCoupon") |
| | | public R<UserCouponVo> getUserCoupon(@RequestBody GetUserCouponDto dto) { |
| | |
| | | return R.ok(); |
| | | } |
| | | XpAppUserCoupon appUserCoupon = xpAppUserCouponService.getById(dto.getUserCouponId()); |
| | | //状态(1=未使用,2=已使用,3=已过期) |
| | | //状态(1=未使用,2=已使用,3=已过期 0=待领取 4=占用中) |
| | | if(appUserCoupon.getExpirationTime().isAfter(LocalDateTime.now())){ |
| | | appUserCoupon.setStatus(3); |
| | | }else{ |
| | |
| | | } |
| | | return R.ok(null); |
| | | } |
| | | /** |
| | | * 获取即将过期的优惠卷 |
| | | */ |
| | | @GetMapping("/api/v1/mini-program/coupon/findListExpirationTime") |
| | | @ApiOperation(value = "获取即将过期的优惠卷", tags = {"小程序-获取即将过期的优惠卷"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<List<XpAppUserCoupon>> findListExpirationTime(HttpServletRequest request) { |
| | | String uid = request.getHeader("XP-Uid"); |
| | | List<XpAppUserCoupon> listExpirationTime = xpAppUserCouponService.findListExpirationTime(uid); |
| | | return R.ok(listExpirationTime); |
| | | } |
| | | |
| | | /** |
| | | * 获取优惠券列表total |
| | |
| | | } |
| | | |
| | | |
| | | @PostMapping("/api/v1/appUserCoupon/saveInfo_activity") |
| | | @ApiOperation(value = "活动发放优惠券", tags = {"管理后台-活动发放优惠券"}) |
| | | public R<String> saveInfo_activity(@RequestBody UseUserCouponDto dto) { |
| | | xpAppUserCouponService.saveInfo_activity(dto); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 发放优惠券 |
| | | */ |
| | |
| | | xpAppUserCouponService.send(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/logan/inner/appUserCoupon/holding") |
| | | @ApiOperation(value = "查询优惠券是否已有用户使用", tags = {"管理后台-优惠券是否占用"}) |
| | | public R<Boolean> holding(@RequestParam Long couponId) { |
| | | |
| | | return R.ok(xpAppUserCouponService.holding(couponId)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | return R.ok(num); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取优惠券切换页面列表 |
| | | * @param orderMoney |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @GetMapping("/api/v1/mini-program/getUserCouponList") |
| | | @ApiOperation(value = "获取优惠券切换页面列表", tags = {"小程序-获取用户可用优惠券数量"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<UserCouponListVo> getUserCouponList(BigDecimal orderMoney, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | UserCouponListVo userCouponList = xpAppUserCouponService.getUserCouponList(orderMoney, uid); |
| | | return R.ok(userCouponList); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户活动领取的优惠券 |
| | | * @return |
| | | */ |
| | | @PostMapping("/logan/inner/appUserCoupon/getXpAppUserCoupon") |
| | | public R<List<XpAppUserCoupon>> getXpAppUserCoupon(@RequestParam Long activityId){ |
| | | List<XpAppUserCoupon> list = xpAppUserCouponService.list(new QueryWrapper<XpAppUserCoupon>() |
| | | .eq("activity_id", activityId).eq("is_deleted", 0)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/api/v1/activity/getCouponReceiptRecord") |
| | | @ApiOperation(value = "获取活动领取记录", tags = {"管理后台-活动管理"}) |
| | | public R<PageInfo<CouponReceiptRecordDto>> getCouponReceiptRecord(@RequestBody CouponReceiptRecordVo vo){ |
| | | PageInfo<CouponReceiptRecordDto> pageInfo = new PageInfo<CouponReceiptRecordDto>(vo.getPageNum(), vo.getPageSize()); |
| | | List<CouponReceiptRecordDto> couponReceiptRecord = xpAppUserCouponService.getCouponReceiptRecord(pageInfo, vo); |
| | | pageInfo.setRecords(couponReceiptRecord); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | |
| | | |
| | | } |