feat:收益列表增加关联订单字段
This commit is contained in:
@@ -43,37 +43,18 @@ public class ProfitLogController extends BaseController {
|
||||
@ApiOperation("分页查询门店收益明细表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ProfitLog>> page(ProfitLogParam param) {
|
||||
PageResult<ProfitLog> result = profitLogService.pageRel(param);
|
||||
|
||||
PageParam<ProfitLog, ProfitLogParam> page = new PageParam<>(param);
|
||||
QueryWrapper<ProfitLog> wrapper = page.getWrapper("beginDate", "endDate", "scene");
|
||||
LocalDate beginDate = param.getBeginDate();
|
||||
if(null != beginDate){
|
||||
// Date dBegin = LocalDateUtil.localDate2Date(beginDate);
|
||||
wrapper.ge("create_time", beginDate);
|
||||
}
|
||||
|
||||
LocalDate endDate = param.getEndDate();
|
||||
if(null != endDate){
|
||||
// Date dEnd = LocalDateUtil.localDate2Date(endDate.plusDays(1));
|
||||
wrapper.lt("create_time", endDate.plusDays(1));
|
||||
}
|
||||
|
||||
Integer scene = param.getScene();
|
||||
if(null != scene && scene > 0){
|
||||
wrapper.eq("scene", scene);
|
||||
}
|
||||
|
||||
wrapper.orderByDesc("create_time");
|
||||
Page<ProfitLog> result = profitLogService.page(new Page<>(param.getPage(), param.getLimit()), wrapper);
|
||||
|
||||
JSONObject total = new JSONObject();
|
||||
wrapper.select("ifnull(sum(money), 0) money");
|
||||
ProfitLog sum = profitLogService.getOne(wrapper);
|
||||
if(null != sum){
|
||||
total.put("total", sum.getMoney());
|
||||
}
|
||||
PageResult<ProfitLog> retPage = new PageResult<>(result.getRecords(), result.getTotal());
|
||||
retPage.setOtherData(total);
|
||||
return success(retPage);
|
||||
result.setOtherData(total);
|
||||
return success(result);
|
||||
// 使用关联查询
|
||||
// return success(profitLogService.pageRel(param));
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@ public class ProfitLog implements Serializable {
|
||||
@ApiModelProperty(value = "订单号")
|
||||
private String orderNo;
|
||||
|
||||
@ApiModelProperty(value = "关联订单号")
|
||||
@TableField(exist = false)
|
||||
private String relationOrderNo;
|
||||
|
||||
private Integer orderSource;
|
||||
|
||||
@ApiModelProperty(value = "是否续费订单")
|
||||
@@ -113,4 +117,13 @@ public class ProfitLog implements Serializable {
|
||||
}
|
||||
return sceneDis;
|
||||
}
|
||||
|
||||
public String getRelationOrderNo(){
|
||||
if (null != relationOrderNo){
|
||||
if (relationOrderNo.contains("续租订单:")){//FIXME 还有更好的做法?
|
||||
return relationOrderNo.replace("续租订单:","");
|
||||
}
|
||||
}
|
||||
return relationOrderNo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,55 +4,31 @@
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*,b.user as orderUserName
|
||||
SELECT a.*,b.id,b.comments as relationOrderNo
|
||||
FROM shop_profit_log a
|
||||
LEFT JOIN shop_order_pay b ON a.order_id = b.id
|
||||
<where>
|
||||
<if test="param.profitId != null">
|
||||
AND a.profit_id = #{param.profitId}
|
||||
</if>
|
||||
<if test="param.orderId != null">
|
||||
AND a.order_id = #{param.orderId}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.scene != null">
|
||||
AND a.scene = #{param.scene}
|
||||
</if>
|
||||
<if test="param.money != null">
|
||||
AND a.money = #{param.money}
|
||||
</if>
|
||||
<if test="param.balance != null">
|
||||
AND a.balance = #{param.balance}
|
||||
</if>
|
||||
<if test="param.remark != null">
|
||||
AND a.remark LIKE CONCAT('%', #{param.remark}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
AND a.deleted = 0
|
||||
<if test="param.merchantCode != null">
|
||||
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
<if test="param.beginDate != null">
|
||||
AND a.create_time >= #{param.beginDate}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
<if test="param.endDate != null">
|
||||
AND a.create_time <= #{param.endDate}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.create_time desc
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
|
||||
@@ -34,18 +34,8 @@ public class ProfitLogServiceImpl extends ServiceImpl<ProfitLogMapper, ProfitLog
|
||||
@Override
|
||||
public PageResult<ProfitLog> pageRel(ProfitLogParam param) {
|
||||
PageParam<ProfitLog, ProfitLogParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
|
||||
List<ProfitLog> list = baseMapper.selectPageRel(page, param);
|
||||
if(!CollectionUtils.isEmpty(list)) {
|
||||
Set<Integer> orderIds = list.stream().map(ProfitLog::getOrderId).collect(Collectors.toSet());
|
||||
List<Order> orderList = orderService.lambdaQuery().in(Order::getOrderId, orderIds).list();
|
||||
Map<Integer, List<Order>> collect = orderList.stream().collect(Collectors.groupingBy(Order::getOrderId));
|
||||
|
||||
list.forEach(item -> {
|
||||
item.setOrder(CollectionUtils.firstElement(collect.get(item.getOrderId())));
|
||||
});
|
||||
}
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user