Просмотр исходного кода

增加接收铁合金协议转让通知生成合同功能

zhou.xiaoning 3 лет назад
Родитель
Сommit
5ec2ca7fcc

+ 1 - 0
.gitignore

@@ -2,3 +2,4 @@ log/
 .tmp/
 __debug_bin.exe
 bin/
+static/~$*

+ 1 - 0
global/funcode.go

@@ -2,4 +2,5 @@ package global
 
 var (
 	THJPurchaseTradeNtf = 1441865 // 铁合金成交通知
+	PurchaseTransferNtf = 1441846 // 铁合金协议转让通知
 )

+ 12 - 1
model/thj.go

@@ -12,8 +12,19 @@ func (t *Wrpresaleinfo) Get() (has bool, err error) {
 	return global.M2A_DB.Where("PRESALEAPPLYID = ?", t.PRESALEAPPLYID).Get(t)
 }
 
-// UpdateContractAddrBuy 更新预售模板合同
+// UpdateContractAddrBuy 更新预售模板合同地址
 func (t *Thjpurchasetradedetail) UpdateContractAddrBuy() (err error) {
 	_, err = global.M2A_DB.Where("WRTRADEDETAILID = ?", t.WRTRADEDETAILID).Cols("CONTRACTADDRBUY").Update(t)
 	return
 }
+
+// Get 协议转让ID获取信息
+func (t *Thjpurchasetransfer) Get() (has bool, err error) {
+	return global.M2A_DB.Where("TRANSFERID = ?", t.TRANSFERID).Get(t)
+}
+
+// UpdateContractAddr 更新协议转让合同地址
+func (t *Thjpurchasetransfer) UpdateContractAddr() (err error) {
+	_, err = global.M2A_DB.Where("TRANSFERID = ?", t.TRANSFERID).Cols("CONTRACTADDR").Update(t)
+	return
+}

+ 84 - 8
res/pb/mtp2.pb.go

@@ -209,6 +209,62 @@ func (x *THJPurchaseTradeNtf) GetWRTradeDetailID() uint64 {
 	return 0
 }
 
+// 铁合金协议转让通知
+type PurchaseTransferNtf struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Header     *MessageHead `protobuf:"bytes,1,opt,name=Header" json:"Header,omitempty"`          // 消息头
+	TransferID *uint64      `protobuf:"varint,2,opt,name=TransferID" json:"TransferID,omitempty"` // uint64 协议转让ID
+}
+
+func (x *PurchaseTransferNtf) Reset() {
+	*x = PurchaseTransferNtf{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_mtp2_proto_msgTypes[2]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *PurchaseTransferNtf) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PurchaseTransferNtf) ProtoMessage() {}
+
+func (x *PurchaseTransferNtf) ProtoReflect() protoreflect.Message {
+	mi := &file_mtp2_proto_msgTypes[2]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use PurchaseTransferNtf.ProtoReflect.Descriptor instead.
+func (*PurchaseTransferNtf) Descriptor() ([]byte, []int) {
+	return file_mtp2_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *PurchaseTransferNtf) GetHeader() *MessageHead {
+	if x != nil {
+		return x.Header
+	}
+	return nil
+}
+
+func (x *PurchaseTransferNtf) GetTransferID() uint64 {
+	if x != nil && x.TransferID != nil {
+		return *x.TransferID
+	}
+	return 0
+}
+
 var File_mtp2_proto protoreflect.FileDescriptor
 
 var file_mtp2_proto_rawDesc = []byte{
@@ -240,7 +296,13 @@ var file_mtp2_proto_rawDesc = []byte{
 	0x61, 0x64, 0x52, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x0f, 0x57, 0x52,
 	0x54, 0x72, 0x61, 0x64, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x49, 0x44, 0x18, 0x02, 0x20,
 	0x01, 0x28, 0x04, 0x52, 0x0f, 0x57, 0x52, 0x54, 0x72, 0x61, 0x64, 0x65, 0x44, 0x65, 0x74, 0x61,
-	0x69, 0x6c, 0x49, 0x44,
+	0x69, 0x6c, 0x49, 0x44, 0x22, 0x5e, 0x0a, 0x13, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65,
+	0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x4e, 0x74, 0x66, 0x12, 0x27, 0x0a, 0x06, 0x48,
+	0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62,
+	0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x65, 0x61, 0x64, 0x52, 0x06, 0x48, 0x65,
+	0x61, 0x64, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72,
+	0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66,
+	0x65, 0x72, 0x49, 0x44,
 }
 
 var (
@@ -255,18 +317,20 @@ func file_mtp2_proto_rawDescGZIP() []byte {
 	return file_mtp2_proto_rawDescData
 }
 
-var file_mtp2_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_mtp2_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
 var file_mtp2_proto_goTypes = []interface{}{
 	(*MessageHead)(nil),         // 0: pb.MessageHead
 	(*THJPurchaseTradeNtf)(nil), // 1: pb.THJPurchaseTradeNtf
+	(*PurchaseTransferNtf)(nil), // 2: pb.PurchaseTransferNtf
 }
 var file_mtp2_proto_depIdxs = []int32{
 	0, // 0: pb.THJPurchaseTradeNtf.Header:type_name -> pb.MessageHead
-	1, // [1:1] is the sub-list for method output_type
-	1, // [1:1] is the sub-list for method input_type
-	1, // [1:1] is the sub-list for extension type_name
-	1, // [1:1] is the sub-list for extension extendee
-	0, // [0:1] is the sub-list for field type_name
+	0, // 1: pb.PurchaseTransferNtf.Header:type_name -> pb.MessageHead
+	2, // [2:2] is the sub-list for method output_type
+	2, // [2:2] is the sub-list for method input_type
+	2, // [2:2] is the sub-list for extension type_name
+	2, // [2:2] is the sub-list for extension extendee
+	0, // [0:2] is the sub-list for field type_name
 }
 
 func init() { file_mtp2_proto_init() }
@@ -299,6 +363,18 @@ func file_mtp2_proto_init() {
 				return nil
 			}
 		}
+		file_mtp2_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*PurchaseTransferNtf); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -306,7 +382,7 @@ func file_mtp2_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_mtp2_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   2,
+			NumMessages:   3,
 			NumExtensions: 0,
 			NumServices:   0,
 		},

+ 6 - 0
res/pb/mtp2.proto

@@ -21,4 +21,10 @@ message MessageHead {
 message THJPurchaseTradeNtf {
 	optional MessageHead Header = 1; // 消息头
 		optional uint64 WRTradeDetailID = 2; // uint64 预售成交明细ID
+}
+
+// 铁合金协议转让通知
+message PurchaseTransferNtf {
+	optional MessageHead Header = 1; // 消息头
+		optional uint64 TransferID = 2; // uint64 协议转让ID
 }

+ 225 - 11
service/thjNtf.go

@@ -33,6 +33,9 @@ func (t *THJNtf) Process(msg *[]byte) {
 		// 等待两秒
 		<-time.After(2 * time.Second)
 		onTHJPurchaseTradeNtf(&bytes)
+	case uint32(global.THJPurchaseTradeNtf):
+		<-time.After(2 * time.Second)
+		onTHJPurchaseTransferNtf(&bytes)
 	}
 }
 
@@ -54,7 +57,7 @@ func onTHJPurchaseTradeNtf(bytes *[]byte) {
 	// 铁合金采购成交扩展信息
 	thjpurchasetradedetail := model.Thjpurchasetradedetail{WRTRADEDETAILID: int64(p.GetWRTradeDetailID())}
 	if has, err := thjpurchasetradedetail.Get(); err != nil || !has {
-		global.M2A_LOG.Error("[onTHJPurchaseTradeNtf] 获取铁合金采购成交扩展信息失败", zap.Error(err))
+		global.M2A_LOG.Error("[铁合金成交通知] 获取铁合金采购成交扩展信息失败", zap.Error(err))
 		return
 	}
 	// 交割方式
@@ -66,27 +69,27 @@ func onTHJPurchaseTradeNtf(bytes *[]byte) {
 	// 现货商品信息
 	wrstandard := model.Wrstandard{WRSTANDARDID: int64(thjpurchasetradedetail.WRSTANDARDID)}
 	if has, err := wrstandard.Get(); err != nil || !has {
-		global.M2A_LOG.Error("[onTHJPurchaseTradeNtf] 获取现货商品信息失败", zap.Error(err))
+		global.M2A_LOG.Error("[铁合金成交通知] 获取现货商品信息失败", zap.Error(err))
 		return
 	}
 
 	// 仓单预售信息
 	wrpresaleinfo := model.Wrpresaleinfo{PRESALEAPPLYID: thjpurchasetradedetail.PRESALEAPPLYID}
 	if has, err := wrpresaleinfo.Get(); err != nil || !has {
-		global.M2A_LOG.Error("[onTHJPurchaseTradeNtf] 获取仓单预售信息失败", zap.Error(err))
+		global.M2A_LOG.Error("[铁合金成交通知] 获取仓单预售信息失败", zap.Error(err))
 		return
 	}
 
 	// 甲方信息
 	userinfo := model.Userinfo{USERID: thjpurchasetradedetail.BUYUSERID}
 	if has, err := userinfo.Get(); err != nil || !has {
-		global.M2A_LOG.Error("[onTHJPurchaseTradeNtf] 获取甲方信息失败", zap.Error(err))
+		global.M2A_LOG.Error("[铁合金成交通知] 获取甲方信息失败", zap.Error(err))
 		return
 	}
 	division := model.Division{AUTOID: int64(userinfo.DISTRICTID)}
 	totalAddress, err := division.GetTotalAddressByDistrictID(userinfo.ADDRESS)
 	if err != nil {
-		global.M2A_LOG.Error("[onTHJPurchaseTradeNtf] 获取甲方地址信息失败", zap.Error(err))
+		global.M2A_LOG.Error("[铁合金成交通知] 获取甲方地址信息失败", zap.Error(err))
 		return
 	}
 	// 证件号码解密
@@ -110,7 +113,7 @@ func onTHJPurchaseTradeNtf(bytes *[]byte) {
 	// 甲方签约信息
 	bankaccountsign := model.Bankaccountsign{}
 	if has, err := bankaccountsign.GetByUserID(uint64(thjpurchasetradedetail.BUYUSERID)); err != nil || !has {
-		global.M2A_LOG.Error("[onTHJPurchaseTradeNtf] 获取甲方签约信息失败", zap.Error(err))
+		global.M2A_LOG.Error("[铁合金成交通知] 获取甲方签约信息失败", zap.Error(err))
 		return
 	}
 	// 账号解密
@@ -125,14 +128,14 @@ func onTHJPurchaseTradeNtf(bytes *[]byte) {
 	// 银行信息
 	bankinfo := model.Bankbankinfo{BANKID: bankaccountsign.BANKID}
 	if has, err := bankinfo.Get(); err != nil || !has {
-		global.M2A_LOG.Error("[onTHJPurchaseTradeNtf] 获取银行信息失败", zap.Error(err))
+		global.M2A_LOG.Error("[铁合金成交通知] 获取银行信息失败", zap.Error(err))
 		return
 	}
 
 	// 生产厂家信息
 	selluserinfo := model.Userinfo{USERID: thjpurchasetradedetail.SELLUSERID}
 	if has, err := selluserinfo.Get(); err != nil || !has {
-		global.M2A_LOG.Error("[onTHJPurchaseTradeNtf] 获取生产厂家信息失败", zap.Error(err))
+		global.M2A_LOG.Error("[铁合金成交通知] 获取生产厂家信息失败", zap.Error(err))
 		return
 	}
 
@@ -185,7 +188,7 @@ func onTHJPurchaseTradeNtf(bytes *[]byte) {
 	success := utils.ConvertToPDF("./.tmp/"+docxFilename, savePath)
 	if !success {
 		// 转换失败
-		global.M2A_LOG.Error("[onTHJPurchaseTradeNtf] docx转换pdf失败", zap.Error(err))
+		global.M2A_LOG.Error("[铁合金成交通知] docx转换pdf失败", zap.Error(err))
 		return
 	}
 
@@ -193,8 +196,219 @@ func onTHJPurchaseTradeNtf(bytes *[]byte) {
 	// pdfFilename = docxFilename // 临时代码
 	thjpurchasetradedetail.CONTRACTADDRBUY = fmt.Sprintf("./uploadFile/%v/%v", folderPath, pdfFilename)
 	if err = thjpurchasetradedetail.UpdateContractAddrBuy(); err != nil {
-		global.M2A_LOG.Error("[onTHJPurchaseTradeNtf] 更新数据库失败", zap.Error(err))
+		global.M2A_LOG.Error("[铁合金成交通知] 更新数据库失败", zap.Error(err))
+		return
+	}
+	global.M2A_LOG.Info("[铁合金成交通知] 合同生成成功", zap.Any("file", savePath+pdfFilename))
+}
+
+// onTHJPurchaseTransferNtf 铁合金协议转让通知
+func onTHJPurchaseTransferNtf(bytes *[]byte) {
+	// Read from docx file
+	r, err := docx.ReadDocxFile("./static/协议转让合同.docx")
+	if err != nil {
+		global.M2A_LOG.Error("读取合同文件失败", zap.Error(err))
+		return
+	}
+
+	var p pb.PurchaseTransferNtf
+	if err := proto.Unmarshal(*bytes, &p); err != nil {
+		global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
+		return
+	}
+
+	// 铁合金采购协议表
+	thjpurchasetransfer := model.Thjpurchasetransfer{TRANSFERID: int64(p.GetTransferID())}
+	if has, err := thjpurchasetransfer.Get(); err != nil || !has {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取铁合金采购成交扩展信息失败", zap.Error(err))
+		return
+	}
+
+	// 铁合金采购成交扩展信息
+	thjpurchasetradedetail := model.Thjpurchasetradedetail{WRTRADEDETAILID: thjpurchasetransfer.WRTRADEDETAILID}
+	if has, err := thjpurchasetradedetail.Get(); err != nil || !has {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取铁合金采购成交扩展信息失败", zap.Error(err))
+		return
+	}
+
+	// 现货商品信息
+	wrstandard := model.Wrstandard{WRSTANDARDID: int64(thjpurchasetradedetail.WRSTANDARDID)}
+	if has, err := wrstandard.Get(); err != nil || !has {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取现货商品信息失败", zap.Error(err))
+		return
+	}
+
+	// ******************* 甲方信息(卖方)*******************
+	a_userinfo := model.Userinfo{USERID: thjpurchasetransfer.SELLUSERID}
+	if has, err := a_userinfo.Get(); err != nil || !has {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取甲方信息失败", zap.Error(err))
+		return
+	}
+	a_division := model.Division{AUTOID: int64(a_userinfo.DISTRICTID)}
+	a_totalAddress, err := a_division.GetTotalAddressByDistrictID(a_userinfo.ADDRESS)
+	if err != nil {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取甲方地址信息失败", zap.Error(err))
+		return
+	}
+	// 证件号码解密
+	key, _ := hex.DecodeString(utils.AESSecretKey)
+	if len(a_userinfo.CARDNUM) > 0 {
+		if cardnum, err := hex.DecodeString(a_userinfo.CARDNUM); err == nil { // hex -> []byte
+			if c, err := utils.AESDecrypt(cardnum, key); err == nil {
+				a_userinfo.CARDNUM = string(c)
+			}
+		}
+	}
+	// 手机号码解密
+	if len(a_userinfo.MOBILE) > 0 {
+		if phonenum, err := hex.DecodeString(a_userinfo.MOBILE); err == nil { // hex -> []byte
+			if mobile, err := utils.AESDecrypt(phonenum, key); err == nil {
+				a_userinfo.MOBILE = string(mobile)
+			}
+		}
+	}
+	// 签约信息
+	a_bankaccountsign := model.Bankaccountsign{}
+	if has, err := a_bankaccountsign.GetByUserID(uint64(thjpurchasetradedetail.BUYUSERID)); err != nil || !has {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取甲方签约信息失败", zap.Error(err))
+		return
+	}
+	// 账号解密
+	if len(a_bankaccountsign.BANKACCOUNTNO) > 0 {
+		if tt, err := hex.DecodeString(a_bankaccountsign.BANKACCOUNTNO); err == nil { // hex -> []byte
+			if dd, err := utils.AESDecrypt(tt, key); err == nil {
+				a_bankaccountsign.BANKACCOUNTNO = string(dd)
+			}
+		}
+	}
+	// 银行信息
+	a_bankinfo := model.Bankbankinfo{BANKID: a_bankaccountsign.BANKID}
+	if has, err := a_bankinfo.Get(); err != nil || !has {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取银行信息失败", zap.Error(err))
+		return
+	}
+
+	// ******************* 乙方信息(买方)*******************
+	b_userinfo := model.Userinfo{USERID: thjpurchasetransfer.SELLUSERID}
+	if has, err := b_userinfo.Get(); err != nil || !has {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取甲方信息失败", zap.Error(err))
+		return
+	}
+	b_division := model.Division{AUTOID: int64(b_userinfo.DISTRICTID)}
+	b_totalAddress, err := b_division.GetTotalAddressByDistrictID(b_userinfo.ADDRESS)
+	if err != nil {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取甲方地址信息失败", zap.Error(err))
+		return
+	}
+	// 证件号码解密
+	if len(b_userinfo.CARDNUM) > 0 {
+		if cardnum, err := hex.DecodeString(b_userinfo.CARDNUM); err == nil { // hex -> []byte
+			if c, err := utils.AESDecrypt(cardnum, key); err == nil {
+				b_userinfo.CARDNUM = string(c)
+			}
+		}
+	}
+	// 手机号码解密
+	if len(b_userinfo.MOBILE) > 0 {
+		if phonenum, err := hex.DecodeString(b_userinfo.MOBILE); err == nil { // hex -> []byte
+			if mobile, err := utils.AESDecrypt(phonenum, key); err == nil {
+				b_userinfo.MOBILE = string(mobile)
+			}
+		}
+	}
+	// 签约信息
+	b_bankaccountsign := model.Bankaccountsign{}
+	if has, err := b_bankaccountsign.GetByUserID(uint64(thjpurchasetradedetail.BUYUSERID)); err != nil || !has {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取甲方签约信息失败", zap.Error(err))
+		return
+	}
+	// 账号解密
+	if len(b_bankaccountsign.BANKACCOUNTNO) > 0 {
+		if tt, err := hex.DecodeString(b_bankaccountsign.BANKACCOUNTNO); err == nil { // hex -> []byte
+			if dd, err := utils.AESDecrypt(tt, key); err == nil {
+				b_bankaccountsign.BANKACCOUNTNO = string(dd)
+			}
+		}
+	}
+	// 银行信息
+	b_bankinfo := model.Bankbankinfo{BANKID: a_bankaccountsign.BANKID}
+	if has, err := b_bankinfo.Get(); err != nil || !has {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 获取银行信息失败", zap.Error(err))
+		return
+	}
+
+	docx1 := r.Editable()
+	docx1.Replace("TRANSFERID", strconv.Itoa(int(thjpurchasetransfer.TRANSFERID)), -1)
+	if transfertradedate, e := time.Parse("20060102", thjpurchasetransfer.TRANSFERTRADEDATE); e != nil {
+		docx1.Replace("TRANSFERTRADEDATE", transfertradedate.Format("2006年01月02日"), -1)
+	}
+	docx1.Replace("WRSTANDARDNAME", wrstandard.WRSTANDARDNAME, -1)
+	docx1.Replace("WRTRADEDETAILID", strconv.Itoa(int(thjpurchasetradedetail.WRTRADEDETAILID)), -1)
+	docx1.Replace("TRANSFERQTY", strconv.Itoa(int(thjpurchasetransfer.TRANSFERQTY)), -1)
+	docx1.Replace("TRADEAMOUNT", strconv.FormatFloat(thjpurchasetradedetail.TRADEAMOUNT, 'f', -1, 64), -1)
+	docx1.Replace("TRANSFERAMOUNT", strconv.FormatFloat(thjpurchasetransfer.TRANSFERAMOUNT, 'f', -1, 64), -1)
+	docx1.Replace("TRANSFERPRICE", strconv.FormatFloat(thjpurchasetransfer.TRANSFERPRICE, 'f', -1, 64), -1)
+	// ********************* 甲方 *********************
+	// 判断甲方是公司还是个人
+	if a_userinfo.USERINFOTYPE == 1 {
+		// 个人
+		docx1.Replace("PARTYA_COMPANY", "", -1)
+		docx1.Replace("PARTYA_LEGALPERSONNAME", a_userinfo.CUSTOMERNAME, -1)
+	} else {
+		// 公司
+		docx1.Replace("PARTYA_COMPANY", a_userinfo.CUSTOMERNAME, -1)
+		docx1.Replace("PARTYA_LEGALPERSONNAME", a_userinfo.LEGALPERSONNAME, -1)
+	}
+	docx1.Replace("PARTYA_DESADDRESS", a_totalAddress, -1)
+	docx1.Replace("PARTYA_CARDNUM", a_userinfo.CARDNUM, -1)
+	docx1.Replace("PARTYA_MOBILE", a_userinfo.MOBILE, -1)
+	docx1.Replace("PARTYA_BANK_BANKACCOUNTNO",
+		fmt.Sprintf("%v%v", a_bankinfo.BANKNAME, a_bankaccountsign.BANKACCOUNTNO), -1)
+	// ********************* 乙方 *********************
+	// 判断乙方是公司还是个人
+	if b_userinfo.USERINFOTYPE == 1 {
+		// 个人
+		docx1.Replace("PARTYB_COMPANY", "", -1)
+		docx1.Replace("PARTYB_LEGALPERSONNAME", b_userinfo.CUSTOMERNAME, -1)
+	} else {
+		// 公司
+		docx1.Replace("PARTYB_COMPANY", b_userinfo.CUSTOMERNAME, -1)
+		docx1.Replace("PARTYB_LEGALPERSONNAME", b_userinfo.LEGALPERSONNAME, -1)
+	}
+	docx1.Replace("PARTYB_DESADDRESS", b_totalAddress, -1)
+	docx1.Replace("PARTYB_CARDNUM", b_userinfo.CARDNUM, -1)
+	docx1.Replace("PARTYB_MOBILE", b_userinfo.MOBILE, -1)
+	docx1.Replace("PARTYB_BANK_BANKACCOUNTNO",
+		fmt.Sprintf("%v%v", b_bankinfo.BANKNAME, b_bankaccountsign.BANKACCOUNTNO), -1)
+
+	// 暂存docx文件
+	if exist, _ := utils.PathExists("./.tmp"); !exist {
+		os.Mkdir("./.tmp", os.ModePerm)
+	}
+	uid, _ := uuid.NewV4()
+	docxFilename := fmt.Sprintf("%v_%v.docx", strconv.Itoa(int(thjpurchasetransfer.TRANSFERID)), uid.String())
+	pdfFilename := strings.Replace(docxFilename, "docx", "pdf", -1)
+	docx1.WriteToFile("./.tmp/" + docxFilename)
+	r.Close()
+
+	// 导出pdf到目标目录
+	folderPath := "Agreement_Assignment/" + time.Now().Format("20060102")
+	savePath := global.M2A_CONFIG.System.StorePath + "/" + folderPath
+	if exist, _ := utils.PathExists(savePath); !exist {
+		os.MkdirAll(savePath, os.ModePerm)
+	}
+	success := utils.ConvertToPDF("./.tmp/"+docxFilename, savePath)
+	if !success {
+		// 转换失败
+		global.M2A_LOG.Error("[铁合金协议转让通知] docx转换pdf失败", zap.Error(err))
+		return
+	}
+
+	// 更新数据库
+	thjpurchasetransfer.CONTRACTADDR = fmt.Sprintf("./uploadFile/%v/%v", folderPath, pdfFilename)
+	if err = thjpurchasetransfer.UpdateContractAddr(); err != nil {
+		global.M2A_LOG.Error("[铁合金协议转让通知] 更新数据库失败", zap.Error(err))
 		return
 	}
-	global.M2A_LOG.Info("[onTHJPurchaseTradeNtf] 合同生成成功", zap.Any("file", savePath+pdfFilename))
+	global.M2A_LOG.Info("[铁合金协议转让通知] 合同生成成功", zap.Any("file", savePath+pdfFilename))
 }

BIN
static/协议转让合同.docx


BIN
static/协议转让电子合同模板.docx


BIN
static/现货贸易合同(买家模板).doc


BIN
static/现货贸易合同(卖家模板).doc


BIN
static/现货预售合同.doc


BIN
static/现货预售合同.docx