aa
This commit is contained in:
@@ -225,6 +225,8 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m
|
||||
//如果取消订单则要把库存加回去
|
||||
if order, err2 := c.LoadOrder(orderStatus.VendorOrderID, orderStatus.VendorID); err2 == nil {
|
||||
ModifyOrderSkusStock(db, order, true)
|
||||
//门店发单的订单,取消后要退回配送费
|
||||
resetCreateWaybillFee(db, order)
|
||||
}
|
||||
}
|
||||
if !isDuplicated {
|
||||
@@ -405,6 +407,16 @@ func filterOrderInfo(order *model.GoodsOrder) {
|
||||
order.ConsigneeAddress = strings.ReplaceAll(order.ConsigneeAddress, "·", "")
|
||||
}
|
||||
|
||||
func resetCreateWaybillFee(db *dao.DaoDB, order *model.GoodsOrder) (err error) {
|
||||
store, _ := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode)
|
||||
if store != nil {
|
||||
if expend, lastFee, err := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID); err == nil {
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), lastFee, partner.StoreAcctTypeIncomeCancelReal, order.VendorOrderID, expend.ID)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func checkPriceDefendOrderByStock(db *dao.DaoDB, storeID, skuID, stock, jxPrice int) (realStock int) {
|
||||
var (
|
||||
sumStock = 0
|
||||
|
||||
@@ -587,7 +587,9 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
s.solutionJdsOrder(bill)
|
||||
}
|
||||
//门店发单的门店,需要根据实际运费更新账户(多退少补)
|
||||
s.updateStoreAccount(order, bill)
|
||||
if savedOrderInfo.storeDetail.CreateDeliveryType == model.YES {
|
||||
s.updateStoreAccount(order, bill)
|
||||
}
|
||||
//订单已经是结束状态之后来的运单143945553920000001
|
||||
if order.Status > model.OrderStatusEndBegin {
|
||||
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
@@ -1321,7 +1323,20 @@ func (s *DefScheduler) updateOrderByBill(order *model.GoodsOrder, bill *model.Wa
|
||||
}
|
||||
|
||||
func (s *DefScheduler) updateStoreAccount(order *model.GoodsOrder, bill *model.Waybill) {
|
||||
|
||||
realDesiredFee := bill.DesiredFee
|
||||
if expend, lastFee, err := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID); err == nil {
|
||||
lastFee64 := int64(lastFee)
|
||||
if lastFee64 != realDesiredFee {
|
||||
var diffFee int64
|
||||
if lastFee64 > realDesiredFee {
|
||||
diffFee = lastFee64 - realDesiredFee
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), int(diffFee), partner.StoreAcctTypeRealFeeIncome, order.VendorOrderID, expend.ID)
|
||||
} else {
|
||||
diffFee = realDesiredFee - lastFee64
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), int(diffFee), partner.StoreAcctTypeRealFeeExpend, order.VendorOrderID, expend.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DefScheduler) updateBillsInfo(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) (isBillExist bool) {
|
||||
|
||||
@@ -2052,9 +2052,9 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
|
||||
case 1:
|
||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
var (
|
||||
v = batchItemList[0].(*model.SkuName)
|
||||
skuNames []model.SkuName
|
||||
skuName = &model.SkuNameExt{
|
||||
v = batchItemList[0].(*model.SkuName)
|
||||
sku *model.SkuName
|
||||
skuName = &model.SkuNameExt{
|
||||
SkuName: model.SkuName{},
|
||||
Skus: []*model.SkuWithVendor{
|
||||
&model.SkuWithVendor{
|
||||
@@ -2078,8 +2078,7 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
|
||||
SELECT * FROM sku_name WHERE upc = ? AND deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{*v.Upc, utils.DefaultTimeValue}
|
||||
err = dao.GetRows(db, &skuNames, sql, sqlParams)
|
||||
if len(skuNames) > 0 {
|
||||
if err = dao.GetRow(db, &sku, sql, sqlParams); err == nil && sku != nil {
|
||||
// retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "商品在京西库中已存在!")}
|
||||
return retVal, err
|
||||
}
|
||||
@@ -2123,32 +2122,27 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
|
||||
}
|
||||
}
|
||||
if v.Price == 0 {
|
||||
result, err := api.AliUpcAPI.GetAliUpcInfo(*v.Upc)
|
||||
if err != nil {
|
||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())}
|
||||
return retVal, err
|
||||
}
|
||||
if result.Price == "" {
|
||||
if productInfo.Price != 0 {
|
||||
skuName.Price = productInfo.Price
|
||||
} else {
|
||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品售价,请补充商品售价!")}
|
||||
return retVal, err
|
||||
} else {
|
||||
skuName.Price = int(utils.Str2Int64(result.Price) * 100)
|
||||
}
|
||||
} else {
|
||||
skuName.Price = v.Price
|
||||
}
|
||||
skuName.Name = productInfo.Name
|
||||
getNetUpcInfo, err := api.AliUpcAPI.GetNetUpcInfo(*v.Upc)
|
||||
// getNetUpcInfo, err := api.AliUpcAPI.GetNetUpcInfo(*v.Upc)
|
||||
if v.Unit != "" {
|
||||
skuName.Unit = v.Unit
|
||||
} else {
|
||||
if productInfo.Unit == "" {
|
||||
if getNetUpcInfo.Unit != "" {
|
||||
skuName.Unit = getNetUpcInfo.Unit
|
||||
} else {
|
||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品单位,请补充商品单位!")}
|
||||
return retVal, err
|
||||
}
|
||||
// if getNetUpcInfo.Unit != "" {
|
||||
// skuName.Unit = getNetUpcInfo.Unit
|
||||
// } else {
|
||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品单位,请补充商品单位!")}
|
||||
return retVal, err
|
||||
// }
|
||||
} else {
|
||||
skuName.Unit = productInfo.Unit
|
||||
}
|
||||
@@ -2168,18 +2162,18 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
|
||||
}
|
||||
} else {
|
||||
if productInfo.SpecQuality == 0 {
|
||||
if getNetUpcInfo.SpecQuality != 0 {
|
||||
if getNetUpcInfo.SpecUnit == model.SpecUnitNames[1] || getNetUpcInfo.SpecUnit == model.SpecUnitNames[2] ||
|
||||
getNetUpcInfo.SpecUnit == "KG" || getNetUpcInfo.SpecUnit == "l" {
|
||||
skuName.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(getNetUpcInfo.SpecQuality) * 1000)))
|
||||
} else {
|
||||
skuName.Skus[0].Weight = utils.Float32ToInt(getNetUpcInfo.SpecQuality)
|
||||
}
|
||||
skuName.Skus[0].SpecQuality = getNetUpcInfo.SpecQuality
|
||||
} else {
|
||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品重量,请补充商品重量!")}
|
||||
return retVal, err
|
||||
}
|
||||
// if getNetUpcInfo.SpecQuality != 0 {
|
||||
// if getNetUpcInfo.SpecUnit == model.SpecUnitNames[1] || getNetUpcInfo.SpecUnit == model.SpecUnitNames[2] ||
|
||||
// getNetUpcInfo.SpecUnit == "KG" || getNetUpcInfo.SpecUnit == "l" {
|
||||
// skuName.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(getNetUpcInfo.SpecQuality) * 1000)))
|
||||
// } else {
|
||||
// skuName.Skus[0].Weight = utils.Float32ToInt(getNetUpcInfo.SpecQuality)
|
||||
// }
|
||||
// skuName.Skus[0].SpecQuality = getNetUpcInfo.SpecQuality
|
||||
// } else {
|
||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品重量,请补充商品重量!")}
|
||||
return retVal, err
|
||||
// }
|
||||
} else {
|
||||
if productInfo.Weight != 0 {
|
||||
skuName.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(productInfo.Weight))))
|
||||
@@ -2190,11 +2184,11 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
|
||||
}
|
||||
}
|
||||
if productInfo.SpecUnit == "" {
|
||||
if getNetUpcInfo.SpecUnit != "" {
|
||||
skuName.Skus[0].SpecUnit = getNetUpcInfo.SpecUnit
|
||||
} else {
|
||||
skuName.Skus[0].SpecUnit = model.SpecUnitNames[0]
|
||||
}
|
||||
// if getNetUpcInfo.SpecUnit != "" {
|
||||
// skuName.Skus[0].SpecUnit = getNetUpcInfo.SpecUnit
|
||||
// } else {
|
||||
skuName.Skus[0].SpecUnit = model.SpecUnitNames[0]
|
||||
// }
|
||||
} else {
|
||||
skuName.Skus[0].SpecUnit = productInfo.SpecUnit
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func init() {
|
||||
partner.InitStoreAcctManager(FixedStoreAcctManager)
|
||||
}
|
||||
|
||||
func (s *StoreAcctManager) InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error) {
|
||||
func (s *StoreAcctManager) InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error) {
|
||||
var (
|
||||
userID, userName string
|
||||
goodsVendorOrderID string
|
||||
@@ -49,6 +49,9 @@ func (s *StoreAcctManager) InsertStoreAcctIncome(ctx *jxcontext.Context, storeID
|
||||
VendorOrderID: goodsVendorOrderID,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(storeAcctIncome, userName)
|
||||
if expendID != 0 {
|
||||
storeAcctIncome.ExpID = expendID
|
||||
}
|
||||
err = dao.CreateEntity(db, storeAcctIncome)
|
||||
globals.SugarLogger.Debugf("InsertStoreAcctIncome orderID: [%v] , price :[%v] , type :[%v]", vendorOrderID, price, acctType)
|
||||
return err
|
||||
@@ -80,7 +83,7 @@ func (s *StoreAcctManager) InsertStoreAcctExpend(ctx *jxcontext.Context, storeID
|
||||
}
|
||||
dao.WrapAddIDCULEntity(storeAcctExpend, userName)
|
||||
if expendID != 0 {
|
||||
|
||||
storeAcctExpend.ExpID = expendID
|
||||
}
|
||||
err = dao.CreateEntity(db, storeAcctExpend)
|
||||
globals.SugarLogger.Debugf("InsertStoreAcctExpend orderID: [%v] , price :[%v] , type :[%v]", vendorOrderID, price, acctType)
|
||||
@@ -140,9 +143,9 @@ func (s *StoreAcctManager) InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *j
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *StoreAcctManager) InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error) {
|
||||
func (s *StoreAcctManager) InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error) {
|
||||
utils.CallFuncAsync(func() {
|
||||
if err = s.InsertStoreAcctIncome(ctx, storeID, price, acctType, vendorOrderID); err == nil {
|
||||
if err = s.InsertStoreAcctIncome(ctx, storeID, price, acctType, vendorOrderID, expendID); err == nil {
|
||||
s.UpdateStoreAcctBalance(ctx, storeID, price, true)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -33,13 +33,13 @@ func InitStoreAcctManager(curStoreManager IStoreAcctManager) {
|
||||
|
||||
type IStoreAcctManager interface {
|
||||
//增加一条收入流水
|
||||
InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
|
||||
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 string, expendID int) (err error)
|
||||
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
|
||||
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
|
||||
CheckStoreAcctExpendExist(vendorOrderID string) (isEqual, isZero bool, err error)
|
||||
GetStoreAcctExpendLastCreateWayBillFee(vendorOrderID string) (expend *dao.GetStoreAcctExpendLastCreateWayBillFeeResult, lastFee int, err error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user