1
This commit is contained in:
@@ -607,16 +607,28 @@ func orderFeeSettle(db *dao.DaoDB, order *model.GoodsOrder, bill *model.Waybill,
|
|||||||
globals.SugarLogger.Errorf("GetStoreAcctIncomeTotal 551 err :%v", err)
|
globals.SugarLogger.Errorf("GetStoreAcctIncomeTotal 551 err :%v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, v := range bills {
|
|
||||||
allFee += int(v.DesiredFee)
|
} else {
|
||||||
allFee += int(v.TipFee)
|
billExpend, err = dao.GetBrandBillOrderExpend(db, store.BrandID, bill.VendorOrderID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
// 运单支出费用统计,应该等于 支出费用- 退还费用
|
billIncome, err = dao.GetBrandBillOrderIncome(db, store.BrandID, bill.VendorOrderID)
|
||||||
globals.SugarLogger.Errorf("计算错误:订单支出费用应该=退还费用+运单支出费用,支出费用:%d,已经退还费用:%d,运单计算费用:%d", billExpend, billIncome, allFee)
|
if err != nil {
|
||||||
if allFee != billExpend-billIncome {
|
return err
|
||||||
globals.SugarLogger.Errorf("计算错误:订单支出费用应该=退还费用+运单支出费用,支出费用:%d,已经退还费用:%d,剩余退还费用:%d", billExpend, billIncome, billExpend-billIncome)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, v := range bills {
|
||||||
|
allFee += int(v.DesiredFee)
|
||||||
|
allFee += int(v.TipFee)
|
||||||
|
}
|
||||||
|
// 运单支出费用统计,应该等于 支出费用- 退还费用
|
||||||
|
globals.SugarLogger.Errorf("计算错误:订单支出费用应该=退还费用+运单支出费用,支出费用:%d,已经退还费用:%d,运单计算费用:%d", billExpend, billIncome, allFee)
|
||||||
|
if allFee != billExpend-billIncome {
|
||||||
|
globals.SugarLogger.Errorf("计算错误:订单支出费用应该=退还费用+运单支出费用,支出费用:%d,已经退还费用:%d,剩余退还费用:%d", billExpend, billIncome, billExpend-billIncome)
|
||||||
|
}
|
||||||
|
|
||||||
if billExpend-billIncome == allFee {
|
if billExpend-billIncome == allFee {
|
||||||
globals.SugarLogger.Debugf("计算正确,运单消耗[%d],账户支出[%d],账户退回[%d]", allFee, billExpend, billIncome)
|
globals.SugarLogger.Debugf("计算正确,运单消耗[%d],账户支出[%d],账户退回[%d]", allFee, billExpend, billIncome)
|
||||||
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("计算正确,运单消耗[%d],账户支出[%d],账户退回[%d]", allFee, billExpend, billIncome), "")
|
partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("计算正确,运单消耗[%d],账户支出[%d],账户退回[%d]", allFee, billExpend, billIncome), "")
|
||||||
|
|||||||
@@ -1397,6 +1397,34 @@ func GetBrandBalance(db *DaoDB, brandID int) (result int, err error) {
|
|||||||
return balance.Balance, err
|
return balance.Balance, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBrandBillOrderExpend 获取订单品牌支出记录
|
||||||
|
func GetBrandBillOrderExpend(db *DaoDB, brandId int, vendorOrderID string) (int, error) {
|
||||||
|
var Price = &struct {
|
||||||
|
Price int
|
||||||
|
}{}
|
||||||
|
|
||||||
|
sql := `SELECT IFNULL(SUM(price),0) balance FROM brand_bill
|
||||||
|
WHERE brand_id = ? AND bill_type = ? AND vendor_order_id = ? AND fee_type IN (?,?,?) `
|
||||||
|
sqlParam := []interface{}{brandId, model.BrandBillTypeExpend, vendorOrderID, model.BrandBillFeeTypeDelivery, model.BrandBillFeeTypeTipFee, model.BrandBillFeeTypeDeductFee}
|
||||||
|
|
||||||
|
err := GetRow(db, &Price, sql, sqlParam)
|
||||||
|
return Price.Price, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBrandBillOrderIncome 获取品牌订单的退还记录
|
||||||
|
func GetBrandBillOrderIncome(db *DaoDB, brandId int, vendorOrderID string) (int, error) {
|
||||||
|
var Price = &struct {
|
||||||
|
Price int
|
||||||
|
}{}
|
||||||
|
|
||||||
|
sql := `SELECT IFNULL(SUM(price),0) balance FROM brand_bill
|
||||||
|
WHERE brand_id = ? AND bill_type = ? AND vendor_order_id = ? AND fee_type IN (?,?,?) `
|
||||||
|
sqlParam := []interface{}{brandId, model.BrandBillTypeIncome, vendorOrderID, model.BrandBillFeeTypeDelivery, model.BrandBillFeeTypeTipFee, model.BrandBillFeeTypeDeductFee}
|
||||||
|
|
||||||
|
err := GetRow(db, &Price, sql, sqlParam)
|
||||||
|
return Price.Price, err
|
||||||
|
}
|
||||||
|
|
||||||
func GetBrandBill(db *DaoDB, brandID int, vendorOrderID string, billType, feeType int, vendorWaybillOrderID string) (result []*model.BrandBill, err error) {
|
func GetBrandBill(db *DaoDB, brandID int, vendorOrderID string, billType, feeType int, vendorWaybillOrderID string) (result []*model.BrandBill, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT *
|
SELECT *
|
||||||
|
|||||||
Reference in New Issue
Block a user