Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop
This commit is contained in:
@@ -94,6 +94,10 @@ func AutoSettingFakeDelivery() {
|
||||
// 获取刷单门店订单
|
||||
storeList := strings.Split(configList[0].Value, ",")
|
||||
for _, v := range storeList {
|
||||
if !strings.Contains(v, "-") {
|
||||
globals.SugarLogger.Errorf("newConfig 刷单门店配置异常")
|
||||
return
|
||||
}
|
||||
storeIdAndVendorId := strings.Split(v, "-")
|
||||
if len(storeIdAndVendorId) == model.NO {
|
||||
continue
|
||||
|
||||
@@ -876,7 +876,7 @@ func (c *OrderManager) GetStoresOrderSaleInfo(ctx *jxcontext.Context, storeIDLis
|
||||
return c.GetStoresOrderSaleInfoNew(ctx, storeIDList, fromTime, toTime, statusList)
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetStoresOrderSaleInfo2(ctx *jxcontext.Context, fromTime time.Time, toTime time.Time, storeId int) (map[string]interface{}, error) {
|
||||
func (c *OrderManager) GetStoresOrderSaleInfo2(ctx *jxcontext.Context, fromTime time.Time, toTime time.Time, storeId int, brandId, vendorId []int) (map[string]interface{}, error) {
|
||||
year, month, day := time.Now().Date()
|
||||
if fromTime.IsZero() {
|
||||
fromTime = time.Date(year, month, day, 0, 0, 0, 0, time.Local)
|
||||
@@ -887,19 +887,19 @@ func (c *OrderManager) GetStoresOrderSaleInfo2(ctx *jxcontext.Context, fromTime
|
||||
|
||||
db := dao.GetDB()
|
||||
// 门店统计
|
||||
storeStatus, err := dao.StatisticsStoreInfo(db)
|
||||
storeStatus, err := dao.StatisticsStoreInfo(db, brandId, vendorId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 订单统计
|
||||
orderStatus, err := dao.StatisticsOrderInfo(db, fromTime, toTime, storeId)
|
||||
orderStatus, err := dao.StatisticsOrderInfo(db, fromTime, toTime, storeId, brandId, vendorId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 售后单统计
|
||||
afsOrderStatus, err := dao.StatisticsAfsOrderInfo(db, fromTime, toTime, storeId)
|
||||
afsOrderStatus, err := dao.StatisticsAfsOrderInfo(db, fromTime, toTime, storeId, brandId, vendorId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -252,8 +252,8 @@ func GetComplaintReasons() (complaintReasonList []*dadaapi.ComplaintReason) {
|
||||
return complaintReasonList
|
||||
}
|
||||
|
||||
func ComplaintRider(ctx *jxcontext.Context, vendorOrderID string, vendorWaybillId string, complaintID int) (err error) {
|
||||
wayBillList, err := dao.GetComplaintList(dao.GetDB(), vendorOrderID, vendorWaybillId)
|
||||
func ComplaintRider(ctx *jxcontext.Context, vendorOrderID string, waybillVendorID string, complaintID int) (err error) {
|
||||
wayBillList, err := dao.GetComplaintList(dao.GetDB(), vendorOrderID, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -262,7 +262,11 @@ func ComplaintRider(ctx *jxcontext.Context, vendorOrderID string, vendorWaybillI
|
||||
}
|
||||
p := partner.GetDeliveryPlatformFromVendorID(wayBillList[0].WaybillVendorID).Handler
|
||||
if err == nil && len(wayBillList) > 0 {
|
||||
err = p.ComplaintRider(wayBillList[0], complaintID, complaintReasonsMap[complaintID])
|
||||
for _, v := range wayBillList {
|
||||
if utils.Int2Str(v.WaybillVendorID) == waybillVendorID {
|
||||
err = p.ComplaintRider(wayBillList[0], complaintID, complaintReasonsMap[complaintID])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cms
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/baidunavi"
|
||||
@@ -613,9 +614,10 @@ func GetSToURidingDistance(sLng, sLat, uLng, uLat float64, orderId string) (step
|
||||
// GetSToURidingDistance2 获取商家与用户间步行距离
|
||||
func GetSToURidingDistance2(sLng, sLat, uLng, uLat float64, orderId string) (wayBill *model.Waybill, err error) {
|
||||
var (
|
||||
origin = fmt.Sprintf("%f,%f", sLng, sLat)
|
||||
destination = fmt.Sprintf("%f,%f", uLng, uLat)
|
||||
db = dao.GetDB()
|
||||
//origin = fmt.Sprintf("%f,%f", sLng, sLat)
|
||||
//destination = fmt.Sprintf("%f,%f", uLng, uLat)
|
||||
db = dao.GetDB()
|
||||
vendorMaps = map[int]int{model.VendorIDDada: 1, model.VendorIDFengNiao: 1, model.VendorIDMTPS: 1, model.VendorIDUUPT: 1, model.VendorIDSFPS: 1}
|
||||
)
|
||||
|
||||
for {
|
||||
@@ -631,53 +633,57 @@ func GetSToURidingDistance2(sLng, sLat, uLng, uLat float64, orderId string) (way
|
||||
//if v.Status >= model.WaybillStatusAccepted && v.Status <= model.WaybillStatusCanceled {
|
||||
// 获取骑行路线图
|
||||
if v.OriginalData == "" {
|
||||
originalData, distance, durationTime, err := GetCyclingLine(origin, destination)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
//originalData, distance, durationTime, err := GetCyclingLine(origin, destination)
|
||||
originalData, distance, durationTime, err := GetCyclingLine(sLng, sLat, uLng, uLat)
|
||||
if err == nil {
|
||||
v.OriginalData = strings.Join(originalData, ";")
|
||||
v.Distance = distance
|
||||
v.DurationTime = durationTime
|
||||
}
|
||||
v.OriginalData = strings.Join(originalData, ";")
|
||||
v.Distance = distance
|
||||
v.DurationTime = durationTime
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
// 如果是三方配送,更新骑手信息
|
||||
if handler := partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID); handler != nil {
|
||||
riderInfo, _ := handler.Handler.GetRiderInfo(v.VendorOrderID, v.ID+1000000, v.VendorWaybillID)
|
||||
if riderInfo != nil {
|
||||
if len(riderInfo.Longitude) < len("104.065861") && riderInfo.Longitude != "" {
|
||||
riderInfo.Longitude += "0"
|
||||
}
|
||||
if len(riderInfo.Latitude) < len("27.934441") && riderInfo.Latitude != "" {
|
||||
riderInfo.Latitude += "0"
|
||||
}
|
||||
v.CourierCoordinate = fmt.Sprintf("%s,%s", riderInfo.Longitude, riderInfo.Latitude)
|
||||
if (v.CourierName == "" || v.CourierMobile == "") && riderInfo.CourierName != "" {
|
||||
v.CourierName = riderInfo.CourierName
|
||||
v.CourierMobile = riderInfo.CourierPhone
|
||||
if vendorMaps[v.WaybillVendorID] == model.YES {
|
||||
// 如果是三方配送,更新骑手信息
|
||||
if handler := partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID); handler != nil {
|
||||
riderInfo, _ := handler.Handler.GetRiderInfo(v.VendorOrderID, v.ID+1000000, v.VendorWaybillID)
|
||||
if riderInfo != nil {
|
||||
if len(riderInfo.Longitude) < len("104.065861") || riderInfo.Longitude != "" {
|
||||
riderInfo.Longitude += "0"
|
||||
}
|
||||
if len(riderInfo.Latitude) < len("27.934441") || riderInfo.Latitude != "" {
|
||||
riderInfo.Latitude += "0"
|
||||
}
|
||||
v.CourierCoordinate = fmt.Sprintf("%s,%s", riderInfo.Longitude, riderInfo.Latitude)
|
||||
if (v.CourierName == "" || v.CourierMobile == "") && riderInfo.CourierName != "" {
|
||||
v.CourierName = riderInfo.CourierName
|
||||
v.CourierMobile = riderInfo.CourierPhone
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果是平台配送,获取骑手信息
|
||||
if handler := partner.GetPurchaseOrderHandlerFromVendorID(v.WaybillVendorID); handler != nil {
|
||||
riderInfo, _ := handler.OrderLogisticsStatus(v.VendorOrderID)
|
||||
if riderInfo != nil {
|
||||
if len(riderInfo.Longitude) < len("104.065861") && riderInfo.Longitude != "" {
|
||||
riderInfo.Longitude += "0"
|
||||
}
|
||||
if len(riderInfo.Latitude) < len("27.934441") && riderInfo.Latitude != "" {
|
||||
riderInfo.Latitude += "0"
|
||||
}
|
||||
v.CourierCoordinate = fmt.Sprintf("%s,%s", riderInfo.Longitude, riderInfo.Latitude)
|
||||
if (v.CourierName == "" || v.CourierMobile == "") && riderInfo.CourierName != "" {
|
||||
v.CourierName = riderInfo.CourierName
|
||||
v.CourierMobile = riderInfo.CourierPhone
|
||||
} else {
|
||||
// 如果是平台配送,获取骑手信息
|
||||
if handler := partner.GetPurchaseOrderHandlerFromVendorID(v.WaybillVendorID); handler != nil {
|
||||
riderInfo, _ := handler.OrderLogisticsStatus(v.VendorOrderID)
|
||||
if riderInfo != nil {
|
||||
if len(riderInfo.Longitude) < len("104.065861") || riderInfo.Longitude != "" {
|
||||
riderInfo.Longitude += "0"
|
||||
}
|
||||
if len(riderInfo.Latitude) < len("27.934441") || riderInfo.Latitude != "" {
|
||||
riderInfo.Latitude += "0"
|
||||
}
|
||||
v.CourierCoordinate = fmt.Sprintf("%s,%s", riderInfo.Longitude, riderInfo.Latitude)
|
||||
if (v.CourierName == "" || v.CourierMobile == "") && riderInfo.CourierName != "" {
|
||||
v.CourierName = riderInfo.CourierName
|
||||
v.CourierMobile = riderInfo.CourierPhone
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 当这个运单为假物流/门店真实自送/获取运单骑手信息为空的时候使用假的骑手信息
|
||||
if v.WaybillVendorID == model.VendorJXFakeWL || v.WaybillVendorID == model.VendorIDUnknown || v.CourierCoordinate == "" {
|
||||
if (v.WaybillVendorID == model.VendorJXFakeWL || v.WaybillVendorID == model.VendorIDUnknown || v.CourierCoordinate == "") && v.OriginalData != "" {
|
||||
riderLine := strings.Split(v.OriginalData, ";") // 路线坐标点
|
||||
|
||||
courierDistance := float64(time.Now().Unix()-v.WaybillCreatedAt.Unix()) * (float64(v.Distance) / float64(v.DurationTime)) // 当前骑手骑行距离
|
||||
@@ -708,24 +714,62 @@ func GetSToURidingDistance2(sLng, sLat, uLng, uLat float64, orderId string) (way
|
||||
}
|
||||
|
||||
// GetCyclingLine 获取骑行路线
|
||||
func GetCyclingLine(origin, destination string) (polyLineList []string, distance, duration int64, errCode error) {
|
||||
for {
|
||||
polyLineList, distance, duration, errCode = api.AutonaviAPI.GetCyclingPlan(origin, destination)
|
||||
if errCode != nil {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "高德地图骑行方案获取错误:", utils.Format4Output(errCode, false))
|
||||
}
|
||||
if errCode != nil && errCode.Error() == autonavi.DAILYQUERYOVERLIMIT {
|
||||
AutonaviKeyIndex += model.YES
|
||||
if AutonaviKeyIndex >= len(AutonaviKeyList) {
|
||||
AutonaviKeyIndex = model.NO
|
||||
}
|
||||
api.AutonaviAPI.SetKey(AutonaviKeyList[AutonaviKeyIndex])
|
||||
} else if errCode != nil {
|
||||
return nil, 0, 0, errCode
|
||||
}
|
||||
func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, distance, duration int64, err error) {
|
||||
// 百度
|
||||
var coords []*baidunavi.Coordinate
|
||||
coords = append(coords, &baidunavi.Coordinate{
|
||||
Lng: sLng,
|
||||
Lat: sLat,
|
||||
}, &baidunavi.Coordinate{
|
||||
Lat: uLat,
|
||||
Lng: uLng,
|
||||
})
|
||||
|
||||
if len(polyLineList) > model.NO {
|
||||
return polyLineList, distance, duration, errCode
|
||||
}
|
||||
coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGCJ02, baidunavi.CoordSysBaiDu)
|
||||
if err != nil || len(coords) <= model.NO {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
data, err := api.BaiDuNaviAPI.DirectionLiteRide(coords)
|
||||
if err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
if data == "" {
|
||||
return nil, 0, 0, fmt.Errorf("获取骑行规划路线错误")
|
||||
}
|
||||
path := &baidunavi.RiderPath{}
|
||||
if err := json.Unmarshal([]byte(data.(string)), path); err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
if path.Status != model.NO {
|
||||
return nil, 0, 0, fmt.Errorf("%d,%s", path.Status, path.Message)
|
||||
}
|
||||
distance = int64(path.Result.Routes[0].Distance) // 距离
|
||||
duration = int64(path.Result.Routes[0].Duration) // 时间
|
||||
|
||||
for _, v := range path.Result.Routes[0].Steps {
|
||||
polyLineList = append(polyLineList, strings.Split(v.Path, ";")...)
|
||||
}
|
||||
|
||||
// 高德()免费次数太少暂时不用
|
||||
//for {
|
||||
// polyLineList, distance, duration, errCode = api.AutonaviAPI.GetCyclingPlan(origin, destination)
|
||||
// if errCode != nil {
|
||||
// ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "获取骑行路线:", utils.Format4Output(errCode, false))
|
||||
// }
|
||||
// if errCode != nil && (errCode.Error() == autonavi.DAILYQUERYOVERLIMIT || errCode.Error() == autonavi.USERDAILYQUERYOVERLIMIT) {
|
||||
// AutonaviKeyIndex += model.YES
|
||||
// if AutonaviKeyIndex >= len(AutonaviKeyList) {
|
||||
// AutonaviKeyIndex = model.NO
|
||||
// }
|
||||
// api.AutonaviAPI.SetKey(AutonaviKeyList[AutonaviKeyIndex])
|
||||
// } else if errCode != nil {
|
||||
// return nil, 0, 0, errCode
|
||||
// }
|
||||
//
|
||||
// if len(polyLineList) > model.NO {
|
||||
// return polyLineList, distance, duration, errCode
|
||||
// }
|
||||
//}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/jx-callback/business/bidding"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auto_delivery"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/delivery"
|
||||
|
||||
@@ -218,10 +217,10 @@ func Init() {
|
||||
}, 10*time.Second, 5*time.Minute)
|
||||
|
||||
// (自动发单拣货,设置骑手) 刷单用
|
||||
ScheduleTimerFuncByInterval(func() {
|
||||
auto_delivery.Init() // 初始化骑手列表
|
||||
auto_delivery.AutoSettingFakeDelivery()
|
||||
}, 10*time.Second, 5*time.Minute)
|
||||
//ScheduleTimerFuncByInterval(func() {
|
||||
// auto_delivery.Init() // 初始化骑手列表
|
||||
// auto_delivery.AutoSettingFakeDelivery()
|
||||
//}, 10*time.Second, 5*time.Minute)
|
||||
|
||||
// 定时任务更新负责人信息
|
||||
ScheduleTimerFunc("RefreshStoreOperator", func() {
|
||||
|
||||
@@ -1698,11 +1698,23 @@ type StatisticsStore struct {
|
||||
}
|
||||
|
||||
// StatisticsStoreInfo 统计所有的门店信息
|
||||
func StatisticsStoreInfo(db *DaoDB) ([]*StatisticsStore, error) {
|
||||
func StatisticsStoreInfo(db *DaoDB, brandId []int, vendorId []int) ([]*StatisticsStore, error) {
|
||||
statistics := make([]*StatisticsStore, 0, 0)
|
||||
|
||||
sql := ` SELECT count(s.status) count, s.status FROM store s GROUP BY s.status `
|
||||
if err := GetRows(db, &statistics, sql, nil); err != nil {
|
||||
sql := ` SELECT count(s.status) count, s.status FROM store s `
|
||||
param := make([]interface{}, 0, 0)
|
||||
if len(vendorId) > model.NO {
|
||||
sql += ` INNER JOIN store_map m ON s.id = m.store_id AND m.vendor_id IN (` + GenQuestionMarks(len(vendorId)) + `)`
|
||||
param = append(param, vendorId)
|
||||
}
|
||||
sql += ` WHERE 1=1 `
|
||||
if len(brandId) > model.NO {
|
||||
sql += ` AND s.brand_id IN (` + GenQuestionMarks(len(brandId)) + `)`
|
||||
param = append(param, brandId)
|
||||
}
|
||||
|
||||
sql += ` GROUP BY s.status `
|
||||
if err := GetRows(db, &statistics, sql, param); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return statistics, nil
|
||||
@@ -1715,13 +1727,25 @@ type StatisticsOrder struct {
|
||||
}
|
||||
|
||||
// StatisticsOrderInfo 统计订单信息
|
||||
func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int) ([]*StatisticsOrder, error) {
|
||||
sql := ` SELECT count(g.vendor_order_id) count,g.status status ,sum(g.total_shop_money) total_shop_money FROM goods_order g WHERE g.order_created_at >= ? AND g.order_created_at <= ? `
|
||||
parma := []interface{}{startTime, endTime}
|
||||
func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId []int) ([]*StatisticsOrder, error) {
|
||||
parma := []interface{}{}
|
||||
sql := ` SELECT count(g.vendor_order_id) count,g.status status ,sum(g.total_shop_money) total_shop_money FROM goods_order g `
|
||||
|
||||
if len(brandId) > model.NO {
|
||||
sql += ` INNER JOIN store s ON IF(g.store_id <> 0,g.store_id,g.jx_store_id) = s.id AND s.brand_id IN (` + GenQuestionMarks(len(brandId)) + `)`
|
||||
parma = append(parma, brandId)
|
||||
}
|
||||
|
||||
sql += ` WHERE g.order_created_at >= ? AND g.order_created_at <= ?`
|
||||
parma = append(parma, startTime, endTime)
|
||||
if storeId != model.NO {
|
||||
sql += ` AND IF(g.store_id <> 0,g.store_id,g.jx_store_id) = ?`
|
||||
parma = append(parma, storeId)
|
||||
}
|
||||
if len(vendorId) > model.NO {
|
||||
sql += ` AND g.vendor_id IN (` + GenQuestionMarks(len(vendorId)) + `)`
|
||||
parma = append(parma, vendorId)
|
||||
}
|
||||
sql += ` GROUP BY g.status `
|
||||
orderStatistics := make([]*StatisticsOrder, 0, 0)
|
||||
if err := GetRows(GetDB(), &orderStatistics, sql, parma...); err != nil {
|
||||
@@ -1731,13 +1755,27 @@ func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int) (
|
||||
}
|
||||
|
||||
// StatisticsAfsOrderInfo 售后单信息统计
|
||||
func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int) ([]*StatisticsOrder, error) {
|
||||
sql := `SELECT count(a.vendor_order_id) count,a.status status ,sum(a.afs_total_shop_money) total_shop_money FROM afs_order a WHERE a.afs_created_at >= ? AND a.afs_created_at <= ? `
|
||||
parma := []interface{}{startTime, endTime}
|
||||
func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId []int) ([]*StatisticsOrder, error) {
|
||||
parma := []interface{}{}
|
||||
sql := `SELECT count(a.vendor_order_id) count,a.status status ,sum(a.afs_total_shop_money) total_shop_money FROM afs_order a `
|
||||
|
||||
if len(brandId) > model.NO {
|
||||
sql += ` INNER JOIN store s ON IF(a.store_id <> 0,a.store_id,a.jx_store_id) = s.id AND s.brand_id IN (` + GenQuestionMarks(len(brandId)) + `)`
|
||||
parma = append(parma, brandId)
|
||||
}
|
||||
sql += ` WHERE a.afs_created_at >= ? AND a.afs_created_at <= ?`
|
||||
parma = append(parma, startTime, endTime)
|
||||
|
||||
if storeId != model.NO {
|
||||
sql += ` AND IF(a.store_id <> 0,a.store_id,a.jx_store_id) = 100743`
|
||||
sql += ` AND IF(a.store_id <> 0,a.store_id,a.jx_store_id) = ?`
|
||||
parma = append(parma, storeId)
|
||||
}
|
||||
|
||||
if len(vendorId) > 0 {
|
||||
sql += ` AND a.vendor_id IN (` + GenQuestionMarks(len(vendorId)) + `)`
|
||||
parma = append(parma, vendorId)
|
||||
}
|
||||
|
||||
sql += ` GROUP BY a.status`
|
||||
orderStatistics := make([]*StatisticsOrder, 0, 0)
|
||||
if err := GetRows(GetDB(), &orderStatistics, sql, parma...); err != nil {
|
||||
|
||||
@@ -117,12 +117,14 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
|
||||
riderInfo, err = handlerInfo.Handler.GetRiderInfo(v.VendorOrderID, 0, v.VendorWaybillID)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("Get Order waybill rider info err FN/DADA/SFPS :%v", err)
|
||||
continue
|
||||
}
|
||||
} else if v.WaybillVendorID == model.VendorIDMTPS {
|
||||
if v.VendorWaybillID != "" {
|
||||
riderInfo, err = handlerInfo.Handler.GetRiderInfo(v.VendorOrderID, v.ID+1000000, v.VendorWaybillID)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("Get Order waybill rider info err MT:%v", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -326,8 +328,7 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *utils.RiderInfo) {
|
||||
|
||||
waybill2, err := cms.GetSToURidingDistance2(jxutils.IntCoordinate2Standard(storeDetail.Lng), jxutils.IntCoordinate2Standard(storeDetail.Lat), jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), fakeWayBill.VendorOrderID)
|
||||
if err != nil {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "高德地图骑行方案获取错误:", utils.Format4Output(err.Error(), false))
|
||||
return
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "百度地图骑行方案获取错误:", utils.Format4Output(err.Error(), false))
|
||||
}
|
||||
courierCoordinate := strings.Split(waybill2.CourierCoordinate, ",")
|
||||
if len(courierCoordinate) < 2 && fakeWayBill.Status < model.WaybillStatusDelivered {
|
||||
|
||||
@@ -281,7 +281,7 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo
|
||||
}
|
||||
|
||||
func (d DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, resonContent string) (err error) {
|
||||
return nil
|
||||
return fmt.Errorf("顺丰暂未实现投诉")
|
||||
}
|
||||
|
||||
// GetDeliverLiquidatedDamages 获取取消运单违约金
|
||||
|
||||
@@ -927,7 +927,7 @@ func (c *PurchaseHandler) OrderLogisticsStatus(orderId string) (*utils.RiderInfo
|
||||
}
|
||||
|
||||
// 获取骑手坐标最后一个
|
||||
lng, lat, _ := api.GetDeliveryPath(utils.Str2Int64(orderId), orderInfo.VendorOrderID)
|
||||
lng, lat, _ := api.GetDeliveryPath(utils.Str2Int64(orderId), orderInfo.VendorStoreID)
|
||||
status.Longitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(int(lng)))
|
||||
status.Latitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(int(lat)))
|
||||
return status, nil
|
||||
|
||||
@@ -66,6 +66,8 @@ func (c *PurchaseHandler) OnAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma
|
||||
func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwmapi.CallbackResponse) {
|
||||
var err error
|
||||
orderStatus := c.callbackAfsMsg2Status(msg)
|
||||
globals.SugarLogger.Debugf("=================msg := %s", utils.Format4Output(msg, false))
|
||||
globals.SugarLogger.Debugf("=================orderStatus := %s", utils.Format4Output(orderStatus, false))
|
||||
needCallNew := orderStatus.Status == model.AfsOrderStatusWait4Approve || orderStatus.Status == model.AfsOrderStatusNew
|
||||
if !needCallNew {
|
||||
_, err := partner.CurOrderManager.LoadAfsOrder(orderStatus.VendorOrderID, orderStatus.VendorID)
|
||||
@@ -146,6 +148,8 @@ func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma
|
||||
if orderStatus.Status == model.AfsOrderStatusFinished {
|
||||
afsOrder.AfsFinishedAt = afsOrder.AfsCreatedAt
|
||||
}
|
||||
globals.SugarLogger.Debugf("afsOrder=============== : %s", utils.Format4Output(afsOrder, false))
|
||||
globals.SugarLogger.Debugf("orderStatus=============== : %s", utils.Format4Output(orderStatus, false))
|
||||
err = partner.CurOrderManager.OnAfsOrderNew(afsOrder, orderStatus)
|
||||
}
|
||||
} else {
|
||||
@@ -183,7 +187,7 @@ func (c *PurchaseHandler) callbackAfsMsg2Status(msg *mtwmapi.CallbackMsg) (order
|
||||
OrderType: model.OrderTypeAfsOrder,
|
||||
RefVendorOrderID: utils.Int64ToStr(refundData.OrderID),
|
||||
RefVendorID: model.VendorIDMTWM,
|
||||
VendorStatus: fmt.Sprintf("%s:%d", refundData.NotifyType, refundData.ResType),
|
||||
VendorStatus: refundData.Status, // fmt.Sprintf("%s:%d", refundData.NotifyType, refundData.ResType),
|
||||
Status: c.GetAfsStatusFromVendorStatus(refundData.ResType, refundData.NotifyType),
|
||||
StatusTime: utils.Timestamp2Time(refundData.Timestamp),
|
||||
Remark: refundData.Reason,
|
||||
@@ -193,10 +197,22 @@ func (c *PurchaseHandler) callbackAfsMsg2Status(msg *mtwmapi.CallbackMsg) (order
|
||||
} else {
|
||||
orderStatus.VendorOrderID = orderStatus.RefVendorOrderID
|
||||
}
|
||||
if refundData.NotifyType == "" && refundData.ResType == model.NO {
|
||||
orderStatus.VendorStatus = "用户申请退货且退款"
|
||||
}
|
||||
// 1-已申请 10-初审已同意 11-初审已驳回 16-初审已申诉 17-初审申诉已同意 18-初审申诉已驳回 20-终审已发起(用户已发货) 21-终审已同意 22-终审已驳回 26-终审已申诉 27-终审申诉已同意 28-终审申诉已驳回 30-已取消
|
||||
if refundData.Status == "21" {
|
||||
orderStatus.Status = model.AfsOrderStatusFinished
|
||||
orderStatus.VendorStatus += "," + refundData.Status
|
||||
}
|
||||
return orderStatus
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetAfsStatusFromVendorStatus(resType int, notifyType string) int {
|
||||
// 当resType为0且notifyType为空的时候,是退货退款,之前是未处理这个,现在退货退款默认成退款未处理
|
||||
if notifyType == "" {
|
||||
notifyType = mtwmapi.NotifyTypeApply
|
||||
}
|
||||
status := AfsVendorStatus2StatusMap[notifyType]
|
||||
if status == model.AfsOrderStatusWait4Approve && resType != mtwmapi.ResTypePending {
|
||||
status = model.AfsOrderStatusNew
|
||||
|
||||
@@ -3,6 +3,8 @@ package tao_vegetable
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -249,7 +251,7 @@ func PushDelivererChangeInfo(order *model.GoodsOrder, bill *model.Waybill, deliv
|
||||
LogisticsNo: utils.String2Pointer(bill.VendorWaybillID),
|
||||
},
|
||||
}
|
||||
return getAPI(order.VendorOrgCode, 0, "").DelivererChange(param)
|
||||
return getAPI(order.VendorOrgCode, order.JxStoreID, order.VendorStoreID).DelivererChange(param)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetOrder(vendorOrgCode, vendorOrderID, vendorStoreID string) (order *model.GoodsOrder, err error) {
|
||||
@@ -498,24 +500,25 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
|
||||
|
||||
// PickupGoods 拣货
|
||||
func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) {
|
||||
var err2 error
|
||||
if isSelfDelivery {
|
||||
param, err := orderStatusChangeNotice(order, tao_vegetable.OrderStatusPickedUp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
api := getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "")
|
||||
err = api.DeliveryFinish(param)
|
||||
if err != nil && strings.Contains(err.Error(), "并发操作,执行失败,请重试") {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
err2 = api.DeliveryFinish(param)
|
||||
} else if err != nil {
|
||||
return err
|
||||
for i := 0; i < 3; i++ {
|
||||
err2 := api.DeliveryFinish(param)
|
||||
if err2 != nil {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
err = err2
|
||||
continue
|
||||
}
|
||||
if err2 == nil {
|
||||
c.postFakeMsg(order.VendorOrderID, tao_vegetable.OrderStatusPickedUp, tao_vegetable.OrderStatusPickedUp)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil && err2 != nil {
|
||||
c.postFakeMsg(order.VendorOrderID, tao_vegetable.OrderStatusPickedUp, tao_vegetable.OrderStatusPickedUp)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -579,7 +582,36 @@ func (c *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userNam
|
||||
// SelfDeliverDelivered 自配送订单送达
|
||||
func (c *PurchaseHandler) SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
param := OrderStatusChangeDelivery(order, tao_vegetable.OrderStatusDeliveryOver)
|
||||
return getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").DeliveryFinish(param)
|
||||
api := getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "")
|
||||
err = api.DeliveryFinish(param)
|
||||
// 这个是因为自动拣货失败出现订单状态为更新,无法设置送达
|
||||
if err != nil && strings.Contains(err.Error(), "当前状态不允许更新") {
|
||||
errMap := make(map[string]interface{}, 0)
|
||||
|
||||
pickupErr := c.PickupGoods(order, true, userName) // 自动拣货
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
deliverErr := c.Swtich2SelfDeliver(order, userName) // 出库
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
deliveringErr := c.SelfDeliverDelivering(order, userName) // 配送中
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
deliveredErr := c.Swtich2SelfDelivered(order, userName) // 送达
|
||||
if pickupErr != nil {
|
||||
errMap["pickupErr"] = pickupErr
|
||||
}
|
||||
if deliverErr != nil {
|
||||
errMap["deliverErr"] = deliverErr
|
||||
}
|
||||
if deliveringErr != nil {
|
||||
errMap["deliveringErr"] = deliveringErr
|
||||
}
|
||||
if deliveredErr != nil {
|
||||
errMap["deliveredErr"] = deliveredErr
|
||||
}
|
||||
if len(errMap) > 0 {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "淘宝订单拣货异常,导致设置送达错误:", utils.Format4Output(errMap, false))
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *model.GoodsOrder) (mobile string, err error) {
|
||||
|
||||
@@ -484,16 +484,24 @@ func (c *OrderController) GetStoresOrderSaleInfo() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param fromTime query string true "起始时间"
|
||||
// @Param toTime query string true "结束时间"
|
||||
// @Param storeIDs query int false "门店id"
|
||||
// @Param brandIds query string false "品牌id"
|
||||
// @Param vendorIds query string false "平台id"
|
||||
// @Param storeID query int false "门店id"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /StaleIndexInfo [get]
|
||||
func (c *OrderController) StaleIndexInfo() {
|
||||
c.callStaleIndexInfo(func(params *tOrderStaleIndexInfoParams) (retVal interface{}, code string, err error) {
|
||||
timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime)
|
||||
if err == nil {
|
||||
retVal, err = orderman.FixedOrderManager.GetStoresOrderSaleInfo2(params.Ctx, timeList[0], timeList[1], params.StoreIDs)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
var vendors []int
|
||||
var brandIds []int
|
||||
if err := jxutils.Strings2Objs(params.VendorIds, &vendors, params.BrandIds, &brandIds); err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
retVal, err = orderman.FixedOrderManager.GetStoresOrderSaleInfo2(params.Ctx, timeList[0], timeList[1], params.StoreID, brandIds, vendors)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -69,28 +69,23 @@ func (a *APIManager) GetAPI(vendorID int, appOrgCode string) (pfAPI interface{})
|
||||
}
|
||||
case model.VendorIDTaoVegetable:
|
||||
api := api.TaoVegetableApi
|
||||
if beego.BConfig.RunMode == "dev" {
|
||||
api.SetToken("50002C00414zMSClqLiSDjBr2N19748391yiazjtFmsgTOdbBftik0XDfkUQywSmcjfC")
|
||||
} else if api == nil || api.GetToken() == "" {
|
||||
codes, _ := dao.GetVendorOrgCode(db, vendorID, appOrgCode, "platform")
|
||||
if len(codes) == 0 {
|
||||
codes, _ := dao.GetVendorOrgCode(db, vendorID, appOrgCode, "platform")
|
||||
if len(codes) == 0 {
|
||||
return nil
|
||||
}
|
||||
code := codes[0]
|
||||
api = tao_vegetable.NewTaoVegetable(code.AppKey, code.AppSecret, beego.AppConfig.DefaultString("taoVegetableServerUrl", ""))
|
||||
if code.Token != "" {
|
||||
var tokenInfo *tao_vegetable.StoreTokenInfo
|
||||
if err := json.Unmarshal([]byte(code.Token), &tokenInfo); err != nil {
|
||||
return nil
|
||||
}
|
||||
code := codes[0]
|
||||
api = tao_vegetable.NewTaoVegetable(code.AppKey, code.AppSecret, beego.AppConfig.DefaultString("taoVegetableServerUrl", ""))
|
||||
if code.Token != "" {
|
||||
var tokenInfo *tao_vegetable.StoreTokenInfo
|
||||
if err := json.Unmarshal([]byte(code.Token), &tokenInfo); err != nil {
|
||||
return nil
|
||||
}
|
||||
if tokenInfo.AccessToken != "" && tokenInfo.ExpireTime > time.Now().UnixNano()/1e6 {
|
||||
api.SetToken(tokenInfo.AccessToken)
|
||||
} else {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "DDC5657B43EE11E9A9FF525400E86DC0", "淘鲜达token过期", ",请重新授权")
|
||||
}
|
||||
if tokenInfo.AccessToken != "" && tokenInfo.ExpireTime > time.Now().UnixNano()/1e6 {
|
||||
api.SetToken(tokenInfo.AccessToken)
|
||||
} else {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "DDC5657B43EE11E9A9FF525400E86DC0", "淘鲜达token过期", ",请重新授权")
|
||||
}
|
||||
}
|
||||
|
||||
pfAPI = api
|
||||
case model.VendorIDEBAI:
|
||||
pfAPI = api.EbaiAPI
|
||||
|
||||
Reference in New Issue
Block a user