pull/4/head^2
perry 2023-05-30 18:40:55 +08:00
parent 3702a8b4ef
commit fc29029540
8 changed files with 188 additions and 3 deletions

View File

@ -110,6 +110,18 @@ public class RechargeOrderController {
return success(pageResult);
}
@PostMapping("/findPromoterDrawPage")
@Operation(summary = "获得推广员抽佣统计")
@PreAuthorize("@ss.hasPermission('shop:recharge-order:query')")
@TenantIgnore
public CommonResult<PageResult<PromoterDrawVO>> getRechargeOrderPage(@RequestBody PromoterDrawReqVO pageVO) {
if(!TenantContextHolder.ID_SYSTEM.equals(SecurityFrameworkUtils.getLoginUser().getTenantId())){
pageVO.setTenantId(SecurityFrameworkUtils.getLoginUser().getTenantId());
}
PageResult<PromoterDrawVO> pageResult = rechargeOrderService.findPromoterDrawPage(pageVO);
return success(pageResult);
}
@GetMapping("/export-excel")
@Operation(summary = "导出订单 Excel")

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
public class PromoterDrawReqVO extends PageParam {
private Long tenantId;
@Schema(description = "组织名称")
private String deptName;
@Schema(description = "组织结构名称")
private String parentOrganizationName;
@Schema(description = "推广员名称")
private String nickname;
@Schema(description = "手机号")
private String mobile;
@Schema(description = "成为推广员时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
public class PromoterDrawVO {
@Schema(description = "用户id")
private Long userId;
@Schema(description = "组织id")
private Long deptId;
@Schema(description = "商户id")
private Long tenantId;
@Schema(description = "组织名称")
private String deptName;
@Schema(description = "组织结构名称")
private String parentOrganizationName;
@Schema(description = "推广员名称")
private String nickname;
@Schema(description = "手机号")
private String mobile;
@Schema(description = "成为推广员时间")
private LocalDateTime createTime;
@Schema(description = "会员提成")
private Integer memberCommission;
@Schema(description = "商品提成")
private Integer goodsCommission;
@Schema(description = "成交定单数")
private BigDecimal orderCount;
@Schema(description = "可提现金额")
private BigDecimal drawAmount;
@Schema(description = "成交金额")
private BigDecimal dealAmount;
@Schema(description = "累计金额")
private BigDecimal totalAmount;
}

View File

@ -2,6 +2,9 @@ package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 订单 Response VO")
@ -26,5 +29,6 @@ public class RechargeOrderRespVO extends RechargeOrderBaseVO {
private String parentOrganizationName;
@Schema(description = "推广员名称")
private String nickname;
@Schema(description = "提成金额", required = true, example = "3114")
private BigDecimal commissionPrice;
}

View File

@ -60,6 +60,10 @@ public interface RechargeOrderMapper extends BaseMapperX<RechargeOrderDO> {
.orderByDesc(RechargeOrderDO::getId));
}
IPage<RechargeOrderRespVO> findListPage(IPage<RechargeOrderRespVO> page, @Param("data") RechargeOrderPageReqVO data);
IPage<PromoterDrawVO> findPromoterDrawPage(IPage<PromoterDrawVO> page, @Param("data") PromoterDrawReqVO data);
List<PromoterDrawVO> findPromoterDrawCount(@Param("promoterIds") List<Long> promoterIds);
BigDecimal promoterOrderCount(@Param("startDate") LocalDateTime startDate, @Param("endDate")LocalDateTime endDate,@Param("promoterId") Long promoterId);
List<RechargeOrderExcelVO> findListExcel(@Param("data") RechargeOrderExportReqVO data);

View File

@ -64,7 +64,7 @@ public interface RechargeOrderService {
* @return
*/
PageResult<RechargeOrderRespVO> getRechargeOrderPage(RechargeOrderPageReqVO pageReqVO);
PageResult<PromoterDrawVO> findPromoterDrawPage(PromoterDrawReqVO pageReqVO);
/**
* , Excel
*

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.shop.service.recharge;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
@ -44,6 +45,7 @@ import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.shop.enums.ErrorCodeConstants.*;
import static java.util.stream.Collectors.toMap;
/**
* Service
@ -124,7 +126,36 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
rechargeOrderMapper.findListPage(page, pageReqVO);
return new PageResult<>(page.getRecords(), page.getTotal());
}
@Override
public PageResult<PromoterDrawVO> findPromoterDrawPage(PromoterDrawReqVO pageReqVO) {
Page<PromoterDrawVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
rechargeOrderMapper.findPromoterDrawPage(page, pageReqVO);
List<PromoterDrawVO> list = page.getRecords();
if(list!=null && list.size() > 0){
List<Long> collect1 = list.stream().map(PromoterDrawVO::getUserId).collect(Collectors.toList());
List<PromoterDrawVO> promoterDrawVOList = rechargeOrderMapper.findPromoterDrawCount(collect1);
Map<Long,PromoterDrawVO> nameList = promoterDrawVOList.stream().collect(toMap(PromoterDrawVO::getUserId, value -> value,(value1,value2)->value1));
list.forEach(promoterDrawVO -> {
PromoterDrawVO promoterDrawNew = nameList.get(promoterDrawVO.getUserId());
if(promoterDrawNew!=null){
promoterDrawVO.setDealAmount(promoterDrawNew.getDealAmount());
promoterDrawVO.setTotalAmount(promoterDrawNew.getTotalAmount());
promoterDrawVO.setOrderCount(promoterDrawNew.getOrderCount());
if(promoterDrawVO.getMemberCommission()==null){
promoterDrawVO.setMemberCommission(0);
}
promoterDrawVO.setDrawAmount(NumberUtil.mul(promoterDrawNew.getDealAmount(),NumberUtil.div(promoterDrawVO.getMemberCommission().toString(),"100"),2));
}else {
promoterDrawVO.setDealAmount(new BigDecimal(0));
promoterDrawVO.setTotalAmount(new BigDecimal(0));
promoterDrawVO.setOrderCount(new BigDecimal(0));
promoterDrawVO.setMemberCommission(0);
promoterDrawVO.setDrawAmount(new BigDecimal(0));
}
});
}
return new PageResult<>(list, page.getTotal());
}
@Override
public List<RechargeOrderDO> getRechargeOrderList(RechargeOrderExportReqVO exportReqVO) {
return rechargeOrderMapper.selectList(exportReqVO);

View File

@ -10,6 +10,61 @@
-->
<select id="findPromoterDrawPage" resultType="cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.PromoterDrawVO">
SELECT
a.user_id,
a.dept_id,
a.tenant_id,
c.`name`as dept_name,
c.parent_organization_name,
d.nickname,
d.mobile,
a.create_time,
b.member_commission,
b.goods_commission
FROM
member_promoter a
LEFT JOIN system_dept c on c.id= a.dept_id
LEFT JOIN member_user d on d.id=a.user_id
LEFT JOIN system_tenant b on b.id=a.tenant_id
<where>
<if test="data.tenantId!=null">
and a.tenant_id=#{data.tenantId}
</if>
<if test="data.tenantId!=null">
and c.parent_Organization_name=#{data.parentOrganizationName}
</if>
<if test="data.mobile!=null and data.mobile!=''">
and d.mobile=#{data.mobile}
</if>
<if test="data.nickname!=null and data.nickname!=''">
and d.nickname=#{data.nickname}
</if>
<if test="data.createTime !=null ">
and a.create_time &gt;=#{data.createTime[0]}
</if>
<if test="data.createTime !=null ">
and a.create_time &lt;=#{data.createTime[1]}
</if>
</where>
</select>
<select id="findPromoterDrawCount" resultType="cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.PromoterDrawVO">
select b.promoter_id as user_id,count(case b.paid=1 when 1 then 0 end) as order_count,
sum(case b.paid =1 when 1 then 0 end) as deal_amount,
sum(case b.paid in (1,2) when 1 then 0 end) as total_amount
from cy_recharge_order b
<where>
<if test="promoterIds!=null and promoterIds.size()>0">
and b.promoter_id in
<foreach collection="promoterIds" separator="," open="(" close=")" item="id">
#{id}
</foreach>
</if>
</where>
GROUP BY b.promoter_id
</select>
<select id="findListPage" resultType="cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderRespVO">
select
a.id,
@ -50,6 +105,8 @@
a.pay_type,
a.total_price,
a.pay_price,
a.pay_price,
CONVERT(a.pay_price*e.member_commission/100, DECIMAL(15,2)) as commissionPrice,
a.paid,
d.parent_organization_name
from cy_recharge_order a