From ed32a2620e6bca744e6ff3338ee4007f5d258559 Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 6 Oct 2026 20:42:31 +0530 Subject: [PATCH] delivery slot updated in orders and deliveries fix --- models/order.go | 50 ++++++++++++++++++++++----------- repositories/orderRepository.go | 14 +++++++-- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/models/order.go b/models/order.go index e2f887c..be3c7df 100644 --- a/models/order.go +++ b/models/order.go @@ -130,23 +130,39 @@ type OrderInfo struct { Deliverylat FlexibleString `json:"deliverylat"` Deliverylong FlexibleString `json:"deliverylong"` Deliverytype string `json:"deliverytype"` - Paymenttype int `json:"paymenttype"` - Tenantname string `json:"tenantname"` - Tenanttoken string `json:"tenanttoken"` - Tenantsuburb string `json:"tenantsuburb"` - Tenantcity string `json:"tenantcity"` - Tenantcontactno string `json:"tenantcontactno"` - Tenantpostcode string `json:"tenantpostcode"` - Locationname string `json:"locationname"` - Locationsuburb string `json:"locationsuburb"` - Locationcity string `json:"locationcity"` - Locationcontactno string `json:"locationcontactno"` - Rider string `json:"rider"` - Ridercontactno string `json:"ridercontactno"` - Riderkms FlexibleString `json:"riderkms"` - Smsdelivery int `json:"smsdelivery"` - Customertoken string `json:"customertoken"` - Ridertoken string `json:"ridertoken"` + // The delivery window the customer asked for. + // + // ON THIS STRUCT, not only on Orders. GetTenantOrders — which is what the + // console and the app both read — scans into OrderInfo, so fields added to + // Orders alone never reach the list. That was the whole of the + // products.showhealthscore bug: written correctly, selected correctly, + // absent from the response, and every reading taken from it meaningless. + // + // The last four are joined from deliveryslots and read-only, so a shop that + // renames a window sees the new name on orders already placed. + Deliveryslotid int `json:"deliveryslotid" gorm:"column:deliveryslotid"` + Deliveryslotdate string `json:"deliveryslotdate" gorm:"column:deliveryslotdate"` + Slotkey string `json:"slotkey" gorm:"->"` + Deliveryslotname string `json:"deliveryslotname" gorm:"->"` + Deliveryslotstart string `json:"deliveryslotstart" gorm:"->"` + Deliveryslotend string `json:"deliveryslotend" gorm:"->"` + Paymenttype int `json:"paymenttype"` + Tenantname string `json:"tenantname"` + Tenanttoken string `json:"tenanttoken"` + Tenantsuburb string `json:"tenantsuburb"` + Tenantcity string `json:"tenantcity"` + Tenantcontactno string `json:"tenantcontactno"` + Tenantpostcode string `json:"tenantpostcode"` + Locationname string `json:"locationname"` + Locationsuburb string `json:"locationsuburb"` + Locationcity string `json:"locationcity"` + Locationcontactno string `json:"locationcontactno"` + Rider string `json:"rider"` + Ridercontactno string `json:"ridercontactno"` + Riderkms FlexibleString `json:"riderkms"` + Smsdelivery int `json:"smsdelivery"` + Customertoken string `json:"customertoken"` + Ridertoken string `json:"ridertoken"` } type DeliveryQuery struct { diff --git a/repositories/orderRepository.go b/repositories/orderRepository.go index 82a2247..82a8672 100644 --- a/repositories/orderRepository.go +++ b/repositories/orderRepository.go @@ -138,12 +138,22 @@ const ( a.deliverycustomer,a.deliverycontactno,a.deliverylocation as deliverysuburb, a.deliverycity,a.paymenttype, a.smsdelivery, a.orderamount, b.tenantname, b.tenanttoken, b.primarycontact AS tenantcontactno, b.postcode AS tenantpostcode, b.suburb AS tenantsuburb,b.city AS tenantcity, c.locationname, c.contactno AS locationcontactno, c.postcode AS locationpostcode, c.suburb AS locationsuburb, c.city AS locationcity, - d.locationname AS applocation + d.locationname AS applocation, + -- The delivery window, same as the 'base' select above. + -- + -- BOTH selects need it. 'base' backs the console's list; this one backs the + -- partner, customer, user and admin reads -- including the customer app's + -- own order history, which is where a shopper expects to see the window + -- they picked. Fixing one and not the other is how a field ends up present + -- on some screens and silently absent on others. + a.deliveryslotid, a.deliveryslotdate, s.slotkey, s.name AS deliveryslotname, + s.starttime AS deliveryslotstart, s.endtime AS deliveryslotend FROM orders a LEFT JOIN tenants b ON a.tenantid = b.tenantid LEFT JOIN tenantlocations c ON a.locationid = c.locationid LEFT JOIN app_location d ON a.applocationid = d.applocationid - LEFT JOIN app_locationconfig e ON d.applocationid = e.applocationid` + LEFT JOIN app_locationconfig e ON d.applocationid = e.applocationid + LEFT JOIN deliveryslots s ON a.deliveryslotid = s.slotid` ) func (r *orderRepository) GetTenantOrders(input models.DeliveryQuery) ([]models.OrderInfo, error) {