def get_codefee(self): """ 获取码商/上游费用 :return: """ if self.order_obj.paypass in (0, 1): # 码商费用以及码商流水 rate = get_Rate(self.qrcode_obj.userid, paytypeid=self.order_obj.paytype, type="2") self.order_obj.codefee = float( self.order_obj.confirm_amount) * float(rate) upd_bal(userid=self.qrcode_obj.userid, bal=self.order_obj.codefee, up_bal=self.amount, memo="扫码", ordercode=self.order_obj.ordercode, flag=True, upd_business_agent_tot=True) else: # 上游聚到服务费 paypass = PayPass.objects.get(paypassid=self.order_obj.paypass) rate = get_Rate(paypass.paypassid, paytypeid=self.order_obj.paytype, type="0") self.order_obj.codefee = float( self.order_obj.confirm_amount) * float(rate) paypass.bal = float(paypass.bal) + float(self.order_obj.codefee)
def get_tech_cost(self): """ 获取商户技术费 :return: """ self.stand_rate = get_Rate(self.order_obj.userid, paytypeid=self.order_obj.paytype) self.order_obj.tech_cost = float( self.order_obj.confirm_amount) * float(self.stand_rate) upd_bal(userid=self.order_obj.userid, bal=float(self.order_obj.confirm_amount) - float(self.order_obj.tech_cost), up_bal=self.amount, memo="扫码", ordercode=self.order_obj.ordercode)
def get_agent_free(self): """ 获取代理费用 :return: """ agent_free = 0.0 for item in UserLink.objects.filter( userid=self.order_obj.userid).order_by('-level'): rate = get_Rate(item.userid_to, paytypeid=self.order_obj.paytype) amount = float(self.order_obj.confirm_amount) * float( self.stand_rate - rate) if float(self.stand_rate - rate) > 0.0 else 0.0 if amount > 0.0: upd_bal(userid=item.userid_to, bal=amount, up_bal=self.amount, memo="扫码", ordercode=self.order_obj.ordercode) self.stand_rate = rate agent_free += amount self.order_obj.agentfee = agent_free
def work_handler_updbal(self, ordercode=None, memo='调账'): """ 手工修改余额,传入摘要 :return: """ if not ordercode: raise PubErrorCustom("订单号不能为空") self.init_order_obj(ordercode=ordercode) self.order_obj.confirm_amount = self.order_obj.amount self.amount = self.order_obj.amount # 商户技术费 stand_rate = get_Rate(self.order_obj.userid, paytypeid=self.order_obj.paytype) self.order_obj.tech_cost = float( self.order_obj.confirm_amount) * float(stand_rate) upd_bal(userid=self.order_obj.userid, bal=float(self.order_obj.confirm_amount) - float(self.order_obj.tech_cost), up_bal=self.amount, memo=memo, ordercode=self.order_obj.ordercode) # 代理费用 agent_free = 0.0 for item in UserLink.objects.filter( userid=self.order_obj.userid).order_by('-level'): rate = get_Rate(item.userid_to, paytypeid=self.order_obj.paytype) amount = float(self.order_obj.confirm_amount) * float( stand_rate - rate) if float(stand_rate - rate) > 0.0 else 0.0 if amount > 0.0: upd_bal(userid=item.userid_to, bal=amount, up_bal=self.amount, memo=memo, ordercode=self.order_obj.ordercode) stand_rate = rate agent_free += amount self.order_obj.agentfee = agent_free # if self.order_obj.paypass in (0, 1): # self.init_qrcode_obj(self.order_obj.qr_id) # # 码商费用以及码商流水 # rate = get_Rate(self.qrcode_obj.userid, paytypeid=self.order_obj.paytype, type="2") # self.order_obj.codefee = float(self.order_obj.confirm_amount) * float(rate) # upd_bal(userid=self.qrcode_obj.userid, bal=self.order_obj.codefee, up_bal=self.amount, memo=memo, # ordercode=self.order_obj.ordercode,flag=True,upd_business_agent_tot=True) # else: # 上游聚到服务费 paypass = PayPass.objects.get(paypassid=self.order_obj.paypass) rate = get_Rate(paypass.paypassid, paytypeid=self.order_obj.paytype, type="0") self.order_obj.codefee = float( self.order_obj.confirm_amount) * float(rate) paypass.bal = float(paypass.bal) + float(self.order_obj.codefee) # 咱们自己的收入 self.order_obj.myfee = float(self.order_obj.tech_cost) - float( self.order_obj.codefee) - float(agent_free) if self.order_obj.userid not in [3, 20, 5]: upd_bal(userid=1, bal=self.order_obj.myfee, up_bal=self.amount, memo=memo, ordercode=self.order_obj.ordercode, upd_business_agent_tot=True) self.order_obj.save()