Compare commits
15 Commits
20250806-1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f7e6b9c418 | |||
| ea08aa94a6 | |||
| fdb5d99214 | |||
| b202835205 | |||
| 44a500df9f | |||
| 1a962ecb39 | |||
| 24a911d63a | |||
| a6bdfa3e4c | |||
| 5cc59bb505 | |||
| a3a079edd4 | |||
| 26f58eee32 | |||
| 00aa36c574 | |||
| ff1ab9a008 | |||
| cf4a2d9436 | |||
| 30bed90d27 |
@@ -210,7 +210,7 @@ class GoodCache
|
|||||||
|
|
||||||
foreach ($list as &$item) {
|
foreach ($list as &$item) {
|
||||||
$item['sku_list'] = $skuListArr[$item['id']] ?? [];
|
$item['sku_list'] = $skuListArr[$item['id']] ?? [];
|
||||||
$item['spu_image_url'] = $imageList[$item['image_id']] ?? '';
|
$item['spu_image_url']['url'] = $imageList[$item['image_id']]['url'] ?? '';
|
||||||
$item['image_list'] = $imageArr[$item['id']] ?? [];
|
$item['image_list'] = $imageArr[$item['id']] ?? [];
|
||||||
$item['price'] = !empty($price[$item['id']]) ? (min($price[$item['id']]) ?? 0) : 0;
|
$item['price'] = !empty($price[$item['id']]) ? (min($price[$item['id']]) ?? 0) : 0;
|
||||||
}
|
}
|
||||||
@@ -349,7 +349,10 @@ class GoodCache
|
|||||||
*/
|
*/
|
||||||
private function buildStockData(&$data): mixed
|
private function buildStockData(&$data): mixed
|
||||||
{
|
{
|
||||||
|
if (empty($data)) return $data;
|
||||||
|
|
||||||
foreach ($data as &$spu) {
|
foreach ($data as &$spu) {
|
||||||
|
if (empty($spu['sku_list'])) continue;
|
||||||
foreach ($spu['sku_list'] as &$sku) {
|
foreach ($spu['sku_list'] as &$sku) {
|
||||||
$sku['stock'] = $this->getStock($sku['id']);
|
$sku['stock'] = $this->getStock($sku['id']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,6 @@ class UserSite extends Model
|
|||||||
*/
|
*/
|
||||||
public function getUserDefaultInfoByUserId(int $userId)
|
public function getUserDefaultInfoByUserId(int $userId)
|
||||||
{
|
{
|
||||||
return $this->where('user_id', $userId)->where('is_default',SiteCode::USER_NO_DEFAULT)->first();
|
return $this->where('user_id', $userId)->where('is_default',SiteCode::USER_DEFAULT)->first();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,18 @@ class OrderListService extends BaseService
|
|||||||
->when($this->request->input('search_kitchen_id'), function ($query) {
|
->when($this->request->input('search_kitchen_id'), function ($query) {
|
||||||
$query->where('kitchen_id', $this->request->input('search_kitchen_id'));
|
$query->where('kitchen_id', $this->request->input('search_kitchen_id'));
|
||||||
})
|
})
|
||||||
|
->when($this->request->input('search_order_sno'), function ($query) {
|
||||||
|
$searchOrderSno = $this->request->input('search_order_sno');
|
||||||
|
$query->where('order_sno', 'like', "$searchOrderSno%");
|
||||||
|
})
|
||||||
|
->when($this->request->input('search_create_time'), function ($query) {
|
||||||
|
$searchCreateTime = $this->request->input('search_create_time');
|
||||||
|
$query->whereBetween('create_time', [reset($searchCreateTime), end($searchCreateTime)]);
|
||||||
|
})
|
||||||
|
->when($this->request->input('search_pay_time'), function ($query) {
|
||||||
|
$searchPayTime = $this->request->input('search_pay_time');
|
||||||
|
$query->whereBetween('pay_time', [reset($searchPayTime), end($searchPayTime)]);
|
||||||
|
})
|
||||||
->select([
|
->select([
|
||||||
'id',
|
'id',
|
||||||
'cycle_id',
|
'cycle_id',
|
||||||
|
|||||||
@@ -87,11 +87,17 @@ class ChefService extends BaseService
|
|||||||
|
|
||||||
$skuIds = array_column($list['data'], 'sku_id');
|
$skuIds = array_column($list['data'], 'sku_id');
|
||||||
$chefIds = array_column($list['data'], 'chef_id');
|
$chefIds = array_column($list['data'], 'chef_id');
|
||||||
$skuList = $this->skuModel->whereIn('id', $skuIds)->pluck('title', 'id')->toArray();
|
$skuList = $this->skuModel->whereIn('id', $skuIds)->select('price','title','id')->get();
|
||||||
$chefList = $this->adminUserModel->whereIn('id',$chefIds)->pluck('chinese_name','id')->toArray();
|
if ($skuList->isNotEmpty()) {
|
||||||
|
$skuList = array_column($skuList->toArray(), null,'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
$chefList = $this->adminUserModel->getChefNameByIds($chefIds);
|
||||||
foreach ($list['data'] as &$v) {
|
foreach ($list['data'] as &$v) {
|
||||||
$v['sku_title'] = $skuList[$v['sku_id']] ?? '';
|
$v['sku_title'] = $skuList[$v['sku_id']]['title'] ?? '';
|
||||||
$v['chef_name'] = $chefList[$v['chef_id']] ?? '';
|
$v['sku_price'] = $skuList[$v['sku_id']]['price'] ?? '0.00';
|
||||||
|
$v['total_price'] = bcmul($skuList[$v['sku_id']]['price'],(string)$v['sale'],2);
|
||||||
|
$v['chef_name'] = $chefList[$v['chef_id']]['chinese_name'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->return->success('success', ['list' => $list]);
|
return $this->return->success('success', ['list' => $list]);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class FinancesService extends BaseService
|
|||||||
->when($searchKitchenId, function ($query) use ($searchKitchenId) {
|
->when($searchKitchenId, function ($query) use ($searchKitchenId) {
|
||||||
$query->where('kitchen_id', $searchKitchenId);
|
$query->where('kitchen_id', $searchKitchenId);
|
||||||
})
|
})
|
||||||
->groupBy('cycle_id')
|
->groupBy('cycle_id','date')
|
||||||
->orderByDesc('cycle_id')
|
->orderByDesc('cycle_id')
|
||||||
->select(
|
->select(
|
||||||
'date',
|
'date',
|
||||||
|
|||||||
@@ -114,9 +114,11 @@ class OptionalListService extends BaseService
|
|||||||
$favorable = [];
|
$favorable = [];
|
||||||
$skuList = [];
|
$skuList = [];
|
||||||
foreach ($data as &$item) {
|
foreach ($data as &$item) {
|
||||||
foreach ($item['sku_list'] as &$v) {
|
if (!empty($item['sku_list'])) {
|
||||||
$v['surplus_stock'] = $this->redisCache->zScore($stockKey,$v['id']) ?? 0;
|
foreach ($item['sku_list'] as &$v) {
|
||||||
$v['category_id'] = $item['category_id'];
|
$v['surplus_stock'] = $this->redisCache->zScore($stockKey,$v['id']) ?? 0;
|
||||||
|
$v['category_id'] = $item['category_id'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item['favorable'] == GoodCode::IS_FAVORABLE) {
|
if ($item['favorable'] == GoodCode::IS_FAVORABLE) {
|
||||||
@@ -136,10 +138,10 @@ class OptionalListService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$res[$item['category_id']]['spu_list'][] = $item;
|
$res[$item['category_id']]['spu_list'][] = $item;
|
||||||
$skuList = array_merge($skuList, $item['sku_list']);
|
$skuList = array_merge($skuList, $item['sku_list'] ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($skuList)) throw new ErrException('数据错误');
|
if (empty($skuList)) return array_values($res);
|
||||||
$skuList = array_column($skuList,null,'id');
|
$skuList = array_column($skuList,null,'id');
|
||||||
|
|
||||||
if (!empty($purchaseData)) {
|
if (!empty($purchaseData)) {
|
||||||
|
|||||||
@@ -72,7 +72,20 @@ class ConfirmationOrderService extends BaseOrderService
|
|||||||
foreach ($filtered as &$value) {
|
foreach ($filtered as &$value) {
|
||||||
$value['amount'] = match ($value['coupon_type']) {
|
$value['amount'] = match ($value['coupon_type']) {
|
||||||
CouponCode::COUPON_TYPE_INSTANT_REDUCTION => $value['amount'],
|
CouponCode::COUPON_TYPE_INSTANT_REDUCTION => $value['amount'],
|
||||||
CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcsub("1", (string)$value['ratio'],2),(string)$orderMaxPrice,2),
|
// CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcsub("100", (string)$value['ratio'],2),(string)$orderMaxPrice,2),
|
||||||
|
CouponCode::COUPON_TYPE_DISCOUNT => bcmul(
|
||||||
|
bcdiv(
|
||||||
|
bcsub(
|
||||||
|
"100",
|
||||||
|
(string)$value['ratio'],
|
||||||
|
2
|
||||||
|
),
|
||||||
|
"100",
|
||||||
|
2
|
||||||
|
),
|
||||||
|
bcadd((string)max(array_column($this->orderRes['good'],'price')),(string)$this->orderRes['sundry_price'],2),
|
||||||
|
2
|
||||||
|
),
|
||||||
default => 0
|
default => 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ declare(strict_types=1);
|
|||||||
namespace App\Service\Api\Order;
|
namespace App\Service\Api\Order;
|
||||||
|
|
||||||
use App\Cache\Redis\Api\SiteCache;
|
use App\Cache\Redis\Api\SiteCache;
|
||||||
|
use App\Cache\Redis\Common\ConfigCache;
|
||||||
use App\Constants\Common\GoodCode;
|
use App\Constants\Common\GoodCode;
|
||||||
use App\Constants\Common\OrderCode;
|
use App\Constants\Common\OrderCode;
|
||||||
|
use App\Constants\ConfigCode;
|
||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
use App\Model\AdminUser;
|
use App\Model\AdminUser;
|
||||||
use App\Model\Chef;
|
use App\Model\Chef;
|
||||||
@@ -69,6 +71,12 @@ class OrderInfoService extends BaseService
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected SiteCache $siteCache;
|
protected SiteCache $siteCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ConfigCache
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected ConfigCache $configCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
@@ -147,11 +155,20 @@ class OrderInfoService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 1; $i <= (count($newOrderSkuList) ?? 0); $i++) {
|
for ($i = 1; $i <= (count($newOrderSkuList) ?? 0); $i++) {
|
||||||
|
|
||||||
|
$pickupCodeOneCopies = $pickupCodeList[$i] ?? null;
|
||||||
|
$boxNum = 0;
|
||||||
|
if (!empty($pickupCodeOneCopies)) {
|
||||||
|
$pickupCodeOneCopiesArr = explode('-', $pickupCodeOneCopies);
|
||||||
|
$boxNum = ceil((int)(end($pickupCodeOneCopiesArr) ?? 0) / (int)$this->configCache->getConfigValueByKey(ConfigCode::MAXIMUM_VALUE_IN_FULL_BOX));
|
||||||
|
}
|
||||||
|
|
||||||
$oneCopiesInfo = [
|
$oneCopiesInfo = [
|
||||||
'total_price' => '0.00',
|
'total_price' => '0.00',
|
||||||
'total_quantity' => 0,
|
'total_quantity' => 0,
|
||||||
'sku_list' => [],
|
'sku_list' => [],
|
||||||
'pickup_code' => $pickupCodeList[$i] ?? '', //取餐码
|
'pickup_code' => $pickupCodeOneCopies ?? '', // 取餐码
|
||||||
|
'box_num' => $boxNum,
|
||||||
'is_add_staple_food' => GoodCode::IS_NOT_ADD_STAPLE_FOOD,
|
'is_add_staple_food' => GoodCode::IS_NOT_ADD_STAPLE_FOOD,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ declare(strict_types=1);
|
|||||||
namespace App\Service\Api\Order;
|
namespace App\Service\Api\Order;
|
||||||
|
|
||||||
use App\Cache\Redis\Api\SiteCache;
|
use App\Cache\Redis\Api\SiteCache;
|
||||||
|
use App\Cache\Redis\Common\ConfigCache;
|
||||||
use App\Constants\Common\GoodCode;
|
use App\Constants\Common\GoodCode;
|
||||||
use App\Constants\Common\OrderCode;
|
use App\Constants\Common\OrderCode;
|
||||||
|
use App\Constants\ConfigCode;
|
||||||
use App\Model\Order;
|
use App\Model\Order;
|
||||||
use App\Model\OrderGood;
|
use App\Model\OrderGood;
|
||||||
use App\Model\PickupCode;
|
use App\Model\PickupCode;
|
||||||
@@ -61,6 +63,12 @@ class OrderListService extends BaseService
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected SiteCache $siteCache;
|
protected SiteCache $siteCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ConfigCache
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected ConfigCache $configCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
@@ -164,6 +172,7 @@ class OrderListService extends BaseService
|
|||||||
'total_price' => '0.00',
|
'total_price' => '0.00',
|
||||||
'total_quantity' => 0,
|
'total_quantity' => 0,
|
||||||
'pickup_code' => '', //这个没有取餐码
|
'pickup_code' => '', //这个没有取餐码
|
||||||
|
'box_num' => 0,
|
||||||
'image_list' => [],
|
'image_list' => [],
|
||||||
'is_add_staple_food' => GoodCode::IS_ADD_STAPLE_FOOD,
|
'is_add_staple_food' => GoodCode::IS_ADD_STAPLE_FOOD,
|
||||||
];
|
];
|
||||||
@@ -171,11 +180,18 @@ class OrderListService extends BaseService
|
|||||||
|
|
||||||
for ($i = 1; $i <= (count($newOrderSkuList[$order['id']]) ?? 0); $i++) {
|
for ($i = 1; $i <= (count($newOrderSkuList[$order['id']]) ?? 0); $i++) {
|
||||||
$breakFlag = 0;
|
$breakFlag = 0;
|
||||||
|
$pickupCodeOneCopies = $pickupCodeArrList[$order['id']][$i]['pickup_code'] ?? null;
|
||||||
|
$boxNum = 0;
|
||||||
|
if (!empty($pickupCodeOneCopies)) {
|
||||||
|
$pickupCodeOneCopiesArr = explode('-', $pickupCodeOneCopies);
|
||||||
|
$boxNum = ceil((int)(end($pickupCodeOneCopiesArr) ?? 0) / (int)$this->configCache->getConfigValueByKey(ConfigCode::MAXIMUM_VALUE_IN_FULL_BOX));
|
||||||
|
}
|
||||||
$oneCopiesInfo = [
|
$oneCopiesInfo = [
|
||||||
'total_price' => '0.00',
|
'total_price' => '0.00',
|
||||||
'total_quantity' => 0,
|
'total_quantity' => 0,
|
||||||
'image_list' => [],
|
'image_list' => [],
|
||||||
'pickup_code' => $pickupCodeArrList[$order['id']][$i]['pickup_code'] ?? '', // 取餐码
|
'pickup_code' => $pickupCodeOneCopies ?? '', // 取餐码
|
||||||
|
'box_num' => $boxNum,
|
||||||
'is_add_staple_food' => GoodCode::IS_NOT_ADD_STAPLE_FOOD,
|
'is_add_staple_food' => GoodCode::IS_NOT_ADD_STAPLE_FOOD,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user