陈少旭 2 months ago
parent
commit
e07317abef

+ 8 - 7
controllers/admin_api_controllers/analysis_api_controller.go View File

50
 		"curYearPaymentCollectionSumamtPriceCount":   curYearPaymentCollectionSumamtPriceCount,
50
 		"curYearPaymentCollectionSumamtPriceCount":   curYearPaymentCollectionSumamtPriceCount,
51
 		"curYearPaymentCollectionSoftwarePriceCount": curYearPaymentCollectionSoftwarePriceCount,
51
 		"curYearPaymentCollectionSoftwarePriceCount": curYearPaymentCollectionSoftwarePriceCount,
52
 		"curYearPaymentCollectionHardwarePriceCount": curYearPaymentCollectionHardwarePriceCount,
52
 		"curYearPaymentCollectionHardwarePriceCount": curYearPaymentCollectionHardwarePriceCount,
53
-		"oneMonthCount":                              oneMonthCount,
54
-		"threeMontheCount":                           threeMontheCount,
55
-		"curYearRenewalCount":                        curYearRenewalCount,
56
-		"curYearPaymentCollectionCount":              curYearPaymentCollectionCount,
57
-		"curYearWaitPutIntoEffectCount":              curYearWaitPutIntoEffectCount,
58
-		"curYearWaitAbutmentCount":                   curYearWaitAbutmentCount,
59
-		"cure":                                       cure,
53
+
54
+		"oneMonthCount":                 oneMonthCount,
55
+		"threeMontheCount":              threeMontheCount,
56
+		"curYearRenewalCount":           curYearRenewalCount,
57
+		"curYearPaymentCollectionCount": curYearPaymentCollectionCount,
58
+		"curYearWaitPutIntoEffectCount": curYearWaitPutIntoEffectCount,
59
+		"curYearWaitAbutmentCount":      curYearWaitAbutmentCount,
60
+		"cure":                          cure,
60
 	})
61
 	})
61
 
62
 
62
 }
63
 }

+ 2 - 1
controllers/admin_api_controllers/custom_api_controller.go View File

146
 	}
146
 	}
147
 }
147
 }
148
 func (this *CustomAPIController) GetCustomList() {
148
 func (this *CustomAPIController) GetCustomList() {
149
-	list, _ := service.GetAllCustoms()
149
+	types, _ := this.GetInt64("type")
150
+	list, _ := service.GetAllCustoms(types)
150
 	this.ServeSuccessJSON(map[string]interface{}{
151
 	this.ServeSuccessJSON(map[string]interface{}{
151
 		"list": list,
152
 		"list": list,
152
 	})
153
 	})

+ 1 - 1
routers/router.go View File

9
 func init() {
9
 func init() {
10
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
10
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
11
 		AllowAllOrigins:  true,
11
 		AllowAllOrigins:  true,
12
-		AllowOrigins:     []string{"http://xtsf.sgjyun.com", "http://api.szjkhd.com", "http://sf.sgjyun.com", "http://admin.xt.test.szjkhd.com", "http://admin.xt.szjkhd.com", "http://localhost:9527"},
12
+		AllowOrigins:     []string{"http://xtsf.sgjyun.com", "http://api.szjkhd.com", "http://sf.sgjyun.com", "http://admin.xt.test.szjkhd.com", "http://admin.xt.szjkhd.com", "http://localhost:9527", "'http://localhost:8080"},
13
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
13
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
14
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
14
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
15
 		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
15
 		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},

+ 42 - 3
service/custom_service.go View File

1
 package service
1
 package service
2
 
2
 
3
-import "XT_Admin_Api/models"
3
+import (
4
+	"XT_Admin_Api/models"
5
+	"time"
6
+)
4
 
7
 
5
 func FindCustomInfo(org_id int64) (admin models.KyyChargeCustom, err error) {
8
 func FindCustomInfo(org_id int64) (admin models.KyyChargeCustom, err error) {
6
 	err = ChargeReadDB().Model(&models.KyyChargeCustom{}).Where("xt_org_id = ? AND status = 1", org_id).First(&admin).Error
9
 	err = ChargeReadDB().Model(&models.KyyChargeCustom{}).Where("xt_org_id = ? AND status = 1", org_id).First(&admin).Error
21
 	err = ChargeWriteDB().Model(&models.KyyChargeCustomThree{}).Save(&admin).Error
24
 	err = ChargeWriteDB().Model(&models.KyyChargeCustomThree{}).Save(&admin).Error
22
 	return
25
 	return
23
 }
26
 }
24
-func GetAllCustoms() (cus []*models.KyyChargeCustom, err error) {
25
-	err = ChargeReadDB().Model(&models.KyyChargeCustomTwo{}).Where("status = 1").Find(&cus).Error
27
+func GetAllCustoms(types int64) (cus []*models.KyyChargeCustom, err error) {
28
+	switch types {
29
+	case 0:
30
+		err = ChargeReadDB().Model(&models.KyyChargeCustomTwo{}).Where("status = 1").Find(&cus).Error
31
+		break
32
+	case 2:
33
+		currentDate := time.Now()
34
+		oneMonthLater := currentDate.AddDate(0, 1, 0)
35
+
36
+		err = ChargeReadDB().Model(&models.KyyChargeCustomTwo{}).Joins("LEFT JOIN kyy_charge_renewal as kr ON kyy_charge_custom.id = kr.custom_id").Where("status = 1 and ((kr.end_time BETWEEN ? AND ?) OR (kr.end_time BETWEEN ? AND ?) OR (kr.end_time IS NULL AND kyy_charge_custom.sign_end_time BETWEEN ? AND ?) OR (kr.end_time IS NULL AND kyy_charge_custom.sign_end_time BETWEEN ? AND ?))", currentDate, oneMonthLater,
37
+			currentDate, oneMonthLater,
38
+			currentDate, oneMonthLater,
39
+			currentDate, oneMonthLater).Find(&cus).Error
40
+
41
+		break
42
+	case 1:
43
+		currentDate := time.Now()
44
+		threeMonthsLater := currentDate.AddDate(0, 3, 0)
45
+		err = ChargeReadDB().Model(&models.KyyChargeCustomTwo{}).Joins("LEFT JOIN kyy_charge_renewal as kr ON kyy_charge_custom.id = kr.custom_id").Where("status = 1 and ((kr.end_time BETWEEN ? AND ?) OR (kr.end_time BETWEEN ? AND ?) OR (kr.end_time IS NULL AND kyy_charge_custom.sign_end_time BETWEEN ? AND ?) OR (kr.end_time IS NULL AND kyy_charge_custom.sign_end_time BETWEEN ? AND ?))", currentDate, threeMonthsLater,
46
+			currentDate, threeMonthsLater,
47
+			currentDate, threeMonthsLater,
48
+			currentDate, threeMonthsLater).Find(&cus).Error
49
+
50
+		break
51
+	case 3:
52
+		currentYear := time.Now().Year()
53
+		err = ChargeReadDB().Model(&models.KyyChargeCustomTwo{}).Joins("JOIN kyy_charge_renewal kcr on kcr.custom_id = kyy_charge_custom.id and YEAR(kcr.start_time) = ?", currentYear).Where("status = 1").Find(&cus).Error
54
+		break
55
+	case 4:
56
+		currentYear := time.Now().Year()
57
+		err = ChargeReadDB().Model(&models.KyyChargeCustomTwo{}).Where("YEAR(sign_time) = ? and is_implement = 0", currentYear).Find(&cus).Error
58
+		break
59
+	case 5:
60
+		currentYear := time.Now().Year()
61
+		err = ChargeReadDB().Model(&models.KyyChargeCustomTwo{}).Where("(YEAR(sign_time) = ? and lis_status = 0) or (YEAR(sign_time) = ? and qc_status = 0) or (YEAR(sign_time) = ? and yb_status = 0)", currentYear, currentYear, currentYear).Find(&cus).Error
62
+		break
63
+	}
64
+
26
 	return
65
 	return
27
 }
66
 }
28
 
67