删除日志
This commit is contained in:
@@ -38,7 +38,6 @@ func (ctx *Context) GetTrackInfo() string {
|
||||
func (ctx *Context) GetRealRemoteIP() (ip string) {
|
||||
r := ctx.r
|
||||
if r != nil {
|
||||
// globals.SugarLogger.Debugf("GetRealRemoteIP header:%s", utils.Format4Output(r.Header, false))
|
||||
ip = r.Header.Get("X-Forwarded-For")
|
||||
if ip == "" {
|
||||
ip = r.Header.Get("X-real-ip")
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/alipayapi"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
@@ -28,7 +27,6 @@ func init() {
|
||||
}
|
||||
|
||||
func (a *Auther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
globals.SugarLogger.Debugf("VerifySecret dummy:%s, code:%s", dummy, code)
|
||||
tokenInfo, err := api.AliPayAPI.SystemAuthToken(alipayapi.GrantTypeCode, code, "")
|
||||
if err == nil {
|
||||
//userInfo, err2 := api.AliPayAPI.UserInfoShare(tokenInfo.AccessToken)
|
||||
|
||||
@@ -35,7 +35,6 @@ func (a *DefAuther) AddAuthBind(authBindEx *auth2.AuthBindEx, userName string) (
|
||||
}
|
||||
|
||||
func (a *DefAuther) UnbindAuth(userID, authType, authTypeID, userName string) (err error) {
|
||||
//globals.SugarLogger.Debugf("DefAuther.UnbindAuth userID:%s, authType:%s, GetAuthTypeID:%s, userName:%s", userID, authType, authTypeID, userName)
|
||||
condition := map[string]interface{}{
|
||||
"UserID": userID,
|
||||
"Type": authType,
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
@@ -22,7 +21,6 @@ func init() {
|
||||
}
|
||||
|
||||
func (a *QRCodeAuther) VerifySecret(dummy, code string) (*auth2.AuthBindEx, error) {
|
||||
globals.SugarLogger.Debugf("dingding qrcode VerifySecret code:%s", code)
|
||||
userQRInfo, err := api.DingDingQRCodeAPI.GetUserInfoByCode(code)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -35,7 +33,6 @@ func (a *QRCodeAuther) VerifySecret(dummy, code string) (*auth2.AuthBindEx, erro
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("dingding qrcode VerifySecret code:%s, userQRInfo:%s", code, utils.Format4Output(userQRInfo, false))
|
||||
authBindEx, err := a.UnionFindAuthBind(AuthTypeQRCode, api.DingDingQRCodeAPI.GetAppID(), []string{AuthTypeStaff, AuthTypeQRCode}, userQRInfo.OpenID, userQRInfo.UnionID, userQRInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
@@ -23,8 +22,6 @@ func init() {
|
||||
}
|
||||
|
||||
func (a *StaffAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
globals.SugarLogger.Debugf("dingding staff VerifySecret code:%s", code)
|
||||
|
||||
userID, err := api.DingDingAPI.GetUserID(code)
|
||||
if err == nil {
|
||||
userDetail, err2 := api.DingDingAPI.GetUserDetail(userID.UserID)
|
||||
|
||||
@@ -30,13 +30,11 @@ func init() {
|
||||
}
|
||||
|
||||
func (a *TiktopMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
globals.SugarLogger.Debugf("toktok mini VerifySecret jsCode:%s", code)
|
||||
appID, realCode := splitCode(code)
|
||||
sessionInfo, err := getTikTokApp(appID).GetTiktokOauth(realCode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debug("toktok mini VerifySecret sessionInfo:", sessionInfo)
|
||||
sessionKey := sessionInfo.Data.SessionKey
|
||||
if authBindEx, err = a.UnionFindAuthBind(AuthTypeTiktokMini, api.TiktokApi.GetAppID(), []string{AuthTypeTiktokMini}, sessionInfo.Data.OpenId, sessionInfo.Data.Unionid, sessionInfo); err == nil {
|
||||
authBindEx.UserData = sessionKey
|
||||
@@ -46,7 +44,6 @@ func (a *TiktopMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.A
|
||||
|
||||
// 特殊接口
|
||||
func (a *TiktopMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
|
||||
globals.SugarLogger.Debugf("weixin mini DecryptData jsCode:%s, encryptedData:%s, iv:%s", jsCode, encryptedData, iv)
|
||||
var sessionKey string
|
||||
appID, jsCode := weixin.SplitJsCode(jsCode)
|
||||
if jsCode != "" {
|
||||
@@ -106,6 +103,5 @@ func splitCode(code string) (appID, realCode string) {
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("splitCode abnormal code:%s", code)
|
||||
}
|
||||
globals.SugarLogger.Debug("dayin realCode", realCode)
|
||||
return appID, realCode
|
||||
}
|
||||
|
||||
@@ -68,8 +68,6 @@ func (a *Auther) SendVerifyCode(mobileNumber string) (verifyCode string, err err
|
||||
}
|
||||
|
||||
func (a *Auther) VerifySecret(mobileNumber, code string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
globals.SugarLogger.Debugf("VerifySecret mobileNumber:%s, code:%s", mobileNumber, code)
|
||||
|
||||
err = ErrVerifyCodeIsWrong
|
||||
if (code == auth2.InternalAuthSecret ||
|
||||
auth2.TestMobileMap[mobileNumber] == 1 && code == TestVerifyCode) ||
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -35,7 +34,6 @@ func init() {
|
||||
}
|
||||
|
||||
func (a *Auther) VerifySecret(userID, passMD5 string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
globals.SugarLogger.Debugf("localpass VerifySecret userID:%s", userID)
|
||||
var authBind *model.AuthBind
|
||||
if authBind, err = dao.GetAuthBind(dao.GetDB(), model.AuthBindTypeAuth, AuthType, userID); err == nil {
|
||||
if err = a.checkPassword(authBind, passMD5); err == nil {
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
@@ -57,7 +56,6 @@ func init() {
|
||||
}
|
||||
|
||||
func (a *Auther) VerifySecret(id, secret string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
globals.SugarLogger.Debugf("weixin VerifySecret id:%s secret:%s", id, secret)
|
||||
var openID, accessToken string
|
||||
_, jsCode := SplitJsCode(secret)
|
||||
if a.authType != AuthTypeWXNative {
|
||||
|
||||
@@ -34,8 +34,6 @@ func init() {
|
||||
}
|
||||
|
||||
func (a *MiniAuther) VerifySecret(dummy, jsCode string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
globals.SugarLogger.Debugf("weixin mini VerifySecret jsCode:%s", jsCode)
|
||||
|
||||
appID, jsCode := SplitJsCode(jsCode)
|
||||
sessionInfo, err := getWxApp(appID).SNSCode2Session(jsCode)
|
||||
if err == nil {
|
||||
@@ -50,7 +48,6 @@ func (a *MiniAuther) VerifySecret(dummy, jsCode string) (authBindEx *auth2.AuthB
|
||||
|
||||
// 特殊接口
|
||||
func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
|
||||
globals.SugarLogger.Debugf("weixin mini DecryptData jsCode:%s, encryptedData:%s, iv:%s", jsCode, encryptedData, iv)
|
||||
var sessionKey string
|
||||
appID, jsCode := SplitJsCode(jsCode)
|
||||
if jsCode != "" {
|
||||
|
||||
@@ -2,7 +2,6 @@ package casbinauth
|
||||
|
||||
import (
|
||||
jxmodel "git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego/client/orm"
|
||||
"github.com/casbin/casbin/model"
|
||||
"github.com/casbin/casbin/persist"
|
||||
@@ -93,7 +92,6 @@ func (a *Adapter) clearAll(o orm.Ormer) (err error) {
|
||||
|
||||
// SavePolicy saves policy to database.
|
||||
func (a *Adapter) SavePolicy(model model.Model) error {
|
||||
globals.SugarLogger.Debugf("SavePolicy")
|
||||
o := orm.NewOrm()
|
||||
|
||||
a.clearAll(o)
|
||||
|
||||
@@ -27,7 +27,6 @@ func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResp
|
||||
}
|
||||
|
||||
func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("onOrderMsg:%s", utils.Format4Output(msg, true))
|
||||
if msg.Event == weimobapi.MsgEventOrderStatusChange {
|
||||
if utils.ForceInterface2Int64(msg.MsgBody["orderStatus"]) == weimobapi.MsgOrderStatusFinished {
|
||||
if orderDetail, err := api.WeimobAPI.QueryOrderDetail2(msg.OrderNo, false); err == nil {
|
||||
@@ -35,7 +34,6 @@ func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackRespons
|
||||
changeStoreSkusByOrder(orderDetail)
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("onOrderMsg order:%s failed with err:%v", msg.OrderNo, err)
|
||||
response = weimobapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
}
|
||||
@@ -44,14 +42,12 @@ func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackRespons
|
||||
}
|
||||
|
||||
func changeStoreSkusByOrder(order *weimobapi.OrderDetail) {
|
||||
globals.SugarLogger.Debugf("changeStoreSkusByOrder order:%s", utils.Format4Output(order, true))
|
||||
receiverMobile := order.DeliveryDetail.LogisticsDeliveryDetail.ReceiverMobile
|
||||
ctx := jxcontext.NewWithUserName(nil, utils.LimitStringLen(utils.Int64ToStr(order.OrderNo), 32), nil, nil)
|
||||
if storeList, err := GetStoreList4Mobile(dao.GetDB(), []string{receiverMobile}); err == nil {
|
||||
if len(storeList) >= 1 {
|
||||
var skuBindInfos []*cms.StoreSkuBindInfo
|
||||
storeID := storeList[0].ID
|
||||
globals.SugarLogger.Debugf("changeStoreSkusByOrder storeID:%d", storeID)
|
||||
for _, v := range order.ItemList {
|
||||
nameID := int(utils.Str2Int64WithDefault(v.SkuCode, 0))
|
||||
unitPrice := v.CostPrice
|
||||
|
||||
@@ -31,7 +31,6 @@ func UpdateEnterpriseSuite(data *enterprise_wechat.SuiteTicketInfo) error {
|
||||
if data.SuiteTicket != "" && data.TimeStamp > 0 {
|
||||
EnterpriseSuite = data
|
||||
}
|
||||
globals.SugarLogger.Debug("修改数据库配置数据-》", data.SuiteTicket)
|
||||
// 修改数据库
|
||||
db := dao.GetDB()
|
||||
config := &legacymodel.Config{
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -166,7 +165,6 @@ func CheckBoosGroupChat(store *dao.StoreDetail2) ([]string, error) {
|
||||
for _, v := range userList {
|
||||
enterpriseId, err := api.EnterpriseChatHeadApi.GetUserIdByMobile(*v.Mobile)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("Get enterpriseId err ,maybe system mobile different with enterprise", err)
|
||||
continue
|
||||
}
|
||||
enterpriseList = append(enterpriseList, enterpriseId)
|
||||
|
||||
@@ -47,8 +47,6 @@ func (c *OrderManager) notifyNewFakeJdOrder(order *model.GoodsOrder) (err error)
|
||||
}
|
||||
|
||||
func notifyWxNewFakeJdOrder(order *model.GoodsOrder, storeID int) (err error) {
|
||||
globals.SugarLogger.Debugf("notifyWxNewFakeJdOrder orderID:%s", order.VendorOrderID)
|
||||
|
||||
sb := new(strings.Builder)
|
||||
sb.WriteString("老板,你有新订单了\n")
|
||||
sb.WriteString(fmt.Sprintf("订单号:%s\n", order.VendorOrderID))
|
||||
|
||||
@@ -54,7 +54,6 @@ func (c *OrderManager) SaveOrderFinancialInfo(order *model.OrderFinancial, opera
|
||||
for _, activity := range order.Discounts {
|
||||
if err = dao.CreateEntity(db, activity); err != nil {
|
||||
if !dao.IsDuplicateError(err) {
|
||||
globals.SugarLogger.Warnf("On SaveOrderDiscountFinancialInfo order.VendorOrderID:%s err: order is err", order.VendorOrderID)
|
||||
return err
|
||||
}
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -102,7 +101,6 @@ func (c *OrderManager) SaveOrderFinancialInfo(order *model.OrderFinancial, opera
|
||||
}
|
||||
if err = dao.CreateEntity(db, sku); err != nil {
|
||||
if !dao.IsDuplicateError(err) {
|
||||
globals.SugarLogger.Warnf("On SaveOrderSkuFinancialInfo order.VendorOrderID:%s err:%v", order.VendorOrderID, err)
|
||||
return err
|
||||
}
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -123,7 +121,6 @@ func (c *OrderManager) SaveOrderFinancialInfo(order *model.OrderFinancial, opera
|
||||
sku.JxShopMoney = order.JxShopMoney - sku.JxShopMoney
|
||||
if err = dao.CreateEntity(db, sku); err != nil {
|
||||
if !dao.IsDuplicateError(err) {
|
||||
globals.SugarLogger.Warnf("On SaveOrderSkuFinancialInfo order.VendorOrderID:%s err:%v", order.VendorOrderID, err)
|
||||
return err
|
||||
}
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -136,7 +133,6 @@ func (c *OrderManager) SaveOrderFinancialInfo(order *model.OrderFinancial, opera
|
||||
order.JxSubsidyMoney += order.JxSkuSubsidyMoney
|
||||
if err = dao.CreateEntity(db, order); err != nil {
|
||||
if !dao.IsDuplicateError(err) {
|
||||
globals.SugarLogger.Warnf("On SaveOrderFinancialInfo order.VendorOrderID:%s err: order is err", order.VendorOrderID)
|
||||
return err
|
||||
}
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -148,7 +144,6 @@ func (c *OrderManager) SaveOrderFinancialInfo(order *model.OrderFinancial, opera
|
||||
|
||||
// 处理售后订单结账信息
|
||||
func (c *OrderManager) SaveAfsOrderFinancialInfo(afsOrder *model.AfsOrder) (err error) {
|
||||
globals.SugarLogger.Debug(afsOrder.AfsOrderID)
|
||||
db := dao.GetDB()
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
@@ -165,7 +160,6 @@ func (c *OrderManager) SaveAfsOrderFinancialInfo(afsOrder *model.AfsOrder) (err
|
||||
// order.TotalMoney += order.SkuJxMoney // 退款单京西补贴部分先不作计算
|
||||
if err = dao.CreateEntity(db, afsOrder); err != nil {
|
||||
if !dao.IsDuplicateError(err) {
|
||||
globals.SugarLogger.Warnf("On SaveAfsOrderFinancialInfo afsOrder.AfsOrderID:%s err: SaveAfsOrder is err", afsOrder.AfsOrderID)
|
||||
return err
|
||||
}
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -179,7 +173,6 @@ func (c *OrderManager) SaveAfsOrderFinancialInfo(afsOrder *model.AfsOrder) (err
|
||||
afsOrder.Skus[0].RefundMoneyByCal += orderSku.RefundMoneyByCal
|
||||
if err = dao.CreateEntity(db, orderSku); err != nil {
|
||||
if !dao.IsDuplicateError(err) {
|
||||
globals.SugarLogger.Warnf("On SaveAfsOrderFinancialInfo afsOrder.AfsOrderID:%s err: SaveAfsOrderSku is err", afsOrder.AfsOrderID)
|
||||
return err
|
||||
}
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -251,7 +244,6 @@ func (c *OrderManager) UpdataOrderFinancialInfo(orderFinancial *model.OrderFinan
|
||||
}
|
||||
}
|
||||
if err = dao.CreateEntity(db, orderFinancial); err != nil {
|
||||
globals.SugarLogger.Warnf("On SaveOrderFinancialInfo err: order is err")
|
||||
return err
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
|
||||
@@ -51,7 +51,6 @@ type tSkuCountPrice struct {
|
||||
// msgVendorStatus的意思是事件本身的类型,类似有时收到NewOrder事件去取,订单状态不一定就是New的
|
||||
// OnOrderAdjust也类似,而OrderStatus要记录的是消息,所以添加这个
|
||||
func (c *OrderManager) OnOrderNew(order *model.GoodsOrder, orderStatus *model.OrderStatus) (err error) {
|
||||
globals.SugarLogger.Debugf("OnOrderNew orderID:%s", order.VendorOrderID)
|
||||
if order.ConsigneeMobile2 == "" && jxutils.IsStringLikeMobile(order.ConsigneeMobile) {
|
||||
order.ConsigneeMobile2 = order.ConsigneeMobile
|
||||
}
|
||||
@@ -59,7 +58,6 @@ func (c *OrderManager) OnOrderNew(order *model.GoodsOrder, orderStatus *model.Or
|
||||
db := dao.GetDB()
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
globals.SugarLogger.Debugf("OnOrderNew exit orderID:%s", order.VendorOrderID)
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
panic(r)
|
||||
@@ -91,7 +89,6 @@ func (c *OrderManager) OnOrderNew(order *model.GoodsOrder, orderStatus *model.Or
|
||||
|
||||
// todo 调整单的处理可能还需要再细化一点,当前只是简单的删除重建
|
||||
func (c *OrderManager) OnOrderAdjust(order *model.GoodsOrder, orderStatus *model.OrderStatus) (err error) {
|
||||
globals.SugarLogger.Debugf("OnOrderAdjust orderID:%s, status:%d", order.VendorOrderID, order.Status)
|
||||
if order.ConsigneeMobile2 == "" && jxutils.IsStringLikeMobile(order.ConsigneeMobile) {
|
||||
order.ConsigneeMobile2 = order.ConsigneeMobile
|
||||
}
|
||||
@@ -124,7 +121,6 @@ func (c *OrderManager) OnOrderAdjust(order *model.GoodsOrder, orderStatus *model
|
||||
VendorID: order.VendorID,
|
||||
}
|
||||
if err = dao.GetEntity(db, previousOrder, model.FieldVendorOrderID, model.FieldVendorID); err != nil && !dao.IsNoRowsError(err) {
|
||||
globals.SugarLogger.Warnf("OnOrderAdjust, order:%s GetEntity failed with error:%v", order.VendorOrderID, err)
|
||||
return err
|
||||
}
|
||||
if err == nil {
|
||||
@@ -313,7 +309,6 @@ func setFakeOrderFlag(db *dao.DaoDB, order *model.GoodsOrder) {
|
||||
}
|
||||
|
||||
func (c *OrderManager) SaveOrder(order *model.GoodsOrder, isAdjust bool, db *dao.DaoDB) (isDuplicated bool, err error) {
|
||||
globals.SugarLogger.Debugf("SaveOrder orderID:%s, VendorStoreID:%s, status:%d", order.VendorOrderID, order.VendorStoreID, order.Status)
|
||||
// 忽略美团超市的订单
|
||||
if order.VendorID == model.VendorIDMTWM {
|
||||
if order.VendorStoreID == "2391979" || order.VendorStoreID == "7379027" {
|
||||
@@ -462,7 +457,6 @@ func ResetCreateWaybillFee(db *dao.DaoDB, order *model.GoodsOrder) (err error) {
|
||||
// 获取运单记录
|
||||
orderStatusList, err := GetOrderStatusList2(order.VendorOrderID, order.VendorWaybillID, 2, order.WaybillVendorID)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("获取订单操作流程错误:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -483,19 +477,16 @@ func ResetCreateWaybillFee(db *dao.DaoDB, order *model.GoodsOrder) (err error) {
|
||||
}
|
||||
|
||||
if isRefund { // 骑手已经到店了,无法退款
|
||||
globals.SugarLogger.Debug("Refund Money Fail:", "骑手已到店,无法退款")
|
||||
return errors.New("骑手已到店,无法退款")
|
||||
}
|
||||
|
||||
// 获取品牌的支付记录
|
||||
orderBill, _ := dao.GetBrandBill(db, store.BrandID, order.VendorOrderID, 0, model.BrandBillFeeTypeDelivery, order.VendorWaybillID)
|
||||
if len(orderBill) <= 0 {
|
||||
globals.SugarLogger.Debug("Refund Money Fail:", "无记录,不退款")
|
||||
return errors.New("无记录,不退款")
|
||||
}
|
||||
for _, v := range orderBill {
|
||||
if v.BillType == model.BrandBillTypeIncome { // 已经退款了
|
||||
globals.SugarLogger.Debug("Refund Money Fail:", "同一订单无法重复退款")
|
||||
return errors.New("无法重复退款")
|
||||
}
|
||||
}
|
||||
@@ -557,7 +548,6 @@ func checkPriceDefendOrderByStock(db *dao.DaoDB, storeID, skuID, stock, jxPrice
|
||||
}
|
||||
|
||||
func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.DaoDB, storePayPercentage, changePriceType int) (err error) {
|
||||
globals.SugarLogger.Debugf("updateOrderSkuOtherInfo orderID:%s, VendorStoreID:%s", order.VendorOrderID, order.VendorStoreID)
|
||||
jxStoreID := jxutils.GetShowStoreIDFromOrder(order)
|
||||
var opNumStr string
|
||||
if time.Now().Sub(order.OrderCreatedAt) < 1*time.Hour && order.VendorID != model.VendorIDJD {
|
||||
@@ -586,7 +576,6 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
|
||||
}
|
||||
l, err := dao.GetStoreSkuPriceAndWeight(db, vendorStoreID, order.VendorID, vendorSkuIDs)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("updateOrderSkuOtherInfo orderID:%s failed with err:%v", order.VendorOrderID, err)
|
||||
return err
|
||||
}
|
||||
skumapper := storeSkuPriceAndWeight2Map(l)
|
||||
@@ -601,7 +590,6 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
|
||||
if v.ShopPrice == 0 {
|
||||
v.ShopPrice = v.SalePrice * 70 / 100
|
||||
}
|
||||
globals.SugarLogger.Infof("updateOrderSkuOtherInfo [运营%s]%s订单sku找不到门店价格(或商品映射),orderID:%s, StoreID:%d, VendorSkuID:%s, sku:%v", opNumStr, model.VendorChineseNames[order.VendorID], order.VendorOrderID, jxStoreID, v.VendorSkuID, v)
|
||||
} else {
|
||||
// TODO 客户端当前逻辑认为SkuID为0为赠品
|
||||
if v.SkuID == 0 {
|
||||
@@ -717,8 +705,6 @@ func updateSingleOrderEarningPrice(order *model.GoodsOrder, db *dao.DaoDB) {
|
||||
}
|
||||
|
||||
func (c *OrderManager) updateOrderOtherInfo(order *model.GoodsOrder, db *dao.DaoDB) (err error) {
|
||||
globals.SugarLogger.Debugf("updateOrderOtherInfo orderID:%s, VendorStoreID:%s", order.VendorOrderID, order.VendorStoreID)
|
||||
|
||||
payPercentage := 0
|
||||
changePriceType := model.StoreChangePriceTypeDirect
|
||||
var storeDetail *dao.StoreDetail
|
||||
@@ -729,7 +715,6 @@ func (c *OrderManager) updateOrderOtherInfo(order *model.GoodsOrder, db *dao.Dao
|
||||
}
|
||||
if err != nil {
|
||||
if !dao.IsNoRowsError(err) {
|
||||
globals.SugarLogger.Warnf("updateOrderOtherInfo GetStoreDetailByVendorStoreID orderID:%s, VendorStoreID:%s, error:%v", order.VendorOrderID, order.VendorStoreID, err)
|
||||
return err
|
||||
}
|
||||
if time.Now().Sub(order.OrderCreatedAt) < 1*time.Hour {
|
||||
@@ -775,7 +760,6 @@ func (c *OrderManager) updateOrderOtherInfo(order *model.GoodsOrder, db *dao.Dao
|
||||
// }
|
||||
|
||||
func (c *OrderManager) addOrderStatus(orderStatus *model.OrderStatus, db *dao.DaoDB) (isDuplicated bool, order *model.GoodsOrder, err error) {
|
||||
globals.SugarLogger.Debugf("addOrderStatus refOrderID:%s, orderID:%s", orderStatus.RefVendorOrderID, orderStatus.VendorOrderID)
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
@@ -885,7 +869,6 @@ func (c *OrderManager) loadOrder(vendorOrderID, vendorOrderID2 string, vendorID
|
||||
if err == orm.ErrNoRows {
|
||||
err = ErrCanNotFindOrder
|
||||
}
|
||||
globals.SugarLogger.Infof("LoadOrder orderID:%s failed with error:%v", vendorOrderID, err)
|
||||
}
|
||||
return order, err
|
||||
}
|
||||
@@ -936,7 +919,6 @@ func (c *OrderManager) loadOrderFinancial(vendorOrderID, vendorOrderID2 string,
|
||||
if err == orm.ErrNoRows {
|
||||
err = ErrCanNotFindOrder
|
||||
}
|
||||
globals.SugarLogger.Infof("LoadOrderFinancial orderID:%s failed with error:%v", vendorOrderID, err)
|
||||
}
|
||||
return order, err
|
||||
}
|
||||
@@ -1310,7 +1292,6 @@ func setJdsOrderSeq(order *model.GoodsOrder) (err error) {
|
||||
}
|
||||
|
||||
func MergeJdsOrders(ctx *jxcontext.Context, vendorOrderIDs []string) (vendorOrderIDJds string, err error) {
|
||||
globals.SugarLogger.Debugf("jds MergeJdsOrders vendorOrderIDs: %v", vendorOrderIDs)
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
orders []*model.GoodsOrder
|
||||
@@ -1461,7 +1442,6 @@ func MergeJdsOrders(ctx *jxcontext.Context, vendorOrderIDs []string) (vendorOrde
|
||||
}
|
||||
|
||||
func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int) (vendorOrderIDJds string, err error) {
|
||||
globals.SugarLogger.Debugf("jds TransferJdsOrder vendorOrderID: %v, storeID : %v", vendorOrderID, storeID)
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
waybill *model.Waybill
|
||||
@@ -2035,7 +2015,6 @@ func SaveJdsOrders(ctx *jxcontext.Context, orderCreatedStart, orderCreatedEnd ti
|
||||
}
|
||||
for _, order := range orders {
|
||||
partner.CurOrderManager.OnOrderNew(order, model.Order2Status(order))
|
||||
globals.SugarLogger.Debugf("SaveJdsOrders, order: [%v]", utils.Format4Output(order, false))
|
||||
noticeMsg := fmt.Sprintf("京东商城新订单,订单号:[%v] ,将要发到的门店id:[%v] , 门店名:[%v]", order.VendorOrderID, order.StoreID, order.StoreName)
|
||||
if order.OrderType == model.OrderTypeAddressErr {
|
||||
noticeMsg += " 此订单地址有问题,需要矫正坐标!"
|
||||
@@ -2070,7 +2049,6 @@ func result2Orders(ctx *jxcontext.Context, result *jdshopapi.AllOrdersResult) (o
|
||||
|
||||
orderDetail, err := jdshop.GetAPI("2").OrderDetail(utils.Int64ToStr(jdsOrder.OrderID))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("jds OrderDetail error: %v", err.Error())
|
||||
continue
|
||||
}
|
||||
order := &model.GoodsOrder{
|
||||
@@ -2098,7 +2076,6 @@ func result2Orders(ctx *jxcontext.Context, result *jdshopapi.AllOrdersResult) (o
|
||||
//获取真实手机号
|
||||
fakeMobile, err := jdshop.GetAPI("2").PhoneSensltiveInfo(order.VendorOrderID2, orderDetail.MobileKey)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("jds PhoneSensltiveInfo error: %v", err.Error())
|
||||
continue
|
||||
} else {
|
||||
order.ConsigneeMobile = jxutils.DecryptDESECB([]byte(fakeMobile), []byte(jdshopapi.JdsMobileKey))
|
||||
@@ -2152,7 +2129,6 @@ func result2Orders(ctx *jxcontext.Context, result *jdshopapi.AllOrdersResult) (o
|
||||
order.JxStoreID = store.ID
|
||||
order.StoreName = store.Name
|
||||
order.VendorStoreID = utils.Int64ToStr(jdsOrder.MdbStoreID)
|
||||
globals.SugarLogger.Debugf("jds GetStoreListByLocation, orderID: %v storeID :%v", order.VendorOrderID, order.StoreID)
|
||||
//结算类型
|
||||
if store.PayPercentage < 50 {
|
||||
order.EarningType = model.EarningTypePoints
|
||||
@@ -2173,7 +2149,6 @@ func result2Orders(ctx *jxcontext.Context, result *jdshopapi.AllOrdersResult) (o
|
||||
}
|
||||
if order.EarningType == model.EarningTypeQuote && shopPriceSum+700 > int(order.TotalShopMoney) {
|
||||
buildOrderTo102919(order)
|
||||
globals.SugarLogger.Debugf("resultjdsOrders return 2")
|
||||
}
|
||||
if order.ConsigneeAddress != "" {
|
||||
var (
|
||||
@@ -2211,17 +2186,14 @@ func result2Orders(ctx *jxcontext.Context, result *jdshopapi.AllOrdersResult) (o
|
||||
distance := jxutils.EarthDistance(lng, lat, lng2, lat2)
|
||||
if distance > 1 {
|
||||
order.OrderType = model.OrderTypeAddressErr
|
||||
globals.SugarLogger.Debugf("resultjdsOrders return address")
|
||||
order.DeliveryFlag = model.OrderDeliveryFlagMaskScheduleDisabled
|
||||
}
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("resultjdsOrders return 5")
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
buildOrderTo102919(order)
|
||||
globals.SugarLogger.Debugf("resultjdsOrders return 6")
|
||||
}
|
||||
//TODO 2021-10-11 取消限额
|
||||
//if order.ActualPayPrice > 300000 {
|
||||
@@ -2232,11 +2204,9 @@ func result2Orders(ctx *jxcontext.Context, result *jdshopapi.AllOrdersResult) (o
|
||||
distance := jxutils.EarthDistance(jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat))
|
||||
if distance > 4 {
|
||||
buildOrderTo102919(order)
|
||||
globals.SugarLogger.Debugf("resultjdsOrders return 4")
|
||||
}
|
||||
if store.Status != model.StoreStatusOpened && store.Status != model.StoreStatusHaveRest {
|
||||
buildOrderTo102919(order)
|
||||
globals.SugarLogger.Debugf("resultjdsOrders return status")
|
||||
}
|
||||
}
|
||||
orders = append(orders, order)
|
||||
|
||||
@@ -39,7 +39,6 @@ func (c *OrderManager) OnAfsOrderNew(afsOrder *model.AfsOrder, orderStatus *mode
|
||||
|
||||
func (c *OrderManager) onAfsOrderNew(afsOrder *model.AfsOrder, orderStatus *model.OrderStatus, isAdjust bool) (err error) {
|
||||
db := dao.GetDB()
|
||||
globals.SugarLogger.Debugf("onAfsOrderNew1 orderID:%s", afsOrder.VendorOrderID)
|
||||
c.setAfsOrderID(db, orderStatus)
|
||||
if afsOrder.AfsOrderID == "" {
|
||||
afsOrder.AfsOrderID = orderStatus.VendorOrderID
|
||||
@@ -50,8 +49,6 @@ func (c *OrderManager) onAfsOrderNew(afsOrder *model.AfsOrder, orderStatus *mode
|
||||
if afsOrder.Status == model.OrderStatusUnknown {
|
||||
afsOrder.Status = orderStatus.Status
|
||||
}
|
||||
globals.SugarLogger.Debugf("onAfsOrderNew2 orderID:%s", afsOrder.VendorOrderID)
|
||||
//
|
||||
if order, _ := c.LoadOrder(afsOrder.VendorOrderID, afsOrder.VendorID); order != nil {
|
||||
if order.ConsigneeMobile2 == "" {
|
||||
if handler := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID); handler != nil {
|
||||
@@ -71,7 +68,6 @@ func (c *OrderManager) onAfsOrderNew(afsOrder *model.AfsOrder, orderStatus *mode
|
||||
}
|
||||
}()
|
||||
isDuplicated, err := addOrderOrWaybillStatus(orderStatus, db)
|
||||
globals.SugarLogger.Debugf("onAfsOrderNew afsOrderID:%s, isDuplicated:%t", afsOrder.AfsOrderID, isDuplicated)
|
||||
if err != nil || isDuplicated {
|
||||
if err == nil {
|
||||
dao.Commit(db, txDB)
|
||||
@@ -108,14 +104,12 @@ func (c *OrderManager) onAfsOrderNew(afsOrder *model.AfsOrder, orderStatus *mode
|
||||
}
|
||||
|
||||
func (c *OrderManager) SaveAfsOrder(db *dao.DaoDB, afsOrder *model.AfsOrder, isDeleteFirst bool) (err error) {
|
||||
globals.SugarLogger.Debug(afsOrder.AfsOrderID)
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
if err = c.updateAfsOrderOtherInfo(db, afsOrder); err != nil {
|
||||
return err
|
||||
}
|
||||
globals.SugarLogger.Debugf("SaveAfsOrder afsorder :%v", utils.Format4Output(afsOrder, true))
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
@@ -150,7 +144,6 @@ func (c *OrderManager) SaveAfsOrder(db *dao.DaoDB, afsOrder *model.AfsOrder, isD
|
||||
afsOrder.RefundMoneyByCal = afsOrder.SkuUserMoney + afsOrder.FreightUserMoney + deductionsByPm - afsOrder.PmRefundMoney
|
||||
// order.TotalMoney += order.SkuJxMoney // 退款单京西补贴部分先不作计算
|
||||
if err = dao.CreateEntity(db, afsOrder); err != nil {
|
||||
globals.SugarLogger.Debugf("On SaveAfsOrder afsOrder.AfsOrderID:%s err:%v", afsOrder.AfsOrderID, err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -160,7 +153,6 @@ func (c *OrderManager) SaveAfsOrder(db *dao.DaoDB, afsOrder *model.AfsOrder, isD
|
||||
utils.Float64TwoInt64(float64(afsOrder.RefundMoneyByCal-afsOrder.PmSkuSubsidyMoney)*float64(orderSku.UserMoney+orderSku.PmSubsidyMoney-orderSku.PmSkuSubsidyMoney)/float64(afsOrder.SkuUserMoney+afsOrder.PmSubsidyMoney-afsOrder.PmSkuSubsidyMoney))
|
||||
afsOrder.Skus[0].RefundMoneyByCal += orderSku.RefundMoneyByCal
|
||||
if err = dao.CreateEntity(db, orderSku); err != nil {
|
||||
globals.SugarLogger.Warnf("On SaveAfsOrder afsOrder.AfsOrderID:%s err:%v, orderSku:%s", afsOrder.AfsOrderID, err, utils.Format4Output(orderSku, true))
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -168,7 +160,6 @@ func (c *OrderManager) SaveAfsOrder(db *dao.DaoDB, afsOrder *model.AfsOrder, isD
|
||||
orderSku := afsOrder.Skus[0]
|
||||
orderSku.RefundMoneyByCal = afsOrder.RefundMoneyByCal - orderSku.RefundMoneyByCal
|
||||
if err = dao.CreateEntity(db, orderSku); err != nil {
|
||||
globals.SugarLogger.Warnf("On SaveAfsOrder afsOrder.AfsOrderID:%s err:%v, orderSku:%s", afsOrder.AfsOrderID, err, utils.Format4Output(orderSku, true))
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@@ -203,7 +194,6 @@ func (c *OrderManager) OnAfsOrderStatusChanged(orderStatus *model.OrderStatus) (
|
||||
}
|
||||
|
||||
func (c *OrderManager) addAfsOrderStatus(db *dao.DaoDB, orderStatus *model.OrderStatus) (isDuplicated bool, order *model.AfsOrder, err error) {
|
||||
globals.SugarLogger.Debugf("addAfsOrderStatus refOrderID:%s, orderID:%s", orderStatus.RefVendorOrderID, orderStatus.VendorOrderID)
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
@@ -253,11 +243,9 @@ func (c *OrderManager) addAfsOrderStatus(db *dao.DaoDB, orderStatus *model.Order
|
||||
}
|
||||
|
||||
func (c *OrderManager) updateAfsOrderSkuOtherInfo(db *dao.DaoDB, order *model.AfsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("updateAfsOrderSkuOtherInfo orderID:%s, VendorStoreID:%s", order.VendorOrderID, order.VendorStoreID)
|
||||
jxStoreID := jxutils.GetSaleStoreIDFromAfsOrder(order)
|
||||
opNumStr := "2"
|
||||
if jxStoreID == 0 {
|
||||
globals.SugarLogger.Infof("updateAfsOrderSkuOtherInfo [运营%s]订单在京西与平台都找不到京西门店信息orderID:%s, VendorStoreID:%s", opNumStr, order.VendorOrderID, order.VendorStoreID)
|
||||
return nil
|
||||
}
|
||||
orderSkus := order.Skus
|
||||
@@ -281,7 +269,6 @@ func (c *OrderManager) updateAfsOrderSkuOtherInfo(db *dao.DaoDB, order *model.Af
|
||||
}
|
||||
l, err := dao.GetStoreSkuPriceAndWeight(db, vendorStoreID, order.VendorID, vendorSkuIDs)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("updateAfsOrderSkuOtherInfo orderID:%s failed with err:%v", order.VendorOrderID, err)
|
||||
return err
|
||||
}
|
||||
skumapper := storeSkuPriceAndWeight2Map(l)
|
||||
@@ -291,7 +278,6 @@ func (c *OrderManager) updateAfsOrderSkuOtherInfo(db *dao.DaoDB, order *model.Af
|
||||
if order2, err2 := c.LoadOrder(order.VendorOrderID, order.VendorID); err2 == nil {
|
||||
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, model.ActTypeAll, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order2.OrderCreatedAt, order2.OrderCreatedAt)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("updateAfsOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
|
||||
return err
|
||||
}
|
||||
actStoreSkuMap = jxutils.NewActStoreSkuMap(actStoreSkuList, false)
|
||||
@@ -329,7 +315,6 @@ func (c *OrderManager) updateAfsOrderSkuOtherInfo(db *dao.DaoDB, order *model.Af
|
||||
}
|
||||
|
||||
func (c *OrderManager) updateAfsOrderOtherInfo(db *dao.DaoDB, afsOrder *model.AfsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("updateAfsOrderOtherInfo orderID:%s, VendorStoreID:%s", afsOrder.VendorOrderID, afsOrder.VendorStoreID)
|
||||
if afsOrder.VendorStoreID != "" {
|
||||
if storeDetail, err := dao.GetStoreDetailByVendorStoreID(db, afsOrder.VendorStoreID, 0, ""); err == nil {
|
||||
afsOrder.JxStoreID = storeDetail.Store.ID
|
||||
@@ -369,7 +354,6 @@ func (c *OrderManager) UpdateAfsOrderFields(afsOrder *model.AfsOrder, fieldList
|
||||
}
|
||||
|
||||
func (c *OrderManager) setAfsOrderID(db *dao.DaoDB, orderStatus *model.OrderStatus) {
|
||||
// globals.SugarLogger.Debugf("setAfsOrderID1 orderStatus:%v", utils.Format4Output(orderStatus, true))
|
||||
if dao.IsVendorThingIDEmpty(orderStatus.VendorOrderID) {
|
||||
index := 1
|
||||
if afsOrderList, err2 := dao.GetAfsOrders(db, orderStatus.RefVendorID, orderStatus.RefVendorOrderID, ""); err2 == nil {
|
||||
@@ -387,7 +371,6 @@ func (c *OrderManager) setAfsOrderID(db *dao.DaoDB, orderStatus *model.OrderStat
|
||||
}
|
||||
orderStatus.VendorOrderID = composeAfsOrderID(orderStatus.RefVendorOrderID, index)
|
||||
}
|
||||
// globals.SugarLogger.Debugf("setAfsOrderID2 orderStatus:%v", utils.Format4Output(orderStatus, true))
|
||||
}
|
||||
|
||||
func composeAfsOrderID(vendorOrderID string, index int) (afsOrderID string) {
|
||||
@@ -399,7 +382,6 @@ func composeAfsOrderID(vendorOrderID string, index int) (afsOrderID string) {
|
||||
|
||||
func (c *OrderManager) CreateAfsOrderFromOrder(vendorOrderID string, vendorID int) (afsOrder *model.AfsOrder, err error) {
|
||||
order, err := c.LoadOrder(vendorOrderID, vendorID)
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(order, false))
|
||||
if err == nil {
|
||||
afsOrder = &model.AfsOrder{
|
||||
VendorID: vendorID,
|
||||
@@ -410,7 +392,6 @@ func (c *OrderManager) CreateAfsOrderFromOrder(vendorOrderID string, vendorID in
|
||||
VendorOrgCode: order.VendorOrgCode,
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("CreateAfsOrderFromOrder, orderID:%s is not found from partner.CurOrderManager.LoadOrder", vendorOrderID)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -71,10 +71,8 @@ var (
|
||||
)
|
||||
|
||||
func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (err error) {
|
||||
globals.SugarLogger.Debug("OnOrderComments")
|
||||
db := dao.GetDB()
|
||||
for _, orderComment := range orderCommentList {
|
||||
globals.SugarLogger.Debugf("OnOrderComments, orderID:%s", orderComment.VendorOrderID)
|
||||
comment2 := &legacymodel.JxBadComments{
|
||||
OrderId: orderComment.VendorOrderID,
|
||||
}
|
||||
@@ -169,7 +167,6 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("OnOrderComments orderID:%s failed with error:%v", orderComment.VendorOrderID, err)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -187,14 +184,12 @@ func (c *OrderManager) replyOrderComment(vendorOrgCode string, orderComment *mod
|
||||
if configs, err := dao.QueryConfigs(dao.GetDB(), utils.Int2Str(score), model.ConfigTypeReply, ""); err == nil {
|
||||
json.Unmarshal([]byte(configs[0].Value), &config)
|
||||
}
|
||||
globals.SugarLogger.Debugf("replyOrderComment config: %v", utils.Format4Output(config, true))
|
||||
if config == nil {
|
||||
return
|
||||
}
|
||||
//config := replyConfig[score]
|
||||
delaySeconds := config.DelayGapBegin + rand.Intn(config.DelayGapEnd-config.DelayGapBegin)
|
||||
content := config.Comments[rand.Intn(len(config.Comments))]
|
||||
globals.SugarLogger.Debugf("replyOrderComment orderID:%s, delaySeconds:%d, content:%s", orderComment.VendorOrderID, delaySeconds, content)
|
||||
utils.AfterFuncWithRecover(time.Duration(delaySeconds)*time.Second, func() {
|
||||
if handler := partner.GetPurchaseOrderHandlerFromVendorID(orderComment.VendorID); handler != nil {
|
||||
if err = handler.ReplyOrderComment(jxcontext.AdminCtx, vendorOrgCode, orderComment, content); err != nil {
|
||||
|
||||
@@ -74,7 +74,6 @@ func addOrderOrWaybillStatus(status *model.OrderStatus, db *dao.DaoDB) (isDuplic
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
globals.SugarLogger.Debug("rollback")
|
||||
dao.Rollback(db, txDB)
|
||||
if r != nil {
|
||||
panic(r)
|
||||
@@ -86,7 +85,6 @@ func addOrderOrWaybillStatus(status *model.OrderStatus, db *dao.DaoDB) (isDuplic
|
||||
created, _, err := db.Db.ReadOrCreate(status, "VendorOrderID", "VendorID", "OrderType", "Status", "VendorStatus", "StatusTime")
|
||||
if err == nil {
|
||||
if !created {
|
||||
globals.SugarLogger.Debugf("duplicated event:%v", status)
|
||||
isDuplicated = true
|
||||
status.DuplicatedCount++
|
||||
utils.CallFuncLogError(func() error {
|
||||
@@ -118,7 +116,6 @@ func (c *OrderManager) GetStatusDuplicatedCount(status *model.OrderStatus) (dupl
|
||||
// todo 最好还是改成全事件回放算了
|
||||
func LoadPendingOrders() {
|
||||
orders, err := dao.LoadPendingOrders(dao.GetDB(), time.Now().Add(-pendingOrderGapMax), model.OrderStatusEndBegin)
|
||||
globals.SugarLogger.Infof("LoadPendingOrders orders count:%d, err:%v", len(orders), err)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -126,7 +123,6 @@ func LoadPendingOrders() {
|
||||
ordersCount := len(orders)
|
||||
if ordersCount > 0 {
|
||||
bills := FixedOrderManager.LoadPendingWaybills()
|
||||
globals.SugarLogger.Infof("LoadPendingOrders waybills count:%d", len(bills))
|
||||
var sortOrders StatusTimerSlice
|
||||
orderMap := make(map[string]*model.GoodsOrder)
|
||||
for _, order := range orders {
|
||||
|
||||
@@ -67,7 +67,6 @@ type OrderCount struct {
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID, lastHours, lastMinutes int, isIncludeFake bool) (countInfo []*model.GoodsOrderCountInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetStoreOrderCountInfo storeID:%d", storeID)
|
||||
if lastHours > maxLastHours {
|
||||
lastHours = maxLastHours
|
||||
} else if lastHours == 0 && lastMinutes == 0 {
|
||||
@@ -107,13 +106,10 @@ func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID, l
|
||||
if err == nil {
|
||||
return countInfo, nil
|
||||
}
|
||||
globals.SugarLogger.Infof("GetStoreOrderCountInfo storeID:%d failed with error:%v", storeID, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetOrderSkuInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID int) (skus []*model.OrderSkuExt, err error) {
|
||||
globals.SugarLogger.Debugf("GetOrderSkuInfo orderID:%s", vendorOrderID)
|
||||
|
||||
fullSkuNameSQL := "t1.sku_name"
|
||||
if vendorID == model.VendorIDJD {
|
||||
fullSkuNameSQL = "CONCAT(t1.sku_name, IF(t3.is_spu = 1 AND LOCATE(';', t1.sku_name) = 0, CONCAT('[约', t2.spec_quality, t2.spec_unit, '/', t3.unit, ']'), ''))"
|
||||
@@ -163,7 +159,6 @@ func (c *OrderManager) GetOrderSkuInfo(ctx *jxcontext.Context, vendorOrderID str
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetOrderInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID int, isRefresh bool) (order *model.GoodsOrderExt, err error) {
|
||||
globals.SugarLogger.Debugf("GetOrderInfo orderID:%s", vendorOrderID)
|
||||
db := dao.GetDB()
|
||||
orders := []*model.GoodsOrderExt{}
|
||||
rorder, _ := dao.GetSimpleOrder(db, vendorOrderID)
|
||||
@@ -213,7 +208,6 @@ func (c *OrderManager) GetOrderInfo(ctx *jxcontext.Context, vendorOrderID string
|
||||
order.CurrentConsigneeMobile = tmpOrder.ConsigneeMobile
|
||||
} else {
|
||||
order.CurrentConsigneeMobile = "Error"
|
||||
globals.SugarLogger.Infof("GetOrderInfo GetOrder failed with error:%v", err2)
|
||||
}
|
||||
}
|
||||
return order, nil
|
||||
@@ -221,12 +215,10 @@ func (c *OrderManager) GetOrderInfo(ctx *jxcontext.Context, vendorOrderID string
|
||||
if err == nil {
|
||||
err = ErrCanNotFindOrder
|
||||
}
|
||||
globals.SugarLogger.Infof("GetOrderInfo orderID:%s failed with error:%v", vendorOrderID, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetOrderWaybillInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID int, isNotEnded, isGetPos bool) (bills []*model.WaybillExt, err error) {
|
||||
globals.SugarLogger.Debugf("GetOrderWaybillInfo orderID:%s", vendorOrderID)
|
||||
db := dao.GetDB()
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
@@ -266,8 +258,6 @@ func (c *OrderManager) GetOrderWaybillInfo(ctx *jxcontext.Context, vendorOrderID
|
||||
}
|
||||
|
||||
func (c *OrderManager) ExportMTWaybills(ctx *jxcontext.Context, fromDateStr, toDateStr string) (excelContent []byte, err error) {
|
||||
globals.SugarLogger.Debugf("ExportMTWaybills from:%s to:%s", fromDateStr, toDateStr)
|
||||
|
||||
fromDate, err := utils.TryStr2Time(fromDateStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -433,7 +423,6 @@ type AfsOrderExt struct {
|
||||
}
|
||||
|
||||
func (c *OrderManager) ExportOrders(ctx *jxcontext.Context, fromDateStr, toDateStr string, mapParams map[string]interface{}) (hint string, err error) {
|
||||
globals.SugarLogger.Debugf("ExportOrders from:%s to:%s", fromDateStr, toDateStr)
|
||||
var (
|
||||
orders []*model.GoodsOrderExt
|
||||
afsSkuMap map[string]map[int]*model.OrderSkuFinancial
|
||||
@@ -470,7 +459,6 @@ func (c *OrderManager) ExportOrders(ctx *jxcontext.Context, fromDateStr, toDateS
|
||||
}
|
||||
}
|
||||
orders, _, err = dao.GetOrders(dao.GetDB(), nil, true, true, fromDateStr, toDateStr, true, nil, false, "", mapParams, 0, model.UnlimitedPageSize)
|
||||
globals.SugarLogger.Debugf("orders:%d, er:%v", len(orders), err)
|
||||
case 1:
|
||||
afsSkuMap, err = c.getAfsOrderSkuInfo4ExportOrders(ctx, fromDateStr, toDateStr)
|
||||
case 2:
|
||||
@@ -593,7 +581,6 @@ func (c *OrderManager) ExportOrders(ctx *jxcontext.Context, fromDateStr, toDateS
|
||||
if err = err2; err == nil {
|
||||
task.SetNoticeMsg(excelURL)
|
||||
}
|
||||
globals.SugarLogger.Debugf("导出订单SKU信息excelURL:%s, err:%v", excelURL, err)
|
||||
}
|
||||
return nil, err
|
||||
}, 5)
|
||||
@@ -603,8 +590,6 @@ func (c *OrderManager) ExportOrders(ctx *jxcontext.Context, fromDateStr, toDateS
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetWaybills(ctx *jxcontext.Context, fromDateStr, toDateStr string, params map[string]interface{}, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetWaybills from:%s to:%s", fromDateStr, toDateStr)
|
||||
|
||||
fromDate, err := utils.TryStr2Time(fromDateStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -757,7 +742,6 @@ func GetOrderStatusCancelList(refVendorOrderID string) (statusList []*model.Orde
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetOrdersFinancial(ctx *jxcontext.Context, fromDateStr, toDateStr string, params map[string]interface{}, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetOrdersFinancial from:%s to:%s", fromDateStr, toDateStr)
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
sql := `
|
||||
@@ -1071,7 +1055,6 @@ type GetAfsOrdersResult struct {
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetAfsOrders(ctx *jxcontext.Context, keyword, afsOrderID, vendorOrderID string, vendorIDList, appealTypeList, storeIDList, statusList, skuIDs []int, fromTime, toTime time.Time, isDetail bool, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetAfsOrders")
|
||||
//权限
|
||||
if permission.IsRoled(ctx) {
|
||||
if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
|
||||
@@ -1253,7 +1236,6 @@ func (c *OrderManager) getAfsOrderSkuInfo4ExportOrders(ctx *jxcontext.Context, f
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetStoreAfsOrderCountInfo(ctx *jxcontext.Context, storeID, lastHours int) (countInfo []*model.GoodsOrderCountInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetStoreAfsOrderCountInfo storeID:%d", storeID)
|
||||
if lastHours > maxLastHours {
|
||||
lastHours = maxLastHours
|
||||
} else if lastHours == 0 {
|
||||
@@ -1272,7 +1254,6 @@ func (c *OrderManager) GetStoreAfsOrderCountInfo(ctx *jxcontext.Context, storeID
|
||||
if err == nil {
|
||||
return countInfo, nil
|
||||
}
|
||||
globals.SugarLogger.Infof("GetStoreAfsOrderCountInfo storeID:%d failed with error:%v", storeID, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -53,14 +53,12 @@ func (w *OrderManager) LoadPendingWaybills() []*model.Waybill {
|
||||
AND t1.status < ?
|
||||
`, tillTime, model.OrderStatusEndBegin, tillTime, model.WaybillStatusEndBegin).QueryRows(&bills)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("LoadPendingWaybills load pending waybills error:%v", err)
|
||||
return nil
|
||||
}
|
||||
return bills
|
||||
}
|
||||
|
||||
func (w *OrderManager) onWaybillNew(bill2 *model.Waybill, db *dao.DaoDB) (isDuplicated bool, err error) {
|
||||
globals.SugarLogger.Debugf("onWaybillNew bill:%v", bill2)
|
||||
isDuplicated, err = addOrderOrWaybillStatus(model.Waybill2Status(bill2), db)
|
||||
if err == nil && !isDuplicated {
|
||||
bill2.ID = 0
|
||||
@@ -73,7 +71,6 @@ func (w *OrderManager) onWaybillNew(bill2 *model.Waybill, db *dao.DaoDB) (isDupl
|
||||
if !created {
|
||||
bill.DuplicatedCount++
|
||||
if bill2.VendorOrderID == bill2.VendorWaybillID { // 购物平台(比如京东)重新建的运单,单号始终是与订单相同的
|
||||
globals.SugarLogger.Infof("onWaybillNew duplicated1, DuplicatedCount:%d, bill:%v msg received", bill2.DuplicatedCount, bill2)
|
||||
bill2.ID = bill.ID
|
||||
bill2.CreatedAt = bill.CreatedAt
|
||||
bill2.DuplicatedCount = bill.DuplicatedCount
|
||||
@@ -82,7 +79,6 @@ func (w *OrderManager) onWaybillNew(bill2 *model.Waybill, db *dao.DaoDB) (isDupl
|
||||
return err
|
||||
}, "onWaybillNew Update1")
|
||||
} else {
|
||||
globals.SugarLogger.Infof("onWaybillNew duplicated2 DuplicatedCount:%d, bill:%v msg received", bill.DuplicatedCount, bill2)
|
||||
isDuplicated = true
|
||||
err = utils.CallFuncLogError(func() error {
|
||||
_, err = db.Db.Update(bill, "DuplicatedCount")
|
||||
@@ -91,7 +87,6 @@ func (w *OrderManager) onWaybillNew(bill2 *model.Waybill, db *dao.DaoDB) (isDupl
|
||||
}
|
||||
} else {
|
||||
*bill2 = *bill
|
||||
globals.SugarLogger.Debugf("onWaybillNew created bill:%v", bill2)
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("onWaybillNew create bill:%v, error:%v", bill2, err)
|
||||
@@ -213,7 +208,6 @@ func (w *OrderManager) addWaybillStatus(bill *model.Waybill, db *dao.DaoDB, addP
|
||||
"vendor_status": bill.VendorStatus,
|
||||
"status_time": bill.StatusTime,
|
||||
}, addParams)
|
||||
globals.SugarLogger.Debugf("addWaybillStatus waybill: %v, params: %v", utils.Format4Output(bill, true), utils.Format4Output(addParams, true))
|
||||
utils.CallFuncLogError(func() error {
|
||||
_, err = db.Db.QueryTable("waybill").Filter("vendor_waybill_id", bill.VendorWaybillID).Filter("waybill_vendor_id", bill.WaybillVendorID).Filter("status__lte", bill.Status).Update(params)
|
||||
return err
|
||||
@@ -238,7 +232,6 @@ func (c *OrderManager) LoadWaybill(vendorWaybillID string, waybillVendorID int)
|
||||
if err == orm.ErrNoRows {
|
||||
err = ErrCanNotFindWaybill
|
||||
}
|
||||
globals.SugarLogger.Infof("LoadWaybill vendorWaybillID:%s failed with error:%v", vendorWaybillID, err)
|
||||
}
|
||||
return bill, err
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ type BaseScheduler struct {
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
||||
globals.SugarLogger.Infof("AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt)
|
||||
if /*order.LockStatus == model.OrderStatusUnknown && */ order.Status == model.OrderStatusNew || order.Status == model.OrderStatusWaitAccepted {
|
||||
if c.IsReallyCallPlatformAPI {
|
||||
err = utils.CallFuncLogErrorWithInfo(func() error {
|
||||
@@ -36,13 +35,11 @@ func (c *BaseScheduler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt
|
||||
}
|
||||
} else {
|
||||
return scheduler.ErrOrderStatusAlreadySatisfyCurOperation
|
||||
globals.SugarLogger.Debugf("AcceptOrRefuseOrder orderID:%s, status:%d is not suitable, isAcceptIt:%t", order.VendorOrderID, order.Status, isAcceptIt)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) {
|
||||
globals.SugarLogger.Infof("PickupGoods orderID:%s,order :%v", order.VendorOrderID, utils.Format4Output(order, false))
|
||||
if /*order.LockStatus == model.OrderStatusUnknown && */ order.Status == model.OrderStatusAccepted {
|
||||
if c.IsReallyCallPlatformAPI {
|
||||
handler := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID)
|
||||
@@ -58,17 +55,14 @@ func (c *BaseScheduler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool
|
||||
} else {
|
||||
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusAccepted {
|
||||
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
|
||||
globals.SugarLogger.Infof("PickupGoods orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
|
||||
} else {
|
||||
err = scheduler.ErrOrderStatusAlreadySatisfyCurOperation
|
||||
globals.SugarLogger.Debugf("PickupGoods orderID:%s status:%d already ok", order.VendorOrderID, order.Status)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Infof("Swtich2SelfDeliver orderID:%s", order.VendorOrderID)
|
||||
if /*order.LockStatus == model.OrderStatusUnknown && */ order.Status >= model.OrderStatusFinishedPickup && order.Status <= model.OrderStatusDelivering {
|
||||
if order.DeliveryFlag&model.OrderDeliveryFlagMaskPurcahseDisabled == 0 && c.IsReallyCallPlatformAPI {
|
||||
err = utils.CallFuncLogErrorWithInfo(func() error {
|
||||
@@ -83,17 +77,14 @@ func (c *BaseScheduler) Swtich2SelfDeliver(order *model.GoodsOrder, userName str
|
||||
} else {
|
||||
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusFinishedPickup || order.VendorID == order.WaybillVendorID {
|
||||
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
|
||||
globals.SugarLogger.Infof("Swtich2SelfDeliver orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
|
||||
} else {
|
||||
err = scheduler.ErrOrderStatusAlreadySatisfyCurOperation
|
||||
globals.SugarLogger.Debugf("Swtich2SelfDeliver orderID:%s status:%d already ok", order.VendorOrderID, order.Status)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) Swtich2SelfDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Infof("Swtich2SelfDelivered orderID:%s", order.VendorOrderID)
|
||||
if /*order.LockStatus == model.OrderStatusUnknown && */ order.Status == model.OrderStatusDelivering {
|
||||
if c.IsReallyCallPlatformAPI {
|
||||
err = utils.CallFuncLogError(func() error {
|
||||
@@ -103,17 +94,14 @@ func (c *BaseScheduler) Swtich2SelfDelivered(order *model.GoodsOrder, userName s
|
||||
} else {
|
||||
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusDelivering {
|
||||
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
|
||||
globals.SugarLogger.Infof("Swtich2SelfDelivered orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
|
||||
} else {
|
||||
err = scheduler.ErrOrderStatusAlreadySatisfyCurOperation
|
||||
globals.SugarLogger.Debugf("Swtich2SelfDelivered orderID:%s status:%d already ok", order.VendorOrderID, order.Status)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Infof("SelfDeliverDelivering orderID:%s", order.VendorOrderID)
|
||||
if order.Status == model.OrderStatusFinishedPickup {
|
||||
if c.IsReallyCallPlatformAPI {
|
||||
err = utils.CallFuncLogError(func() error {
|
||||
@@ -158,17 +146,14 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName
|
||||
} else {
|
||||
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusFinishedPickup {
|
||||
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
|
||||
globals.SugarLogger.Infof("SelfDeliverDelivering orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
|
||||
} else {
|
||||
err = scheduler.ErrOrderStatusAlreadySatisfyCurOperation
|
||||
globals.SugarLogger.Debugf("SelfDeliverDelivering orderID:%s, status:%d already ok", order.VendorOrderID, order.Status)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Infof("SelfDeliverDelivered orderID:%s", order.VendorOrderID)
|
||||
if /*order.LockStatus == model.OrderStatusUnknown && */ order.Status >= model.OrderStatusFinishedPickup &&
|
||||
order.Status <= model.OrderStatusDelivering {
|
||||
if c.IsReallyCallPlatformAPI {
|
||||
@@ -183,19 +168,15 @@ func (c *BaseScheduler) SelfDeliverDelivered(order *model.GoodsOrder, userName s
|
||||
} else {
|
||||
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusDelivering {
|
||||
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
|
||||
globals.SugarLogger.Infof("SelfDeliverDelivered orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
|
||||
} else {
|
||||
err = scheduler.ErrOrderStatusAlreadySatisfyCurOperation
|
||||
globals.SugarLogger.Debugf("SelfDeliverDelivered orderID:%s, status:%d already ok", order.VendorOrderID, order.Status)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||
globals.SugarLogger.Infof("CreateWaybill to meituan orderID:%s, vendor:%s", order.VendorOrderID, jxutils.GetVendorName(platformVendorID))
|
||||
if !model.IsOrderSolid(order) { // 如果订单是不完整的
|
||||
globals.SugarLogger.Warnf("CreateWaybill orderID:%s, vendorID:%d is not solid!!!", order.VendorOrderID, platformVendorID)
|
||||
return nil, scheduler.ErrOrderIsNotSolid
|
||||
}
|
||||
// if order.DeliveryFlag&model.OrderDeliveryFlagMaskScheduleDisabled != 0 {
|
||||
@@ -259,7 +240,6 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
||||
globals.SugarLogger.Infof("CancelWaybill bill:%v, cancelReasonID:%d cancelReason:%s", bill, cancelReasonID, cancelReason)
|
||||
// 部分快递平台在取消成功后有时会不发运单取消消息过来(比如达达,904200512000442),为避免二次取消报错,添加状态判断
|
||||
if c.IsReallyCallPlatformAPI && bill.OrderVendorID != bill.WaybillVendorID && bill.Status != model.WaybillStatusCanceled {
|
||||
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(bill.WaybillVendorID); handlerInfo != nil {
|
||||
@@ -274,7 +254,6 @@ func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, c
|
||||
bill.DeliveryFlag |= model.WaybillDeliveryFlagMaskActiveCancel
|
||||
_, err = dao.UpdateEntity(nil, bill, "Status", "DeliveryFlag")
|
||||
}
|
||||
globals.SugarLogger.Debugf("CancelWaybill bill:%v canceled by myself", bill)
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
||||
@@ -27,8 +27,6 @@ const (
|
||||
)
|
||||
|
||||
func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order *model.GoodsOrder, courierVendorIDs, excludeCourierVendorIDs []int, maxDeliveryFee int64, createOnlyOne bool) (bills []*model.Waybill, err error) {
|
||||
userName := ctx.GetUserName()
|
||||
globals.SugarLogger.Infof("CreateWaybillOnProviders orderID:%s userName:%s, courierVendorIDs:%v, excludeCourierVendorIDs:%v", order.VendorOrderID, userName, courierVendorIDs, excludeCourierVendorIDs)
|
||||
storeCourierList, err := dao.GetStoreCourierList2(dao.GetDB(), []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, model.StoreStatusOpened, []int{model.StoreAuditStatusOnline, model.StoreAuditStatusUpdated})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -45,13 +43,11 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order *
|
||||
// 创建运单
|
||||
bill, err2 := c.CreateWaybill(courierVendorID, order, maxDeliveryFee)
|
||||
if err = err2; err == nil {
|
||||
globals.SugarLogger.Debugf("CreateWaybillOnProviders orderID:%s userName:%s vendorID:%d bill:%v", order.VendorOrderID, userName, courierVendorID, bill)
|
||||
bills = append(bills, bill)
|
||||
if createOnlyOne {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("CreateWaybillOnProviders orderID:%s userName:%s vendorID:%d failed with error:%v", order.VendorOrderID, userName, courierVendorID, err)
|
||||
errList.AddErr(fmt.Errorf("平台:%s,%s", jxutils.GetVendorName(courierVendorID), err.Error()))
|
||||
}
|
||||
}
|
||||
@@ -68,14 +64,12 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order *
|
||||
} else {
|
||||
err = fmt.Errorf("orderID:%s所有运单失败:%s", order.VendorOrderID, errList.GetErrListAsOne().Error())
|
||||
}
|
||||
globals.SugarLogger.Infof("CreateWaybillOnProviders orderID:%s userName:%s error:%v", order.VendorOrderID, userName, err)
|
||||
return bills, err
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) SelfDeliveredAndUpdateStatus(ctx *jxcontext.Context, vendorOrderID string, vendorID int, userName string) (err error) {
|
||||
jxutils.CallMsgHandler(func() {
|
||||
err = func() (err error) {
|
||||
globals.SugarLogger.Infof("SelfDeliveredAndUpdateStatus orderID:%s userName:%s", vendorOrderID, userName)
|
||||
order, err := partner.CurOrderManager.LoadOrder(vendorOrderID, vendorID)
|
||||
if err == nil {
|
||||
if model.IsOrderDeliveryByStore(order) {
|
||||
@@ -86,12 +80,10 @@ func (c *BaseScheduler) SelfDeliveredAndUpdateStatus(ctx *jxcontext.Context, ven
|
||||
if err == nil {
|
||||
// order.Status = model.OrderStatusFinished // todo 是否需要强制设置完成状态?
|
||||
if err = dao.SetOrderFlag(dao.GetDB(), ctx.GetUserName(), order.VendorOrderID, order.VendorID, model.OrderFlagMaskSetDelivered); err == nil {
|
||||
globals.SugarLogger.Infof("SelfDeliveredAndUpdateStatus orderID:%s userName:%s successfully", vendorOrderID, userName)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Infof("SelfDeliveredAndUpdateStatus orderID:%s userName:%s error:%v", vendorOrderID, userName, err)
|
||||
return err
|
||||
}()
|
||||
}, jxutils.ComposeUniversalOrderID(vendorOrderID, vendorID))
|
||||
@@ -101,7 +93,6 @@ func (c *BaseScheduler) SelfDeliveredAndUpdateStatus(ctx *jxcontext.Context, ven
|
||||
func (c *BaseScheduler) PickupGoodsAndUpdateStatus(ctx *jxcontext.Context, vendorOrderID string, vendorID int, userName string) (err error) {
|
||||
jxutils.CallMsgHandler(func() {
|
||||
err = func() (err error) {
|
||||
globals.SugarLogger.Infof("PickupGoodsAndUpdateStatus orderID:%s userName:%s", vendorOrderID, userName)
|
||||
order, err := partner.CurOrderManager.LoadOrder(vendorOrderID, vendorID)
|
||||
if err == nil {
|
||||
flag := model.IsOrderDeliveryByStore(order) || model.IsOrderDeliveryBySelf(order)
|
||||
@@ -109,12 +100,10 @@ func (c *BaseScheduler) PickupGoodsAndUpdateStatus(ctx *jxcontext.Context, vendo
|
||||
if err == nil {
|
||||
order.Status = model.OrderStatusFinishedPickup
|
||||
if err = partner.CurOrderManager.UpdateOrderStatusAndDeliveryFlag(order); err == nil {
|
||||
globals.SugarLogger.Infof("PickupGoodsAndUpdateStatus orderID:%s userName:%s successfully", vendorOrderID, userName)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Infof("PickupGoodsAndUpdateStatus orderID:%s userName:%s error:%v", vendorOrderID, userName, err)
|
||||
return err
|
||||
}()
|
||||
}, jxutils.ComposeUniversalOrderID(vendorOrderID, vendorID))
|
||||
@@ -285,7 +274,6 @@ func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID s
|
||||
if approveType != partner.AfsApproveTypeRefused {
|
||||
storeDetail, err := partner.CurOrderManager.LoadStoreDetail(afsOrder.StoreID, afsOrder.VendorID)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("Get store detail Err : ", err)
|
||||
return err
|
||||
}
|
||||
if storeDetail.IsPrintRefundOrder == model.YES { // 打印退款订单
|
||||
@@ -368,7 +356,6 @@ func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order
|
||||
if order.WaybillTipMoney >= tipFee {
|
||||
return fmt.Errorf("当前小费已经是%s元,想要设置%s元", jxutils.IntPrice2StandardString(order.WaybillTipMoney), jxutils.IntPrice2StandardString(tipFee))
|
||||
}
|
||||
globals.SugarLogger.Debugf("SetOrderWaybillTipByOrder, orderID %s, tip:%d", order.VendorOrderID, tipFee)
|
||||
db := dao.GetDB()
|
||||
storeDetail, _ := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, "")
|
||||
flag := false
|
||||
@@ -425,7 +412,6 @@ func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) confirmSelfTake(ctx *jxcontext.Context, order *model.GoodsOrder, selfTakeCode string) (err error) {
|
||||
globals.SugarLogger.Debugf("confirmSelfTake orderID:%s, selfTakeCode:%s", order.VendorOrderID, selfTakeCode)
|
||||
vendorID := order.VendorID
|
||||
// if vendorID == model.VendorIDJD || vendorID == model.VendorIDJX {
|
||||
if vendorID != model.VendorIDJX {
|
||||
|
||||
@@ -164,7 +164,6 @@ func (s *WatchOrderInfo) SetOrder(order *model.GoodsOrder) (retVal *model.GoodsO
|
||||
}
|
||||
|
||||
func (s *WatchOrderInfo) updateOrderStoreFeature(order *model.GoodsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("updateOrderStoreFeature orderID:%s", order.VendorOrderID)
|
||||
jxStoreID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
if jxStoreID > 0 {
|
||||
db := dao.GetDB()
|
||||
@@ -175,7 +174,6 @@ func (s *WatchOrderInfo) updateOrderStoreFeature(order *model.GoodsOrder) (err e
|
||||
s.autoPickupTimeoutMinute = int(storeDetail.AutoPickup)
|
||||
s.isDeliveryCompetition = storeDetail.DeliveryCompetition != 0
|
||||
}
|
||||
globals.SugarLogger.Debugf("updateOrderStoreFeature2 orderID:%s, isDeliveryCompetition:%t", order.VendorOrderID, s.isDeliveryCompetition)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -310,7 +308,6 @@ func init() {
|
||||
TimeoutGap: 0,
|
||||
},
|
||||
TimeoutAction: func(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) (err error) {
|
||||
globals.SugarLogger.Debugf("OrderStatusFinishedPickup timeout: %v", utils.Format4Output(savedOrderInfo, true))
|
||||
// 启动抢单TIMER
|
||||
sch.saveDeliveryFeeFromAndStartWatch(savedOrderInfo, savedOrderInfo.order.StatusTime)
|
||||
return sch.createWaybillOn3rdProviders(savedOrderInfo, 0, nil)
|
||||
@@ -334,10 +331,6 @@ func init() {
|
||||
// 饿百转自送的时机不太清楚,暂时禁用超时转自送,在饿百运单取消时还是会自动创建
|
||||
// 非自配送商家使用
|
||||
order := savedOrderInfo.order
|
||||
globals.SugarLogger.Debugf("waybill timer: %v", utils.Format4Output(order, true))
|
||||
globals.SugarLogger.Debugf("waybill timer 1: %v", model.IsOrderDeliveryByPlatform(order))
|
||||
globals.SugarLogger.Debugf("waybill timer 2: %v", isOrderCanSwitch2SelfDeliver(order))
|
||||
globals.SugarLogger.Debugf("waybill timer 3: %v", savedOrderInfo.isDeliveryCompetition)
|
||||
return order.VendorID != model.VendorIDEBAI &&
|
||||
order.VendorID == bill.WaybillVendorID &&
|
||||
savedOrderInfo.isDeliveryCompetition &&
|
||||
@@ -383,7 +376,6 @@ func Init() {
|
||||
|
||||
// 以下是订单
|
||||
func (s *DefScheduler) OnOrderNew(order *model.GoodsOrder, isPending bool, isAuto bool) (err error) {
|
||||
globals.SugarLogger.Debugf("OnOrderNew orderID:%s", order.VendorOrderID)
|
||||
savedOrderInfo := s.loadSavedOrderFromMap(model.Order2Status(order), false)
|
||||
savedOrderInfo.SetOrder(order)
|
||||
if order.VendorID == model.VendorIDEBAI { //饿百订单待接单的时候就推所有东西
|
||||
@@ -423,7 +415,6 @@ func (s *DefScheduler) OnOrderNew(order *model.GoodsOrder, isPending bool, isAut
|
||||
// todo 这个接口应该可以直接传order的,因为在OrderManager中每次都生成了
|
||||
func (s *DefScheduler) OnOrderStatusChanged(order *model.GoodsOrder, status *model.OrderStatus, isPending bool) (err error) {
|
||||
if status.Status > model.OrderStatusMsg && status.Status != model.OrderStatusUnknown {
|
||||
globals.SugarLogger.Debugf("OnOrderStatusChanged orderID:%s %s, status:%v", status.VendorOrderID, model.OrderStatusName[status.Status], status)
|
||||
if order == nil {
|
||||
globals.SugarLogger.Warnf("OnOrderStatusChanged order is nil, status:%s", utils.Format4Output(status, true))
|
||||
} else if order.Status > model.OrderStatusUnknown && status.Status > model.OrderStatusUnknown && order.Status != status.Status {
|
||||
@@ -513,7 +504,6 @@ func (s *DefScheduler) OnOrderStatusChanged(order *model.GoodsOrder, status *mod
|
||||
// 以下是运单 (将订单数据放入系统内部调度器当中)
|
||||
func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending bool) (err error) {
|
||||
if bill.Status > model.WaybillStatusUnknown {
|
||||
globals.SugarLogger.Debugf("OnWaybillStatusChanged orderID:%s %s, bill:%v", bill.VendorOrderID, model.WaybillStatusName[bill.Status], utils.Format4Output(bill, true))
|
||||
savedOrderInfo := s.loadSavedOrderFromMap(model.Waybill2Status(bill), true)
|
||||
order := savedOrderInfo.order
|
||||
|
||||
@@ -549,10 +539,8 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
} else {
|
||||
needAddTip := order.WaybillTipMoney > 0 && !model.IsWaybillPlatformOwn(bill)
|
||||
if model.IsOrderHaveWaybill(order) { // 是否有有效运单
|
||||
globals.SugarLogger.Debugf("OnWaybillStatusChanged multiple waybill created, bill:%v", bill)
|
||||
if model.IsWaybillPlatformOwn(bill) { // 是购物平台运单
|
||||
if !model.IsOrderHaveOwnWaybill(order) { // 既有运单不是购物平台运单
|
||||
globals.SugarLogger.Infof("OnWaybillStatusChanged bill:%v purchase platform bill came later than others, strange!!!", bill)
|
||||
oldBill := savedOrderInfo.waybills[order.WaybillVendorID]
|
||||
if oldBill != nil {
|
||||
s.ProxyCancelWaybill(order, oldBill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
@@ -683,7 +671,6 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
} else if !s.isBillCandidate(order, bill) && bill.WaybillVendorID != order.VendorID {
|
||||
// 发生这种情况的原因就是两个接单事件几乎同时到达(来不及取消),也算正常
|
||||
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
globals.SugarLogger.Infof("OnWaybillStatusChanged Accepted orderID:%s got multiple bill:%v", order.VendorOrderID, bill)
|
||||
}
|
||||
if isBillAlreadyCandidate && !s.isWaybillCourierSame(savedOrderInfo, bill) && !model.IsWaybillPlatformOwn(bill) {
|
||||
s.notify3rdPartyWaybill(order, bill, isBillAlreadyCandidate)
|
||||
@@ -773,7 +760,6 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
if !s.isBillCandidate(order, bill) {
|
||||
// 一般只会消息乱序才会到这里,即新订单消息在运单接单消息后到达
|
||||
// 典型的一个:1223633660228537567
|
||||
globals.SugarLogger.Infof("OnWaybillStatusChanged Delivered order(%d, %s) bill(%d, %s), bill:%v shouldn't get here", order.WaybillVendorID, order.VendorWaybillID, bill.WaybillVendorID, bill.VendorWaybillID, bill)
|
||||
if !model.IsOrderHaveWaybill(order) {
|
||||
s.updateOrderByBill(order, bill, false)
|
||||
}
|
||||
@@ -822,7 +808,6 @@ func (s *DefScheduler) cancelWaybillNotInStoreOpentime(savedOrderInfo *WatchOrde
|
||||
time3 := jxutils.JxOperationTime2TimeByDate(storeDetail.OpenTime2, time.Now())
|
||||
time4 := jxutils.JxOperationTime2TimeByDate(storeDetail.CloseTime2, time.Now())
|
||||
if time.Now().Sub(time3) < 0 || time.Now().Sub(time4.Add(time.Minute*30)) > 0 {
|
||||
globals.SugarLogger.Debug("不在营业时间范围内取消订单")
|
||||
s.CancelWaybill(bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonNotInStoreOpenTime)
|
||||
//s.reverseBrandAccount(storeDetail, bill)
|
||||
}
|
||||
@@ -869,7 +854,6 @@ func (s *DefScheduler) onEbaiWaybillCanceled(savedOrderInfo *WatchOrderInfo, exc
|
||||
jxutils.CallMsgHandlerAsync(func() {
|
||||
ts := s.loadSavedOrderFromMap(model.Order2Status(order), true)
|
||||
order := ts.order
|
||||
globals.SugarLogger.Debugf("fire timer ebai waybill cancled, orderID:%s, status:%d", order.VendorOrderID, order.Status)
|
||||
if order.Status < model.OrderStatusDelivering && order.LockStatus == model.OrderStatusLocked {
|
||||
msgContent := fmt.Sprintf("门店:%d,订单:%s的平台运单被取消了,可能导致订单被取消,请重点关注,必要的话可以先手动转自送", jxutils.GetSaleStoreIDFromOrder(order), order.VendorOrderID)
|
||||
s.notifyOrderStakeHolder(order, "", msgContent)
|
||||
@@ -891,7 +875,6 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
||||
if !savedOrderInfo.isDeliveryCompetition {
|
||||
globals.SugarLogger.Debugf("createWaybillOn3rdProviders orderID:%s门店没有设置配送竞争", order.VendorOrderID)
|
||||
}
|
||||
globals.SugarLogger.Debugf("createWaybillOn3rdProviders, orderID:%s, status:%d, maxDeliveryFee:%d, excludeBill:%v", order.VendorOrderID, order.Status, maxDeliveryFee, excludeBill)
|
||||
if err = s.canOrderCreateWaybillNormally(order, savedOrderInfo); err == nil {
|
||||
if (order.DeliveryFlag & model.OrderDeliveryFlagMaskScheduleDisabled) == 0 {
|
||||
if savedOrderInfo.retryCount <= maxWaybillRetryCount {
|
||||
@@ -939,13 +922,11 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
||||
storeDetail, err = dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, "")
|
||||
//}
|
||||
if storeDetail != nil {
|
||||
globals.SugarLogger.Debugf("三方运单门店营业时间范围 orderID: %s :time1 %v ,time2 %v", order.VendorOrderID, storeDetail.OpenTime1, storeDetail.CloseTime1)
|
||||
if storeDetail.OpenTime1 != 0 && storeDetail.CloseTime1 != 0 {
|
||||
time1 := jxutils.JxOperationTime2TimeByDate(storeDetail.OpenTime1, time.Now())
|
||||
time2 := jxutils.JxOperationTime2TimeByDate(storeDetail.CloseTime1, time.Now())
|
||||
if time.Now().Sub(time1) < 0 || time.Now().Sub(time2.Add(time.Minute*30)) > 0 {
|
||||
if storeDetail.OpenTime2 != 0 && storeDetail.CloseTime2 != 0 {
|
||||
globals.SugarLogger.Debugf("三方运单门店营业时间范围 :time3 %v ,time4 %v", storeDetail.OpenTime2, storeDetail.CloseTime2)
|
||||
time3 := jxutils.JxOperationTime2TimeByDate(storeDetail.OpenTime2, time.Now())
|
||||
time4 := jxutils.JxOperationTime2TimeByDate(storeDetail.CloseTime2, time.Now())
|
||||
if time.Now().Sub(time3) < 0 || time.Now().Sub(time4.Add(time.Minute*30)) > 0 {
|
||||
@@ -974,7 +955,6 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
||||
errMsg := fmt.Sprintf("订单:%s已经自动创建过了%d次运单,仍然无法配送,请关注!", order.VendorOrderID, savedOrderInfo.retryCount)
|
||||
err = fmt.Errorf(errMsg)
|
||||
s.notifyOrderStakeHolder(order, "", errMsg)
|
||||
globals.SugarLogger.Infof("createWaybillOn3rdProviders [运营2]同一订单orderID:%s尝试了%d次创建运单失败, 停止调度,如果还需要发单,请人工处理", order.VendorOrderID, savedOrderInfo.retryCount)
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("createWaybillOn3rdProviders, orderID:%s, store:%d dont't support 3rd delivery platform", order.VendorOrderID, jxutils.GetSaleStoreIDFromOrder(order))
|
||||
@@ -989,7 +969,6 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
||||
}
|
||||
|
||||
func (s *DefScheduler) cancelOtherWaybillsCheckOrderDeliveryFlag(savedOrderInfo *WatchOrderInfo, bill2Keep *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
||||
globals.SugarLogger.Debugf("cancelOtherWaybillsCheckOrderDeliveryFlag, orderID:%s, bill:%v", savedOrderInfo.order.VendorOrderID, bill2Keep)
|
||||
if (savedOrderInfo.order.DeliveryFlag & model.OrderDeliveryFlagMaskScheduleDisabled) == 0 {
|
||||
err = s.cancelOtherWaybills(savedOrderInfo, bill2Keep, cancelReasonID, cancelReason)
|
||||
} else {
|
||||
@@ -1014,7 +993,6 @@ func (s *DefScheduler) solutionJdsOrder(bill *model.Waybill) (err error) {
|
||||
}
|
||||
|
||||
func (s *DefScheduler) cancelOtherWaybills(savedOrderInfo *WatchOrderInfo, bill2Keep *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
||||
globals.SugarLogger.Debugf("cancelOtherWaybills, orderID:%s, bill:%v", savedOrderInfo.order.VendorOrderID, bill2Keep)
|
||||
for _, v := range savedOrderInfo.waybills {
|
||||
if v.Status < model.WaybillStatusEndBegin &&
|
||||
!model.IsWaybillPlatformOwn(v) &&
|
||||
@@ -1050,7 +1028,6 @@ func (s *DefScheduler) swtich2SelfDeliverWithRetry(savedOrderInfo *WatchOrderInf
|
||||
})
|
||||
} else {
|
||||
errStr := fmt.Sprintf("订单:%s转自配送失败, 错误信息:%v", order.VendorOrderID, err)
|
||||
globals.SugarLogger.Info(errStr)
|
||||
if strings.Contains(err.Error(), "1047") {
|
||||
if err := s.SelfDeliverDelivering(order, "非专送、快送、混合送订单,转自送失败,调用deriving转自送"); err != nil {
|
||||
s.notify3rdPartyWaybill(order, bill, false)
|
||||
@@ -1084,7 +1061,6 @@ func (s *DefScheduler) swtich2SelfDeliverWithRetry(savedOrderInfo *WatchOrderInf
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"DeliveryFlag"})
|
||||
|
||||
// 进到这里的原因是,在这个时间点,购物平台物流已经抢单(但抢单消息还没有被收到),所以转自送会失败 (比如:818810379000941),更好的做法应该是判断Swtich2SelfDeliver的返回值,这种情况下就不得试了
|
||||
globals.SugarLogger.Infof("swtich2SelfDeliverWithRetry orderID:%s status is wrong(maybe purchase platform accepted waybill)", order.VendorOrderID)
|
||||
partner.CurOrderManager.OnOrderMsg(order, "转商家自配送失败", "平台物流已接单")
|
||||
// globals.SugarLogger.Warnf("swtich2SelfDeliverWithRetry orderID:%s status is wrong, order details:%v", order.VendorOrderID, order)
|
||||
}
|
||||
@@ -1092,14 +1068,11 @@ func (s *DefScheduler) swtich2SelfDeliverWithRetry(savedOrderInfo *WatchOrderInf
|
||||
|
||||
// 这个函数这样写的原因是适应一些消息错序
|
||||
func (s *DefScheduler) loadSavedOrderFromMap(status *model.OrderStatus, isForceLoad bool) *WatchOrderInfo {
|
||||
globals.SugarLogger.Debugf("loadSavedOrderFromMap status:%v", status)
|
||||
universalOrderID := jxutils.ComposeUniversalOrderID(status.RefVendorOrderID, status.RefVendorID)
|
||||
var realSavedInfo *WatchOrderInfo
|
||||
if savedInfo, ok := s.orderMap.Load(universalOrderID); ok {
|
||||
globals.SugarLogger.Debugf("loadSavedOrderFromMap step 1")
|
||||
realSavedInfo = savedInfo.(*WatchOrderInfo)
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("loadSavedOrderFromMap step 2")
|
||||
realSavedInfo = NewWatchOrderInfo(nil)
|
||||
s.orderMap.StoreWithTimeout(universalOrderID, realSavedInfo, orderMapStoreMaxTime)
|
||||
}
|
||||
@@ -1115,7 +1088,6 @@ func (s *DefScheduler) loadSavedOrderFromMap(status *model.OrderStatus, isForceL
|
||||
OrderCreatedAt: status.StatusTime,
|
||||
WaybillVendorID: model.VendorIDUnknown,
|
||||
})
|
||||
globals.SugarLogger.Infof("loadSavedOrderFromMap can not load order orderID:%s with error:%v", status.RefVendorOrderID, err)
|
||||
}
|
||||
}
|
||||
return realSavedInfo
|
||||
@@ -1133,7 +1105,6 @@ func (s *DefScheduler) resetTimer(savedOrderInfo *WatchOrderInfo, bill *model.Wa
|
||||
vendorID = bill.WaybillVendorID
|
||||
statusTime = bill.StatusTime
|
||||
}
|
||||
globals.SugarLogger.Debugf("resetTimer, orderID:%s statusType:%d status:%d", order.VendorOrderID, statusType, status)
|
||||
config := s.mergeOrderStatusConfig(savedOrderInfo, statusTime, statusType, status)
|
||||
|
||||
stopStatusType := statusType
|
||||
@@ -1149,8 +1120,6 @@ func (s *DefScheduler) resetTimer(savedOrderInfo *WatchOrderInfo, bill *model.Wa
|
||||
}
|
||||
|
||||
if config != nil && config.TimeoutAction != nil && config.TimerType != partner.TimerTypeByPass {
|
||||
globals.SugarLogger.Debugf("CallShouldSetTimer : savedOrderInfo : %v, %v", savedOrderInfo, savedOrderInfo.isNeedCreate3rdWaybill)
|
||||
globals.SugarLogger.Debugf("CallShouldSetTimer : order : %v, waybill: %v", utils.Format4Output(savedOrderInfo.order, true), utils.Format4Output(bill, true))
|
||||
if config.CallShouldSetTimer(savedOrderInfo, bill) {
|
||||
timeout := config.GetRefTimeout(statusTime, order.OrderCreatedAt)
|
||||
if config.TimeoutGap != 0 {
|
||||
@@ -1170,6 +1139,7 @@ func (s *DefScheduler) resetTimer(savedOrderInfo *WatchOrderInfo, bill *model.Wa
|
||||
} else if statusType == model.OrderTypeWaybill {
|
||||
timerName = model.WaybillStatusName[status]
|
||||
}
|
||||
globals.SugarLogger.Debugf("timerName %s", timerName)
|
||||
timerInfo := &tTimerInfo{
|
||||
statusType: statusType,
|
||||
vendorID: vendorID,
|
||||
@@ -1178,7 +1148,6 @@ func (s *DefScheduler) resetTimer(savedOrderInfo *WatchOrderInfo, bill *model.Wa
|
||||
}
|
||||
timerInfo.timer = utils.AfterFuncWithRecover(timeout, func() {
|
||||
jxutils.CallMsgHandlerAsync(func() {
|
||||
globals.SugarLogger.Debugf("fire timer:%s, orderID:%s", timerName, order.VendorOrderID)
|
||||
ts := s.loadSavedOrderFromMap(model.Order2Status(order), true)
|
||||
config.CallTimeoutAction(ts, bill)
|
||||
timerInfo.timer = nil
|
||||
@@ -1187,7 +1156,6 @@ func (s *DefScheduler) resetTimer(savedOrderInfo *WatchOrderInfo, bill *model.Wa
|
||||
})
|
||||
savedOrderInfo.AddTimer(timerInfo)
|
||||
}
|
||||
globals.SugarLogger.Debugf("resetTimer, orderID:%s, statusType:%d, status:%d, timeout:%v", order.VendorOrderID, statusType, status, timeout)
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("resetTimer, orderID:%s, statusType:%d, status:%d, should not set timer", order.VendorOrderID, statusType, status)
|
||||
}
|
||||
@@ -1377,7 +1345,6 @@ func (s *DefScheduler) mergeOrderStatusConfig(savedOrderInfo *WatchOrderInfo, st
|
||||
}
|
||||
|
||||
func (s *DefScheduler) handleAutoAcceptOrder(orderID string, vendorID int, userMobile string, jxStoreID int, db orm.Ormer, handler func(accepted bool) error) int {
|
||||
globals.SugarLogger.Debugf("handleAutoAcceptOrder order:%s, vendorID:%d", orderID, vendorID)
|
||||
handleType := 0
|
||||
if userMobile != "" {
|
||||
if db == nil {
|
||||
@@ -1394,11 +1361,11 @@ func (s *DefScheduler) handleAutoAcceptOrder(orderID string, vendorID int, userM
|
||||
handleType = 1
|
||||
} else {
|
||||
// 强制拒单
|
||||
globals.SugarLogger.Infof("handleAutoAcceptOrder force reject order:%s, vendorID:%d", orderID, vendorID)
|
||||
//globals.SugarLogger.Infof("handleAutoAcceptOrder force reject order:%s, vendorID:%d", orderID, vendorID)
|
||||
handleType = -1
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Infof("handleAutoAcceptOrder order:%s, vendorID:%d, mobile is empty, should accept order", orderID, vendorID)
|
||||
//globals.SugarLogger.Infof("handleAutoAcceptOrder order:%s, vendorID:%d, mobile is empty, should accept order", orderID, vendorID)
|
||||
handleType = 1
|
||||
}
|
||||
if handleType == 1 {
|
||||
@@ -1453,7 +1420,6 @@ func (s *DefScheduler) updateStoreAccount(order *model.GoodsOrder, bill *model.W
|
||||
}
|
||||
|
||||
func (s *DefScheduler) updateBrandAccount(store *dao.StoreDetail, bill *model.Waybill) {
|
||||
globals.SugarLogger.Debugf("updateBrandAccount bill: %v", utils.Format4Output(bill, true))
|
||||
brandBills, _ := dao.GetBrandBill(dao.GetDB(), store.BrandID, bill.VendorOrderID, model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorWaybillID)
|
||||
if len(brandBills) == 0 {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, int(bill.DesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorOrderID, bill.VendorWaybillID)
|
||||
@@ -1471,7 +1437,6 @@ func (s *DefScheduler) updateBrandAccount(store *dao.StoreDetail, bill *model.Wa
|
||||
|
||||
// 取消退费
|
||||
func (s *DefScheduler) reverseBrandAccount(store *dao.StoreDetail, bill *model.Waybill) {
|
||||
globals.SugarLogger.Debugf("reverseBrandAccount bill: %v", utils.Format4Output(bill, true))
|
||||
brandBills, _ := dao.GetBrandBill(dao.GetDB(), store.BrandID, bill.VendorOrderID, model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorWaybillID)
|
||||
if len(brandBills) > 0 {
|
||||
sum := 0
|
||||
@@ -1644,8 +1609,6 @@ func (s *DefScheduler) isBillCandidate(order *model.GoodsOrder, bill *model.Wayb
|
||||
}
|
||||
|
||||
func (s *DefScheduler) ProxyCancelWaybill(order *model.GoodsOrder, bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
||||
globals.SugarLogger.Debugf("ProxyCancelWaybill orderID:%s", order.VendorOrderID)
|
||||
|
||||
if (order.DeliveryFlag & model.OrderDeliveryFlagMaskScheduleDisabled) == 0 {
|
||||
if err = s.CancelWaybill(bill, cancelReasonID, cancelReason); err != nil {
|
||||
partner.CurOrderManager.OnOrderMsg(order, "取消三方运单失败", err.Error())
|
||||
@@ -1658,7 +1621,6 @@ func (s *DefScheduler) ProxyCancelWaybill(order *model.GoodsOrder, bill *model.W
|
||||
}
|
||||
return err
|
||||
}
|
||||
globals.SugarLogger.Debugf("ProxyCancelWaybill orderID:%s stop schedule, bypass CancelWaybill", order.VendorOrderID)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1672,7 +1634,6 @@ func OnDefSchConfChanged(key, value string) {
|
||||
}()
|
||||
conf := FixedScheduler.defWorkflowConfig[1][model.WaybillStatusNew]
|
||||
conf.Timeout = time.Duration(waitMinutes) * time.Minute
|
||||
globals.SugarLogger.Debugf("defsch wait miniutes 4 3rd delivery changed to:%d", waitMinutes)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1755,7 +1716,6 @@ func OrderProfitWarning(order *model.GoodsOrder) {
|
||||
return
|
||||
}
|
||||
if order.TotalShopMoney == 0 {
|
||||
globals.SugarLogger.Debugf("OrderProfitWarning TotalShopMoney=0 orderID:%s", order.VendorOrderID)
|
||||
return
|
||||
}
|
||||
storeID := jxutils.GetShowStoreIDFromOrder(order)
|
||||
@@ -1780,7 +1740,6 @@ func OrderProfitWarning(order *model.GoodsOrder) {
|
||||
profit = utils.Str2Float64(utils.Int64ToStr(order.TotalShopMoney*int64(payPercentage)/200)) / 100
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debugf("OrderProfitWarning profit : %v", profit)
|
||||
if profit < 0 {
|
||||
operatorPhone, operatorName := getOrderOperatorInfo(order, storeDetail)
|
||||
operatorRole := getOrderOperatorRoleInfo(order, storeDetail)
|
||||
|
||||
@@ -6,8 +6,6 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||
@@ -29,12 +27,10 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven
|
||||
var order *model.GoodsOrder
|
||||
jxutils.CallMsgHandler(func() {
|
||||
err = func() (err error) {
|
||||
globals.SugarLogger.Infof("SelfDeliveringAndUpdateStatus orderID:%s userName:%s", vendorOrderID, userName)
|
||||
savedOrderInfo := s.loadSavedOrderByID(vendorOrderID, vendorID, true)
|
||||
if savedOrderInfo != nil {
|
||||
order = savedOrderInfo.order
|
||||
if err = s.isPossibleSwitch2SelfDelivery(order); err == nil {
|
||||
globals.SugarLogger.Infof("SelfDeliveringAndUpdateStatus ordersavedOrderInfoID:%s", utils.Format4Output(savedOrderInfo, false))
|
||||
err = s.cancelOtherWaybillsCheckOrderDeliveryFlag(savedOrderInfo, nil, partner.CancelWaybillReasonOther, partner.CancelWaybillReasonStrActive)
|
||||
if err == nil {
|
||||
if model.IsOrderDeliveryByStore(order) {
|
||||
@@ -60,7 +56,6 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven
|
||||
order.DeliveryFlag |= model.OrderDeliveryFlagMaskScheduleDisabled | model.OrderDeliveryFlagMaskPurcahseDisabled
|
||||
if err = partner.CurOrderManager.UpdateOrderStatusAndDeliveryFlag(order); err == nil {
|
||||
s.stopTimer(savedOrderInfo)
|
||||
globals.SugarLogger.Infof("SelfDeliveringAndUpdateStatus orderID:%s userName:%s successfully", vendorOrderID, userName)
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -71,7 +66,6 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven
|
||||
}
|
||||
err = scheduler.ErrCanNotFindOrder
|
||||
}
|
||||
globals.SugarLogger.Infof("SelfDeliveringAndUpdateStatus orderID:%s userName:%s error:%v", vendorOrderID, userName, err)
|
||||
return err
|
||||
}()
|
||||
}, jxutils.ComposeUniversalOrderID(vendorOrderID, vendorID))
|
||||
@@ -228,7 +222,6 @@ func (s *DefScheduler) CreateWaybillOnProviders4SavedOrder(ctx *jxcontext.Contex
|
||||
}
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debugf("CreateWaybillOnProviders4SavedOrder orderID:%s userName:%s successfully", order.VendorOrderID, ctx.GetUserName())
|
||||
return bills, err
|
||||
}
|
||||
}
|
||||
@@ -252,8 +245,6 @@ func (s *DefScheduler) CreateWaybillOnProvidersEx(ctx *jxcontext.Context, vendor
|
||||
|
||||
billFunc := func() {
|
||||
bills, err = func() (bills []*model.Waybill, err error) {
|
||||
userName := ctx.GetUserName()
|
||||
globals.SugarLogger.Debugf("CreateWaybillOnProvidersEx orderID:%s userName:%s", vendorOrderID, userName)
|
||||
if vendorID == model.VendorIDELM {
|
||||
return nil, fmt.Errorf("不要直接使用饿了么订单号,请使用相应的饿百订单号")
|
||||
}
|
||||
@@ -283,7 +274,6 @@ func (s *DefScheduler) CreateWaybillOnProvidersEx(ctx *jxcontext.Context, vendor
|
||||
} else {
|
||||
err = scheduler.ErrCanNotFindOrder
|
||||
}
|
||||
globals.SugarLogger.Infof("CreateWaybillOnProvidersEx orderID:%s userName:%s error:%v", vendorOrderID, userName, err)
|
||||
return bills, err
|
||||
}()
|
||||
}
|
||||
@@ -320,7 +310,6 @@ func (s *DefScheduler) CheckStoreBalance(ctx *jxcontext.Context, order *model.Go
|
||||
//前者无,表示就是第一次发,直接扣
|
||||
//2、小程序里这次金额用发单平台的金额,后台里这次金额用所有平台最高费用
|
||||
isEqual, isZero, err := partner.CurStoreAcctManager.CheckStoreAcctExpendExist(order.VendorOrderID)
|
||||
globals.SugarLogger.Debugf("CheckStoreBalance orderID :%v, isEqual : %v, isZero: %v", order.VendorOrderID, isEqual, isZero)
|
||||
//表示前者有,后者无
|
||||
if !isZero && !isEqual {
|
||||
var newPrice int64
|
||||
@@ -392,21 +381,18 @@ func (s *DefScheduler) CancelAll3rdWaybills(ctx *jxcontext.Context, vendorOrderI
|
||||
jxutils.CallMsgHandler(func() {
|
||||
err = func() (err error) {
|
||||
// 取消三方运单,取消各平台单号信息,间隔一段时间后定时任务重新调度
|
||||
globals.SugarLogger.Infof("CancelAll3rdWaybills orderID:%s userName:%s", vendorOrderID, ctx.GetUserName())
|
||||
savedOrderInfo := s.loadSavedOrderByID(vendorOrderID, vendorID, true)
|
||||
if savedOrderInfo != nil {
|
||||
err = s.cancelOtherWaybills(savedOrderInfo, nil, partner.CancelWaybillReasonOther, partner.CancelWaybillReasonStrActive)
|
||||
} else {
|
||||
err = scheduler.ErrCanNotFindOrder
|
||||
}
|
||||
globals.SugarLogger.Infof("CancelAll3rdWaybills orderID:%s userName:%s error:%v", vendorOrderID, ctx.GetUserName(), err)
|
||||
// 停止调度,同事停止订单调度,不在通知第三方
|
||||
if err == nil && isStopSchedule {
|
||||
order := savedOrderInfo.order
|
||||
order.DeliveryFlag |= model.OrderDeliveryFlagMaskScheduleDisabled
|
||||
if err = partner.CurOrderManager.UpdateOrderStatusAndDeliveryFlag(order); err == nil {
|
||||
s.stopTimer(savedOrderInfo)
|
||||
globals.SugarLogger.Infof("CancelAll3rdWaybills orderID:%s userName:%s successfully", vendorOrderID, ctx.GetUserName())
|
||||
}
|
||||
}
|
||||
return err
|
||||
@@ -419,9 +405,6 @@ func (s *DefScheduler) CancelAll3rdWaybills(ctx *jxcontext.Context, vendorOrderI
|
||||
func (s *DefScheduler) QueryOrderWaybillFeeInfoEx(ctx *jxcontext.Context, vendorOrderID string, vendorID int) (deliveryFeeMap map[int]*partner.WaybillFeeInfo, err error) {
|
||||
jxutils.CallMsgHandler(func() {
|
||||
deliveryFeeMap, err = func() (deliveryFeeMap map[int]*partner.WaybillFeeInfo, err error) {
|
||||
userName := ctx.GetUserName()
|
||||
globals.SugarLogger.Infof("GetWaybillsInfoEx orderID:%s userName:%s", vendorOrderID, userName)
|
||||
|
||||
db := dao.GetDB()
|
||||
order, err := partner.CurOrderManager.LoadOrder(vendorOrderID, vendorID)
|
||||
if err != nil {
|
||||
|
||||
@@ -211,7 +211,6 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
|
||||
if act.Type != model.ActSkuFake {
|
||||
effectActStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, act.Type, storeIDs, skuIDs, act.BeginAt, act.EndAt)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("GetEffectiveActStoreSkuInfo can not get sku promotion info for error:%v", err)
|
||||
return nil, nil, nil, nil, err
|
||||
}
|
||||
if len(effectActStoreSkuList) > 0 {
|
||||
@@ -805,9 +804,6 @@ func vendorActInfo2Model(ctx *jxcontext.Context, db *dao.DaoDB, act2 *model.Act2
|
||||
vendorStoreIDMap[v.VendorStoreID] = 1
|
||||
vendorSkuIDMap[v.VendorSkuID] = 1
|
||||
}
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(vendorStoreIDMap, false))
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(vendorSkuIDMap, false))
|
||||
|
||||
vendorID := act2.VendorID
|
||||
storeSkuList, err2 := dao.GetStoresSkusInfoByVendorInfo(db, vendorID, jxutils.StringMap2List(vendorStoreIDMap), jxutils.StringMap2List(vendorSkuIDMap))
|
||||
if err = err2; err != nil {
|
||||
@@ -855,7 +851,6 @@ func vendorActInfo2Model(ctx *jxcontext.Context, db *dao.DaoDB, act2 *model.Act2
|
||||
}
|
||||
|
||||
func (a *ActManager) CreateActFromVendor(ctx *jxcontext.Context, act2 *model.Act2, actStoreSku []*model.ActStoreSku2) (actID int, err error) {
|
||||
globals.SugarLogger.Debugf("CreateActFromVendor vendorID:%d, vendorActID:%s", act2.VendorID, act2.VendorActID)
|
||||
db := dao.GetDB()
|
||||
return createActFromVendor(ctx, db, act2, actStoreSku)
|
||||
}
|
||||
@@ -1185,25 +1180,15 @@ func RefreshPageActs(ctx *jxcontext.Context, vendorIDs []int, createdFrom time.T
|
||||
if handler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformPageActHandler); handler != nil {
|
||||
db := dao.GetDB()
|
||||
actList, err2 := handler.GetPageActList(ctx, createdFrom)
|
||||
globals.SugarLogger.Debug(utils.Format4Output(actList, false))
|
||||
if err = err2; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// actInfo, err2 := dao.QueryActs(db, 0, 0, -1, -1, "", vendorID, nil, []int{model.ActCreateTypeSpider},
|
||||
// nil, 0, nil, 0, utils.DefaultTimeValue, utils.DefaultTimeValue, createdFrom, utils.DefaultTimeValue)
|
||||
vendorActIDs, err2 := dao.GetExistVendorActIDs(db, vendorID)
|
||||
if err = err2; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
localActMap := jxutils.StringList2Map(vendorActIDs)
|
||||
// localActMap := make(map[string]*dao.ActVendorInfo)
|
||||
// for _, v := range vendorActIDs {
|
||||
// if v.VendorList[0].VendorActID != "" {
|
||||
// localActMap[v.VendorList[0].VendorActID] = v
|
||||
// }
|
||||
// }
|
||||
var needAddActList []*model.Act2
|
||||
// var needUpdateActList []*model.Act
|
||||
for _, v := range actList {
|
||||
localAct := localActMap[v.VendorActID]
|
||||
if localAct == 0 {
|
||||
@@ -1351,7 +1336,6 @@ func DeleteSkusFromAct(ctx *jxcontext.Context, vendorID int, actTypes, skuIDs []
|
||||
}
|
||||
}
|
||||
if len(deleteList) > 0 {
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(deleteList, false))
|
||||
originSyncStatus, err2 := DeleteActStoreSkuBind(ctx, db, actID, deleteList)
|
||||
if err = err2; err == nil && originSyncStatus == 0 {
|
||||
if _, err = SyncAct(ctx, task, actID, nil, false); err == nil {
|
||||
@@ -1715,7 +1699,6 @@ func ChangeJxPriceByDiscountAct(ctx *jxcontext.Context) {
|
||||
db = dao.GetDB()
|
||||
pageSize = 9999
|
||||
)
|
||||
globals.SugarLogger.Debug("ChangeJxPriceByDiscountAct begin:")
|
||||
page, err := dao.QueryActs(db, 0, 0, pageSize, -1, "", model.VendorIDJX, []int{model.YES}, []int{model.ActSkuDiscount}, nil, 0, nil, 0, utils.ZeroTimeValue, utils.ZeroTimeValue, time.Now().AddDate(0, -3, 0), time.Now())
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
// todo 是否需要将Store.MarketManPhone与OperatorPhone成角色?
|
||||
|
||||
func TransferLegacyWeixins(mobile string) (err error) {
|
||||
globals.SugarLogger.Debugf("TransferLegacyWeixins mobile:%s", mobile)
|
||||
if !globals.EnableWXAuth2 || globals.DisableWXAuth1 {
|
||||
return nil
|
||||
}
|
||||
@@ -75,7 +74,6 @@ func TransferLegacyWeixins(mobile string) (err error) {
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(user, false))
|
||||
if len(userList) == 0 {
|
||||
err = CreateUser(user, v.LastOperator)
|
||||
} else {
|
||||
|
||||
@@ -65,10 +65,9 @@ func GetStoreMessages(ctx *jxcontext.Context, msgIDs, storeIDs, types []int, fro
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
db := dao.GetDB()
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer dao.Commit(db, txDB)
|
||||
var msgList []*model.Message
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
if err = dao.GetRowsTx(txDB, &msgList, sql, sqlParams...); err == nil {
|
||||
pagedInfo = &model.PagedInfo{
|
||||
TotalCount: dao.GetLastTotalRowCount2(db, txDB),
|
||||
@@ -124,11 +123,9 @@ func GetStoreMessageStatuses(ctx *jxcontext.Context, msgIDs, storeIDs, confirmSt
|
||||
sql += " LIMIT ? OFFSET ?"
|
||||
sqlParams = append(sqlParams, jxutils.FormalizePageSize(pageSize), offset)
|
||||
db := dao.GetDB()
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer dao.Commit(db, txDB)
|
||||
var msgStatusList []*MessageStatusExt
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
||||
if err = dao.GetRowsTx(txDB, &msgStatusList, sql, sqlParams...); err == nil {
|
||||
pagedInfo = &model.PagedInfo{
|
||||
TotalCount: dao.GetLastTotalRowCount2(db, txDB),
|
||||
|
||||
@@ -108,7 +108,6 @@ func GetCategories(ctx *jxcontext.Context, parentID int, isExd bool) (catList []
|
||||
ids = append(ids, v.ID)
|
||||
}
|
||||
//thingMapMap, err2 := dao.GetThingMapMap(db, model.ThingTypeCategory, nil, ids)
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(thingMapMap, false))
|
||||
//if err = err2; err == nil {
|
||||
for _, v := range cats {
|
||||
catList = append(catList, &dao.SkuCategoryWithVendor{
|
||||
@@ -787,7 +786,6 @@ func IsSensitiveWordInList(str string) (bool, string) {
|
||||
for index > 0 {
|
||||
index = strings.Index(keyWord, ",")
|
||||
keyWord = keyWord[:index-1]
|
||||
globals.SugarLogger.Debug("keyWord", keyWord)
|
||||
checkHas := strings.Contains(str, keyWord)
|
||||
if checkHas {
|
||||
return true, keyWord
|
||||
@@ -948,7 +946,6 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s
|
||||
}
|
||||
|
||||
func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interface{}, isExd bool) (num int64, err error) {
|
||||
globals.SugarLogger.Debugf("=====------%s", utils.Format4Output(payload, false))
|
||||
userName := ctx.GetUserName()
|
||||
skuName := &model.SkuName{}
|
||||
skuName.ID = nameID
|
||||
@@ -1025,8 +1022,6 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
||||
}
|
||||
}()
|
||||
// valid[model.FieldJdSyncStatus] = model.SyncFlagModifiedMask | skuName.JdSyncStatus
|
||||
globals.SugarLogger.Debugf("skuname====%s", utils.Format4Output(skuName, false))
|
||||
globals.SugarLogger.Debugf("skuname====%s", utils.Format4Output(valid, false))
|
||||
if num, err = dao.UpdateEntityLogically(db, skuName, valid, userName, nil); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return 0, err
|
||||
@@ -1340,7 +1335,6 @@ func UpdateSku(ctx *jxcontext.Context, skuID int, payload map[string]interface{}
|
||||
var beforSku = *sku
|
||||
valid := dao.StrictMakeMapByStructObject(payload, sku, userName)
|
||||
if len(valid) > 0 {
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(valid, false))
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -1849,7 +1843,6 @@ func SumExianDaDepot(ctx *jxcontext.Context, isAsync, isContinueWhenError bool)
|
||||
v := batchItemList[0].(*ebaiapi.ExianDaSkus)
|
||||
skus, err := api.EbaiAPI.GetExianDaSku(utils.Str2Int64(v.ElemeGoodsID))
|
||||
if err != nil || skus == nil {
|
||||
globals.SugarLogger.Debugf("GetExianDaSku,[%v]", v.ElemeGoodsID)
|
||||
return result, err
|
||||
}
|
||||
// sku := &model.Sku{}
|
||||
@@ -2005,7 +1998,6 @@ func SendNoCatSkusToOperater(ctx *jxcontext.Context) (err error) {
|
||||
db = dao.GetDB()
|
||||
skuNames []*model.SkuName
|
||||
)
|
||||
globals.SugarLogger.Debugf("SendNoCatSkusToOperater")
|
||||
sql := `
|
||||
SELECT * FROM sku_name WHERE deleted_at = ? AND (category_id = ? OR img = ?) AND unit <> ?
|
||||
`
|
||||
@@ -2419,7 +2411,6 @@ func RefreshJdDepot(ctx *jxcontext.Context) (err error) {
|
||||
time.Sleep(time.Second * 1)
|
||||
_, err = api.JdAPI.UpdateSku2(param)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("RefreshJdDepot UpdateSku2", err.Error())
|
||||
continue
|
||||
}
|
||||
api.JdAPI.RefreshJdDepot(v.JdID)
|
||||
|
||||
@@ -628,8 +628,6 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
//mapLimit := false
|
||||
//globals.SugarLogger.Debug(sql)
|
||||
//globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
||||
txDB, _ := dao.Begin(db)
|
||||
if err = dao.GetRowsTx(txDB, &storeList, sql, sqlParams...); err == nil {
|
||||
retVal.Stores = storeList
|
||||
@@ -738,7 +736,6 @@ func filterStoreByOrderInfo(db *dao.DaoDB, inStores []*StoreExt, orderTimeFrom,
|
||||
}
|
||||
|
||||
func getMapCenter(storeList []*StoreExt) (lng, lat float64) {
|
||||
globals.SugarLogger.Debugf("getMapCenter len(storeList):%d", len(storeList))
|
||||
if len(storeList) == 0 {
|
||||
return 0, 0
|
||||
}
|
||||
@@ -774,7 +771,6 @@ func getMapCenter(storeList []*StoreExt) (lng, lat float64) {
|
||||
// for _, store := range storeList {
|
||||
// globals.SugarLogger.Debugf("store:%s, lng:%, lat:%f", store.Name, store.FloatLng, store.FloatLat)
|
||||
// }
|
||||
// globals.SugarLogger.Debugf("lng:%f, lat:%f", lng, lat)
|
||||
return lng, lat
|
||||
}
|
||||
return getMapCenter(newStoreList)
|
||||
@@ -869,7 +865,6 @@ func checkStoreDeliveryRange(deliveryRange string) (err error) {
|
||||
}
|
||||
|
||||
func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
||||
globals.SugarLogger.Debugf("UpdateStore storeID:%d, payload:%s", storeID, utils.Format4Output(payload, true))
|
||||
if err = checkBankBranch(utils.Interface2String(payload["payeeBankBranchName"])); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -916,7 +911,6 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
store.Name = valid["name"].(string)
|
||||
syncStatus |= model.SyncFlagStoreName
|
||||
}
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(valid, false))
|
||||
printerVendorID := int(utils.Interface2Int64WithDefault(valid["printerVendorID"], 0))
|
||||
if printerVendorID == 0 {
|
||||
printerVendorID = store.PrinterVendorID
|
||||
@@ -981,7 +975,6 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
return 0, err
|
||||
}
|
||||
valid["linkStoreID"] = linkStoreID
|
||||
// globals.SugarLogger.Debug(linkStoreID)
|
||||
}
|
||||
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(valid, false))
|
||||
@@ -1075,7 +1068,6 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
}
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debugf("UpdateStore track:%s, storeID:%d, valid:%s", ctx.GetTrackInfo(), storeID, utils.Format4Output(valid, true))
|
||||
if len(valid) > 0 {
|
||||
if globals.IsAddEvent {
|
||||
mapBefore := refutil.FindMapAndStructMixed(valid, beforStore)
|
||||
@@ -1099,7 +1091,6 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
}, model.FieldSyncStatus, syncStatus)
|
||||
if err = err2; err == nil {
|
||||
dao.Commit(db, txDB)
|
||||
globals.SugarLogger.Debugf("UpdateStore track:%s, before call SyncStore", ctx.GetTrackInfo())
|
||||
_, err = CurVendorSync.SyncStore(ctx, db, -1, store.ID, false, userName)
|
||||
if valid["tel1"] != nil || valid["tel2"] != nil {
|
||||
TryAddStoreBossRole4StoreByMobile(ctx, store.ID, []string{utils.Interface2String(valid["tel1"]), utils.Interface2String(valid["tel2"])})
|
||||
@@ -1209,7 +1200,6 @@ func checkStoreHaveLinkedStore(storeID, linkStoreID int) (err error) {
|
||||
|
||||
// 创建京西门店,同时生成专送门店。
|
||||
func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
|
||||
globals.SugarLogger.Debugf("CreateStore storeExt:%s", utils.Format4Output(storeExt, false))
|
||||
if err = checkBankBranch(storeExt.PayeeBankBranchName); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -1317,7 +1307,6 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
|
||||
|
||||
// 创建京西门店,不在生成专送门店!
|
||||
func CreateStore2JX(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
|
||||
globals.SugarLogger.Debugf("CreateStore storeExt:%s", utils.Format4Output(storeExt, false))
|
||||
if err = checkBankBranch(storeExt.PayeeBankBranchName); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -1744,8 +1733,6 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
dao.Rollback(db, txDB)
|
||||
return 0, err
|
||||
}
|
||||
globals.SugarLogger.Debug("==============num", num)
|
||||
|
||||
if num > 0 {
|
||||
if globals.IsAddEvent {
|
||||
mapBefore := refutil.FindMapAndStructMixed(valid, beforeStoreMap)
|
||||
@@ -1796,7 +1783,6 @@ func DeleteStore(ctx *jxcontext.Context, storeID int) (num int64, err error) {
|
||||
if err = dao.GetRow(db, &ct, sql, storeID, utils.DefaultTimeValue, storeID, utils.DefaultTimeValue); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("DeleteStore storeID:%d, ct=%d", storeID, ct)
|
||||
if ct > 0 {
|
||||
return 0, fmt.Errorf("删除京西门店前必须将所有门店解绑且门店处于关店状态")
|
||||
}
|
||||
@@ -1919,8 +1905,6 @@ func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, keyword string, storeI
|
||||
defer func() {
|
||||
dao.Rollback(db, txDB)
|
||||
}()
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
||||
if err = dao.GetRowsTx(txDB, &commentList, sql, sqlParams...); err == nil {
|
||||
retVal = map[string]interface{}{
|
||||
"total": dao.GetLastTotalRowCount2(db, txDB),
|
||||
@@ -1945,8 +1929,6 @@ func GetStoreCourierMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, ven
|
||||
cond[model.FieldVendorID] = vendorID
|
||||
}
|
||||
err = dao.GetEntitiesByKV(db, &storeCourierMaps, cond, false)
|
||||
globals.SugarLogger.Debug("之前的storeCourierMaps")
|
||||
globals.SugarLogger.Debug(utils.Format4Output(storeCourierMaps, false))
|
||||
if len(storeCourierMaps) != 0 {
|
||||
//同步美团配送与否状态及美团门店是否存在
|
||||
for _, v := range storeCourierMaps {
|
||||
@@ -1954,8 +1936,6 @@ func GetStoreCourierMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, ven
|
||||
continue
|
||||
} else {
|
||||
SetMTPSStatus(jxcontext.AdminCtx, v.StoreID, v.Status)
|
||||
globals.SugarLogger.Debug("之后的storeCourierMaps")
|
||||
globals.SugarLogger.Debug(v)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -1982,7 +1962,6 @@ func addStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID
|
||||
storeCourierMap.StoreID = storeID
|
||||
storeCourierMap.VendorID = vendorID
|
||||
storeCourierMap.VendorStatus = storeCourierMap.Status
|
||||
globals.SugarLogger.Debugf("addStoreCourierMap %s, storeCourierMap:%s, isNeedUpdateRemote:%t", model.VendorChineseNames[vendorID], utils.Format4Output(storeCourierMap, true), isNeedUpdateRemote)
|
||||
|
||||
if handler := partner.GetDeliveryPlatformFromVendorID(vendorID); handler != nil {
|
||||
if db == nil {
|
||||
@@ -2076,8 +2055,6 @@ func UpdateStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendo
|
||||
}
|
||||
|
||||
func updateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (err error) {
|
||||
globals.SugarLogger.Debugf("updateCourierStore %s, storeID:%d, vendorStoreID:%s", model.VendorChineseNames[storeDetail.VendorID], storeDetail.ID, storeDetail.VendorStoreID)
|
||||
|
||||
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(storeDetail.VendorID); handlerInfo != nil && handlerInfo.Use4CreateWaybill {
|
||||
if updateHandler, ok := handlerInfo.Handler.(partner.IDeliveryUpdateStoreHandler); ok {
|
||||
err = updateHandler.UpdateStore(ctx, formalizeStore4Courier(storeDetail))
|
||||
@@ -2093,8 +2070,6 @@ func updateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (
|
||||
//VendorIDMTPS = 102 // 美团配送
|
||||
//VendorIDFengNiao = 103 // 蜂鸟配送
|
||||
func updateCourierStores(ctx *jxcontext.Context, storeID int) (err error) {
|
||||
globals.SugarLogger.Debugf("updateCourierStores storeID:%d", storeID)
|
||||
|
||||
db := dao.GetDB()
|
||||
errList := errlist.New()
|
||||
for k, v := range partner.DeliveryPlatformHandlers {
|
||||
@@ -2139,7 +2114,6 @@ func updateOrCreateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDe
|
||||
remoteStoreDetail, err2 := handlerInfo.Handler.GetStore(ctx, 0, storeDetail.VendorStoreID)
|
||||
if err = err2; err != nil {
|
||||
if handlerInfo.Handler.IsErrStoreNotExist(err) {
|
||||
globals.SugarLogger.Debugf("创建门店的三种方式")
|
||||
// 本地门店同步第三方平台
|
||||
storeDetail.VendorStoreID, storeDetail.AuditStatus, err = handlerInfo.Handler.CreateStore(ctx, storeDetail)
|
||||
if err == nil {
|
||||
@@ -2166,15 +2140,12 @@ func updateOrCreateCourierStore(ctx *jxcontext.Context, storeDetail *dao.StoreDe
|
||||
}
|
||||
if err != nil {
|
||||
err = fmt.Errorf("门店ID:%d,门店名:%s,错误描述:%s", storeDetail.Store.ID, storeDetail.Name, err.Error())
|
||||
globals.SugarLogger.Debugf("updateOrCreateCourierStore storeID:%d failed with error:%v", storeDetail.ID, err)
|
||||
}
|
||||
}
|
||||
return isCreated, err
|
||||
}
|
||||
|
||||
func UpdateOrCreateCourierStores(ctx *jxcontext.Context, storeID int, isForceUpdate, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debugf("UpdateOrCreateCourierStores storeID:%d", storeID)
|
||||
|
||||
var storeIDs []int
|
||||
if storeID != 0 {
|
||||
storeIDs = []int{storeID}
|
||||
@@ -2876,7 +2847,6 @@ func SyncStoresCourierInfo(ctx *jxcontext.Context, storeIDs []int, isAsync, isCo
|
||||
"VendorID": vendorID,
|
||||
})
|
||||
if distance > 0.2 {
|
||||
globals.SugarLogger.Infof("SyncStoresCourierInfo [运营2]门店:%s-%d的%s配送门店坐标不一致,京西:%d,%d,平台:%d,%d,距离:%f公里", store.Name, store.ID, model.VendorChineseNames[vendorID], store.Lng, store.Lat, storeCourier.Lng, storeCourier.Lat, distance)
|
||||
retVal = [][]interface{}{
|
||||
[]interface{}{
|
||||
store,
|
||||
@@ -3235,7 +3205,6 @@ func CreateStorePriceScore(ctx *jxcontext.Context) (err error) {
|
||||
}
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
globals.SugarLogger.Debugf("CreateStorePriceScore")
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -3372,7 +3341,6 @@ func UpdateJdStoreNameAll(ctx *jxcontext.Context) (err error) {
|
||||
_, storeParams.CloseStatus = jd.JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus))
|
||||
}
|
||||
// fillOpTimeParams(storeParams, store.GetOpTimeList())
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(storeParams, false))
|
||||
errList := errlist.New()
|
||||
if globals.EnableJdStoreWrite {
|
||||
errList.AddErr(a.UpdateStoreInfo4Open2(storeParams, modifyCloseStatus))
|
||||
|
||||
@@ -87,7 +87,6 @@ func InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int,
|
||||
storeAcctExpend.ExpID = expendID
|
||||
}
|
||||
err = dao.CreateEntity(db, storeAcctExpend)
|
||||
globals.SugarLogger.Debugf("InsertStoreAcctExpend orderID: [%v] , price :[%v] , type :[%v]", vendorOrderID, price, acctType)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -118,7 +117,6 @@ func (s *StoreAcctManager) UpdateStoreAcctBalance(ctx *jxcontext.Context, storeI
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("UpdateStoreAcctBalance1 storeID: [%v] , balance :[%v] ,", storeID, storeAcct.AccountBalance)
|
||||
if isIncome {
|
||||
storeAcct.AccountBalance += price
|
||||
} else {
|
||||
@@ -158,7 +156,6 @@ func (s *StoreAcctManager) CheckStoreAcctExpendExist(vendorOrderID string) (isEq
|
||||
expends, incomes int
|
||||
db = dao.GetDB()
|
||||
)
|
||||
globals.SugarLogger.Debugf("CheckStoreAcctExpendExist orderID:[%v]", vendorOrderID)
|
||||
// 发单扣除的临时运费
|
||||
expends, err = dao.GetStoreAcctExpendTotal(db, 0, []int{partner.StoreAcctTypeExpendCreateWaybillEx, partner.StoreAcctTypeRealFeeExpend}, vendorOrderID, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
||||
// 真实运费 < 临时运费, 临时运费-真实运费的值
|
||||
@@ -193,7 +190,6 @@ func (s *StoreAcctManager) InsertBrandBill(ctx *jxcontext.Context, brandID, pric
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if price == 0 {
|
||||
globals.SugarLogger.Debugf("InsertBrandBill failed price is 0, brandID: %d, vendorOrderID: %s", brandID, vendorOrderID)
|
||||
return
|
||||
}
|
||||
brandBill := &model.BrandBill{
|
||||
|
||||
@@ -3,7 +3,6 @@ package cms
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -12,7 +11,6 @@ func UpdateStoreOperatorConfig() {
|
||||
db := dao.GetDB()
|
||||
store, err := dao.GetStoreList(db, nil, nil, []int{-1, 0, 1}, nil, nil, "")
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("定时任务,获取所有门店信息错误")
|
||||
return
|
||||
}
|
||||
userData := make(map[string][][]interface{}, 0)
|
||||
@@ -23,7 +21,6 @@ func UpdateStoreOperatorConfig() {
|
||||
for _, v := range store {
|
||||
storeDetail, err := dao.GetStoreDetail(dao.GetDB(), v.ID, 0, "")
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("定时任务,更新门店负责人,美团负责人.....错误", v.ID)
|
||||
return
|
||||
}
|
||||
if storeDetail.MarketManPhone != "" { // 平台负责人jx
|
||||
@@ -46,11 +43,9 @@ func UpdateStoreOperatorConfig() {
|
||||
// 写入配置
|
||||
byteData, err := json.Marshal(userData)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("Marshal err :", err)
|
||||
return
|
||||
}
|
||||
if err := dao.UpdateOperatorConfig(string(byteData)); err != nil {
|
||||
globals.SugarLogger.Debug("update new_config err :", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
|
||||
@@ -1111,12 +1111,10 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []str
|
||||
sqlParams2 := append([]interface{}{}, sqlParams...)
|
||||
sqlParams2 = append(sqlParams2, sqlParamsPage)
|
||||
var storeNameList []*tStoreNameBind
|
||||
beginTime := time.Now()
|
||||
if err = dao.GetRowsTx(txDB, &storeNameList, sql2, sqlParams2...); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("GetStoresSkusNew get result1:%v", time.Now().Sub(beginTime))
|
||||
skuNamesInfo.TotalCount = dao.GetLastTotalRowCount2(db, txDB)
|
||||
sql += " AND (1 = 0"
|
||||
for _, v := range storeNameList {
|
||||
@@ -1154,7 +1152,6 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []str
|
||||
sql += " , t4.unit_price DESC LIMIT 99"
|
||||
}
|
||||
var tmpList []*tGetStoresSkusInfo
|
||||
beginTime := time.Now()
|
||||
if err = dao.GetRowsTx(txDB, &tmpList, sql, sqlParams...); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return nil, err
|
||||
@@ -1163,7 +1160,6 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []str
|
||||
skuNamesInfo.TotalCount = dao.GetLastTotalRowCount2(db, txDB)
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
globals.SugarLogger.Debugf("GetStoresSkusNew get result2:%v", time.Now().Sub(beginTime))
|
||||
storeNameMap := make(map[int64]*dao.StoreSkuNameExt)
|
||||
for _, v := range tmpList {
|
||||
var storeName *dao.StoreSkuNameExt
|
||||
@@ -1207,7 +1203,6 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []str
|
||||
err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
|
||||
}
|
||||
}
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(skuNamesInfo, false))
|
||||
return skuNamesInfo, err
|
||||
}
|
||||
|
||||
@@ -1284,12 +1279,10 @@ func GetStoresSkusNew2(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []st
|
||||
sqlParams2 := append([]interface{}{}, sqlParams...)
|
||||
sqlParams2 = append(sqlParams2, sqlParamsPage)
|
||||
var storeNameList []*tStoreNameBind
|
||||
beginTime := time.Now()
|
||||
if err = dao.GetRowsTx(txDB, &storeNameList, sql2, sqlParams2...); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("GetStoresSkusNew get result1:%v", time.Now().Sub(beginTime))
|
||||
skuNamesInfo.TotalCount = dao.GetLastTotalRowCount2(db, txDB)
|
||||
sql += " AND (1 = 0"
|
||||
for _, v := range storeNameList {
|
||||
@@ -1327,7 +1320,6 @@ func GetStoresSkusNew2(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []st
|
||||
sql += " , t4.unit_price DESC LIMIT 99"
|
||||
}
|
||||
var tmpList []*tGetStoresSkusInfo
|
||||
beginTime := time.Now()
|
||||
if err = dao.GetRowsTx(txDB, &tmpList, sql, sqlParams...); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return nil, err
|
||||
@@ -1336,7 +1328,6 @@ func GetStoresSkusNew2(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []st
|
||||
skuNamesInfo.TotalCount = dao.GetLastTotalRowCount2(db, txDB)
|
||||
}
|
||||
dao.Commit(db, txDB)
|
||||
globals.SugarLogger.Debugf("GetStoresSkusNew get result2:%v", time.Now().Sub(beginTime))
|
||||
storeNameMap := make(map[int64]*dao.StoreSkuNameExt)
|
||||
for _, v := range tmpList {
|
||||
var storeName *dao.StoreSkuNameExt
|
||||
@@ -1380,7 +1371,6 @@ func GetStoresSkusNew2(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []st
|
||||
err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
|
||||
}
|
||||
}
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(skuNamesInfo, false))
|
||||
return skuNamesInfo, err
|
||||
}
|
||||
|
||||
@@ -1554,8 +1544,6 @@ func GetStoreAbnormalSkuCount(ctx *jxcontext.Context, storeID, syncStatus int, i
|
||||
}
|
||||
|
||||
func GetStoresSkusSaleInfo(ctx *jxcontext.Context, storeIDs []int, skuIDs []int, fromTime, toTime time.Time, fromCount, toCount int) (saleInfoList []*SkuSaleInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetStoresSkusSaleInfo storeIDs:%v, fromTime:%v, toTime:%v, fromCount:%d, toCount:%d", storeIDs, fromTime, toTime, fromCount, toCount)
|
||||
|
||||
db := dao.GetDB()
|
||||
sql := `
|
||||
SELECT IF(t2.jx_store_id <> 0, jx_store_id, store_id) store_id, t1.sku_id, COUNT(*) times, SUM(count) count
|
||||
@@ -1588,7 +1576,6 @@ func GetStoresSkusSaleInfo(ctx *jxcontext.Context, storeIDs []int, skuIDs []int,
|
||||
`
|
||||
sqlParams = append(sqlParams, fromCount, toCount)
|
||||
if err = dao.GetRows(db, &saleInfoList, sql, sqlParams...); err == nil {
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(saleInfoList, false))
|
||||
return saleInfoList, nil
|
||||
}
|
||||
return nil, err
|
||||
@@ -1718,7 +1705,6 @@ func UpdateStoreSkus(ctx *jxcontext.Context, causeFlag, storeID int, skuBindInfo
|
||||
}
|
||||
|
||||
func UpdateStoresSkus(ctx *jxcontext.Context, causeFlag int, storeIDs []int, skuBindInfos []*StoreSkuBindInfo, isScale, isRefreshHigh, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debugf("UpdateStoresSkus:%s, storeIDs:%v, skuBindInfos:%s", ctx.GetTrackInfo(), storeIDs, utils.Format4Output(skuBindInfos, true))
|
||||
if beego.BConfig.RunMode == "jxgy" {
|
||||
doStoreSkuAuditForGy(ctx, storeIDs, skuBindInfos)
|
||||
var num int64
|
||||
@@ -1891,7 +1877,6 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
||||
skuBindInfos = uniqueStoreNameBind(skuBindInfos)
|
||||
|
||||
sort.Ints(storeIDs)
|
||||
// globals.SugarLogger.Debugf("updateStoresSkusWithoutSync, storeIDs:%v, skuBindInfos:%s", storeIDs, utils.Format4Output(skuBindInfos, false))
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
@@ -1989,7 +1974,6 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
if err = dao.GetRows(db, &allBinds, sql, sqlParams...); err == nil {
|
||||
if len(allBinds) > 0 {
|
||||
globals.SugarLogger.Debug(utils.Format4Output(allBinds, true))
|
||||
inSkuBinsMap := make(map[int]*StoreSkuBindSkuInfo, len(inSkuBinds))
|
||||
for _, v := range inSkuBinds {
|
||||
inSkuBinsMap[v.SkuID] = v
|
||||
@@ -2650,7 +2634,6 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
|
||||
}
|
||||
sqlDelete += sqlCatAndSku
|
||||
sqlDeleteParams = append(sqlDeleteParams, sqlCatAndSkuParams)
|
||||
// globals.SugarLogger.Debug(sqlDelete)
|
||||
num2, err2 := dao.ExecuteSQL(db, sqlDelete, sqlDeleteParams)
|
||||
if err = err2; err != nil {
|
||||
errList.AddErr(err)
|
||||
@@ -2658,7 +2641,6 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
|
||||
break
|
||||
}
|
||||
num += num2
|
||||
globals.SugarLogger.Debugf("CopyStoreSkus fromStoreID:%d, toStoreID:%d, trackInfo:%s num1:%d", fromStoreID, toStoreID, ctx.GetTrackInfo(), num2)
|
||||
}
|
||||
isModifyStatus := 1
|
||||
syncStatus := model.SyncFlagStoreSkuOnlyMask
|
||||
@@ -2723,9 +2705,7 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
|
||||
}
|
||||
sql += sqlCatAndSku
|
||||
sqlParams = append(sqlParams, sqlCatAndSkuParams)
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
num2, err2 := dao.ExecuteSQL(db, sql, sqlParams)
|
||||
globals.SugarLogger.Debugf("CopyStoreSkus fromStoreID:%d, toStoreID:%d, trackInfo:%s num2:%d", fromStoreID, toStoreID, ctx.GetTrackInfo(), num2)
|
||||
if err = err2; err != nil {
|
||||
errList.AddErr(err)
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -2805,7 +2785,6 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
|
||||
dao.Rollback(db, txDB)
|
||||
break
|
||||
}
|
||||
globals.SugarLogger.Debugf("CopyStoreSkus fromStoreID:%d, toStoreID:%d, trackInfo:%s num3:%d", fromStoreID, toStoreID, ctx.GetTrackInfo(), num2)
|
||||
dao.Commit(db, txDB)
|
||||
|
||||
//同一商品若源门店的规格少于要复制到的门店,则在复制的门店里的其他规格的unitprice不会变,
|
||||
@@ -2872,7 +2851,6 @@ func shouldPendingStorePriceChange(ctx *jxcontext.Context, storeID int, skuBindI
|
||||
}
|
||||
|
||||
func filterStorePriceChange(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (filteredStoreIDs []int, filteredSkuBindInfos []*StoreSkuBindInfo, err error) {
|
||||
globals.SugarLogger.Debug("filterStorePriceChange")
|
||||
if globals.EnablePendingChange {
|
||||
db := dao.GetDB()
|
||||
txDB, _ := dao.Begin(db)
|
||||
@@ -3115,8 +3093,6 @@ func GetStoreOpRequests(ctx *jxcontext.Context, fromTime, toTime time.Time, keyw
|
||||
sqlPageSize := pageSize
|
||||
sqlParams = append(sqlParams, sqlPageSize, sqlOffset)
|
||||
db := dao.GetDB()
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
||||
var requestList []*StoreOpRequestInfo
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer dao.Commit(db, txDB)
|
||||
@@ -3169,7 +3145,6 @@ func getStoreOpRequestsInfo(reqIDs []int) (infoMap map[int]*StoreOpRequestInfo,
|
||||
}
|
||||
|
||||
func changeStoreOpStatus(ctx *jxcontext.Context, reqIDs []int, status int8, rejectReason string) (err error) {
|
||||
globals.SugarLogger.Debugf("changeStoreOpStatus, reqIDs:%v", reqIDs)
|
||||
if globals.EnablePendingChange {
|
||||
if len(reqIDs) > 0 {
|
||||
infoMap, err2 := getStoreOpRequestsInfo(reqIDs)
|
||||
@@ -3189,7 +3164,6 @@ func changeStoreOpStatus(ctx *jxcontext.Context, reqIDs []int, status int8, reje
|
||||
dao.WrapUpdateULEntity(op, ctx.GetUserName())
|
||||
op.DeletedAt = time.Now()
|
||||
op.ID = reqID
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(op, false))
|
||||
if _, err = dao.UpdateEntity(db, op, "IntParam0", "Remark", "Status", "DeletedAt", "LastOperator", "UpdatedAt"); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -3356,7 +3330,6 @@ func RefreshStoresSkuByVendor(ctx *jxcontext.Context, storeIDs []int, vendorID i
|
||||
}
|
||||
|
||||
func GetVendorStoreSkusInfo(ctx *jxcontext.Context, storeID int, vendorIDs, skuIDs []int, isContinueWhenError bool) (skuVendorMap map[int][]*partner.StoreSkuInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetVendorStoreSkusInfo, storeID:%d, vendorIDs:%v, skuID:%v", storeID, vendorIDs, skuIDs)
|
||||
db := dao.GetDB()
|
||||
var locker sync.RWMutex
|
||||
skuVendorMap = make(map[int][]*partner.StoreSkuInfo)
|
||||
@@ -3447,7 +3420,6 @@ func GetVendorStoreSkusToStruct(ctx *jxcontext.Context, storeID, vendorID int) (
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug(err)
|
||||
} else {
|
||||
globals.SugarLogger.Debug(len(tmpList))
|
||||
if len(tmpList) == 0 { //数据库中无匹配项 直接将第三方数据进行导出
|
||||
goto creatExec
|
||||
} else { //进行比较
|
||||
@@ -3539,7 +3511,6 @@ func ComPareLocalWithVendors(localSku []*tGetStoresSkusInfoContainCategoryName,
|
||||
}
|
||||
localStoreSkus = append(localStoreSkus, skus)
|
||||
}
|
||||
globals.SugarLogger.Debug(localStoreSkus, vendorSkus)
|
||||
// 由于go语言中无法子定义struct比较规则 因此需要把数据提取出来进行处理
|
||||
// 进行比较处理 对两个slice 进行遍历 放到map中 以 skuID slice的形式进行存储 如果不存在则直接进行put操作 如果存在则进行比较类别,价格,以及上下架状态
|
||||
compareMap := make(map[int]*VendorStoreSkus)
|
||||
@@ -3584,7 +3555,6 @@ func ComPareLocalWithVendors(localSku []*tGetStoresSkusInfoContainCategoryName,
|
||||
for _, v := range compareMap {
|
||||
updateStoreSkus = append(updateStoreSkus, v)
|
||||
}
|
||||
globals.SugarLogger.Debug(updateStoreSkus)
|
||||
return updateStoreSkus
|
||||
}
|
||||
|
||||
@@ -5012,7 +4982,6 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
|
||||
if user != nil && err == nil {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "警告!门店爆品数量异常!", v)
|
||||
}
|
||||
globals.SugarLogger.Debugf("SendSeckillSkusCountMsg: [%v]", v)
|
||||
}
|
||||
for k, v := range marketMap {
|
||||
if operaterMap[k] != "" {
|
||||
@@ -5022,7 +4991,6 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
|
||||
if user != nil && err == nil {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "警告!门店爆品数量异常!", v)
|
||||
}
|
||||
globals.SugarLogger.Debugf("SendSeckillSkusCountMsg: [%v]", v)
|
||||
}
|
||||
}
|
||||
return result, err
|
||||
@@ -5908,7 +5876,6 @@ func GetStoreSkuAudit(ctx *jxcontext.Context, storeIDs, nameIDs, skuIDs, statuss
|
||||
}
|
||||
|
||||
func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (isAudit bool, err error) {
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit storeIDs: %v", storeIDs)
|
||||
time.Sleep(time.Second / 5)
|
||||
db := dao.GetDB()
|
||||
for _, storeID := range storeIDs {
|
||||
@@ -5916,7 +5883,6 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
|
||||
//扣点的门店改价不进审核
|
||||
if len(stores) > 0 {
|
||||
if stores[0].PayPercentage <= 50 || stores[0].StoreLevel == "E" || stores[0].StoreLevel == "D" {
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit return0 storeID : %v", storeID)
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
@@ -5925,12 +5891,10 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
|
||||
storeAudits, err := dao.GetStoreSkuAuditLight(db, []int{storeID}, []int{skuBindInfo.NameID}, model.StoreAuditStatusOnline)
|
||||
//取消关注,可售排除
|
||||
if skuBindInfo.IsFocus == -1 || skuBindInfo.IsSale != 0 || skuBindInfo.UnitPrice == 0 {
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit return1 storeID : %v nameID: %v", storeID, skuBindInfo.NameID)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit return3 storeID : %v loginType: %v", storeID, ctx.GetLoginType())
|
||||
authInfo, err := ctx.GetV2AuthInfo()
|
||||
if err == nil && authInfo != nil && (ctx.GetFullUser().Type&model.UserTypeOperator) != 0 {
|
||||
if len(storeAudits) > 0 {
|
||||
@@ -5943,7 +5907,6 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
|
||||
// }
|
||||
// }
|
||||
}
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit return3 storeID : %v nameID: %v", storeID, skuBindInfo.NameID)
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
@@ -5976,7 +5939,6 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
|
||||
storeAudits[0].DeletedAt = time.Now()
|
||||
dao.UpdateEntity(db, storeAudits[0], "DeletedAt")
|
||||
}
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit cover storeID : %v nameID: %v", storeID, skuBindInfo.NameID)
|
||||
}
|
||||
} else {
|
||||
return false, fmt.Errorf("未查询到该门店商品价,storeID: %v, nameID: %v", storeID, skuBindInfo.NameID)
|
||||
@@ -5992,7 +5954,6 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
|
||||
}
|
||||
|
||||
func doStoreSkuAuditForGy(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (isAudit bool, err error) {
|
||||
globals.SugarLogger.Debugf("doStoreSkuAuditForGy storeIDs: %v", storeIDs)
|
||||
time.Sleep(time.Second / 5)
|
||||
db := dao.GetDB()
|
||||
for _, storeID := range storeIDs {
|
||||
@@ -6005,16 +5966,13 @@ func doStoreSkuAuditForGy(ctx *jxcontext.Context, storeIDs []int, skuBindInfos [
|
||||
// }
|
||||
// }
|
||||
for _, skuBindInfo := range skuBindInfos {
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit storeID: %v , nameID: %v", storeID, skuBindInfo.NameID)
|
||||
storeAudits, err := dao.GetStoreSkuAuditLight(db, []int{storeID}, []int{skuBindInfo.NameID}, model.StoreAuditStatusOnline)
|
||||
//取消关注,可售排除
|
||||
if skuBindInfo.IsFocus == -1 || skuBindInfo.IsSale != 0 || skuBindInfo.UnitPrice == 0 {
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit return1 storeID : %v nameID: %v", storeID, skuBindInfo.NameID)
|
||||
return false, err
|
||||
}
|
||||
|
||||
if ctx.GetLoginType() != weixin.AuthTypeMP && ctx.GetLoginType() != weixin.AuthTypeMini && ctx.GetLoginType() != weixin.AuthTypeWxApp && ctx.GetLoginType() != auth2.AuthTypeMobile {
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit return3 storeID : %v loginType: %v", storeID, ctx.GetLoginType())
|
||||
authInfo, err := ctx.GetV2AuthInfo()
|
||||
if err == nil && authInfo != nil && (ctx.GetFullUser().Type&model.UserTypeOperator) != 0 {
|
||||
if len(storeAudits) > 0 {
|
||||
@@ -6045,7 +6003,6 @@ func doStoreSkuAuditForGy(ctx *jxcontext.Context, storeIDs []int, skuBindInfos [
|
||||
storeAudits[0].DeletedAt = time.Now()
|
||||
dao.UpdateEntity(db, storeAudits[0], "DeletedAt")
|
||||
}
|
||||
globals.SugarLogger.Debugf("doStoreSkuAudit cover storeID : %v nameID: %v", storeID, skuBindInfo.NameID)
|
||||
} else {
|
||||
return false, fmt.Errorf("未查询到该门店商品价,storeID: %v, nameID: %v", storeID, skuBindInfo.NameID)
|
||||
}
|
||||
|
||||
@@ -628,7 +628,6 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool
|
||||
|
||||
func StoreOpenAll(ctx *jxcontext.Context) {
|
||||
AutoFocusStoreSkusForTopSkus(ctx, true, true)
|
||||
//globals.SugarLogger.Debug("StoreOpenAll skuID is start")
|
||||
///*获取美团门店信息*/
|
||||
//StoreInfoList, _ := api.MtpsAPI.GetStoreStatusAll()
|
||||
//StoreInfoList2 := make(map[string]string)
|
||||
@@ -913,8 +912,6 @@ func StoreOpenAll(ctx *jxcontext.Context) {
|
||||
// Map.DeliveryFeeDeductionFee = 0
|
||||
// Map.IsOrder = 0
|
||||
// if _, err := AddStoreVendorMap(ctx, db, 9, "", StoreList.ID, Map); err != nil {
|
||||
// globals.SugarLogger.Debugf("AddStoreVendorMap调用出错,StoreID是" + strconv.Itoa(StoreList.ID))
|
||||
// globals.SugarLogger.Debugf(err.Error())
|
||||
// }
|
||||
// }
|
||||
// /*改配送范围*/
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
type StoreManager struct {
|
||||
@@ -78,7 +77,6 @@ func (s *StoreManager) OnStoreStatusChanged(vendorStoreID string, vendorID int,
|
||||
}
|
||||
}()
|
||||
if storeKV != nil {
|
||||
globals.SugarLogger.Debugf("OnStoreStatusChanged venvendorStoreID:%s, storeKV:%s", vendorStoreID, utils.Format4Output(storeKV, true))
|
||||
store := &model.Store{}
|
||||
store.ID = storeDetail.Store.ID
|
||||
if err = utils.CallFuncLogError(func() error {
|
||||
@@ -89,7 +87,6 @@ func (s *StoreManager) OnStoreStatusChanged(vendorStoreID string, vendorID int,
|
||||
}
|
||||
}
|
||||
if storeMapKV != nil {
|
||||
globals.SugarLogger.Debugf("OnStoreStatusChanged venvendorStoreID:%s, storeMapKV:%s", vendorStoreID, utils.Format4Output(storeMapKV, true))
|
||||
if err = utils.CallFuncLogError(func() error {
|
||||
_, err = dao.UpdateEntityLogically(db, &model.StoreMap{}, storeMapKV, model.AdminName, map[string]interface{}{
|
||||
model.FieldStoreID: storeDetail.Store.ID,
|
||||
@@ -145,6 +142,5 @@ func (s *StoreManager) OnCourierStoreStatusChanged(ctx *jxcontext.Context, vendo
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debugf("OnCourierStoreStatusChanged vendorStoreID:%s, auditStatus:%d, err:%v", vendorStoreID, auditStatus, err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -554,7 +554,6 @@ func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, parentTask tasksch.I
|
||||
|
||||
//执行比较店铺与运营商的sku差异
|
||||
func (c *ComparePlatform) CompareStoreWithOperator(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debug("开始执行CompareStoreWithOperator")
|
||||
return hint, makeSyncError(err)
|
||||
}
|
||||
|
||||
@@ -656,7 +655,6 @@ func (v *VendorSync) AddCreateFlagForJxStoreSku(ctx *jxcontext.Context, vendorID
|
||||
}
|
||||
|
||||
func (v *VendorSync) AmendAndPruneStoreStuff(ctx *jxcontext.Context, vendorIDs []int, storeIDs []int, isAsync, isContinueWhenError bool, optType int, isForceUpdate bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debug("AmendAndPruneStoreStuff")
|
||||
hint, err = v.LoopStoresMap(ctx, dao.GetDB(), fmt.Sprintf("处理京西平台商家分类与商品差异:%v", storeIDs), isAsync, true, vendorIDs, storeIDs,
|
||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
||||
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
||||
@@ -1219,7 +1217,6 @@ func SyncJdsStoreStock(ctx *jxcontext.Context, isAsync, isContinueWhenError bool
|
||||
}
|
||||
|
||||
func syncJdsStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, parentTask tasksch.ITask, storeMap *model.StoreMap, isAsync, isContinueWhenError bool) (err error) {
|
||||
globals.SugarLogger.Debugf("syncJdsStoresSkus")
|
||||
var (
|
||||
mainSkusMap = make(map[int][]*dao.StoreSkuSyncInfo)
|
||||
skusMap = make(map[int][]*dao.StoreSkuSyncInfo)
|
||||
@@ -1347,8 +1344,6 @@ func SyncSkuExperfixAndWatermark(ctx *jxcontext.Context) (err error) {
|
||||
}
|
||||
|
||||
func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
||||
globals.SugarLogger.Debug("SetMTPSStatus is start ")
|
||||
globals.SugarLogger.Debug("StoreId", "CourierStatus", storeId, courierStatus)
|
||||
/*获取美团门店信息*/
|
||||
//&& CourierStatus != 0
|
||||
if storeId != 0 {
|
||||
@@ -1432,7 +1427,6 @@ func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
||||
{
|
||||
sl := make(map[string]interface{})
|
||||
sl["vendorStatus"] = 0
|
||||
globals.SugarLogger.Debug("因为没找到被修改配送状态的VendorStoreID是", ShopName, storeId)
|
||||
UpdateStoreCourierMap(ctx, nil, storeId, model.VendorIDMTPS, sl, ctx.GetUserName())
|
||||
return
|
||||
}
|
||||
@@ -1496,7 +1490,6 @@ func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
||||
diff := false
|
||||
StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, nil, "")
|
||||
if StoreLists == nil {
|
||||
globals.SugarLogger.Debugf("StoreID为:%s,在store表未找到", StoreCourierList1.StoreID)
|
||||
continue
|
||||
}
|
||||
if StoreCourierList1.VendorID != model.VendorIDMTPS || StoreCourierList1.VendorStoreID == "" {
|
||||
@@ -1511,7 +1504,6 @@ func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
||||
MTPSInfo := new(mtpsapi.ShopInfo)
|
||||
MTPSInfo, _ = api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID)
|
||||
if MTPSInfo == nil {
|
||||
globals.SugarLogger.Debug("美团未找到该门店," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID)
|
||||
diff = true
|
||||
}
|
||||
if MTPSInfo != nil && MTPSInfo.ShopName == "" {
|
||||
@@ -1519,23 +1511,19 @@ func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
||||
}
|
||||
if MTPSInfo != nil && MTPSInfo.ShopLng != StoreCourierList1.Lng && MTPSInfo.ShopLat == StoreCourierList1.Lat {
|
||||
/*平台上但是坐标不同,解绑*/
|
||||
globals.SugarLogger.Debug("商店与美团配送上的坐标不同," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID)
|
||||
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
return
|
||||
}
|
||||
diff = true
|
||||
}
|
||||
if diff {
|
||||
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
return
|
||||
}
|
||||
//break test
|
||||
}
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debug("SetMTPSStatus is Complete")
|
||||
}
|
||||
|
||||
func SetMTPSStatus2(storeID int) {
|
||||
|
||||
@@ -94,7 +94,6 @@ func syncCategories(ctx *jxcontext.Context, db *dao.DaoDB, parentTask tasksch.IT
|
||||
func SyncCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorIDs []int, appOrgCodes []string, catIDs []int, isAsync bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
catList, err := dao.GetSkuCategoryWithVendor(db, vendorIDs, appOrgCodes, -1, catIDs, true)
|
||||
globals.SugarLogger.Debugf("SyncCategories catListLenght:%v", len(catList))
|
||||
if err == nil && len(catList) > 0 {
|
||||
//TODO 同一平台不同账号会有影响needSyncParentIDs,暂不处理
|
||||
var needSyncParentIDs []int
|
||||
@@ -103,15 +102,12 @@ func SyncCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorIDs
|
||||
needSyncParentIDs = append(needSyncParentIDs, cat.ParentID)
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debugf("needSyncParentIDs needSyncParentIDsLen:%v", needSyncParentIDs)
|
||||
|
||||
if len(needSyncParentIDs) > 0 {
|
||||
task := tasksch.NewSeqTask(fmt.Sprintf("同步分类1:%v", catIDs), ctx,
|
||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
switch step {
|
||||
case 0:
|
||||
catList2, err := dao.GetSkuCategoryWithVendor(db, vendorIDs, appOrgCodes, -1, needSyncParentIDs, true)
|
||||
globals.SugarLogger.Debugf("GetSkuCategoryWithVendor catList2:%v", catList2)
|
||||
if err == nil {
|
||||
_, err = syncCategories(ctx, db, task, catList2, false)
|
||||
}
|
||||
@@ -227,7 +223,6 @@ func SyncSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorIDs []int,
|
||||
}
|
||||
|
||||
func SyncReorderCategories(ctx *jxcontext.Context, parentCatID int, isAsync bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debugf("SyncReorderCategories parentCatID:%d", parentCatID)
|
||||
db := dao.GetDB()
|
||||
hint, err = CurVendorSync.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("分类重排序:%d", parentCatID), isAsync, false,
|
||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
@@ -272,7 +267,6 @@ func SyncReorderCategories(ctx *jxcontext.Context, parentCatID int, isAsync bool
|
||||
}
|
||||
|
||||
func SyncReorderCategories2(ctx *jxcontext.Context, parentCatID, vendorID int, vendorOrgCode string) (err error) {
|
||||
globals.SugarLogger.Debugf("SyncReorderCategories parentCatID:%d", parentCatID)
|
||||
db := dao.GetDB()
|
||||
multiStoresHandler := CurVendorSync.GetMultiStoreHandler(vendorID)
|
||||
if multiStoresHandler != nil {
|
||||
@@ -442,7 +436,6 @@ func SkuVendor2ThingMap(sku *dao.StoreSkuSyncInfo) (thingMap *model.ThingMap) {
|
||||
}
|
||||
|
||||
func OnThingSync(ctx *jxcontext.Context, db *dao.DaoDB, thingMap *model.ThingMap, syncErr error) (err error) {
|
||||
globals.SugarLogger.Debugf("OnThingSync thingMap:%s", utils.Format4Output(thingMap, true))
|
||||
if syncErr != nil {
|
||||
err = syncErr
|
||||
thingMap.Remark = utils.LimitUTF8StringLen(err.Error(), 255)
|
||||
|
||||
@@ -69,7 +69,6 @@ func CreateStoreCategoryByStoreSku(ctx *jxcontext.Context, vendorID, storeID int
|
||||
}
|
||||
|
||||
func SyncStoreCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, nameIDs, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debugf("SyncStoreCategories %s storeID:%d, %s, userName:%s", model.VendorChineseNames[vendorID], storeID, vendorStoreID, ctx.GetUserName())
|
||||
handler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||
num := 0
|
||||
db := dao.GetDB()
|
||||
@@ -387,12 +386,6 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item
|
||||
|
||||
func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyncInfo, syncStatus int8) (num int64, err error) {
|
||||
if len(storeSkuList) > 0 {
|
||||
// defer func() {
|
||||
// if r := recover(); r != nil {
|
||||
// globals.SugarLogger.Debugf("updateStoreSku panic, vendorID:%d, len:%d, storeID0:%d, skuID0:%d, syncStatus:%d", vendorID, len(storeSkuList), storeSkuList[0].StoreID, storeSkuList[0].SkuID, syncStatus)
|
||||
// panic(r)
|
||||
// }
|
||||
// }()
|
||||
if vendorID == model.VendorIDJDShop {
|
||||
if syncStatus != model.SyncFlagPriceMask && syncStatus != model.SyncFlagSaleMask && syncStatus != model.SyncFlagStockMask {
|
||||
for _, v := range storeSkuList {
|
||||
@@ -440,7 +433,6 @@ func isSkuLockTimeValid(sku *dao.StoreSkuSyncInfo) bool {
|
||||
}
|
||||
|
||||
func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag int, isFull bool, vendorID, storeID int, vendorOrgCode string, nameIDs, skuIDs, excludeSkuIDs []int, useVendorPriceDirectly, isContinueWhenError bool) (err error) {
|
||||
globals.SugarLogger.Debugf("syncStoreSkuNew causeFlag:%d ,vendorOrgCode:%s", causeFlag, vendorOrgCode)
|
||||
db := dao.GetDB()
|
||||
storeDetail, err := dao.GetStoreDetail(db, storeID, vendorID, vendorOrgCode)
|
||||
if err != nil {
|
||||
@@ -503,7 +495,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
var bareSku *partner.StoreSkuInfo
|
||||
isNeedReorder := false
|
||||
if isStoreSkuSyncNeedDelete(sku) {
|
||||
globals.SugarLogger.Debug("1.进入isStoreSkuSyncNeedDelete")
|
||||
if !dao.IsVendorThingIDEmpty(sku.VendorSkuID) {
|
||||
bareSku = storeSkuSyncInfo2Bare(sku)
|
||||
if singleStoreHandler == nil {
|
||||
@@ -516,10 +507,8 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
updateItems = append(updateItems, sku2Update(vendorID, sku, model.SyncFlagDeletedMask))
|
||||
}
|
||||
} else if model.IsSyncStatusNew(sku.SkuSyncStatus) {
|
||||
globals.SugarLogger.Debug("4.进入model.IsSyncStatusNew(sku.SkuSyncStatus)")
|
||||
calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage))
|
||||
if singleStoreHandler == nil {
|
||||
globals.SugarLogger.Debug("5.进入singleStoreHandler == nil")
|
||||
if dao.IsVendorThingIDEmpty(sku.VendorSkuID) {
|
||||
// todo 多平台商品库没有正常创建,直接跳过
|
||||
} else {
|
||||
@@ -532,11 +521,9 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
} else {
|
||||
offlineList = append(offlineList, bareSku)
|
||||
}
|
||||
globals.SugarLogger.Debug("6.stockList,priceList,onlineList||offlineList ==============", stockList, priceList, onlineList, offlineList)
|
||||
}
|
||||
} else {
|
||||
if sku.MergedStatus == model.SkuStatusNormal {
|
||||
globals.SugarLogger.Debug("7.进入sku.MergedStatus == model.SkuStatusNormal")
|
||||
if vendorID == model.VendorIDDD {
|
||||
createList = append(createList, sku)
|
||||
} else if dao.IsVendorThingIDEmpty(sku.VendorCatID) && !strings.Contains(sku.StoreName, model.ExdStoreName) && vendorID != model.VendorIDYB && vendorID != model.VendorIDJDShop {
|
||||
@@ -547,13 +534,10 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
createList = append(createList, sku)
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debug("8.createList=======", createList)
|
||||
}
|
||||
isNeedReorder = true
|
||||
} else {
|
||||
globals.SugarLogger.Debug("9.进入not isStoreSkuSyncNeedDelete IsSyncStatusNew")
|
||||
if dao.IsVendorThingIDEmpty(sku.VendorSkuID) && vendorID != model.VendorIDJDShop {
|
||||
globals.SugarLogger.Debug("10.进入vendorID != model.VendorIDJDShop")
|
||||
// err = fmt.Errorf("门店:%d,修改没有创建的商品:%d", storeID, sku.SkuID)
|
||||
if vendorID != model.VendorIDJDShop || (vendorID == model.VendorIDJDShop && storeID == model.JdShopMainStoreID && sku.StoreSkuStatus != model.SkuStatusDontSale) {
|
||||
err = utils.NewErrorCode(fmt.Sprintf("门店:%d,修改没有创建的商品:%d", storeID, sku.SkuID), "-1", 0)
|
||||
@@ -564,14 +548,12 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
parentTask.AddBatchErr(err)
|
||||
parentTask.AddFailedList(failedList)
|
||||
}
|
||||
globals.SugarLogger.Debug("11.failedList======", failedList)
|
||||
} else {
|
||||
globals.SugarLogger.Debug("12.进入vendorID == model.VendorIDJDShop")
|
||||
isAdded2Update := false
|
||||
// 修改商品信息时不改价(以免活动引起的失败),而用单独的改价来改
|
||||
if (model.IsSyncStatusUpdate(sku.SkuSyncStatus) || (model.IsSyncStatusSeq(sku.SkuSyncStatus) && reorderHandler == nil)) && singleStoreHandler != nil {
|
||||
if dao.IsVendorThingIDEmpty(sku.VendorCatID) && !strings.Contains(sku.StoreName, model.ExdStoreName) && vendorID != model.VendorIDYB {
|
||||
// globals.SugarLogger.Warnf("syncStoreSkuNew 修改门店:%d商品:%d,但没有平台分类ID", storeID, sku.SkuID)
|
||||
globals.SugarLogger.Warnf("syncStoreSkuNew 修改门店:%d商品:%d,但没有平台分类ID", storeID, sku.SkuID)
|
||||
} else {
|
||||
isAdded2Update = true
|
||||
updateList = append(updateList, calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
||||
@@ -582,7 +564,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
priceList = append(priceList, bareSku)
|
||||
}
|
||||
if !isAdded2Update {
|
||||
globals.SugarLogger.Debug("15.进入!isAdded2Update")
|
||||
if model.IsSyncStatusUpdate(sku.SkuSyncStatus) && singleStoreHandler == nil { // 正常就不应该进到这里
|
||||
// if bareSku == nil {
|
||||
// bareSku = storeSkuSyncInfo2Bare(sku)
|
||||
@@ -603,7 +584,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
// stockList = append(stockList, bareSku)
|
||||
// }
|
||||
}
|
||||
globals.SugarLogger.Debug("16.onlineList,stockList,offlineList===========", onlineList, stockList, offlineList)
|
||||
}
|
||||
//if model.IsSyncStatusStock(sku.SkuSyncStatus) {
|
||||
// if bareSku == nil {
|
||||
@@ -738,7 +718,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
err = nil
|
||||
failedList = nil // 因为batchSize为1,可以这样处理
|
||||
} else if err2 != nil {
|
||||
globals.SugarLogger.Debug("31.sth wrong on err2: %v", err2)
|
||||
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(batchedStoreSkuList, err2, storeID, model.VendorChineseNames[vendorID], "查询是否有该商品")...)
|
||||
}
|
||||
}
|
||||
@@ -758,7 +737,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
}
|
||||
successList := putils.UnselectStoreSkuSyncListByVendorSkuIDs(batchedStoreSkuList, GetVendorSkuIDList(failedList))
|
||||
if len(successList) > 0 {
|
||||
globals.SugarLogger.Debug("19.len(successList) > 0 ,successList=========", successList)
|
||||
_, err := updateStoreSku(dao.GetDB(), vendorID, successList, model.SyncFlagNewMask)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("20.sth wrong on updateStoreSku: %v", err)
|
||||
@@ -787,7 +765,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
task.AddFailedList(failedList)
|
||||
}
|
||||
successList := putils.UnselectStoreSkuSyncListByVendorSkuIDs(batchedStoreSkuList, GetVendorSkuIDList(failedList))
|
||||
globals.SugarLogger.Debug("23.failedList,successList============", failedList, successList)
|
||||
if len(successList) > 0 {
|
||||
_, err := updateStoreSku(dao.GetDB(), vendorID, successList, model.SyncFlagModifiedMask)
|
||||
if err != nil {
|
||||
@@ -804,7 +781,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
_, err = putils.FreeBatchStoreSkuInfo("更新门店商品库存", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
|
||||
var failedList []*partner.StoreSkuInfoWithErr
|
||||
failedList, err = storeSkuHandler.UpdateStoreSkusStock(ctx, storeDetail.VendorOrgCode, storeID, vendorStoreID, batchedStoreSkuList)
|
||||
globals.SugarLogger.Debugf("failedList===========%s", utils.Format4Output(failedList, true))
|
||||
failedList, err = buildFailedListAndErr(failedList, err, batchedStoreSkuList, nil, storeID, vendorID, "更新门店商品库存")
|
||||
if len(failedList) > 0 {
|
||||
task.AddFailedList(failedList)
|
||||
@@ -869,7 +845,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
||||
for vendorCatID := range reorderSkuMap {
|
||||
vendorCatIDs = append(vendorCatIDs, vendorCatID)
|
||||
}
|
||||
globals.SugarLogger.Debugf("================门店商品排序%s", utils.Format4Output(reorderSkuMap, true))
|
||||
reorderTask := tasksch.NewParallelTask("门店商品排序", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError2), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
vendorCatID := batchItemList[0].(string)
|
||||
@@ -1140,8 +1115,6 @@ func AddCreateFlagForJxStoreSku(ctx *jxcontext.Context, parentTask tasksch.ITask
|
||||
}
|
||||
|
||||
func ClearRemoteStoreStuffAndSetNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
userName := ctx.GetUserName()
|
||||
globals.SugarLogger.Debugf("ClearRemoteStoreStuffAndSetNew storeID:%d, isContinueWhenError:%t, userName:%s", storeID, isContinueWhenError, userName)
|
||||
handler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||
if handler == nil {
|
||||
return "", fmt.Errorf("平台:%s不支持此操作", model.VendorChineseNames[vendorID])
|
||||
@@ -1299,7 +1272,6 @@ func parseStoreSkuActList(isCreateAct bool, storeSkuList []*partner.StoreSkuInfo
|
||||
}
|
||||
|
||||
func createStoreSkuActs(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID int, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, isChangePrice bool) (err error) {
|
||||
globals.SugarLogger.Debugf("createStoreSkuActs vendorID:%d, storeID:%d, storeSkuList:%s", vendorID, storeID, utils.Format4Output(storeSkuList, true))
|
||||
skuIDs := putils.StoreSkuList2IDs(storeSkuList)
|
||||
db := dao.GetDB()
|
||||
storeSkuActList, err := dao.GetStoresSkusAct(db, 0, false, []int{storeID}, skuIDs, []int{vendorID}, false, 1, 0)
|
||||
@@ -1313,7 +1285,6 @@ func createStoreSkuActs(ctx *jxcontext.Context, parentTask tasksch.ITask, vendor
|
||||
}
|
||||
|
||||
func cancelStoreSkuActs(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID int, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, isChangePrice bool) (err error) {
|
||||
globals.SugarLogger.Debugf("cancelStoreSkuActs vendorID:%d, storeID:%d, storeSkuList:%s", vendorID, storeID, utils.Format4Output(storeSkuList, true))
|
||||
skuIDs := putils.StoreSkuList2IDs(storeSkuList)
|
||||
db := dao.GetDB()
|
||||
storeSkuActList, err := dao.GetStoresSkusAct(db, 0, false, []int{storeID}, skuIDs, []int{vendorID}, true, 0, 0)
|
||||
@@ -1328,7 +1299,6 @@ func cancelStoreSkuActs(ctx *jxcontext.Context, parentTask tasksch.ITask, vendor
|
||||
|
||||
func createStoreSkuActs2(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID int, vendorOrgCode string, storeID int, vendorStoreID string,
|
||||
storeSkuList []*partner.StoreSkuInfo, storeSkuActList []*model.StoreSkuAct) (err error) {
|
||||
globals.SugarLogger.Debugf("createStoreSkuActs vendorID:%d, storeID:%d, storeSkuList:%s", vendorID, storeID, utils.Format4Output(storeSkuList, true))
|
||||
storeSkuList2, storeSkuActMap := parseStoreSkuActList(true, storeSkuList, storeSkuActList)
|
||||
if len(storeSkuList2) > 0 {
|
||||
storeSkuHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
|
||||
@@ -1350,7 +1320,6 @@ func createStoreSkuActs2(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo
|
||||
|
||||
func cancelStoreSkuActs2(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID int, vendorOrgCode string, storeID int, vendorStoreID string,
|
||||
storeSkuList []*partner.StoreSkuInfo, storeSkuActList []*model.StoreSkuAct) (err error) {
|
||||
globals.SugarLogger.Debugf("cancelStoreSkuActs vendorID:%d, storeID:%d, storeSkuList:%s", vendorID, storeID, utils.Format4Output(storeSkuList, true))
|
||||
storeSkuList2, storeSkuActMap := parseStoreSkuActList(false, storeSkuList, storeSkuActList)
|
||||
if len(storeSkuList2) > 0 {
|
||||
storeSkuHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
|
||||
|
||||
@@ -159,7 +159,6 @@ func SyncStoreSku4FakeJD(ctx *jxcontext.Context, parentTask tasksch.ITask, store
|
||||
task := tasksch.NewParallelTask("SyncStoreSku4FakeJD", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError2), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
step := batchItemList[0].(int)
|
||||
// globals.SugarLogger.Debugf("step:%d", step)
|
||||
switch step {
|
||||
case 0:
|
||||
for k, list := range [][]*partner.StoreSkuInfo{stockList /*, onlineList*/} {
|
||||
@@ -299,7 +298,7 @@ func UploadFakeJdThingMap(ctx *jxcontext.Context, reader io.Reader, isSyncNow, i
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
|
||||
@@ -18,7 +18,6 @@ package cms
|
||||
// WHERE t1.parentid = -1 AND t1.jxstoreid = ?
|
||||
// GROUP BY 1,2,3,4,5,6,7;
|
||||
// `
|
||||
// // globals.SugarLogger.Debug(sql)
|
||||
// if err = dao.GetRows(nil, &storeUserInfos, sql, storeID); err == nil {
|
||||
// for _, storeUserInfo := range storeUserInfos {
|
||||
// if storeUserInfo.MembersStr != "" {
|
||||
@@ -45,7 +44,6 @@ package cms
|
||||
// return nil, auth.ErrIllegalLoginType
|
||||
// }
|
||||
// storeUserInfo, err = dao.GetUserStoreInfo(dao.GetDB(), fieldName, loginInfo.GetAuthID())
|
||||
// globals.SugarLogger.Debugf("GetSelfInfo:%s, token:%s, storeUserInfo:%s, err:%v", ctx.GetTrackInfo(), ctx.GetToken(), utils.Format4Output(storeUserInfo, true), err)
|
||||
// return storeUserInfo, err
|
||||
// }
|
||||
|
||||
@@ -116,7 +114,6 @@ package cms
|
||||
// parentUser.Tel = parentMobile
|
||||
// if err = dao.GetEntity(db, parentUser, "Tel"); err == nil {
|
||||
// if parentUser.ParentID == -1 {
|
||||
// globals.SugarLogger.Debug(parentUser)
|
||||
// if err = verifyMobileHasNoMembers(db, mobile); err == nil {
|
||||
// user, err2 := verifyMobileIsBlank(db, mobile)
|
||||
// if err = err2; err == nil || err == orm.ErrNoRows {
|
||||
|
||||
@@ -193,7 +193,6 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri
|
||||
|
||||
// auth2.RemoveUserInfo(mobileAuth.Token)
|
||||
// if newAuthInfo, err := auth2.BindUser(mobileAuth, user); err == nil {
|
||||
// globals.SugarLogger.Debugf("testRegisterUserWithMobile", utils.Format4Output(mobileAuth, false), utils.Format4Output(newAuthInfo, false))
|
||||
// return nil, jsonerr.New(newAuthInfo, model.ErrCodeJsonUserAlreadyExist)
|
||||
// } else {
|
||||
// return nil, err
|
||||
|
||||
@@ -27,7 +27,6 @@ type tUploadFileInfo struct {
|
||||
}
|
||||
|
||||
func SendFilesToStores(ctx *jxcontext.Context, files []*multipart.FileHeader, title, shopName string, isAsync bool, userName string) (hint string, err error) {
|
||||
globals.SugarLogger.Debugf("SendFilesToStores, fileCount:%d isAsync:%t, userName:%s", len(files), isAsync, userName)
|
||||
if len(files) == 0 {
|
||||
return "", errors.New("没有文件上传!")
|
||||
}
|
||||
@@ -59,7 +58,6 @@ func SendFilesToStores(ctx *jxcontext.Context, files []*multipart.FileHeader, ti
|
||||
db := dao.GetDB()
|
||||
storeID, _ := dao.GetRealLinkStoreID(db, fileInfo.StoreID)
|
||||
file, err := fileHeader.Open()
|
||||
globals.SugarLogger.Debugf("SendFilesToStores upload file:%s", fileHeader.Filename)
|
||||
if err == nil {
|
||||
ret := storage.PutRet{}
|
||||
key := "storeBill/" + utils.Int2Str(storeID) + "_" + strings.ToLower(utils.GetUUID()) + path.Ext(fileHeader.Filename)
|
||||
|
||||
@@ -683,7 +683,6 @@ func ScheduleTimerFuncOnce(name string, handler func(interface{}), timeStr strin
|
||||
nextTime := jxutils.GetNextTimeFromList(now, []string{timeStr})
|
||||
duration := nextTime.Sub(now) + 1*time.Second
|
||||
utils.AfterFuncWithRecover(duration, func() {
|
||||
globals.SugarLogger.Debugf("ScheduleTimerFuncOnce func:%s", name)
|
||||
handler(param)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -481,10 +481,8 @@ func ScoreStoreRange(storeInfo *cms.StoreExt) {
|
||||
}
|
||||
}
|
||||
if finalScore < 0 {
|
||||
globals.SugarLogger.Infof("ScoreStoreRange abnormal finalScore:%d, storeInfo:%s", finalScore, utils.Format4Output(storeInfo, true))
|
||||
finalScore = 0
|
||||
} else if finalScore > ItemTotalScore {
|
||||
globals.SugarLogger.Infof("ScoreStoreRange abnormal finalScore:%d, storeInfo:%s", finalScore, utils.Format4Output(storeInfo, true))
|
||||
finalScore = ItemTotalScore
|
||||
}
|
||||
storeScoreDataWrapper.SetData(storeID, model.FieldStoreRange, finalScore)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/alibabacloud-go/dyplsapi-20170525/client"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
@@ -28,7 +27,6 @@ func QuerySecretNoRemain(city string) (b bool, err error) {
|
||||
err = fmt.Errorf(tea.StringValue(result.Body.Message))
|
||||
return false, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("QuerySecretNoRemain city: %s, result: %v", city, utils.Format4Output(result, true))
|
||||
if tea.Int64Value(result.Body.SecretRemainDTO.Amount) > 0 {
|
||||
return true, nil
|
||||
}
|
||||
@@ -266,7 +264,7 @@ func CallbackBrandBill(res *SecretNumberMsgRes) (err error) {
|
||||
if brands, _ := dao.GetBrands(db, "", 0, res.PoolKey, false, ""); len(brands) > 0 {
|
||||
if brandID := brands[0].ID; brandID != 0 {
|
||||
price := utils.Float64TwoInt(utils.Str2Time(res.ReleaseTime).Sub(utils.Str2Time(res.StartTime)).Minutes()+1) * 6
|
||||
if err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, brandID, price, model.BrandBillTypeExpend, model.BrandBillFeeTypeSecretNumber, "",""); err == nil {
|
||||
if err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, brandID, price, model.BrandBillTypeExpend, model.BrandBillFeeTypeSecretNumber, "", ""); err == nil {
|
||||
//计算余额,小于10就解绑
|
||||
balance, _ := partner.CurStoreAcctManager.GetBrandBalance(brandID)
|
||||
if balance < model.BrandBalanceLimit {
|
||||
|
||||
@@ -93,7 +93,6 @@ func Convert2JDSPU(ctx *jxcontext.Context, count int, isAsync, isContinueWhenErr
|
||||
// return "", err
|
||||
// }
|
||||
|
||||
// globals.SugarLogger.Debugf("Convert2JDSPU, skuName:%s, skuCount:%d", skuName.Name, len(skuList))
|
||||
// txDB , _ := dao.Begin(db)
|
||||
// skuNameNew2 := *skuName
|
||||
// skuNameNew := &skuNameNew2
|
||||
@@ -128,7 +127,6 @@ func Convert2JDSPU(ctx *jxcontext.Context, count int, isAsync, isContinueWhenErr
|
||||
// for _, placeBind := range skuNamePlaceBindList {
|
||||
// dao.WrapAddIDCULEntity(placeBind, ctx.GetUserName())
|
||||
// placeBind.NameID = skuNameNew.ID
|
||||
// globals.SugarLogger.Debugf("Convert2JDSPU, placeBind:%s", utils.Format4Output(placeBind, false))
|
||||
// if err = dao.CreateEntity(db, placeBind); err != nil {
|
||||
// dao.Rollback(db, txDB)
|
||||
// return "", err
|
||||
@@ -256,7 +254,6 @@ func Change2JDSPU4Store(ctx *jxcontext.Context, storeIDs []int, step int, isAsyn
|
||||
// sqlParams = append(sqlParams, storeIDs)
|
||||
// }
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
||||
// var num int64
|
||||
// if num, err = dao.ExecuteSQL(db, sql, sqlParams...); err != nil {
|
||||
// return "", err
|
||||
@@ -513,7 +510,6 @@ func PullJdOrder(ctx *jxcontext.Context, fromTime, toTime time.Time, isAsync, is
|
||||
"orderPurchaseTime_begin": utils.Time2Str(subFromTime),
|
||||
"orderPurchaseTime_end": utils.Time2Str(subToTime),
|
||||
}
|
||||
// globals.SugarLogger.Debugf("PullJdOrder, commonParams=%s", utils.Format4Output(commonParams, false))
|
||||
orderList, totalCount, err := api.JdAPI.OrderQuery(commonParams)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -658,7 +654,6 @@ func TransformJdSpu2Sku(ctx *jxcontext.Context, skuNameIDs []int, count int, isA
|
||||
// if err = dao.GetRows(db, &skuList, sql, sqlParams...); err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
// globals.SugarLogger.Debugf("TransformJdSpu2Sku skuList:%s", utils.Format4Output(skuList, false))
|
||||
// if len(skuList) > 0 {
|
||||
// for _, sku := range skuList {
|
||||
// locker.Lock()
|
||||
@@ -805,7 +800,6 @@ func RefreshEbaiBadComment(ctx *jxcontext.Context, fromTime, toTime time.Time, i
|
||||
toTime = time.Now().Add(-3 * time.Hour)
|
||||
}
|
||||
days := int(toTime.Sub(fromTime)/(24*time.Hour) + 1)
|
||||
globals.SugarLogger.Debugf("RefreshEbaiBadComment fromTime:%s, toTime:%s, days:%d", utils.Time2Str(fromTime), utils.Time2Str(toTime), days)
|
||||
rootTask := tasksch.NewSeqTask("RefreshEbaiBadComment", ctx,
|
||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
batchFromTime := fromTime.Add(time.Duration(step) * 24 * time.Hour)
|
||||
@@ -879,7 +873,6 @@ func RetrieveEbaiShopLicence(ctx *jxcontext.Context, isAsync, isContinueWhenErro
|
||||
FROM store_map
|
||||
WHERE vendor_id = ? AND deleted_at = ?
|
||||
`, model.VendorIDEBAI, utils.DefaultTimeValue); err == nil {
|
||||
globals.SugarLogger.Debugf("RetrieveEbaiShopLicence, count:%d", len(ebaiStoreList))
|
||||
rootTask := tasksch.NewParallelTask("XXXX", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
ebaiStore := batchItemList[0].(*model.StoreMap)
|
||||
@@ -920,7 +913,6 @@ func RefreshMtpsWaybillFee(ctx *jxcontext.Context, isAsync, isContinueWhenError
|
||||
FROM waybill
|
||||
WHERE status_time > '2019-04-01' AND waybill_vendor_id = 102 AND desired_fee = 0
|
||||
`); err == nil {
|
||||
globals.SugarLogger.Debugf("RefreshMtpsWaybillFee, count:%d", len(waybillList))
|
||||
rootTask := tasksch.NewParallelTask("RefreshMtpsWaybillFee", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
bill := batchItemList[0].(*model.Waybill)
|
||||
@@ -1261,7 +1253,6 @@ func JdStoreInfo1125() (hint string, err error) {
|
||||
sheetName := "老格明细"
|
||||
file, err2 := excelize.OpenFile(fileName)
|
||||
if err = err2; err == nil {
|
||||
// globals.SugarLogger.Debug(err, file)
|
||||
rows, err2 := file.GetRows(sheetName)
|
||||
if err = err2; err == nil {
|
||||
str2Coords := func(str string) (lng, lat int) {
|
||||
@@ -1422,7 +1413,6 @@ func BuildSkuFromEbaiStore(ctx *jxcontext.Context, baiduShopID int64, isAsync, i
|
||||
skuNameExt.CategoryID = cat.ID
|
||||
skuNameExt.Img = strings.Replace(skuNameExt.Img, "https://", "http://", 1)
|
||||
if imgContent, _, err = jxutils.DownloadFileByURL(skuNameExt.Img); err != nil {
|
||||
globals.SugarLogger.Infof("download pic %s failed with error:%v", skuNameExt.Img, err)
|
||||
if !isContinueWhenError {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1438,7 +1428,6 @@ func BuildSkuFromEbaiStore(ctx *jxcontext.Context, baiduShopID int64, isAsync, i
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
globals.SugarLogger.Infof("upload pic %s failed with error:%v", skuNameExt.Img, err)
|
||||
if !isContinueWhenError {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1489,8 +1478,6 @@ func BuildSkuFromEbaiStore(ctx *jxcontext.Context, baiduShopID int64, isAsync, i
|
||||
}
|
||||
|
||||
func addShopCategory(pid int64, shopCategoryName string, shopCategoryLevel, sort int, userName string) (catId string, err error) {
|
||||
// globals.SugarLogger.Debug(pid, shopCategoryName, shopCategoryLevel, sort, userName)
|
||||
// return "123", err
|
||||
return api.JdAPI.AddShopCategory(pid, shopCategoryName, shopCategoryLevel, sort, userName)
|
||||
}
|
||||
|
||||
@@ -1975,7 +1962,6 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
|
||||
//}
|
||||
curDate := utils.Time2Date(time.Now().AddDate(0, 0, -1))
|
||||
orderman.FixedOrderManager.AmendMissingOrders(jxcontext.AdminCtx, []int{model.VendorIDMTWM}, 668214, curDate, curDate, true, true)
|
||||
globals.SugarLogger.Debugf("test AmendMissingOrders")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
)
|
||||
|
||||
func SendDDUserMessage(msgType, ddUserID, title, content string) (err error) {
|
||||
globals.SugarLogger.Debugf("SendDDUserMessage ddUserID:%s, title:%s", ddUserID, title)
|
||||
if globals.IsProductEnv() {
|
||||
if msgType == dingdingapi.MsgTyeText {
|
||||
err = api.DingDingAPI.CorpAsyncSendSimple(ddUserID, content)
|
||||
@@ -24,7 +23,6 @@ func SendDDUserMessage(msgType, ddUserID, title, content string) (err error) {
|
||||
}
|
||||
|
||||
func SendUserMessage(msgType, userID, title, content string) (err error) {
|
||||
globals.SugarLogger.Debugf("SendUserMessage userID:%s, title:%s", userID, title)
|
||||
authList, err := auth2.GetUserBindAuthInfo(userID)
|
||||
findOneMethod := false
|
||||
if err == nil {
|
||||
|
||||
@@ -60,11 +60,9 @@ func New(notUsed interface{}, token string, w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Infof("jxcontext wrong token:%s", token)
|
||||
errCode = model.ErrCodeTokenIsInvalid
|
||||
// userInfo, err2 := auth.GetUserInfo(token)
|
||||
// if err = err2; err == nil {
|
||||
// // globals.SugarLogger.Debugf("jxcontext New, V1 authInfo:%s", utils.Format4Output(userInfo, true))
|
||||
// ctx.userInfo = userInfo
|
||||
// }
|
||||
}
|
||||
@@ -119,7 +117,6 @@ func (ctx *Context) GetLoginInfo() IAuther {
|
||||
|
||||
func (ctx *Context) GetV2AuthInfo() (authInfo *auth2.AuthInfo, err error) {
|
||||
authInfo, ok := ctx.userInfo.(*auth2.AuthInfo)
|
||||
// globals.SugarLogger.Debugf("GetV2AuthInfo, userInfo:%s", utils.Format4Output(ctx.userInfo, false))
|
||||
if ok {
|
||||
return authInfo, nil
|
||||
}
|
||||
|
||||
@@ -233,7 +233,6 @@ func RebindAllPrinters(ctx *jxcontext.Context, isForce, isAsync bool) (hint stri
|
||||
}
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debugf("RebindAllPrinters len(needRebindList):%d", len(needRebindList))
|
||||
if len(needRebindList) > 0 {
|
||||
db := dao.GetDB()
|
||||
task := tasksch.NewParallelTask("RebindAllPrinters", tasksch.NewParallelConfig().SetIsContinueWhenError(true).SetParallelCount(4), ctx,
|
||||
|
||||
@@ -72,7 +72,6 @@ func RefreshConfig(configKey string, expiresTime time.Duration, configGetter fun
|
||||
if handleType != 0 {
|
||||
if curConfig.Token, curConfig.Date, curConfig.RefreshToken = configGetter(); curConfig.Token == "" {
|
||||
if globals.IsProductEnv() {
|
||||
globals.SugarLogger.Infof("RefreshConfig %s get empty token", configKey)
|
||||
sleepDuration = errRefreshGap
|
||||
} else {
|
||||
globals.SugarLogger.Infof("RefreshConfig %s get empty token", configKey)
|
||||
@@ -198,7 +197,6 @@ func RefreshQywxToken() (err error) {
|
||||
func RefreshWeixin2Token() (err error) {
|
||||
if api.WeixinMiniAPI2 != nil {
|
||||
err = RefreshConfig("wechat2", weixinTokenExpires, func() (token string, expireTimeStr string, invalidParameter string) {
|
||||
globals.SugarLogger.Debugf("RefreshWeixin2Token RunMode:%s", beego.BConfig.RunMode)
|
||||
if globals.IsMainProductEnv() {
|
||||
if tokenInfo, err := api.WeixinMiniAPI2.CBRetrieveToken(); err == nil {
|
||||
token = tokenInfo.AccessToken
|
||||
@@ -225,7 +223,6 @@ func RefreshPushToken() (err error) {
|
||||
err = RefreshConfig("push", pushTokenExpires, func() (token string, expireTimeStr string, invalidParameter string) {
|
||||
if globals.IsMainProductEnv() {
|
||||
if tokenInfo, err := api.PushAPI.CBRetrieveToken(); err == nil {
|
||||
globals.SugarLogger.Debugf("RefreshPushToken tokenInfo:%s", utils.Format4Output(tokenInfo, true))
|
||||
token = tokenInfo.Token
|
||||
} else {
|
||||
globals.SugarLogger.Errorf("RefreshPushToken RefreshToken failed with error:%v", err)
|
||||
@@ -248,10 +245,8 @@ func RefreshPushToken() (err error) {
|
||||
func RefreshWeixin3Token() (err error) {
|
||||
// if api.WeixinMiniAPI3 != nil {
|
||||
// err = RefreshConfig("wechat3", weixinTokenExpires, func() (token string, expireTimeStr string) {
|
||||
// globals.SugarLogger.Debugf("RefreshWeixin3Token RunMode:%s", beego.BConfig.RunMode)
|
||||
// if globals.IsMainProductEnv() {
|
||||
// if tokenInfo, err := api.WeixinMiniAPI3.CBRetrieveToken(); err == nil {
|
||||
// globals.SugarLogger.Debugf("RefreshWeixin3Token tokenInfo:%s", utils.Format4Output(tokenInfo, true))
|
||||
// token = tokenInfo.AccessToken
|
||||
// } else {
|
||||
// globals.SugarLogger.Errorf("RefreshWeixin3Token RefreshToken failed with error:%v", err)
|
||||
@@ -264,7 +259,6 @@ func RefreshWeixin3Token() (err error) {
|
||||
// }
|
||||
// return token, expireTimeStr
|
||||
// }, func(value string) {
|
||||
// globals.SugarLogger.Debugf("RefreshWeixinToken setter value:%s", value)
|
||||
// syseventhub.SysEventHub.OnNewWX3Token(value)
|
||||
// api.WeixinMiniAPI3.CBSetToken(value)
|
||||
// })
|
||||
@@ -309,7 +303,6 @@ func RefreshDingDingToken() (err error) {
|
||||
return RefreshConfig("dingding", dingdingTokenExpires, func() (string, string, string) {
|
||||
if true { //globals.IsProductEnv() {
|
||||
if token, err := api.DingDingAPI.RetrieveToken(); err == nil {
|
||||
globals.SugarLogger.Debugf("RefreshDingDingToken tokenInfo:%s", token)
|
||||
return token, "", ""
|
||||
} else {
|
||||
globals.SugarLogger.Errorf("RefreshDingDingToken RefreshToken failed with error:%v", err)
|
||||
@@ -378,7 +371,6 @@ func PollingRemotEvent(remoteURL string, waitSecond int, params map[string]inter
|
||||
if result.Code == "0" {
|
||||
if result.Data != "" {
|
||||
if err = utils.UnmarshalUseNumber([]byte(result.Data), &tokenInfo); err == nil && tokenInfo != nil {
|
||||
globals.SugarLogger.Debugf("PollingRemotEvent %s:%s", remoteURL, utils.Format4Output(tokenInfo, false))
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -391,7 +383,6 @@ func PollingRemotEvent(remoteURL string, waitSecond int, params map[string]inter
|
||||
err = platformapi.ErrHTTPCodeIsNot200
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Infof("PollingRemotEvent %s failed with error:%v", remoteURL, err)
|
||||
if err != nil {
|
||||
time.Sleep(errRefreshGap)
|
||||
}
|
||||
@@ -492,7 +483,6 @@ func getWeimobTokenFromRemote(oldToken string) (tokenInfo *syseventhub.TokenInfo
|
||||
// })
|
||||
// return token, expireTimeStr, refreshToken
|
||||
// }, func(value, v2 string) {
|
||||
// globals.SugarLogger.Debugf("RefreshFnToken setter value:[%s],[%s]", value, v2)
|
||||
// api.TiktokStore.SetToken(value)
|
||||
// api.TiktokStore.SetRefreshToken(v2)
|
||||
// })
|
||||
|
||||
@@ -124,10 +124,8 @@ func (task *ParallelTask) Run() {
|
||||
result, successCount, err := task.callWorker2(func() (retVal interface{}, successCount int, err error) {
|
||||
return task.worker(task, job, task.params...)
|
||||
})
|
||||
// globals.SugarLogger.Debugf("ParallelTask.Run %s, after call worker result:%v, err:%v", task.Name, result, err)
|
||||
task.finishedOneJob(len(job), successCount, err)
|
||||
if err != nil { // 出错
|
||||
// globals.SugarLogger.Infof("ParallelTask.Run %s, subtask(job:%s, params:%s) result:%v, failed with error:%v", task.Name, utils.Format4Output(job, true), utils.Format4Output(task.params, true), result, err)
|
||||
if task.IsContinueWhenError {
|
||||
task.AddBatchErr(err)
|
||||
} else {
|
||||
@@ -142,7 +140,6 @@ func (task *ParallelTask) Run() {
|
||||
}
|
||||
}
|
||||
end:
|
||||
// globals.SugarLogger.Debugf("ParallelTask.Run %s, put to chann chanRetVal:%v", task.Name, chanRetVal)
|
||||
task.locker.RLock()
|
||||
if task.Status < TaskStatusEndBegin {
|
||||
task.subFinishChan <- chanRetVal
|
||||
@@ -159,7 +156,6 @@ func (task *ParallelTask) Run() {
|
||||
var taskErr error
|
||||
for i := 0; i < task.ParallelCount; i++ {
|
||||
result := <-task.subFinishChan
|
||||
// globals.SugarLogger.Debugf("ParallelTask.Run %s, received from chann result:%v", taskName, result)
|
||||
if err, ok := result.(error); ok {
|
||||
task.Cancel()
|
||||
taskResult = nil
|
||||
|
||||
@@ -44,7 +44,6 @@ func (task *SeqTask) Run() {
|
||||
})
|
||||
task.finishedOneJob(1, 0, err)
|
||||
if err != nil {
|
||||
// globals.SugarLogger.Infof("SeqTask.Run %s step:%d failed with error:%v", task.Name, i, err)
|
||||
if task.IsContinueWhenError {
|
||||
task.AddBatchErr(err)
|
||||
} else {
|
||||
|
||||
@@ -35,7 +35,6 @@ func pushToSingle(content, title string, storeID int) {
|
||||
Body: content,
|
||||
})
|
||||
if err = err2; err != nil {
|
||||
globals.SugarLogger.Debugf("NotifyNewOrder push error: [%v]", err)
|
||||
continue
|
||||
}
|
||||
if status == unipushapi.SuccessOffLine {
|
||||
@@ -52,7 +51,6 @@ func pushToSingle(content, title string, storeID int) {
|
||||
}
|
||||
|
||||
func NotifyNewOrder(order *model.GoodsOrder) {
|
||||
globals.SugarLogger.Debugf("NotifyNewOrder push begin orderID :[%v]", order.VendorOrderID)
|
||||
if order == nil || len(order.Skus) == 0 {
|
||||
return
|
||||
}
|
||||
@@ -89,7 +87,6 @@ func getOrderDetailBrief(order *model.GoodsOrder) (brief string) {
|
||||
}
|
||||
|
||||
func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyAfsOrder push begin orderID :[%v]", afsOrder.VendorOrderID)
|
||||
pushToSingle("老板,您有新的售后单,请尽快处理!", "京西菜市售后单推送", jxutils.GetSaleStoreIDFromAfsOrder(afsOrder))
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@ func GetWeixinOpenIDsFromStoreID(storeID int) (retVal []string) {
|
||||
retVal = jxutils.StringMap2List(openIDMap)
|
||||
if !globals.ReallyCallPlatformAPI {
|
||||
// todo,调试,只发给我
|
||||
globals.SugarLogger.Debugf("GetWeixinOpenIDsFromStoreID store:%d, openids:%v", storeID, retVal)
|
||||
if storeID == 100146 {
|
||||
retVal = []string{"oYN_ust9hXKEvEv0X6Mq6nlAWs_E"}
|
||||
} else {
|
||||
@@ -129,7 +128,6 @@ func GetWeixinOpenIDsFromStoreID(storeID int) (retVal []string) {
|
||||
}
|
||||
|
||||
func SendMsgToStore(storeID int, templateID, downloadURL, miniPageURL string, data interface{}) (err error) {
|
||||
globals.SugarLogger.Debugf("SendMsgToStore storeID:%d, templateID:%s, downloadURL:%s, miniPageURL:%s", storeID, templateID, downloadURL, miniPageURL)
|
||||
if storeID == 0 { // 测试,只发给我
|
||||
// SmartMessageTemplateSend("oYN_ust9hXKEvEv0X6Mq6nlAWs_E", templateID, downloadURL, miniPageURL, data)
|
||||
} else {
|
||||
@@ -137,10 +135,6 @@ func SendMsgToStore(storeID int, templateID, downloadURL, miniPageURL string, da
|
||||
successCount := 0
|
||||
for _, openID := range openIDs {
|
||||
realMiniPageURL := miniPageURL
|
||||
// if testMiniProgramStoreMap[storeID] == 0 && debugOpenIDMap[openID] == 0 {
|
||||
// realMiniPageURL = ""
|
||||
// }
|
||||
globals.SugarLogger.Debugf("SendMsgToStore storeID:%d, openID:%s, templateID:%s, downloadURL:%s, realMiniPageURL:%s", storeID, openID, templateID, downloadURL, realMiniPageURL)
|
||||
if err2 := SmartMessageTemplateSend(openID, templateID, downloadURL, realMiniPageURL, data); err2 == nil {
|
||||
successCount++
|
||||
} else {
|
||||
@@ -165,7 +159,6 @@ func SmartMessageTemplateSend(userOpenID, templateID, downloadURL, miniPageURL s
|
||||
"pagepath": miniPageURL,
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debugf("SmartMessageTemplateSend openID:%s, templateID:%s, downloadURL:%s, miniProgram:%s", userOpenID, templateID, downloadURL, utils.Format4Output(miniProgram, true))
|
||||
if globals.ReallySendWeixinMsg || debugOpenIDMap[userOpenID] == 1 {
|
||||
if err = api.WeixinAPI.CBMessageTemplateSend(userOpenID, templateID, downloadURL, miniProgram, data); err != nil {
|
||||
globals.SugarLogger.Debugf("SmartMessageTemplateSend openID:%s, templateID:%s, downloadURL:%s, miniProgram:%s, failed with error:%v", userOpenID, templateID, downloadURL, utils.Format4Output(miniProgram, true), err)
|
||||
@@ -205,7 +198,6 @@ func getOrderDetailBrief(order *model.GoodsOrder) (brief string) {
|
||||
}
|
||||
|
||||
func NotifyNewOrder(order *model.GoodsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyNewOrder orderID:%s", order.VendorOrderID)
|
||||
if order.VendorID == model.VendorIDELM {
|
||||
return nil
|
||||
}
|
||||
@@ -262,7 +254,6 @@ func NotifyNewOrder(order *model.GoodsOrder) (err error) {
|
||||
}
|
||||
|
||||
func NotifyWaybillStatus(bill *model.Waybill, order *model.GoodsOrder, isBillAlreadyCandidate bool) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyWaybillStatus orderID:%s bill:%v", order.VendorOrderID, bill)
|
||||
if order.VendorID == model.VendorIDELM {
|
||||
return nil
|
||||
}
|
||||
@@ -337,7 +328,6 @@ func NotifyWaybillStatus(bill *model.Waybill, order *model.GoodsOrder, isBillAlr
|
||||
}
|
||||
|
||||
func NotifyUserApplyCancel(order *model.GoodsOrder, cancelReason string) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyUserApplyCancel orderID:%s", order.VendorOrderID)
|
||||
if order.VendorID == model.VendorIDELM {
|
||||
return nil
|
||||
}
|
||||
@@ -384,7 +374,6 @@ func NotifyUserApplyCancel(order *model.GoodsOrder, cancelReason string) (err er
|
||||
}
|
||||
|
||||
func NotifyOrderChanged(order *model.GoodsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyOrderChanged orderID:%s", order.VendorOrderID)
|
||||
if order.VendorID == model.VendorIDELM {
|
||||
return nil
|
||||
}
|
||||
@@ -430,7 +419,6 @@ func NotifyOrderChanged(order *model.GoodsOrder) (err error) {
|
||||
}
|
||||
|
||||
func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyOrderCanceled orderID:%s", order.VendorOrderID)
|
||||
if order.VendorID == model.VendorIDELM {
|
||||
return nil
|
||||
}
|
||||
@@ -491,7 +479,6 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
|
||||
}
|
||||
|
||||
func PushJDBadCommentToWeiXin(comment *legacymodel.JxBadComments, isBadComment bool, order *model.GoodsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("PushJDBadCommentToWeiXin orderID:%s", comment.OrderId)
|
||||
suffix := ""
|
||||
storeDetail, err := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, "")
|
||||
if err == nil && storeDetail != nil {
|
||||
@@ -549,7 +536,6 @@ func PushJDBadCommentToWeiXin(comment *legacymodel.JxBadComments, isBadComment b
|
||||
}
|
||||
|
||||
func NotifySaleBill(storeID int, title, shopName, fileURL string) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifySaleBill storeID:%d, fileURL:%s", storeID, fileURL)
|
||||
if title == "" {
|
||||
title = "当期账单"
|
||||
}
|
||||
@@ -582,7 +568,6 @@ func NotifySaleBill(storeID int, title, shopName, fileURL string) (err error) {
|
||||
}
|
||||
|
||||
func NotifyStoreOpRequestStatus(isAccepted bool, storeID, nameID int, spuName string, originalUnitPrice, unitPrice int, rejectReason string) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyStoreOpRequestStatus isAccepted:%t, storeID:%d, nameID:%d, spuName:%s, originalUnitPrice:%d, unitPrice:%d, rejectReason:%s", isAccepted, storeID, nameID, spuName, originalUnitPrice, unitPrice, rejectReason)
|
||||
templateID := ""
|
||||
fileURL := globals.WxBackstageHost + fmt.Sprintf("%s%d", WX_TO_STORE_SKU_PAGE_URL, storeID)
|
||||
data := make(map[string]interface{})
|
||||
@@ -638,7 +623,6 @@ func NotifyStoreOpRequestStatus(isAccepted bool, storeID, nameID int, spuName st
|
||||
}
|
||||
|
||||
func NotifyStoreMessage(storeID, msgID, msgStatusID int, msg *model.Message) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyStoreMessage storeID:%d, msgID:%d, title:%s, content:%s", storeID, msgID, msg.Title, msg.Content)
|
||||
templateID := ""
|
||||
fileURL := globals.WxBackstageHost + fmt.Sprintf(WX_TO_SHOW_MSG, msgID, msgStatusID)
|
||||
data := make(map[string]interface{})
|
||||
@@ -692,7 +676,6 @@ func NotifyStoreMessage(storeID, msgID, msgStatusID int, msg *model.Message) (er
|
||||
}
|
||||
|
||||
func NotifyAfsOrderStatus(afsOrder *model.AfsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyAfsOrderStatus orderID:%s", afsOrder.VendorOrderID)
|
||||
if afsOrder.VendorID == model.VendorIDELM {
|
||||
return nil
|
||||
}
|
||||
@@ -799,7 +782,6 @@ func NotifyStoreStatusChanged(openUserID, title, content string) (err error) {
|
||||
}
|
||||
|
||||
func NotifyStoreAlertMessage(storeID int, storeName, title, content string) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyStoreAlertMessage storeID:%d, storeName:%d, title:%s, content:%s", storeID, storeName, title, content)
|
||||
templateID := WX_STORE_ALERT_TEMPLATE_ID
|
||||
data := map[string]interface{}{
|
||||
"first": map[string]interface{}{
|
||||
@@ -896,7 +878,6 @@ func SendStoreMessage(ctx *jxcontext.Context, title, content string, storeIDs []
|
||||
msgStatus.Status = model.MessageStatusSendAllFailed
|
||||
}
|
||||
dao.WrapUpdateULEntity(msgStatus, ctx.GetUserName())
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(msgStatus, false))
|
||||
_, err = dao.UpdateEntity(db, msgStatus)
|
||||
return nil, err
|
||||
}, msgStatusList)
|
||||
@@ -911,7 +892,6 @@ func SendStoreMessage(ctx *jxcontext.Context, title, content string, storeIDs []
|
||||
}
|
||||
|
||||
func NotifyAdjustOrder(order *model.GoodsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyAdjustOrder orderID:%s", order.VendorOrderID)
|
||||
if order.VendorID == model.VendorIDELM {
|
||||
return nil
|
||||
}
|
||||
@@ -1010,7 +990,6 @@ func SendStoreMessageKnowledge(ctx *jxcontext.Context, title string, knowIDs, st
|
||||
msgStatus.Status = model.MessageStatusSendAllFailed
|
||||
}
|
||||
dao.WrapUpdateULEntity(msgStatus, ctx.GetUserName())
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(msgStatus, false))
|
||||
_, err = dao.UpdateEntity(db, msgStatus)
|
||||
return nil, err
|
||||
}, msgStatusList)
|
||||
@@ -1024,7 +1003,6 @@ func SendStoreMessageKnowledge(ctx *jxcontext.Context, title string, knowIDs, st
|
||||
}
|
||||
|
||||
func NotifyKnowledge(storeID int, title string) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyKnowledge storeID:%d, title:%s", storeID, title)
|
||||
templateID := WX_KNOWLEDGE_BASE_TEMPLATE_ID
|
||||
data := map[string]interface{}{
|
||||
"first": map[string]interface{}{
|
||||
@@ -1103,7 +1081,6 @@ func SendUserMessage(ctx *jxcontext.Context, title, content string, userIDs []st
|
||||
}
|
||||
|
||||
func NotifyUserMessage(userID string, title, content string) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyUserMessage userID:%d, title:%s, content:%s", userID, title, content)
|
||||
templateID := WX_NORMAL_STORE_MSG_TEMPLATE_ID
|
||||
data := map[string]interface{}{
|
||||
"first": map[string]interface{}{
|
||||
@@ -1126,7 +1103,6 @@ func NotifyUserMessage(userID string, title, content string) (err error) {
|
||||
}
|
||||
|
||||
func SendMsgToUser(userID string, templateID string, data interface{}) (err error) {
|
||||
globals.SugarLogger.Debugf("SendMsgToUser userID:%d, templateID:%s", userID, templateID)
|
||||
authBinds, err := dao.GetUserBindAuthInfo(dao.GetDB(), userID, model.AuthBindTypeAuth, []string{"weixinsns"}, "", "", []string{"wx2bb99eb5d2c9b82c"})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1135,7 +1111,6 @@ func SendMsgToUser(userID string, templateID string, data interface{}) (err erro
|
||||
if len(authBinds) == 0 {
|
||||
return fmt.Errorf("此用户未找到微信认证方式!userID: %v", userID)
|
||||
}
|
||||
globals.SugarLogger.Debugf("SendMsgToUser userID:%d, openID:%s, templateID:%s", userID, authBinds[0].AuthID, templateID)
|
||||
if err2 := SmartMessageTemplateSend(authBinds[0].AuthID, templateID, "", "", data); err2 == nil {
|
||||
successCount++
|
||||
} else {
|
||||
|
||||
@@ -72,7 +72,6 @@ func GetActVendorInfo(db *DaoDB, actID int, vendorIDs []int) (actMap map[int]*mo
|
||||
}
|
||||
|
||||
func GetActStoreSkuVendorList(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs []int, keyword string, offset, pageSize int) (totalCount int, actStoreSkuList []*model.ActStoreSku2, err error) {
|
||||
globals.SugarLogger.Debugf("GetActStoreSkuVendorList actID:%d", actID)
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
|
||||
@@ -148,9 +147,6 @@ func GetActStoreSkuVendorList(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs
|
||||
}
|
||||
sql += " LIMIT ? OFFSET ?;"
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(actStoreSkuList, false))
|
||||
txDB, _ := Begin(db)
|
||||
defer Commit(db, txDB)
|
||||
if err = GetRowsTx(txDB, &actStoreSkuList, sql, sqlParams...); err == nil {
|
||||
@@ -299,7 +295,6 @@ func QueryActs(db *DaoDB, actID int, offset, pageSize int, syncStatus int, keywo
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
if err = GetRowsTx(txDB, &idList, sql, sqlParams...); err != nil || len(idList) == 0 {
|
||||
//Rollback(db, txDB)
|
||||
Commit(db, txDB)
|
||||
@@ -326,7 +321,6 @@ func QueryActs(db *DaoDB, actID int, offset, pageSize int, syncStatus int, keywo
|
||||
}
|
||||
}
|
||||
var actList []*tActAndMap
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
if err = GetRows(db, &actList, sql, sqlParams...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -467,8 +461,6 @@ func GetEffectiveActStoreSkuInfo2(db *DaoDB, actID int, vendorIDs []int, actType
|
||||
if globals.IsStoreSkuAct {
|
||||
sql += " AND t1.is_special = 0"
|
||||
}
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
||||
err = GetRows(db, &actStoreSkuList, sql, sqlParams...)
|
||||
return actStoreSkuList, err
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ func Begin(db *DaoDB) (txDB orm.TxOrmer, err error) {
|
||||
func (db *DaoDB) startWatchTransaction() {
|
||||
db.beginTransactionStack = debug.Stack()
|
||||
db.transactionWatchTimer = utils.AfterFuncWithRecover(transactionWarningSeconds*time.Second, func() {
|
||||
globals.SugarLogger.Warnf("Begin Transaction too long, %s", string(db.beginTransactionStack))
|
||||
db.transactionWatchTimer = nil
|
||||
db.beginTransactionStack = nil
|
||||
})
|
||||
|
||||
@@ -21,7 +21,6 @@ func GetAuthBind(db *DaoDB, bindType int, authType, authID string) (authBind *mo
|
||||
authType,
|
||||
authID,
|
||||
}
|
||||
// globals.SugarLogger.Debugf("GetAuthBind sql:%s, sqlParams:%s", sql, utils.Format4Output(sqlParams, false))
|
||||
err = GetRow(db, &authBind, sql, sqlParams...)
|
||||
return authBind, err
|
||||
}
|
||||
|
||||
@@ -131,7 +131,6 @@ func UpdateEntityLogicallyAndUpdateSyncStatus(db *DaoDB, item interface{}, kvs m
|
||||
valueRows := reflect.New(reflect.SliceOf(typeInfo))
|
||||
rows := valueRows.Interface()
|
||||
if err = GetEntitiesByKV(db, rows, conditions, false); err == nil {
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(rows, false))
|
||||
valueRows = reflect.Indirect(valueRows)
|
||||
for i := 0; i < valueRows.Len(); i++ {
|
||||
value := reflect.Indirect(valueRows.Index(i))
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -342,7 +341,6 @@ func GetStoresOrderSaleInfo(db *DaoDB, storeIDList []int, fromTime time.Time, to
|
||||
GROUP BY 1,2,3`
|
||||
|
||||
sql += " ORDER BY 1,2,3"
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
err = GetRows(db, &saleInfoList, sql, sqlParams...)
|
||||
return saleInfoList, err
|
||||
}
|
||||
@@ -811,7 +809,6 @@ func GetOrderPayList(db *DaoDB, vendorOrderID string, vendorID int) (payList []*
|
||||
}
|
||||
|
||||
func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDateStr, toDateStr string, isDateFinish bool, skuIDs []int, isJxFirst bool, userID string, params map[string]interface{}, offset, pageSize int) (orders []*model.GoodsOrderExt, totalCount int, err error) {
|
||||
globals.SugarLogger.Debugf("dao GetOrders ids:%v from:%s to:%s", ids, fromDateStr, toDateStr)
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
|
||||
@@ -1172,7 +1169,6 @@ func GetPendingFakeOrders(db *DaoDB, vendorIDs []int, orderCreatedAfter, orderCr
|
||||
sql += " AND t1.vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")"
|
||||
sqlParams = append(sqlParams, vendorIDs)
|
||||
}
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
err = GetRows(db, &orderList, sql, sqlParams...)
|
||||
return orderList, err
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ func TestGetAfsOrderSkuInfo(t *testing.T) {
|
||||
//if err != nil {
|
||||
// t.Fatal(err)
|
||||
//}
|
||||
//globals.SugarLogger.Debug(utils.Format4Output(afsSkus, false))
|
||||
//afsSkus, err = GetAfsOrderSkuInfo(GetDB(), "916829559000841", "", 0)
|
||||
//if err != nil {
|
||||
// t.Fatal(err)
|
||||
|
||||
@@ -3,9 +3,7 @@ package dao
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
)
|
||||
|
||||
@@ -23,7 +21,6 @@ func TestSelectEntities(t *testing.T) {
|
||||
WHERE t1.name_id = ?
|
||||
`, 40)
|
||||
|
||||
globals.SugarLogger.Debug(utils.Format4Output(places, false))
|
||||
}
|
||||
|
||||
func TestGetPlaceByName(t *testing.T) {
|
||||
|
||||
@@ -39,7 +39,6 @@ func GetUserByID(db *DaoDB, fieldName, fieldValue string) (user *model.User, err
|
||||
model.UserStatusNormal,
|
||||
fieldValue,
|
||||
}
|
||||
// globals.SugarLogger.Debugf("GetUserByID sql:%s, sqlParams:%s", sql, utils.Format4Output(sqlParams, false))
|
||||
err = GetRow(db, &user, sql, sqlParams...)
|
||||
return user, err
|
||||
}
|
||||
@@ -55,7 +54,6 @@ func GetUserByIDWithMembers(db *DaoDB, fieldName, fieldValue string) (getSelfInf
|
||||
model.UserStatusNormal,
|
||||
fieldValue,
|
||||
}
|
||||
// globals.SugarLogger.Debugf("GetUserByID sql:%s, sqlParams:%s", sql, utils.Format4Output(sqlParams, false))
|
||||
err = GetRow(db, &getSelfInfoResult, sql, sqlParams...)
|
||||
return getSelfInfoResult, err
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
// 带购物平台信息的
|
||||
@@ -752,8 +751,6 @@ func GetStorePriceScoreSnapshot(db *DaoDB, snapDate time.Time) (storePriceScoreS
|
||||
}
|
||||
|
||||
func SetStoreMapSyncStatus(db *DaoDB, vendorIDs, storeIDs []int, syncStatus int) (num int64, err error) {
|
||||
globals.SugarLogger.Debugf("SetStoreMapSyncStatus, vendorIDs:%v, storeIDs:%v", vendorIDs, storeIDs)
|
||||
|
||||
sql := `
|
||||
UPDATE store_map t1
|
||||
SET t1.sync_status = t1.sync_status | ?
|
||||
|
||||
@@ -793,8 +793,6 @@ func GetStoreSkuPriceAndWeight(db *DaoDB, vendorStoreID string, vendorID int, ve
|
||||
|
||||
// 这个函数之前是要设置没有删除或同步标志不为0的,会导致将同步标志不为0且删除了的把标志去掉,现在改为只设置没有删除的
|
||||
func SetStoreSkuSyncStatus(db *DaoDB, vendorID int, storeIDs []int, skuIDs []int, syncStatus int) (num int64, err error) {
|
||||
globals.SugarLogger.Debugf("SetStoreSkuSyncStatus, storeIDs:%v, vendorID:%d", storeIDs, vendorID)
|
||||
|
||||
isSingleStorePF := model.MultiStoresVendorMap[vendorID] != 1
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[vendorID])
|
||||
sql := `
|
||||
@@ -1515,7 +1513,6 @@ func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesI
|
||||
|
||||
actStoreSkuList, err := GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, model.ActTypeAll, storeIDs, skuIDs, time.Now(), time.Now())
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err)
|
||||
return err
|
||||
}
|
||||
actStoreSkuMap4Act := jxutils.NewActStoreSkuMap(actStoreSkuList, true)
|
||||
|
||||
@@ -73,7 +73,6 @@ func routinueFunc() {
|
||||
delete(channelMap[registerMsg.StoreID], registerMsg.Chan2Listen)
|
||||
close(registerMsg.Chan2Close)
|
||||
case ServerMsgNewOrder, ServerMsgFinishedPickup, ServerMsgKeyOrderStatusChanged, ServerMsgNewWait4ApproveAfsOrder, ServerMsgKeyAfsOrderStatusChanged:
|
||||
globals.SugarLogger.Debugf("msghub routinueFunc, msg:%s", utils.Format4Output(msg, true))
|
||||
utils.CallFuncAsync(func() {
|
||||
for chan2Send := range channelMap[msg.StoreID] {
|
||||
chan2Send <- msg
|
||||
@@ -165,7 +164,6 @@ func GetMsg(ctx *jxcontext.Context, storeID int, lastOrderTime time.Time, lastOr
|
||||
}
|
||||
|
||||
func OnNewOrder(order *model.GoodsOrder) {
|
||||
globals.SugarLogger.Debugf("msghub OnNewOrder, order:%s", utils.Format4Output(order, true))
|
||||
utils.CallFuncAsync(func() {
|
||||
msgChan <- &ServerMsg{
|
||||
Type: ServerMsgNewOrder,
|
||||
@@ -197,7 +195,6 @@ func OnFinishedPickup(order *model.GoodsOrder) {
|
||||
}
|
||||
|
||||
func OnKeyOrderStatusChanged(order *model.GoodsOrder) {
|
||||
globals.SugarLogger.Debugf("msghub OnKeyOrderStatusChanged, order:%s", utils.Format4Output(order, true))
|
||||
utils.CallFuncAsync(func() {
|
||||
msgChan <- &ServerMsg{
|
||||
Type: ServerMsgKeyOrderStatusChanged,
|
||||
@@ -208,7 +205,6 @@ func OnKeyOrderStatusChanged(order *model.GoodsOrder) {
|
||||
}
|
||||
|
||||
func OnNewWait4ApproveAfsOrder(order *model.AfsOrder) {
|
||||
globals.SugarLogger.Debugf("msghub OnNewWait4ApproveAfsOrder, order:%s", utils.Format4Output(order, true))
|
||||
utils.CallFuncAsync(func() {
|
||||
msgChan <- &ServerMsg{
|
||||
Type: ServerMsgNewWait4ApproveAfsOrder,
|
||||
|
||||
@@ -31,7 +31,6 @@ func GetCityShops(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorIDs []
|
||||
if err = err2; err == nil {
|
||||
retVal = storeList
|
||||
}
|
||||
globals.SugarLogger.Debugf("GetCityShops vendorID:%d, cityCode:%d, len(storeList):%d, err:%v", vendorID, cityCode, len(storeList), err)
|
||||
return retVal, err
|
||||
}, vendorIDs)
|
||||
tasksch.AddChild(parentTask, task).Run()
|
||||
@@ -173,7 +172,6 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
|
||||
cityCodeList2 = append(cityCodeList2, cityCodeList[:index]...)
|
||||
cityCodeList = cityCodeList2
|
||||
}
|
||||
globals.SugarLogger.Debugf("GetAndStoreCitiesShops last cityCode:%d, cityCodeList:%v", lastShop.CityCode, cityCodeList)
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("GetAndStoreCitiesShops get lastest city code error:%v", err2)
|
||||
}
|
||||
@@ -191,10 +189,9 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
|
||||
task := tasksch.NewParallelTask(fmt.Sprintf("GetAndStoreCitiesShops:%v", vendorIDs), tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
cityCode := batchItemList[0].(int)
|
||||
globals.SugarLogger.Debugf("process city:%d", cityCode)
|
||||
shopList, err := GetCityShops(ctx, task, vendorIDs, cityCode, radius, gridWith)
|
||||
if err == nil {
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -222,7 +219,6 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
|
||||
dao.Commit(db, txDB)
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debugf("process city:%d, len(shopList):%d, err:%v", cityCode, len(shopList), err)
|
||||
return nil, err
|
||||
}, cityCodeList)
|
||||
tasksch.ManageTask(task).Run()
|
||||
|
||||
@@ -302,7 +302,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
// 检查两天内是否有订单
|
||||
var result *dadaapi.CreateOrderResponse
|
||||
if len(waybillList) > 0 && waybillList[0].Status != model.WaybillStatusFailed {
|
||||
globals.SugarLogger.Debugf("CreateWaybill orderID:%s len(waybillList)=%d use ReaddOrder", order.VendorOrderID, len(waybillList))
|
||||
// 检索达达配送费阀值
|
||||
if err = delivery.CallCreateWaybillPolicy(waybillList[0].ActualFee, maxDeliveryFee, order, model.VendorIDDada); err != nil {
|
||||
return nil, err
|
||||
@@ -310,7 +309,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
// 重新发送订单
|
||||
result, err = api.DadaAPI.ReaddOrder(billParams)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("CreateWaybill orderID:%s error:%v", order.VendorOrderID, err)
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
@@ -325,7 +323,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
}
|
||||
// 真实发布订单
|
||||
if err = api.DadaAPI.AddOrderAfterQuery(result.DeliveryNo); err != nil {
|
||||
globals.SugarLogger.Warnf("CreateWaybill for Dada order err , orderID:%s error:%v", order.VendorOrderID, err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -369,7 +366,6 @@ func (c *DeliveryHandler) getDataCityCodeFromOrder(order *model.GoodsOrder, db *
|
||||
TelCode string
|
||||
}{}
|
||||
if err = dao.GetRow(db, codeInfo, sql, jxStoreID); err != nil {
|
||||
globals.SugarLogger.Errorf("GetDataCityCodeFromOrder can not find store info for vendorID:%d, store:%s, error:%v", order.VendorID, order.VendorStoreID, err)
|
||||
if err == nil {
|
||||
err = ErrCanNotFindDadaCityCode
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ func init() {
|
||||
func TestCreateWaybill(t *testing.T) {
|
||||
orderID := "817540316000041"
|
||||
if order, err := partner.CurOrderManager.LoadOrder(orderID, model.VendorIDJD); err == nil {
|
||||
// globals.SugarLogger.Debug(order)
|
||||
_, err = CurDeliveryHandler.CreateWaybill(order, 0)
|
||||
if err == nil {
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
@@ -35,7 +35,6 @@ func CallCreateWaybillPolicy(deliveryFee, maxDeliveryFee int64, order *model.Goo
|
||||
}
|
||||
|
||||
func CalculateDeliveryFee(db *dao.DaoDB, jxStoreID int, hint string, consigneeLng, consigneeLat, coordinateType, weight int, billTime time.Time) (deliveryFee, addFee int64, err error) {
|
||||
globals.SugarLogger.Debugf("CalculateOrderDeliveryFee orderID:%s", hint)
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
@@ -62,11 +61,9 @@ func CalculateDeliveryFee(db *dao.DaoDB, jxStoreID int, hint string, consigneeLn
|
||||
deliveryFee = priceInfo.CityPrice
|
||||
}
|
||||
if deliveryFee == 0 {
|
||||
// globals.SugarLogger.Warnf("CalculateOrderDeliveryFee 查不到美团配送价格 orderID:%s", hint)
|
||||
deliveryFee = 650
|
||||
}
|
||||
if lng == 0 || lat == 0 {
|
||||
globals.SugarLogger.Infof("[运营]计算订单配送费orderID:%s,门店:%d没有坐标信息", hint, jxStoreID)
|
||||
return 0, 0, fmt.Errorf("找不到门店:%d的坐标", jxStoreID)
|
||||
}
|
||||
lng2, lat2, _ := jxutils.IntCoordinate2MarsStandard(consigneeLng, consigneeLat, coordinateType)
|
||||
@@ -76,7 +73,7 @@ func CalculateDeliveryFee(db *dao.DaoDB, jxStoreID int, hint string, consigneeLn
|
||||
// 距离加价
|
||||
distance := jxutils.WalkingDistance(lng, lat, lng2, lat2)
|
||||
if distance > warningDistance {
|
||||
//globals.SugarLogger.Infof("[运营]计算订单配送费orderID:%s,距离%.3fkm太远,请检查门店坐标信息", hint, distance)
|
||||
globals.SugarLogger.Infof("[运营]计算订单配送费orderID:%s,距离%.3fkm太远,请检查门店坐标信息", hint, distance)
|
||||
}
|
||||
distanceAddFee = int64(jxutils.CalcStageValue([][]float64{
|
||||
[]float64{
|
||||
@@ -95,7 +92,7 @@ func CalculateDeliveryFee(db *dao.DaoDB, jxStoreID int, hint string, consigneeLn
|
||||
|
||||
// 重量加价
|
||||
if weight > warningWeight {
|
||||
//globals.SugarLogger.Infof("[运营]计算订单配送费orderID:%s,重量:%dg太重,请检查商品属性", hint, weight)
|
||||
globals.SugarLogger.Infof("[运营]计算订单配送费orderID:%s,重量:%dg太重,请检查商品属性", hint, weight)
|
||||
}
|
||||
weightAddFee = int64(jxutils.CalcStageValue([][]float64{
|
||||
[]float64{
|
||||
|
||||
@@ -142,7 +142,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
// 创建蜂鸟订单,运单id
|
||||
fnOrderId, err := api.FnAPI.CreateOrder(parameter)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("CreateWaybill failed, orderID:%s, billParams:%v, error:%v", order.VendorOrderID, parameter, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -203,7 +202,6 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
|
||||
func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify) (resp *fnpsapi.CallbackResponse) {
|
||||
cc := &fnpsapi.OrderCallbackParam{}
|
||||
if err := utils.Map2StructByJson(msg.Param, cc, true); err != nil {
|
||||
globals.SugarLogger.Debugf("FNPS strconv.Atoi fail :[%s]", err)
|
||||
return fnpsapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
|
||||
@@ -230,7 +228,6 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify) (resp *fnpsapi.CallbackRespon
|
||||
|
||||
orderStatus, err := strconv.Atoi(order.VendorStatus)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("FNPS strconv.Atoi fail :[%s]", err)
|
||||
return fnpsapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
switch orderStatus {
|
||||
@@ -257,7 +254,6 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify) (resp *fnpsapi.CallbackRespon
|
||||
globals.SugarLogger.Warnf("onWaybillMsg unknown msg:%v", msg)
|
||||
}
|
||||
if err := partner.CurOrderManager.OnWaybillStatusChanged(order); err != nil {
|
||||
globals.SugarLogger.Debugf("FNPS partner.CurOrderManager.OnWaybillStatusChanged fail :[%s]", err)
|
||||
return fnpsapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
defer delivery.GetOrderRiderInfoToPlatform(order.VendorOrderID) // 骑手位置更新
|
||||
|
||||
@@ -39,7 +39,6 @@ func OnStoreStatus(msg *mtpsapi.CallbackShopStatusMsg) (retVal *mtpsapi.Callback
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) OnStoreStatus(msg *mtpsapi.CallbackShopStatusMsg) (retVal *mtpsapi.CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("mtps OnStoreStatus, msg:%s", utils.Format4Output(msg, true))
|
||||
err := partner.CurStoreManager.OnCourierStoreStatusChanged(jxcontext.AdminCtx, msg.ShopID, model.VendorIDMTPS, getAuditStatus(msg.Status), msg.RejectMessage)
|
||||
retVal = mtpsapi.Err2CallbackResponse(err, "mtps OnStoreStatus")
|
||||
return retVal
|
||||
|
||||
@@ -108,7 +108,6 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
|
||||
case mtpsapi.OrderStatusCanceled:
|
||||
order.Status = model.WaybillStatusCanceled
|
||||
default:
|
||||
globals.SugarLogger.Warnf("onWaybillMsg unknown msg:%v", msg)
|
||||
return mtpsapi.SuccessResponse
|
||||
}
|
||||
order2, _ := partner.CurOrderManager.LoadOrder(order.VendorOrderID, order.OrderVendorID)
|
||||
@@ -140,7 +139,6 @@ func (c *DeliveryHandler) pushToGy(msg *mtpsapi.CallbackOrderMsg) {
|
||||
urls := utils.Map2URLValues(params)
|
||||
sign := signParams(urls)
|
||||
params["sign"] = sign
|
||||
globals.SugarLogger.Debugf("pushToGy", utils.Format4Output(msg, false))
|
||||
request, err := http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/mtps/status", strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
if err != nil {
|
||||
return
|
||||
@@ -316,7 +314,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
// 通知美团订单,获取返回订单配送费
|
||||
result, err := api.MtpsAPI.CreateOrderByShop2(billParams)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("CreateWaybill failed, orderID:%s, billParams:%v, error:%v", order.VendorOrderID, billParams, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ func init() {
|
||||
func TestCreateWaybill(t *testing.T) {
|
||||
orerID := "817109342000022"
|
||||
order, _ := partner.CurOrderManager.LoadOrder(orerID, model.VendorIDJD)
|
||||
// globals.SugarLogger.Debug(order)
|
||||
c := new(DeliveryHandler)
|
||||
_, err := c.CreateWaybill(order, 0)
|
||||
if err != nil {
|
||||
@@ -38,6 +37,6 @@ func TestCancelWaybill(t *testing.T) {
|
||||
|
||||
func Test11(t *testing.T) {
|
||||
type1 := 3
|
||||
type1 |=2
|
||||
type1 |= 2
|
||||
fmt.Println(type1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ func GetOrderRiderInfoToPlatform(orderId string) {
|
||||
// 每五分钟查询当前订单信息,待配送状态订单1
|
||||
orders, _, err := dao.GetOrders(dao.GetDB(), nil, false, true, time.Now().Add(-24*time.Hour).Format("2006-01-02"), time.Now().Format("2006-01-02"), false, nil, false, "", params, 0, 10000)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("GetOrder err :%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -50,10 +49,6 @@ func GetOrderRiderInfoToPlatform(orderId string) {
|
||||
//3.当同一个订单已经上传了一次配送信息,如再次同步会更新配送信息,以最新的一次为准。
|
||||
//4.如订单已完成、已取消等状态发货将失败。
|
||||
for _, v := range orders {
|
||||
globals.SugarLogger.Debugf("回传信息测试输出------------------,%s---%d---%s", v.VendorOrderID, v.WaybillVendorID, v.VendorWaybillID)
|
||||
//if v.Status < 20 {
|
||||
// continue
|
||||
//}
|
||||
riderInfo := &mtpsapi.RiderInfo{}
|
||||
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID); handlerInfo != nil {
|
||||
if v.WaybillVendorID == model.VendorIDDada || v.WaybillVendorID == model.VendorIDFengNiao {
|
||||
@@ -76,7 +71,6 @@ func GetOrderRiderInfoToPlatform(orderId string) {
|
||||
riderInfo.CourierName = "石锋"
|
||||
riderInfo.CourierPhone = "18048531223"
|
||||
riderInfo.LogisticsProviderCode = "10017"
|
||||
globals.SugarLogger.Debug("同步外卖骑手位置信息到美团失败,未获取到订单的骑手信息:", "----")
|
||||
}
|
||||
|
||||
riderInfo.ThirdCarrierOrderId = v.VendorWaybillID
|
||||
@@ -102,7 +96,6 @@ func GetOrderRiderInfoToPlatform(orderId string) {
|
||||
if riderInfo.Latitude == "" {
|
||||
riderInfo.Latitude = utils.Float64ToStr(utils.Int2Float64(v.ConsigneeLat) / 1000000)
|
||||
}
|
||||
globals.SugarLogger.Debugf("骑手信息----------------%v", riderInfo)
|
||||
// 目前只推送美团骑手信息
|
||||
switch v.VendorID {
|
||||
case model.VendorIDMTWM: // 美团发单
|
||||
@@ -142,7 +135,6 @@ func UpdateOrder2Complete() {
|
||||
time.Now().AddDate(0, 1, 0),
|
||||
}
|
||||
if num, err := dao.ExecuteSQL(dao.GetDB(), sql, sqlParams); err != nil {
|
||||
globals.SugarLogger.Errorf("Update Order Status 20 To 110 Fail")
|
||||
globals.SugarLogger.Debug("Update Order Status 20 To 110 Time,Count", time.Now(), num)
|
||||
}
|
||||
return
|
||||
|
||||
@@ -5,11 +5,9 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/pay"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
func OnCallback(msg *wxpayapi.CallbackMsg) (err error) {
|
||||
globals.SugarLogger.Debugf("wxpay OnCallback msg:%s", utils.Format4Output(msg, true))
|
||||
switch msg.MsgType {
|
||||
case wxpayapi.MsgTypePay:
|
||||
err = onWxpayFinished(msg.Data.(*wxpayapi.PayResultMsg))
|
||||
|
||||
@@ -223,7 +223,6 @@ func (c *PrinterHandler) GetVendorID() int {
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, id1, id2, msgTitle, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("PrintMsg id1:%s", id1)
|
||||
if id1 != "" {
|
||||
if globals.EnableStoreWrite {
|
||||
_, err = api.FeieAPI.PrintMsg(id1, msgContent, 1)
|
||||
@@ -252,7 +251,6 @@ func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, printerSN, pri
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder, printType string, asfOrder *model.AfsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("feie PrintOrderByOrder orderID:%s, storeID:%d", order.VendorOrderID, store.ID)
|
||||
if len(order.Skus) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -238,8 +238,6 @@ func (c *PrinterHandler) getOrderContentByTemplate(order *model.GoodsOrder, stor
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder, printType string, afs *model.AfsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("jxprint PrintOrderByOrder orderID:%s, storeID:%d", order.VendorOrderID, store.ID)
|
||||
|
||||
if len(order.Skus) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -100,8 +100,6 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel, globals.StoreName)
|
||||
content = fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), escapeString4Printer(orderParams)...)
|
||||
// globals.SugarLogger.Debugf("xiaowm orderParams:%s\n", utils.Format4Output(orderParams, false))
|
||||
// globals.SugarLogger.Debugf("xiaowm getOrderContent:%s\n", content)
|
||||
return content
|
||||
}
|
||||
|
||||
@@ -174,8 +172,6 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
|
||||
// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel, globals.StoreName)
|
||||
content = fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), escapeString4Printer(orderParams)...)
|
||||
// globals.SugarLogger.Debugf("xiaowm orderParams:%s\n", utils.Format4Output(orderParams, false))
|
||||
// globals.SugarLogger.Debugf("xiaowm getOrderContent:%s\n", content)
|
||||
return content
|
||||
}
|
||||
|
||||
@@ -257,7 +253,6 @@ func (c *PrinterHandler) GetVendorID() int {
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, printerNumber, printerToken, msgTitle, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("PrintMsg printerNumber:%s", printerNumber)
|
||||
if printerNumber != "" {
|
||||
if globals.EnableStoreWrite {
|
||||
_, err = api.XiaoWMAPI.SendMsg(printerNumber, printerToken, msgContent)
|
||||
@@ -293,7 +288,6 @@ func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, printerNumber,
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder, printType string, asfOrder *model.AfsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("xiaowm PrintOrderByOrder orderID:%s, storeID:%d", order.VendorOrderID, store.ID)
|
||||
var content string
|
||||
if isV500(store.PrinterSN) {
|
||||
content = c.getOrderContent2(order, store.Tel1)
|
||||
@@ -321,7 +315,6 @@ func isV500(printerNo string) bool {
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, printerNumber, notUsed, printerName string, storeID int64) (newID1, printerToken string, err error) {
|
||||
globals.SugarLogger.Debugf("xiaowm RegisterPrinter printerNumber:%s", printerNumber)
|
||||
if printerNumber == "" { //len(printerNumber) != len("7JizmSyiXNzkggaqU") {
|
||||
err = fmt.Errorf("外卖管家打印机设备编号:%s长度不合法", printerNumber)
|
||||
} else {
|
||||
@@ -336,7 +329,6 @@ func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, printerNumber,
|
||||
}
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debugf("xiaowm RegisterPrinter printerNumber:%s, error:%v", printerNumber, err)
|
||||
return "", printerToken, err
|
||||
}
|
||||
|
||||
|
||||
@@ -395,7 +395,6 @@ func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, machineCode, p
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder, printType string, asfOrder *model.AfsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("yilianyun PrintOrderByOrder orderID:%s, storeID:%d", order.VendorOrderID, store.ID)
|
||||
if len(order.Skus) == 0 {
|
||||
return
|
||||
}
|
||||
@@ -423,7 +422,6 @@ func (c *PrinterHandler) PrintStore(ctx *jxcontext.Context, store *model.Store,
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("yilianyun PrintCancelOrRefundOrder orderID:%s, storeID:%d", order.VendorOrderID, store.ID)
|
||||
if len(order.Skus) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -194,7 +194,6 @@ func (c *PrinterHandler) GetVendorID() int {
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, deviceID, deviceSecret, msgTitle, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("PrintMsg deviceID:%s", deviceID)
|
||||
if deviceID != "" {
|
||||
var status int
|
||||
if globals.EnableStoreWrite {
|
||||
@@ -220,7 +219,6 @@ func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, deviceID, devi
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder, printType string, asfOrder *model.AfsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("zhongwu PrintOrderByOrder orderID:%s, storeID:%d", order.VendorOrderID, store.ID)
|
||||
content := ""
|
||||
if store.PrinterFontSize == partner.PrinterFontSizeBig {
|
||||
content = c.getOrderContentBig(order, store.Tel1, storeDetail)
|
||||
|
||||
@@ -105,7 +105,6 @@ package doudian
|
||||
//
|
||||
//// shop/editStore 编辑门店信息 正向推送平台
|
||||
//func (P *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||
// globals.SugarLogger.Debugf("doudian Update storeID:%d, userName:%s", storeID, userName)
|
||||
// var (
|
||||
// storeInfo *dao.StoreDetail
|
||||
// name string
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package doudian
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
shop_batchCreateStore_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_batchCreateStore/request"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store"
|
||||
@@ -32,6 +33,7 @@ func TestCreateStore(t *testing.T) {
|
||||
StoreList: storeLists,
|
||||
}
|
||||
resp, err := a.BatchCreateStore(param)
|
||||
fmt.Println(resp, err)
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -100,7 +100,6 @@ func act2EbaiActivity(act *model.Act2, actOrderRules []*model.ActOrderRule) (act
|
||||
}
|
||||
|
||||
func createOneShopAct(act *model.Act2, shopID string, oneStoreActSku []*model.ActStoreSku2) (ebaiActIDStr string, err error) {
|
||||
globals.SugarLogger.Debugf("ebai createOneShopAct")
|
||||
activity := act2EbaiActivity(act, nil)
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
ebaiActID, err2 := api.EbaiAPI.ActivityCreate(shopID, 0, 0, activity)
|
||||
@@ -117,7 +116,6 @@ func createOneShopAct(act *model.Act2, shopID string, oneStoreActSku []*model.Ac
|
||||
}
|
||||
|
||||
func ActivitySkuAddBatch(activityID int64, shopID string, baiduShopID int64, activityType int, skuList []*ebaiapi.ActivitySkuInfo4Add, isSkuIDCustom bool) (successIDs []string, err error) {
|
||||
globals.SugarLogger.Debugf("ebai ActivitySkuAddBatch")
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
successIDs, err = api.EbaiAPI.ActivitySkuAddBatch(activityID, shopID, baiduShopID, activityType, skuList, isSkuIDCustom)
|
||||
} else {
|
||||
@@ -129,7 +127,6 @@ func ActivitySkuAddBatch(activityID int64, shopID string, baiduShopID int64, act
|
||||
}
|
||||
|
||||
func ActivitySkuDeleteBatch(activityID int64, shopID string, baiduShopID int64, skuIDs []string, isSkuIDCustom bool) (successIDs []string, err error) {
|
||||
globals.SugarLogger.Debugf("ebai ActivitySkuDeleteBatch")
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
successIDs, err = api.EbaiAPI.ActivitySkuDeleteBatch(activityID, shopID, baiduShopID, skuIDs, isSkuIDCustom)
|
||||
} else {
|
||||
@@ -139,7 +136,6 @@ func ActivitySkuDeleteBatch(activityID int64, shopID string, baiduShopID int64,
|
||||
}
|
||||
|
||||
func ActivitySkuUpdateBatch(activityID int64, actSkuInfoList []*ebaiapi.ActivitySkuInfo4Update) (faildInfoList []string, err error) {
|
||||
globals.SugarLogger.Debugf("ebai ActivitySkuUpdateBatch")
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
faildInfoList, err = api.EbaiAPI.ActivitySkuUpdateBatch(activityID, actSkuInfoList)
|
||||
}
|
||||
@@ -147,7 +143,6 @@ func ActivitySkuUpdateBatch(activityID int64, actSkuInfoList []*ebaiapi.Activity
|
||||
}
|
||||
|
||||
func ActivityDisable(activityID int64, shopID string, baiduShopID, supplierID int64) (err error) {
|
||||
globals.SugarLogger.Debugf("ebai ActivityDisable")
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.ActivityDisable(activityID, shopID, baiduShopID, supplierID)
|
||||
}
|
||||
@@ -163,7 +158,6 @@ func getActStoreSkuFromTaskResult(taskReslt []interface{}) (list []*model.ActSto
|
||||
}
|
||||
|
||||
func createSkuAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.Act2, actStoreSku []*model.ActStoreSku2) (createdList []*model.ActStoreSku2, err error) {
|
||||
globals.SugarLogger.Debugf("ebai createSkuAct")
|
||||
actStoreSkuListList := partner.SplitActStoreSku2List(actStoreSku)
|
||||
task := tasksch.NewParallelTask("ebai createSkuAct", nil, ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
@@ -183,7 +177,6 @@ func createSkuAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.A
|
||||
}
|
||||
|
||||
func cancelSkuAct(ctx *jxcontext.Context, parentTask tasksch.ITask, actStoreSkuMap map[string][]*model.ActStoreSku2) (canceledList []*model.ActStoreSku2, err error) {
|
||||
globals.SugarLogger.Debugf("ebai cancelSkuAct")
|
||||
var vendorActIDs []string
|
||||
for k := range actStoreSkuMap {
|
||||
vendorActIDs = append(vendorActIDs, k)
|
||||
@@ -206,7 +199,6 @@ func cancelSkuAct(ctx *jxcontext.Context, parentTask tasksch.ITask, actStoreSkuM
|
||||
}
|
||||
|
||||
func deleteSkuActSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, actStoreSkuMap, vendorActInfoMap map[string][]*model.ActStoreSku2) (deletedList []*model.ActStoreSku2, err error) {
|
||||
globals.SugarLogger.Debugf("ebai deleteSkuActSkus")
|
||||
var vendorActIDs []string
|
||||
for k := range actStoreSkuMap {
|
||||
if k != "" {
|
||||
@@ -240,7 +232,6 @@ func deleteSkuActSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, actStore
|
||||
}
|
||||
|
||||
func addSkuActSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.Act2, actStoreSku []*model.ActStoreSku2, vendorActIDMap map[int]string) (addedList []*model.ActStoreSku2, err error) {
|
||||
globals.SugarLogger.Debugf("ebai addSkuActSkus, actID:%d", act.ID)
|
||||
actStoreSkuListList := partner.SplitActStoreSku2List(actStoreSku)
|
||||
if len(actStoreSkuListList) > 0 {
|
||||
task := tasksch.NewParallelTask("ebai addSkuActSkus", nil, ctx,
|
||||
@@ -271,7 +262,6 @@ func addSkuActSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.Act2, actOrderRules []*model.ActOrderRule, actStoreSkuList []*model.ActStoreSku2) (err error) {
|
||||
globals.SugarLogger.Debugf("ebai SyncAct, actID:%d", act.ID)
|
||||
vendorActInfoMap := make(map[string][]*model.ActStoreSku2)
|
||||
deleteActInfoMap := make(map[string][]*model.ActStoreSku2)
|
||||
vendorActIDMap := make(map[int]string)
|
||||
@@ -310,7 +300,6 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
|
||||
updateItems = append(updateItems, partner.Act2Update(ctx, act, model.SyncFlagNewMask))
|
||||
}
|
||||
} else if model.IsSyncStatusUpdate(act.SyncStatus) {
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(updateItems, false))
|
||||
if len(actStoreSkuList4Create) > 0 {
|
||||
addedList, err2 := addSkuActSkus(ctx, nil, act, actStoreSkuList4Create, vendorActIDMap)
|
||||
updateItems = append(updateItems, partner.ActStoreSku2Update(ctx, addedList, model.SyncFlagNewMask)...)
|
||||
|
||||
@@ -8,21 +8,15 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func OnCallbackMsg(msg *ebaiapi.CallbackMsg) (response *ebaiapi.CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("ebai OnCallbackMsg msg:%s", utils.Format4Output(msg, true))
|
||||
if CurPurchaseHandler != nil {
|
||||
globals.SugarLogger.Debugf("ebai OnCallbackMsg msg 1")
|
||||
if orderID := GetOrderIDFromMsg(msg); orderID != "" {
|
||||
globals.SugarLogger.Debugf("ebai OnCallbackMsg msg 2 ,%d", orderID)
|
||||
jxutils.CallMsgHandler(func() {
|
||||
globals.SugarLogger.Debugf("ebai OnCallbackMsg msg 2.5 ,%s", msg.Cmd)
|
||||
switch msg.Cmd {
|
||||
case ebaiapi.CmdOrderCreate, ebaiapi.CmdOrderStatus, ebaiapi.CmdOrderUserCancel, ebaiapi.CmdOrderPartRefund:
|
||||
globals.SugarLogger.Debugf("ebai OnCallbackMsg msg 3 ,%s", msg.Cmd)
|
||||
response = CurPurchaseHandler.onOrderMsg(msg)
|
||||
case ebaiapi.CmdOrderDeliveryStatus:
|
||||
response = CurPurchaseHandler.onWaybillMsg(msg)
|
||||
|
||||
@@ -69,7 +69,6 @@ func (p *PurchaseHandler) GetVendorID() int {
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, vendorOrgCode, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
|
||||
globals.SugarLogger.Debugf("ebai UploadImg imgURL:%s, imgName:%s, imgType:%d", imgURL, imgName, imgType)
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if imgType == model.ImgTypeMain {
|
||||
imgHint, err = api.EbaiAPI.PictureUpload(imgURL, imgData)
|
||||
|
||||
@@ -38,7 +38,6 @@ func (p *PurchaseHandler) onFinancialMsg(msg *ebaiapi.CallbackMsg) (response *eb
|
||||
// 获得退款订单ID,去本地数据库拿?饿百消息推送只给了订单号,但是没有查询全额退款的接口,只有部分退款才可以查询
|
||||
orderFinancial, err := partner.CurOrderManager.LoadOrderFinancial(afsOrderID, model.VendorIDEBAI)
|
||||
if err == nil {
|
||||
globals.SugarLogger.Debug(utils.Format4Output(orderFinancial, false))
|
||||
err = partner.CurOrderManager.SaveAfsOrderFinancialInfo(CurPurchaseHandler.OrderFinancialDetail2Refund(orderFinancial, msg))
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("ebai OnFinancialMsg, afsOrderID:%s is not found from partner.CurOrderManager.LoadOrderFinancial", afsOrderID)
|
||||
@@ -71,11 +70,9 @@ func (p *PurchaseHandler) OrderFinancialDetail2Refund(orderFinancial *model.Orde
|
||||
// if msg.Body["timestamp"] != nil {
|
||||
// afsOrder.AfsCreateAt = utils.Timestamp2Time(utils.Str2Int64(utils.Interface2String(msg.Body["timestamp"])))
|
||||
// } else {
|
||||
// globals.SugarLogger.Warnf("ebai OrderFinancialDetail2Refund timestamp is not found in afsOrder:%s", afsOrder.AfsOrderID)
|
||||
// afsOrder.AfsCreateAt = time.Now()
|
||||
// }
|
||||
order, err := partner.CurOrderManager.LoadOrder(afsOrder.VendorOrderID, afsOrder.VendorID)
|
||||
globals.SugarLogger.Debug(utils.Format4Output(order, false))
|
||||
if err == nil {
|
||||
afsOrder.JxStoreID = order.JxStoreID
|
||||
afsOrder.VendorStoreID = order.VendorStoreID
|
||||
@@ -132,7 +129,6 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData map[string]interfac
|
||||
afsOrder.PmRefundMoney = orderFinancial.PmMoney - utils.MustInterface2Int64(orderData["commission"])
|
||||
} else {
|
||||
// 此处应该报错
|
||||
// globals.SugarLogger.Warnf("ebai AfsOrderDetail2Financial, afsOrderID:%s is not found from partner.CurOrderManager.LoadOrderFinancial", afsOrder.VendorOrderID)
|
||||
err = nil
|
||||
}
|
||||
if orderData["refund_detail"] != nil {
|
||||
|
||||
@@ -340,7 +340,6 @@ func getSkuSalePrice2(product *ebaiapi.OrderProductInfo) (salePrice, baiduRate i
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("ebai AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt)
|
||||
if isAcceptIt {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.OrderConfirm(order.VendorOrderID)
|
||||
@@ -364,7 +363,6 @@ func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("ebai PickupGoods orderID:%s, isSelfDelivery:%t", order.VendorOrderID, isSelfDelivery)
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
// err = api.EbaiAPI.OrderPickComplete(order.VendorOrderID)
|
||||
}
|
||||
@@ -388,7 +386,6 @@ func (p *PurchaseHandler) ConfirmReceiveGoods(ctx *jxcontext.Context, order *mod
|
||||
|
||||
// 将订单从购物平台配送转为自送
|
||||
func (p *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("ebai Swtich2SelfDeliver orderID:%s", order.VendorOrderID)
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if err = api.EbaiAPI.OrderSwitchselfdelivery(order.VendorOrderID); err != nil {
|
||||
if utils.IsErrMatch(err, "301251", nil) {
|
||||
@@ -422,7 +419,6 @@ func (p *PurchaseHandler) trySyncCancelStatus(vendorOrderID string) (err error)
|
||||
|
||||
// 将订单从购物平台配送转为自送后又送达
|
||||
func (p *PurchaseHandler) Swtich2SelfDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("ebai Swtich2SelfDelivered orderID:%s", order.VendorOrderID)
|
||||
// todo 饿百转商家自送后,没有确认送达的概念,空操作
|
||||
if globals.EnableEbaiStoreWrite && order.WaybillVendorID > 100 {
|
||||
err = api.EbaiAPI.OrderComplete(order.VendorOrderID, userName)
|
||||
@@ -432,7 +428,6 @@ func (p *PurchaseHandler) Swtich2SelfDelivered(order *model.GoodsOrder, userName
|
||||
|
||||
// 完全自送的门店表示开始配送
|
||||
func (p *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("ebai SelfDeliverDelivering orderID:%s", order.VendorOrderID)
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.OrderselfDeliveryStateSync(order.VendorOrderID, userName)
|
||||
}
|
||||
@@ -445,7 +440,6 @@ func (p *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userNam
|
||||
|
||||
// 完全自送的门店表示配送完成
|
||||
func (p *PurchaseHandler) SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("ebai SelfDeliverDelivered orderID:%s", order.VendorOrderID)
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.OrderComplete(order.VendorOrderID, userName)
|
||||
}
|
||||
@@ -457,10 +451,8 @@ func (c *PurchaseHandler) onOrderMsg(msg *ebaiapi.CallbackMsg) (retVal *ebaiapi.
|
||||
if c.isAfsMsg(msg) {
|
||||
retVal = c.onAfsOrderMsg(msg)
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("ebai OnCallbackMsg msg 4 ,%v", utils.Format4Output(msg, true))
|
||||
status := c.callbackMsg2Status(msg)
|
||||
if partner.CurOrderManager.GetStatusDuplicatedCount(status) > 0 {
|
||||
globals.SugarLogger.Debugf("ebai OnCallbackMsg msg 5 %d", partner.CurOrderManager.GetStatusDuplicatedCount(status))
|
||||
return nil
|
||||
}
|
||||
if ebaiapi.CmdOrderCreate == msg.Cmd {
|
||||
|
||||
@@ -35,7 +35,6 @@ func (c *PurchaseHandler) refreshCommentOnce() {
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error) {
|
||||
globals.SugarLogger.Debugf("RefreshComment fromTime:%s, toTime:%s", utils.Time2Str(fromTime), utils.Time2Str(toTime))
|
||||
var orderCommentList []*model.OrderComment
|
||||
//stepGap := 24 * time.Hour
|
||||
//stepFromTime := fromTime
|
||||
@@ -110,7 +109,6 @@ func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error)
|
||||
// orderComment.StoreID = jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// orderComment.ConsigneeMobile = order.ConsigneeMobile
|
||||
// } else {
|
||||
// globals.SugarLogger.Infof("RefreshComment, load orderID:%s failed", orderComment.VendorOrderID)
|
||||
// }
|
||||
// orderCommentList = append(orderCommentList, orderComment)
|
||||
// }
|
||||
|
||||
@@ -178,7 +178,6 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
||||
}
|
||||
result, err := api.EbaiAPI.ShopGet("", baiduShopID)
|
||||
if err == nil {
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
retVal := &dao.StoreDetail{
|
||||
Store: model.Store{
|
||||
Address: utils.Interface2String(result["address"]),
|
||||
@@ -242,8 +241,6 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("ebai UpdateStore storeID:%d, userName:%s", storeID, userName)
|
||||
|
||||
var stores []*tEbaiStoreInfo
|
||||
sql := `
|
||||
SELECT
|
||||
@@ -264,7 +261,6 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
shopID = store.ID
|
||||
}
|
||||
store2, err2 := p.ReadStore(jxcontext.AdminCtx, store.VendorOrgCode, store.VendorStoreID, "")
|
||||
// globals.SugarLogger.Debugf("ebai UpdateStore2 store2:%s, err2:%v", utils.Format4Output(store2, true), err2)
|
||||
if err = err2; err == nil {
|
||||
if store2.ID == store.ID {
|
||||
shopID = -1
|
||||
@@ -313,7 +309,6 @@ func isStoreStatusSame(status1, status2 int) bool {
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debugf("ebai RefreshAllStoresID")
|
||||
const batchSize = 50
|
||||
const stepCount = 3
|
||||
var stores []*tEbaiStoreInfo
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
@@ -42,10 +41,8 @@ func (p *PurchaseHandler) GetWaybillStatusFromVendorStatus(vendorStatus string)
|
||||
|
||||
func (c *PurchaseHandler) onWaybillMsg(msg *ebaiapi.CallbackMsg) (retVal *ebaiapi.CallbackResponse) {
|
||||
order := c.callbackMsg2Waybill(msg)
|
||||
globals.SugarLogger.Debugf("ebai onWaybillMsg orderID:%s", order.VendorOrderID)
|
||||
if order.Status == model.WaybillStatusNew || order.Status == model.WaybillStatusAccepted { // 饿百新运单事件要查询快递员信息,因为可能事件错序
|
||||
if result, err := api.EbaiAPI.OrderDeliveryGet(order.VendorOrderID); err != nil {
|
||||
globals.SugarLogger.Warnf("ebai onWaybillMsg orderID:%s OrderDeliveryGet failed with error:%v", order.VendorOrderID, err)
|
||||
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, order.VendorOrderID)
|
||||
} else {
|
||||
order.CourierName = utils.Interface2String(result["name"])
|
||||
|
||||
@@ -93,7 +93,6 @@ func (c *PurchaseHandler) onOrderStatusMsg(msg *elmapi.CallbackOrderStatusMsg) (
|
||||
case elmapi.MsgTypeOrderFinished:
|
||||
status.Status = model.OrderStatusFinished
|
||||
default:
|
||||
globals.SugarLogger.Warnf("onOrderStatusMsg elm msg:%v not handled", msg)
|
||||
return elmapi.SuccessResponse
|
||||
}
|
||||
err := partner.CurOrderManager.OnOrderStatusChanged("", status)
|
||||
@@ -140,7 +139,6 @@ func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
consigneeMobile = utils.Interface2String(phoneList[0])
|
||||
}
|
||||
|
||||
// globals.SugarLogger.Debug(result)
|
||||
order = &model.GoodsOrder{
|
||||
VendorOrderID: orderID,
|
||||
VendorID: model.VendorIDELM,
|
||||
@@ -252,7 +250,6 @@ func (c *PurchaseHandler) getStatusFromVendorStatus(vendorStatus string) int {
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("elm AcceptOrRefuseOrder orderID:%s", order.VendorOrderID)
|
||||
// if globals.EnableElmStoreWrite {
|
||||
// if isAcceptIt {
|
||||
// err = api.ElmAPI.ConfirmOrder(order.VendorOrderID)
|
||||
|
||||
@@ -17,7 +17,6 @@ const (
|
||||
func (c *PurchaseHandler) ClientUrgeOrder(orderID string) (err error) {
|
||||
utils.CallFuncAsync(func() {
|
||||
var err error
|
||||
globals.SugarLogger.Debugf("ClientUrgeOrder orderID:%s", orderID)
|
||||
order, err2 := partner.CurOrderManager.LoadOrder(orderID, model.VendorIDELM)
|
||||
if err = err2; err == nil {
|
||||
templateCode := ""
|
||||
|
||||
@@ -254,7 +254,6 @@ func cancelSkuAct(ctx *jxcontext.Context, act *model.Act2, vendorActID string) (
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.Act2, actOrderRules []*model.ActOrderRule, actStoreSkuList []*model.ActStoreSku2) (err error) {
|
||||
globals.SugarLogger.Debugf("jd SyncAct, actID:%d", act.ID)
|
||||
vendorActInfoMap := make(map[string][]*model.ActStoreSku2)
|
||||
deleteActInfoMap := make(map[string][]*model.ActStoreSku2)
|
||||
var actStoreSkuList4Create []*model.ActStoreSku2
|
||||
@@ -340,7 +339,6 @@ func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITa
|
||||
}
|
||||
return err
|
||||
}()
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(updateItems, false))
|
||||
_, err2 := dao.BatchUpdateActEntity(db, model.IsSyncStatusDelete(act.SyncStatus), updateItems)
|
||||
if err == nil {
|
||||
err = err2
|
||||
|
||||
@@ -154,7 +154,6 @@ func (p *PurchaseHandler) OrderDetail2Financial(a *jdapi.API, orderData map[stri
|
||||
}
|
||||
}
|
||||
}
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(orderFinancial.Discounts, false))
|
||||
}
|
||||
order1, err2 := a.OrderShoudSettlementService(orderFinancial.VendorOrderID)
|
||||
if err = err2; err == nil {
|
||||
|
||||
@@ -24,7 +24,6 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
globals.SugarLogger.Debug("init jd")
|
||||
CurPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(CurPurchaseHandler)
|
||||
}
|
||||
@@ -44,7 +43,6 @@ func GetAPIbyKey(appKey string) (apiObj *jdapi.API) {
|
||||
if code, err := dao.GetVendorOrgCodeByKey(dao.GetDB(), model.VendorIDJD, appKey); err == nil && code != nil {
|
||||
return jdapi.New(code.Token, code.AppKey, code.AppSecret)
|
||||
}
|
||||
globals.SugarLogger.Warnf("GetAPIbyKey appKey:%s get empty vendorOrgCode", appKey)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,10 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"time"
|
||||
)
|
||||
|
||||
func MemberCreateMsg(msg *jdapi.CallbackMemberMsg) (retVal *jdapi.CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("MemberCreateMsg msg :%v", utils.Format4Output(msg, true))
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
@@ -35,6 +33,5 @@ func MemberCreateMsg(msg *jdapi.CallbackMemberMsg) (retVal *jdapi.CallbackRespon
|
||||
}
|
||||
|
||||
func MemberRenewMsg(msg *jdapi.CallbackMemberMsg) (retVal *jdapi.CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("MemberRenewMsg msg :%v", utils.Format4Output(msg, true))
|
||||
return jdapi.SuccessResponse
|
||||
}
|
||||
|
||||
@@ -84,7 +84,6 @@ func (c *PurchaseHandler) updateOrderFinancialInfo(a *jdapi.API, orderID string)
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) onOrderMsg(a *jdapi.API, msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("jd deliverOrder 4.5 %v", utils.Format4Output(msg, true))
|
||||
// a := getAPI(vendorOrgCode)
|
||||
if afsMsgMap[msg.MsgURL] {
|
||||
retVal = c.OnAfsOrderMsg(a, msg)
|
||||
@@ -121,7 +120,6 @@ func (c *PurchaseHandler) onOrderMsg(a *jdapi.API, msg *jdapi.CallbackOrderMsg)
|
||||
// globals.SugarLogger.Warnf("京东取消拣货:%v", err2)
|
||||
// }
|
||||
// }
|
||||
globals.SugarLogger.Debug("OnOrderStatusChanged jd %v", utils.Format4Output(status, true))
|
||||
err := partner.CurOrderManager.OnOrderStatusChanged(AppKey2OrgCode(msg.AppKey), status)
|
||||
retVal = jdapi.Err2CallbackResponse(err, status.VendorStatus)
|
||||
}
|
||||
@@ -141,7 +139,6 @@ func (c *PurchaseHandler) onOrderInfoChangeMsg(vendorOrgCode string, msg *jdapi.
|
||||
db := dao.GetDB()
|
||||
order, err := dao.GetSimpleOrder(db, msg.BillID)
|
||||
if err == nil {
|
||||
globals.SugarLogger.Debugf("onOrderInfoChangeMsg msg:%v", utils.Format4Output(msg, false))
|
||||
//任意一项变了
|
||||
if order.AdjustCount < 3 {
|
||||
if msg.BuyerFullAddress != order.ConsigneeAddress || msg.BuyerFullName != order.ConsigneeName || msg.BuyerMobile != order.ConsigneeMobile ||
|
||||
@@ -196,7 +193,6 @@ func updateOrderBySettleMent(order *model.GoodsOrder, orderSettlement *jdapi.Ord
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) getOrder(a *jdapi.API, orderID string) (order *model.GoodsOrder, orderMap map[string]interface{}, err error) {
|
||||
globals.SugarLogger.Debugf("jd getOrder orderID:%s", orderID)
|
||||
var (
|
||||
realMobile string
|
||||
orderSettlement *jdapi.OrderSettlementInfo
|
||||
@@ -257,7 +253,6 @@ func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
func Map2Order(orderData map[string]interface{}) (order *model.GoodsOrder) {
|
||||
result := orderData
|
||||
orderID := utils.Int64ToStr(utils.MustInterface2Int64(result["orderId"]))
|
||||
globals.SugarLogger.Debugf("jd Map2Order orderID:%s", orderID)
|
||||
|
||||
const defaultStatusTimeField = "orderPurchaseTime"
|
||||
statusTimeField := defaultStatusTimeField
|
||||
@@ -360,10 +355,8 @@ func Map2Order(orderData map[string]interface{}) (order *model.GoodsOrder) {
|
||||
|
||||
//
|
||||
func (c *PurchaseHandler) onOrderNew(a *jdapi.API, msg *jdapi.CallbackOrderMsg, orderStatus *model.OrderStatus) (response *jdapi.CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("onOrderNew orderID:%s", msg.BillID)
|
||||
order, orderMap, err := c.getOrder(a, msg.BillID)
|
||||
if err == nil {
|
||||
globals.SugarLogger.Debugf("onOrderNew2 orderID:%s", msg.BillID)
|
||||
if err = partner.CurOrderManager.OnOrderNew(order, orderStatus); err == nil {
|
||||
utils.CallFuncAsync(func() {
|
||||
c.OnOrderDetail(a, orderMap, partner.CreatedPeration)
|
||||
@@ -428,7 +421,6 @@ func getStatusFromVendorStatus(vendorStatus string) int {
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("jd AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt)
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = getAPI(order.VendorOrgCode).OrderAcceptOperate(order.VendorOrderID, isAcceptIt, userName)
|
||||
if isAcceptIt && err == nil {
|
||||
@@ -446,7 +438,6 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("jd PickupGoods orderID:%s, isSelfDelivery:%t", order.VendorOrderID, isSelfDelivery)
|
||||
if !isSelfDelivery && globals.EnableJdStoreWrite {
|
||||
_, err = getAPI(order.VendorOrgCode).OrderJDZBDelivery(order.VendorOrderID, userName)
|
||||
} else {
|
||||
@@ -461,7 +452,6 @@ func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bo
|
||||
if err == nil {
|
||||
orderSettlement, _ := getAPI(order.VendorOrgCode).OrderShoudSettlementService2(order.VendorOrderID)
|
||||
updateOrderBySettleMent(order, orderSettlement)
|
||||
globals.SugarLogger.Debugf("jd PickupGoods, %v", order.NewEarningPrice)
|
||||
err = partner.CurOrderManager.UpdateOrderFields(order, []string{"NewEarningPrice"})
|
||||
}
|
||||
return err
|
||||
@@ -489,7 +479,6 @@ func (p *PurchaseHandler) ConfirmReceiveGoods(ctx *jxcontext.Context, order *mod
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("jd Swtich2SelfDeliver orderID:%s", order.VendorOrderID)
|
||||
if globals.EnableJdStoreWrite {
|
||||
if order.VendorOrgCode == jdapi.ModifySellerDeliveryNo { // 自配送门店不需要达达配送转自送
|
||||
return err
|
||||
@@ -497,7 +486,6 @@ func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName s
|
||||
_, err = getAPI(order.VendorOrgCode).ModifySellerDelivery(order.VendorOrderID, userName)
|
||||
if err != nil {
|
||||
if errWithCode, ok := err.(*utils.ErrorWithCode); ok && errWithCode.Level() == 1 {
|
||||
globals.SugarLogger.Infof("Swtich2SelfDeliver failed with error:%v try get current status", err)
|
||||
if order2, err2 := c.GetOrder(order.VendorOrgCode, order.VendorOrderID, ""); err2 == nil {
|
||||
var mapData map[string]interface{}
|
||||
if err2 = utils.UnmarshalUseNumber([]byte(order2.OriginalData), &mapData); err2 == nil {
|
||||
@@ -513,7 +501,6 @@ func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName s
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) Swtich2SelfDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("jd Swtich2SelfDelivered orderID:%s", order.VendorOrderID)
|
||||
if globals.EnableJdStoreWrite {
|
||||
_, err = getAPI(order.VendorOrgCode).DeliveryEndOrder(order.VendorOrderID, userName)
|
||||
}
|
||||
@@ -521,7 +508,6 @@ func (c *PurchaseHandler) Swtich2SelfDelivered(order *model.GoodsOrder, userName
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("jd SelfDeliverDelivering orderID:%s", order.VendorOrderID)
|
||||
if globals.EnableJdStoreWrite {
|
||||
_, err = getAPI(order.VendorOrgCode).OrderSerllerDelivery(order.VendorOrderID, userName)
|
||||
}
|
||||
@@ -530,7 +516,6 @@ func (c *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userNam
|
||||
|
||||
// 京东送达接口都是一样的
|
||||
func (c *PurchaseHandler) SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
globals.SugarLogger.Debugf("jd SelfDeliverDelivered orderID:%s", order.VendorOrderID)
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = c.Swtich2SelfDelivered(order, userName)
|
||||
}
|
||||
@@ -597,7 +582,6 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, vendorOrgCode strin
|
||||
if vendorStoreID != "" {
|
||||
queryParam.DeliveryStationNo = vendorStoreID
|
||||
}
|
||||
globals.SugarLogger.Debugf("jd ListOrders queryParam", utils.Format4Output(queryParam, true))
|
||||
orderList, _, err := getAPI(vendorOrgCode).OrderQuery2(queryParam)
|
||||
if err == nil {
|
||||
vendorOrderIDs = make([]string, len(orderList))
|
||||
|
||||
@@ -117,7 +117,6 @@ func (c *PurchaseHandler) convertAfsAppealType(vendorAppealType string) int8 {
|
||||
if status, ok := afsAppealTypeMap[vendorAppealType]; ok {
|
||||
return status
|
||||
}
|
||||
globals.SugarLogger.Warnf("jd convertAfsAppealType unknown vendorAppealType:%d", vendorAppealType)
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ func (c *PurchaseHandler) onOrderComment2(a *jdapi.API, msg *jdapi.CallbackOrder
|
||||
intOrderID := utils.Str2Int64(msg.BillID)
|
||||
result, err := a.GetCommentByOrderId2(intOrderID)
|
||||
if err == nil {
|
||||
globals.SugarLogger.Debugf("onOrderComment comment:%s", utils.Format4Output(result, true))
|
||||
orderCommend := &model.OrderComment{
|
||||
VendorOrderID: utils.Int64ToStr(result.OrderID),
|
||||
VendorID: model.VendorIDJD,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user