feat : catering
This commit is contained in:
@@ -10,16 +10,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Catering\Meal;
|
||||
|
||||
use App\Constants\Admin\CateringCode;
|
||||
use App\Constants\Common\OrderCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderMealCateringLog;
|
||||
use App\Service\Admin\Catering\CateringBaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
class CheckService extends CateringBaseService
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
//todo Write logic
|
||||
}
|
||||
|
||||
/**
|
||||
* @var OrderMealCateringLog
|
||||
@@ -32,10 +32,51 @@ class CheckService extends CateringBaseService
|
||||
*/
|
||||
protected OrderMealCateringLog $logInfo;
|
||||
|
||||
public function info()
|
||||
/**
|
||||
* @var Order
|
||||
*/
|
||||
#[Inject]
|
||||
protected Order $orderModel;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
$this->logInfo = $this->orderMealCateringLog->find($this->request->input('id'));
|
||||
$this->logInfo = $this->orderMealCateringLog
|
||||
->where('sku_id', $this->request->input('sku_id'))
|
||||
->where('cycle_id',$this->cycleId)
|
||||
->where('status',CateringCode::CATERING_STATUS_UNDERWAY)
|
||||
->where('quantity','>',0)
|
||||
->first();
|
||||
|
||||
if (!empty($this->logInfo)) $this->tips();
|
||||
|
||||
$orderIds = $this->orderModel
|
||||
->where('cycle_id', $this->cycleId)
|
||||
->where('type',OrderCode::ORDER_TYPE_MEAL)
|
||||
->where('status',OrderCode::PAYED)
|
||||
->pluck('order_id')
|
||||
->toArray();
|
||||
|
||||
if (empty($orderIds)) throw new ErrException('数据错误');
|
||||
|
||||
$this->orderModel->whereIn('id', $orderIds)->update(['status' => OrderCode::PLAN]);
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function tips(): void
|
||||
{
|
||||
$siteInfo = $this->siteModel->find($this->logInfo->site_id);
|
||||
if (empty($siteInfo)) throw new ErrException('数据错误');
|
||||
$driverInfo = $this->driverSequenceModel->find($siteInfo->delivered_id);
|
||||
if (empty($driverInfo)) throw new ErrException('数据错误');
|
||||
|
||||
throw new ErrException($driverInfo->driver_num.'-'.$siteInfo->sequence.'还未配餐完成,请刷新页面并完成配餐再执行');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user