修改收益落地
This commit is contained in:
@@ -14,6 +14,8 @@ import cn.pluss.platform.merchantProfit.MerchantProfitService;
|
|||||||
import cn.pluss.platform.notice.NoticeService;
|
import cn.pluss.platform.notice.NoticeService;
|
||||||
import cn.pluss.platform.user.UserLevelService;
|
import cn.pluss.platform.user.UserLevelService;
|
||||||
import cn.pluss.platform.user.impl.GeneralPushUtil;
|
import cn.pluss.platform.user.impl.GeneralPushUtil;
|
||||||
|
import cn.pluss.platform.userAccount.UserAccountService;
|
||||||
|
import cn.pluss.platform.userAccount.impl.UserAccountServiceImpl;
|
||||||
import cn.pluss.platform.userAssess.UserAssessService;
|
import cn.pluss.platform.userAssess.UserAssessService;
|
||||||
import cn.pluss.platform.userRewardFlow.UserRewardFlowService;
|
import cn.pluss.platform.userRewardFlow.UserRewardFlowService;
|
||||||
import cn.pluss.platform.util.DateUtils;
|
import cn.pluss.platform.util.DateUtils;
|
||||||
@@ -57,6 +59,10 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
|
|||||||
@Resource
|
@Resource
|
||||||
private MerchantOrderMapper mapperOrderMapper;
|
private MerchantOrderMapper mapperOrderMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
UserAccountServiceImpl userAccountService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = RuntimeException.class, propagation = Propagation.NESTED)
|
@Transactional(rollbackFor = RuntimeException.class, propagation = Propagation.NESTED)
|
||||||
public void batchInsert(Vector<MerchantProfit> profitList) {
|
public void batchInsert(Vector<MerchantProfit> profitList) {
|
||||||
@@ -263,6 +269,9 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
|
|||||||
private void calcUserProfitV2(UserApp userApp, MerchantOrder order, String orderType) {
|
private void calcUserProfitV2(UserApp userApp, MerchantOrder order, String orderType) {
|
||||||
//2.0
|
//2.0
|
||||||
Vector<MerchantProfit> profitList = new Vector<MerchantProfit>();
|
Vector<MerchantProfit> profitList = new Vector<MerchantProfit>();
|
||||||
|
Vector<UserAccount> userAccounts=new Vector<>();
|
||||||
|
Vector<UserAccountFlow> userAccountFlows=new Vector<>();
|
||||||
|
|
||||||
// if (UserRoleEnum.SV2.getCode().equals(userApp.getRoleCode())) {
|
// if (UserRoleEnum.SV2.getCode().equals(userApp.getRoleCode())) {
|
||||||
// createUserSV2Profit(userApp, order, null, userApp, profitList, 1, orderType);
|
// createUserSV2Profit(userApp, order, null, userApp, profitList, 1, orderType);
|
||||||
// } else if (UserRoleEnum.ZY_BST.getCode().equals(userApp.getRoleCode())) {
|
// } else if (UserRoleEnum.ZY_BST.getCode().equals(userApp.getRoleCode())) {
|
||||||
@@ -283,12 +292,18 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
createUserV3Profit(order,userPromotion.getParentUserId(),profitList,order.getRate().divide(BigDecimal.valueOf(100)));
|
createUserV3Profit(order,userPromotion.getParentUserId(),profitList,userAccounts,userAccountFlows,order.getRate().divide(BigDecimal.valueOf(100)));
|
||||||
|
|
||||||
if (!profitList.isEmpty()) {
|
if (!profitList.isEmpty()) {
|
||||||
log.info("【分润计算完成】开始批量插入分润数据,生成分润的订单编号:{},分润条数:{}", order.getOrderNumber(), profitList.size());
|
log.info("【分润计算完成】开始批量插入分润数据,生成分润的订单编号:{},分润条数:{}", order.getOrderNumber(), profitList.size());
|
||||||
try {
|
try {
|
||||||
batchInsert(profitList);
|
batchInsert(profitList);
|
||||||
|
//更新账户余额
|
||||||
|
userAccountService.updateBatchById(userAccounts);
|
||||||
|
//添加账户流水
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
log.info("【分润插入】插入分润成功!");
|
log.info("【分润插入】插入分润成功!");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -307,7 +322,7 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
|
|||||||
@Autowired
|
@Autowired
|
||||||
UserPromotionMapper userPromotionMapper;
|
UserPromotionMapper userPromotionMapper;
|
||||||
|
|
||||||
private void createUserV3Profit(MerchantOrder order,String userId,Vector<MerchantProfit> profits,BigDecimal nowRate){
|
private void createUserV3Profit(MerchantOrder order,String userId,Vector<MerchantProfit> profits,Vector<UserAccount> accounts,Vector<UserAccountFlow> accountFlows,BigDecimal nowRate){
|
||||||
UserPromotion userPromotion= userPromotionMapper.selectByUserId(userId);
|
UserPromotion userPromotion= userPromotionMapper.selectByUserId(userId);
|
||||||
if(ObjectUtil.isEmpty(userPromotion)){
|
if(ObjectUtil.isEmpty(userPromotion)){
|
||||||
log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
|
log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
|
||||||
@@ -320,7 +335,7 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if("MC".equals(userPromotion.getTypeCode())){
|
if("MC".equals(userPromotion.getTypeCode())){
|
||||||
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
createUserV3Profit(order,userPromotion.getParentUserId(),profits,accounts,accountFlows,new BigDecimal(userPromotion.getCurrentFee()));
|
||||||
// if("1".equals(userPromotion.getIsExtend())||"2".equals(userPromotion.getIsExtend())){
|
// if("1".equals(userPromotion.getIsExtend())||"2".equals(userPromotion.getIsExtend())){
|
||||||
// BigDecimal profitRate = BigDecimal.ZERO;
|
// BigDecimal profitRate = BigDecimal.ZERO;
|
||||||
//
|
//
|
||||||
@@ -368,8 +383,23 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
|
|||||||
BigDecimal profitAmt = profitRate.divide(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getConsumeFee())).setScale(4, BigDecimal.ROUND_DOWN);
|
BigDecimal profitAmt = profitRate.divide(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getConsumeFee())).setScale(4, BigDecimal.ROUND_DOWN);
|
||||||
MerchantProfit profit = new MerchantProfit(nowUserApp,nowUserApp , order, profitAmt, profitRate, "5", "1");
|
MerchantProfit profit = new MerchantProfit(nowUserApp,nowUserApp , order, profitAmt, profitRate, "5", "1");
|
||||||
profits.add(profit);
|
profits.add(profit);
|
||||||
|
|
||||||
|
UserAccount userAccount= userAccountService.getUserAccountByUserId(Integer.valueOf(userId));
|
||||||
|
userAccount.setBalance(userAccount.getBalance().add(profitAmt));
|
||||||
|
userAccount.setUpdateTime(new Date());
|
||||||
|
UserAccountFlow flow=new UserAccountFlow();
|
||||||
|
|
||||||
|
flow.setUserId(Integer.valueOf(userId));
|
||||||
|
flow.setBizCode("102");
|
||||||
|
flow.setBizName("收款收益");
|
||||||
|
flow.setAmount(profitAmt);
|
||||||
|
flow.setBalance(userAccount.getBalance());
|
||||||
|
flow.setCreateTime(new Date());
|
||||||
|
accounts.add(userAccount);
|
||||||
|
accountFlows.add(flow);
|
||||||
|
|
||||||
sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
|
sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
|
||||||
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
createUserV3Profit(order,userPromotion.getParentUserId(),profits,accounts,accountFlows,new BigDecimal(userPromotion.getCurrentFee()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user