Bladeren bron

fix:开票校验修改

duxin 1 jaar geleden
bovenliggende
commit
21adf049d3

+ 18 - 14
src/jfw/front/dataExport.go

@@ -346,14 +346,17 @@ func (d *DataExport) CancelOrder() error {
 	return nil
 }
 
-// 查询订单最后开票状态
-func QmxInvoice(res map[string]interface{}) bool {
-	if res["is_backstage_order"] == 1 && res["order_channel"] != "xdqd04" {
-		if res["return_status"] == 1 && public.Mysql.Count("invoice", map[string]interface{}{
+// 是否可开票
+func IsAllowInvoice(res map[string]interface{}) bool {
+	filter := util.ObjToString(res["filter"].(string))
+	filter_map := map[string]interface{}{}
+	_ = json.Unmarshal([]byte(filter), &filter_map)
+	if res["order_status"] == 1 && filter_map["badge"] != "exchange" && res["applybill_status"] == 1 &&
+		//用户下单|| 代用户下单|| qmx下单 已全额回款 发票企业为剑鱼
+		(res["is_backstage_order"] == 0 || res["order_channel"] == "xdqd04" || (res["return_status"] == 1 && public.Mysql.Count("invoice", map[string]interface{}{
 			"order_code": res["order_code"],
-		}) == 0 && res["signing_subject"] == "北京剑鱼信息技术有限公司" {
-			return true
-		}
+		}) == 0 && res["signing_subject"] == "北京剑鱼信息技术有限公司")) {
+		return true
 	}
 	return false
 }
@@ -420,14 +423,15 @@ func (d *DataExport) ToOrderDetail(orderCode string) error {
 		orderDetail = *public.Mysql.FindOne(tableName_order, queryMap, "", "")
 		//最后一次开票查询
 		//orderDetail["source"] = LastInvoiceSource(orderCode)
-		//如果是管理后台的单子 是否满足可开票
-		orderDetail["qmx_invoice"] = QmxInvoice(orderDetail)
-		//剩余可开票金额
-		var invoicePrice bool
-		if util.Int64All(orderDetail["create_time"]) > 1704038400 {
-			invoicePrice = InvoicePrice(orderDetail) > 0
+		//是否满足可开票
+		var isCanInvoic bool
+		create_time_str := util.ObjToString(orderDetail["create_time"])
+		create_time, _ := time.ParseInLocation(Date_Full_Layout, create_time_str, time.Local)
+		if create_time.Unix() > 1704038400 {
+			//剩余可开票金额
+			isCanInvoic = IsAllowInvoice(orderDetail) && InvoicePrice(orderDetail) > 0
 		}
-		orderDetail["invoice_price"] = invoicePrice
+		orderDetail["is_can_invoice"] = isCanInvoic
 		//是否存在可查看发票
 		orderDetail["invoice_show"] = len(ShowList(util.InterfaceToStr(orderDetail["order_code"]))) > 0
 	}

+ 10 - 7
src/jfw/modules/subscribepay/src/service/invoice.go

@@ -1373,14 +1373,17 @@ func LastInvoiceSource(orderCode string) int64 {
 	return 0
 }
 
-// 查询订单最后开票状态
-func QmxInvoice(res map[string]interface{}) bool {
-	if res["is_backstage_order"] == 1 && res["order_channel"] != "xdqd04" {
-		if res["return_status"] == 1 && util.Mysql.Count("invoice", map[string]interface{}{
+// 是否可开票
+func IsAllowInvoice(res map[string]interface{}) bool {
+	filter := qutil.ObjToString(res["filter"].(string))
+	filter_map := map[string]interface{}{}
+	_ = json.Unmarshal([]byte(filter), &filter_map)
+	if res["order_status"] == 1 && filter_map["badge"] != "exchange" && res["applybill_status"] == 1 &&
+		//用户下单|| 代用户下单|| qmx下单 已全额回款 发票企业为剑鱼
+		(res["is_backstage_order"] == 0 || res["order_channel"] == "xdqd04" || (res["return_status"] == 1 && util.Mysql.Count("invoice", map[string]interface{}{
 			"order_code": res["order_code"],
-		}) == 0 && res["signing_subject"] == config.InvoiceConfig.SigningSubject {
-			return true
-		}
+		}) == 0 && res["signing_subject"] == config.InvoiceConfig.SigningSubject)) {
+		return true
 	}
 	return false
 }

+ 10 - 12
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -663,14 +663,13 @@ func (o *OrderListDetails) Datas(sql string, pageNum, pagesize_max int) (haveNex
 			}
 			//新增最后开票
 			//result[i]["source"] = LastInvoiceSource(qutil.InterfaceToStr(result[i]["order_code"])) p537 用户可查看所有发票
-			//如果是管理后台的单子 是否满足可开票
-			result[i]["qmx_invoice"] = QmxInvoice(result[i])
-			//剩余可开票金额
-			var invoicePrice bool
+			//是否满足可开票
+			var isCanInvoic bool
 			if create_time.Unix() > config.InvoiceConfig.Order_createtime {
-				invoicePrice = InvoicePrice(result[i]) > 0
+				//剩余可开票金额
+				isCanInvoic = IsAllowInvoice(result[i]) && InvoicePrice(result[i]) > 0
 			}
-			result[i]["invoice_price"] = invoicePrice
+			result[i]["is_can_invoice"] = isCanInvoic
 			//是否存在可查看发票
 			result[i]["invoice_show"] = len(ShowList(qutil.InterfaceToStr(result[i]["order_code"]))) > 0
 		}
@@ -875,14 +874,13 @@ func CommonDetail(bigm int, fields, userId, order_code string, session *httpsess
 					data["isNewOrder"] = qutil.If(t.Unix() >= config.Config.NewOrderTime, true, false)
 				}
 				//data["source"] = LastInvoiceSource(qutil.InterfaceToStr(data["order_code"]))
-				//如果是管理后台的单子 是否满足可开票
-				data["qmx_invoice"] = QmxInvoice(data)
-				//剩余可开票金额
-				var invoicePrice bool
+				//是否满足可开票
+				var isCanInvoic bool
 				if t.Unix() > config.InvoiceConfig.Order_createtime {
-					invoicePrice = InvoicePrice(data) > 0
+					//剩余可开票金额
+					isCanInvoic = IsAllowInvoice(data) && InvoicePrice(data) > 0
 				}
-				data["invoice_price"] = invoicePrice
+				data["is_can_invoice"] = isCanInvoic
 				//是否存在可查看发票
 				data["invoice_show"] = len(ShowList(qutil.InterfaceToStr(data["order_code"]))) > 0
 				if bigm == 0 || bigm == 4 {