282 lines
12 KiB
PHP
282 lines
12 KiB
PHP
<?php
|
||
/**
|
||
* 云贝餐饮连锁V2版权说明:
|
||
|
||
******************************************************************
|
||
|
||
《云贝餐饮连锁V2》是武汉云贝网络科技有限公司历经2余年时间独立创作开发而成,且在不断的进行升级开发中,《云贝餐饮连锁V2 》的源代码、布局、界面设计、电子文档等均已提交国家版权局登记备案,并已获得著作权审批 和销售许可 (软著登字第 6839058号 登记号 2021SR0114741)。
|
||
|
||
官方网址为:www.b-ke.cn
|
||
|
||
官方联系方式:153-0719-3890(王经理)
|
||
|
||
******************************************************************
|
||
|
||
注意:本软件非开源系统,版权归武汉云贝网络科技有限公司依法所有,并受到法律的严格保护;未经过我司授权,不得擅自二开、破解、倒卖等任何的侵权、盗版行为均将追究其法律责任。
|
||
*/
|
||
namespace app\controllers\channelApi;
|
||
use Illuminate\Support\Facades\DB;
|
||
use Yii;
|
||
use app\models\common\Config;
|
||
use app\models\common\Drag;
|
||
use app\models\common\WeChat;
|
||
use app\models\common\File;
|
||
use app\models\common\Power;
|
||
use app\models\common\Store;
|
||
|
||
class ConfigController extends CommonController{
|
||
public $enableCsrfValidation = false;
|
||
public function actionConfig()
|
||
{
|
||
$result=axios_request();
|
||
$res=Config::getSystemSet($result['ident'],$this->wqData['uniacid']);
|
||
if($result['ident']=='system'){
|
||
$color=Config::getSystemSet('style',$this->wqData['uniacid']);
|
||
$res['color']=$color['color']?:'#DBA86F';
|
||
$name=Config::getSystemSet('customName',$this->wqData['uniacid']);
|
||
$res['custom']=$name;
|
||
$res['custom']['live']=$name['live']?:'直播列表';
|
||
$res['custom']['takeOut']=$name['takeOut']?:'外卖';
|
||
$res['custom']['integral']=$name['integral']?:'积分';
|
||
$res['custom']['balance']=$name['balance']?:'余额';
|
||
$res['custom']['rechargeTitle']=$name['rechargeTitle']?:'充值中心';
|
||
$res['custom']['systemRedbag']=$name['systemRedbag']?:'平台红包';
|
||
$res['custom']['orderNumber']=$name['orderNumber']?:'取单号';
|
||
$res['custom']['informationTitle']=$name['informationTitle']?:'资讯中心';
|
||
$res['custom']['hbfh']=$name['hbfh']?:'¥';
|
||
$res['custom']['hbmc']=$name['hbmc']?:'元';
|
||
$res['custom']['inStore']=$name['inStore']?:'店内';
|
||
$member=Config::getSystemSet('member',$this->wqData['uniacid']);
|
||
$res['member']['payType']=$member['payType']?:1;
|
||
$storeSet=Config::getSystemSet('storeSet',$this->wqData['uniacid']);
|
||
$res['storeSet']['showType']=$storeSet['showType']?:1;
|
||
$power=Power::getPower($this->wqData['uniacid']);
|
||
$res['storeSet']['storeModel']=$power['shopModel']?:2;
|
||
$res['copyright']['support']=Power::getPower($this->wqData['uniacid'],'support')['support']?:'';
|
||
$switch=Config::getSystemSet('currency',$this->wqData['uniacid']);
|
||
$res['switch']['scribingPriceShow']=$switch['scribingPriceShow']?:1;
|
||
$res['switch']['saleShow']=$switch['saleShow']?:1;//
|
||
$res['switch']['stockShow']=$switch['stockShow']?:1;
|
||
$res['powerList']['instore']=Power::getPower($this->wqData['uniacid'],'instore')['instore']?:1;
|
||
$res['powerList']['takeout']=Power::getPower($this->wqData['uniacid'],'instore')['takeout']?:1;
|
||
$res['powerList']['queuing']=Power::getPayPower($this->wqData['uniacid'],'queuing')?1:0;
|
||
$res['powerList']['reserve']=Power::getPayPower($this->wqData['uniacid'],'reserve')?1:0;
|
||
|
||
}
|
||
if($result['ident']=='collection'){
|
||
$res['couponArr']=[];
|
||
if($res['isCoupon']==1){
|
||
$list=(new \yii\db\Query())
|
||
->select('id,name,timeType,useEndTime,isNextDay,day,isFull,fullMoney,type,money,discount')
|
||
->from('{{%ybwm_coupon}}')
|
||
->where(['in','id',$res['coupon']])
|
||
->all();
|
||
for($i=0;$i<count($list);$i++){
|
||
if($list[$i]['timeType']==1){
|
||
//日期范围
|
||
$list[$i]['useExplain']="有效期至".date("Y-m-d H:i",$list[$i]['useEndTime']);
|
||
}else{
|
||
if($list[$i]['isNextDay']==1){
|
||
$list[$i]['useExplain']="领取后".$list[$i]['day']."天内有效(次日起)";
|
||
}else{
|
||
$list[$i]['useExplain']="领取后".$list[$i]['day']."天内有效";
|
||
}
|
||
}
|
||
$list[$i]['explain']='';
|
||
if($list[$i]['isFull']==1){
|
||
$list[$i]['explain'] .='无门槛,';
|
||
}else{
|
||
$list[$i]['explain'] .='满'.$list[$i]['fullMoney'].'可用,';
|
||
}
|
||
}
|
||
$res['couponArr']=$list;
|
||
}
|
||
}
|
||
return $this->result(1,'成功',$res);
|
||
|
||
}
|
||
//查看模板id
|
||
public function actionTemplateList()
|
||
{
|
||
$appType=$this->wqData['appType'];
|
||
$res=Config::getSystemSet('miniTemplates',$this->wqData['uniacid']);
|
||
if($appType==3){
|
||
$res=Config::getSystemSet('aliTemplates',$this->wqData['uniacid']);
|
||
}
|
||
$data['saveOrder']=[];
|
||
$data['payOrder']=[];
|
||
$data['cashierOrder']=[];
|
||
if($res['payOkTid']){
|
||
$data['saveOrder'][]=$res['payOkTid'];
|
||
}
|
||
if($res['takeTid']){
|
||
$data['saveOrder'][]=$res['takeTid'];
|
||
}
|
||
if($res['deliveryTid']){
|
||
$data['saveOrder'][]=$res['deliveryTid'];
|
||
}
|
||
if($res['refuseTid']){
|
||
$data['payOrder'][]=$res['refuseTid'];
|
||
}
|
||
if($res['acceptTid']){
|
||
$data['payOrder'][]=$res['acceptTid'];
|
||
}
|
||
if($res['refundResultTid']){
|
||
$data['payOrder'][]=$res['refundResultTid'];
|
||
}
|
||
if($res['cashierTid']){
|
||
$data['cashierOrder'][]=$res['cashierTid'];
|
||
}
|
||
if($res['fastTakeTid']){
|
||
$data['fastOrder'][]=$res['fastTakeTid'];
|
||
}
|
||
if($res['inOrderTid']){
|
||
$data['inStoreOrder'][]=$res['inOrderTid'];
|
||
}
|
||
if($res['queuingTid']){
|
||
$data['queuingOrder'][]=$res['queuingTid'];
|
||
}
|
||
return $this->result(1,'成功',$data);
|
||
}
|
||
//坐标转地址
|
||
public function actionCoordinateToAdd() {
|
||
$result=axios_request();
|
||
$coordinate=$result['lat'].','.$result['lng'];
|
||
$set = Config::getSystemSet('system', $this->wqData['uniacid']);
|
||
$txKey=$set['txKey']?:Yii::$app->params['txKey'];
|
||
$location = "https://apis.map.qq.com/ws/geocoder/v1/?location=" . $coordinate . "&key=" . $txKey. "&get_poi=0";
|
||
$coordinate = httpRequest($location);
|
||
$coordinate = json_decode($coordinate, true);
|
||
return $this->result(1, '成功', $coordinate);
|
||
}
|
||
|
||
//获取单个拖拽式数据
|
||
public function actionGetDragRow(){
|
||
$result=axios_request();
|
||
$pageId=$result['pageId'];
|
||
if($pageId){
|
||
$info=(new \yii\db\Query())
|
||
->select('id,body')
|
||
->from('{{%ybwm_drag}}')
|
||
->where(['deleteAt'=>0,'id'=>$pageId,'display'=>1,'uniacid'=>$this->wqData['uniacid']])
|
||
->one();
|
||
$info['body']=json_decode($info['body'],true)?:[];
|
||
return $this->result(1, '成功', $info);
|
||
}
|
||
$info=(new \yii\db\Query())
|
||
->select('id,body')
|
||
->from('{{%ybwm_drag}}')
|
||
->where(['deleteAt'=>0,'page'=>$result['id'],'display'=>1,'uniacid'=>$this->wqData['uniacid']])
|
||
->one();
|
||
if(!$info){
|
||
Drag::getDefault($this->wqData['uniacid'],$result['id']);
|
||
$info=(new \yii\db\Query())
|
||
->select('id,body')
|
||
->from('{{%ybwm_drag}}')
|
||
->where(['deleteAt'=>0,'page'=>$result['id'],'display'=>1,'uniacid'=>$this->wqData['uniacid']])
|
||
->one();
|
||
}
|
||
$info['body']=json_decode($info['body'],true)?:[];
|
||
return $this->result(1, '成功', $info);
|
||
|
||
}
|
||
//获取小程序直播
|
||
public function actionGetMiniLive(){
|
||
$result=axios_request();
|
||
$page=$result['page'];
|
||
$size=$result['size']?:10;
|
||
$table=(new \yii\db\Query())
|
||
->from('{{%ybwm_live}}')
|
||
->where('uniacid=:uniacid',[':uniacid'=>$this->wqData['uniacid']]);
|
||
$res=$table->offset(($page - 1) * $size)->limit($size)->all();
|
||
// $res=WeChat::getMiniLive($this->wqData['uniacid'],$result['page'],$result['size']);
|
||
return $this->result(1, '成功', $res);
|
||
}
|
||
|
||
//获取小程序公告
|
||
public function actionGetArticleList(){
|
||
$result=axios_request();
|
||
$type=$result['type']?:1;
|
||
if($type==1){
|
||
$storeId=Store::getMainStore($this->wqData['uniacid'])['id'];
|
||
}else{
|
||
$storeId=$result['storeId'];
|
||
}
|
||
$uniacid=$this->wqData['uniacid'];
|
||
$data=(new \yii\db\Query())
|
||
->select('id,title,introduction,from_unixtime(createdAt)createdAt,body')
|
||
->from('{{%ybwm_notice}}')
|
||
->where(['deleteAt'=>0,'uniacid'=>$uniacid,'display'=>1,'noticeType'=>1,'storeId'=>$storeId])
|
||
->orderBy('id desc')->all();
|
||
return $this->result(1, '成功', $data);
|
||
}
|
||
public function actionGetCode(){
|
||
$result=axios_request();
|
||
$page=WeChat::getQrCode($this->wqData['uniacid'],$this->wqData['module'],$result['page'],$result['ident'],$result['scene']);
|
||
return $this->result(1, '成功', $page);
|
||
}
|
||
//上传图片
|
||
public function actionUpload(){
|
||
//print_R($_FILES['file']);die;
|
||
$config=Config::getSystemSet('storage',$this->wqData['uniacid']);
|
||
if($config['type']==1){
|
||
$fname=File::qiniuUpload('file',$this->wqData['module'],$this->wqData['uniacid'],$config);
|
||
}elseif($config['type']==2){
|
||
$fname=File::aliUpload('file',$this->wqData['module'],$this->wqData['uniacid'],$config);
|
||
}elseif($config['type']==3){
|
||
$fname=File::txyUpload('file',$this->wqData['module'],$this->wqData['uniacid'],$config);
|
||
}else{
|
||
$fname=File::channelUploadImage('file','',$this->wqData['module'],$this->wqData['uniacid']);
|
||
}
|
||
return $fname;
|
||
}
|
||
//资讯
|
||
public function actionInformation(){
|
||
$result=axios_request();
|
||
$storeId=$result['storeId'];
|
||
$page=$result['page']?:1;
|
||
$size=$result['size']?:10;
|
||
if($storeId){
|
||
$table=(new \yii\db\Query())
|
||
->from('{{%ybwm_information}}')
|
||
->where('uniacid=:uniacid AND storeId=:storeId AND type=1 AND display=1 AND deleteAt=0',[':uniacid'=>$this->wqData['uniacid'],':storeId'=>$storeId]);
|
||
}else{
|
||
$table=(new \yii\db\Query())
|
||
->from('{{%ybwm_information}}')
|
||
->where('uniacid=:uniacid AND type=1 AND display=1 AND deleteAt=0',[':uniacid'=>$this->wqData['uniacid']]);
|
||
}
|
||
|
||
$res=$table->offset(($page - 1) * $size)->limit($size)->orderBy('sort asc,id desc')->all();
|
||
return $this->result(1, '成功', $res);
|
||
}
|
||
//资讯详情
|
||
public function actionInformationInfo(){
|
||
$result=axios_request();
|
||
$res=(new \yii\db\Query())
|
||
->select('a.*,s.name as storeName')
|
||
->from('{{%ybwm_information}} as a')
|
||
->join('LEFT JOIN', '{{%ybwm_store}} as s', 's.id = a.storeId')
|
||
->where('a.id=:id AND a.deleteAt=0',[':id'=>$result['id']])->one();
|
||
if($res){
|
||
Yii::$app->db->createCommand()->update('{{%ybwm_information}}', ['views'=>new \yii\db\Expression('views + 1')], 'id=:id', ['id' =>$result['id']])->execute();
|
||
return $this->result(1, '成功', $res);
|
||
}
|
||
return $this->result(1, '成功', []);
|
||
|
||
}
|
||
//通过活码id查找参数
|
||
public function actionGetCodeData(){
|
||
$result=axios_request();
|
||
$info=(new \yii\db\Query())
|
||
->from('{{%ybwm_code}}')
|
||
->where('id=:id',[':id'=>$result['id']])->one();
|
||
$data=json_decode($info['data'],true);
|
||
return $this->result(1, '成功', $data);
|
||
}
|
||
public function actionGetStoreConfig(){
|
||
$result=axios_request();
|
||
$res=Config::getStoreSet($result['ident'],$result['storeId']);
|
||
return $this->result(1, '成功', $res);
|
||
}
|
||
}
|