作者 唐旭辉

更新注释

@@ -16,7 +16,7 @@ import ( @@ -16,7 +16,7 @@ import (
16 16
17 //从其他系统接收订单数据 17 //从其他系统接收订单数据
18 const ( 18 const (
19 - BEST_SHOP_UNIONID string = "gh_18eb644002fb" //海鲜干货小程序原始id 19 + BEST_SHOP_UNIONID string = "gh_18eb644002fb" //香米小程序原始id
20 ) 20 )
21 21
22 type SyncOrderService struct { 22 type SyncOrderService struct {
@@ -79,6 +79,7 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests @@ -79,6 +79,7 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests
79 // 79 //
80 logs.Warning("订单数据已存在:order_code=%s", cmd.OrderCode) 80 logs.Warning("订单数据已存在:order_code=%s", cmd.OrderCode)
81 } else { 81 } else {
  82 + //复制数据到order_base表
82 err = s.CreateOrderFromBestshop(cmd) 83 err = s.CreateOrderFromBestshop(cmd)
83 } 84 }
84 return err 85 return err
@@ -225,6 +226,8 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord @@ -225,6 +226,8 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
225 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) 226 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
226 } 227 }
227 for _, v := range companyData.Applets { 228 for _, v := range companyData.Applets {
  229 + //BEST_SHOP_UNIONID string = "gh_18eb644002fb" //香米小程序原始id
  230 + //接收香米小程序的订单数据
228 if len(v.Id) > 0 { 231 if len(v.Id) > 0 {
229 canCopyOrder = true 232 canCopyOrder = true
230 } 233 }
@@ -237,7 +240,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord @@ -237,7 +240,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
237 orderbase domain.OrderBase 240 orderbase domain.OrderBase
238 ordergoods []domain.OrderGood 241 ordergoods []domain.OrderGood
239 ) 242 )
240 - //TODO 添加orderBase 243 + //添加orderBase
241 orderBestshop.CopyToOrderBase(&orderbase) 244 orderBestshop.CopyToOrderBase(&orderbase)
242 orderbase.CompanyId = companyData.Id 245 orderbase.CompanyId = companyData.Id
243 for i := range orderBestshop.Goods { 246 for i := range orderBestshop.Goods {
@@ -245,13 +248,15 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord @@ -245,13 +248,15 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
245 orderBestshop.Goods[i].CopyToOrderGood(&good) 248 orderBestshop.Goods[i].CopyToOrderGood(&good)
246 good.CompanyId = partnerData.CompanyId 249 good.CompanyId = partnerData.CompanyId
247 good.Compute() 250 good.Compute()
  251 + //初始接收的订单按照待支付状态处理
248 good.CurrentBonusStatus.WartPayPartnerBonus(&good) 252 good.CurrentBonusStatus.WartPayPartnerBonus(&good)
249 ordergoods = append(ordergoods, good) 253 ordergoods = append(ordergoods, good)
250 } 254 }
251 orderbase.Goods = ordergoods 255 orderbase.Goods = ordergoods
252 orderbase.PartnerId = partnerData.Partner.Id 256 orderbase.PartnerId = partnerData.Partner.Id
253 orderbase.CompanyId = partnerData.CompanyId 257 orderbase.CompanyId = partnerData.CompanyId
254 - orderbase.PartnerCategory = domain.PartnerCategory{Id: 1, Name: "事业合伙人"} // 默认设定为事业合伙人订单 258 + // 默认设定为事业合伙人订单
  259 + orderbase.PartnerCategory = domain.PartnerCategory{Id: 1, Name: "事业合伙人"}
255 orderbase.Compute() 260 orderbase.Compute()
256 err = orderBaseRepository.Save(&orderbase) 261 err = orderBaseRepository.Save(&orderbase)
257 if err != nil { 262 if err != nil {
@@ -311,6 +311,7 @@ func (good *OrderGood) Compute() error { @@ -311,6 +311,7 @@ func (good *OrderGood) Compute() error {
311 planamount := price.Mul(decimal.NewFromInt(int64(planGoodNumber))) 311 planamount := price.Mul(decimal.NewFromInt(int64(planGoodNumber)))
312 var partnerBonusPercent float64 312 var partnerBonusPercent float64
313 if good.PartnerBonusPercent < 0 { 313 if good.PartnerBonusPercent < 0 {
  314 + //判断合伙人分成比例是否设置,若未设置则按照 0 来计算分成
314 partnerBonusPercent = 0 315 partnerBonusPercent = 0
315 } else { 316 } else {
316 partnerBonusPercent = good.PartnerBonusPercent 317 partnerBonusPercent = good.PartnerBonusPercent