|
@@ -100,20 +100,13 @@ class SplitAccount(models.Model):
|
|
|
|
|
|
|
|
|
|
def unfreezeAccount(self):
|
|
def unfreezeAccount(self):
|
|
- # 解冻剩余资金 如果由于客户或其他原因 无法完成分账 就手动解除资金冻结
|
|
|
|
|
|
+ # 解冻剩余资金 默认资金冻结30天 如果由于客户或其他原因 无法完成分账 就手动解除资金冻结
|
|
pass
|
|
pass
|
|
|
|
|
|
- def handSplitAccont(self, spd, spr, pay, app):
|
|
|
|
|
|
+ def handSplitAccont(self, spd, pay, app):
|
|
'''手动申请分账(在自动申请分账失败后 手动申请分账)'''
|
|
'''手动申请分账(在自动申请分账失败后 手动申请分账)'''
|
|
- if pay.status != Pay.CONFIRM:
|
|
|
|
- raise CustomError(u'该订单未完成付款,无法分账!')
|
|
|
|
- if spd.status == SplitAccountDetail.SUCCESS:
|
|
|
|
- raise CustomError(u'该分账已成功,禁止重复申请!')
|
|
|
|
- private_key = ''
|
|
|
|
- cert_serial_no = ''
|
|
|
|
- apiv3_key = ''
|
|
|
|
- spc = SplitAccountFuc(app.authorizer_appid, app.agent_num, private_key, cert_serial_no, apiv3_key, cert_dir=None, proxy=None)
|
|
|
|
- # 状态是"待分账" 的查询分账
|
|
|
|
|
|
+ spc = SplitAccountFuc(app.authorizer_appid, app.agent_num, app.private_key, app.cert_serial_no, app.apiv3_key, cert_dir=app.cert_dir, proxy=None)
|
|
|
|
+ # 状态是"待分账" 的查询分账 (状态是默认的怎么处理?没有申请过的 查询分账结果会报错--如果返回错误信息根据错误信息 如果没有发现该订单就重新申请 其他原因就不再申请)
|
|
if spd.status == SplitAccountDetail.PENDING:
|
|
if spd.status == SplitAccountDetail.PENDING:
|
|
self.splictAccountQuery(spc, pay.no, self.no, spd)
|
|
self.splictAccountQuery(spc, pay.no, self.no, spd)
|
|
|
|
|
|
@@ -122,6 +115,9 @@ class SplitAccount(models.Model):
|
|
|
|
|
|
if spd.status == SplitAccountDetail.PENDING:
|
|
if spd.status == SplitAccountDetail.PENDING:
|
|
raise CustomError(u'该分账正在处理!')
|
|
raise CustomError(u'该分账正在处理!')
|
|
|
|
+ spr = SplitAccountReceiver.objects.filter(account=spd.account).first()
|
|
|
|
+ if not spr:
|
|
|
|
+ spr = SplitAccountReceiver.objects.create(account=spd.account)
|
|
# 添加分账接收人
|
|
# 添加分账接收人
|
|
self.splictAccountAddReceiver(spc, spr)
|
|
self.splictAccountAddReceiver(spc, spr)
|
|
# 分账申请
|
|
# 分账申请
|
|
@@ -183,14 +179,12 @@ class SplitAccount(models.Model):
|
|
detail.save()
|
|
detail.save()
|
|
|
|
|
|
def splitAccount(self, app, spd, spr, pay):
|
|
def splitAccount(self, app, spd, spr, pay):
|
|
|
|
+ '''自动分账 支付成功后自动分账'''
|
|
if pay.status != Pay.CONFIRM:
|
|
if pay.status != Pay.CONFIRM:
|
|
return
|
|
return
|
|
if spd.status != SplitAccountDetail.DEFAULT:
|
|
if spd.status != SplitAccountDetail.DEFAULT:
|
|
return
|
|
return
|
|
- private_key = ''
|
|
|
|
- cert_serial_no = ''
|
|
|
|
- apiv3_key = ''
|
|
|
|
- spc = SplitAccountFuc(app.authorizer_appid, app.agent_num, private_key, cert_serial_no, apiv3_key, cert_dir=None, proxy=None)
|
|
|
|
|
|
+ spc = SplitAccountFuc(app.authorizer_appid, app.agent_num, app.private_key, app.cert_serial_no, app.apiv3_key, cert_dir=app.cert_dir, proxy=None)
|
|
|
|
|
|
if spr.status != SplitAccountReceiver.ADD:
|
|
if spr.status != SplitAccountReceiver.ADD:
|
|
add = spc.splitaccount_addreceiver(spr.account)
|
|
add = spc.splitaccount_addreceiver(spr.account)
|
|
@@ -307,6 +301,9 @@ class SplitAccountReceiver(models.Model):
|
|
verbose_name = u"分账接收人"
|
|
verbose_name = u"分账接收人"
|
|
ordering = ('-id',)
|
|
ordering = ('-id',)
|
|
index_together = ('account', 'status', )
|
|
index_together = ('account', 'status', )
|
|
|
|
+ unique_together = (
|
|
|
|
+ 'account',
|
|
|
|
+ )
|
|
default_permissions = ()
|
|
default_permissions = ()
|
|
|
|
|
|
|
|
|