|
@@ -162,6 +162,10 @@ func (c *ContractController) Contract_Add() {
|
|
|
T_project := c.GetString("T_project")
|
|
|
T_recoveries := c.GetString("T_recoveries")
|
|
|
T_invoice := c.GetString("T_invoice")
|
|
|
+ T_submit := c.GetString("T_submit")
|
|
|
+ if len(T_submit) == 0 {
|
|
|
+ T_submit = c.User.T_uuid
|
|
|
+ }
|
|
|
|
|
|
var_ := Contract.Contract{
|
|
|
T_number: T_number,
|
|
@@ -175,7 +179,7 @@ func (c *ContractController) Contract_Add() {
|
|
|
T_State: 3,
|
|
|
T_remark: T_remark,
|
|
|
T_pdf: T_pdf,
|
|
|
- T_submit: c.User.T_uuid,
|
|
|
+ T_submit: T_submit,
|
|
|
T_recoveries: T_recoveries,
|
|
|
T_invoice: T_invoice,
|
|
|
}
|
|
@@ -285,6 +289,7 @@ func (c *ContractController) Contract_Edit() {
|
|
|
T_project := c.GetString("T_project")
|
|
|
T_recoveries := c.GetString("T_recoveries")
|
|
|
T_invoice := c.GetString("T_invoice")
|
|
|
+ T_submit := c.GetString("T_submit")
|
|
|
|
|
|
o := orm.NewOrm()
|
|
|
o.Begin()
|
|
@@ -323,13 +328,16 @@ func (c *ContractController) Contract_Edit() {
|
|
|
if len(T_invoice) > 0 {
|
|
|
contract.T_invoice = T_invoice
|
|
|
}
|
|
|
+ if len(T_submit) > 0 {
|
|
|
+ contract.T_submit = T_submit
|
|
|
+ }
|
|
|
|
|
|
//1-已通过 2-未通过 3-待审核 合同状态为未通过,修改之后将状态更改为待审核
|
|
|
if contract.T_State == 2 {
|
|
|
contract.T_State = 3
|
|
|
}
|
|
|
|
|
|
- err = ContractDao.Update_Contract(contract, "T_customer", "T_money", "T_date", "T_remark", "T_pdf", "T_State", "T_project", "T_recoveries", "T_invoice")
|
|
|
+ err = ContractDao.Update_Contract(contract, "T_customer", "T_money", "T_date", "T_remark", "T_pdf", "T_State", "T_project", "T_recoveries", "T_invoice", "T_submit")
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
|
|
@@ -500,18 +508,18 @@ func (c *ContractController) Contract_Del() {
|
|
|
return
|
|
|
}
|
|
|
//合同类型 1-销售合同 2-验证合同
|
|
|
- if contract.T_type == 1 {
|
|
|
- cpList := ContractProductDao.Read_ContractProduct_List(T_number)
|
|
|
- for _, v := range cpList {
|
|
|
- err = ContractProductDao.Delete_ContractProduct(v)
|
|
|
- if err != nil {
|
|
|
- o.Rollback()
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
+
|
|
|
+ cpList := ContractProductDao.Read_ContractProduct_List(T_number)
|
|
|
+ for _, v := range cpList {
|
|
|
+ err = ContractProductDao.Delete_ContractProduct(v)
|
|
|
+ if err != nil {
|
|
|
+ o.Rollback()
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
o.Commit()
|
|
|
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "合同", "删除", T_number)
|
|
@@ -569,13 +577,8 @@ func (c *ContractController) Contract_Product_List() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- if contract.T_type == 2 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
- c.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
- productList := ContractProductDao.Read_ContractProduct_List(contract.T_number)
|
|
|
+ productList := ContractProductDao.Read_ContractProduct_OutList(contract.T_number)
|
|
|
Stock.Read_Stock_All_Map(T_depot_id)
|
|
|
|
|
|
var pList []Contract.ContractProduct_Out
|
|
@@ -658,6 +661,7 @@ func (c *ContractController) VerifyContract_Add() {
|
|
|
T_discount, _ := c.GetFloat("T_discount")
|
|
|
T_date := c.GetString("T_date")
|
|
|
T_product := c.GetString("T_product")
|
|
|
+ T_submit := c.GetString("T_submit")
|
|
|
T_remark := c.GetString("T_remark")
|
|
|
T_pdf := c.GetString("T_pdf")
|
|
|
T_project := c.GetString("T_project")
|
|
@@ -677,7 +681,7 @@ func (c *ContractController) VerifyContract_Add() {
|
|
|
T_State: 1,
|
|
|
T_remark: T_remark,
|
|
|
T_pdf: T_pdf,
|
|
|
- T_submit: c.User.T_uuid,
|
|
|
+ T_submit: T_submit,
|
|
|
T_recoveries: T_recoveries,
|
|
|
T_invoice: T_invoice,
|
|
|
T_start_date: T_start_date,
|
|
@@ -704,7 +708,7 @@ func (c *ContractController) VerifyContract_Add() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- _, err = ContractDao.Add_Contract(var_)
|
|
|
+ ContractID, err := ContractDao.Add_Contract(var_)
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
|
|
@@ -714,20 +718,30 @@ func (c *ContractController) VerifyContract_Add() {
|
|
|
|
|
|
if len(T_product) == 0 {
|
|
|
o.Rollback()
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "销售合同产品明细不能为空"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "验证合同明细不能为空"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
productList := lib.SplitString(T_product, "|")
|
|
|
+ ContractOut := 0
|
|
|
for _, v := range productList {
|
|
|
product_id, _ := strconv.Atoi(strings.Split(v, ",")[0])
|
|
|
num, _ := strconv.Atoi(strings.Split(v, ",")[1])
|
|
|
+ price := lib.StringToFloat64TwoDecimal(strings.Split(v, ",")[2])
|
|
|
+ product, _ := Basic.Read_Product_ById(product_id)
|
|
|
contractProduct := Contract.ContractProduct{
|
|
|
T_contract_number: T_number,
|
|
|
T_product_id: product_id,
|
|
|
T_product_total: num,
|
|
|
- T_product_out: 0, // 已出库数量
|
|
|
- T_State: 1, // 1-未出库 2-已部分出库 3-已全部出库
|
|
|
+ T_product_out: 0, // 已出库数量
|
|
|
+ T_price: float32(price), // 已出库数量
|
|
|
+ T_State: 1, // 1-未出库 2-已部分出库 3-已全部出库
|
|
|
+ }
|
|
|
+ if product.T_class < 0 {
|
|
|
+ contractProduct.T_State = 3
|
|
|
+ }
|
|
|
+ if product.T_class == 0 {
|
|
|
+ ContractOut = 1
|
|
|
}
|
|
|
_, err = ContractProductDao.Add_ContractProduct(contractProduct)
|
|
|
if err != nil {
|
|
@@ -740,6 +754,16 @@ func (c *ContractController) VerifyContract_Add() {
|
|
|
}
|
|
|
|
|
|
o.Commit()
|
|
|
+ o2 := orm.NewOrm()
|
|
|
+ ContractDao2 := Contract.NewContract(o2)
|
|
|
+ if ContractOut == 1 {
|
|
|
+ err = ContractDao2.Update_Contract(Contract.Contract{Id: int(ContractID), T_out: ContractOut}, "T_out")
|
|
|
+ if err != nil {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "更新合同出库状态失败"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
err = Update_VerifyContract_State(T_customer_id, "ADD")
|
|
|
if err != nil {
|
|
@@ -768,6 +792,7 @@ func (c *ContractController) VerifyContract_Edit() {
|
|
|
T_invoice := c.GetString("T_invoice")
|
|
|
T_start_date := c.GetString("T_start_date")
|
|
|
T_end_date := c.GetString("T_end_date")
|
|
|
+ T_submit := c.GetString("T_submit")
|
|
|
|
|
|
o := orm.NewOrm()
|
|
|
o.Begin()
|
|
@@ -809,8 +834,11 @@ func (c *ContractController) VerifyContract_Edit() {
|
|
|
if len(T_end_date) > 0 {
|
|
|
contract.T_end_date = T_end_date
|
|
|
}
|
|
|
+ if len(T_submit) > 0 {
|
|
|
+ contract.T_submit = T_submit
|
|
|
+ }
|
|
|
|
|
|
- err = ContractDao.Update_Contract(contract, "T_money", "T_date", "T_remark", "T_pdf", "T_State", "T_project", "T_recoveries", "T_invoice", "T_start_date", "T_end_date")
|
|
|
+ err = ContractDao.Update_Contract(contract, "T_money", "T_date", "T_remark", "T_pdf", "T_State", "T_project", "T_recoveries", "T_invoice", "T_start_date", "T_end_date", "T_submit")
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
|