371 lines
12 KiB
PHP
371 lines
12 KiB
PHP
|
<?php
|
|||
|
/**
|
|||
|
* 云贝餐饮连锁V2版权说明:
|
|||
|
|
|||
|
******************************************************************
|
|||
|
|
|||
|
《云贝餐饮连锁V2》是武汉云贝网络科技有限公司历经2余年时间独立创作开发而成,且在不断的进行升级开发中,《云贝餐饮连锁V2 》的源代码、布局、界面设计、电子文档等均已提交国家版权局登记备案,并已获得著作权审批 和销售许可 (软著登字第 6839058号 登记号 2021SR0114741)。
|
|||
|
|
|||
|
官方网址为:www.b-ke.cn
|
|||
|
|
|||
|
官方联系方式:153-0719-3890(王经理)
|
|||
|
|
|||
|
******************************************************************
|
|||
|
|
|||
|
注意:本软件非开源系统,版权归武汉云贝网络科技有限公司依法所有,并受到法律的严格保护;未经过我司授权,不得擅自二开、破解、倒卖等任何的侵权、盗版行为均将追究其法律责任。
|
|||
|
*/
|
|||
|
namespace app\models\common;
|
|||
|
use Yii;
|
|||
|
use yii\base\Model;
|
|||
|
use yii\db\ActiveRecord;
|
|||
|
use app\models\common\File;
|
|||
|
class Config extends ActiveRecord{
|
|||
|
//应用列表
|
|||
|
public function appConfig(){
|
|||
|
$data=[
|
|||
|
[
|
|||
|
'id'=>1,
|
|||
|
'name'=>'channel',
|
|||
|
'use_name'=>'连锁版'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>2,
|
|||
|
'name'=>'delivery',
|
|||
|
'use_name'=>'跑腿'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>3,
|
|||
|
'name'=>'o2o',
|
|||
|
'use_name'=>'O2O'
|
|||
|
],
|
|||
|
];
|
|||
|
return $data;
|
|||
|
}
|
|||
|
|
|||
|
public function serviceConfig()
|
|||
|
{
|
|||
|
$data=[
|
|||
|
[
|
|||
|
'id'=>1,
|
|||
|
'name'=>'app',
|
|||
|
'use_name'=>'商家端',
|
|||
|
],
|
|||
|
];
|
|||
|
return $data;
|
|||
|
}
|
|||
|
//渠道列表
|
|||
|
public function channelConfig(){
|
|||
|
$config=getSysInfo()['authData']['channel'];
|
|||
|
$data=[
|
|||
|
[
|
|||
|
'id'=>1,
|
|||
|
'name'=>'mini',
|
|||
|
'use_name'=>'微信小程序',
|
|||
|
'channel_image'=>'/web/static/images/platform/icon_xcx.png'
|
|||
|
],
|
|||
|
// [
|
|||
|
// 'id'=>2,
|
|||
|
// 'name'=>'ali',
|
|||
|
// 'use_name'=>'支付宝小程序',
|
|||
|
// 'channel_image'=>'/web/static/images/platform/icon_zfb.png'
|
|||
|
// ],
|
|||
|
// [
|
|||
|
// 'id'=>3,
|
|||
|
// 'name'=>'zijie',
|
|||
|
// 'use_name'=>'字节跳动小程序',
|
|||
|
// 'channel_image'=>'/web/static/images/platform/icon_zjtd.png'
|
|||
|
// ],
|
|||
|
// [
|
|||
|
// 'id'=>4,
|
|||
|
// 'name'=>'wechat',
|
|||
|
// 'use_name'=>'微信公众号',
|
|||
|
// 'channel_image'=>'/web/static/images/platform/icon_wx.png'
|
|||
|
// ],
|
|||
|
];
|
|||
|
$list=[];
|
|||
|
foreach ($data as $v){
|
|||
|
if(in_array($v['name'],$config)){
|
|||
|
$list[]=$v;
|
|||
|
}
|
|||
|
}
|
|||
|
return $list;
|
|||
|
}
|
|||
|
//增值插件列表
|
|||
|
public function plugConfig(){
|
|||
|
$config=getSysInfo()['authData']['plug'];
|
|||
|
$data=[
|
|||
|
[
|
|||
|
'id'=>1,
|
|||
|
'name'=>'miniPlay',
|
|||
|
'use_name'=>'小程序直播'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>2,
|
|||
|
'name'=>'rollBag',
|
|||
|
'use_name'=>'券包'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>3,
|
|||
|
'name'=>'payVip',
|
|||
|
'use_name'=>'付费会员卡'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>4,
|
|||
|
'name'=>'cashier',
|
|||
|
'use_name'=>'收银台'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>5,
|
|||
|
'name'=>'oldWithNew',
|
|||
|
'use_name'=>'老带新'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>6,
|
|||
|
'name'=>'distribution',
|
|||
|
'use_name'=>'分销商'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>7,
|
|||
|
'name'=>'queuing',
|
|||
|
'use_name'=>'排队取号'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>8,
|
|||
|
'name'=>'reserve',
|
|||
|
'use_name'=>'餐桌预定'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>9,
|
|||
|
'name'=>'dividend',
|
|||
|
'use_name'=>'瓜分红包'
|
|||
|
],
|
|||
|
];
|
|||
|
$list=[];
|
|||
|
foreach ($data as $v){
|
|||
|
if(in_array($v['name'],$config)){
|
|||
|
$list[]=$v;
|
|||
|
}
|
|||
|
}
|
|||
|
return $list;
|
|||
|
}
|
|||
|
//应用授权插件
|
|||
|
public function menuConfig(){
|
|||
|
$data=[
|
|||
|
|
|||
|
[
|
|||
|
'id'=>1,
|
|||
|
'name'=>'balanceRecharge',
|
|||
|
'use_name'=>'会员储值'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>2,
|
|||
|
'name'=>'signIndex',
|
|||
|
'use_name'=>'积分签到'
|
|||
|
],
|
|||
|
[
|
|||
|
'id'=>3,
|
|||
|
'name'=>'integralShop',
|
|||
|
'use_name'=>'积分商城'
|
|||
|
],
|
|||
|
];
|
|||
|
return $data;
|
|||
|
}
|
|||
|
|
|||
|
//获取系统设置
|
|||
|
public static function getSystemSet($name, $uniacid) {
|
|||
|
$res=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_core_system}}')
|
|||
|
->where('uniacid=:uniacid AND ident=:ident',[':uniacid'=>$uniacid,':ident' => $name])
|
|||
|
->one();
|
|||
|
|
|||
|
$data=json_decode($res['data'], true)?:[];
|
|||
|
|
|||
|
return $data;
|
|||
|
}
|
|||
|
//获取商家设置
|
|||
|
public static function getStoreSet($name, $storeId,$uniacid=null) {
|
|||
|
$res=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store_set}}')
|
|||
|
->where('storeId=:storeId AND ident=:ident',[':storeId'=>$storeId,':ident' => $name]);
|
|||
|
if($uniacid){
|
|||
|
$res->andWhere('uniacid=:uniacid',['uniacid'=>$uniacid]);
|
|||
|
}
|
|||
|
//var_dump(ddSql($res));die;
|
|||
|
$data=$res->one();
|
|||
|
$res=json_decode($data['data'], true)?:[];
|
|||
|
if($name=='takeOutSet'){
|
|||
|
if(!$res['address']){
|
|||
|
$shopInfo=(new \yii\db\Query())
|
|||
|
->select(['address', 'lat','lng'])
|
|||
|
->from('{{%ybwm_store}}')
|
|||
|
->where('id=:storeId',[':storeId'=>$storeId])->one();
|
|||
|
$res['address']=$shopInfo['address'];
|
|||
|
$res['lat']=$shopInfo['lat'];
|
|||
|
$res['lng']=$shopInfo['lng'];
|
|||
|
}
|
|||
|
$res['orderMedia']=$res['orderMedia']?:[];
|
|||
|
$res['distributionSupport']=$res['distributionSupport']?:['1','2'];
|
|||
|
$res['diningType']=$res['diningType']?:['1','2'];
|
|||
|
$res['orderNotice']=$res['orderNotice']?:'商家暂无公告';
|
|||
|
$res['notice']=$res['notice']?:'商家暂无公告';
|
|||
|
$res['timeType']=$res['timeType']?:'1';
|
|||
|
$res['boxType']=$res['boxType']?:'2';
|
|||
|
$res['printType']=$res['printType']?:'1';
|
|||
|
|
|||
|
}
|
|||
|
if($name=='instoreSet'){
|
|||
|
$res['payMode']=$res['payMode']?:'1';
|
|||
|
$res['orderMode']=$res['orderMode']?:'1';
|
|||
|
$res['orderMedia']=$res['orderMedia']?:[];
|
|||
|
$res['timeType']=$res['timeType']?:'1';
|
|||
|
$res['orderNotice']=$res['orderNotice']?:'商家暂无公告';
|
|||
|
$res['notice']=$res['notice']?:'商家暂无公告';
|
|||
|
}
|
|||
|
return $res;
|
|||
|
}
|
|||
|
|
|||
|
//保存系统设置
|
|||
|
public static function saveSystemSet($data,$name,$uniacid=null,$zwName=null) {
|
|||
|
$configData['ident']=$name;
|
|||
|
$configData['name']=$zwName;
|
|||
|
if($name=='system'){
|
|||
|
$configData['name']="基础设置";
|
|||
|
}
|
|||
|
if($name=='currency'){
|
|||
|
$configData['name']="通用设置";
|
|||
|
}
|
|||
|
if($name=='sms'){
|
|||
|
$configData['name']="短信设置";
|
|||
|
}
|
|||
|
if($name=='serviceCharge'){
|
|||
|
$configData['name']="服务费设置";
|
|||
|
}
|
|||
|
if($name=='miniConfig'){
|
|||
|
$configData['name']="微信小程序配置";
|
|||
|
}
|
|||
|
if($name=='payConfig'){
|
|||
|
$configData['name']="支付配置";
|
|||
|
}
|
|||
|
if($name=='withdrawal'){
|
|||
|
$configData['name']="提现设置";
|
|||
|
}
|
|||
|
if($name=='storeSet'){
|
|||
|
$configData['name']="门店设置";
|
|||
|
}
|
|||
|
if($name=='style'){
|
|||
|
$configData['name']="风格设置";
|
|||
|
}
|
|||
|
if($name=='storage'){
|
|||
|
$res=File::checkAttachmentSet($data['type'],$data);
|
|||
|
if(!$res){
|
|||
|
return $res;
|
|||
|
}
|
|||
|
}
|
|||
|
$configData['data']=arrayToJson($data);
|
|||
|
$row=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_core_system}}')
|
|||
|
->where(['uniacid'=>$uniacid,'ident'=>$name])
|
|||
|
->one();
|
|||
|
if($row){
|
|||
|
$configData['changeAt']=time();
|
|||
|
$res=Yii::$app->db->createCommand()->update('{{%ybwm_core_system}}', $configData, 'id=:id', ['id' =>$row['id']])->execute();
|
|||
|
}else{
|
|||
|
$configData['uniacid']=$uniacid;
|
|||
|
$configData['createdAt']=time();
|
|||
|
try{
|
|||
|
$res=Yii::$app->db->createCommand()->insert('{{%ybwm_core_system}}', $configData)->execute();
|
|||
|
}catch (\Exception $e){
|
|||
|
return $e;
|
|||
|
}
|
|||
|
}
|
|||
|
if($res){
|
|||
|
return true;
|
|||
|
}else{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
//保存商家设置
|
|||
|
public static function saveStoreSet($data,$name, $storeId,$zwName=null,$appType=null) {
|
|||
|
$configData['ident']=$name;
|
|||
|
$configData['name']=$zwName;
|
|||
|
if($name=='delivery'){
|
|||
|
$configData['name']="配送设置";
|
|||
|
}
|
|||
|
if($name=='advanceSet'){
|
|||
|
$configData['name']="预订单设置";
|
|||
|
}
|
|||
|
if($name=='takeOutSet'){
|
|||
|
$configData['name']="外卖设置";
|
|||
|
}
|
|||
|
if($name=='makeTime'){
|
|||
|
$configData['name']="制作时间";
|
|||
|
}
|
|||
|
if($name=='deliveryMode'){
|
|||
|
$configData['name']="配送方式";
|
|||
|
}
|
|||
|
$configData['data']=arrayToJson($data);
|
|||
|
$store=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store}}')
|
|||
|
->where(['id'=>$storeId])
|
|||
|
->one();
|
|||
|
$configData['uniacid']=$store['uniacid'];
|
|||
|
$row=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store_set}}')
|
|||
|
->where('storeId=:storeId AND ident=:ident',[':storeId'=>$storeId,':ident'=>$name])
|
|||
|
->one();
|
|||
|
if($row){
|
|||
|
$configData['changeAt']=time();
|
|||
|
if($appType){
|
|||
|
$oldData=json_decode($row['data'],true);
|
|||
|
$configData['data']=array_merge($data,$oldData);
|
|||
|
}
|
|||
|
$res=Yii::$app->db->createCommand()->update('{{%ybwm_store_set}}', $configData, 'id=:id', ['id' =>$row['id']])->execute();
|
|||
|
}else{
|
|||
|
$configData['storeId']=$storeId;
|
|||
|
$configData['createdAt']=time();
|
|||
|
try{
|
|||
|
$res=Yii::$app->db->createCommand()->insert('{{%ybwm_store_set}}', $configData)->execute();
|
|||
|
}catch (\Exception $e){
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
if($res){
|
|||
|
return true;
|
|||
|
}else{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//效验付费插件是否授权
|
|||
|
public function checkPlug($uniacid,$plugStr){
|
|||
|
$plugList=self::plugConfig();
|
|||
|
$data=self::getSystemSet('sysTopImage',$uniacid);
|
|||
|
$plugConfig=$data['plug_str'];
|
|||
|
$plug_ids=[];
|
|||
|
foreach ($plugList as $v){
|
|||
|
if(in_array($v['name'],$plugConfig)){
|
|||
|
$plug_ids[]=$v['name'];
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if(in_array($plugStr,$plug_ids)){
|
|||
|
echo json_encode(['code'=>1,'msg'=>'成功','type'=>1]);die;
|
|||
|
}else{
|
|||
|
echo json_encode(['code'=>1,'msg'=>'该付费插件未开通','type'=>2]);die;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//商家端小程序保存
|
|||
|
public function saveConfig($bool,$ident,$identName){
|
|||
|
$result=axios_request();
|
|||
|
if ($bool) {
|
|||
|
$res=Config::getSystemSet($ident,0);
|
|||
|
echo json_encode(['code'=>1,'msg'=>'成功','data'=>$res]);die;
|
|||
|
}
|
|||
|
Config::saveSystemSet($result,$ident,0,$identName?:'');
|
|||
|
return $this->result(1,'成功');
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|