12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package service
- import (
- "context"
- "youngee_b_api/db"
- "youngee_b_api/model/gorm_model"
- "youngee_b_api/model/http_model"
- )
- var Logistics *logistics
- type logistics struct {
- }
- func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogisticsRequest) (*http_model.CreateLogisticsData, error) {
- ThingsType := newLogistics.ThingsType
- RecruitStrategyID := newLogistics.RecruitStrategyID
- Logistics := gorm_model.YoungeeTaskLogistics{
- LogisticsID: newLogistics.LogisticsID,
- TaskID: newLogistics.TaskID,
- ThingsType: ThingsType,
- }
- //实物
- if ThingsType == 1 {
- Logistics.CompanyName = newLogistics.CompanyName
- Logistics.DeliveryTime = newLogistics.DeliveryTime
- } else if ThingsType == 2 {
- Logistics.ExplorestoreStarttime = newLogistics.ExplorestoreStarttime
- Logistics.ExplorestoreEndtime = newLogistics.ExplorestoreEndtime
- Logistics.ExplorestorePeriod = newLogistics.ExplorestorePeriod
- } else {
- Logistics.CouponCodeInformation = newLogistics.CouponCodeInformation
- }
- logisticsID, err := db.CreateLogistics(ctx, Logistics, RecruitStrategyID)
- if err != nil {
- return nil, err
- }
- res := &http_model.CreateLogisticsData{
- LogisticsID: *logisticsID,
- }
- return res, nil
- }
- func (*logistics) Update(ctx context.Context, newLogistics http_model.CreateLogisticsRequest) (*http_model.CreateLogisticsData, error) {
- ThingsType := newLogistics.ThingsType
- Logistics := gorm_model.YoungeeTaskLogistics{
- LogisticsID: newLogistics.LogisticsID,
- TaskID: newLogistics.TaskID,
- ThingsType: ThingsType,
- }
- //实物
- if ThingsType == 1 {
- Logistics.CompanyName = newLogistics.CompanyName
- Logistics.DeliveryTime = newLogistics.DeliveryTime
- } else if ThingsType == 2 {
- Logistics.ExplorestoreStarttime = newLogistics.ExplorestoreStarttime
- Logistics.ExplorestoreEndtime = newLogistics.ExplorestoreEndtime
- Logistics.ExplorestorePeriod = newLogistics.ExplorestorePeriod
- } else {
- Logistics.CouponCodeInformation = newLogistics.CouponCodeInformation
- }
- logisticsID, err := db.UpdateLogistics(ctx, Logistics)
- if err != nil {
- return nil, err
- }
- res := &http_model.CreateLogisticsData{
- LogisticsID: *logisticsID,
- }
- return res, nil
- }
|