推广部分小修改

This commit is contained in:
liuyingfang
2023-07-25 14:41:25 +08:00
parent ae628adba4
commit 817223d79f
9 changed files with 141 additions and 23 deletions

View File

@@ -65,12 +65,12 @@ public class MainPageController {
*/
@GetMapping("/userApp/teamControl")
public Result<Object> teamControl(String name,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "1") Integer current,
@RequestParam(defaultValue = "10") Integer size,
@RequestParam("typeCode") String typeCode){
UserApp result = userAppService.queryUserBaseInfoByToken();
Map<String, Object> merchantProfitVOS = merchantProfitService.teamList(typeCode, result.getUserId(),
page,size,name);
current,size,name);
return ResultGenerator.genSuccessResult(merchantProfitVOS);
}

View File

@@ -14,6 +14,8 @@ import cn.pluss.platform.merchantOrder.MerchantOrderService;
import cn.pluss.platform.merchantProfit.MerchantProfitService;
import cn.pluss.platform.userApp.UserAppService;
import cn.pluss.platform.util.StringUtil;
import cn.pluss.platform.vo.MerchantProfitVO;
import cn.pluss.platform.vo.ProfitOrderVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -124,7 +126,7 @@ public class MerchantProfitController {
map.put("endTime", sdf.parse(endTime));
}
}
//直属
List<MerchantProfit> merchantProfitList = merchantProfitService.queryMerchantProfitPage(map);
if (merchantProfitList != null && merchantProfitList.size() > 0) {
@@ -253,5 +255,17 @@ public class MerchantProfitController {
merchantProfit = merchantProfitService.queryMerchantProfit(merchantProfit);
return ResultGenerator.genSuccessResult(merchantProfit);
}
@GetMapping("/profitOrderList")
public Result<List<ProfitOrderVO>> ProfitOrderList(@RequestParam Integer type, @RequestParam Integer page,
@RequestParam Integer size){
UserApp userApp = userAppService.queryUserAppByToken();
Integer pageSize = size;
Integer offset = (page-1) * size;
if (type == 1) {
return ResultGenerator.genSuccessResult(merchantProfitMapper.directlyOrder(userApp.getUserId(), pageSize, offset));
}
return ResultGenerator.genSuccessResult(merchantProfitMapper.teamOrder(userApp.getUserId(), pageSize, offset));
}
}

View File

@@ -1,9 +1,12 @@
package cn.pluss.platform.mapper;
import cn.pluss.platform.api.PageInfo;
import cn.pluss.platform.dto.MerchantFeeDTO;
import cn.pluss.platform.entity.MerchantChannelStatus;
import cn.pluss.platform.entity.MerchantProfit;
import cn.pluss.platform.vo.DeviceGoodsVO;
import cn.pluss.platform.vo.MerchantProfitVO;
import cn.pluss.platform.vo.ProfitOrderVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -115,7 +118,7 @@ public interface MerchantProfitMapper extends BaseMapper<MerchantProfit> {
BigDecimal getConsumeFeeTeamToday(@Param("userId") String userId);
List<MerchantProfitVO> getTeamList(@Param("typeCode") String typeCode, @Param("userId") Long userId,
@Param("page") Integer page, @Param("size") Integer size, @Param("userName") String userName);
@Param("userName") String userName);
@Select("SELECT\n" +
"\tcount(*) \n" +
@@ -128,5 +131,17 @@ public interface MerchantProfitMapper extends BaseMapper<MerchantProfit> {
List<MerchantChannelStatus> getChannelStatus(@Param("merchantCode") String merchantCode);
/**
* 直属交易
* @param userId
* @param pageSize
* @param offset
* @return
*/
List<ProfitOrderVO> directlyOrder(@Param("userId") Long userId,@Param("pageSize") Integer pageSize,@Param("offset") Integer offset);
/**
* 团队交易
*/
List<ProfitOrderVO> teamOrder(@Param("userId") Long userId,@Param("pageSize") Integer pageSize,@Param("offset") Integer offset);
}

View File

@@ -2,6 +2,7 @@ package cn.pluss.platform.mapper;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -16,6 +17,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.val;
import org.apache.ibatis.annotations.Mapper;
import cn.pluss.platform.entity.UserApp;
@@ -145,6 +147,7 @@ public interface UserAppMapper extends BaseMapper<UserApp> {
* 获取指定进件状态的商户
*/
Integer selectUserAppWithChannelStatusCount(@Param(Constants.WRAPPER) Wrapper<UserApp> updateWrapper);
Integer selectUserAppWithChannelStatusCountV2(@Param("userId") String userId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
/**
* 获取指定进件状态的商户

View File

@@ -248,17 +248,14 @@
<select id="queryMerchantProfitPage" parameterType="java.util.Map"
resultType="cn.pluss.platform.entity.MerchantProfit">
SELECT
u.loginName as childLoginName,
u.trueName as childtrueName,
p.type_code ,
t.loginName as userLoginName,
t.trueName as usertrueName,
profit.*
profit.*,
ua.userType,
bi.alias
FROM
tb_pluss_merchant_profit profit
LEFT JOIN tb_pluss_user_promotion p ON profit.userId = p.parent_user_id
LEFT JOIN tb_pluss_user_info u ON p.user_id = u.id
left join tb_pluss_user_info t on profit.userId=t.id
LEFT JOIN tb_pluss_merchant_order merchantOrder ON profit.orderNumber = merchantOrder.orderNumber
LEFT JOIN tb_pluss_user_app ua ON ua.userId = profit.userId
LEFT JOIN tb_pluss_merchant_base_info bi ON merchantOrder.merchantCode = bi.merchantCode
<where>
profit.userId=#{userId}
<if test="id!= null">
@@ -283,7 +280,7 @@
and profit.merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and profit.merchantName like CONCAT('%',#{merchantName},'%')
and bi.alias like CONCAT('%',#{merchantName},'%')
</if>
<if test="consumeFee!= null">
and profit.consumeFee = #{consumeFee}
@@ -888,7 +885,7 @@
</select>
<select id="getConsumeFeeTeamToday" resultType="java.math.BigDecimal">
SELECT
SUM(v.consumeFee)
IFNULL(SUM(v.consumeFee),0)
FROM
(
SELECT
@@ -904,6 +901,7 @@
LEFT JOIN tb_pluss_merchant_order v ON v.merchantCode = b.merchantCode
WHERE
FIND_IN_SET( p.user_id, ID._ids )
AND b.userId != #{userId}
AND v.status = 1
AND date_format( `v`.`transDt`, '%Y-%m-%d' ) = date_format(( curdate() - INTERVAL 0 DAY ), '%Y-%m-%d' )
</select>
@@ -923,7 +921,10 @@
WHERE
up.parent_user_id = #{userId}
AND up.type_code = #{typeCode}
order by ua.userId ASC limit #{page}, #{size}
<if test="userName != null and userName != ''">
AND ua.userName = #{userName}
</if>
order by ua.userId DESC
</select>
<select id="getChannelStatus" resultType="cn.pluss.platform.entity.MerchantChannelStatus">
SELECT
@@ -933,4 +934,52 @@
WHERE merchantCode = #{merchantCode}
</select>
<select id="directlyOrder" resultType="cn.pluss.platform.vo.ProfitOrderVO">
SELECT
v.merchantName,
v.consumeFee,
v.transDt,
v.orderNumber
FROM
view_base_order v
WHERE v.userId in (select p.user_id from tb_pluss_user_promotion p where p.parent_user_id= #{userId})
order by v.id desc
limit #{pageSize} offset #{offset}
</select>
<select id="teamOrder" resultType="cn.pluss.platform.vo.ProfitOrderVO">
SELECT
v.merchantName,
v.consumeFee,
v.transDt,
v.orderNumber
FROM
view_base_order v
WHERE
v.userId IN (
SELECT
p.user_id
FROM
(
SELECT
@ids AS _ids,
( SELECT @ids := GROUP_CONCAT( user_id ) FROM tb_pluss_user_promotion WHERE FIND_IN_SET( parent_user_id, @ids ) ) AS cids,
@l := @l + 1 AS LEVEL
FROM
tb_pluss_user_promotion,
( SELECT @ids := #{userId}, @l := 0 ) b
WHERE
@ids IS NOT NULL
) ID,
tb_pluss_user_promotion p
WHERE
FIND_IN_SET( p.user_id, ID._ids )
ORDER BY
user_id
)
and v.userId!=#{userId}
ORDER BY
v.id desc
limit #{pageSize} offset #{offset}
</select>
</mapper>

View File

@@ -1666,4 +1666,15 @@
left join tb_pluss_user_info ui on ua.userId = ui.id
where ui.phone = #{phone} and userType not in ('agent_staff','staff') AND LENGTH(ui.phone) = 11
</select>
<select id="selectUserAppWithChannelStatusCountV2" resultType="java.lang.Integer">
SELECT
count(*)
FROM
tb_pluss_user_app ua
LEFT JOIN tb_pluss_user_promotion up ON ua.userId = up.parent_user_id
WHERE
up.parent_user_id = #{userId}
AND up.create_time <![CDATA[ >= ]]> #{startTime}
AND up.create_time <![CDATA[ <= ]]> #{endTime}
</select>
</mapper>

View File

@@ -0,0 +1,20 @@
package cn.pluss.platform.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* 直推间推商户收款
* @author lyf
*/
@Data
public class ProfitOrderVO {
private String merchantName;
private BigDecimal consumeFee;
private String transDt;
private String orderNumber;
}

View File

@@ -8,6 +8,7 @@ import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.entity.UserPromotion;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.mapper.MerchantProfitMapper;
import cn.pluss.platform.mapper.UserAppMapper;
import cn.pluss.platform.mapper.UserPromotionMapper;
import cn.pluss.platform.merchantOrder.MerchantOrderStatisticsService;
import cn.pluss.platform.merchantProfit.MerchantProfitService;
@@ -49,6 +50,8 @@ public class PromoterMainPageServiceImpl implements MainPageService {
private MerchantProfitMapper merchantProfitMapper;
@Resource
private UserPromotionMapper userPromotionMapper;
@Resource
private UserAppMapper userAppMapper;
@Override
public Map<String, Object> getSpreadData(String userId) {
@@ -91,11 +94,7 @@ public class PromoterMainPageServiceImpl implements MainPageService {
BigDecimal todaySum = merchantProfitMapper.getTodaySum(userId);
//今日新增商户数
QueryWrapper<UserApp> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("parentId", queryUserApp.getUserId());
queryWrapper.in("merchantAuditStatus", 3, 4);
queryWrapper.between("createDt", DateUtils.getDayBegin(), DateUtils.getDayEnd());
Integer newMerchantCount = userAppService.getUserAppWithChannelStatus(queryWrapper);
Integer newMerchantCount = userAppMapper.selectUserAppWithChannelStatusCountV2(userId, DateUtils.getDayBegin(), DateUtils.getDayEnd());
//直属商户交易
BigDecimal consumeFee = merchantProfitMapper.getConsumeFee(userId);
//团队商户交易

View File

@@ -1,6 +1,7 @@
package cn.pluss.platform.merchantProfit.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.pluss.platform.api.PageInfo;
import cn.pluss.platform.constants.Constant;
import cn.pluss.platform.entity.*;
import cn.pluss.platform.enums.BstLevelCode;
@@ -30,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Service
@@ -124,12 +126,13 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
default:
throw new MsgException("身份错误");
}
List<MerchantProfitVO> teamList = merchantProfitMapper.getTeamList(typeCode, userId, page,size,name);
// PageInfo<MerchantProfitVO> teamList= merchantProfitMapper.getTeamList(typeCode, userId, page,size,name);
Integer countChild = merchantProfitMapper.getCountChild(userId, typeCode);
//商户列表
if ("MC".equals(typeCode)) {
List<MerchantProfitVO> teamList = merchantProfitMapper.getTeamList(typeCode, userId,name);
for (MerchantProfitVO values : teamList) {
if (values.getMerchantCode() != null) {
String merchantCode = values.getMerchantCode();
@@ -156,17 +159,21 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
}
}
}
teamList = teamList.stream().skip(page * size).limit(size).collect(Collectors.toList());
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("total", countChild);
hashMap.put("teamList", teamList);
return hashMap;
}
//团队管理
List<MerchantProfitVO> teamList = merchantProfitMapper.getTeamList(typeCode, userId,name);
for (MerchantProfitVO values : teamList) {
values.setYestedayConsumeFee(mapperOrderMapper.getPlatformAmtYestday(values.getMerchantCode(),
values.setCurrentMonth(mapperOrderMapper.getPlatformAmtYestday(values.getMerchantCode(),
DateUtils.getBeginDayOfMonth(), DateUtils.getEndDayOfMonth()));
values.setConsumeFee(mapperOrderMapper.getAmountData(values.getMerchantCode()));
}
teamList = teamList.stream().skip(page * size).limit(size).collect(Collectors.toList());
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("total", countChild);
hashMap.put("teamList", teamList);