活动赠送商品
订单超时 回滚赠送使用数量
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateInRecord)表实体类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:50:16
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TbActivateInRecord extends Model<TbActivateInRecord> {
|
||||
|
||||
private Integer id;
|
||||
//会员id
|
||||
private Integer vipUserId;
|
||||
//商品id
|
||||
private Integer proId;
|
||||
//赠送数量
|
||||
private Integer num;
|
||||
//未使用数量
|
||||
private Integer overNum;
|
||||
//店铺id
|
||||
private Integer shopId;
|
||||
//来源活动id
|
||||
private Integer sourceActId;
|
||||
|
||||
private Integer sourceFlowId;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getVipUserId() {
|
||||
return vipUserId;
|
||||
}
|
||||
|
||||
public void setVipUserId(Integer vipUserId) {
|
||||
this.vipUserId = vipUserId;
|
||||
}
|
||||
|
||||
public Integer getProId() {
|
||||
return proId;
|
||||
}
|
||||
|
||||
public void setProId(Integer proId) {
|
||||
this.proId = proId;
|
||||
}
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(Integer num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public Integer getOverNum() {
|
||||
return overNum;
|
||||
}
|
||||
|
||||
public void setOverNum(Integer overNum) {
|
||||
this.overNum = overNum;
|
||||
}
|
||||
|
||||
public Integer getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(Integer shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public Integer getSourceActId() {
|
||||
return sourceActId;
|
||||
}
|
||||
|
||||
public void setSourceActId(Integer sourceActId) {
|
||||
this.sourceActId = sourceActId;
|
||||
}
|
||||
|
||||
public Integer getSourceFlowId() {
|
||||
return sourceFlowId;
|
||||
}
|
||||
|
||||
public void setSourceFlowId(Integer sourceFlowId) {
|
||||
this.sourceFlowId = sourceFlowId;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表(TbActivateOutRecord)表实体类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:53:52
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TbActivateOutRecord extends Model<TbActivateOutRecord> {
|
||||
|
||||
private Integer id;
|
||||
//商品赠送Id
|
||||
private Integer giveId;
|
||||
//商品id
|
||||
private Integer proId;
|
||||
//未使用数量
|
||||
private Integer useNum;
|
||||
//退单量
|
||||
private Integer refNum;
|
||||
//订单id
|
||||
private String orderId;
|
||||
//新建: create, 完成: closed, 取消:cancel,
|
||||
private String status;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getGiveId() {
|
||||
return giveId;
|
||||
}
|
||||
|
||||
public void setGiveId(Integer giveId) {
|
||||
this.giveId = giveId;
|
||||
}
|
||||
|
||||
public Integer getProId() {
|
||||
return proId;
|
||||
}
|
||||
|
||||
public void setProId(Integer proId) {
|
||||
this.proId = proId;
|
||||
}
|
||||
|
||||
public Integer getUseNum() {
|
||||
return useNum;
|
||||
}
|
||||
|
||||
public void setUseNum(Integer useNum) {
|
||||
this.useNum = useNum;
|
||||
}
|
||||
|
||||
public Integer getRefNum() {
|
||||
return refNum;
|
||||
}
|
||||
|
||||
public void setRefNum(Integer refNum) {
|
||||
this.refNum = refNum;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateInRecord)表数据库访问层
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:50:16
|
||||
*/
|
||||
public interface TbActivateInRecordMapper extends BaseMapper<TbActivateInRecord> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表(TbActivateOutRecord)表数据库访问层
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:53:52
|
||||
*/
|
||||
public interface TbActivateOutRecordMapper extends BaseMapper<TbActivateOutRecord> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateInRecord)表服务接口
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:50:16
|
||||
*/
|
||||
public interface TbActivateInRecordService extends IService<TbActivateInRecord> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表(TbActivateOutRecord)表服务接口
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:53:52
|
||||
*/
|
||||
public interface TbActivateOutRecordService extends IService<TbActivateOutRecord> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbActivateInRecordMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateInRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateInRecord)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:50:16
|
||||
*/
|
||||
@Service("tbActivateInRecordService")
|
||||
public class TbActivateInRecordServiceImpl extends ServiceImpl<TbActivateInRecordMapper, TbActivateInRecord> implements TbActivateInRecordService {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbActivateOutRecordMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateOutRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表(TbActivateOutRecord)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:53:52
|
||||
*/
|
||||
@Service("tbActivateOutRecordService")
|
||||
public class TbActivateOutRecordServiceImpl extends ServiceImpl<TbActivateOutRecordMapper, TbActivateOutRecord> implements TbActivateOutRecordService {
|
||||
}
|
||||
|
||||
@@ -10,7 +10,12 @@ import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mapper.order.TbOrderInfoMapper;
|
||||
import cn.ysk.cashier.mapper.product.TbProductMapper;
|
||||
import cn.ysk.cashier.mapper.product.TbProductSkuMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateProduct;
|
||||
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateInRecordService;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateOutRecordService;
|
||||
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
@@ -33,6 +38,8 @@ import cn.ysk.cashier.vo.TbOrderInfoVo;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -79,6 +86,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
private final RedisUtils redisUtils;
|
||||
private final ThirdPayService thirdPayService;
|
||||
private final TbCashierCartRepository cartRepository;
|
||||
private final TbActivateInRecordService inRecordService;
|
||||
private final TbActivateOutRecordService outRecordService;
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Value("${thirdPay.url}")
|
||||
@@ -362,6 +371,22 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void upOrderStatus(TbOrderInfo tbOrderInfo) {
|
||||
tbOrderInfo.setStatus("cancelled");
|
||||
//订单取消 赠送商品数量返回
|
||||
QueryWrapper<TbActivateOutRecord> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id",tbOrderInfo.getId());
|
||||
queryWrapper.eq("status","create");
|
||||
List<TbActivateOutRecord> outRecords = outRecordService.list(queryWrapper);
|
||||
for (TbActivateOutRecord outRecord : outRecords) {
|
||||
TbActivateInRecord inRecord = inRecordService.getById(outRecord.getGiveId());
|
||||
inRecord.setOverNum(inRecord.getOverNum() + outRecord.getUseNum());
|
||||
inRecordService.updateById(inRecord);
|
||||
}
|
||||
LambdaUpdateWrapper<TbActivateOutRecord> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(TbActivateOutRecord::getOrderId, tbOrderInfo.getId())
|
||||
.eq(TbActivateOutRecord::getStatus, "create")
|
||||
.set(TbActivateOutRecord::getStatus, "cancel");
|
||||
outRecordService.update(lambdaUpdateWrapper);
|
||||
|
||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
||||
Set<String> keys = new HashSet<>();
|
||||
for (TbOrderDetail detail : details) {
|
||||
|
||||
Reference in New Issue
Block a user