订单详情接口调整

This commit is contained in:
2025-10-24 16:50:36 +08:00
parent fc62fa3167
commit 22b96b6feb
8 changed files with 218 additions and 298 deletions

View File

@@ -5,8 +5,9 @@ import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.memberapi.api.user.MemberUserApi;
import com.tashow.cloud.trade.controller.admin.order.vo.TradeOrderDetailRespVO;
import com.tashow.cloud.trade.controller.admin.order.vo.TradeOrderPageRespVO;
import com.tashow.cloud.trade.controller.admin.order.vo.TradeOrderPageReqVO;
import com.tashow.cloud.trade.controller.admin.order.vo.TradeOrderPageRespVO;
import com.tashow.cloud.trade.controller.admin.order.vo.TradeOrderSummaryRespVO;
import com.tashow.cloud.trade.convert.order.TradeOrderConvert;
import com.tashow.cloud.trade.dal.dataobject.order.TradeOrderDO;
import com.tashow.cloud.trade.dal.dataobject.order.TradeOrderItemDO;
@@ -91,12 +92,18 @@ public class TradeOrderController {
return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, orderLogs));
}
// // 获得交易订单统计
// @GetMapping("/summary")
//
/**
* 获得交易订单统计
* @return
*/
@GetMapping("/summary")
@PermitAll
// @PreAuthorize("@ss.hasPermission('trade:order:query')")
// public CommonResult<TradeOrderSummaryRespVO> getOrderSummary(TradeOrderPageReqVO reqVO) {
// return success(tradeOrderQueryService.getOrderSummary(reqVO));
// }
public CommonResult<TradeOrderSummaryRespVO> getOrderSummary() {
return success(tradeOrderQueryService.getOrderSummary());
}
//
// // 获得交易订单的物流轨迹
// // id: 交易订单编号

View File

@@ -3,6 +3,7 @@ package com.tashow.cloud.trade.controller.admin.order.vo;
// 移除Swagger相关导入
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.tashow.cloud.common.util.json.databind.StringLocalDateTimeSerializer;
import lombok.Data;
@@ -14,7 +15,7 @@ import java.util.List;
// 管理后台 - 交易订单的详情 Response VO
@Data
@Accessors(chain = true)
public class TradeOrderDetailRespVO {
public class TradeOrderDetailRespVO extends TradeOrderBaseVO{
//订单类目id
private Long orderCategoryId;
@@ -31,14 +32,24 @@ public class TradeOrderDetailRespVO {
private LocalDateTime propertyTime;
//保障状态
private Integer propertyStatus;
//订单金额
private Integer price;
//实付金额
private Integer payPrice;
//优惠金额
private Integer discountPrice;
//退款金额
private Integer refundPrice;
//实收金额
private Integer livePrice;
//支付方式
private Integer payType;
//支付渠道 (线上线下)
private String payChannelCode;
private Integer payChannelCode;
//倒计时()
private String payLastTime;
//财务状态
private Integer financeStatus;
//交易流水号
private String payOrderId;
//支付时间
@@ -53,7 +64,7 @@ public class TradeOrderDetailRespVO {
private List<Item> items;
//服务信息(order_serve_info配置)
private JSONArray tradeServeInfo;
private JSONObject tradeServeInfo;
//扩展服务信息(order_serve_info配置)
private JSONArray tradeExtendServeInfo;
//附加费信息(order_serve_info配置)
@@ -111,7 +122,5 @@ public class TradeOrderDetailRespVO {
private String properties;
//服务内容
private String serveContent;
}
}

View File

@@ -10,13 +10,10 @@ public class TradeOrderSummaryRespVO {
// 订单数量 - 必填示例1024
private Long orderCount;
// 订单金额 - 必填示例1024
private Long orderPayPrice;
// 实付金额 - 必填示例1024
private Long payPrice;
// 退款单数 - 必填示例1024
private Long afterSaleCount;
// 退款金额 - 必填示例1024
private Long afterSalePrice;
// 最终实收金额 - 必填示例1024
private Long livePrice;
}

View File

@@ -2,7 +2,7 @@ package com.tashow.cloud.trade.convert.order;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.common.util.collection.CollectionUtils;
@@ -28,7 +28,6 @@ import com.tashow.cloud.trade.dal.dataobject.order.TradeOrderItemDO;
import com.tashow.cloud.trade.dal.dataobject.order.TradeOrderLogDO;
import com.tashow.cloud.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
import com.tashow.cloud.trade.framework.order.config.TradeOrderProperties;
import com.tashow.cloud.trade.framework.order.core.utils.TransOrderByTempUtils;
import com.tashow.cloud.trade.service.brokerage.bo.BrokerageAddReqBO;
import com.tashow.cloud.trade.service.price.bo.TradePriceCalculateReqBO;
import com.tashow.cloud.trade.service.price.bo.TradePriceCalculateRespBO;
@@ -83,31 +82,20 @@ public interface TradeOrderConvert {
//订单基本信息
TradeOrderDetailRespVO orderVO = convert2(order, orderItems, orderLogs);
//计算商品到手价
orderVO.getItems().stream().forEach(item -> {
item.setHandedPrice(item.getPrice() - item.getDiscountPrice());
item.setTotalPrice(item.getPrice() * item.getCount() - item.getDiscountPrice());
//产品类目在订单详情里
orderVO.setOrderCategoryId(item.getOrderCategoryId());
orderVO.setOrderCategoryName(item.getOrderCategoryName());
//todo 服务保障列表 properties 服务内容 serveContent
//转换
});
//转换服务信息
orderItems.stream().filter(a -> StrUtil.isNotBlank(a.getServeInfo()))
.findAny()
.ifPresent(orderItem -> {
JSONObject transResult = TransOrderByTempUtils.trans(orderItem);
//服务信息(order_serve_info配置)
orderVO.setTradeServeInfo(transResult.getJSONArray("serveInfo"));
//可选服务 //扩展服务信息(order_serve_info配置)
orderVO.setTradeExtendServeInfo(transResult.getJSONArray("selectedServeInfo"));
//服务附加费 //附加费信息(order_serve_info配置)
orderVO.setTradeExtendCostInfo(transResult.getJSONArray("priceExtInfo"));
});
//服务信息
orderItems.stream().filter(a->StrUtil.isNotBlank(a.getServeInfo())).findAny().ifPresent(a -> {
orderVO.setTradeServeInfo(JSON.parseObject(a.getServeInfo()));
orderVO.setTradeExtendServeInfo(JSON.parseArray(a.getServeExtInfo()));
orderVO.setTradeExtendCostInfo(JSON.parseArray(a.getPriceExtInfo()));
});
//保障时间 保障状态 如果状态是已完成 则
if (Objects.equals(order.getOrderStatus(), TradeOrderStatusEnum.COMPLETED.getStatus())) {

View File

@@ -46,15 +46,13 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
.orderByDesc(TradeOrderDO::getId));
}
// TODO @疯狂:如果用 map 返回,要不这里直接用 TradeOrderSummaryRespVO 返回?也算合理,就当 sql 查询出这么个玩意~~
default List<Map<String, Object>> selectOrderSummaryGroupByRefundStatus(TradeOrderPageReqVO reqVO, Set<Long> userIds) {
default List<Map<String, Object>> selectOrderSummary() {
return selectMaps(new MPJLambdaWrapperX<TradeOrderDO>()
.selectAs(TradeOrderDO::getRefundStatus, TradeOrderDO::getRefundStatus) // 售后状态
.selectCount(TradeOrderDO::getId, "count") // 售后状态对应的数量
.selectSum(TradeOrderDO::getPayPrice, "price") // 售后状态对应的支付金额
.inIfPresent(TradeOrderDO::getUserId, userIds)
.betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime())
.groupBy(TradeOrderDO::getRefundStatus)); // 按售后状态分组
.selectCount(TradeOrderDO::getId, "count")
.selectSum(TradeOrderDO::getPayPrice, "payPrice")
.selectSum(TradeOrderDO::getLivePrice, "livePrice")
.groupBy(TradeOrderDO::getId)
);
}
default PageResult<TradeOrderDO> selectPage(AppTradeOrderPageReqVO reqVO, Long userId) {

View File

@@ -70,10 +70,9 @@ public interface TradeOrderQueryService {
/**
* 获得订单统计
*
* @param reqVO 请求参数
* @return 订单统计
*/
TradeOrderSummaryRespVO getOrderSummary(TradeOrderPageReqVO reqVO);
TradeOrderSummaryRespVO getOrderSummary();
/**
* 【会员】获得交易订单分页

View File

@@ -1,7 +1,6 @@
package com.tashow.cloud.trade.service.order;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.tashow.cloud.common.pojo.PageResult;
@@ -18,7 +17,6 @@ import com.tashow.cloud.trade.framework.delivery.core.client.ExpressClientFactor
import com.tashow.cloud.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO;
import com.tashow.cloud.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
import com.tashow.cloud.trade.service.delivery.DeliveryExpressService;
import com.tashow.cloud.tradeapi.enums.order.TradeOrderRefundStatusEnum;
import com.tashow.cloud.tradeapi.enums.order.TradeOrderStatusEnum;
import com.tashow.cloud.tradeapi.enums.order.TradeOrderTypeEnum;
import jakarta.annotation.Resource;
@@ -118,27 +116,12 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
}
@Override
public TradeOrderSummaryRespVO getOrderSummary(TradeOrderPageReqVO reqVO) {
// 根据用户查询条件构建用户编号列表
Set<Long> userIds = buildQueryConditionUserIds(reqVO);
if (userIds == null) { // 没查询到用户,说明肯定也没他的订单
return new TradeOrderSummaryRespVO();
}
// 查询每个售后状态对应的数量、金额
List<Map<String, Object>> list = tradeOrderMapper.selectOrderSummaryGroupByRefundStatus(reqVO, userIds);
TradeOrderSummaryRespVO vo = new TradeOrderSummaryRespVO().setAfterSaleCount(0L).setAfterSalePrice(0L);
for (Map<String, Object> map : list) {
Long count = MapUtil.getLong(map, "count", 0L);
Long price = MapUtil.getLong(map, "price", 0L);
// 未退款的计入订单,部分退款、全部退款计入售后
if (TradeOrderRefundStatusEnum.NONE.getStatus().equals(MapUtil.getInt(map, "refundStatus"))) {
vo.setOrderCount(count).setOrderPayPrice(price);
} else {
vo.setAfterSaleCount(vo.getAfterSaleCount() + count).setAfterSalePrice(vo.getAfterSalePrice() + price);
}
}
return vo;
public TradeOrderSummaryRespVO getOrderSummary() {
List<Map<String, Object>> list = tradeOrderMapper.selectOrderSummary();
return new TradeOrderSummaryRespVO()
.setOrderCount(list.stream().mapToLong(x -> Long.parseLong(x.get("count").toString())).sum())
.setLivePrice(list.stream().mapToLong(x -> Long.parseLong(x.get("livePrice").toString())).sum())
.setPayPrice(list.stream().mapToLong(x -> Long.parseLong(x.get("payPrice").toString())).sum());
}
@Override

View File

@@ -1,244 +1,183 @@
{
"serveInfo": [
{
"key": "petName",
"name": "宠物名字",
"sort": 1
"serveInfo": {
"boneInfo": {
"petName": "aaa",
"petType": "aaa",
"weight": "aaa",
"diedTime": "aaa",
"diedReason": "aaa",
"boneUrl": [
"aaa",
"bbb"
]
},
{
"key": "petType",
"name": "宠物品种",
"sort": 2
},
{
"key": "weight",
"name": "体型/体重",
"sort": 3
},
{
"key": "diedTime",
"name": "离世时间",
"sort": 4
},
{
"key": "diedReason",
"name": "离世原因",
"sort": 5
},
{
"key": "remainsPhoneUrl",
"name": "遗体照片",
"sort": 6
},
{
"key": "subType",
"name": "预约类型",
"sort": 1
},
{
"key": "changeRule",
"name": "更改规则",
"sort": 2
},
{
"key": "subOrder",
"name": "预约时间",
"sort": 3
},
{
"key": "userRemark",
"name": "用户备注",
"sort": 4
},
{
"key": "merchantRemark",
"name": "客服备注",
"sort": 5
},
{
"key": "pickUpAddress",
"name": "取货地址",
"sort": 6
},
{
"key": "sendAddress",
"name": "送货地址",
"sort": 7
"subInfo": {
"subType": "bbbb",
"changeRule": "bbbb",
"subOrder": "bbbb",
"userRemark": "bbbb",
"merchantRemark": "bbbb",
"pickUpAddress": "bbbb",
"sendAddress": "bbbb"
}
],
},
"selectedServeInfo": [
{
"key": "serveUrl",
"name": "服务主图",
"sort": 1
},
{
"key": "prodUrl",
"name": "纪念品主图",
"sort": 1
},
{
"key": "serveName",
"name": "服务名称",
"sort": 2
},
{
"key": "prodName",
"name": "商品名称",
"sort": 2
},
{
"key": "serveDesc",
"name": "服务描述",
"sort": 3
},
{
"key": "prodDesc",
"name": "商品描述",
"sort": 3
},
{
"key": "prodType",
"name": "商品类型",
"sort": 4
},
{
"key": "parentActive",
"name": "父工作流",
"sort": 5
},
{
"key": "count",
"name": "数量",
"sort": 4
},
{
"key": "price",
"name": "单价",
"sort": 5
},
{
"key": "handPrice",
"name": "到手价",
"sort": 6
},
{
"key": "totalPrice",
"name": "商品总价",
"sort": 7
},
{
"key": "discountPrice",
"name": "优惠金额",
"sort": 8
},
{
"key": "payPrice",
"name": "实付金额",
"sort": 9
},
{
"key": "refundMoney",
"name": "累计退款金额",
"sort": 10
},
{
"key": "refundCount",
"name": "累计退款次数",
"sort": 11
},
{
"key": "deliveryType",
"name": "配送方式",
"sort": 12
},
{
"key": "receiptUser",
"name": "收货人",
"sort": 13
},
{
"key": "pickUpUser",
"name": "提货人",
"sort": 13
},
{
"key": "userMobile",
"name": "手机号码",
"sort": 14
},
{
"key": "receiveAddress",
"name": "收货地址",
"sort": 15
},
{
"key": "pickUpAddress",
"name": "自提地址",
"sort": 15
}
[
{
"tempType": 1,
"serve": [
{
"serveUrl": "ccc",
"serveName": "ccc",
"serveDesc": "ccc",
"count": "ccc",
"price": "ccc",
"handPrice": "ccc"
}
],
"totalPrice": "ccc",
"discountPrice": "ccc",
"payPrice": "ccc",
"refundMoney": "ccc",
"refundCount": "ccc"
},
{
"tempType": 2,
"serve": [
{
"serveUrl": "ccc",
"serveName": "ccc",
"serveDesc": "ccc",
"count": "ccc",
"price": "ccc",
"handPrice": "ccc",
"parentActive": "ccc",
"riteAddress": "ccc"
}
],
"totalPrice": "ccc",
"discountPrice": "ccc",
"payPrice": "ccc",
"refundMoney": "ccc",
"refundCount": "ccc"
}
],
[
{
"tempType": 3,
"serveTitle": "骨灰处理",
"serveType": "处理方式",
"serve": [
{
"serveUrl": "ccc",
"serveName": "ccc",
"serveDesc": "ccc",
"count": "ccc",
"price": "ccc",
"handPrice": "ccc"
},
{
"serveUrl": "ccc",
"serveName": "ccc",
"serveDesc": "ccc",
"count": "ccc",
"price": "ccc",
"handPrice": "ccc"
}
],
"totalPrice": "ccc",
"discountPrice": "ccc",
"payPrice": "ccc",
"refundMoney": "ccc",
"refundCount": "ccc"
},
{
"deliveryType": "配送方式",
"receiveUser": "收货人",
"sendUser": "提货人",
"userMobile": "手机号码",
"address": "收货地址"
}
],
[
{
"tempType": 4,
"serve": [
{
"prodUrl": "ccc",
"prodName": "ccc",
"prodDesc": "ccc",
"prodType": "ccc",
"parentActivity": "ccc",
"count": "ccc",
"price": "ccc",
"handPrice": "ccc"
}
],
"totalPrice": "ccc",
"discountPrice": "ccc",
"payPrice": "ccc",
"refundMoney": "ccc",
"refundCount": "ccc"
},
{
"deliveryType": "配送方式",
"receiveUser": "收货人",
"sendUser": "提货人",
"userMobile": "手机号码",
"address": "收货地址"
}
]
],
"priceExtInfo": [
{
"key": "costName",
"name": "费用名称",
"sort": 1
"serveExtFee": "",
"costName": "超区域服务费",
"serveArea": "可服务区域",
"targetArea": "目标区域",
"chargeType": "收费方式",
"payInfo": {
"totalPrice": "11",
"discountPrice": "222",
"payPrice": "333"
},
"refundPrice": "11"
},
{
"key": "serveArea",
"name": "可服务区域",
"sort": 2
"serveExtFee": "",
"respMode": "响应模式",
"respTime": "响应时间",
"chargeType": "收费方式",
"payInfo": {
"totalPrice": "11",
"discountPrice": "222",
"payPrice": "333"
},
"refundPrice": "11"
},
{
"key": "targetArea",
"name": "目标区域",
"sort": 3
"serveExtFee": "",
"costName": "超区域服务费",
"weight": "体型/体重",
"chargeType": "收费方式",
"payInfo": {
"totalPrice": "11",
"discountPrice": "222",
"payPrice": "333"
},
"refundPrice": "11"
},
{
"key": "chargeType",
"name": "收费方式",
"sort": 4
},
{
"key": "respMode",
"name": "响应模式",
"sort": 1
},
{
"key": "respTime",
"name": "响应时间",
"sort": 2
},
{
"key": "weight",
"name": "体型/体重",
"sort": 2
},
{
"key": "chargeTime",
"name": "收费时段",
"sort": 2
},
{
"key": "totalPrice",
"name": "服务总价",
"sort": 5
},
{
"key": "discountPrice",
"name": "优惠金额",
"sort": 6
},
{
"key": "payPrice",
"name": "实付金额",
"sort": 7
},
{
"key": "refundPrice",
"name": "累计退款金额",
"sort": 8
"serveExtFee": "",
"costName": "超区域服务费",
"chargeTime": "收费时段",
"chargeType": "收费方式",
"payInfo": {
"totalPrice": "11",
"discountPrice": "222",
"payPrice": "333"
},
"refundPrice": "11"
}
]
}