feat : chef name
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Model\OrderOptionCateringLog;
|
|||||||
use App\Model\Sku;
|
use App\Model\Sku;
|
||||||
use App\Model\Spu;
|
use App\Model\Spu;
|
||||||
use App\Service\ServiceTrait\Common\CycleTrait;
|
use App\Service\ServiceTrait\Common\CycleTrait;
|
||||||
|
use Hyperf\DbConnection\Db;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
@@ -112,10 +113,11 @@ trait CateringTrait
|
|||||||
*/
|
*/
|
||||||
private function manageSubMealCateringLog(): void
|
private function manageSubMealCateringLog(): void
|
||||||
{
|
{
|
||||||
$orderGoods = $this->orderGoodModel->where('order_id',$this->orderInfo->id)->pluck('copies','sku_id')->toArray();
|
$orderGoods = $this->orderGoodModel->where('order_id',$this->orderInfo->id)->select('sku_id',Db::raw('SUM(`quantity`) as quantity'))->groupBy('sku_id')->get();
|
||||||
|
if ($orderGoods->isEmpty()) return;
|
||||||
|
|
||||||
foreach ($orderGoods as $key => $orderGood) {
|
foreach ($orderGoods->toArray() as $orderGood) {
|
||||||
$logInfo = $this->orderMealCateringLogModel->getInfoBySiteIdAndCycleIdAndSkuId($this->orderInfo->site_id,$this->orderInfo->cycle_id,(int)$key);
|
$logInfo = $this->orderMealCateringLogModel->getInfoBySiteIdAndCycleIdAndSkuId($this->orderInfo->site_id,$this->orderInfo->cycle_id,(int)$orderGood['sku_id']);
|
||||||
|
|
||||||
if (empty($logInfo)) {
|
if (empty($logInfo)) {
|
||||||
$this->log->error(__CLASS__.':Function:refundCallBackHandle:manageSubMealCateringLog:订单套餐配餐记录不存在,订单信息:'.json_encode($this->orderInfo->toArray()).':订单商品信息:'.json_encode($orderGoods));
|
$this->log->error(__CLASS__.':Function:refundCallBackHandle:manageSubMealCateringLog:订单套餐配餐记录不存在,订单信息:'.json_encode($this->orderInfo->toArray()).':订单商品信息:'.json_encode($orderGoods));
|
||||||
@@ -127,7 +129,7 @@ trait CateringTrait
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$logInfo->quantity = $logInfo->quantity - $orderGood;
|
$logInfo->quantity = $logInfo->quantity - $orderGood['quantity'];
|
||||||
|
|
||||||
if (!$logInfo->save()) {
|
if (!$logInfo->save()) {
|
||||||
$this->log->error(__CLASS__.':Function:refundCallBackHandle:manageSubMealCateringLog:修改配餐记录失败,订单信息:'.json_encode($this->orderInfo->toArray()).':订单商品信息:'.json_encode($orderGoods));
|
$this->log->error(__CLASS__.':Function:refundCallBackHandle:manageSubMealCateringLog:修改配餐记录失败,订单信息:'.json_encode($this->orderInfo->toArray()).':订单商品信息:'.json_encode($orderGoods));
|
||||||
@@ -191,24 +193,25 @@ trait CateringTrait
|
|||||||
*/
|
*/
|
||||||
private function manageAddMealCateringLog(): bool
|
private function manageAddMealCateringLog(): bool
|
||||||
{
|
{
|
||||||
$orderGoods = $this->orderGoodModel->where('order_id',$this->orderInfo->id)->pluck('copies','sku_id')->toArray();
|
$orderGoods = $this->orderGoodModel->where('order_id',$this->orderInfo->id)->select('sku_id',Db::raw('SUM(`quantity`) as quantity'))->groupBy('sku_id')->get();
|
||||||
|
if ($orderGoods->isEmpty()) return false;
|
||||||
|
|
||||||
foreach ($orderGoods as $key => $orderGood) {
|
foreach ($orderGoods->toArray() as $orderGood) {
|
||||||
$logInfo = $this->orderMealCateringLogModel->getInfoBySiteIdAndCycleIdAndSkuId($this->orderInfo->site_id,$this->orderInfo->cycle_id,(int)$key);
|
$logInfo = $this->orderMealCateringLogModel->getInfoBySiteIdAndCycleIdAndSkuId($this->orderInfo->site_id,$this->orderInfo->cycle_id,(int)$orderGood['sku_id']);
|
||||||
|
|
||||||
if (empty($logInfo)) {
|
if (empty($logInfo)) {
|
||||||
$logInfo = new OrderMealCateringLog();
|
$logInfo = new OrderMealCateringLog();
|
||||||
|
|
||||||
$logInfo->site_id = $this->orderInfo->site_id;
|
$logInfo->site_id = $this->orderInfo->site_id;
|
||||||
$logInfo->cycle_id = $this->orderInfo->cycle_id;
|
$logInfo->cycle_id = $this->orderInfo->cycle_id;
|
||||||
$logInfo->sku_id = (int)$key;
|
$logInfo->sku_id = (int)$orderGood['sku_id'];
|
||||||
$logInfo->quantity = 0;
|
$logInfo->quantity = 0;
|
||||||
$logInfo->status = CateringCode::CATERING_STATUS_UNDERWAY;
|
$logInfo->status = CateringCode::CATERING_STATUS_UNDERWAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($logInfo->status == CateringCode::CATERING_STATUS_FINISH) return false;
|
if ($logInfo->status == CateringCode::CATERING_STATUS_FINISH) return false;
|
||||||
|
|
||||||
$logInfo->quantity = $logInfo->quantity + $orderGood;
|
$logInfo->quantity = $logInfo->quantity + $orderGood['quantity'];
|
||||||
|
|
||||||
if (!$logInfo->save()) return false;
|
if (!$logInfo->save()) return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user