From 171cbe9ea184cf373945b1c2ba64b201554a45b2 Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Sat, 15 Nov 2025 19:38:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=AE=B6=E8=AE=A2=E5=8D=95=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=80=80=E6=AC=BE=E6=95=B0=E6=8D=AE=E4=B8=8A=E5=8E=BB?= =?UTF-8?q?=E3=80=82=E5=95=86=E5=AE=B6=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E5=AE=8C=E6=95=B4=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/order/dto/MchOrderInfoDTO.java | 7 +- .../order/dto/MchReturnOrderDetailDTO.java | 193 ++++++++ .../dto/MchReturnOrderItemDetailDTO.java | 106 ++++ .../impl/ShopOrderReturnServiceImpl.java | 158 ++++-- .../mapper/order/ShopOrderBaseMapper.xml | 452 ++++++++++++------ 5 files changed, 745 insertions(+), 171 deletions(-) create mode 100644 mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchReturnOrderDetailDTO.java create mode 100644 mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchReturnOrderItemDetailDTO.java diff --git a/mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchOrderInfoDTO.java b/mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchOrderInfoDTO.java index 10666a79..2d95fff0 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchOrderInfoDTO.java +++ b/mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchOrderInfoDTO.java @@ -42,6 +42,9 @@ public class MchOrderInfoDTO implements Serializable { // 物流轨迹信息(物流,已发货的才有数据) @ApiModelProperty(value = "物流轨迹信息") Map logistics_traces; + + // 退款订单详情 + MchReturnOrderDetailDTO return_order_detail; // 订单信息 @ApiModelProperty(value = "订单编号") @@ -95,16 +98,12 @@ public class MchOrderInfoDTO implements Serializable { private Integer is_deny_return; @ApiModelProperty(value = "异常订单操作流程,0-可操作自行发货,1-可操作订单完成,2-订单完成不可操作") private String operate_flag; - @ApiModelProperty(value = "订单配送预约状态:1-立即配送;2-预约配送") private Integer booking_state; - @ApiModelProperty(value = "预约送达起始时间,格式如:yyyy-MM-dd HH:mm:ss") private Date booking_begin_time; - @ApiModelProperty(value = "预约送达截止时间,格式如:yyyy-MM-dd HH:mm:ss") private Date booking_end_time; - @ApiModelProperty(value = "预订单到达时间戳(秒)") private Long booking_at; } diff --git a/mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchReturnOrderDetailDTO.java b/mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchReturnOrderDetailDTO.java new file mode 100644 index 00000000..93a3c5b6 --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchReturnOrderDetailDTO.java @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit. + * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. + * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. + * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. + * Vestibulum commodo. Ut rhoncus gravida arcu. + */ + +package com.suisung.mall.common.modules.order.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "退款单详情主表实体类 对象", description = "商家版退款单详情主表实体类") +public class MchReturnOrderDetailDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "退货单编号") + private String return_id; + + @ApiModelProperty(value = "订单编号") + private String order_id; + + @ApiModelProperty(value = "买家用户ID") + private Integer buyer_user_id; + + @ApiModelProperty(value = "买家店铺ID") + private Integer buyer_store_id; + + @ApiModelProperty(value = "退货原因ID") + private Integer return_reason_id; + + @ApiModelProperty(value = "退货原因名称") + private String return_reason_name; + + @ApiModelProperty(value = "买家退货留言") + private String return_buyer_message; + + @ApiModelProperty(value = "店铺ID") + private Integer store_id; + + @ApiModelProperty(value = "退货退款金额") + private BigDecimal return_refund_amount; + + @ApiModelProperty(value = "退货佣金费用") + private BigDecimal return_commision_fee; + + @ApiModelProperty(value = "退货状态ID") + private Integer return_state_id; + + @ApiModelProperty(value = "退货状态名称") + private String return_state_name; + + @ApiModelProperty(value = "退货联系电话") + private String return_tel; + + @ApiModelProperty(value = "退货年份") + private Integer return_year; + + @ApiModelProperty(value = "退货月份") + private Integer return_month; + + @ApiModelProperty(value = "退货日期") + private Integer return_day; + + @ApiModelProperty(value = "退货地址") + private String return_addr; + + @ApiModelProperty(value = "退货联系手机") + private Long return_mobile; + + @ApiModelProperty(value = "退货联系电话") + private String return_telephone; + + @ApiModelProperty(value = "退货联系人姓名") + private String return_contact_name; + + @ApiModelProperty(value = "分站ID") + private Integer subsite_id; + + @ApiModelProperty(value = "退货申请时间") + private Date return_add_time; + + @ApiModelProperty(value = "退货完成时间") + private Date return_finish_time; + + @ApiModelProperty(value = "是否已退款(ENUM): 0-未退款; 1-已退款") + private Integer return_is_paid; + + @ApiModelProperty(value = "退款渠道代码") + private String return_channel_code; + + @ApiModelProperty(value = "退款渠道交易ID") + private String return_channel_trans_id; + + @ApiModelProperty(value = "退款渠道处理时间") + private Date return_channel_time; + + @ApiModelProperty(value = "退款渠道状态(ENUM): 0-待退; 1-已退; 2-异常") + private Integer return_channel_flag; + + @ApiModelProperty(value = "支付交易号") + private String deposit_trade_no; + + @ApiModelProperty(value = "支付渠道ID") + private Integer payment_channel_id; + + @ApiModelProperty(value = "商家处理留言") + private String return_store_message; + + @ApiModelProperty(value = "平台退货状态ID") + private Integer plantform_return_state_id; + + @ApiModelProperty(value = "平台退货状态名称") + private String plantform_return_state_name; + + @ApiModelProperty(value = "退货类型(ENUM): 0-不用退货; 1-需要退货") + private Integer return_flag; + + @ApiModelProperty(value = "申请类型(ENUM): 1-退款申请; 2-退货申请; 3-虚拟退款") + private Integer return_type; + + @ApiModelProperty(value = "提交的退货退款金额") + private BigDecimal submit_return_refund_amount; + + @ApiModelProperty(value = "订单商品ID列表") + private List order_item_ids; + + @ApiModelProperty(value = "买家用户名") + private String buyer_user_name; + + @ApiModelProperty(value = "是否有合同类型") + private Boolean contract_type_ids; + + @ApiModelProperty(value = "尝试退款次数") + private Integer try_return_count; + + // 收货地址相关信息 + @ApiModelProperty(value = "收货省份") + private String da_province; + + @ApiModelProperty(value = "收货城市") + private String da_city; + + @ApiModelProperty(value = "收货区县") + private String da_county; + + @ApiModelProperty(value = "收货详细地址") + private String da_address; + + @ApiModelProperty(value = "收货人姓名") + private String da_name; + + @ApiModelProperty(value = "收货人手机号") + private String da_mobile; + + @ApiModelProperty(value = "收货人电话") + private String da_telephone; + + @ApiModelProperty(value = "收货省份ID") + private Integer da_province_id; + + @ApiModelProperty(value = "收货城市ID") + private Integer da_city_id; + + @ApiModelProperty(value = "收货区县ID") + private Integer da_county_id; + + @ApiModelProperty(value = "纬度") + private String da_latitude; + + @ApiModelProperty(value = "经度") + private String da_longitude; + + // 退款商品列表 + @ApiModelProperty(value = "退货商品详情列表") + private List items; +} diff --git a/mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchReturnOrderItemDetailDTO.java b/mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchReturnOrderItemDetailDTO.java new file mode 100644 index 00000000..996c8885 --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/modules/order/dto/MchReturnOrderItemDetailDTO.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit. + * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. + * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. + * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. + * Vestibulum commodo. Ut rhoncus gravida arcu. + */ + +package com.suisung.mall.common.modules.order.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "退款单商品详情实体对象", description = "退款单商品详情实体类") +public class MchReturnOrderItemDetailDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "退货商品项ID") + private Long order_return_item_id; + + @ApiModelProperty(value = "退货单编号") + private String return_id; + + @ApiModelProperty(value = "订单商品项ID") + private Long order_item_id; + + @ApiModelProperty(value = "订单编号") + private String order_id; + + @ApiModelProperty(value = "退货商品数量") + private Integer return_item_num; + + @ApiModelProperty(value = "退货商品小计金额") + private BigDecimal return_item_subtotal; + + @ApiModelProperty(value = "退货原因ID") + private Integer return_reason_id; + + @ApiModelProperty(value = "退货商品备注") + private String return_item_note; + + @ApiModelProperty(value = "退货商品图片") + private String return_item_image; + + @ApiModelProperty(value = "退货商品状态ID") + private Integer return_state_id; + + @ApiModelProperty(value = "退货商品佣金费用") + private BigDecimal return_item_commision_fee; + + @ApiModelProperty(value = "退货商品商家备注") + private String return_item_store_remark; + + // 关联的订单商品信息 + @ApiModelProperty(value = "商品名称") + private String item_name; + + @ApiModelProperty(value = "产品名称") + private String product_name; + + @ApiModelProperty(value = "货品ID") + private Long item_id; + + @ApiModelProperty(value = "订单商品图片") + private String order_item_image; + + @ApiModelProperty(value = "单位ID") + private Integer unit_id; + + @ApiModelProperty(value = "单位名称") + private String unit_name; + + @ApiModelProperty(value = "订单商品单价") + private BigDecimal order_item_unit_price; + + @ApiModelProperty(value = "订单商品数量") + private Integer order_item_quantity; + + @ApiModelProperty(value = "订单商品总金额") + private BigDecimal order_item_amount; + + @ApiModelProperty(value = "订单商品总重量") + private BigDecimal order_item_weight_total; + + @ApiModelProperty(value = "订单商品备注") + private String order_item_note; + + @ApiModelProperty(value = "商品编号") + private String item_number; + + @ApiModelProperty(value = "产品编号") + private String product_number; +} diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderReturnServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderReturnServiceImpl.java index b803fb8d..d1b6066e 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderReturnServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderReturnServiceImpl.java @@ -1151,45 +1151,91 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl(); + } Map return_row = Convert.toMap(String.class, Object.class, shopOrderReturn); + // 2. 获取退货单商品明细 QueryWrapper itemQueryWrapper = new QueryWrapper<>(); itemQueryWrapper.eq("return_id", return_id); List shopOrderReturnItems = orderReturnItemService.find(itemQueryWrapper); List return_item_rows = Convert.toList(Map.class, shopOrderReturnItems); - List order_item_ids = shopOrderReturnItems.stream().map(s -> s.getOrder_item_id()).distinct().collect(Collectors.toList()); + List order_item_ids = shopOrderReturnItems.stream() + .map(ShopOrderReturnItem::getOrder_item_id) + .distinct() + .collect(Collectors.toList()); + // 3. 获取原订单详情 String order_id = shopOrderReturn.getOrder_id(); Map order_row = shopOrderBaseService.getOrderDetail(order_id, null); + if (order_row == null) { + logger.warn("原订单详情不存在: order_id={}", order_id); + return return_row; + } + + // 4. 获取退货原因列表 List return_reason_rows = orderReturnReasonService.find(new QueryWrapper<>()); + // 5. 获取订单收货地址信息 ShopOrderDeliveryAddress deliveryAddress = orderDeliveryAddressService.get(order_id); - Map order_delivery = Convert.toMap(String.class, Object.class, deliveryAddress); - return_row.putAll(order_delivery); + if (deliveryAddress != null) { + Map order_delivery = Convert.toMap(String.class, Object.class, deliveryAddress); + return_row.putAll(order_delivery); + } + // 6. 获取订单商品相关信息 List order_row_items = (List) order_row.get("items"); + if (CollUtil.isEmpty(order_row_items)) { + logger.warn("订单商品列表为空: order_id={}", order_id); + return_row.put("items", new ArrayList<>()); + return return_row; + } - List item_ids = order_row_items.stream().map(s -> Convert.toLong(s.get("item_id"))).distinct().collect(Collectors.toList()); - List product_items = shopProductItemService.gets(item_ids); + List item_ids = order_row_items.stream() + .map(s -> Convert.toLong(s.get("item_id"))) + .filter(Objects::nonNull) + .distinct() + .collect(Collectors.toList()); - List product_ids = order_row_items.stream().map(s -> Convert.toInt(s.get("product_id"))).distinct().collect(Collectors.toList()); - List product_infos = shopProductInfoService.gets(product_ids); + List product_items = CollUtil.isEmpty(item_ids) ? new ArrayList<>() : + shopProductItemService.gets(item_ids); - List product_indexs = shopProductIndexService.gets(product_ids); + List product_ids = order_row_items.stream() + .map(s -> Convert.toInt(s.get("product_id"))) + .filter(Objects::nonNull) + .distinct() + .collect(Collectors.toList()); - // 退货商品数据 - Map return_item_temp_rows = new HashMap(); + List product_infos = CollUtil.isEmpty(product_ids) ? new ArrayList<>() : + shopProductInfoService.gets(product_ids); + + List product_indexs = CollUtil.isEmpty(product_ids) ? new ArrayList<>() : + shopProductIndexService.gets(product_ids); + + // 7. 构建退货商品临时数据映射 + Map return_item_temp_rows = new HashMap<>(); for (Map item : order_row_items) { Long order_item_id = Convert.toLong(item.get("order_item_id")); + // 只处理当前退货单相关的订单商品 if (order_item_ids.contains(order_item_id)) { Map order_item = new HashMap(); Long item_id = Convert.toLong(item.get("item_id")); Integer product_id = Convert.toInt(item.get("product_id")); + // 复制订单商品基本信息 order_item.put("item_name", item.get("item_name")); order_item.put("product_name", item.get("product_name")); order_item.put("item_id", item_id); @@ -1202,55 +1248,113 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl productItemOpl = product_items.stream().filter(s -> ObjectUtil.equal(item_id, Convert.toInt(s.get("item_id")))).findFirst(); - Map productItem = productItemOpl.orElseGet(HashMap::new); - order_item.put("item_number", productItem.get("item_number")); + // 关联SKU信息 + if (CollUtil.isNotEmpty(product_items)) { + Optional productItemOpl = product_items.stream() + .filter(s -> ObjectUtil.equal(item_id, Convert.toLong(s.get("item_id")))) + .findFirst(); + Map productItem = productItemOpl.orElse(new HashMap<>()); + order_item.put("item_number", productItem.get("item_number")); + } - Optional productInfoOpl = product_infos.stream().filter(s -> ObjectUtil.equal(product_id, s.getProduct_id())).findFirst(); - ShopProductInfo productInfo = productInfoOpl.orElseGet(ShopProductInfo::new); - order_item.put("product_number", productInfo.getProduct_number()); + // 关联商品信息 + if (CollUtil.isNotEmpty(product_infos)) { + Optional productInfoOpl = product_infos.stream() + .filter(s -> ObjectUtil.equal(product_id, s.getProduct_id())) + .findFirst(); + ShopProductInfo productInfo = productInfoOpl.orElse(new ShopProductInfo()); + order_item.put("product_number", productInfo.getProduct_number()); + } return_item_temp_rows.put(order_item_id, order_item); } } + // 8. 合并退货商品详细信息 for (Map return_item_row : return_item_rows) { Long order_item_id = Convert.toLong(return_item_row.get("order_item_id")); - Map return_item_temp_row = (Map) return_item_temp_rows.get(order_item_id); - return_item_row.putAll(ObjectUtil.defaultIfNull(return_item_temp_row, new HashMap())); + Map return_item_temp_row = return_item_temp_rows.get(order_item_id); + // 合并订单商品信息到退货商品中 + if (return_item_temp_row != null) { + return_item_row.putAll(return_item_temp_row); + } + + // 处理退货图片信息 String return_item_image = (String) return_item_row.get("return_item_image"); if (StrUtil.isNotBlank(return_item_image)) { - return_item_row.put("return_item_image", Convert.toList(String.class, return_item_image)); + // 如果是逗号分隔的图片字符串,转换为列表 + if (return_item_image.contains(",")) { + return_item_row.put("return_item_image", + Arrays.asList(return_item_image.split(","))); + } else { + return_item_row.put("return_item_image", + Collections.singletonList(return_item_image)); + } } else { return_item_row.put("return_item_image", new ArrayList<>()); } } + // 9. 处理合同类型信息 if (CollUtil.isNotEmpty(product_indexs)) { - return_row.put("contract_type_ids", StrUtil.isNotEmpty(product_indexs.get(0).getContract_type_ids())); + ShopProductIndex firstIndex = product_indexs.get(0); + if (firstIndex != null && StrUtil.isNotEmpty(firstIndex.getContract_type_ids())) { + return_row.put("contract_type_ids", true); + } else { + return_row.put("contract_type_ids", false); + } + } else { + return_row.put("contract_type_ids", false); } + // 10. 添加买家信息 return_row.put("buyer_user_name", order_row.get("buyer_user_name")); - BigDecimal return_item_subtotal = shopOrderReturnItems.stream().map(s -> s.getReturn_item_subtotal()).reduce(BigDecimal.ZERO, BigDecimal::add); + // 11. 计算退货总金额 + BigDecimal return_item_subtotal = shopOrderReturnItems.stream() + .map(ShopOrderReturnItem::getReturn_item_subtotal) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); return_row.put("submit_return_refund_amount", return_item_subtotal); return_row.put("order_item_ids", order_item_ids); + // 12. 处理退货原因名称 Integer return_reason_id = Convert.toInt(return_row.get("return_reason_id")); - Optional reasonOpl = return_reason_rows.stream().filter(s -> ObjectUtil.equal(return_reason_id, s.getReturn_reason_id())).findFirst(); - ShopOrderReturnReason returnReason = reasonOpl.orElseGet(ShopOrderReturnReason::new); - return_row.put("return_reason_name", returnReason.getReturn_reason_name()); + if (return_reason_id != null && CollUtil.isNotEmpty(return_reason_rows)) { + Optional reasonOpl = return_reason_rows.stream() + .filter(s -> ObjectUtil.equal(return_reason_id, s.getReturn_reason_id())) + .findFirst(); + ShopOrderReturnReason returnReason = reasonOpl.orElse(new ShopOrderReturnReason()); + return_row.put("return_reason_name", returnReason.getReturn_reason_name()); + } else { + return_row.put("return_reason_name", ""); + } + + // 13. 设置退货商品列表和状态名称 return_row.put("items", return_item_rows); - return_row.put("return_state_name", stateCodeService.getText(Convert.toInt(return_row.get("return_state_id")), "1")); + Integer return_state_id = Convert.toInt(return_row.get("return_state_id")); + if (return_state_id != null) { + return_row.put("return_state_name", + stateCodeService.getText(return_state_id, "1")); + } else { + return_row.put("return_state_name", ""); + } + + // 14. 处理平台退货状态名称 Integer plantform_return_state_id = Convert.toInt(return_row.get("plantform_return_state_id")); - return_row.put("plantform_return_state_name", getPlantformReturnStateName(plantform_return_state_id)); - + if (plantform_return_state_id != null) { + return_row.put("plantform_return_state_name", + getPlantformReturnStateName(plantform_return_state_id)); + } else { + return_row.put("plantform_return_state_name", ""); + } return return_row; } + /** * 退货单审核(商家同意退款退库) * 处理逻辑: diff --git a/mall-shop/src/main/resources/mapper/order/ShopOrderBaseMapper.xml b/mall-shop/src/main/resources/mapper/order/ShopOrderBaseMapper.xml index bf8a0044..e1be6fcc 100644 --- a/mall-shop/src/main/resources/mapper/order/ShopOrderBaseMapper.xml +++ b/mall-shop/src/main/resources/mapper/order/ShopOrderBaseMapper.xml @@ -592,6 +592,7 @@ + @@ -656,10 +657,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + SELECT + ob.order_id, + ob.order_time, + + + CASE + WHEN oi.delivery_type_id IS NOT NULL AND oi.delivery_type_id = 16 AND #{expireSeconds} IS NOT NULL AND + #{expireSeconds} > 0 + THEN oi.order_time + #{expireSeconds}*1000 + ELSE oi.order_time + 864000000 + END as arrival_time, + + ob.order_product_amount, + ob.order_payment_amount, + ob.currency_id, + ob.order_state_id, + ob.operate_flag, + ST_Distance_Sphere( + POINT(sb.store_longitude, sb.store_latitude), + POINT(oda.da_longitude, oda.da_latitude) + ) as distance, + oi.order_title, + oi.order_pickup_num, + oi.delivery_type_id, + oi.buyer_user_id, + oi.order_picked_time, + oi.order_is_received, + oi.kind_id, + IF((SELECT count(*) FROM shop_order_base WHERE buyer_user_id = oi.buyer_user_id AND order_state_id IN + (2011,2012, + 2013, 2014, 2020, 2030, 2040))>1,2,1) + AS is_new_buyer, + oi.payment_time, + oi.booking_state, + oi.booking_begin_time, + oi.booking_end_time, + oi.booking_at, + od.order_shipping_fee, + IFNULL(od.order_shipping_fee_inner, 0) as order_shipping_fee_inner, + IFNULL(od.lkl_fee, 0) as lkl_fee, + + (od.order_discount_amount + od.voucher_price + od.order_points_fee + od.order_adjust_fee) as + total_discount_amount, + + (ob.order_product_amount-od.order_discount_amount-od.voucher_price-od.order_points_fee-od.order_adjust_fee-od.platform_fee-order_shipping_fee_inner-lkl_fee+od.packing_fee) + as order_income_amount, + (od.platform_fee+lkl_fee) as platform_fee, + od.packing_fee, + od.order_message, + sb.store_id, + sb.store_name, + sb.store_logo, + sb.store_latitude, + sb.store_longitude, + sb.store_area, + sb.store_address, + sb.store_grade_id, + sbsg.store_grade_name, + oit.item_id, + oit.product_id, + oit.item_name, + oit.order_item_quantity, + oit.item_unit_price, + oit.order_item_amount, + IF(oit.order_item_return_num > 0, oit.order_item_return_num, 0) AS order_item_return_num, + IF(oit.order_item_return_agree_amount > 0, oit.order_item_return_agree_amount, 0.00) AS + order_item_return_agree_amount, + spi.item_barcode, + oit.order_item_image, + oit.spec_info, + oda.da_name, + oda.da_mobile, + oda.da_latitude, + oda.da_longitude, + oda.da_province, + oda.da_city, + oda.da_county, + oda.da_address, + osf.sf_order_id, + osf.operator_name, + osf.operator_phone, + osf.rider_lng, + osf.rider_lat, + osf.order_status, + osf.status_desc, + osf.cancel_code, + osf.cancel_reason, + osf.push_time, + osf.h5_url, + osf.feed, + + + sor.return_id, + sor.order_id as return_order_id, + sor.buyer_user_id as return_buyer_user_id, + sor.buyer_store_id as return_buyer_store_id, + sor.return_reason_id, + sorr.return_reason_name, + sor.return_buyer_message, + sor.store_id as return_store_id, + sor.return_refund_amount, + sor.return_commision_fee, + sor.return_state_id, + sc1.state_code_name as return_state_name, + sor.return_tel, + sor.return_year, + sor.return_month, + sor.return_day, + sor.return_addr, + sor.return_mobile, + sor.return_telephone, + sor.return_contact_name, + sor.subsite_id as return_subsite_id, + sor.return_add_time, + sor.return_finish_time, + sor.return_is_paid, + sor.return_channel_code, + sor.return_channel_trans_id, + sor.return_channel_time, + sor.return_channel_flag, + sor.deposit_trade_no as return_deposit_trade_no, + sor.payment_channel_id as return_payment_channel_id, + sor.return_store_message, + sor.plantform_return_state_id, + sc2.state_code_name as plantform_return_state_name, + sor.return_flag, + sor.return_type, + sor.return_refund_amount as submit_return_refund_amount, + ob.buyer_user_name as return_buyer_user_name, + sor.try_return_count, + + + sorda.da_province as return_da_province, + sorda.da_city as return_da_city, + sorda.da_county as return_da_county, + sorda.da_address as return_da_address, + sorda.da_name as return_da_name, + sorda.da_mobile as return_da_mobile, + sorda.da_telephone as return_da_telephone, + sorda.da_province_id as return_da_province_id, + sorda.da_city_id as return_da_city_id, + sorda.da_county_id as return_da_county_id, + sorda.da_latitude as return_da_latitude, + sorda.da_longitude as return_da_longitude, + + + sori.order_return_item_id, + sori.return_id as item_return_id, + sori.order_item_id as return_order_item_id, + sori.order_id as item_order_id, + sori.return_item_num, + sori.return_item_subtotal, + sori.return_reason_id as item_return_reason_id, + sori.return_item_note, + sori.return_item_image, + sori.return_state_id as item_return_state_id, + sori.return_item_commision_fee, + sori.return_item_store_remark, + soi.item_name as return_item_name, + spb.product_name as return_product_name, + soi.item_id as return_item_id, + soi.order_item_image as return_order_item_image, + spb.unit_id as return_unit_id, + sbpu.unit_name as return_unit_name, + soi.order_item_unit_price as return_order_item_unit_price, + soi.order_item_quantity as return_order_item_quantity, + soi.order_item_amount as return_order_item_amount, + soi.order_item_note as return_order_item_note, + spi.item_number as return_item_number, + spb.product_number as return_product_number + + + + + FROM shop_order_base ob + JOIN shop_order_info oi ON ob.order_id = oi.order_id + JOIN shop_order_data od ON ob.order_id = od.order_id + JOIN shop_store_base sb ON ob.store_id = sb.store_id + JOIN shop_order_delivery_address oda ON ob.order_id = oda.order_id + JOIN shop_order_item oit ON ob.order_id = oit.order_id + LEFT JOIN shop_store_sf_order osf ON ob.order_id = osf.shop_order_id + LEFT JOIN shop_product_item spi ON oit.item_id = spi.item_id + LEFT JOIN shop_base_store_grade sbsg ON sb.store_grade_id = sbsg.store_grade_id + LEFT JOIN shop_order_return sor ON ob.order_id = sor.order_id + LEFT JOIN shop_order_return_reason sorr ON sor.return_reason_id = sorr.return_reason_id + LEFT JOIN shop_base_state_code sc1 ON sor.return_state_id = sc1.state_code_id + LEFT JOIN shop_base_state_code sc2 ON sor.plantform_return_state_id = sc2.state_code_id + LEFT JOIN shop_order_delivery_address sorda ON sor.order_id = sorda.order_id + LEFT JOIN shop_order_return_item sori ON sor.return_id = sori.return_id + LEFT JOIN shop_order_item soi ON sori.order_item_id = soi.order_item_id + LEFT JOIN shop_product_base spb ON soi.product_id = spb.product_id + LEFT JOIN shop_base_product_unit sbpu ON spb.unit_id = sbpu.unit_id + + + @@ -765,145 +1076,6 @@ - - - SELECT - ob.order_id, - ob.order_time, - - CASE - WHEN oi.delivery_type_id IS NOT NULL AND oi.delivery_type_id = 16 AND #{expireSeconds} IS NOT NULL AND - #{expireSeconds} > 0 - THEN oi.order_time + #{expireSeconds}*1000 - ELSE oi.order_time + 864000000 - END as arrival_time, - ob.order_product_amount, - ob.order_payment_amount, - ob.currency_id, - ob.order_state_id, - ob.operate_flag, - ST_Distance_Sphere( - POINT(sb.store_longitude, sb.store_latitude), - POINT(oda.da_longitude, oda.da_latitude) - ) as distance, - oi.order_title, - oi.order_pickup_num, - oi.delivery_type_id, - oi.buyer_user_id, - oi.order_picked_time, - oi.order_is_received, - oi.kind_id, - IF((SELECT count(*) FROM shop_order_base WHERE buyer_user_id = oi.buyer_user_id AND order_state_id IN - (2011,2012, - 2013, 2014, 2020, 2030, 2040))>1,2,1) - AS is_new_buyer, - oi.payment_time, - oi.booking_state, - oi.booking_begin_time, - oi.booking_end_time, - oi.booking_at, - od.order_shipping_fee, - IFNULL(od.order_shipping_fee_inner, 0) as order_shipping_fee_inner, - IFNULL(od.lkl_fee, 0) as lkl_fee, - - (od.order_discount_amount + od.voucher_price + od.order_points_fee + od.order_adjust_fee) as - total_discount_amount, - - (ob.order_product_amount-od.order_discount_amount-od.voucher_price-od.order_points_fee-od.order_adjust_fee-od.platform_fee-order_shipping_fee_inner-lkl_fee+od.packing_fee) - as order_income_amount, - (od.platform_fee+lkl_fee) as platform_fee, - od.packing_fee, - od.order_message, - sb.store_id, - sb.store_name, - sb.store_logo, - sb.store_latitude, - sb.store_longitude, - sb.store_area, - sb.store_address, - sb.store_grade_id, - sbsg.store_grade_name, - oit.item_id, - oit.product_id, - oit.item_name, - oit.order_item_quantity, - oit.item_unit_price, - oit.order_item_amount, - IF(oit.order_item_return_num > 0, oit.order_item_return_num, 0) AS order_item_return_num, - IF(oit.order_item_return_agree_amount > 0, oit.order_item_return_agree_amount, 0.00) AS - order_item_return_agree_amount, - spi.item_barcode, - oit.order_item_image, - oit.spec_info, - oda.da_name, - oda.da_mobile, - oda.da_latitude, - oda.da_longitude, - oda.da_province, - oda.da_city, - oda.da_county, - oda.da_address, - osf.sf_order_id, - osf.operator_name, - osf.operator_phone, - osf.rider_lng, - osf.rider_lat, - osf.order_status, - osf.status_desc, - osf.cancel_code, - osf.cancel_reason, - osf.push_time, - osf.h5_url, - osf.feed - - - - - - - -