فهرست منبع

fix: 修改统计 id 、添加创建合同数据验证

liuyaqi 2 سال پیش
والد
کامیت
19dcb7623f

+ 8 - 0
opms_parent/app/service/contract/ctr_contract.go

@@ -328,6 +328,14 @@ func (s CtrContractService) Add(ctx context.Context, req *model.CtrContractAddRe
 	if validErr != nil {
 		return 0, myerrors.TipsError(validErr.Current().Error())
 	}
+	if len(req.Product) == 0 {
+		return 0, myerrors.TipsError("产品不能为空")
+	}
+	for _, p := range req.Product {
+		if p.ProdNum < 1 {
+			return 0, myerrors.TipsError("产品数量必须大于 0")
+		}
+	}
 
 	c, err := s.Dao.Where("contract_name = ?", req.ContractName).One()
 	if err != nil {

+ 2 - 2
opms_parent/app/service/home/home.go

@@ -106,10 +106,10 @@ func (s *HomeService) getReportData(id int64, params *map[string]interface{}) (i
 	case 20003:
 		// 报表数据   总部销售回款
 		return getCompanyContractReportData(s.ContextService.Ctx, "COLLECTION", params)
-	case 20004:
+	case 20006:
 		// 报表数据   季度销售指标
 		return getQuarterGoalReportData(s.ContextService.Ctx, "10", params)
-	case 20005:
+	case 20007:
 		// 报表数据   季度回款指标
 		return getQuarterGoalReportData(s.ContextService.Ctx, "20", params)
 	default:

+ 3 - 3
opms_parent/app/service/home/report.go

@@ -189,8 +189,8 @@ func getQuarterGoalReportData(ctx context.Context, dataType string, params *map[
 		return nil, fmt.Errorf("请输入年度")
 	}
 	p := *params
-	year, _ := p["year"].(int)
-	quarter, _ := p["quarter"].(int)
+	year := gconv.Int(p["year"])
+	quarter := gconv.Int(p["quarter"])
 	if year == 0 {
 		return nil, fmt.Errorf("请输入年度")
 	}
@@ -258,7 +258,7 @@ func getQuarterGoalReportData(ctx context.Context, dataType string, params *map[
 	var reportData home.ReportData
 	for _, c := range productLineCode {
 		reportData.XData = append(reportData.XData, productLine[c])
-		reportData.YDataTarget = append(reportData.YDataTarget, goal[c]/10000)
+		reportData.YDataTarget = append(reportData.YDataTarget, goal[c])
 		reportData.YDataReal = append(reportData.YDataReal, got[c]/10000)
 	}
 	return &reportData, nil

+ 32 - 0
opms_parent/app/service/home/report_test.go

@@ -0,0 +1,32 @@
+package home
+
+import (
+	"testing"
+
+	"dashoo.cn/micro/app/model/contract"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
+)
+
+func TestInsertGoal(t *testing.T) {
+	for _, goalType := range []string{"10", "20"} {
+		for _, productLine := range []string{"10", "20", "30", "40", "50", "90"} {
+			for _, quarter := range []int{1, 2, 3, 4} {
+				g.DB().Insert("ctr_contract_goal", contract.CtrContractGoal{
+					GoalType:    goalType,
+					Year:        2023,
+					Quarter:     quarter,
+					ProductLine: productLine,
+					Amount:      float64(quarter) * 100,
+					Remark:      "",
+					CreatedBy:   1000,
+					CreatedName: "大数华创",
+					CreatedTime: gtime.Now(),
+					UpdatedBy:   1000,
+					UpdatedName: "大数华创",
+					UpdatedTime: gtime.Now(),
+				})
+			}
+		}
+	}
+}