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; } }