request->isGet()) { $shopId = $this->request->get('shop_id', '', 'trim'); $validate = Validate::rule('shop_id', 'require|integer|gt:0'); if(!$validate->check(['shop_id'=>$shopId])) { return JsonServer::error($validate->getError()); } $data = ShopContentLogic::getShopInfo($shopId, $this->user_id, input()); return JsonServer::success('获取店铺信息成功', $data); }else{ return JsonServer::error('请求类型错误'); } } /** * 店铺列表 */ public function getShopList() { if($this->request->isGet()) { $get = $this->request->get(); $get['page_no'] = $this->page_no; $get['page_size'] = $this->page_size; $data = ShopContentLogic::getShopList($get); return JsonServer::success('获取店铺列表成功', $data); }else{ return JsonServer::error('请求类型错误'); } } /** * @notes 附近店铺列表 * @return \think\response\Json * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author ljj * @date 2022/9/20 4:29 下午 */ public function getNearbyShops() { if($this->request->isGet()) { $get = $this->request->get(); $get['page_no'] = $this->page_no; $get['page_size'] = $this->page_size; $data = ShopContentLogic::getNearbyShops($get); return JsonServer::success('获取店铺列表成功', $data); }else{ return JsonServer::error('请求类型错误'); } } /* * 验证秘钥 * */ public function smsCode(){ $code = request()->param('code'); $code = trim($code); $mcode = request()->param('mcode'); $mcode = trim($mcode); //查询 $data = ShopContentLogic::codeInfo($code,$mcode); if($data['status'] == 100){ //通过 $respon = []; return JsonServer::success($data['msg'], $respon); }else{ //失败 return JsonServer::error('请求类型错误-'.$data['msg']); } } /* * 获取配置 * 拼接默认配置 + 设备配置 * 需要加密 * https://api.zx2049.com/api/shopContent/getShopConfig?code=7729c5e9779d9eb37c75a2715e332b29 */ public function getShopConfig(){ //判断是否存在默认配置 $code = request()->param('code'); //秘钥 $data = ShopContentLogic::getComputer($code); //var_dump($data); if($data['status'] !== 100){ //失败 直接报错 return JsonServer::error('请求错误-'.$data['msg']); }else{ $json_data = []; //通过 电脑设备信息 获取手机配置 $default_config = ShopContentLogic::getDefaultMobile($data['item']); if($default_config['status'] !== 100){ return JsonServer::error('请求错误-'.$default_config['msg']); } //通过 电脑设备信息 获取手机信息 $mobile_list = ShopContentLogic::getMobile($data['item']); if($mobile_list['status'] !== 100){ return JsonServer::error('请求错误-'.$mobile_list['msg']); } //存在手机设备 if(isset($mobile_list['ids'])){ //dump($mobile_list);die; //var_dump($mobile_list['ids']);die; //通过配置id 获取具体的配置 $json_data = ShopContentLogic::getMobileConfig($mobile_list['data'],$mobile_list['ids'],$mobile_list['ver']); } //直接使用默认配置 $json_data['default'] = $default_config['data']; //data 针对 $key = 'ABCDEFGHIJKLMNOP'; //16位 $vi = '0102030405060708'; //16位 $str = json_encode($json_data,JSON_UNESCAPED_UNICODE); //讲数组转为字符串 $sign = openssl_encrypt($str, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $vi); $sign = base64_encode($sign); //先跳过加密 $res = [ 'data' => $json_data ]; return JsonServer::success($data['msg'], $res); } } /* * 加密数据的接口 * https://api.zx2049.com/api/shopContent/getShopConfig2?code=7729c5e9779d9eb37c75a2715e332b29 */ public function getShopConfig2(){ //判断是否存在默认配置 $code = request()->param('code'); //秘钥 $data = ShopContentLogic::getComputer($code); //var_dump($data); if($data['status'] !== 100){ //失败 直接报错 return JsonServer::error('请求错误-'.$data['msg']); }else{ $json_data = []; //通过 电脑设备信息 获取手机配置 $default_config = ShopContentLogic::getDefaultMobile($data['item']); if($default_config['status'] !== 100){ return JsonServer::error('请求错误-'.$default_config['msg']); } //通过 电脑设备信息 获取手机信息 $mobile_list = ShopContentLogic::getMobile($data['item']); if($mobile_list['status'] !== 100){ return JsonServer::error('请求错误-'.$mobile_list['msg']); } //存在手机设备 if(isset($mobile_list['ids'])){ //dump($mobile_list);die; //var_dump($mobile_list['ids']);die; //通过配置id 获取具体的配置 $json_data = ShopContentLogic::getMobileConfig($mobile_list['data'],$mobile_list['ids'],$mobile_list['ver']); } //直接使用默认配置 $json_data['default'] = $default_config['data']; //data 针对 $key = 'ABCDEFGHIJKLMNOP'; //16位 $vi = '0102030405060708'; //16位 $str = json_encode($json_data,JSON_UNESCAPED_UNICODE); //讲数组转为字符串 $sign = openssl_encrypt($str, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $vi); $sign = base64_encode($sign); //先跳过加密 $res = [ 'data' => $sign ]; return JsonServer::success($data['msg'], $res); } } /* * xpath规则维护 * 无需加密 获取到页无用 * https://api.zx2049.com/api/shopContent/getXpath?app=xhs */ public function getXpath(){ $app = request()->param('app'); //应用类型 //$ver = request()->param('ver'); //小红书定义版本号 $ver_code = [ "xhs" => [ 'default' => [ 'appuim' => ShopContentLogic::getXhsDefaultAppuim(), 'u2' => ShopContentLogic::getXhsDefaultU2() ], "v.8.68.5.5684ad5" => [ 'appuim' => ShopContentLogic::getXhsAppuim_1(), 'u2' => ShopContentLogic::getXhsU2_1() ] ] ]; if(isset($ver_code[$app])){ return JsonServer::success('ok', $ver_code[$app]); }else{ return JsonServer::success('default', []); } } /** * 获取钉钉消息 已加密 * http://shop.zx10000.com/api/shopcontent/getAppService */ public function getAppService() { //先获取商家id $code = request()->param('code'); //秘钥 if(empty($code)){ return JsonServer::error('code不能为空'); } $data = ShopContentLogic::getComputer($code); $data = $data['item']; $shop_id = $data['shop_id']; if((int)$shop_id > 0){ $config = [ "dingding_url" => ConfigServer::get('shop_app_service', 'dingding_url', '',$shop_id), "dingding_pass" => ConfigServer::get('shop_app_service', 'dingding_pass', '',$shop_id), "dingding_user" => ConfigServer::get('shop_app_service', 'dingding_user', '',$shop_id) ]; $key = 'ABCDEFGHIJKLMNOP'; //16位 $vi = '0102030405060708'; //16位 $str = json_encode($config,JSON_UNESCAPED_UNICODE); $sign = openssl_encrypt($str, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $vi); $sign = base64_encode($sign); $res = [ 'data' => $config ]; //var_dump($sign);die(); return JsonServer::success('', $res); }else{ //报错 return JsonServer::error('商户ID查找错误'); } } /* * 通过 code 获取 可同时运行数量 * https://api.zx2049.com/api/shopContent/getRunNum?code=7729c5e9779d9eb37c75a2715e332b29 */ public function getRunNum() { $code = request()->param('code'); //��钥 $data = ShopContentLogic::getComputer($code); $data = $data['item']; $shop_id = $data['shop_id']; if((int)$shop_id > 0){ //读取商家配置 $tid = shopModel::where('id', $data['shop_id'])->value('tid'); if ((int)$tid === 0) { //未配置 $count_pc = 1; $count_mobile = 3; $count_run = 3; } else if ((int)$tid > 0) { //查找配置 $one = shopGoodsModel::where('id', $tid)->find(); $count_pc = $one['pc_num']; $count_mobile = $one['mobile_num']; $count_run = $one['run_num']; } else { //其他 $count_pc = 1; $count_mobile = 3; $count_run = 3; } return JsonServer::success('', ['run_num' => $count_run]); }else{ //报错 return JsonServer::error('商户ID查找错误'); } } /** * 查询获客剩余数量 */ public function getHKSYCount() { if ($this->request->isGet()) { $get = $this->request->get(); $data = ShopContentLogic::getHKSYCount($get); if ($data === false) { return JsonServer::error(ShopContentLogic::getError(), ['err_code' => ShopContentLogic::getErrCode()]); } return JsonServer::success('', $data); } return JsonServer::error('请求方式错误', ['err_code' => 10001]); } /** * 减少获客剩余数量 */ public function subHKSYCount() { if ($this->request->isPost()) { $post = $this->request->post(); $count = ShopContentLogic::subHKSYCount($post); if ($count === false) { return JsonServer::error(ShopContentLogic::getError(), ['err_code' => ShopContentLogic::getErrCode()]); } return JsonServer::success('操作成功', ['count' => $count]); } return JsonServer::error('请求方式错误', ['err_code' => 10001]); } }