From 9b3beb0dc0405a6b8e5f0f05a3f9cdf640a53e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 24 Dec 2020 16:20:20 +0800 Subject: [PATCH] tx --- business/jxstore/cms/cms.go | 1 + business/jxstore/cms/job.go | 33 +++++++++++++++++++++++++-- business/model/job.go | 45 +++++++++++++++++++++++++------------ conf/app.conf | 5 ++++- globals/api/api.go | 5 ++++- 5 files changed, 71 insertions(+), 18 deletions(-) diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index 666fab889..0765b9b2e 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -95,6 +95,7 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) { "deliveryStatusName": model.DeliveryStatusName, "cashbackName": model.CashbackName, "consumeName": model.ConsumeName, + "txWaybillNames": model.TxWaybillNames, }, } } diff --git a/business/jxstore/cms/job.go b/business/jxstore/cms/job.go index 7387b2ec8..bfeef6dd8 100644 --- a/business/jxstore/cms/job.go +++ b/business/jxstore/cms/job.go @@ -8,6 +8,8 @@ import ( "sync" "time" + "git.rosy.net.cn/baseapi/platformapi/txcloudapi" + "git.rosy.net.cn/jx-callback/business/jxutils/ddmsg" "git.rosy.net.cn/baseapi/platformapi/dingdingapi" @@ -1163,8 +1165,35 @@ func GetDeliveryDetail(ctx *jxcontext.Context, vendorWaybillID string) (queryDyn return api.JdEclpAPI.QueryDynamicTraceInfo(vendorWaybillID) } -func GetAllDeliveryDetail(ctx *jxcontext.Context, vendorWaybillID, comType string) (a string, err error) { - return a, err +func GetAllDeliveryDetail(ctx *jxcontext.Context, vendorWaybillID, comType string) (result interface{}, err error) { + var ( + db = dao.GetDB() + ) + jobOrder := &model.JobOrder{ + VendorWaybillID: vendorWaybillID, + } + err = dao.GetEntity(db, jobOrder, "VendorWaybillID") + if jobOrder == nil { + return result, fmt.Errorf("运单号有误,无法查询!") + } + if jobOrder.WaybillStatus == model.OrderStatusFinished { + return jobOrder.WaybillInfo, err + } + if jobOrder.WaybillQueryTime != utils.ZeroTimeValue { + if time.Now().Sub(jobOrder.WaybillQueryTime) <= time.Hour*12 { + return jobOrder.WaybillInfo, err + } + } + getWaybillDetailInfoResult, err := api.TxAPI.GetWaybillDetailInfo(vendorWaybillID, comType) + jobOrder.WaybillQueryTime = time.Now() + if waybillInfo, err := json.Marshal(getWaybillDetailInfoResult); err == nil { + jobOrder.WaybillInfo = string(waybillInfo) + } + if getWaybillDetailInfoResult.State == utils.Int2Str(txcloudapi.StatusFinished) { + jobOrder.WaybillStatus = model.OrderStatusFinished + } + dao.UpdateEntity(db, jobOrder, "WaybillQueryTime", "WaybillInfo", "WaybillStatus") + return result, err } func CheckJdDeliveryWeight(ctx *jxcontext.Context) (err error) { diff --git a/business/model/job.go b/business/model/job.go index 9932a17e3..d7cf2dd67 100644 --- a/business/model/job.go +++ b/business/model/job.go @@ -1,6 +1,10 @@ package model -import "time" +import ( + "time" + + "git.rosy.net.cn/baseapi/platformapi/txcloudapi" +) const ( JobStatusDoing = 0 //正在进行中 @@ -70,6 +74,17 @@ var ( ConsumeTypeMember: "充会员", ConsumeTypeDelivery: "发快递", } + + TxWaybillNames = map[int]string{ + txcloudapi.StatusErr: "单号或代码错误", + txcloudapi.StatusNull: "暂无轨迹", + txcloudapi.StatusAccept: "快递收件", + txcloudapi.StatusDelivering: "在途中", + txcloudapi.StatusFinished: "已签收", + txcloudapi.StatusProblem: "问题件 (派件不成功或要求择日派送)", + txcloudapi.StatusException: "疑难件(收件人拒绝签收,地址有误或不能送达派送区域,收费等原因无法正常派送)", + txcloudapi.StatusFailed: "退件签收", + } ) type Job struct { @@ -179,19 +194,21 @@ type JobOrder struct { Comment string `json:"comment"` //审核理由 UserActualPrice int `json:"userActualPrice"` //用户订单实际支付(用户自填) - DropShippingCount int `json:"dropShippingCount"` //一件代发购买商品数量 - DropShippingDeliveryID int `orm:"column(drop_shipping_delivery_id)" json:"dropShippingDeliveryID"` - DropShippingName string `json:"dropShippingName"` - DropShippingMobile string `json:"dropShippingMobile"` - DropShippingAddress string `json:"dropShippingAddress"` - DropShippingDetailAddress string `json:"dropShippingDetailAddress"` - DropShippingLng float64 `json:"dropShippingLng"` - DropShippingLat float64 `json:"dropShippingLat"` - DropShippingAutoAddress string `json:"dropShippingAutoAddress"` - DropShippingCityCode int `json:"dropShippingCityCode"` - DropShippingDistrictCode int `json:"dropShippingDistrictCode"` - VendorWaybillID string `json:"vendorWaybillID"` //运单号 - WaybillInfo string `orm:"type(text)" json:"waybillInfo"` //物流信息 + DropShippingCount int `json:"dropShippingCount"` //一件代发购买商品数量 + DropShippingDeliveryID int `orm:"column(drop_shipping_delivery_id)" json:"dropShippingDeliveryID"` + DropShippingName string `json:"dropShippingName"` + DropShippingMobile string `json:"dropShippingMobile"` + DropShippingAddress string `json:"dropShippingAddress"` + DropShippingDetailAddress string `json:"dropShippingDetailAddress"` + DropShippingLng float64 `json:"dropShippingLng"` + DropShippingLat float64 `json:"dropShippingLat"` + DropShippingAutoAddress string `json:"dropShippingAutoAddress"` + DropShippingCityCode int `json:"dropShippingCityCode"` + DropShippingDistrictCode int `json:"dropShippingDistrictCode"` + VendorWaybillID string `json:"vendorWaybillID"` //运单号 + WaybillInfo string `orm:"type(text)" json:"waybillInfo"` //物流信息 + WaybillQueryTime time.Time `json:"waybillQueryTime"` //上次查询时间 + WaybillStatus int `json:"waybillStatus"` //运单状态(一件代发) } func (v *JobOrder) TableIndex() [][]string { diff --git a/conf/app.conf b/conf/app.conf index 259b49397..d240453f5 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -289,4 +289,7 @@ pushMasterSecret= "dGZcR0XGGg7H5Pd7FR3n47" ejyPlatName = "1Zbve" ejyBeforeKey = "htvse3XEDhBnCTNo" -ejyAfterKey = "QM5RnGl6kNh3ENLT" \ No newline at end of file +ejyAfterKey = "QM5RnGl6kNh3ENLT" + +txCloudSecretID = "AKIDFNmm1U7vhITlVItry0ng5Q268lGjDZyQUR6" +txCloudSecretKey = "25p3aynr97hOMJEfpvr0LoXD0gI62l7wcHA7nsM6" \ No newline at end of file diff --git a/globals/api/api.go b/globals/api/api.go index 27aaa3afd..17307e6e5 100644 --- a/globals/api/api.go +++ b/globals/api/api.go @@ -4,6 +4,8 @@ import ( "io/ioutil" "time" + "git.rosy.net.cn/baseapi/platformapi/txcloudapi" + "git.rosy.net.cn/baseapi/platformapi/ejyapi" "git.rosy.net.cn/baseapi/platformapi/mtmemberapi" @@ -79,6 +81,7 @@ var ( WeixinPageAPI *weixinapi.API // 用户微信扫码登录 AliPayAPI *alipayapi.API + TxAPI *txcloudapi.API AutonaviAPI *autonavi.API BaiDuNaviAPI *baidunavi.API @@ -241,7 +244,7 @@ func Init() { ShowAPI = showapi.New(beego.AppConfig.DefaultInt("showAppID", 0), beego.AppConfig.DefaultString("showAppSecret", "")) Cacher = redis.New(beego.AppConfig.DefaultString("redisHost", "localhost"), beego.AppConfig.DefaultInt("redisPort", 0), beego.AppConfig.DefaultString("redisPassword", "")) AliUpcAPI = aliupcapi.New(beego.AppConfig.String("aliUpcAppCode")) - + TxAPI = txcloudapi.New(beego.AppConfig.String("txCloudSecretID"), beego.AppConfig.String("txCloudSecretKey")) DingDingAPI = dingdingapi.NewWithAgentID(beego.AppConfig.DefaultInt64("dingdingAgentID", 0), beego.AppConfig.DefaultString("dingdingCorpID", ""), beego.AppConfig.DefaultString("dingdingAppKey", ""), beego.AppConfig.DefaultString("dingdingSecret", "")) DingDingQRCodeAPI = dingdingapi.New(beego.AppConfig.DefaultString("dingdingCorpID", ""), beego.AppConfig.DefaultString("dingdingQRCodeAppKey", ""), beego.AppConfig.DefaultString("dingdingQRCodeSecret", ""))