当前位置: 首页>>代码示例>>Python>>正文


Python UserModel.get_user_by_merchantid_username方法代码示例

本文整理汇总了Python中models.user.UserModel.get_user_by_merchantid_username方法的典型用法代码示例。如果您正苦于以下问题:Python UserModel.get_user_by_merchantid_username方法的具体用法?Python UserModel.get_user_by_merchantid_username怎么用?Python UserModel.get_user_by_merchantid_username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.user.UserModel的用法示例。


在下文中一共展示了UserModel.get_user_by_merchantid_username方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_order_sms

# 需要导入模块: from models.user import UserModel [as 别名]
# 或者: from models.user.UserModel import get_user_by_merchantid_username [as 别名]
def send_order_sms(self, merchant_id, hotel_name, order_id, confirm_type):
    Log.info(u">>> send sms to merchant {} hotel {} order_id {} confirm type {}".format(merchant_id, hotel_name, order_id, confirm_type))

    order = OrderModel.get_by_id(self.session, order_id)
    breakfast_str = u'含早' if order.get_has_breakfast() else u'无早'
    customers = json.loads(order.customer_info)
    customer_str = " ".join([customer['name'] for customer in customers])


    if confirm_type == OrderModel.CONFIRM_TYPE_AUTO:
        content = u"尊敬的用户您好,系统收到编号{}自动确认订单:{},房型:{},入离日期:{}至{}( {}晚 ),入住人:{},总价:{},{}。订单号:{},请及时关注。客服联系电话:4006103330".format(merchant_id, hotel_name, order.roomtype_name, order.checkin_date, order.checkout_date, order.get_stay_days(), customer_str, order.total_price / 100, breakfast_str, order_id)
    elif confirm_type == OrderModel.CONFIRM_TYPE_MANUAL:
        content = u"尊敬的用户您好,系统收到编号{}待确认订单:{},房型:{},入离日期:{}至{}( {}晚 ),入住人:{},总价:{},{}。订单号:{},请尽快处理。客服联系电话:4006103330".format(merchant_id, hotel_name, order.roomtype_name, order.checkin_date, order.checkout_date, order.get_stay_days(), customer_str, order.total_price / 100, breakfast_str, order_id)
    send_sms_to_service(merchant_id, content)

    user =UserModel.get_user_by_merchantid_username(self.session, merchant_id, 'admin')
    if not user:
        Log.info("send sms no user(order {})".format(order_id))
        return
    phone = user.mobile
    if not phone:
        Log.info("send sms no phone(order {})".format(order_id))
        return

    Log.info(">> send sms to {}".format(phone))
    Log.info(u">> sms content: {}".format(content))
    
    send_sms([phone], content)
开发者ID:icyCloud,项目名称:test_e_b_k,代码行数:30,代码来源:sms.py

示例2: post

# 需要导入模块: from models.user import UserModel [as 别名]
# 或者: from models.user.UserModel import get_user_by_merchantid_username [as 别名]
    def post(self):
        args = self.get_json_arguments()
        merchant_id, username, password, re_password, department, mobile, authority, is_valid = \
            get_and_valid_arguments(
                args, 'merchant_id', 'username', 'password', 're_password', 'department', 'mobile',
                'authority', 'is_valid')

        hotel_id = None
        if 'hotel_id' in args:
            hotel_id = args['hotel_id']
            try:
                hotel_id = int(hotel_id)
                authority = 0
                authority += PERMISSIONS.update_order
                authority += PERMISSIONS.view_cooperated_hotel
                authority += PERMISSIONS.view_order
                authority += PERMISSIONS.inventory
                authority += PERMISSIONS.pricing
                authority += PERMISSIONS.update_password
            except Exception:
                self.finish_json('1', u'不合法的酒店')
                return

        if merchant_id != self.current_user.merchant_id:
            self.finish_json(1, u'您只能管理自己的酒店')
            return
        if not username:
            self.finish_json(1, u'请填写用户名')
            return
        if (not password) or (not re_password):
            self.finish_json(1, u'请输入密码')
            return
        if password != re_password:
            self.finish_json(1, u'两次密码不一致')
            return
        if not department:
            self.finish_json(1, u'请输入部门')
            return
        if not mobile:
            self.finish_json(1, u'请输入手机号')
            return
        if authority & PERMISSIONS.admin or authority & PERMISSIONS.root:
            self.finish_json(1, u'不允许添加管理员用户')
            return

        user = UserModel.get_user_by_merchantid_username(
            self.db, merchant_id, username)

        if user:
            self.finish_json(1, u'用户名已被使用')
        else:
            UserModel.add_user(self.db, merchant_id, username,
                               password, department, mobile, authority, is_valid, hotel_id)
            self.finish_json(0, u'添加成功')
开发者ID:icyCloud,项目名称:test_e_b_k,代码行数:56,代码来源:user.py

示例3: get_current_user

# 需要导入模块: from models.user import UserModel [as 别名]
# 或者: from models.user.UserModel import get_user_by_merchantid_username [as 别名]
    def get_current_user(self):
        # check wechat login first
        yield self.valid_wechat_login()

        username = self.get_secure_cookie('username')
        merchant_id = self.get_secure_cookie('merchant_id')
        if username and merchant_id:
            self.set_secure_cookie('username', username, expires_days=0.02)
            self.set_secure_cookie('merchant_id', merchant_id, expires_days=0.02)
            self.merchant = MerchantModel.get_by_id(self.db, merchant_id)
            self.current_user = UserModel.get_user_by_merchantid_username(self.db, merchant_id, username)
            self.current_user.hotel_id = None
            if self.current_user.type == UserModel.TYPE_SUB:
                maps = UserHotelMappingModel.get_hotel_by_id(self.db, self.current_user.id, merchant_id)
                if maps:
                    self.current_user.hotel_id = maps[0].hotel_id
        raise gen.Return(self.current_user)
开发者ID:icyCloud,项目名称:test_e_b_k,代码行数:19,代码来源:base.py


注:本文中的models.user.UserModel.get_user_by_merchantid_username方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。