PrintOrders.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <?php
  2. namespace addons\Printer\common\logic;
  3. use addons\Mch\common\models\Mch;
  4. use addons\Printer\common\logic\printer\yilianyun\Lib\Api\PrintService;
  5. use addons\Printer\common\logic\printer\yilianyun\Lib\Config\YlyConfig;
  6. use addons\Printer\common\logic\printer\yilianyun\Lib\Oauth\YlyOauthClient;
  7. use addons\Store\common\models\Store;
  8. use addons\Store\common\models\StoreCashierOrder;
  9. use addons\Store\common\models\StoreCashierOrderDetail;
  10. use common\enums\RedisKeyEnum;
  11. use common\enums\StatusEnum;
  12. use common\helpers\StringHelper;
  13. use common\models\mall\MallAddons;
  14. use common\models\order\Order;
  15. use common\models\mall\Mall;
  16. use common\enums\PayTypeEnum;
  17. use common\enums\ShippingTypeEnum;
  18. use addons\Printer\common\logic\templates\DefaultTemplate;
  19. use common\models\common\MallSetting;
  20. use addons\Printer\common\models\Printer;
  21. use addons\Printer\common\models\PrinterTemplate;
  22. use addons\Store\common\models\StoreOrder;
  23. use addons\Store\common\models\StoreOrderPickup;
  24. use common\enums\AddonsEnum;
  25. use common\models\order\OrderDetail;
  26. use Exception;
  27. class PrintOrders
  28. {
  29. private $order;
  30. private $order_detail;
  31. private $mall_id;
  32. private $event;
  33. private $config;
  34. private $template_list;
  35. private $mall_info;
  36. //打印类型
  37. const PRINT_TYPE_ORDER = 'order_printer_config'; //下单
  38. const PRINT_TYPE_PAY = 'pay_printer_config'; //支付
  39. const PRINT_TYPE_CONFIRM = 'confirm_printer_config'; //确认收货
  40. const PRINT_TYPE_SYSTEM = 'system_printer_config'; //后台
  41. public function setPrinter($param)
  42. {
  43. $this->event = $param['event'];
  44. if (!isset($param['order_type'])) {
  45. $this->order = Order::find()->where(['id' => $param['order_id']])->one();
  46. $this->mall_id = $this->order['mall_id'];
  47. $this->order_detail = $this->order->detail;
  48. } else {
  49. $order_type = $param['order_type'];
  50. switch ($order_type){
  51. case "C":
  52. $storeCashierOrder = StoreCashierOrder::find()->where(['id' => $param['order_id']])->one();
  53. $extra = json_decode($storeCashierOrder['extra'],true);
  54. $this->mall_id = $storeCashierOrder['mall_id'];
  55. $order = new Order();
  56. $order->user_id = $storeCashierOrder['user_id'];
  57. $order->mall_id = $storeCashierOrder['mall_id'];
  58. $order->store_id = $storeCashierOrder['store_id'];
  59. $order->order_no = $storeCashierOrder['order_no'];
  60. $order->payment_type = $storeCashierOrder['payment_type'];
  61. $order->pay_money = $storeCashierOrder['pay_money'];
  62. $order->created_at = $storeCashierOrder['created_at'];
  63. $order->remark = $storeCashierOrder['remark'];
  64. $order->original_goods_price = $storeCashierOrder['money'];
  65. $order->seller_remark = '';
  66. $order->score_money = 0.00;
  67. $order->coupon_money = 0.00;
  68. if(!empty($extra)&&is_array($extra)){
  69. if(!empty($extra['deduct_num_score'])){
  70. $order->score_money = $extra['discount_money'];
  71. }
  72. if(!empty($extra['discount'])){
  73. $order->coupon_money = $extra['discount'];
  74. }
  75. }
  76. $order_detail = StoreCashierOrderDetail::lists(['where'=>[['cashier_order_id'=>$storeCashierOrder['id']]]],false);
  77. if(empty($order_detail)) $order_detail = new OrderDetail();
  78. $this->order = $order;
  79. $this->order_detail = $order_detail;
  80. break;
  81. }
  82. }
  83. $params = [
  84. 'where' => [['=', 'mall_id', $this->mall_id], ['in', 'name', ['contact_tel', 'web_url', 'quick_map_address']]],
  85. 'select' => ['value', 'name']
  86. ];
  87. $this->mall_info = array_column(MallSetting::lists($params), 'value', 'name');
  88. return $this;
  89. }
  90. /**
  91. * 设置打印机配置
  92. * @return array
  93. */
  94. public function getOpenPrinterConfig()
  95. {
  96. $params = [
  97. 'select' => [$this->event, 'terminal', 'secret_key', 'api_key', 'mall_id', 'user_id', 'printer_type', 'store_id','mch_id', 'client_id','print_width'],
  98. 'where' => [['=', 'mall_id', $this->mall_id], ['status'=>StatusEnum::ENABLED]]
  99. ];
  100. $list = Printer::lists($params);
  101. if (empty($list)) return [];
  102. foreach ($list as $k => $val) {
  103. $v = json_decode($val[$this->event], true);
  104. if ($v['is_printer'] == 0) {
  105. unset($list[$k]);
  106. continue;
  107. }
  108. if(!empty($this->order['mch_id'])){
  109. if($this->order['mch_id']!=$val['mch_id']){
  110. continue;
  111. }
  112. }
  113. if(!empty($this->order['store_id'])){
  114. if($this->order['store_id']!=$val['store_id']){
  115. continue;
  116. }
  117. }
  118. $this->config[] = [
  119. 'user_id' => $val['user_id'],
  120. 'mall_id' => $val['mall_id'],
  121. 'client_id' => $val['client_id'],
  122. 'machine_code' => $val['terminal'],
  123. 'key' => $val['secret_key'],
  124. 'client_key' => $val['api_key'],
  125. 'time' => $v['num'],
  126. 'printer_type' => $val['printer_type'],
  127. 'store_id' => $val['store_id'],
  128. 'mch_id' => $val['mch_id'],
  129. 'template_id' => $v['template_id'],
  130. 'print_width' => $val['print_width'],
  131. ];
  132. }
  133. }
  134. public function getPrinterTemplate()
  135. {
  136. if(!empty($this->config)){
  137. $template_id = array_column($this->config, 'template_id');
  138. $params = [
  139. 'where' => [['=', 'mall_id', $this->mall_id], ['status'=>StatusEnum::ENABLED], ['in', 'id', $template_id]]
  140. ];
  141. $this->template_list = array_column(PrinterTemplate::lists($params), null, 'id');
  142. }
  143. }
  144. /**
  145. * 打印
  146. */
  147. public function print()
  148. {
  149. try {
  150. //判断是商场打印机还是门店打印机
  151. $this->getOpenPrinterConfig();
  152. $this->getPrinterTemplate();
  153. if (empty($this->template_list) || empty($this->config)) {
  154. return;
  155. }
  156. $template = new DefaultTemplate();
  157. $redis = \Yii::$app->redis;
  158. foreach ($this->config as $config) {
  159. if (($config['printer_type'] == 1 && $this->order['store_id'] == 0 && $this->order['mch_id'] == 0) || ($config['printer_type'] == 2 && $this->order['store_id'] == $config['store_id'])|| ($config['printer_type'] == 3 && $this->order['mch_id'] == $config['mch_id'])) {
  160. \Yii::error('===================='.json_encode($config));
  161. $clientId = $config['client_id'];
  162. $machine_code = $config['machine_code'];
  163. $clientSecret = $config['client_key'];
  164. $yilian_config = new YlyConfig($clientId, $clientSecret);
  165. $client = new YlyOauthClient($yilian_config);
  166. $mall_id = $config['mall_id'];
  167. $cacheKey = RedisKeyEnum::suffix('printer_keys', $clientId);
  168. $access_token = $redis->get($cacheKey);
  169. if (empty($access_token)) {
  170. $token = $client->getToken();
  171. $access_token = $token->access_token; //调用API凭证AccessToken 永久有效,请妥善保存.
  172. $redis->set($cacheKey,$access_token,'EX',30*24*3600-1);
  173. }
  174. $machine_code = $config['machine_code']; //机器码
  175. $origin_id = StringHelper::generateOrderNo('p'); //内部订单号(32位以内)
  176. $template_info = $this->template_list[$config['template_id']];
  177. $printData = $this->setOrderPrintData($template_info);
  178. /**文本接口开始**/
  179. $print = new PrintService($access_token, $yilian_config);
  180. $content = $this->getContent($printData,$config['print_width']);
  181. $res = $print->index($machine_code, $content, $origin_id);
  182. if(isset($res->error)&&$res->error!=0){
  183. throw new Exception($res->error_description);
  184. }else{
  185. $result['err'] = 0;
  186. $result['msg'] = '打印成功';
  187. }
  188. }
  189. }
  190. if(!isset($result['err'])){
  191. $result['err'] = 1;
  192. $result['msg'] = '打印错误,请检查打印机配置是否正确';
  193. }
  194. } catch (Exception $e) {
  195. \Yii::error('打印错误,msg=' . $e->getMessage() . ',行数:' . $e->getLine() . $e->getFile());
  196. $result['err'] = 1;
  197. $result['msg'] = '打印错误,msg=' . $e->getMessage() . ',行数:' . $e->getLine() . $e->getFile();
  198. }
  199. return $result;
  200. }
  201. public function getContentOld($data)
  202. {
  203. $content = '';
  204. foreach ($data as $item) {
  205. if (isset($item['show']) && $item['show'] == 0) {
  206. continue;
  207. }
  208. $getter = 'get' . $item['handle'];
  209. if (isset($item['children'])) {
  210. $children = $item['content'];
  211. foreach ($item['children'] as $value) {
  212. if (isset($value['content'])) {
  213. $childGetter = 'get' . $value['handle'];
  214. $children .= $this->$childGetter($value['content']);
  215. }
  216. }
  217. $content .= $this->$getter($children);
  218. } else {
  219. $content .= $this->$getter($item['content']);
  220. }
  221. }
  222. return $content;
  223. }
  224. public function getContent($printData,$print_width)
  225. {
  226. $order_type = '商城订单';
  227. $mall_name = '';
  228. if(!empty($printData->mall_name)){
  229. $mall_name = $printData->mall_name;
  230. }
  231. if(!empty($this->order['mch_id'])){
  232. $order_type = '商户订单';
  233. if(MallAddons::isInstall($this->order['mall_id'],'Mch')){
  234. $mch = Mch::findOne(['id'=>$this->order['mch_id']]);
  235. if(!empty($mch['store_name'])){
  236. $mall_name = $mch['store_name'];
  237. }
  238. }
  239. }
  240. $is_store = false;
  241. if(!empty($this->order['store_id'])){
  242. $order_no = $this->order['order_no'];
  243. if($order_no[0]=='C'){
  244. $order_type = '门店收银台订单';
  245. }else{
  246. $order_type = '门店订单';
  247. }
  248. $store = Store::findOne(['id'=>$this->order['store_id']]);
  249. if(!empty($store['store_name'])){
  250. $is_store = true;
  251. $mall_name = $store['store_name'];
  252. }
  253. }
  254. $content = "<FS2><center>".$printData->ticket_nam."</center></FS2>";
  255. if(!empty($mall_name)){
  256. $content .= "<FS2><center>".$mall_name."</center></FS2>";
  257. }
  258. $content .= $this->getDivide($print_width);
  259. if ($printData->is_show_pickup && $printData->pickup_code) {
  260. $content .= "自提码:{$printData->pickup_code}" . "\n";
  261. }
  262. $content .= "订单类型:{$order_type}" . "\n";
  263. $content .= "订单编号:".$printData->order_no."\n";
  264. $content .= "下单时间:".$printData->created_at."\n";
  265. $content .= $this->getDivide($print_width);
  266. if(isset($this->order_detail)&&isset($this->order_detail[0]['id'])){
  267. $content .= "<table>";
  268. $content .= "<tr><td>名称</td><td>数量</td>";
  269. if(isset($printData->is_show_price)&&$printData->is_show_price) $content .= "<td>单价</td>";
  270. $content .= "</tr>";
  271. foreach ($printData->goods_list as $item) {
  272. $content .= "<tr><td>$item->name</td><td>$item->num</td>";
  273. if(isset($printData->is_show_price)&&$printData->is_show_price){
  274. $content .= "<td>$item->unit_price</td>";
  275. }
  276. $content .= "</tr>";
  277. // 规格
  278. if ($printData->is_show_attr && !empty($item->attr)) {
  279. $content .= "<tr><td>[" . $item->attr . "]</td></tr>";
  280. }
  281. }
  282. $content .= "</table>";
  283. $content .= $this->getDivide($print_width);
  284. }
  285. $content .= "商品总计:".$printData->price."\n";
  286. $content .= "运费:".$printData->shipping_money."\n";
  287. $content .= "积分抵扣:".$printData->score_money."\n";
  288. $content .= "优惠券优惠:".$printData->coupon_money."\n";
  289. $content .= "实际支付:".$printData->pay_money."\n";
  290. if(!empty($printData->is_show_name)||!empty($printData->is_show_addr)||!empty($printData->is_show_phone)) {
  291. $content .= $this->getDivide($print_width);
  292. if(isset($printData->is_show_name)&&$printData->is_show_name) $content .= "收货人:".$printData->receiver_name."\n";
  293. if(isset($printData->is_show_addr)&&$printData->is_show_addr) $content .= "收货地址:".$printData->address."\n";
  294. if(isset($printData->is_show_phone)&&$printData->is_show_phone) $content .= "收货电话:".$printData->mobile."\n";
  295. }
  296. if(!empty($printData->is_show_mall_phone)||!empty($printData->is_show_mall_addr)) {
  297. $content .= $this->getDivide($print_width);
  298. if ($is_store) {
  299. // 门店
  300. if (isset($printData->is_show_mall_phone) && $printData->is_show_mall_phone && $is_store) $content .= "商家联系方式:" . $store['shop_mobile'] ."\n";
  301. if (isset($printData->is_show_mall_addr) && $printData->is_show_mall_addr && $is_store) $content .= "商家地址:" . $store['address'] ."\n";
  302. } else {
  303. if(isset($printData->is_show_mall_phone)&&$printData->is_show_mall_phone) $content .= "商家联系方式:".$printData->contact_tel."\n";
  304. if(isset($printData->is_show_mall_addr)&&$printData->is_show_mall_addr) $content .= "商家地址:".$printData->quick_map_address."\n";
  305. }
  306. }
  307. if(!empty($printData->is_show_mall_code)||!empty($printData->is_show_remark)||!empty($printData->is_show_seller_remark)){
  308. $content .= $this->getDivide($print_width);
  309. if(isset($printData->is_show_mall_code)&&$printData->is_show_mall_code) $content .= "<FS2><center><QR>".$printData->mall_qrcode_url."</QR></center></FS2>";
  310. if(isset($printData->is_show_remark)&&$printData->is_show_remark) $content .= "备注:".$printData->remark."\n";
  311. if(isset($printData->is_show_seller_remark)&&$printData->is_show_seller_remark) $content .= "商家留言:".$printData->seller_remark."\n";
  312. }
  313. if(!empty($printData->is_show_qrcode_url)||!empty($printData->bottom_info)){
  314. $content .= $this->getDivide($print_width);
  315. if(!empty($printData->is_show_qrcode_url)) $content .= "<FS2><center><QR>".$printData->qrcode_url."</QR></center></FS2>";
  316. if(!empty($printData->bottom_info)) $content .= "<FS2><center>".$printData->bottom_info."</center></FS2>";
  317. }
  318. return $content;
  319. }
  320. /**
  321. * 设置打印数据
  322. */
  323. public function setOrderPrintData($template)
  324. {
  325. $mall = Mall::findOne($this->mall_id);
  326. if (empty($mall)) {
  327. return false;
  328. }
  329. $data = new OrderContent();
  330. $data->mall_name = empty($template['head_info']) ? '' : $mall->name;
  331. $data->ticket_nam = $template['ticket_nam'];
  332. $order_type = '商城订单';
  333. if(!empty($this->order['mch_id'])){
  334. $order_type = '商户订单';
  335. }
  336. if(!empty($this->order['store_id'])){
  337. $order_no = $this->order['order_no'];
  338. if($order_no[0]=='C'){
  339. $order_type = '门店收银台订单';
  340. $template['price_info'] = 1;
  341. }else{
  342. $order_type = '门店订单';
  343. }
  344. }
  345. $data->order_type = $order_type;
  346. $data->attribute = $this->order;
  347. $data->created_at = date("Y-m-d H:i:s", $this->order->created_at);
  348. $data->contact_tel = $this->mall_info['contact_tel'];
  349. $data->quick_map_address = $this->mall_info['quick_map_address'];
  350. $data->remark = $this->order['remark'];
  351. $data->seller_remark = $this->order['seller_remark'];
  352. $data->qrcode_url = $template['qrcode_url'];
  353. $data->mall_qrcode_url = $this->mall_info['web_url']; //var_dump($this->mall_info['quick_map_address']);
  354. $data->bottom_info = $template['bottom_info'];
  355. $data->address = $this->order->region_name. $this->order->address;
  356. $data->remark = $this->order->remark;
  357. $data->seller_remark = $this->order->seller_remark;
  358. // 自提码
  359. if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_STORE)) {
  360. $packup = StoreOrderPickup::getPickupDataByMallOrderId($this->order->id);
  361. $packup && $data->is_show_pickup = empty($template['pickup_code']) ? false : true;
  362. $packup && $data->pickup_code = $packup['code'];
  363. }
  364. $paymentTypeEnum = PayTypeEnum::getMap();
  365. $data->payment_type = isset($paymentTypeEnum[$this->order->payment_type]) ? $paymentTypeEnum[$this->order->payment_type] : '未知方式';
  366. $ShippingTypeEnum = ShippingTypeEnum::getMap();
  367. $orderInfo = [];
  368. foreach ($this->order_detail as $item) {
  369. $orderInfo[] = (object)[
  370. 'attr' => $item->goods_attr_name ?? '',
  371. 'num' => $item->num ?? 0,
  372. 'total_price' => $item->original_goods_price ?? 0,
  373. 'unit_price' => $item->price ?? 0,
  374. 'name' => $item->goods_name ?? ''
  375. ];
  376. }
  377. $data->goods_list = $orderInfo;
  378. $data->is_show_price = false;
  379. $data->is_show_barcode = false;
  380. if (!empty($template['goods_info'])) {
  381. $goods_info = json_decode($template['goods_info'], true);
  382. if (in_array(1, $goods_info)) {
  383. $data->is_show_price = true;
  384. }
  385. if (in_array(2, $goods_info)) {
  386. $data->is_show_barcode = true;
  387. }
  388. // 是否显示规格
  389. if (in_array(3, $goods_info)) {
  390. $data->is_show_attr = true;
  391. }
  392. }
  393. $data->price = $template['price_info'] == 1 ? $data->original_goods_price : $data->pay_money;
  394. if (!empty($template['remarks_info'])) {
  395. $remarks_info = json_decode($template['remarks_info'], true);
  396. if (in_array(1, $remarks_info) && $data->remark) {
  397. $data->is_show_remark = true;
  398. }
  399. if (in_array(2, $remarks_info) && $data->seller_remark) {
  400. $data->is_show_seller_remark = true;
  401. }
  402. }
  403. if (!empty($template['buyer_info'])) {
  404. $buyer_info = json_decode($template['buyer_info'], true);
  405. if (in_array(1, $buyer_info)) {
  406. $data->is_show_name = true;
  407. }
  408. if (in_array(2, $buyer_info)) {
  409. $data->is_show_phone = true;
  410. }
  411. if (in_array(3, $buyer_info)) {
  412. $data->is_show_addr = true;
  413. }
  414. }
  415. if (!empty($template['mall_info'])) {
  416. $mall_info = json_decode($template['mall_info'], true);
  417. if (in_array(1, $mall_info)) {
  418. $data->is_show_mall_phone = true;
  419. }
  420. if (in_array(2, $mall_info)) {
  421. $data->is_show_mall_addr = true;
  422. }
  423. if (in_array(3, $mall_info)) {
  424. $data->is_show_mall_code = true;
  425. }
  426. }
  427. if (!empty($template['qrcode_url'])) {
  428. $data->qrcode_url = $template['qrcode_url'];
  429. $data->is_show_qrcode_url = true;
  430. }
  431. $data->bottom_info = $template['bottom_info'];
  432. return $data;
  433. }
  434. /**
  435. * 补齐空格
  436. * 每n个中文字符长度为一个数组元素
  437. * @param string $input
  438. * @param integer $n
  439. * @return array
  440. */
  441. protected function rStrPad1($input, $n = 7)
  442. {
  443. $string = "";
  444. $count = 0;
  445. $c_count = 0;
  446. $arr = array();
  447. for ($i = 0; $i < mb_strlen($input, 'UTF-8'); $i++) {
  448. $char = mb_substr($input, $i, 1, 'UTF-8');
  449. $string .= $char;
  450. if (strlen($char) == 3) {
  451. $count += 2;
  452. $c_count++;
  453. } else {
  454. $count += 1;
  455. }
  456. if ($count >= $n * 2) {
  457. $arr[] = $string;
  458. $string = '';
  459. $count = 0;
  460. $c_count = 0;
  461. }
  462. }
  463. if ($count < $n * 2) {
  464. $string = str_pad($string, $n * 2 + $c_count);
  465. $arr[] = $string;
  466. }
  467. return $arr;
  468. }
  469. /**
  470. * 补齐空格
  471. * 截取七个中文字符长度
  472. * @param string $input
  473. * @param integer $n
  474. * @return string
  475. */
  476. protected function rStrPad($input, $n = 7)
  477. {
  478. $string = "";
  479. $count = 0;
  480. $c_count = 0;
  481. for ($i = 0; $i < mb_strlen($input, 'UTF-8'); $i++) {
  482. $char = mb_substr($input, $i, 1, 'UTF-8');
  483. $string .= $char;
  484. if (strlen($char) == 3) {
  485. $count += 2;
  486. $c_count++;
  487. } else {
  488. $count += 1;
  489. }
  490. if ($count >= $n * 2) {
  491. break;
  492. }
  493. }
  494. if ($count < $n * 2) {
  495. $string = str_pad($string, $n * 2 + $c_count);
  496. }
  497. return $string;
  498. }
  499. /**
  500. * @return string
  501. * 打印次数
  502. */
  503. public function getTimes()
  504. {
  505. return '';
  506. }
  507. /**
  508. * @param $content
  509. * @return mixed
  510. * 居中
  511. */
  512. public function getCenter($content)
  513. {
  514. return $content;
  515. }
  516. /**
  517. * @param $content
  518. * @return mixed
  519. * 加粗
  520. */
  521. public function getBold($content)
  522. {
  523. return $content;
  524. }
  525. /**
  526. * @param $content
  527. * @return string
  528. * 居中加粗
  529. */
  530. public function getCenterBold($content)
  531. {
  532. return "$content";
  533. }
  534. /**
  535. * @param $content
  536. * @return mixed
  537. * 换行
  538. */
  539. public function getBR($content)
  540. {
  541. return $content;
  542. }
  543. /**
  544. * @param OrderContent $data
  545. * @return mixed
  546. * 表格---不显示规格
  547. */
  548. public function getTableNoAttr($data)
  549. {
  550. return '';
  551. }
  552. /**
  553. * @param OrderContent $data
  554. * @return mixed
  555. * 表格--显示规格
  556. */
  557. public function getTableAttr($data)
  558. {
  559. return '';
  560. }
  561. /**
  562. * @param $content
  563. * @return string
  564. * 价格--后缀
  565. */
  566. public function getPrice($content)
  567. {
  568. return $content . '元';
  569. }
  570. /**
  571. * @return mixed
  572. * 分隔符
  573. */
  574. public function getDivide($print_width='58mm')
  575. {
  576. switch ($print_width){
  577. case '58mm':
  578. return $this->getBR("--------------------------------");
  579. case '72mm':
  580. return $this->getBR("------------------------------------------------");
  581. default:
  582. return $this->getBR("--------------------------------");
  583. }
  584. }
  585. public function getRemarkText($text)
  586. {
  587. $arrText = $this->rStrPad1($text, 18);
  588. $newText = '';
  589. foreach ($arrText as $item) {
  590. $newText .= $this->getBR($item);
  591. }
  592. return $newText;
  593. }
  594. }