From 6f52e069fe72b4e37b0712a7e097e3af97bbc25e Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 07 八月 2023 10:22:11 +0800
Subject: [PATCH] 收款计划兼容其他模块

---
 api/v1/serviceCollectionPlan.go |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/api/v1/serviceCollectionPlan.go b/api/v1/serviceCollectionPlan.go
index 7476dd7..346aec8 100644
--- a/api/v1/serviceCollectionPlan.go
+++ b/api/v1/serviceCollectionPlan.go
@@ -1,6 +1,7 @@
 package v1
 
 import (
+	"aps_crm/constvar"
 	"aps_crm/model/request"
 	"aps_crm/model/response"
 	"aps_crm/pkg/contextx"
@@ -13,8 +14,8 @@
 type ServiceCollectionPlanApi struct{}
 
 // Add
-// @Tags		鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
-// @Summary	娣诲姞鏈嶅姟鍚堝悓鏀舵璁″垝
+// @Tags		鏀舵璁″垝绠$悊
+// @Summary	娣诲姞鏀舵璁″垝
 // @Produce	application/json
 // @Param		object	body		request.AddServiceCollectionPlan	true	"鏌ヨ鍙傛暟"
 // @Success	200		{object}	contextx.Response{}
@@ -24,6 +25,20 @@
 	ctx, ok := contextx.NewContext(c, &params)
 	if !ok {
 		return
+	}
+
+	for _, plan := range params.List {
+		if plan.SourceType == 0 ||
+			plan.SourceId == 0 ||
+			plan.CollectionType == 0 ||
+			plan.CollectionDate.IsZero() ||
+			plan.Amount.IsZero() ||
+			plan.Percent.IsZero() ||
+			plan.PrincipalId == 0 {
+			ctx.Fail(ecode.ParamsErr)
+			return
+		}
+		plan.Status = constvar.CollectionStatusUnCollected
 	}
 
 	errCode := service.NewServiceCollectionPlanService().AddServiceCollectionPlan(params.List)
@@ -36,8 +51,8 @@
 }
 
 // Delete
-// @Tags		鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
-// @Summary	鍒犻櫎鏈嶅姟鍚堝悓鏀舵璁″垝
+// @Tags		鏀舵璁″垝绠$悊
+// @Summary	鍒犻櫎鏀舵璁″垝
 // @Produce	application/json
 // @Param		id	path		int	true	"鏌ヨ鍙傛暟"
 // @Success	200	{object}	contextx.Response{}
@@ -59,8 +74,8 @@
 }
 
 // Update
-// @Tags		鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
-// @Summary	鏇存柊鏈嶅姟鍚堝悓鏀舵璁″垝
+// @Tags		鏀舵璁″垝绠$悊
+// @Summary	鏇存柊鏀舵璁″垝
 // @Produce	application/json
 // @Param		object	body		request.UpdateServiceCollectionPlan	true	"鏌ヨ鍙傛暟"
 // @Success	200		{object}	contextx.Response{}
@@ -86,8 +101,8 @@
 }
 
 // List
-// @Tags		鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
-// @Summary	鑾峰彇鏈嶅姟鍚堝悓鏀舵璁″垝鍒楄〃
+// @Tags		鏀舵璁″垝绠$悊
+// @Summary	鑾峰彇鏀舵璁″垝鍒楄〃
 // @Produce	application/json
 // @Param		object	query		request.GetServiceCollectionPlanList	true	"鍙傛暟"
 // @Success	200	{object}	response.ListResponse{data=[]model.ServiceCollectionPlan}

--
Gitblit v1.8.0