예제 #1
0
def store_Seller(newSMS):
    print >> sys.stderr, "within store seller"
    if check_Seller_Exists(newSMS):
        print >> sys.stderr, "within store seller if"
        statement = "Okimanyi nti e nnamba eno wagiwaandiisa dda ku lukalala?"
        # Do you know you've already registered this number for the mailing list?
        create_Outbox_Message(newSMS.number, statement)
    else:
        try:
            print >> sys.stderr, "within store seller else try"
            bodyList = split_Body(newSMS)
            if len(bodyList) > 4:
                print >> sys.stderr, "within store seller else if"
                newSeller = Seller(givenName = bodyList[1], familyName = bodyList[2], product = bodyList[3], kind = bodyList[4], market = 1)
                newSeller.save()
                update_query = Number.update(seller=newSeller).where(Number.number == newSMS.number.number)
                update_query.execute()
                numberObject = get_Number_Object(newSMS.number.number)
                listObject = get_List_Object(newSeller.market)
                newListRelationship = create_ListRelationship(listObject, numberObject, numberObject, numberObject)
                statement = newSeller
            else:
                print >> sys.stderr, "within store seller else else"
                statement = "Okutwegattako Goberera enkola eno 'okuyunga Erinnya Eppaatiike Erinnya Ery'ekika Byotunda'" #explanation of how to join
                create_Outbox_Message(newSMS.number, statement)
        except:
            print >> sys.stderr, "within except"
            print >> sys.stderr, str(sys.exc_info()[0]) # These write the nature of the error
            print >> sys.stderr, str(sys.exc_info()[1])
            statement = 'An exception has Occurred'+ str(sys.exc_type) + '[' + str(sys.exc_value) + ']'
            return statement
    return statement
예제 #2
0
파일: api.py 프로젝트: jzxyouok/kefu_web
def update_seller(store_id, seller_id):
    db = g._imdb
    form = request.form
    name = form.get('name', '')
    password = form.get('password', '')
    md5_password = form.get('md5_password', '')
    salt = form.get('salt', '')
    is_password_empty = not password and (not md5_password or not salt)
    if not name and is_password_empty:
        return INVALID_PARAM()

    if password:
        password = generate_password_hash(password)
    elif md5_password:
        password = "******"%(salt, md5_password)

    db.begin()

    if name:
        Seller.set_seller_name(db, store_id, seller_id, name)
    if password:
        Seller.set_seller_password(db, store_id, seller_id, password)

    db.commit()
        
    return ""
예제 #3
0
def store_seller(store_id):
    """
    store 销售人员

    """
    db = g._imdb

    offset = int(request.args.get('offset', 0))
    limit = int(request.args.get('limit', 10))

    rows_found = Seller.get_seller_count(db, store_id)
    sellers = Seller.get_page_seller(db, store_id, offset, limit)
    store_info = Store.get_store(db, store_id)

    g.pagination.setdefault()
    g.pagination.rows_found = rows_found
    g.pagination.limit = limit
    g.pagination.offset = offset

    return render_template('store/seller.html',
                           data={
                               'offset': offset,
                               'list': sellers,
                               'store_info': store_info,
                               'pagination': g.pagination,
                           })
예제 #4
0
파일: store.py 프로젝트: jzxyouok/kefu_web
def store_seller(store_id):
    """
    store 销售人员

    """
    db = g._imdb

    offset = int(request.args.get('offset', 0))
    limit = int(request.args.get('limit', 10))

    rows_found = Seller.get_seller_count(db, store_id)
    sellers = Seller.get_page_seller(db, store_id, offset, limit)
    store_info = Store.get_store(db, store_id)

    g.pagination.setdefault()
    g.pagination.rows_found = rows_found
    g.pagination.limit = limit
    g.pagination.offset = offset

    return render_template('store/seller.html',
                           data={'offset': offset,
                                 'list': sellers,
                                 'store_info': store_info,
                                 'pagination': g.pagination,
                                 })
예제 #5
0
def create_tables():
    Number.create_table(True)
    SMS.create_table(True)
    Seller.create_table(True)
    Market.create_table(True)
    List.create_table(True)
    ListRelationship.create_table(True)
    Outbox.create_table(True)
예제 #6
0
파일: user.py 프로젝트: Split174/CarSale
 def add_seller(self, seller, user_id):
     """
     Добавить продавца
     :return:
     """
     new_seller = Seller(zip_code=seller['zip_code'],
                         street=seller['street'],
                         home=seller['home'],
                         phone=seller['phone'],
                         account_id=user_id)
     self.session.add(new_seller)
     self.session.commit()
     return new_seller.as_dict()
def update_profile(userId):
    print(session.get('user_id'))
    print(session.get('userId'))
    seller = Seller.objects(id=userId).first()
    if request.method == "GET":
        sellers_listings = ProductListing.objects(seller_id=seller).all()
        return render_template("profile.html",
                               seller=seller,
                               listings=sellers_listings)

    seller_name_v = request.form.get("seller_name")
    seller_email_v = request.form.get("email")
    seller_phone_v = request.form.get("phone")
    seller_city_v = request.form.get("city")
    password_v = request.form.get("password")
    seller_photo_v = request.files.get("photo")

    photo_url = upload_image("users", seller_photo_v)

    seller.seller_name = seller_name_v
    seller.email = seller_email_v
    seller.phone = seller_phone_v
    seller.city = seller_city_v
    seller.password = password_v
    seller.seller_photoURL = photo_url
    seller.save()

    return jsonify({"msg": "Profile updated successfully"})
예제 #8
0
def get_one_supporter(db, rds, store_id):
    online_sellers = []
    sellers = Seller.get_sellers(db, store_id)

    if not sellers:
        return None

    for seller in sellers:
        status = Supporter.get_user_status(rds, seller['id'])
        seller['status'] = status
        if status == Supporter.STATUS_ONLINE:
            online_sellers.append(seller)

    if len(online_sellers) == 0:
        #假设第一个客服是管理员
        seller = sellers[0]
    else:
        index = random.randint(0, len(online_sellers) - 1)
        seller = sellers[index]

    name = ""
    if seller.has_key('name') and seller['name']:
        name = seller['name'].split('@')[0]

    resp = {
        "seller_id": seller['id'],
        "name": name,
        "status": seller["status"]
    }
    return resp
예제 #9
0
파일: api.py 프로젝트: jzxyouok/kefu_web
def get_sellers(store_id):
    db = g._imdb
    sellers = Seller.get_sellers(db, store_id)
    for s in sellers:
        if 'number' in s and not s['number']:
            s.pop('number')
    return make_response(200, sellers)
예제 #10
0
def store_seller_post(store_id):
    """
    store 添加商店人员

    """
    db = g._imdb
    developer_id = session['user']['id']

    form = request.form
    name = form.get('name', '')
    password = form.get('password', '')
    number = form.get('number', '')
    if not name or not password or not store_id:
        return INVALID_PARAM()
        
    if not number:
        number = None
    password = md5.new(password).hexdigest()

    group_id = Store.get_store_gid(db, store_id)

    db.begin()
    seller_id = Seller.add_seller(db, name, password, store_id, group_id, number)
    Group.add_group_member(db, group_id, seller_id)
    db.commit()

    content = "%d,%d"%(group_id, seller_id)
    publish_message(g.im_rds, "group_member_add", content)
    
    return redirect(url_for('.store_seller', store_id=store_id))
예제 #11
0
def get_one_supporter(db, rds, store_id):
    online_sellers = []
    sellers = Seller.get_sellers(db, store_id)

    if not sellers:
        return None

    for seller in sellers:
        status = Supporter.get_user_status(rds, seller['id'])
        seller['status'] = status
        if status == Supporter.STATUS_ONLINE:
            online_sellers.append(seller)

    if len(online_sellers) == 0:
        #假设第一个客服是管理员
        seller = sellers[0]
    else:
        index = random.randint(0, len(online_sellers) - 1)
        seller = sellers[index]

    name = ""
    if seller.has_key('name') and seller['name']:
        name = seller['name'].split('@')[0]

    resp = {
        "seller_id":seller['id'], 
        "name":name,
        "status":seller["status"]
    }
    return resp
def login():
    if request.method == "POST":
        email_v = request.form.get("email")
        password_v = request.form.get("password")
        # check if email and password exists in db
        existing_seller = Seller.objects(seller_email=email_v).first()

        if existing_seller:
            # ensure hashed password matches user input
            password_valid = existing_seller.check_password(password_v)
            if password_valid:
                session["user"] = existing_seller.seller_name
                session["userId"] = str(existing_seller.id)
                flash(f"Welcome {existing_seller.seller_name}")
                return redirect(url_for("get_products"))
                return render_template("products.html", seller=existing_seller)

            else:
                # invalid password match
                flash("Incorrect Username and/or Password")
                return redirect(url_for("login"))

        else:
            # username doesn't exist
            flash("Incorrect Username and/or Password")
            return redirect(url_for("login"))

    return render_template("login.html")
예제 #13
0
def store_seller_post(store_id):
    """
    store 添加商店人员

    """
    db = g._imdb
    developer_id = session['user']['id']

    form = request.form
    name = form.get('name', '')
    password = form.get('password', '')
    number = form.get('number', '')
    if not name or not password or not store_id:
        return INVALID_PARAM()

    if not number:
        number = None
    password = md5.new(password).hexdigest()

    group_id = Store.get_store_gid(db, store_id)

    db.begin()
    seller_id = Seller.add_seller(db, name, password, store_id, group_id,
                                  number)
    Group.add_group_member(db, group_id, seller_id)
    db.commit()

    content = "%d,%d" % (group_id, seller_id)
    publish_message(g.im_rds, "group_member_add", content)

    return redirect(url_for('.store_seller', store_id=store_id))
def register():
    if request.method == "POST":
        seller_name_v = request.form.get("seller_name")
        seller_email_v = request.form.get("email")
        seller_phone_v = request.form.get("phone")
        seller_city_v = request.form.get("city")
        password_v = request.form.get("password")

        # check if username already exists in db
        existing_seller = Seller.objects(seller_email=seller_email_v).first()

        if existing_seller:
            flash("User already exists")
            return redirect(url_for("register"))

        new_seller = Seller(seller_name=seller_name_v,
                            seller_email=seller_email_v,
                            seller_city=seller_city_v,
                            seller_phone=seller_phone_v)

        new_seller.set_password(password_v)

        new_seller.save()

        # put the new user into 'session' cookie
        session["user"] = new_seller.seller_name
        session["userId"] = str(new_seller.id)

        print(session)
        print(new_seller.id)
        flash("Registration Successful!")
        return redirect(url_for("update_profile", userId=session["userId"]))
    return render_template("register.html")
예제 #15
0
def reset_password():
    if not request.data:
        raise MainException.ACCOUNT_PASSWORD_INVALID

    data = json.loads(request.data)
    code = data.get('code')
    password = data.get('password')
    password = generate_password_hash(password)

    if code:
        verify_email = Account.get_verify_email(
            g._db, code, EmailUsageType.SELLER_RESET_PWD)
        if verify_email:
            seller_id = verify_email['ro_id']
            Seller.set_seller_password(g._db, 0, seller_id, password)
            return MainException.OK

    raise MainException.ACCOUNT_INVALID_EMAIL_CODE
예제 #16
0
파일: api.py 프로젝트: jzxyouok/kefu_web
def delete_seller(store_id, seller_id):
    rds = g.im_rds
    db = g._imdb

    group_id = Store.get_store_gid(db, store_id)

    db.begin()
    Seller.delete_seller(db, store_id, seller_id)
    if group_id:
        Group.delete_group_member(db, group_id, seller_id)
    db.commit()

    Store.delete_seller_id(rds, store_id, seller_id)

    if group_id:
        content = "%d,%d"%(group_id, seller_id)
        publish_message(g.im_rds, "group_member_remove", content)

    return ""
예제 #17
0
파일: app.py 프로젝트: cdchinmoy/flaskjwt
def create_seller():
    data = request.get_json()
    hashed_password = generate_password_hash(data['password'], method='sha256')
    new_seller = Seller(id=str(uuid.uuid4()),
                        name=data['name'],
                        email=data['email'],
                        username=data['username'],
                        password=hashed_password)
    db.session.add(new_seller)
    db.session.commit()
    return jsonify({'message': 'New seller created'})
예제 #18
0
def ssignup():
    if request.method == 'POST':
        name = request.form['name']
        password = request.form['password']
        f = request.files['avatar']
        avatar = f.filename
        f.save(os.path.join(basedir + avatar))
        u = Seller(name=name, password=password, avatar=avatar)
        db.session.add(u)
        db.session.commit()
        return redirect(f'{prefix}/seller/signin')
        # return redirect('/seller/signin')
    return render_template('signup.html')
예제 #19
0
def SeedSellers():
    for seller_name in ['George', 'Paul', 'Ringo', 'John']:
        s1 = Seller(name=seller_name,
                    address="Abby Road",
                    city="Soho",
                    state="London",
                    email=seller_name + "@Beatles.com",
                    active=True)
        s1.save()

        for item_name in ['bird', 'house', 'chainsaw', 'motorcycle']:
            listing = ItemForSale(
                seller=s1,
                title=item_name + " for sale",
                description="great " + item_name + " for sale, like new.",
                price=50.00,
                listing_date=datetime.datetime.now()
            )
            listing.save()

    user = User.objects.create_user(username='******', password='******')
    user.is_staff = True
    user.save()
예제 #20
0
def verify_mail():
    """
    """
    email = request.form.get('email', '')
    password = request.form.get('password', '')
    password = generate_password_hash(password)

    account_obj = _get_account_by_email(g._db, email)
    if account_obj:
        raise MainException.ACCOUNT_DUPLICATE

    code = random_ascii_string(40)

    appid = config.KEFU_APPID
    db = g._db

    mode = 1  #fix_mode
    db.begin()
    store_id = Store.create_store(db, '', 0, mode, 0)
    account_id = Seller.add_seller(db, email, password, store_id, email, 0)
    Account.insert_verify_email(db, email, code, EmailUsageType.SELLER_VERIFY,
                                account_id)
    db.commit()

    Store.add_seller_id(g.im_rds, store_id, account_id)

    if 'user' not in session:
        session['user'] = {}

    session['user']['id'] = account_id
    session['user']['email'] = email
    session['user']['email_checked'] = 0
    session['user']['store_id'] = store_id
    session['user']['name'] = email

    account = {
        "id": account_id,
        "email": email,
        "email_checked": 0,
    }

    send_verify_email(email,
                      code,
                      email_cb=url_for('account.register_valid',
                                       code='',
                                       _external=True))

    return send_response(account)
예제 #21
0
    def test_seller(self):
        postal_address = PostalAddress(street_address="123 Carrot down road",
                                       locality="Warszawa",
                                       region="Mazowieckie",
                                       postal_code="01-222",
                                       country="Poland")

        nip = "111"
        #nip = "111"

        seller = Seller(company_name="AtomicSolutions",
                        postal_address=postal_address,
                        NIP=nip,
                        account_number="4435 4444 1111 0000 9999",
                        bank_name="Macros")

        print(seller)
예제 #22
0
파일: app.py 프로젝트: colaftc/ggtools
def add_seller():
    if request.method == 'POST':
        try:
            name = request.form['name']
            tel = request.form['tel']
            if len(name) < 2 or len(tel) < 11:
                flash('输入长度不足')
            elif not re.match('^\d{11}$', tel):
                flash('电话号码不正确')
            else:
                s = Seller(name=name, tel=tel)
                db.session.add(s)
                db.session.commit()
                flash('添加话务员成功')
        except Exception as e:
            print(e)
            flash('添加失败,请重新输入,如输入无误则可能由于称呼与电话已存在所致')
        return redirect(url_for('add_seller'))
    return render_template('add-seller.html', sellers=Seller.query.all())
예제 #23
0
파일: api.py 프로젝트: jzxyouok/kefu_web
def add_seller(store_id):
    rds = g.im_rds
    db = g._imdb
    form = request.form
    name = form.get('name', '')
    password = form.get('password', '')
    md5_password = form.get('md5_password', '')
    salt = form.get('salt', '')
    number = form.get('number', '')
    is_password_empty = not password and (not md5_password or not salt)

    if not name or is_password_empty or not store_id:
        return INVALID_PARAM()
        
    if not number:
        number = None

    if password:
        password = generate_password_hash(password)
    elif md5_password:
        password = "******"%(salt,md5_password)

    logging.debug("seller name:%s number:%s password md5:%s", name, number, md5_password)
    group_id = Store.get_store_gid(db, store_id)

    db.begin()
    seller_id = Seller.add_seller(db, name, password, store_id, number)
    if group_id:
        Group.add_group_member(db, group_id, seller_id)
    db.commit()

    Store.add_seller_id(rds, store_id, seller_id)

    if group_id:
        content = "%d,%d"%(group_id, seller_id)
        publish_message(g.im_rds, "group_member_add", content)

    obj = {"seller_id":seller_id}
    return make_response(200, obj)
예제 #24
0
def index(password):
    print >> sys.stderr, "within index"
    try:
        if password == PASSWORD:
            print >> sys.stderr, "within try"
            sellerList = Seller.select()
            smsList = SMS.select()
            numberList = Number.select()
            l = List.select()
            marketList = Market.select()
            lrList = ListRelationship.select()
            outboxList = Outbox.select()
            return render_template("index.html", title = 'TABLES', sellerList = sellerList, smsList = smsList, l = l, marketList = marketList)
            #return 'hello world'
        else:
            print >> sys.stderr, "wrong password"
    except:
        print >> sys.stderr, "within except"
        print >> sys.stderr, str(sys.exc_info()[0]) # These write the nature of the error
        print >> sys.stderr, str(sys.exc_info()[1])
        statement = 'An exception has Occured'+ str(sys.exc_type) + '[' + str(sys.exc_value) + ']'
        return statement
def list_product(userId):
    categories = Category.objects().all()
    seller = Seller.objects(id=userId).first()
    if request.method == "POST":
        category_id = request.form.get("category_id")
        product_name_v = request.form.get("product_name")
        product_price_v = request.form.get("product_price")
        product_description_v = request.form.get("product_description")
        product_photo_v = request.files["photo"]

        photo_url = upload_image("products", product_photo_v)

        # check if product is already listed
        existing_product = ProductListing.objects(
            product_name=product_name_v).first()

        category = Category.objects(id=category_id)
        if existing_product:
            flash("Product already listed")
            return redirect(url_for("list_product"))

        new_listing = ProductListing(category_id=category_id,
                                     product_name=product_name_v,
                                     product_price=product_price_v,
                                     product_description=product_description_v,
                                     seller_id=seller,
                                     product_photoURL=photo_url)

        new_listing.save()
        flash("Item listed")

        return redirect(url_for("list_product", userId=userId))

    return render_template("listing_page.html",
                           seller=seller,
                           categories=categories)
예제 #26
0
        else:
            logging.debug("unsupport msg type:%s", msg_type)
            obj = None

        now = int(time.time())
        if u.seller_id == 0:
            seller = get_one_supporter(db, rds, u.store_id)
            if not seller:
                logging.warning("no supporter:%d", u.store_id)
            else:
                logging.debug("got seller id:%s", seller['seller_id'])
                WXUser.set_seller_id(rds, gh_id, openid, seller['seller_id'])
                WXUser.set_seller_timestamp(rds, gh_id, openid, now)
                u.seller_id = seller['seller_id']
        elif now - u.seller_timestamp > 3600:
            sellers = Seller.get_sellers(db, u.store_id)
            if not sellers:
                raise ResponseMeta(400, 'store no supporter')

            deleted = True
            for s in sellers:
                if s['id'] == u.seller_id:
                    deleted = False
                    break

            if not deleted:
                WXUser.set_seller_timestamp(rds, gh_id, openid, now)
            else:
                #客服已经被删除
                seller = get_one_supporter(db, rds, u.store_id)
                if not seller:
예제 #27
0
def auth_callback(uid):
    rds = g.im_rds
    db = g._db
    auth_code = request.args.get('auth_code')
    expires_in = request.args.get('expires_in')
    if not auth_code or not expires_in:
        return "非法调用"

    seller = Seller.get_seller(db, uid)
    store_id = seller['store_id']

    logging.debug("auth callback code:%s uid:%s store_id:%s", 
                  auth_code, uid, store_id)

    component_token = get_component_access_token(rds)
    if not component_token:
        return "授权失败"

    wx = WXOpenAPI(APPID, APPSECRET, component_token)
    r = wx.request_auth(auth_code)
    if r:
        info = r['authorization_info']
        logging.debug("auth callback info:%s", info)
        wx_appid = info['authorizer_appid']
        access_token = info['authorizer_access_token']
        expires_in = info['expires_in']
        #提前10分钟过期
        if expires_in > 20*60:
            expires_in = expires_in - 10*60

        refresh_token = info['authorizer_refresh_token']
        funcs = info['func_info']
        fids = []
        for f in funcs:
            fid = f['funcscope_category']['id']
            fids.append(fid)

        is_app = False
        AUTHORIZATION_MESSAGE = 1
        AUTHORIZATION_CONTACT = 19
        if AUTHORIZATION_MESSAGE in fids:
            #公众号
            is_app = False
        elif AUTHORIZATION_CONTACT in fids:
            #小程序
            is_app = True
        else:
            logging.warning("no message authorization")
            return "没有消息权限"

        app_info = wx.request_info(wx_appid)
        if not app_info:
            logging.warning("request app info fail")
            return "获取公众号信息失败"
        name = app_info['authorizer_info']['nick_name']
        gh_id = app_info['authorizer_info']['user_name']

        app = App.get_wx(db, wx_appid)
        if app:
            Client.update_wx(db, wx_appid, refresh_token, 1)
            if app['store_id'] != 0 and app['store_id'] != store_id:
                return "已被其它账号授权"
            if app['store_id'] == 0:
                App.set_store_id(db, app['id'], store_id)
        else:
            App.create_wx(db, name, gh_id, wx_appid, refresh_token, store_id, is_app)
        WX.set_access_token(rds, wx_appid, access_token, expires_in)
        return "授权成功"
    else:
        return "获取令牌失败"
예제 #28
0
def handleAdd(request):
	try:
        		manager_id = request.session["manager_id"]
        		man = Man.objects.get(man_id=manager_id)
	except:
        		return render(request, 'manager/login.html')

	sellid = request.POST.get("sellid")
	sellname = request.POST.get("sellname")
	sellaccount = request.POST.get("sellaccount")
	sellpassword = request.POST.get("sellpassword")
	sellphone = request.POST.get("sellphone")
	sellwechat = request.POST.get("sellwechat")

	if len(sellid) != 4:
		return render(request, "manager/addseller.html", {"message": "编号必须为四位"})
	try:
		int(sellid)
	except:
		return render(request, "manager/addseller.html", {"message": "编号必须为四位数字"})
	seller = Seller()
	seller.sell_id = sellid
	seller.sell_phone = sellphone
	seller.sell_name = sellname
	seller.sell_account = sellaccount
	seller.sell_wechat = sellwechat
	seller.sell_password = sellpassword
	seller.sell_shop = manager_id
	seller.save()      	
	return showInforManager(request)
예제 #29
0
def auth_callback(uid):
    rds = g.im_rds
    db = g._db
    auth_code = request.args.get('auth_code')
    expires_in = request.args.get('expires_in')
    if not auth_code or not expires_in:
        return "非法调用"

    seller = Seller.get_seller(db, uid)
    store_id = seller['store_id']

    logging.debug("auth callback code:%s uid:%s store_id:%s", auth_code, uid,
                  store_id)

    component_token = get_component_access_token(rds)
    if not component_token:
        return "授权失败"

    wx = WXOpenAPI(APPID, APPSECRET, component_token)
    r = wx.request_auth(auth_code)
    if r:
        info = r['authorization_info']
        logging.debug("auth callback info:%s", info)
        wx_appid = info['authorizer_appid']
        access_token = info['authorizer_access_token']
        expires_in = info['expires_in']
        #提前10分钟过期
        if expires_in > 20 * 60:
            expires_in = expires_in - 10 * 60

        refresh_token = info['authorizer_refresh_token']
        funcs = info['func_info']
        fids = []
        for f in funcs:
            fid = f['funcscope_category']['id']
            fids.append(fid)

        is_app = False
        AUTHORIZATION_MESSAGE = 1
        AUTHORIZATION_CONTACT = 19
        if AUTHORIZATION_MESSAGE in fids:
            #公众号
            is_app = False
        elif AUTHORIZATION_CONTACT in fids:
            #小程序
            is_app = True
        else:
            logging.warning("no message authorization")
            return "没有消息权限"

        app_info = wx.request_info(wx_appid)
        if not app_info:
            logging.warning("request app info fail")
            return "获取公众号信息失败"
        name = app_info['authorizer_info']['nick_name']
        gh_id = app_info['authorizer_info']['user_name']

        app = App.get_wx(db, wx_appid)
        if app:
            Client.update_wx(db, wx_appid, refresh_token, 1)
            if app['store_id'] != 0 and app['store_id'] != store_id:
                return "已被其它账号授权"
            if app['store_id'] == 0:
                App.set_store_id(db, app['id'], store_id)
        else:
            App.create_wx(db, name, gh_id, wx_appid, refresh_token, store_id,
                          is_app)
        WX.set_access_token(rds, wx_appid, access_token, expires_in)
        return "授权成功"
    else:
        return "获取令牌失败"
예제 #30
0
        else:
            logging.debug("unsupport msg type:%s", msg_type)
            obj = None

        now = int(time.time())
        if u.seller_id == 0:
            seller = get_one_supporter(db, rds, u.store_id)
            if not seller:
                logging.warning("no supporter:%d", u.store_id)
            else:
                logging.debug("got seller id:%s", seller['seller_id'])
                WXUser.set_seller_id(rds, gh_id, openid, seller['seller_id'])
                WXUser.set_seller_timestamp(rds, gh_id, openid, now)
                u.seller_id = seller['seller_id']
        elif now - u.seller_timestamp > 3600:
            sellers = Seller.get_sellers(db, u.store_id)
            if not sellers:
                raise ResponseMeta(400, 'store no supporter')

            deleted = True
            for s in sellers:
                if s['id'] == u.seller_id:
                    deleted = False
                    break
                            
            if not deleted:
                WXUser.set_seller_timestamp(rds, gh_id, openid, now)
            else:
                #客服已经被删除
                seller = get_one_supporter(db, rds, u.store_id)
                if not seller: