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

---
 go.sum                                 |   11 ++
 service/serviceCollectionPlan.go       |    8 +-
 api/v1/serviceCollectionPlan.go        |   31 +++++--
 model/request/serviceCollectionPlan.go |    2 
 go.mod                                 |    2 
 constvar/serviceCollectionPlan.go      |   10 ++
 docs/swagger.yaml                      |   30 ++++---
 docs/docs.go                           |   32 +++++---
 docs/swagger.json                      |   32 +++++---
 model/serviceCollectionPlan.go         |   41 +++++----
 10 files changed, 130 insertions(+), 69 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}
diff --git a/constvar/serviceCollectionPlan.go b/constvar/serviceCollectionPlan.go
index 32450ec..6f32e72 100644
--- a/constvar/serviceCollectionPlan.go
+++ b/constvar/serviceCollectionPlan.go
@@ -1,4 +1,5 @@
 package constvar
+
 type ServiceCollectionPlanQueryClass string
 
 const (
@@ -8,5 +9,12 @@
 type ServiceCollectionPlanKeywordType string
 
 const (
-	ServiceCollectionPlanKeywordCustomerName   ServiceCollectionPlanKeywordType = ""
+	ServiceCollectionPlanKeywordCustomerName ServiceCollectionPlanKeywordType = ""
+)
+
+type CollectionStatus int
+
+const (
+	CollectionStatusUnCollected CollectionStatus = 1 //寰呮敹娆�
+	CollectionStatusCollected   CollectionStatus = 2 //宸叉敹娆�
 )
diff --git a/docs/docs.go b/docs/docs.go
index a31ad29..4364ed1 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -6693,9 +6693,9 @@
                     "application/json"
                 ],
                 "tags": [
-                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                    "鏀舵璁″垝绠$悊"
                 ],
-                "summary": "娣诲姞鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "summary": "娣诲姞鏀舵璁″垝",
                 "parameters": [
                     {
                         "description": "鏌ヨ鍙傛暟",
@@ -6723,9 +6723,9 @@
                     "application/json"
                 ],
                 "tags": [
-                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                    "鏀舵璁″垝绠$悊"
                 ],
-                "summary": "鍒犻櫎鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "summary": "鍒犻櫎鏀舵璁″垝",
                 "parameters": [
                     {
                         "type": "integer",
@@ -6751,9 +6751,9 @@
                     "application/json"
                 ],
                 "tags": [
-                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                    "鏀舵璁″垝绠$悊"
                 ],
-                "summary": "鑾峰彇鏈嶅姟鍚堝悓鏀舵璁″垝鍒楄〃",
+                "summary": "鑾峰彇鏀舵璁″垝鍒楄〃",
                 "parameters": [
                     {
                         "type": "integer",
@@ -6793,9 +6793,9 @@
                     "application/json"
                 ],
                 "tags": [
-                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                    "鏀舵璁″垝绠$悊"
                 ],
-                "summary": "鏇存柊鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "summary": "鏇存柊鏀舵璁″垝",
                 "parameters": [
                     {
                         "description": "鏌ヨ鍙傛暟",
@@ -10444,8 +10444,12 @@
                     "description": "澶囨敞",
                     "type": "string"
                 },
-                "serviceContractId": {
-                    "description": "鏈嶅姟鍚堝悓id",
+                "sourceId": {
+                    "description": "婧愬崟id",
+                    "type": "integer"
+                },
+                "sourceType": {
+                    "description": "婧愬崟绫诲瀷锛�1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁級",
                     "type": "integer"
                 },
                 "status": {
@@ -14648,8 +14652,12 @@
                     "description": "澶囨敞",
                     "type": "string"
                 },
-                "serviceContractId": {
-                    "description": "鏈嶅姟鍚堝悓id",
+                "sourceId": {
+                    "description": "婧愬崟id",
+                    "type": "integer"
+                },
+                "sourceType": {
+                    "description": "婧愬崟绫诲瀷锛�1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁級",
                     "type": "integer"
                 },
                 "status": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 7209ba5..d5c765e 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -6681,9 +6681,9 @@
                     "application/json"
                 ],
                 "tags": [
-                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                    "鏀舵璁″垝绠$悊"
                 ],
-                "summary": "娣诲姞鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "summary": "娣诲姞鏀舵璁″垝",
                 "parameters": [
                     {
                         "description": "鏌ヨ鍙傛暟",
@@ -6711,9 +6711,9 @@
                     "application/json"
                 ],
                 "tags": [
-                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                    "鏀舵璁″垝绠$悊"
                 ],
-                "summary": "鍒犻櫎鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "summary": "鍒犻櫎鏀舵璁″垝",
                 "parameters": [
                     {
                         "type": "integer",
@@ -6739,9 +6739,9 @@
                     "application/json"
                 ],
                 "tags": [
-                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                    "鏀舵璁″垝绠$悊"
                 ],
-                "summary": "鑾峰彇鏈嶅姟鍚堝悓鏀舵璁″垝鍒楄〃",
+                "summary": "鑾峰彇鏀舵璁″垝鍒楄〃",
                 "parameters": [
                     {
                         "type": "integer",
@@ -6781,9 +6781,9 @@
                     "application/json"
                 ],
                 "tags": [
-                    "鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊"
+                    "鏀舵璁″垝绠$悊"
                 ],
-                "summary": "鏇存柊鏈嶅姟鍚堝悓鏀舵璁″垝",
+                "summary": "鏇存柊鏀舵璁″垝",
                 "parameters": [
                     {
                         "description": "鏌ヨ鍙傛暟",
@@ -10432,8 +10432,12 @@
                     "description": "澶囨敞",
                     "type": "string"
                 },
-                "serviceContractId": {
-                    "description": "鏈嶅姟鍚堝悓id",
+                "sourceId": {
+                    "description": "婧愬崟id",
+                    "type": "integer"
+                },
+                "sourceType": {
+                    "description": "婧愬崟绫诲瀷锛�1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁級",
                     "type": "integer"
                 },
                 "status": {
@@ -14636,8 +14640,12 @@
                     "description": "澶囨敞",
                     "type": "string"
                 },
-                "serviceContractId": {
-                    "description": "鏈嶅姟鍚堝悓id",
+                "sourceId": {
+                    "description": "婧愬崟id",
+                    "type": "integer"
+                },
+                "sourceType": {
+                    "description": "婧愬崟绫诲瀷锛�1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁級",
                     "type": "integer"
                 },
                 "status": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 5bb4c66..a70480d 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1166,8 +1166,11 @@
       remark:
         description: 澶囨敞
         type: string
-      serviceContractId:
-        description: 鏈嶅姟鍚堝悓id
+      sourceId:
+        description: 婧愬崟id
+        type: integer
+      sourceType:
+        description: 婧愬崟绫诲瀷锛�1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁級
         type: integer
       status:
         description: 鐘舵�侊紙1鏈敹2宸叉敹锛�
@@ -4012,8 +4015,11 @@
       remark:
         description: 澶囨敞
         type: string
-      serviceContractId:
-        description: 鏈嶅姟鍚堝悓id
+      sourceId:
+        description: 婧愬崟id
+        type: integer
+      sourceType:
+        description: 婧愬崟绫诲瀷锛�1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁級
         type: integer
       status:
         description: 鐘舵�侊紙1鏈敹2宸叉敹锛�
@@ -9104,9 +9110,9 @@
           description: OK
           schema:
             $ref: '#/definitions/contextx.Response'
-      summary: 娣诲姞鏈嶅姟鍚堝悓鏀舵璁″垝
+      summary: 娣诲姞鏀舵璁″垝
       tags:
-      - 鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+      - 鏀舵璁″垝绠$悊
   /api/serviceCollectionPlan/delete/{id}:
     delete:
       parameters:
@@ -9122,9 +9128,9 @@
           description: OK
           schema:
             $ref: '#/definitions/contextx.Response'
-      summary: 鍒犻櫎鏈嶅姟鍚堝悓鏀舵璁″垝
+      summary: 鍒犻櫎鏀舵璁″垝
       tags:
-      - 鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+      - 鏀舵璁″垝绠$悊
   /api/serviceCollectionPlan/list:
     get:
       parameters:
@@ -9146,9 +9152,9 @@
                     $ref: '#/definitions/model.ServiceCollectionPlan'
                   type: array
               type: object
-      summary: 鑾峰彇鏈嶅姟鍚堝悓鏀舵璁″垝鍒楄〃
+      summary: 鑾峰彇鏀舵璁″垝鍒楄〃
       tags:
-      - 鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+      - 鏀舵璁″垝绠$悊
   /api/serviceCollectionPlan/update:
     put:
       parameters:
@@ -9165,9 +9171,9 @@
           description: OK
           schema:
             $ref: '#/definitions/contextx.Response'
-      summary: 鏇存柊鏈嶅姟鍚堝悓鏀舵璁″垝
+      summary: 鏇存柊鏀舵璁″垝
       tags:
-      - 鏈嶅姟鍚堝悓鏀舵璁″垝绠$悊
+      - 鏀舵璁″垝绠$悊
   /api/serviceContract/add:
     post:
       parameters:
diff --git a/go.mod b/go.mod
index 99e593f..2d77042 100644
--- a/go.mod
+++ b/go.mod
@@ -31,6 +31,7 @@
 	gorm.io/driver/mysql v1.5.1
 	gorm.io/gorm v1.25.1
 	moul.io/zapgorm2 v1.3.0
+	github.com/shopspring/decimal v1.3.1
 )
 
 require (
@@ -96,6 +97,7 @@
 	github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
 	github.com/rogpeppe/go-internal v1.10.0 // indirect
 	github.com/shirou/gopsutil/v3 v3.22.5 // indirect
+	github.com/shopspring/decimal v1.3.1 // indirect
 	github.com/spf13/afero v1.9.5 // indirect
 	github.com/spf13/cast v1.5.1 // indirect
 	github.com/spf13/jwalterweatherman v1.1.0 // indirect
diff --git a/go.sum b/go.sum
index 9a0e61d..dd321fd 100644
--- a/go.sum
+++ b/go.sum
@@ -50,6 +50,8 @@
 github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
 github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
 github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
+github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
 github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
 github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible h1:Ft+KeWIJxFP76LqgJbvtOA1qBIoC8vGkTV3QeCOeJC4=
 github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
@@ -165,6 +167,7 @@
 github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
 github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
 github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
+github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
 github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
 github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
 github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
@@ -259,6 +262,8 @@
 github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
 github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
 github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
+github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
 github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
 github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
 github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
@@ -379,6 +384,7 @@
 github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
 github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
 github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
+github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
 github.com/microsoft/go-mssqldb v1.1.0 h1:jsV+tpvcPTbNNKW0o3kiCD69kOHICsfjZ2VcVu2lKYc=
 github.com/microsoft/go-mssqldb v1.1.0/go.mod h1:LzkFdl4z2Ck+Hi+ycGOTbL56VEfgoyA2DvYejrNGbRk=
 github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
@@ -396,6 +402,7 @@
 github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
 github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
+github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
 github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
 github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E=
 github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ=
@@ -435,6 +442,8 @@
 github.com/shirou/gopsutil/v3 v3.22.5/go.mod h1:so9G9VzeHt/hsd0YwqprnjHnfARAUktauykSbr+y2gA=
 github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
 github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
+github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
+github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
 github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
 github.com/songzhibin97/gkit v1.2.11 h1:O8+l6eLMrZ2yNbT6Vohc6ggWnH5zt4P8/3ZEkf8jUL4=
@@ -580,6 +589,7 @@
 golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
 golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
 golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
@@ -925,6 +935,7 @@
 gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
 gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
 gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/model/request/serviceCollectionPlan.go b/model/request/serviceCollectionPlan.go
index b8e4f35..a1a9a11 100644
--- a/model/request/serviceCollectionPlan.go
+++ b/model/request/serviceCollectionPlan.go
@@ -5,7 +5,7 @@
 )
 
 type AddServiceCollectionPlan struct {
-	List []*model.ServiceCollectionPlan
+	List []*model.ServiceCollectionPlan `json:"list" binding:"required"`
 }
 
 type UpdateServiceCollectionPlan struct {
diff --git a/model/serviceCollectionPlan.go b/model/serviceCollectionPlan.go
index be9da1b..cb15770 100644
--- a/model/serviceCollectionPlan.go
+++ b/model/serviceCollectionPlan.go
@@ -5,27 +5,30 @@
 	"aps_crm/pkg/mysqlx"
 	"errors"
 	"fmt"
+	"github.com/shopspring/decimal"
 	"gorm.io/gorm"
+	"time"
 )
 
 type (
-	// ServiceCollectionPlan 鏈嶅姟鍚堝悓鏀舵璁″垝
+	// ServiceCollectionPlan 鏀舵璁″垝
 	ServiceCollectionPlan struct {
-		Id                int     `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
-		CollectionType    int     `gorm:"collection_type" json:"collectionType"`        // 绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級
-		ServiceContractId int     `gorm:"service_contract_id" json:"serviceContractId"` // 鏈嶅姟鍚堝悓id
-		PrincipalId       int     `gorm:"principal_id" json:"principalId"`              // 鏀舵璐熻矗浜篒D
-		Term              int     `gorm:"term" json:"term"`                             // 鏈熸
-		Percent           float64 `gorm:"percent" json:"percent"`                       // 姣斾緥
-		Amount            float64 `gorm:"amount" json:"amount"`                         // 閲戦
-		MoneyType         string  `gorm:"money_type" json:"moneyType"`                  // 甯佺
-		CollectionDate    string  `gorm:"collection_date" json:"collectionDate"`        // 璁″垝鏀舵鏃ユ湡
-		Remark            string  `gorm:"remark" json:"remark"`                         // 澶囨敞
-		Status            int     `gorm:"status" json:"status"`                         // 鐘舵�侊紙1鏈敹2宸叉敹锛�
-		FileId            int     `gorm:"file_id" json:"fileId"`                        // 闄勪欢id
+		Id             int                       `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		CollectionType int                       `gorm:"collection_type" json:"collectionType"` // 绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級
+		SourceType     int                       `gorm:"source_type" json:"sourceType"`         // 婧愬崟绫诲瀷锛�1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁級
+		SourceId       int                       `gorm:"source_id" json:"sourceId"`             // 婧愬崟id
+		PrincipalId    int                       `gorm:"principal_id" json:"principalId"`       // 鏀舵璐熻矗浜篒D
+		Term           int                       `gorm:"term" json:"term"`                      // 鏈熸
+		Percent        decimal.Decimal           `gorm:"percent" json:"percent"`                // 姣斾緥
+		Amount         decimal.Decimal           `gorm:"amount" json:"amount"`                  // 閲戦
+		MoneyType      string                    `gorm:"money_type" json:"moneyType"`           // 甯佺
+		CollectionDate time.Time                 `gorm:"collection_date" json:"collectionDate"` // 璁″垝鏀舵鏃ユ湡
+		Remark         string                    `gorm:"remark" json:"remark"`                  // 澶囨敞
+		Status         constvar.CollectionStatus `gorm:"status" json:"status"`                  // 鐘舵�侊紙1鏈敹2宸叉敹锛�
+		FileId         int                       `gorm:"file_id" json:"fileId"`                 // 闄勪欢id
 	}
 
-	// ServiceCollectionPlanSearch 鏈嶅姟鍚堝悓鏀舵璁″垝鎼滅储鏉′欢
+	// ServiceCollectionPlanSearch 鏀舵璁″垝鎼滅储鏉′欢
 	ServiceCollectionPlanSearch struct {
 		ServiceCollectionPlan
 		Orm         *gorm.DB
@@ -38,7 +41,7 @@
 )
 
 func (ServiceCollectionPlan) TableName() string {
-	return "service_collection_plan"
+	return "collection_plan"
 }
 
 func NewServiceCollectionPlanSearch() *ServiceCollectionPlanSearch {
@@ -53,8 +56,8 @@
 		db = db.Where("id = ?", slf.Id)
 	}
 
-	if slf.ServiceContractId != 0 {
-		db = db.Where("service_contract_id = ?", slf.ServiceContractId)
+	if slf.SourceId != 0 {
+		db = db.Where("source_id = ?", slf.SourceId)
 	}
 
 	return db
@@ -97,8 +100,8 @@
 	return slf
 }
 
-func (slf *ServiceCollectionPlanSearch) SetServiceContractId(id int) *ServiceCollectionPlanSearch {
-	slf.ServiceContractId = id
+func (slf *ServiceCollectionPlanSearch) SetSourceId(id int) *ServiceCollectionPlanSearch {
+	slf.SourceId = id
 	return slf
 }
 
diff --git a/service/serviceCollectionPlan.go b/service/serviceCollectionPlan.go
index fdaa235..f87f5a4 100644
--- a/service/serviceCollectionPlan.go
+++ b/service/serviceCollectionPlan.go
@@ -17,9 +17,9 @@
 	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
 		}
@@ -45,8 +45,8 @@
 	return ecode.OK
 }
 
-func (ServiceCollectionPlanService) GetServiceCollectionPlanList(contractId int) ([]*model.ServiceCollectionPlan, int64, int) {
-	list, total, err := model.NewServiceCollectionPlanSearch().SetServiceContractId(contractId).Find()
+func (ServiceCollectionPlanService) GetServiceCollectionPlanList(sourceId int) ([]*model.ServiceCollectionPlan, int64, int) {
+	list, total, err := model.NewServiceCollectionPlanSearch().SetSourceId(sourceId).Find()
 	if err != nil {
 		return nil, 0, ecode.DBErr
 	}

--
Gitblit v1.8.0