12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\index\controller;
- use app\index\service\HelperService;
- use app\index\service\TokenService;
- use \think\Controller;
- class CmsController extends Controller
- {
- public $post = [];
- public $allowCompany = [
- 'YAWY','YTMALL','GREENLNNHOTEL','VOWKIN','TMZJ','VWHEEL','JINRONGYUAN',
- 'CCHLK','MISAP','AYKJ','ALJL','YLBG','SMDD','GD','RHZB',"WPCW"
- ];
- public function _initialize()
- {
- HelperService::$_startExecTime = microtime(true);
- $params_list = ['token'=>'string','companyCode'=>'string'];
- $this->post = $this->request->post();
- //跳过验证的特殊办法
- if(isset($this->request->param()['leo_debug'])
- && $this->request->param()['leo_debug']== 'leo'){
- return true;
- }
- HelperService::diffParam($params_list,$this->post);
- $TokenService = new TokenService();
- $res = $TokenService->checkToken($this->post);
- if($res !== true){
- HelperService::returnJson($res);
- }else{
- unset($this->post['token']);
- }
- }
- protected function returnJson($data,$code=200,$msg='success'){
- HelperService::returnJson([
- 'code'=>$code,
- 'msg'=>$msg,
- 'data'=>$data
- ]);
- }
- protected function toArray($res){
- $data = [];
- if(!empty($res)){
- foreach($res as $k=>$v){
- $data[] = $res[$k]->toArray();
- }
- }
- return $data ;
- }
- /**
- * 生成订单号
- * @return string
- */
- protected function createOrderNum(){
- $key = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 4, 5);
- $key.=rand(100,999);
- usleep(1000);
- return $key;
- }
- }
|