作者 陈志颖

fix:修复订单产品更新问题

@@ -243,6 +243,29 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend @@ -243,6 +243,29 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
243 log.Logger.Info("待更新的分红订单产品", map[string]interface{}{ 243 log.Logger.Info("待更新的分红订单产品", map[string]interface{}{
244 "orderGoodModelsToUpdate": orderGoodModelsToUpdate, 244 "orderGoodModelsToUpdate": orderGoodModelsToUpdate,
245 }) 245 })
  246 + for i, orderGoodModelToUpdate := range orderGoodModelsToUpdate {
  247 + for j, orderGood := range dividendsOrder.Goods {
  248 + if orderGood.OrderGoodId == orderGoodModelToUpdate.OrderGoodId {
  249 + orderGoodModelsToUpdate[i] = &models.OrderGood{
  250 + OrderGoodId: dividendsOrder.Goods[j].OrderGoodId,
  251 + OrderGoodAmount: dividendsOrder.Goods[j].OrderGoodAmount,
  252 + OrderGoodName: dividendsOrder.Goods[j].OrderGoodName,
  253 + OrderGoodPrice: dividendsOrder.Goods[j].OrderGoodPrice,
  254 + OrderGoodQuantity: dividendsOrder.Goods[j].OrderGoodQuantity,
  255 + DividendsOrderNumber: dividendsOrder.Goods[j].DividendsOrderNumber,
  256 + DividendsReturnedOrderNumber: dividendsOrder.Goods[j].DividendsReturnedOrderNumber,
  257 + CooperationContractNumber: dividendsOrder.Goods[j].CooperationContractNumber,
  258 + OrgId: dividendsOrder.Goods[j].OrgId,
  259 + CompanyId: dividendsOrder.Goods[j].CompanyId,
  260 + OrderGoodExpense: dividendsOrder.Goods[j].OrderGoodExpense,
  261 + OrderGoodDividendsStatus: dividendsOrder.Goods[j].OrderGoodDividendsStatus,
  262 + CreatedAt: orderGoodModelsToUpdate[i].CreatedAt,
  263 + DeletedAt: orderGoodModelsToUpdate[i].DeletedAt,
  264 + UpdatedAt: time.Now(),
  265 + }
  266 + }
  267 + }
  268 + }
246 if len(orderGoodModelsToUpdate) > 0 { 269 if len(orderGoodModelsToUpdate) > 0 {
247 if _, err := tx.Model(&orderGoodModelsToUpdate).WherePK().Update(); err != nil { 270 if _, err := tx.Model(&orderGoodModelsToUpdate).WherePK().Update(); err != nil {
248 return nil, err 271 return nil, err
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "fmt" 4 "fmt"
5 "github.com/go-pg/pg/v10" 5 "github.com/go-pg/pg/v10"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
7 "time" 8 "time"
8 9
9 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" 10 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
@@ -246,6 +247,32 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -246,6 +247,32 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
246 } 247 }
247 } 248 }
248 } 249 }
  250 + log.Logger.Info("待更新的分红退货单产品", map[string]interface{}{
  251 + "orderGoodModelsToUpdate": orderGoodModelsToUpdate,
  252 + })
  253 + for i, orderGoodModelToUpdate := range orderGoodModelsToUpdate {
  254 + for j, orderGood := range dividendsReturnedOrder.Goods {
  255 + if orderGood.OrderGoodId == orderGoodModelToUpdate.OrderGoodId {
  256 + orderGoodModelsToUpdate[i] = &models.OrderGood{
  257 + OrderGoodId: dividendsReturnedOrder.Goods[j].OrderGoodId,
  258 + OrderGoodAmount: dividendsReturnedOrder.Goods[j].OrderGoodAmount,
  259 + OrderGoodName: dividendsReturnedOrder.Goods[j].OrderGoodName,
  260 + OrderGoodPrice: dividendsReturnedOrder.Goods[j].OrderGoodPrice,
  261 + OrderGoodQuantity: dividendsReturnedOrder.Goods[j].OrderGoodQuantity,
  262 + DividendsOrderNumber: dividendsReturnedOrder.Goods[j].DividendsOrderNumber,
  263 + DividendsReturnedOrderNumber: dividendsReturnedOrder.Goods[j].DividendsReturnedOrderNumber,
  264 + CooperationContractNumber: dividendsReturnedOrder.Goods[j].CooperationContractNumber,
  265 + OrgId: dividendsReturnedOrder.Goods[j].OrgId,
  266 + CompanyId: dividendsReturnedOrder.Goods[j].CompanyId,
  267 + OrderGoodExpense: dividendsReturnedOrder.Goods[j].OrderGoodExpense,
  268 + OrderGoodDividendsStatus: dividendsReturnedOrder.Goods[j].OrderGoodDividendsStatus,
  269 + CreatedAt: orderGoodModelsToUpdate[i].CreatedAt,
  270 + DeletedAt: orderGoodModelsToUpdate[i].DeletedAt,
  271 + UpdatedAt: time.Now(),
  272 + }
  273 + }
  274 + }
  275 + }
249 if len(orderGoodModelsToUpdate) > 0 { 276 if len(orderGoodModelsToUpdate) > 0 {
250 if _, err := tx.Model(&orderGoodModelsToUpdate).WherePK().Update(); err != nil { 277 if _, err := tx.Model(&orderGoodModelsToUpdate).WherePK().Update(); err != nil {
251 return nil, err 278 return nil, err