自动退单

This commit is contained in:
邹宗楠
2023-03-01 16:04:37 +08:00
parent 6081ec223b
commit 70521e362c
4 changed files with 80 additions and 33 deletions

View File

@@ -1830,3 +1830,33 @@ func GetOrderListByStoreList(db *DaoDB, storeId []int64) (order []*model.GoodsOr
return order, nil
}
type CourierInfo struct {
CourierName string `json:"courier_name"`
CourierMobile string `json:"courier_mobile"`
}
// 获取同区域的骑手信息
func GetAddressRiderInfo(db *DaoDB, address string, randNumber int64) (*CourierInfo, error) {
sql := `
SELECT w.courier_name,w.courier_mobile FROM goods_order s
LEFT JOIN waybill w ON s.vendor_order_id = w.vendor_order_id AND w.courier_name <>"" AND w.courier_mobile <>""
WHERE s.order_created_at >= ? AND s.status = ? AND s.delivery_type = ? AND s.consignee_address LIKE ?
LIMIT ?,? `
param := []interface{}{time.Now().AddDate(0, -3, 0), model.OrderStatusFinished, model.OrderDeliveryTypePlatform, "%" + fmt.Sprintf("%s", address) + "%", randNumber, 1}
courier := &CourierInfo{}
if err := GetRow(db, courier, sql, param); err != nil {
return nil, err
}
if courier.CourierName == "" || courier.CourierMobile == "" {
info, err := GetAddressRiderInfo(db, address, randNumber+1)
if err != nil {
return nil, err
}
return info, err
}
return courier, nil
}

View File

@@ -83,7 +83,7 @@ func GetThingToTiktokMapList(db *DaoDB, vendorId int, thingId int64, vendorOrgCo
// DeleteThingToTiktokMapList 删除同步关联关系
func DeleteThingToTiktokMapList(vendorId int, vendorThingId string, skuId int) error {
sql := ` DELETE FROM thing_map t1 WHERE t1.vendor_thing_id = ? AND t1.vendor_id = ? AND t1.thing_id = ? `
sql := ` DELETE FROM thing_map WHERE vendor_thing_id = ? AND vendor_id = ? AND thing_id = ? `
param := []interface{}{vendorThingId, vendorId, skuId}
_, err := ExecuteSQL(GetDB(), sql, param...)
return err