소스 검색

fix:近期开票内容回显

duxin 6 달 전
부모
커밋
8fef94abec
1개의 변경된 파일29개의 추가작업 그리고 8개의 파일을 삭제
  1. 29 8
      src/jfw/modules/subscribepay/src/service/invoice.go

+ 29 - 8
src/jfw/modules/subscribepay/src/service/invoice.go

@@ -524,9 +524,12 @@ func (this *Invoice) NewInvoiceShow() {
 	stype := this.GetString("stype")
 	code := this.GetString("code")
 	data := make(map[string]interface{})
+	var sData map[string]interface{}
 	switch stype {
 	case "1": //订单回显金额
-		data["pay_money"] = ResidueMoney(code)
+		payMoney, phone := ResidueMoney(code)
+		data["pay_money"] = payMoney
+		sData = ShowData(phone)
 	case "2": //发票信息回显
 		invoice := util.Mysql.FindOne("invoice", map[string]interface{}{"id": encrypt.SE.Decode4Hex(code)}, "id,only_Identifying,order_code,invoice_order_code,invoice_money,remark,invoice_type,invoice_content,invoice_variety,company_name,phone,mail,taxpayer_identnum,invoice_money,invoice_order_money,company_address,bank_name,recipient,delivery_address,bank_account,company_phone", "")
 		if invoice != nil {
@@ -539,7 +542,8 @@ func (this *Invoice) NewInvoiceShow() {
 		data["invoice"] = invoice
 	}
 	this.ServeJson(map[string]interface{}{
-		"data": data,
+		"data":     data,
+		"showData": sData,
 	})
 }
 
@@ -1522,6 +1526,10 @@ func (this *Invoice) InvoiceSubmit() {
 		this.ServeJson(NewResult("", errors.New("发票抬头有误")))
 		return
 	}
+	if len([]rune(this.GetString("company_address"))) > 55 {
+		this.ServeJson(NewResult("", errors.New("单位地址过长")))
+		return
+	}
 	now := time.Now()
 	again, _ := this.GetInteger("again")                                                //是否是失败重新开票 0 首次提交  1 再此提交
 	oldOnlyIdentifying := encrypt.SE.DecodeString(this.GetString("oldOnlyIdentifying")) //最后一次失败的发票信息唯一标识
@@ -1680,7 +1688,8 @@ func AdminOpenInvoice(onlyIdentifying, invoiceMoney, operator string, data map[s
 	}
 	//提交时订单金额再做一次校验
 	for orderCode, money := range orderMap {
-		if ResidueMoney(orderCode) < qutil.Int64All(money) {
+		payMoney, _ := ResidueMoney(orderCode)
+		if payMoney < qutil.Int64All(money) {
 			return errors.New("该订单发票信息已经提交过申请")
 		}
 	}
@@ -1776,16 +1785,19 @@ func (this *Invoice) InvoiceQuery() {
 		orderArr = append(orderArr, invoiceMoneyArr[0])
 		money += qutil.Int64All(invoiceMoneyArr[1])
 	}
+	var sData map[string]interface{}
 	invoiceOne := util.Mysql.FindOne("invoice", map[string]interface{}{
 		"only_Identifying": onlyIdentifying,
 	}, "id,invoice_changed,order_code, invoice_order_code,bank_account,invoice_code, create_time,invoice_number,company_phone,company_name, phone, mail,company_phone, invoice_type, invoice_content, url, invoice_status, invoice_serialnum, taxpayer_identnum,operator, operable_time, invoicing_entity, remark, invoice_variety, logistics_code, company_address, bank_name, recipient, delivery_address,only_Identifying", " create_time   DESC")
 	companyName := ""
 	if invoiceOne == nil {
 		//查询公司名称
-		querySQL := fmt.Sprintf("select company_name  from   dataexport_order  where order_code  in  (%s)   and  company_name!=''   ORDER BY  create_time   DESC LIMIT 1", fmt.Sprintf("\"%s\"", strings.Join(orderArr, "\",\"")))
+		querySQL := fmt.Sprintf("select company_name,user_phone  from   dataexport_order  where order_code  in  (%s)   and  company_name!=''   ORDER BY  create_time   DESC LIMIT 1", fmt.Sprintf("\"%s\"", strings.Join(orderArr, "\",\"")))
 		orderArr := util.Mysql.SelectBySql(querySQL)
 		if orderArr != nil && len(*orderArr) > 0 {
 			companyName = qutil.ObjToString((*orderArr)[0]["company_name"])
+			sData = ShowData(qutil.ObjToString((*orderArr)[0]["user_phone"]))
+			//回显内容
 		}
 	} else {
 		(*invoiceOne)["order_code"] = qutil.If((*invoiceOne)["invoice_order_code"] != nil, (*invoiceOne)["invoice_order_code"], (*invoiceOne)["order_code"])
@@ -1818,10 +1830,19 @@ func (this *Invoice) InvoiceQuery() {
 		"invoice":      &invoiceOne,
 		"operator":     operator,
 		"company_name": companyName,
+		"showData":     sData, //回显近期信息
 		"isFollowWx":   1,
 	}, nil))
 }
 
+func ShowData(phone string) map[string]interface{} {
+	data := util.Mysql.SelectBySql(fmt.Sprintf(`SELECT company_name,phone,mail,invoice_type,company_address,bank_name,bank_account,remark,taxpayer_identnum FROM invoice WHERE phone = '%s' ORDER BY create_time desc LIMIT 1`, phone))
+	if data != nil && len(*data) > 0 {
+		return (*data)[0]
+	}
+	return nil
+}
+
 // GetUserId 获取用户id从订单中
 func GetUserId(orderCode string) (userId string) {
 	rs := util.Mysql.SelectBySql(fmt.Sprintf("select user_id from %s where order_code=?", "dataexport_order"), orderCode)
@@ -1928,14 +1949,14 @@ func InvoicePrice(orderData map[string]interface{}) int64 {
 }
 
 // 订单剩余金额查询
-func ResidueMoney(orderCode string) int64 {
+func ResidueMoney(orderCode string) (int64, string) {
 	residueMoney := int64(0)
 	//订单信息查询
-	orderData := util.Mysql.SelectBySql("select  pay_money,applybill_status from  dataexport_order  where  order_code =?", orderCode)
+	orderData := util.Mysql.SelectBySql("select  pay_money,applybill_status,user_phone from  dataexport_order  where  order_code =?", orderCode)
 	if len(*orderData) == 0 || orderData == nil {
-		return residueMoney
+		return residueMoney, ""
 	}
-	return InvoicePrice((*orderData)[0])
+	return InvoicePrice((*orderData)[0]), qutil.InterfaceToStr((*orderData)[0]["user_phone"])
 
 	//发票信息查询
 	//invoiceData := util.Mysql.SelectBySql("select invoice_status,sum(invoice_order_money) as  money  from  invoice where  order_code=?  and  invoice_status>=0  GROUP BY  invoice_status", orderCode)