|
@@ -15,23 +15,25 @@ import (
|
|
|
|
|
|
// 合同
|
|
|
type Contract struct {
|
|
|
- Id int `orm:"column(ID);size(11);auto;pk"`
|
|
|
- T_number string `orm:"size(256);null"` // 合同编号
|
|
|
- T_customer string `orm:"size(256);null"` // 客户名称
|
|
|
- T_customer_id string `orm:"size(256);null"` // 客户id
|
|
|
- T_money float32 `orm:"digits(12);decimals(2)"` // 合同金额
|
|
|
- T_discount float32 `orm:"digits(12);decimals(2)"` // 合同优惠价
|
|
|
- T_project string `orm:"size(256);null"` // 项目
|
|
|
- T_type int `orm:"size(2);default(1)"` // 合同类型 1-销售合同 2-验证合同
|
|
|
- T_date string `orm:"size(256);null"` // 签订时间
|
|
|
- T_out int `orm:"size(2);default(1)"` // 出库状态 1-未出库 2-部分出库 3-已出库
|
|
|
- T_State int `orm:"size(2);default(1)"` // 0 删除(伪删除) 1-已通过 2-未通过 3-待审核 审核状态
|
|
|
- T_pdf string `orm:"size(256);null"` // 附件
|
|
|
- T_remark string `orm:"type(text);null"` // 备注
|
|
|
- T_recoveries string `orm:"type(text);null"` // 回款信息 回款时间,回款金额|回款时间,回款金额|
|
|
|
- T_invoice string `orm:"type(text);null"` // 开票信息 开票时间,开票金额|开票时间,开票金额|
|
|
|
- T_start_date string `orm:"size(256);null"` // 起始时间
|
|
|
- T_end_date string `orm:"size(256);null"` // 终止时间
|
|
|
+ Id int `orm:"column(ID);size(11);auto;pk"`
|
|
|
+ T_number string `orm:"size(256);null"` // 合同编号
|
|
|
+ T_customer string `orm:"size(256);null"` // 客户名称
|
|
|
+ T_customer_id string `orm:"size(256);null"` // 客户id
|
|
|
+ T_money float32 `orm:"digits(12);decimals(2)"` // 合同金额
|
|
|
+ T_discount float32 `orm:"digits(12);decimals(2)"` // 合同优惠价
|
|
|
+ T_project string `orm:"size(256);null"` // 项目
|
|
|
+ T_type int `orm:"size(2);default(1)"` // 合同类型 1-销售合同 2-验证合同
|
|
|
+ T_date string `orm:"size(256);null"` // 签订时间
|
|
|
+ T_out int `orm:"size(2);default(1)"` // 出库状态 1-未出库 2-部分出库 3-已出库
|
|
|
+ T_State int `orm:"size(2);default(1)"` // 0 删除(伪删除) 1-已通过 2-未通过 3-待审核 审核状态
|
|
|
+ T_pdf string `orm:"size(256);null"` // 附件
|
|
|
+ T_remark string `orm:"type(text);null"` // 备注
|
|
|
+ T_recoveries string `orm:"type(text);null"` // 回款信息 回款时间,回款金额|回款时间,回款金额|
|
|
|
+ T_recoveries_money float32 `orm:"digits(12);decimals(2)"` // 回款总金额
|
|
|
+ T_invoice string `orm:"type(text);null"` // 开票信息 开票时间,开票金额|开票时间,开票金额|
|
|
|
+ T_invoice_money float32 `orm:"digits(12);decimals(2)"` // 开票总金额
|
|
|
+ T_start_date string `orm:"size(256);null"` // 起始时间
|
|
|
+ T_end_date string `orm:"size(256);null"` // 终止时间
|
|
|
|
|
|
T_submit string `orm:"size(256);null"` // 合同提交人员
|
|
|
T_approver string `orm:"size(256);null"` // 审批人
|
|
@@ -58,20 +60,23 @@ func init() {
|
|
|
}
|
|
|
|
|
|
type Contract_R struct {
|
|
|
- Id int
|
|
|
- T_number string // 合同编号
|
|
|
- T_customer string // 客户名称
|
|
|
- T_money float32 // 合同金额
|
|
|
- T_discount float32 // 合同优惠价
|
|
|
- T_type int // 合同类型 1-销售合同 2-验证合同
|
|
|
- T_date string // 签订时间
|
|
|
- T_out int // 出库状态 1-未出库 2-已部分出库 3-已全部出库
|
|
|
- T_submit string // 合同提交人员uuid
|
|
|
- T_submit_name string // 合同提交人员名称
|
|
|
- T_approver string // 合同审批人员uuid
|
|
|
- T_approver_name string // 合同审批人员名称
|
|
|
- T_pdf string // 附件
|
|
|
- T_State int // 1-已通过 2-未通过 3-待审核 审核状态
|
|
|
+ Id int
|
|
|
+ T_number string // 合同编号
|
|
|
+ T_customer string // 客户名称
|
|
|
+ T_money float32 // 合同金额
|
|
|
+ T_discount float32 // 合同优惠价 验证合同才有优惠价
|
|
|
+ T_type int // 合同类型 1-销售合同 2-验证合同
|
|
|
+ T_date string // 签订时间
|
|
|
+ T_out int // 出库状态 1-未出库 2-已部分出库 3-已全部出库
|
|
|
+ T_submit string // 合同提交人员uuid
|
|
|
+ T_submit_name string // 合同提交人员名称
|
|
|
+ T_approver string // 合同审批人员uuid
|
|
|
+ T_approver_name string // 合同审批人员名称
|
|
|
+ T_pdf string // 附件
|
|
|
+ T_State int // 1-已通过 2-未通过 3-待审核 审核状态
|
|
|
+ T_recoveries_money float32 // 回款总金额
|
|
|
+ T_invoice_money float32 // 开票总金额
|
|
|
+
|
|
|
}
|
|
|
|
|
|
type Contract_Detail struct {
|
|
@@ -113,6 +118,8 @@ type Contract_Verify struct {
|
|
|
T_start_date string // 起始时间
|
|
|
T_end_date string // 终止时间
|
|
|
T_verify_state int // 1-未签约 2-已作废 3-已签约 4-即将到期
|
|
|
+ T_recoveries string // 回款信息
|
|
|
+ T_invoice string // 开票信息
|
|
|
}
|
|
|
|
|
|
func ContractToContractFinance_R(T_detail string) (r []ContractFinance_R, money float32) {
|
|
@@ -138,23 +145,11 @@ func ContractToContractFinance_R(T_detail string) (r []ContractFinance_R, money
|
|
|
func ContractToContract_R(t Contract) (r Contract_R) {
|
|
|
// 1-未出库 2-已部分出库 3-已全部出库
|
|
|
r.T_out = t.T_out
|
|
|
- // 1-已通过 2-未通过 3-待审核
|
|
|
- //if t.T_State == 1 {
|
|
|
- // r.T_out = 2
|
|
|
- // state := Read_ContractProduct_T_State_List(t.T_number)
|
|
|
- // if len(state) == 1 {
|
|
|
- // if state[0] == 1 {
|
|
|
- // r.T_out = 1
|
|
|
- // }
|
|
|
- // if state[0] == 3 {
|
|
|
- // r.T_out = 3
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
r.Id = t.Id
|
|
|
r.T_number = t.T_number
|
|
|
r.T_customer = t.T_customer
|
|
|
r.T_money = t.T_money
|
|
|
+ r.T_discount = t.T_discount
|
|
|
r.T_type = t.T_type
|
|
|
r.T_date = t.T_date
|
|
|
r.T_State = t.T_State
|
|
@@ -163,6 +158,8 @@ func ContractToContract_R(t Contract) (r Contract_R) {
|
|
|
r.T_submit_name = Account.Read_User_T_name_Get(t.T_submit)
|
|
|
r.T_approver = t.T_approver
|
|
|
r.T_approver_name = Account.Read_User_T_name_Get(t.T_approver)
|
|
|
+ r.T_recoveries_money = t.T_recoveries_money
|
|
|
+ r.T_invoice_money = t.T_invoice_money
|
|
|
return r
|
|
|
}
|
|
|
|
|
@@ -232,6 +229,8 @@ func ContractToContract_Verify(t Contract) (r Contract_Verify) {
|
|
|
}
|
|
|
|
|
|
r.T_verify_state = state
|
|
|
+ r.T_recoveries = t.T_recoveries
|
|
|
+ r.T_invoice = t.T_invoice
|
|
|
|
|
|
return r
|
|
|
}
|
|
@@ -355,7 +354,10 @@ func (dao *ContractDaoImpl) Read_VerifyContract_List(T_name, T_customer_id strin
|
|
|
|
|
|
// 过滤
|
|
|
cond := orm.NewCondition()
|
|
|
- cond1 := cond.And("T_State__gt", 0).And("T_type", 2).And("T_customer_id", T_customer_id)
|
|
|
+ cond1 := cond.And("T_State__gt", 0).And("T_type", 2)
|
|
|
+ if len(T_customer_id) > 0 {
|
|
|
+ cond1 = cond1.And("T_customer_id", T_customer_id)
|
|
|
+ }
|
|
|
if len(T_name) > 0 {
|
|
|
cond1 = cond1.AndCond(cond.Or("T_number__icontains", T_name).Or("T_customer__icontains", T_name))
|
|
|
}
|
|
@@ -387,6 +389,68 @@ func (dao *ContractDaoImpl) Read_VerifyContract_List(T_name, T_customer_id strin
|
|
|
return r_, cnt
|
|
|
}
|
|
|
|
|
|
+func (dao *ContractDaoImpl) Read_Contract_List_For_RecoveriesAndInvoice(T_name string, T_recoveries_state, T_invoice_state, page, page_z int) (r_ []Contract_R, cnt int64) {
|
|
|
+ // 也可以直接使用 Model 结构体作为表名
|
|
|
+ qs := dao.orm.QueryTable(new(Contract))
|
|
|
+ var offset int64
|
|
|
+ if page <= 1 {
|
|
|
+ offset = 0
|
|
|
+ } else {
|
|
|
+ offset = int64((page - 1) * page_z)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 过滤
|
|
|
+ cond := orm2.NewCondition()
|
|
|
+ cond = cond.And("T_State", 1)
|
|
|
+ // 回款状态 1 未回款 2 部分回款 3 全部回款
|
|
|
+ // 开票状态 1 未开票 2 部分开票 3 全部开票
|
|
|
+ if len(T_name) > 0 {
|
|
|
+ cond = cond.AndCond(cond.Or("T_number__icontains", T_name).Or("T_customer__icontains", T_name))
|
|
|
+ }
|
|
|
+ qs = qs.SetCond(cond)
|
|
|
+
|
|
|
+ if T_recoveries_state == 1 {
|
|
|
+ qs = qs.FilterRaw("t_recoveries_money", " = 0")
|
|
|
+ }
|
|
|
+ if T_recoveries_state == 2 {
|
|
|
+ qs = qs.FilterRaw("t_recoveries_money", " < t_discount").FilterRaw("t_recoveries_money", " > 0")
|
|
|
+ }
|
|
|
+ if T_recoveries_state == 3 {
|
|
|
+ qs = qs.FilterRaw("t_recoveries_money", " = t_discount")
|
|
|
+ }
|
|
|
+
|
|
|
+ if T_invoice_state == 1 {
|
|
|
+ qs = qs.FilterRaw("t_invoice_money", " = 0")
|
|
|
+ }
|
|
|
+ if T_invoice_state == 2 {
|
|
|
+ qs = qs.FilterRaw("t_invoice_money", " < t_discount").FilterRaw("t_invoice_money", " > 0")
|
|
|
+ }
|
|
|
+ if T_invoice_state == 3 {
|
|
|
+ qs = qs.FilterRaw("t_invoice_money", " = t_discount")
|
|
|
+ }
|
|
|
+ cond = qs.GetCond()
|
|
|
+ // 查询
|
|
|
+ var r []Contract
|
|
|
+ _, err := qs.Limit(page_z, offset).SetCond(cond).OrderBy("-Id").All(&r)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(lib.FuncName(), err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ cnt, err = qs.SetCond(cond).Count()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(lib.FuncName(), err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range r {
|
|
|
+ r_ = append(r_, ContractToContract_R(v))
|
|
|
+ }
|
|
|
+
|
|
|
+ return r_, cnt
|
|
|
+}
|
|
|
+
|
|
|
// 获取最新的验证合同
|
|
|
func (dao *ContractDaoImpl) Read_VerifyContract_Newest(T_customer_id string) (r_ Contract) {
|
|
|
// 也可以直接使用 Model 结构体作为表名
|