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.
426 lines
17 KiB
426 lines
17 KiB
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Administrator
|
|
* Date: 2018/3/21
|
|
* Time: 9:28
|
|
*/
|
|
|
|
namespace app\home\controller;
|
|
use think\Db;
|
|
use think\Request;
|
|
use think\Cache;
|
|
|
|
|
|
class Api extends Base
|
|
{
|
|
|
|
/**
|
|
* 拍品预约
|
|
*/
|
|
public function subscription(){
|
|
|
|
$params=request()->param();
|
|
if(isset($params['type'])&&$params['type']==3){
|
|
$params['c_id']=$params['id'];
|
|
}
|
|
$query=$this->_checksub($params);
|
|
|
|
if($query)$this->success('提交成功');
|
|
else $this->error('提交失败');
|
|
}
|
|
public function wxShare(){
|
|
$appId='wxa0cb14dc087a5d99';
|
|
$appSecret='fe3853cbea525e10a9e704d1428fe357';
|
|
|
|
$link=input('link','');
|
|
$nonce=input('nonce','');
|
|
$jssdk=new \weixin\Jssdk($appId, $appSecret);
|
|
$signPackage = $jssdk->GetSignPackage($link,$nonce);
|
|
|
|
$title='望拍';
|
|
$img=SITE_PATH.'app/home/view/szwjs/index/Public/Img/wang.png';
|
|
if(strpos($link,'shuopai')!==false){
|
|
$title='朔拍';
|
|
$img=SITE_PATH.'app/home/view/szwjs/index/Public/Img/shuopai.jpg';
|
|
}
|
|
$share=array();
|
|
$share['title']=$title;
|
|
$share['desc']=$title;
|
|
$share['link']=$link;
|
|
$share['imgUrl']=$img;
|
|
|
|
echo json_encode(['share'=>$share,'signPackage'=>$signPackage]);
|
|
}
|
|
/**
|
|
* 古建资产管理展示接口
|
|
* @return string
|
|
*/
|
|
public function gjproducts(){
|
|
$kind=11;
|
|
$childs=[];
|
|
$parents=[];
|
|
$states=[];
|
|
$parents=config('building.parents');
|
|
$states=[1=>['name'=>'信息披露'],['name'=>'正式披露'],['name'=>'成交公示'],['name'=>'艺术资产转让']];
|
|
|
|
$page=input('page',1,'intval');
|
|
$verpage=input('verPage',10,'intval');
|
|
$cid=input('cid','','intval');
|
|
$state=input('state','','intval');
|
|
|
|
if($cid||$state){
|
|
$where=['c_status'=>1,'c_kind'=>$kind];
|
|
$parent='';
|
|
if($cid){
|
|
$where['c_parent']=array('like',[$cid.',%','%,'.$cid.'%',$cid],'OR');
|
|
$parent.=isset($parents[$cid])?$parents[$cid].'-':'';
|
|
}
|
|
|
|
if($state){
|
|
$where['c_state']=$state;
|
|
$stateslist=[1=>'预披露','正式披露','成交公示','艺术资产转让'];
|
|
$parent.=isset($stateslist[$state])?$stateslist[$state]:'';
|
|
}
|
|
$parent=rtrim($parent,'-');
|
|
|
|
$db=Db::name('finance')->where($where);
|
|
$order=['c_order'=>'desc','c_time'=>'desc'];
|
|
$products=$db->field('c_id,c_name,c_logo,c_code,c_gptime,c_count,c_content,c_price,c_gprice,c_tprice')->order($order)->paginate($verpage,false,['query'=>get_query()]);
|
|
|
|
$var_page=$products->listRows();
|
|
$tpage=$products->lastPage();
|
|
$total=$products->total();
|
|
$show = $products->render();
|
|
if($products){
|
|
$products=$products->toArray();
|
|
$products=$products['data'];
|
|
|
|
foreach ($products as $k=>$item){
|
|
if($item['c_logo']){
|
|
$products[$k]['c_logo']=url($item['c_logo'],'',false,true);
|
|
}
|
|
$products[$k]['c_count']=$item['c_count']?$item['c_count']:0;
|
|
$products[$k]['c_gptime']=$item['c_gptime']?date("Y-m-d",$item['c_gptime']):'';
|
|
}
|
|
}
|
|
return json_encode(['products'=>$products,'category'=>$parent,'page'=>intval($page),'total'=>$total,'totalPage'=>$tpage,'verPage'=>$var_page,'cid'=>intval($cid),'state'=>intval($state)]);
|
|
}else{
|
|
$list=[];
|
|
if(count($states)){
|
|
$where=['c_status'=>1,'c_kind'=>$kind];
|
|
foreach ($states as $id=>$item){
|
|
$where['c_state']=$id;
|
|
$db=Db::name('finance')->field('c_id,c_name,c_logo,c_code,c_gptime,c_count,c_content,c_price,c_gprice,c_tprice')->where($where);
|
|
$products=$db->order('c_order desc,c_time desc')->limit(5)->select();
|
|
|
|
foreach ($products as $k=>$item){
|
|
if($item['c_logo']){
|
|
$products[$k]['c_logo']=url($item['c_logo'],'',false,true);
|
|
}
|
|
$products[$k]['c_count']=$item['c_count']?$item['c_count']:0;
|
|
$products[$k]['c_gptime']=$item['c_gptime']?date("Y-m-d",$item['c_gptime']):'';
|
|
}
|
|
if(!count($products)){
|
|
unset($states[$id]);
|
|
continue;
|
|
}
|
|
$states[$id]['products']=$products;
|
|
}
|
|
}
|
|
foreach ($parents as $id=>$item){
|
|
$row=[];
|
|
$row['id']=$id;
|
|
$row['name']=$item;
|
|
$childrow=isset($childs[$id])?$childs[$id]:[];
|
|
$row['has']=count($childrow)?1:0;
|
|
|
|
if($kind==11){
|
|
$where=['c_status'=>1,'c_kind'=>$kind];
|
|
$where['c_parent']=array('like',[$id.',%','%,'.$id.'%',$id],'OR');
|
|
}
|
|
if(count($childrow)){
|
|
foreach ($childrow as $k=>$v){
|
|
$where['c_cid']=$k;
|
|
$check=Db::name('finance')->where($where)->count();
|
|
|
|
if($check==0)unset($childrow[$k]);
|
|
}
|
|
if(isset($where['c_cid']))unset($where['c_cid']);
|
|
}
|
|
|
|
$row['childs']=$childrow;
|
|
$db=Db::name('finance')->field('c_id,c_name,c_logo,c_code,c_gptime,c_count,c_content,c_price,c_gprice,c_tprice')->where($where)->order('c_order desc,c_time desc');
|
|
$products=$db->limit(10)->select();
|
|
foreach ($products as $k=>$item){
|
|
if($item['c_logo']){
|
|
$products[$k]['c_logo']=url($item['c_logo'],'',false,true);
|
|
}
|
|
$products[$k]['c_count']=$item['c_count']?$item['c_count']:0;
|
|
$products[$k]['c_gptime']=$item['c_gptime']?date("Y-m-d",$item['c_gptime']):'';
|
|
}
|
|
|
|
$row['products']=$products;
|
|
array_push($list,$row);
|
|
}
|
|
return json_encode(['states'=>$states,'list'=>$list]);
|
|
}
|
|
|
|
}
|
|
/**
|
|
* 古建资产管理展示接口
|
|
* @return string
|
|
*/
|
|
public function productdetail(){
|
|
|
|
$id=input('id',0,'intval');
|
|
$cid=input('cid',0,'intval');
|
|
$list=Db::name('finance')->field('c_id,c_name,c_logo,c_code,c_gptime,c_count,c_content,c_price,c_gprice,c_tprice,c_photos,c_parent,c_num,c_author,c_video,c_notice,c_size,c_class,c_year')->where(['c_status'=>1,'c_id'=>$id,'c_kind'=>11])->find();
|
|
if(!$list){
|
|
$list=['cid'=>'','category'=>'','c_id'=>'','c_name'=>'','c_logo'=>'','c_code'=>'','c_gptime'=>'','c_count'=>0,'c_content'=>'','c_price'=>'','c_gprice'=>'','c_tprice'=>'','c_photos'=>'','c_parent'=>'','c_num'=>'','c_author'=>'','c_video'=>'','c_notice'=>'','c_size'=>'','c_class'=>'','c_year'=>''];
|
|
}
|
|
$showtypes=config("building.parents");
|
|
$pic_list =isset($list['c_photos'])&&$list['c_photos']?array_filter(explode(",", $list['c_photos'])):[];
|
|
if(count($pic_list)&&is_array($pic_list)){
|
|
foreach ($pic_list as $k=>$item){
|
|
if($item)$pic_list[$k]=url($item,'',false,true);
|
|
}
|
|
}
|
|
$parent=isset($showtypes[$cid])?$showtypes[$cid]:'';
|
|
if(empty($cid)){
|
|
$parents=explode(',',$list['c_parent']);
|
|
if(count($parents)){
|
|
$cid=$parents[0];
|
|
$parent=isset($showtypes[$parents[0]])?$showtypes[$parents[0]]:'';
|
|
}
|
|
}
|
|
$list['c_count']=$list['c_count']?$list['c_count']:0;
|
|
$list['c_photos']=$pic_list;
|
|
$list['cid']=$cid;
|
|
$list['category']=$parent?$parent:'';
|
|
return json_encode($list);
|
|
}
|
|
/**
|
|
* 望拍产品
|
|
*/
|
|
public function products(){
|
|
$cid=input('cid',1,'intval');
|
|
$page=input('page',1,'intval');
|
|
$pagesize=input('pagesize',8,'intval');
|
|
$lists=Db::name('product')->where(['cid'=>$cid,'status'=>1])->order('sort asc,create_time desc')->paginate($pagesize,false,['cid'=>$cid,'page'=>$page]);
|
|
$category=Db::name('procategory')->where(['status'=>1,'id'=>$cid])->find();
|
|
$qid='';
|
|
if($category){
|
|
$qid=$category['pid'];
|
|
}
|
|
$quarter=Db::name('proquarter')->where(['status'=>1,'id'=>$qid])->find();
|
|
echo json_encode(['list'=>$lists,'category'=>$category,'quarter'=>$quarter]);
|
|
}
|
|
/**
|
|
* 产品详情
|
|
*/
|
|
public function product(){
|
|
$id=input('id','','intval');
|
|
|
|
$lists=Db::name('product')->where(['id'=>$id,'status'=>1])->find();
|
|
$cid='';
|
|
if($lists){
|
|
$cid=$lists['cid'];
|
|
}
|
|
$category=Db::name('procategory')->where(['status'=>1,'id'=>$cid])->find();
|
|
$qid='';
|
|
if($category){
|
|
$qid=$category['pid'];
|
|
}
|
|
$quarter=Db::name('proquarter')->where(['status'=>1,'id'=>$qid])->find();
|
|
echo json_encode(['product'=>$lists,'category'=>$category,'quarter'=>$quarter]);
|
|
}
|
|
/**
|
|
* 获取望拍场次属性
|
|
*/
|
|
public function quarter(){
|
|
$id=input('id','','intval');
|
|
if(empty($id)){
|
|
$content=Db::name('proquarter')->where(['status'=>1])->order('sort desc,id desc')->find();
|
|
}else{
|
|
$content=Db::name('proquarter')->where(['status'=>1,'id'=>$id])->find();
|
|
}
|
|
if($content){
|
|
$cates=Db::name('procategory')->where(['status'=>1,'pid'=>$id])->select();
|
|
$list=[];
|
|
if($cates){
|
|
$list=$cates;
|
|
}
|
|
$content['categorys']=$list;
|
|
}
|
|
echo json_encode($content);
|
|
}
|
|
/**
|
|
* 同步规则指引API
|
|
*/
|
|
public function ruleGuide()
|
|
{
|
|
$sign = input("sign");
|
|
$id = input("id");
|
|
$catid = input("catlogid");
|
|
$cid = input("cid");
|
|
$name = input("filename");
|
|
$fileallUrl = input("url");
|
|
$order = input("sort");
|
|
$createtime = input("createtime",time());
|
|
$param = array('id'=>$id,'catlogid'=>$catid,'cid'=>$cid,'filename'=>$name,'url'=>$fileallUrl);
|
|
try{
|
|
if(empty($sign)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "数据签名不允许为空!";
|
|
}else if (empty($id)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "ID不允许为空!";
|
|
}else if (empty($catid)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "分类ID不允许为空!";
|
|
}else if (empty($cid)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "次级分类ID不允许为空!";
|
|
}else if (empty($name)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "文件名称不允许为空!";
|
|
}else if (empty($fileallUrl)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "文件下载url不允许为空!";
|
|
}else if (empty($createtime)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "创建时间不允许为空!";
|
|
}else if(getApiSign($param)!=$sign){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "没有访问权限!";
|
|
}else{
|
|
$d_data=array(
|
|
'd_name'=>$name,
|
|
'd_status'=>1,
|
|
'd_uid'=>'',
|
|
'd_time'=>$createtime,
|
|
'd_order'=>$order,
|
|
'd_url'=>$fileallUrl,
|
|
'd_cid'=>$cid,
|
|
'd_catlogid'=>$catid,
|
|
'd_sourceid'=>$id,
|
|
'd_count'=>0
|
|
);
|
|
|
|
$rule = Db::name('download')->where('d_sourceid',$id)->select();
|
|
if($rule){
|
|
$updateRst=Db::name('download')->where('d_sourceid',$id)->update($d_data);
|
|
if($updateRst){
|
|
$return_data['result'] = "success";
|
|
$return_data['msg'] = "数据同步成功!";
|
|
}else{
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "更新失败!";
|
|
}
|
|
}else{
|
|
$insertRst=Db::name('download')->insert($d_data);
|
|
if($insertRst){
|
|
$return_data['result'] = "success";
|
|
$return_data['msg'] = "数据同步成功!";
|
|
}else{
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "插入数据库失败!";
|
|
}
|
|
}
|
|
}
|
|
|
|
}catch (\Exception $exception){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] =$exception ->getMessage();
|
|
}
|
|
$return_data['data'] ="";
|
|
echo json_encode($return_data);die;
|
|
}
|
|
|
|
/**
|
|
* 同步文章API
|
|
*/
|
|
public function upArticle()
|
|
{
|
|
try{
|
|
$sign = input("sign");
|
|
$id = input("id");//ID
|
|
$catid = input("catlogid");//分类ID
|
|
$cid = input("cid");//次级分类ID
|
|
$title = input("title");//标题
|
|
$img = input("img");//缩略图
|
|
$desc = input("desc");//描述
|
|
$content = htmlspecialchars_decode(input("content"));//文章内容
|
|
$createtime = input("createtime",time());
|
|
$param = array('id'=>$id,'catlogid'=>$catid,'cid'=>$cid,'title'=>$title,'content'=>$content);
|
|
|
|
$return_data=[];
|
|
if(empty($sign)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "数据签名不允许为空!";
|
|
}else if (empty($id)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "ID不允许为空!";
|
|
}else if (empty($catid)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "分类ID不允许为空!";
|
|
}else if (empty($cid)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "次级分类ID不允许为空!";
|
|
}else if (empty($title)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "文章标题不允许为空!";
|
|
}else if (empty($content)){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "文章内容不允许为空!";
|
|
}else if (getApiSign($param)!=$sign){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "没有访问权限!";
|
|
}else{
|
|
$sl_data=array(
|
|
'n_title'=>$title,
|
|
'n_cid'=>$cid,
|
|
'n_source'=>'掌柜文化金服',
|
|
'n_pics'=>'',//多图路径
|
|
'n_img'=>$img,//封面图片路径
|
|
'n_status'=>'1',
|
|
'n_desc'=>$desc,
|
|
'n_content'=>$content,
|
|
'n_uid'=>'',
|
|
'n_time'=>$createtime,
|
|
'n_order'=>'50',
|
|
'n_sourceid'=>$id
|
|
);
|
|
$table='sczcxy';//市场政策行研(1:挂牌信息2:融资快讯3:企业挂牌咨讯4:政策行研)
|
|
$cates=[];
|
|
$cates[5]='bsyw'; //新闻(1:本所动态2:市场动态3:政策动态4:合作媒体)
|
|
$cates[6]='bsyw'; //公告(1:文交所公告2:挂牌企业公告3:登记托管公告4:国有资产公告)
|
|
if(isset($cates[$catid]))$table=$cates[$catid];
|
|
|
|
|
|
$result= Db::name($table)->where('n_sourceid',$id)->where("n_cid",$cid)->select();
|
|
if($result){
|
|
//数据库没有该数据才添加
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "数据已存在!";
|
|
}else{
|
|
$insertRst=Db::name($table)->insert($sl_data);
|
|
if($insertRst){
|
|
$return_data['result'] = "success";
|
|
$return_data['msg'] = "数据同步成功!";
|
|
}else{
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] = "插入数据库失败!";
|
|
}
|
|
}
|
|
|
|
}
|
|
}catch (\Exception $exception){
|
|
$return_data['result'] = "fail";
|
|
$return_data['msg'] =$exception ->getMessage();
|
|
}
|
|
$return_data['data'] ="";
|
|
echo json_encode($return_data);die;
|
|
}
|
|
}
|
|
|