Browse Source

Merge branch 'master' into feature/v4.8.88

lianbingjie 1 year ago
parent
commit
df7b9fdb8d
2 changed files with 102 additions and 61 deletions
  1. 41 30
      src/jfw/front/index.go
  2. 61 31
      src/jfw/modules/subscribepay/src/service/invoice.go

+ 41 - 30
src/jfw/front/index.go

@@ -204,14 +204,14 @@ func (nIndex *NewIndex) NewIndex() error {
 		})
 	}
 	//政府采购
-	procure, procureName := GetIndexProjectList(8, 10)
+	procure, procureName := GetIndexProjectListRedis(8, 10)
 	bidTrends = append(bidTrends, map[string]interface{}{
 		"listData": procure,
 		"types":    procureName,
 		"url":      fmt.Sprintf("%s", BiddingTypeUrl[8]),
 	})
 	//项目分包
-	projectPage, typesName := GetIndexProjectList(6, 10)
+	projectPage, typesName := GetIndexProjectListRedis(6, 10)
 	bidTrends = append(bidTrends, map[string]interface{}{
 		"listData": projectPage,
 		"types":    typesName,
@@ -222,7 +222,7 @@ func (nIndex *NewIndex) NewIndex() error {
 	projectZoneType := []int{13, 14, 15, 16}
 	projectZone := []map[string]interface{}{}
 	for _, val := range projectZoneType {
-		listData, types := GetIndexProjectList(val, 10)
+		listData, types := GetIndexProjectListRedis(val, 10)
 		projectZone = append(projectZone, map[string]interface{}{
 			"listData": listData,
 			"types":    types,
@@ -299,7 +299,9 @@ func GetRecommendBidZone(typ int, pageSize int) (list []map[string]interface{},
 		return nil, ""
 	}
 	finalArr := FillingBiddingBaseFields(gctx.New(), queryRes.List(), typs)
-	redis.Put(RedisNameNew, rediskey, finalArr, 24*3600)
+	if finalArr != nil && len(finalArr) > 0 {
+		redis.Put(RedisNameNew, rediskey, finalArr, 24*3600)
+	}
 	return finalArr, typs
 }
 
@@ -347,23 +349,40 @@ func FillingBiddingBaseFields(ctx context.Context, res []map[string]interface{},
 
 // GetStrategyList 招投标攻略
 func GetStrategyList() (strategyList []map[string]interface{}) {
-	if l, ok := redis.Get(RedisNameNew, "pcIndexStrategyList").([]interface{}); ok && l != nil && len(l) > 0 {
+	/*if l, ok := redis.Get(RedisNameNew, "pcIndexStrategyList").([]interface{}); ok && l != nil && len(l) > 0 {
 		strategyList = common.ObjArrToMapArr(l)
-	} else {
-		for _, item := range jySchool.GuidelineColumn().SeedData {
-			if res := jySchool.Guideline(item.Code, 15); res != nil && len(*res) > 0 {
-				strategyList = append(strategyList, map[string]interface{}{
-					"name": item.Name,
-					"code": item.Code,
-					"list": res,
-				})
-			}
+	} else {*/
+	for _, item := range jySchool.GuidelineColumn().SeedData {
+		if res := jySchool.Guideline(item.Code, 15); res != nil && len(*res) > 0 {
+			strategyList = append(strategyList, map[string]interface{}{
+				"name": item.Name,
+				"code": item.Code,
+				"list": res,
+			})
 		}
 	}
+	//}
 	return strategyList
 }
 
-func GetIndexProjectList(typ, pageSize int) (data []map[string]interface{}, types string) {
+func GetIndexProjectList(typ, pageSize int, resArr []map[string]interface{}) (data []map[string]interface{}, types string) {
+	if len(resArr) > 5 {
+		return resArr[:5], types
+	}
+	res, err := g.DB().Query(gctx.New(), fmt.Sprintf(`SELECT bid_id,publish_time,bitmapToArray(sign) FROM new_bid_sign WHERE bitmapContains(sign, %d) ORDER BY publish_time DESC LIMIT %d, %d`, typ, pageSize-10, 10))
+	if err != nil || res.IsEmpty() {
+		return nil, types
+	}
+	finalArr := FillingBiddingBaseFields(gctx.New(), res.List(), types)
+	if len(finalArr) > 5 {
+		finalArr = finalArr[:5]
+	}
+
+	resArr = append(resArr, finalArr...)
+	return GetIndexProjectList(typ, pageSize+10, resArr)
+}
+
+func GetIndexProjectListRedis(typ, pageSize int) (data []map[string]interface{}, types string) {
 	switch typ {
 	case 5:
 		types = "采购意向"
@@ -386,21 +405,11 @@ func GetIndexProjectList(typ, pageSize int) (data []map[string]interface{}, type
 		data = common.ObjArrToMapArr(redisArr)
 		return
 	}
-	res, err := g.DB().Query(gctx.New(), fmt.Sprintf(`SELECT bid_id,publish_time,bitmapToArray(sign) FROM new_bid_sign WHERE bitmapContains(sign, %d) ORDER BY publish_time DESC LIMIT %d`, typ, pageSize))
-	if err != nil || res.IsEmpty() {
-		return nil, types
-	}
-	/*for _, v := range res.List() {
-		v["_id"] = encrypt.EncodeArticleId2ByCheck(common.InterfaceToStr(v["bid_id"]))
-		v["publish_time"] = time.Unix(common.Int64All(v["publish_time"]), 0).Format("2006-01-02")
-		data = append(data, v)
-	}*/
-	finalArr := FillingBiddingBaseFields(gctx.New(), res.List(), types)
-	if len(finalArr) > 5 {
-		finalArr = finalArr[:5]
+	data, _ = GetIndexProjectList(typ, pageSize, []map[string]interface{}{})
+	if data != nil && len(data) > 0 {
+		redis.Put(RedisNameNew, redidKey, data, 24*3600)
 	}
-	redis.Put(RedisNameNew, redidKey, finalArr, 24*3600)
-	return finalArr, types
+	return data, types
 }
 
 // 优秀供应商
@@ -460,6 +469,8 @@ func GetImportBidding() []*hotKeyWord {
 	}
 	randomNumber := rand.Intn(len(subjectMatter) - 30)
 	res := subjectMatter[randomNumber : randomNumber+30]
-	redis.Put(RedisNameNew, "pcIndexImportBidding", res, 24*3600)
+	if len(res) > 0 {
+		redis.Put(RedisNameNew, "pcIndexImportBidding", res, 24*3600)
+	}
 	return res
 }

+ 61 - 31
src/jfw/modules/subscribepay/src/service/invoice.go

@@ -420,13 +420,7 @@ func (this *Invoice) Callbackinvoice() {
 			if changed == "1" {
 				m := make(map[string]interface{})
 				query := make(map[string]interface{})
-				if strings.Contains(order_code, "xx") {
-					//自助开票
-					query["only_Identifying"] = order_code
-				} else {
-					//系统开票
-					query["order_code"] = order_code
-				}
+				query["order_code"] = order_code
 				query["invoice_changed"] = 1
 				m["invoice_code"] = fpdm
 				m["invoice_number"] = fphm
@@ -454,26 +448,6 @@ func (this *Invoice) Callbackinvoice() {
 							}
 							emailHtml := emailHtml_gr
 							emailHtmls := fmt.Sprintf(emailHtml, (*res)["phone"], user_mail)
-							if strings.Contains(order_code, "xx") {
-								//自助开票
-								orderCodeArr := util.Mysql.SelectBySql("select   GROUP_CONCAT(order_code) as  order_code  from   invoice  where  only_Identifying=?", order_code)
-								if len(*orderCodeArr) > 0 {
-									order_code = qutil.ObjToString((*orderCodeArr)[0]["order_code"])
-									for _, v := range strings.Split(order_code, ",") {
-										//订单信息保存
-										updateData := map[string]interface{}{}
-										if InvoiceStatusHandle(v) {
-											updateData["applybill_status"] = 2
-										} else {
-											updateData["applybill_status"] = 3
-										}
-										util.Mysql.Update("dataexport_order", map[string]interface{}{
-											"order_code": v,
-										}, updateData)
-									}
-								}
-
-							}
 							html := fmt.Sprintf(email_format, order_code, "电子普通发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子普通发票", emailHtmls)
 							InvoiceSendMail(user_mail, html, "电子发票")
 						}()
@@ -522,14 +496,28 @@ func (this *Invoice) Callbackinvoice() {
 				}
 			} else {
 				t := make(map[string]interface{})
-				t["order_code"] = order_code
+
+				if strings.Contains(order_code, "xx") {
+					//自助开票
+					t["only_Identifying"] = order_code
+				} else {
+					//系统开票
+					t["order_code"] = order_code
+				}
 				t["invoice_changed"] = 0
 				user_info := util.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": order_code}, "user_nickname,user_mail", "")
 				res := util.Mysql.FindOne(dbname, t, "invoice_type,mail,taxpayer_identnum,company_name,phone,url", "")
 				if res != nil {
 					m := make(map[string]interface{})
 					query := make(map[string]interface{})
-					query["order_code"] = order_code
+					if strings.Contains(order_code, "xx") {
+						//自助开票
+						query["only_Identifying"] = order_code
+					} else {
+						//系统开票
+						query["order_code"] = order_code
+					}
+					query["invoice_changed"] = 0
 					m["invoice_code"] = fpdm
 					m["invoice_number"] = fphm
 					m["url"] = "http://" + path
@@ -554,6 +542,26 @@ func (this *Invoice) Callbackinvoice() {
 								}
 								emailHtml := emailHtml_gr
 								emailHtmls := fmt.Sprintf(emailHtml, (*res)["phone"], user_mail)
+								if strings.Contains(order_code, "xx") {
+									//自助开票
+									orderCodeArr := util.Mysql.SelectBySql("select   GROUP_CONCAT(order_code) as  order_code  from   invoice  where  only_Identifying=?", order_code)
+									if len(*orderCodeArr) > 0 {
+										order_code = qutil.ObjToString((*orderCodeArr)[0]["order_code"])
+										for _, v := range strings.Split(order_code, ",") {
+											//订单信息保存
+											updateData := map[string]interface{}{}
+											if InvoiceStatusHandle(v) {
+												updateData["applybill_status"] = 2
+											} else {
+												updateData["applybill_status"] = 3
+											}
+											util.Mysql.Update("dataexport_order", map[string]interface{}{
+												"order_code": v,
+											}, updateData)
+										}
+									}
+
+								}
 								html := fmt.Sprintf(email_format, order_code, "电子普通发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子普通发票", emailHtmls)
 								InvoiceSendMail(user_mail, html, "电子发票")
 
@@ -574,6 +582,26 @@ func (this *Invoice) Callbackinvoice() {
 							}
 							emailHtml := emailHtml_gs
 							emailHtmls := fmt.Sprintf(emailHtml, (*res)["company_name"], (*res)["taxpayer_identnum"], (*res)["phone"], company_mail)
+							if strings.Contains(order_code, "xx") {
+								//自助开票
+								orderCodeArr := util.Mysql.SelectBySql("select   GROUP_CONCAT(order_code) as  order_code  from   invoice  where  only_Identifying=?", order_code)
+								if len(*orderCodeArr) > 0 {
+									order_code = qutil.ObjToString((*orderCodeArr)[0]["order_code"])
+									for _, v := range strings.Split(order_code, ",") {
+										//订单信息保存
+										updateData := map[string]interface{}{}
+										if InvoiceStatusHandle(v) {
+											updateData["applybill_status"] = 2
+										} else {
+											updateData["applybill_status"] = 3
+										}
+										util.Mysql.Update("dataexport_order", map[string]interface{}{
+											"order_code": v,
+										}, updateData)
+									}
+								}
+
+							}
 							html := fmt.Sprintf(email_format, order_code, "电子普通发票", fmt.Sprintf("<a href=\"%s\" download class=\"download\">下载发票</a>", url), "电子普通发票", emailHtmls)
 							InvoiceSendMail((*res)["mail"].(string), html, "电子发票")
 
@@ -1049,7 +1077,7 @@ func (this *Invoice) InvoiceSubmit() {
 	now := time.Now()
 	onlyIdentifying := encrypt.SE.DecodeString(this.GetString("onlyIdentifying"))
 	invoiceMoney := encrypt.SE.DecodeString(this.GetString("invoiceMoney"))
-	operator := encrypt.SE.DecodeString(this.GetString("operator"))
+	operator := encrypt.SE.Decode4HexByCheck(this.GetString("operator"))
 	if onlyIdentifying == "" || invoiceMoney == "" {
 		this.ServeJson(NewResult("", errors.New("传入参数不正确")))
 		return
@@ -1273,6 +1301,9 @@ func htjs(body map[string]interface{}, orderCode []string, invoiceType, companyN
 			}
 			defer response.Body.Close()
 			resData := (*resMap)["data"].(map[string]interface{})
+			if invoice_status == 1 {
+				sendMail(invoiceType, strings.Join(orderCode, ","), companyName, taxpayerIdentnum, mail, phone, qutil.InterfaceToStr(resData["path"]))
+			}
 			for _, v := range orderCode {
 				util.Mysql.Update(dbname, map[string]interface{}{"order_code": v, "invoice_status": 0}, map[string]interface{}{
 					"invoice_serialnum": resData["swno"],
@@ -1292,7 +1323,6 @@ func htjs(body map[string]interface{}, orderCode []string, invoiceType, companyN
 					"order_code": v,
 				}, updateData)
 			}
-			sendMail(invoiceType, strings.Join(orderCode, ","), companyName, taxpayerIdentnum, mail, phone, qutil.InterfaceToStr(resData["path"]))
 		}
 	}
 }