zhangchuanxing 2 週間 前
コミット
5b89715378

+ 21 - 0
controllers/statistic/rai_data_summary.go

@@ -1134,6 +1134,27 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 		}
 
 	case "未到款比例":
+		if sellerId > 0 {
+			condition += ` AND a.rai_seller_id = ? `
+			pars = append(pars, sellerId)
+		}
+		condition += " AND  a.is_deleted = 0   AND  a.start_date >= ?  AND  a.start_date <= ?    AND product_ids LIKE '%2%' "
+		pars = append(pars, startDate, endDate)
+		listFmsData, err := fms.GetContractRegisterAmountList(condition, pars)
+		if err != nil {
+			br.Msg = "获取数据信息失败"
+			br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
+			return
+		}
+
+		for _, v := range listFmsData {
+			item := new(statistic_report.RaiDataSummaryDetailResp)
+			item.InvoicedAmount = v.InvoicedAmount
+			item.PaymentAmount = v.PaymentAmount
+			item.NotReceivedtAmount = v.InvoicedAmount - v.PaymentAmount
+			item.CreateTime = v.CreateTime.Format(utils.FormatDate)
+			listResp = append(listResp, item)
+		}
 
 	case "新客开票":
 		if sellerId > 0 {

+ 13 - 0
models/fms/invoice_payment_summary.go

@@ -184,3 +184,16 @@ func GetContractRegisterList(condition string, pars []interface{}, startSize, pa
 
 	return
 }
+
+// 获取开票金额与未到账金额的统计
+func GetContractRegisterAmountList(condition string, pars []interface{}) (items []*ContractRegisterSummary, err error) {
+	o := orm.NewOrmUsingDB("fms")
+	sql := `SELECT
+			SUM( invoiced_amount ) AS invoiced_amount,
+			SUM( payment_amount ) AS payment_amount FROM contract_register  as a  WHERE 1= 1  `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 1 - 0
models/statistic_report/rai_data_summary.go

@@ -146,4 +146,5 @@ type RaiDataSummaryDetailResp struct {
 	ContractCode           string  `description:"合同编号"`
 	InvoicedAmount         float64 ` description:"开票金额"`
 	PaymentAmount          float64 ` description:"到款金额"`
+	NotReceivedtAmount     float64 ` description:"未到账金额"`
 }