zhangqian
2024-07-01 fe794b385cc1fe28cb6d0731664a3023199843ac
models/operation_details.go
@@ -29,6 +29,7 @@
      AuxiliaryUnit    string          `json:"auxiliaryUnit" gorm:"type:varchar(191);comment:辅助单位"`
      Remark           string          `gorm:"type:varchar(1024);comment:备注" json:"remark"`
      IsInternalOutput bool            `json:"isInternalOutput"` //是否调拨产生的出库
      DealerType       string          `json:"dealerType"`       //出入库类型
      Cost      decimal.Decimal `json:"cost" `      //成本单价
      SalePrice decimal.Decimal `json:"salePrice" ` //销售单价
@@ -312,3 +313,20 @@
   }
   return result, nil
}
type GroupByDealerTypeWarehouse struct {
   DealerType string
   ProductID  string
   Sum        decimal.Decimal
}
func (slf *OperationDetailsSearch) GroupMultiSumAmount() ([]*GroupByDealerTypeWarehouse, error) {
   var (
      db     = slf.build()
      result = make([]*GroupByDealerTypeWarehouse, 0)
   )
   if err := db.Select("sum(amount) as sum, dealer_type, product_id").Group("product_id, dealer_type").Scan(&result).Error; err != nil {
      return nil, fmt.Errorf("select group err: %v", err)
   }
   return result, nil
}