1
This commit is contained in:
parent
594a07f933
commit
48d4bcaea6
@ -29,7 +29,7 @@ public class MemberCoupon extends DlBaseEntity
|
|||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
/** 用户id */
|
/** 用户id */
|
||||||
private String userId;
|
private Long userId;
|
||||||
|
|
||||||
/** 类型(1-增加|2-扣减) */
|
/** 类型(1-增加|2-扣减) */
|
||||||
@Excel(name = "类型", readConverterExp = "1=-增加|2-扣减")
|
@Excel(name = "类型", readConverterExp = "1=-增加|2-扣减")
|
||||||
@ -44,7 +44,7 @@ public class MemberCoupon extends DlBaseEntity
|
|||||||
|
|
||||||
/** 剩余 */
|
/** 剩余 */
|
||||||
@Excel(name = "剩余")
|
@Excel(name = "剩余")
|
||||||
private Long balance;
|
private Integer balance;
|
||||||
|
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
@Excel(name = "备注")
|
@Excel(name = "备注")
|
||||||
|
@ -1,16 +1,34 @@
|
|||||||
package com.ruoyi.member.service;
|
package com.ruoyi.member.service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.member.domain.MemberCoupon;
|
import com.ruoyi.member.domain.MemberCoupon;
|
||||||
|
import com.ruoyi.member.domain.MemberOrder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户通告券变动记录Service接口
|
* 用户通告券变动记录Service接口
|
||||||
*
|
*
|
||||||
* @author vinjor-m
|
* @author vinjor-m
|
||||||
* @date 2025-03-17
|
* @date 2025-03-17
|
||||||
*/
|
*/
|
||||||
public interface IMemberCouponService extends IService<MemberCoupon>
|
public interface IMemberCouponService extends IService<MemberCoupon> {
|
||||||
{
|
|
||||||
|
/**
|
||||||
|
* @param order 订单
|
||||||
|
* @author PQZ
|
||||||
|
* @date 15:02 2025/3/28
|
||||||
|
**/
|
||||||
|
void dealMemberCoupon(MemberOrder order);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存通告券变动记录
|
||||||
|
*
|
||||||
|
* @param userId 用户id
|
||||||
|
* @param type 变动类型(1增加2减少)
|
||||||
|
* @param noticeId 通告id
|
||||||
|
* @param couponNum 变动数量
|
||||||
|
* @author PQZ
|
||||||
|
* @date 15:19 2025/3/28
|
||||||
|
**/
|
||||||
|
void saveCoupon(Long userId, String type, String noticeId, Integer couponNum);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -126,8 +126,8 @@ public class MemberCardServiceImpl extends ServiceImpl<MemberCardMapper, MemberC
|
|||||||
.eq(MemberCard::getCardId, cardId)
|
.eq(MemberCard::getCardId, cardId)
|
||||||
.eq(MemberCard::getUserId, userId)
|
.eq(MemberCard::getUserId, userId)
|
||||||
.eq(DlBaseEntity::getDelFlag, 0)
|
.eq(DlBaseEntity::getDelFlag, 0)
|
||||||
.ge(MemberCard::getStartDate, time)
|
.lt(MemberCard::getStartDate, time)
|
||||||
.lt(MemberCard::getEndDate, time);
|
.ge(MemberCard::getEndDate, time);
|
||||||
return list(lambdaQueryWrapper);
|
return list(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
package com.ruoyi.member.service.impl;
|
package com.ruoyi.member.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.base.domain.BaseCoupon;
|
||||||
|
import com.ruoyi.base.service.IBaseCouponService;
|
||||||
|
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||||
|
import com.ruoyi.member.domain.MemberCoupon;
|
||||||
|
import com.ruoyi.member.domain.MemberOrder;
|
||||||
|
import com.ruoyi.member.mapper.MemberCouponMapper;
|
||||||
|
import com.ruoyi.member.service.IMemberCouponService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.ruoyi.member.mapper.MemberCouponMapper;
|
import java.util.List;
|
||||||
import com.ruoyi.member.domain.MemberCoupon;
|
|
||||||
import com.ruoyi.member.service.IMemberCouponService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户通告券变动记录Service业务层处理
|
* 用户通告券变动记录Service业务层处理
|
||||||
@ -20,6 +25,62 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper,Memb
|
|||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private MemberCouponMapper memberCouponMapper;
|
private MemberCouponMapper memberCouponMapper;
|
||||||
|
@Autowired
|
||||||
|
private IBaseCouponService baseCouponService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param order 订单
|
||||||
|
* @author PQZ
|
||||||
|
* @date 15:02 2025/3/28
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void dealMemberCoupon(MemberOrder order) {
|
||||||
|
BaseCoupon coupon = baseCouponService.getById(order.getGoodsId());
|
||||||
|
saveCoupon(order.getUserId(), "2",null,coupon.getCouponNum());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存通告券变动记录
|
||||||
|
*
|
||||||
|
* @param userId 用户id
|
||||||
|
* @param type 变动类型(1增加2减少)
|
||||||
|
* @param noticeId 通告id
|
||||||
|
* @param couponNum 变动数量
|
||||||
|
* @author PQZ
|
||||||
|
* @date 15:19 2025/3/28
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void saveCoupon(Long userId, String type, String noticeId, Integer couponNum) {
|
||||||
|
//查询当前用户最新变动记录
|
||||||
|
LambdaQueryWrapper<MemberCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper
|
||||||
|
.eq(MemberCoupon::getUserId,userId)
|
||||||
|
.eq(DlBaseEntity::getDelFlag,0)
|
||||||
|
.orderByDesc(DlBaseEntity::getCreateTime);
|
||||||
|
List<MemberCoupon> list = list(lambdaQueryWrapper);
|
||||||
|
MemberCoupon memberCoupon = new MemberCoupon();
|
||||||
|
memberCoupon.setUserId(userId);
|
||||||
|
memberCoupon.setType(type);
|
||||||
|
memberCoupon.setNoticeId(noticeId);
|
||||||
|
memberCoupon.setCouponNum(couponNum);
|
||||||
|
//如果无记录则为初始新增
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
memberCoupon.setBalance(couponNum);
|
||||||
|
} else {
|
||||||
|
//如果有记录则取最新记录中的剩余值进行计算后得出新值
|
||||||
|
Integer oldBalance = list.get(0).getBalance();
|
||||||
|
Integer newBalance;
|
||||||
|
if ("1".equals(type)) {
|
||||||
|
newBalance = oldBalance + couponNum;
|
||||||
|
} else {
|
||||||
|
newBalance = oldBalance - couponNum;
|
||||||
|
}
|
||||||
|
memberCoupon.setBalance(newBalance);
|
||||||
|
}
|
||||||
|
save(memberCoupon);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单Service业务层处理
|
* 订单Service业务层处理
|
||||||
@ -65,12 +66,17 @@ public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper,Member
|
|||||||
LambdaQueryWrapper<MemberOrder> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<MemberOrder> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(DlBaseEntity::getDelFlag,0).eq(MemberOrder::getOrderNo,orderNo);
|
lambdaQueryWrapper.eq(DlBaseEntity::getDelFlag,0).eq(MemberOrder::getOrderNo,orderNo);
|
||||||
MemberOrder memberOrder = getOne(lambdaQueryWrapper);
|
MemberOrder memberOrder = getOne(lambdaQueryWrapper);
|
||||||
/*2、处理不同类型*/
|
/*2、处理不同类型订单*/
|
||||||
if ("01".equals(memberOrder.getOrderType())) {
|
if ("01".equals(memberOrder.getOrderType())) {
|
||||||
cardService.dealMemberCard(memberOrder);
|
cardService.dealMemberCard(memberOrder);
|
||||||
} else {
|
} else {
|
||||||
|
couponService.dealMemberCoupon(memberOrder);
|
||||||
}
|
}
|
||||||
|
/*3、处理订单表数据*/
|
||||||
|
memberOrder.setPayTime(new Date());
|
||||||
|
memberOrder.setIsPay(1);
|
||||||
|
memberOrder.setPayWay("02");
|
||||||
|
updateById(memberOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,5 +49,6 @@
|
|||||||
<if test="entity.isPay != null "> and is_pay = #{entity.isPay}</if>
|
<if test="entity.isPay != null "> and is_pay = #{entity.isPay}</if>
|
||||||
<if test="entity.isRefund != null "> and is_refund = #{entity.isRefund}</if>
|
<if test="entity.isRefund != null "> and is_refund = #{entity.isRefund}</if>
|
||||||
</where>
|
</where>
|
||||||
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue
Block a user