| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | |
| | | if len(serviceCollectionPlan) == 0 { |
| | | return ecode.ParamsErr |
| | | } |
| | | contractId := serviceCollectionPlan[0].ServiceContractId |
| | | sourceId := serviceCollectionPlan[0].SourceId |
| | | err := model.WithTransaction(func(db *gorm.DB) error { |
| | | err := model.NewServiceCollectionPlanSearch().SetOrm(db).SetServiceContractId(contractId).Delete() |
| | | err := model.NewServiceCollectionPlanSearch().SetOrm(db).SetSourceId(sourceId).Delete() |
| | | if err != nil { |
| | | return err |
| | | } |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ServiceCollectionPlanService) GetServiceCollectionPlanList(contractId int) ([]*model.ServiceCollectionPlan, int64, int) { |
| | | list, total, err := model.NewServiceCollectionPlanSearch().SetServiceContractId(contractId).Find() |
| | | func (ServiceCollectionPlanService) GetServiceCollectionPlanList(sourceType constvar.CollectionSourceType, sourceId int) ([]*model.ServiceCollectionPlan, int64, int) { |
| | | list, total, err := model.NewServiceCollectionPlanSearch().SetSourceType(sourceType).SetSourceId(sourceId).Find() |
| | | if err != nil { |
| | | return nil, 0, ecode.DBErr |
| | | } |
| | |
| | | } |
| | | |
| | | func (ServiceCollectionPlanService) UpdateServiceCollectionPlan(serviceCollectionPlan *model.ServiceCollectionPlan) int { |
| | | err := model.NewServiceCollectionPlanSearch().SetId(serviceCollectionPlan.Id).Save(serviceCollectionPlan) |
| | | err := model.NewServiceCollectionPlanSearch().SetId(serviceCollectionPlan.Id).Update(serviceCollectionPlan) |
| | | if err != nil { |
| | | return ecode.DBErr |
| | | } |