Shop.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\shopapi\controller;
  13. use app\model\shop\Shop as ShopModel;
  14. use app\model\system\Site;
  15. /**
  16. * 店铺
  17. * Class Shop
  18. * @package app\shop\controller
  19. */
  20. class Shop extends BaseApi
  21. {
  22. public function __construct()
  23. {
  24. //执行父类构造函数
  25. parent::__construct();
  26. $token = $this->checkToken();
  27. if ($token[ 'code' ] < 0) {
  28. echo $this->response($token);
  29. exit;
  30. }
  31. }
  32. /**
  33. * 获取店铺信息
  34. * @return false|string
  35. */
  36. public function shopInfo()
  37. {
  38. $condition = array (
  39. [ "site_id", "=", $this->site_id ]
  40. );
  41. $shop_info_result = (new ShopModel())->getShopInfo($condition);
  42. $site_info = (new Site())->getSiteInfo($condition);
  43. $shop_info = array_merge($shop_info_result['data'], $site_info['data']);
  44. $user_info = [
  45. 'group_id' => $this->user_info[ 'group_id' ],
  46. 'group_name' => $this->user_info[ 'group_name' ],
  47. 'is_admin' => $this->user_info[ 'is_admin' ],
  48. 'status' => $this->user_info[ 'status' ],
  49. 'uid' => $this->user_info[ 'uid' ],
  50. 'username' => $this->user_info[ 'username' ],
  51. ];
  52. $res = [
  53. 'shop_info' => $shop_info,
  54. 'user_info' => $user_info
  55. ];
  56. return $this->response($this->success($res));
  57. }
  58. /**
  59. * 店铺设置
  60. * @return mixed
  61. */
  62. public function config()
  63. {
  64. $shop_model = new Site();
  65. $logo = isset($this->params[ 'logo' ]) ? $this->params[ 'logo' ] : '';//店铺logo
  66. $avatar = isset($this->params[ 'avatar' ]) ? $this->params[ 'avatar' ] : '';//店铺头像(大图)
  67. $banner = isset($this->params[ 'banner' ]) ? $this->params[ 'banner' ] : '';//店铺条幅
  68. $sit_name = isset($this->params['site_name']) ? $this->params['site_name'] : '';
  69. $seo_keywords = isset($this->params[ 'seo_keywords' ]) ? $this->params[ 'seo_keywords' ] : '';
  70. $seo_description = isset($this->params[ 'seo_description' ]) ? $this->params[ 'seo_description' ] : '';//店铺简介
  71. $data = array (
  72. "logo" => $logo,
  73. "avatar" => $avatar,
  74. "site_name"=> $sit_name,
  75. "banner" => $banner,
  76. "seo_keywords" => $seo_keywords,
  77. "seo_description" => $seo_description,
  78. );
  79. $res = $shop_model->editSite($data, [ [ 'site_id', '=', $this->site_id ] ]);
  80. return $this->response($res);
  81. }
  82. /**
  83. * 联系方式
  84. * @return mixed
  85. */
  86. public function contact()
  87. {
  88. $shop_model = new ShopModel();
  89. $province = isset($this->params[ 'province' ]) ? $this->params[ 'province' ] : '';//省级地址
  90. $province_name = isset($this->params[ 'province_name' ]) ? $this->params[ 'province_name' ] : '';//省级地址
  91. $city = isset($this->params[ 'city' ]) ? $this->params[ 'city' ] : '';//市级地址
  92. $city_name = isset($this->params[ 'city_name' ]) ? $this->params[ 'city_name' ] : '';//市级地址
  93. $district = isset($this->params[ 'district' ]) ? $this->params[ 'district' ] : '';//县级地址
  94. $district_name = isset($this->params[ 'district_name' ]) ? $this->params[ 'district_name' ] : '';//县级地址
  95. $community = isset($this->params[ 'community' ]) ? $this->params[ 'community' ] : '';//乡镇地址
  96. $community_name = isset($this->params[ 'community_name' ]) ? $this->params[ 'community_name' ] : '';//乡镇地址
  97. $address = isset($this->params[ 'address' ]) ? $this->params[ 'address' ] : '';//详细地址
  98. $full_address = isset($this->params[ 'full_address' ]) ? $this->params[ 'full_address' ] : '';//完整地址
  99. $longitude = isset($this->params[ 'longitude' ]) ? $this->params[ 'longitude' ] : '';//经度
  100. $latitude = isset($this->params[ 'latitude' ]) ? $this->params[ 'latitude' ] : '';//纬度
  101. $qq = isset($this->params[ 'qq' ]) ? $this->params[ 'qq' ] : '';//qq
  102. $ww = isset($this->params[ 'ww' ]) ? $this->params[ 'ww' ] : '';//ww
  103. $email = isset($this->params[ 'email' ]) ? $this->params[ 'email' ] : '';//邮箱
  104. $telephone = isset($this->params[ 'telephone' ]) ? $this->params[ 'telephone' ] : '';//联系电话
  105. $name = isset($this->params[ 'name' ]) ? $this->params[ 'name' ] : '';//联系人姓名
  106. $mobile = isset($this->params[ 'mobile' ]) ? $this->params[ 'mobile' ] : '';//联系人手机号
  107. $work_week = isset($this->params[ 'work_week' ]) ? $this->params[ 'work_week' ] : '';//工作日 例如 : 1,2,3,4,5,6,7
  108. $start_time = isset($this->params[ 'start_time' ]) ? $this->params[ 'start_time' ] : '';//开始时间
  109. $end_time = isset($this->params[ 'end_time' ]) ? $this->params[ 'end_time' ] : '';//结束时间
  110. $data = array (
  111. "province" => $province,
  112. "province_name" => $province_name,
  113. "city" => $city,
  114. "city_name" => $city_name,
  115. "district" => $district,
  116. "district_name" => $district_name,
  117. "community" => $community,
  118. "community_name" => $community_name,
  119. "address" => $address,
  120. "full_address" => $full_address,
  121. "longitude" => $longitude,
  122. "latitude" => $latitude,
  123. "qq" => $qq,
  124. "ww" => $ww,
  125. "email" => $email,
  126. "telephone" => $telephone,
  127. "work_week" => $work_week,
  128. "start_time" => $start_time,
  129. "end_time" => $end_time,
  130. "name" => $name,
  131. "mobile" => $mobile
  132. );
  133. $res = $shop_model->editShop($data, [ [ 'site_id', '=', $this->site_id ] ]);
  134. return $this->response($res);
  135. }
  136. }