Ejemplo n.º 1
0
    def POST(self):
        params = self.req.input()
        shopid = params.get("shopid", '')
        newpwd = params.get("newpwd", '')
        if not shopid or not newpwd:
            raise ParamError("参数错误")

        # 验证是否是当前商户的子商户
        userid = self.user.userid
        cate = self.get_cate()
        if cate == "bigmerchant":
            subids = get_linkids(userid)
            shopid = int(shopid)
            if shopid not in subids:
                raise ParamError("非大商户的子商户")

            try:
                apcli("changePwd", uid=shopid, password=newpwd)

                kick_user(int(shopid), mode = 'not_opuser')
                return self.write(success(data={"result": "success"}))
            except:
                log.debug(traceback.format_exc())
                return self.write(success(data={"result": "fail"}))
        else:
            raise ParamError("角色错误")
Ejemplo n.º 2
0
    def POST(self):

        cate = self.get_cate()

        params = self.req.input()
        sub_mchnt_id = params.get('shopid', '')
        try:
            userid = self.user.userid
            sub_mchnt_id = int(sub_mchnt_id)
            if not sub_mchnt_id:
                raise ParamError("子商户错误")
            else:
                if cate == "bigmerchant":
                    subids = get_linkids(userid)
                    if sub_mchnt_id not in subids:
                        raise ParamError("非大商户的子商户")
        except:
            log.warn('sub merchant error : %s ' % traceback.format_exc())
            raise ParamError("无法识别子商户")

        try:
            thrift_callex(config.APOLLO_SERVERS, ApolloServer, 'unbindRelation', int(userid), int(sub_mchnt_id), 'merchant')
        except:
            log.warn('user ({userid}) remove sub merchant({sub_mchnt_id}) error : {reason}'.format(userid=userid, sub_mchnt_id = sub_mchnt_id, reason = traceback.format_exc()))
            return self.write(error(QFRET.THIRDERR))
        return self.write(success(data={}))
Ejemplo n.º 3
0
    def _(self, *args, **kwargs):
        userid = int(self.user.userid)

        params = self.req.input()
        if params.has_key("shopid"):
            shopid = params.get("shopid", '')
            if not shopid:
                raise ParamError("商户id参数错误")

            try:
                shopid = hids.decode(shopid)[0]
            except:
                raise ParamError("商户id参数错误")

            # 验证是否是当前商户的子商户
            cate = self.get_cate()
            if cate == "bigmerchant":
                subids = get_linkids(userid)
                if shopid not in subids:
                    raise ParamError("非大商户的子商户")
                else:
                    userid = shopid

        ret = func(self, userid)
        return ret
Ejemplo n.º 4
0
    def GET(self):

        params = self.req.input()
        shopid = params.get("shopid", '')
        if not shopid:
            raise ParamError("商户id参数错误")

        # 验证是否是当前商户的子商户
        userid = self.user.userid
        cate = self.get_cate()
        if cate == "bigmerchant":
            subids = get_linkids(userid)
            shopid = int(shopid)
            if shopid not in subids:
                raise ParamError("非大商户的子商户")
        else:
            pass

        try:
            res = {}
            user_ext = apcli_ex('getUserExt', int(shopid))

            user_detail_info = get_user_detail_info(shopid)

            audit_info = re_audit_info(shopid).get(shopid)
            res['audit_str'], res['audit_flag'], res['audit_fail_reason'] = audit_info.get('audit_str'), audit_info.get('audit_flag'), audit_info.get('audit_fail_reason')

            res['login_account'] = user_detail_info.get("mobile", '') if user_detail_info else ''
            res['shopname'] = user_detail_info.get("shopname", '') if user_detail_info else ''
            res['logo'] = user_ext.logo_url or config.DEFAULT_SHOP_LOGO_URL
            res['register_time'] = user_detail_info.get("jointime", '') if user_detail_info else ''
            res['telephone'] = user_detail_info.get('telephone', '') if user_detail_info else ''
            res['address'] = user_detail_info.get("address", '') if user_detail_info else ''
            # 获取银行信息
            bank_info = get_user_bank_info(shopid)
            res['payee'] = bank_info.get("bankuser", '') if bank_info else ''
            bank_account = bank_info.get("bankaccount", '') if bank_info else ''
            res['bank_account'] = self.del_cardno(bank_account)
            res['branch_bank_name'] = bank_info.get("bankname", '') if bank_info else ''

            return self.write(success(data=res))
        except:
            log.warn('Get shop detail error:%s' % traceback.format_exc())
            raise DBError('获取商户详细信息失败')
Ejemplo n.º 5
0
    def GET(self):

        params = self.req.input()
        audit_status = str(params.get('audit_status', '0'))

        need_all = params.get("need_all", 'notall')

        if audit_status not in ['', '0', '1', '2', '3']:
            raise ParamError("审核状态参数错误")
        try:
            page = int(params.get('page', '0'))
            length = int(params.get('length', '10'))
        except:
            raise ParamError("分页参数错误")

        start = page * length

        userid = self.user.userid
        cate = self.get_cate()
        if cate == "bigmerchant":
            sub_uids = get_linkids(userid)

            if not sub_uids:
                return self.write(success(data={"shops": []}))

            all_userinfo = get_userinfo(sub_uids)  # 调Apollo的商户信息接口

            # 对子店排序,按照创建时间倒叙
            sub_uids = sorted(sub_uids, key=lambda x: all_userinfo[x].get('jointime', ''), reverse=True)

            user_exts = apcli_ex('getUserExts', sub_uids)
            user_exts = {i.uid:i for i in user_exts}

            # 获取审核状态信息
            all_audit_state = re_audit_info(sub_uids)
            all_res = []
            for uid in sub_uids:
                one_res = dict()
                # 获取审核状态, 审核标志
                audit_state = all_audit_state.get(int(uid))
                audit_flag = audit_state.get("audit_flag", '')

                if audit_status == '' or audit_status == '0' or audit_flag == audit_status:  # 筛选audit_status

                    one_res['audit_flag'] = audit_flag
                    one_res['audit_fail_reason'] = audit_state.get("audit_fail_reason", '')
                    one_res['audit_str'] = audit_state.get("audit_str", '')

                    userinfo = all_userinfo.get(uid, {})
                    user_ext = user_exts.get(uid, UserExt())

                    one_res['login_account'] = userinfo.get('mobile', '') if userinfo else ''
                    one_res['shopname'] = userinfo.get('shopname', '') if userinfo else ''
                    one_res['logo'] = user_ext.logo_url or config.DEFAULT_SHOP_LOGO_URL
                    one_res['shopid'] = int(uid)
                    all_res.append(one_res)

            return self.write(success(data={"shops": all_res[start: start+length] if need_all != "all" else all_res}))

        else:
            raise DBError('角色错误')
Ejemplo n.º 6
0
    def GET(self):

        params = self.req.input()
        userid = params.get("userid", '')
        usertype = params.get("usertype", '')
        try:
            usertype = int(usertype)
        except:
            raise ParamError("usertype参数错误")
        if usertype not in UserDefine.SIGNUP_USERTYPES:
            raise ParamError("usertype参数错误")
        if not userid:
            raise ParamError("userid参数错误")

        # 验证传入的userid是否属于当前业务员
        curr_uid = self.user.userid

        qd_info = get_qd_mchnt(userid)
        if qd_info:
            slsm_uid = qd_info.slsm_uid
            if slsm_uid != int(curr_uid):
                return self.write(error(QFRET.DBERR, respmsg="商户id参数与当前操作员无绑定关系"))

        cate = self.get_cate(userid=userid)
        if cate == "bigmerchant":
            sub_uids = get_linkids(userid)

            if not sub_uids:
                return self.write(success(data={}))
            else:

                # 先筛选出状态为审核通过的商户 最新商户信息从审核通过商户中选取
                with get_connection('qf_mis') as db:
                    rows = db.select('apply', where={'user': ('in', sub_uids), 'state': APPLY_STATE.get("pass")}, fields='user')
                if rows:
                    sub_uids = [i['user'] for i in rows]
                else:
                    return self.write(success(data={}))

                ret = dict()

                # 查询出最新的userid, name和legalname
                with get_connection("qf_core") as db:
                    rows = db.select("profile", where={"userid": ("in", sub_uids), "user_type": usertype},
                                     fields="userid, name, legalperson, user_type", other="order by jointime desc")
                    if len(rows) <= 0:
                        return self.write(success(data={}))
                    latest_uid = rows[0]['userid']

                    usertype = int(rows[0]['user_type'])
                    name = rows[0]['name']
                    legal_name = rows[0]['legalperson']

                    if usertype == UserDefine.SIGNUP_USERTYPE_TINY:
                        ret['name'] = name
                    else:
                        ret['name'] = legal_name

                try:
                    detail_info = apcli('userprofile_by_id', latest_uid)
                except:
                    log.debug(traceback.format_exc())
                    raise ThirdError("获取商户详情失败")
                user_info = detail_info['user']
                bank_info = detail_info['bankInfo']

                ret['banktype'] = bank_info['banktype']
                ret['bankuser'] = bank_info['bankuser']
                ret['bankaccount'] = bank_info['bankaccount']
                ret['bankmobile'] = bank_info['bankmobile']
                ret['bankProvince'] = bank_info['bankProvince']
                bank_city = bank_info.get('bankCity', '')
                head_bankname = bank_info.get('headbankname', '')
                ret['bankCity'] = bank_city
                ret['headbankname'] = head_bankname
                with get_connection_exception('qf_mis') as db:
                    r = db.select_one('tools_areacity', where={'city_name': bank_city}, fields='city_no, city_name') or {}
                    head_bank = db.select_one('tools_bank', where={'bank_name': head_bankname, 'bank_display': 1},
                                              fields='bank_name, bank_no') or {}
                ret['city_id'] = r.get('city_no', '')
                ret['headbankid'] = head_bank.get('bank_no', '')
                ret['bankcode'] = bank_info.get('bankcode', '')
                ret['bankname'] = bank_info['bankname']

                ret['idnumber'] = user_info['idnumber']
                ret['address'] = user_info['address']


                user_ext = apcli_ex('getUserExt', int(latest_uid))
                ret['shoptype_id'] = ''
                if user_ext:
                    ret['shoptype_id'] = user_ext.shoptype_id

                # 身份证有效期, 照片,
                cert_names = ["idcardfront", "idcardback", "idcardinhand", "licensephoto"]

                # 常量对应
                cert_imgurl = {"idcardfront": 'idcardfront_url', "idcardback": 'idcardback_url',
                               "idcardinhand": "idcardinhand_url", "licensephoto": "license_photo_url"}

                all_img_info = get_img_info(latest_uid, cert_names)

                for i in all_img_info:
                    ret.update({cert_imgurl[i['name']]: i['imgurl']})

                with get_connection('qf_mis') as db:
                    db_ret = db.select('apply', fields="idstatdate, idenddate",
                                       where={"user": latest_uid}, other="limit 1")
                    if db_ret:
                        ret.update(db_ret[0])
                    else:
                        ret.update({
                            "idstatdate": "",  # 身份证起始时间
                            "idenddate": "",  # 身份证结束时间
                        })
                return self.write(success(data=ret))

        else:
            raise ParamError("角色错误")
Ejemplo n.º 7
0
    def GET(self):

        params = self.req.input()
        if params.has_key("shopid"):
            shopid = params.get("shopid")
            try:
                userid = int(shopid)
            except:
                raise ParamError("子商户参数错误")
            # 判断下当前传入的userid是否是子商户
            if userid not in get_linkids(self.user.userid):
                raise ParamError("传入的子商户不属于此商户")
        else:
            userid = int(self.user.ses.get('userid', 0))

        url = config.QRCODE_URL % hids.encode(userid)

        # 获取用户信息
        user = apcli.user_by_id(userid)
        if not user:
            return self.write(error(QFRET.PARAMERR, respmsg='查询用户信息失败'))
        mchnt_name = user['shopname']

        # 获取图片信息
        img_conf = get_qd_conf_value(
            mode=None, key='qrcode', groupid=user['groupid']) or {}

        if not params.has_key("shopid"):
            # 操作员信息
            opinfo = self.get_opinfo()
            opuid, opname = opinfo.get('opuid'), opinfo.get('opname', '')
            if opuid:
                url += '&o=' + str(opuid)
                op_img_conf = {
                    k[3:]: v
                    for k, v in img_conf.iteritems() if k.startswith('op_')
                }
                img_conf = op_img_conf or img_conf

                opname = '%04d' % int(opuid)
            else:
                img_conf = {
                    k: v
                    for k, v in img_conf.iteritems() if not k.startswith('op_')
                }
        else:
            return self.write(
                success({
                    "qrcode": url,
                    "img_conf": {
                        k: v
                        for k, v in img_conf.iteritems()
                        if not k.startswith('op_')
                    }
                }))

        return self.write(
            success({
                'qrcode': url,
                'img_conf': img_conf,
                'mchnt_name': mchnt_name,
                'opname': opname
            }))