修复错误,和添加打印流程

This commit is contained in:
Jack 2025-11-29 17:18:47 +08:00
parent 81abf15dcd
commit d530054e03
7 changed files with 34 additions and 22 deletions

View File

@ -94,7 +94,7 @@ public class LakalaController extends BaseControllerImpl {
// return lakalaApiService.tradeQuery(paramsJSON.getInt("storeId"), paramsJSON.getStr("orderId"));
return shopStorePrinterService.printShopStoreReturnOrder(paramsJSON.getStr("orderId"), paramsJSON.getStr("returnId"));
return shopStorePrinterService.printShopStoreReturnOrder(paramsJSON.getStr("returnId"));
}
@ApiOperation(value = "批量发送推送消息 - 测试案例", notes = "批量发送推送消息 - 测试案例")

View File

@ -5195,7 +5195,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
for (String orderId : orderIds) {
try {
// 控制API调用频率
Thread.sleep(1200); // 根据实际API限制调整
Thread.sleep(1000); // 根据实际API限制调整
wxOrderShippingService.setMsgJumpPath(orderId);
log.info("[异步处理] 订单跳转路径设置入口 processOrderJumpPathAsync订单ID: {}", orderId);
} catch (InterruptedException e) {

View File

@ -59,6 +59,7 @@ import com.suisung.mall.shop.product.service.ShopProductItemService;
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.ShopStorePrinterService;
import com.suisung.mall.shop.store.service.ShopStoreShippingAddressService;
import com.suisung.mall.shop.sync.service.SyncThirdDataService;
import io.seata.spring.annotation.GlobalTransactional;
@ -196,6 +197,10 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
@Autowired
private LklOrderSeparateService lklOrderSeparateService;
@Lazy
@Autowired
private ShopStorePrinterService shopStorePrinterService;
@Lazy
@Autowired
private LklOrderDrawService lklOrderDrawService;
@ -618,6 +623,9 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
data.put("return", orderReturn);
data.put("items", shopOrderReturnItems);
// 打票机打印退款订单到店(异步执行)
shopStorePrinterService.printShopStoreReturnOrder(return_id);
// 发送消息通知
if (needSendMsg != null && needSendMsg) {
// 退款提醒商家
@ -1378,7 +1386,9 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
Integer store_id = Optional.ofNullable(shopOrderReturn.getStore_id())
.orElseGet(() -> Convert.toInt(getCurrentUser().getStore_id()));
List<String> return_ids = Convert.toList(String.class, shopOrderReturn.getReturn_id());
String returnId = shopOrderReturn.getReturn_id();
List<String> return_ids = Convert.toList(String.class, returnId);
List<ShopOrderReturn> orderReturns = gets(return_ids);
if (!CheckUtil.checkDataRights(store_id, orderReturns, ShopOrderReturn::getStore_id)) {
@ -1416,6 +1426,9 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
}
}
// 打票机打印退款订单到店(异步执行)
shopStorePrinterService.printShopStoreReturnOrder(returnId);
// 3. 通知买家
messageService.sendNoticeMsg(
shopOrderReturn.getBuyer_user_id(),
@ -2613,7 +2626,6 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
QueryWrapper<ShopOrderItem> itemQueryWrapper = new QueryWrapper<>();
itemQueryWrapper.eq("order_id", orderId);
List<ShopOrderItem> allOrderItems = shopOrderItemService.find(itemQueryWrapper);
if (CollectionUtil.isEmpty(allOrderItems)) {
logger.warn("订单剩余商品退款申请失败订单商品表为空订单ID: {}", orderId);
throw new ApiException(I18nUtil._("订单商品表为空!"));

View File

@ -83,11 +83,10 @@ public interface ShopStorePrinterService extends IBaseService<ShopStorePrinter>
/**
* 退货成功后立即打印门店的退货信息
*
* @param orderId
* @param returnId
* @return
*/
Boolean printShopStoreReturnOrder(String orderId, String returnId);
Boolean printShopStoreReturnOrder(String returnId);
/**
* 获取店铺所有有效打印机

View File

@ -32,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.util.Pair;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -407,7 +408,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
}
/**
* 打印店铺退货订单的小票信息
* 异步打印店铺退货订单的小票信息
* <p>
* 该方法通过调用飞鹅打票机接口完成指定订单的退货小票打印功能主要流程包括
* 1. 校验订单号是否合法
@ -417,12 +418,12 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
* 5. 记录打印日志
* </p>
*
* @param orderId 订单编号不能为空
* @param returnId 退货单编号用于标识具体的退货记录
* @return 打印操作是否成功成功返回 true否则返回 false
*/
@Async
@Override
public Boolean printShopStoreReturnOrder(String orderId, String returnId) {
public Boolean printShopStoreReturnOrder(String returnId) {
logger.debug("#### 调用飞鹅打票机的打印退款订单操作开始 ####");
// 参数校验
@ -433,16 +434,16 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
try {
// 获取打印的订单信息并检查订单是否存在且已支付
OrderPrintVO binding = shopOrderReturnService.fetchReturnOrderPrintInfo(orderId, returnId);
if (binding == null) {
OrderPrintVO orderPrintVO = shopOrderReturnService.fetchReturnOrderPrintInfo("", returnId);
if (orderPrintVO == null) {
logger.error("退款订单Id{}信息无法获取,无法打印小票。", returnId);
return false;
}
logger.debug("退款订单信息:{}", binding);
logger.debug("退款订单信息:{}", orderPrintVO);
orderId = binding.getOrder_id();
Integer storeId = binding.getStore_id();
String orderId = orderPrintVO.getOrder_id();
Integer storeId = orderPrintVO.getStore_id();
if (CheckUtil.isEmpty(storeId) || CheckUtil.isEmpty(orderId)) {
logger.error("订单Id:{}店铺ID:{}为空,无法打印小票。", orderId, storeId);
return false;
@ -467,7 +468,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
}
// 重要重构实体类处理标题数量价格适应长度
List<OrderItemPrintVO> orderItems = binding.getOrder_items();
List<OrderItemPrintVO> orderItems = orderPrintVO.getOrder_items();
if (CollUtil.isEmpty(orderItems)) {
logger.error("订单{}商品信息为空,无法打印小票。", orderId);
return false;
@ -479,10 +480,10 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
rebuiltItems.add(item.rebuild());
}
}
binding.setOrder_items(rebuiltItems);
orderPrintVO.setOrder_items(rebuiltItems);
// 使用 FreeMarker 模板引擎渲染实际要打印的内容
String printContent = FreeMakerUtils.processTemplate(template.getTemplate_name(), template.getTemplate_value(), binding);
String printContent = FreeMakerUtils.processTemplate(template.getTemplate_name(), template.getTemplate_value(), orderPrintVO);
if (StrUtil.isBlank(printContent)) {
logger.error("订单{}信息模版渲染异常,无法打印小票。", orderId);
return false;
@ -520,7 +521,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
orderId,
template.getTemplate_id(),
template.getTemplate_value(),
JsonUtil.object2json(binding),
JsonUtil.object2json(orderPrintVO),
printContent,
respSn.getSecond(),
respSn.getFirst()
@ -533,7 +534,7 @@ public class ShopStorePrinterServiceImpl extends BaseServiceImpl<ShopStorePrinte
return true;
} catch (Exception e) {
logger.error("打印退货订单小票时发生异常,订单ID: {}, 退货单ID: {}", orderId, returnId, e);
logger.error("打印退货订单小票时发生异常, 退货单ID: {}", returnId, e);
return false;
}
}

View File

@ -143,7 +143,7 @@
soi.order_title, soi.delivery_type_id, soi.payment_type_id, soi.payment_time,
LPAD(soi.order_pickup_num, 7, '0') as order_pickup_num_str,
CASE WHEN soi.booking_state = 2 THEN 2 ELSE 1 END AS booking_state, soi.booking_begin_time,
sod.order_message, sod.order_item_amount, sod.order_shipping_fee, sod.order_shipping_fee_amount, sod.delivery_time,
sod.order_message, sod.order_shipping_fee, sod.order_shipping_fee_amount, sod.delivery_time,
(sod.order_discount_amount + sod.voucher_price + sod.order_points_fee + sod.order_adjust_fee) as total_discount_amount,
sod.packing_fee,
ssi.store_tel,

View File

@ -42,7 +42,7 @@
修改后的模版
<CB><B>用户退款订单<BR></B></CB>
<CB><B>用户退款订单</B></CB><BR>
<CB>${store_name}</CB><BR>
--------------------------------<BR>
<CB>#${order_pickup_num_str}</CB><BR>
@ -78,4 +78,4 @@
<CB>${store_name}</CB><BR>--------------------------------<BR><CB>#${order_pickup_num_str}</CB><BR><L>买家备注:${order_message!'-'}</L><BR><BOLD>配送时间:${delivery_time}</BOLD><BR>--------------------------------<BR>订单编号:${order_id}<BR>订单来源:微信小程序<BR>支付方式:微信支付<BR>配送来源:顺丰同城<BR>付款时间:${payment_time}<BR>--------------------------------<BR><L>商品名称 数量 金额</L><BR>--------------------------------<BR><#list order_items as item><L>${item.s_name}</L><L><BOLD>${item.s_quantity}</BOLD></L><L>${item.s_amount}</L><BR><#if item.s_name_segs??><#list item.s_name_segs as seg><L>${seg}</L><BR></#list></#if><BOLD><#if item.product_sn?default("")?trim?length gt 1>${item.product_sn}</BOLD><BR></#if></#list>--------------------------------<BR>商品总件数:<BOLD>${order_items_count!0}</BOLD><BR>商品总额:<BOLD>¥${order_product_amount?string('0.00')}</BOLD><BR>押金:<BOLD>¥${(yajin!0)?string('0.00')}</BOLD><BR>运费:<BOLD>¥${order_shipping_fee?string('0.00')}</BOLD><BR>会员权益:<BOLD>-¥${(quanyi!0)?string('0.00')}</BOLD><BR>秒杀:<BOLD>-¥${(miaosha!0)?string('0.00')}</BOLD><BR>实付金额:<BOLD>¥${order_payment_amount?string('0.00')}</BOLD><BR><#if seller_message?default("")?trim?length gt 1>--------------------------------<BR><BOLD>商家备注:${seller_message!'---'}</BOLD><BR></#if>--------------------------------<BR><BOLD>收货人:${buyer_user_name!''}</BOLD><BR><BOLD>收货人手机:${store_tel!''}</BOLD><BR><BOLD>收货地址:${da_province!'-'}${da_city!'-'}${da_address!'-'}</BOLD><BR>--------------------------------<BR>门店:${store_name}<BR>门店电话:<BOLD>${store_tel!'-'}</BOLD><BR>收银员:${cashier!'-'}<BR>
带参模版:
<CB><B>用户退款订单<BR></B></CB><CB>${store_name}</CB><BR>--------------------------------<BR><CB>#${order_pickup_num_str}</CB><BR><L>退款原因:${return_buyer_message!'-'}</L><BR><BOLD>配送时间:${payment_time?string('yyyy-MM-dd HH:mm:ss')}20-30分钟</BOLD><BR>--------------------------------<BR>订单编号:${order_id}<BR>退单编号:${return_id}<BR>订单来源:${order_channel_name!'微信小程序'}<BR>支付方式:${payment_type_name!'微信支付'}<BR>配送来源:${deliver_type_name!'顺丰同城'}<BR>付款时间:${payment_time?string('yyyy-MM-dd HH:mm:ss')}<BR>申请退款:${return_add_time?string('yyyy-MM-dd HH:mm:ss')}<BR>确认退款:${return_finish_time?string('yyyy-MM-dd HH:mm:ss')}<BR>--------------------------------<BR><C>******* 退款商品 ******</C><BR>--------------------------------<BR><#list order_items as item><L>${item.s_name}</L><L><BOLD>${item.s_quantity}</BOLD></L><L>${item.s_amount}</L><BR><#if item.s_name_segs??><#list item.s_name_segs as seg><L>${seg}</L><BR></#list></#if><BOLD><#if item.product_sn?default("")?trim?length gt 1>${item.product_sn}</BOLD><BR></#if></#list>--------------------------------<BR>实付金额:<BOLD>¥${order_payment_amount?string('0.00')}元</BOLD><BR>配送费:<BOLD>¥${order_shipping_fee?string('0.00')}元</BOLD><BR>申请退款:<BOLD>¥${return_refund_amount?string('0.00')}</BOLD><BR>退款方式:<BOLD>${return_flag_str}</BOLD><BR>商家审批备注:<BOLD>${return_store_message!'-'}</BOLD><BR>--------------------------------<BR><BOLD>会员名称:${buyer_user_name}</BOLD><BR><BOLD>会员手机:${return_tel}</BOLD><BR>--------------------------------<BR>操作员:${cashier!'-'}<BR>
<CB><B>用户退款订单</B></CB><BR><CB>${store_name}</CB><BR>--------------------------------<BR><CB>#${order_pickup_num_str}</CB><BR><L>退款原因:${return_buyer_message!'-'}</L><BR><BOLD>配送时间:${payment_time?string('yyyy-MM-dd HH:mm:ss')}20-30分钟</BOLD><BR>--------------------------------<BR>订单编号:${order_id}<BR>退单编号:${return_id}<BR>订单来源:${order_channel_name!'微信小程序'}<BR>支付方式:${payment_type_name!'微信支付'}<BR>配送来源:${deliver_type_name!'顺丰同城'}<BR>付款时间:${payment_time?string('yyyy-MM-dd HH:mm:ss')}<BR>申请退款:${return_add_time?string('yyyy-MM-dd HH:mm:ss')}<BR>确认退款:${return_finish_time?string('yyyy-MM-dd HH:mm:ss')}<BR>--------------------------------<BR><C>******* 退款商品 ******</C><BR>--------------------------------<BR><#list order_items as item><L>${item.s_name}</L><L><BOLD>${item.s_quantity}</BOLD></L><L>${item.s_amount}</L><BR><#if item.s_name_segs??><#list item.s_name_segs as seg><L>${seg}</L><BR></#list></#if><BOLD><#if item.product_sn?default("")?trim?length gt 1>${item.product_sn}</BOLD><BR></#if></#list>--------------------------------<BR>实付金额:<BOLD>¥${order_payment_amount?string('0.00')}元</BOLD><BR>配送费:<BOLD>¥${order_shipping_fee?string('0.00')}元</BOLD><BR>申请退款:<BOLD>¥${return_refund_amount?string('0.00')}</BOLD><BR>退款方式:<BOLD>${return_flag_str}</BOLD><BR>商家审批备注:<BOLD>${return_store_message!'-'}</BOLD><BR>--------------------------------<BR><BOLD>会员名称:${buyer_user_name}</BOLD><BR><BOLD>会员手机:${return_tel}</BOLD><BR>--------------------------------<BR>操作员:${cashier!'-'}<BR>