82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Api\Evaluation;
|
|
|
|
use App\Constants\Common\OrderCode;
|
|
use App\Exception\ErrException;
|
|
use App\Model\AdminUser;
|
|
use App\Model\Order;
|
|
use App\Model\OrderGood;
|
|
use App\Model\Sku;
|
|
use App\Service\Api\BaseService;
|
|
use App\Service\ServiceTrait\Common\OssTrait;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
|
class ViewService extends BaseService
|
|
{
|
|
use OssTrait;
|
|
|
|
/**
|
|
* @var Order
|
|
*/
|
|
#[Inject]
|
|
protected Order $orderModel;
|
|
|
|
/**
|
|
* @var OrderGood
|
|
*/
|
|
#[Inject]
|
|
protected OrderGood $orderGoodModel;
|
|
|
|
/**
|
|
* @var Sku
|
|
*/
|
|
#[Inject]
|
|
protected Sku $skuModel;
|
|
|
|
/**
|
|
* @var AdminUser
|
|
*/
|
|
#[Inject]
|
|
protected AdminUser $adminUserModel;
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function handle(): array
|
|
{
|
|
$orderGoodInfo = $this->orderGoodModel->find($this->request->input('order_good_id'));
|
|
if (empty($orderGoodInfo)) throw new ErrException('订单信息异常,请稍后再试或者联系客服');
|
|
|
|
$orderInfo = $this->orderModel->find($orderGoodInfo->order_id);
|
|
if (empty($orderInfo)) throw new ErrException('订单不存在');
|
|
|
|
if ($orderInfo->status != OrderCode::FINISH) throw new ErrException('订单尚未完成,请稍候');
|
|
|
|
$skuInfo = $this->skuModel->find($orderGoodInfo->sku_id);
|
|
if (empty($skuInfo)) throw new ErrException('该菜品信息不存在,请稍后再试');
|
|
|
|
$adminInfo = $this->adminUserModel->find($skuInfo->chef_id);
|
|
|
|
$imageList = $this->getOssObjects(explode(',',$skuInfo->image_ids));
|
|
$imageUrl = array_column($imageList,'url');
|
|
|
|
$res = [
|
|
'title' => $skuInfo->title,
|
|
'price' => $skuInfo->price,
|
|
'chef_id' => $skuInfo->chef_id,
|
|
'chef_name' => $adminInfo->chinese_name,
|
|
'image_url' => $imageUrl,
|
|
];
|
|
|
|
return $this->return->success('success',$res);
|
|
}
|
|
} |