用户分账余额记录接口

This commit is contained in:
张松 2025-10-28 16:39:53 +08:00
parent 5f78e3e0c2
commit c199711e4d
6 changed files with 83 additions and 9 deletions

View File

@ -4,6 +4,7 @@ import com.czg.market.dto.MkDistributionWithdrawFlowDTO;
import com.czg.account.entity.UserInfo;
import com.czg.market.dto.MkDistributionUserDTO;
import com.czg.market.entity.MkDistributionWithdrawFlow;
import com.czg.market.service.MkDistributionFlowService;
import com.czg.market.service.MkDistributionUserService;
import com.czg.market.service.MkDistributionWithdrawFlowService;
import com.czg.market.vo.DistributionCenterShopVO;
@ -36,6 +37,8 @@ public class UDistributionController {
private AppWxServiceImpl appWxService;
@Resource
private MkDistributionWithdrawFlowService withdrawFlowService;
@Resource
private MkDistributionFlowService distributionFlowService;
/**
* 分销员购买
@ -150,4 +153,18 @@ public class UDistributionController {
return CzgResult.success(withdrawFlowService.pageInfo(StpKit.USER.getLoginIdAsLong()));
}
/**
* 收益明细
* @param startTime
* @param endTime
* @param shopId
* @param status pending待入账 success已入账
*/
@GetMapping("/distributionFlow")
public CzgResult<Map<String, Object>> distributionFlow(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime,
@RequestParam(required = false) Long shopId, @RequestParam(required = false) String status) {
return CzgResult.success(distributionFlowService.distributionFlow(StpKit.USER.getLoginIdAsLong(), startTime, endTime, shopId, status));
}
}

View File

@ -15,4 +15,6 @@ import java.util.Map;
public interface MkDistributionFlowService extends IService<MkDistributionFlow> {
Map<String, Object> pageInfo(Long shopId, LocalDateTime startTime, LocalDateTime endTime, String key, String status, Long id);
Map<String, Object> distributionFlow(long loginIdAsLong, String startTime, String endTime, Long shopId, String status);
}

View File

@ -18,4 +18,5 @@ public class MkDistributionFlowVO extends MkDistributionFlow implements Serializ
private String orderNo;
private String phone;
private String sourcePhone;
private String shopName;
}

View File

@ -5,6 +5,7 @@ import com.czg.market.vo.MkDistributionFlowVO;
import com.mybatisflex.core.BaseMapper;
import com.czg.market.entity.MkDistributionFlow;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@ -16,5 +17,6 @@ import java.util.List;
*/
public interface MkDistributionFlowMapper extends BaseMapper<MkDistributionFlow> {
List<MkDistributionFlowVO> pageInfo(Long shopId, LocalDateTime startTime, LocalDateTime endTime, String status, String key, Long id);
List<MkDistributionFlowVO> pageInfo(Long shopId, LocalDateTime startTime, LocalDateTime endTime, String status, String key, Long id, String type);
BigDecimal totalAmount(Long shopId, LocalDateTime startTime, LocalDateTime endTime, String status, String key, Long id, String type);
}

View File

@ -1,6 +1,7 @@
package com.czg.service.market.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopInfoService;
@ -40,7 +41,7 @@ public class MkDistributionFlowServiceImpl extends ServiceImpl<MkDistributionFlo
@Override
public Map<String, Object> pageInfo(Long shopId, LocalDateTime startTime, LocalDateTime endTime, String key, String status, Long id) {
PageHelper.startPage(PageUtil.buildPageHelp());
List<MkDistributionFlowVO> list = mapper.pageInfo(shopId, startTime, endTime, status, key, id);
List<MkDistributionFlowVO> list = mapper.pageInfo(shopId, startTime, endTime, status, key, id, null);
Page<MkDistributionFlowVO> page = PageUtil.convert(new PageInfo<>(list));
Map<String, Object> map = BeanUtil.beanToMap(page);
map.put("successAmount", getOne(new QueryWrapper().eq(MkDistributionFlow::getShopId, shopId)
@ -52,4 +53,16 @@ public class MkDistributionFlowServiceImpl extends ServiceImpl<MkDistributionFlo
map.put("balanceAmount", shopInfoService.getById(shopId).getAmount());
return map;
}
@Override
public Map<String, Object> distributionFlow(long loginIdAsLong, String startTime, String endTime, Long shopId, String status) {
PageHelper.startPage(PageUtil.buildPageHelp());
List<MkDistributionFlowVO> list = mapper.pageInfo(shopId, StrUtil.isBlank(startTime) ? null : DateUtil.parseLocalDateTime(startTime),
StrUtil.isBlank(endTime) ? null : DateUtil.parseLocalDateTime(endTime), status,null, null, null);
Page<MkDistributionFlowVO> page = PageUtil.convert(new PageInfo<>(list));
Map<String, Object> map = BeanUtil.beanToMap(page);
map.put("totalAmount", mapper.totalAmount(shopId, StrUtil.isBlank(startTime) ? null : DateUtil.parseLocalDateTime(startTime),
StrUtil.isBlank(endTime) ? null : DateUtil.parseLocalDateTime(endTime), status,null, null, null));
return map;
}
}

View File

@ -5,7 +5,44 @@
<mapper namespace="com.czg.service.market.mapper.MkDistributionFlowMapper">
<select id="pageInfo" resultType="com.czg.market.vo.MkDistributionFlowVO">
select a.*, b.phone, c.phone as sourcePhone from mk_distribution_flow as a
select a.*, b.phone, c.phone as sourcePhone, e.shop_name from mk_distribution_flow as a
left join mk_distribution_user as d on d.id=a.distribution_user_id
left join tb_shop_info as e on e.id=a.shop_id
left join tb_shop_user as b on a.shop_user_id=b.id
left join tb_shop_user as c on c.id=a.shop_user_id
<where>
<if test="shopId != null">
and a.shop_id=#{shopId}
</if>
<if test="startTime != null">
and a.create_time>=#{startTime}
</if>
<if test="endTime != null">
and a.create_time&lt;=#{endTime}
</if>
<if test="status != null and status != ''">
and a.status=#{status}
</if>
<if test="key != null and key != ''">
and (
b.nick_name like concat('%',#{key},'%')
or b.id like concat('%',#{key},'%')
or c.id like concat('%',#{key},'%')
or c.nick_name like concat('%',#{key},'%')
)
</if>
<if test="id != null">
and d.id=#{id}
</if>
<if test="type != null and type != ''">
and a.type=#{type}
</if>
</where>
order by a.create_time desc
</select>
<select id="totalAmount" resultType="java.math.BigDecimal">
select sum(a.amount) from mk_distribution_flow as a
left join mk_distribution_user as d on d.id=a.distribution_user_id
left join tb_shop_user as b on a.shop_user_id=b.id
left join tb_shop_user as c on c.id=a.shop_user_id
@ -21,15 +58,17 @@
</if>
<if test="key != null and key != ''">
and (
b.nick_name like concat('%',#{key},'%')
or b.id like concat('%',#{key},'%')
or c.id like concat('%',#{key},'%')
or c.nick_name like concat('%',#{key},'%')
)
b.nick_name like concat('%',#{key},'%')
or b.id like concat('%',#{key},'%')
or c.id like concat('%',#{key},'%')
or c.nick_name like concat('%',#{key},'%')
)
</if>
<if test="id != null">
and d.id=#{id}
</if>
order by a.create_time desc
<if test="type != null and type != ''">
and a.type=#{type}
</if>
</select>
</mapper>