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.

72 lines
1.9 KiB

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller;
  4. use Hyperf\DbConnection\Db;
  5. use Hyperf\HttpServer\Annotation\AutoController;
  6. use OSS\Core\OssException;
  7. use OSS\OssClient;
  8. /**
  9. * @AutoController()
  10. * Class StoreController
  11. * @package App\Controller
  12. */
  13. class StoreController extends BaseController
  14. {
  15. public function infoEdit()
  16. {
  17. $id = $this->request->input('id');
  18. if (empty($id)){
  19. return $this->result(1,[],'id不能为空');
  20. }
  21. $logo = $this->request->input('logo');
  22. $name = $this->request->input('name');
  23. $tel = $this->request->input('tel');
  24. $address = $this->request->input('address');
  25. $coordinates = $this->request->input('coordinates');
  26. $capita = $this->request->input('capita');
  27. $start_at = $this->request->input('start_at');
  28. $announcement = $this->request->input('announcement');
  29. $environment = $this->request->input('environment');
  30. //>>1上传logo到阿里云oss
  31. //>>2.上传商家环境到阿里云oss
  32. //>>3.保存数据到数据库存
  33. $fileName = $object = 'public/upload/' . date('Y') . '/' . date('m-d') . '/' . rand(0,9999999999999999).'.jpg';
  34. $fileUpload = new FileUpload();
  35. $resLogo = $fileUpload->ossUpload($logo,$fileName);
  36. if (isset($resLogo['info']['http_code'])&&$resLogo['info']['http_code']==200){
  37. $logo_url = $fileName;
  38. }else{
  39. return $this->result(1,[]);
  40. }
  41. $res = Db::table('ims_cjdc_store')->where('id',$id)->update([
  42. 'logo'=>$logo_url??"",
  43. 'name'=>$name,
  44. 'tel'=>$tel,
  45. 'address'=>$address,
  46. 'coordinates'=>$coordinates,
  47. 'capita'=>$capita,
  48. 'start_at'=>$start_at,
  49. 'announcement'=>$announcement,
  50. 'environment'=>$environment,
  51. ]);
  52. return $this->success($res);
  53. }
  54. }