Cert.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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 addon\shopwithdraw\model\Config as ShopWithdrawConfig;
  14. use app\model\shop\ShopApply;
  15. use app\model\shop\ShopGroup as ShopGroupModel;
  16. use app\model\system\Promotion as PromotionModel;
  17. use app\model\web\WebSite as WebsiteModel;
  18. use app\model\shop\Config as ShopConfigModel;
  19. use app\model\shop\Shop as ShopModel;
  20. use app\model\shop\ShopReopen as ShopReopenModel;
  21. use app\model\system\Address as AddressModel;
  22. /**
  23. * 快捷开店认证
  24. * Class Cert
  25. * @package app\shop\controller
  26. */
  27. class Cert extends BaseApi
  28. {
  29. public function __construct()
  30. {
  31. //执行父类构造函数
  32. parent::__construct();
  33. $token = $this->checkToken();
  34. if ($token[ 'code' ] < 0) {
  35. echo $this->response($token);
  36. exit;
  37. }
  38. }
  39. /**
  40. * 认证首页
  41. */
  42. public function index()
  43. {
  44. $shop_group_model = new ShopGroupModel();
  45. $promotion_model = new PromotionModel();
  46. //插件
  47. $promotions = $promotion_model->getPromotions();
  48. $promotions = $promotions[ 'shop' ];
  49. //店铺等级
  50. $shop_group = $shop_group_model->getGroupList([ [ 'is_own', '=', 0 ] ], '*', 'fee asc')[ 'data' ];
  51. foreach ($shop_group as $k => $v) {
  52. $addon_array = !empty($v[ 'addon_array' ]) ? explode(',', $v[ 'addon_array' ]) : [];
  53. foreach ($promotions as $key => &$promotion) {
  54. if (!empty($promotion[ 'is_developing' ])) {
  55. unset($promotions[ $key ]);
  56. continue;
  57. }
  58. $promotion[ 'is_checked' ] = 0;
  59. if (in_array($promotion[ 'name' ], $addon_array)) {
  60. $promotion[ 'is_checked' ] = 1;
  61. }
  62. $shop_group[ $k ][ 'promotion' ][] = $promotion;
  63. }
  64. array_multisort(array_column($shop_group[ $k ][ 'promotion' ], 'is_checked'), SORT_DESC, $shop_group[ $k ][ 'promotion' ]);
  65. }
  66. $data[ 'group_info' ] = $shop_group;
  67. //查询省级数据列表
  68. $address_model = new AddressModel();
  69. $list = $address_model->getAreaList([ [ "pid", "=", 0 ], [ "level", "=", 1 ] ]);
  70. $data[ 'province_list' ] = $list[ "data" ];
  71. $shop_apply_model = new ShopApply();
  72. $shop_apply_info = $shop_apply_model->getApplyDetail([ [ 'uid', '=', $this->uid ] ]);
  73. $data[ 'shop_apply_info' ] = $shop_apply_info[ 'data' ];
  74. //商家信息
  75. $shop_apply_model = new ShopModel();
  76. $shop = $shop_apply_model->getShopInfo([ [ 'site_id', '=', $this->site_id ] ], 'site_id,site_name,category_id,category_name');
  77. $data[ 'shop_info' ] = $shop[ 'data' ];
  78. //平台配置信息
  79. $website_model = new WebsiteModel();
  80. $website_info = $website_model->getWebSite([ [ 'site_id', '=', 0 ] ], 'web_qrcode,web_phone');
  81. $data[ 'website_info' ] = $website_info[ 'data' ];
  82. //收款信息
  83. $shop_config_model = new ShopConfigModel();
  84. $receivable_config = $shop_config_model->getSystemBankAccount();
  85. $data[ 'receivable_config' ] = $receivable_config[ 'data' ];
  86. $data[ 'support_transfer_type' ] = $this->getTransferType();
  87. return $this->response($this->success($data));
  88. }
  89. public function getTransferType()
  90. {
  91. $support_type = [];
  92. if (addon_is_exit("shopwithdraw")) {
  93. $config_model = new ShopWithdrawConfig();
  94. $config_result = $config_model->getConfig();
  95. $config = $config_result[ "data" ];
  96. if ($config[ "is_use" ]) {
  97. $support_type = explode(",", $config[ "value" ][ "transfer_type" ]);
  98. } else {
  99. $support_type = [ "alipay", "bank" ];
  100. }
  101. } else {
  102. $support_type = [ "alipay", "bank" ];
  103. }
  104. return $support_type;
  105. }
  106. /**
  107. * 申请续签
  108. */
  109. public function reopen()
  110. {
  111. if (request()->isPost()) {
  112. $site_id = $this->site_id;
  113. $reopen_data = [
  114. 'site_id' => $site_id,//店铺ID
  115. 'apply_year' => isset($this->params[ 'apply_year' ]) ? $this->params[ 'apply_year' ] : '',//入驻年长
  116. 'shop_group_name' => isset($this->params[ 'shop_group_name' ]) ? $this->params[ 'shop_group_name' ] : '',//开店套餐名称
  117. 'shop_group_id' => isset($this->params[ 'shop_group_id' ]) ? $this->params[ 'shop_group_id' ] : 0,//开店套餐id
  118. 'paying_money_certificate' => isset($this->params[ 'paying_money_certificate' ]) ? $this->params[ 'paying_money_certificate' ] : '',//支付凭证
  119. 'paying_money_certificate_explain' => isset($this->params[ 'paying_money_certificate_explain' ]) ? $this->params[ 'paying_money_certificate_explain' ] : '' //付款凭证说明
  120. ];
  121. $model = new ShopReopenModel();
  122. //计算入驻金额
  123. $apply_money = $model->getReopenMoney($reopen_data[ 'apply_year' ], $reopen_data[ 'shop_group_id' ]);
  124. $reopen_data[ 'paying_amount' ] = $apply_money[ 'data' ][ 'money' ];
  125. $result = $model->addReopen($reopen_data);
  126. return $this->response($result);
  127. } else {
  128. //获取店铺信息
  129. $condition[] = [ 'site_id', '=', $this->site_id ];
  130. $field = 'site_id,site_name,category_id,category_name,group_id,group_name';
  131. $shop_model = new ShopModel();
  132. $shop_info = $shop_model->getShopInfo($condition, $field);
  133. $data[ 'shop_info' ] = $shop_info[ 'data' ];
  134. $shop_group_model = new ShopGroupModel();
  135. $promotion_model = new PromotionModel();
  136. //插件
  137. $promotions = $promotion_model->getPromotions();
  138. $promotions = $promotions[ 'shop' ];
  139. //店铺等级
  140. $shop_group = $shop_group_model->getGroupList([ [ 'is_own', '=', 0 ] ], '*', 'fee asc');
  141. $shop_group = $shop_group[ 'data' ];
  142. foreach ($shop_group as $k => $v) {
  143. $addon_array = !empty($v[ 'addon_array' ]) ? explode(',', $v[ 'addon_array' ]) : [];
  144. foreach ($promotions as $key => &$promotion) {
  145. if (!empty($promotion[ 'is_developing' ])) {
  146. unset($promotions[ $key ]);
  147. continue;
  148. }
  149. $promotion[ 'is_checked' ] = 0;
  150. if (in_array($promotion[ 'name' ], $addon_array)) {
  151. $promotion[ 'is_checked' ] = 1;
  152. }
  153. $shop_group[ $k ][ 'promotion' ][] = $promotion;
  154. }
  155. array_multisort(array_column($shop_group[ $k ][ 'promotion' ], 'is_checked'), SORT_DESC, $shop_group[ $k ][ 'promotion' ]);
  156. }
  157. $data[ 'group_info' ] = $shop_group;
  158. //平台配置信息
  159. $website_model = new WebsiteModel();
  160. $website_info = $website_model->getWebSite([ [ 'site_id', '=', 0 ] ], 'web_qrcode,web_phone');
  161. $data[ 'website_info' ] = $website_info[ 'data' ];
  162. //收款信息
  163. $shop_config_model = new ShopConfigModel();
  164. $receivable_config = $shop_config_model->getSystemBankAccount();
  165. $data[ 'receivable_config' ] = $receivable_config[ 'data' ];
  166. return $this->response($this->success($data));
  167. }
  168. }
  169. /**
  170. * 编辑续签首页
  171. */
  172. public function editReopenInfo()
  173. {
  174. $reopen_model = new ShopReopenModel();
  175. if (request()->isPost()) {
  176. $site_id = $this->site_id;
  177. $reopen_data = [
  178. 'id' => isset($this->params[ 'id' ]) ? $this->params[ 'id' ] : '',
  179. 'site_id' => $site_id,//店铺ID
  180. 'paying_money_certificate' => isset($this->params[ 'paying_money_certificate' ]) ? $this->params[ 'paying_money_certificate' ] : '',//支付凭证
  181. 'paying_money_certificate_explain' => isset($this->params[ 'paying_money_certificate_explain' ]) ? $this->params[ 'paying_money_certificate_explain' ] : '' //付款凭证说明
  182. ];
  183. $result = $reopen_model->editReopen($reopen_data);
  184. return $this->response($result);
  185. } else {
  186. //获取店铺信息
  187. $condition[] = [ 'site_id', '=', $this->site_id ];
  188. $apply_model = new ShopModel();
  189. $field = 'site_id,site_name,category_id,category_name,group_id,group_name';
  190. $shop_info = $apply_model->getShopInfo($condition, $field);
  191. $data[ 'shop_info' ] = $shop_info[ 'data' ];
  192. $shop_group_model = new ShopGroupModel();
  193. $promotion_model = new PromotionModel();
  194. //插件
  195. $promotions = $promotion_model->getPromotions();
  196. $promotions = $promotions[ 'shop' ];
  197. //店铺等级
  198. $shop_group = $shop_group_model->getGroupList([ [ 'is_own', '=', 0 ] ], '*', 'fee asc')[ 'data' ];
  199. foreach ($shop_group as $k => $v) {
  200. $addon_array = !empty($v[ 'addon_array' ]) ? explode(',', $v[ 'addon_array' ]) : [];
  201. foreach ($promotions as $key => &$promotion) {
  202. if (!empty($promotion[ 'is_developing' ])) {
  203. unset($promotions[ $key ]);
  204. continue;
  205. }
  206. $promotion[ 'is_checked' ] = 0;
  207. if (in_array($promotion[ 'name' ], $addon_array)) {
  208. $promotion[ 'is_checked' ] = 1;
  209. }
  210. $shop_group[ $k ][ 'promotion' ][] = $promotion;
  211. }
  212. array_multisort(array_column($shop_group[ $k ][ 'promotion' ], 'is_checked'), SORT_DESC, $shop_group[ $k ][ 'promotion' ]);
  213. }
  214. $data[ 'group_info' ] = $shop_group;
  215. //平台配置信息
  216. $website_model = new WebsiteModel();
  217. $website_info = $website_model->getWebSite([ [ 'site_id', '=', 0 ] ], 'web_qrcode,web_phone');
  218. $data[ 'website_info' ] = $website_info[ 'data' ];
  219. //收款信息
  220. $shop_config_model = new ShopConfigModel();
  221. $receivable_config = $shop_config_model->getSystemBankAccount();
  222. $data[ 'receivable_config' ] = $receivable_config[ 'data' ];
  223. //获取续签信息
  224. $reopen_info = $reopen_model->getReopenInfo([ [ 'sr.apply_state', 'in', '-1,1' ], [ 'sr.site_id', '=', $this->site_id ] ], '*');
  225. $data[ 'reopen_info' ] = $reopen_info[ 'data' ];
  226. return $this->response($this->success($data));
  227. }
  228. }
  229. }