| | |
| | | package cn.lili.controller.lmk; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.query.ActivityQuery; |
| | | import cn.lili.modules.lmk.service.CouponVirtualService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @RestController |
| | | @RequestMapping("/buyer/lmk/coupon/card") |
| | | public class CouponCardController { |
| | | private CouponVirtualService couponVirtualService; |
| | | private final CouponVirtualService couponVirtualService; |
| | | |
| | | @PostMapping("/{cardId}") |
| | | @ApiOperation(value = "领取购物卡", notes = "领取购物卡") |
| | |
| | | return couponVirtualService.tackCardById(cardId); |
| | | } |
| | | @PostMapping("/changShareStatus/{cardId}") |
| | | @ApiOperation(value = "领取购物卡", notes = "领取购物卡") |
| | | @ApiOperation(value = "更改分享状态", notes = "更改分享状态") |
| | | public Result changShareStatus(@PathVariable String cardId){ |
| | | return couponVirtualService.changShareStatus(cardId); |
| | | } |
| | | @PostMapping("/couponCardInfo/{cardId}") |
| | | @ApiOperation(value = "获取领取信息", notes = "获取领取信息") |
| | | public Result couponCardInfo(@PathVariable String cardId){ |
| | | return couponVirtualService.couponCardInfo(cardId); |
| | | } |
| | | } |
New file |
| | |
| | | package cn.lili.controller.lmk; |
| | | |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.query.CouponVirtualQuery; |
| | | import cn.lili.modules.lmk.service.CouponVirtualService; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | 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; |
| | | |
| | | /** |
| | | * lmk-shop-java |
| | | * 虚拟优惠卷商品 |
| | | * |
| | | * @author : zxl |
| | | * @date : 2025-09-12 09:41 |
| | | **/ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/buyer/lmk/couponVirtual") |
| | | public class CouponVirtualController { |
| | | |
| | | private final CouponVirtualService couponVirtualService; |
| | | |
| | | @GetMapping() |
| | | @ApiOperation(value = "列表", notes = "列表") |
| | | public Result getPage(CouponVirtualQuery query){ |
| | | //更具订单id查询 |
| | | return couponVirtualService.page(query); |
| | | } |
| | | |
| | | } |
| | |
| | | Map<String, Object> specMap = new LinkedHashMap<>(); |
| | | |
| | | // 原始规格项 |
| | | String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight", "alertQuantity"}; |
| | | String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight", "alertQuantity","couponId","couponName"}; |
| | | //获取规格信息 |
| | | for (Map.Entry<String, Object> spec : skuInfo.entrySet()) { |
| | | //保存新增规格信息 |
| | |
| | | @Data |
| | | @ApiModel(value = "CouponVirtual查询参数", description = "虚拟商品优惠卷查询参数") |
| | | public class CouponVirtualQuery extends AbsQuery { |
| | | private String orderId; |
| | | private String userNickName; |
| | | |
| | | private String skuName; |
| | | } |
| | | |
| | |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.modules.lmk.domain.entity.CouponVirtual; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | |
| | | private String claimStatus; |
| | | |
| | | |
| | | private Boolean deleteFlag; |
| | | |
| | | private String original; |
| | | |
| | | private String userNickName; |
| | | |
| | | public static CouponVirtualVO getVoByEntity(@NonNull CouponVirtual entity, CouponVirtualVO vo) { |
| | | if(vo == null) { |
| | | vo = new CouponVirtualVO(); |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * lmk-shop-java |
| | | * |
| | | * @author : zxl |
| | | * @date : 2025-09-12 15:19 |
| | | **/ |
| | | @Data |
| | | public class CouponVirtualVOInfo { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | private String orderId; |
| | | |
| | | |
| | | |
| | | private String itemOrderId; |
| | | |
| | | |
| | | private String goodsId; |
| | | |
| | | |
| | | private String skuId; |
| | | |
| | | |
| | | private String skuName; |
| | | |
| | | |
| | | private String couponId; |
| | | |
| | | |
| | | private String couponNo; |
| | | |
| | | |
| | | private String couponName; |
| | | |
| | | |
| | | private String userId; |
| | | |
| | | |
| | | private String userNickname; |
| | | |
| | | /** 领取时间 */ |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date claimTime; |
| | | |
| | | /** 领取时间 */ |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | /** 名称 */ |
| | | private String name; |
| | | |
| | | /** 是否分享 */ |
| | | private String shareStatus; |
| | | |
| | | /** 是否领取 */ |
| | | private String claimStatus; |
| | | |
| | | private String goodsUrl; |
| | | } |
| | |
| | | Result tackCardById( String cardId); |
| | | |
| | | Result changShareStatus( String cardId); |
| | | |
| | | Result couponCardInfo(String cardId); |
| | | } |
| | |
| | | import cn.lili.common.exception.ServiceException; |
| | | import cn.lili.common.security.AuthUser; |
| | | import cn.lili.common.security.context.UserContext; |
| | | import cn.lili.modules.goods.service.GoodsService; |
| | | import cn.lili.modules.lmk.domain.entity.CouponVirtual; |
| | | import cn.lili.modules.lmk.domain.form.CouponVirtualForm; |
| | | import cn.lili.modules.lmk.domain.query.CouponVirtualQuery; |
| | | import cn.lili.modules.lmk.domain.vo.CouponVirtualVO; |
| | | import cn.lili.modules.lmk.domain.vo.CouponVirtualVOInfo; |
| | | import cn.lili.modules.lmk.mapper.CouponVirtualMapper; |
| | | import cn.lili.modules.lmk.service.CouponVirtualService; |
| | | import cn.lili.modules.order.order.entity.dos.Order; |
| | |
| | | import cn.lili.modules.order.order.service.OrderItemService; |
| | | import cn.lili.modules.order.order.service.OrderService; |
| | | import cn.lili.modules.promotion.service.MemberCouponService; |
| | | import cn.lili.utils.COSUtil; |
| | | import cn.lili.utils.PageUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | private final OrderService orderService; |
| | | |
| | | private final MemberCouponService memberCouponService; |
| | | |
| | | private final GoodsService goodsService; |
| | | |
| | | private final COSUtil cosUtil; |
| | | /** |
| | | * 添加 |
| | | * |
| | |
| | | public Result page(CouponVirtualQuery query) { |
| | | IPage<CouponVirtualVO> page = PageUtil.getPage(query, CouponVirtualVO.class); |
| | | baseMapper.getPage(page, query); |
| | | for (CouponVirtualVO record : page.getRecords()) { |
| | | String original = record.getOriginal(); |
| | | if (StringUtils.isNotBlank(original) && !original.contains("http")) { |
| | | record.setOriginal(cosUtil.getPreviewUrl(original)); |
| | | } |
| | | } |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | |
| | | lock = redissonClient.getLock(LOCK_COUPON_VIRTUAL_CARD_ID + cardId); |
| | | LambdaQueryWrapper<CouponVirtual> forUpdate = Wrappers.<CouponVirtual>lambdaQuery().eq(CouponVirtual::getId, cardId).last("FOR UPDATE"); |
| | | CouponVirtual cardInfo = this.getOne(forUpdate); |
| | | if (cardInfo == null) { |
| | | throw new ServiceException("当前优惠卷不存在"); |
| | | } |
| | | if (ClaimStatusEnum.CLAIM.name().equals(cardInfo.getClaimStatus())) { |
| | | throw new ServiceException("当前购物卡已经被领取"); |
| | | } |
| | |
| | | cardInfo.setUserNickname(nickName); |
| | | cardInfo.setUserId(userId); |
| | | cardInfo.setClaimStatus(ClaimStatusEnum.CLAIM.name()); |
| | | cardInfo.setShareStatus(ShareStatusEnum.SHARE.name()); |
| | | cardInfo.setClaimTime(new Date()); |
| | | boolean b = this.updateById(cardInfo); |
| | | //去领取优惠卷 |
| | | if (!b) { |
| | | throw new RuntimeException("领取失败"); |
| | | } |
| | | return Result.ok("领取成功"); |
| | | return Result.ok().data(cardInfo.getCouponId()); |
| | | } finally { |
| | | assert lock != null; |
| | | if (lock.isHeldByCurrentThread()) { |
| | |
| | | this.updateById(couponVirtual); |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public Result couponCardInfo(String cardId) { |
| | | CouponVirtual couponVirtual = this.getById(cardId); |
| | | if (couponVirtual == null) { |
| | | throw new ServiceException("当前购物卡不存在"); |
| | | } |
| | | CouponVirtualVOInfo virtualVOInfo = new CouponVirtualVOInfo(); |
| | | BeanUtils.copyProperties(couponVirtual, virtualVOInfo); |
| | | |
| | | String goodsId = virtualVOInfo.getGoodsId(); |
| | | String url = goodsService.getById(goodsId).getOriginal(); |
| | | if (StringUtils.isNotBlank(url) && !url.contains("http")) { |
| | | virtualVOInfo.setGoodsUrl(cosUtil.getPreviewUrl(url)); |
| | | } |
| | | return Result.ok().data(virtualVOInfo); |
| | | } |
| | | } |
| | |
| | | @ApiModelProperty(value = "订单促销类型") |
| | | private String orderPromotionType; |
| | | |
| | | private String couponFlag; |
| | | |
| | | |
| | | public <T> QueryWrapper<T> queryWrapper() { |
| | | AuthUser currentUser = UserContext.getCurrentUser(); |
| | | QueryWrapper<T> wrapper = new QueryWrapper<>(); |
| | |
| | | //按评价状态 |
| | | wrapper.eq(CharSequenceUtil.isNotEmpty(commentStatus), "oi.comment_status", commentStatus); |
| | | |
| | | wrapper.eq(CharSequenceUtil.isNotEmpty(couponFlag),"o.coupon_flag", couponFlag); |
| | | |
| | | //按标签查询 |
| | | if (CharSequenceUtil.isNotEmpty(tag)) { |
| | | String orderStatusColumn = "o.order_status"; |
| | |
| | | @Data |
| | | public class OrderSimpleXcxVO { |
| | | |
| | | private String id; |
| | | |
| | | @ApiModelProperty("sn") |
| | | private String sn; |
| | | |
| | |
| | | |
| | | @ApiModelProperty(value = "卖家订单备注") |
| | | private String sellerRemark; |
| | | |
| | | @ApiModelProperty(value = "是否是礼品卡") |
| | | private String couponFlag; |
| | | |
| | | private int i = 0; |
| | | public List<OrderItemVO> initOrderItems() { |
| | | if (CharSequenceUtil.isEmpty(groupGoodsId)) { |
| | |
| | | * @param queryWrapper 查询条件 |
| | | * @return 简短订单分页 |
| | | */ |
| | | @Select("select o.sn,o.flow_price,o.create_time,o.order_status,o.pay_status,o.payment_method,o.payment_time,o.member_name,o.store_name as " + |
| | | "store_name,o.store_id as store_id,o.client_type,o.order_type,o.deliver_status,o.order_promotion_type,o.seller_remark " + |
| | | @Select("select o.id,o.sn,o.flow_price,o.create_time,o.order_status,o.pay_status,o.payment_method,o.payment_time,o.member_name,o.store_name as " + |
| | | "store_name,o.store_id as store_id,o.client_type,o.order_type,o.deliver_status,o.order_promotion_type,o.seller_remark,o.coupon_flag " + |
| | | ",GROUP_CONCAT(oi.goods_id) as group_goods_id," + |
| | | " GROUP_CONCAT(oi.sku_id) as group_sku_id," + |
| | | " GROUP_CONCAT(oi.num) as group_num" + |
| | |
| | | log.error("当前订单订单号为:{}不存在中的优惠卷不存在----------------------->{}",order.getId(),orderItem.getOrderSn()); |
| | | }else { |
| | | Integer num = orderItem.getNum(); |
| | | //当购买数量部位空的时候进行 |
| | | //当购买数量不为空的时候进行 |
| | | if (num != null) { |
| | | for (int i = 1; i <= num; i++) { |
| | | CouponVirtual couponVirtual = getCouponVirtual(orderItem); |
| | |
| | | |
| | | private static CouponVirtual getCouponVirtual(OrderItem orderItem) { |
| | | CouponVirtual couponVirtual = new CouponVirtual(); |
| | | couponVirtual.setOrderId(orderItem.getSn()); |
| | | couponVirtual.setOrderId(orderItem.getOrderSn()); |
| | | couponVirtual.setCouponId(orderItem.getCouponId()); |
| | | couponVirtual.setCouponName(orderItem.getCouponName()); |
| | | couponVirtual.setGoodsId(orderItem.getGoodsId()); |
| | |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_by" property="updateBy" /> |
| | | <result column="delete_flag" property="deleteFlag" /> |
| | | <result column="original" property="original" /> |
| | | <result column="user_nickname" property="userNickName" /> |
| | | </resultMap> |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | |
| | | LCV.create_time, |
| | | LCV.update_by, |
| | | LCV.delete_flag, |
| | | LCV.id |
| | | LCV.user_nickname, |
| | | LCV.id, |
| | | LGS.original |
| | | FROM |
| | | lmk_coupon_virtual LCV |
| | | lmk_coupon_virtual LCV JOIN li_goods_sku LGS ON LGS.id = LCV.sku_id |
| | | WHERE |
| | | LCV.deleted = 0 |
| | | LCV.delete_flag = 0 AND LGS.delete_flag = 0 |
| | | <if test="query.orderId != null and query.orderId !=''"> |
| | | AND LCV.order_id = #{query.orderId} |
| | | </if> |
| | | <if test="query.userNickName != null and query.userNickName !=''"> |
| | | AND LCV.user_nickname like CONCAT('%', #{query.userNickName}, '%') |
| | | </if> |
| | | <if test="query.skuName != null and query.skuName !=''"> |
| | | AND LCV.sku_name like CONCAT('%', #{query.skuName}, '%') |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
New file |
| | |
| | | package cn.lili.controller.lmk; |
| | | |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.query.CouponVirtualQuery; |
| | | import cn.lili.modules.lmk.service.CouponVirtualService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | 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; |
| | | |
| | | /** |
| | | * lmk-shop-java |
| | | * |
| | | * @author : zxl |
| | | * @date : 2025-09-12 18:11 |
| | | **/ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @Api(value = "礼品卡包", tags = "礼品卡包") |
| | | @RestController |
| | | @RequestMapping("/manager/cardPack") |
| | | public class CardPackController { |
| | | private final CouponVirtualService couponVirtualService; |
| | | |
| | | @GetMapping |
| | | @ApiOperation(value = "列表", notes = "列表") |
| | | public Result getPage(CouponVirtualQuery query){ |
| | | //更具订单id查询 |
| | | return couponVirtualService.page(query); |
| | | } |
| | | |
| | | } |