feat:收益列表增加关联订单字段
This commit is contained in:
@@ -43,37 +43,18 @@ public class ProfitLogController extends BaseController {
|
|||||||
@ApiOperation("分页查询门店收益明细表")
|
@ApiOperation("分页查询门店收益明细表")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public ApiResult<PageResult<ProfitLog>> page(ProfitLogParam param) {
|
public ApiResult<PageResult<ProfitLog>> page(ProfitLogParam param) {
|
||||||
|
PageResult<ProfitLog> result = profitLogService.pageRel(param);
|
||||||
|
|
||||||
PageParam<ProfitLog, ProfitLogParam> page = new PageParam<>(param);
|
PageParam<ProfitLog, ProfitLogParam> page = new PageParam<>(param);
|
||||||
QueryWrapper<ProfitLog> wrapper = page.getWrapper("beginDate", "endDate", "scene");
|
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();
|
JSONObject total = new JSONObject();
|
||||||
wrapper.select("ifnull(sum(money), 0) money");
|
wrapper.select("ifnull(sum(money), 0) money");
|
||||||
ProfitLog sum = profitLogService.getOne(wrapper);
|
ProfitLog sum = profitLogService.getOne(wrapper);
|
||||||
if(null != sum){
|
if(null != sum){
|
||||||
total.put("total", sum.getMoney());
|
total.put("total", sum.getMoney());
|
||||||
}
|
}
|
||||||
PageResult<ProfitLog> retPage = new PageResult<>(result.getRecords(), result.getTotal());
|
result.setOtherData(total);
|
||||||
retPage.setOtherData(total);
|
return success(result);
|
||||||
return success(retPage);
|
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
// return success(profitLogService.pageRel(param));
|
// return success(profitLogService.pageRel(param));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ public class ProfitLog implements Serializable {
|
|||||||
@ApiModelProperty(value = "订单号")
|
@ApiModelProperty(value = "订单号")
|
||||||
private String orderNo;
|
private String orderNo;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "关联订单号")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String relationOrderNo;
|
||||||
|
|
||||||
private Integer orderSource;
|
private Integer orderSource;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否续费订单")
|
@ApiModelProperty(value = "是否续费订单")
|
||||||
@@ -113,4 +117,13 @@ public class ProfitLog implements Serializable {
|
|||||||
}
|
}
|
||||||
return sceneDis;
|
return sceneDis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRelationOrderNo(){
|
||||||
|
if (null != relationOrderNo){
|
||||||
|
if (relationOrderNo.contains("续租订单:")){//FIXME 还有更好的做法?
|
||||||
|
return relationOrderNo.replace("续租订单:","");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return relationOrderNo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,55 +4,31 @@
|
|||||||
|
|
||||||
<!-- 关联查询sql -->
|
<!-- 关联查询sql -->
|
||||||
<sql id="selectSql">
|
<sql id="selectSql">
|
||||||
SELECT a.*,b.user as orderUserName
|
SELECT a.*,b.id,b.comments as relationOrderNo
|
||||||
FROM shop_profit_log a
|
FROM shop_profit_log a
|
||||||
|
LEFT JOIN shop_order_pay b ON a.order_id = b.id
|
||||||
<where>
|
<where>
|
||||||
<if test="param.profitId != null">
|
<if test="param.profitId != null">
|
||||||
AND a.profit_id = #{param.profitId}
|
AND a.profit_id = #{param.profitId}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.orderId != null">
|
|
||||||
AND a.order_id = #{param.orderId}
|
|
||||||
</if>
|
|
||||||
<if test="param.userId != null">
|
<if test="param.userId != null">
|
||||||
AND a.user_id = #{param.userId}
|
AND a.user_id = #{param.userId}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.scene != null">
|
<if test="param.scene != null">
|
||||||
AND a.scene = #{param.scene}
|
AND a.scene = #{param.scene}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.money != null">
|
AND a.deleted = 0
|
||||||
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>
|
|
||||||
<if test="param.merchantCode != null">
|
<if test="param.merchantCode != null">
|
||||||
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
|
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.createTimeStart != null">
|
<if test="param.beginDate != null">
|
||||||
AND a.create_time >= #{param.createTimeStart}
|
AND a.create_time >= #{param.beginDate}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.createTimeEnd != null">
|
<if test="param.endDate != null">
|
||||||
AND a.create_time <= #{param.createTimeEnd}
|
AND a.create_time <= #{param.endDate}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
ORDER BY a.create_time desc
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<!-- 分页查询 -->
|
<!-- 分页查询 -->
|
||||||
|
|||||||
@@ -34,18 +34,8 @@ public class ProfitLogServiceImpl extends ServiceImpl<ProfitLogMapper, ProfitLog
|
|||||||
@Override
|
@Override
|
||||||
public PageResult<ProfitLog> pageRel(ProfitLogParam param) {
|
public PageResult<ProfitLog> pageRel(ProfitLogParam param) {
|
||||||
PageParam<ProfitLog, ProfitLogParam> page = new PageParam<>(param);
|
PageParam<ProfitLog, ProfitLogParam> page = new PageParam<>(param);
|
||||||
//page.setDefaultOrder("create_time desc");
|
|
||||||
|
|
||||||
List<ProfitLog> list = baseMapper.selectPageRel(page, param);
|
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());
|
return new PageResult<>(list, page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user