储值送积分活动
This commit is contained in:
@@ -6,6 +6,7 @@ import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* (TbActivate)表数据库访问层
|
||||
@@ -66,5 +67,11 @@ public interface TbActivateMapper {
|
||||
int deleteById(Integer id);
|
||||
|
||||
TbActivate selectByAmount(@Param("shopId") String shopId, @Param("amount") BigDecimal amount);
|
||||
|
||||
TbActivate selectByAmountScope(@Param("shopId") String shopId,@Param("amount") BigDecimal amount);
|
||||
|
||||
int updateMemberPoints(@Param("memberId") Long memberId,@Param("points") Integer points);
|
||||
|
||||
int insertMemberPointsLog(Map<String,Object> params);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* (TbActivate)实体类
|
||||
@@ -23,6 +23,10 @@ public class TbActivate implements Serializable {
|
||||
* 赠送金额
|
||||
*/
|
||||
private Integer giftAmount;
|
||||
/**
|
||||
* 赠送积分
|
||||
*/
|
||||
private Integer giftPoints;
|
||||
/**
|
||||
* 是否使用优惠卷 0否 1是
|
||||
*/
|
||||
@@ -113,5 +117,12 @@ public class TbActivate implements Serializable {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Integer getGiftPoints() {
|
||||
return giftPoints;
|
||||
}
|
||||
|
||||
public void setGiftPoints(Integer giftPoints) {
|
||||
this.giftPoints = giftPoints;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
@@ -377,6 +379,23 @@ public class MemberService {
|
||||
flow.setIsReturn("0");
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
//充值送积分
|
||||
TbActivate activate = tbActivateMapper.selectByAmountScope(shopUser.getShopId(), memberIn.getAmount());
|
||||
if (ObjectUtil.isNotNull(activate)) {
|
||||
tbActivateMapper.updateMemberPoints(Convert.toLong(shopUser.getId()),activate.getGiftAmount());
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("shopId", shopInfo.getId());
|
||||
params.put("memberId", shopUser.getId());
|
||||
params.put("memberName", shopUser.getName());
|
||||
params.put("avatarUrl", shopUser.getHeadImg());
|
||||
params.put("mobile", shopUser.getTelephone());
|
||||
params.put("content", StrUtil.format("充值¥{}送{}积分", amount, activate.getGiftPoints()));
|
||||
params.put("orderNo", memberIn.getOrderNo());
|
||||
params.put("floatType", "add");
|
||||
params.put("floatPoints", activate.getGiftPoints());
|
||||
tbActivateMapper.insertMemberPointsLog(params);
|
||||
}
|
||||
|
||||
BigDecimal fl = giveActivate(shopUser, amount, flow.getId());
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@@ -587,9 +606,9 @@ public class MemberService {
|
||||
flow.setBalance(shopUser.getAmount());
|
||||
flow.setIsReturn("0");
|
||||
flow.setCreateTime(new Date());
|
||||
flow.setRemark(memberIn.getOrderNo());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
|
||||
TbActivate activate = tbActivateMapper.selectByAmount(shopUser.getId().toString(), memberIn.getAmount());
|
||||
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
|
||||
BigDecimal awardAmount = activate.getGiftAmount() == null ? BigDecimal.ZERO : new BigDecimal(activate.getGiftAmount());
|
||||
@@ -626,6 +645,23 @@ public class MemberService {
|
||||
baObj.put("time", flow.getCreateTime());
|
||||
producer.balance(baObj.toString());
|
||||
}
|
||||
|
||||
//充值送积分
|
||||
activate = tbActivateMapper.selectByAmountScope(shopUser.getShopId(), memberIn.getAmount());
|
||||
if (ObjectUtil.isNotNull(activate)) {
|
||||
tbActivateMapper.updateMemberPoints(Convert.toLong(shopUser.getId()),activate.getGiftAmount());
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("shopId", shopUser.getShopId());
|
||||
params.put("memberId", shopUser.getId());
|
||||
params.put("memberName", shopUser.getName());
|
||||
params.put("avatarUrl", shopUser.getHeadImg());
|
||||
params.put("mobile", shopUser.getTelephone());
|
||||
params.put("content", StrUtil.format("充值¥{}送{}积分", memberIn.getAmount(), activate.getGiftPoints()));
|
||||
params.put("orderNo", memberIn.getOrderNo());
|
||||
params.put("floatType", "add");
|
||||
params.put("floatPoints", activate.getGiftPoints());
|
||||
tbActivateMapper.insertMemberPointsLog(params);
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS, memberIn);
|
||||
|
||||
}
|
||||
@@ -728,6 +764,23 @@ public class MemberService {
|
||||
flow.get().setIsReturn("0");
|
||||
tbShopUserFlowMapper.insert(flow.get());
|
||||
fl.set(giveActivate(shopUser, amount, flow.get().getId()));
|
||||
|
||||
//充值送积分
|
||||
TbActivate activate = tbActivateMapper.selectByAmountScope(shopUser.getShopId(), memberIn.getAmount());
|
||||
if (ObjectUtil.isNotNull(activate)) {
|
||||
tbActivateMapper.updateMemberPoints(Convert.toLong(shopUser.getId()),activate.getGiftAmount());
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("shopId", shopInfo.getId());
|
||||
params.put("memberId", shopUser.getId());
|
||||
params.put("memberName", shopUser.getName());
|
||||
params.put("avatarUrl", shopUser.getHeadImg());
|
||||
params.put("mobile", shopUser.getTelephone());
|
||||
params.put("content", StrUtil.format("充值¥{}送{}积分", amount, activate.getGiftPoints()));
|
||||
params.put("orderNo", memberIn.getOrderNo());
|
||||
params.put("floatType", "add");
|
||||
params.put("floatPoints", activate.getGiftPoints());
|
||||
tbActivateMapper.insertMemberPointsLog(params);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user