|
|
@@ -0,0 +1,373 @@
|
|
|
+package oilcontract
|
|
|
+
|
|
|
+import (
|
|
|
+ msg2 "dashoo.cn/backend/api/business/msg"
|
|
|
+ "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
|
|
|
+ "dashoo.cn/backend/api/business/oilsupplier/oilcostmanage"
|
|
|
+ "dashoo.cn/backend/api/business/oilsupplier/supplier"
|
|
|
+ "dashoo.cn/backend/api/business/paymentinfo"
|
|
|
+ "encoding/json"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "dashoo.cn/backend/api/business/auditsetting"
|
|
|
+ "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
|
|
|
+ "dashoo.cn/backend/api/business/workflow"
|
|
|
+ . "dashoo.cn/backend/api/controllers"
|
|
|
+ "dashoo.cn/utils"
|
|
|
+)
|
|
|
+
|
|
|
+type OilContractDailyListenerController struct {
|
|
|
+ BaseController
|
|
|
+}
|
|
|
+
|
|
|
+type ListenerApproveParams struct {
|
|
|
+ BusinessKey string `json:"businessKey"`
|
|
|
+}
|
|
|
+
|
|
|
+type ListenerApproveInfo struct {
|
|
|
+ Users string `json:"users"`
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取二级单位分办人员列表 --回调
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {string} string
|
|
|
+// @router /pre-fen-trail [post]
|
|
|
+func (this *OilContractDailyListenerController) PreFenTrialStatus() {
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ var listenerApprove ListenerApproveParams
|
|
|
+ json.Unmarshal(jsonBlob, &listenerApprove)
|
|
|
+ annualId := strings.Split(listenerApprove.BusinessKey, "-")[0]
|
|
|
+
|
|
|
+ srv := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
+ var annualEntity annualaudit.OilAnnualAudit
|
|
|
+ srv.GetEntityById(annualId, &annualEntity)
|
|
|
+ cols := []string{
|
|
|
+ "Id",
|
|
|
+ "Status",
|
|
|
+ }
|
|
|
+ //进入此步骤,记录在数据库中
|
|
|
+ annualEntity.Status = suppliercert.FEN_TRIAL_STATUS //二级单位分办
|
|
|
+ srv.UpdateEntityByIdCols(annualId, annualEntity, cols)
|
|
|
+
|
|
|
+ //查出二级单位分办的人员
|
|
|
+ // 获取准入资质信息:
|
|
|
+ supplierCertSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
+ var supplierCertEntity suppliercert.OilSupplierCert
|
|
|
+ supplierCertSrv.GetEntityById(annualEntity.CerId, &supplierCertEntity)
|
|
|
+
|
|
|
+ stepCode := workflow.GetWorkFlowStepCode(supplierCertEntity.SupplierTypeCode) // TODO 年审的准入方式
|
|
|
+ auditSettingService := auditsetting.GetOilAuditSettingService(utils.DBE)
|
|
|
+ approverIds := auditSettingService.GetApproverIdsByStepCodeAndUnitId(stepCode, annualEntity.CommitComId)
|
|
|
+ var approveInfo ListenerApproveInfo
|
|
|
+ approveInfo.Users = approverIds
|
|
|
+ this.Data["json"] = &approveInfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// 用
|
|
|
+// @Title 获取二级单位初审人员列表--回调
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {string} string
|
|
|
+// @router /pre-first-trail [get]
|
|
|
+func (this *OilContractDailyListenerController) PreFirstTrail() {
|
|
|
+ businessKey := this.GetString("businessKey")
|
|
|
+ annualId := strings.Split(businessKey, "-")[0]
|
|
|
+
|
|
|
+ svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
+ var annualEntity annualaudit.OilAnnualAudit
|
|
|
+ svc.GetEntityById(annualId, &annualEntity)
|
|
|
+ cols := []string{
|
|
|
+ "Id",
|
|
|
+ "Status",
|
|
|
+ }
|
|
|
+ //进入此步骤,记录在数据库中
|
|
|
+ annualEntity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
|
|
|
+ svc.UpdateEntityByIdCols(annualId, annualEntity, cols)
|
|
|
+
|
|
|
+ //返回查出的初审人员操作人员列表
|
|
|
+ approverIds := annualEntity.FirstAudit
|
|
|
+ this.Data["json"] = approverIds
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取二级单位复审人员列表--回调
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {string} string
|
|
|
+// @router /pre-second-trail [get]
|
|
|
+func (this *OilContractDailyListenerController) PreSecondTrail() {
|
|
|
+ businessKey := this.GetString("businessKey")
|
|
|
+ annualId := strings.Split(businessKey, "_")[0]
|
|
|
+
|
|
|
+ certSrv := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
+ var annualEntity annualaudit.OilAnnualAudit
|
|
|
+ certSrv.GetEntityById(annualId, &annualEntity)
|
|
|
+ cols := []string{
|
|
|
+ "Id",
|
|
|
+ "Status",
|
|
|
+ }
|
|
|
+ //进入此步骤,记录在数据库中
|
|
|
+ annualEntity.Status = suppliercert.SECOND_TRIAL_STATUS //二级单位复审
|
|
|
+ certSrv.UpdateEntityByIdCols(annualId, annualEntity, cols)
|
|
|
+
|
|
|
+ //返回查出的复审人员操作人员列表
|
|
|
+ approverIds := annualEntity.SecondAudit
|
|
|
+ this.Data["json"] = approverIds
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 查询是否交费--回调
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {string} string
|
|
|
+// @router /check-need-pay [get]
|
|
|
+func (this *OilContractDailyListenerController) CheckNeedPay() {
|
|
|
+ businessKey := this.GetString("businessKey")
|
|
|
+ annualId := strings.Split(businessKey, "-")[0]
|
|
|
+
|
|
|
+ svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
+ var annualEntity annualaudit.OilAnnualAudit
|
|
|
+ svc.GetEntityById(annualId, &annualEntity)
|
|
|
+
|
|
|
+ certSvc := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
+ var supplierCertEntity suppliercert.OilSupplierCert
|
|
|
+ certSvc.GetEntityById(annualEntity.CerId, &supplierCertEntity)
|
|
|
+
|
|
|
+ var isPayList []string
|
|
|
+ isPayList = append(isPayList, suppliercert.PINGSHEN)
|
|
|
+ isPayList = append(isPayList, suppliercert.WAIBUSHICHANG)
|
|
|
+ var unPayList []string
|
|
|
+ unPayList = append(unPayList, suppliercert.YIJIWUZI)
|
|
|
+ unPayList = append(unPayList, suppliercert.ERJIWUZI)
|
|
|
+ unPayList = append(unPayList, suppliercert.ZHANLUEHEZUO)
|
|
|
+ unPayList = append(unPayList, suppliercert.NEIBUDUOYUAN)
|
|
|
+
|
|
|
+ result := 0
|
|
|
+ isPay := "false"
|
|
|
+ unPay := "false"
|
|
|
+ for _, eachItem := range isPayList {
|
|
|
+ if eachItem == supplierCertEntity.InStyle {
|
|
|
+ // 需要付费
|
|
|
+ isPay = "true"
|
|
|
+ result = 1
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, eachItem := range unPayList {
|
|
|
+ if eachItem == supplierCertEntity.InStyle {
|
|
|
+ // 不需要付费
|
|
|
+ unPay = "true"
|
|
|
+ result = 2
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if isPay == unPay {
|
|
|
+ // 准入类型是否付费有误!请联系管理员
|
|
|
+ result = 0
|
|
|
+ }
|
|
|
+
|
|
|
+ this.Data["json"] = result
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 获取交费人--回调
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {string} string
|
|
|
+// @router /pre-payer [get]
|
|
|
+func (this *OilContractDailyListenerController) GetPrePayer() {
|
|
|
+ businessKey := this.GetString("businessKey")
|
|
|
+ annualId := strings.Split(businessKey, "-")[0]
|
|
|
+ srv := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
+ var annualEntity annualaudit.OilAnnualAudit
|
|
|
+ srv.GetEntityById(annualId, &annualEntity)
|
|
|
+
|
|
|
+ cols := []string{
|
|
|
+ "Id",
|
|
|
+ "Status",
|
|
|
+ }
|
|
|
+ //进入此步骤,记录在数据库中
|
|
|
+ annualEntity.Status = suppliercert.PAYING_AUDIT_STATUS //待缴费
|
|
|
+ srv.UpdateEntityByIdCols(annualId, annualEntity, cols)
|
|
|
+
|
|
|
+ // 获取准入资质信息:
|
|
|
+ supplierCertSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
+ var supplierCertEntity suppliercert.OilSupplierCert
|
|
|
+ supplierCertSrv.GetEntityById(annualEntity.CerId, &supplierCertEntity)
|
|
|
+
|
|
|
+ // 年审审批通过且需要交费, 创建交费信息
|
|
|
+ supplierSrv := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+ var supplierEntity supplier.OilSupplier
|
|
|
+ supplierSrv.GetEntityById(annualEntity.SupplierId, &supplierEntity)
|
|
|
+
|
|
|
+ paySvc := paymentinfo.GetPaymentService(utils.DBE)
|
|
|
+ var Amount float64
|
|
|
+ costSvc := oilcostmanage.GetOilCostManageService(utils.DBE)
|
|
|
+ Amount = costSvc.GetAmount("ANNUAL", supplierCertEntity.SupplierTypeCode)
|
|
|
+ var payInfo paymentinfo.OilPaymentInfo
|
|
|
+ payInfo.SrcId = annualEntity.Id
|
|
|
+ payInfo.SupplierId = annualEntity.SupplierId
|
|
|
+ payInfo.SupplierCertId = annualEntity.CerId
|
|
|
+ payInfo.USCCode = supplierEntity.CommercialNo
|
|
|
+ payInfo.SupplierName = supplierEntity.SupplierName
|
|
|
+ payInfo.PayType = "2"
|
|
|
+ payInfo.IsPay = "0"
|
|
|
+ payInfo.IsInvoice = "0"
|
|
|
+ payInfo.Amount = strconv.FormatFloat(Amount, 'E', -1, 64)
|
|
|
+ payInfo.CreateUserId = annualEntity.CreateUserId
|
|
|
+ payInfo.CreateBy = annualEntity.CreateBy
|
|
|
+ payInfo.CreateOn = time.Now()
|
|
|
+ paySvc.InsertEntity(&payInfo)
|
|
|
+
|
|
|
+ //创建人即为交费的人员
|
|
|
+ approverIds := annualEntity.CreateUserId
|
|
|
+ this.Data["json"] = approverIds
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 企业法规处审批人员列表 --回调
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {string} string
|
|
|
+// @router /law-office-auditors [post]
|
|
|
+func (this *OilContractDailyListenerController) GetLawOfficeAuditors() {
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ var listenerApprove ListenerApproveParams
|
|
|
+ json.Unmarshal(jsonBlob, &listenerApprove)
|
|
|
+ annualId := strings.Split(listenerApprove.BusinessKey, "-")[0]
|
|
|
+
|
|
|
+ svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
+ var annualEntity annualaudit.OilAnnualAudit
|
|
|
+ svc.GetEntityById(annualId, &annualEntity)
|
|
|
+ cols := []string{
|
|
|
+ "Id",
|
|
|
+ "Status",
|
|
|
+ }
|
|
|
+ //进入此步骤,记录在数据库中
|
|
|
+ annualEntity.Status = suppliercert.CENT_AUDIT_STATUS //企业法规处
|
|
|
+ svc.UpdateEntityByIdCols(annualId, annualEntity, cols)
|
|
|
+
|
|
|
+ //查出企业法规处审批的人员
|
|
|
+ stepCode := workflow.PROF_REGULATION //企业法规处
|
|
|
+ auditSettingService := auditsetting.GetOilAuditSettingService(utils.DBE)
|
|
|
+ approverIds := auditSettingService.GetApproverIdsByStepCodeForConcentrateAudit(stepCode)
|
|
|
+ var approveInfo ListenerApproveInfo
|
|
|
+ approveInfo.Users = approverIds
|
|
|
+ this.Data["json"] = &approveInfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 企业法规处入库人员列表 --回调
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {string} string
|
|
|
+// @router /pre-storage-audit [post]
|
|
|
+func (this *OilContractDailyListenerController) GetStorageAuditor() {
|
|
|
+ var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+ var listenerApprove ListenerApproveParams
|
|
|
+ json.Unmarshal(jsonBlob, &listenerApprove)
|
|
|
+ annualId := strings.Split(listenerApprove.BusinessKey, "-")[0]
|
|
|
+
|
|
|
+ srv := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
+ var annualEntity annualaudit.OilAnnualAudit
|
|
|
+ srv.GetEntityById(annualId, &annualEntity)
|
|
|
+ cols := []string{
|
|
|
+ "Id",
|
|
|
+ "Status",
|
|
|
+ }
|
|
|
+ //进入此步骤,记录在数据库中
|
|
|
+ annualEntity.Status = suppliercert.STOREING_STATUS //待入库
|
|
|
+ srv.UpdateEntityByIdCols(annualId, annualEntity, cols)
|
|
|
+
|
|
|
+ //查出入库审批的人员
|
|
|
+ stepCode := workflow.PROF_REGULATION //待入库(企业法规处)
|
|
|
+ auditSettingService := auditsetting.GetOilAuditSettingService(utils.DBE)
|
|
|
+ approverIds := auditSettingService.GetApproverIdsByStepCodeForConcentrateAudit(stepCode)
|
|
|
+ var approveInfo ListenerApproveInfo
|
|
|
+ approveInfo.Users = approverIds
|
|
|
+ this.Data["json"] = &approveInfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 企业法规处审批入库完成, 工作流结束--回调
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {string} string
|
|
|
+// @router /workflow-end [get]
|
|
|
+func (this *OilContractDailyListenerController) WorkflowEndAudit() {
|
|
|
+ businessKey := this.GetString("businessKey")
|
|
|
+ annualId := strings.Split(businessKey, "-")[0]
|
|
|
+ srv := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
+ var annualEntity annualaudit.OilAnnualAudit
|
|
|
+ srv.GetEntityById(annualId, &annualEntity)
|
|
|
+
|
|
|
+ cols := []string{
|
|
|
+ "Id",
|
|
|
+ "Status",
|
|
|
+ "ApplyTime",
|
|
|
+ }
|
|
|
+ //进入此步骤,记录在数据库中
|
|
|
+ annualEntity.Status = suppliercert.STORE_STATUS //审核完成
|
|
|
+ annualEntity.ApplyTime = annualEntity.ApplyTime.AddDate(1, 0, 0) //更新年审表时间
|
|
|
+ srv.UpdateEntityByIdCols(annualId, annualEntity, cols)
|
|
|
+
|
|
|
+ //更新准入表时间
|
|
|
+ paymentInfoSvc := paymentinfo.GetPaymentService(utils.DBE)
|
|
|
+ var certModel suppliercert.OilSupplierCert
|
|
|
+ certModel.ApplyTime = annualEntity.ApplyTime.AddDate(1, 0, 0)
|
|
|
+ certModel.InFlag = "1"
|
|
|
+ paymentInfoSvc.UpdateEntityByIdCols(strconv.Itoa(annualEntity.CerId), &certModel, []string{"ApplyTime", "InFlag"})
|
|
|
+
|
|
|
+ this.Data["json"] = 1
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 审批驳回--回调
|
|
|
+// @Description get user by token
|
|
|
+// @Success 200 {string} string
|
|
|
+// @router /approval-refuse [get]
|
|
|
+func (this *OilContractDailyListenerController) ApprovalRefuse() {
|
|
|
+ businessKey := this.GetString("businessKey")
|
|
|
+ stepCodeStatus := this.GetString("stepCode")
|
|
|
+ annualId := strings.Split(businessKey, "-")[0]
|
|
|
+ srv := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
+ var annualEntity annualaudit.OilAnnualAudit
|
|
|
+ srv.GetEntityById(annualId, &annualEntity)
|
|
|
+
|
|
|
+ cols := []string{
|
|
|
+ "Id",
|
|
|
+ "Status",
|
|
|
+ }
|
|
|
+ //进入此步骤,记录在数据库中
|
|
|
+ annualEntity.Status = stepCodeStatus
|
|
|
+ srv.UpdateEntityByIdCols(annualId, annualEntity, cols)
|
|
|
+
|
|
|
+ // 获取准入资质信息:
|
|
|
+ //supplierCertSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
+ //var supplierCertEntity suppliercert.OilSupplierCert
|
|
|
+ //supplierCertSrv.GetEntityById(annualEntity.CerId, &supplierCertEntity)
|
|
|
+ //supplierSrv := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+ //var supplierEntity supplier.OilSupplier
|
|
|
+ //supplierSrv.GetEntityById(annualEntity.SupplierId, &supplierEntity)
|
|
|
+
|
|
|
+ // TODO 发送驳回通知短信
|
|
|
+ //this.AuditRejectNotice(supplierCertEntity, supplierEntity)
|
|
|
+
|
|
|
+ this.Data["json"] = annualEntity.CreateUserId
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 增项申请审核未通过短信通知
|
|
|
+// @Description 审核未通过短信通知
|
|
|
+// @Success 200 {object}
|
|
|
+// @router /audit-reject-notice/:id [post]
|
|
|
+func (this *OilContractDailyListenerController) AuditRejectNotice(supplierCertEntity suppliercert.OilSupplierCert, supplierEntity supplier.OilSupplier) {
|
|
|
+ toMobile := supplierEntity.Mobile
|
|
|
+ bFlag := ""
|
|
|
+ if supplierCertEntity.SupplierTypeCode == "01" {
|
|
|
+ bFlag = "物资类"
|
|
|
+ } else if supplierCertEntity.SupplierTypeCode == "02" {
|
|
|
+ bFlag = "基建类"
|
|
|
+ } else {
|
|
|
+ bFlag = "服务类"
|
|
|
+ }
|
|
|
+ msg := "您的" + bFlag + "年审申请审核未通过,请及时查看!"
|
|
|
+ msgService := msg2.GetMsgService(utils.DBE)
|
|
|
+ msgService.HandleMsg(toMobile, msg, "5-2", supplierCertEntity.CreateBy, supplierEntity.ContactName, strconv.Itoa(supplierCertEntity.CreateUserId), this.User.Username)
|
|
|
+}
|