|
@@ -24,20 +24,16 @@ class ActivityController extends O2oBaseController {
|
|
if($code && $state){
|
|
if($code && $state){
|
|
$accessInfo = CommonWeixin::getAccessInfo($code);
|
|
$accessInfo = CommonWeixin::getAccessInfo($code);
|
|
$userId = '';
|
|
$userId = '';
|
|
- echo "1";exit;
|
|
|
|
if (!isset($accessInfo['errcode']) && $state == 'yiguanjia') {
|
|
if (!isset($accessInfo['errcode']) && $state == 'yiguanjia') {
|
|
- echo "2";
|
|
|
|
$appToken = md5(substr($accessInfo['openid'],2));
|
|
$appToken = md5(substr($accessInfo['openid'],2));
|
|
//微信校验通过,登录(注册),分发token
|
|
//微信校验通过,登录(注册),分发token
|
|
$userInfo = CommonWeixin::getUserInfo($accessInfo['access_token'], $accessInfo['openid']);
|
|
$userInfo = CommonWeixin::getUserInfo($accessInfo['access_token'], $accessInfo['openid']);
|
|
if (!isset($accessInfo['errcode'])) {
|
|
if (!isset($accessInfo['errcode'])) {
|
|
- echo "3";
|
|
|
|
//检查是否有注册,没有就注册
|
|
//检查是否有注册,没有就注册
|
|
$criteria = new EMongoCriteria();
|
|
$criteria = new EMongoCriteria();
|
|
$criteria->unionid('==', $accessInfo['unionid']);
|
|
$criteria->unionid('==', $accessInfo['unionid']);
|
|
$user = RUser::model()->find($criteria);
|
|
$user = RUser::model()->find($criteria);
|
|
if ($user) {
|
|
if ($user) {
|
|
- echo "4";
|
|
|
|
$userId = $user->_id;
|
|
$userId = $user->_id;
|
|
if(!isset($user->wx_pub_openid) || empty($user->wx_pub_openid)){
|
|
if(!isset($user->wx_pub_openid) || empty($user->wx_pub_openid)){
|
|
$user->wx_pub_openid = $accessInfo['openid'];
|
|
$user->wx_pub_openid = $accessInfo['openid'];
|
|
@@ -45,7 +41,6 @@ class ActivityController extends O2oBaseController {
|
|
$user->update(array('wx_pub_openid','wx_have_follow'),true);
|
|
$user->update(array('wx_pub_openid','wx_have_follow'),true);
|
|
}
|
|
}
|
|
}else{
|
|
}else{
|
|
- echo "5";
|
|
|
|
$userAr = new RUser();
|
|
$userAr = new RUser();
|
|
$userAr->user_name = $userInfo['nickname'];
|
|
$userAr->user_name = $userInfo['nickname'];
|
|
$userAr->avatar = $userInfo['headimgurl'];
|
|
$userAr->avatar = $userInfo['headimgurl'];
|
|
@@ -65,7 +60,6 @@ class ActivityController extends O2oBaseController {
|
|
|
|
|
|
$result = $userAr->save();
|
|
$result = $userAr->save();
|
|
if($result){
|
|
if($result){
|
|
- echo "6";
|
|
|
|
//异步同步微信头像到七牛
|
|
//异步同步微信头像到七牛
|
|
if (!empty($userAr->unionid) && (strpos($userAr->avatar, 'qiniu') === false)) {
|
|
if (!empty($userAr->unionid) && (strpos($userAr->avatar, 'qiniu') === false)) {
|
|
$list = new ARedisList('after_user_reg');
|
|
$list = new ARedisList('after_user_reg');
|
|
@@ -78,13 +72,12 @@ class ActivityController extends O2oBaseController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//用户注册后,发放代金券
|
|
//用户注册后,发放代金券
|
|
- echo "7";
|
|
|
|
|
|
+
|
|
$coupon_id =new MongoId($coupon_id);
|
|
$coupon_id =new MongoId($coupon_id);
|
|
$start_time = time(); //发放优惠券可用开始时间
|
|
$start_time = time(); //发放优惠券可用开始时间
|
|
$end_time = $start_time + 86400*30; //发放优惠券过期时间
|
|
$end_time = $start_time + 86400*30; //发放优惠券过期时间
|
|
if (CommonFn::isMongoId($coupon_id)) {
|
|
if (CommonFn::isMongoId($coupon_id)) {
|
|
if (CommonFn::isMongoId($user->_id)) {
|
|
if (CommonFn::isMongoId($user->_id)) {
|
|
- echo "8";
|
|
|
|
Service::factory('CouponService')->giveCoupon($user->_id, $coupon_id, $start_time, $end_time);//发放代金券
|
|
Service::factory('CouponService')->giveCoupon($user->_id, $coupon_id, $start_time, $end_time);//发放代金券
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -96,7 +89,6 @@ class ActivityController extends O2oBaseController {
|
|
}
|
|
}
|
|
|
|
|
|
if($home_page){
|
|
if($home_page){
|
|
- echo "9";exit;
|
|
|
|
$this->renderpartial('//o2o/web/index', array(
|
|
$this->renderpartial('//o2o/web/index', array(
|
|
'version' => '2015111601',
|
|
'version' => '2015111601',
|
|
'debug' => 'false',
|
|
'debug' => 'false',
|
|
@@ -138,8 +130,6 @@ class ActivityController extends O2oBaseController {
|
|
}
|
|
}
|
|
$scope = 'snsapi_userinfo';
|
|
$scope = 'snsapi_userinfo';
|
|
$state = 'yiguanjia';
|
|
$state = 'yiguanjia';
|
|
- echo "1";
|
|
|
|
- var_dump($redirectURI);exit;
|
|
|
|
$codeURI = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $wxConfig['appId'] . '&redirect_uri=' . urlencode($redirectURI) . '&response_type=code&scope=' . $scope . '&state=' . $state . '#wechat_redirect';
|
|
$codeURI = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $wxConfig['appId'] . '&redirect_uri=' . urlencode($redirectURI) . '&response_type=code&scope=' . $scope . '&state=' . $state . '#wechat_redirect';
|
|
|
|
|
|
$this->renderpartial('wxIndex', array(
|
|
$this->renderpartial('wxIndex', array(
|