分销员

This commit is contained in:
曹磊 2024-08-06 22:52:11 +08:00
parent e505863610
commit b08af71547
13 changed files with 514 additions and 28 deletions

View File

@ -53,11 +53,17 @@ public class FxyApplyController {
return Result.success();
}
@GetMapping("/findUserPage")
@ApiOperation("查询(分页)")
public Result findUserPage(FxyApply fxyApply){
return service.findUserPage(fxyApply);
@GetMapping("/findSuperiorFxyPage")
@ApiOperation("查询上级分销员(分页)")
public Result findSuperiorFxyPage(FxyApply fxyApply){
return service.findSuperiorFxyPage(fxyApply);
}
@PostMapping("/setSuperiorFxy")
@ApiOperation("设置上级分销员")
public Result setSuperiorFxy(FxyApply fxyApply){
service.setSuperiorFxy(fxyApply);
return Result.success();
}
}

View File

@ -0,0 +1,64 @@
package com.sqx.modules.bl.commission.fxy.controller;
import com.sqx.common.utils.Result;
import com.sqx.modules.bl.commission.fxy.entity.FxyData;
import com.sqx.modules.bl.commission.fxy.service.FxyDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/commission/fxyData")
@Api(value = "分佣管理", tags = {"分销员数据"})
public class FxyDataController {
@Autowired
private FxyDataService service;
@GetMapping("/findPage")
@ApiOperation("查询(分页)")
public Result findPage(FxyData fxyData){
return service.findPage(fxyData);
}
@GetMapping("/invitationPage")
@ApiOperation("邀请技师或用户(分页)")
public Result invitationPage(FxyData fxyData){
return service.invitationPage(fxyData);
}
@GetMapping("/findOrderPage")
@ApiOperation("分销员订单(分页)")
public Result findOrderPage(FxyData fxyData){
return service.findOrderPage(fxyData);
}
//
// @GetMapping("/artificerPage")
// @ApiOperation("技师(分页)")
// public Result artificerPage(FxyData fxyData){
// return service.artificerPage(jjrData);
// }
//
// @PostMapping("/cancelInvitation")
// @ApiOperation("取消邀请技师")
// public Result cancelInvitation(FxyData fxyData){
// service.cancelInvitation(jjrData);
// return Result.success();
// }
//
// @GetMapping("/jjrList")
// @ApiOperation("经纪人列表")
// public Result jjrList(FxyData fxyData){
// return service.findJjrPage(jjrData);
// }
//
// @PostMapping("/modifyJjr")
// @ApiOperation("技师修改经纪人")
// public Result modifyJjr(FxyData fxyData){
// service.modifyJjr(jjrData);
// return Result.success();
// }
}

View File

@ -13,5 +13,6 @@ public interface FxyApplyDao extends BaseMapper<FxyApply> {
int add(FxyApply fxyApply);
int update(FxyApply fxyApply);
int approve(FxyApply fxyApply);
IPage<FxyApply> findUserPage(Page<FxyApply> page, @Param("params") FxyApply fxyApply);
IPage<FxyApply> findSuperiorFxyPage(Page<FxyApply> page, @Param("params") FxyApply fxyApply);
int setSuperiorFxy(FxyApply fxyApply);
}

View File

@ -0,0 +1,17 @@
package com.sqx.modules.bl.commission.fxy.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sqx.modules.bl.commission.fxy.entity.FxyData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface FxyDataDao extends BaseMapper<FxyData> {
IPage<FxyData> findPage(Page<FxyData> page, @Param("params") FxyData fxyData);
IPage<FxyData> invitationPage(Page<FxyData> page, @Param("params") FxyData fxyData);
IPage<FxyData> userPage(Page<FxyData> page, @Param("params") FxyData fxyData);
IPage<FxyData> findOrderPage(Page<FxyData> page, @Param("params") FxyData fxyData);
}

View File

@ -53,6 +53,21 @@ public class FxyApply implements Serializable {
*/
@TableField(exist = false)
private String invitationCode;
/**
*分销员等级
*/
@TableField(exist = false)
private String blFxyLevel;
/**
*上级分销员
*/
@TableField(exist = false)
private String superiorFxy;
/**
*代理商
*/
@TableField(exist = false)
private String agent;
/**
*备注
*/
@ -94,11 +109,5 @@ public class FxyApply implements Serializable {
@TableField(exist = false)
private Integer limit;
@TableField(exist = false)
private Integer userPage;
@TableField(exist = false)
private Integer userLimit;
public FxyApply() {}
}

View File

@ -0,0 +1,162 @@
package com.sqx.modules.bl.commission.fxy.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @description bl_fxy_data
* 分销员数据
* @author caolei
* @date 2024-08-06
*/
@Data
@TableName("bl_fxy_data")
public class FxyData implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
/**
* ID
*/
private Long id;
/**
*技师用户ID
*/
@TableField(exist = false)
private Long artificerUserId;
/**
*经纪人用户ID
*/
@TableField(exist = false)
private Long userId;
/**
*姓名
*/
@TableField(exist = false)
private String name;
/**
*电话
*/
@TableField(exist = false)
private String phone;
/**
*头像
*/
@TableField(exist = false)
private String avatar;
/**
*昵称
*/
@TableField(exist = false)
private String userName;
/**
*分销员等级
*/
@TableField(exist = false)
private Integer blFxyLevel;
/**
*邀请码
*/
@TableField(exist = false)
private String invitationCode;
/**
*比例
*/
@TableField(exist = false)
private BigDecimal rate;
/**
*备注
*/
@TableField(exist = false)
private String remarks;
/**
*状态
*/
@TableField(exist = false)
private Integer status;
/**
*创建时间
*/
@TableField(exist = false)
private String createTime;
/**
*累计邀请用户
*/
@TableField(exist = false)
private Integer userCount;
/**
*累计邀请下级分析员数量
*/
@TableField(exist = false)
private Integer fxtCount;
/**
*累计成交订单数量
*/
@TableField(exist = false)
private Integer ordersCount;
/**
*当日累计邀请用户
*/
@TableField(exist = false)
private Integer curUserCount;
/**
*当日邀请下级分析员数量
*/
@TableField(exist = false)
private Integer curFxyCount;
/**
*当日成交订单数量
*/
@TableField(exist = false)
private Integer curOrdersCount;
/**
*累计获得佣金
*/
@TableField(exist = false)
private BigDecimal money;
/**
*入住时间
*/
@TableField(exist = false)
private String approveTime;
/**
*标识 1下级分销 2用户
*/
@TableField(exist = false)
private String flag;
/**
*订单号
*/
@TableField(exist = false)
private String tradeNo;
/**
*下单时间
*/
@TableField(exist = false)
private String payTime;
/**
*开始时间
*/
@TableField(exist = false)
private String startTime;
/**
*结束时间
*/
@TableField(exist = false)
private String endTime;
@TableField(exist = false)
private Integer page;
@TableField(exist = false)
private Integer limit;
public FxyData() {}
}

View File

@ -9,6 +9,6 @@ public interface FxyApplyService extends IService<FxyApply> {
int add(FxyApply fxyApply);
int update(FxyApply fxyApply);
int approve(FxyApply fxyApply);
Result findUserPage(FxyApply fxyApply);
Result findSuperiorFxyPage(FxyApply fxyApply);
int setSuperiorFxy(FxyApply fxyApply);
}

View File

@ -0,0 +1,11 @@
package com.sqx.modules.bl.commission.fxy.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sqx.common.utils.Result;
import com.sqx.modules.bl.commission.fxy.entity.FxyData;
public interface FxyDataService extends IService<FxyData> {
Result findPage(FxyData fxyData);
Result invitationPage(FxyData fxyData);
Result findOrderPage(FxyData fxyData);
}

View File

@ -44,8 +44,13 @@ public class FxyApplyServiceImpl extends ServiceImpl<FxyApplyDao, FxyApply> impl
}
@Override
public Result findUserPage(FxyApply fxyApply){
Page<FxyApply> pages=new Page<>(fxyApply.getUserPage(),fxyApply.getUserLimit());
return Result.success().put("data",new PageUtils(baseMapper.findUserPage(pages,fxyApply)));
public Result findSuperiorFxyPage(FxyApply fxyApply){
Page<FxyApply> pages=new Page<>(fxyApply.getPage(),fxyApply.getLimit());
return Result.success().put("data",new PageUtils(baseMapper.findSuperiorFxyPage(pages,fxyApply)));
}
@Override
public int setSuperiorFxy(FxyApply fxyApply){
return baseMapper.setSuperiorFxy(fxyApply);
}
}

View File

@ -0,0 +1,57 @@
package com.sqx.modules.bl.commission.fxy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.common.utils.PageUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.app.entity.UserMoneyDetails;
import com.sqx.modules.app.service.UserMoneyDetailsService;
import com.sqx.modules.artificer.entity.Period;
import com.sqx.modules.bl.commission.fxy.dao.FxyDataDao;
import com.sqx.modules.bl.commission.fxy.entity.FxyData;
import com.sqx.modules.bl.commission.fxy.service.FxyDataService;
import com.sqx.modules.bl.commission.jjr.dao.JjrDataDao;
import com.sqx.modules.bl.commission.jjr.entity.JjrConfig;
import com.sqx.modules.bl.commission.jjr.entity.JjrData;
import com.sqx.modules.bl.commission.jjr.service.JjrConfigService;
import com.sqx.modules.bl.commission.jjr.service.JjrDataService;
import com.sqx.modules.utils.PeriodUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class FxyDataServiceImpl extends ServiceImpl<FxyDataDao, FxyData> implements FxyDataService {
@Override
public Result findPage(FxyData fxyData){
Page<FxyData> pages=new Page<>(fxyData.getPage(),fxyData.getLimit());
return Result.success().put("data",new PageUtils(baseMapper.findPage(pages,fxyData)));
}
@Override
public Result invitationPage(FxyData fxyData){
Page<FxyData> pages=new Page<>(fxyData.getPage(),fxyData.getLimit());
IPage<FxyData> iPage = null;
if(fxyData.getFlag().equals("1")){
iPage = baseMapper.invitationPage(pages,fxyData);
}else{
iPage = baseMapper.userPage(pages,fxyData);
}
return Result.success().put("data",new PageUtils(iPage));
}
@Override
public Result findOrderPage(FxyData fxyData){
Page<FxyData> pages=new Page<>(fxyData.getPage(),fxyData.getLimit());
return Result.success().put("data",new PageUtils(baseMapper.findOrderPage(pages,fxyData)));
}
}

View File

@ -4,9 +4,12 @@
<mapper namespace="com.sqx.modules.bl.commission.fxy.dao.FxyApplyDao">
<select id="findPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyApply">
select a.id,a.user_id,b.avatar,b.user_name,a.name,a.phone,a.remarks,a.create_time,a.status,a.opinion
select a.id,a.user_id,b.avatar,b.user_name,a.name,a.phone,a.remarks,a.create_time,a.status,a.opinion,b.bl_fxy_level,ifnull(c.name,'') as superiorFxy
from bl_fxy_apply a
inner join tb_user b on a.user_id = b.user_id
left join (
select a.name,b.invitation_code from bl_fxy_apply a inner join tb_user b on a.user_id = b.user_id
) c on b.bl_fxy_code = c.invitation_code
where 1=1
<if test="params.status!=null">
and a.status=#{params.status}
@ -50,20 +53,18 @@
where id=#{id}
</update>
<select id="findUserPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyApply">
select b.user_id,b.avatar,b.user_name,b.phone,b.invitation_code
<select id="findSuperiorFxyPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyApply">
select b.user_id,b.avatar,a.name,a.phone,b.invitation_code
from tb_user b
inner join bl_fxy_apply a on a.user_id = b.user_id
where b.status = 1
and b.user_id not in (
select a.user_id
from bl_fxy_apply a
where a.status != 2
)
<if test="params.userName!=null and params.userName!=''">
and b.user_name like concat('%',#{params.userName},'%')
and b.bl_fxy_level = 2
and a.status = 1
<if test="params.name!=null and params.name!=''">
and a.name like concat('%',#{params.name},'%')
</if>
<if test="params.phone!=null and params.phone!=''">
and b.phone like concat('%',#{params.phone},'%')
and a.phone like concat('%',#{params.phone},'%')
</if>
<if test="params.invitationCode!=null and params.invitationCode!=''">
and b.invitation_code like concat('%',#{params.invitationCode},'%')
@ -71,4 +72,10 @@
order by b.user_id
</select>
<update id="setSuperiorFxy" parameterType="com.sqx.modules.bl.commission.fxy.entity.FxyApply">
update tb_user
set bl_fxy_code = #{invitationCode}
where user_id=#{userId}
</update>
</mapper>

View File

@ -0,0 +1,146 @@
<?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.sqx.modules.bl.commission.fxy.dao.FxyDataDao">
<select id="findPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select
x.id,x.user_id,y.avatar,y.user_name,x.name,x.phone,x.remarks,x.create_time,x.status,x.opinion,y.invitation_code,x.approve_time,
ifnull((select count(*) from tb_user ac where ac.bl_fxy_code = y.invitation_code and bl_is_fxy = 0),0) as userCount,
ifnull((select count(*) from tb_user ac where ac.bl_fxy_code = y.invitation_code and bl_is_fxy = 1),0) as fxtCount,
ifnull(t1.ordersCount,0)+ifnull(t2.ordersCount,0) as ordersCount,
ifnull(t3.money,0) as money
from bl_fxy_apply x
inner join tb_user y on x.user_id = y.user_id
left join (
select count(*) as ordersCount, aa.user_id, bb.bl_fxy_code
from (
select o1.orders_id,o1.user_id
from orders o1
left join orders o2 on o1.old_orders_id = o2.orders_id and o2.status != 4
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
where o1.old_orders_id is not null
and o1.status in (3,5)
union all
select o1.orders_id,o1.user_id
from orders o1
where o1.parent_id = 0
and o1.old_orders_id is null
and o1.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.status in (3,5)
) aa inner join tb_user bb on aa.user_id = bb.user_id
group by aa.user_id, bb.bl_fxy_code
) t1 on t1.bl_fxy_code = y.invitation_code
left join (
select count(*) as ordersCount,cc.bl_fxy_code
from (
select o1.orders_id,o1.user_id
from orders o1
left join orders o2 on o1.old_orders_id = o2.orders_id and o2.status != 4
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
where o1.old_orders_id is not null
and o1.status in (3,5)
union all
select o1.orders_id,o1.user_id
from orders o1
where o1.parent_id = 0
and o1.old_orders_id is null
and o1.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.status in (3,5)
) aa inner join tb_user bb on aa.user_id = bb.user_id
inner join tb_user cc on cc.invitation_code = bb.bl_fxy_code
group by cc.bl_fxy_code
) t2 on t2.bl_fxy_code = y.invitation_code
left join (
select sum(money) money,user_id
from user_money_details
where state = 2
and type = 1
and bl_role = 5
group by user_id
) t3 on t3.user_id = x.user_id
where x.status= 1
<if test="params.name!=null and params.name!=''">
and x.name like concat('%',#{params.name},'%')
</if>
<if test="params.phone!=null and params.phone!=''">
and x.phone like concat('%',#{params.phone},'%')
</if>
<if test="params.startTime!=null and params.startTime!=''">
and x.approve_time >= #{params.startTime}
</if>
<if test="params.endTime!=null and params.endTime!=''">
and x.approve_time &lt;= #{params.endTime}
</if>
order by x.id desc
</select>
<select id="invitationPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select a.id,a.user_id,b.avatar,b.user_name,a.name,a.phone,a.remarks,a.create_time
from bl_fxy_apply a
inner join tb_user b on a.user_id = b.user_id
where b.bl_fxy_code = #{params.invitationCode}
<if test="params.name!=null and params.name!=''">
and a.name like concat('%',#{params.name},'%')
</if>
<if test="params.phone!=null and params.phone!=''">
and a.phone like concat('%',#{params.phone},'%')
</if>
order by a.user_id desc
</select>
<select id="userPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select b.user_id,b.avatar,b.user_name as name,b.phone
from tb_user b
where b.bl_fxy_code = #{params.invitationCode}
and b.bl_is_fxy = 0
<if test="params.name!=null and params.name!=''">
and b.user_name like concat('%',#{params.name},'%')
</if>
<if test="params.phone!=null and params.phone!=''">
and b.phone like concat('%',#{params.phone},'%')
</if>
order by b.user_id desc
</select>
<select id="findOrderPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
select a.id,a.user_id,b.avatar,a.name,a.phone,c.trade_no,c.money,c.pay_time,b.bl_fxy_level
from bl_fxy_apply a
inner join tb_user b on a.user_id = b.user_id
inner join pay_details c on a.user_id = c.user_id
where c.state = 1
and c.type = 9
<if test="params.name!=null and params.name!=''">
and b.user_name like concat('%',#{params.name},'%')
</if>
<if test="params.phone!=null and params.phone!=''">
and b.phone like concat('%',#{params.phone},'%')
</if>
<if test="params.startTime!=null and params.startTime!=''">
and c.pay_time >= #{params.startTime}
</if>
<if test="params.endTime!=null and params.endTime!=''">
and c.pay_time &lt;= #{params.endTime}
</if>
order by b.user_id desc
</select>
</mapper>

View File

@ -6,7 +6,7 @@
<select id="findPage" resultType="com.sqx.modules.bl.commission.jjr.entity.JjrData">
select
x.id,x.user_id,y.avatar,y.user_name,x.name,x.phone,x.remarks,x.create_time,x.status,x.opinion,y.invitation_code,x.approve_time,
ifnull(select count(*) from tb_user ac inner join artificer aa on a.user_id = aa.user_id where ac.bl_jjr_code = y.invitation_code,0) as artificerCount,
ifnull((select count(*) from tb_user ac inner join artificer aa on ac.user_id = aa.user_id where ac.bl_jjr_code = y.invitation_code),0) as artificerCount,
ifnull(t1.ordersCount,0) as ordersCount,
ifnull(t3.money,0) as money
from bl_jjr_apply x
@ -46,6 +46,7 @@
from user_money_details
where state = 2
and type = 1
and bl_role = 4
group by user_id
) t3 on t3.user_id = x.user_id
where x.status= 1