From 28061633ce2e8f7f84a3c291510f8c2b9639663e Mon Sep 17 00:00:00 2001 From: lanzu_qsy <334039090@qq.com> Date: Wed, 2 Sep 2020 16:38:39 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Actions/ModifyOrderState.php | 58 ++++++++ app/Admin/Actions/Show/OrderDetail.php | 78 ++++++++++ .../ImsCjdcOrderMainController.php | 139 ++++++++++++++++++ app/Admin/Controllers/Test.php | 18 +++ app/Admin/Extensions/CheckRow.php | 61 +++++--- app/Admin/Extensions/OrderDetail.php | 16 ++ app/Admin/Extensions/OrderStateHandle.php | 55 +++++++ app/Admin/Repositories/ImsCjdcMarket.php | 6 + app/Admin/Repositories/ImsCjdcOrderMain.php | 5 +- app/Admin/routes.php | 3 + app/Models/ImsCjdcMarket.php | 14 +- app/Models/ImsCjdcOrderMain.php | 2 + app/Models/StoreAccount.php | 5 - config/order.php | 48 ++++++ resources/lang/zh-CN/ims-cjdc-order-main.php | 16 ++ resources/views/orderdetail.php | 14 ++ 16 files changed, 496 insertions(+), 42 deletions(-) create mode 100644 app/Admin/Actions/ModifyOrderState.php create mode 100644 app/Admin/Actions/Show/OrderDetail.php create mode 100644 app/Admin/Controllers/ImsCjdcOrderMainController.php create mode 100644 app/Admin/Controllers/Test.php create mode 100644 app/Admin/Extensions/OrderDetail.php create mode 100644 app/Admin/Extensions/OrderStateHandle.php create mode 100644 config/order.php create mode 100644 resources/lang/zh-CN/ims-cjdc-order-main.php create mode 100644 resources/views/orderdetail.php diff --git a/app/Admin/Actions/ModifyOrderState.php b/app/Admin/Actions/ModifyOrderState.php new file mode 100644 index 0000000..4cc0f48 --- /dev/null +++ b/app/Admin/Actions/ModifyOrderState.php @@ -0,0 +1,58 @@ +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 []; + } +} diff --git a/app/Admin/Actions/Show/OrderDetail.php b/app/Admin/Actions/Show/OrderDetail.php new file mode 100644 index 0000000..318f14a --- /dev/null +++ b/app/Admin/Actions/Show/OrderDetail.php @@ -0,0 +1,78 @@ +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 []; + } +} diff --git a/app/Admin/Controllers/ImsCjdcOrderMainController.php b/app/Admin/Controllers/ImsCjdcOrderMainController.php new file mode 100644 index 0000000..b8d4ecc --- /dev/null +++ b/app/Admin/Controllers/ImsCjdcOrderMainController.php @@ -0,0 +1,139 @@ +>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(function (Grid\Displayers\Actions $actions) { + $state = $actions->row->state; + if ($state==2){ + $actions->append(new OrderStateHandle('接单',3)); + }elseif ($state==31){ + $actions->append(new OrderStateHandle('完成',4)); + } + $actions->append(new OrderDetail('详情')); + + //$actions->append("拒绝  "); + //$actions->append("同意"); + + + }); + //$grid->column('详情')->modal('详情',function ()use ($grid){ + // return view('orderdetail',['id'=>2]); + // + //}); + $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 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; + } +} diff --git a/app/Admin/Controllers/Test.php b/app/Admin/Controllers/Test.php new file mode 100644 index 0000000..7ef955c --- /dev/null +++ b/app/Admin/Controllers/Test.php @@ -0,0 +1,18 @@ +state = $state; + } + + /** - * 添加JS + * 处理请求 * - * @return string + * @param Request $request + * + * @return \Dcat\Admin\Actions\Response */ - protected function script() + public function handle(Request $request) { - return <<getKey(); + $orderMain = new ImsCjdcOrderMain(); + $state = $request->get('state'); + $res = $orderMain->modifyState($id,$state); + if ($res==true){ + return $this->response()->success('操作成功')->refresh(); + }else{ + return $this->response()->error('操作失败'); + } + - // 获取当前行数据的用户名 - $username = $this->row->username; - // 这里需要添加一个class, 和上面script方法对应 - $this->setHtmlAttribute(['data-id' => $id, 'email' => $username, 'class' => 'grid-check-row']); + } - return parent::html(); + /** + * 设置要POST到接口的数据 + * + * @return array + */ + public function parameters() + { + return [ + 'state' => $this->state, + ]; } } diff --git a/app/Admin/Extensions/OrderDetail.php b/app/Admin/Extensions/OrderDetail.php new file mode 100644 index 0000000..7ae0e87 --- /dev/null +++ b/app/Admin/Extensions/OrderDetail.php @@ -0,0 +1,16 @@ +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'); + $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, + ]; + } +} diff --git a/app/Admin/Repositories/ImsCjdcMarket.php b/app/Admin/Repositories/ImsCjdcMarket.php index 09e1e92..d498e9e 100644 --- a/app/Admin/Repositories/ImsCjdcMarket.php +++ b/app/Admin/Repositories/ImsCjdcMarket.php @@ -13,4 +13,10 @@ class ImsCjdcMarket extends EloquentRepository * @var string */ protected $eloquentClass = Model::class; + + // 通过这个方法可以指定查询的字段,默认"*" + public function getGridColumns() + { + return [$this->getKeyName(), 'name']; + } } diff --git a/app/Admin/Repositories/ImsCjdcOrderMain.php b/app/Admin/Repositories/ImsCjdcOrderMain.php index c09e322..97349dc 100644 --- a/app/Admin/Repositories/ImsCjdcOrderMain.php +++ b/app/Admin/Repositories/ImsCjdcOrderMain.php @@ -18,9 +18,9 @@ class ImsCjdcOrderMain extends EloquentRepository public function get(Grid\Model $model) { $builder = new \App\Models\ImsCjdcOrderMain(); - $builder = $builder::leftJoin('ims_cjdc_user','ims_cjdc_user.id','ims_cjdc_order_main.user_id') + $builder = $builder::leftJoin('ims_cjdc_user as u','u.id','ims_cjdc_order_main.user_id') ->with('market') - ->select('ims_cjdc_order_main.*','ims_cjdc_user.name as user_name') + ->select('ims_cjdc_order_main.*','u.name as user_name') ->where('type',1) ->orderBy('ims_cjdc_order_main.id','desc');//只取线上订单数据 @@ -38,6 +38,7 @@ class ImsCjdcOrderMain extends EloquentRepository }); $query = $query->toArray(); + //如果订单状态为配送中 将state设置为31 foreach ($query['data'] as &$value){ if ($value['state']==3&&$value['order_shipping_code']==1){ $value['state'] = 31; diff --git a/app/Admin/routes.php b/app/Admin/routes.php index a6102e8..4b9dbcf 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -44,5 +44,8 @@ Route::group([ //统计店铺新增用户 $router->resource('/storeUserReport', 'StoreUserReportController'); + $router->resource('/order', 'ImsCjdcOrderMainController'); + $router->any('/detail', 'ImsCjdcOrderMainController@orderDetail'); + $router->any('/test', 'Test@test'); }); diff --git a/app/Models/ImsCjdcMarket.php b/app/Models/ImsCjdcMarket.php index 8f441d5..1496a8c 100644 --- a/app/Models/ImsCjdcMarket.php +++ b/app/Models/ImsCjdcMarket.php @@ -29,18 +29,6 @@ class ImsCjdcMarket extends Model return $this->hasOne('\App\Models\LanzuMpInfo','id','mp_id'); } - /** - * 获取市场信息 - * @return \Illuminate\Http\JsonResponse - */ - public static function getMarket() - { - $markets = self::get(); - $item = []; - foreach ($markets as $market) { - $item[$market->id] = $market->name; - } - return $item; - } + } diff --git a/app/Models/ImsCjdcOrderMain.php b/app/Models/ImsCjdcOrderMain.php index e9f4d63..76ad925 100644 --- a/app/Models/ImsCjdcOrderMain.php +++ b/app/Models/ImsCjdcOrderMain.php @@ -54,4 +54,6 @@ class ImsCjdcOrderMain extends Model }); } + + } diff --git a/app/Models/StoreAccount.php b/app/Models/StoreAccount.php index 23de9ae..029559b 100644 --- a/app/Models/StoreAccount.php +++ b/app/Models/StoreAccount.php @@ -9,7 +9,6 @@ namespace App\Models; use Dcat\Admin\Traits\HasDateTimeFormatter; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; -use App\Models\ImsCjdcStore as storeModel; class StoreAccount extends Model { @@ -46,8 +45,4 @@ class StoreAccount extends Model return false; } } - - public function store(){ - return $this->hasMany(storeModel::class,'id','store_id'); - } } diff --git a/config/order.php b/config/order.php new file mode 100644 index 0000000..23caf29 --- /dev/null +++ b/config/order.php @@ -0,0 +1,48 @@ +[ + 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' + ], +]; diff --git a/resources/lang/zh-CN/ims-cjdc-order-main.php b/resources/lang/zh-CN/ims-cjdc-order-main.php new file mode 100644 index 0000000..3600905 --- /dev/null +++ b/resources/lang/zh-CN/ims-cjdc-order-main.php @@ -0,0 +1,16 @@ + [ + 'ImsCjdcOrderMain' => 'ImsCjdcOrderMain', + ], + 'fields' => [ + 'user_id' => '用户id', + 'order_num' => '订单号', + 'state' => '1.待付款2.待结单3.等待送达4.完成5.已评价6.取消7.拒绝8.退款中9.已退款10.退款拒绝', + 'time' => '下单时间', + 'pay_time' => '支付时间', + 'money' => '付款金额', + ], + 'options' => [ + ], +]; diff --git a/resources/views/orderdetail.php b/resources/views/orderdetail.php new file mode 100644 index 0000000..ec2878a --- /dev/null +++ b/resources/views/orderdetail.php @@ -0,0 +1,14 @@ + + + + + Laravel + + + + + + +

{{$id}}

+ + From b468729be00050180c58f76ee85c668dd635500c Mon Sep 17 00:00:00 2001 From: lanzu_qsy <334039090@qq.com> Date: Wed, 2 Sep 2020 17:00:44 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=AA=91=E6=89=8B?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LanzuServiceHorsemanController.php | 79 ++++++ .../Repositories/LanzuServiceHorseman.php | 16 ++ app/Admin/routes.php | 2 + app/Models/LanzuServiceHorseman.php | 16 ++ dcat_admin_ide_helper.php | 236 ++++++++++++------ .../lang/zh-CN/lanzu-service-horseman.php | 17 ++ 6 files changed, 294 insertions(+), 72 deletions(-) create mode 100644 app/Admin/Controllers/LanzuServiceHorsemanController.php create mode 100644 app/Admin/Repositories/LanzuServiceHorseman.php create mode 100644 app/Models/LanzuServiceHorseman.php create mode 100644 resources/lang/zh-CN/lanzu-service-horseman.php diff --git a/app/Admin/Controllers/LanzuServiceHorsemanController.php b/app/Admin/Controllers/LanzuServiceHorsemanController.php new file mode 100644 index 0000000..4a5e39b --- /dev/null +++ b/app/Admin/Controllers/LanzuServiceHorsemanController.php @@ -0,0 +1,79 @@ +id->sortable(); + $grid->name; + $grid->tel; + $grid->market_id('所属市场'); + $grid->status('状态'); + $grid->head_url; + $grid->created_at; + $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; + $show->name; + $show->tel; + $show->market_id; + $show->status; + $show->qr_url; + $show->head_url; + $show->created_at; + $show->updated_at; + }); + } + + /** + * 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->text('market_id','所属市场')->options(ImsCjdcMarket::getMarket())->required(); + $form->radio('status','状态')->options([1=>'启用',-1=>'禁用'])->value(1)->required(); + $form->image('head_url')->uniqueName(); + + $form->display('created_at'); + $form->display('updated_at'); + }); + } +} diff --git a/app/Admin/Repositories/LanzuServiceHorseman.php b/app/Admin/Repositories/LanzuServiceHorseman.php new file mode 100644 index 0000000..56a449f --- /dev/null +++ b/app/Admin/Repositories/LanzuServiceHorseman.php @@ -0,0 +1,16 @@ +resource('/order', 'ImsCjdcOrderMainController'); $router->any('/detail', 'ImsCjdcOrderMainController@orderDetail'); + $router->resource('/horseman', 'LanzuServiceHorsemanController'); + $router->any('/test', 'Test@test'); }); diff --git a/app/Models/LanzuServiceHorseman.php b/app/Models/LanzuServiceHorseman.php new file mode 100644 index 0000000..74ad9f0 --- /dev/null +++ b/app/Models/LanzuServiceHorseman.php @@ -0,0 +1,16 @@ + [ + 'LanzuServiceHorseman' => 'LanzuServiceHorseman', + ], + 'fields' => [ + 'user_id' => '用户id', + 'name' => '姓名', + 'tel' => '电话', + 'market_id' => '市场id', + 'status' => '状态 -1禁用 1正常 2删除', + 'qr_url' => '骑手二维码', + 'head_url' => '头像', + ], + 'options' => [ + ], +]; From 7f3e3dd7fe17672f7c52b2a8f1816fe87f28032d Mon Sep 17 00:00:00 2001 From: lanzu_qsy <334039090@qq.com> Date: Wed, 2 Sep 2020 21:07:41 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImsCjdcOrderMainController.php | 6 + .../LanzuServiceHorsemanController.php | 35 +- app/Admin/Extensions/OrderPrint.php | 34 ++ app/Admin/Extensions/OrderStateHandle.php | 9 +- app/Libs/feier_print/api_php_demo.php | 326 ++++++++++++++++++ app/Libs/feier_print/httpclient.php | 307 +++++++++++++++++ .../飞鹅云打印说明文档.txt | 46 +++ app/Models/ImsCjdcMarket.php | 16 +- app/Models/ImsCjdcOrderMain.php | 5 +- app/Models/LanzuServiceHorseman.php | 2 +- 10 files changed, 768 insertions(+), 18 deletions(-) create mode 100644 app/Admin/Extensions/OrderPrint.php create mode 100644 app/Libs/feier_print/api_php_demo.php create mode 100644 app/Libs/feier_print/httpclient.php create mode 100644 app/Libs/feier_print/飞鹅云打印说明文档.txt diff --git a/app/Admin/Controllers/ImsCjdcOrderMainController.php b/app/Admin/Controllers/ImsCjdcOrderMainController.php index b8d4ecc..a40ba17 100644 --- a/app/Admin/Controllers/ImsCjdcOrderMainController.php +++ b/app/Admin/Controllers/ImsCjdcOrderMainController.php @@ -3,6 +3,7 @@ namespace App\Admin\Controllers; use App\Admin\Extensions\OrderDetail; +use App\Admin\Extensions\OrderPrint; use App\Admin\Extensions\OrderStateHandle; use App\Admin\Repositories\ImsCjdcOrderMain; use Dcat\Admin\Admin; @@ -44,9 +45,14 @@ class ImsCjdcOrderMainController extends AdminController $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("拒绝  "); diff --git a/app/Admin/Controllers/LanzuServiceHorsemanController.php b/app/Admin/Controllers/LanzuServiceHorsemanController.php index 4a5e39b..0feca6f 100644 --- a/app/Admin/Controllers/LanzuServiceHorsemanController.php +++ b/app/Admin/Controllers/LanzuServiceHorsemanController.php @@ -22,10 +22,14 @@ class LanzuServiceHorsemanController extends AdminController $grid->id->sortable(); $grid->name; $grid->tel; - $grid->market_id('所属市场'); - $grid->status('状态'); - $grid->head_url; - $grid->created_at; + $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'); @@ -44,15 +48,20 @@ class LanzuServiceHorsemanController extends AdminController { return Show::make($id, new LanzuServiceHorseman(), function (Show $show) { $show->id; - $show->user_id; + $show->user_id('懒ID'); $show->name; $show->tel; - $show->market_id; - $show->status; - $show->qr_url; - $show->head_url; - $show->created_at; - $show->updated_at; + $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); + }); }); } @@ -68,9 +77,9 @@ class LanzuServiceHorsemanController extends AdminController $form->text('user_id','懒ID')->required(); $form->text('name')->required(); $form->mobile('tel')->required(); - $form->text('market_id','所属市场')->options(ImsCjdcMarket::getMarket())->required(); + $form->select('market_id','所属市场')->options(ImsCjdcMarket::getMarket())->required(); $form->radio('status','状态')->options([1=>'启用',-1=>'禁用'])->value(1)->required(); - $form->image('head_url')->uniqueName(); + $form->image('head_url')->uniqueName()->required(); $form->display('created_at'); $form->display('updated_at'); diff --git a/app/Admin/Extensions/OrderPrint.php b/app/Admin/Extensions/OrderPrint.php new file mode 100644 index 0000000..d813fd1 --- /dev/null +++ b/app/Admin/Extensions/OrderPrint.php @@ -0,0 +1,34 @@ +getKey(); + dd($id); + } + + /** + * 设置要POST到接口的数据 + * + * @return array + */ + public function parameters() + { + + } +} diff --git a/app/Admin/Extensions/OrderStateHandle.php b/app/Admin/Extensions/OrderStateHandle.php index 3615407..5e34e39 100644 --- a/app/Admin/Extensions/OrderStateHandle.php +++ b/app/Admin/Extensions/OrderStateHandle.php @@ -33,7 +33,14 @@ class OrderStateHandle extends RowAction $id = $this->getKey(); $orderMain = new ImsCjdcOrderMain(); $state = $request->get('state'); - $res = $orderMain->modifyState($id,$state); + if ($state==30){ + $res = $orderMain->updateShippingType($id,1); + }elseif ($state==100){ + + }else{ + $res = $orderMain->modifyState($id,$state); + } + if ($res==true){ return $this->response()->success('操作成功')->refresh(); }else{ diff --git a/app/Libs/feier_print/api_php_demo.php b/app/Libs/feier_print/api_php_demo.php new file mode 100644 index 0000000..916993a --- /dev/null +++ b/app/Libs/feier_print/api_php_demo.php @@ -0,0 +1,326 @@ +测试打印
'; +$content .= '名称      单价 数量 金额
'; +$content .= '--------------------------------
'; +$content .= '饭       10.0 10 100.0
'; +$content .= '炒饭      10.0 10 100.0
'; +$content .= '蛋炒饭     10.0 10 100.0
'; +$content .= '鸡蛋炒饭    10.0 10 100.0
'; +$content .= '西红柿炒饭   10.0 10 100.0
'; +$content .= '西红柿蛋炒饭  10.0 10 100.0
'; +$content .= '西红柿鸡蛋炒饭 10.0 10 100.0
'; +$content .= '--------------------------------
'; +$content .= '备注:加辣
'; +$content .= '合计:xx.0元
'; +$content .= '送货地点:广西南宁五象新区
'; +$content .= '联系电话:13888888888888
'; +$content .= '订餐时间:2014-08-08 08:08:08
'; +$content .= 'http://www.feieyun.com';//把二维码字符串用标签套上即可自动生成二维码 +//标签说明: +$content = "1";//设定打印时出纸和打印字体的方向,n 0 或 1,每次设备重启后都会初始化为 0 值设置,1:正向出纸,0:反向出纸, +$content .= "#001 五号桌 1/3可乐鸡翅张三先生 13800138000";//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 = '懒族生活
'; + $orderInfo .= '名称 单价 数量 金额
'; + $orderInfo .= '--------------------------------
'; + $shopname = ""; + $shopnum = 0; + foreach ($arr as $k5 => $v5) { + if ($shopname != $v5['shopname']) { + if ($shopname != "") { + $orderInfo .= '
'; + } + $shopnum++; + $orderInfo .= "(" . $shopnum . ")" .$v5['shopname'] . '
'; + $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.'
'; + } + 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.'
'; + } + } + $orderInfo .= $head.$tail; + if(!empty($v5['o_note'])){ + $orderInfo .= '备注:'.$v5['o_note'].'
'; + } + @$nums += $prices; + } +// $time = date('Y-m-d H:i:s', time()); + $orderInfo .= '--------------------------------
'; + 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'] . '
'; + } + 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'].'
'; + } + 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.'
'; + } + $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.'
'; + $orderInfo .= '送货地点:' . $arr[0]['address'] . '
'; + $tel = substr_replace( $arr[0]['tel'], '****', 3, 4); + $orderInfo .= '联系电话:' . $tel . '
'; + $orderInfo .= '配送时间:' . $arr[0]['ps_time'] . '
'; + if(!empty($arr[0]['note'])){ + $orderInfo .= '备注:'.$arr[0]['note'].'

'; + } + //$orderInfo .= 'http://www.feieyun.com';//把解析后的二维码生成的字符串用标签套上即可自动生成二维码 + return $orderInfo; +} + +?> diff --git a/app/Libs/feier_print/httpclient.php b/app/Libs/feier_print/httpclient.php new file mode 100644 index 0000000..4f691ef --- /dev/null +++ b/app/Libs/feier_print/httpclient.php @@ -0,0 +1,307 @@ +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 '
HttpClient Debug: '.$msg; + if ($object) { + ob_start(); + print_r($object); + $content = htmlentities(ob_get_contents()); + ob_end_clean(); + print '
'.$content.'
'; + } + print '
'; + } + } +} + +?> \ No newline at end of file diff --git a/app/Libs/feier_print/飞鹅云打印说明文档.txt b/app/Libs/feier_print/飞鹅云打印说明文档.txt new file mode 100644 index 0000000..4fecb48 --- /dev/null +++ b/app/Libs/feier_print/飞鹅云打印说明文档.txt @@ -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 = '测试打印
'; + $content .= '名称      单价 数量 金额
'; + $content .= '--------------------------------
'; + $content .= '饭       10.0 10 100.0
'; + $content .= '炒饭      10.0 10 100.0
'; + $content .= '蛋炒饭     10.0 10 100.0
'; + $content .= '鸡蛋炒饭    10.0 10 100.0
'; + $content .= '西红柿炒饭   10.0 10 100.0
'; + $content .= '西红柿蛋炒饭  10.0 10 100.0
'; + $content .= '西红柿鸡蛋炒饭 10.0 10 100.0
'; + $content .= '--------------------------------
'; + $content .= '备注:加辣
'; + $content .= '合计:xx.0元
'; + $content .= '送货地点:广西南宁五象新区
'; + $content .= '联系电话:13888888888888
'; + $content .= '订餐时间:2014-08-08 08:08:08
'; + $content .= 'http://www.feieyun.com';//把二维码字符串用标签套上即可自动生成二维码 + //标签说明: + $content = "1";//设定打印时出纸和打印字体的方向,n 0 或 1,每次设备重启后都会初始化为 0 值设置,1:正向出纸,0:反向出纸, + $content .= "#001 五号桌 1/3可乐鸡翅张三先生 13800138000";//40mm宽度标签纸打印例子,打开注释调用标签打印接口打印 + +四、查询订单状态 + + 方法名 queryOrderState($orderid) + + 参数说明 $orderid 飞鹅订单号(发起打印请求成功时,从回调的参数中获取) + 如:550510805_20200603103522_387054119 \ No newline at end of file diff --git a/app/Models/ImsCjdcMarket.php b/app/Models/ImsCjdcMarket.php index 1496a8c..ca35ebb 100644 --- a/app/Models/ImsCjdcMarket.php +++ b/app/Models/ImsCjdcMarket.php @@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Model; class ImsCjdcMarket extends Model { - use HasDateTimeFormatter; + use HasDateTimeFormatter; use SoftDeletes; protected $table = 'ims_cjdc_market'; @@ -29,6 +29,18 @@ class ImsCjdcMarket extends Model return $this->hasOne('\App\Models\LanzuMpInfo','id','mp_id'); } - + /** + * 获取市场信息 + * @return \Illuminate\Http\JsonResponse + */ + public static function getMarket() + { + $markets = self::get(); + $item = []; + foreach ($markets as $market) { + $item[$market->id] = $market->name; + } + return $item; + } } diff --git a/app/Models/ImsCjdcOrderMain.php b/app/Models/ImsCjdcOrderMain.php index 76ad925..661354b 100644 --- a/app/Models/ImsCjdcOrderMain.php +++ b/app/Models/ImsCjdcOrderMain.php @@ -55,5 +55,8 @@ class ImsCjdcOrderMain extends Model } - + public function updateShippingType($oid,$type) + { + return self::where('id',$oid)->update(['order_shipping_code'=>$type]); + } } diff --git a/app/Models/LanzuServiceHorseman.php b/app/Models/LanzuServiceHorseman.php index 74ad9f0..38017bc 100644 --- a/app/Models/LanzuServiceHorseman.php +++ b/app/Models/LanzuServiceHorseman.php @@ -12,5 +12,5 @@ class LanzuServiceHorseman extends Model use SoftDeletes; protected $table = 'lanzu_service_horseman'; - + protected $dateFormat = 'U'; } From 319b09ac4ecf4c399861c1d60832aa42db42aa63 Mon Sep 17 00:00:00 2001 From: lanzu_qsy <334039090@qq.com> Date: Thu, 3 Sep 2020 10:18:10 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=89=93=E5=8D=B0,=E9=9C=80=E8=B0=83?= =?UTF-8?q?=E7=94=A8hyperf=E6=89=93=E5=8D=B0api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Extensions/OrderPrint.php | 39 +++++++++++++++++++++++++++++ app/Models/Feprint.php | 14 +++++++++++ 2 files changed, 53 insertions(+) create mode 100644 app/Models/Feprint.php diff --git a/app/Admin/Extensions/OrderPrint.php b/app/Admin/Extensions/OrderPrint.php index d813fd1..2af1e85 100644 --- a/app/Admin/Extensions/OrderPrint.php +++ b/app/Admin/Extensions/OrderPrint.php @@ -4,6 +4,8 @@ namespace App\Admin\Extensions; +use App\Models\Feprint; +use App\Models\ImsCjdcOrderMain; use Dcat\Admin\Grid\RowAction; use Illuminate\Http\Request; @@ -19,6 +21,7 @@ class OrderPrint extends RowAction public function handle(Request $request) { $id = $this->getKey(); + $this->doPrint(); dd($id); } @@ -31,4 +34,40 @@ class OrderPrint extends RowAction { } + + 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); + } } diff --git a/app/Models/Feprint.php b/app/Models/Feprint.php new file mode 100644 index 0000000..56dd942 --- /dev/null +++ b/app/Models/Feprint.php @@ -0,0 +1,14 @@ + Date: Thu, 3 Sep 2020 14:42:52 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E8=87=AA=E9=80=81=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImsCjdcOrderMainController.php | 35 +++++++- app/Admin/Extensions/CheckRow.php | 51 +++-------- app/Admin/Extensions/OrderPrint.php | 1 - app/Admin/Extensions/OrderStateHandle.php | 16 +++- app/Libs/feier_print/api_php_demo.php | 2 +- composer.lock | 89 ++----------------- 6 files changed, 67 insertions(+), 127 deletions(-) diff --git a/app/Admin/Controllers/ImsCjdcOrderMainController.php b/app/Admin/Controllers/ImsCjdcOrderMainController.php index a40ba17..6433eed 100644 --- a/app/Admin/Controllers/ImsCjdcOrderMainController.php +++ b/app/Admin/Controllers/ImsCjdcOrderMainController.php @@ -2,9 +2,12 @@ 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; @@ -41,8 +44,34 @@ class ImsCjdcOrderMainController extends AdminController $grid->column('market.name','所属市场'); $grid->time; $grid->pay_time; - $grid->actions(function (Grid\Displayers\Actions $actions) { + + $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('打印')); @@ -83,7 +112,9 @@ class ImsCjdcOrderMainController extends AdminController - + $grid->disableViewButton(); + $grid->disableEditButton(); + $grid->disableDeleteButton(); diff --git a/app/Admin/Extensions/CheckRow.php b/app/Admin/Extensions/CheckRow.php index eb43473..1c2cf65 100644 --- a/app/Admin/Extensions/CheckRow.php +++ b/app/Admin/Extensions/CheckRow.php @@ -1,59 +1,32 @@ 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'); - $res = $orderMain->modifyState($id,$state); - if ($res==true){ - return $this->response()->success('操作成功')->refresh(); - }else{ - return $this->response()->error('操作失败'); - } - - } - /** - * 设置要POST到接口的数据 - * - * @return array - */ - public function parameters() + public function render() { - return [ - 'state' => $this->state, - ]; + // 实例化表单类并传递自定义参数 + $form = CouponTieForm::make(); + + return Modal::make() + ->lg() + ->title($this->title) + ->body($form) + ->button($this->title); } } diff --git a/app/Admin/Extensions/OrderPrint.php b/app/Admin/Extensions/OrderPrint.php index 2af1e85..0ecd573 100644 --- a/app/Admin/Extensions/OrderPrint.php +++ b/app/Admin/Extensions/OrderPrint.php @@ -65,7 +65,6 @@ class OrderPrint extends RowAction public function feiErPrint($order_num) { - include_once app_path('Libs\feier_print\api_php_demo.php'); $result = json_decode(FeiePrint($order_num)); dd($result); diff --git a/app/Admin/Extensions/OrderStateHandle.php b/app/Admin/Extensions/OrderStateHandle.php index 5e34e39..c653c23 100644 --- a/app/Admin/Extensions/OrderStateHandle.php +++ b/app/Admin/Extensions/OrderStateHandle.php @@ -2,7 +2,9 @@ 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 @@ -11,6 +13,7 @@ class OrderStateHandle extends RowAction protected $model; protected $state; protected $title; + protected $content; public function __construct($title=null,$state=null) { @@ -20,6 +23,7 @@ class OrderStateHandle extends RowAction } + /** * 处理请求 * @@ -34,7 +38,12 @@ class OrderStateHandle extends RowAction $orderMain = new ImsCjdcOrderMain(); $state = $request->get('state'); if ($state==30){ - $res = $orderMain->updateShippingType($id,1); + $content = new Content(); + $content = $this->showForm($content); + return $content; + + dd('弹出表单'); + //$res = $orderMain->updateShippingType($id,1); }elseif ($state==100){ }else{ @@ -59,4 +68,9 @@ class OrderStateHandle extends RowAction 'state' => $this->state, ]; } + + public function showForm(Content $content) + { + return $content->title('站内自送')->body("

hello world!

"); + } } diff --git a/app/Libs/feier_print/api_php_demo.php b/app/Libs/feier_print/api_php_demo.php index 916993a..4b8611c 100644 --- a/app/Libs/feier_print/api_php_demo.php +++ b/app/Libs/feier_print/api_php_demo.php @@ -150,7 +150,7 @@ function signature($time) function FeiePrint($order_num) { - $data = Db::table('ims_cjdc_order_main') + $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') diff --git a/composer.lock b/composer.lock index d8f4dbc..14a912f 100644 --- a/composer.lock +++ b/composer.lock @@ -165,16 +165,16 @@ }, { "name": "dcat/laravel-admin", - "version": "1.6.5", + "version": "1.7.1", "source": { "type": "git", "url": "https://github.com/jqhph/dcat-admin.git", - "reference": "684ea3da59a6caa8f00771781b7ff50d18759b81" + "reference": "b2694de229a9fd52f9ab048870d4e93b8ee7a505" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jqhph/dcat-admin/zipball/684ea3da59a6caa8f00771781b7ff50d18759b81", - "reference": "684ea3da59a6caa8f00771781b7ff50d18759b81", + "url": "https://api.github.com/repos/jqhph/dcat-admin/zipball/b2694de229a9fd52f9ab048870d4e93b8ee7a505", + "reference": "b2694de229a9fd52f9ab048870d4e93b8ee7a505", "shasum": "", "mirrors": [ { @@ -233,7 +233,7 @@ "laravel", "laravel admin" ], - "time": "2020-07-28T03:26:18+00:00" + "time": "2020-09-02T13:19:24+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -2131,12 +2131,6 @@ "wechat", "weibo" ], - "funding": [ - { - "url": "https://www.patreon.com/overtrue", - "type": "patreon" - } - ], "time": "2020-03-04T15:22:25+00:00" }, { @@ -2210,20 +2204,6 @@ "weixin", "weixin-sdk" ], - "funding": [ - { - "url": "https://www.easywechat.com/img/pay/wechat.jpg", - "type": "custom" - }, - { - "url": "https://github.com/overtrue", - "type": "github" - }, - { - "url": "https://www.patreon.com/overtrue", - "type": "patreon" - } - ], "time": "2020-07-29T07:36:50+00:00" }, { @@ -3203,20 +3183,6 @@ "caching", "psr6" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-07-23T17:22:30+00:00" }, { @@ -3285,20 +3251,6 @@ "interoperability", "standards" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-07-06T13:23:11+00:00" }, { @@ -4898,20 +4850,6 @@ "psr-17", "psr-7" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-06-25T08:21:47+00:00" }, { @@ -5441,20 +5379,6 @@ "instantiate", "serialize" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-06-07T15:42:22+00:00" }, { @@ -7865,6 +7789,5 @@ "platform": { "php": "^7.2.5" }, - "platform-dev": [], - "plugin-api-version": "1.1.0" + "platform-dev": [] } From 549e2322de3c10c361693e52675bb01263dbc287 Mon Sep 17 00:00:00 2001 From: lanzu_qsy <334039090@qq.com> Date: Mon, 7 Sep 2020 08:52:38 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=A1=86=E6=9E=B6=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + composer.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ff712e7..d3b01e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /node_modules /public/hot /public/storage +/public/vendors /storage/*.key /vendor .env diff --git a/composer.lock b/composer.lock index 14a912f..655bd1c 100644 --- a/composer.lock +++ b/composer.lock @@ -6826,6 +6826,7 @@ "keywords": [ "tokenizer" ], + "abandoned": true, "time": "2019-09-17T06:23:10+00:00" }, { From 1bbc14ee818f66fd4551b69ea66577bbc5120551 Mon Sep 17 00:00:00 2001 From: lanzu_qsy <334039090@qq.com> Date: Mon, 7 Sep 2020 09:56:59 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Forms/SelectHorseman.php | 47 +++++++++++++++++++++ app/Admin/Repositories/ImsCjdcOrderMain.php | 8 ++-- app/Models/ImsCjdcOrder.php | 2 +- app/Models/ImsCjdcOrderMain.php | 3 +- 4 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 app/Admin/Forms/SelectHorseman.php diff --git a/app/Admin/Forms/SelectHorseman.php b/app/Admin/Forms/SelectHorseman.php new file mode 100644 index 0000000..dfd49ee --- /dev/null +++ b/app/Admin/Forms/SelectHorseman.php @@ -0,0 +1,47 @@ +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', + ]; + } +} diff --git a/app/Admin/Repositories/ImsCjdcOrderMain.php b/app/Admin/Repositories/ImsCjdcOrderMain.php index 97349dc..1005792 100644 --- a/app/Admin/Repositories/ImsCjdcOrderMain.php +++ b/app/Admin/Repositories/ImsCjdcOrderMain.php @@ -18,11 +18,11 @@ class ImsCjdcOrderMain extends EloquentRepository public function get(Grid\Model $model) { $builder = new \App\Models\ImsCjdcOrderMain(); - $builder = $builder::leftJoin('ims_cjdc_user as u','u.id','ims_cjdc_order_main.user_id') + $builder = $builder::leftJoin('ims_cjdc_user as u','u.id','lanzu_order_main.user_id') ->with('market') - ->select('ims_cjdc_order_main.*','u.name as user_name') + ->select('lanzu_order_main.*','u.name as user_name') ->where('type',1) - ->orderBy('ims_cjdc_order_main.id','desc');//只取线上订单数据 + ->orderBy('lanzu_order_main.id','desc');//只取线上订单数据 $this->setSort($model); $this->setPaginate($model); @@ -40,7 +40,7 @@ class ImsCjdcOrderMain extends EloquentRepository $query = $query->toArray(); //如果订单状态为配送中 将state设置为31 foreach ($query['data'] as &$value){ - if ($value['state']==3&&$value['order_shipping_code']==1){ + if ($value['state']==3&&$value['shipping_type']==1){ $value['state'] = 31; } } diff --git a/app/Models/ImsCjdcOrder.php b/app/Models/ImsCjdcOrder.php index bc1a2ec..a88180f 100644 --- a/app/Models/ImsCjdcOrder.php +++ b/app/Models/ImsCjdcOrder.php @@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Model; class ImsCjdcOrder extends Model { use HasDateTimeFormatter; - protected $table = 'ims_cjdc_order as order'; + protected $table = 'lanzu_order as order'; public $timestamps = false; public function user() diff --git a/app/Models/ImsCjdcOrderMain.php b/app/Models/ImsCjdcOrderMain.php index 661354b..c54c904 100644 --- a/app/Models/ImsCjdcOrderMain.php +++ b/app/Models/ImsCjdcOrderMain.php @@ -10,7 +10,8 @@ use Illuminate\Support\Facades\DB; class ImsCjdcOrderMain extends Model { use HasDateTimeFormatter; - protected $table = 'ims_cjdc_order_main'; + //protected $table = 'ims_cjdc_order_main'; + protected $table = 'lanzu_order_main'; public $timestamps = false; public function imsCjdcUser()