1
This commit is contained in:
@@ -446,10 +446,53 @@ func filterOrderInfo(order *model.GoodsOrder) {
|
||||
|
||||
func resetCreateWaybillFee(db *dao.DaoDB, order *model.GoodsOrder) (err error) {
|
||||
store, _ := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode)
|
||||
if store != nil && store.CreateDeliveryType == model.YES {
|
||||
if expend, lastFee, err := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID); err == nil && expend != nil {
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), lastFee, partner.StoreAcctTypeIncomeCancelReal, order.VendorOrderID, expend.ID)
|
||||
if store != nil && store.CreateDeliveryType == model.YES { // 门店发单(非京西品牌)
|
||||
// 无运单不参与退款
|
||||
if order.VendorWaybillID == "" {
|
||||
return err
|
||||
}
|
||||
// 自配送不参与退款
|
||||
if order.VendorOrderID == order.VendorWaybillID {
|
||||
return err
|
||||
}
|
||||
|
||||
// 获取运单记录
|
||||
orderStatusList, err := GetOrderStatusList2(order.VendorOrderID, order.VendorWaybillID, 2, order.WaybillVendorID)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("获取订单操作流程错误:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
isRefund := true // 默认可以退费
|
||||
for _, v := range orderStatusList {
|
||||
if order.WaybillVendorID == model.VendorIDMTPS && v.VendorStatus == "30" {
|
||||
isRefund = false
|
||||
break
|
||||
}
|
||||
if order.WaybillVendorID == model.VendorIDFengNiao && v.VendorStatus == "80" {
|
||||
isRefund = false
|
||||
break
|
||||
}
|
||||
if order.WaybillVendorID == model.VendorIDDada && v.VendorStatus == "3" {
|
||||
isRefund = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !isRefund {
|
||||
return err
|
||||
}
|
||||
|
||||
// 获取品牌的支付记录
|
||||
orderBill, _ := dao.GetBrandBill(dao.GetDB(), store.BrandID, order.VendorOrderID, model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery)
|
||||
if len(orderBill) != model.YES {
|
||||
return errors.New("订单支出数据异常,应该为一条数据")
|
||||
}
|
||||
|
||||
// 将支出记录修改为退款记录,支付类型为收入,且类型为三方配送时:退费
|
||||
orderBill[0].BillType = model.BrandBillTypeIncome
|
||||
newBill := orderBill[0]
|
||||
_, err = dao.UpdateEntity(dao.GetDB(), newBill)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user