|
@@ -355,3 +355,44 @@ func GetLastYear() string {
|
|
|
func WaitElementX5(page *rod.Page, xpath string) *rod.Element {
|
|
|
return WaitElementXFoTimes(page, xpath, 5)
|
|
|
}
|
|
|
+
|
|
|
+// 获取上一年的最后一天
|
|
|
+func GetLastYearLastDate() string {
|
|
|
+ now := time.Now()
|
|
|
+ lastYear := now.AddDate(-1, 0, 0)
|
|
|
+ lastDayOfLastYear := time.Date(lastYear.Year(), 12, 31, 0, 0, 0, 0, time.Local)
|
|
|
+ return lastDayOfLastYear.Format(`2006-01-02`)
|
|
|
+}
|
|
|
+
|
|
|
+// 获取本账期开始和结束日期
|
|
|
+func GetQuarterStartTimeAndEndTime(period string) (string, string) {
|
|
|
+ quarterStart := ""
|
|
|
+ quarterEnd := ""
|
|
|
+ quarter := math.Ceil(StrToFloat(period[4:6])/3) - 1
|
|
|
+ if quarter == 0 { //第一季度
|
|
|
+ quarterStart = period[0:4] + "-01-01"
|
|
|
+ quarterEnd = period[0:4] + "-03-31"
|
|
|
+ }
|
|
|
+ if quarter == 1 { //第二季度
|
|
|
+ quarterStart = period[0:4] + "-04-01"
|
|
|
+ quarterEnd = period[0:4] + "-06-30"
|
|
|
+ }
|
|
|
+ if quarter == 2 { //第三季度
|
|
|
+ quarterStart = period[0:4] + "-07-01"
|
|
|
+ quarterEnd = period[0:4] + "-09-30"
|
|
|
+ }
|
|
|
+ if quarter == 3 { //第四季度
|
|
|
+ quarterStart = period[0:4] + "-10-01"
|
|
|
+ quarterEnd = period[0:4] + "-12-31"
|
|
|
+ }
|
|
|
+ return quarterStart, quarterEnd
|
|
|
+}
|
|
|
+
|
|
|
+func GetCurrentPeriod3() string { //仅本期报税使用
|
|
|
+ tm := time.Unix(time.Now().Unix(), 0)
|
|
|
+ currentYear, currentMonth, _ := tm.Date()
|
|
|
+ currentLocation := tm.Location()
|
|
|
+ firstOfMonth := time.Date(currentYear, currentMonth, 10, 0, 0, 0, 0, currentLocation)
|
|
|
+ period := firstOfMonth.AddDate(0, -1, 0).Format("2006-01") // 当前账期-1
|
|
|
+ return period
|
|
|
+}
|