123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\api\controller;
-
- use app\common\basics\Api;
-
- use app\common\model\shop\ShopGoods as shopGoodsModel;
- use app\common\model\shop\Shop as shopModel;
-
- use app\common\server\ConfigServer;
- use app\common\server\JsonServer;
- use think\facade\Validate;
-
- use app\api\logic\ShopContentLogic;
-
-
- class ShopContent extends Api
- {
- public $like_not_need_login = ['getShopInfo', 'getShopList','getNearbyShops','smsCode','getShopConfig','getXpath','getAppService','getRunNum','getShopConfig2','subHKSYCount'];
-
-
-
- public function getShopInfo()
- {
- if($this->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('请求类型错误');
- }
- }
-
-
-
-
- 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 = [
- 'is_gi' => $data['is_gi'],
- 'count' => $data['count']
- ];
- return JsonServer::success($data['msg'], $respon);
- }else{
-
- return JsonServer::error('请求类型错误-'.$data['msg']);
- }
- }
-
-
-
- public function getShopConfig(){
-
- $code = request()->param('code');
- $data = ShopContentLogic::getComputer($code);
-
-
-
- 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'])){
-
-
-
- $json_data = ShopContentLogic::getMobileConfig($mobile_list['data'],$mobile_list['ids'],$mobile_list['ver']);
- }
-
- $json_data['default'] = $default_config['data'];
-
-
- $key = 'ABCDEFGHIJKLMNOP';
- $vi = '0102030405060708';
- $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);
- }
- }
-
-
-
-
- public function getShopConfig2(){
-
- $code = request()->param('code');
- $data = ShopContentLogic::getComputer($code);
-
-
-
- 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'])){
-
-
-
- $json_data = ShopContentLogic::getMobileConfig($mobile_list['data'],$mobile_list['ids'],$mobile_list['ver']);
- }
-
- $json_data['default'] = $default_config['data'];
-
-
- $key = 'ABCDEFGHIJKLMNOP';
- $vi = '0102030405060708';
- $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);
- }
- }
-
-
-
-
- public function getXpath(){
-
- $app = request()->param('app');
-
-
-
- $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', []);
- }
- }
-
-
-
-
-
-
-
-
- public function getAppService()
- {
-
-
-
- $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';
- $vi = '0102030405060708';
- $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
- ];
-
-
- return JsonServer::success('', $res);
- }else{
-
- return JsonServer::error('商户ID查找错误');
- }
- }
-
-
-
-
- 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]);
- }
- }
|