fix(printer): 修复小票打印商品名称错误

- 在 PayNotifyLogic 中添加 XpsdkPrintApi 类的引用
- 在 OrderXprinterPushSend 中修正商品名称的获取方式
- 优化代码格式和结构,提高可读性
This commit is contained in:
mkm 2024-12-23 18:12:15 +08:00
parent df8f3523f6
commit 2be22adcb3
2 changed files with 37 additions and 35 deletions

View File

@ -32,6 +32,7 @@ use app\common\model\user_sign\UserSign;
use app\common\model\vip_flow\VipFlow;
use app\common\service\Curl;
use app\common\service\PushService;
use app\common\service\xpyun\XpsdkPrintApi;
use support\exception\BusinessException;
use support\Log;
use think\facade\Db;
@ -54,6 +55,7 @@ class PayNotifyLogic extends BaseLogic
return true;
} catch (\Exception $e) {
Db::rollback();
d($e);
Log::error('支付回调处理失败' . $e->getMessage() . ',lien:' . $e->getLine() . ',file:' . $e->getFile());
throw new BusinessException($e->getMessage());
}

View File

@ -33,7 +33,7 @@ class OrderXprinterPushSend implements Consumer
$pay_type = PayEnum::getPaySceneDesc($order['pay_type']);
$SystemStore = SystemStore::where('id', $order['store_id'])->find();
$cart_info = StoreOrderCartInfo::where('oid', $order['id'])->select()->each(function ($item) {
$find = StoreProduct::with('unitName')->withTrashed()->find();
$find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find();
$item['store_name'] = $find['store_name'];
return $item;
});
@ -41,7 +41,7 @@ class OrderXprinterPushSend implements Consumer
$product_arr = [];
foreach ($cart_info as $k => $v) {
$product_arr[] = [
'name'=>$v['name'],
'name' => $v['store_name'],
'price' => $v['price'] . '元',
'quantity' => $v['cart_num'],
'subtotal' => $v['total_price'] . '元'
@ -61,7 +61,7 @@ class OrderXprinterPushSend implements Consumer
'pay_type_name' => $pay_type,
'product_arr' => $product_arr
];
($api->printFontAlign('74AMP5N6DP21148',$order));
$res = ($api->printFontAlign('74AMP5N6DP21148', $order));
}
// 消费失败时
public function onConsumeFailure(\Throwable $exception, $package)