瀏覽代碼

种草物流

Ethan 3 周之前
父節點
當前提交
d011509e4e
共有 5 個文件被更改,包括 54 次插入14 次删除
  1. 2 0
      handler/logistics_create.go
  2. 2 0
      model/gorm_model/project_task.go
  3. 9 6
      model/http_model/logistics_create.go
  4. 1 0
      route/init.go
  5. 40 8
      service/logistics.go

+ 2 - 0
handler/logistics_create.go

@@ -55,6 +55,7 @@ func (h *CreateLogisticsHandler) run() {
 		}
 		h.resp.Message = "成功添加物流信息"
 		h.resp.Data = res
+		h.resp.Status = 20000
 	} else {
 		res, err := service.Logistics.Update(h.ctx, data)
 		if err != nil {
@@ -65,6 +66,7 @@ func (h *CreateLogisticsHandler) run() {
 		}
 		h.resp.Message = "成功修改物流信息"
 		h.resp.Data = res
+		h.resp.Status = 20000
 	}
 
 }

+ 2 - 0
model/gorm_model/project_task.go

@@ -74,6 +74,8 @@ type YoungeeTaskInfo struct {
 	City                   string    `gorm:"column:city"`                                                                     //报名达人的所在城市
 	SOperatename           string    `gorm:"column:s_operate_name;type:varchar(255);comment:提报达人服务商名称" json:"s_operate_name"` //提报达人服务商名称
 	TalentName             string    `gorm:"column:talent_name"`                                                              //达人昵称
+	CreateLogisticUserId   string    `gorm:"column:create_logistic_user_id"`                                                  //创建快递单ID
+	CreateLogisticUserType int       `gorm:"column:create_logistic_user_type"`                                                //创建快递单用户类型,1商家,2子账号,3管理后台
 }
 
 func (m *YoungeeTaskInfo) TableName() string {

+ 9 - 6
model/http_model/logistics_create.go

@@ -1,18 +1,21 @@
 package http_model
 
 type CreateLogisticsRequest struct {
+	EnterpriseId    string `json:"enterprise_id"`
+	SubAccountId    int64  `json:"sub_account_id"`
+	TaskID          string `json:"task_id"`          // 任务id
+	CompanyName     string `json:"company_name"`     // 实物商品-物流公司名称
+	LogisticsNumber string `json:"logistics_number"` // 实物商品-物流单号
+	ThingsType      int    `json:"things_type"`      // 产品类型 1:实物, 2:线下探店 3:虚拟产品
+	IsUpdate        int    `json:"is_update"`        //更新标志位 0:不更新 1:更新
+	LogisticsID     int64  `json:"logistics_id"`     // 货物-id
+
 	StrategyID            int64  `json:"strategy_id"`             //招募策略id
-	LogisticsID           int64  `json:"logistics_id"`            // 货物-id
-	CompanyName           string `json:"company_name"`            // 实物商品-物流公司名称
-	LogisticsNumber       string `json:"logistics_number"`        // 实物商品-物流单号
 	ExplorestoreStarttime string `json:"explorestore_starttime"`  // 线下探店-探店开始时间
 	ExplorestoreEndtime   string `json:"explorestore_endtime"`    // 线下探店-探店结束时间
 	ExplorestorePeriod    string `json:"explorestore_period"`     // 线下探店-探店持续时间
 	CouponCodeInformation string `json:"coupon_code_information"` // 虚拟产品-券码信息
-	TaskID                string `json:"task_id"`                 // 任务id
 	DeliveryTime          string `json:"delivery_time"`           // 发货时间
-	ThingsType            int    `json:"things_type"`             //产品类型 1:实物, 2:虚拟产品,3:线下探店
-	IsUpdate              int    `json:"is_update"`               //更新标志位 0:不更新 1:更新
 }
 
 type CreateLogisticsData struct {

+ 1 - 0
route/init.go

@@ -310,6 +310,7 @@ func InitRoute(r *gin.Engine) {
 		task.POST("/logistics/selection/talent/count", controller.TaskController{}.LogisticsSelectionTalentCount) // 带货待发货、待签收、已签收角标
 		task.POST("/logistics/talent/list", controller.TaskController{}.LogisticsTalentList)                      // 种草达人物流列表
 		task.POST("/logistics/talent/count", controller.TaskController{}.LogisticsTalentCount)                    // 种草待发货、待签收、已签收角标
+		task.POST("/logistics/createLogistics", handler.WrapCreateLogisticsHandler)                               // 创建物流信息
 
 		// 探店管理
 		task.POST("/store/explore/list", controller.TaskController{}.StoreExploreList)            // 探店本地生活列表

+ 40 - 8
service/logistics.go

@@ -23,7 +23,6 @@ func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogi
 	ThingsType := newLogistics.ThingsType
 	StrategyID := newLogistics.StrategyID
 	Logistics := gorm_model.YoungeeTaskLogistics{
-		LogisticsID:           newLogistics.LogisticsID,
 		TaskID:                newLogistics.TaskID,
 		ThingsType:            int64(ThingsType),
 		ExplorestoreStarttime: time.Now(),
@@ -35,7 +34,6 @@ func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogi
 	if ThingsType == 1 {
 		Logistics.CompanyName = newLogistics.CompanyName
 		Logistics.LogisticsNumber = newLogistics.LogisticsNumber
-		Logistics.DeliveryTime = time.Now()
 	} else if ThingsType == 3 {
 		fmt.Println("开始时间:", newLogistics.ExplorestoreStarttime)
 		fmt.Println("结束时间:", newLogistics.ExplorestoreEndtime)
@@ -53,6 +51,29 @@ func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogi
 		return nil, err
 	}
 
+	// 修改task_info中发货状态
+	err = db.UpdateLogisticsStatus(ctx, Logistics.TaskID, 2)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics service] call UpdateLogisticsStatus error,err:%+v", err)
+		return nil, err
+	}
+
+	updateTaskData := gorm_model.YoungeeTaskInfo{
+		TaskID: newLogistics.TaskID,
+	}
+	if newLogistics.SubAccountId == 0 {
+		updateTaskData.CreateLogisticUserId = newLogistics.EnterpriseId
+		updateTaskData.CreateLogisticUserType = 1
+	} else {
+		updateTaskData.CreateLogisticUserId = conv.MustString(newLogistics.SubAccountId)
+		updateTaskData.CreateLogisticUserType = 2
+	}
+	_, err5 := db.UpdateTask(ctx, updateTaskData, nil)
+	if err5 != nil {
+		logrus.WithContext(ctx).Errorf("[projectPay service] call SpecialSettlePay error,err:%+v", err5)
+		return nil, err5
+	}
+
 	projectId, err1 := db.GetProjectIdByTaskId(ctx, newLogistics.TaskID)
 	if err1 != nil {
 		logrus.WithContext(ctx).Errorf("[project service] call GetProjectIdByTaskId error,err:%+v", err1)
@@ -73,12 +94,6 @@ func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogi
 		logrus.WithContext(ctx).Errorf("[project service] call UpdateLogisticsNumber error,err:%+v", err)
 		return nil, err
 	}
-	// 修改task_info中发货状态
-	err = db.UpdateLogisticsStatus(ctx, Logistics.TaskID, 2)
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[logistics service] call UpdateLogisticsStatus error,err:%+v", err)
-		return nil, err
-	}
 
 	// 修改task_info中发货时间
 	err = db.UpdateLogisticsDate(ctx, Logistics.TaskID)
@@ -146,6 +161,23 @@ func (*logistics) Update(ctx context.Context, newLogistics http_model.CreateLogi
 	res := &http_model.CreateLogisticsData{
 		LogisticsID: *logisticsID,
 	}
+
+	updateTaskData := gorm_model.YoungeeTaskInfo{
+		TaskID: newLogistics.TaskID,
+	}
+	if newLogistics.SubAccountId == 0 {
+		updateTaskData.CreateLogisticUserId = newLogistics.EnterpriseId
+		updateTaskData.CreateLogisticUserType = 1
+	} else {
+		updateTaskData.CreateLogisticUserId = conv.MustString(newLogistics.SubAccountId)
+		updateTaskData.CreateLogisticUserType = 2
+	}
+	_, err5 := db.UpdateTask(ctx, updateTaskData, nil)
+	if err5 != nil {
+		logrus.WithContext(ctx).Errorf("[projectPay service] call SpecialSettlePay error,err:%+v", err5)
+		return nil, err5
+	}
+
 	return res, nil
 }