This commit is contained in:
邹宗楠
2023-03-02 17:58:07 +08:00
parent 23d5cf212a
commit a9416695ba
5 changed files with 98 additions and 31 deletions

View File

@@ -4,7 +4,6 @@ import (
"fmt"
"regexp"
"strconv"
"strings"
"time"
"git.rosy.net.cn/baseapi/utils"
@@ -1837,24 +1836,17 @@ type CourierInfo struct {
CourierMobile string `json:"courier_mobile"`
}
// 获取同区域的骑手信息
func GetAddressRiderInfo(db *DaoDB, address string, randNumber int64) (*CourierInfo, error) {
// GetAddressRiderInfo 获取同区域的骑手信息
func GetAddressRiderInfo(db *DaoDB, address string) ([]*CourierInfo, error) {
sql := `
SELECT w.courier_name,w.courier_mobile FROM goods_order s
SELECT DISTINCT w.courier_mobile,w.courier_name 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(-1, 0, 0), model.OrderStatusFinished, model.OrderDeliveryTypePlatform, "%" + fmt.Sprintf("%s", address) + "%", randNumber, 1}
WHERE s.order_created_at >= ? AND s.consignee_address LIKE ? `
param := []interface{}{time.Now().AddDate(-2, 0, 0), "%" + fmt.Sprintf("%s", address) + "%"}
courier := &CourierInfo{}
err := GetRow(db, courier, sql, param)
if (err != nil && strings.Contains(err.Error(), "no row found")) || courier.CourierName == "" || courier.CourierMobile == "" || len(courier.CourierMobile) != 11 {
info, err := GetAddressRiderInfo(db, address, randNumber-1)
if err != nil {
return nil, err
}
return info, err
var courier []*CourierInfo
if err := GetRows(db, &courier, sql, param); err != nil {
return nil, err
}
return courier, nil

View File

@@ -62,8 +62,8 @@ func GetSysConfigAsInt64(db *DaoDB, key string) (value int64, err error) {
}
// 修改配置
func UpdateOperatorConfig(param string) error {
func UpdateOperatorConfig(param string, types, key string) error {
sql := `UPDATE new_config c SET c.value = ?,c.updated_at = ? WHERE c.type = ? AND c.key = ?`
_, err := ExecuteSQL(GetDB(), sql, []interface{}{param, time.Now(), "Sys", "FZR"})
_, err := ExecuteSQL(GetDB(), sql, []interface{}{param, time.Now(), types, key})
return err
}