<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Faka\Admin\Controller; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Routing\Controller; use ModStart\Admin\Auth\AdminPermission; use ModStart\Admin\Concern\HasAdminQuickCRUD; use ModStart\Admin\Layout\AdminCRUDBuilder; use ModStart\Core\Input\Response; use ModStart\Core\Util\CRUDUtil; use ModStart\Grid\Displayer\ItemOperate; use ModStart\Grid\GridFilter; use ModStart\Support\Concern\HasFields; use ModStart\Widget\TextAjaxRequest; use Module\Faka\Job\ProductOrderProcessorJob; use Module\Faka\Job\ProductOrderProcessorResendJob; use Module\Faka\Type\ProductDeliverType; use Module\Faka\Type\ProductOrderProcessStatus; class ProductOrderProcessorController extends Controller { use HasAdminQuickCRUD; use DispatchesJobs; protected function crud(AdminCRUDBuilder $A2Tuf) { $A2Tuf->init('faka_product_order_processor')->field(function ($A2Tuf) { $A2Tuf->id('id', '业务订单ID')->editable(true); $A2Tuf->display('created_at', '创建时间')->editable(true); $A2Tuf->display('orderId', '订单ID'); $A2Tuf->type('deliverType', '发货类型')->type(ProductDeliverType::class); $A2Tuf->type('processStatus', '处理状态')->type(ProductOrderProcessStatus::class); $A2Tuf->display('startTime', '开始时间'); $A2Tuf->display('endTime', '结束时间'); })->gridFilter(function (GridFilter $cbHm3) { $cbHm3->eq('id', '业务订单ID'); $cbHm3->eq('orderId', '订单ID'); $cbHm3->eq('deliverType', '发货类型')->select(ProductDeliverType::class); $cbHm3->eq('processStatus', '处理状态')->select(ProductOrderProcessStatus::class); })->hookItemOperateRendering(function (ItemOperate $i3KYf) { $vPOhn = $i3KYf->item(); switch ($vPOhn->processStatus) { case ProductOrderProcessStatus::WAIT_PROCESS: $i3KYf->prepend(TextAjaxRequest::primary('立即执行', action('\\' . __CLASS__ . '@process', array('id' => $vPOhn->id)))); break; case ProductOrderProcessStatus::PROCESSED: $i3KYf->prepend(TextAjaxRequest::primary('重新发送', action('\\' . __CLASS__ . '@processResend', array('id' => $vPOhn->id)))); break; } })->disableCUD()->canShow(true)->canEdit(false)->title('发卡处理'); } public function process() { goto dEkEZ; dEkEZ: AdminPermission::demoCheck(); goto UsYwd; UsYwd: ProductOrderProcessorJob::create(CRUDUtil::id()); goto tXFkS; tXFkS: return Response::redirect(CRUDUtil::jsGridRefresh()); goto bW5X8; bW5X8: } public function processResend() { goto u3BKz; u3BKz: AdminPermission::demoCheck(); goto moyrY; moyrY: ProductOrderProcessorResendJob::create(CRUDUtil::id()); goto iIPV0; iIPV0: return Response::redirect(CRUDUtil::jsGridRefresh()); goto gzbb7; gzbb7: } }