feat : catering
This commit is contained in:
@@ -45,4 +45,19 @@ class CateringController
|
||||
{
|
||||
return (new OptionCycleListService)->remainCount();
|
||||
}
|
||||
|
||||
public function getMealGoodsList()
|
||||
{
|
||||
return (new MealCycleListService)->skuList();
|
||||
}
|
||||
|
||||
public function mealCatering()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function optionCatering()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use Hyperf\DbConnection\Model\Model;
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $cycle_id
|
||||
* @property int $kitchen_id
|
||||
* @property int $site_id
|
||||
* @property int $quantity
|
||||
* @property int $add_staple_food_num
|
||||
@@ -32,15 +33,16 @@ class OrderOptionCateringLog extends Model
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['id' => 'integer', 'cycle_id' => 'integer', 'site_id' => 'integer', 'quantity' => 'integer', 'add_staple_food_num' => 'integer', 'status' => 'integer'];
|
||||
protected array $casts = ['id' => 'integer', 'cycle_id' => 'integer', 'kitchen_id' => 'integer', 'site_id' => 'integer', 'quantity' => 'integer', 'add_staple_food_num' => 'integer', 'status' => 'integer'];
|
||||
|
||||
/**
|
||||
* @param int $siteId
|
||||
* @param int $cycleId
|
||||
* @param int $kitchenId
|
||||
* @return Builder|\Hyperf\Database\Model\Model|null
|
||||
*/
|
||||
public function getInfoBySiteIdAndCycleId(int $siteId, int $cycleId): \Hyperf\Database\Model\Model|Builder|null
|
||||
public function getInfoBySiteIdAndCycleIdAndSiteId(int $siteId, int $cycleId, int $kitchenId): \Hyperf\Database\Model\Model|Builder|null
|
||||
{
|
||||
return $this->where('site_id', $siteId)->where('cycle_id', $cycleId)->first();
|
||||
return $this->where('site_id', $siteId)->where('cycle_id', $cycleId)->where('kitchen_id',$kitchenId)->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ abstract class CateringBaseService extends BaseService
|
||||
$this->checkRole();
|
||||
|
||||
$this->getCycleId();
|
||||
|
||||
$this->getKitchenId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,6 +98,12 @@ abstract class CateringBaseService extends BaseService
|
||||
$this->cycleId = (int)$cycleId;
|
||||
}
|
||||
|
||||
private function getKitchenId(): void
|
||||
{
|
||||
//todo 自选配餐员工要绑定厨房 套餐配餐员工要绑定每日套餐
|
||||
$this->kitchenId = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return array
|
||||
|
||||
@@ -69,4 +69,21 @@ class CycleListService extends CateringBaseService
|
||||
|
||||
return $this->return->success('success',['count' => $count]);
|
||||
}
|
||||
|
||||
public function skuList()
|
||||
{
|
||||
$res = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'spu_name'
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'spu2_name'
|
||||
]
|
||||
];
|
||||
|
||||
return $this->return->success('success',$res);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ class CycleListService extends CateringBaseService
|
||||
{
|
||||
$cycleCateringLogs = $this->orderOptionCateringLogModel
|
||||
->where('cycle_id',$this->cycleId)
|
||||
->where('kitchen_id',$this->kitchenId)
|
||||
->select(['site_id','quantity','status','id'])
|
||||
->get();
|
||||
|
||||
@@ -51,6 +52,7 @@ class CycleListService extends CateringBaseService
|
||||
{
|
||||
$count = $this->orderOptionCateringLogModel
|
||||
->where('cycle_id',$this->cycleId)
|
||||
->where('kitchen_id',$this->kitchenId)
|
||||
->sum('quantity') ?? 0;
|
||||
|
||||
return $this->return->success('success',['count' => $count]);
|
||||
|
||||
@@ -25,7 +25,7 @@ trait CouponDispenseTrait
|
||||
|
||||
$this->cycleId = $cycleInfo->id;
|
||||
|
||||
$appointValue = json_encode($this->request->input('appoint_value'));
|
||||
$appointValue = $this->request->input('appoint_value');
|
||||
// if ($this->groupType == CouponCode::DISPENSE_APPOINT_GROUP_DESIGNATED_SITES_AND_GOODS) {
|
||||
// $this->appointValue = [
|
||||
// 'site' => explode(',', $appointValue['site']),
|
||||
@@ -152,7 +152,7 @@ trait CouponDispenseTrait
|
||||
{
|
||||
$this->checkAppointValue();
|
||||
|
||||
$appointValue = json_encode($this->request->input('appoint_value'));
|
||||
$appointValue = $this->request->input('appoint_value');
|
||||
|
||||
return explode(',', $appointValue['user_ids']);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Service\ServiceTrait;
|
||||
|
||||
use App\Cache\Redis\Api\SiteCache;
|
||||
use App\Constants\Common\OrderCode;
|
||||
use App\Model\OrderMealCateringLog;
|
||||
use App\Model\OrderOptionCateringLog;
|
||||
@@ -23,8 +24,16 @@ trait CateringTrait
|
||||
#[Inject]
|
||||
protected OrderMealCateringLog $orderMealCateringLogModel;
|
||||
|
||||
/**
|
||||
* @var SiteCache
|
||||
*/
|
||||
#[Inject]
|
||||
protected SiteCache $siteCache;
|
||||
|
||||
/**
|
||||
* @return bool 添加失败需要退款
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function manageAddCateringLog(): bool
|
||||
{
|
||||
@@ -46,8 +55,6 @@ trait CateringTrait
|
||||
OrderCode::ORDER_TYPE_MEAL => $this->manageSubMealCateringLog(),
|
||||
OrderCode::ORDER_TYPE_OPTIONAL => $this->manageSubOptionCateringLog(),
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,8 +67,10 @@ trait CateringTrait
|
||||
// todo 减少可以不减少根据订单 cycle_id 获取加一碗米饭 的数量 减少查询压力
|
||||
// $addStapleFoodNum = 0;
|
||||
|
||||
//todo 需要绑定一个 kitchen_id
|
||||
$logInfo = $this->orderOptionCateringLogModel->getInfoBySiteIdAndCycleId($this->orderInfo->site_id, $this->orderInfo->cycle_id);
|
||||
$siteInfo = $this->siteCache->getSiteInfo($this->orderInfo->site_id);
|
||||
|
||||
//需要绑定一个 kitchen_id
|
||||
$logInfo = $this->orderOptionCateringLogModel->getInfoBySiteIdAndCycleIdAndSiteId($this->orderInfo->site_id, $this->orderInfo->cycle_id, (int)$siteInfo['kitchen_id']);
|
||||
|
||||
if (empty($logInfo)) {
|
||||
$this->log->error(__CLASS__.':Function:refundCallBackHandle:manageSubOptionCateringLog:订单套餐配餐记录不存在,订单信息:'.json_encode($this->orderInfo->toArray()));
|
||||
@@ -114,20 +123,24 @@ trait CateringTrait
|
||||
/**
|
||||
* 添加自选配餐数据
|
||||
* @return bool
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function manageAddOptionCateringLog(): bool
|
||||
{
|
||||
//todo 根据订单 cycle_id 获取加一碗米饭 的数量
|
||||
$addStapleFoodNum = 0;
|
||||
|
||||
//todo 需要绑定一个 kitchen_id
|
||||
$logInfo = $this->orderOptionCateringLogModel->getInfoBySiteIdAndCycleId($this->orderInfo->site_id, $this->orderInfo->cycle_id);
|
||||
$siteInfo = $this->siteCache->getSiteInfo($this->orderInfo->site_id);
|
||||
//需要绑定一个 kitchen_id
|
||||
$logInfo = $this->orderOptionCateringLogModel->getInfoBySiteIdAndCycleIdAndSiteId($this->orderInfo->site_id, $this->orderInfo->cycle_id,(int)$siteInfo['kitchen_id']);
|
||||
|
||||
if (empty($logInfo)) {
|
||||
$logInfo = new OrderOptionCateringLog();
|
||||
|
||||
$logInfo->site_id = $this->orderInfo->site_id;
|
||||
$logInfo->cycle_id = $this->orderInfo->cycle_id;
|
||||
$logInfo->kitchen_id = (int)$siteInfo['kitchen_id'];
|
||||
$logInfo->quantity = 0;
|
||||
$logInfo->add_staple_food_num = 0;
|
||||
$logInfo->status = 1;
|
||||
|
||||
Reference in New Issue
Block a user