закупы в бэк
This commit is contained in:
@@ -632,28 +632,52 @@ type Purchase struct {
|
||||
Status string `json:"status"`
|
||||
CreativeID string `json:"creative_id"`
|
||||
Channels []PurchaseChannelOut `json:"channels"`
|
||||
Details *PurchaseDetails `json:"details,omitempty"`
|
||||
}
|
||||
|
||||
type PurchaseChannelOut struct {
|
||||
ID string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
PlannedCost *float64 `json:"planned_cost"`
|
||||
Comment *string `json:"comment"`
|
||||
InviteLink string `json:"invite_link"`
|
||||
InviteLinkType string `json:"invite_link_type"`
|
||||
Channel Channel `json:"channel"`
|
||||
ID string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
Comment *string `json:"comment"`
|
||||
InviteLink string `json:"invite_link"`
|
||||
InviteLinkType string `json:"invite_link_type"`
|
||||
Channel Channel `json:"channel"`
|
||||
Details *PurchaseChannelDetails `json:"details,omitempty"`
|
||||
}
|
||||
|
||||
type CostInfo struct {
|
||||
Type string `json:"type"`
|
||||
Value float64 `json:"value"`
|
||||
}
|
||||
|
||||
type PurchaseDetails struct {
|
||||
PlacementAt *string `json:"placement_at,omitempty"`
|
||||
PaymentAt *string `json:"payment_at,omitempty"`
|
||||
Cost *CostInfo `json:"cost,omitempty"`
|
||||
CostBeforeBargain *float64 `json:"cost_before_bargain,omitempty"`
|
||||
PurchaseType *string `json:"purchase_type,omitempty"`
|
||||
Format *string `json:"format,omitempty"`
|
||||
Comment *string `json:"comment,omitempty"`
|
||||
}
|
||||
|
||||
type PurchaseChannelDetails struct {
|
||||
PlacementAt *string `json:"placement_at,omitempty"`
|
||||
Cost *CostInfo `json:"cost,omitempty"`
|
||||
CostBeforeBargain *float64 `json:"cost_before_bargain,omitempty"`
|
||||
Format *string `json:"format,omitempty"`
|
||||
}
|
||||
|
||||
type CreatePurchaseChannelInput struct {
|
||||
Username string `json:"username"`
|
||||
Status *string `json:"status,omitempty"`
|
||||
PlannedCost *float64 `json:"planned_cost,omitempty"`
|
||||
Comment *string `json:"comment,omitempty"`
|
||||
Username string `json:"username"`
|
||||
Status *string `json:"status,omitempty"`
|
||||
Comment *string `json:"comment,omitempty"`
|
||||
Details *PurchaseChannelDetails `json:"details,omitempty"`
|
||||
}
|
||||
|
||||
type CreatePurchaseInput struct {
|
||||
CreativeID string `json:"creative_id"`
|
||||
Channels []CreatePurchaseChannelInput `json:"channels"`
|
||||
Details *PurchaseDetails `json:"details,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Client) CreatePurchase(
|
||||
|
||||
@@ -105,8 +105,8 @@ func (s *PurchaseDetails) renderDetails(b *bot.Bot, mode bot.RenderMode, jwt str
|
||||
text += fmt.Sprintf("%d. %s <b>%s</b>\n", i+1, statusSymbol, channelName)
|
||||
|
||||
// Стоимость
|
||||
if ch.PlannedCost != nil {
|
||||
text += fmt.Sprintf(" ▸ Стоимость: %.0f₽\n", *ch.PlannedCost)
|
||||
if ch.Details != nil && ch.Details.Cost != nil {
|
||||
text += fmt.Sprintf(" ▸ Стоимость: %.0f₽\n", ch.Details.Cost.Value)
|
||||
}
|
||||
|
||||
// Комментарий
|
||||
|
||||
@@ -221,10 +221,20 @@ func (s *SelectChannelsForPurchase) createPurchase(b *bot.Bot, jwt string) {
|
||||
// Преобразуем каналы в формат API
|
||||
var apiChannels []backend.CreatePurchaseChannelInput
|
||||
for _, ch := range s.Channels {
|
||||
var details *backend.PurchaseChannelDetails
|
||||
if ch.PlannedCost != nil {
|
||||
cost := backend.CostInfo{
|
||||
Type: "fixed",
|
||||
Value: *ch.PlannedCost,
|
||||
}
|
||||
details = &backend.PurchaseChannelDetails{
|
||||
Cost: &cost,
|
||||
}
|
||||
}
|
||||
apiChannels = append(apiChannels, backend.CreatePurchaseChannelInput{
|
||||
Username: ch.Username,
|
||||
PlannedCost: ch.PlannedCost,
|
||||
Comment: ch.Comment,
|
||||
Username: ch.Username,
|
||||
Comment: ch.Comment,
|
||||
Details: details,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user