feat : rank
This commit is contained in:
@@ -24,6 +24,7 @@ use App\Model\User;
|
|||||||
use App\Service\Admin\Catering\CateringBaseService;
|
use App\Service\Admin\Catering\CateringBaseService;
|
||||||
use App\Service\Admin\Catering\Print\PrintOrderFactory;
|
use App\Service\Admin\Catering\Print\PrintOrderFactory;
|
||||||
use App\Service\ServiceTrait\Admin\Catering\PrintTrait;
|
use App\Service\ServiceTrait\Admin\Catering\PrintTrait;
|
||||||
|
use App\Service\ServiceTrait\Common\PickupCodeTrait;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Hyperf\DbConnection\Db;
|
use Hyperf\DbConnection\Db;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
@@ -33,6 +34,7 @@ use Psr\Container\NotFoundExceptionInterface;
|
|||||||
class CateringService extends CateringBaseService
|
class CateringService extends CateringBaseService
|
||||||
{
|
{
|
||||||
use PrintTrait;
|
use PrintTrait;
|
||||||
|
use PickupCodeTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var OrderOptionCateringLog
|
* @var OrderOptionCateringLog
|
||||||
@@ -418,35 +420,35 @@ class CateringService extends CateringBaseService
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* @param array $data
|
// * @param array $data
|
||||||
* @return array
|
// * @return array
|
||||||
*/
|
// */
|
||||||
private function buildPickupCodeListData(array $data): array
|
// private function buildPickupCodeListData(array $data): array
|
||||||
{
|
// {
|
||||||
$result = [];
|
// $result = [];
|
||||||
foreach ($data as $item) {
|
// foreach ($data as $item) {
|
||||||
// 提取关键字段
|
// // 提取关键字段
|
||||||
$orderId = $item["order_id"];
|
// $orderId = $item["order_id"];
|
||||||
$copies = $item["copies"];
|
// $copies = $item["copies"];
|
||||||
$pickupCode = $item["pickup_code"];
|
// $pickupCode = $item["pickup_code"];
|
||||||
$heapsort = $item["heapsort"];
|
// $heapsort = $item["heapsort"];
|
||||||
|
//
|
||||||
// 按层级构建数组结构
|
// // 按层级构建数组结构
|
||||||
if (!isset($result[$orderId])) {
|
// if (!isset($result[$orderId])) {
|
||||||
$result[$orderId] = [];
|
// $result[$orderId] = [];
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (!isset($result[$orderId][$copies])) {
|
// if (!isset($result[$orderId][$copies])) {
|
||||||
$result[$orderId][$copies] = [
|
// $result[$orderId][$copies] = [
|
||||||
'pickup_code' => $pickupCode,
|
// 'pickup_code' => $pickupCode,
|
||||||
'heapsort' => $heapsort,
|
// 'heapsort' => $heapsort,
|
||||||
];
|
// ];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return $result;
|
// return $result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打印置灰和截单
|
* 打印置灰和截单
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ use App\Model\AdminUser;
|
|||||||
use App\Model\Chef;
|
use App\Model\Chef;
|
||||||
use App\Model\Order;
|
use App\Model\Order;
|
||||||
use App\Model\OrderGood;
|
use App\Model\OrderGood;
|
||||||
|
use App\Model\PickupCode;
|
||||||
use App\Model\Sku;
|
use App\Model\Sku;
|
||||||
use App\Model\Spu;
|
use App\Model\Spu;
|
||||||
use App\Service\Api\BaseService;
|
use App\Service\Api\BaseService;
|
||||||
use App\Service\ServiceTrait\Common\OssTrait;
|
use App\Service\ServiceTrait\Common\OssTrait;
|
||||||
|
use App\Service\ServiceTrait\Common\PickupCodeTrait;
|
||||||
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;
|
||||||
@@ -29,6 +31,7 @@ use Psr\Container\NotFoundExceptionInterface;
|
|||||||
class OrderInfoService extends BaseService
|
class OrderInfoService extends BaseService
|
||||||
{
|
{
|
||||||
use OssTrait;
|
use OssTrait;
|
||||||
|
use PickupCodeTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Order
|
* @var Order
|
||||||
@@ -85,6 +88,13 @@ class OrderInfoService extends BaseService
|
|||||||
return $this->return->success('success', $orderInfo);
|
return $this->return->success('success', $orderInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PickupCode
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected PickupCode $pickupCodeModel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $orderInfo
|
* @param array $orderInfo
|
||||||
* @return void
|
* @return void
|
||||||
@@ -118,6 +128,11 @@ class OrderInfoService extends BaseService
|
|||||||
$chefList = $this->adminUserModel->getDataArrByIds($chefId);
|
$chefList = $this->adminUserModel->getDataArrByIds($chefId);
|
||||||
$chefList = array_column($chefList, null,'id');
|
$chefList = array_column($chefList, null,'id');
|
||||||
|
|
||||||
|
$pickupCodeList = $this->pickupCodeModel
|
||||||
|
->where('order_id',$orderInfo['id'])
|
||||||
|
->pluck('pickup_code','copies')
|
||||||
|
->toArray();
|
||||||
|
|
||||||
$orderCopiesList = [];
|
$orderCopiesList = [];
|
||||||
$addStapleFood = [];
|
$addStapleFood = [];
|
||||||
if ($orderInfo['type'] == OrderCode::ORDER_TYPE_MEAL) {
|
if ($orderInfo['type'] == OrderCode::ORDER_TYPE_MEAL) {
|
||||||
@@ -125,7 +140,7 @@ class OrderInfoService extends BaseService
|
|||||||
'total_price' => '0.00',
|
'total_price' => '0.00',
|
||||||
'total_quantity' => 0,
|
'total_quantity' => 0,
|
||||||
'sku_list' => [],
|
'sku_list' => [],
|
||||||
'take_food_code' => '', //取餐码
|
'pickup_code' => '', //取餐码
|
||||||
'url' => '',
|
'url' => '',
|
||||||
'is_add_staple_food' => GoodCode::IS_ADD_STAPLE_FOOD,
|
'is_add_staple_food' => GoodCode::IS_ADD_STAPLE_FOOD,
|
||||||
];
|
];
|
||||||
@@ -136,7 +151,7 @@ class OrderInfoService extends BaseService
|
|||||||
'total_price' => '0.00',
|
'total_price' => '0.00',
|
||||||
'total_quantity' => 0,
|
'total_quantity' => 0,
|
||||||
'sku_list' => [],
|
'sku_list' => [],
|
||||||
'take_food_code' => '', //todo 取餐码
|
'pickup_code' => $pickupCodeList[$i] ?? '', //取餐码
|
||||||
'is_add_staple_food' => GoodCode::IS_NOT_ADD_STAPLE_FOOD,
|
'is_add_staple_food' => GoodCode::IS_NOT_ADD_STAPLE_FOOD,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ use App\Constants\Common\GoodCode;
|
|||||||
use App\Constants\Common\OrderCode;
|
use App\Constants\Common\OrderCode;
|
||||||
use App\Model\Order;
|
use App\Model\Order;
|
||||||
use App\Model\OrderGood;
|
use App\Model\OrderGood;
|
||||||
|
use App\Model\PickupCode;
|
||||||
use App\Model\Sku;
|
use App\Model\Sku;
|
||||||
use App\Service\Api\BaseService;
|
use App\Service\Api\BaseService;
|
||||||
use App\Service\ServiceTrait\Common\OssTrait;
|
use App\Service\ServiceTrait\Common\OssTrait;
|
||||||
|
use App\Service\ServiceTrait\Common\PickupCodeTrait;
|
||||||
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;
|
||||||
@@ -26,13 +28,14 @@ class OrderListService extends BaseService
|
|||||||
{
|
{
|
||||||
|
|
||||||
use OssTrait;
|
use OssTrait;
|
||||||
|
use PickupCodeTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int 当前订单/历史订单
|
* @var int 当前订单/历史订单
|
||||||
*/
|
*/
|
||||||
CONST CURRENT_ORDER = 1;
|
CONST int CURRENT_ORDER = 1;
|
||||||
|
|
||||||
CONST HISTORY_ORDER = 2;
|
CONST int HISTORY_ORDER = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Order
|
* @var Order
|
||||||
@@ -102,6 +105,13 @@ class OrderListService extends BaseService
|
|||||||
return $this->return->success('success', ['list' => $orderList]);
|
return $this->return->success('success', ['list' => $orderList]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PickupCode
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected PickupCode $pickupCodeModel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建订单列表数据
|
* 构建订单列表数据
|
||||||
* @param array $orderList
|
* @param array $orderList
|
||||||
@@ -139,6 +149,13 @@ class OrderListService extends BaseService
|
|||||||
$imageIds = array_unique(explode(',',implode(',',$imageIdArr)));
|
$imageIds = array_unique(explode(',',implode(',',$imageIdArr)));
|
||||||
$imageList = $this->getOssObjects($imageIds);
|
$imageList = $this->getOssObjects($imageIds);
|
||||||
|
|
||||||
|
$pickupCodeList = $this->pickupCodeModel
|
||||||
|
->whereIn('order_id',$orderIds)
|
||||||
|
->get(['pickup_code', 'order_id', 'copies', 'heapsort', 'id'])
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$pickupCodeArrList = $this->buildPickupCodeListData($pickupCodeList);
|
||||||
|
|
||||||
foreach ($orderList as &$order) {
|
foreach ($orderList as &$order) {
|
||||||
$orderCopiesList = [];
|
$orderCopiesList = [];
|
||||||
$addStapleFood = [];
|
$addStapleFood = [];
|
||||||
@@ -146,7 +163,7 @@ class OrderListService extends BaseService
|
|||||||
$addStapleFood = [
|
$addStapleFood = [
|
||||||
'total_price' => '0.00',
|
'total_price' => '0.00',
|
||||||
'total_quantity' => 0,
|
'total_quantity' => 0,
|
||||||
'take_food_code' => '', //这个没有取餐码
|
'pickup_code' => '', //这个没有取餐码
|
||||||
'image_list' => [],
|
'image_list' => [],
|
||||||
'is_add_staple_food' => GoodCode::IS_ADD_STAPLE_FOOD,
|
'is_add_staple_food' => GoodCode::IS_ADD_STAPLE_FOOD,
|
||||||
];
|
];
|
||||||
@@ -158,7 +175,7 @@ class OrderListService extends BaseService
|
|||||||
'total_price' => '0.00',
|
'total_price' => '0.00',
|
||||||
'total_quantity' => 0,
|
'total_quantity' => 0,
|
||||||
'image_list' => [],
|
'image_list' => [],
|
||||||
'take_food_code' => '', //todo 取餐码
|
'pickup_code' => $pickupCodeArrList[$order['id']][$i]['pickup_code'] ?? '', // 取餐码
|
||||||
'is_add_staple_food' => GoodCode::IS_NOT_ADD_STAPLE_FOOD,
|
'is_add_staple_food' => GoodCode::IS_NOT_ADD_STAPLE_FOOD,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
36
app/Service/ServiceTrait/Common/PickupCodeTrait.php
Normal file
36
app/Service/ServiceTrait/Common/PickupCodeTrait.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service\ServiceTrait\Common;
|
||||||
|
|
||||||
|
trait PickupCodeTrait
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function buildPickupCodeListData(array $data): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
foreach ($data as $item) {
|
||||||
|
// 提取关键字段
|
||||||
|
$orderId = $item["order_id"];
|
||||||
|
$copies = $item["copies"];
|
||||||
|
$pickupCode = $item["pickup_code"];
|
||||||
|
$heapsort = $item["heapsort"];
|
||||||
|
|
||||||
|
// 按层级构建数组结构
|
||||||
|
if (!isset($result[$orderId])) {
|
||||||
|
$result[$orderId] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($result[$orderId][$copies])) {
|
||||||
|
$result[$orderId][$copies] = [
|
||||||
|
'pickup_code' => $pickupCode,
|
||||||
|
'heapsort' => $heapsort,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user