|
|
@@ -2,6 +2,7 @@ package oilsupplier
|
|
|
|
|
|
import (
|
|
|
"dashoo.cn/backend/api/business/workflow"
|
|
|
+ "dashoo.cn/business/parameter"
|
|
|
"encoding/json"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
@@ -627,6 +628,13 @@ func (this *OilSupplierController) GetJoinCertEntityList() {
|
|
|
where = where + " and b.SupplierTypeCode = '" + SupplierTypeCode + "'"
|
|
|
}
|
|
|
|
|
|
+ //企业用户只看自己的数据记录
|
|
|
+ parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
|
|
|
+ extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
|
|
|
+ if extOrganizeId == this.User.DepartmentId {
|
|
|
+ where = where + " and a.CreateUserId = '" + this.User.Id + "'"
|
|
|
+ }
|
|
|
+
|
|
|
svc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
var list []supplier.OilSupplierView
|
|
|
|
|
|
@@ -1017,12 +1025,35 @@ func (this *OilSupplierController) AddEntity() {
|
|
|
var modelCert suppliercert.OilSupplierCert
|
|
|
var modelCertVM suppliercert.OilSupplierVM
|
|
|
var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
+
|
|
|
+ json.Unmarshal(jsonBlob, &model)
|
|
|
+ json.Unmarshal(jsonBlob, &modelCertVM)
|
|
|
+ serviceCert := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
+ canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, this.User.DepartmentId, this.User.Id)
|
|
|
+ var errinfo ErrorDataInfo
|
|
|
+ if !canApply {
|
|
|
+ errinfo.Message = "添加失败!供方用户只能申请一次"
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var list []supplier.OilSupplierView
|
|
|
+ service := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+ service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
|
|
|
+ if len(list) > 0 {
|
|
|
+ errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
var session *xorm.Session
|
|
|
session = utils.DBE.NewSession()
|
|
|
svc := supplier.GetOilSupplierSession(session)
|
|
|
svcCert := suppliercert.GetOilSupplierCertSession(session)
|
|
|
|
|
|
- json.Unmarshal(jsonBlob, &model)
|
|
|
model.CreateOn = time.Now()
|
|
|
model.CreateBy = this.User.Realname
|
|
|
model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
@@ -1035,8 +1066,6 @@ func (this *OilSupplierController) AddEntity() {
|
|
|
session.Rollback()
|
|
|
}
|
|
|
modelCert.SupplierId = model.Id
|
|
|
-
|
|
|
- json.Unmarshal(jsonBlob, &modelCertVM)
|
|
|
modelCert.SupplierTypeCode = modelCertVM.SupplierTypeCode
|
|
|
modelCert.SupplierTypeName = modelCertVM.SupplierTypeName
|
|
|
modelCert.Step = 1 //企业信息保存完成
|
|
|
@@ -1051,7 +1080,6 @@ func (this *OilSupplierController) AddEntity() {
|
|
|
// add Commit() after all actions
|
|
|
err = session.Commit()
|
|
|
|
|
|
- var errinfo ErrorDataInfo
|
|
|
if err == nil {
|
|
|
//新增
|
|
|
errinfo.Message = "添加成功!"
|
|
|
@@ -1329,3 +1357,36 @@ func (this *OilSupplierController) DeleteEntity() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// @Title 判断是否可以申请准入
|
|
|
+// @Description
|
|
|
+// @Success 200 {string} Count
|
|
|
+// @Failure 403 :id 为空
|
|
|
+// @router /iscanapply/:type [get]
|
|
|
+func (this *OilSupplierController) IsCanApply() {
|
|
|
+ Type := this.Ctx.Input.Param(":type")
|
|
|
+ var errinfo ErrorInfo
|
|
|
+ if Type == "" {
|
|
|
+ errinfo.Message = "操作失败!请求信息不完整"
|
|
|
+ errinfo.Code = -2
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ svc := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
+ canApply := svc.IsCanApplyByExtOrganizeUser(Type, this.User.DepartmentId, this.User.Id)
|
|
|
+
|
|
|
+ if canApply {
|
|
|
+ errinfo.Message = "无申请记录,可以申请"
|
|
|
+ errinfo.Code = 0
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ errinfo.Message = "供方用户只能申请一次"
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|