增加单位功能
This commit is contained in:
@@ -866,6 +866,54 @@ func (c *BackendCrmPaybackController) DeleteRecord() {
|
||||
pipelineOk(&c.Controller, map[string]interface{}{"id": id})
|
||||
}
|
||||
|
||||
// UpdateRecord PUT /backend/crm/payback/record/:id
|
||||
// 补传/更新回款流水回执(仅更新回执文件,不改金额与状态)。
|
||||
func (c *BackendCrmPaybackController) UpdateRecord() {
|
||||
claims, err := pipelineClaims(&c.Controller)
|
||||
if err != nil {
|
||||
pipelineErr(&c.Controller, 401, 401, err.Error())
|
||||
return
|
||||
}
|
||||
id, _ := strconv.ParseUint(c.Ctx.Input.Param(":id"), 10, 64)
|
||||
if id == 0 {
|
||||
pipelineErr(&c.Controller, 400, 400, "无效的ID")
|
||||
return
|
||||
}
|
||||
raw, _ := io.ReadAll(c.Ctx.Request.Body)
|
||||
var p struct {
|
||||
ReceiptURL string `json:"receipt_url"`
|
||||
ReceiptName string `json:"receipt_name"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &p); err != nil {
|
||||
pipelineErr(&c.Controller, 400, 400, "参数错误")
|
||||
return
|
||||
}
|
||||
tenantID := pipelineTenantID(claims)
|
||||
var row models.TenantCrmPaybackRecord
|
||||
if err := models.Orm.QueryTable(new(models.TenantCrmPaybackRecord)).
|
||||
Filter("id", id).Filter("tenant_id", tenantID).
|
||||
Filter("delete_time__isnull", true).One(&row); err != nil {
|
||||
pipelineErr(&c.Controller, 404, 404, "回款记录不存在")
|
||||
return
|
||||
}
|
||||
now := time.Now()
|
||||
if _, uerr := models.Orm.QueryTable(new(models.TenantCrmPaybackRecord)).
|
||||
Filter("id", id).Filter("tenant_id", tenantID).
|
||||
Update(orm.Params{
|
||||
"receipt_url": strings.TrimSpace(p.ReceiptURL),
|
||||
"receipt_name": strings.TrimSpace(p.ReceiptName),
|
||||
"update_time": now,
|
||||
}); uerr != nil {
|
||||
pipelineErr(&c.Controller, 500, 500, "更新失败: "+uerr.Error())
|
||||
return
|
||||
}
|
||||
pipelineOk(&c.Controller, map[string]interface{}{
|
||||
"id": id,
|
||||
"receipt_url": strings.TrimSpace(p.ReceiptURL),
|
||||
"receipt_name": strings.TrimSpace(p.ReceiptName),
|
||||
})
|
||||
}
|
||||
|
||||
// refreshPlanReceived 按回款记录重算计划的已回款金额,并同步计划状态(1进行中 / 2已完成)。
|
||||
func refreshPlanReceived(tenantID string, paybackID uint64) {
|
||||
if paybackID == 0 {
|
||||
|
||||
Reference in New Issue
Block a user