Blogger Information
Blog 143
fans 1
comment 0
visits 440348
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
人人商城 小程序与公众号 ims_ewei_shop_member 表中 unionId同步处理
弘德誉曦的博客
Original
1184 people have browsed it

人人商城 小程序与公众号 ims_ewei_shop_member 表中 unionId同步处理


w.lexiangwangluo.com/addons/ewei_shopv2/core/model/member.php    [addons/ewei_shopv2/core/model/member.php]

方法名称 public function checkMemberFromPlatform($openid = '',$acc='')

    447:16                 pdo_insert('ewei_shop_member', $member);
    868:12             pdo_insert('ewei_shop_member', $member);
    983:12             pdo_insert('ewei_shop_member', $data);

需要加入以下字段信息

$unionId = pdo_fetchcolumn('select unionId from ims_mc_mapping_fans where openid = :openid',array('openid'=>$openid));

'unionId' => $unionId,

代码如下:

public function checkMemberFromPlatform($openid = '',$acc='') {
        global $_W;
        if (empty($acc))
        {
            $acc = WeiXinAccount::create();
        }
        $userinfo = $acc->fansQueryInfo($openid);
        $userinfo['avatar'] = $userinfo['headimgurl'];

        $redis = redis();
        if (!is_error($redis)){
            $member = $redis->get($openid.'_checkMemberFromPlatform');
            if (!empty($member)){
                return json_decode($member,true);
            }
        }

        load()->model('mc');
        $uid = mc_openid2uid($openid);
        if (!empty($uid)) {
            pdo_update('mc_members', array(
                'nickname' => $userinfo['nickname'],
                'gender' => $userinfo['sex'],
                'nationality' => $userinfo['country'],
                'resideprovince' => $userinfo['province'],
                'residecity' => $userinfo['city'],
                'avatar' => $userinfo['headimgurl']), array('uid' => $uid)
            );
        }
        pdo_update('mc_mapping_fans', array(
            'nickname' => $userinfo['nickname']
        ), array('uniacid' => $_W['uniacid'], 'openid' => $openid));

        $member = $this->getMember($openid);
        if (empty($member)) {
            $unionId = pdo_fetchcolumn('select unionId from ims_mc_mapping_fans where openid = :openid',array('openid'=>$openid));
            $mc = mc_fetch($uid, array('realname', 'nickname', 'mobile', 'avatar', 'resideprovince', 'residecity', 'residedist'));
            $member = array(
                'uniacid' => $_W['uniacid'],
                'uid' => $uid,
                'openid' => $openid,
                'realname' => $mc['realname'],
                'mobile' => $mc['mobile'],
                'nickname' => !empty($mc['nickname']) ? $mc['nickname'] : $userinfo['nickname'],
                'avatar' => !empty($mc['avatar']) ? $mc['avatar'] : $userinfo['avatar'],
                'gender' => !empty($mc['gender']) ? $mc['gender'] : $userinfo['sex'],
                'province' => !empty($mc['resideprovince']) ? $mc['resideprovince'] : $userinfo['province'],
                'city' => !empty($mc['residecity']) ? $mc['residecity'] : $userinfo['city'],
                'area' => $mc['residedist'],
                'createtime' => time(),
                'unionId' => $unionId,
                'status' => 0
            );
            pdo_insert('ewei_shop_member', $member);
            if(method_exists(m('member'),'memberRadisCountDelete')) {
                m('member')->memberRadisCountDelete(); //清除会员统计radis缓存
            }
            $member['id'] = pdo_insertid();
            $member['isnew'] = true;
        } else {
            $member['nickname'] = $userinfo['nickname'];
            $member['avatar'] = $userinfo['headimgurl'];
            $member['province'] = $userinfo['province'];
            $member['city'] = $userinfo['city'];
            pdo_update('ewei_shop_member', $member, array('id' => $member['id']));
            if((time()-$member['createtime'])<60){
                $member['isnew'] = true;
            }else {
                $member['isnew'] = false;
            }
        }
        if (!is_error($redis)){
            $redis->set($openid.'_checkMemberFromPlatform',json_encode($member),20);
        }
        return $member;
    }

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post