1
This commit is contained in:
@@ -2,10 +2,11 @@ package basesch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
@@ -382,9 +383,9 @@ func (c *BaseScheduler) CheckStoreBalanceWithTip(ctx *jxcontext.Context, order *
|
||||
if roundTipFee != tipFee {
|
||||
return model.ErrCodeOnePayTipFeeMore, fmt.Errorf("小费必须是1元的整数倍")
|
||||
}
|
||||
//if order.WaybillTipMoney >= tipFee {
|
||||
// return model.ErrCodeOnePayTipFeeMore, fmt.Errorf("本次小费金额不能小于已经支付的小费")
|
||||
//}
|
||||
if order.WaybillTipMoney >= tipFee {
|
||||
return model.ErrCodeOnePayTipFeeMore, fmt.Errorf("本次小费金额不能小于已经支付的小费")
|
||||
}
|
||||
if order.CreateDeliveryType == model.YES {
|
||||
//加小费只判断余额
|
||||
storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order))
|
||||
|
||||
@@ -950,7 +950,7 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
||||
if err == nil && err2 == nil {
|
||||
// 1.检查门店三方配送配置,达达>蜂鸟>美团>顺丰>uu
|
||||
// excludeVendorIDs 包括上面已经发送的平台id
|
||||
storeCourierList, _ := dao.GetStoreCourierList2(dao.GetDB(), []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, model.StoreStatusOpened, []int{model.StoreAuditStatusOnline, model.StoreAuditStatusUpdated})
|
||||
storeCourierList, err := dao.GetStoreCourierList2(dao.GetDB(), []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, model.StoreStatusOpened, []int{model.StoreAuditStatusOnline, model.StoreAuditStatusUpdated})
|
||||
excludeVendorIDsMap := make(map[int]int, 0) // 被排除的配送
|
||||
for _, v := range excludeVendorIDs {
|
||||
excludeVendorIDsMap[v] = model.YES
|
||||
@@ -989,17 +989,9 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
||||
}
|
||||
|
||||
if vendorID != model.NO {
|
||||
if bills, err := s.CreateWaybillOnProviders4SavedOrder(jxcontext.AdminCtx, savedOrderInfo, nil, excludeVendorIDs, false, maxDeliveryFee); err == nil {
|
||||
for _, v := range bills {
|
||||
if v.DesiredFee >= model.AlarmFee {
|
||||
s.CancelWaybill(v, 0, partner.CancelWaybillReasonStrDeliveryFeeUp)
|
||||
partner.CurOrderManager.OnOrderMsg(order, utils.Int2Str(vendorID), fmt.Sprintf("发起自动创建三方运单,目标创建运单平台[%s],创建失败:%s", jxutils.GetVendorName(vendorID), partner.CancelWaybillReasonStrDeliveryFeeUp))
|
||||
} else {
|
||||
savedOrderInfo.retryCount++
|
||||
partner.CurOrderManager.OnOrderMsg(order, utils.Int2Str(vendorID), fmt.Sprintf("订单自动创建三方运单成功:%s", jxutils.GetVendorName(vendorID)))
|
||||
|
||||
}
|
||||
}
|
||||
if _, err = s.CreateWaybillOnProviders4SavedOrder(jxcontext.AdminCtx, savedOrderInfo, nil, excludeVendorIDs, false, maxDeliveryFee); err == nil {
|
||||
savedOrderInfo.retryCount++
|
||||
partner.CurOrderManager.OnOrderMsg(order, utils.Int2Str(vendorID), fmt.Sprintf("订单自动创建三方运单成功:%s", jxutils.GetVendorName(vendorID)))
|
||||
} else {
|
||||
partner.CurOrderManager.OnOrderMsg(order, utils.Int2Str(vendorID), fmt.Sprintf("发起自动创建三方运单,目标创建运单平台[%s],创建失败:%v", jxutils.GetVendorName(vendorID), err))
|
||||
}
|
||||
|
||||
@@ -2,12 +2,13 @@ package defsch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"math"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||
@@ -287,16 +288,6 @@ func (s *DefScheduler) CreateWaybillOnProvidersEx(ctx *jxcontext.Context, vendor
|
||||
return nil, errCode, err
|
||||
}
|
||||
}
|
||||
excludeCourierVendorIDs := make([]int, 0, 0)
|
||||
allDelivery := map[int]int{model.VendorIDFengNiao: 1, model.VendorIDDada: 1, model.VendorIDMTPS: 1, model.VendorIDUUPT: 1, model.VendorIDSFPS: 1}
|
||||
for _, v := range courierVendorIDs {
|
||||
if allDelivery[v] == model.YES {
|
||||
delete(allDelivery, v)
|
||||
}
|
||||
}
|
||||
for k, _ := range allDelivery {
|
||||
excludeCourierVendorIDs = append(excludeCourierVendorIDs, k)
|
||||
}
|
||||
|
||||
billFunc := func() {
|
||||
bills, err = func() (bills []*model.Waybill, err error) {
|
||||
@@ -322,7 +313,7 @@ func (s *DefScheduler) CreateWaybillOnProvidersEx(ctx *jxcontext.Context, vendor
|
||||
order.DeliveryFlag = 0
|
||||
err = partner.CurOrderManager.UpdateOrderStatusAndDeliveryFlag(order)
|
||||
// 创建订单
|
||||
if bills, err = s.CreateWaybillOnProviders4SavedOrder(ctx, savedOrderInfo, courierVendorIDs, excludeCourierVendorIDs, forceCreate, maxDeliveryFee); err == nil && len(bills) > 0 {
|
||||
if bills, err = s.CreateWaybillOnProviders4SavedOrder(ctx, savedOrderInfo, courierVendorIDs, nil, forceCreate, maxDeliveryFee); err == nil && len(bills) > 0 {
|
||||
partner.CurOrderManager.OnOrderMsg(order, "手动创建运单成功", fmt.Sprintf("%s创建%s平台运单,强发:%t,最高限价:%d", ctx.GetUserName(), model.VendorChineseNames[bills[0].WaybillVendorID], forceCreate, maxDeliveryFee))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -794,14 +794,12 @@ func CreateActForMtByOrder(ctx *jxcontext.Context, act *model.Act, vendorIDs []i
|
||||
ActPrice: jxutils.IntPrice2Standard(int64(v.JdsPrice)),
|
||||
})
|
||||
}
|
||||
//sort.Slice(actData, func(i, j int) bool {
|
||||
// return actData[i].ActPrice < actData[j].ActPrice
|
||||
//})
|
||||
sort.Slice(actData, func(i, j int) bool {
|
||||
return actData[i].ActPrice < actData[j].ActPrice
|
||||
})
|
||||
//for i := 1; i <= len(actData); i++ {
|
||||
// actData[i-1].Sequence = i
|
||||
//}
|
||||
|
||||
actIdResult := make(map[string]int64, 0)
|
||||
actResult, faileInfoList, _ := api.MtwmAPI.RetailDiscountBatchSave2(storeDetail.VendorStoreID, mtwmapi.RetailActTypeDirectDown, actData)
|
||||
for _, v := range actResult {
|
||||
var (
|
||||
@@ -815,27 +813,7 @@ func CreateActForMtByOrder(ctx *jxcontext.Context, act *model.Act, vendorIDs []i
|
||||
actStoreSkuMapUpdate.VendorActID = utils.Int64ToStr(v.ActID)
|
||||
dao.UpdateEntity(db, actStoreSkuMapUpdate, "VendorActID")
|
||||
}
|
||||
actIdResult[v.AppFoodCode] = v.ActID
|
||||
}
|
||||
|
||||
// RetailDiscountBatchSave2 创建时无法使用排序,只能更时排序生效所以这样写,美团恢复可以删除
|
||||
actData2 := make([]*mtwmapi.RetailDiscountActData, 0, 0)
|
||||
if len(actIdResult) != model.NO {
|
||||
for _, v := range actData {
|
||||
if actIdResult[v.AppFoodCode] != model.NO {
|
||||
v.ItemID = actIdResult[v.AppFoodCode]
|
||||
}
|
||||
actData2 = append(actData2, v)
|
||||
}
|
||||
sort.Slice(actData2, func(i, j int) bool {
|
||||
return actData2[i].ActPrice < actData2[j].ActPrice
|
||||
})
|
||||
for i := 1; i <= len(actData2); i++ {
|
||||
actData2[i-1].Sequence = i
|
||||
}
|
||||
api.MtwmAPI.RetailDiscountBatchSave2(storeDetail.VendorStoreID, mtwmapi.RetailActTypeDirectDown, actData2)
|
||||
}
|
||||
|
||||
for _, v := range faileInfoList {
|
||||
err2 += fmt.Sprintf("创建失败!门店ID:[%v],商品ID:[%v],原因:[%v]", storeID, v.AppFoodCode, v.ErrorMsg)
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -137,7 +138,7 @@ type GoodsOrder struct {
|
||||
ExpectedDeliveredTime time.Time `orm:"type(datetime)" json:"expectedDeliveredTime"` // 预期送达时间
|
||||
CancelApplyReason string `orm:"size(255)" json:"-"` // ""表示没有申请,不为null表示用户正在取消申请
|
||||
DeliveryType string `orm:"size(32)" json:"deliveryType"` // 订单配送方式,缺省是平台配送
|
||||
CreateDeliveryType int `orm:"default(0)" json:"createDeliveryType"` // 默认0系统发单,1为门店发单
|
||||
CreateDeliveryType int `orm:"default(0)" json:"createDeliveryType"` //默认0系统发单,1为门店发单
|
||||
VendorWaybillID string `orm:"column(vendor_waybill_id);size(48)" json:"vendorWaybillID"` // 运单id
|
||||
WaybillVendorID int `orm:"column(waybill_vendor_id)" json:"waybillVendorID"` // 表示当前承运商,-1表示还没有安排
|
||||
AdjustCount int8 `json:"adjustCount"` // 调整单(次数)
|
||||
|
||||
@@ -3,10 +3,11 @@ package dada
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
tao "git.rosy.net.cn/baseapi/platformapi/tao_vegetable"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/tao_vegetable"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -394,7 +395,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if result == nil {
|
||||
return nil, errors.New("达达配送,平台调用错误,无订单数据返回")
|
||||
}
|
||||
|
||||
@@ -21,9 +21,6 @@ const (
|
||||
)
|
||||
|
||||
func CallCreateWaybillPolicy(deliveryFee, maxDeliveryFee int64, order *model.GoodsOrder, waybillVendorID int) (err error) {
|
||||
if maxDeliveryFee != model.NO {
|
||||
return nil
|
||||
}
|
||||
if maxDeliveryFee <= model.DefMaxDeliveryFee {
|
||||
maxDeliveryFee = model.DefMaxDeliveryFee
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
|
||||
return deliveryFeeInfo, err
|
||||
}
|
||||
|
||||
// CreateWaybill (美团配送)
|
||||
// CreateWaybill(美团配送)
|
||||
func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||
db := dao.GetDB()
|
||||
// 检查配送平台是否被禁用
|
||||
@@ -331,6 +331,17 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debugf("===================maxDeliveryFee := %d", maxDeliveryFee)
|
||||
if maxDeliveryFee == model.NO {
|
||||
fee, err := c.GetWaybillFee(order)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fee.DeliveryFee >= model.DefMaxDeliveryFee {
|
||||
return nil, fmt.Errorf("美团配送超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(fee.DeliveryFee), jxutils.IntPrice2StandardCurrencyString(model.DefMaxDeliveryFee))
|
||||
}
|
||||
}
|
||||
|
||||
// 忽略坐标转换错误,即使是转换出错,也只能当成转换成功来处理,底层会有错误日志输出
|
||||
lngFloat, latFloat, _ := jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
billParams := &mtpsapi.CreateOrderByShopParam{
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -450,57 +452,6 @@ func SetJxMsgRead(appID, vendorStoreID, vendorID, userID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DelRedisByKey 清除redis数据
|
||||
func DelRedisByKey(keys []string) {
|
||||
var errList errlist.ErrList
|
||||
for _, key := range keys {
|
||||
err := rdb.Del(key)
|
||||
if err != nil {
|
||||
errList.AddErr(err)
|
||||
}
|
||||
}
|
||||
if errList.GetErrListAsOne() != nil {
|
||||
globals.SugarLogger.Debugf("DelRedisByKey err=%v", errList.GetErrListAsOne())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var rel = map[int]string{
|
||||
589: "a81eb3df418d83d6a1a4b7c572156d2f",
|
||||
5873: "41c479790a76f86326f89e8048964739",
|
||||
4123: "df2c88338b85f830cebce2a9eab56628",
|
||||
}
|
||||
|
||||
// DecryptIm 解密操作
|
||||
func DecryptIm(appID int, msg string) (string, error) {
|
||||
data, _ := base64.StdEncoding.DecodeString(msg)
|
||||
key := utils.LimitUTF8StringLen2(rel[appID], 16)
|
||||
res, err := utils.AESCBCDecpryt(data, []byte(key), []byte(key))
|
||||
if len(string(res)) > 0 && err == nil {
|
||||
return string(res), nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
//加密操作
|
||||
|
||||
// FilterIm 过滤操作
|
||||
func FilterIm(appID int, msg string) bool {
|
||||
var check = "[自动回复]"
|
||||
data, _ := DecryptIm(appID, msg)
|
||||
if len(data) > 0 && strings.Contains(data, check) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// RandTimeNumber 生成int类型 随机数+时间戳
|
||||
func RandTimeNumber() int {
|
||||
num, _ := rand.Int(rand.Reader, big.NewInt(100000))
|
||||
str := utils.Int64ToStr(num.Int64()) + utils.Int2Str(int(time.Now().Unix()))
|
||||
return utils.Str2Int(str)
|
||||
}
|
||||
|
||||
// AutoReply 是否已回复
|
||||
//key=AppID+:+UserID+:+msgID(mt)
|
||||
//key=AppID+:+UserID+:+msgID(elm)
|
||||
@@ -514,26 +465,23 @@ type AutoReply struct {
|
||||
// CheckAndReply 判断并回复
|
||||
func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
|
||||
var (
|
||||
flag = false
|
||||
errList errlist.ErrList
|
||||
key string
|
||||
flag = false
|
||||
vendorID int
|
||||
errList errlist.ErrList
|
||||
apply AutoReply
|
||||
jxMsg = &JXMsg{}
|
||||
userList = &UserMessageList{}
|
||||
)
|
||||
if req.SendType == SendTypeMt {
|
||||
vendorID = VendorIDMT
|
||||
mt := req.MsgContent.(mtwmapi.PushContentReq)
|
||||
key := utils.Int2Str(mt.AppID) + ":" + utils.Int2Str(mt.OpenUserID) + ":autoReply"
|
||||
key = utils.Int2Str(mt.AppID) + ":" + utils.Int2Str(mt.OpenUserID) + ":autoReply"
|
||||
//1 检测是否已自动回复
|
||||
if n, err := rdb.Exists(key); n > 0 && err == nil {
|
||||
str := rdb.LRange(key)
|
||||
for i := 0; i < len(str); i++ {
|
||||
v := AutoReply{}
|
||||
if err = json.Unmarshal([]byte(str[i]), &v); err == nil {
|
||||
flag = v.IsApply
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flag = GetIfReply(key)
|
||||
//判断flag状态
|
||||
if !flag {
|
||||
apply := AutoReply{
|
||||
apply = AutoReply{
|
||||
UserID: mt.AppID,
|
||||
MsgID: mt.MsgID,
|
||||
IsApply: true,
|
||||
@@ -542,10 +490,13 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
|
||||
|
||||
temp := mt
|
||||
//获取自定义回复模板
|
||||
if template := GetCustomTemplate(utils.Int2Str(mt.AppID), mt.AppPoiCode); len(template) != 0 {
|
||||
if template := GetCustomTemplate(utils.Int2Str(mt.AppID), mt.AppPoiCode); len(template) > 0 {
|
||||
temp.MsgContent = template
|
||||
} else {
|
||||
temp.MsgContent = AutoReplyByAppID[mt.AppID]
|
||||
temp.MsgContent, err = GetDefaultTemplate(utils.Int2Str(mt.AppID), mt.AppPoiCode, VendorIDMT)
|
||||
if err != nil {
|
||||
temp.MsgContent = AutoReplyByAppID[mt.AppID]
|
||||
}
|
||||
}
|
||||
temp.MsgSource = mtwmapi.MsgSourceStore
|
||||
temp.Cts = int(time.Now().Unix())
|
||||
@@ -556,47 +507,120 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
|
||||
apply.IsApply = false
|
||||
globals.SugarLogger.Debugf("CheckAndReply mtSend err:%v", err)
|
||||
} else {
|
||||
jxMsg := &JXMsg{
|
||||
jxMsg = &JXMsg{
|
||||
SendType: SendTypeJx,
|
||||
MsgContent: temp,
|
||||
}
|
||||
userList := &UserMessageList{
|
||||
userList = &UserMessageList{
|
||||
VendorID: VendorIDMT,
|
||||
UserID: utils.Int2Str(mt.OpenUserID),
|
||||
LatestMsg: mt.MsgContent,
|
||||
LatestTime: mt.Cts,
|
||||
OrderID: "",
|
||||
}
|
||||
//1 存储详细聊天记录list
|
||||
if err = SetMessageDetail(jxMsg, VendorIDMT, elmAppID); err != nil {
|
||||
errList.AddErr(fmt.Errorf("存储详细聊天记录错误:%v", err))
|
||||
}
|
||||
//2 存储展示列表时单条数据
|
||||
if err = SetUserList(jxMsg, userList, VendorIDMT, elmAppID); err != nil {
|
||||
errList.AddErr(fmt.Errorf("存储STU聊天记录错误:%v", err))
|
||||
}
|
||||
}
|
||||
|
||||
//记录自动回复状态
|
||||
data, _ := json.Marshal(apply)
|
||||
err := rdb.RPush(key, string(data))
|
||||
ok, err := rdb.ExpireResult(key, ExpireTimeDay)
|
||||
if err != nil || !ok {
|
||||
globals.SugarLogger.Debugf("CheckAndReply apply err:%v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if req.SendType == SendTypeElm {
|
||||
//
|
||||
//}
|
||||
if req.SendType == SendTypeElm {
|
||||
vendorID = VendorIDELM
|
||||
elm := req.MsgContent.(ebaiapi.ImMessageSend)
|
||||
key = elmAppID + ":" + elm.PayLoad.SenderID + ":autoReply"
|
||||
|
||||
//1 检测是否已自动回复
|
||||
flag = GetIfReply(key)
|
||||
if !flag {
|
||||
apply = AutoReply{
|
||||
UserID: utils.Str2Int(elm.PayLoad.SenderID),
|
||||
MsgID: utils.Str2Int(elm.PayLoad.MsgID),
|
||||
IsApply: true,
|
||||
Timestamp: elm.PayLoad.CreateTime,
|
||||
}
|
||||
|
||||
temp := &ebaiapi.BusinessSendMsgReq{
|
||||
PlatformShopId: elm.PlatformShopID,
|
||||
BizType: ebaiapi.IMType,
|
||||
SubBizType: ebaiapi.IMTypeSendMsg,
|
||||
Payload: ebaiapi.BusinessMsgPayload{
|
||||
GroupId: elm.PayLoad.GroupID,
|
||||
MsgId: utils.Int2Str(RandTimeNumber()),
|
||||
ReceiverIds: elm.PayLoad.ReceiverIDs,
|
||||
ContentType: utils.Int2Str(ebaiapi.ContentTypeNormal),
|
||||
},
|
||||
}
|
||||
if template := GetCustomTemplate(elmAppID, elm.PlatformShopID); len(template) > 0 {
|
||||
temp.Payload.Content = template
|
||||
} else {
|
||||
temp.Payload.Content, err = GetDefaultTemplate(elmAppID, elm.PlatformShopID, VendorIDELM)
|
||||
if err != nil {
|
||||
temp.Payload.Content = LastTemplate
|
||||
}
|
||||
}
|
||||
|
||||
if err = partner.CurAPIManager.GetAPI(model.VendorIDEBAI, elmAppID).(*ebaiapi.API).BusinessSendMsg(temp); err != nil {
|
||||
apply.IsApply = false
|
||||
globals.SugarLogger.Debugf("CheckAndReply mtSend err:%v", err)
|
||||
} else {
|
||||
jxMsg = &JXMsg{
|
||||
SendType: SendTypeJx,
|
||||
MsgContent: temp,
|
||||
}
|
||||
userList = &UserMessageList{
|
||||
VendorID: VendorIDMT,
|
||||
UserID: elm.PayLoad.SenderID,
|
||||
LatestMsg: elm.PayLoad.Content,
|
||||
LatestTime: elm.PayLoad.CreateTime,
|
||||
OrderID: "",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//1 存储详细聊天记录list
|
||||
if err = SetMessageDetail(jxMsg, vendorID, elmAppID); err != nil {
|
||||
errList.AddErr(fmt.Errorf("自动回复:存储详细聊天记录错误:%v", err))
|
||||
}
|
||||
//2 存储展示列表时单条数据
|
||||
if err = SetUserList(jxMsg, userList, vendorID, elmAppID); err != nil {
|
||||
errList.AddErr(fmt.Errorf("自动回复:存储STU聊天记录错误:%v", err))
|
||||
}
|
||||
//3 记录自动回复状态
|
||||
if err = RecordAutoStatus(key, apply); err != nil {
|
||||
errList.AddErr(fmt.Errorf("自动回复:记录自动回复状态错误:%v", err))
|
||||
}
|
||||
if errList.GetErrListAsOne() != nil {
|
||||
return fmt.Errorf("CheckAndReply err=%v", errList.GetErrListAsOne())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetIfReply 检查是否已回复
|
||||
func GetIfReply(key string) (flag bool) {
|
||||
flag = false
|
||||
if n, err := rdb.Exists(key); n > 0 && err == nil {
|
||||
str := rdb.LRange(key)
|
||||
for i := 0; i < len(str); i++ {
|
||||
v := AutoReply{}
|
||||
if err = json.Unmarshal([]byte(str[i]), &v); err == nil {
|
||||
flag = v.IsApply
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag
|
||||
}
|
||||
|
||||
// RecordAutoStatus 记录是否已自动回复状态
|
||||
func RecordAutoStatus(key string, apply AutoReply) error {
|
||||
data, _ := json.Marshal(apply)
|
||||
err := rdb.RPush(key, string(data))
|
||||
ok, err := rdb.ExpireResult(key, ExpireTimeDay)
|
||||
if err != nil || !ok {
|
||||
globals.SugarLogger.Debugf("CheckAndReply apply err:%v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GenCustomReplyID 生成门店自动回复模板ID
|
||||
func GenCustomReplyID(appID, vendorStoreID string) string {
|
||||
return BaseCusKey + ":" + appID + ":" + vendorStoreID
|
||||
@@ -625,5 +649,97 @@ func AddCustomReply(appID, vendorStoreID, replyTemplate string) (storeTemplate s
|
||||
err = rdb.Set(key, replyTemplate, 0)
|
||||
}
|
||||
return "", err
|
||||
|
||||
}
|
||||
|
||||
// GetDefaultTemplate 获取门店默认回复模板
|
||||
func GetDefaultTemplate(appID, vendorStoreID string, vendorID int) (string, error) {
|
||||
var (
|
||||
phoneNum = " "
|
||||
t string
|
||||
)
|
||||
store, err := dao.GetStoreDetail2(dao.GetDB(), 0, vendorStoreID, vendorID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(store.Tel1) > 0 {
|
||||
t = store.Tel1
|
||||
}
|
||||
if len(store.Tel1) == 0 && len(store.Tel2) == 0 {
|
||||
t = BasePhoneNum
|
||||
}
|
||||
phoneNum = t[:3] + "-" + t[3:7] + "-" + t[7:]
|
||||
temp := BaseTemplate + phoneNum
|
||||
|
||||
if vendorID == VendorIDMT {
|
||||
data, err := EncryptIm(utils.Str2Int(appID), temp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
if vendorID == VendorIDELM {
|
||||
return temp, nil
|
||||
}
|
||||
|
||||
return "", nil
|
||||
}
|
||||
|
||||
/************************工具函数*/
|
||||
|
||||
// DelRedisByKey 清除redis数据
|
||||
func DelRedisByKey(keys []string) {
|
||||
var errList errlist.ErrList
|
||||
for _, key := range keys {
|
||||
err := rdb.Del(key)
|
||||
if err != nil {
|
||||
errList.AddErr(err)
|
||||
}
|
||||
}
|
||||
if errList.GetErrListAsOne() != nil {
|
||||
globals.SugarLogger.Debugf("DelRedisByKey err=%v", errList.GetErrListAsOne())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var rel = map[int]string{
|
||||
589: "a81eb3df418d83d6a1a4b7c572156d2f",
|
||||
5873: "41c479790a76f86326f89e8048964739",
|
||||
4123: "df2c88338b85f830cebce2a9eab56628",
|
||||
}
|
||||
|
||||
// DecryptIm 解密操作
|
||||
func DecryptIm(appID int, msg string) (string, error) {
|
||||
data, _ := base64.StdEncoding.DecodeString(msg)
|
||||
key := utils.LimitUTF8StringLen2(rel[appID], 16)
|
||||
res, err := utils.AESCBCDecpryt(data, []byte(key), []byte(key))
|
||||
if len(string(res)) > 0 && err == nil {
|
||||
return string(res), nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
// EncryptIm 加密操作
|
||||
func EncryptIm(appID int, msg string) (retVal string, err error) {
|
||||
key := utils.LimitUTF8StringLen2(rel[appID], 16)
|
||||
if data, err := utils.AESCBCEncpryt([]byte(msg), []byte(key), []byte(key)); err == nil {
|
||||
retVal = base64.StdEncoding.EncodeToString(data)
|
||||
}
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
// FilterIm 过滤操作
|
||||
func FilterIm(appID int, msg string) bool {
|
||||
var check = "[自动回复]"
|
||||
data, _ := DecryptIm(appID, msg)
|
||||
if len(data) > 0 && strings.Contains(data, check) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// RandTimeNumber 生成int类型 随机数+时间戳
|
||||
func RandTimeNumber() int {
|
||||
num, _ := rand.Int(rand.Reader, big.NewInt(100000))
|
||||
str := utils.Int64ToStr(num.Int64()) + utils.Int2Str(int(time.Now().Unix()))
|
||||
return utils.Str2Int(str)
|
||||
}
|
||||
|
||||
@@ -75,7 +75,6 @@ var (
|
||||
CancelWaybillReasonStrActive = "操作由人员主动发起"
|
||||
CancelWaybillReasonNotInStoreOpenTime = "不在门店的营业时间范围内"
|
||||
CancelWaybillReasonStrDYPSCancel = "抖音门店转自送,取消自动运力"
|
||||
CancelWaybillReasonStrDeliveryFeeUp = "配送距离太远,配送费超过15元"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -796,7 +796,7 @@ func (c *PurchaseHandler) ConfirmSelfTake(ctx *jxcontext.Context, order *model.G
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) ComplaintRider(vendorOrderId string, resonID int, resonContent string) (err error) {
|
||||
return fmt.Errorf("饿了么暂无投诉骑手,请联系饿了么客服")
|
||||
return fmt.Errorf("饿了么暂无投诉骑手API")
|
||||
}
|
||||
|
||||
// 转自配送时取消非专送混合送门店取消理由
|
||||
|
||||
@@ -311,7 +311,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, vendorOrgCode strin
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) ComplaintRider(vendorOrderId string, resonID int, resonContent string) (err error) {
|
||||
return fmt.Errorf("暂无投诉渠道,请致电京东客服")
|
||||
return err
|
||||
}
|
||||
|
||||
// 转自配送时取消非专送混合送门店取消理由
|
||||
|
||||
@@ -537,7 +537,7 @@ func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bo
|
||||
|
||||
// 美团专送、快送、混合送、美团企客
|
||||
logisticsCode := utils.Interface2String(orderDetail["logistics_code"])
|
||||
isSelfDelivery = logisticsCode == mtwmapi.PeiSongTypeMTZSJM || logisticsCode == mtwmapi.PeiSongTypeMTZSZJ || logisticsCode == mtwmapi.PeiSongTypeKuaiDi || logisticsCode == mtwmapi.PeiSongTypeMixed || logisticsCode == mtwmapi.PeiSongTypeQiKe || logisticsCode == mtwmapi.PeiSongTypeMixedExpressQiKe
|
||||
isSelfDelivery = logisticsCode == mtwmapi.PeiSongTypeMTZSJM || logisticsCode == mtwmapi.PeiSongTypeMTZSZJ || logisticsCode == mtwmapi.PeiSongTypeKuaiDi || logisticsCode == mtwmapi.PeiSongTypeMixed || logisticsCode == mtwmapi.PeiSongTypeQiKe
|
||||
//1001-专送(加盟);1002-专送(自建)
|
||||
//2002-快送;3001-混合送(专送+快送)
|
||||
//4015-企客远距离配送
|
||||
@@ -554,7 +554,6 @@ func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bo
|
||||
//PeiSongTypeKuaiDi = "2002" // 快送
|
||||
//PeiSongTypeWholeCity = "2010" // 全城送
|
||||
//PeiSongTypeMixed = "3001" // 混合送(即美团专送+快送)
|
||||
//PeiSongTypeMixedExpressQiKe = "30012002" // 混合送(混合快送)
|
||||
if isSelfDelivery {
|
||||
err = api.PreparationMealComplete(utils.Str2Int64(order.VendorOrderID))
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@ package tiktok_store
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/ascription_place"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/ascription_place"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
|
||||
order_getSettleBillDetailV3_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_getSettleBillDetailV3/request"
|
||||
order_logisticsAdd_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_logisticsAdd/request"
|
||||
order_orderDetail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/response"
|
||||
@@ -990,7 +991,7 @@ func (c *PurchaseHandler) ConfirmSelfTake(ctx *jxcontext.Context, order *model.G
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) ComplaintRider(vendorOrderId string, resonID int, resonContent string) (err error) {
|
||||
return fmt.Errorf("抖店暂不提供投诉骑手API,联系客服")
|
||||
return fmt.Errorf("抖店暂不提供投诉骑手API")
|
||||
}
|
||||
|
||||
// GetCancelDeliveryReason 转自配送时取消非专送混合送门店取消理由
|
||||
|
||||
@@ -3,6 +3,12 @@ package controllers
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -12,11 +18,6 @@ import (
|
||||
taoVegetable "git.rosy.net.cn/jx-callback/business/partner/purchase/tao_vegetable"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/astaxie/beego/server/web"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type TaoBaoVegetableController struct {
|
||||
@@ -224,19 +225,10 @@ func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() {
|
||||
return
|
||||
}
|
||||
default:
|
||||
//callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusOnSaleCancel, utils.Int64ToStr(afsOrder.PartCancelRequest.BizOrderId), afsOrder)
|
||||
//c.Data["json"] = callbackResponse
|
||||
order, err := partner.CurOrderManager.LoadOrder(utils.Int64ToStr(afsOrder.PartCancelRequest.BizOrderId), model.VendorIDTaoVegetable)
|
||||
if err != nil {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultOnSaleCancel(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
if order.Status == model.OrderStatusCanceled {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultOnSaleCancel(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
if order.Status >= model.OrderStatusDelivering {
|
||||
if err != nil || order.Status >= model.OrderStatusDelivering {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultOnSaleCancel(fmt.Errorf("不支持售中取消"))
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
|
||||
@@ -295,9 +295,9 @@ func Init() {
|
||||
QiniuAPI = qbox.NewMac(beego.AppConfig.DefaultString("qiniuAK", ""), beego.AppConfig.DefaultString("qiniuSK", ""))
|
||||
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", ""))
|
||||
//Cacher = redis.New(beego.AppConfig.DefaultString("redisHost", "localhost"), beego.AppConfig.DefaultInt("redisPort", 0), beego.AppConfig.DefaultString("redisPassword", ""))
|
||||
//Todo 本地测试用
|
||||
//Cacher = redis.New(beego.AppConfig.DefaultString("redisHost", "127.0.0.1"), beego.AppConfig.DefaultInt("redisPort", 6379), beego.AppConfig.DefaultString("redisPassword", "123456"))
|
||||
Cacher = redis.New(beego.AppConfig.DefaultString("redisHost", "127.0.0.1"), beego.AppConfig.DefaultInt("redisPort", 6379), beego.AppConfig.DefaultString("redisPassword", "123456"))
|
||||
|
||||
AliUpcAPI = aliupcapi.New(beego.AppConfig.DefaultString("aliUpcAppCode", ""))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user