You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
3.3 KiB
86 lines
3.3 KiB
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controller;
|
|
|
|
use Hyperf\DbConnection\Db;
|
|
use Hyperf\HttpServer\Annotation\AutoController;
|
|
use OSS\Core\OssException;
|
|
use OSS\OssClient;
|
|
|
|
/**
|
|
* @AutoController()
|
|
* Class StoreController
|
|
* @package App\Controller
|
|
*/
|
|
class StoreController extends BaseController
|
|
{
|
|
public function infoEdit()
|
|
{
|
|
$id = $this->request->input('id');
|
|
if (empty($id)) {
|
|
return $this->result(1, [], 'id不能为空');
|
|
}
|
|
if ($this->request->isMethod('post')) {
|
|
$logo = $this->request->input('logo');
|
|
$name = $this->request->input('name');
|
|
$tel = $this->request->input('tel');
|
|
$address = $this->request->input('address');
|
|
$coordinates = $this->request->input('coordinates');
|
|
$capita = $this->request->input('capita');
|
|
$start_at = $this->request->input('start_at');
|
|
$announcement = $this->request->input('announcement');
|
|
$environment = $this->request->input('environment');
|
|
|
|
//>>1上传logo到阿里云oss
|
|
//>>2.上传商家环境到阿里云oss
|
|
//>>3.保存数据到数据库存
|
|
$fileNameLogo = $object = 'public/upload/' . date('Y') . '/' . date('m-d') . '/' . rand(0, 9999999999999999) . '.jpg';
|
|
$fileUpload = new FileUpload();
|
|
$resLogo = $fileUpload->ossUpload($logo, $fileNameLogo);
|
|
if (isset($resLogo['info']['http_code']) && $resLogo['info']['http_code'] == 200) {
|
|
$logo_url = $fileNameLogo;
|
|
} else {
|
|
return $this->result(1, []);
|
|
}
|
|
$environments = explode(',', $environment);
|
|
$envPaths = [];
|
|
foreach ($environments as $env) {
|
|
$fileNameEnv = $object = 'public/upload/' . date('Y') . '/' . date('m-d') . '/' . rand(0, 9999999999999999) . '.jpg';
|
|
$resEnv = $fileUpload->ossUpload($env, $fileNameEnv);
|
|
if (isset($resEnv['info']['http_code']) && $resLogo['info']['http_code'] == 200) {
|
|
$envPaths[] = $fileNameEnv;
|
|
}
|
|
}
|
|
if (count($envPaths)) {
|
|
$envPath = implode(',', $envPaths);
|
|
}
|
|
|
|
$res = Db::table('ims_cjdc_store')->where('id', $id)->update([
|
|
'logo' => $logo_url ?? "",
|
|
'name' => $name,
|
|
'tel' => $tel,
|
|
'address' => $address,
|
|
'coordinates' => $coordinates,
|
|
'capita' => $capita,
|
|
'start_at' => $start_at,
|
|
'announcement' => $announcement,
|
|
'environment' => $envPath ?? "",
|
|
]);
|
|
return $this->success($res);
|
|
}
|
|
//'id','name','logo','tel','address','coordinates','capita','start_at','announcement','environment'
|
|
//获取店铺信息
|
|
$data = Db::table('ims_cjdc_store')
|
|
->select(['id','name','logo','tel','address','coordinates','capita','start_at','announcement','environment'])
|
|
->where('id',$id)
|
|
->first();
|
|
if ($data){
|
|
$data->site = config('site_host');
|
|
}
|
|
return $this->success($data);
|
|
|
|
|
|
|
|
}
|
|
}
|