|
@@ -1,6 +1,9 @@
|
1
|
1
|
package service
|
2
|
2
|
|
3
|
|
-import "XT_Admin_Api/models"
|
|
3
|
+import (
|
|
4
|
+ "XT_Admin_Api/models"
|
|
5
|
+ "time"
|
|
6
|
+)
|
4
|
7
|
|
5
|
8
|
func FindCustomInfo(org_id int64) (admin models.KyyChargeCustom, err error) {
|
6
|
9
|
err = ChargeReadDB().Model(&models.KyyChargeCustom{}).Where("xt_org_id = ? AND status = 1", org_id).First(&admin).Error
|
|
@@ -21,8 +24,44 @@ func SaveCustomTwo(admin models.KyyChargeCustomThree) (err error) {
|
21
|
24
|
err = ChargeWriteDB().Model(&models.KyyChargeCustomThree{}).Save(&admin).Error
|
22
|
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
|
65
|
return
|
27
|
66
|
}
|
28
|
67
|
|