Site.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\model\system;
  11. use app\model\BaseModel;
  12. use app\model\upload\Upload;
  13. /**
  14. * 站点管理
  15. * @author Administrator
  16. *
  17. */
  18. class Site extends BaseModel
  19. {
  20. /**
  21. * 添加站点
  22. */
  23. public function addSite($data)
  24. {
  25. $res = model('site')->add($data);
  26. return $this->success($res);
  27. }
  28. /**
  29. * getSiteInfo 获取站点详情
  30. * @param $condtion
  31. * @param string $fields
  32. */
  33. public function getSiteInfo($condition, $fields = '*')
  34. {
  35. $res = model('site')->getInfo($condition, $fields);
  36. return $this->success($res);
  37. }
  38. /**
  39. * 修改商城站点信息
  40. * @param $site_data
  41. * @param $condition
  42. * @return int
  43. */
  44. public function editSite($site_data, $condition)
  45. {
  46. $site_info = $this->getSiteInfo($condition);
  47. if($site_info['data'] && $site_data['logo'] && $site_info['data']['logo'] != $site_data['logo']){
  48. $upload_model = new Upload();
  49. $upload_model->deletePic($site_info['data']['logo'], $site_info['data']['site_id']);
  50. }
  51. if($site_info['data'] && !empty($site_data['logo_square']) && $site_info['data']['logo_square'] != $site_data['logo_square']){
  52. $upload_model = new Upload();
  53. $upload_model->deletePic($site_info['data']['logo_square'], $site_info['data']['site_id']);
  54. }
  55. $res = model('site')->update($site_data, $condition);
  56. if($res && $site_data['logo']){
  57. copy($site_data['logo'],"public/static/img/default_img/login.png");
  58. }
  59. return $this->success($res);
  60. }
  61. }