feat : phone pool
This commit is contained in:
@@ -19,6 +19,8 @@ use App\Model\OrderMealCateringLog;
|
||||
use App\Model\Site;
|
||||
use App\Service\Admin\Catering\CateringBaseService;
|
||||
use App\Service\ServiceTrait\Admin\Catering\PrintTrait;
|
||||
use Exception;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
@@ -84,16 +86,24 @@ class CateringService extends CateringBaseService
|
||||
// 生成 key
|
||||
$this->__initMealRedisKey();
|
||||
|
||||
// 配餐
|
||||
$this->catering();
|
||||
try {
|
||||
Db::beginTransaction();
|
||||
|
||||
// 配餐
|
||||
$this->catering();
|
||||
|
||||
// 查询该点所有套餐是否已经配餐 如果是就缓存关闭该点
|
||||
$this->isCloseMealSite();
|
||||
|
||||
Db::commit();
|
||||
}catch (Exception|ErrException $e) {
|
||||
Db::rollBack();
|
||||
throw new ErrException($e->getMessage());
|
||||
}
|
||||
// 加缓存
|
||||
$this->joinMealCateringCache();
|
||||
|
||||
// 查询该点所有套餐是否已经配餐 如果是就缓存关闭该点
|
||||
$this->isCloseMealSite();
|
||||
|
||||
// 关闭线路
|
||||
// 关闭线路缓存
|
||||
if ($this->closeSiteFlag == 1) $this->closeMealWholeLine();
|
||||
|
||||
return $this->return->success('success',['num' => $this->resCount]);
|
||||
@@ -116,6 +126,18 @@ class CateringService extends CateringBaseService
|
||||
|
||||
$this->closeMealSite();
|
||||
|
||||
$orderIds = $this->orderModel
|
||||
->where('site_id', $this->siteInfo->id)
|
||||
->where('cycle_id', $this->logInfo->cycle_id)
|
||||
->where('type',OrderCode::ORDER_TYPE_MEAL)
|
||||
->pluck('order_id')
|
||||
->toArray();
|
||||
if (empty($orderIds)) throw new ErrException('配餐失败,更新逻辑失败');
|
||||
|
||||
foreach (array_chunk($orderIds, 100) as $chunk) {
|
||||
if (!$this->orderModel->isCateringByOrderIds($chunk) || !$this->orderGoodModel->isCateringByOrderIds($chunk)) throw new ErrException('修改订单数据状态失败');
|
||||
}
|
||||
|
||||
$this->closeSiteFlag = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,29 +68,29 @@ class CheckService extends CateringBaseService
|
||||
|
||||
if (!empty($this->logInfo)) $this->tips();
|
||||
|
||||
$todayLog = $this->orderMealCateringLog
|
||||
->where('cycle_id',$this->cycleId)
|
||||
->where('status',CateringCode::CATERING_STATUS_UNDERWAY)
|
||||
->where('quantity','>',0)
|
||||
->first();
|
||||
// $todayLog = $this->orderMealCateringLog
|
||||
// ->where('cycle_id',$this->cycleId)
|
||||
// ->where('status',CateringCode::CATERING_STATUS_UNDERWAY)
|
||||
// ->where('quantity','>',0)
|
||||
// ->first();
|
||||
//
|
||||
// if (!empty($todayLog)) return $this->closeSku();
|
||||
|
||||
if (!empty($todayLog)) return $this->closeSku();
|
||||
|
||||
$orderIds = $this->orderModel
|
||||
->where('cycle_id', $this->cycleId)
|
||||
->where('type',OrderCode::ORDER_TYPE_MEAL)
|
||||
->where('status',OrderCode::PAYED)
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
|
||||
if (empty($orderIds)) throw new ErrException('数据错误');
|
||||
// $orderIds = $this->orderModel
|
||||
// ->where('cycle_id', $this->cycleId)
|
||||
// ->where('type',OrderCode::ORDER_TYPE_MEAL)
|
||||
// ->where('status',OrderCode::PAYED)
|
||||
// ->pluck('id')
|
||||
// ->toArray();
|
||||
//
|
||||
// if (empty($orderIds)) throw new ErrException('数据错误');
|
||||
|
||||
// $this->orderModel->whereIn('id', $orderIds)->update(['status' => OrderCode::PLAN]);
|
||||
Db::transaction(function () use ($orderIds) {
|
||||
foreach (array_chunk($orderIds, 100) as $chunk) {
|
||||
if (!$this->orderModel->isCateringByOrderIds($chunk) || !$this->orderGoodModel->isCateringByOrderIds($chunk)) throw new Exception('修改订单数据状态失败');
|
||||
}
|
||||
});
|
||||
// Db::transaction(function () use ($orderIds) {
|
||||
// foreach (array_chunk($orderIds, 100) as $chunk) {
|
||||
// if (!$this->orderModel->isCateringByOrderIds($chunk) || !$this->orderGoodModel->isCateringByOrderIds($chunk)) throw new Exception('修改订单数据状态失败');
|
||||
// }
|
||||
// });
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -113,9 +113,9 @@ class CheckService extends CateringBaseService
|
||||
private function tips(): void
|
||||
{
|
||||
$siteInfo = $this->siteModel->find($this->logInfo->site_id);
|
||||
if (empty($siteInfo)) throw new ErrException('数据错误');
|
||||
if (empty($siteInfo)) throw new ErrException('数据错误-地点无数据,site:'.$this->logInfo->site_id);
|
||||
$driverInfo = $this->driverSequenceModel->find($siteInfo->delivered_id);
|
||||
if (empty($driverInfo)) throw new ErrException('数据错误');
|
||||
if (empty($driverInfo)) throw new ErrException('数据错误-司机无数据,driver:'.$siteInfo->delivered_id);
|
||||
|
||||
throw new ErrException($driverInfo->driver_num.'-'.$siteInfo->sequence.'还未配餐完成,请刷新页面并完成配餐再执行');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user