/**
* @param $openid | string
* 通过微信的openid 得到 user
*/
protected function actionGetByWxOpenid($openid)
{
$one = $this->_customerModel->findOne(['wx_openid' => $openid]);
if(!$one){
$model = $this->_customerRegisterModel;
$model->type='wx';
$model->password=rand(111111,99999);
$model->wx_openid=$openid;
$model->created_at = time();
$model->updated_at = time();
$model->save();
}
$one = $this->_customerModel->findOne(['wx_openid' => $openid]);
$primaryKey = $this->getPrimaryKey();
if ($one[$primaryKey]) {
return $one;
}
return null;
}
临时修改为如上所示,暂时可以直接创建账号并直接登陆。 希望能够提供一个不影响以后升级的解决方案。
https://github.com/fecshop/yii2_fecshop/blob/master/services/Customer.php#L843 我希望能够修改这个代码,如何未能找到openid的用户,直接在此处创建一个账号。但不影响后续升级