会员 充值活动 奖励 赠送商品
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateGiveRecord)表数据库访问层
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 15:20:43
|
||||
*/
|
||||
public interface TbActivateGiveRecordMapper {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
TbActivateGiveRecord queryById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*
|
||||
* @param tbActivateGiveRecord 查询条件
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<TbActivateGiveRecord> queryAll(TbActivateGiveRecord tbActivateGiveRecord);
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tbActivateGiveRecord 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(TbActivateGiveRecord tbActivateGiveRecord);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<TbActivateGiveRecord> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<TbActivateGiveRecord> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tbActivateGiveRecord 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(TbActivateGiveRecord tbActivateGiveRecord);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
}
|
||||
|
||||
@@ -11,19 +11,19 @@ import java.util.List;
|
||||
@Component
|
||||
@Mapper
|
||||
public interface TbActivateMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
// int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(TbActivate record);
|
||||
// int insert(TbActivate record);
|
||||
|
||||
int insertSelective(TbActivate record);
|
||||
// int insertSelective(TbActivate record);
|
||||
|
||||
TbActivate selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(TbActivate record);
|
||||
// int updateByPrimaryKeySelective(TbActivate record);
|
||||
|
||||
int updateByPrimaryKey(TbActivate record);
|
||||
// int updateByPrimaryKey(TbActivate record);
|
||||
|
||||
TbActivate selectByAmount(@Param("shopId") String shopId,@Param("amount") BigDecimal amount);
|
||||
|
||||
List<TbActivate> selectByShpopId(String shopId);
|
||||
List<TbActivate> selectByShopId(String shopId);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbActivateProduct;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表(TbActivateProduct)表数据库访问层
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 15:14:55
|
||||
*/
|
||||
public interface TbActivateProductMapper {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
TbActivateProduct queryById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*
|
||||
* @param tbActivateProduct 查询条件
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<TbActivateProduct> queryAll(TbActivateProduct tbActivateProduct);
|
||||
|
||||
List<TbActivateProduct> queryAllByActivateId(Integer activateId);
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tbActivateProduct 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(TbActivateProduct tbActivateProduct);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<TbActivateProduct> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<TbActivateProduct> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tbActivateProduct 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(TbActivateProduct tbActivateProduct);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ public class TbActivate implements Serializable {
|
||||
|
||||
private String isDel;
|
||||
|
||||
//是否赠送商品 0否 1是
|
||||
private Integer isGiftPro;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Integer getId() {
|
||||
@@ -75,4 +78,12 @@ public class TbActivate implements Serializable {
|
||||
public void setIsDel(String isDel) {
|
||||
this.isDel = isDel == null ? null : isDel.trim();
|
||||
}
|
||||
|
||||
public Integer getIsGiftPro() {
|
||||
return isGiftPro;
|
||||
}
|
||||
|
||||
public void setIsGiftPro(Integer isGiftPro) {
|
||||
this.isGiftPro = isGiftPro;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateGiveRecord)实体类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 15:20:43
|
||||
*/
|
||||
public class TbActivateGiveRecord implements Serializable {
|
||||
private static final long serialVersionUID = -53463432636369401L;
|
||||
|
||||
private Integer id;
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
private Integer vipUserId;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer proId;
|
||||
/**
|
||||
* 赠送数量
|
||||
*/
|
||||
private Integer num;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Integer shopId;
|
||||
private Integer sourceFlowId;
|
||||
/**
|
||||
* 来源活动id
|
||||
*/
|
||||
private Integer sourceActId;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
public TbActivateGiveRecord(Integer vipUserId, Integer proId, Integer num, Integer shopId, Integer sourceActId,Integer sourceFlowId) {
|
||||
this.vipUserId = vipUserId;
|
||||
this.proId = proId;
|
||||
this.num = num;
|
||||
this.shopId = shopId;
|
||||
this.sourceActId = sourceActId;
|
||||
this.sourceFlowId = sourceFlowId;
|
||||
this.createTime=new Date();
|
||||
}
|
||||
|
||||
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 getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(Integer shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
|
||||
public Integer getSourceFlowId() {
|
||||
return sourceFlowId;
|
||||
}
|
||||
|
||||
public void setSourceFlowId(Integer sourceFlowId) {
|
||||
this.sourceFlowId = sourceFlowId;
|
||||
}
|
||||
|
||||
public Integer getSourceActId() {
|
||||
return sourceActId;
|
||||
}
|
||||
|
||||
public void setSourceActId(Integer sourceActId) {
|
||||
this.sourceActId = sourceActId;
|
||||
}
|
||||
|
||||
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,83 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表(TbActivateProduct)实体类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 15:15:01
|
||||
*/
|
||||
public class TbActivateProduct implements Serializable {
|
||||
private static final long serialVersionUID = 592370528166603965L;
|
||||
|
||||
private Integer id;
|
||||
/**
|
||||
* 活动Id
|
||||
*/
|
||||
private Integer activateId;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer productId;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getActivateId() {
|
||||
return activateId;
|
||||
}
|
||||
|
||||
public void setActivateId(Integer activateId) {
|
||||
this.activateId = activateId;
|
||||
}
|
||||
|
||||
public Integer getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Integer productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(Integer num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -71,6 +71,10 @@ public class PayService {
|
||||
|
||||
@Autowired
|
||||
TbShopPayTypeMapper tbShopPayTypeMapper;
|
||||
@Autowired
|
||||
private TbActivateProductMapper actProductMapper;
|
||||
@Autowired
|
||||
private TbActivateGiveRecordMapper actGiveRecordMapper;
|
||||
|
||||
@Autowired
|
||||
private TbShopSongOrderMapper tbShopSongOrderMapper;
|
||||
@@ -982,7 +986,7 @@ public class PayService {
|
||||
|
||||
public Result getActivate(String shopId, int page, int pageSize) {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<TbActivate> list = tbActivateMapper.selectByShpopId(shopId);
|
||||
List<TbActivate> list = tbActivateMapper.selectByShopId(shopId);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return Result.success(CodeEnum.SUCCESS, pageInfo);
|
||||
}
|
||||
@@ -1079,42 +1083,53 @@ public class PayService {
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
TbActivate activate = tbActivateMapper.selectByAmount(tbShopUser.getShopId(), memberIn.getAmount());
|
||||
//会员活动
|
||||
giveActivate(tbShopUser,memberIn.getAmount(),flow.getId());
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("shopId", memberIn.getShopId());
|
||||
jsonObject.put("type", "wxMemberIn");
|
||||
jsonObject.put("amount", memberIn.getAmount());
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
return "success";
|
||||
}
|
||||
|
||||
public void giveActivate(TbShopUser tbShopUser, BigDecimal memAmount,Integer flowId){
|
||||
TbActivate activate = tbActivateMapper.selectByAmount(tbShopUser.getShopId(), memAmount);
|
||||
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
|
||||
if (activate.getIsGiftPro() != null && activate.getIsGiftPro() == 1) {
|
||||
List<TbActivateProduct> tbActivateProducts = actProductMapper.queryAllByActivateId(activate.getId());
|
||||
List<TbActivateGiveRecord> actGiveRecords = new ArrayList<>();
|
||||
for (TbActivateProduct actPro : tbActivateProducts) {
|
||||
TbActivateGiveRecord record = new TbActivateGiveRecord(Integer.valueOf(tbShopUser.getId()), actPro.getProductId(), actPro.getNum(), Integer.valueOf(tbShopUser.getShopId()), activate.getId(),flowId);
|
||||
actGiveRecords.add(record);
|
||||
}
|
||||
actGiveRecordMapper.insertBatch(actGiveRecords);
|
||||
}
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
switch (activate.getHandselType()) {
|
||||
case "GD":
|
||||
amount = activate.getHandselNum();
|
||||
break;
|
||||
case "RATIO":
|
||||
amount = memberIn.getAmount().multiply(activate.getHandselNum());
|
||||
amount = memAmount.multiply(activate.getHandselNum());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().add(amount));
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser);
|
||||
|
||||
flow = new TbShopUserFlow();
|
||||
TbShopUserFlow flow = new TbShopUserFlow();
|
||||
flow.setShopUserId(Integer.valueOf(tbShopUser.getId()));
|
||||
flow.setBizCode("scanMemberAwardIn");
|
||||
flow.setBizName("会员充值奖励");
|
||||
flow.setBizName("充值活动奖励");
|
||||
flow.setType("+");
|
||||
flow.setAmount(amount);
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("shopId", memberIn.getShopId());
|
||||
jsonObject.put("type", "wxMemberIn");
|
||||
jsonObject.put("amount", memberIn.getAmount());
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
}
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
@@ -1161,36 +1176,8 @@ public class PayService {
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
TbActivate activate = tbActivateMapper.selectByAmount(tbShopUser.getShopId(), memberIn.getAmount());
|
||||
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
|
||||
BigDecimal amount = BigDecimal.ZERO;
|
||||
switch (activate.getHandselType()) {
|
||||
case "GD":
|
||||
amount = activate.getHandselNum();
|
||||
break;
|
||||
case "RATIO":
|
||||
amount = memberIn.getAmount().multiply(activate.getHandselNum());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().add(amount));
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser);
|
||||
|
||||
flow = new TbShopUserFlow();
|
||||
flow.setShopUserId(Integer.valueOf(tbShopUser.getId()));
|
||||
flow.setBizCode("scanMemberAwardIn");
|
||||
flow.setType("+");
|
||||
flow.setBizName("充值活动奖励");
|
||||
flow.setAmount(amount);
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
}
|
||||
|
||||
|
||||
//会员活动
|
||||
giveActivate(tbShopUser,memberIn.getAmount(),flow.getId());
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("shopId", memberIn.getShopId());
|
||||
jsonObject.put("type", "wxMemberIn");
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord;
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateGiveRecord)表服务接口
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 15:20:43
|
||||
*/
|
||||
public interface TbActivateGiveRecordService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
TbActivateGiveRecord queryById(Integer id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tbActivateGiveRecord 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
TbActivateGiveRecord insert(TbActivateGiveRecord tbActivateGiveRecord);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tbActivateGiveRecord 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
TbActivateGiveRecord update(TbActivateGiveRecord tbActivateGiveRecord);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbActivateProduct;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表(TbActivateProduct)表服务接口
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 15:15:01
|
||||
*/
|
||||
public interface TbActivateProductService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
TbActivateProduct queryById(Integer id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tbActivateProduct 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
TbActivateProduct insert(TbActivateProduct tbActivateProduct);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tbActivateProduct 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
TbActivateProduct update(TbActivateProduct tbActivateProduct);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbActivateGiveRecordMapper;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbActivateGiveRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateGiveRecord)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 15:20:43
|
||||
*/
|
||||
@Service("tbActivateGiveRecordService")
|
||||
public class TbActivateGiveRecordServiceImpl implements TbActivateGiveRecordService {
|
||||
@Resource
|
||||
private TbActivateGiveRecordMapper tbActivateGiveRecordMapper;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public TbActivateGiveRecord queryById(Integer id) {
|
||||
return this.tbActivateGiveRecordMapper.queryById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tbActivateGiveRecord 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public TbActivateGiveRecord insert(TbActivateGiveRecord tbActivateGiveRecord) {
|
||||
this.tbActivateGiveRecordMapper.insert(tbActivateGiveRecord);
|
||||
return tbActivateGiveRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tbActivateGiveRecord 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public TbActivateGiveRecord update(TbActivateGiveRecord tbActivateGiveRecord) {
|
||||
this.tbActivateGiveRecordMapper.update(tbActivateGiveRecord);
|
||||
return this.queryById(tbActivateGiveRecord.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Integer id) {
|
||||
return this.tbActivateGiveRecordMapper.deleteById(id) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbActivateProductMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbActivateProduct;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbActivateProductService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表(TbActivateProduct)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 15:15:02
|
||||
*/
|
||||
@Service("tbActivateProductService")
|
||||
public class TbActivateProductServiceImpl implements TbActivateProductService {
|
||||
@Resource
|
||||
private TbActivateProductMapper tbActivateProductMapper;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public TbActivateProduct queryById(Integer id) {
|
||||
return this.tbActivateProductMapper.queryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tbActivateProduct 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public TbActivateProduct insert(TbActivateProduct tbActivateProduct) {
|
||||
this.tbActivateProductMapper.insert(tbActivateProduct);
|
||||
return tbActivateProduct;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tbActivateProduct 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public TbActivateProduct update(TbActivateProduct tbActivateProduct) {
|
||||
this.tbActivateProductMapper.update(tbActivateProduct);
|
||||
return this.queryById(tbActivateProduct.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Integer id) {
|
||||
return this.tbActivateProductMapper.deleteById(id) > 0;
|
||||
}
|
||||
}
|
||||
123
src/main/resources/mapper/TbActivateGiveRecordMapper.xml
Normal file
123
src/main/resources/mapper/TbActivateGiveRecordMapper.xml
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbActivateGiveRecordMapper">
|
||||
|
||||
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord" id="TbActivateGiveRecordMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="vipUserId" column="vip_user_id" jdbcType="INTEGER"/>
|
||||
<result property="proId" column="pro_id" jdbcType="INTEGER"/>
|
||||
<result property="num" column="num" jdbcType="INTEGER"/>
|
||||
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
||||
<result property="sourceActId" column="source_act_id" jdbcType="INTEGER"/>
|
||||
<result property="sourceFlowId" column="source_flow_id" jdbcType="INTEGER"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
, vip_user_id, pro_id, num, shop_id, source_flow_id,source_act_id, create_time, update_time </sql>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="TbActivateGiveRecordMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
|
||||
from tb_activate_give_record
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAll" resultMap="TbActivateGiveRecordMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
|
||||
from tb_activate_give_record
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="vipUserId != null">
|
||||
and vip_user_id = #{vipUserId}
|
||||
</if>
|
||||
<if test="proId != null">
|
||||
and pro_id = #{proId}
|
||||
</if>
|
||||
<if test="num != null">
|
||||
and num = #{num}
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
and shop_id = #{shopId}
|
||||
</if>
|
||||
<if test="sourceActId != null">
|
||||
and source_act_id = #{sourceActId}
|
||||
</if>
|
||||
<if test="sourceFlowId != null">
|
||||
and source_flow_id = #{sourceFlowId}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_activate_give_record(vip_user_id, pro_id, num, shop_id, source_act_id, source_flow_id, create_time, update_time)
|
||||
values (#{vipUserId}, #{proId}, #{num}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{createTime}, #{updateTime})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_activate_give_record(vip_user_id, pro_id, num, shop_id, source_act_id, source_flow_id, create_time, update_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.vipUserId}, #{entity.proId}, #{entity.num}, #{entity.shopId}, #{entity.sourceActId},
|
||||
#{entity.sourceFlowId},#{entity.createTime}, #{entity.updateTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update tb_activate_give_record
|
||||
<set>
|
||||
<if test="vipUserId != null">
|
||||
vip_user_id = #{vipUserId},
|
||||
</if>
|
||||
<if test="proId != null">
|
||||
pro_id = #{proId},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num = #{num},
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
shop_id = #{shopId},
|
||||
</if>
|
||||
<if test="sourceActId != null">
|
||||
source_act_id = #{sourceActId},
|
||||
</if>
|
||||
<if test="sourceFlowId != null">
|
||||
source_flow_id = #{sourceFlowId},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete
|
||||
from tb_activate_give_record
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
<result column="handsel_num" jdbcType="DECIMAL" property="handselNum" />
|
||||
<result column="handsel_type" jdbcType="VARCHAR" property="handselType" />
|
||||
<result column="is_del" jdbcType="VARCHAR" property="isDel" />
|
||||
<result column="is_gift_pro" jdbcType="INTEGER" property="isGiftPro" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, shop_id, min_num, max_num, handsel_num, handsel_type, is_del
|
||||
id, shop_id, min_num, max_num, handsel_num, handsel_type, is_del,is_gift_pro
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
@@ -116,10 +117,16 @@
|
||||
</update>
|
||||
|
||||
<select id="selectByAmount" resultMap="BaseResultMap">
|
||||
select * from tb_activate where shop_id=#{shopId} and is_del=0 and min_num <= #{amount} and max_num >= #{amount}
|
||||
</select>
|
||||
select *
|
||||
from tb_activate
|
||||
where shop_id = #{shopId}
|
||||
and is_del = 0
|
||||
and min_num <= #{amount}
|
||||
and max_num >= #{amount}
|
||||
order by max_num desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectByShpopId" resultMap="BaseResultMap">
|
||||
<select id="selectByShopId" resultMap="BaseResultMap">
|
||||
select * from tb_activate where shop_id=#{shopId}
|
||||
</select>
|
||||
</mapper>
|
||||
105
src/main/resources/mapper/TbActivateProductMapper.xml
Normal file
105
src/main/resources/mapper/TbActivateProductMapper.xml
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbActivateProductMapper">
|
||||
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbActivateProduct" id="TbActivateProductMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="activateId" column="activate_id" jdbcType="INTEGER"/>
|
||||
<result property="productId" column="product_id" jdbcType="INTEGER"/>
|
||||
<result property="num" column="num" jdbcType="INTEGER"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, activate_id, product_id, num, create_time, update_time </sql>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="TbActivateProductMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
|
||||
from tb_activate_product
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAll" resultMap="TbActivateProductMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
|
||||
from tb_activate_product
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="activateId != null">
|
||||
and activate_id = #{activateId}
|
||||
</if>
|
||||
<if test="productId != null">
|
||||
and product_id = #{productId}
|
||||
</if>
|
||||
<if test="num != null">
|
||||
and num = #{num}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="queryAllByActivateId" resultMap="TbActivateProductMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from tb_activate_product
|
||||
where
|
||||
activate_id = #{activateId}
|
||||
</select>
|
||||
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_activate_product(activate_id, product_id, num, create_time, update_time)
|
||||
values (#{activateId}, #{productId}, #{num}, #{createTime}, #{updateTime})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_activate_product(activate_id, product_id, num, create_time, update_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.activateId}, #{entity.productId}, #{entity.num}, #{entity.createTime}, #{entity.updateTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update tb_activate_product
|
||||
<set>
|
||||
<if test="activateId != null">
|
||||
activate_id = #{activateId},
|
||||
</if>
|
||||
<if test="productId != null">
|
||||
product_id = #{productId},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num = #{num},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete from tb_activate_product where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
delete from tb_shop_user_flow
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||
insert into tb_shop_user_flow (id, shop_user_id, amount,
|
||||
balance, biz_code, biz_name,
|
||||
create_time, type)
|
||||
|
||||
Reference in New Issue
Block a user