1
This commit is contained in:
@@ -4667,7 +4667,10 @@ func RefreshTiktokShopToken(ctx *jxcontext.Context) (err error) {
|
||||
v.UpdatedAt = time.Now()
|
||||
v.StoreBrandName = "定时任务更新"
|
||||
dao.UpdateEntity(db, v, "Token", "UpdatedAt", "StoreBrandName")
|
||||
tiktok_store.HttpToGuoYuan(utils.Struct2MapByJson(v), tiktok_store.CaiShiPushGyTagToken, model.ServerTypeFruits)
|
||||
if v.VendorOrgCode == "68023619" {
|
||||
// 抖音目前只有菜市和百货
|
||||
tiktok_store.HttpToGuoYuan(utils.Struct2MapByJson(v), tiktok_store.CaiShiPushGyTagToken, model.ServerTypePet)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,6 @@ func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, printSn, orderSeq, msg
|
||||
|
||||
func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, id1, id2 string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
tmpStatus, err := api.JxPrintAPI.GetPrinterStatus(id1)
|
||||
globals.SugarLogger.Debugf("--------id1 := %s", id1)
|
||||
globals.SugarLogger.Debugf("--------tmpStatus := %d", tmpStatus)
|
||||
globals.SugarLogger.Debugf("--------err := %v", err)
|
||||
if err == nil {
|
||||
printerStatus = &partner.PrinterStatus{
|
||||
PrinterStatus: int(tmpStatus),
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -25,6 +24,8 @@ const (
|
||||
CaiShiPushGyTagWayBill = "waybill" // 配送
|
||||
)
|
||||
|
||||
var TiktokVendorStoreID = make(map[string]string, 0)
|
||||
|
||||
// OnOrderMsg 抖音
|
||||
func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackResponse) {
|
||||
if CurPurchaseHandler != nil {
|
||||
@@ -38,13 +39,11 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes
|
||||
}
|
||||
vendorStoreID := orderDetail.SkuOrderList[0].StoreInfo.StoreId
|
||||
|
||||
if vendorStoreID != "" {
|
||||
storeDetail, err := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), vendorStoreID, model.VendorIDDD, "")
|
||||
if err != nil || storeDetail == nil || storeDetail.Store.ID == 0 {
|
||||
if _, ok := TiktokVendorStoreID[vendorStoreID]; !ok {
|
||||
storeDetail, _ := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), vendorStoreID, model.VendorIDDD, "")
|
||||
if storeDetail == nil || storeDetail.Store.ID == 0 {
|
||||
gyMsg := map[string]interface{}{"tag": msgId, "msg_id": utils.Int64ToStr(time.Now().Unix()) + msgId, "data": msg}
|
||||
switch beego.BConfig.RunMode {
|
||||
case model.ServerTypeFruits:
|
||||
// 当前订单所属门店不属于菜市时,将消息推送到果园
|
||||
if shopId == 68023619 {
|
||||
gyResult, err := HttpToGuoYuan(gyMsg, CaiShiPushGyTagOrder, model.ServerTypePet)
|
||||
if err != nil {
|
||||
return tiktokShop.Err2CallbackResponse(err, "")
|
||||
@@ -55,21 +54,37 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes
|
||||
return tiktokShop.Err2CallbackResponse(err2, "")
|
||||
}
|
||||
return guoYuan
|
||||
case model.ServerTypeVegetable:
|
||||
// 当前订单所属门店不属于菜市时,将消息推送到果园
|
||||
gyResult, err := HttpToGuoYuan(gyMsg, CaiShiPushGyTagOrder, model.ServerTypeFruits)
|
||||
if err != nil {
|
||||
return tiktokShop.Err2CallbackResponse(err, "")
|
||||
}
|
||||
result, _ := ioutil.ReadAll(gyResult.Body)
|
||||
var guoYuan *tiktokShop.CallbackResponse
|
||||
if err2 := json.Unmarshal(result, guoYuan); err2 != nil {
|
||||
return tiktokShop.Err2CallbackResponse(err2, "")
|
||||
}
|
||||
return guoYuan
|
||||
case model.ServerTypePet:
|
||||
return nil
|
||||
}
|
||||
//switch beego.BConfig.RunMode {
|
||||
//case model.ServerTypeFruits:
|
||||
// // 当前订单所属门店不属于菜市时,将消息推送到果园
|
||||
// gyResult, err := HttpToGuoYuan(gyMsg, CaiShiPushGyTagOrder, model.ServerTypePet)
|
||||
// if err != nil {
|
||||
// return tiktokShop.Err2CallbackResponse(err, "")
|
||||
// }
|
||||
// result, _ := ioutil.ReadAll(gyResult.Body)
|
||||
// var guoYuan *tiktokShop.CallbackResponse
|
||||
// if err2 := json.Unmarshal(result, guoYuan); err2 != nil {
|
||||
// return tiktokShop.Err2CallbackResponse(err2, "")
|
||||
// }
|
||||
// return guoYuan
|
||||
//case model.ServerTypeVegetable:
|
||||
// // 当前订单所属门店不属于菜市时,将消息推送到果园
|
||||
// gyResult, err := HttpToGuoYuan(gyMsg, CaiShiPushGyTagOrder, model.ServerTypeFruits)
|
||||
// if err != nil {
|
||||
// return tiktokShop.Err2CallbackResponse(err, "")
|
||||
// }
|
||||
// result, _ := ioutil.ReadAll(gyResult.Body)
|
||||
// var guoYuan *tiktokShop.CallbackResponse
|
||||
// if err2 := json.Unmarshal(result, guoYuan); err2 != nil {
|
||||
// return tiktokShop.Err2CallbackResponse(err2, "")
|
||||
// }
|
||||
// return guoYuan
|
||||
//case model.ServerTypePet:
|
||||
// return nil
|
||||
//}
|
||||
} else {
|
||||
TiktokVendorStoreID[vendorStoreID] = "1"
|
||||
}
|
||||
}
|
||||
jxutils.CallMsgHandler(func() {
|
||||
@@ -133,9 +148,13 @@ func HttpToGuoYuan(param map[string]interface{}, requestType string, serverType
|
||||
}
|
||||
|
||||
httpReq.Header.Set("Content-Type", "application/json")
|
||||
//httpReq.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
httpReq.Header.Set("accept", "application/json, text/plain, */*")
|
||||
|
||||
httpRes, err := http.DefaultClient.Do(httpReq)
|
||||
defer httpRes.Body.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return httpRes, err
|
||||
}
|
||||
|
||||
@@ -58,27 +58,35 @@ func (c *LogisticsController) LogisticsRegister() {
|
||||
return
|
||||
}
|
||||
// 查询订单的运单是否存在
|
||||
data, err := dao.GetWayBillsByWayBillId(dao.GetDB(), register.TrackNo)
|
||||
data, _ := dao.GetWayBillsByWayBillId(dao.GetDB(), register.TrackNo)
|
||||
|
||||
// 此订单可能是果园订单
|
||||
if len(data) == 0 || err != nil {
|
||||
if len(data) == 0 {
|
||||
var resp *http.Response
|
||||
var err error
|
||||
switch web.BConfig.RunMode {
|
||||
case model.ServerTypeVegetable:
|
||||
resp, err = tiktok_store.HttpToGuoYuan(utils.Struct2Map(register, "", true), tiktok_store.CaiShiPushGyTagDeliveryRegister, model.ServerTypeFruits)
|
||||
if err != nil {
|
||||
c.Data["json"] = LogisticsQueryRestMsg("单号不存在", "1002")
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
case model.ServerTypeFruits:
|
||||
//resp, err = tiktok_store.HttpToGuoYuan(utils.Struct2Map(register, "", true), tiktok_store.CaiShiPushGyTagDeliveryRegister, model.ServerTypeFruits)
|
||||
//if err != nil {
|
||||
// c.Data["json"] = LogisticsQueryRestMsg("单号不存在", "1002")
|
||||
// c.ServeJSON()
|
||||
// return
|
||||
//}
|
||||
|
||||
// 抖音只推送百货
|
||||
resp, err = tiktok_store.HttpToGuoYuan(utils.Struct2Map(register, "", true), tiktok_store.CaiShiPushGyTagDeliveryRegister, model.ServerTypePet)
|
||||
if err != nil {
|
||||
c.Data["json"] = LogisticsQueryRestMsg("单号不存在", "1002")
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
case model.ServerTypeFruits:
|
||||
//resp, err = tiktok_store.HttpToGuoYuan(utils.Struct2Map(register, "", true), tiktok_store.CaiShiPushGyTagDeliveryRegister, model.ServerTypePet)
|
||||
//if err != nil {
|
||||
// c.Data["json"] = LogisticsQueryRestMsg("单号不存在", "1002")
|
||||
// c.ServeJSON()
|
||||
// return
|
||||
//}
|
||||
}
|
||||
|
||||
gyData := &LogisticsRegisterResp{}
|
||||
@@ -173,7 +181,14 @@ func (c *LogisticsController) LogisticsQuery() {
|
||||
var err error
|
||||
switch web.BConfig.RunMode {
|
||||
case model.ServerTypeVegetable:
|
||||
resp, err = tiktok_store.HttpToGuoYuan(utils.Struct2Map(param, "", true), tiktok_store.CaiShiPushGyTagDeliveryDetail, model.ServerTypeFruits)
|
||||
//resp, err = tiktok_store.HttpToGuoYuan(utils.Struct2Map(param, "", true), tiktok_store.CaiShiPushGyTagDeliveryDetail, model.ServerTypeFruits)
|
||||
//if err != nil {
|
||||
// c.Data["json"] = LogisticsQueryRestMsg("运单账号不存在", "1002")
|
||||
// c.ServeJSON()
|
||||
// return
|
||||
//}
|
||||
// 抖音只推送百货
|
||||
resp, err = tiktok_store.HttpToGuoYuan(utils.Struct2Map(param, "", true), tiktok_store.CaiShiPushGyTagDeliveryDetail, model.ServerTypePet)
|
||||
if err != nil {
|
||||
c.Data["json"] = LogisticsQueryRestMsg("运单账号不存在", "1002")
|
||||
c.ServeJSON()
|
||||
|
||||
@@ -151,7 +151,7 @@ func (c *TiktokShopController) TokenMsg() {
|
||||
return
|
||||
}
|
||||
if param.VendorOrgCode == "68023619" {
|
||||
tiktok_store.HttpToGuoYuan(utils.Struct2Map(param, "", false), model.ServerTypePet, tiktok_store.CaiShiPushGyTagToken)
|
||||
tiktok_store.HttpToGuoYuan(utils.Struct2Map(param, "", false), tiktok_store.CaiShiPushGyTagToken, model.ServerTypePet)
|
||||
}
|
||||
|
||||
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackSuccessCode, Msg: tiktok_api.CallbackSuccess}
|
||||
|
||||
Reference in New Issue
Block a user