Пример #1
0
def init_merchant_user(merchant_id, merchant_name, password):
    from app.main import flask_app
    from app.libs.string_kit import RandomString
    if not password:
        password = RandomString.gen_random_str(10,
                                               (CharOp.N, CharOp.L, CharOp.U))

    with flask_app.app_context():
        from scripts.init_data import InitData
        InitData.merchant_name = merchant_name
        InitData.merchant_id = merchant_id
        InitData.password = RandomString.gen_md5_string(
            password.encode('utf8'))

        merchant = InitData.get_merchant_user()
        if not merchant:
            InitData.init_merchant_user()
            merchant = InitData.get_merchant_user()
            print("Merchant generated, merchant: %s, password: %s" %
                  (merchant_name, password))
        else:
            merchant.reset_password(mid=merchant_id,
                                    password=InitData.password)
            print("password changed, merchant: %s, password: %s" %
                  (merchant_name, password))

        rst = merchant.verify_login(merchant_name, InitData.password)
        if rst:
            return merchant_name, password
    return None, None
Пример #2
0
def init_admin_user(account, password):
    from app.main import flask_app
    from app.libs.string_kit import RandomString
    from scripts.init_data import InitData

    if not password:
        password = RandomString.gen_random_str(10,
                                               (CharOp.N, CharOp.L, CharOp.U))

    with flask_app.app_context():
        InitData.admin_user_account = account
        InitData.password = RandomString.gen_md5_string(
            password.encode('utf8'))

        admin = InitData.get_admin_user()
        if not admin:
            InitData.init_admin_user()
            admin = InitData.get_admin_user()
            print("account generated, admin: %s, password: %s" %
                  (account, password))
        else:
            admin.reset_password(account=account, login_pwd=InitData.password)
            print("password changed, admin: %s, password: %s" %
                  (account, password))

        rst = admin.verify_login(account, InitData.password)
        print('verify login %s' % rst)

        if rst:
            return account, password

    return None, None
Пример #3
0
 def generate_sign(self, params: dict):
     """
     生成签名
     :param params:
     :return:
     """
     raw_str = self.join_sign_str(params)
     raw_str += '&key=' + self.get_secret_key()
     sign = RandomString.gen_md5_string(raw_str.encode('utf8')).upper()
     return sign
Пример #4
0
 def generate_sign(request_fields_str, third_config):
     """
     生成签名
     :param merchant_id: 通道分配给我们的商户ID
     :param channel_tx_id: 通道交易ID(由通道侧生成)
     :param tx_amount: 实际支付金额
     :return:
     """
     sign_str = request_fields_str + "&key="
     sign_str += third_config['secret_key']
     return RandomString.gen_md5_string(sign_str.encode("utf8")).upper()
Пример #5
0
 def generate_sign(cls, merchant_id, channel_tx_id, tx_amount):
     """
     生成签名
     :param merchant_id: 通道分配给我们的商户ID
     :param channel_tx_id: 通道交易ID(由通道侧生成)
     :param tx_amount: 实际支付金额
     :return:
     """
     sign_str = "".join([merchant_id, channel_tx_id, tx_amount])
     sign_str += cls.third_config['secret_key']
     return RandomString.gen_md5_string(sign_str.encode("gb2312")).lower()
Пример #6
0
 def generate_sign(cls, request_fields_str):
     """
     生成签名
     :param merchant_id: 通道分配给我们的商户ID
     :param channel_tx_id: 通道交易ID(由通道侧生成)
     :param tx_amount: 实际支付金额
     :return:
     """
     sign_str = request_fields_str + "&key="
     sign_str += cls.third_config['secret_key']
     current_app.logger.info('sign data: %s', sign_str)
     return RandomString.gen_md5_string(sign_str.encode("utf8")).upper()
Пример #7
0
 def generate_sign(self, params: dict):
     """
     生成签名
     :param params:
     :return:
     """
     raw_str = self.join_sign_str(params)
     raw_str += '&secret_key=' + self.get_secret_key()
     print('raw_str:', raw_str)
     sign = RandomString.gen_md5_string(raw_str.encode('utf8'))
     print('sign:', sign)
     return sign
Пример #8
0
 def generate_sign(self, params: dict):
     """
     生成签名
     :param params:
     :return:
     """
     raw_str = self.join_sign_str(params)
     raw_str += '&key=' + self.get_secret_key()
     # current_app.logger.info('raw_str: %s', raw_str)
     # current_app.logger.info('raw_str utf8: %s', raw_str.encode('utf8'))
     sign = RandomString.gen_md5_string(raw_str.encode('utf8')).upper()
     return sign
Пример #9
0
    def generate_sign(self, corderid, money):
        """
        merchant_id	商户编号	是	 商户号
        corderid	订单号	是	 商户订单号
        money	订单金额	是	 订单金额
        status	交易状态	否	1 为已成功,2,为作废(金额退回)。
        sign	签名	否

        string  parastring =  merchant_id + corderid + money + key;
        sign=MD5(parastring);
        """
        params_string = ''.join([
            self.third_config['mch_id'], corderid,
            str(money), self.third_config['secret_key']
        ])
        return RandomString.gen_md5_string(
            params_string.encode("gb2312")).upper()