订单打印增加 标题后面加规格

This commit is contained in:
Jack 2025-10-01 23:56:49 +08:00
parent 1d4b884215
commit 4ff33b938d
3 changed files with 116 additions and 61 deletions

View File

@ -28,7 +28,6 @@ import com.suisung.mall.shop.order.service.ShopOrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -228,28 +227,24 @@ public class ShopOrderItemServiceImpl extends BaseServiceImpl<ShopOrderItemMappe
@Override
public List<ShopStoreOrderProductPrintVO> selectOrderItemPrintInfo(String orderId) {
// 输入验证
if (StrUtil.isBlank(orderId)) {
return null;
return Collections.emptyList();
}
List<Map> mList = shopOrderItemMapper.selectOrderItemPrintInfo(orderId);
if (CollUtil.isEmpty(mList)) {
return null;
return Collections.emptyList();
}
DecimalFormat df2 = new DecimalFormat("#.##");
List<ShopStoreOrderProductPrintVO> retList = new ArrayList<>();
for (Map map : mList) {
return mList.stream().map(map -> {
ShopStoreOrderProductPrintVO vo = new ShopStoreOrderProductPrintVO();
vo.setProduct_sn((String) map.get("product_sn"));
vo.setItem_name((String) map.get("item_name"));
vo.setProduct_sn(Convert.toStr(map.get("product_sn")));
vo.setItem_name(Convert.toStr(map.get("item_name")));
vo.setOrder_item_amount(Convert.toBigDecimal(map.get("order_item_amount")));
vo.setOrder_item_quantity((Integer) map.get("order_item_quantity"));
retList.add(vo);
}
return retList;
vo.setOrder_item_quantity(Convert.toInt(map.get("order_item_quantity")));
return vo;
}).collect(Collectors.toList());
}
}

View File

@ -58,10 +58,7 @@ import com.suisung.mall.shop.sfexpress.service.SFExpressApiService;
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
import com.suisung.mall.shop.store.service.ShopStoreConfigService;
import com.suisung.mall.shop.store.service.ShopStoreShippingAddressService;
import io.seata.core.context.RootContext;
import io.seata.core.exception.TransactionException;
import io.seata.spring.annotation.GlobalTransactional;
import io.seata.tm.api.GlobalTransactionContext;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -968,7 +965,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
* @param shopOrderId 商城订单ID
* @return Boolean 处理结果true表示成功false表示失败
*/
@GlobalTransactional
@Transactional
@Override
public Boolean sfExpressExpiredForceRefund(String shopOrderId) {
logger.info("[顺丰超时自动退款] 开始处理订单: shopOrderId={}", shopOrderId);
@ -976,7 +973,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
try {
String remark = "同城配送异常自动退款!";
// 先整单退货申请
// 对已存在部分退款的订单进行剩余商品的全部退款
CommonResult commonResult = addRemainingItems(shopOrderId, true, remark);
commonResult.checkFenResult();
logger.debug("[顺丰超时自动退款] 整单退货申请创建成功: shopOrderId={}", shopOrderId);
@ -995,7 +992,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
shopOrderReturn.setReturn_store_message(remark);
logger.debug("[顺丰超时自动退款] 退货单信息设置完成: returnId={}", shopOrderReturn.getReturn_id());
// 退货审核商家同意退款仅仅退款因为商品还没有配送出去
// 退货审核
Boolean result = processReviewList(shopOrderReturn, 0);
if (result) {
logger.info("[顺丰超时自动退款] 处理完成: shopOrderId={}", shopOrderId);
@ -1005,14 +1002,9 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
return result;
} catch (Exception e) {
// 如果本地异常直接本地事务回滚如果是分布式异常则本地事务回滚
logger.error("[顺丰超时自动退款] 处理过程中发生异常: shopOrderId={}", shopOrderId, e);
// 手动触发Seata事务回滚
try {
GlobalTransactionContext.reload(RootContext.getXID()).rollback();
} catch (TransactionException transactionException) {
logger.error("[顺丰超时自动退款] Seata事务回滚异常: shopOrderId={}", shopOrderId, transactionException);
}
throw e;
throw new ApiException(I18nUtil._("顺丰退货审核处理失败!"));
}
}
@ -2294,6 +2286,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
* @param remark 退单备注
* @return CommonResult 退款申请结果
*/
@Transactional
@Override
public CommonResult addRemainingItems(String orderId, Boolean isSystemOpt, String remark) {
logger.info("开始处理订单剩余商品退款申请订单ID: {}", orderId);
@ -2699,7 +2692,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
logger.info("商家退款订单:{}", JSONUtil.toJsonStr(refundOrder));
if (!processReviewList(refundOrder, 0)) {
return CommonResult.failed("处理失败");
throw new ApiException("退款审核失败!");
}
// === 7. 特殊场景同城配送订单取消 ===

View File

@ -2,7 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.suisung.mall.shop.order.mapper.ShopOrderItemMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">order_item_id
<sql id="Base_Column_List">
order_item_id
, order_id, buyer_id, store_id, product_id, item_id,
item_name, category_id, spec_id, spec_info, item_unit_price, item_unit_points, item_unit_sp,
order_item_unit_price,
@ -38,24 +39,47 @@
INNER JOIN
shop_product_index ON shop_order_item.product_id = shop_product_index.product_id
<where>
<if test="map.store_id!=null">shop_order_info.store_id=#{map.store_id}</if>
<if test="map.item_name!=null">and shop_order_item.item_name like concat('%', #{map.item_name}, '%')</if>
<if test="map.product_name!=null">and shop_product_index.product_name like concat('%', #{map.product_name},
<if test="map.store_id!=null">
shop_order_info.store_id=#{map.store_id}
</if>
<if test="map.item_name!=null">
and shop_order_item.item_name like concat('%', #{map.item_name}, '%')
</if>
<if test="map.product_name!=null">
and shop_product_index.product_name like concat('%', #{map.product_name},
'%')
</if>
<if test="map.category_id!=null">and shop_order_item.category_id=#{map.category_id}</if>
<if test="map.product_id!=null">and shop_order_item.product_id=#{map.product_id}</if>
<if test="map.order_st_time!=null">and shop_order_info.order_time &gt;=#{map.order_st_time}</if>
<if test="map.order_ed_time">and shop_order_info.order_time &lt;=#{map.order_ed_time}</if>
<if test="map.da_province_id!=null">and shop_order_delivery_address.da_province_id =#{map.da_province_id}
<if test="map.category_id!=null">
and shop_order_item.category_id=#{map.category_id}
</if>
<if test="map.da_city_id!=null">and shop_order_delivery_address.da_city_id =#{map.da_city_id}</if>
<if test="map.da_county_id!=null">and shop_order_delivery_address.da_county_id =#{map.da_county_id}</if>
<if test="map.da_address!=null">and shop_order_delivery_address.da_address like concat('%',
<if test="map.product_id!=null">
and shop_order_item.product_id=#{map.product_id}
</if>
<if test="map.order_st_time!=null">
and shop_order_info.order_time &gt;=#{map.order_st_time}
</if>
<if test="map.order_ed_time">
and shop_order_info.order_time &lt;=#{map.order_ed_time}
</if>
<if test="map.da_province_id!=null">
and shop_order_delivery_address.da_province_id =#{map.da_province_id}
</if>
<if test="map.da_city_id!=null">
and shop_order_delivery_address.da_city_id =#{map.da_city_id}
</if>
<if test="map.da_county_id!=null">
and shop_order_delivery_address.da_county_id =#{map.da_county_id}
</if>
<if test="map.da_address!=null">
and shop_order_delivery_address.da_address like concat('%',
#{map.da_address}, '%')
</if>
<if test="map.order_is_paid!=null">and shop_order_info.order_is_paid =#{map.order_is_paid}</if>
<if test="map.subsite_id!=null">and shop_order_info.subsite_id =#{map.subsite_id}</if>
<if test="map.order_is_paid!=null">
and shop_order_info.order_is_paid =#{map.order_is_paid}
</if>
<if test="map.subsite_id!=null">
and shop_order_info.subsite_id =#{map.subsite_id}
</if>
</where>
GROUP BY
shop_order_item.item_id
@ -68,29 +92,72 @@
left join shop_order_delivery_address a ON a.order_id = o.order_id
left join shop_product_base b ON m.product_id = b.product_id
<where>
<if test="params.store_id!=null">m.store_id=#{params.store_id}</if>
<if test="params.order_id!=null">and m.order_id=#{params.order_id}</if>
<if test="params.item_id!=null">and m.item_id=#{params.item_id}</if>
<if test="params.order_is_paid!=null">and o.order_is_paid=#{params.order_is_paid}</if>
<if test="params.order_st_time!=null">and o.order_time &gt;=#{params.order_st_time}</if>
<if test="params.order_ed_time">and o.order_time &lt;=#{params.order_ed_time}</if>
<if test="params.query_order_st_time!=null">and o.order_time &gt;=#{params.query_order_st_time}</if>
<if test="params.query_order_ed_time!=null">and o.order_time &lt;=#{params.query_order_ed_time}</if>
<if test="params.category_id!=null">and m.category_id=#{params.category_id}</if>
<if test="params.product_name!=null">and b.product_name like concat('%', #{params.product_name}, '%')</if>
<if test="params.product_id!=null">and m.product_id=#{params.product_id}</if>
<if test="params.da_province_id!=null">and a.da_province_id =#{params.da_province_id}</if>
<if test="params.da_city_id!=null">and a.da_city_id =#{params.da_city_id}</if>
<if test="params.da_county_id!=null">and a.da_county_id =#{params.da_county_id}</if>
<if test="params.da_address!=null">and a.da_address like concat('%', #{params.da_address}, '%')</if>
<if test="params.store_id!=null">
m.store_id=#{params.store_id}
</if>
<if test="params.order_id!=null">
and m.order_id=#{params.order_id}
</if>
<if test="params.item_id!=null">
and m.item_id=#{params.item_id}
</if>
<if test="params.order_is_paid!=null">
and o.order_is_paid=#{params.order_is_paid}
</if>
<if test="params.order_st_time!=null">
and o.order_time &gt;=#{params.order_st_time}
</if>
<if test="params.order_ed_time">
and o.order_time &lt;=#{params.order_ed_time}
</if>
<if test="params.query_order_st_time!=null">
and o.order_time &gt;=#{params.query_order_st_time}
</if>
<if test="params.query_order_ed_time!=null">
and o.order_time &lt;=#{params.query_order_ed_time}
</if>
<if test="params.category_id!=null">
and m.category_id=#{params.category_id}
</if>
<if test="params.product_name!=null">
and b.product_name like concat('%', #{params.product_name}, '%')
</if>
<if test="params.product_id!=null">
and m.product_id=#{params.product_id}
</if>
<if test="params.da_province_id!=null">
and a.da_province_id =#{params.da_province_id}
</if>
<if test="params.da_city_id!=null">
and a.da_city_id =#{params.da_city_id}
</if>
<if test="params.da_county_id!=null">
and a.da_county_id =#{params.da_county_id}
</if>
<if test="params.da_address!=null">
and a.da_address like concat('%', #{params.da_address}, '%')
</if>
</where>
</select>
<select id="selectOrderItemPrintInfo" resultType="java.util.Map">
SELECT a.product_id,a.item_name,a.order_item_unit_price,a.order_item_quantity,a.order_item_amount,
SELECT a.product_id,
-- 条件判断spec_info非空且item_name不包含spec_info时拼接
CASE
WHEN a.spec_info IS NOT NULL
AND a.spec_info != ''
AND a.spec_info != 'null'
AND a.spec_info != 'none'
AND a.spec_info != 'undefined'
AND INSTR(a.item_name, a.spec_info) = 0 -- INSTR返回0表示不包含
THEN CONCAT(a.item_name, ' ', a.spec_info)
ELSE a.item_name
END AS item_name,
a.spec_info,
a.order_item_unit_price,
a.order_item_quantity,
a.order_item_amount,
"" as product_sn
FROM shop_order_item a
WHERE a.order_id=#{orderId}
ORDER BY a.order_item_id asc
FROM shop_order_item a WHERE a.order_id = #{orderId} ORDER BY a.order_item_id asc
</select>
</mapper>