當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。