72 lines
2.7 KiB
PHP
72 lines
2.7 KiB
PHP
|
<?php
|
||
|
namespace app\controllers\channelApi;
|
||
|
use Illuminate\Support\Facades\DB;
|
||
|
use Yii;
|
||
|
use yii\web\Controller;
|
||
|
use app\models\common\Config;
|
||
|
use app\models\common\Store;
|
||
|
class CloudController extends CommonController{
|
||
|
public $enableCsrfValidation = false;
|
||
|
public function actionCheckBusiness()
|
||
|
{
|
||
|
$result=axios_request();
|
||
|
$store=(new \yii\db\Query())
|
||
|
->select(['id', 'timeLimit', 'times', 'storeOpen', 'judgeOpen'])
|
||
|
->from('{{%ybwm_store}}')
|
||
|
->where('uniacid=:uniacid AND display=1 AND deleteAt=0',[':uniacid'=>$result['uniacid']])->all();
|
||
|
for ($t = 0; $t < count($store); $t++) {
|
||
|
$timeOpen=Store::getStoreOutBusiness($store[$t]['id']);
|
||
|
if ($store[$t]['storeOpen'] == 1 AND $timeOpen == 1) {
|
||
|
Yii::$app->db->createCommand()->update('{{%ybwm_store}}', array('judgeOpen' => 1), 'id=:id', ['id' =>$store[$t]['id']])->execute();
|
||
|
} else {
|
||
|
Yii::$app->db->createCommand()->update('{{%ybwm_store}}', array('judgeOpen' => 2), 'id=:id', ['id' =>$store[$t]['id']])->execute();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//记录用户访问小程序浏览量
|
||
|
public function actionVisitCollect(){
|
||
|
$result=axios_request();
|
||
|
if(!$this->wqData['userId']){
|
||
|
echo json_encode(['code'=>1,'msg'=>'成功']);
|
||
|
}
|
||
|
$request_type=Yii::$app->request->isPost?'post':'get';
|
||
|
|
||
|
if($result['storeId']&&$this->wqData['userId']){
|
||
|
$row= (new \yii\db\Query())
|
||
|
->from('{{%ybwm_member}}')
|
||
|
->where('id=:id and uniacid=:uniacid',[':id'=>$this->wqData['userId'],':uniacid'=>$this->wqData['uniacid']])
|
||
|
->one();
|
||
|
$userData=array(
|
||
|
'createdAt'=>time(),
|
||
|
'uniacid'=>$this->wqData['uniacid'],
|
||
|
'bindType'=>1,
|
||
|
'openId'=>$row['openId'],
|
||
|
'userTel'=>$row['userTel'],
|
||
|
'userId'=>$this->wqData['userId'],
|
||
|
'storeId'=>$result['storeId'],
|
||
|
);
|
||
|
$this->memberBind($result['storeId'],$this->wqData['userId'],$userData);
|
||
|
}
|
||
|
|
||
|
$data=array(
|
||
|
'uniacid'=>$this->wqData['uniacid'],
|
||
|
'model'=>$this->wqData['module'],
|
||
|
'modelname'=>$result['moduleName'],
|
||
|
'type'=>1,
|
||
|
'createdAt'=>time(),
|
||
|
'ip'=>getIps(),
|
||
|
'userId'=>$this->wqData['userId'],
|
||
|
'request_type'=>$request_type,
|
||
|
'par_str'=>json_encode($result),
|
||
|
'storeId'=>$result['storeId'],
|
||
|
);
|
||
|
YII::$app->db->createCommand()->insert('{{%ybwm_visit_list}}', $data)->execute();
|
||
|
|
||
|
|
||
|
echo json_encode(['code'=>1,'msg'=>'访问记录已录入']);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|