feat : spu
This commit is contained in:
@@ -7,6 +7,8 @@ use App\Constants\Admin\CateringCode;
|
||||
use App\Constants\Common\OrderCode;
|
||||
use App\Model\OrderMealCateringLog;
|
||||
use App\Model\OrderOptionCateringLog;
|
||||
use App\Model\Sku;
|
||||
use App\Model\Spu;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
@@ -65,8 +67,15 @@ trait CateringTrait
|
||||
*/
|
||||
private function manageSubOptionCateringLog(): void
|
||||
{
|
||||
// todo 减少可以不减少根据订单 cycle_id 获取加一碗米饭 的数量 减少查询压力
|
||||
// $addStapleFoodNum = 0;
|
||||
$extraStapleArr = $this->spuModel->getCycleIdAddStapleFoodSkuIds($this->orderInfo->cycle_id);
|
||||
$orderGoods = $this->orderGoodModel->where('order_id',$this->orderInfo->id)->pluck('copies','sku_id')->toArray();
|
||||
|
||||
$addStapleFoodNum = 0;
|
||||
foreach ($orderGoods as $key => $copies) {
|
||||
if (!in_array($key, $extraStapleArr)) continue;
|
||||
|
||||
$addStapleFoodNum = $copies + $addStapleFoodNum;
|
||||
}
|
||||
|
||||
$siteInfo = $this->siteCache->getSiteInfo($this->orderInfo->site_id);
|
||||
|
||||
@@ -83,8 +92,8 @@ trait CateringTrait
|
||||
return;
|
||||
}
|
||||
|
||||
$logInfo->quantity = $logInfo->quantity + $this->orderInfo->copies;
|
||||
// $logInfo->add_staple_food_num = $this->orderInfo->add_staple_food_num - $addStapleFoodNum;
|
||||
$logInfo->quantity = $logInfo->quantity - $this->orderInfo->copies;
|
||||
$logInfo->add_staple_food_num = $this->orderInfo->add_staple_food_num - $addStapleFoodNum;
|
||||
|
||||
if (!$logInfo->save()) {
|
||||
$this->log->error(__CLASS__.':Function:refundCallBackHandle:manageSubOptionCateringLog:修改配餐记录失败,订单信息:'.json_encode($this->orderInfo->toArray()));
|
||||
@@ -121,6 +130,12 @@ trait CateringTrait
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Spu
|
||||
*/
|
||||
#[Inject]
|
||||
protected Spu $spuModel;
|
||||
|
||||
/**
|
||||
* 添加自选配餐数据
|
||||
* @return bool
|
||||
@@ -129,8 +144,16 @@ trait CateringTrait
|
||||
*/
|
||||
private function manageAddOptionCateringLog(): bool
|
||||
{
|
||||
//todo 根据订单 cycle_id 获取加一碗米饭 的数量
|
||||
//根据订单 cycle_id 获取加一碗米饭 的数量
|
||||
$extraStapleArr = $this->spuModel->getCycleIdAddStapleFoodSkuIds($this->orderInfo->cycle_id);
|
||||
$orderGoods = $this->orderGoodModel->where('order_id',$this->orderInfo->id)->pluck('copies','sku_id')->toArray();
|
||||
|
||||
$addStapleFoodNum = 0;
|
||||
foreach ($orderGoods as $key => $copies) {
|
||||
if (!in_array($key, $extraStapleArr)) continue;
|
||||
|
||||
$addStapleFoodNum = $copies + $addStapleFoodNum;
|
||||
}
|
||||
|
||||
$siteInfo = $this->siteCache->getSiteInfo($this->orderInfo->site_id);
|
||||
//需要绑定一个 kitchen_id
|
||||
|
||||
Reference in New Issue
Block a user