Explorar el Código

feature(优化): 项目,合同编辑时不修改销售工程师,项目升级修改

ZZH-wl hace 2 años
padre
commit
c05184db1b

+ 25 - 1
opms_parent/app/handler/proj/business.go

@@ -158,11 +158,35 @@ func (p *BusinessHandler) DeleteByIds(ctx context.Context, req *comm_def.IdsReq,
 
 // BusinessUpgrade 项目升级
 // Swagger:Business 项目 项目升级
-func (p *BusinessHandler) BusinessUpgrade(ctx context.Context, args *multipart.MultipartFile, rsp *comm_def.CommonMsg) error {
+func (p *BusinessHandler) BusinessUpgrade(ctx context.Context, req *projModel.BusinessUpgradeReq, rsp *comm_def.CommonMsg) error {
+	// 参数校验
+	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
+		return err
+	}
+	if req.NboType != projSrv.StatusC && req.NboBudget <= 0 {
+		return myerrors.TipsError("项目预算不能小于0")
+	}
+	businessService, err := projSrv.NewBusinessService(ctx)
+	if err != nil {
+		return err
+	}
+	err = businessService.BusinessUpgrade(req, nil)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+// BusinessUpgradeA 项目升级A类
+// Swagger:Business 项目 项目升级
+func (p *BusinessHandler) BusinessUpgradeA(ctx context.Context, args *multipart.MultipartFile, rsp *comm_def.CommonMsg) error {
 	req := new(projModel.BusinessUpgradeReq)
 	if err := gconv.Struct(args.Meta, req); err != nil {
 		return err
 	}
+	if req.NboType != projSrv.StatusC && req.NboBudget <= 0 {
+		return myerrors.TipsError("项目预算不能小于0")
+	}
 	if req.NboType == projSrv.StatusA && req.IsAdoptDashoo == "10" {
 		if args.FileName == "" {
 			return fmt.Errorf("文件名称不能为空")

+ 8 - 8
opms_parent/app/model/proj/proj_business.go

@@ -98,14 +98,14 @@ type BusinessProduct struct {
 
 // BusinessUpgradeReq 项目升级请求
 type BusinessUpgradeReq struct {
-	Id                      int         `json:"id"                      v:"required|min:1#|id不能为空"`                                // 主键
-	NboType                 string      `json:"nboType"                 v:"required|in:10,20,30#项目级别不能为空|项目级别错误"`                  // 项目级别
-	NboBudget               float64     `json:"nboBudget"               v:"required-unless:nboType,30|min:0.01#项目预算不能为空|项目预算应大于0"` // 项目预算
-	DistributorId           int         `json:"distributorId"           `                                                          // 经销商/代理商ID
-	DistributorName         string      `json:"distributorName"         `                                                          // 经销商/代理商名称
-	TechnicalSupportName    string      `json:"technicalSupportName"    v:"required-unless:nboType,30#技术支持人员不能为空"`                 // 技术支持人员
-	TechnicalSupportContent string      `json:"technicalSupportContent" v:"required-unless:nboType,30#技术支持内容不能为空"`                 // 技术支持内容
-	TechnicalSupportTime    *gtime.Time `json:"technicalSupportTime"    v:"required-unless:nboType,30#技术支持时间不能为空"`                 // 技术支持时间
+	Id                      int         `json:"id"                      v:"required|min:1#|id不能为空"`                // 主键
+	NboType                 string      `json:"nboType"                 v:"required|in:10,20,30#项目级别不能为空|项目级别错误"`  // 项目级别
+	NboBudget               float64     `json:"nboBudget"               v:"required-unless:nboType,30#项目预算不能为空"`   // 项目预算
+	DistributorId           int         `json:"distributorId"           `                                          // 经销商/代理商ID
+	DistributorName         string      `json:"distributorName"         `                                          // 经销商/代理商名称
+	TechnicalSupportName    string      `json:"technicalSupportName"    v:"required-unless:nboType,30#技术支持人员不能为空"` // 技术支持人员
+	TechnicalSupportContent string      `json:"technicalSupportContent" v:"required-unless:nboType,30#技术支持内容不能为空"` // 技术支持内容
+	TechnicalSupportTime    *gtime.Time `json:"technicalSupportTime"    v:"required-unless:nboType,30#技术支持时间不能为空"` // 技术支持时间
 	//CustomerSatisfaction      string      `json:"customerSatisfaction"`      // 客户满意度 (10很满意、20满意、30较满意、40一般、50不满意)
 	ParentReceiver            string      `json:"parentReceiver"`                                                  // 总部对接人
 	NboBudgetTime             *gtime.Time `json:"nboBudgetTime"`                                                   // 项目预算期限

+ 6 - 6
opms_parent/app/service/contract/ctr_contract.go

@@ -790,12 +790,12 @@ func (s CtrContractService) Update(ctx context.Context, req *model.CtrContractUp
 	if req.ContractEndTime != nil {
 		toupdate["contract_end_time"] = req.ContractEndTime
 	}
-	if req.InchargeId != 0 {
-		toupdate["incharge_id"] = req.InchargeId
-	}
-	if req.InchargeName != "" {
-		toupdate["incharge_name"] = req.InchargeName
-	}
+	//if req.InchargeId != 0 {
+	//	toupdate["incharge_id"] = req.InchargeId
+	//}
+	//if req.InchargeName != "" {
+	//	toupdate["incharge_name"] = req.InchargeName
+	//}
 	if req.SignatoryId != 0 {
 		toupdate["signatory_id"] = req.SignatoryId
 	}

+ 3 - 2
opms_parent/app/service/proj/business.go

@@ -296,7 +296,8 @@ func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) error {
 
 	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
 		// 更新项目
-		_, err = p.Dao.TX(tx).FieldsEx(service.UpdateFieldEx...).WherePri(projDao.ProjBusiness.C.Id, req.Id).Update(businessData)
+		updateFieldEx := append(service.UpdateFieldEx, p.Dao.C.SaleId, p.Dao.C.SaleName)
+		_, err = p.Dao.TX(tx).FieldsEx(updateFieldEx...).WherePri(projDao.ProjBusiness.C.Id, req.Id).Update(businessData)
 		if err != nil {
 			return err
 		}
@@ -542,7 +543,7 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq, args *m
 		if err != nil {
 			return err
 		}
-		err = p.BusUpgradeDingEvent(business, req, args)
+		//err = p.BusUpgradeDingEvent(business, req, args)
 		return err
 	})
 	return err