|
@@ -4,6 +4,7 @@ import (
|
|
"ERP_storage/Nats/NatsServer"
|
|
"ERP_storage/Nats/NatsServer"
|
|
"ERP_storage/conf"
|
|
"ERP_storage/conf"
|
|
"ERP_storage/models/Account"
|
|
"ERP_storage/models/Account"
|
|
|
|
+ "ERP_storage/models/Basic"
|
|
"ERP_storage/models/Contract"
|
|
"ERP_storage/models/Contract"
|
|
"ERP_storage/models/Percentage"
|
|
"ERP_storage/models/Percentage"
|
|
"ERP_storage/models/Stock"
|
|
"ERP_storage/models/Stock"
|
|
@@ -100,7 +101,6 @@ func (c *PercentageController) Percentage_Get() {
|
|
|
|
|
|
// 查询
|
|
// 查询
|
|
T_id, _ := c.GetInt("T_id")
|
|
T_id, _ := c.GetInt("T_id")
|
|
-
|
|
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
PercentageDao := Percentage.NewPercentage(o)
|
|
PercentageDao := Percentage.NewPercentage(o)
|
|
ContractDao := Contract.NewContract(o)
|
|
ContractDao := Contract.NewContract(o)
|
|
@@ -114,7 +114,7 @@ func (c *PercentageController) Percentage_Get() {
|
|
}
|
|
}
|
|
contract, err := ContractDao.Read_Contract_ByT_number(percentage.T_number)
|
|
contract, err := ContractDao.Read_Contract_ByT_number(percentage.T_number)
|
|
if err != nil {
|
|
if err != nil {
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "合同不存在!"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -130,6 +130,7 @@ func (c *PercentageController) Percentage_Get() {
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
Account.Read_User_All_Map(userList)
|
|
Account.Read_User_All_Map(userList)
|
|
Contract.Read_VerifyContract_All_Map()
|
|
Contract.Read_VerifyContract_All_Map()
|
|
|
|
+ Basic.Read_VerifyItem_All_Map()
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Percentage.PercentageToPercentage_Detail(percentage, contract, pList)}
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Percentage.PercentageToPercentage_Detail(percentage, contract, pList)}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -155,12 +156,21 @@ func (c *PercentageController) Percentage_Add() {
|
|
T_uuid: T_uuid,
|
|
T_uuid: T_uuid,
|
|
T_money: float32(T_money),
|
|
T_money: float32(T_money),
|
|
T_type: T_type, //类型 1-验证实施 2-报告编写
|
|
T_type: T_type, //类型 1-验证实施 2-报告编写
|
|
- T_State: 1,
|
|
|
|
|
|
+ T_State: 6, // 6-未提交审核
|
|
T_submit: c.User.T_uuid,
|
|
T_submit: c.User.T_uuid,
|
|
T_item: T_item,
|
|
T_item: T_item,
|
|
}
|
|
}
|
|
|
|
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
|
|
+ ContractDao := Contract.NewContract(o)
|
|
|
|
+ _, err := ContractDao.Read_Contract_ByT_number(T_number)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "合同不存在!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ Basic.Read_VerifyItem_All_Map()
|
|
|
|
+
|
|
o.Begin()
|
|
o.Begin()
|
|
PercentageDao := Percentage.NewPercentage(o)
|
|
PercentageDao := Percentage.NewPercentage(o)
|
|
|
|
|
|
@@ -171,13 +181,14 @@ func (c *PercentageController) Percentage_Add() {
|
|
if T_type == 2 {
|
|
if T_type == 2 {
|
|
T_type_str = "报告编写"
|
|
T_type_str = "报告编写"
|
|
}
|
|
}
|
|
- _, err := PercentageDao.Read_Percentage_ByT_number_T_type(T_number, T_type)
|
|
|
|
|
|
+ _, err = PercentageDao.Read_Percentage_ByT_number_T_type(T_number, T_type)
|
|
if err == nil {
|
|
if err == nil {
|
|
o.Rollback()
|
|
o.Rollback()
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("该合同已提交过%s提成申请", T_type_str)}
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("该合同已提交过%s提成申请", T_type_str)}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ var_.T_item_price = Percentage.Generate_VerifyItem_Price(var_.T_item)
|
|
|
|
|
|
_, err = PercentageDao.Add_Percentage(var_)
|
|
_, err = PercentageDao.Add_Percentage(var_)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -189,8 +200,6 @@ func (c *PercentageController) Percentage_Add() {
|
|
|
|
|
|
o.Commit()
|
|
o.Commit()
|
|
|
|
|
|
- NatsServer.AddNews(conf.FinanceUuid, fmt.Sprintf("【提成申请】您有一条提成申请(%s)待审核", var_.T_number), conf.PercentageApprovalUrl)
|
|
|
|
-
|
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "提成", "添加", var_)
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "提成", "添加", var_)
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_number}
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_number}
|
|
@@ -201,12 +210,10 @@ func (c *PercentageController) Percentage_Add() {
|
|
func (c *PercentageController) Percentage_Approval() {
|
|
func (c *PercentageController) Percentage_Approval() {
|
|
|
|
|
|
T_id, _ := c.GetInt("T_id")
|
|
T_id, _ := c.GetInt("T_id")
|
|
|
|
+ T_item := c.GetString("T_item")
|
|
T_state, _ := c.GetInt("T_state")
|
|
T_state, _ := c.GetInt("T_state")
|
|
- if T_state != Percentage.AuditPass && T_state != Percentage.AuditUnPass {
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_state Err!"}
|
|
|
|
- c.ServeJSON()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ T_approval_money, _ := c.GetFloat("T_approval_money")
|
|
|
|
+ T_approval_opinion := c.GetString("T_approval_opinion")
|
|
|
|
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
PercentageDao := Percentage.NewPercentage(o)
|
|
PercentageDao := Percentage.NewPercentage(o)
|
|
@@ -217,9 +224,34 @@ func (c *PercentageController) Percentage_Approval() {
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 未提交审核 不能修改
|
|
|
|
+ if percentage.T_State == Percentage.NotSubmit ||
|
|
|
|
+ percentage.T_State == Percentage.AuditPass ||
|
|
|
|
+ percentage.T_State == Percentage.RemitPart ||
|
|
|
|
+ percentage.T_State == Percentage.RemitAll {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("状态为%s,禁止提交!", Percentage.Read_Audit_Get(percentage.T_State))}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ Basic.Read_VerifyItem_All_Map()
|
|
|
|
+
|
|
|
|
+ if len(T_approval_opinion) > 0 {
|
|
|
|
+ percentage.T_approval_opinion = T_approval_opinion
|
|
|
|
+ }
|
|
|
|
+ if T_approval_money > 0 {
|
|
|
|
+ percentage.T_approval_money = float32(T_approval_money)
|
|
|
|
+ }
|
|
// 2-已通过 3-未通过
|
|
// 2-已通过 3-未通过
|
|
- percentage.T_State = T_state
|
|
|
|
- err = PercentageDao.Update_Percentage(percentage, "T_State")
|
|
|
|
|
|
+ if T_state == 2 || T_state == 3 {
|
|
|
|
+ percentage.T_State = T_state
|
|
|
|
+ }
|
|
|
|
+ if len(T_item) > 0 {
|
|
|
|
+ percentage.T_item = T_item
|
|
|
|
+ percentage.T_item_price = Percentage.Generate_VerifyItem_Price(percentage.T_item)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ err = PercentageDao.Update_Percentage(percentage, "T_State", "T_approval_opinion", "T_approval_money", "T_item", "T_item_price")
|
|
if err != nil {
|
|
if err != nil {
|
|
o.Rollback()
|
|
o.Rollback()
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
@@ -262,6 +294,13 @@ func (c *PercentageController) Percentage_Edit() {
|
|
}
|
|
}
|
|
|
|
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
|
|
+ ContractDao := Contract.NewContract(o)
|
|
|
|
+ _, err := ContractDao.Read_Contract_ByT_number(T_number)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "合同不存在!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
PercentageDao := Percentage.NewPercentage(o)
|
|
PercentageDao := Percentage.NewPercentage(o)
|
|
|
|
|
|
percentage, err := PercentageDao.Read_Percentage_ById(T_id)
|
|
percentage, err := PercentageDao.Read_Percentage_ById(T_id)
|
|
@@ -283,7 +322,7 @@ func (c *PercentageController) Percentage_Edit() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- // 1-待审核 2-审核通过 3-审核不通过 4-部分打款 5-全部打款 合同状态为未通过,修改之后将状态更改为待审核
|
|
|
|
|
|
+ // 1-待审核 2-审核通过 3-审核不通过 4-部分打款 5-全部打款 6-未提交审核 合同状态为未通过,修改之后将状态更改为待审核
|
|
if percentage.T_State == Percentage.AuditPass || percentage.T_State == Percentage.RemitPart || percentage.T_State == Percentage.RemitAll {
|
|
if percentage.T_State == Percentage.AuditPass || percentage.T_State == Percentage.RemitPart || percentage.T_State == Percentage.RemitAll {
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("状态为%s,禁止修改!", Percentage.Read_Audit_Get(percentage.T_State))}
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("状态为%s,禁止修改!", Percentage.Read_Audit_Get(percentage.T_State))}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -304,17 +343,16 @@ func (c *PercentageController) Percentage_Edit() {
|
|
}
|
|
}
|
|
if len(T_item) > 0 {
|
|
if len(T_item) > 0 {
|
|
percentage.T_item = T_item
|
|
percentage.T_item = T_item
|
|
|
|
+ percentage.T_item_price = Percentage.Generate_VerifyItem_Price(percentage.T_item)
|
|
}
|
|
}
|
|
- percentage.T_State = 1
|
|
|
|
|
|
|
|
- err = PercentageDao.Update_Percentage(percentage, "T_number", "T_uuid", "T_money", "T_type", "T_item", "T_State")
|
|
|
|
|
|
+ err = PercentageDao.Update_Percentage(percentage, "T_number", "T_uuid", "T_money", "T_type", "T_item", "T_item_price")
|
|
if err != nil {
|
|
if err != nil {
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- NatsServer.AddNews(conf.FinanceUuid, fmt.Sprintf("【提成申请】您有一条提成申请(%s)待审核", percentage.T_number), conf.PercentageApprovalUrl)
|
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "提成", "修改", percentage)
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "提成", "修改", percentage)
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: percentage.Id}
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: percentage.Id}
|
|
@@ -389,11 +427,11 @@ func (c *PercentageController) Percentage_Remit() {
|
|
}
|
|
}
|
|
_, money := Percentage.PercentageToPercentageRemit_R(T_remit)
|
|
_, money := Percentage.PercentageToPercentageRemit_R(T_remit)
|
|
// 部分打款
|
|
// 部分打款
|
|
- if percentage.T_money > money && money > 0 {
|
|
|
|
|
|
+ if percentage.T_approval_money > money && money > 0 {
|
|
percentage.T_State = 4
|
|
percentage.T_State = 4
|
|
}
|
|
}
|
|
// 全部打款
|
|
// 全部打款
|
|
- if percentage.T_money == money {
|
|
|
|
|
|
+ if percentage.T_approval_money == money && money > 0 {
|
|
percentage.T_State = 5
|
|
percentage.T_State = 5
|
|
}
|
|
}
|
|
|
|
|
|
@@ -491,3 +529,38 @@ func (c *PercentageController) Contract_List() {
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// 提交审核
|
|
|
|
+func (c *PercentageController) Percentage_Submit_Audit() {
|
|
|
|
+
|
|
|
|
+ T_id, _ := c.GetInt("T_id")
|
|
|
|
+
|
|
|
|
+ o := orm.NewOrm()
|
|
|
|
+ PercentageDao := Percentage.NewPercentage(o)
|
|
|
|
+
|
|
|
|
+ percentage, err := PercentageDao.Read_Percentage_ById(T_id)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "提交失败!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if percentage.T_State != 6 && percentage.T_State != 3 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("状态为%s,禁止提交!", Percentage.Read_Audit_Get(percentage.T_State))}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 1-待审核 2-审核通过 3-审核不通过 4-部分打款 5-全部打款 6-待审核 审核状态
|
|
|
|
+ percentage.T_State = 1
|
|
|
|
+ err = PercentageDao.Update_Percentage(percentage, "T_State")
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ NatsServer.AddNews(conf.FinanceUuid, fmt.Sprintf("【提成申请】您有一条提成申请(%s)待审核", percentage.T_number), conf.PercentageApprovalUrl)
|
|
|
|
+ NatsServer.AddUserLogs(c.User.T_uuid, "提成", "审核", percentage)
|
|
|
|
+
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|