|
|
@@ -502,18 +502,6 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq) error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- var upgradeType string
|
|
|
- switch true {
|
|
|
- case business.NboType == StatusC && req.NboType == StatusB:
|
|
|
- upgradeType = "option_0"
|
|
|
- case business.NboType == StatusB && req.NboType == StatusA:
|
|
|
- upgradeType = "option_1"
|
|
|
- case business.NboType == StatusC && req.NboType == StatusA:
|
|
|
- upgradeType = "option_2"
|
|
|
- default:
|
|
|
- return myerrors.TipsError("错误的升级类型")
|
|
|
- }
|
|
|
- fmt.Println(upgradeType)
|
|
|
businessMap := g.Map{
|
|
|
p.Dao.C.ApproStatus: ApprovalWaiting,
|
|
|
}
|
|
|
@@ -524,8 +512,6 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq) error {
|
|
|
opnContent["approStatus"] = ApprovalWaiting
|
|
|
service.SetUpdatedInfo(opnContent, p.GetCxtUserId(), p.GetCxtUserName())
|
|
|
|
|
|
- // 审批流
|
|
|
- workflowSrv, _ := workflowService.NewFlowService(p.Ctx)
|
|
|
err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
|
|
|
// 更新项目调级
|
|
|
_, err = p.Dao.TX(tx).WherePri(req.Id).Data(businessMap).Update()
|
|
|
@@ -542,10 +528,90 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq) error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- // OMS项目降级 审批
|
|
|
- bizCode := business.NboCode + ":" + strconv.Itoa(business.Id)
|
|
|
- _, err = workflowSrv.StartProcessInstance(bizCode, workflowModel.ProjectUpGrade, "", &workflow.StartProcessInstanceRequest{
|
|
|
- ProcessCode: &BusinessUpgradeRequestProcessCode,
|
|
|
+ err = p.BusUpgradeDingEvent(business, req)
|
|
|
+ return err
|
|
|
+ })
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+// 获取项目的钉钉审批的升级类型
|
|
|
+func (p *businessService) getBusDingUpgradeType(dbNboType, reqNboType string) string {
|
|
|
+ var upgradeType string
|
|
|
+ switch true {
|
|
|
+ case dbNboType == StatusReserve && reqNboType == StatusC: // 储备转C
|
|
|
+ upgradeType = "option_0"
|
|
|
+ case dbNboType == StatusReserve && reqNboType == StatusB: // 储备转B
|
|
|
+ upgradeType = "option_1"
|
|
|
+ case dbNboType == StatusReserve && reqNboType == StatusA: // 储备转A
|
|
|
+ upgradeType = "option_KTAX3Y9K5340"
|
|
|
+ case dbNboType == StatusC && reqNboType == StatusB: // C转B
|
|
|
+ upgradeType = "option_0"
|
|
|
+ case dbNboType == StatusC && reqNboType == StatusA: // C转A
|
|
|
+ upgradeType = "option_0"
|
|
|
+ case dbNboType == StatusB && reqNboType == StatusA: // B转A
|
|
|
+ upgradeType = "option_1"
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ return upgradeType
|
|
|
+}
|
|
|
+
|
|
|
+// BusUpgradeDingEvent 项目升级钉钉审批流调用
|
|
|
+func (p *businessService) BusUpgradeDingEvent(business *model.ProjBusiness, req *model.BusinessUpgradeReq) error {
|
|
|
+ upgradeType := p.getBusDingUpgradeType(business.NboType, req.NboType)
|
|
|
+ if upgradeType == "" {
|
|
|
+ return myerrors.TipsError("错误的升级类型")
|
|
|
+ }
|
|
|
+ // 审批流
|
|
|
+ workflowSrv, _ := workflowService.NewFlowService(p.Ctx)
|
|
|
+ // OMS项目升级 审批
|
|
|
+ var err error
|
|
|
+ var dingReq *workflow.StartProcessInstanceRequest
|
|
|
+ bizCode := business.NboCode + ":" + strconv.Itoa(business.Id)
|
|
|
+ switch req.NboType {
|
|
|
+ case StatusC:
|
|
|
+ dingReq = &workflow.StartProcessInstanceRequest{
|
|
|
+ ProcessCode: &BusinessUpgradeCRequestProcessCode,
|
|
|
+ FormComponentValues: []*workflow.StartProcessInstanceRequestFormComponentValues{
|
|
|
+ {
|
|
|
+ Id: utils.String("TextField-K2AD4O5B"),
|
|
|
+ Name: utils.String("项目编码"),
|
|
|
+ Value: utils.String(business.NboCode),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("TextField_BDLSECETVSG0"),
|
|
|
+ Name: utils.String("项目名称"),
|
|
|
+ Value: utils.String(business.NboName),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("DDSelectField_VSA3U380ZK00"),
|
|
|
+ Name: utils.String("升级类型"),
|
|
|
+ Value: utils.String(upgradeType),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("TextField_1J9BJMOZ18F40"),
|
|
|
+ Name: utils.String("客户名称"),
|
|
|
+ Value: utils.String(business.CustName),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("TextField_AEUWH63LJ0O0"),
|
|
|
+ Name: utils.String("销售工程师"),
|
|
|
+ Value: utils.String(business.SaleName),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Id: utils.String("TextareaField_1LO81IKHH91C0"),
|
|
|
+ Name: utils.String("转化原因"),
|
|
|
+ Value: utils.String(req.Remark),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
+ case StatusB, StatusA: // 目前转B、A表单提交参数一致,仅A比B多几个必填-----2023.02.27
|
|
|
+ processCode := &BusinessUpgradeBRequestProcessCode
|
|
|
+ if req.NboType == StatusA {
|
|
|
+ processCode = &BusinessUpgradeARequestProcessCode
|
|
|
+ }
|
|
|
+ dingReq = &workflow.StartProcessInstanceRequest{
|
|
|
+ ProcessCode: processCode,
|
|
|
FormComponentValues: []*workflow.StartProcessInstanceRequestFormComponentValues{
|
|
|
{
|
|
|
Id: utils.String("TextField-K2AD4O5B"),
|
|
|
@@ -602,18 +668,25 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq) error {
|
|
|
Name: utils.String("是否我司参数"),
|
|
|
Value: utils.String(gconv.String(yesOrNoType[req.IsAdoptDashoo])),
|
|
|
},
|
|
|
+ {
|
|
|
+ Id: utils.String("TextareaField_1GEL8JJL3H5S0"),
|
|
|
+ Name: utils.String("备注"),
|
|
|
+ Value: utils.String(req.Remark),
|
|
|
+ },
|
|
|
},
|
|
|
- })
|
|
|
- if err != nil {
|
|
|
- g.Log().Error(err)
|
|
|
- return err
|
|
|
}
|
|
|
+ default:
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ _, err = workflowSrv.StartProcessInstance(bizCode, workflowModel.ProjectUpGrade, "", dingReq)
|
|
|
+ if err != nil {
|
|
|
+ g.Log().Error(err)
|
|
|
return err
|
|
|
- })
|
|
|
- return err
|
|
|
+ }
|
|
|
+ return nil
|
|
|
}
|
|
|
|
|
|
-// BusinessUpgradeNotify 项目降级 审批结果通知
|
|
|
+// BusinessUpgradeNotify 项目升级 审批结果通知
|
|
|
func (p *businessService) BusinessUpgradeNotify(flow *workflowModel.PlatWorkflow, msg *message.MixMessage) error {
|
|
|
business, err := p.checkDingTalkNotify(flow, msg)
|
|
|
if err != nil {
|