fix: 商城提成
parent
0dfbe4a2d4
commit
4e56534695
|
@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeGearRes
|
||||||
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderPageReqVO;
|
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderPageReqVO;
|
||||||
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderRespVO;
|
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderRespVO;
|
||||||
import cn.iocoder.yudao.module.shop.controller.app.member.vo.PromoterMemberOrderVO;
|
import cn.iocoder.yudao.module.shop.controller.app.member.vo.PromoterMemberOrderVO;
|
||||||
|
import cn.iocoder.yudao.module.shop.controller.app.member.vo.ShoppingMemberOrderVO;
|
||||||
import cn.iocoder.yudao.module.shop.convert.recharge.RechargeOrderConvert;
|
import cn.iocoder.yudao.module.shop.convert.recharge.RechargeOrderConvert;
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
|
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
|
||||||
import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest;
|
import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest;
|
||||||
|
@ -72,6 +73,15 @@ public class MemberController {
|
||||||
pageRespVO.setPromoterId(SecurityFrameworkUtils.getLoginUserId());
|
pageRespVO.setPromoterId(SecurityFrameworkUtils.getLoginUserId());
|
||||||
return CommonResult.success(rechargeOrderService.promoterOrderInfo(pageRespVO));
|
return CommonResult.success(rechargeOrderService.promoterOrderInfo(pageRespVO));
|
||||||
}
|
}
|
||||||
|
@Operation(summary = "获取当前登录商城数量统计")
|
||||||
|
@RequestMapping(value = "/shoppingOrderCount", method = RequestMethod.GET)
|
||||||
|
@PreAuthenticated
|
||||||
|
@TenantIgnore
|
||||||
|
@Parameter(name = "type", description = "时间类型1、当日2、上周3、上月4、累计", required = true)
|
||||||
|
public CommonResult<ShoppingMemberOrderVO> shoppingOrderCount(@RequestParam Integer type) {
|
||||||
|
return CommonResult.success(rechargeOrderService.shoppingOrderCount(type,SecurityFrameworkUtils.getLoginUserId()));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取当前登录发展会员数量统计")
|
@Operation(summary = "获取当前登录发展会员数量统计")
|
||||||
@RequestMapping(value = "/promoterOrderCount", method = RequestMethod.GET)
|
@RequestMapping(value = "/promoterOrderCount", method = RequestMethod.GET)
|
||||||
@PreAuthenticated
|
@PreAuthenticated
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package cn.iocoder.yudao.module.shop.controller.app.member.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "商城发展数量统计")
|
||||||
|
public class ShoppingMemberOrderVO {
|
||||||
|
@Schema(description = "总金额")
|
||||||
|
private Long memberCount;
|
||||||
|
@Schema(description = "总金额")
|
||||||
|
private BigDecimal totalAmount;
|
||||||
|
@Schema(description = "会员提成")
|
||||||
|
private Integer goodsCommission;
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,4 +72,6 @@ public interface StoreOrderMapper extends BaseMapperX<StoreOrder> {
|
||||||
* @param spreadId 推广人uid
|
* @param spreadId 推广人uid
|
||||||
*/
|
*/
|
||||||
OrderBrokerageData getBrokerageData(@Param("uid") Long uid, @Param("spreadId") Integer spreadId);
|
OrderBrokerageData getBrokerageData(@Param("uid") Long uid, @Param("spreadId") Integer spreadId);
|
||||||
|
|
||||||
|
BigDecimal shoppingOrderCount(@Param("startDate") LocalDateTime startDate, @Param("endDate")LocalDateTime endDate,@Param("promoterId") Long promoterId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.*;
|
||||||
import javax.validation.*;
|
import javax.validation.*;
|
||||||
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*;
|
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*;
|
||||||
import cn.iocoder.yudao.module.shop.controller.app.member.vo.PromoterMemberOrderVO;
|
import cn.iocoder.yudao.module.shop.controller.app.member.vo.PromoterMemberOrderVO;
|
||||||
|
import cn.iocoder.yudao.module.shop.controller.app.member.vo.ShoppingMemberOrderVO;
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
|
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest;
|
import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest;
|
||||||
|
@ -86,4 +87,6 @@ public interface RechargeOrderService {
|
||||||
List<RechargeOrderRespVO> memberOrderInfoByPhone(String phone);
|
List<RechargeOrderRespVO> memberOrderInfoByPhone(String phone);
|
||||||
|
|
||||||
Boolean memberChangeTie(MemberChangeTieRequest changeTieRequest);
|
Boolean memberChangeTie(MemberChangeTieRequest changeTieRequest);
|
||||||
|
|
||||||
|
ShoppingMemberOrderVO shoppingOrderCount(Integer type, Long loginUserId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,9 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.AppUserInfoReqDTO;
|
import cn.iocoder.yudao.module.member.api.user.dto.AppUserInfoReqDTO;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.shop.controller.app.member.vo.PromoterMemberOrderVO;
|
import cn.iocoder.yudao.module.shop.controller.app.member.vo.PromoterMemberOrderVO;
|
||||||
|
import cn.iocoder.yudao.module.shop.controller.app.member.vo.ShoppingMemberOrderVO;
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO;
|
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO;
|
||||||
|
import cn.iocoder.yudao.module.shop.dal.mysql.order.StoreOrderMapper;
|
||||||
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderInfoMapper;
|
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderInfoMapper;
|
||||||
import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest;
|
import cn.iocoder.yudao.module.shop.request.member.MemberChangeTieRequest;
|
||||||
import cn.iocoder.yudao.module.shop.request.member.RefundRequest;
|
import cn.iocoder.yudao.module.shop.request.member.RefundRequest;
|
||||||
|
@ -68,6 +70,9 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
|
||||||
private MemberUserApi memberUserApi;
|
private MemberUserApi memberUserApi;
|
||||||
@Resource
|
@Resource
|
||||||
private TenantApi tenantApi;
|
private TenantApi tenantApi;
|
||||||
|
@Resource
|
||||||
|
private StoreOrderMapper storeOrderMapper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createRechargeOrder(RechargeOrderCreateReqVO createReqVO) {
|
public Long createRechargeOrder(RechargeOrderCreateReqVO createReqVO) {
|
||||||
|
@ -131,21 +136,21 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
|
||||||
Page<PromoterDrawVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
Page<PromoterDrawVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||||
rechargeOrderMapper.findPromoterDrawPage(page, pageReqVO);
|
rechargeOrderMapper.findPromoterDrawPage(page, pageReqVO);
|
||||||
List<PromoterDrawVO> list = page.getRecords();
|
List<PromoterDrawVO> list = page.getRecords();
|
||||||
if(list!=null && list.size() > 0){
|
if (list != null && list.size() > 0) {
|
||||||
List<Long> collect1 = list.stream().map(PromoterDrawVO::getUserId).collect(Collectors.toList());
|
List<Long> collect1 = list.stream().map(PromoterDrawVO::getUserId).collect(Collectors.toList());
|
||||||
List<PromoterDrawVO> promoterDrawVOList = rechargeOrderMapper.findPromoterDrawCount(collect1);
|
List<PromoterDrawVO> promoterDrawVOList = rechargeOrderMapper.findPromoterDrawCount(collect1);
|
||||||
Map<Long,PromoterDrawVO> nameList = promoterDrawVOList.stream().collect(toMap(PromoterDrawVO::getUserId, value -> value,(value1,value2)->value1));
|
Map<Long, PromoterDrawVO> nameList = promoterDrawVOList.stream().collect(toMap(PromoterDrawVO::getUserId, value -> value, (value1, value2) -> value1));
|
||||||
list.forEach(promoterDrawVO -> {
|
list.forEach(promoterDrawVO -> {
|
||||||
PromoterDrawVO promoterDrawNew = nameList.get(promoterDrawVO.getUserId());
|
PromoterDrawVO promoterDrawNew = nameList.get(promoterDrawVO.getUserId());
|
||||||
if(promoterDrawNew!=null){
|
if (promoterDrawNew != null) {
|
||||||
promoterDrawVO.setDealAmount(promoterDrawNew.getDealAmount());
|
promoterDrawVO.setDealAmount(promoterDrawNew.getDealAmount());
|
||||||
promoterDrawVO.setTotalAmount(promoterDrawNew.getTotalAmount());
|
promoterDrawVO.setTotalAmount(promoterDrawNew.getTotalAmount());
|
||||||
promoterDrawVO.setOrderCount(promoterDrawNew.getOrderCount());
|
promoterDrawVO.setOrderCount(promoterDrawNew.getOrderCount());
|
||||||
if(promoterDrawVO.getMemberCommission()==null){
|
if (promoterDrawVO.getMemberCommission() == null) {
|
||||||
promoterDrawVO.setMemberCommission(0);
|
promoterDrawVO.setMemberCommission(0);
|
||||||
}
|
}
|
||||||
promoterDrawVO.setDrawAmount(NumberUtil.mul(promoterDrawNew.getDealAmount(),NumberUtil.div(promoterDrawVO.getMemberCommission().toString(),"100",2)));
|
promoterDrawVO.setDrawAmount(NumberUtil.mul(promoterDrawNew.getDealAmount(), NumberUtil.div(promoterDrawVO.getMemberCommission().toString(), "100"), 2));
|
||||||
}else {
|
} else {
|
||||||
promoterDrawVO.setDealAmount(new BigDecimal(0));
|
promoterDrawVO.setDealAmount(new BigDecimal(0));
|
||||||
promoterDrawVO.setTotalAmount(new BigDecimal(0));
|
promoterDrawVO.setTotalAmount(new BigDecimal(0));
|
||||||
promoterDrawVO.setOrderCount(new BigDecimal(0));
|
promoterDrawVO.setOrderCount(new BigDecimal(0));
|
||||||
|
@ -156,6 +161,7 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
|
||||||
}
|
}
|
||||||
return new PageResult<>(list, page.getTotal());
|
return new PageResult<>(list, page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RechargeOrderDO> getRechargeOrderList(RechargeOrderExportReqVO exportReqVO) {
|
public List<RechargeOrderDO> getRechargeOrderList(RechargeOrderExportReqVO exportReqVO) {
|
||||||
return rechargeOrderMapper.selectList(exportReqVO);
|
return rechargeOrderMapper.selectList(exportReqVO);
|
||||||
|
@ -230,14 +236,14 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PromoterMemberOrderVO promoterOrderCount(Integer type,Long promoterId) {
|
public PromoterMemberOrderVO promoterOrderCount(Integer type, Long promoterId) {
|
||||||
PromoterMemberOrderVO promoterMemberOrderVO = new PromoterMemberOrderVO();
|
PromoterMemberOrderVO promoterMemberOrderVO = new PromoterMemberOrderVO();
|
||||||
AppUserInfoReqDTO appUserInfoReqDTO = new AppUserInfoReqDTO();
|
AppUserInfoReqDTO appUserInfoReqDTO = new AppUserInfoReqDTO();
|
||||||
appUserInfoReqDTO.setPromoterId(promoterId);
|
appUserInfoReqDTO.setPromoterId(promoterId);
|
||||||
if(type==1){
|
if (type == 1) {
|
||||||
appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(LocalDateTime.now()));
|
appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(LocalDateTime.now()));
|
||||||
appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(LocalDateTime.now()));
|
appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(LocalDateTime.now()));
|
||||||
}else if (type == 2){
|
} else if (type == 2) {
|
||||||
LocalDateTime todayOfLastWeek = LocalDateTime.now().minusDays(7);
|
LocalDateTime todayOfLastWeek = LocalDateTime.now().minusDays(7);
|
||||||
LocalDateTime monday = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
LocalDateTime monday = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
||||||
LocalDateTime sunday = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
LocalDateTime sunday = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
||||||
|
@ -250,7 +256,7 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
|
||||||
appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(firstDay));
|
appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(firstDay));
|
||||||
appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(lastDay));
|
appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(lastDay));
|
||||||
}
|
}
|
||||||
BigDecimal totalAmount =rechargeOrderMapper.promoterOrderCount(appUserInfoReqDTO.getStartTime(),appUserInfoReqDTO.getEndTime(),promoterId);
|
BigDecimal totalAmount = rechargeOrderMapper.promoterOrderCount(appUserInfoReqDTO.getStartTime(), appUserInfoReqDTO.getEndTime(), promoterId);
|
||||||
promoterMemberOrderVO.setTotalAmount(totalAmount);
|
promoterMemberOrderVO.setTotalAmount(totalAmount);
|
||||||
promoterMemberOrderVO.setMemberCount(memberUserApi.promoterOrderCount(appUserInfoReqDTO));
|
promoterMemberOrderVO.setMemberCount(memberUserApi.promoterOrderCount(appUserInfoReqDTO));
|
||||||
TenantDTO tenantDTO = tenantApi.getTenant(TenantContextHolder.getTenantId());
|
TenantDTO tenantDTO = tenantApi.getTenant(TenantContextHolder.getTenantId());
|
||||||
|
@ -320,7 +326,36 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
|
||||||
Assert.notNull(loginUser, "登录失效,请重新登录!");
|
Assert.notNull(loginUser, "登录失效,请重新登录!");
|
||||||
MemberUserRespDTO user = userService.getUser(loginUser.getId());
|
MemberUserRespDTO user = userService.getUser(loginUser.getId());
|
||||||
user.setPromoterId(changeTieRequest.getPromoterId());
|
user.setPromoterId(changeTieRequest.getPromoterId());
|
||||||
return memberUserApi.updateById(user)>0;
|
return memberUserApi.updateById(user) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShoppingMemberOrderVO shoppingOrderCount(Integer type, Long promoterId) {
|
||||||
|
ShoppingMemberOrderVO shoppingMemberOrderVO = new ShoppingMemberOrderVO();
|
||||||
|
AppUserInfoReqDTO appUserInfoReqDTO = new AppUserInfoReqDTO();
|
||||||
|
appUserInfoReqDTO.setPromoterId(promoterId);
|
||||||
|
if (type == 1) {
|
||||||
|
appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(LocalDateTime.now()));
|
||||||
|
appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(LocalDateTime.now()));
|
||||||
|
} else if (type == 2) {
|
||||||
|
LocalDateTime todayOfLastWeek = LocalDateTime.now().minusDays(7);
|
||||||
|
LocalDateTime monday = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
||||||
|
LocalDateTime sunday = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
||||||
|
appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(monday));
|
||||||
|
appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(sunday));
|
||||||
|
} else if (type == 3) {
|
||||||
|
LocalDateTime lastMonth = LocalDateTime.now().minusMonths(1); // 当前月份减1
|
||||||
|
LocalDateTime firstDay = lastMonth.with(TemporalAdjusters.firstDayOfMonth()); // 获取当前月的第一天
|
||||||
|
LocalDateTime lastDay = lastMonth.with(TemporalAdjusters.lastDayOfMonth()); // 获取当前月的最后一天
|
||||||
|
appUserInfoReqDTO.setStartTime(LocalDateTimeUtil.beginOfDay(firstDay));
|
||||||
|
appUserInfoReqDTO.setEndTime(LocalDateTimeUtil.endOfDay(lastDay));
|
||||||
|
}
|
||||||
|
BigDecimal totalAmount = storeOrderMapper.shoppingOrderCount(appUserInfoReqDTO.getStartTime(), appUserInfoReqDTO.getEndTime(), promoterId);
|
||||||
|
shoppingMemberOrderVO.setTotalAmount(totalAmount);
|
||||||
|
shoppingMemberOrderVO.setMemberCount(memberUserApi.promoterOrderCount(appUserInfoReqDTO));
|
||||||
|
TenantDTO tenantDTO = tenantApi.getTenant(TenantContextHolder.getTenantId());
|
||||||
|
shoppingMemberOrderVO.setGoodsCommission(tenantDTO.getGoodsCommission());
|
||||||
|
return shoppingMemberOrderVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,4 +51,17 @@
|
||||||
right join eb_user_brokerage_record as br on br.link_id = o.order_id and br.status = 3 and br.uid = #{spreadId}
|
right join eb_user_brokerage_record as br on br.link_id = o.order_id and br.status = 3 and br.uid = #{spreadId}
|
||||||
where o.uid = #{uid} and o.status > 1;
|
where o.uid = #{uid} and o.status > 1;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="shoppingOrderCount" resultType="java.math.BigDecimal">
|
||||||
|
select sum(pay_price) from eb_store_order
|
||||||
|
<where>
|
||||||
|
paid=1 and promoter_id=#{promoterId}
|
||||||
|
<if test="startDate!=null">
|
||||||
|
and pay_time>=#{startDate}
|
||||||
|
</if>
|
||||||
|
<if test="endDate!=null">
|
||||||
|
and pay_time<=#{endDate}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue