<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Res\Admin\Controller; use Illuminate\Routing\Controller; use ModStart\Admin\Concern\HasAdminQuickCRUD; use ModStart\Admin\Layout\AdminCRUDBuilder; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Exception\BizException; use ModStart\Field\AbstractField; use ModStart\Field\AutoRenderedFieldValue; use ModStart\Form\Form; use ModStart\Grid\Displayer\ItemOperate; use ModStart\Grid\GridFilter; use ModStart\Repository\RepositoryUtil; use ModStart\Support\Concern\HasFields; use ModStart\Widget\TextLink; use Module\Member\Util\MemberFieldUtil; use Module\PayCenter\Util\PayOrderUtil; use Module\Res\Core\ResPayCenterBiz; use Module\Res\Util\UrlUtil; use Module\Vendor\Type\OrderStatus; class ResAssetBuyOrderController extends Controller { use HasAdminQuickCRUD; protected function crud(AdminCRUDBuilder $lZifj) { MemberFieldUtil::register(); $lZifj->init('res_asset_buy_order')->field(function ($lZifj) { $lZifj->id('id', '业务订单ID')->editable(false); $lZifj->display('created_at', '创建时间')->editable(true); $lZifj->display('sn', '订单号')->editable(true); $lZifj->adminMemberInfo('memberUserId', '用户'); $lZifj->type('status', '状态')->type(OrderStatus::class)->editable(false); $lZifj->display('docId', '文档')->hookRendering(function (AbstractField $pZ_lR, $jIWZA, $aaYHa) { $zk4Tz = ModelUtil::get('wenku_doc', $jIWZA->docId); return AutoRenderedFieldValue::make(TextLink::primary(htmlspecialchars($zk4Tz['title']), UrlUtil::show($zk4Tz), 'target="_blank"')); }); $lZifj->currency('payFee', '支付金额')->editable(true); })->hookItemOperateRendering(function (ItemOperate $zCZzC) { $jIWZA = $zCZzC->item(); })->gridFilter(function (GridFilter $bu01d) { $bu01d->eq('id', '业务订单ID'); $bu01d->eq('memberUserId', '用户ID'); $bu01d->eq('status', '状态')->select(OrderStatus::simple()); })->dialogSizeSmall()->hookChanged(function (Form $yZTO2) { RepositoryUtil::makeItems($yZTO2->item())->map(function ($jIWZA) { if ($jIWZA->status == OrderStatus::WAIT_PAY) { goto M6wzz; uNFDn: PayOrderUtil::updateFee(ResPayCenterBiz::NAME, $jIWZA->id, $ahibX); goto aTJp3; M6wzz: $ahibX = floatval($jIWZA->payFee); goto oq1mR; oq1mR: if ($ahibX >= 0 && $ahibX <= 0) { $Tbn6c = PayOrderUtil::autoPay(ResPayCenterBiz::NAME, $jIWZA->id, 0); BizException::throwsIfResponseError($Tbn6c); } goto uNFDn; aTJp3: } }); })->disableCUD()->canShow(false)->canEdit(true)->title('资源订单'); } }