Store.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\store\storeapi\controller;
  11. use addon\store\model\Category;
  12. use addon\store\model\Label;
  13. use app\model\express\Local as LocalModel;
  14. use app\model\store\Store as StoreModel;
  15. use app\storeapi\controller\BaseStoreApi;
  16. use addon\store\model\Config;
  17. /**
  18. * 门店控制器
  19. */
  20. class Store extends BaseStoreApi
  21. {
  22. /**
  23. * 获取门店信息
  24. * @return false|string
  25. * @throws \app\exception\ApiException
  26. */
  27. public function info()
  28. {
  29. $store_model = new StoreModel();
  30. $store_info = $store_model->getStoreDetail([ [ 'store_id', '=', $this->store_id ] ]);
  31. return $this->response($store_info);
  32. }
  33. /**
  34. * 门店修改
  35. */
  36. public function edit()
  37. {
  38. $condition = array (
  39. [ "site_id", "=", $this->site_id ],
  40. [ "store_id", "=", $this->store_id ]
  41. );
  42. $store_model = new StoreModel();
  43. $store_name = $this->params[ 'store_name' ] ?? '';
  44. $telphone = $this->params[ 'telphone' ] ?? '';
  45. $store_image = $this->params[ 'store_image' ] ?? '';
  46. $status = $this->params[ 'status' ] ?? 0;
  47. $province_id = $this->params[ 'province_id' ] ?? 0;
  48. $city_id = $this->params[ 'city_id' ] ?? 0;
  49. $district_id = $this->params[ 'district_id' ] ?? 0;
  50. $community_id = $this->params[ 'community_id' ] ?? 0;
  51. $address = $this->params[ 'address' ] ?? '';
  52. $full_address = $this->params[ 'full_address' ] ?? '';
  53. $longitude = $this->params[ 'longitude' ] ?? 0;
  54. $latitude = $this->params[ 'latitude' ] ?? 0;
  55. $open_date = $this->params[ 'open_date' ] ?? '';
  56. $start_time = $this->params[ 'start_time' ] ?? 0;
  57. $end_time = $this->params[ 'end_time' ] ?? 0;
  58. $time_type = $this->params[ 'time_type' ] ?? 0;
  59. $time_week = $this->params[ 'time_week' ] ?? '';
  60. $store_type = $this->params[ 'store_type' ] ?? '';
  61. $support_trade_type = $this->params[ 'support_trade_type' ] ?? '';
  62. $stock_type = $this->params[ 'stock_type' ] ?? '';
  63. $data = array (
  64. "store_name" => $store_name,
  65. "telphone" => $telphone,
  66. "store_image" => $store_image,
  67. "status" => $status,
  68. "province_id" => $province_id,
  69. "city_id" => $city_id,
  70. "district_id" => $district_id,
  71. "community_id" => $community_id,
  72. "address" => $address,
  73. "full_address" => $full_address,
  74. "longitude" => $longitude,
  75. "latitude" => $latitude,
  76. "open_date" => $open_date,
  77. 'start_time' => $start_time,
  78. 'end_time' => $end_time,
  79. 'time_type' => $time_type,
  80. 'time_week' => $time_week,
  81. 'support_trade_type' => $support_trade_type,
  82. 'stock_type' => $stock_type,
  83. 'category_id' => $this->params[ 'category_id' ] ?? 0,
  84. 'category_name' => $this->params[ 'category_name' ] ?? '',
  85. 'label_id' => $this->params[ 'label_id' ] ?? '',
  86. 'label_name' => $this->params[ 'label_name' ] ?? '',
  87. 'time_interval' => $this->params[ 'time_interval' ] ?? 30,
  88. 'delivery_time' => $this->params[ 'delivery_time' ] ?? '',
  89. 'advance_day' => input('advance_day', 0),
  90. 'most_day' => input('most_day', 7),
  91. 'store_type' => $store_type
  92. );
  93. $result = $store_model->editStore($data, $condition, [], 1, 1);
  94. return $this->response($result);
  95. }
  96. /**
  97. * 同城配送详情
  98. * @return false|string
  99. */
  100. public function localInfo()
  101. {
  102. $local_model = new LocalModel();
  103. $local_result = $local_model->getLocalInfo([ [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $this->store_id ] ]);
  104. return $this->response($local_result);
  105. }
  106. /**
  107. * 同城配送修改
  108. * @return false|string
  109. */
  110. public function editLocal()
  111. {
  112. $data = [
  113. 'type' => $this->params[ 'type' ] ?? 'default',
  114. 'area_type' => $this->params[ 'area_type' ] ?? 1,
  115. 'local_area_json' => $this->params[ 'local_area_json' ] ?? '',//区域及业务集合json
  116. 'time_is_open' => $this->params[ 'time_is_open' ] ?? 0,
  117. 'time_type' => $this->params[ 'time_type' ] ?? 0,//时间选取类型 0 全天 1 自定义
  118. 'time_week' => $this->params[ 'time_week' ] ?? '',
  119. 'start_time' => $this->params[ 'start_time' ] ?? 0,
  120. 'end_time' => $this->params[ 'end_time' ] ?? 0,
  121. 'update_time' => time(),
  122. 'is_open_step' => $this->params[ 'is_open_step' ] ?? 0,
  123. 'start_distance' => $this->params[ 'start_distance' ] ?? 0,
  124. 'start_delivery_money' => $this->params[ 'start_delivery_money' ] ?? 0,
  125. 'continued_distance' => $this->params[ 'continued_distance' ] ?? 0,
  126. 'continued_delivery_money' => $this->params[ 'continued_delivery_money' ] ?? 0,
  127. 'start_money' => $this->params[ 'start_money' ] ?? 0,
  128. 'delivery_money' => $this->params[ 'delivery_money' ] ?? 0,
  129. 'area_array' => $this->params[ 'area_array' ] ?? '',//地域集合
  130. 'man_money' => $this->params[ 'man_money' ] ?? '',
  131. 'man_type' => $this->params[ 'man_type' ] ?? '',
  132. 'man_discount' => $this->params[ 'man_discount' ] ?? '',
  133. 'time_interval' => $this->params[ 'time_interval' ] ?? 30,
  134. 'delivery_time' => $this->params[ 'delivery_time' ] ?? '',
  135. 'advance_day' => input('advance_day', 0),
  136. 'most_day' => input('most_day', 7)
  137. ];
  138. $condition = array (
  139. [ 'site_id', '=', $this->site_id ],
  140. [ 'store_id', '=', $this->store_id ],
  141. );
  142. $local_model = new LocalModel();
  143. $res = $local_model->editLocal($data, $condition);
  144. return $this->response($res);
  145. }
  146. /**
  147. * 门店标签
  148. */
  149. public function label()
  150. {
  151. $label_list = ( new Label() )->getStoreLabelList([ [ 'site_id', '=', $this->site_id ] ], 'label_id,label_name');
  152. return $this->response($label_list);
  153. }
  154. /**
  155. * 门点分类
  156. * @return false|string
  157. */
  158. public function category()
  159. {
  160. $category = new Category();
  161. $category_config = $category->getCategoryConfig($this->site_id)[ 'data' ][ 'value' ];
  162. $category_list = $category->getStoreCategoryList([ [ 'site_id', '=', $this->site_id ] ], 'category_id,category_name')[ 'data' ];
  163. return $this->response($this->success([
  164. 'status' => $category_config[ 'status' ],
  165. 'list' => $category_list
  166. ]));
  167. }
  168. /**
  169. * 提现配置
  170. * @return false|string
  171. */
  172. public function withdrawConfig()
  173. {
  174. $config = ( new Config() )->getStoreWithdrawConfig($this->site_id)[ 'data' ][ 'value' ];
  175. return $this->response($this->success($config));
  176. }
  177. }