def mct_update_super_money_pre(is_change):
     """
     是否开启超额提现开关 True为开启
                       False为关闭
     :return:
     """
     SqlSave.update_super_money(is_change)
    def get_amount():
        '''获取待结算表各账户的余额'''
        # 存管户
        depository_mch_accnt_no = ConfigManager.get_service(
            Constants.SubMerchant.DEPOSITORY)
        depository_event_amt = SqlSave.select_his_mch_accnt_keep_event_amt(
            depository_mch_accnt_no, 'depository')
        # 在途商户
        onway_mch_accnt_no = ConfigManager.get_service(
            Constants.SubMerchant.ONWAY)
        onway_event_amt = SqlSave.select_his_mch_accnt_keep_event_amt(
            onway_mch_accnt_no, 'onway')
        # 分润商户的损益金额
        profit_mch_accnt_no = ConfigManager.get_service(
            Constants.SubMerchant.PROFIT['profit_1'])
        profit_event_amt = SqlSave.select_his_mch_accnt_keep_event_amt(
            profit_mch_accnt_no, 'profit')
        # 子商户的金额
        mch_accnt_no = ConfigManager.get_service(
            Constants.SubMerchant.MUCSUB['mucsub_1'])
        mch_accnt_no_event_amt = SqlSave.select_his_mch_accnt_keep_event_amt(
            mch_accnt_no, 'pay')

        amount_list = [
            depository_event_amt, onway_event_amt, profit_event_amt,
            mch_accnt_no_event_amt
        ]

        return amount_list
 def mch_update_fixed_poundage(number=100, button=True):
     """
     清空fixed_poundage
     或设置费率为100
     :return:
     """
     SqlSave.mch_update_fixed_poundage(button, number)
示例#4
0
 def creat_download_info(channel, download_url, bill_data, typ, id='99999'):
     """创建解析对账单的数据"""
     SqlSave.insert_download_info(channel,
                                  download_url,
                                  bill_data,
                                  typ,
                                  id=id)
 def mct_promotion_remain_amt_pre(button):
     """
     在活动金额记账时使准备金账户的余额充足或不足
     :param button:
     :return:
     """
     SqlSave.update_remain_amt(button)
示例#6
0
 def machaccnt_refund_dispatch_clear(mch_ant_bef, mach_pay_up_obj):
     """退款记账数据清理"""
     for table_name in mch_ant_bef.keys():
         SqlSave.delete_amt_info_refund(table_name=table_name,
                                        trans_no=mach_pay_up_obj.trans_no)
     for oder_id in mach_pay_up_obj.oder_no_list:
         SqlSave.delete_mch_accnt_balance_record(oder_id=oder_id)
 def mch_update_prepay_amount(amt='1000', set_amt='1000'):
     """
     设置提现准备金账户余额和可结算余额
     :return:
     """
     mch = ConfigManager.get_service(Constants.SubMerchant.PREPAY['prepay_1'])
     SqlSave.update_amount(amt, set_amt, mch)
示例#8
0
 def withdrawal_clear(data):
     """提现记录数据清理"""
     order_no = data['data']['biz_content']['order_no']
     table_name = [Constants.TableName.WITH_DRAW_INFO, Constants.TableName.HIS_ACCNT_PROFILE,
                   Constants.TableName.HIS_ACCNT_MCH_SUB, Constants.TableName.HIS_SETTLED_AMOUNT,
                   Constants.TableName.HIS_ACCNT_PREPAY,Constants.TableName.MCH_CHARGE_UP]
     for tb in table_name:
         SqlSave.delete_withdrawal_info(table_name=tb, order_no=order_no)
 def mct_update_acct_type(button=True):
     """
     更改测试商户下分润商户的数量
     button为True   分润商户设置为0
     button为False  分润商户还原
     操作的商户分别为 PROFIT_1   PREPAY_2
     :return:
     """
     SqlSave.mct_update_acct_type(button)
示例#10
0
 def machaccnt_promotion_refund_dispatch_clear(exe_data):
     """活动退款记账数据清理"""
     trans_no = Base.get_trans_no(exe_data)
     table_name = [
         Constants.TableName.HIS_ACCNT_PREPAY,
         Constants.TableName.HIS_ACCNT_PROFILE,
         Constants.TableName.HIS_ACCNT_MCH_SUB
     ]
     for t_n in table_name:
         SqlSave.delete_amt_info(table_name=t_n, trans_no=trans_no)
 def amt_depository_and_prepay(mch, amount, Type, fix=False):
     """存管户计算"""
     amt = SqlSave.select_remain_amt(mch)  # 根据商户号查询余额
     fix_amount = SqlSave.select_fix_poundage()  # 查询手续费
     if Type:
         if fix:
             result_amt = int(amt[0][0]) - int(amount) + int(fix_amount)
         else:
             result_amt = int(amt[0][0]) - int(amount)
         return result_amt
     return amt[0][0]
 def amt_prepay(mch_prepay, mch_accnt, amount, Type):
     """准备金计算"""
     amt = SqlSave.select_remain_amt(mch_prepay)  # 根据商户号查询余额
     set = SqlSave.select_settled_amt(mch_accnt)  # 查询结算余额
     set_amt = ((0, ), ) if int(set[0][0]) <= 0 else set
     fix_amount = SqlSave.select_fix_poundage()  # 查询手续费
     if Type:
         result_amt = int(amt[0][0]) - (int(amount) - int(set_amt[0][0]) -
                                        int(fix_amount))
         return result_amt
     return amt[0][0]
 def mct_promotion_pre(button, all=False):
     """
     在提现时更改备用准备金账户类型为准备金
     :return:
     """
     # 多个准备金账户暂时不管
     if all:
         mch_no_list = [ConfigManager.get_service(Constants.SubMerchant.PREPAY['prepay_1']),
                        ConfigManager.get_service(Constants.SubMerchant.PREPAY['prepay_2'])]
     else:
         mch_no_list = [ConfigManager.get_service(Constants.SubMerchant.PREPAY['prepay_1'])]
     for i in mch_no_list:
         SqlSave.update_accnt_type(i, button=button)
 def amt_mch_accnt(mch, amount, Type):
     """子商户或分润计算  fix 是否有手续费,type是否为预期结果"""
     amt = SqlSave.select_remain_amt(mch)
     set_amt = SqlSave.select_settled_amt(mch)
     if Type:
         result_amt = int(amt[0][0]) - int(amount)
         result_set_amt = int(set_amt[0][0]) - int(amount)
         if int(set_amt[0][0]) <= 0:
             return result_amt, set_amt[0][0]
         if int(result_set_amt) < 0:
             return result_amt, 0
         return result_amt, result_set_amt
     return amt[0][0], set_amt[0][0]
 def amt_mch_profit(mch, amount, Type):
     """分润商户增加手续费计算"""
     amt = SqlSave.select_remain_amt(mch)
     set_amt = SqlSave.select_settled_amt(mch)
     fix_amount = SqlSave.select_fix_poundage()  # 查询手续费
     if Type:
         result_amt = int(amt[0][0]) + int(fix_amount)
         result_set_amt = int(set_amt[0][0]) + int(fix_amount)
         print('查询出来的amt::%s' % amt)
         print('查询出来的可结算余额::%s' % set_amt)
         print('传入的提现金额::%s' % amount)
         print('子商户或分润计算 amt+amount%s' % result_amt)
         return result_amt, result_set_amt
     return amt[0][0], set_amt[0][0]
 def precondition_reconciliation_result():
     """
     拿到预期结果的 手续费合计,对账单扣除手续费合计
     (手续费合计,对账单扣除手续费合计,是否对平)
     """
     a = SqlSave.select_reconciliation_result()
     return a
 def mct_update_amount_pre(unusual_parameter, amt='10000', set_amt='10000',
                           ):
     """
     设置提现专用子商户的余额和可结算余额amt, set_amt
     :return:
     """
     data = unusual_parameter['data']
     if not isinstance(data, dict):
         data = json.loads(data)
     data = data['biz_content']
     if data.get('mch_accnt_no') in Constants.SubMerchant.MUCSUB.keys():
         mch = ConfigManager.get_service(Constants.SubMerchant.MUCSUB[data.get('mch_accnt_no')])
     elif data.get('mch_accnt_no') in Constants.SubMerchant.PROFIT.keys():
         mch = ConfigManager.get_service(Constants.SubMerchant.PROFIT[data.get('mch_accnt_no')])
     else:
         mch = ConfigManager.get_service(Constants.SubMerchant.PREPAY[data.get('mch_accnt_no')])
     SqlSave.update_amount(amt, set_amt, mch)
 def timer_expected_results(type, *args):
     """校验定时器处理提现数据 type 为true 为预期, flase为实际 结构为 withdraw_status,status,remark"""
     if type:
         result_tuple = args
     else:
         result_tuple = SqlSave.select_withdraw_and_status()
     print(result_tuple)
     return result_tuple
示例#19
0
 def get_csv_name_from_db():
     """从数据库获取拉取对账单的数据"""
     csv_name_tuple = SqlSave.select_download_url()
     if len(csv_name_tuple) == 0:
         return [], [], 0
     csv_name_list = [i[0] for i in csv_name_tuple]
     csv_type_list = [i[1] for i in csv_name_tuple]
     return csv_name_list, csv_type_list, len(csv_name_tuple)
示例#20
0
 def err_data_clear(exe_data, trans_no=True):
     """特殊清理方法"""
     if trans_no is True:
         trans_no = Base.get_trans_no(exe_data)
     else:
         trans_no = trans_no
     table_name = [
         Constants.TableName.HIS_ACCNT_PREPAY,
         Constants.TableName.HIS_ACCNT_ONWAY,
         Constants.TableName.HIS_ACCNT_PROFILE,
         Constants.TableName.HIS_ACCNT_MCH_SUB
     ]
     oder_id = [
         'test1', 'test2', 'test3', 'test4', 'test5', 'test6', 'test10'
     ]
     for table_name in table_name:
         SqlSave.delete_amt_info(table_name=table_name, trans_no=trans_no)
     for id in oder_id:
         SqlSave.delete_mch_accnt_balance_record(oder_id=id)
 def precondition_reconciliation_result_info():
     """
     拿到问题件产生的类型 [问题件]
     :return:
     """
     result = []
     a = SqlSave.select_reconciliation_result_info()
     for i in a:
         result.append(i[0])
     return result
    def get_trans_amount_total(channel, is_change):
        """统计结算入账的总金额"""
        # 获取支付记账的金额
        data_list = Constants.CREATE().get_creat_pay_true_list()
        # 获取有转账的金额
        data_list2 = Constants.CREATE().get_creat_dispatch_true_list()
        trans_amount_no_transfer = 0
        if is_change == 1:
            for list in data_list:
                trans_amount_no_transfer = int(
                    list[1]) + trans_amount_no_transfer
            trans_amount_transfer = 0
            for list2 in data_list2:
                trans_amount_transfer = trans_amount_transfer + int(list2[5])

            trans_amount_total = trans_amount_no_transfer + trans_amount_transfer
            return trans_amount_total
        elif is_change == 2:
            for list in data_list:
                trans_amount_no_transfer = int(
                    list[1]) + trans_amount_no_transfer
            trans_amount_transfer = 0
            for list2 in data_list2:
                trans_amount_transfer = trans_amount_transfer + int(list2[5])

            acc_mch_id = ''
            if hasattr(Constants.CHANNEL, channel):
                acc_mch_id = getattr(Constants.CHANNEL, channel)

            channel_rate = float(SqlSave.select_settle_change(acc_mch_id))

            # 支付记账手续费
            trans_amount_no_transfer_rate = 0
            for list in data_list:
                trans_amount_no_transfer_rate = round(
                    int(list[1]) * channel_rate,
                    0) + trans_amount_no_transfer_rate
            # 获取转账的手续费
            trans_amount_transfer_rate = 0
            for list2 in data_list2:
                trans_amount_transfer_rate = round(
                    int(list2[4][0][0]) * channel_rate,
                    0) + trans_amount_transfer_rate

            # 计算应扣的手续费
            rate_amount = int(trans_amount_no_transfer_rate +
                              trans_amount_transfer_rate)

            trans_amount_total = trans_amount_no_transfer + trans_amount_transfer - rate_amount

            return trans_amount_total
    def public_handle(self, channel, is_change):
        """进行存管户和在途账户的金额校验"""
        result = SqlSave.select_reconciliation_result_settle(channel)
        recon_amt = result[2]
        profit_loss_amt = result[3]
        depository_mch_accnt_no = ConfigManager.get_service(
            Constants.SubMerchant.DEPOSITORY)
        depository_event_amt = SqlSave.select_his_mch_accnt_keep_event_amt(
            depository_mch_accnt_no, 'depository')

        self.assertEqual(depository_event_amt, recon_amt)

        onway_mch_accnt_no = ConfigManager.get_service(
            Constants.SubMerchant.ONWAY)
        onway_event_amt = SqlSave.select_his_mch_accnt_keep_event_amt(
            onway_mch_accnt_no, 'onway')

        self.assertEqual(onway_event_amt, recon_amt)

        profit_mch_accnt_no = ConfigManager.get_service(
            Constants.SubMerchant.PROFIT['profit_1'])
        profit_event_amt = SqlSave.select_his_mch_accnt_keep_event_amt(
            profit_mch_accnt_no, 'profit')

        self.assertEqual(profit_event_amt, profit_loss_amt)

        # 进行子商户的金额校验
        mch_accnt_no = ConfigManager.get_service(
            Constants.SubMerchant.MUCSUB['mucsub_1'])

        mch_accnt_no_event_amt = SqlSave.select_his_mch_accnt_keep_event_amt(
            mch_accnt_no, 'pay')

        trans_amount_total = HandleSettle.get_trans_amount_total(
            channel, is_change)

        self.assertEqual(trans_amount_total, mch_accnt_no_event_amt)
 def info_assert_amt_mch_accnt(self, Type, **kwargs):
     """
     子商户或分润明细预期结果生成
     with_draw_info_index  提现明细数量
     mch_accnt_info_index  提现账户明细数量
     his_settled_amount_index 结算金额明细数量
     profit_index 分润账户明细数量
     propay_index 准备金账户明细数量
     """
     if Type:
         dic = MachAntWithdrawUp.info_assert_kwargs()
         dic['with_draw_info_index'] = kwargs[
             'with_draw_info_index']  # 提现明细数量
         dic['mch_accnt_info_index'] = kwargs[
             'mch_accnt_info_index']  # 提现账户明细数量
         dic['his_settled_amount_index'] = kwargs[
             'his_settled_amount_index']  # 结算金额记录明细数量
         dic['profit_index'] = kwargs['profit_index']  # 分润账户明细数量
         dic['propay_index'] = kwargs['propay_index']  # 准备金账户明细数量
         return dic
     table_name_list = [
         Constants.TableName.WITH_DRAW_INFO,
         Constants.TableName.HIS_ACCNT_MCH_SUB,
         Constants.TableName.HIS_SETTLED_AMOUNT,
         Constants.TableName.HIS_ACCNT_PROFILE,
         Constants.TableName.HIS_ACCNT_PREPAY
     ]
     dic_key_list = [
         'with_draw_info_index', 'mch_accnt_info_index',
         'his_settled_amount_index', 'profit_index', 'propay_index'
     ]
     dic = MachAntWithdrawUp.info_assert_kwargs()
     for index in range(len(table_name_list)):
         result = SqlSave.mch_select_info(table_name_list[index])
         if len(result) == 0:
             dic[dic_key_list[index]] = ''
         dic[dic_key_list[index]] = len(result)
     return dic
 def mct_update_amount_for_prepay_pre(amt='10000', set_amt='10000'):
     """
     在提现时更改准备金账户金额,默认为10000
     :return:
     """
     SqlSave.update_amount_for_prepay(amt, set_amt)
 def clear_mch_account_details():
     """清理解析表里的测试数据"""
     SqlSave.delete_mch_account_details()
 def clear_down_load_info():
     """清理download_info的数据"""
     SqlSave.delete_download_info()
 def update_pay_url(pay_type):
     """更新提现真实请求的接口,模拟返回"""
     SqlSave.update_pay_url(pay_type)
示例#29
0
 def machaccnt_promotion_dispatch_clear(mch_ant_bef, mach_pay_up_obj):
     """活动记账数据清理"""
     for table_name in mch_ant_bef.keys():
         SqlSave.delete_amt_info(table_name=table_name,
                                 trans_no=mach_pay_up_obj.trans_no)
 def update_card_name(button):
     """修改银行卡姓名"""
     SqlSave.update_card_name(button)