截流自动化的商城平台
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\api\controller;
  20. use app\common\basics\Api;
  21. use app\common\model\shop\ShopGoods as shopGoodsModel;
  22. use app\common\model\shop\shop as shopModel;
  23. use app\common\server\ConfigServer;
  24. use app\common\server\JsonServer;
  25. use think\facade\Validate;
  26. use app\api\logic\ShopContentLogic;
  27. class ShopContent extends Api
  28. {
  29. public $like_not_need_login = ['getShopInfo', 'getShopList','getNearbyShops','smsCode','getShopConfig','getXpath','getAppService','getRunNum'];
  30. /**
  31. * 店铺信息
  32. */
  33. public function getShopInfo()
  34. {
  35. if($this->request->isGet()) {
  36. $shopId = $this->request->get('shop_id', '', 'trim');
  37. $validate = Validate::rule('shop_id', 'require|integer|gt:0');
  38. if(!$validate->check(['shop_id'=>$shopId])) {
  39. return JsonServer::error($validate->getError());
  40. }
  41. $data = ShopContentLogic::getShopInfo($shopId, $this->user_id, input());
  42. return JsonServer::success('获取店铺信息成功', $data);
  43. }else{
  44. return JsonServer::error('请求类型错误');
  45. }
  46. }
  47. /**
  48. * 店铺列表
  49. */
  50. public function getShopList()
  51. {
  52. if($this->request->isGet()) {
  53. $get = $this->request->get();
  54. $get['page_no'] = $this->page_no;
  55. $get['page_size'] = $this->page_size;
  56. $data = ShopContentLogic::getShopList($get);
  57. return JsonServer::success('获取店铺列表成功', $data);
  58. }else{
  59. return JsonServer::error('请求类型错误');
  60. }
  61. }
  62. /**
  63. * @notes 附近店铺列表
  64. * @return \think\response\Json
  65. * @throws \think\db\exception\DataNotFoundException
  66. * @throws \think\db\exception\DbException
  67. * @throws \think\db\exception\ModelNotFoundException
  68. * @author ljj
  69. * @date 2022/9/20 4:29 下午
  70. */
  71. public function getNearbyShops()
  72. {
  73. if($this->request->isGet()) {
  74. $get = $this->request->get();
  75. $get['page_no'] = $this->page_no;
  76. $get['page_size'] = $this->page_size;
  77. $data = ShopContentLogic::getNearbyShops($get);
  78. return JsonServer::success('获取店铺列表成功', $data);
  79. }else{
  80. return JsonServer::error('请求类型错误');
  81. }
  82. }
  83. /*
  84. * 验证秘钥
  85. *
  86. */
  87. public function smsCode(){
  88. $code = request()->param('code');
  89. $code = trim($code);
  90. $mcode = request()->param('mcode');
  91. $mcode = trim($mcode);
  92. //查询
  93. $data = ShopContentLogic::codeInfo($code,$mcode);
  94. if($data['status'] == 100){
  95. //通过
  96. $respon = [];
  97. return JsonServer::success($data['msg'], $respon);
  98. }else{
  99. //失败
  100. return JsonServer::error('请求类型错误-'.$data['msg']);
  101. }
  102. }
  103. /*
  104. * 获取配置
  105. * 拼接默认配置 + 设备配置
  106. * 需要加密
  107. */
  108. public function getShopConfig(){
  109. //判断是否存在默认配置
  110. $code = request()->param('code'); //秘钥
  111. $data = ShopContentLogic::getComputer($code);
  112. //var_dump($data);
  113. if($data['status'] !== 100){
  114. //失败 直接报错
  115. return JsonServer::error('请求错误-'.$data['msg']);
  116. }else{
  117. $json_data = [];
  118. //通过 电脑设备信息 获取手机配置
  119. $default_config = ShopContentLogic::getDefaultMobile($data['item']);
  120. if($default_config['status'] !== 100){
  121. return JsonServer::error('请求错误-'.$default_config['msg']);
  122. }
  123. //通过 电脑设备信息 获取手机信息
  124. $mobile_list = ShopContentLogic::getMobile($data['item']);
  125. if($mobile_list['status'] !== 100){
  126. return JsonServer::error('请求错误-'.$mobile_list['msg']);
  127. }
  128. //存在手机设备
  129. if(isset($mobile_list['ids'])){
  130. //通过配置id 获取具体的配置
  131. $json_data = ShopContentLogic::getMobileConfig($mobile_list['data'],$mobile_list['ids'],$mobile_list['ver']);
  132. }
  133. //直接使用默认配置
  134. $json_data['default'] = $default_config['data'];
  135. //data 针对
  136. $key = 'ABCDEFGHIJKLMNOP'; //16位
  137. $vi = '0102030405060708'; //16位
  138. $str = json_encode($json_data,JSON_UNESCAPED_UNICODE); //讲数组转为字符串
  139. $sign = openssl_encrypt($str, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $vi);
  140. $sign = base64_encode($sign);
  141. $res = [
  142. 'data' => $sign
  143. ];
  144. return JsonServer::success($data['msg'], $res);
  145. }
  146. }
  147. /*
  148. * xpath规则维护
  149. * 无需加密 获取到页无用
  150. */
  151. public function getXpath(){
  152. $app = request()->param('app'); //应用类型
  153. //$ver = request()->param('ver');
  154. //小红书定义版本号
  155. $ver_code = [
  156. "xhs" => [
  157. 'default' => [
  158. 'appuim' => ShopContentLogic::getXhsDefaultAppuim(),
  159. 'u2' => ShopContentLogic::getXhsDefaultU2()
  160. ],
  161. "v.8.68.5.5684ad5" => [
  162. 'appuim' => ShopContentLogic::getXhsAppuim_1(),
  163. 'u2' => ShopContentLogic::getXhsU2_1()
  164. ]
  165. ]
  166. ];
  167. if(isset($ver_code[$app])){
  168. return JsonServer::success('ok', $ver_code[$app]);
  169. }else{
  170. return JsonServer::success('default', []);
  171. }
  172. }
  173. /**
  174. * 获取钉钉消息 已加密
  175. * http://shop.zx10000.com/api/shopcontent/getAppService
  176. */
  177. public function getAppService()
  178. {
  179. //先获取商家id
  180. $code = request()->param('code'); //秘钥
  181. if(empty($code)){
  182. return JsonServer::error('code不能为空');
  183. }
  184. $data = ShopContentLogic::getComputer($code);
  185. $data = $data['item'];
  186. $shop_id = $data['shop_id'];
  187. if((int)$shop_id > 0){
  188. $config = [
  189. 'dingding_url' => ConfigServer::get('shop_app_service', 'dingding_url', '',$shop_id),
  190. 'dingding_pass' => ConfigServer::get('shop_app_service', 'dingding_pass', '',$shop_id),
  191. 'dingding_user' => ConfigServer::get('shop_app_service', 'dingding_user', '',$shop_id),
  192. ];
  193. $key = 'ABCDEFGHIJKLMNOP'; //16位
  194. $vi = '0102030405060708'; //16位
  195. $str = json_encode($config,JSON_UNESCAPED_UNICODE);
  196. $sign = openssl_encrypt($str, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $vi);
  197. $sign = base64_encode($sign);
  198. $res = [
  199. 'data' => $sign
  200. ];
  201. //var_dump($sign);die();
  202. return JsonServer::success('', $res);
  203. }else{
  204. //报错
  205. return JsonServer::error('商户ID查找错误');
  206. }
  207. }
  208. /*
  209. * 通过 code 获取 可同时运行数量
  210. * http://shop.zx10000.com/api/shopcontent/getRunNum
  211. */
  212. public function getRunNum()
  213. {
  214. $code = request()->param('code'); //��钥
  215. $data = ShopContentLogic::getComputer($code);
  216. $data = $data['item'];
  217. $shop_id = $data['shop_id'];
  218. if((int)$shop_id > 0){
  219. //读取商家配置
  220. $tid = shopModel::where('id', $data['shop_id'])->value('tid');
  221. if ((int)$tid === 0) {
  222. //未配置
  223. $count_pc = 1;
  224. $count_mobile = 3;
  225. $count_run = 3;
  226. } else if ((int)$tid > 0) {
  227. //查找配置
  228. $one = shopGoodsModel::where('id', $tid)->find();
  229. $count_pc = $one['pc_num'];
  230. $count_mobile = $one['mobile_num'];
  231. $count_run = $one['run_num'];
  232. } else {
  233. //其他
  234. $count_pc = 1;
  235. $count_mobile = 3;
  236. $count_run = 3;
  237. }
  238. return JsonServer::success('', ['run_num' => $count_run]);
  239. }else{
  240. //报错
  241. return JsonServer::error('商户ID查找错误');
  242. }
  243. }
  244. /*
  245. *
  246. */
  247. }