Compare commits
No commits in common. "eb1c9548948830ed48cff2890cc7257e4a2aabb1" and "793429a5025860ce4819700be480c66f74dcd09e" have entirely different histories.
eb1c954894
...
793429a502
|
|
@ -82,4 +82,5 @@ public interface CuMemberBonusMapper extends BaseMapper<CuMemberBonus> {
|
||||||
*/
|
*/
|
||||||
void mergeBackRangeBonusIncome(@Param("pkOrder") Long pkOrder, @Param("bonusValue") Integer bonusValue);
|
void mergeBackRangeBonusIncome(@Param("pkOrder") Long pkOrder, @Param("bonusValue") Integer bonusValue);
|
||||||
|
|
||||||
|
void recalculateTeamNewBoxNum(@Param("pkId") Long pkId, @Param("retailsTableName") String retailsTableName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,4 +144,11 @@ public interface ICuMemberBonusService extends IService<CuMemberBonus> {
|
||||||
|
|
||||||
CuMemberBonusExt initCuMemberBonus();
|
CuMemberBonusExt initCuMemberBonus();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户激活后会抛出MQ
|
||||||
|
* 在此需要补偿该用户的当日秒结的团队新增
|
||||||
|
*
|
||||||
|
* @param pkIdList
|
||||||
|
*/
|
||||||
|
void recalculateTeamNewBoxNum(List<Long> pkIdList);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hzs.bonus.bonus.service.impl;
|
package com.hzs.bonus.bonus.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
@ -21,6 +22,7 @@ import com.hzs.common.core.utils.ComputeUtil;
|
||||||
import com.hzs.common.core.utils.DateUtils;
|
import com.hzs.common.core.utils.DateUtils;
|
||||||
import com.hzs.common.core.web.page.TableDataInfo;
|
import com.hzs.common.core.web.page.TableDataInfo;
|
||||||
import com.hzs.common.domain.member.bonus.CuMemberBonus;
|
import com.hzs.common.domain.member.bonus.CuMemberBonus;
|
||||||
|
import com.hzs.common.domain.member.bonus.CuMemberBonusRange;
|
||||||
import com.hzs.common.domain.member.ext.*;
|
import com.hzs.common.domain.member.ext.*;
|
||||||
import com.hzs.common.domain.system.config.BdBonusItems;
|
import com.hzs.common.domain.system.config.BdBonusItems;
|
||||||
import com.hzs.common.domain.system.config.ext.BdBonusItemsExt;
|
import com.hzs.common.domain.system.config.ext.BdBonusItemsExt;
|
||||||
|
|
@ -557,4 +559,18 @@ public class CuMemberBonusServiceImpl extends ServiceImpl<CuMemberBonusMapper, C
|
||||||
baseMapper.mergeBackRangeBonusIncome(pkOrder, EBonusItems.RANGE_INCOME.getValue());
|
baseMapper.mergeBackRangeBonusIncome(pkOrder, EBonusItems.RANGE_INCOME.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void recalculateTeamNewBoxNum(List<Long> pkIdList) {
|
||||||
|
String retailsTableName = getDayTableName();
|
||||||
|
log.info("recalculateTeamNewBoxNum: pkIdList: {}, tableName: {}", JSONUtil.toJsonStr(pkIdList), retailsTableName);
|
||||||
|
for (Long pkId : pkIdList) {
|
||||||
|
baseMapper.recalculateTeamNewBoxNum(pkId, retailsTableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDayTableName() {
|
||||||
|
String localDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
|
int period = iCuMemberSettlePeriodService.getCuMemberSettlePeriodByDate(localDate).getPkId();
|
||||||
|
return TableNameConstants.CU_MEMBER_RETAIL_S + period;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,24 +56,10 @@ public class BonusTotalVO implements Serializable {
|
||||||
@Excel(name = "见点收益", scale = 2)
|
@Excel(name = "见点收益", scale = 2)
|
||||||
private BigDecimal globalPoints;
|
private BigDecimal globalPoints;
|
||||||
|
|
||||||
/**
|
|
||||||
* 领导奖级差收益-众康
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Excel(name = "领导奖", scale = 2)
|
|
||||||
private BigDecimal retailRangeIncome;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 领导奖平级收益-众康
|
|
||||||
*/
|
|
||||||
@Excel(name = "平级奖", scale = 2)
|
|
||||||
private BigDecimal retailSameLevelIncome;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实发收益总计
|
* 实发收益总计
|
||||||
*/
|
*/
|
||||||
@Excel(name = "实发收益总计", scale = 2)
|
@Excel(name = "实发收益总计", scale = 2)
|
||||||
private BigDecimal realIncomeTotal;
|
private BigDecimal realIncomeTotalOri;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.hzs.bonus.listener;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.hzs.bonus.bonus.service.IBonusSettleService;
|
||||||
|
import com.hzs.bonus.bonus.service.ICuMemberBonusService;
|
||||||
|
import com.hzs.bonus.bonus.service.ICuMemberRetailLogService;
|
||||||
|
import com.hzs.common.core.constant.CountryConstants;
|
||||||
|
import com.hzs.common.core.constant.MagicNumberConstants;
|
||||||
|
import com.hzs.common.core.constant.RabbitMqConstants;
|
||||||
|
import com.hzs.common.core.enums.EYesNo;
|
||||||
|
import com.hzs.common.domain.member.bonus.CuMemberRetailLog;
|
||||||
|
import com.hzs.common.domain.sale.ext.SaOrderExt;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.*;
|
||||||
|
import org.springframework.amqp.support.AmqpHeaders;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.messaging.Message;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单秒接
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class SaOrderSecondActivateCompensationListener {
|
||||||
|
@Autowired
|
||||||
|
private ICuMemberBonusService memberBonusService;
|
||||||
|
|
||||||
|
@RabbitListener(bindings = @QueueBinding(
|
||||||
|
exchange = @Exchange(value = RabbitMqConstants.ORDER_SECOND_ACTIVATE_COMPENSATION_EXCHANGE, type = "topic"),
|
||||||
|
value = @Queue(value = RabbitMqConstants.ORDER_SECOND_ACTIVATE_COMPENSATION_QUEUE, durable = "true", autoDelete = "false"),
|
||||||
|
key = RabbitMqConstants.ORDER_SECOND_ACTIVATE_COMPENSATION_KEY))
|
||||||
|
@RabbitHandler
|
||||||
|
public void onMessage(Message<List<Long>> message, Channel channel) throws Exception {
|
||||||
|
List<Long> activateCompensationIdList = message.getPayload();
|
||||||
|
log.info("秒结开始消费,接收到的参数:{}", JSONUtil.toJsonStr(activateCompensationIdList));
|
||||||
|
|
||||||
|
Long deliveryTag = (Long) message.getHeaders().get(AmqpHeaders.DELIVERY_TAG);
|
||||||
|
channel.basicAck(deliveryTag, false);
|
||||||
|
|
||||||
|
memberBonusService.recalculateTeamNewBoxNum(activateCompensationIdList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -461,9 +461,7 @@ cb.real_income_total,
|
||||||
nvl(min(bc.out_exchange_rate),1) out_exchange_rate,
|
nvl(min(bc.out_exchange_rate),1) out_exchange_rate,
|
||||||
sum(cb.direct_income) direct_income,
|
sum(cb.direct_income) direct_income,
|
||||||
sum(cb.global_points) global_points,
|
sum(cb.global_points) global_points,
|
||||||
sum(cb.store_income) store_income,
|
sum(cb.STORE_INCOME) STORE_INCOME,
|
||||||
sum(cb.retail_range_income) retail_range_income,
|
|
||||||
sum(cb.retail_same_level_income) retail_same_level_income,
|
|
||||||
sum(cb.real_income_total) real_income_total
|
sum(cb.real_income_total) real_income_total
|
||||||
from cu_member_bonus cb
|
from cu_member_bonus cb
|
||||||
inner join cu_member_settle_period cp
|
inner join cu_member_settle_period cp
|
||||||
|
|
@ -524,4 +522,30 @@ cb.real_income_total,
|
||||||
from dual connect by rownum <= #{rowNum}
|
from dual connect by rownum <= #{rowNum}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<update id="recalculateTeamNewBoxNum">
|
||||||
|
MERGE INTO ${retailsTableName} s
|
||||||
|
USING (
|
||||||
|
SELECT SUM(boxNum) AS boxNum, SUM(pv) AS pv, pk_id
|
||||||
|
FROM (
|
||||||
|
SELECT b.PK_ID,
|
||||||
|
NVL(s.NEW_CONSUME_PV, 0) AS pv
|
||||||
|
FROM ${retailsTableName} s
|
||||||
|
RIGHT JOIN (
|
||||||
|
SELECT cm.PK_ID
|
||||||
|
FROM cu_member cm
|
||||||
|
WHERE cm.PK_ID != #{pkId}
|
||||||
|
START WITH cm.PK_ID = #{pkId}
|
||||||
|
CONNECT BY PRIOR cm.pk_id = cm.pk_parent
|
||||||
|
ORDER BY LEVEL
|
||||||
|
) b ON s.PK_MEMBER = b.PK_ID
|
||||||
|
) c
|
||||||
|
GROUP BY pk_id
|
||||||
|
) result
|
||||||
|
ON (s.PK_MEMBER = result.PK_ID)
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
UPDATE SET
|
||||||
|
s.ENABLE_STATUS = 0,
|
||||||
|
s.TEAM_NEW_PV = result.pv
|
||||||
|
WHERE s.PK_MEMBER = #{pkId}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ import com.hzs.system.config.dto.AreaCurrencyDTO;
|
||||||
import com.hzs.third.pay.ITOnlinePaymentServiceApi;
|
import com.hzs.third.pay.ITOnlinePaymentServiceApi;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -84,6 +85,8 @@ public class CuMemberBusinessServiceImpl implements ICuMemberBusinessService {
|
||||||
private MemberToolsHandler memberToolsHandler;
|
private MemberToolsHandler memberToolsHandler;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
@Autowired
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ICuMemberAccountService iCuMemberAccountService;
|
private ICuMemberAccountService iCuMemberAccountService;
|
||||||
|
|
@ -1241,6 +1244,9 @@ public class CuMemberBusinessServiceImpl implements ICuMemberBusinessService {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handleRetailMemberAccount(saOrder, cuMemberAccountExt);
|
this.handleRetailMemberAccount(saOrder, cuMemberAccountExt);
|
||||||
|
|
||||||
|
// 推送会员激活处理
|
||||||
|
rabbitTemplate.convertAndSend(RabbitMqConstants.ORDER_SECOND_ACTIVATE_COMPENSATION_EXCHANGE, RabbitMqConstants.ORDER_SECOND_ACTIVATE_COMPENSATION_KEY, Collections.singletonList(cuMember.getPkId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|
|
||||||
|
|
@ -687,6 +687,23 @@ public class CuHandleBusinessServiceImpl extends ServiceImpl<CuHandleBusinessMap
|
||||||
saveMemberAwards(handleBusinessVO, loginUser);
|
saveMemberAwards(handleBusinessVO, loginUser);
|
||||||
result = row > 0;
|
result = row > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
// 修改是否激活,旧值为未激活,新值为激活的会员需要推MQ处理秒结状态
|
||||||
|
List<Long> pkMemberList = handleBusinessVO.getBusinessMemberList().stream()
|
||||||
|
.filter(
|
||||||
|
tmpData -> EApprovalBusiness.IS_ACTIVATE.getValue() == tmpData.getBusinessType()
|
||||||
|
&& tmpData.getOldValue().equals(EYesNo.NO.getIntValue() + "")
|
||||||
|
&& tmpData.getNewValue().equals(EYesNo.YES.getIntValue() + "")
|
||||||
|
)
|
||||||
|
.map(BusinessMemberVO::getPkMember)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(pkMemberList)) {
|
||||||
|
// 推送会员激活处理
|
||||||
|
rabbitTemplate.convertAndSend(RabbitMqConstants.ORDER_SECOND_ACTIVATE_COMPENSATION_EXCHANGE, RabbitMqConstants.ORDER_SECOND_ACTIVATE_COMPENSATION_KEY, pkMemberList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,19 @@ public class RabbitMqConstants {
|
||||||
*/
|
*/
|
||||||
public static final String ORDER_SECOND_KEY = PREFIX + "order.second.key";
|
public static final String ORDER_SECOND_KEY = PREFIX + "order.second.key";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 奖金秒接-激活补偿 exchange
|
||||||
|
*/
|
||||||
|
public static final String ORDER_SECOND_ACTIVATE_COMPENSATION_EXCHANGE = PREFIX + "order.second_activate_compensation.exchange";
|
||||||
|
/**
|
||||||
|
* 奖金秒接-激活补偿 queue
|
||||||
|
*/
|
||||||
|
public static final String ORDER_SECOND_ACTIVATE_COMPENSATION_QUEUE = PREFIX + "order.second_activate_compensation.queue";
|
||||||
|
/**
|
||||||
|
* 奖金秒接-激活补偿 key
|
||||||
|
*/
|
||||||
|
public static final String ORDER_SECOND_ACTIVATE_COMPENSATION_KEY = PREFIX + "order.second_activate_compensation.key";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 活动 exchange
|
* 活动 exchange
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue