updated at
parent
152cd0450c
commit
f5513a086a
|
@ -37,6 +37,7 @@ type CrmCustomer struct {
|
|||
AmountsOfTheInstallments string
|
||||
BookedPackages string
|
||||
AssignedEmployee string
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// swagger:model CrmTableCustomerResponse
|
||||
|
@ -58,6 +59,7 @@ type CrmTableCustomer struct {
|
|||
LastContact time.Time
|
||||
AssignedEmployee string
|
||||
CreatedBy string
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (CrmTableCustomer) TableName() string {
|
||||
|
|
|
@ -220,6 +220,8 @@ func UpdateCrmCustomer(c *fiber.Ctx) error {
|
|||
return c.SendStatus(fiber.StatusBadRequest)
|
||||
}
|
||||
|
||||
crmCustomer["UpdatedAt"] = time.Now()
|
||||
|
||||
result := database.DB.Model(&structs.CrmCustomer{}).
|
||||
Where("id = ?", params.Id).
|
||||
Select("*"). // update all fields (even if they are empty)
|
||||
|
@ -410,10 +412,36 @@ func CreateCrmCallProtocol(c *fiber.Ctx) error {
|
|||
return c.SendStatus(fiber.StatusInternalServerError)
|
||||
}
|
||||
|
||||
// update last contact date
|
||||
|
||||
result = database.DB.Model(&structs.CrmCustomer{}).
|
||||
Where("id = ?", body.CustomerId).
|
||||
Update("last_contact", time.Now())
|
||||
|
||||
if result.Error != nil {
|
||||
logger.AddCrmLog(rslogger.LogTypeError, "Failed to update last contact date: %v", result.Error.Error())
|
||||
return c.SendStatus(fiber.StatusInternalServerError)
|
||||
}
|
||||
|
||||
socketclients.BroadcastMessageToTopicStartsWith(utils.SubscribedTopicCrm,
|
||||
structs.SendSocketMessage{
|
||||
Cmd: utils.SentCmdCrmCallProtocolCreated,
|
||||
Body: crmCallProtocol,
|
||||
Cmd: utils.SentCmdCrmCallProtocolCreated,
|
||||
Body: struct {
|
||||
CallProtocol structs.CrmCallProtocol
|
||||
Customer struct {
|
||||
Id string
|
||||
LastContact time.Time
|
||||
}
|
||||
}{
|
||||
CallProtocol: crmCallProtocol,
|
||||
Customer: struct {
|
||||
Id string
|
||||
LastContact time.Time
|
||||
}{
|
||||
Id: body.CustomerId,
|
||||
LastContact: time.Now(),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
logger.AddCrmLog(rslogger.LogTypeInfo, "Crm call protocol id: %s created: %v", crmCallProtocol.Id, crmCallProtocol)
|
||||
|
@ -492,8 +520,6 @@ func DeleteCrmCallProtocol(c *fiber.Ctx) error {
|
|||
return c.SendStatus(fiber.StatusBadRequest)
|
||||
}
|
||||
|
||||
logger.AddCrmLog(rslogger.LogTypeInfo, "Crm call protocol id: %s delete requested", params.Id)
|
||||
|
||||
var crmCallProtocol structs.CrmCallProtocol
|
||||
|
||||
database.DB.First(&crmCallProtocol, "id = ?", params.Id)
|
||||
|
|
Loading…
Reference in New Issue