小程序接口
This commit is contained in:
parent
247b6196bc
commit
7222c14d62
@ -57,6 +57,7 @@ use AlibabaCloud\Tea\Utils\Utils;
|
|||||||
use Darabonba\OpenApi\Models\Config;
|
use Darabonba\OpenApi\Models\Config;
|
||||||
use AlibabaCloud\SDK\Ocr\V20191230\Models\RecognizeBusinessLicenseRequest;
|
use AlibabaCloud\SDK\Ocr\V20191230\Models\RecognizeBusinessLicenseRequest;
|
||||||
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
|
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Common
|
* Class Common
|
||||||
* @package app\controller\api
|
* @package app\controller\api
|
||||||
@ -110,7 +111,7 @@ class Common extends BaseController
|
|||||||
|
|
||||||
public function config()
|
public function config()
|
||||||
{
|
{
|
||||||
$config = systemConfig(['open_update_info', 'store_street_theme', 'is_open_service', 'is_phone_login', 'global_theme', 'integral_status', 'mer_location', 'alipay_open', 'hide_mer_status', 'mer_intention_open', 'share_info', 'share_title', 'share_pic', 'store_user_min_recharge', 'recharge_switch', 'balance_func_status', 'yue_pay_status', 'site_logo', 'routine_logo', 'site_name', 'login_logo', 'procudt_increase_status', 'sys_extension_type', 'member_status', 'copy_command_status', 'community_status','community_reply_status','community_app_switch', 'withdraw_type', 'recommend_switch', 'member_interests_status', 'beian_sn', 'community_reply_auth','hot_ranking_switch','svip_switch_status','margin_ico','margin_ico_switch']);
|
$config = systemConfig(['open_update_info', 'store_street_theme', 'is_open_service', 'is_phone_login', 'global_theme', 'integral_status', 'mer_location', 'alipay_open', 'hide_mer_status', 'mer_intention_open', 'share_info', 'share_title', 'share_pic', 'store_user_min_recharge', 'recharge_switch', 'balance_func_status', 'yue_pay_status', 'site_logo', 'routine_logo', 'site_name', 'login_logo', 'procudt_increase_status', 'sys_extension_type', 'member_status', 'copy_command_status', 'community_status', 'community_reply_status', 'community_app_switch', 'withdraw_type', 'recommend_switch', 'member_interests_status', 'beian_sn', 'community_reply_auth', 'hot_ranking_switch', 'svip_switch_status', 'margin_ico', 'margin_ico_switch']);
|
||||||
$make = app()->make(TemplateMessageRepository::class);
|
$make = app()->make(TemplateMessageRepository::class);
|
||||||
|
|
||||||
$cache = app()->make(CacheRepository::class)->search(['copyright_status', 'copyright_context', 'copyright_image', 'sys_intention_agree']);
|
$cache = app()->make(CacheRepository::class)->search(['copyright_status', 'copyright_context', 'copyright_image', 'sys_intention_agree']);
|
||||||
@ -191,7 +192,7 @@ class Common extends BaseController
|
|||||||
public function wechatNotify()
|
public function wechatNotify()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if($this->request->header('content-type') === 'application/json'){
|
if ($this->request->header('content-type') === 'application/json') {
|
||||||
return response(WechatService::create()->handleNotifyV3()->getContent());
|
return response(WechatService::create()->handleNotifyV3()->getContent());
|
||||||
}
|
}
|
||||||
return response(WechatService::create()->handleNotify()->getContent());
|
return response(WechatService::create()->handleNotify()->getContent());
|
||||||
@ -231,12 +232,12 @@ class Common extends BaseController
|
|||||||
public function routineNotify()
|
public function routineNotify()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if($this->request->header('content-type') === 'application/json'){
|
if ($this->request->header('content-type') === 'application/json') {
|
||||||
return response(MiniProgramService::create()->handleNotifyV3()->getContent());
|
return response(MiniProgramService::create()->handleNotifyV3()->getContent());
|
||||||
}
|
}
|
||||||
return response(MiniProgramService::create()->handleNotify()->getContent());
|
return response(MiniProgramService::create()->handleNotify()->getContent());
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::info('支付回调失败:' . var_export([$e->getMessage(), $e->getFile() . ':' . $e->getLine(),$this->request->header()], true));
|
Log::info('支付回调失败:' . var_export([$e->getMessage(), $e->getFile() . ':' . $e->getLine(), $this->request->header()], true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,9 +478,9 @@ class Common extends BaseController
|
|||||||
if ($user && $user['wechat_user_id']) {
|
if ($user && $user['wechat_user_id']) {
|
||||||
$wechatUserService = app()->make(WechatUserRepository::class);
|
$wechatUserService = app()->make(WechatUserRepository::class);
|
||||||
$subscribe = $wechatUserService->getWhereCount([
|
$subscribe = $wechatUserService->getWhereCount([
|
||||||
'wechat_user_id' => $user['wechat_user_id'],
|
'wechat_user_id' => $user['wechat_user_id'],
|
||||||
'subscribe' => 1
|
'subscribe' => 1
|
||||||
]) > 0;
|
]) > 0;
|
||||||
return app('json')->success(['subscribe' => $subscribe]);
|
return app('json')->success(['subscribe' => $subscribe]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -487,36 +488,39 @@ class Common extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//区县数据
|
//区县数据
|
||||||
public function get_area($city_code){
|
public function get_area($city_code)
|
||||||
$select=Db::name('geo_area')->where('city_code',$city_code)->field('area_id id,area_code code,area_name name')->select();
|
{
|
||||||
|
$select = Db::name('geo_area')->where('city_code', $city_code)->field('area_id id,area_code code,area_name name')->select();
|
||||||
return app('json')->success($select);
|
return app('json')->success($select);
|
||||||
}
|
}
|
||||||
//街道 乡镇数据
|
//街道 乡镇数据
|
||||||
public function get_street($area_code){
|
public function get_street($area_code)
|
||||||
$select=Db::name('geo_street')->where('area_code',$area_code)->field('street_id id,street_code code,street_name name')->select();
|
{
|
||||||
$arr=$select?$select->toArray():[];
|
$select = Db::name('geo_street')->where('area_code', $area_code)->field('street_id id,street_code code,street_name name')->select();
|
||||||
foreach ($arr as $k=>$item){
|
$arr = $select ? $select->toArray() : [];
|
||||||
|
foreach ($arr as $k => $item) {
|
||||||
$first_char = mb_str_split($item['name']);
|
$first_char = mb_str_split($item['name']);
|
||||||
if($first_char[0]){
|
if ($first_char[0]) {
|
||||||
$pinyin=new Pinyin();
|
$pinyin = new Pinyin();
|
||||||
$string=$first_char[0];
|
$string = $first_char[0];
|
||||||
$pinyin = $pinyin->abbr($string);
|
$pinyin = $pinyin->abbr($string);
|
||||||
$arr[$k]['pinyin']=$pinyin;
|
$arr[$k]['pinyin'] = $pinyin;
|
||||||
}else{
|
} else {
|
||||||
$arr[$k]['pinyin']='';
|
$arr[$k]['pinyin'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return app('json')->success($arr);
|
return app('json')->success($arr);
|
||||||
}
|
}
|
||||||
//村数据
|
//村数据
|
||||||
public function get_village($street_code){
|
public function get_village($street_code)
|
||||||
$select=Db::name('geo_village')->where('street_code',$street_code)->field('village_id id,village_code code,village_name name')->select();
|
{
|
||||||
|
$select = Db::name('geo_village')->where('street_code', $street_code)->field('village_id id,village_code code,village_name name')->select();
|
||||||
return app('json')->success($select);
|
return app('json')->success($select);
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取云店铺
|
//获取云店铺
|
||||||
public function get_cloud_shop($street_code){
|
public function get_cloud_shop($street_code)
|
||||||
|
{
|
||||||
//更新查询镇级供应链店铺
|
//更新查询镇级供应链店铺
|
||||||
// $typeTownSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeTownSupplyChain'])->value('mer_type_id');
|
// $typeTownSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeTownSupplyChain'])->value('mer_type_id');
|
||||||
/*
|
/*
|
||||||
@ -529,34 +533,35 @@ class Common extends BaseController
|
|||||||
->join('merchant_category c','m.category_id=c.merchant_category_id')
|
->join('merchant_category c','m.category_id=c.merchant_category_id')
|
||||||
->field('m.mer_id,category_id,category_name,c.background,c.cover,c.description')->select();
|
->field('m.mer_id,category_id,category_name,c.background,c.cover,c.description')->select();
|
||||||
*/
|
*/
|
||||||
$find=DB::name('merchant_category')
|
$find = DB::name('merchant_category')
|
||||||
->where('cover', '<>' ,'')
|
->where('cover', '<>', '')
|
||||||
->field('merchant_category_id as category_id,category_name,background,cover,description')->select();
|
->field('merchant_category_id as category_id,category_name,background,cover,description')->select();
|
||||||
return app('json')->success($find??[]);
|
return app('json')->success($find ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询组合数据
|
* 查询组合数据
|
||||||
*/
|
*/
|
||||||
public function system_group_value($name){
|
public function system_group_value($name)
|
||||||
$group_id= Db::name('system_group')->where('group_key',$name)->value('group_id');
|
{
|
||||||
$data=[];
|
$group_id = Db::name('system_group')->where('group_key', $name)->value('group_id');
|
||||||
if($group_id){
|
$data = [];
|
||||||
$select=Db::name('system_group_data')->where('group_id',$group_id)
|
if ($group_id) {
|
||||||
->limit(100)->select();
|
$select = Db::name('system_group_data')->where('group_id', $group_id)
|
||||||
foreach($select as $k=>$v){
|
->limit(100)->select();
|
||||||
$data[$k]=json_decode($v['value'],true);
|
foreach ($select as $k => $v) {
|
||||||
|
$data[$k] = json_decode($v['value'], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return app('json')->success($data);
|
return app('json')->success($data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 商户营业执照
|
* 商户营业执照
|
||||||
*/
|
*/
|
||||||
public function merchant_license_identify($image){
|
public function merchant_license_identify($image)
|
||||||
|
{
|
||||||
$config = new Config([
|
$config = new Config([
|
||||||
// 必填,您的 AccessKey ID
|
// 必填,您的 AccessKey ID
|
||||||
"accessKeyId" => 'LTAI5t7mhH3ij2cNWs1zhPmv',
|
"accessKeyId" => 'LTAI5t7mhH3ij2cNWs1zhPmv',
|
||||||
@ -565,36 +570,33 @@ class Common extends BaseController
|
|||||||
]);
|
]);
|
||||||
// Endpoint 请参考 https://api.aliyun.com/product/ocr
|
// Endpoint 请参考 https://api.aliyun.com/product/ocr
|
||||||
$config->endpoint = "ocr.cn-shanghai.aliyuncs.com";
|
$config->endpoint = "ocr.cn-shanghai.aliyuncs.com";
|
||||||
$client= new Ocr($config);
|
$client = new Ocr($config);
|
||||||
$recognizeBusinessLicenseRequest = new RecognizeBusinessLicenseRequest([
|
$recognizeBusinessLicenseRequest = new RecognizeBusinessLicenseRequest([
|
||||||
"imageURL" => $image
|
"imageURL" => $image
|
||||||
]);
|
]);
|
||||||
$runtime = new RuntimeOptions([]);
|
$runtime = new RuntimeOptions([]);
|
||||||
try {
|
try {
|
||||||
// 复制代码运行请自行打印 API 的返回值
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
$resp=$client->recognizeBusinessLicenseWithOptions($recognizeBusinessLicenseRequest, $runtime);
|
$resp = $client->recognizeBusinessLicenseWithOptions($recognizeBusinessLicenseRequest, $runtime);
|
||||||
$a= Utils::toArray($resp->body);
|
$a = Utils::toArray($resp->body);
|
||||||
$data=[];
|
$data = [];
|
||||||
if($a){
|
if ($a) {
|
||||||
$data['address']=$a['Data']['Address'];
|
$data['address'] = $a['Data']['Address'];
|
||||||
$data['business']=$a['Data']['Business'];
|
$data['business'] = $a['Data']['Business'];
|
||||||
$data['legal_person']=$a['Data']['LegalPerson'];
|
$data['legal_person'] = $a['Data']['LegalPerson'];
|
||||||
$data['name']=$a['Data']['Name'];
|
$data['name'] = $a['Data']['Name'];
|
||||||
$data['register_number']=$a['Data']['RegisterNumber'];
|
$data['register_number'] = $a['Data']['RegisterNumber'];
|
||||||
$data['type']=$a['Data']['Type'];
|
$data['type'] = $a['Data']['Type'];
|
||||||
}
|
}
|
||||||
return app('json')->success($data);
|
return app('json')->success($data);
|
||||||
|
} catch (Exception $error) {
|
||||||
}
|
|
||||||
catch (Exception $error) {
|
|
||||||
if (!($error instanceof TeaError)) {
|
if (!($error instanceof TeaError)) {
|
||||||
$error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
|
$error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
|
||||||
}
|
}
|
||||||
$a=Utils::assertAsString($error->message);
|
$a = Utils::assertAsString($error->message);
|
||||||
return app('json')->fail($a);
|
return app('json')->fail($a);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品标签
|
* 商品标签
|
||||||
@ -603,7 +605,23 @@ class Common extends BaseController
|
|||||||
{
|
{
|
||||||
[$page, $limit] = $this->getPage();
|
[$page, $limit] = $this->getPage();
|
||||||
$where = $this->request->params(['name', 'type', 'status']);
|
$where = $this->request->params(['name', 'type', 'status']);
|
||||||
$data = $repository->getList($where,$page, $limit);
|
$data = $repository->getList($where, $page, $limit);
|
||||||
return app('json')->success($data);
|
return app('json')->success($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序版本
|
||||||
|
*/
|
||||||
|
public function applet()
|
||||||
|
{
|
||||||
|
$group_id = Db::name('system_group')->where('group_key', 'applet')->value('group_id');
|
||||||
|
$list = [];
|
||||||
|
if ($group_id) {
|
||||||
|
$select = Db::name('system_group_data')->where('group_id', $group_id)->field('value')->limit(30)->select();
|
||||||
|
foreach ($select as $key => $value) {
|
||||||
|
$list[] = json_decode($value['value'], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return app('json')->success($list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ use think\facade\Route;
|
|||||||
|
|
||||||
Route::group('api/', function () {
|
Route::group('api/', function () {
|
||||||
Route::any('test', 'api.Auth/test');
|
Route::any('test', 'api.Auth/test');
|
||||||
|
Route::any('applet', 'api.Common/applet');
|
||||||
Route::get('label_lst', 'api.Common/label_lst');
|
Route::get('label_lst', 'api.Common/label_lst');
|
||||||
Route::any('system_group_value', 'api.Common/system_group_value');
|
Route::any('system_group_value', 'api.Common/system_group_value');
|
||||||
Route::any('demo_ceshi', 'api.Demo/index');
|
Route::any('demo_ceshi', 'api.Demo/index');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user