def save_models(self): #获取保持对象 obj = self.new_obj obj.save() if obj is not None: bid_audit = obj bid_audit.auditor = self.user.username bid_audit.audiTime = timezone.now() bid_request = bid_audit.bidRequestId #如果审核成功 if bid_audit.state == BitStatesUtils.STATE_AUDIT(): #给标添加状态信息 bid_request.bidRequestState = BidConst.GET_BIDREQUEST_STATE_APPROVE_PENDING_2() #满标二审状态 bid_request.note = bid_audit.remark #添加满标二审历史 self.createBrAuditHistory(bid_request) elif bid_audit.state == BitStatesUtils.STATE_REJECT(): #审核失败,修改借款状态 bid_request.bidRequestState = BidConst.GET_BIDREQUEST_STATE_REJECTED() #满标审核拒绝 #进行退款 self.retureMoney(bid_request) #移出借款人借款状态码 bid_request.createUser.userProfile.removeState(BitStatesUtils.GET_OP_HAS_BIDREQUEST_PROCESS()) bid_request.createUser.userProfile.save() #保存模型 bid_request.save() bid_audit.save()
class MoneyWithdraw(BaseAudit): moneyAmount = models.DecimalField(max_digits=18, decimal_places=BidConst.STORE_SCALE(), default=BidConst.ZERO(), verbose_name="提现金额") # // 提现金额 charge = models.DecimalField(max_digits=18, decimal_places=BidConst.STORE_SCALE(), default=BidConst.ZERO(), verbose_name="提现手续费") #// 提现手续费 bankName = models.CharField(max_length=50, blank=True, null=True, verbose_name="银行名称") # // 银行名称 accountName = models.CharField(max_length=50, blank=True, null=True, verbose_name="开户人姓名") # // 开户人姓名 accountNumber = models.CharField(max_length=50, blank=True, null=True, verbose_name="银行账号") # // 银行账号 bankForkName = models.CharField(max_length=50, blank=True, null=True, verbose_name="开户支行") # // 开户支行I class Meta: verbose_name = u"提现审核" verbose_name_plural = verbose_name
class Bid(models.Model): actualRate = models.DecimalField( max_digits=18, decimal_places=BidConst.STORE_SCALE(), default=BidConst.ZERO(), verbose_name="年化利率") #// (等同于bidrequest上的currentRate) availableAmount = models.DecimalField( max_digits=18, decimal_places=BidConst.STORE_SCALE(), default=BidConst.ZERO(), verbose_name="这次投标金额") # // 这次投标金额 bidRequestId = models.ForeignKey( BidRequest, related_name='bids', verbose_name=u"借款标来源", on_delete=models.CASCADE) #// 关联借款 来自于哪个借款标 bidRequestTitle = models.CharField(max_length=50, blank=True, null=True, verbose_name="借款标题") #// 冗余数据, 等同于借款标题 bidUser = models.ForeignKey(Investor, verbose_name=u"投标人", on_delete=models.CASCADE) #// 借款人#// 投标人 bidTime = models.DateTimeField(blank=True, null=True, verbose_name=u"投标时间") #// 投标时间 class Meta: verbose_name = u"一次投资对象表" verbose_name_plural = verbose_name
def calTotalInterest(cls,returnType, bidRequestAmount, yearRate, monthes2Return): # cls.cal_set() bidRequestAmount = Decimal(str(bidRequestAmount)) yearRate = Decimal(str(yearRate)) totalInterest = Decimal('0.0000') monthlyRate = cls.getMonthlyRate(yearRate) if returnType == BidConst.GET_RETURN_TYPE_MONTH_INTEREST_PRINCIPAL(): #按月分期 #只借款一个月 if monthes2Return == 1: totalInterest = bidRequestAmount * monthlyRate else: temp1 = bidRequestAmount * monthlyRate temp2 = pow((Decimal('1') + monthlyRate), monthes2Return) temp3 = pow((Decimal('1') + monthlyRate),monthes2Return) - Decimal('1') #计算每月还款 monthToReturnMoney = (temp1 * temp2) / temp3 #计算总还款 totalReturnMoney = monthToReturnMoney * Decimal(str(monthes2Return)) #算出利息 totalInterest = totalReturnMoney - bidRequestAmount elif returnType == BidConst.GET_RETURN_TYPE_MONTH_INTEREST(): #按月到期 monthlyInterest = DecimalFormatUtil.amountformat((bidRequestAmount * monthlyRate)) totalInterest = monthlyInterest * monthes2Return return DecimalFormatUtil.formatBigDecimal(totalInterest, BidConst.STORE_SCALE())
def post(self, request): #// 检查, 得到借款信息 query = BidRequest.objects.filter(id=request.POST.get('bidRequestId')) loaner_bid_amount = Decimal(request.POST.get('amount')) #获取贷款款账户 loaner_account = Account.objects.get(userProfile=request.user) #如何借款信息存在 if query.exists(): #获得借款信息对象 bid_request = query.first() # 1,借款状态为招标中; 2,当前用户不是借款的借款人; 3,当前用户账户余额>=投标金额; 4,投标金额>=最小投标金额; 5,投标金额<=借款剩余投标金额; if bid_request.minBidAmount <= loaner_bid_amount \ and bid_request.bidRequestState == BidConst.GET_BIDREQUEST_STATE_BIDDING() \ and bid_request.createUser.userProfile.id != loaner_account.userProfile.id \ and loaner_account.usableAmount >= loaner_bid_amount \ and bid_request.getRemainAmount() >= loaner_bid_amount: # // 执行投标操作 # // 1, 创建一个投标对象; # 设置相关属性; bid_form = BidForm() bid_form.save(user=request.user, bid_request=bid_request, loaner_bid_amount=loaner_bid_amount) #2, 得到投标人账户, 修改账户信息; loaner_account.usableAmount = loaner_account.usableAmount - loaner_bid_amount loaner_account.freezedAmount = loaner_account.freezedAmount + loaner_bid_amount loaner_account.save() #// 3,生成一条投标流水; account_flow = AccountFlowForm() account_flow.save(loaner_account=loaner_account, loaner_bid_amount=loaner_bid_amount) # // 4, 修改借款相关信息; bid_request.bidCount = bid_request.bidCount + 1 bid_request.currentSum = bid_request.currentSum + loaner_bid_amount bid_request.save() #// 判断当前标是否投满: if bid_request.bidRequestAmount == bid_request.currentSum: # // 1, 修改标的状态;,满标一审 bid_request.bidRequestState = BidConst.GET_BIDREQUEST_STATE_APPROVE_PENDING_1( ) bid_request.save() #生成满标一审 self.createBrAuditHistory(bid_request=bid_request) print(bid_request.bids.all()) return HttpResponse('{"status":"success", "message":"投标成功"}', content_type='application/json') return HttpResponse('{"status":"failure", "message":"投标失败"}', content_type='application/json')
def get_investor_nums(self, year, month): # 统计借款人数 bid_request_query = BidRequest.objects.filter( (Q(bidRequestState=BidConst.GET_BIDREQUEST_STATE_PAYING_BACK()) | Q(bidRequestState=BidConst.GET_BIDREQUEST_STATE_BIDDING())) & Q(applyTime__month=month) & Q(applyTime__year=year)) if bid_request_query.exists(): return bid_request_query.count() else: return 0
def createPaymentScheduleDetail(self,payment_schedule, br): bids = br.bids.values_list('bidUser') # 取出所有投标用户id, 并去重 bid_user_ids = list(set((list(zip(*bids)))[0])) # // 汇总利息和本金, 用于最后一个投标的用户的利息和本金计算 total_amount = Decimal('0') for idx, bid_user_id in enumerate(bid_user_ids): # 获取所有投资人 bids_temp_query = br.bids.filter(bidUser_id=bid_user_id) #获取单个投资人 bid = bids_temp_query.first() # 获取相同投资人投的标数量 # 统计投资金额 available_amount_total = bids_temp_query.aggregate(Sum('availableAmount')) payment_schedule_detail = PaymentScheduleDetail.objects.create(bidId=bid) payment_schedule_detail.bidAmount = available_amount_total['availableAmount__sum'] payment_schedule_detail.bidRequestId = br payment_schedule_detail.deadline = payment_schedule.deadLine #还款人 payment_schedule_detail.borrower = br.createUser if idx == len(bid_user_ids) - 1: payment_schedule_detail.totalAmount = payment_schedule.totalAmount - total_amount # // 计算利息 interest = DecimalFormatUtil.formatBigDecimal( data=(available_amount_total['availableAmount__sum'] / br.bidRequestAmount) * payment_schedule.interest, scal=BidConst.STORE_SCALE() ) payment_schedule_detail.interest = interest payment_schedule_detail.principal = payment_schedule_detail.totalAmount - payment_schedule_detail.interest else: # // 计算利息 interest = DecimalFormatUtil.formatBigDecimal( data=(available_amount_total['availableAmount__sum'] / br.bidRequestAmount) * payment_schedule.interest, scal=BidConst.STORE_SCALE() ) # // 计算本金 principal = DecimalFormatUtil.formatBigDecimal( data=(available_amount_total['availableAmount__sum'] / br.bidRequestAmount) * payment_schedule.principal, scal=BidConst.STORE_SCALE() ) payment_schedule_detail.interest=interest payment_schedule_detail.principal = principal payment_schedule_detail.totalAmount = interest + principal total_amount = total_amount + payment_schedule_detail.totalAmount payment_schedule_detail.monthIndex = payment_schedule.monthIndex payment_schedule_detail.paymentScheduleId = payment_schedule #//投资人 payment_schedule_detail.investor = bid.bidUser payment_schedule_detail.save()
class SystemAccount(models.Model): usableAmount = models.DecimalField(max_digits=18, decimal_places=BidConst.STORE_SCALE(), default=BidConst.ZERO(), verbose_name="平台账户剩余金额") freezedAmount = models.DecimalField(max_digits=18, decimal_places=BidConst.STORE_SCALE(), default=BidConst.ZERO(), verbose_name="平台账户冻结金额") class Meta: verbose_name = u"平台账户" verbose_name_plural = verbose_name
def post(self, request): account = Account.objects.get(userProfile=request.user) without_amount = int(request.POST.get('moneyAmount')) #最小提现 <提现金额<最大提现, 提现金额<可提现金额 if request.user.isBindBankInfo() and not request.user.isMoneyWithoutProcess() \ and without_amount <= int(account.usableAmount) \ and BidConst.MIN_WITHDRAW_AMOUNT() <= without_amount <= BidConst.MAX_WITHDRAW_AMOUNT(): form = MoneyWithdrawViewForm(request.POST) if form.is_valid(): form.save(user_profile=request.user, account=account) return HttpResponse('{"status":"success", "message":"提现申请成功"}', content_type='application/json') return HttpResponse('{"status":"failure", "message":"提现失败"}', content_type='application/json')
def save_models(self): #获取保持对象 obj = self.new_obj obj.save() if obj is not None: bid_audit = obj bid_audit.auditor = self.user.username bid_audit.audiTime = timezone.now() user_profile_obj = bid_audit.applier #如果审核成功 if bid_audit.state == BitStatesUtils.STATE_AUDIT(): #给标添加状态信息 bid_request = bid_audit.bidRequestId bid_request.bidRequestState = BidConst.GET_BIDREQUEST_STATE_BIDDING() bid_request.note = bid_audit.remark #保存模型 bid_request.save() #给申请用户添加借款标状态 user_profile_obj.addState(BitStatesUtils.GET_OP_HAS_BIDREQUEST_PROCESS()) else: #审核失败,移出用户招标状态 user_profile_obj.removeState(BitStatesUtils.GET_OP_HAS_BIDREQUEST_PROCESS()) user_profile_obj.save() bid_audit.save()
def save_models(self): #获取保持对象 obj = self.new_obj obj.save() if obj is not None: charge_obj = obj charge_obj.auditor = self.user.username charge_obj.audiTime = timezone.now() #如果审核成功 if charge_obj.state == BitStatesUtils.STATE_AUDIT(): #得到申请人的账户对象 user_account = Account.objects.get(userProfile=charge_obj.applier) #增加账户可用余额 user_account.usableAmount = user_account.usableAmount + charge_obj.amount user_account.save() #生成流水 account_flow = AccountFlow.objects.create(accountId=user_account)#添加用户账户 account_flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_RECHARGE_OFFLINE()#充值类型 account_flow.amount = charge_obj.amount #添加变化金额 account_flow.freezedAmount = user_account.freezedAmount #添加冻结金额 account_flow.note = '线下充值成功,充值金额:'+str(charge_obj.amount) account_flow.tradeTime = timezone.now() #添加时间 account_flow.usableAmount = user_account.usableAmount #添加可用金额 account_flow.save() charge_obj.save()
def interestChargeFeeFlow(self, psd, interestChargeFee, account): flow = self.createBaseFlow(account=account) flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_INTEREST_SHARE() flow.amount = interestChargeFee flow.note = "回款成功,还款金额:" + str( psd.totalAmount) + ",支付利息管理费:" + str(interestChargeFee) flow.save()
def generateMoneyWithDrawApplyFlow(self, account, money_with_draw): flow = AccountFlow.objects.create(accountId=account) flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_WITHDRAW_FREEZED() flow.usableAmount = account.usableAmount flow.freezedAmount = account.freezedAmount flow.amount = money_with_draw.moneyAmount flow.note = "提现申请,冻结金额:" + str(money_with_draw.moneyAmount) flow.save()
def bidSuccessFlow(self,bid, account,total_bid_amount): account_flow = AccountFlow.objects.create(accountId=account) account_flow.amount = total_bid_amount account_flow.tradeTime = timezone.now() account_flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_BID_SUCCESSFUL() account_flow.usableAmount = account.usableAmount account_flow.freezedAmount = account.freezedAmount account_flow.note = "投标" +bid.bidRequestTitle + '成功,取消投标冻结金额:' + str(total_bid_amount) account_flow.save()
def generateRetureMoneyFlow(self, investor_account,br, available_amount_total): account_flow = AccountFlow.objects.create(accountId=investor_account) account_flow.amount = available_amount_total account_flow.tradeTime = timezone.now() account_flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_BID_UNFREEZED() account_flow.usableAmount = investor_account.usableAmount account_flow.freezedAmount = investor_account.freezedAmount account_flow.note = "投标" +br.title + '二审失败,退款投标金额:' + str(available_amount_total) account_flow.save()
def generateBorrowChargeFeeFlow(self, borrow_account, br, manageChargeFee): account_flow = AccountFlow.objects.create(accountId=borrow_account) account_flow.amount = br.bidRequestAmount account_flow.tradeTime = timezone.now() account_flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_CHARGE() account_flow.usableAmount = borrow_account.usableAmount account_flow.freezedAmount = borrow_account.freezedAmount account_flow.note = "借款" + br.title + '支付手续费成功,扣除金额:' + str(manageChargeFee) # '借款成功,收到借款金额:' + str(all_amount) account_flow.save()
def generateWithDrawChargeFeeFlow(self,w,account): account_flow = AccountFlow.objects.create(accountId=account) account_flow.amount = w.moneyAmount account_flow.tradeTime = timezone.now() account_flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_WITHDRAW_MANAGE_CHARGE() account_flow.usableAmount = account.usableAmount account_flow.freezedAmount = account.freezedAmount account_flow.note = '支付提现手续费成功,扣除金额:' + str(w.charge) # '借款成功,收到借款金额:' + str(all_amount) account_flow.save()
def generateWithDrawSuccessFlow(self,realWithdrawFee,account): account_flow = AccountFlow.objects.create(accountId=account) account_flow.amount = realWithdrawFee account_flow.tradeTime = timezone.now() account_flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_WITHDRAW_MANAGE_CHARGE() account_flow.usableAmount = account.usableAmount account_flow.freezedAmount = account.freezedAmount account_flow.note = '提现成功,提现金额:' + str(realWithdrawFee) # '借款成功,收到借款金额:' + str(all_amount) account_flow.save()
def generateBorrowSuccessFlow(self, borrow_account,br): account_flow = AccountFlow.objects.create(accountId=borrow_account) account_flow.amount = br.bidRequestAmount account_flow.tradeTime = timezone.now() account_flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_BIDREQUEST_SUCCESSFUL() account_flow.usableAmount = borrow_account.usableAmount account_flow.freezedAmount = borrow_account.freezedAmount account_flow.note = "借款" +br.title + '成功,获得金额:' + str(br.bidRequestAmount) # '借款成功,收到借款金额:' + str(all_amount) account_flow.save()
def calBidInterest(cls, bidRequestAmount, monthes2Return,yearRate, returnType, acturalBidAmount): cls.cal_set() acturalBidAmount =Decimal(str(acturalBidAmount)) #// 借款产生的总利息 totalInterest = cls.calTotalInterest(returnType, bidRequestAmount, yearRate, monthes2Return) #// 所占比例 proportion = acturalBidAmount / bidRequestAmount bidInterest = totalInterest * proportion return DecimalFormatUtil.formatBigDecimal(bidInterest, BidConst.STORE_SCALE())
def getavailable_amount_total(self, year, month): # 统计投资金额 bid_request_query = BidRequest.objects.filter( Q(bidRequestState=BidConst.GET_BIDREQUEST_STATE_PAYING_BACK()) & Q(applyTime__month=month) & Q(applyTime__year=year)) if bid_request_query.exists(): available_amount_total = bid_request_query.aggregate( Sum('bidRequestAmount')) return available_amount_total['bidRequestAmount__sum'] else: return 0
def save(self, loaner_account, loaner_bid_amount, commit=False): account_flow = super(AccountFlowForm, self).save(commit=False) account_flow.accountId = loaner_account account_flow.amount = loaner_bid_amount account_flow.tradeTime = timezone.now() account_flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_BID_SUCCESSFUL( ) account_flow.usableAmount = loaner_account.usableAmount account_flow.freezedAmount = loaner_account.freezedAmount account_flow.note = '投标成功,投标金额:' + str(loaner_bid_amount) account_flow.save() return account_flow
def calMonthlyInterest(cls, returnType, bidRequestAmount, yearRate, monthIndex, monthes2Return): # cls.cal_set() bidRequestAmount = Decimal(str(bidRequestAmount)) yearRate = Decimal(str(yearRate)) monthlyInterest = Decimal('0.0000') monthlyRate = cls.getMonthlyRate(yearRate) if returnType == BidConst.GET_RETURN_TYPE_MONTH_INTEREST_PRINCIPAL(): #按月分期 if monthes2Return == 1: #只借一个月 monthlyInterest = bidRequestAmount * monthlyRate else: temp1 = bidRequestAmount * monthlyRate temp2 = pow(Decimal('1') + monthlyRate, monthes2Return) temp3 = pow(Decimal('1') + monthlyRate, monthes2Return) - Decimal('1') temp4 = pow(Decimal('1') + monthlyRate, monthIndex-1) #计算每月还款 monthToReturnMoney = (temp1 * temp2) / temp3 #算出总还款 totalReturnMoney = monthToReturnMoney * Decimal(str(monthes2Return)) #算出利息 totalInterest = totalReturnMoney - bidRequestAmount if monthIndex < monthes2Return: monthlyInterest = ((temp1 - monthToReturnMoney) * temp4)+monthToReturnMoney elif monthIndex == monthes2Return: temp6 = Decimal('0.0000') # 汇总最后一期之前所有利息之和 for i in range(1,monthes2Return): temp5 = pow(Decimal('1') + monthlyRate, i-1) monthlyInterest = ((temp1 - monthToReturnMoney) * temp5) + monthToReturnMoney temp6 = temp6 + monthlyInterest monthlyInterest = totalInterest - temp6 # for elif returnType == BidConst.GET_RETURN_TYPE_MONTH_INTEREST(): #按月到期 monthlyInterest = DecimalFormatUtil.amountformat((bidRequestAmount * monthlyRate)) return monthlyInterest
def post(self, request): x = int(request.POST.get("bidRequestAmount", "")) y = int(request.POST.get("currentRate", "")) z = int(request.POST.get("minBidAmount", "")) account_query = Account.objects.filter(userProfile=request.user) if account_query.exists(): account_obj = account_query.first() # 系统最小借款金额 <= 借款金额 <=剩余信用额度, #5<= 利息 <=20, #最小投标金额>=系统最小投标金额 if int(account_obj.getRemainBorrowLimit()) >= int(request.POST.get("bidRequestAmount", "")) >= BidConst.SMALLEST_BID_AMOUNT()\ and BidConst.MAX_CURRENT_RATE() >= int(request.POST.get("currentRate", "")) >= BidConst.SMALLEST_CURRENT_RATE() \ and int(request.POST.get("minBidAmount", "")) >= BidConst.SMALLEST_BID_AMOUNT(): form = BidRequestForm(request.POST) if form.is_valid(): form.save(request.user) return render(request, "succeed_bid.html", {'message': '投标成功'}) # 判断是否满足条件 return HttpResponse('{"status":"请求失败"}', content_type='application/json')
class PaymentSchedule(models.Model): RETURN_TYPE_CHOICE = ((0, "按月分期还款"), (1, "按月到期还款")) STATE_CHOICE = ((0, "正常待还"), (1, "已还"), (2, "逾期")) BID_REQUEST_TYPE_CHOICE = ((0, "普通信用标"), (1, "普通信用标")) bidRequestId = models.ForeignKey(BidRequest, related_name='PaymentSchedules', null=True, verbose_name=u"借款标", on_delete=models.CASCADE) #; // 对应借款 bidRequestTitle = models.CharField(max_length=50, blank=True, null=True, verbose_name="借款名称") # // 借款名称 borrower = models.ForeignKey(Borrower, verbose_name=u"还款人", null=True, related_name='PaymentSchedules', on_delete=models.CASCADE) #; // 还款人 deadLine = models.DateTimeField(null=True, verbose_name=u"本期还款截止期限") # // 本期还款截止期限 payDate = models.DateTimeField(null=True, verbose_name=u"还款时间") # // 还款时间 totalAmount = models.DecimalField( max_digits=18, decimal_places=BidConst.STORE_SCALE(), default=BidConst.ZERO(), verbose_name="本期还款总金额") #// // 本期还款总金额,利息 + 本金 principal = models.DecimalField(max_digits=18, decimal_places=BidConst.STORE_SCALE(), default=BidConst.ZERO(), verbose_name="本期还款本金") #// 本期还款本金 interest = models.DecimalField(max_digits=18, decimal_places=BidConst.STORE_SCALE(), default=BidConst.ZERO(), verbose_name="本期还款总利息") # // 本期还款总利息 monthIndex = models.IntegerField(null=True, blank=True, verbose_name="第几期") #// 第几期(即第几个月) state = BidConst.PAYMENT_STATE_NORMAL = models.IntegerField( null=True, blank=True, default=BidConst.GET_PAYMENT_STATE_NORMAL(), choices=STATE_CHOICE, verbose_name="本期还款状态") # // 本期还款状态(默认正常待还) bidRequestType = models.IntegerField(null=True, blank=True, choices=BID_REQUEST_TYPE_CHOICE, verbose_name="借款类型(信用标)") #// 借款类型 returnType = models.IntegerField( null=True, blank=True, choices=RETURN_TYPE_CHOICE, verbose_name="还款方式") #// 还款方式,等同借款(BidRequest) class Meta: verbose_name = u"还款计划" verbose_name_plural = verbose_name
def calMonthToReturnMoney(cls, returnType, bidRequestAmount, yearRate, monthIndex, monthes2Return): # cls.cal_set() bidRequestAmount = Decimal(str(bidRequestAmount)) yearRate = Decimal(str(yearRate)) monthToReturnMoney = Decimal('0.0000') monthlyRate = cls.getMonthlyRate(yearRate) if returnType == BidConst.GET_RETURN_TYPE_MONTH_INTEREST_PRINCIPAL():#按月分期 if monthes2Return == 1: # 只借一个月 monthlyInterest = bidRequestAmount + (bidRequestAmount * monthlyRate) else: temp1 = bidRequestAmount * monthlyRate temp2 = pow(Decimal('1') + monthlyRate, monthes2Return) temp3 = pow(Decimal('1') + monthlyRate, monthes2Return) - Decimal('1') #计算每月还款 monthToReturnMoney = (temp1 * temp2) / temp3 elif returnType == BidConst.GET_RETURN_TYPE_MONTH_INTEREST(): #按月到期 monthlyInterest = bidRequestAmount * monthlyRate if monthIndex == monthes2Return: monthToReturnMoney = bidRequestAmount + monthlyInterest elif monthIndex < monthes2Return: monthToReturnMoney = monthlyInterest return DecimalFormatUtil.formatBigDecimal(monthToReturnMoney,BidConst.STORE_SCALE())
def generateChargeWithdrawFeeFlow(self,w): # // 1, 得到当前系统账户; system_account = SystemAccount.objects.first() system_account.usableAmount = system_account.usableAmount + CalculatetUtil.calAccountManagementCharge(w.charge) system_account.save() # //生成系统流水 account_flow = SystemAccountFlow.objects.create(systemAccountId=system_account) account_flow.amount = w.moneyAmount account_flow.tradeTime = timezone.now() account_flow.accountType = BidConst.GET_ACCOUNT_ACTIONTYPE_WITHDRAW_MANAGE_CHARGE() account_flow.usableAmount = system_account.usableAmount account_flow.freezedAmount = system_account.freezedAmount account_flow.note = '提现手续费充值成功,增加金额:' + str(w.charge) # '借款成功,收到借款金额:' + str(all_amount) account_flow.save()
def systemReceiveChargeFeeFromBorrow(self,br,manage_charge_fee): # // 1, 得到当前系统账户; system_account = SystemAccount.objects.first() # // 2, 修改账户余额; system_account.usableAmount = system_account.usableAmount +manage_charge_fee system_account.save() # // 3, 生成收款流水 flow = SystemAccountFlow.objects.create(systemAccountId=system_account) flow.accountActionType = BidConst.GET_SYSTEM_ACCOUNT_ACTIONTYPE_MANAGE_CHARGE() flow.amount = manage_charge_fee flow.usableAmount = system_account.usableAmount flow.freezedAmount = system_account.freezedAmount flow.note = "借款" +br.title + '成功,收取手续费:' + str(manage_charge_fee) flow.save()
class RechargeOffline(BaseAudit): bankInfo = models.ForeignKey(PlatformBankInfo, verbose_name=u"平台账户", on_delete=models.CASCADE) tradeCode = models.CharField(max_length=50, blank=True, null=True, verbose_name="交易号") #// 交易号 amount = models.DecimalField(max_digits=18, decimal_places=BidConst.STORE_SCALE(), default=BidConst.ZERO(), verbose_name="充值金额") #// 充值金额 tradeTime = models.DateTimeField(blank=True, null=True, verbose_name=u"充值时间") #// 充值时间 note = models.TextField(max_length=40, null=True, blank=True, verbose_name='充值说明') # // 充值说明 class Meta: verbose_name = u"充值审核" verbose_name_plural = verbose_name
def chargeInterestFeeForSystem(self, psd, interestChargeFee): # // 1, 得到当前系统账户; systemAccount = SystemAccount.objects.first() # // 2, 修改账户余额; systemAccount.usableAmount = systemAccount.usableAmount + interestChargeFee # // 3, 生成收款流水 flow = SystemAccountFlow.objects.create(systemAccountId=systemAccount) flow.accountActionType = BidConst.GET_SYSTEM_ACCOUNT_ACTIONTYPE_INTREST_MANAGE_CHARGE( ) flow.amount = interestChargeFee flow.usableAmount = systemAccount.usableAmount flow.createdTime = timezone.now() flow.freezedAmount = systemAccount.freezedAmount flow.note = "用户收款" + str( psd.totalAmount) + "成功,收取利息管理费:" + str(interestChargeFee) flow.save()