| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- <?php
- /**
- * @link:http://www.gdqijianshi.com/
- * @copyright: Copyright (c) 2020 广东七件事集团
- * Created by PhpStorm
- * Author: zal
- * Date: 2020-04-01
- * Time: 21:49
- */
- namespace common\helpers\printer\templates;
- /**
- * Class FirstTemplate
- * @package common\helpers\printer\prints\templates
- */
- class DefaultTemplate extends BaseTemplate
- {
- public function getContent()
- {
- $data = $this->data;
- $printer = $this->printer;
- $content = $printer->getTimes();
- $content .= $printer->getCenterBold($data->mall_name);
- $content .= $printer->getBR("订单类型:{$data->order_type}");
- $content .= $printer->getBR("支付方式:{$data->payment_type}");
- $content .= $printer->getBR("发货方式:{$data->shippingTypText}");
- $content .= $printer->getBR("订单号:{$data->order_no}");
- $content .= $printer->getBR("下单时间:{$data->created_at}");
- $content .= $printer->getDivide();
- if ($data->is_attr == 0) {
- $content .= $printer->getTableNoAttr($data);
- } else {
- $content .= $printer->getTableAttr($data);
- }
- $content .= $printer->getDivide();
- $content .= $printer->getBR("商品总计:" . $printer->getPrice($data->original_goods_price));
- if ($data->send_type == 0) {
- $content .= $printer->getBR("运费:" . $printer->getPrice($data->shipping_money));
- }
- if (isset($data->coupon_money) && $data->coupon_money) {
- $content .= $printer->getBR("优惠券优惠:" . $printer->getPrice($data->coupon_money));
- }
- if (isset($data->score_money) && $data->score_money) {
- $content .= $printer->getBR("积分抵扣:" . $printer->getPrice($data->score_money));
- }
- if (isset($data->member_discount_price) && $data->member_discount_price) {
- $content .= $printer->getBR("会员优惠:" . $printer->getPrice($data->member_discount_price));
- }
- if ($data->back_price < 0) {
- $subPrice = round(abs($data->back_price), 2);
- $content .= $printer->getBR("后台改价:" . $printer->getPrice($subPrice));
- } elseif ($data->back_price > 0) {
- $subPrice = round(abs($data->back_price), 2);
- $content .= $printer->getBR("后台改价:" . $printer->getPrice($subPrice));
- }
- if (count($data->plugin_data) > 0) {
- foreach ($data->plugin_data as $datum) {
- $content .= $printer->getBR($datum['label'] . $printer->getPrice($datum['value']));
- }
- }
- $content .= $printer->getBR("实际支付:" . $printer->getPrice($data->pay_money));
- $content .= $printer->getDivide();
- if ($data->send_type != 1) {
- $content .= $printer->getBR("收货人:{$data->receiver_name}");
- $content .= $printer->getBR("收货地址:{$data->address}");
- $content .= $printer->getBR("收货人电话:{$data->mobile}");
- $content .= $printer->getDivide();
- } else {
- $content .= $printer->getBR("联系人:{$data->receiver_name}");
- $content .= $printer->getBR("联系人电话:{$data->receiver_name}");
- $content .= $printer->getDivide();
- $content .= $printer->getBR("门店信息");
- $content .= $printer->getBR("{$data->store_name}");
- $content .= $printer->getBR("{$data->store_mobile}");
- $content .= $printer->getBR("{$data->store_address}");
- $content .= $printer->getDivide();
- }
- if ($data->remark) {
- $content .= $printer->getRemarkText("备注:{$data->remark}");
- } else {
- foreach ($data->order_form as $ofItem) {
- if (isset($ofItem['key']) && $ofItem['key'] == 'text' || $ofItem['key'] == 'textarea') {
- $label = isset($ofItem['label']) ? $ofItem['label'] : '';
- $value = isset($ofItem['value']) ? $ofItem['value'] : '';
- if ($label && $value) {
- $content .= $printer->getRemarkText("{$label}:{$value}");
- }
- }
- }
- }
- return $content;
- }
- public function getContentByArray()
- {
- $data = $this->data;
- $content = [
- [
- 'handle' => 'times',
- 'content' => ''
- ],
- [
- 'handle' => 'centerBold',
- 'content' => $data->mall_name
- ],
- [
- 'handle' => 'bR',
- 'content' => '订单类型:' . $data->order_type
- ],
- [
- 'handle' => 'bR',
- 'content' => '支付方式:' . $data->payment_type
- ],
- [
- 'handle' => 'bR',
- 'content' => '发货方式:' . $data->shippingTypText
- ],
- [
- 'handle' => 'bR',
- 'content' => '订单号:' . $data->order_no
- ],
- [
- 'handle' => 'bR',
- 'content' => '下单时间:' . $data->created_at
- ],
- [
- 'handle' => 'divide',
- 'content' => ''
- ],
- [
- 'handle' => 'tableNoAttr',
- 'content' => $data,
- 'show' => $data->is_attr == 0 ? 1 : 0
- ],
- [
- 'handle' => 'tableAttr',
- 'content' => $data,
- 'show' => $data->is_attr == 1 ? 1 : 0
- ],
- [
- 'handle' => 'divide',
- 'content' => ''
- ],
- [
- 'handle' => 'bR',
- 'children' => [
- [
- 'handle' => 'price',
- 'content' => $data->original_goods_price
- ]
- ],
- 'content' => '商品总计:'
- ],
- [
- 'handle' => 'bR',
- 'children' => [
- [
- 'handle' => 'price',
- 'content' => $data->shipping_money
- ]
- ],
- 'content' => '运费:',
- 'show' => $data->send_type != 1 ? 1 : 0
- ],
- [
- 'handle' => 'bR',
- 'children' => [
- [
- 'handle' => 'price',
- 'content' => $data->coupon_money
- ]
- ],
- 'content' => '优惠券优惠:',
- 'show' => $data->coupon_money ? 1 : 0
- ],
- [
- 'handle' => 'bR',
- 'children' => [
- [
- 'handle' => 'price',
- 'content' => $data->score_money
- ]
- ],
- 'content' => '积分抵扣:',
- 'show' => $data->score_money ? 1 : 0
- ],
- [
- 'handle' => 'bR',
- 'children' => [
- [
- 'handle' => 'price',
- 'content' => $data->member_discount_price
- ]
- ],
- 'content' => '会员优惠:',
- 'show' => $data->member_discount_price ? 1 : 0
- ],
- [
- 'handle' => 'bR',
- 'children' => [
- [
- 'handle' => 'price',
- 'content' => abs($data->back_price)
- ]
- ],
- 'content' => '后台改价:',
- 'show' => $data->back_price != 0 ? 1 : 0
- ],
- ];
- if (count($data->plugin_data) > 0) {
- foreach ($data->plugin_data as $datum) {
- $content[] = [
- 'handle' => 'bR',
- 'children' => [
- [
- 'handle' => 'price',
- 'content' => $datum['value']
- ]
- ],
- 'content' => $datum['label'] . ':',
- 'show' => 1
- ];
- }
- }
- $content2 = [
- [
- 'handle' => 'bR',
- 'children' => [
- [
- 'handle' => 'price',
- 'content' => $data->pay_money
- ]
- ],
- 'content' => '实际支付:'
- ],
- [
- 'handle' => 'divide',
- 'content' => ''
- ],
- [
- 'handle' => 'bR',
- 'content' => ($data->send_type != 1 ? '收货人:' : '联系人:') . $data->receiver_name
- ],
- [
- 'handle' => 'bR',
- 'content' => '收货地址' . $data->address,
- 'show' => $data->send_type != 1 ? 1 : 0
- ],
- [
- 'handle' => 'bR',
- 'content' => ($data->send_type != 1 ? '收货人电话:' : '联系人电话:') . $data->mobile
- ],
- [
- 'handle' => 'divide',
- 'content' => ''
- ],
- [
- 'handle' => 'bR',
- 'content' => '门店信息',
- 'show' => $data->send_type == 1 ? 1 : 0
- ],
- [
- 'handle' => 'bR',
- 'content' => $data->store_name,
- 'show' => $data->send_type == 1 ? 1 : 0
- ],
- [
- 'handle' => 'bR',
- 'content' => $data->store_mobile,
- 'show' => $data->send_type == 1 ? 1 : 0
- ],
- [
- 'handle' => 'bR',
- 'content' => $data->store_address,
- 'show' => $data->send_type == 1 ? 1 : 0
- ],
- [
- 'handle' => 'divide',
- 'content' => '',
- 'show' => $data->send_type == 1 ? 1 : 0
- ],
- [
- 'handle' => 'remarkText',
- 'content' => '备注:' . $data->remark,
- 'show' => $data->remark ? 1 : 0
- ],
- ];
- $content = array_merge($content, $content2);//dd($data->order_form);
- // foreach ($data->order_form as $ofItem) {
- // if (isset($ofItem['key']) && $ofItem['key'] == 'text' || $ofItem['key'] == 'textarea') {
- // $label = isset($ofItem['label']) ? $ofItem['label'] : '';
- // $value = isset($ofItem['value']) ? $ofItem['value'] : '';
- //
- // $content[] = [
- // 'handle' => 'remarkText',
- // 'content' => "{$label}:" . $value,
- // 'show' => $label && $value ? 1 : 0,
- // ];
- // }
- // }
- // 执行效果同getContent
- return $content;
- }
- }
|