- up
This commit is contained in:
@@ -352,7 +352,7 @@ func caculateOrderEarningPrice(order *model.GoodsOrder, storePayPercentage int)
|
|||||||
if skuEarningPrice == 0 {
|
if skuEarningPrice == 0 {
|
||||||
skuEarningPrice = jxutils.CaculateSkuEarningPrice(v.ShopPrice, v.SalePrice, storePayPercentage)
|
skuEarningPrice = jxutils.CaculateSkuEarningPrice(v.ShopPrice, v.SalePrice, storePayPercentage)
|
||||||
}
|
}
|
||||||
order.EarningPrice += skuEarningPrice
|
order.EarningPrice += skuEarningPrice * int64(v.Count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -298,79 +298,81 @@ func CreateJdPromotion(ctx *jxcontext.Context, vendorID int, isIDJd bool, isAsyn
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if len(conflictPromotion) > 0 {
|
if len(conflictPromotion) > 0 {
|
||||||
return "", fmt.Errorf("有冲突配置:%s", utils.Format4Output(conflictPromotion, true))
|
return "", fmt.Errorf("有冲突配置:%s", utils.Format4Output(conflictPromotion, false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if vendorPromotionID == "" && vendorID == model.VendorIDJD {
|
if vendorPromotionID == "" {
|
||||||
sql := `
|
if vendorID == model.VendorIDJD {
|
||||||
|
sql := `
|
||||||
SELECT t1.*, t2.jd_id, t3.vendor_store_id
|
SELECT t1.*, t2.jd_id, t3.vendor_store_id
|
||||||
FROM store_sku_bind t1
|
FROM store_sku_bind t1
|
||||||
JOIN sku t2 ON t1.sku_id = t2.id
|
JOIN sku t2 ON t1.sku_id = t2.id
|
||||||
JOIN store_map t3 ON t1.store_id = t3.store_id AND t3.vendor_id = ? AND t3.deleted_at = ?
|
JOIN store_map t3 ON t1.store_id = t3.store_id AND t3.vendor_id = ? AND t3.deleted_at = ?
|
||||||
WHERE t1.deleted_at = ?
|
WHERE t1.deleted_at = ?
|
||||||
`
|
`
|
||||||
sqlParam := []interface{}{
|
sqlParam := []interface{}{
|
||||||
model.VendorIDJD,
|
model.VendorIDJD,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
skuIDs,
|
skuIDs,
|
||||||
}
|
}
|
||||||
if isIDJd {
|
if isIDJd {
|
||||||
sql += " AND t2.jd_id IN (" + dao.GenQuestionMarks(len(skuIDs)) + ") AND t3.vendor_store_id = ?"
|
sql += " AND t2.jd_id IN (" + dao.GenQuestionMarks(len(skuIDs)) + ") AND t3.vendor_store_id = ?"
|
||||||
} else {
|
} else {
|
||||||
sql += " AND t1.sku_id IN (" + dao.GenQuestionMarks(len(skuIDs)) + ") AND t1.store_id = ?"
|
sql += " AND t1.sku_id IN (" + dao.GenQuestionMarks(len(skuIDs)) + ") AND t1.store_id = ?"
|
||||||
}
|
}
|
||||||
|
|
||||||
errMsg := ""
|
errMsg := ""
|
||||||
index := 0
|
index := 0
|
||||||
for _, storeID := range params.StoreIDs {
|
for _, storeID := range params.StoreIDs {
|
||||||
var skuBinds []*tStoreSkuBindExt
|
var skuBinds []*tStoreSkuBindExt
|
||||||
if err = dao.GetRows(db, &skuBinds, sql, append(sqlParam, storeID)...); err != nil {
|
if err = dao.GetRows(db, &skuBinds, sql, append(sqlParam, storeID)...); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
|
||||||
for k, skuBind := range skuBinds {
|
|
||||||
if k == 0 {
|
|
||||||
jxStoreIDs = append(jxStoreIDs, skuBind.StoreID)
|
|
||||||
}
|
}
|
||||||
mapSkuID := int64(skuBind.SkuID)
|
for k, skuBind := range skuBinds {
|
||||||
if isIDJd {
|
if k == 0 {
|
||||||
mapSkuID = skuBind.JdSkuID
|
jxStoreIDs = append(jxStoreIDs, skuBind.StoreID)
|
||||||
}
|
}
|
||||||
promotionSkuPrice := skuPriceMap[mapSkuID]
|
mapSkuID := int64(skuBind.SkuID)
|
||||||
if promotionSkuPrice.PriceType == PriceTypePercentage {
|
if isIDJd {
|
||||||
promotionSkuPrice.Price = skuBind.Price * promotionSkuPrice.Price / 100
|
mapSkuID = skuBind.JdSkuID
|
||||||
}
|
}
|
||||||
if vendorID != model.VendorIDJX && promotionSkuPrice.Price >= skuBind.Price {
|
promotionSkuPrice := skuPriceMap[mapSkuID]
|
||||||
errMsg += fmt.Sprintf("活动价大于等于原价,storeID:%d, skuID:%d\n", skuBind.StoreID, skuBind.SkuID)
|
if promotionSkuPrice.PriceType == PriceTypePercentage {
|
||||||
}
|
promotionSkuPrice.Price = skuBind.Price * promotionSkuPrice.Price / 100
|
||||||
if promotionSkuPrice.LimitSkuCount <= 0 {
|
}
|
||||||
promotionSkuPrice.LimitSkuCount = DefaultLimitSkuCount
|
if vendorID != model.VendorIDJX && promotionSkuPrice.Price >= skuBind.Price {
|
||||||
}
|
errMsg += fmt.Sprintf("活动价大于等于原价,storeID:%d, skuID:%d\n", skuBind.StoreID, skuBind.SkuID)
|
||||||
if errMsg == "" {
|
}
|
||||||
if params.Type == PromotionTypeLimitedTime {
|
if promotionSkuPrice.LimitSkuCount <= 0 {
|
||||||
if skuBind.Price*PromotionLimitedTimeMinPercentage/100 < promotionSkuPrice.Price {
|
promotionSkuPrice.LimitSkuCount = DefaultLimitSkuCount
|
||||||
modifyPricesList[skuBind.StoreID] = append(modifyPricesList[skuBind.StoreID], &jdapi.SkuPriceInfo{
|
}
|
||||||
OutSkuId: utils.Int2Str(skuBind.SkuID),
|
if errMsg == "" {
|
||||||
Price: promotionSkuPrice.Price*100/PromotionLimitedTimeMinPercentage + 5,
|
if params.Type == PromotionTypeLimitedTime {
|
||||||
})
|
if skuBind.Price*PromotionLimitedTimeMinPercentage/100 < promotionSkuPrice.Price {
|
||||||
|
modifyPricesList[skuBind.StoreID] = append(modifyPricesList[skuBind.StoreID], &jdapi.SkuPriceInfo{
|
||||||
|
OutSkuId: utils.Int2Str(skuBind.SkuID),
|
||||||
|
Price: promotionSkuPrice.Price*100/PromotionLimitedTimeMinPercentage + 5,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
promotionPrices[index] = &jdapi.PromotionSku{
|
||||||
|
StationNo: utils.Str2Int64(skuBind.VendorStoreID),
|
||||||
|
SkuID: skuBind.JdSkuID,
|
||||||
|
PromotionPrice: int64(promotionSkuPrice.Price),
|
||||||
|
LimitSkuCount: promotionSkuPrice.LimitSkuCount,
|
||||||
|
}
|
||||||
|
index++
|
||||||
}
|
}
|
||||||
promotionPrices[index] = &jdapi.PromotionSku{
|
|
||||||
StationNo: utils.Str2Int64(skuBind.VendorStoreID),
|
|
||||||
SkuID: skuBind.JdSkuID,
|
|
||||||
PromotionPrice: int64(promotionSkuPrice.Price),
|
|
||||||
LimitSkuCount: promotionSkuPrice.LimitSkuCount,
|
|
||||||
}
|
|
||||||
index++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if errMsg != "" {
|
||||||
if errMsg != "" {
|
return "", errors.New(errMsg)
|
||||||
return "", errors.New(errMsg)
|
}
|
||||||
}
|
promotionPrices = promotionPrices[:index]
|
||||||
promotionPrices = promotionPrices[:index]
|
if len(promotionPrices) == 0 {
|
||||||
if len(promotionPrices) == 0 {
|
return "", ErrEmptySkus
|
||||||
return "", ErrEmptySkus
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
promotion.VendorPromotionID = vendorPromotionID
|
promotion.VendorPromotionID = vendorPromotionID
|
||||||
@@ -665,7 +667,7 @@ func CancelJdPromotion(ctx *jxcontext.Context, promotionID int) (err error) {
|
|||||||
if err = dao.GetEntity(db, promotion); err != nil {
|
if err = dao.GetEntity(db, promotion); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if promotion.Status != model.PromotionStatusCanceled {
|
if promotion.Status == model.PromotionStatusCanceled {
|
||||||
return errors.New("当前状态已经是取消")
|
return errors.New("当前状态已经是取消")
|
||||||
}
|
}
|
||||||
if promotion.Status == model.PromotionStatusRemoteCreated {
|
if promotion.Status == model.PromotionStatusRemoteCreated {
|
||||||
|
|||||||
Reference in New Issue
Block a user