Browse Source
Merge branch 'qs_local_order' into develop
Merge branch 'qs_local_order' into develop
# Conflicts: # app/Admin/Controllers/Test.php # app/Admin/routes.php # dcat_admin_ide_helper.phpmaster
28 changed files with 1480 additions and 48 deletions
-
58app/Admin/Actions/ModifyOrderState.php
-
78app/Admin/Actions/Show/OrderDetail.php
-
176app/Admin/Controllers/ImsCjdcOrderMainController.php
-
88app/Admin/Controllers/LanzuServiceHorsemanController.php
-
6app/Admin/Controllers/Test.php
-
46app/Admin/Extensions/CheckRow.php
-
16app/Admin/Extensions/OrderDetail.php
-
72app/Admin/Extensions/OrderPrint.php
-
76app/Admin/Extensions/OrderStateHandle.php
-
47app/Admin/Forms/SelectHorseman.php
-
6app/Admin/Repositories/ImsCjdcMarket.php
-
9app/Admin/Repositories/ImsCjdcOrderMain.php
-
16app/Admin/Repositories/LanzuServiceHorseman.php
-
3app/Admin/routes.php
-
326app/Libs/feier_print/api_php_demo.php
-
307app/Libs/feier_print/httpclient.php
-
46app/Libs/feier_print/飞鹅云打印说明文档.txt
-
14app/Models/Feprint.php
-
2app/Models/ImsCjdcMarket.php
-
2app/Models/ImsCjdcOrder.php
-
8app/Models/ImsCjdcOrderMain.php
-
16app/Models/LanzuServiceHorseman.php
-
5app/Models/StoreAccount.php
-
10composer.lock
-
48config/order.php
-
16resources/lang/zh-CN/ims-cjdc-order-main.php
-
17resources/lang/zh-CN/lanzu-service-horseman.php
-
14resources/views/orderdetail.php
@ -0,0 +1,58 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Actions; |
|||
|
|||
use Dcat\Admin\Actions\Action; |
|||
use Dcat\Admin\Actions\Response; |
|||
use Dcat\Admin\Traits\HasPermissions; |
|||
use Illuminate\Contracts\Auth\Authenticatable; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class ModifyOrderState extends Action |
|||
{ |
|||
/** |
|||
* @return string |
|||
*/ |
|||
protected $title = '状态'; |
|||
|
|||
/** |
|||
* Handle the action request. |
|||
* |
|||
* @param Request $request |
|||
* |
|||
* @return Response |
|||
*/ |
|||
public function handle(Request $request) |
|||
{ |
|||
// dump($this->getKey());
|
|||
|
|||
return $this->response()->success('Processed successfully.')->redirect('/'); |
|||
} |
|||
|
|||
/** |
|||
* @return string|array|void |
|||
*/ |
|||
public function confirm() |
|||
{ |
|||
// return ['Confirm?', 'contents'];
|
|||
} |
|||
|
|||
/** |
|||
* @param Model|Authenticatable|HasPermissions|null $user |
|||
* |
|||
* @return bool |
|||
*/ |
|||
protected function authorize($user): bool |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* @return array |
|||
*/ |
|||
protected function parameters() |
|||
{ |
|||
return []; |
|||
} |
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Actions\Show; |
|||
|
|||
use Dcat\Admin\Actions\Response; |
|||
use Dcat\Admin\Show\AbstractTool; |
|||
use Dcat\Admin\Traits\HasPermissions; |
|||
use Illuminate\Contracts\Auth\Authenticatable; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class OrderDetail extends AbstractTool |
|||
{ |
|||
/** |
|||
* @return string |
|||
*/ |
|||
protected $title = '订单订单详情'; |
|||
|
|||
/** |
|||
* Handle the action request. |
|||
* |
|||
* @param Request $request |
|||
* |
|||
* @return Response |
|||
*/ |
|||
public function handle(Request $request) |
|||
{ |
|||
dd($this->getKey()); |
|||
|
|||
return $this->response() |
|||
->success('Processed successfully.') |
|||
->redirect('/'); |
|||
} |
|||
|
|||
/** |
|||
* @return string|void |
|||
*/ |
|||
protected function href() |
|||
{ |
|||
return admin_url('auth/users'); |
|||
} |
|||
|
|||
/** |
|||
* @return string|array|void |
|||
*/ |
|||
public function confirm() |
|||
{ |
|||
return ['Confirm?', 'contents']; |
|||
} |
|||
|
|||
/** |
|||
* @param Model|Authenticatable|HasPermissions|null $user |
|||
* |
|||
* @return bool |
|||
*/ |
|||
protected function authorize($user): bool |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
// 如果你想自定义动作按钮的HTML,可以重写此方法
|
|||
public function html() |
|||
{ |
|||
|
|||
return view('orderdetail'); |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* @return array |
|||
*/ |
|||
protected function parameters() |
|||
{ |
|||
return []; |
|||
} |
|||
} |
|||
@ -0,0 +1,176 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers; |
|||
|
|||
use App\Admin\Extensions\CheckRow; |
|||
use App\Admin\Extensions\CouponTieEdit; |
|||
use App\Admin\Extensions\OrderDetail; |
|||
use App\Admin\Extensions\OrderPrint; |
|||
use App\Admin\Extensions\OrderStateHandle; |
|||
use App\Admin\Forms\CouponTieForm; |
|||
use App\Admin\Repositories\ImsCjdcOrderMain; |
|||
use Dcat\Admin\Admin; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController;; |
|||
|
|||
class ImsCjdcOrderMainController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new ImsCjdcOrderMain(), function (Grid $grid) { |
|||
//>>1.只展示线上订单打√
|
|||
//>>2.不同服务站只能看到自己的市场订单
|
|||
//>>3.订单不允许有添加,编辑,删除
|
|||
//>>4.订单状态变更√
|
|||
//>>5.打印功能
|
|||
//>6.退款
|
|||
$grid->paginate(10);//每页展示数据10条
|
|||
//$grid->id;
|
|||
//$grid->user_id('用户信息');
|
|||
$grid->column('user_name','用户信息'); |
|||
$grid->order_num; |
|||
|
|||
$grid->state('订单状态') |
|||
->using(config('order.state')) |
|||
->label([1=>'dark',2=>'danger',3=>'indigo',4=>'success']); |
|||
$grid->money; |
|||
$grid->column('market.name','所属市场'); |
|||
$grid->time; |
|||
$grid->pay_time; |
|||
|
|||
$grid->actions(new CheckRow('自送')); |
|||
|
|||
$grid->column('配送方式') |
|||
->if(function ($column){ |
|||
if ($this->state==3){ |
|||
return true; |
|||
} |
|||
return false; |
|||
|
|||
}) |
|||
->display('站内自送') |
|||
->modal('站内自送',function ($modal){ |
|||
return CouponTieForm::make(); |
|||
}) |
|||
->else() |
|||
->display('站内自送'); |
|||
|
|||
|
|||
|
|||
|
|||
$grid->actions(function (Grid\Displayers\Actions $actions) use ($grid){ |
|||
$state = $actions->row->state; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
if ($state==2){ |
|||
$actions->append(new OrderStateHandle('接单',3)); |
|||
$actions->append(new OrderPrint('打印')); |
|||
}elseif ($state==31){ |
|||
$actions->append(new OrderStateHandle('完成',4)); |
|||
$actions->append(new OrderPrint('打印')); |
|||
}elseif ($state==3){ |
|||
$actions->append(new OrderStateHandle('站内自送',30)); |
|||
} |
|||
|
|||
$actions->append(new OrderDetail('详情')); |
|||
|
|||
//$actions->append("<a class='btn btn-xs action-btn btn-danger grid-row-refuse' data-id='{$actions->getKey()}'><i class='fa fa-close' title='拒绝退款'>拒绝</i></a> ");
|
|||
//$actions->append("<a class='btn btn-xs action-btn btn-success grid-row-pass' data-id='{$actions->getKey()}'><i class='fa fa-check' title='同意退款'>同意</i></a>");
|
|||
|
|||
|
|||
}); |
|||
//$grid->column('详情')->modal('详情',function ()use ($grid){
|
|||
// return view('orderdetail',['id'=>2]);
|
|||
//
|
|||
//});
|
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
|
|||
}); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
$grid->disableViewButton(); |
|||
$grid->disableEditButton(); |
|||
$grid->disableDeleteButton(); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new ImsCjdcOrderMain(), function (Show $show) { |
|||
$show->id; |
|||
$show->user_id; |
|||
$show->order_num; |
|||
$show->state; |
|||
$show->time; |
|||
$show->pay_time; |
|||
$show->money; |
|||
$show->tools(function (Show\Tools $tools) { |
|||
$tools->append(new \App\Admin\Actions\Show\OrderDetail()); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new ImsCjdcOrderMain(), function (Form $form) { |
|||
$form->display('id'); |
|||
$form->text('user_id'); |
|||
$form->text('order_num'); |
|||
$form->text('state'); |
|||
$form->text('time'); |
|||
$form->text('pay_time'); |
|||
$form->text('money'); |
|||
}); |
|||
} |
|||
|
|||
|
|||
public function orderDetail() |
|||
{ |
|||
echo 111; |
|||
} |
|||
} |
|||
@ -0,0 +1,88 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers; |
|||
|
|||
use App\Admin\Repositories\LanzuServiceHorseman; |
|||
use App\Models\ImsCjdcMarket; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
|
|||
class LanzuServiceHorsemanController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new LanzuServiceHorseman(), function (Grid $grid) { |
|||
$grid->id->sortable(); |
|||
$grid->name; |
|||
$grid->tel; |
|||
$grid->market_id('所属市场')->display(function (){ |
|||
return ImsCjdcMarket::find($this->market_id)->name; |
|||
}); |
|||
$grid->status('状态')->using([1=>'正常',-1=>'禁用']); |
|||
$grid->head_url->image('',50,50); |
|||
$grid->created_at->display(function ($time){ |
|||
return date('Y-m-d H:i',$time); |
|||
}); |
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
|
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new LanzuServiceHorseman(), function (Show $show) { |
|||
$show->id; |
|||
$show->user_id('懒ID'); |
|||
$show->name; |
|||
$show->tel; |
|||
$show->market_id('所属市场')->as(function (){ |
|||
return ImsCjdcMarket::find($this->market_id)->name; |
|||
}); |
|||
$show->status('状态')->using([1=>'正常',-1=>'禁用']); |
|||
$show->head_url->image(); |
|||
$show->created_at->as(function ($time){ |
|||
return date('Y-m-d H:i',$time); |
|||
}); |
|||
$show->updated_at->as(function ($time){ |
|||
return date('Y-m-d H:i',$time); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new LanzuServiceHorseman(), function (Form $form) { |
|||
$form->display('id'); |
|||
$form->text('user_id','懒ID')->required(); |
|||
$form->text('name')->required(); |
|||
$form->mobile('tel')->required(); |
|||
$form->select('market_id','所属市场')->options(ImsCjdcMarket::getMarket())->required(); |
|||
$form->radio('status','状态')->options([1=>'启用',-1=>'禁用'])->value(1)->required(); |
|||
$form->image('head_url')->uniqueName()->required(); |
|||
|
|||
$form->display('created_at'); |
|||
$form->display('updated_at'); |
|||
}); |
|||
} |
|||
} |
|||
@ -1,42 +1,32 @@ |
|||
<?php |
|||
namespace App\Admin\Extensions; |
|||
|
|||
use App\Admin\Forms\CouponTieForm; |
|||
use App\Models\ImsCjdcOrderMain; |
|||
use App\Models\StoreAccount; |
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Dcat\Admin\Widgets\Modal; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class CheckRow extends RowAction |
|||
{ |
|||
|
|||
public function title() |
|||
protected $title; |
|||
public function __construct($title=null) |
|||
{ |
|||
return 'Check row'; |
|||
} |
|||
/** |
|||
* 添加JS |
|||
* |
|||
* @return string |
|||
*/ |
|||
protected function script() |
|||
{ |
|||
return <<<JS |
|||
$('.grid-check-row').on('click', function () { |
|||
parent::__construct($title); |
|||
|
|||
// Your code.
|
|||
console.log($(this).data('id')); |
|||
|
|||
}); |
|||
JS; |
|||
} |
|||
public function html() |
|||
{ |
|||
// 获取当前行数据ID
|
|||
$id = $this->getKey(); |
|||
|
|||
// 获取当前行数据的用户名
|
|||
$username = $this->row->username; |
|||
|
|||
// 这里需要添加一个class, 和上面script方法对应
|
|||
$this->setHtmlAttribute(['data-id' => $id, 'email' => $username, 'class' => 'grid-check-row']); |
|||
|
|||
return parent::html(); |
|||
public function render() |
|||
{ |
|||
// 实例化表单类并传递自定义参数
|
|||
$form = CouponTieForm::make(); |
|||
|
|||
return Modal::make() |
|||
->lg() |
|||
->title($this->title) |
|||
->body($form) |
|||
->button($this->title); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Extensions; |
|||
|
|||
|
|||
use Dcat\Admin\Grid\RowAction; |
|||
|
|||
class OrderDetail extends RowAction |
|||
{ |
|||
public function __construct($title=null) |
|||
{ |
|||
parent::__construct($title); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Extensions; |
|||
|
|||
|
|||
use App\Models\Feprint; |
|||
use App\Models\ImsCjdcOrderMain; |
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class OrderPrint extends RowAction |
|||
{ |
|||
protected $title; |
|||
public function __construct($title=null) |
|||
{ |
|||
parent::__construct($title); |
|||
|
|||
} |
|||
|
|||
public function handle(Request $request) |
|||
{ |
|||
$id = $this->getKey(); |
|||
$this->doPrint(); |
|||
dd($id); |
|||
} |
|||
|
|||
/** |
|||
* 设置要POST到接口的数据 |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function parameters() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public function doPrint() |
|||
{ |
|||
$oid = $this->getKey(); |
|||
$row = ImsCjdcOrderMain::find($oid); |
|||
|
|||
//>>1.获取打印机状态
|
|||
$result = $this->getPrintStatus($row->market_id); |
|||
//>>2.调用打印
|
|||
if ($result==1){ |
|||
$this->feiErPrint($row->order_num); |
|||
} |
|||
//>>3.记录打印次数
|
|||
} |
|||
|
|||
/** |
|||
* @param $oid //主订单ID
|
|||
* @return int |
|||
*/ |
|||
public function getPrintStatus($mid) |
|||
{ |
|||
$fe = Feprint::where('market_id',$mid)->first(); |
|||
if ($fe){ |
|||
return $fe->status; |
|||
}else{ |
|||
return -1; |
|||
} |
|||
} |
|||
|
|||
public function feiErPrint($order_num) |
|||
{ |
|||
include_once app_path('Libs\feier_print\api_php_demo.php'); |
|||
$result = json_decode(FeiePrint($order_num)); |
|||
dd($result); |
|||
} |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
<?php |
|||
namespace App\Admin\Extensions; |
|||
|
|||
use App\Models\ImsCjdcOrderMain; |
|||
use Dcat\Admin\Grid\Displayers\Modal; |
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Dcat\Admin\Layout\Content; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class OrderStateHandle extends RowAction |
|||
{ |
|||
|
|||
protected $model; |
|||
protected $state; |
|||
protected $title; |
|||
protected $content; |
|||
public function __construct($title=null,$state=null) |
|||
{ |
|||
|
|||
parent::__construct($title); |
|||
$this->state = $state; |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* 处理请求 |
|||
* |
|||
* @param Request $request |
|||
* |
|||
* @return \Dcat\Admin\Actions\Response |
|||
*/ |
|||
public function handle(Request $request) |
|||
{ |
|||
// 获取当前行ID
|
|||
$id = $this->getKey(); |
|||
$orderMain = new ImsCjdcOrderMain(); |
|||
$state = $request->get('state'); |
|||
if ($state==30){ |
|||
$content = new Content(); |
|||
$content = $this->showForm($content); |
|||
return $content; |
|||
|
|||
dd('弹出表单'); |
|||
//$res = $orderMain->updateShippingType($id,1);
|
|||
}elseif ($state==100){ |
|||
|
|||
}else{ |
|||
$res = $orderMain->modifyState($id,$state); |
|||
} |
|||
|
|||
if ($res==true){ |
|||
return $this->response()->success('操作成功')->refresh(); |
|||
}else{ |
|||
return $this->response()->error('操作失败'); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 设置要POST到接口的数据 |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function parameters() |
|||
{ |
|||
return [ |
|||
'state' => $this->state, |
|||
]; |
|||
} |
|||
|
|||
public function showForm(Content $content) |
|||
{ |
|||
return $content->title('站内自送')->body("<h1>hello world!</h1>"); |
|||
} |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Forms; |
|||
|
|||
use Dcat\Admin\Widgets\Form; |
|||
use Symfony\Component\HttpFoundation\Response; |
|||
|
|||
class SelectHorseman extends Form |
|||
{ |
|||
/** |
|||
* Handle the form request. |
|||
* |
|||
* @param array $input |
|||
* |
|||
* @return Response |
|||
*/ |
|||
public function handle(array $input) |
|||
{ |
|||
// dump($input);
|
|||
|
|||
// return $this->error('Your error message.');
|
|||
|
|||
return $this->success('Processed successfully.', '/'); |
|||
} |
|||
|
|||
/** |
|||
* Build a form here. |
|||
*/ |
|||
public function form() |
|||
{ |
|||
$this->text('name')->required(); |
|||
$this->email('email')->rules('email'); |
|||
} |
|||
|
|||
/** |
|||
* The data of the form. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function default() |
|||
{ |
|||
return [ |
|||
'name' => 'John Doe', |
|||
'email' => 'John.Doe@gmail.com', |
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories; |
|||
|
|||
use App\Models\LanzuServiceHorseman as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class LanzuServiceHorseman extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
@ -0,0 +1,326 @@ |
|||
<?php |
|||
|
|||
use think\Db; |
|||
|
|||
header("Content-type: text/html; charset=utf-8"); |
|||
include 'httpclient.php'; |
|||
|
|||
define('USER', '13161443713@163.com'); //*必填*:飞鹅云后台注册账号
|
|||
define('UKEY', 'XsaHzgePdyWTfcMX'); //*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】
|
|||
define('SN', '550510805'); //*必填*:打印机编号,必须要在管理后台里添加打印机或调用API接口添加之后,才能调用API
|
|||
|
|||
//以下参数不需要修改
|
|||
define('IP', 'api.feieyun.cn'); //接口IP或域名
|
|||
define('PORT', 80); //接口IP端口
|
|||
define('PATH', '/Api/Open/'); //接口路径
|
|||
|
|||
//拼凑订单内容时可参考如下格式
|
|||
//根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式
|
|||
$content = '<CB>测试打印</CB><BR>'; |
|||
$content .= '名称 单价 数量 金额<BR>'; |
|||
$content .= '--------------------------------<BR>'; |
|||
$content .= '饭 10.0 10 100.0<BR>'; |
|||
$content .= '炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '鸡蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿鸡蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '--------------------------------<BR>'; |
|||
$content .= '备注:加辣<BR>'; |
|||
$content .= '合计:xx.0元<BR>'; |
|||
$content .= '送货地点:广西南宁五象新区<BR>'; |
|||
$content .= '联系电话:13888888888888<BR>'; |
|||
$content .= '订餐时间:2014-08-08 08:08:08<BR>'; |
|||
$content .= '<QR>http://www.feieyun.com</QR>';//把二维码字符串用标签套上即可自动生成二维码
|
|||
//标签说明:
|
|||
$content = "<DIRECTION>1</DIRECTION>";//设定打印时出纸和打印字体的方向,n 0 或 1,每次设备重启后都会初始化为 0 值设置,1:正向出纸,0:反向出纸,
|
|||
$content .= "<TEXT x='9' y='10' font='12' w='1' h='2' r='0'>#001 五号桌 1/3</TEXT><TEXT x='80' y='80' font='12' w='2' h='2' r='0'>可乐鸡翅</TEXT><TEXT x='9' y='180' font='12' w='1' h='1' r='0'>张三先生 13800138000</TEXT>";//40mm宽度标签纸打印例子,打开注释调用标签打印接口打印
|
|||
|
|||
/** |
|||
* [打印订单接口 Open_printMsg] |
|||
* @param [string] $sn [打印机编号sn] |
|||
* @param [string] $content [打印内容] |
|||
* @param [string] $times [打印联数] |
|||
* @return [string] [接口返回值] |
|||
*/ |
|||
function printMsg($sn, $content, $times = 1) |
|||
{ |
|||
$time = time(); //请求时间
|
|||
$msgInfo = array( |
|||
'user' => USER, |
|||
'stime' => $time, |
|||
'sig' => signature($time), |
|||
'apiname' => 'Open_printMsg', |
|||
'sn' => $sn, |
|||
'content' => $content, |
|||
'times' => $times//打印次数
|
|||
); |
|||
$client = new HttpClient(IP, PORT); |
|||
if (!$client->post(PATH, $msgInfo)) { |
|||
echo 'error'; |
|||
} else { |
|||
//服务器返回的JSON字符串,建议要当做日志记录起来
|
|||
$result = $client->getContent(); |
|||
return $result; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* [批量添加打印机接口 Open_printerAddlist] |
|||
* @param [string] $printerContent [打印机的sn#key]
|
|||
* @return [string] [接口返回值] |
|||
*/ |
|||
function printerAddlist($printerContent) |
|||
{ |
|||
$time = time(); //请求时间
|
|||
$msgInfo = array( |
|||
'user' => USER, |
|||
'stime' => $time, |
|||
'sig' => signature($time), |
|||
'apiname' => 'Open_printerAddlist', |
|||
'printerContent' => $printerContent |
|||
); |
|||
$client = new HttpClient(IP, PORT); |
|||
if (!$client->post(PATH, $msgInfo)) { |
|||
echo 'error'; |
|||
} else { |
|||
$result = $client->getContent(); |
|||
return $result; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* [批量删除打印机 Open_printerDelList] |
|||
* @param [string] $snlist [打印机编号,多台打印机请用减号“-”连接起来] |
|||
* @return [string] [接口返回值] |
|||
*/ |
|||
function printerDelList($snlist) |
|||
{ |
|||
$time = time(); //请求时间
|
|||
$msgInfo = array( |
|||
'user' => USER, |
|||
'stime' => $time, |
|||
'sig' => signature($time), |
|||
'apiname' => 'Open_printerDelList', |
|||
'snlist' => $snlist |
|||
); |
|||
$client = new HttpClient(IP, PORT); |
|||
if (!$client->post(PATH, $msgInfo)) { |
|||
echo 'error'; |
|||
} else { |
|||
$result = $client->getContent(); |
|||
return $result; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* [查询订单是否打印成功接口 Open_queryOrderState] |
|||
* @param [string] $orderid [调用打印机接口成功后,服务器返回的JSON中的编号 例如:123456789_20190919163739_95385649] |
|||
* @return [string] [接口返回值] |
|||
*/ |
|||
function queryOrderState($orderid) |
|||
{ |
|||
$time = time(); //请求时间
|
|||
$msgInfo = array( |
|||
'user' => USER, |
|||
'stime' => $time, |
|||
'sig' => signature($time), |
|||
'apiname' => 'Open_queryOrderState', |
|||
'orderid' => $orderid |
|||
); |
|||
$client = new HttpClient(IP, PORT); |
|||
if (!$client->post(PATH, $msgInfo)) { |
|||
echo 'error'; |
|||
} else { |
|||
$result = $client->getContent(); |
|||
return $result; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* [signature 生成签名] |
|||
* @param [string] $time [当前UNIX时间戳,10位,精确到秒] |
|||
* @return [string] [接口返回值] |
|||
*/ |
|||
function signature($time) |
|||
{ |
|||
return sha1(USER . UKEY . $time);//公共参数,请求公钥
|
|||
} |
|||
|
|||
function FeiePrint($order_num) |
|||
{ |
|||
$data = DB::table('ims_cjdc_order_main') |
|||
->alias('m') |
|||
->join(['ims_cjdc_order'=>'o'],'o.order_main_id = m.id','inner') |
|||
->join(['ims_cjdc_order_goods'=>'g'],'o.id = g.order_id','inner') |
|||
->join(['ims_cjdc_feprint'=>'f'],'m.market_id = f.market_id','inner') |
|||
->join(['ims_cjdc_store'=>'s'],'s.id = o.store_id','inner') |
|||
//->distinct(true)
|
|||
->where('m.order_num',$order_num) |
|||
->field("o.note as o_note,g.name,g.number,g.money,g.good_unit,m.delivery_time as ps_time,m.address,m.note,m.name as user_name,m.dada_fee,m.money as m_money,m.yhq_money2,m.box_money,f.sn,m.tel,m.order_num,g.id,g.spec,s.name as shopname") |
|||
->order('s.id') |
|||
->select(); |
|||
// $order_goods = Db::table('ims_cjdc_order_goods')->where('order_id', $order_main['id'])->field("name,number,money")->select();
|
|||
// $sn = Db::table('ims_cjdc_feprint')->where('market_id', $order_main['market_id'])->value("sn");
|
|||
$content = PrintFormat($data, 14, 6, 3, 6); |
|||
$res = printMsg($data[0]['sn'], $content, 1); |
|||
return ($res); |
|||
} |
|||
|
|||
function PrintFormat($arr, $A, $B, $C, $D) |
|||
{ |
|||
$orderInfo = '<CB>懒族生活</CB><BR>'; |
|||
$orderInfo .= '名称 单价 数量 金额<BR>'; |
|||
$orderInfo .= '--------------------------------<BR>'; |
|||
$shopname = ""; |
|||
$shopnum = 0; |
|||
foreach ($arr as $k5 => $v5) { |
|||
if ($shopname != $v5['shopname']) { |
|||
if ($shopname != "") { |
|||
$orderInfo .= ' <BR>'; |
|||
} |
|||
$shopnum++; |
|||
$orderInfo .= "<C>(" . $shopnum . ")" .$v5['shopname'] . '</C><BR>'; |
|||
$shopname = $v5['shopname']; |
|||
} |
|||
$name = $v5['name']; |
|||
if(!empty($v5['spec'])) { |
|||
$name .= "(规格:". $v5['spec'].")"; |
|||
}elseif (!empty($v5['good_unit'])){ |
|||
$name .= "(规格:". $v5['good_unit'].")"; |
|||
} |
|||
$price = $v5['money']; |
|||
$num = $v5['number']; |
|||
$prices = sprintf("%.2f",$v5['money']*$v5['number']); |
|||
$kw3 = ''; |
|||
$kw1 = ''; |
|||
$kw2 = ''; |
|||
$kw4 = ''; |
|||
$str = $name; |
|||
$blankNum = $A;//名称控制为14个字节
|
|||
$lan = mb_strlen($str,'utf-8'); |
|||
$m = 0; |
|||
$j=1; |
|||
$blankNum++; |
|||
$result = array(); |
|||
if(strlen($price) < $B){ |
|||
$k1 = $B - strlen($price); |
|||
for($q=0;$q<$k1;$q++){ |
|||
$kw1 .= ' '; |
|||
} |
|||
$price = $kw1.$price; |
|||
} |
|||
if(strlen($num) < $C){ |
|||
$k2 = $C - strlen($num); |
|||
for($q=0;$q<$k2;$q++){ |
|||
$kw2 .= ' '; |
|||
} |
|||
$num = $kw2.$num; |
|||
} |
|||
if(strlen($prices) < $D){ |
|||
$k3 = $D - strlen($prices); |
|||
for($q=0;$q<$k3;$q++){ |
|||
$kw4 .= ' '; |
|||
} |
|||
$prices = $kw4.$prices; |
|||
} |
|||
for ($i=0;$i<$lan;$i++){ |
|||
$new = mb_substr($str,$m,$j,'utf-8'); |
|||
$j++; |
|||
if(mb_strwidth($new,'utf-8')<$blankNum) { |
|||
if($m+$j>$lan) { |
|||
$m = $m+$j; |
|||
$tail = $new; |
|||
$lenght = iconv("UTF-8", "GBK//IGNORE", $new); |
|||
$k = $A - strlen($lenght); |
|||
for($q=0;$q<$k;$q++){ |
|||
$kw3 .= ' '; |
|||
} |
|||
if($m==$j){ |
|||
$tail .= $kw3.' '.$price.' '.$num.' '.$prices; |
|||
}else{ |
|||
$tail .= $kw3.'<BR>'; |
|||
} |
|||
break; |
|||
}else{ |
|||
$next_new = mb_substr($str,$m,$j,'utf-8'); |
|||
if(mb_strwidth($next_new,'utf-8')<$blankNum) continue; |
|||
else{ |
|||
$m = $i+1; |
|||
$result[] = $new; |
|||
$j=1; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
$head = ''; |
|||
foreach ($result as $key=>$value) { |
|||
if($key < 1){ |
|||
$v_lenght = iconv("UTF-8", "GBK//IGNORE", $value); |
|||
$v_lenght = strlen($v_lenght); |
|||
if($v_lenght == 13) $value = $value." "; |
|||
$head .= $value.' '.$price.' '.$num.' '.$prices; |
|||
}else{ |
|||
$head .= $value.'<BR>'; |
|||
} |
|||
} |
|||
$orderInfo .= $head.$tail; |
|||
if(!empty($v5['o_note'])){ |
|||
$orderInfo .= '备注:'.$v5['o_note'].'<BR>'; |
|||
} |
|||
@$nums += $prices; |
|||
} |
|||
// $time = date('Y-m-d H:i:s', time());
|
|||
$orderInfo .= '--------------------------------<BR>'; |
|||
if ($arr[0]['box_money'] > 0) { |
|||
$kw5 = ''; |
|||
$len = 24 - strlen($arr[0]['box_money']); |
|||
for ($q = 0; $q < $len; $q++) { |
|||
$kw5 .= ' '; |
|||
} |
|||
$orderInfo .= '包装费:' . $kw5 . $arr[0]['box_money'] . '<BR>'; |
|||
} |
|||
if($arr[0]['dada_fee'] > 0){ |
|||
$kw5 = ''; |
|||
$len = 24 - strlen($arr[0]['dada_fee']); |
|||
for ($q = 0; $q < $len; $q++) { |
|||
$kw5 .= ' '; |
|||
} |
|||
$orderInfo .= '配送费:'.$kw5.$arr[0]['dada_fee'].'<BR>'; |
|||
} |
|||
if($arr[0]['yhq_money2'] > 0){ |
|||
$yhq_money2 = sprintf("%.2f",$arr[0]['yhq_money2']); |
|||
$kw6 = ''; |
|||
$len = 25 - strlen($yhq_money2); |
|||
for ($q = 0; $q < $len; $q++) { |
|||
$kw6 .= ' '; |
|||
} |
|||
$orderInfo .= '红包:'.$kw6.'-'.$yhq_money2.'<BR>'; |
|||
} |
|||
$total = '合计:'.$arr[0]['m_money']; |
|||
$user_name = $arr[0]['user_name']; |
|||
if(strlen($user_name)>18){ |
|||
$user_name=substr($user_name,0,18).'...'; |
|||
} |
|||
$str = $user_name . $total; |
|||
$kw5 = ''; |
|||
$lenght = iconv("UTF-8", "GBK//IGNORE", $str); |
|||
$total_len = 32 - strlen($lenght); |
|||
for ($q = 0; $q < $total_len; $q++) { |
|||
$kw5 .= ' '; |
|||
} |
|||
$total_str = $user_name.$kw5.$total; |
|||
$orderInfo .= $total_str.'<BR>'; |
|||
$orderInfo .= '送货地点:' . $arr[0]['address'] . '<BR>'; |
|||
$tel = substr_replace( $arr[0]['tel'], '****', 3, 4); |
|||
$orderInfo .= '联系电话:' . $tel . '<BR>'; |
|||
$orderInfo .= '配送时间:' . $arr[0]['ps_time'] . '<BR>'; |
|||
if(!empty($arr[0]['note'])){ |
|||
$orderInfo .= '备注:'.$arr[0]['note'].'<BR><BR>'; |
|||
} |
|||
//$orderInfo .= '<QR>http://www.feieyun.com</QR>';//把解析后的二维码生成的字符串用标签套上即可自动生成二维码
|
|||
return $orderInfo; |
|||
} |
|||
|
|||
?>
|
|||
@ -0,0 +1,307 @@ |
|||
<?php |
|||
|
|||
class HttpClient { |
|||
// Request vars
|
|||
var $host; |
|||
var $port; |
|||
var $path; |
|||
var $method; |
|||
var $postdata = ''; |
|||
var $cookies = array(); |
|||
var $referer; |
|||
var $accept = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*'; |
|||
var $accept_encoding = 'gzip'; |
|||
var $accept_language = 'en-us'; |
|||
var $user_agent = 'Incutio HttpClient v0.9'; |
|||
var $timeout = 20; |
|||
var $use_gzip = true; |
|||
var $persist_cookies = true; |
|||
var $persist_referers = true; |
|||
var $debug = false; |
|||
var $handle_redirects = true; |
|||
var $max_redirects = 5; |
|||
var $headers_only = false; |
|||
var $username; |
|||
var $password; |
|||
var $status; |
|||
var $headers = array(); |
|||
var $content = ''; |
|||
var $errormsg; |
|||
var $redirect_count = 0; |
|||
var $cookie_host = ''; |
|||
function __construct($host, $port=80) { |
|||
$this->host = $host; |
|||
$this->port = $port; |
|||
} |
|||
function get($path, $data = false) { |
|||
$this->path = $path; |
|||
$this->method = 'GET'; |
|||
if ($data) { |
|||
$this->path .= '?'.$this->buildQueryString($data); |
|||
} |
|||
return $this->doRequest(); |
|||
} |
|||
function post($path, $data) { |
|||
$this->path = $path; |
|||
$this->method = 'POST'; |
|||
$this->postdata = $this->buildQueryString($data); |
|||
return $this->doRequest(); |
|||
} |
|||
function buildQueryString($data) { |
|||
$querystring = ''; |
|||
if (is_array($data)) { |
|||
foreach ($data as $key => $val) { |
|||
if (is_array($val)) { |
|||
foreach ($val as $val2) { |
|||
$querystring .= urlencode($key).'='.urlencode($val2).'&'; |
|||
} |
|||
} else { |
|||
$querystring .= urlencode($key).'='.urlencode($val).'&'; |
|||
} |
|||
} |
|||
$querystring = substr($querystring, 0, -1); // Eliminate unnecessary &
|
|||
} else { |
|||
$querystring = $data; |
|||
} |
|||
return $querystring; |
|||
} |
|||
function doRequest() { |
|||
if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) { |
|||
switch($errno) { |
|||
case -3: |
|||
$this->errormsg = 'Socket creation failed (-3)'; |
|||
case -4: |
|||
$this->errormsg = 'DNS lookup failure (-4)'; |
|||
case -5: |
|||
$this->errormsg = 'Connection refused or timed out (-5)'; |
|||
default: |
|||
$this->errormsg = 'Connection failed ('.$errno.')'; |
|||
$this->errormsg .= ' '.$errstr; |
|||
$this->debug($this->errormsg); |
|||
} |
|||
return false; |
|||
} |
|||
socket_set_timeout($fp, $this->timeout); |
|||
$request = $this->buildRequest(); |
|||
$this->debug('Request', $request); |
|||
fwrite($fp, $request); |
|||
$this->headers = array(); |
|||
$this->content = ''; |
|||
$this->errormsg = ''; |
|||
$inHeaders = true; |
|||
$atStart = true; |
|||
while (!feof($fp)) { |
|||
$line = fgets($fp, 4096); |
|||
if ($atStart) { |
|||
$atStart = false; |
|||
if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) { |
|||
$this->errormsg = "Status code line invalid: ".htmlentities($line); |
|||
$this->debug($this->errormsg); |
|||
return false; |
|||
} |
|||
$http_version = $m[1]; |
|||
$this->status = $m[2]; |
|||
$status_string = $m[3]; |
|||
$this->debug(trim($line)); |
|||
continue; |
|||
} |
|||
if ($inHeaders) { |
|||
if (trim($line) == '') { |
|||
$inHeaders = false; |
|||
$this->debug('Received Headers', $this->headers); |
|||
if ($this->headers_only) { |
|||
break; |
|||
} |
|||
continue; |
|||
} |
|||
if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) { |
|||
continue; |
|||
} |
|||
$key = strtolower(trim($m[1])); |
|||
$val = trim($m[2]); |
|||
if (isset($this->headers[$key])) { |
|||
if (is_array($this->headers[$key])) { |
|||
$this->headers[$key][] = $val; |
|||
} else { |
|||
$this->headers[$key] = array($this->headers[$key], $val); |
|||
} |
|||
} else { |
|||
$this->headers[$key] = $val; |
|||
} |
|||
continue; |
|||
} |
|||
$this->content .= $line; |
|||
} |
|||
fclose($fp); |
|||
if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') { |
|||
$this->debug('Content is gzip encoded, unzipping it'); |
|||
$this->content = substr($this->content, 10); |
|||
$this->content = gzinflate($this->content); |
|||
} |
|||
if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) { |
|||
$cookies = $this->headers['set-cookie']; |
|||
if (!is_array($cookies)) { |
|||
$cookies = array($cookies); |
|||
} |
|||
foreach ($cookies as $cookie) { |
|||
if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) { |
|||
$this->cookies[$m[1]] = $m[2]; |
|||
} |
|||
} |
|||
$this->cookie_host = $this->host; |
|||
} |
|||
if ($this->persist_referers) { |
|||
$this->debug('Persisting referer: '.$this->getRequestURL()); |
|||
$this->referer = $this->getRequestURL(); |
|||
} |
|||
if ($this->handle_redirects) { |
|||
if (++$this->redirect_count >= $this->max_redirects) { |
|||
$this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')'; |
|||
$this->debug($this->errormsg); |
|||
$this->redirect_count = 0; |
|||
return false; |
|||
} |
|||
$location = isset($this->headers['location']) ? $this->headers['location'] : ''; |
|||
$uri = isset($this->headers['uri']) ? $this->headers['uri'] : ''; |
|||
if ($location || $uri) { |
|||
$url = parse_url($location.$uri); |
|||
return $this->get($url['path']); |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
function buildRequest() { |
|||
$headers = array(); |
|||
$headers[] = "{$this->method} {$this->path} HTTP/1.0"; |
|||
$headers[] = "Host: {$this->host}"; |
|||
$headers[] = "User-Agent: {$this->user_agent}"; |
|||
$headers[] = "Accept: {$this->accept}"; |
|||
if ($this->use_gzip) { |
|||
$headers[] = "Accept-encoding: {$this->accept_encoding}"; |
|||
} |
|||
$headers[] = "Accept-language: {$this->accept_language}"; |
|||
if ($this->referer) { |
|||
$headers[] = "Referer: {$this->referer}"; |
|||
} |
|||
if ($this->cookies) { |
|||
$cookie = 'Cookie: '; |
|||
foreach ($this->cookies as $key => $value) { |
|||
$cookie .= "$key=$value; "; |
|||
} |
|||
$headers[] = $cookie; |
|||
} |
|||
if ($this->username && $this->password) { |
|||
$headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password); |
|||
} |
|||
if ($this->postdata) { |
|||
$headers[] = 'Content-Type: application/x-www-form-urlencoded'; |
|||
$headers[] = 'Content-Length: '.strlen($this->postdata); |
|||
} |
|||
$request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata; |
|||
return $request; |
|||
} |
|||
function getStatus() { |
|||
return $this->status; |
|||
} |
|||
function getContent() { |
|||
return $this->content; |
|||
} |
|||
function getHeaders() { |
|||
return $this->headers; |
|||
} |
|||
function getHeader($header) { |
|||
$header = strtolower($header); |
|||
if (isset($this->headers[$header])) { |
|||
return $this->headers[$header]; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
function getError() { |
|||
return $this->errormsg; |
|||
} |
|||
function getCookies() { |
|||
return $this->cookies; |
|||
} |
|||
function getRequestURL() { |
|||
$url = 'https://'.$this->host; |
|||
if ($this->port != 80) { |
|||
$url .= ':'.$this->port; |
|||
} |
|||
$url .= $this->path; |
|||
return $url; |
|||
} |
|||
function setUserAgent($string) { |
|||
$this->user_agent = $string; |
|||
} |
|||
function setAuthorization($username, $password) { |
|||
$this->username = $username; |
|||
$this->password = $password; |
|||
} |
|||
function setCookies($array) { |
|||
$this->cookies = $array; |
|||
} |
|||
function useGzip($boolean) { |
|||
$this->use_gzip = $boolean; |
|||
} |
|||
function setPersistCookies($boolean) { |
|||
$this->persist_cookies = $boolean; |
|||
} |
|||
function setPersistReferers($boolean) { |
|||
$this->persist_referers = $boolean; |
|||
} |
|||
function setHandleRedirects($boolean) { |
|||
$this->handle_redirects = $boolean; |
|||
} |
|||
function setMaxRedirects($num) { |
|||
$this->max_redirects = $num; |
|||
} |
|||
function setHeadersOnly($boolean) { |
|||
$this->headers_only = $boolean; |
|||
} |
|||
function setDebug($boolean) { |
|||
$this->debug = $boolean; |
|||
} |
|||
function quickGet($url) { |
|||
$bits = parse_url($url); |
|||
$host = $bits['host']; |
|||
$port = isset($bits['port']) ? $bits['port'] : 80; |
|||
$path = isset($bits['path']) ? $bits['path'] : '/'; |
|||
if (isset($bits['query'])) { |
|||
$path .= '?'.$bits['query']; |
|||
} |
|||
$client = new HttpClient($host, $port); |
|||
if (!$client->get($path)) { |
|||
return false; |
|||
} else { |
|||
return $client->getContent(); |
|||
} |
|||
} |
|||
function quickPost($url, $data) { |
|||
$bits = parse_url($url); |
|||
$host = $bits['host']; |
|||
$port = isset($bits['port']) ? $bits['port'] : 80; |
|||
$path = isset($bits['path']) ? $bits['path'] : '/'; |
|||
$client = new HttpClient($host, $port); |
|||
if (!$client->post($path, $data)) { |
|||
return false; |
|||
} else { |
|||
return $client->getContent(); |
|||
} |
|||
} |
|||
function debug($msg, $object = false) { |
|||
if ($this->debug) { |
|||
print '<div style="border: 1px solid red; padding: 0.5em; margin: 0.5em;"><strong>HttpClient Debug:</strong> '.$msg; |
|||
if ($object) { |
|||
ob_start(); |
|||
print_r($object); |
|||
$content = htmlentities(ob_get_contents()); |
|||
ob_end_clean(); |
|||
print '<pre>'.$content.'</pre>'; |
|||
} |
|||
print '</div>'; |
|||
} |
|||
} |
|||
} |
|||
|
|||
?>
|
|||
@ -0,0 +1,46 @@ |
|||
一、添加打印机 |
|||
|
|||
方法名 printerContent($content) |
|||
|
|||
参数说明 $content 打印机编号(必填) # 打印机识别码(必填) # 备注名称(选填) # 流量卡号码(选填),多台打印机请换行(\n)添加新打印机信息,每次最多100台 |
|||
如:316500010 # abcdefgh # 快餐前台 # 13688889999 |
|||
316500011 # abcdefgh # 快餐厨房 # 13688889990 |
|||
二、删除打印机 |
|||
|
|||
方法名 printerDelList($snlist) |
|||
|
|||
参数说明 $snlist 打印机编号 多台用-连接 |
|||
如:316500010-316500011 |
|||
三、打印订单 |
|||
|
|||
方法名 printMsg($sn,$content,$times) |
|||
|
|||
参数说明 $sn 打印机编码 $content 打印内容 $times 打印张数 无值默认为1 |
|||
如: $sn = 550510805; |
|||
$content = '<CB>测试打印</CB><BR>'; |
|||
$content .= '名称 单价 数量 金额<BR>'; |
|||
$content .= '--------------------------------<BR>'; |
|||
$content .= '饭 10.0 10 100.0<BR>'; |
|||
$content .= '炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '鸡蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿鸡蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '--------------------------------<BR>'; |
|||
$content .= '备注:加辣<BR>'; |
|||
$content .= '合计:xx.0元<BR>'; |
|||
$content .= '送货地点:广西南宁五象新区<BR>'; |
|||
$content .= '联系电话:13888888888888<BR>'; |
|||
$content .= '订餐时间:2014-08-08 08:08:08<BR>'; |
|||
$content .= '<QR>http://www.feieyun.com</QR>';//把二维码字符串用标签套上即可自动生成二维码 |
|||
//标签说明: |
|||
$content = "<DIRECTION>1</DIRECTION>";//设定打印时出纸和打印字体的方向,n 0 或 1,每次设备重启后都会初始化为 0 值设置,1:正向出纸,0:反向出纸, |
|||
$content .= "<TEXT x='9' y='10' font='12' w='1' h='2' r='0'>#001 五号桌 1/3</TEXT><TEXT x='80' y='80' font='12' w='2' h='2' r='0'>可乐鸡翅</TEXT><TEXT x='9' y='180' font='12' w='1' h='1' r='0'>张三先生 13800138000</TEXT>";//40mm宽度标签纸打印例子,打开注释调用标签打印接口打印 |
|||
|
|||
四、查询订单状态 |
|||
|
|||
方法名 queryOrderState($orderid) |
|||
|
|||
参数说明 $orderid 飞鹅订单号(发起打印请求成功时,从回调的参数中获取) |
|||
如:550510805_20200603103522_387054119 |
|||
@ -0,0 +1,14 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Models; |
|||
|
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Feprint extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
protected $table = 'ims_cjdc_feprint'; |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Models; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\SoftDeletes; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class LanzuServiceHorseman extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
use SoftDeletes; |
|||
|
|||
protected $table = 'lanzu_service_horseman'; |
|||
protected $dateFormat = 'U'; |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
<?php |
|||
return [ |
|||
//自营平台订单状态
|
|||
'state'=>[ |
|||
0=>'错误状态', |
|||
1=>'待付款', |
|||
2=>'待接单', |
|||
3=>'待发货', |
|||
31=>'配送中',//state==3&&order_shipping_code==1
|
|||
4=>'已完成', |
|||
5=>'已评价', |
|||
6=>'已取消', |
|||
7=>'拒绝', |
|||
8=>'申请退款', |
|||
9=>'已退款', |
|||
10=>'退款拒绝', |
|||
9999=>'虚拟订单' |
|||
], |
|||
//达达平台的订单状态
|
|||
'dada_status'=>[ |
|||
1=>'待快递员接单', |
|||
2=>'待取货', |
|||
3=>'配送中', |
|||
4=>'已完成', |
|||
5=>'已取消', |
|||
8=>'指派单', |
|||
9=>'妥投异常之物品返回中', |
|||
10=>'妥投异常之物品返回完成', |
|||
100=>'骑士到店', |
|||
1000=>'创建达达运单失败', |
|||
|
|||
], |
|||
//达达测试0 如果为1则用为正式环境
|
|||
'online'=>0, |
|||
'dada_test_config'=>[ |
|||
'source_id'=>'73753', |
|||
'shop_no'=>'11047059', |
|||
'app_key'=>'dada91f5568c2fa580b', |
|||
'app_secret'=>'851019e075fd94d00942289c9161008c', |
|||
'url'=>'http://newopen.qa.imdada.cn' |
|||
], |
|||
'dada_config'=>[ |
|||
'source_id'=>'49325', |
|||
'app_key'=>'dada9c5cebc86361427', |
|||
'app_secret'=>'bd3cedf12d2749aa8791f1686a9d9a54', |
|||
'url'=>'https://newopen.imdada.cn' |
|||
], |
|||
]; |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
return [ |
|||
'labels' => [ |
|||
'ImsCjdcOrderMain' => 'ImsCjdcOrderMain', |
|||
], |
|||
'fields' => [ |
|||
'user_id' => '用户id', |
|||
'order_num' => '订单号', |
|||
'state' => '1.待付款2.待结单3.等待送达4.完成5.已评价6.取消7.拒绝8.退款中9.已退款10.退款拒绝', |
|||
'time' => '下单时间', |
|||
'pay_time' => '支付时间', |
|||
'money' => '付款金额', |
|||
], |
|||
'options' => [ |
|||
], |
|||
]; |
|||
@ -0,0 +1,17 @@ |
|||
<?php |
|||
return [ |
|||
'labels' => [ |
|||
'LanzuServiceHorseman' => 'LanzuServiceHorseman', |
|||
], |
|||
'fields' => [ |
|||
'user_id' => '用户id', |
|||
'name' => '姓名', |
|||
'tel' => '电话', |
|||
'market_id' => '市场id', |
|||
'status' => '状态 -1禁用 1正常 2删除', |
|||
'qr_url' => '骑手二维码', |
|||
'head_url' => '头像', |
|||
], |
|||
'options' => [ |
|||
], |
|||
]; |
|||
@ -0,0 +1,14 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>Laravel</title> |
|||
|
|||
|
|||
|
|||
</head> |
|||
<body > |
|||
|
|||
<h1>{{$id}}</h1> |
|||
</body> |
|||
</html> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue