Compare commits

..

2 Commits

@ -93,6 +93,31 @@ public class AppBrokerageUserController {
// 统计分销用户数量(一级) // 统计分销用户数量(一级)
Long firstBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 1); Long firstBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 1);
// 统计分销用户数量(二级) // 统计分销用户数量(二级)
Long secondBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), null);
// 拼接返回
return success(BrokerageUserConvert.INSTANCE.convert(yesterdayPrice, withdrawPrice, firstBrokerageUserCount, secondBrokerageUserCount, brokerageUser));
}
@GetMapping("/get-zdscsummary")
@Operation(summary = "郑大商城获得个人分销统计")
@PreAuthenticated
public CommonResult<AppBrokerageUserMySummaryRespVO> getZdscBrokerageUserSummary() {
// 查询当前登录用户信息
BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(getLoginUserId());
// 统计用户昨日的佣金
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
Integer yesterdayPrice = brokerageRecordService.getSummaryPriceByUserId(brokerageUser.getId(),
BrokerageRecordBizTypeEnum.ORDER, BrokerageRecordStatusEnum.SETTLEMENT, beginTime, endTime);
// 统计用户提现的佣金
Integer withdrawPrice = brokerageWithdrawService.getWithdrawSummaryListByUserId(Collections.singleton(brokerageUser.getId()),
BrokerageWithdrawStatusEnum.AUDIT_SUCCESS).stream()
.findFirst().map(BrokerageWithdrawSummaryRespBO::getPrice).orElse(0);
// 统计直销用户数量(一级)
Long firstBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 1);
// 统计分销用户数量(二级)
Long secondBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 2); Long secondBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 2);
// 拼接返回 // 拼接返回

@ -64,7 +64,7 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
.selectCount(BrokerageRecordDO::getId, UserBrokerageSummaryRespBO::getCount) .selectCount(BrokerageRecordDO::getId, UserBrokerageSummaryRespBO::getCount)
.selectSum(BrokerageRecordDO::getPrice) .selectSum(BrokerageRecordDO::getPrice)
.in(BrokerageRecordDO::getUserId, userIds) .in(BrokerageRecordDO::getUserId, userIds)
.eq(BrokerageRecordDO::getBizId, bizType) .eq(BrokerageRecordDO::getBizType, bizType)
.eq(BrokerageRecordDO::getStatus, status) .eq(BrokerageRecordDO::getStatus, status)
.groupBy(BrokerageRecordDO::getUserId)); // 按照 userId 聚合 .groupBy(BrokerageRecordDO::getUserId)); // 按照 userId 聚合
return BeanUtil.copyToList(list, UserBrokerageSummaryRespBO.class); return BeanUtil.copyToList(list, UserBrokerageSummaryRespBO.class);

@ -63,7 +63,7 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> {
Assert.isTrue(incrCount > 0); Assert.isTrue(incrCount > 0);
LambdaUpdateWrapper<BrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<BrokerageUserDO>() LambdaUpdateWrapper<BrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<BrokerageUserDO>()
.setSql(" brokerage_price = brokerage_price + " + incrCount) .setSql(" brokerage_price = brokerage_price + " + incrCount)
.eq(BrokerageUserDO::getBindUserId, id); .eq(BrokerageUserDO::getId, id);
update(null, lambdaUpdateWrapper); update(null, lambdaUpdateWrapper);
} }
@ -95,7 +95,7 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> {
Assert.isTrue(incrCount < 0); Assert.isTrue(incrCount < 0);
LambdaUpdateWrapper<BrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<BrokerageUserDO>() LambdaUpdateWrapper<BrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<BrokerageUserDO>()
.setSql(" brokerage_price = brokerage_price + " + incrCount) // 负数,所以使用 + 号 .setSql(" brokerage_price = brokerage_price + " + incrCount) // 负数,所以使用 + 号
.eq(BrokerageUserDO::getBindUserId, id); .eq(BrokerageUserDO::getId, id);
return update(null, lambdaUpdateWrapper); return update(null, lambdaUpdateWrapper);
} }

@ -250,7 +250,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
if (CollUtil.isEmpty(userMap)) { if (CollUtil.isEmpty(userMap)) {
return PageResult.empty(); return PageResult.empty();
} }
Integer status = BrokerageRecordStatusEnum.SETTLEMENT.getStatus();
// 2. 分页查询 // 2. 分页查询
IPage<AppBrokerageUserChildSummaryRespVO> pageResult = brokerageUserMapper.selectSummaryPageByUserId( IPage<AppBrokerageUserChildSummaryRespVO> pageResult = brokerageUserMapper.selectSummaryPageByUserId(
MyBatisUtils.buildPage(pageReqVO), BrokerageRecordBizTypeEnum.ORDER.getType(), MyBatisUtils.buildPage(pageReqVO), BrokerageRecordBizTypeEnum.ORDER.getType(),
@ -340,6 +340,64 @@ if(ObjectUtil.isNotEmpty(bindUser)){
* @return * @return
*/ */
private List<Long> getChildUserIdsByLevel(Long bindUserId, Integer level) { private List<Long> getChildUserIdsByLevel(Long bindUserId, Integer level) {
if (bindUserId == null) {
return Collections.emptyList();
}
// 情况一level 为空,查询所有级别---郑大商城无限级别需递归查询
if (level == null) {
// 大商城无限级别需递归查询
List<Long> bindUserIds = recursionChildUserIds(new ArrayList<Long>(), bindUserId);
return bindUserIds;
}
// 先查第 1 级
List<Long> bindUserIds = brokerageUserMapper.selectIdListByBindUserIdIn(Collections.singleton(bindUserId));
if (CollUtil.isEmpty(bindUserIds)) {
return Collections.emptyList();
}
// 情况二level 为 1只查询第 1 级
if (level == 1) {
return bindUserIds;
}
// 情况三level 为 1只查询第 2 级
if (level == 2) {
return brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds);
}
throw exception(BROKERAGE_USER_LEVEL_NOT_SUPPORT);
}
/**
*
*
* @param bindUserIds
* @param bindUserId
* level 1+2
* @return
*/
private List<Long> recursionChildUserIds(List<Long> bindUserIds,Long bindUserId){
if (bindUserId == null) {
return Collections.emptyList();
}
//查询下级
List<Long> childbindUserIds = brokerageUserMapper.selectIdListByBindUserIdIn(Collections.singleton(bindUserId));
if (CollUtil.isNotEmpty(childbindUserIds)) {
bindUserIds.addAll(childbindUserIds);
for (Long userId:childbindUserIds) {
recursionChildUserIds(bindUserIds,userId);
}
}
return bindUserIds;
}
/**
* ------
*
* @param bindUserId
* @param level
* level 1+2
* @return
*/
private List<Long> getChildUserIdsByLevelCopy(Long bindUserId, Integer level) {
if (bindUserId == null) { if (bindUserId == null) {
return Collections.emptyList(); return Collections.emptyList();
} }

@ -6,6 +6,7 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO;
@ -93,13 +94,13 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
} }
// 4. 通知用户 // 4. 通知用户
Map<String, Object> templateParams = MapUtil.<String, Object>builder() // Map<String, Object> templateParams = MapUtil.<String, Object>builder()
.put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime())) // .put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime()))
.put("price", MoneyUtils.fenToYuanStr(withdraw.getPrice())) // .put("price", MoneyUtils.fenToYuanStr(withdraw.getPrice()))
.put("reason", withdraw.getAuditReason()) // .put("reason", withdraw.getAuditReason())
.build(); // .build();
notifyMessageSendApi.sendSingleMessageToMember(new NotifySendSingleToUserReqDTO() // notifyMessageSendApi.sendSingleMessageToMember(new NotifySendSingleToUserReqDTO()
.setUserId(withdraw.getUserId()).setTemplateCode(templateCode).setTemplateParams(templateParams)); // .setUserId(withdraw.getUserId()).setTemplateCode(templateCode).setTemplateParams(templateParams));
} }
private BrokerageWithdrawDO validateBrokerageWithdrawExists(Integer id) { private BrokerageWithdrawDO validateBrokerageWithdrawExists(Integer id) {

@ -27,14 +27,19 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreate
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO;
import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert;
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageRecordMapper;
import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper;
import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper;
import cn.iocoder.yudao.module.trade.dal.redis.no.TradeNoRedisDAO; import cn.iocoder.yudao.module.trade.dal.redis.no.TradeNoRedisDAO;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
import cn.iocoder.yudao.module.trade.enums.order.*; import cn.iocoder.yudao.module.trade.enums.order.*;
import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties;
@ -111,6 +116,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Resource @Resource
private BrokerageUserService brokerageUserService; private BrokerageUserService brokerageUserService;
@Resource
private BrokerageRecordMapper brokerageRecordMapper;
// =================== Order =================== // =================== Order ===================
@ -685,7 +693,12 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Override @Override
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE)
public void pickUpOrderByAdmin(Long id, String pickUpVerifyCode) { public void pickUpOrderByAdmin(Long id, String pickUpVerifyCode) {
boolean b = brokerageUserService.updateUserPriceByBindUserId(id, 30); boolean b = brokerageUserService.updateUserPriceByBindUserId(id, 3000);
// 3. 新增记录
BrokerageUserDO user = brokerageUserService.getBrokerageUser(id);
BrokerageRecordDO record = BrokerageRecordConvert.INSTANCE.convert(user, BrokerageRecordBizTypeEnum.ORDER, "", 0, 3000,
null, "门店核销佣金", null, null);
brokerageRecordMapper.insert(record);
getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode));
} }

@ -5,22 +5,18 @@
<select id="selectSummaryPageByUserId" <select id="selectSummaryPageByUserId"
resultType="cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO"> resultType="cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO">
SELECT bu.id, bu.bind_user_time AS brokerageTime, select * from (SELECT bu.id, bu.bind_user_time AS brokerageTime,
(SELECT SUM(price) FROM trade_brokerage_record r (SELECT SUM(price) FROM trade_brokerage_record r
WHERE r.user_id = bu.id AND biz_type = #{bizType} AND r.status = #{status} AND r.deleted = FALSE) AS brokeragePrice, WHERE r.user_id = bu.id AND biz_type = #{bizType} AND r.status = #{status} AND r.deleted = FALSE) AS
brokeragePrice,
(SELECT COUNT(1) FROM trade_brokerage_record r (SELECT COUNT(1) FROM trade_brokerage_record r
WHERE r.user_id = bu.id AND biz_type = #{bizType} AND r.status = #{status} AND r.deleted = FALSE) AS brokerageOrderCount, WHERE r.user_id = bu.id AND biz_type = #{bizType} AND r.status = #{status} AND r.deleted = FALSE) AS
brokerageOrderCount,
(SELECT COUNT(1) FROM trade_brokerage_user c (SELECT COUNT(1) FROM trade_brokerage_user c
WHERE c.bind_user_id = bu.id AND c.deleted = FALSE) AS brokerageUserCount WHERE c.bind_user_id = bu.id AND c.deleted = FALSE) AS brokerageUserCount
FROM trade_brokerage_user AS bu FROM trade_brokerage_user AS bu
<where> <where>
bu.deleted = false bu.deleted = false
<if test="ids != null and ids.size() > 0">
and bu.id in
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
</where> </where>
<choose> <choose>
<when test="sortingField.field == 'userCount'"> <when test="sortingField.field == 'userCount'">
@ -35,7 +31,15 @@
<otherwise> <otherwise>
ORDER BY bu.bind_user_time DESC ORDER BY bu.bind_user_time DESC
</otherwise> </otherwise>
</choose> </choose>) r
<where>
<if test="ids != null and ids.size() > 0">
and r.id in
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
</where>
</select> </select>
</mapper> </mapper>

@ -43,4 +43,11 @@ public class DistributionLogPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
/**
* 线
*/
@Schema(description = "出线时间")
private LocalDateTime outTime;
} }

@ -64,4 +64,12 @@ public class DistributionLogRespVO {
@ExcelProperty("手机号") @ExcelProperty("手机号")
private String phone; private String phone;
/**
* 线
*/
@Schema(description = "出线时间")
private LocalDateTime outTime;
} }

@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import javax.validation.constraints.*; import javax.validation.constraints.*;
@ -36,4 +38,10 @@ public class DistributionLogSaveReqVO {
@Schema(description = "推荐人会员等级id", example = "10242") @Schema(description = "推荐人会员等级id", example = "10242")
private Long levelId; private Long levelId;
/**
* 线
*/
@Schema(description = "出线时间")
private LocalDateTime outTime;
} }

@ -0,0 +1,103 @@
package cn.iocoder.yudao.module.member.controller.app.distributionlog;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.DistributionLogPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.DistributionLogRespVO;
import cn.iocoder.yudao.module.member.controller.app.distributionlog.vo.AppDistributionLogPageReqVO;
import cn.iocoder.yudao.module.member.controller.app.distributionlog.vo.AppDistributionLogRespVO;
import cn.iocoder.yudao.module.member.controller.app.distributionlog.vo.AppDistributionLogSaveReqVO;
import cn.iocoder.yudao.module.member.convert.distributionlog.DistributionLogConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.member.service.distributionlog.DistributionLogService;
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
@Tag(name = "app五占一接口 - 分销记录")
@RestController
@RequestMapping("/member/distribution-log")
@Validated
public class AppDistributionLogController {
@Resource
private DistributionLogService distributionLogService;
@Resource
private MemberUserService memberUserService;
@GetMapping("/getUserId")
@Operation(summary = "获取登录用户排名")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<?> getDistributionLog() {
//获取用户id
JSONObject obj = new JSONObject();
String rankNum = "请先购买1188产品";
Integer totalNum = 0;
Long loginUserId = getLoginUserId();
DistributionLogDO distributionLogDO1 = new DistributionLogDO();
distributionLogDO1.setGameStatus("1");
//查询所有未出线用户记录
List<DistributionLogDO> list1 = distributionLogService.getDistributionLogList(distributionLogDO1);
if(ObjectUtil.isNotEmpty(list1)){
totalNum = list1.size();
}
//先查询是否购买
DistributionLogDO distributionLogDO = new DistributionLogDO();
distributionLogDO.setMebId(loginUserId);
//查询用户记录
List<DistributionLogDO> list = distributionLogService.getDistributionLogList(distributionLogDO);
if(ObjectUtil.isNotEmpty(list)){
DistributionLogDO dto = list.get(0);
if(ObjectUtil.equal(dto.getGameStatus(),"0")){
rankNum = "已出线";
}else{
if(ObjectUtil.isNotEmpty(list1)){
for (int i = 0; i<list.size(); i++) {
DistributionLogDO dto1 = list.get(i);
if(ObjectUtil.equal(dto.getMebId(),loginUserId)){
rankNum = (i+1)+"名";
}
}
}
}
}
obj.put("rankNum",rankNum);
obj.put("totalNum",totalNum);
return success(obj);
}
@GetMapping("/outTodaypage")
@Operation(summary = "已出线记录")
public CommonResult<PageResult<DistributionLogRespVO>> getDistributionLogPage(@Valid DistributionLogPageReqVO pageReqVO) {
pageReqVO.setGameStatus("0");
PageResult<DistributionLogDO> pageResult = distributionLogService.getDistributionLogPage(pageReqVO);
// 拼接结果返回
List<MemberUserDO> users = memberUserService.getUserList(
convertSet(pageResult.getList(), DistributionLogDO::getMebId));
return success(DistributionLogConvert.INSTANCE.convertPage(pageResult, users));
}
}

@ -0,0 +1,54 @@
package cn.iocoder.yudao.module.member.controller.app.distributionlog.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 分销记录分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AppDistributionLogPageReqVO extends PageParam {
@Schema(description = "推荐人id", example = "5267")
private Long referrerId;
@Schema(description = "推荐人id(便于回溯)", example = "23906")
private Long oldReferrerId;
@Schema(description = "购买人id", example = "6637")
private Long mebId;
@Schema(description = "佣金")
private Integer brokerage;
@Schema(description = "分佣结算核销状态", example = "2")
private String status;
@Schema(description = "游戏状态", example = "2")
private String gameStatus;
@Schema(description = "游戏兑换状态", example = "1")
private String convertStatus;
@Schema(description = "推荐人会员等级id", example = "10242")
private Long levelId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
/**
* 线
*/
@Schema(description = "出线时间")
private LocalDateTime outTime;
}

@ -0,0 +1,75 @@
package cn.iocoder.yudao.module.member.controller.app.distributionlog.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 分销记录 Response VO")
@Data
@ExcelIgnoreUnannotated
public class AppDistributionLogRespVO {
@Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4693")
@ExcelProperty("id主键")
private Long id;
@Schema(description = "推荐人id", example = "5267")
@ExcelProperty("推荐人id")
private Long referrerId;
@Schema(description = "推荐人id(便于回溯)", example = "23906")
@ExcelProperty("推荐人id(便于回溯)")
private Long oldReferrerId;
@Schema(description = "购买人id", example = "6637")
@ExcelProperty("购买人id")
private Long mebId;
@Schema(description = "佣金")
@ExcelProperty("佣金")
private Integer brokerage;
@Schema(description = "分佣结算核销状态", example = "2")
@ExcelProperty("分佣结算核销状态")
private String status;
@Schema(description = "游戏状态", example = "2")
@ExcelProperty("游戏状态")
private String gameStatus;
@Schema(description = "游戏兑换状态", example = "1")
@ExcelProperty("游戏兑换状态")
private String convertStatus;
@Schema(description = "推荐人会员等级id", example = "10242")
@ExcelProperty("推荐人会员等级id")
private Long levelId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "用户昵称", example = "2")
@ExcelProperty("用户昵称")
private String nickname;
@Schema(description = "用户名称", example = "2")
@ExcelProperty("用户名称")
private String userName;
@Schema(description = "手机号", example = "2")
@ExcelProperty("手机号")
private String phone;
/**
* 线
*/
@Schema(description = "出线时间")
@ExcelProperty("出线时间")
private LocalDateTime outTime;
}

@ -0,0 +1,45 @@
package cn.iocoder.yudao.module.member.controller.app.distributionlog.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 分销记录新增/修改 Request VO")
@Data
public class AppDistributionLogSaveReqVO {
@Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4693")
private Long id;
@Schema(description = "推荐人id", example = "5267")
private Long referrerId;
@Schema(description = "推荐人id(便于回溯)", example = "23906")
private Long oldReferrerId;
@Schema(description = "购买人id", example = "6637")
private Long mebId;
@Schema(description = "佣金")
private Integer brokerage;
@Schema(description = "分佣结算核销状态", example = "2")
private String status;
@Schema(description = "游戏状态", example = "2")
private String gameStatus;
@Schema(description = "游戏兑换状态", example = "1")
private String convertStatus;
@Schema(description = "推荐人会员等级id", example = "10242")
private Long levelId;
/**
* 线
*/
@Schema(description = "出线时间")
private LocalDateTime outTime;
}

@ -60,4 +60,9 @@ public class DistributionLogDO extends BaseDO {
*/ */
private Long levelId; private Long levelId;
/**
* 线
*/
private LocalDateTime outTime;
} }

@ -28,7 +28,7 @@ public interface DistributionLogMapper extends BaseMapperX<DistributionLogDO> {
.eqIfPresent(DistributionLogDO::getConvertStatus, reqVO.getConvertStatus()) .eqIfPresent(DistributionLogDO::getConvertStatus, reqVO.getConvertStatus())
.eqIfPresent(DistributionLogDO::getLevelId, reqVO.getLevelId()) .eqIfPresent(DistributionLogDO::getLevelId, reqVO.getLevelId())
.betweenIfPresent(DistributionLogDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(DistributionLogDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(DistributionLogDO::getId)); .orderByAsc(DistributionLogDO::getId));
} }
} }

@ -51,5 +51,12 @@ public interface DistributionLogService {
* @return * @return
*/ */
PageResult<DistributionLogDO> getDistributionLogPage(DistributionLogPageReqVO pageReqVO); PageResult<DistributionLogDO> getDistributionLogPage(DistributionLogPageReqVO pageReqVO);
/**
*
*
* @param pageReqVO
* @return
*/
List<DistributionLogDO> getDistributionLogList(DistributionLogDO pageReqVO);
} }

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.member.service.distributionlog; package cn.iocoder.yudao.module.member.service.distributionlog;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -71,4 +73,29 @@ public class DistributionLogServiceImpl implements DistributionLogService {
return distributionLogMapper.selectPage(pageReqVO); return distributionLogMapper.selectPage(pageReqVO);
} }
@Override
public List<DistributionLogDO> getDistributionLogList(DistributionLogDO pageReqVO) {
LambdaQueryWrapperX<DistributionLogDO> queryWrapperX = new LambdaQueryWrapperX<>();
if(ObjectUtil.isNotEmpty(pageReqVO.getMebId())){
queryWrapperX.eq(DistributionLogDO::getMebId,pageReqVO.getMebId());
}
if(ObjectUtil.isNotEmpty(pageReqVO.getStatus())){
queryWrapperX.eq(DistributionLogDO::getStatus,pageReqVO.getStatus());
}
if(ObjectUtil.isNotEmpty(pageReqVO.getConvertStatus())){
queryWrapperX.eq(DistributionLogDO::getConvertStatus,pageReqVO.getConvertStatus());
}
if(ObjectUtil.isNotEmpty(pageReqVO.getGameStatus())){
queryWrapperX.eq(DistributionLogDO::getGameStatus,pageReqVO.getGameStatus());
}
if(ObjectUtil.isNotEmpty(pageReqVO.getLevelId())){
queryWrapperX.eq(DistributionLogDO::getLevelId,pageReqVO.getLevelId());
}
if(ObjectUtil.isNotEmpty(pageReqVO.getReferrerId())){
queryWrapperX.eq(DistributionLogDO::getReferrerId,pageReqVO.getReferrerId());
}
queryWrapperX.orderByAsc(DistributionLogDO::getId);
return distributionLogMapper.selectList(queryWrapperX);
}
} }

@ -444,28 +444,33 @@ public class MemberUserServiceImpl implements MemberUserService {
.orderByAsc(DistributionMebConfigDO::getLevelId)); .orderByAsc(DistributionMebConfigDO::getLevelId));
//添加5占一 //添加5占一
if(ObjectUtil.isNotEmpty(distributionMebConfigDOS)){ if(ObjectUtil.isNotEmpty(distributionMebConfigDOS)){
//添加5占一游戏 Long l = distributionLogMapper.selectCount(new LambdaQueryWrapperX<DistributionLogDO>().eq(DistributionLogDO::getMebId, userId)
DistributionLogDO distributionLogDO = new DistributionLogDO();
distributionLogDO.setMebId(userId);
distributionLogDO.setStatus("1");
// distributionLogDO.setBrokerage();
distributionLogDO.setGameStatus("1");
distributionLogDO.setConvertStatus("1");
distributionLogMapper.insert(distributionLogDO);
//查询5占一总数
List<DistributionLogDO> distributionLogDOS = distributionLogMapper.selectList(new LambdaQueryWrapperX<DistributionLogDO>()
.orderByAsc(DistributionLogDO::getCreateTime)); .orderByAsc(DistributionLogDO::getCreateTime));
int i1 = distributionLogDOS.size() % 5; if(l == 0){
if(i1 == 0){ //添加5占一游戏
// DistributionLogDO vo = distributionLogDOS.get((distributionLogDOS.size()/5)-1); DistributionLogDO distributionLogDO = new DistributionLogDO();
// vo.setGameStatus("0"); distributionLogDO.setMebId(userId);
// distributionLogMapper.updateById(vo); distributionLogDO.setStatus("1");
List<DistributionLogDO> distributionLogDOS1 = distributionLogDOS.subList(0, (distributionLogDOS.size() / 5)); // distributionLogDO.setBrokerage();
for (DistributionLogDO dt:distributionLogDOS1) { distributionLogDO.setGameStatus("1");
dt.setGameStatus("0"); distributionLogDO.setConvertStatus("1");
} distributionLogDO.setOutTime(LocalDateTime.now());
distributionLogMapper.updateBatch(distributionLogDOS1); distributionLogMapper.insert(distributionLogDO);
//查询5占一总数
List<DistributionLogDO> distributionLogDOS = distributionLogMapper.selectList(new LambdaQueryWrapperX<DistributionLogDO>()
.orderByAsc(DistributionLogDO::getCreateTime));
int i1 = distributionLogDOS.size() % 5;
if(i1 == 0){
DistributionLogDO vo = distributionLogDOS.get((distributionLogDOS.size()/5)-1);
vo.setGameStatus("0");
distributionLogMapper.updateById(vo);
// List<DistributionLogDO> distributionLogDOS1 = distributionLogDOS.subList(0, (distributionLogDOS.size() / 5));
// for (DistributionLogDO dt:distributionLogDOS1) {
// dt.setGameStatus("0");
// }
// distributionLogMapper.updateBatch(distributionLogDOS1);
// distributionLogMapper.up // distributionLogMapper.up
}
} }
} }
@ -482,6 +487,8 @@ public class MemberUserServiceImpl implements MemberUserService {
if(eg.getLevelId() == memberUserDO.getLevelId()){ if(eg.getLevelId() == memberUserDO.getLevelId()){
//添加佣金记录 //添加佣金记录
BrokerageRecordDO brokerageRecordDO = new BrokerageRecordDO(); BrokerageRecordDO brokerageRecordDO = new BrokerageRecordDO();
// brokerageRecordDO.setId(Math.toIntExact(brokerageUserDO.getBindUserId()));
brokerageRecordDO.setBizId(orderId+"");
brokerageRecordDO.setUserId(memberUserDO.getId()); brokerageRecordDO.setUserId(memberUserDO.getId());
brokerageRecordDO.setBizType(1); brokerageRecordDO.setBizType(1);
brokerageRecordDO.setTitle("分销直推佣金"); brokerageRecordDO.setTitle("分销直推佣金");
@ -500,11 +507,15 @@ public class MemberUserServiceImpl implements MemberUserService {
brokerageRecordDO.setSourceUserLevel(configLevelDO.getLevel()); brokerageRecordDO.setSourceUserLevel(configLevelDO.getLevel());
brokerageRecordDO.setSourceUserId(userId); brokerageRecordDO.setSourceUserId(userId);
brokerageRecordMapper.insert(brokerageRecordDO); brokerageRecordMapper.insert(brokerageRecordDO);
//修改推广员佣金
BrokerageUserDO brokerageUserDO1 = brokerageUserMapper.selectById(brokerageUserDO.getBindUserId());
brokerageUserDO1.setBrokeragePrice(eg.getBrokerage()*100+brokerageUserDO1.getBrokeragePrice());
brokerageUserMapper.updateById(brokerageUserDO1);
break; break;
} }
} }
} }
recursionMemberLevel(brokerageUserDO.getId(),orderId); recursionMemberLevel(brokerageUserDO.getBindUserId(),orderId);
} }
} }
} }
@ -514,80 +525,82 @@ public class MemberUserServiceImpl implements MemberUserService {
private void recursionMemberLevel(Long userId,Long orderId){ private void recursionMemberLevel(Long userId,Long orderId){
//查询会员信息 //查询会员信息
MemberUserDO memberUserDO = memberUserMapper.selectById(userId); MemberUserDO memberUserDO = memberUserMapper.selectById(userId);
DistributionStatisticsDO distributionStatisticsDO = new DistributionStatisticsDO(); if(ObjectUtil.isNotEmpty(memberUserDO)){
distributionStatisticsDO.setLevelId(memberUserDO.getLevelId()); DistributionStatisticsDO distributionStatisticsDO = new DistributionStatisticsDO();
distributionStatisticsDO.setMebId(memberUserDO.getId()); distributionStatisticsDO.setLevelId(memberUserDO.getLevelId());
distributionStatisticsDO.setLogId(orderId); distributionStatisticsDO.setMebId(memberUserDO.getId());
distributionStatisticsDO.setStatus("1"); distributionStatisticsDO.setLogId(orderId);
distributionStatisticsMapper.insert(distributionStatisticsDO); distributionStatisticsDO.setStatus("1");
//查询会员当前等级 distributionStatisticsMapper.insert(distributionStatisticsDO);
MemberLevelDO memberLevelDO = memberLevelMapper.selectById(memberUserDO.getLevelId()); //查询会员当前等级
if(ObjectUtil.isNotEmpty(memberLevelDO)){ MemberLevelDO memberLevelDO = memberLevelMapper.selectById(memberUserDO.getLevelId());
//查询上一级会员等级 if(ObjectUtil.isNotEmpty(memberLevelDO)){
MemberLevelDO upLevelDO = memberLevelMapper.selectOne(new LambdaQueryWrapperX<MemberLevelDO>() //查询上一级会员等级
.eq(MemberLevelDO::getStatus, 0) MemberLevelDO upLevelDO = memberLevelMapper.selectOne(new LambdaQueryWrapperX<MemberLevelDO>()
.eq(MemberLevelDO::getDeleted, 0) .eq(MemberLevelDO::getStatus, 0)
.eq(MemberLevelDO::getLevel, (memberLevelDO.getLevel()+1)) .eq(MemberLevelDO::getDeleted, 0)
.orderByAsc(MemberLevelDO::getLevel)); .eq(MemberLevelDO::getLevel, (memberLevelDO.getLevel()+1))
if(ObjectUtil.isNotEmpty(upLevelDO)){ .orderByAsc(MemberLevelDO::getLevel));
if(ObjectUtil.equal(memberLevelDO.getLevel(),1)){//帮扶人不升级 if(ObjectUtil.isNotEmpty(upLevelDO)){
//添加推荐统计 if(ObjectUtil.equal(memberLevelDO.getLevel(),1)){//帮扶人不升级
} //添加推荐统计
if(ObjectUtil.equal(memberLevelDO.getLevel(),2)){//帮扶员升级帮扶驿站 }
//查询会员邀请记录下级会员 if(ObjectUtil.equal(memberLevelDO.getLevel(),2)){//帮扶员升级帮扶驿站
List<BrokerageUserDO> brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX<BrokerageUserDO>() //查询会员邀请记录下级会员
.eq(BrokerageUserDO::getBindUserId, userId) List<BrokerageUserDO> brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX<BrokerageUserDO>()
.ge(BrokerageUserDO::getLevel, memberLevelDO.getLevel()) .eq(BrokerageUserDO::getBindUserId, userId)
.eq(BrokerageUserDO::getDeleted, 0) .ge(BrokerageUserDO::getLevel, memberLevelDO.getLevel())
); .eq(BrokerageUserDO::getDeleted, 0)
if(ObjectUtil.isNotEmpty(brokerageUserDOS)){ );
if(brokerageUserDOS.size()>=3){ if(ObjectUtil.isNotEmpty(brokerageUserDOS)){
//升级会员 if(brokerageUserDOS.size()>=3){
memberUserMapper.updateById(new MemberUserDO() //升级会员
.setId(userId) memberUserMapper.updateById(new MemberUserDO()
.setLevelId(upLevelDO.getId()) .setId(userId)
); .setLevelId(upLevelDO.getId())
brokerageUserMapper.updateById(new BrokerageUserDO() );
.setId(userId) brokerageUserMapper.updateById(new BrokerageUserDO()
.setLevel(upLevelDO.getLevel()) .setId(userId)
); .setLevel(upLevelDO.getLevel())
);
}
} }
//判断上级会员是否升级
BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId);
recursionMemberLevel(brokerageUserDO.getBindUserId(),orderId);
} }
//判断上级会员是否升级 if(ObjectUtil.equal(memberLevelDO.getLevel(),3)){//帮扶驿站升级帮扶中心
BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId); //查询会员邀请记录下级会员
recursionMemberLevel(brokerageUserDO.getBindUserId(),orderId); List<BrokerageUserDO> brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX<BrokerageUserDO>()
} .eq(BrokerageUserDO::getBindUserId, userId)
if(ObjectUtil.equal(memberLevelDO.getLevel(),3)){//帮扶驿站升级帮扶中心 .ge(BrokerageUserDO::getLevel, memberLevelDO.getLevel())
//查询会员邀请记录下级会员 .eq(BrokerageUserDO::getDeleted, 0)
List<BrokerageUserDO> brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX<BrokerageUserDO>() );
.eq(BrokerageUserDO::getBindUserId, userId) //查询会员邀请记录下级会员
.ge(BrokerageUserDO::getLevel, memberLevelDO.getLevel()) List<BrokerageUserDO> brokerageUserDOS1 = brokerageUserMapper.selectList(new LambdaQueryWrapperX<BrokerageUserDO>()
.eq(BrokerageUserDO::getDeleted, 0) .eq(BrokerageUserDO::getBindUserId, userId)
); .ge(BrokerageUserDO::getLevel, 2)
//查询会员邀请记录下级会员 .eq(BrokerageUserDO::getDeleted, 0)
List<BrokerageUserDO> brokerageUserDOS1 = brokerageUserMapper.selectList(new LambdaQueryWrapperX<BrokerageUserDO>() );
.eq(BrokerageUserDO::getBindUserId, userId) if(ObjectUtil.isNotEmpty(brokerageUserDOS)){
.ge(BrokerageUserDO::getLevel, 2) if(brokerageUserDOS.size()>=10 || brokerageUserDOS1.size()>=300){
.eq(BrokerageUserDO::getDeleted, 0) //升级会员
); memberUserMapper.updateById(new MemberUserDO()
if(ObjectUtil.isNotEmpty(brokerageUserDOS)){ .setId(userId)
if(brokerageUserDOS.size()>=10 || brokerageUserDOS1.size()>=300){ .setLevelId(upLevelDO.getId())
//升级会员 );
memberUserMapper.updateById(new MemberUserDO() brokerageUserMapper.updateById(new BrokerageUserDO()
.setId(userId) .setId(userId)
.setLevelId(upLevelDO.getId()) .setLevel(upLevelDO.getLevel())
); );
brokerageUserMapper.updateById(new BrokerageUserDO() }
.setId(userId)
.setLevel(upLevelDO.getLevel())
);
} }
//判断上级会员是否升级
BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId);
recursionMemberLevel(brokerageUserDO.getBindUserId(),orderId);
}
if(ObjectUtil.equal(memberLevelDO.getLevel(),4)){//帮扶中心不做升级
} }
//判断上级会员是否升级
BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId);
recursionMemberLevel(brokerageUserDO.getBindUserId(),orderId);
}
if(ObjectUtil.equal(memberLevelDO.getLevel(),4)){//帮扶中心不做升级
} }
} }
} }

@ -197,8 +197,8 @@ const loginData = reactive({
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE !== 'false', tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE !== 'false',
loginForm: { loginForm: {
tenantName: '郑大钒水', tenantName: '郑大钒水',
username: 'admin', username: 'zhengdafanshui',
password: 'admin123', password: '123456',
captchaVerification: '', captchaVerification: '',
rememberMe: false rememberMe: false
} }

Loading…
Cancel
Save