会员分成逻辑类

This commit is contained in:
2024-10-31 17:58:45 +08:00
parent b2079513d4
commit 4b2d08b33d
7 changed files with 138 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
package com.buy507.mall.mapper;
import com.buy507.mall.model.UmsMemberAccountTransaction;
import com.buy507.mall.model.UmsMemberAccountTransactionExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UmsMemberAccountTransactionMapper {
long countByExample(UmsMemberAccountTransactionExample example);
int deleteByExample(UmsMemberAccountTransactionExample example);
int deleteByPrimaryKey(Long id);
int insert(UmsMemberAccountTransaction record);
int insertSelective(UmsMemberAccountTransaction record);
List<UmsMemberAccountTransaction> selectByExample(UmsMemberAccountTransactionExample example);
UmsMemberAccountTransaction selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") UmsMemberAccountTransaction record, @Param("example") UmsMemberAccountTransactionExample example);
int updateByExample(@Param("record") UmsMemberAccountTransaction record, @Param("example") UmsMemberAccountTransactionExample example);
int updateByPrimaryKeySelective(UmsMemberAccountTransaction record);
int updateByPrimaryKey(UmsMemberAccountTransaction record);
}

View File

@@ -0,0 +1,30 @@
package com.buy507.mall.mapper;
import com.buy507.mall.model.UmsMemberRelationTree;
import com.buy507.mall.model.UmsMemberRelationTreeExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UmsMemberRelationTreeMapper {
long countByExample(UmsMemberRelationTreeExample example);
int deleteByExample(UmsMemberRelationTreeExample example);
int deleteByPrimaryKey(Long id);
int insert(UmsMemberRelationTree record);
int insertSelective(UmsMemberRelationTree record);
List<UmsMemberRelationTree> selectByExample(UmsMemberRelationTreeExample example);
UmsMemberRelationTree selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") UmsMemberRelationTree record, @Param("example") UmsMemberRelationTreeExample example);
int updateByExample(@Param("record") UmsMemberRelationTree record, @Param("example") UmsMemberRelationTreeExample example);
int updateByPrimaryKeySelective(UmsMemberRelationTree record);
int updateByPrimaryKey(UmsMemberRelationTree record);
}

View File

@@ -1,6 +1,6 @@
<?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.buy507.mall.model.CmsTopic.UmsMemberAccountTransactionMapper">
<mapper namespace="com.buy507.mall.mapper.UmsMemberAccountTransactionMapper">
<resultMap id="BaseResultMap" type="com.buy507.mall.model.UmsMemberAccountTransaction">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="member_id" jdbcType="BIGINT" property="memberId" />

View File

@@ -1,6 +1,6 @@
<?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.buy507.mall.model.CmsTopic.UmsMemberRelationTreeMapper">
<mapper namespace="com.buy507.mall.mapper.UmsMemberRelationTreeMapper">
<resultMap id="BaseResultMap" type="com.buy507.mall.model.UmsMemberRelationTree">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="member_id" jdbcType="BIGINT" property="memberId" />

View File

@@ -0,0 +1,16 @@
package com.buy507.mall.portal.service;
import com.buy507.mall.model.OmsOrder;
import com.buy507.mall.model.UmsMember;
/**
* 惠麦商城-->会员提成机制
*/
public interface MemberCommissionService {
/**
* 计算会员提成比例
* @param order
* @param currentMember
*/
void computeCommission(OmsOrder order, UmsMember currentMember);
}

View File

@@ -0,0 +1,52 @@
package com.buy507.mall.portal.service.impl;
import com.buy507.mall.mapper.UmsMemberAccountTransactionMapper;
import com.buy507.mall.mapper.UmsMemberRelationTreeMapper;
import com.buy507.mall.model.OmsOrder;
import com.buy507.mall.model.UmsMember;
import com.buy507.mall.portal.service.MemberCommissionService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Service
public class MemberCommissionServiceImpl implements MemberCommissionService {
/**
* 会员上下关系
*/
@Resource
private UmsMemberRelationTreeMapper umsMemberRelationTreeMapper;
/**
* 会员分成流水
*/
@Resource
private UmsMemberAccountTransactionMapper umsMemberAccountTransactionMapper;
/**
* 线程池处理逻辑
*/
private ExecutorService executorService = Executors.newFixedThreadPool(10);
@Override
public void computeCommission(OmsOrder order, UmsMember currentMember) {
executorService.submit(()->{
/**
* 会员排队分红逻辑,及流水记账
*/
System.out.println(order.getBillType());
});
}
}

View File

@@ -138,6 +138,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
@Autowired
private AlipayService alipayService;
@Autowired
private MemberCommissionService memberCommissionService;
@Value("${kuaidi100.url}")
private String KUAIDI100_URL;
@@ -1205,6 +1208,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
history.setNote("完成确认收货");
orderOperateHistoryMapper.insert(history);
/**
* 开始计算会员提成比例
*/
memberCommissionService.computeCommission(order, currentMember);
}
return CommonResult.success(null, "确认收货成功");