Compare commits
37 Commits
20250723-0
...
20250806-2
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a962ecb39 | |||
| 24a911d63a | |||
| a6bdfa3e4c | |||
| 5cc59bb505 | |||
| a3a079edd4 | |||
| 26f58eee32 | |||
| 00aa36c574 | |||
| ff1ab9a008 | |||
| cf4a2d9436 | |||
| 30bed90d27 | |||
| ed4ce5bebe | |||
| eb0ce8a347 | |||
| edf270a6ce | |||
| c4c154cbb9 | |||
| ff36733005 | |||
| f898de515a | |||
| 058b56a348 | |||
| 42dd168c14 | |||
| 4f862caa0b | |||
| ec60074298 | |||
| 006821188d | |||
| 46a305ffe5 | |||
| 5bacdc8585 | |||
| 573aeee8db | |||
| 89797d5bfc | |||
| ba009f4a9d | |||
| ae0d0d83ac | |||
| a1668b60fc | |||
| 356b80a653 | |||
| b8f583bcc7 | |||
| 2f1c7a9b28 | |||
| 66666f4a3a | |||
| bbcc0d054f | |||
| 0a1610fc42 | |||
| a296a30080 | |||
| 4d0e3907b2 | |||
| 408a2bfa2b |
@@ -56,10 +56,10 @@ class ApiReturnAspect extends AbstractAspect
|
|||||||
$this->writeResponseLog(json_encode($result));
|
$this->writeResponseLog(json_encode($result));
|
||||||
|
|
||||||
//正式服加密 测试服不做处理
|
//正式服加密 测试服不做处理
|
||||||
if (SystemUtil::checkProEnv()) {
|
// if (SystemUtil::checkProEnv()) {
|
||||||
$cryptoFactory = $this->CryptoFactory->cryptoClass('api', json_encode($result['data']));
|
// $cryptoFactory = $this->CryptoFactory->cryptoClass('api', json_encode($result['data']));
|
||||||
$result['data'] = $cryptoFactory->encrypt();
|
// $result['data'] = $cryptoFactory->encrypt();
|
||||||
}
|
// }
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ class GoodCache
|
|||||||
private function buildData(&$list): mixed
|
private function buildData(&$list): mixed
|
||||||
{
|
{
|
||||||
$spuIds = array_column($list, 'id');
|
$spuIds = array_column($list, 'id');
|
||||||
|
$spuImage = array_column($list, 'image_id');
|
||||||
|
|
||||||
$skuList = $this->skuModel->getListBySpuIds($spuIds);
|
$skuList = $this->skuModel->getListBySpuIds($spuIds);
|
||||||
|
|
||||||
@@ -176,10 +177,10 @@ class GoodCache
|
|||||||
$skuList = $skuList->toArray();
|
$skuList = $skuList->toArray();
|
||||||
|
|
||||||
$imageIdArr = array_column($skuList,'image_ids');
|
$imageIdArr = array_column($skuList,'image_ids');
|
||||||
$imageList = $this->getOssObjects($imageIdArr);
|
$imageList = $this->getOssObjects(array_merge($spuImage,$imageIdArr));
|
||||||
|
|
||||||
$chefIds = array_column($skuList,'chef_id');
|
$chefIds = array_column($skuList,'chef_id');
|
||||||
$chefList = $this->adminUserModel->getDataByIds($chefIds);
|
$chefList = $this->adminUserModel->getChefNameByIds($chefIds);
|
||||||
|
|
||||||
$skuListArr = [];
|
$skuListArr = [];
|
||||||
$imageArr = [];
|
$imageArr = [];
|
||||||
@@ -209,6 +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']['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;
|
||||||
}
|
}
|
||||||
@@ -347,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']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,17 +97,17 @@ class SiteCache
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $siteId
|
* @param int $siteId
|
||||||
* @return array|false|\Redis|null
|
* @return array|false|\Redis
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function getSiteInfo(int $siteId): false|array|\Redis|null
|
public function getSiteInfo(int $siteId): false|array|\Redis
|
||||||
{
|
{
|
||||||
$siteKey = CommonRedisKey::siteInfoKey($siteId);
|
$siteKey = CommonRedisKey::siteInfoKey($siteId);
|
||||||
|
|
||||||
if (!$this->redis->exists($siteKey,RedisCode::SYSTEM_DB)) $this->setSiteInfo($siteId);
|
if (!$this->redis->exists($siteKey,RedisCode::SYSTEM_DB)) $this->setSiteInfo($siteId);
|
||||||
|
|
||||||
return $this->redis->hGetAll($siteKey,RedisCode::SYSTEM_DB) ?? null;
|
return $this->redis->hGetAll($siteKey,RedisCode::SYSTEM_DB) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use App\Service\Api\System\GetLeaderboardService;
|
|||||||
use App\Service\Api\System\MiniWxConfigService;
|
use App\Service\Api\System\MiniWxConfigService;
|
||||||
use App\Service\Api\System\SiteListService;
|
use App\Service\Api\System\SiteListService;
|
||||||
use App\Service\Api\System\SystemConfigService;
|
use App\Service\Api\System\SystemConfigService;
|
||||||
|
use App\Service\Api\System\TestService;
|
||||||
use App\Service\Api\User\IndexService;
|
use App\Service\Api\User\IndexService;
|
||||||
use DateMalformedStringException;
|
use DateMalformedStringException;
|
||||||
use Hyperf\HttpServer\Annotation\Controller;
|
use Hyperf\HttpServer\Annotation\Controller;
|
||||||
@@ -87,4 +88,10 @@ class SystemController extends AbstractController
|
|||||||
{
|
{
|
||||||
return (new GetLeaderboardService)->handle();
|
return (new GetLeaderboardService)->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[RequestMapping(path: "test", methods: "GET")]
|
||||||
|
public function test()
|
||||||
|
{
|
||||||
|
return (new TestService)->handle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
app/Cron/Coupon/UserCouponTask.php
Normal file
53
app/Cron/Coupon/UserCouponTask.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This crontab file is part of item.
|
||||||
|
*
|
||||||
|
* @author ctexthuang
|
||||||
|
* @contact ctexthuang@qq.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Cron\Coupon;
|
||||||
|
|
||||||
|
use App\Constants\Common\CouponCode;
|
||||||
|
use App\Lib\Log;
|
||||||
|
use App\Model\UserCoupon;
|
||||||
|
use Exception;
|
||||||
|
use Hyperf\Crontab\Annotation\Crontab;
|
||||||
|
use Hyperf\Di\Annotation\Inject;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
|
||||||
|
#[Crontab(rule: "* * * * *", name: "UserCouponTask", singleton: true , callback: "execute", memo: "每秒执行优惠券过期")]
|
||||||
|
class UserCouponTask
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Log
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected Log $log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var UserCoupon
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected UserCoupon $userCouponModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function execute(): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->userCouponModel
|
||||||
|
->where('status', CouponCode::COUPON_STATUS_UNUSED)
|
||||||
|
->where('validity_end_time', '<', date('Y-m-d H:i:s'))
|
||||||
|
->update(['status' => CouponCode::COUPON_STATUS_EXPIRE]);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->log->error(__CLASS__.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -107,6 +107,32 @@ class AdminUser extends Model
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $ids
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getChefNameByIds(array $ids): array
|
||||||
|
{
|
||||||
|
$data = $this
|
||||||
|
->join('chef', function ($join) use ($ids) {
|
||||||
|
$join->on('chef.user_id', '=', 'admin_user.id')
|
||||||
|
->whereIn('chef.id', $ids)
|
||||||
|
->where('admin_user.is_del',UserCode::IS_NO_DEL)
|
||||||
|
->select([
|
||||||
|
'admin_user.chinese_name',
|
||||||
|
'chef.id',
|
||||||
|
'admin_user.username',
|
||||||
|
]);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($data->isEmpty()) return [];
|
||||||
|
|
||||||
|
$data = $data->toArray();
|
||||||
|
|
||||||
|
return array_column($data,null,'id');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $ids
|
* @param array $ids
|
||||||
* @return array
|
* @return array
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class Sku extends Model
|
|||||||
->where('saleable',GoodCode::LISTING)
|
->where('saleable',GoodCode::LISTING)
|
||||||
// ->where('is_add_staple_food',GoodCode::IS_NOT_ADD_STAPLE_FOOD)
|
// ->where('is_add_staple_food',GoodCode::IS_NOT_ADD_STAPLE_FOOD)
|
||||||
->orderBy('sort')
|
->orderBy('sort')
|
||||||
->select(['id','spu_id','title','image_ids','price','param','extra','total_stock','surplus_stock','order_num','is_add_staple_food','occupied','chef_id','origin_sku_id'])
|
->select(['id','spu_id','title','image_ids','price','param','extra','total_stock','surplus_stock','order_num','is_add_staple_food','occupied','chef_id','origin_sku_id','sub_title'])
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use Hyperf\DbConnection\Model\Model;
|
|||||||
* @property int $kitchen_id
|
* @property int $kitchen_id
|
||||||
* @property int $chef_id
|
* @property int $chef_id
|
||||||
* @property int $caterer_id
|
* @property int $caterer_id
|
||||||
|
* @property int $image_id
|
||||||
* @property string $title
|
* @property string $title
|
||||||
* @property string $sub_title
|
* @property string $sub_title
|
||||||
* @property int $category_id
|
* @property int $category_id
|
||||||
@@ -85,7 +86,7 @@ class Spu extends Model
|
|||||||
->where('type',$type)
|
->where('type',$type)
|
||||||
->where('saleable',GoodCode::LISTING)
|
->where('saleable',GoodCode::LISTING)
|
||||||
->orderBy('sort')
|
->orderBy('sort')
|
||||||
->select(['id','cycle_id','chef_id','title','title','sub_title','category_id','favorable'])
|
->select(['id','cycle_id','chef_id','title','title','sub_title','category_id','favorable','image_id'])
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ class UserCoupon extends Model
|
|||||||
*/
|
*/
|
||||||
protected array $casts = ['id' => 'integer', 'coupon_template_id' => 'integer', 'coupon_dispense_id' => 'integer', 'user_id' => 'integer', 'status' => 'integer'];
|
protected array $casts = ['id' => 'integer', 'coupon_template_id' => 'integer', 'coupon_dispense_id' => 'integer', 'user_id' => 'integer', 'status' => 'integer'];
|
||||||
|
|
||||||
const string CREATED_AT = 'created_time';
|
const string CREATED_AT = 'create_time';
|
||||||
const string UPDATED_AT = 'updated_time';
|
const string UPDATED_AT = 'update_time';
|
||||||
|
|
||||||
public function getReceiveCountByUserIds(int $user_id,array $couponIdArr): array
|
public function getReceiveCountByUserIds(int $user_id,array $couponIdArr): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class PrintService extends CateringBaseService
|
|||||||
*/
|
*/
|
||||||
public function cancel(): array
|
public function cancel(): array
|
||||||
{
|
{
|
||||||
$service = $this->printOrderFactory->handle($this->request->input('type'));
|
$service = $this->printOrderFactory->handle((int)$this->request->input('type'));
|
||||||
$service->printId = (int)$this->request->input('print_id');
|
$service->printId = (int)$this->request->input('print_id');
|
||||||
$service->handle();
|
$service->handle();
|
||||||
$service->printCancel();
|
$service->printCancel();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Service\Admin\Catering\Print;
|
namespace App\Service\Admin\Catering\Print;
|
||||||
|
|
||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
|
use App\Lib\Log;
|
||||||
use App\Lib\Print\YlyBasicsLib;
|
use App\Lib\Print\YlyBasicsLib;
|
||||||
use App\Model\Printer;
|
use App\Model\Printer;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
@@ -58,6 +59,12 @@ class YlyPrintService implements PrintOrderInterface
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected Printer $printerModel;
|
protected Printer $printerModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Log
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected Log $log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
@@ -108,9 +115,12 @@ class YlyPrintService implements PrintOrderInterface
|
|||||||
empty($this->data['order_sno']) ||
|
empty($this->data['order_sno']) ||
|
||||||
empty($this->data['username']) ||
|
empty($this->data['username']) ||
|
||||||
empty($this->data['mobile']) ||
|
empty($this->data['mobile']) ||
|
||||||
empty($this->data['date']) ||
|
empty($this->data['date'])
|
||||||
empty($this->data['heapsort'])
|
// empty($this->data['heapsort'])
|
||||||
) throw new ErrException('打印数据丢失');
|
) {
|
||||||
|
$this->log->error('打印数据'.json_encode($this->data));
|
||||||
|
throw new ErrException('打印数据丢失');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,9 +136,6 @@ class YlyPrintService implements PrintOrderInterface
|
|||||||
//设置宽度
|
//设置宽度
|
||||||
$this->content .= "<PW>048</PW>";
|
$this->content .= "<PW>048</PW>";
|
||||||
|
|
||||||
$this->content .= "\n";
|
|
||||||
$this->content .= "\n";
|
|
||||||
|
|
||||||
//取餐号
|
//取餐号
|
||||||
$this->content .= "<FS3><CA>{$this->data['pickup_code']}</CA></FS3>\n";
|
$this->content .= "<FS3><CA>{$this->data['pickup_code']}</CA></FS3>\n";
|
||||||
|
|
||||||
@@ -190,7 +197,7 @@ class YlyPrintService implements PrintOrderInterface
|
|||||||
$contentEdibleTimeTips = config('print.yly.content_edible_time_tips');
|
$contentEdibleTimeTips = config('print.yly.content_edible_time_tips');
|
||||||
$this->content .= "<LR2>保质期,$contentEdibleTimeTips</LR2>";
|
$this->content .= "<LR2>保质期,$contentEdibleTimeTips</LR2>";
|
||||||
|
|
||||||
$this->content .= "<FS3><CA>{$this->data['heapsort']}</CA></FS3>";
|
$this->content .= "<FS3><CA>{$this->data['pickup_code']}</CA></FS3>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -231,6 +238,8 @@ class YlyPrintService implements PrintOrderInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
private function checkBoxLabelData(): void
|
private function checkBoxLabelData(): void
|
||||||
{
|
{
|
||||||
@@ -244,7 +253,10 @@ class YlyPrintService implements PrintOrderInterface
|
|||||||
empty($this->data['driver_name']) ||
|
empty($this->data['driver_name']) ||
|
||||||
empty($this->data['current_num']) ||
|
empty($this->data['current_num']) ||
|
||||||
empty($this->data['date_text'])
|
empty($this->data['date_text'])
|
||||||
) throw new ErrException('打印数据丢失');
|
) {
|
||||||
|
$this->log->error('打印数据'.json_encode($this->data));
|
||||||
|
throw new ErrException('打印数据丢失-01');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class SkuService extends BaseService
|
|||||||
$spuInfo = $this->spuModel->getInfoById($skuInfo->spu_id);
|
$spuInfo = $this->spuModel->getInfoById($skuInfo->spu_id);
|
||||||
if (empty($spuInfo)) throw new ErrException('数据出错');
|
if (empty($spuInfo)) throw new ErrException('数据出错');
|
||||||
|
|
||||||
$purchaseInfo = $this->purchaseModel->getListByCycleIdAndKitchenId($skuInfo->cycle_id,$spuInfo->kitchen_id);
|
$purchaseInfo = $this->purchaseModel->getListByCycleIdAndKitchenId($spuInfo->cycle_id,$spuInfo->kitchen_id);
|
||||||
$purchaseIds = [];
|
$purchaseIds = [];
|
||||||
if (!empty($purchaseInfo)) {
|
if (!empty($purchaseInfo)) {
|
||||||
foreach ($purchaseInfo->toArray() as $one) {
|
foreach ($purchaseInfo->toArray() as $one) {
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ class SpuService extends BaseService
|
|||||||
if (empty($list['data'])) return $this->return->success('success', ['list' => $list]);
|
if (empty($list['data'])) return $this->return->success('success', ['list' => $list]);
|
||||||
|
|
||||||
$spuIds = array_column($list['data'], 'id');
|
$spuIds = array_column($list['data'], 'id');
|
||||||
|
$spuImageIds = array_column($list['data'], 'image_id');
|
||||||
|
|
||||||
$skuList = $this->skuModel
|
$skuList = $this->skuModel
|
||||||
->whereIn('spu_id',$spuIds)
|
->whereIn('spu_id',$spuIds)
|
||||||
@@ -99,7 +100,7 @@ class SpuService extends BaseService
|
|||||||
|
|
||||||
$imageIdArr = array_column($skuList,'image_ids');
|
$imageIdArr = array_column($skuList,'image_ids');
|
||||||
$imageIds = array_unique(explode(',',implode(',',$imageIdArr)));
|
$imageIds = array_unique(explode(',',implode(',',$imageIdArr)));
|
||||||
$imageList = $this->getOssObjects($imageIds);
|
$imageList = $this->getOssObjects(array_merge($imageIds,$spuImageIds));
|
||||||
|
|
||||||
$skuListArr = [];
|
$skuListArr = [];
|
||||||
foreach ($skuList as $sku) {
|
foreach ($skuList as $sku) {
|
||||||
@@ -126,6 +127,7 @@ class SpuService extends BaseService
|
|||||||
|
|
||||||
foreach ($list['data'] as &$item) {
|
foreach ($list['data'] as &$item) {
|
||||||
$item['sku_list'] = $skuListArr[$item['id']] ?? [];
|
$item['sku_list'] = $skuListArr[$item['id']] ?? [];
|
||||||
|
$item['image_url'] = $imageList[$item['image_id']] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->return->success('success', ['list' => $list]);
|
return $this->return->success('success', ['list' => $list]);
|
||||||
@@ -156,6 +158,9 @@ class SpuService extends BaseService
|
|||||||
|
|
||||||
if (!empty($info)) throw new ErrException('该菜品在当前城市已存在');
|
if (!empty($info)) throw new ErrException('该菜品在当前城市已存在');
|
||||||
|
|
||||||
|
$imageId = $this->request->input('image_id');
|
||||||
|
|
||||||
|
$this->updateOssObjects([$imageId]);
|
||||||
|
|
||||||
$insertModel = new Spu();
|
$insertModel = new Spu();
|
||||||
|
|
||||||
@@ -170,6 +175,7 @@ class SpuService extends BaseService
|
|||||||
$insertModel->saleable = $this->request->input('saleable');
|
$insertModel->saleable = $this->request->input('saleable');
|
||||||
$insertModel->type = $this->request->input('type');
|
$insertModel->type = $this->request->input('type');
|
||||||
$insertModel->sort = $this->request->input('sort');
|
$insertModel->sort = $this->request->input('sort');
|
||||||
|
$insertModel->image_id = $imageId;
|
||||||
$insertModel->favorable = GoodCode::NOT_FAVORABLE;
|
$insertModel->favorable = GoodCode::NOT_FAVORABLE;
|
||||||
|
|
||||||
if (!$insertModel->save()) throw new ErrException('添加菜品失败');
|
if (!$insertModel->save()) throw new ErrException('添加菜品失败');
|
||||||
@@ -233,6 +239,8 @@ class SpuService extends BaseService
|
|||||||
|
|
||||||
$this->checkInfo();
|
$this->checkInfo();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$kitchenId = (int)$this->request->input('kitchen_id');
|
$kitchenId = (int)$this->request->input('kitchen_id');
|
||||||
$oldKitchenId = (int)$info->kitchen_id;
|
$oldKitchenId = (int)$info->kitchen_id;
|
||||||
|
|
||||||
@@ -245,6 +253,12 @@ class SpuService extends BaseService
|
|||||||
$info->saleable = $this->request->input('saleable');
|
$info->saleable = $this->request->input('saleable');
|
||||||
$info->type = $this->request->input('type');
|
$info->type = $this->request->input('type');
|
||||||
$info->sort = $this->request->input('sort');
|
$info->sort = $this->request->input('sort');
|
||||||
|
$requestOssId = $this->request->input('image_id',0);
|
||||||
|
if ($requestOssId != $info->image_id) {
|
||||||
|
$info->image_id = $requestOssId;
|
||||||
|
$this->updateOssObjects([$requestOssId]);
|
||||||
|
$this->updateOssObjectsDisable([$info->image_ids]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$info->save()) throw new ErrException('修改菜品失败');
|
if (!$info->save()) throw new ErrException('修改菜品失败');
|
||||||
|
|
||||||
@@ -311,6 +325,7 @@ class SpuService extends BaseService
|
|||||||
$info['city_name'] = $this->systemCityModel->getCityNameById((int)$info['city_id']);
|
$info['city_name'] = $this->systemCityModel->getCityNameById((int)$info['city_id']);
|
||||||
$info['kitchen_name'] = $this->kitchenModel->getNameById((int)$info['kitchen_id']);
|
$info['kitchen_name'] = $this->kitchenModel->getNameById((int)$info['kitchen_id']);
|
||||||
// $info['chef_name'] = $this->chefModel->getChineseNameById((int)$info['chef_id']);
|
// $info['chef_name'] = $this->chefModel->getChineseNameById((int)$info['chef_id']);
|
||||||
|
$info['image_url'] = $this->getOssObjectById((int)$info['image_id']) ?? '';
|
||||||
$info['chef_name'] = '';
|
$info['chef_name'] = '';
|
||||||
$info['category_name'] = $this->categoryModel->getNameById((int)$info['category_id']);
|
$info['category_name'] = $this->categoryModel->getNameById((int)$info['category_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]);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class DriverService extends BaseService
|
|||||||
|
|
||||||
$list = $this->siteDriverStatementModel
|
$list = $this->siteDriverStatementModel
|
||||||
->when($searchCityId, function ($query) use ($searchCityId) {
|
->when($searchCityId, function ($query) use ($searchCityId) {
|
||||||
$query->whereIn('city_id', $searchCityId);
|
$query->where('city_id', $searchCityId);
|
||||||
})
|
})
|
||||||
->when($searchDriverId, function ($query) use ($searchDriverId) {
|
->when($searchDriverId, function ($query) use ($searchDriverId) {
|
||||||
$query->where('driver_id', $searchDriverId);
|
$query->where('driver_id', $searchDriverId);
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SiteService extends BaseService
|
|||||||
|
|
||||||
$list = $this->siteDriverStatementModel
|
$list = $this->siteDriverStatementModel
|
||||||
->when($searchCityId, function ($query) use ($searchCityId) {
|
->when($searchCityId, function ($query) use ($searchCityId) {
|
||||||
$query->whereIn('city_id', $searchCityId);
|
$query->where('city_id', $searchCityId);
|
||||||
})
|
})
|
||||||
->when($searchSiteId, function ($query) use ($searchSiteId) {
|
->when($searchSiteId, function ($query) use ($searchSiteId) {
|
||||||
$query->where('site_id', $searchSiteId);
|
$query->where('site_id', $searchSiteId);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class EmployeeService extends BaseService
|
|||||||
/**
|
/**
|
||||||
* @var array|string[]
|
* @var array|string[]
|
||||||
*/
|
*/
|
||||||
private array $filed = ['id','username','avatar','chinese_name','mobile','status','last_login_ip','last_login_time','role_id'];
|
private array $filed = ['id','username','avatar','chinese_name','mobile','status','last_login_ip','last_login_time','role_id','bind_user_id'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
@@ -160,8 +160,8 @@ class EmployeeService extends BaseService
|
|||||||
|
|
||||||
$bindUserId = (int)$this->request->input('bind_user_id', 0);
|
$bindUserId = (int)$this->request->input('bind_user_id', 0);
|
||||||
if ($bindUserId > 0) {
|
if ($bindUserId > 0) {
|
||||||
$oldBindUserId = $this->adminUserModel->getAdminInfoByBindUserId($bindUserId);
|
$oldInfo = $this->adminUserModel->getAdminInfoByBindUserId($bindUserId);
|
||||||
if (!empty($oldBindUserId) && $info->bind_user_id != $oldBindUserId) throw new ErrException('绑定用户已存在');
|
if (!empty($oldBindUserId) && $info->bind_user_id != $oldInfo->bind_user_id) throw new ErrException('绑定用户已存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use App\Constants\ConfigCode;
|
|||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
use App\Model\Category;
|
use App\Model\Category;
|
||||||
use App\Service\Api\BaseService;
|
use App\Service\Api\BaseService;
|
||||||
|
use App\Service\ServiceTrait\Api\BannerTrait;
|
||||||
use App\Service\ServiceTrait\Common\CycleTrait;
|
use App\Service\ServiceTrait\Common\CycleTrait;
|
||||||
use App\Service\ServiceTrait\Common\OssTrait;
|
use App\Service\ServiceTrait\Common\OssTrait;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
@@ -30,6 +31,7 @@ use function Hyperf\Config\config;
|
|||||||
class OptionalListService extends BaseService
|
class OptionalListService extends BaseService
|
||||||
{
|
{
|
||||||
use CycleTrait;
|
use CycleTrait;
|
||||||
|
use BannerTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var GoodCache
|
* @var GoodCache
|
||||||
@@ -55,6 +57,12 @@ class OptionalListService extends BaseService
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected Category $categoryModel;
|
protected Category $categoryModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认地址
|
||||||
|
* @var array|false
|
||||||
|
*/
|
||||||
|
private array|false $siteInfo = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
@@ -67,18 +75,20 @@ class OptionalListService extends BaseService
|
|||||||
if (empty($cycleId)) return $this->return->success('success', ['list' => []]);
|
if (empty($cycleId)) return $this->return->success('success', ['list' => []]);
|
||||||
|
|
||||||
$this->goodCache->cycleId = (int)$cycleId;
|
$this->goodCache->cycleId = (int)$cycleId;
|
||||||
$siteInfo = $this->siteCache->getSiteInfo((int)$this->request->input('site_id'));
|
|
||||||
|
|
||||||
if (empty($siteInfo) || empty($siteInfo['kitchen_id'])) $siteInfo['kitchen_id'] = config('system.kitchen_id');
|
if (!empty($this->request->input('site_id'))){
|
||||||
|
$this->siteInfo = $this->siteCache->getSiteInfo((int)$this->request->input('site_id'));
|
||||||
|
}
|
||||||
|
if (empty($this->siteInfo) || empty($this->siteInfo['kitchen_id'])) $this->siteInfo['kitchen_id'] = config('system.default_kitchen_id');
|
||||||
|
|
||||||
$this->goodCache->kitchenId = (int)$siteInfo['kitchen_id'];
|
$this->goodCache->kitchenId = (int)$this->siteInfo['kitchen_id'];
|
||||||
$data = $this->goodCache->getOptionalGoodList();
|
$data = $this->goodCache->getOptionalGoodList();
|
||||||
|
|
||||||
if (empty($data)) return $this->return->success('success', ['list' => []]);
|
if (empty($data)) return $this->return->success('success', ['list' => []]);
|
||||||
|
|
||||||
$res = $this->buildData($data);
|
$res = $this->buildData($data);
|
||||||
|
|
||||||
return $this->return->success('success', ['list' => $res]);
|
return $this->return->success('success', ['list' => $res,'banner' => $this->getBanner((int)$this->request->input('city_id',config('system.default_city_id')))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
use OssTrait;
|
use OssTrait;
|
||||||
@@ -104,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) {
|
||||||
@@ -126,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)) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use App\Model\CouponTemplate;
|
|||||||
use App\Model\UserCoupon;
|
use App\Model\UserCoupon;
|
||||||
use App\Service\Api\BaseService;
|
use App\Service\Api\BaseService;
|
||||||
use App\Service\ServiceTrait\Admin\Catering\PrintTrait;
|
use App\Service\ServiceTrait\Admin\Catering\PrintTrait;
|
||||||
|
use App\Service\ServiceTrait\Api\CouponTrait;
|
||||||
use App\Service\ServiceTrait\Api\OrderTrait;
|
use App\Service\ServiceTrait\Api\OrderTrait;
|
||||||
use App\Service\ServiceTrait\Common\CycleTrait;
|
use App\Service\ServiceTrait\Common\CycleTrait;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
@@ -24,7 +25,7 @@ use Psr\Container\NotFoundExceptionInterface;
|
|||||||
|
|
||||||
abstract class BaseOrderService extends BaseService
|
abstract class BaseOrderService extends BaseService
|
||||||
{
|
{
|
||||||
use CycleTrait,OrderTrait,PrintTrait;
|
use CycleTrait,OrderTrait,PrintTrait,CouponTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int 周期id
|
* @var int 周期id
|
||||||
@@ -100,7 +101,7 @@ abstract class BaseOrderService extends BaseService
|
|||||||
* 优惠券id
|
* 优惠券id
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected int $couponId;
|
protected int $couponId = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地点id
|
* 地点id
|
||||||
|
|||||||
@@ -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 = $pickupCodeArrList[$order['id']][$i]['pickup_code'] ?? null;
|
||||||
|
$boxNum = 0;
|
||||||
|
if (!empty($pickupCodeOneCopies)) {
|
||||||
|
$pickupCodeOneCopiesArr = explode('-', $pickupCodeOneCopies);
|
||||||
|
$boxNum = ceil(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(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,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ class PlaceOrderService extends BaseOrderService
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws ErrException
|
||||||
*/
|
*/
|
||||||
private function placeOrder(): void
|
private function placeOrder(): void
|
||||||
{
|
{
|
||||||
@@ -133,12 +134,16 @@ class PlaceOrderService extends BaseOrderService
|
|||||||
|
|
||||||
$this->insertOrderGoods();
|
$this->insertOrderGoods();
|
||||||
|
|
||||||
|
$this->couponLock();
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
//回滚数据库 和 缓存
|
//回滚数据库 和 缓存
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
$this->rollbackStock();
|
$this->rollbackStock();
|
||||||
|
|
||||||
|
// $this->rollbackCouponLock();
|
||||||
//意外抛出
|
//意外抛出
|
||||||
throw new ErrException($e->getMessage());
|
throw new ErrException($e->getMessage());
|
||||||
}
|
}
|
||||||
@@ -207,7 +212,7 @@ class PlaceOrderService extends BaseOrderService
|
|||||||
$orderInsertModel->is_refund_all = OrderCode::REFUND_NULL;
|
$orderInsertModel->is_refund_all = OrderCode::REFUND_NULL;
|
||||||
$orderInsertModel->order_json = json_encode($this->orderRes);
|
$orderInsertModel->order_json = json_encode($this->orderRes);
|
||||||
|
|
||||||
if (!$orderInsertModel->save()) throw new Exception('下单失败');
|
if (!$orderInsertModel->save()) throw new Exception('下单失败-01');
|
||||||
|
|
||||||
$this->orderId = $orderInsertModel->id;
|
$this->orderId = $orderInsertModel->id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Service\Api\System;
|
namespace App\Service\Api\System;
|
||||||
|
|
||||||
use App\Cache\Redis\Api\SiteCache;
|
use App\Cache\Redis\Api\SiteCache;
|
||||||
|
use App\Constants\Common\SiteCode;
|
||||||
use App\Extend\SystemUtil;
|
use App\Extend\SystemUtil;
|
||||||
use App\Model\Site;
|
use App\Model\Site;
|
||||||
use App\Service\Api\BaseService;
|
use App\Service\Api\BaseService;
|
||||||
@@ -36,6 +37,7 @@ class SiteListService extends BaseService
|
|||||||
$query->where('name', 'like', "%$name%");
|
$query->where('name', 'like', "%$name%");
|
||||||
})
|
})
|
||||||
// ->where('name', 'like', '%'.$this->request->input('search_value').'%')
|
// ->where('name', 'like', '%'.$this->request->input('search_value').'%')
|
||||||
|
->where('is_del',SiteCode::SITE_NO_DEL)
|
||||||
->paginate($limit)
|
->paginate($limit)
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
|
|||||||
39
app/Service/Api/System/TestService.php
Normal file
39
app/Service/Api/System/TestService.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This service file is part of item.
|
||||||
|
*
|
||||||
|
* @author ctexthuang
|
||||||
|
* @contact ctexthuang@qq.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Service\Api\System;
|
||||||
|
|
||||||
|
use App\Constants\Common\CouponCode;
|
||||||
|
use App\Model\UserCoupon;
|
||||||
|
use App\Service\Api\BaseService;
|
||||||
|
use Hyperf\Di\Annotation\Inject;
|
||||||
|
|
||||||
|
class TestService extends BaseService
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var UserCoupon
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected UserCoupon $userCouponModel;
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
var_dump(date('Y-m-d H:i:s'));
|
||||||
|
$data = $this->userCouponModel
|
||||||
|
->where('status', CouponCode::COUPON_STATUS_UNUSED)
|
||||||
|
->where('validity_end_time', '<', date('Y-m-d H:i:s'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data = $data->toArray();
|
||||||
|
|
||||||
|
var_dump($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,7 +34,7 @@ class IndexService extends BaseService
|
|||||||
$avatar = $this->getOssObjectById($userInfo->avatar_id);
|
$avatar = $this->getOssObjectById($userInfo->avatar_id);
|
||||||
|
|
||||||
$res = [
|
$res = [
|
||||||
'banner' => $this->getBanner(),
|
// 'banner' => $this->getBanner(),
|
||||||
'nickname' => $userInfo->nickname,
|
'nickname' => $userInfo->nickname,
|
||||||
'avatar' => $avatar,
|
'avatar' => $avatar,
|
||||||
'point' => 0,
|
'point' => 0,
|
||||||
|
|||||||
41
app/Service/ServiceTrait/Api/BannerTrait.php
Normal file
41
app/Service/ServiceTrait/Api/BannerTrait.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service\ServiceTrait\Api;
|
||||||
|
|
||||||
|
use App\Constants\Common\BannerCode;
|
||||||
|
use App\Model\Banner;
|
||||||
|
use App\Service\ServiceTrait\Common\OssTrait;
|
||||||
|
use Hyperf\Di\Annotation\Inject;
|
||||||
|
|
||||||
|
trait BannerTrait
|
||||||
|
{
|
||||||
|
use OssTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Banner
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected Banner $bannerModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getBanner(int $cityId): array
|
||||||
|
{
|
||||||
|
$res = $this->bannerModel
|
||||||
|
->where('city_id',$cityId)
|
||||||
|
->where('status',BannerCode::DISPLAYED)
|
||||||
|
->orderBy('sort')
|
||||||
|
->get();
|
||||||
|
if ($res->isEmpty()) return [];
|
||||||
|
$res = $res->toArray();
|
||||||
|
|
||||||
|
$imageList = $this->getOssObjects(array_column($res, 'image_id'));
|
||||||
|
|
||||||
|
foreach ($res as &$v) {
|
||||||
|
$v['url'] = $imageList[$v['image_id']]['url'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace App\Service\ServiceTrait\Api;
|
|||||||
|
|
||||||
use App\Constants\Common\CouponCode;
|
use App\Constants\Common\CouponCode;
|
||||||
use App\Constants\Common\OrderCode;
|
use App\Constants\Common\OrderCode;
|
||||||
|
use App\Exception\ErrException;
|
||||||
use App\Extend\DateUtil;
|
use App\Extend\DateUtil;
|
||||||
use App\Model\UserCoupon;
|
use App\Model\UserCoupon;
|
||||||
use Exception;
|
use Exception;
|
||||||
@@ -32,14 +33,56 @@ trait CouponTrait
|
|||||||
$couponInfo = $this->userCouponModel->where('id', $orderInfo->coupon_id)->where('user_id',$orderInfo->user_id)->first();
|
$couponInfo = $this->userCouponModel->where('id', $orderInfo->coupon_id)->where('user_id',$orderInfo->user_id)->first();
|
||||||
|
|
||||||
if (empty($couponInfo)) return;
|
if (empty($couponInfo)) return;
|
||||||
|
if ($couponInfo->status != CouponCode::COUPON_STATUS_USED) return;
|
||||||
|
|
||||||
$couponInfo->status = CouponCode::COUPON_STATUS_UNUSED;
|
$couponInfo->status = CouponCode::COUPON_STATUS_UNUSED;
|
||||||
|
$couponInfo->use_time = null;
|
||||||
|
|
||||||
if (date('Y-m-d H:i:s') > $couponInfo->validity_end_time) $couponInfo->status = CouponCode::COUPON_STATUS_EXPIRE;
|
if (date('Y-m-d H:i:s') > $couponInfo->validity_end_time) $couponInfo->status = CouponCode::COUPON_STATUS_EXPIRE;
|
||||||
|
|
||||||
if (!$couponInfo->save()) throw new Exception('CancelOrderConsumer:error:couponStatusUpdateError:'.json_encode($orderInfo->toArray()));
|
if (!$couponInfo->save()) throw new Exception('CancelOrderConsumer:error:couponStatusUpdateError:'.json_encode($orderInfo->toArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected function couponLock(): void
|
||||||
|
{
|
||||||
|
if ($this->couponId <= 0) return;
|
||||||
|
|
||||||
|
$couponInfo = $this->userCouponModel->where('id', $this->couponId)->where('user_id',$this->userId)->first();
|
||||||
|
|
||||||
|
if (empty($couponInfo)) return;
|
||||||
|
|
||||||
|
$couponInfo->status = CouponCode::COUPON_STATUS_USED;
|
||||||
|
$couponInfo->use_time = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
if (date('Y-m-d H:i:s') > $couponInfo->validity_end_time) throw new Exception('优惠券已过期');
|
||||||
|
|
||||||
|
if (!$couponInfo->save()) throw new Exception('couponLock:error:couponLockUpdateError:'.json_encode($couponInfo->toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
* @throws ErrException
|
||||||
|
*/
|
||||||
|
protected function rollbackCouponLock(): void
|
||||||
|
{
|
||||||
|
if ($this->couponId <= 0) return;
|
||||||
|
|
||||||
|
$couponInfo = $this->userCouponModel->where('id', $this->couponId)->where('user_id',$this->userId)->first();
|
||||||
|
|
||||||
|
if (empty($couponInfo)) return;
|
||||||
|
|
||||||
|
if ($couponInfo->status != CouponCode::COUPON_STATUS_USED) return;
|
||||||
|
|
||||||
|
$couponInfo->status = CouponCode::COUPON_STATUS_UNUSED;
|
||||||
|
$couponInfo->use_time = '1970-01-01 00:00:00';
|
||||||
|
|
||||||
|
if (!$couponInfo->save()) throw new ErrException('系统错误-rollback_coupon失败');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $type
|
* @param int $type
|
||||||
* @param string $value
|
* @param string $value
|
||||||
|
|||||||
@@ -30,5 +30,7 @@ return [
|
|||||||
// upload_dir
|
// upload_dir
|
||||||
'upload_dir' => BASE_PATH.'/uploads/',
|
'upload_dir' => BASE_PATH.'/uploads/',
|
||||||
// 默认的厨房 id
|
// 默认的厨房 id
|
||||||
'default_kitchen_id' => env('DEFAULT_KITCHEN_ID',''),
|
'default_kitchen_id' => env('DEFAULT_KITCHEN_ID',1),
|
||||||
|
// 默认 城市 id
|
||||||
|
'default_city_id' => env('DEFAULT_CITY_ID',3),
|
||||||
];
|
];
|
||||||
@@ -60,5 +60,5 @@ WX_PAYMENT_MCH_SECRET_KEY=075cf77f5b57cc84ba59e9df3b86eda1
|
|||||||
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem
|
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem
|
||||||
WX_PAYMENT_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
|
WX_PAYMENT_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
|
||||||
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
|
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
|
||||||
WX_PAYMENT_SUB_MINI_APP_ID=wxc2bc0e47e212d831
|
WX_PAYMENT_SUB_MINI_APP_ID=wxc0edbbd0ff0fe7ed
|
||||||
WX_PAYMENT_SUB_MCH_ID=1656142874
|
WX_PAYMENT_SUB_MCH_ID=1723727305
|
||||||
@@ -55,5 +55,5 @@ WX_PAYMENT_MCH_SECRET_KEY=075cf77f5b57cc84ba59e9df3b86eda1
|
|||||||
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem
|
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem
|
||||||
WX_PAYMENT_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
|
WX_PAYMENT_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
|
||||||
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
|
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
|
||||||
WX_PAYMENT_SUB_MINI_APP_ID=wxc2bc0e47e212d831
|
WX_PAYMENT_SUB_MINI_APP_ID=wxc0edbbd0ff0fe7ed
|
||||||
WX_PAYMENT_SUB_MCH_ID=1656142874
|
WX_PAYMENT_SUB_MCH_ID=1723727305
|
||||||
4
env.pre
4
env.pre
@@ -58,5 +58,5 @@ WX_PAYMENT_MCH_SECRET_KEY=075cf77f5b57cc84ba59e9df3b86eda1
|
|||||||
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem
|
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem
|
||||||
WX_PAYMENT_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
|
WX_PAYMENT_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
|
||||||
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
|
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
|
||||||
WX_PAYMENT_SUB_MINI_APP_ID=wxc2bc0e47e212d831
|
WX_PAYMENT_SUB_MINI_APP_ID=wxc0edbbd0ff0fe7ed
|
||||||
WX_PAYMENT_SUB_MCH_ID=1656142874
|
WX_PAYMENT_SUB_MCH_ID=1723727305
|
||||||
6
env.prod
6
env.prod
@@ -1,6 +1,6 @@
|
|||||||
# [app] -- 集群配置需一致
|
# [app] -- 集群配置需一致
|
||||||
APP_NAME=hhl_meal
|
APP_NAME=hhl_meal
|
||||||
APP_ENV=dev
|
APP_ENV=prod
|
||||||
API_RETURN_KEY=hch@shenzhen
|
API_RETURN_KEY=hch@shenzhen
|
||||||
JWT_KEY=hch@shenzhen
|
JWT_KEY=hch@shenzhen
|
||||||
JWT_EXPIRE=2592000
|
JWT_EXPIRE=2592000
|
||||||
@@ -58,5 +58,5 @@ WX_PAYMENT_MCH_SECRET_KEY=075cf77f5b57cc84ba59e9df3b86eda1
|
|||||||
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem
|
WX_PAYMENT_MCH_SECRET_CERT=__DIR__/config/pay/wx/apiclient_key.pem
|
||||||
WX_PAYMENT_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
|
WX_PAYMENT_MCH_PUBLIC_CERT_PATH=__DIR__/config/pay/wx/apiclient_cert.pem
|
||||||
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
|
WX_PAYMENT_MINI_APP_ID=wx444b711b6101f25b
|
||||||
WX_PAYMENT_SUB_MINI_APP_ID=wxc2bc0e47e212d831
|
WX_PAYMENT_SUB_MINI_APP_ID=wxc0edbbd0ff0fe7ed
|
||||||
WX_PAYMENT_SUB_MCH_ID=1656142874
|
WX_PAYMENT_SUB_MCH_ID=1723727305
|
||||||
Reference in New Issue
Block a user