会员 充值活动 奖励 赠送商品

This commit is contained in:
2024-08-21 09:29:50 +08:00
parent 9fcee207d5
commit fbb69e60d9
15 changed files with 856 additions and 56 deletions

View File

@@ -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");

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}