|
|
@@ -1,5 +1,6 @@
|
|
|
package com.cyksj.service.distribute.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.mapper.OrderDonMapper;
|
|
|
@@ -43,14 +44,28 @@ public class UserBusinessFrontServiceImpl implements UserBusinessFrontService {
|
|
|
private final UserBusinessDefaultRateConfigMapper defaultRateConfigMapper;
|
|
|
|
|
|
@Override
|
|
|
- public void taskDistributeRateBenefits(Long sharedId, Long businessId, OrderDon order, Integer distributeRate) {
|
|
|
- UserDistributeBusinessRate businessRate = userDistributeBusinessRateMapper.selectOne(Wrappers.lambdaQuery(UserDistributeBusinessRate.class)
|
|
|
+ public void taskDistributeRateBenefits(Long sharedId, Long businessId, Integer goodsType, OrderDon order, Integer distributeRate) {
|
|
|
+ LambdaQueryWrapper<UserDistributeBusinessRate> wrapper = Wrappers.lambdaQuery(UserDistributeBusinessRate.class)
|
|
|
.eq(UserDistributeBusinessRate::getBusinessId, businessId)
|
|
|
.eq(UserDistributeBusinessRate::getGoodsId, order.getGoodsId())
|
|
|
- .eq(UserDistributeBusinessRate::getSkuId, order.getSkuId()).last("limit 1"));
|
|
|
+ .last("limit 1");
|
|
|
+ if (goodsType == 1) {
|
|
|
+ wrapper.eq(UserDistributeBusinessRate::getSkuId, order.getSkuId());
|
|
|
+ }
|
|
|
+ UserDistributeBusinessRate businessRate = userDistributeBusinessRateMapper.selectOne(wrapper);
|
|
|
if (businessRate != null) {
|
|
|
- //首单
|
|
|
if (order.getOrderType() == 1) {
|
|
|
+ //实物商务分销提成 无首单
|
|
|
+ if (goodsType != 1) {
|
|
|
+ UserDistributeBusinessOrderDonRecord record = saveBusinessTakeMoneyRecord(order, businessId, sharedId, businessRate.getFirstOrderRate(), null, distributeRate);
|
|
|
+ if (record == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ businessOrderDonRecordMapper.insert(record);
|
|
|
+ log.info("开始给商务人员:{}分配分销人:{}分销的用户:{}实物:{}提成", businessId, sharedId, order.getUserId(), order.getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //首单
|
|
|
log.info("商务首单orderId:{}分销分配提成开始", order.getId());
|
|
|
//用户之前是否下过单
|
|
|
Integer count = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|