delivery slot updated in orders and deliveries fix

This commit is contained in:
2026-10-06 20:42:31 +05:30
parent a30763d323
commit ed32a2620e
2 changed files with 45 additions and 19 deletions

View File

@@ -130,23 +130,39 @@ type OrderInfo struct {
Deliverylat FlexibleString `json:"deliverylat"` Deliverylat FlexibleString `json:"deliverylat"`
Deliverylong FlexibleString `json:"deliverylong"` Deliverylong FlexibleString `json:"deliverylong"`
Deliverytype string `json:"deliverytype"` Deliverytype string `json:"deliverytype"`
Paymenttype int `json:"paymenttype"` // The delivery window the customer asked for.
Tenantname string `json:"tenantname"` //
Tenanttoken string `json:"tenanttoken"` // ON THIS STRUCT, not only on Orders. GetTenantOrders — which is what the
Tenantsuburb string `json:"tenantsuburb"` // console and the app both read — scans into OrderInfo, so fields added to
Tenantcity string `json:"tenantcity"` // Orders alone never reach the list. That was the whole of the
Tenantcontactno string `json:"tenantcontactno"` // products.showhealthscore bug: written correctly, selected correctly,
Tenantpostcode string `json:"tenantpostcode"` // absent from the response, and every reading taken from it meaningless.
Locationname string `json:"locationname"` //
Locationsuburb string `json:"locationsuburb"` // The last four are joined from deliveryslots and read-only, so a shop that
Locationcity string `json:"locationcity"` // renames a window sees the new name on orders already placed.
Locationcontactno string `json:"locationcontactno"` Deliveryslotid int `json:"deliveryslotid" gorm:"column:deliveryslotid"`
Rider string `json:"rider"` Deliveryslotdate string `json:"deliveryslotdate" gorm:"column:deliveryslotdate"`
Ridercontactno string `json:"ridercontactno"` Slotkey string `json:"slotkey" gorm:"->"`
Riderkms FlexibleString `json:"riderkms"` Deliveryslotname string `json:"deliveryslotname" gorm:"->"`
Smsdelivery int `json:"smsdelivery"` Deliveryslotstart string `json:"deliveryslotstart" gorm:"->"`
Customertoken string `json:"customertoken"` Deliveryslotend string `json:"deliveryslotend" gorm:"->"`
Ridertoken string `json:"ridertoken"` 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 { type DeliveryQuery struct {

View File

@@ -138,12 +138,22 @@ const (
a.deliverycustomer,a.deliverycontactno,a.deliverylocation as deliverysuburb, a.deliverycity,a.paymenttype, a.smsdelivery, a.orderamount, 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, 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, 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 FROM orders a
LEFT JOIN tenants b ON a.tenantid = b.tenantid LEFT JOIN tenants b ON a.tenantid = b.tenantid
LEFT JOIN tenantlocations c ON a.locationid = c.locationid LEFT JOIN tenantlocations c ON a.locationid = c.locationid
LEFT JOIN app_location d ON a.applocationid = d.applocationid 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) { func (r *orderRepository) GetTenantOrders(input models.DeliveryQuery) ([]models.OrderInfo, error) {