feat : add_staple_food
This commit is contained in:
@@ -11,6 +11,8 @@ declare(strict_types=1);
|
||||
namespace App\Service\Api\Order;
|
||||
|
||||
use App\Cache\Redis\Api\SiteCache;
|
||||
use App\Constants\Common\GoodCode;
|
||||
use App\Constants\Common\OrderCode;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderGood;
|
||||
use App\Model\Sku;
|
||||
@@ -124,6 +126,17 @@ class OrderListService extends BaseService
|
||||
|
||||
foreach ($orderList as &$order) {
|
||||
$orderCopiesList = [];
|
||||
$addStapleFood = [];
|
||||
if ($order['type'] == OrderCode::ORDER_TYPE_MEAL) {
|
||||
$addStapleFood = [
|
||||
'total_price' => '0.00',
|
||||
'total_quantity' => 0,
|
||||
'sku_list' => [],
|
||||
'take_food_code' => '', //取餐码
|
||||
'is_add_staple_food' => GoodCode::IS_ADD_STAPLE_FOOD,
|
||||
];
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= ($order['copies'] ?? 0); $i++) {
|
||||
|
||||
$oneCopiesInfo = [
|
||||
@@ -140,6 +153,14 @@ class OrderListService extends BaseService
|
||||
|
||||
$skuInfo = $skuList[$item['sku_id']] ?? [];
|
||||
$imageId = !empty($skuInfo) && !empty(explode(',',$skuInfo['image_ids'])[0]) ? explode(',',$skuInfo['image_ids'])[0] : [];
|
||||
|
||||
if ($skuInfo['is_staple_food'] == GoodCode::IS_ADD_STAPLE_FOOD) {
|
||||
$addStapleFood['total_price'] = bcadd((string)$oneCopiesInfo['total_price'], bcmul((string)$item['unit_price'],(string)$item['quantity'],2), 2);
|
||||
$addStapleFood['total_quantity'] += $item['quantity'];
|
||||
$addStapleFood['url'] = $imageList[$imageId]['url'] ?? '';
|
||||
continue;
|
||||
}
|
||||
|
||||
$oneCopiesInfo['total_price'] = bcadd($oneCopiesInfo['total_price'], bcmul($item['unit_price'],(string)$item['quantity'],2), 2);
|
||||
$oneCopiesInfo['total_quantity'] += $item['quantity'];
|
||||
// $oneCopiesInfo['sku_list'][] = [];
|
||||
@@ -158,6 +179,7 @@ class OrderListService extends BaseService
|
||||
// $oneCopiesInfo['image_list'][] = $imageList[$imageId] ?? [];
|
||||
// }
|
||||
|
||||
if (!empty($addStapleFood)) $oneCopiesInfo[] = $addStapleFood;
|
||||
$orderCopiesList[] = $oneCopiesInfo;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user