|
@@ -12,6 +12,9 @@ import (
|
|
|
userlibs "git.baozhida.cn/ERP_libs/User"
|
|
|
"git.baozhida.cn/ERP_libs/lib"
|
|
|
"github.com/beego/beego/v2/adapter/orm"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+
|
|
|
//"github.com/beego/beego/v2/client/orm"
|
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
|
"math"
|
|
@@ -233,8 +236,9 @@ func (c *ReimburseController) Reimburse_Add() {
|
|
|
data := c.Ctx.Input.RequestBody
|
|
|
err := json.Unmarshal(data, &body)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "json.Unmarshal is err:" + err.Error()}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "json 反序列化错误:" + err.Error()}
|
|
|
c.ServeJSON()
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
if len(body.ReimburseDetails) == 0 {
|
|
@@ -318,6 +322,7 @@ func (c *ReimburseController) Reimburse_Edit() {
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "json.Unmarshal is err:" + err.Error()}
|
|
|
c.ServeJSON()
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
user_r, err := NatsServer.Verification(body.User_tokey, "")
|
|
@@ -579,59 +584,81 @@ func (c *ReimburseController) Reimburse_Edit_Audit() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// 修改打款明细
|
|
|
-func (c *ReimburseController) Reimburse_Edit_Remit() {
|
|
|
+// 修改(财务)
|
|
|
+func (c *ReimburseController) Reimburse_Edit_Finance() {
|
|
|
|
|
|
T_id, _ := c.GetInt("T_id")
|
|
|
- T_remit_detials := c.GetString("T_remit_detials")
|
|
|
+ T_approval_money, _ := c.GetFloat("T_approval_money")
|
|
|
+ T_approval_details := c.GetString("T_approval_details")
|
|
|
+ T_remit_details := c.GetString("T_remit_detials")
|
|
|
|
|
|
o := orm.NewOrm()
|
|
|
+ o.Begin()
|
|
|
ReimburseDao := Reimburse.NewReimburse(o)
|
|
|
-
|
|
|
+ ReimburseDetailsDao := Reimburse.NewReimburseDetails(o)
|
|
|
reimburse, err := ReimburseDao.Read_Reimburse_ById(T_id)
|
|
|
if err != nil {
|
|
|
+ o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 1 未提交审核 2 待审核 3 审核通过 4 审核不通过 5 已部分打款 6 已全部打款
|
|
|
- if reimburse.T_State != Reimburse.AuditPass && reimburse.T_State != Reimburse.RemitPart && reimburse.T_State != Reimburse.RemitAll {
|
|
|
+ if reimburse.T_State == Reimburse.WaitSubmit {
|
|
|
+ o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("状态为%s,禁止修改!", Reimburse.Read_Audit_Get(reimburse.T_State))}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- remitList := Reimburse.ReimburseToRemitDetail(T_remit_detials)
|
|
|
+ approval_details_list := strings.Split(strings.Trim(T_approval_details, "|"), "|")
|
|
|
+ for _, detail := range approval_details_list {
|
|
|
+ id, _ := strconv.Atoi(strings.Split(detail, ",")[0])
|
|
|
+ money := lib.StringToFloat64TwoDecimal(strings.Split(detail, ",")[1]) // 审批金额
|
|
|
+ opinion := strings.Split(detail, ",")[2] // 审批意见
|
|
|
+ err = ReimburseDetailsDao.Update_ReimburseDetails(Reimburse.ReimburseDetails{
|
|
|
+ Id: id,
|
|
|
+ T_approval_money: float32(money),
|
|
|
+ T_approval_opinion: opinion,
|
|
|
+ }, "T_approval_money", "T_approval_opinion")
|
|
|
+ if err != nil {
|
|
|
+ o.Rollback()
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改报销详情失败!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
var T_remit float32
|
|
|
+ remitList := Reimburse.ReimburseToRemitDetail(T_remit_details)
|
|
|
for _, r := range remitList {
|
|
|
T_remit += r.T_money
|
|
|
}
|
|
|
|
|
|
- if T_remit == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "打款金额不正确!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if T_remit == reimburse.T_money {
|
|
|
+ if T_remit == reimburse.T_approval_money && T_remit > 0 {
|
|
|
reimburse.T_State = Reimburse.RemitAll
|
|
|
- } else if T_remit < reimburse.T_money && T_remit > 0 {
|
|
|
+ } else if T_remit < reimburse.T_approval_money && T_remit > 0 {
|
|
|
reimburse.T_State = Reimburse.RemitPart
|
|
|
}
|
|
|
|
|
|
reimburse.T_remit = T_remit
|
|
|
- reimburse.T_remit_detials = T_remit_detials
|
|
|
- _, err = ReimburseDao.Update_Reimburse(reimburse, "T_State", "T_remit", "T_remit_detials")
|
|
|
+ reimburse.T_approval_money = float32(T_approval_money)
|
|
|
+ reimburse.T_remit_detials = T_remit_details
|
|
|
+ _, err = ReimburseDao.Update_Reimburse(reimburse, "T_State", "T_remit", "T_remit_detials", "T_approval_money")
|
|
|
if err != nil {
|
|
|
+ o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改审核状态失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
+ o.Commit()
|
|
|
+ if T_remit > 0 {
|
|
|
+ NatsServer.AddNews(reimburse.T_uid, fmt.Sprintf("【报销打款】您的报销申请已%s", Reimburse.Read_Audit_Get(reimburse.T_State)), conf.MyReimburseUrl)
|
|
|
+ }
|
|
|
|
|
|
- NatsServer.AddNews(reimburse.T_uid, fmt.Sprintf("【报销打款】您的报销申请已%s", Reimburse.Read_Audit_Get(reimburse.T_State)), conf.MyReimburseUrl)
|
|
|
-
|
|
|
- NatsServer.AddUserLogs(c.User.T_uuid, "报销", "修改打款明细", err)
|
|
|
+ NatsServer.AddUserLogs(c.User.T_uuid, "报销", "修改(财务)", err)
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id}
|
|
|
c.ServeJSON()
|