Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop

This commit is contained in:
richboo111
2023-03-23 10:49:45 +08:00
17 changed files with 139 additions and 100 deletions

View File

@@ -278,6 +278,7 @@ func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID s
}
if storeDetail.IsPrintRefundOrder == model.YES { // 打印退款订单
order2, _ := partner.CurOrderManager.LoadOrder(afsOrder.VendorOrderID, afsOrder.VendorID)
order2.Status = model.AfsOrderStatusFinished
_, err = netprinter.PrintRefundOrCancelOrder(jxcontext.AdminCtx, model.NO, order2, afsOrder.StoreID)
}
}

View File

@@ -384,6 +384,7 @@ func (s *DefScheduler) OnOrderNew(order *model.GoodsOrder, isPending bool, isAut
if order.Flag&model.OrderFlagMaskFake == 0 {
utils.CallFuncAsync(func() {
// order = setFakeActualPayPrice(order)
globals.SugarLogger.Debugf("ebai============:%s", utils.Format4Output(order, false))
netprinter.PrintOrderByOrder(jxcontext.AdminCtx, order, model.PrintTypeOrder, nil)
//目前暂且认为AdjustCount > 0 就是调整单
if order.AdjustCount > 0 {
@@ -492,10 +493,10 @@ func (s *DefScheduler) OnOrderStatusChanged(order *model.GoodsOrder, status *mod
}
// 京西云打印机打印数据-如果门店使用京西打印机才使用如下代码块
store, _ := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode)
if err == nil && store.PrinterVendorID == model.VendorIDJxprint {
netprinter.PrintOrderByOrder(jxcontext.AdminCtx, order, model.PrintTypeOrder, nil)
}
//store, _ := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode)
//if err == nil && store.PrinterVendorID == model.VendorIDJxprint {
// netprinter.PrintOrderByOrder(jxcontext.AdminCtx, order, model.PrintTypeOrder, nil)
//}
}
}
return err

View File

@@ -1175,7 +1175,15 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
if skuNameExt.JdCategoryID != "" {
updateOrCreate(model.VendorIDJD, nameID, skuNameExt.JdCategoryID)
flag = true
}
} /*else {
handler, _ := partner.GetPurchasePlatformFromVendorID(model.VendorIDJD).(partner.IPurchasePlatformStoreSkuHandler)
vendorCategoryId, _ := handler.GetSkuCategoryIdByName(beego.AppConfig.DefaultString("jdOrgCode", "320406"), skuNameExt.Name)
if vendorCategoryId != "" {
updateOrCreate(model.VendorIDJD, nameID, skuNameExt.JdCategoryID)
flag = true
}
}*/
if skuNameExt.JdsCategoryID != "" {
updateOrCreate(model.VendorIDJDShop, nameID, skuNameExt.JdsCategoryID)
flag = true
@@ -1187,16 +1195,33 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
if skuNameExt.MtwmCategoryID != "" {
updateOrCreate(model.VendorIDMTWM, nameID, skuNameExt.MtwmCategoryID)
flag = true
} else {
}
if skuNameExt.DdCategoryID != "" {
updateOrCreate(model.VendorIDDD, nameID, skuNameExt.DdCategoryID)
flag = true
}
} /*else {
handler, _ := partner.GetPurchasePlatformFromVendorID(model.VendorIDDD).(partner.IPurchasePlatformStoreSkuHandler)
imgs := fmt.Sprintf("%s|%s|%s|%s|%s|%s", skuNameExt.DescImg, skuNameExt.Img, skuNameExt.Img2, skuNameExt.Img3, skuNameExt.Img4, skuNameExt.Img5)
vendorCategoryId, _ := handler.GetSkuCategoryIdByName("57939570", imgs)
if vendorCategoryId != "" {
updateOrCreate(model.VendorIDDD, nameID, skuNameExt.JdCategoryID)
flag = true
}
}*/
} else {
if payload["jdCategoryID"] != nil {
updateOrCreate(model.VendorIDJD, nameID, payload["jdCategoryID"].(string))
flag = true
}
} /*else {
handler, _ := partner.GetPurchasePlatformFromVendorID(model.VendorIDJD).(partner.IPurchasePlatformStoreSkuHandler)
vendorCategoryId, _ := handler.GetSkuCategoryIdByName(beego.AppConfig.DefaultString("jdOrgCode", "320406"), skuNameExt.Name)
if vendorCategoryId != "" {
updateOrCreate(model.VendorIDJD, nameID, skuNameExt.JdCategoryID)
flag = true
}
}*/
if payload["jdsCategoryID"] != nil {
updateOrCreate(model.VendorIDJDShop, nameID, payload["jdsCategoryID"].(string))
flag = true
@@ -1212,7 +1237,15 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
if payload["ddCategoryID"] != nil {
updateOrCreate(model.VendorIDDD, nameID, payload["ddCategoryID"].(string))
flag = true
}
} /*else {
handler, _ := partner.GetPurchasePlatformFromVendorID(model.VendorIDDD).(partner.IPurchasePlatformStoreSkuHandler)
imgs := fmt.Sprintf("%s,%s,%s,%s,%s,%s", skuNameExt.DescImg, skuNameExt.Img, skuNameExt.Img2, skuNameExt.Img3, skuNameExt.Img4, skuNameExt.Img5)
vendorCategoryId, _ := handler.GetSkuCategoryIdByName("57939570", imgs)
if vendorCategoryId != "" {
updateOrCreate(model.VendorIDDD, nameID, skuNameExt.JdCategoryID)
flag = true
}
}*/
}
}
return flag

View File

@@ -15,6 +15,12 @@ import (
"git.rosy.net.cn/jx-callback/globals/api"
)
const (
SoundsFileNewOrder = "newOrder.caf"
SoundsFileNewAfsOrder = "afsOrder.caf"
SoundsFileNewCancelOrder = "cancelOrder.caf"
)
// NotifyNewOrder 推送新订单
func NotifyNewOrder(order *model.GoodsOrder) {
storeId := order.StoreID
@@ -38,9 +44,10 @@ func NotifyNewOrder(order *model.GoodsOrder) {
msg.VendorName = model.VendorChineseNames[order.VendorID]
msg.OrderSqs = utils.Int2Str(order.OrderSeq)
msg.StoreTitle = storeDetail.Name
msg.Context = "老板,你有新的订单了"
msg.Context = "老板,你有新的订单了!"
context, _ := json.Marshal(msg)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[order.VendorID]+"#"+msg.OrderSqs)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewOrder)
}
func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
@@ -63,11 +70,12 @@ func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
msg.MsgType = "newAfsOrder"
msg.VendorName = model.VendorChineseNames[afsOrder.VendorID]
msg.OrderSqs = "0"
msg.OrderSqs = afsOrder.VendorOrderID
msg.StoreTitle = storeDetail.Name
msg.Context = "老板订单申请退款了"
msg.Context = "老板订单申请退款了!"
context, _ := json.Marshal(msg)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[afsOrder.VendorID]+"#"+msg.OrderSqs)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewAfsOrder)
return err
}
@@ -91,11 +99,12 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
msg.MsgType = "newCancelOrder"
msg.VendorName = model.VendorChineseNames[order.VendorID]
msg.OrderSqs = "0"
msg.OrderSqs = utils.Int2Str(order.OrderSeq)
msg.StoreTitle = storeDetail.Name
msg.Context = "老板订单被取消了"
msg.Context = "老板订单被取消了!"
context, _ := json.Marshal(msg)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[order.VendorID]+"#"+msg.OrderSqs)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewCancelOrder)
return err
}
@@ -134,7 +143,7 @@ type MsgContext struct {
OrderSqs string `json:"order_sqs"` // 订单流水号
}
func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string) {
func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, body string, soundsFileName string) {
var errs []error
for _, v := range cID {
param := map[string]interface{}{
@@ -160,10 +169,10 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string) {
"aps": map[string]interface{}{
"alert": map[string]interface{}{
"title": storeName,
"body": msg,
"body": body,
},
"content-available": 0,
"sound": "ring.mp3",
"sound": soundsFileName,
},
"auto_badge": "+1",
},

View File

@@ -166,6 +166,8 @@ type IPurchasePlatformStoreSkuHandler interface {
CreateStoreSkusAct(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (failedList []*StoreSkuInfoWithErr, err error)
CancelActs(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (failedList []*StoreSkuInfoWithErr, err error)
UpdateStoreSkusSpecTag(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (err error)
// GetSkuCategoryIdByName 获取各个平台推荐分类
GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error)
}
type ISingleStoreStoreSkuHandler interface {

View File

@@ -7,7 +7,31 @@ import (
)
func TestPrintMsg(t *testing.T) {
status, err := CurPrinterHandler.PrintMsg(jxcontext.AdminCtx, "20220818000001", "1", "test", "11")
status, err := CurPrinterHandler.PrintMsg(jxcontext.AdminCtx, "120220915001877", "1", "test", `{
"allSkuCount": "2",
"allSkuTypeCount": "1",
"appId": "1000",
"businessType": "1",
"buyerComment": "(缺货时电话与我联系)",
"consigneeAddress": "胜浦街道苏州市吴中区新胜路1号",
"consigneeMobile": "18468578703,380",
"consigneeName": "刘*****",
"eBaiOrderNo": "好菜鲜生",
"eBailCode": "1126",
"officialName": "京西菜市",
"orderNo": "4016410104553361126",
"orderStatus": "5",
"payOrderTime": "2023-03-22 11:15:06",
"qrcOrder": "4016410104553361126",
"skuList": "[{\"skuName\":\"【精选好价】肥瘦五花肉下午易缺货250g/组\",\"skuCount\":\"X2\",\"salePrice\":\"¥22.10\",\"totalCountPrice\":\"¥44.20\",\"upc\":\"\"}]",
"storeName": "好菜鲜生(胜浦中胜路店)",
"storeTel": "13205196216",
"trySendTime": "2023-03-22 11:45:13",
"userPayMoney": "¥43.20",
"vendorID": "3",
"vendorName": "饿百新零售",
"vendorOrderNo": "5"
}`)
t.Log(utils.Format4Output(status, false))
if err != nil {
t.Fatal(err)

View File

@@ -33,7 +33,7 @@ func (c *PrinterHandler) GetVendorID() int {
}
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, printSn, orderSeq, msgTitle, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
if printSn != "" && globals.EnableStoreWrite {
if printSn != "" {
printSn = strings.Split(printSn, "_")[0]
if _, err := api.JxPrintAPI.DoPrint(printSn, msgContent, utils.Str2Int(orderSeq)); err == nil {
return c.GetPrinterStatus(ctx, printSn, "")
@@ -258,11 +258,14 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
printData[OrderStatus] = utils.Int2Str(130)
}
printData[AppID] = "1000" // 菜市应用
if printData[VendorID] == utils.Int2Str(model.VendorIDEBAI) && (printData[OrderStatus] == utils.Int2Str(model.OrderStatusFinishedPickup) || printData[OrderStatus] == utils.Int2Str(model.OrderStatusWaitAccepted)) {
printData[OrderStatus] = utils.Int2Str(model.OrderStatusNew)
}
orderPrint, err := json.Marshal(printData)
if err != nil {
return nil, err
}
globals.SugarLogger.Debugf("==========jxprintMsg:%s", string(orderPrint))
orderSel := utils.Int2Str(order.VendorID) + utils.Int2Str(order.OrderSeq)
return c.PrintMsg(ctx, store.PrinterSN, orderSel, "", string(orderPrint))

View File

@@ -714,3 +714,7 @@ func (p *PurchaseHandler) CancelActs(ctx *jxcontext.Context, vendorOrgCode strin
func (p *PurchaseHandler) UpdateStoreSkusSpecTag(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
return err
}
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
return "", err
}

View File

@@ -23,3 +23,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) {
return storeStatus, err
}
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
return "", err
}

View File

@@ -285,6 +285,19 @@ func (p *PurchaseHandler) GetSkus(ctx *jxcontext.Context, vendorOrgCode string,
return skuNameList, err
}
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
vendorCategory, err := getAPI(vendorOrgCode).GetSkuCategoryBySkuName(skuName)
if err != nil {
return "", err
}
if vendorCategory == nil {
return "", nil
}
return utils.Int2Str(vendorCategory.CategoryId), nil
}
func setSkuNameListPic(vendorOrgCode string, skuNameList []*partner.SkuNameInfo) []*partner.SkuNameInfo {
jdSkuIDs := make([]int64, len(skuNameList))
for k, v := range skuNameList {

View File

@@ -1299,3 +1299,7 @@ func buildUpdateSkusParam(storeSku *dao.StoreSkuSyncInfo, v *dao.StoreSkuSyncInf
updateSkusParam.Skus = skus
return updateSkusParam, wareSku, err
}
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
return "", err
}

View File

@@ -80,3 +80,7 @@ func (p *PurchaseHandler) GetVendorCategories(ctx *jxcontext.Context) (vendorCat
func (p *PurchaseHandler) GetSkus(ctx *jxcontext.Context, vendorOrgCode string, skuID int, vendorSkuID string) (skuNameList []*partner.SkuNameInfo, err error) {
return skuNameList, err
}
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
return "", err
}

View File

@@ -764,3 +764,7 @@ func (p *PurchaseHandler) UpdateStoreSkusSpecTag(ctx *jxcontext.Context, vendorO
}
return err
}
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
return "", err
}

View File

@@ -3,12 +3,9 @@ package tiktok_store
import (
"fmt"
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
"strings"
"sync"
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner"
@@ -84,61 +81,6 @@ func skuCategory(param1 []*tiktok_api.RetailCategoryInfo) (vendorCats []*model.S
return
}
func rangeMtwm2JX(areaStr string) string {
var area []interface{}
if err := utils.UnmarshalUseNumber([]byte(areaStr), &area); err == nil {
if len(area) > 0 {
coordList := make([]string, len(area))
for k, v := range area {
vv := v.(map[string]interface{})
coordList[k] = fmt.Sprintf("%.6f,%.6f", jxutils.IntCoordinate2Standard(int(utils.ForceInterface2Int64(vv["x"]))), jxutils.IntCoordinate2Standard(int(utils.ForceInterface2Int64(vv["y"]))))
}
return strings.Join(coordList, ";")
}
}
return ""
}
func rangeJX2Mtwm(coords string) string {
pairs := strings.Split(strings.Trim(coords, ";"), ";")
if len(pairs) > 0 {
coordList := make([]map[string]interface{}, len(pairs))
for k, v := range pairs {
pair := strings.Split(v, ",")
coordList[k] = map[string]interface{}{
"x": jxutils.StandardCoordinate2Int(utils.Str2Float64(pair[0])),
"y": jxutils.StandardCoordinate2Int(utils.Str2Float64(pair[1])),
}
}
return string(utils.MustMarshal(coordList))
}
return ""
}
func openTimeMtwm2JX(vendorOpenTime string) (opTimeList []int16) {
timePairs := strings.Split(vendorOpenTime, ",")
for _, v := range timePairs {
times := strings.Split(v, "-")
if len(times) >= 2 {
opTimeList = append(opTimeList, jxutils.StrTime2JxOperationTime(times[0]+":00", 700), jxutils.StrTime2JxOperationTime(times[1]+":00", 2000))
}
}
return opTimeList
}
func openTimeJX2Mtwm(opTimeList []int16) string {
timesLen := len(opTimeList) / 2 * 2
var strPairs []string
for i := 0; i < timesLen; i += 2 {
if opTimeList[i] != 0 {
strPairs = append(strPairs, jxutils.JxOperationTime2StrTime(opTimeList[i])+"-"+jxutils.JxOperationTime2StrTime(opTimeList[i+1]))
} else {
break
}
}
return strings.Join(strPairs, ",")
}
func bizStatusTiktok2JX(status int64) int {
switch status {
case tiktok_api.StoreStateNormalBusiness:
@@ -149,22 +91,6 @@ func bizStatusTiktok2JX(status int64) int {
return model.StoreStatusDisabled
}
func bizStatusJX2Mtwm(status int) (openLevel, online int) {
if status == model.StoreStatusDisabled {
return mtwmapi.PoiOpenLevelHaveRest, mtwmapi.PoiStatusOnline //mtwmapi.PoiStatusOffline
} else if status == model.StoreStatusHaveRest || status == model.StoreStatusClosed {
return mtwmapi.PoiOpenLevelHaveRest, mtwmapi.PoiStatusOnline
}
return mtwmapi.PoiOpenLevelNormal, mtwmapi.PoiStatusOnline
}
func skuStatusJX2Tiktok(status int) int {
if status == model.SkuStatusNormal {
return mtwmapi.SellStatusOnline
}
return mtwmapi.SellStatusOffline
}
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, vendorOrgCode, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
poiCode4UploadImg := p.getUploadImgPoiCode()
if poiCode4UploadImg == "" {
@@ -227,7 +153,3 @@ func getAPI(appOrgCode string, storeID int, vendorStoreID string) (apiObj *tikto
func GetTiktokApi(appOrgCode string, storeID int, vendorStoreID string) *tiktok_api.API {
return getAPI(appOrgCode, storeID, vendorStoreID)
}
func getAPIWithoutToken(appOrgCode string) (apiObj *tiktok_api.API) {
return partner.CurAPIManager.GetAPI(model.VendorIDDD, appOrgCode).(*tiktok_api.API)
}

View File

@@ -336,3 +336,8 @@ func GetProductAuditList(vendorOrgCode string, page, pageSize int64) (map[string
}
return updateCategory, total
}
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (string, error) {
vendorCategoryId, err := getAPI(vendorOrgCode, 0, "").GetRecommendCategory(strings.Split(skuName, "|"))
return utils.Int64ToStr(vendorCategoryId), err
}

View File

@@ -201,3 +201,6 @@ func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask ta
func composeFakeDelName(name string) string {
return "del_" + name
}
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
return "", err
}

View File

@@ -398,6 +398,9 @@ func (p *PurchaseHandler) IsErrSkuNotExist(err error) (isNotExist bool) {
return yinbaoapi.IsErrSkuNotExist(err)
}
func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string) (vendorCategoryId string, err error) {
return "", err
}
func ybSkuStatus2Jx(ybStatus int) (jxSkuStatus int) {
if ybStatus == yinbaoapi.SkuStatusEnable {
jxSkuStatus = model.SkuStatusNormal