|
@@ -307,15 +307,35 @@ func (detail *ContractDetail) getDocxFile(createTime time.Time) (filePath string
|
|
|
"Contract.Amount": strconv.FormatFloat(detail.Amount/100, 'f', -1, 64), //合同金额 {Contract.Amount}
|
|
|
"Contract.Amount.Font": cncap.CapitalizeCurrency(detail.Amount / 100.0), //合同大写金额 {Contract.Amount.Font}
|
|
|
"PartyB.Person": detail.PartyBPerson, //乙方联系人 {PartyB.Person}
|
|
|
- "PartyB.Date.Year": createTime.Year(), //乙方日期-年 {PartyB.Date.Year}
|
|
|
- "PartyB.Date.Month": fmt.Sprintf("%02d", int(createTime.Month())), //乙方日期-月 {PartyB.Date.Month}
|
|
|
- "PartyB.Date.Day": fmt.Sprintf("%02d", createTime.Day()), //乙方日期-日 {PartyB.Date.Day}
|
|
|
+ "PartyB.Date.Y": createTime.Year(), //乙方日期-年 {PartyB.Date.Year}
|
|
|
+ "PartyB.Date.M": fmt.Sprintf("%02d", int(createTime.Month())), //乙方日期-月 {PartyB.Date.Month}
|
|
|
+ "PartyB.Date.D": fmt.Sprintf("%02d", createTime.Day()), //乙方日期-日 {PartyB.Date.Day}
|
|
|
}
|
|
|
if detail.PartyAType == 2 {
|
|
|
replaceMap["PartyA.EndName"] = detail.PartyAName
|
|
|
} else {
|
|
|
replaceMap["PartyA.EndName"] = ""
|
|
|
}
|
|
|
+ numPageEmptyRows := 0
|
|
|
+ longNum := len([]rune(fmt.Sprintf("%s%s%d%s", detail.Service, detail.ServiceTime, detail.AccountNum, detail.Remark)))
|
|
|
+
|
|
|
+ if longNum <= 30 { //备注过短时,公章上移 18+13
|
|
|
+ numPageEmptyRows = 3
|
|
|
+ } else if longNum > 30 && longNum <= 88 {
|
|
|
+ numPageEmptyRows = 2
|
|
|
+ } else if longNum > 88 && longNum <= 146 {
|
|
|
+ numPageEmptyRows = 1
|
|
|
+ }
|
|
|
+ //fmt.Println("xxxxxxxxxx")
|
|
|
+ //fmt.Println("longNum:", longNum, " numPageEmptyRows:", numPageEmptyRows)
|
|
|
+ //fmt.Println("xxxxxxxxxx")
|
|
|
+ //计算第一页空行数,把落款固定到最下部
|
|
|
+
|
|
|
+ //replaceMap["PageEmptyRows"] = strings.Repeat(" ", 126) + "129" +
|
|
|
+ // strings.Repeat(" ", 180) + "183" +
|
|
|
+ // strings.Repeat(" ", 180) + "183"
|
|
|
+ replaceMap["PageEmptyRows"] = strings.Repeat(" ", numPageEmptyRows*180)
|
|
|
+ //计算第一页空行数,把落款固定到最下部
|
|
|
|
|
|
// read and parse the template docx
|
|
|
doc, err := docx.Open(fmt.Sprintf("web/static/contract/%s.docx", detail.ContractTemplate))
|
|
@@ -397,11 +417,8 @@ func (detail *ContractDetail) convertWordToPDF(inputDocxPath string) error {
|
|
|
// 随机盖章位置 生成一个随机整数
|
|
|
if index == 0 { //首页需要盖着日期
|
|
|
x = 680 + rand.Int63n(10)
|
|
|
- y = 200 + rand.Int63n(30)
|
|
|
- if len([]rune(fmt.Sprintf("%s%s%d%s", detail.Service, detail.ServiceTime, detail.AccountNum, detail.Remark))) <= 32 { //备注过短时,公章上移
|
|
|
- y = y + 50
|
|
|
- }
|
|
|
- //if len([]rune(detail.PartyAAddress)) < 22 {
|
|
|
+ y = 130 + rand.Int63n(30)
|
|
|
+ //if len([]rune(fmt.Sprintf("%s%s%d%s", detail.Service, detail.ServiceTime, detail.AccountNum, detail.Remark))) <= 32 { //备注过短时,公章上移
|
|
|
// y = y + 50
|
|
|
//}
|
|
|
} else {
|