|
@@ -53,7 +53,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder |
|
@@ -53,7 +53,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder |
53
|
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "dividendsReturnedOrder_id")
|
53
|
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "dividendsReturnedOrder_id")
|
54
|
updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
|
54
|
updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
|
55
|
tx := repository.transactionContext.PgTx
|
55
|
tx := repository.transactionContext.PgTx
|
56
|
- if dividendsReturnedOrder.Identify() == nil {
|
56
|
+ if dividendsReturnedOrder.Identify() == nil { // 新增分红退货单
|
57
|
dividendsReturnedOrderId, err := repository.nextIdentify()
|
57
|
dividendsReturnedOrderId, err := repository.nextIdentify()
|
58
|
if err != nil {
|
58
|
if err != nil {
|
59
|
return dividendsReturnedOrder, err
|
59
|
return dividendsReturnedOrder, err
|
|
@@ -137,7 +137,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder |
|
@@ -137,7 +137,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder |
137
|
if _, err := tx.Model(&orderGoodsModel).Insert(); err != nil {
|
137
|
if _, err := tx.Model(&orderGoodsModel).Insert(); err != nil {
|
138
|
return nil, err
|
138
|
return nil, err
|
139
|
}
|
139
|
}
|
140
|
- } else {
|
140
|
+ } else { // 编辑分红退货单
|
141
|
if _, err := tx.QueryOne(
|
141
|
if _, err := tx.QueryOne(
|
142
|
pg.Scan(
|
142
|
pg.Scan(
|
143
|
÷ndsReturnedOrder.DividendsReturnedOrderId,
|
143
|
÷ndsReturnedOrder.DividendsReturnedOrderId,
|
|
@@ -200,8 +200,10 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder |
|
@@ -200,8 +200,10 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder |
200
|
|
200
|
|
201
|
// 待更新分红退货单产品
|
201
|
// 待更新分红退货单产品
|
202
|
var orderGoodsToUpdate []*domain.OrderGood
|
202
|
var orderGoodsToUpdate []*domain.OrderGood
|
|
|
203
|
+
|
203
|
// 待添加分红退货单产品
|
204
|
// 待添加分红退货单产品
|
204
|
var orderGoodsToAdd []*domain.OrderGood
|
205
|
var orderGoodsToAdd []*domain.OrderGood
|
|
|
206
|
+
|
205
|
for _, good := range dividendsReturnedOrder.Goods {
|
207
|
for _, good := range dividendsReturnedOrder.Goods {
|
206
|
if good.OrderGoodId != 0 {
|
208
|
if good.OrderGoodId != 0 {
|
207
|
orderGoodsToUpdate = append(orderGoodsToUpdate, good)
|
209
|
orderGoodsToUpdate = append(orderGoodsToUpdate, good)
|
|
@@ -305,7 +307,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder |
|
@@ -305,7 +307,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder |
305
|
}
|
307
|
}
|
306
|
}
|
308
|
}
|
307
|
if len(orderGoodModelsToDelete) > 0 {
|
309
|
if len(orderGoodModelsToDelete) > 0 {
|
308
|
- if _, err := tx.Model(&orderGoodModelsToDelete).Delete(); err != nil {
|
310
|
+ if _, err := tx.Model(&orderGoodModelsToDelete).WherePK().Delete(); err != nil {
|
309
|
return nil, err
|
311
|
return nil, err
|
310
|
}
|
312
|
}
|
311
|
}
|
313
|
}
|