def goods_get(): f = request.args.get('f', 'search') goodsDao = GoodsDao() schema = GoodsSchema() res = {} key_words = request.args.get('kwd', '') page = int(request.args.get('page', 1)) page_size = int(request.args.get('page_size', 30)) args = {} args['cate'] = str(request.args.get('cate', '')) args['order'] = request.args.get('order', '') args['activity'] = int(request.args.get('activity', 0)) args['classes'] = request.args.get('cls', '') if len(args['cate']) == 2: args['classes'] = args['cate'] pagination = goodsDao.search(key_words, page, page_size, **args) res['items'] = schema.dump(pagination.items, many=True).data res['page'] = { 'pages': pagination.pages, 'page': pagination.page, 'has_next': pagination.has_next } return resp_200(res)
def get_user_orders(): userOrderDao = UserOrdersDao() userOrdersSchema = UserOrdersSchema() orders = userOrdersSchema.dump(userOrderDao.get_orders_by_user(g.user.id), many=True).data return resp_200(orders)
def goods_taokouling(id): goodsDao = GoodsDao() goods = goodsDao.get_by_id(id) tkl = goodsDao.get_tkl_by_url(goods.googs_coupon_buy_url) if tkl is None: return resp_500('淘口令生成失败, 请稍候再试') tkl = "[" + goods.goods_name + "]\n复制这条信息, " + tkl + ", 打开手机淘宝, 即可在手机淘宝中领券购买. 来自[一起淘券网(17taoquan.wang)]优惠分享" return resp_200(tkl)
def goods_details(id): goodsDao = GoodsDao() schema = GoodsSchema() res = {} goods = goodsDao.get_by_id(id) if goods is not None: res = schema.dump(goods).data else: res = {} return resp_200(res)
def regist(): username = request.form.get('username', '') nickname = request.form.get('nickname', '') password = request.form.get('password', '') re_password = request.form.get('re_password', '') if password != re_password: return resp_500('两次密码不一致') user = User.query.filter_by(user_id=username).first() if user: return resp_500('用户名:' + username + '已存在') userDao = UserDao() user = {'username': username, 'nickname': nickname, 'password': password} userDao.add(user) return resp_200('新增成功')
def add_user_orders(mall_order_id): userOrderDao = UserOrdersDao() userOrderDao.add(g.user.id, mall_order_id) return resp_200('关联成功')
def token(): token = g.user.generate_auth_token() return resp_200(token)
def userinfo(): schema = UserSchema() result = schema.dump(g.user) return resp_200(result.data)
def goods_order_get(): goodsOrderDao = GoodsOrderDao() res = goodsOrderDao.get_order() return resp_200(res)
def goods_class_get(): classSchema = GoodsClassSchema() goodsClassDao = GoodsClassDao() res = classSchema.dump(goodsClassDao.get_cls(), many=True).data return resp_200(res)
def get_wallet_info(): res = {} walletDao = WalletDao() res['cf_amt'] = walletDao.get_cf_amt(g.user.id) return resp_200(res)