Exemple #1
0
    def save(self, user_profile, account, commit=False):
        money_with_draw = super(MoneyWithdrawViewForm, self).save(commit=False)
        user_bank_info = UserBanknInfo.objects.get(userProfile=user_profile)
        money_with_draw.charge = Decimal(BidConst.MONEY_WITHDRAW_CHARGEFEE())
        money_with_draw.bankName = user_bank_info.bankForkName
        money_with_draw.accountName = user_bank_info.accountName
        money_with_draw.accountNumber = user_bank_info.accountNumber
        money_with_draw.bankForkName = user_bank_info.bankForkName
        money_with_draw.applier = user_profile
        #用户添加状态码
        user_profile.addState(BitStatesUtils.GET_HAS_MONEYWITHDRAW_PROCESS())
        user_profile.save()

        #生成提现流水
        account.usableAmount = account.usableAmount - Decimal(
            self.cleaned_data.get('moneyAmount'))
        account.freezedAmount = account.freezedAmount + Decimal(
            self.cleaned_data.get('moneyAmount'))
        self.generateMoneyWithDrawApplyFlow(account=account,
                                            money_with_draw=money_with_draw)

        account.save()
        money_with_draw.save()
        return money_with_draw
Exemple #2
0
    def save_models(self):
        #获取保持对象
        obj = self.new_obj
        obj.save()
        if obj is not None:
            withdraw_audit = obj
            withdraw_audit.auditor = self.user.username
            withdraw_audit.audiTime = timezone.now()
            account = Account.objects.get(userProfile=withdraw_audit.applier)
            #如果审核成功
            if withdraw_audit.state == BitStatesUtils.STATE_AUDIT():
                # // 1, 对借款要做什么事情?
                # // ** 1.1
                # // 3, 如果审核通过
                # // 1, 冻结金额减少(减少手续费), 增加提现支付手续费流水;
                account.freezedAmount = account.freezedAmount - withdraw_audit.charge
                self.generateWithDrawChargeFeeFlow(w=withdraw_audit, account=account)
                # // 2, 系统账户增加可用余额, 增加收取提现手续费流水;
                self.generateChargeWithdrawFeeFlow(w=withdraw_audit)

                # // 3, 冻结金额减少(减少提现金额);增加提现成功流水;
                realWithdrawFee = withdraw_audit.moneyAmount - withdraw_audit.charge
                account.freezedAmount = account.freezedAmount - realWithdrawFee
                self.generateWithDrawSuccessFlow(realWithdrawFee=realWithdrawFee,account=account)

            elif withdraw_audit.state == BitStatesUtils.STATE_REJECT():
                # // 4, 如果审核拒绝
                # // 1, 取消冻结金额, 可用余额增加, 增加去掉冻结流水
                account.freezedAmount = account.freezedAmount - withdraw_audit.moneyAmount
                account.usableAmount = account.usableAmount + withdraw_audit.moneyAmount
                self.generateWithDrawFailedFlow(w=withdraw_audit,account=account)

            account.save()
            # 去除用户的提现状态码
            withdraw_audit.applier.removeState(BitStatesUtils.GET_HAS_MONEYWITHDRAW_PROCESS())
            withdraw_audit.save()
Exemple #3
0
 def isMoneyWithoutProcess(self):
     return BitStatesUtils.hasState(
         self.bitState, BitStatesUtils.GET_HAS_MONEYWITHDRAW_PROCESS())