package partner

import (
	"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
	"git.rosy.net.cn/jx-callback/business/model/dao"
)

const (
	//账户收入类型
	StoreAcctTypeIncomePay        = 10 //主动充值
	StoreAcctTypeRealFeeIncome    = 15 //真实运费 < 临时运费， 临时运费-真实运费的值
	StoreAcctTypeIncomeCancelTemp = 18 //运单取消，回退的临时运费
	StoreAcctTypeIncomeCancelReal = 19 //运单取消，回退的真实运费

	//账户支出类型
	StoreAcctTypeExpendCreateWaybillEx        = 20 //发单扣除的临时运费
	StoreAcctTypeExpendCreateWaybillTip       = 21 //手动加小费扣除
	StoreAcctTypeExpendCreateWaybill2ndMore   = 22 //第二次发运单，并且比上次需要更多钱扣的差价
	StoreAcctTypeExpendCreateWaybillDeductFee = 23 //运单取消的违约金
	StoreAcctTypeExpendTextMessageNotify      = 24 //短信通知扣费
	StoreAcctTypeExpendVoiceMessageNotify     = 26 //电话通知扣费
	StoreAcctTypeRealFeeExpend                = 25 //真实运费 > 临时运费， 真实运费的值 - 临时运费的值
)

const (
	MinCreateWaybillBalance = 1000 //余额小于这个值直接不能发
)

var (
	CurStoreAcctManager IStoreAcctManager
)

func InitStoreAcctManager(curStoreManager IStoreAcctManager) {
	CurStoreAcctManager = curStoreManager
}

type IStoreAcctManager interface {
	////增加一条收入流水
	//InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
	////增加一条支出流水
	//InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
	//更新门店账户
	UpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price int, isIncome bool) (err error)
	InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID, vendorWaybillID string, expendID int) (err error)
	InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID, vendOrderID string, expendID int) (err error)
	CheckStoreAcctExpendExist(vendorOrderID string) (isEqual, isZero bool, err error)
	GetStoreAcctExpendLastCreateWayBillFee(vendorOrderID string) (expend *dao.GetStoreAcctExpendLastCreateWayBillFeeResult, lastFee int, err error)

	//品牌账户
	GetBrandBalance(brandID int) (balance int, err error)
	InsertBrandBill(ctx *jxcontext.Context, brandID, price, billType, feeType int, vendorOrderID string, wayVendorOrderId string) (err error)
}
