当前版本CRMEB-BZ v5.4.0(20240708)
数据库变更
php think migrate:create UpdateSystemStore
public function change()
{
$table = $this->table('system_store');
$table->addColumn('terminal_number', 'string', ['limit' => MysqlAdapter::TEXT_TINY, 'default' => '', 'comment' => '终端号'])
->update();
}
代码变更
1. 接收参数
\app\adminapi\controller\v1\merchant\SystemStore::save
增加 ['terminal_number', ''],
2. 订单打印
\app\services\order\StoreOrderServices::orderPrintTicket
变更为:
/**
* 订单小票打印
* @param int $id
* @return bool|void
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function orderPrintTicket(int $id)
{
/** @var StoreOrder $order */
$order = $this->get($id);
if (!$order) {
throw new AdminException(400118);
}
// 存在提货点,单独打印订单
/** @var SystemStore|null $store */
$store = null;
if ($order->store_id) {
$store = SystemStore::find($order->store_id);
}
/** @var StoreOrderCartInfoServices $cartServices */
$cartServices = app()->make(StoreOrderCartInfoServices::class);
$product = $cartServices->getCartInfoPrintProduct($order['id']);
if (!$product) {
throw new AdminException(400463);
}
$switch = (bool)sys_config('pay_success_printing_switch');
if (!$switch) {
throw new AdminException(400464);
}
if (sys_config('print_type', 1) == 1) {
$name = 'yi_lian_yun';
$configData = [
'clientId' => sys_config('printing_client_id', ''),
'apiKey' => sys_config('printing_api_key', ''),
'partner' => sys_config('develop_id', ''),
'terminal' => $store && $store->terminal_number ? $store->terminal_number : sys_config('terminal_number', '')
];
if (!$configData['clientId'] || !$configData['apiKey'] || !$configData['partner'] || !$configData['terminal']) {
throw new AdminException(400465);
}
} else {
$name = 'fei_e_yun';
$configData = [
'feyUser' => sys_config('fey_user', ''),
'feyUkey' => sys_config('fey_ukey', ''),
'feySn' => sys_config('fey_sn', '')
];
if (!$configData['feyUser'] || !$configData['feyUkey'] || !$configData['feySn']) {
throw new AdminException(400465);
}
}
$printer = new Printer($name, $configData);
$res = $printer->setPrinterContent([
'name' => sys_config('site_name'),
'url' => sys_config('site_url'),
'orderInfo' => is_object($order) ? $order->toArray() : $order,
'product' => $product
])->startPrinter();
if (!$res) {
throw new AdminException($printer->getError());
}
return true;
}
版权属于:大卫科技Blog
本文链接:https://www.iyuu.cn/archives/517/
转载时须注明出处