canyin-project/ybcy/controllers/channelApi/Common1Controller.php
2024-11-01 16:07:54 +08:00

123 lines
4.4 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* 云贝餐饮连锁V2版权说明
******************************************************************
《云贝餐饮连锁V2》是武汉云贝网络科技有限公司历经2余年时间独立创作开发而成且在不断的进行升级开发中《云贝餐饮连锁V2 》的源代码、布局、界面设计、电子文档等均已提交国家版权局登记备案,并已获得著作权审批 和销售许可 (软著登字第 6839058号 登记号 2021SR0114741
官方网址为www.b-ke.cn
官方联系方式153-0719-3890王经理
******************************************************************
注意:本软件非开源系统,版权归武汉云贝网络科技有限公司依法所有,并受到法律的严格保护;未经过我司授权,不得擅自二开、破解、倒卖等任何的侵权、盗版行为均将追究其法律责任。
*/
namespace app\controllers\channelApi;
use Yii;
use yii\web\Controller;
use yii\web\Session;
use yii\web\Cookie;
class CommonController extends Controller{
public $enableCsrfValidation = false;
protected $wqData=[];
private $typeInfo = array(
'mini' => 1,
'weChat' => 2,
'ali' => 3,
'baidu' => 4,
'h5' => 5,
'pc' => 6,
'toutiao' => 7,
);
protected $payMode = array(
'1' => '微信支付',
'2' => '支付宝支付',
'5' => '余额支付',
'6' => '现金支付',
'7' => '自有pos机',
'8' => '自有微信',
'9' => '自有支付宝',
'10' => '货到付款',
);
public function result($code=1,$msg='成功',$data=[])
{
return json_encode([
'code'=>$code,
'msg'=>$msg,
'data'=>$data,
]);
}
function init(){
parent::init();
$this->wqData['uniacid'] = 9;//Yii::$app->request->headers->get('uniacid');
if($this->wqData['appType']==2){
$this->wqData['uniacid']=Yii::$app->session->get('configData')['uniacid'];
}
if(Yii::$app->params['isDev']==false) {
$apply = (new \yii\db\Query())
->from('{{%ybwm_apply}}')
->where('id=:id AND status=1 AND end_time>:end_time', [':id' => $this->wqData['uniacid'], ':end_time' => time()])->one();
if (!$apply) {
echo json_encode([
'code' => 2,
'msg' => '平台不存在或已过期'
]);
exit();
}
}
$this->wqData['module'] = Yii::$app->request->headers->get('module');
$this->wqData['appType'] = 1;//$this->typeInfo[Yii::$app->request->headers->get('appType')];//应用类型
$this->wqData['userId'] = 250;//Yii::$app->request->headers->get('userId');//应用类型
if (!$this->wqData['uniacid'] || !$this->wqData['appType']) {
echo json_encode([
'code' => 2,
'msg' => '非法请求'
]);
exit();
}
}
//访问用户绑定门店
public function memberBind($storeId,$userId,$data){
if($storeId&&$userId){
$user = (new \yii\db\Query())
->from('{{%ybwm_member_bind}}')
->where('userId=:userId and storeId=:storeId',[':userId'=>$userId,':storeId'=>$storeId])->one();
if(!$user){
Yii::$app->db->createCommand()->insert('{{%ybwm_member_bind}}',$data)->execute();
}
}
}
//异常商品同步处理
public function actionChangeGoods(){
$result=axios_request();
$uniacid=$result['uniacid'];
$storeId=$result['storeId'];
$mainStore=(new \yii\db\Query())
->select(['id'])
->from('{{%ybwm_store}}')
->where(['uniacid'=>$uniacid,'id'=>$storeId])->one();
if($mainStore['isMain']==1){
echo '主店不需要同步操作';die;
}
$res=(new \yii\db\Query())
->from('{{%ybwm_store_goods}}')
->where(['storeId'=>$storeId,'uniacid'=>$uniacid])
->all();
$data=[];
foreach ($res as &$v){
$res=(new \yii\db\Query())
->from('{{%ybwm_core_goods}}')
->where(['id'=>$v['goodsId']])
->one();
if($v['isSpecs']!==$res['isSpecs']){
$data[]=$v['id'];
}
}
var_dump($data);die;
}
}