- 京西自营商城可以存订单了
This commit is contained in:
@@ -277,6 +277,13 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
|
||||
LEFT JOIN store_sku_bind t2 ON t1.id = t2.sku_id AND t2.deleted_at = ? AND t2.store_id = ?
|
||||
WHERE t1.deleted_at = ? AND %s.%s_id IN (-1, ` + dao.GenQuestionMarks(len(vendorSkuIDs)) + ")"
|
||||
sql = fmt.Sprintf(sql, tableName, fieldPrefix, tableName, fieldPrefix)
|
||||
if order.VendorID == model.VendorIDJX {
|
||||
sql = `
|
||||
SELECT t1.id vendor_sku_id, t1.id sku_id, t2.price, t1.weight
|
||||
FROM sku t1
|
||||
LEFT JOIN store_sku_bind t2 ON t1.id = t2.sku_id AND t2.deleted_at = ? AND t2.store_id = ?
|
||||
WHERE t1.deleted_at = ? AND t1.id IN (-1, ` + dao.GenQuestionMarks(len(vendorSkuIDs)) + ")"
|
||||
}
|
||||
var skuInfos []*tStoreSkuBindAndVendorSkuID
|
||||
if err = dao.GetRows(db, &skuInfos, sql, utils.DefaultTimeValue, jxStoreID, utils.DefaultTimeValue, vendorSkuIDs); err != nil {
|
||||
globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku info for orderID:%s, error:%v", order.VendorOrderID, err)
|
||||
@@ -290,12 +297,6 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
|
||||
// var skuPriceMap map[int64]*dao.PromotionStoreSku
|
||||
var actStoreSkuMap *jxutils.ActStoreSkuMap
|
||||
if len(skuIDMap) > 0 {
|
||||
// skuPriceMap, err = dao.GetPromotionSkuPriceMap(db, model.VendorIDJX, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt)
|
||||
// if err != nil {
|
||||
// globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for orderID:%s, error:%v", order.VendorOrderID, err)
|
||||
// return err
|
||||
// }
|
||||
|
||||
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
|
||||
|
||||
@@ -464,41 +464,6 @@ func GetStoreAndSkuIDsFromInfo(skuNamesInfo *StoreSkuNamesInfo) (storeIDs, skuID
|
||||
return jxutils.IntMap2List(storeIDMap), jxutils.IntMap2List(skuIDMap)
|
||||
}
|
||||
|
||||
// func updateActPrice4StoreSkuName(db *dao.DaoDB, storeIDs, skuIDs []int, skuNamesInfo *StoreSkuNamesInfo) (err error) {
|
||||
// // 活动商品信息
|
||||
// jxSkuPriceMap, err := dao.GetPromotionSkuPriceMap(db, model.VendorIDJX, storeIDs, skuIDs, time.Now(), time.Now())
|
||||
// if err != nil {
|
||||
// globals.SugarLogger.Errorf("updateActPrice4StoreSkuName can not get sku promotion info for error:%v", err)
|
||||
// return err
|
||||
// }
|
||||
// jdSkuPriceMap, err2 := dao.GetPromotionSkuPriceMap(db, model.VendorIDJD, storeIDs, skuIDs, time.Now(), time.Now())
|
||||
// if err = err2; err != nil {
|
||||
// globals.SugarLogger.Errorf("updateActPrice4StoreSkuName can not get sku promotion info for error:%v", err)
|
||||
// return err
|
||||
// }
|
||||
// for _, skuName := range skuNamesInfo.SkuNames {
|
||||
// if len(skuName.Skus2) > 0 {
|
||||
// for _, v := range skuName.Skus2 {
|
||||
// index := dao.GenSkuPriceMapKey(skuName.StoreID, v.SkuID)
|
||||
// if jdSkuPriceMap[index] != nil {
|
||||
// v.ActPrice = jdSkuPriceMap[index].Price
|
||||
// }
|
||||
// if jxSkuPriceMap[index] != nil {
|
||||
// v.EarningPrice = jxSkuPriceMap[index].EarningPrice
|
||||
// }
|
||||
|
||||
// v.RealEarningPrice = v.EarningPrice
|
||||
// if v.RealEarningPrice == 0 {
|
||||
// v.RealEarningPrice = int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.BindPrice), skuName.PayPercentage))
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// skuName.UnitPrice = skuName.Price
|
||||
// }
|
||||
// }
|
||||
// return err
|
||||
// }
|
||||
|
||||
// 根据已经部分关注的商品,得到已经存在的门店商品单价
|
||||
func updateUnitPrice4StoreSkuNameNew(db *dao.DaoDB, skuNamesInfo *StoreSkuNamesInfo) (err error) {
|
||||
storeIDMap := make(map[int]int)
|
||||
@@ -523,11 +488,6 @@ func updateUnitPrice4StoreSkuNameNew(db *dao.DaoDB, skuNamesInfo *StoreSkuNamesI
|
||||
}
|
||||
|
||||
func updateActPrice4StoreSkuNameNew(db *dao.DaoDB, storeIDs, skuIDs []int, skuNamesInfo *StoreSkuNamesInfo) (err error) {
|
||||
// jxSkuPriceMap, err := dao.GetPromotionSkuPriceMap(db, model.VendorIDJX, 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
|
||||
// }
|
||||
if len(skuIDs) == 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -621,233 +581,6 @@ func updateSaleInfo4StoreSkuName(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
||||
return err
|
||||
}
|
||||
|
||||
// 商品不可售,直接排除
|
||||
// 如果门店商品是可售状态,那么会忽略区域限制。否则有区域限制
|
||||
// func GetStoresSkusOld(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bool, keyword string, isBySku bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) {
|
||||
// db := dao.GetDB()
|
||||
// sql, sqlParams, err := getGetStoresSkusBaseSQL(db, storeIDs, skuIDs, isFocus, keyword, isBySku, params)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// sql += `
|
||||
// GROUP BY
|
||||
// t1.id,
|
||||
// t1.created_at,
|
||||
// t1.updated_at,
|
||||
// t1.last_operator,
|
||||
// t1.deleted_at,
|
||||
// t1.prefix,
|
||||
// t1.name,
|
||||
// t1.brand_id,
|
||||
// t1.category_id,
|
||||
// t1.is_global,
|
||||
// t1.unit,
|
||||
// t1.price,
|
||||
// t1.img,
|
||||
// t1.elm_img_hash_code,
|
||||
// t3.id,
|
||||
// t3.name,
|
||||
// t3.pay_percentage`
|
||||
// if isBySku {
|
||||
// sql += `,
|
||||
// t2.id`
|
||||
// }
|
||||
// sqlData := `
|
||||
// SELECT
|
||||
// SQL_CALC_FOUND_ROWS
|
||||
// t1.id,
|
||||
// t1.created_at,
|
||||
// t1.updated_at,
|
||||
// t1.last_operator,
|
||||
// t1.deleted_at,
|
||||
// t1.prefix,
|
||||
// t1.name,
|
||||
// t1.brand_id,
|
||||
// t1.category_id,
|
||||
// t1.is_global,
|
||||
// t1.unit,
|
||||
// t1.price,
|
||||
// t1.img,
|
||||
// t1.elm_img_hash_code,
|
||||
// t3.id store_id,
|
||||
// t3.name store_name,
|
||||
// t3.pay_percentage,
|
||||
// CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"id":', t2.id, ',"comment":"', t2.comment, '","status":', t2.status, ',"createdAt":"',
|
||||
// CONCAT(REPLACE(IF(t4.created_at IS NULL, '1970-01-01 00:00:00', t4.created_at)," ","T"),"+08:00"), '","updatedAt":"', CONCAT(REPLACE(IF(t4.updated_at IS NULL, '1970-01-01 00:00:00', t4.updated_at)," ","T"),"+08:00"),
|
||||
// '","lastOperator":"', IF(t4.last_operator IS NULL, '', t4.last_operator), '","specQuality":', t2.spec_quality, ',"specUnit":"', t2.spec_unit, '","weight":', t2.weight,
|
||||
// ',"categoryID":', t2.category_id, ',"nameID":', t2.name_id, ',"subStoreID":', IF(t4.sub_store_id IS NULL, 0, t4.sub_store_id),
|
||||
// ',"price":', IF(t4.price IS NULL, 0, t4.price), ',"unitPrice":', IF(t4.unit_price IS NULL, t1.price, t4.unit_price),
|
||||
// ',"storeSkuStatus":', IF(t4.status IS NULL, 0, t4.status),
|
||||
// ',"jdID":', t2.jd_id, ',"jdSyncStatus":', IF(t4.jd_sync_status IS NULL, 0, t4.jd_sync_status),
|
||||
// ',"ebaiID":', IF(t4.ebai_id IS NULL, 0, t4.ebai_id), ',"ebaiSyncStatus":', IF(t4.ebai_sync_status IS NULL, 0, t4.ebai_sync_status),
|
||||
// ',"mtwmID":', IF(t4.mtwm_id IS NULL, 0, t4.mtwm_id), ',"mtwmSyncStatus":', IF(t4.mtwm_sync_status IS NULL, 0, t4.mtwm_sync_status),
|
||||
// ',"wscID":', IF(t4.wsc_id IS NULL, 0, t4.wsc_id), ',"wscSyncStatus":', IF(t4.wsc_sync_status IS NULL, 0, t4.wsc_sync_status),
|
||||
// "}")), "]") skus_str
|
||||
// ` + sql + `
|
||||
// ORDER BY t1.id DESC
|
||||
// LIMIT ? OFFSET ?`
|
||||
// pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
// sqlOffset := offset
|
||||
// sqlPageSize := pageSize
|
||||
// isSaleInfo := params["stFromTime"] != nil
|
||||
// if isSaleInfo {
|
||||
// sqlOffset = 0
|
||||
// sqlPageSize = jxutils.FormalizePageSize(-1)
|
||||
// }
|
||||
// sqlParams = append(sqlParams, sqlPageSize, sqlOffset)
|
||||
// skuNamesInfo = &StoreSkuNamesInfo{}
|
||||
// // globals.SugarLogger.Debug(sqlData)
|
||||
// dao.Begin(db)
|
||||
// defer func() {
|
||||
// if r := recover(); r != nil {
|
||||
// dao.Rollback(db)
|
||||
// panic(r)
|
||||
// }
|
||||
// }()
|
||||
// // globals.SugarLogger.Debug(sqlData, sqlParams)
|
||||
// if err = dao.GetRows(db, &skuNamesInfo.SkuNames, sqlData, sqlParams...); err == nil {
|
||||
// skuNamesInfo.TotalCount = dao.GetLastTotalRowCount(db)
|
||||
// dao.Commit(db)
|
||||
|
||||
// // 活动商品信息
|
||||
// jxSkuPriceMap, err2 := dao.GetPromotionSkuPriceMap(db, model.VendorIDJX, storeIDs, skuIDs, time.Now(), time.Now())
|
||||
// if err = err2; err != nil {
|
||||
// globals.SugarLogger.Errorf("GetStoresSkus can not get sku promotion info for error:%v", err)
|
||||
// return nil, err
|
||||
// }
|
||||
// jdSkuPriceMap, err2 := dao.GetPromotionSkuPriceMap(db, model.VendorIDJD, storeIDs, skuIDs, time.Now(), time.Now())
|
||||
// if err = err2; err != nil {
|
||||
// globals.SugarLogger.Errorf("GetStoresSkus can not get sku promotion info for error:%v", err)
|
||||
// return nil, err
|
||||
// }
|
||||
// for _, skuName := range skuNamesInfo.SkuNames {
|
||||
// if skuName.SkusStr != "" {
|
||||
// if err = utils.UnmarshalUseNumber([]byte(skuName.SkusStr), &skuName.Skus); err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// if len(skuName.Skus) > 0 {
|
||||
// skuName.UnitPrice = int(utils.MustInterface2Int64(skuName.Skus[0]["unitPrice"]))
|
||||
// for _, v := range skuName.Skus {
|
||||
// index := dao.GenSkuPriceMapKey(skuName.StoreID, int(utils.MustInterface2Int64(v["id"])))
|
||||
// if jdSkuPriceMap[index] != nil {
|
||||
// v["actPrice"] = jdSkuPriceMap[index].Price
|
||||
// } else {
|
||||
// v["actPrice"] = 0
|
||||
// }
|
||||
|
||||
// earningPrice := 0
|
||||
// if jxSkuPriceMap[index] != nil {
|
||||
// earningPrice = jxSkuPriceMap[index].EarningPrice
|
||||
// }
|
||||
// v["earningPrice"] = earningPrice
|
||||
|
||||
// realEarningPrice := earningPrice
|
||||
// if realEarningPrice == 0 {
|
||||
// shopPrice := utils.Interface2Int64WithDefault(v["price"], 0)
|
||||
// realEarningPrice = int(jxutils.CaculateSkuEarningPrice(shopPrice, shopPrice, skuName.PayPercentage))
|
||||
// }
|
||||
// v["realEarningPrice"] = realEarningPrice
|
||||
|
||||
// delete(v, "unitPrice")
|
||||
// }
|
||||
// } else {
|
||||
// skuName.UnitPrice = skuName.Price
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if isSaleInfo {
|
||||
// var (
|
||||
// saleInfoList []*SkuSaleInfo
|
||||
// skuIDs []int
|
||||
// timeList []time.Time
|
||||
// fromCount, toCount int
|
||||
// )
|
||||
// saleInfoMap := make(map[int64]*SkuSaleInfo)
|
||||
// for _, skuName := range skuNamesInfo.SkuNames {
|
||||
// for _, sku := range skuName.Skus {
|
||||
// skuIDs = append(skuIDs, int(utils.MustInterface2Int64(sku["id"])))
|
||||
// }
|
||||
// }
|
||||
// toTimeStr := ""
|
||||
// if params["stToTime"] != nil {
|
||||
// toTimeStr = params["stToTime"].(string)
|
||||
// }
|
||||
// if timeList, err = jxutils.BatchStr2Time(params["stFromTime"].(string), toTimeStr); err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// if params["stFromCount"] != nil {
|
||||
// fromCount = params["stFromCount"].(int)
|
||||
// }
|
||||
// toCount = math.MaxInt32
|
||||
// if params["stToCount"] != nil {
|
||||
// toCount = params["stToCount"].(int)
|
||||
// }
|
||||
// // 不能用SQL筛除,否则不能区分是没有销量,还是不在条件中
|
||||
// if saleInfoList, err = GetStoresSkusSaleInfo(ctx, storeIDs, skuIDs, timeList[0], timeList[1], 0, math.MaxInt32); err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// for _, saleInfo := range saleInfoList {
|
||||
// saleInfoMap[int64(saleInfo.StoreID)*100000+int64(saleInfo.SkuID)] = saleInfo
|
||||
// }
|
||||
// var newSkuNames []*StoreSkuNameExt
|
||||
// for _, skuName := range skuNamesInfo.SkuNames {
|
||||
// var newSkus []map[string]interface{}
|
||||
// storeID2 := int64(skuName.StoreID) * 100000
|
||||
// for _, sku := range skuName.Skus {
|
||||
// saleInfo := saleInfoMap[storeID2+utils.MustInterface2Int64(sku["id"])]
|
||||
// if saleInfo == nil && fromCount == 0 {
|
||||
// saleInfo = &SkuSaleInfo{}
|
||||
// }
|
||||
// if saleInfo != nil && saleInfo.Count >= fromCount && saleInfo.Count <= toCount {
|
||||
// sku["times"] = saleInfo.Times
|
||||
// sku["count"] = saleInfo.Count
|
||||
// newSkus = append(newSkus, sku)
|
||||
// }
|
||||
// }
|
||||
// if len(newSkus) > 0 {
|
||||
// skuName.Skus = newSkus
|
||||
// newSkuNames = append(newSkuNames, skuName)
|
||||
// }
|
||||
// }
|
||||
// skuNamesInfo.TotalCount = len(newSkuNames)
|
||||
// skuNamesInfo.SkuNames = nil
|
||||
// if offset < skuNamesInfo.TotalCount {
|
||||
// endIndex := offset + pageSize
|
||||
// if endIndex > skuNamesInfo.TotalCount {
|
||||
// endIndex = skuNamesInfo.TotalCount
|
||||
// }
|
||||
// skuNamesInfo.SkuNames = newSkuNames[offset:endIndex]
|
||||
// }
|
||||
// }
|
||||
// if globals.EnablePendingChange {
|
||||
// if isGetOpRequest, ok := params["isGetOpRequest"].(bool); ok && isGetOpRequest {
|
||||
// nameIDs := make([]int, len(skuNamesInfo.SkuNames))
|
||||
// for k, skuName := range skuNamesInfo.SkuNames {
|
||||
// nameIDs[k] = skuName.ID
|
||||
// }
|
||||
// pagedInfo, err2 := GetStoreOpRequests(ctx, utils.DefaultTimeValue, utils.DefaultTimeValue, "", storeIDs, nameIDs, nil, []int{model.RequestStatusNew}, 0, -1)
|
||||
// if err = err2; err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// requestList := pagedInfo.Data.([]*StoreOpRequestInfo)
|
||||
// requestMap := make(map[int]*StoreOpRequestInfo)
|
||||
// for _, requestOp := range requestList {
|
||||
// requestMap[requestOp.ItemID] = requestOp
|
||||
// }
|
||||
// for _, skuName := range skuNamesInfo.SkuNames {
|
||||
// if requestOp := requestMap[skuName.ID]; requestOp != nil {
|
||||
// skuName.PendingUnitPrice = requestOp.IntParam1
|
||||
// skuName.PendingOpType = requestOp.Type
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// dao.Rollback(db)
|
||||
// }
|
||||
// return skuNamesInfo, err
|
||||
// }
|
||||
|
||||
func getValidStoreVendorMap(db *dao.DaoDB, storeIDs []int) (realVendorMap map[int]int, err error) {
|
||||
storeMapList, err := dao.GetStoresMapList(db, nil, storeIDs, model.StoreStatusAll, model.StoreIsSyncYes, "")
|
||||
if err != nil {
|
||||
|
||||
@@ -91,7 +91,21 @@ func GetStoreDetail(db *DaoDB, storeID, vendorID int) (storeDetail *StoreDetail,
|
||||
}
|
||||
|
||||
func GetStoreDetailByVendorStoreID(db *DaoDB, vendorStoreID string, vendorID int) (storeDetail *StoreDetail, err error) {
|
||||
return getStoreDetail(db, 0, vendorID, vendorStoreID)
|
||||
if vendorID != model.VendorIDJX {
|
||||
return getStoreDetail(db, 0, vendorID, vendorStoreID)
|
||||
}
|
||||
store := &model.Store{}
|
||||
store.ID = int(utils.Str2Int64WithDefault(vendorStoreID, 0))
|
||||
if err = GetEntity(db, store); err == nil {
|
||||
// todo 还要补全其它参数
|
||||
storeDetail = &StoreDetail{
|
||||
Store: *store,
|
||||
VendorStoreID: vendorStoreID,
|
||||
VendorStatus: store.Status,
|
||||
PricePercentage: 100,
|
||||
}
|
||||
}
|
||||
return storeDetail, err
|
||||
}
|
||||
|
||||
func GetPossibleStoresByPlaceName(db *DaoDB, cityName, provinceName string) (storeList []*StoreDetail, err error) {
|
||||
|
||||
@@ -30,12 +30,12 @@ type GoodsOrder struct {
|
||||
ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"`
|
||||
ConsigneeMobile2 string `orm:"size(32)" json:"consigneeMobile2"`
|
||||
ConsigneeAddress string `orm:"size(255)" json:"consigneeAddress"`
|
||||
CoordinateType int `json:"-"`
|
||||
ConsigneeLng int `json:"-"` // 坐标 * (10的六次方)
|
||||
ConsigneeLat int `json:"-"` // 坐标 * (10的六次方)
|
||||
SkuCount int `json:"skuCount"` // 商品类别数量,即有多少种商品(注意在某些情况下,相同SKU的商品由于售价不同,也会当成不同商品在这个值里)
|
||||
GoodsCount int `json:"goodsCount"` // 商品个数
|
||||
Status int `json:"status"` // 参见OrderStatus*相关的常量定义
|
||||
CoordinateType int `json:"coordinateType"`
|
||||
ConsigneeLng int `json:"consigneeLng"` // 坐标 * (10的六次方)
|
||||
ConsigneeLat int `json:"consigneeLat"` // 坐标 * (10的六次方)
|
||||
SkuCount int `json:"skuCount"` // 商品类别数量,即有多少种商品(注意在某些情况下,相同SKU的商品由于售价不同,也会当成不同商品在这个值里)
|
||||
GoodsCount int `json:"goodsCount"` // 商品个数
|
||||
Status int `json:"status"` // 参见OrderStatus*相关的常量定义
|
||||
VendorStatus string `orm:"size(255)" json:"vendorStatus"`
|
||||
LockStatus int `json:"lockStatus"`
|
||||
LockStatusTime time.Time `orm:"type(datetime);null" json:"lockStatusTime"` // last lock status time
|
||||
|
||||
11
business/partner/purchase/jx/act.go
Normal file
11
business/partner/purchase/jx/act.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package jx
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.Act2, actOrderRules []*model.ActOrderRule, actStoreSkuList []*model.ActStoreSku2) (err error) {
|
||||
return err
|
||||
}
|
||||
36
business/partner/purchase/jx/callback.go
Normal file
36
business/partner/purchase/jx/callback.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package jx
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
appKey = "4A86853D-E4B6-454E-940A-B68ECDA2B73E"
|
||||
|
||||
MsgTypeOrder = "order"
|
||||
SubMsgTypeOrderNew = "newOrder"
|
||||
SubMsgTypeOrderAdjust = "adjustOrder"
|
||||
SubMsgTypeOrderApplyCancel = "applyCancel"
|
||||
// SubMsgTypeOrderApplayRefund = "applyRefund"
|
||||
)
|
||||
|
||||
type CallbackResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
type CallbackMsg struct {
|
||||
AppKey string `json:"appKey"`
|
||||
MsgType string `json:"msgType"`
|
||||
SubMsgType string `json:"subMsgType"`
|
||||
ThingID string `json:"thingID"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
func OnCallbackMsg(msg *CallbackMsg) (retVal, errCode string, err error) {
|
||||
if msg.AppKey != appKey {
|
||||
return retVal, errCode, fmt.Errorf("无效的AppKey:%s", msg.AppKey)
|
||||
}
|
||||
if msg.MsgType == MsgTypeOrder {
|
||||
retVal, errCode, err = CurPurchaseHandler.OnOrderMsg(msg)
|
||||
}
|
||||
return retVal, errCode, err
|
||||
}
|
||||
32
business/partner/purchase/jx/jx.go
Normal file
32
business/partner/purchase/jx/jx.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package jx
|
||||
|
||||
import (
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
type PurchaseHandler struct {
|
||||
partner.BasePurchasePlatform
|
||||
}
|
||||
|
||||
var (
|
||||
CurPurchaseHandler *PurchaseHandler
|
||||
)
|
||||
|
||||
func init() {
|
||||
globals.SugarLogger.Debug("init jx")
|
||||
if true {
|
||||
CurPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(CurPurchaseHandler)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetVendorID() int {
|
||||
return model.VendorIDJX
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error) {
|
||||
return imgHint, err
|
||||
}
|
||||
52
business/partner/purchase/jx/jx_test.go
Normal file
52
business/partner/purchase/jx/jx_test.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package jx
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
)
|
||||
|
||||
func init() {
|
||||
testinit.Init()
|
||||
}
|
||||
|
||||
func TestBuildNewJxOrder(t *testing.T) {
|
||||
order, err := partner.CurOrderManager.LoadOrder("920931913000041", model.VendorIDJD)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
order.VendorID = model.VendorIDJX
|
||||
order.VendorStoreID = utils.Int2Str(order.StoreID)
|
||||
for _, sku := range order.Skus {
|
||||
sku.VendorID = model.VendorIDJX
|
||||
sku.VendorSkuID = utils.Int2Str(sku.SkuID)
|
||||
}
|
||||
order2 := &Data4Neworder{
|
||||
GoodsOrder: *order,
|
||||
Skus: order.Skus,
|
||||
}
|
||||
msg := &CallbackMsg{
|
||||
AppKey: appKey,
|
||||
MsgType: MsgTypeOrder,
|
||||
SubMsgType: SubMsgTypeOrderNew,
|
||||
ThingID: order.VendorOrderID,
|
||||
Data: utils.Format4Output(order2, true),
|
||||
}
|
||||
t.Logf("\n%s", msg.AppKey)
|
||||
t.Logf("\n%s", msg.MsgType)
|
||||
t.Logf("\n%s", msg.SubMsgType)
|
||||
t.Logf("\n%s", msg.ThingID)
|
||||
t.Logf("\n%s", msg.Data)
|
||||
|
||||
var order3 *model.GoodsOrder
|
||||
err = utils.UnmarshalUseNumber([]byte(msg.Data), &order3)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(order3.OrderCreatedAt)
|
||||
}
|
||||
120
business/partner/purchase/jx/order.go
Normal file
120
business/partner/purchase/jx/order.go
Normal file
@@ -0,0 +1,120 @@
|
||||
package jx
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"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/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
type Data4Neworder struct {
|
||||
model.GoodsOrder
|
||||
Skus []*model.OrderSku `json:"skus"`
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) OnOrderMsg(msg *CallbackMsg) (retVal, errCode string, err error) {
|
||||
jxutils.CallMsgHandler(func() {
|
||||
retVal, errCode, err = c.onOrderMsg(msg)
|
||||
}, jxutils.ComposeUniversalOrderID(msg.ThingID, c.GetVendorID()))
|
||||
return retVal, errCode, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) onOrderMsg(msg *CallbackMsg) (retVal, errCode string, err error) {
|
||||
if msg.SubMsgType == SubMsgTypeOrderNew || msg.SubMsgType == SubMsgTypeOrderAdjust {
|
||||
var order *Data4Neworder
|
||||
if err = utils.UnmarshalUseNumber([]byte(msg.Data), &order); err == nil {
|
||||
retVal, errCode, err = c.onOrderNew(msg, order)
|
||||
}
|
||||
}
|
||||
return retVal, errCode, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) onOrderNew(msg *CallbackMsg, order *Data4Neworder) (retVal, errCode string, err error) {
|
||||
globals.SugarLogger.Debugf("onOrderNew orderID:%s", msg.ThingID)
|
||||
order.GoodsOrder.Skus = order.Skus
|
||||
orderStatus := model.Order2Status(&order.GoodsOrder)
|
||||
if msg.SubMsgType == SubMsgTypeOrderNew {
|
||||
err = partner.CurOrderManager.OnOrderNew(&order.GoodsOrder, orderStatus)
|
||||
} else {
|
||||
err = partner.CurOrderManager.OnOrderAdjust(&order.GoodsOrder, orderStatus)
|
||||
}
|
||||
return retVal, errCode, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *model.GoodsOrder) {
|
||||
return order
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetOrder(orderID string) (order *model.GoodsOrder, err error) {
|
||||
return order, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) AcceptOrRefuseFailedGetOrder(ctx *jxcontext.Context, order *model.GoodsOrder, isAcceptIt bool) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) CallCourier(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) { // 拣货失败后再次招唤平台配送
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ConfirmReceiveGoods(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) { // 投递失败后确认收到退货
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) Swtich2SelfDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// 京东送达接口都是一样的
|
||||
func (c *PurchaseHandler) SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *model.GoodsOrder) (mobile string, err error) {
|
||||
return mobile, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AdjustOrder(ctx *jxcontext.Context, order *model.GoodsOrder, removedSkuList []*model.OrderSku, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch.ITask, queryDate time.Time, vendorStoreID string) (vendorOrderIDs []string, err error) {
|
||||
return vendorOrderIDs, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder) (tipFee int64, err error) {
|
||||
return tipFee, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AddWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee2Add int64) (err error) {
|
||||
return err
|
||||
}
|
||||
38
business/partner/purchase/jx/order_afs.go
Normal file
38
business/partner/purchase/jx/order_afs.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package jx
|
||||
|
||||
import (
|
||||
"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"
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) OnAfsOrderMsg(msg *CallbackMsg) (retVal *CallbackResponse) {
|
||||
jxutils.CallMsgHandlerAsync(func() {
|
||||
retVal = c.onAfsOrderMsg(msg)
|
||||
}, jxutils.ComposeUniversalOrderID(msg.ThingID, c.GetVendorID()))
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) onAfsOrderMsg(msg *CallbackMsg) (retVal *CallbackResponse) {
|
||||
return retVal
|
||||
}
|
||||
|
||||
// 审核售后单申请
|
||||
func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.AfsOrder, approveType int, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// 确认收到退货
|
||||
func (c *PurchaseHandler) ConfirmReceivedReturnGoods(ctx *jxcontext.Context, order *model.AfsOrder) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// 发起全款退款
|
||||
func (c *PurchaseHandler) RefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// 发起部分退款
|
||||
func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, refundSkuList []*model.OrderSku, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
10
business/partner/purchase/jx/order_comment.go
Normal file
10
business/partner/purchase/jx/order_comment.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package jx
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
||||
return err
|
||||
}
|
||||
59
business/partner/purchase/jx/sku.go
Normal file
59
business/partner/purchase/jx/sku.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package jx
|
||||
|
||||
// 这里函数取得的信息,除了与自身实体相关的ID(比如PARENT ID),都已经转换成了本地ID了
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"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"
|
||||
)
|
||||
|
||||
func (p *PurchaseHandler) CreateCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetAllCategories(ctx *jxcontext.Context, vendorOrgCode string) (cats []*partner.BareCategoryInfo, err error) {
|
||||
return cats, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReorderCategories(db *dao.DaoDB, parentCatID int, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) CreateSku(db *dao.DaoDB, sku *model.Sku, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReadSku(vendorSkuID string) (skuNameExt *model.SkuNameExt, err error) {
|
||||
return skuNameExt, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateSku(db *dao.DaoDB, sku *model.Sku, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteSku(db *dao.DaoDB, sku *model.Sku, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) RefreshAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) {
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetVendorCategories(ctx *jxcontext.Context) (vendorCats []*model.SkuVendorCategory, err error) {
|
||||
return vendorCats, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetSkus(ctx *jxcontext.Context, skuID int, vendorSkuID, skuName string) (skuNameList []*partner.SkuNameInfo, err error) {
|
||||
return skuNameList, err
|
||||
}
|
||||
40
business/partner/purchase/jx/store.go
Normal file
40
business/partner/purchase/jx/store.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package jx
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
)
|
||||
|
||||
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (storeDetail *dao.StoreDetail, err error) {
|
||||
return storeDetail, err
|
||||
}
|
||||
|
||||
// stoerIDs为nil表示所有
|
||||
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) {
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) {
|
||||
return storeStatus, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) {
|
||||
return vendorStoreIDs, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorStoreID string, storeID int64) (err error) {
|
||||
return err
|
||||
}
|
||||
28
business/partner/purchase/jx/store_sku2.go
Normal file
28
business/partner/purchase/jx/store_sku2.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package jx
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
)
|
||||
|
||||
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
||||
batchSize = 1
|
||||
return batchSize
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.StoreSkuInfo) (outStoreSkuList []*partner.StoreSkuInfo, err error) {
|
||||
return outStoreSkuList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (successList []*partner.StoreSkuInfo, err error) {
|
||||
return successList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
return successList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
return successList, err
|
||||
}
|
||||
33
controllers/jxshop_callback.go
Normal file
33
controllers/jxshop_callback.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
type JxShopController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title 京西自营商城消息回调接口
|
||||
// @Description 京西自营商城消息回调接口
|
||||
// @Param appKey formData string true "AppKey"
|
||||
// @Param msgType formData string true "消息类型"
|
||||
// @Param subMsgType formData string false "子消息类型"
|
||||
// @Param thingID formData string false "消息对应的事物ID"
|
||||
// @Param data formData string false "详细"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /JxMsg [post]
|
||||
func (c *JxShopController) JxMsg(msgType string) {
|
||||
c.callJxMsg(func(params *tJxshopJxMsgParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, errCode, err = jx.OnCallbackMsg(&jx.CallbackMsg{
|
||||
AppKey: params.AppKey,
|
||||
MsgType: params.MsgType,
|
||||
SubMsgType: params.SubMsgType,
|
||||
ThingID: params.ThingID,
|
||||
Data: params.Data,
|
||||
})
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -592,6 +592,17 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JxShopController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JxShopController"],
|
||||
beego.ControllerComments{
|
||||
Method: "JxMsg",
|
||||
Router: `/JxMsg`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(
|
||||
param.New("msgType", param.IsRequired),
|
||||
),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:MsgController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:MsgController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetStoreMessageStatuses",
|
||||
|
||||
@@ -111,6 +111,11 @@ func init() {
|
||||
&controllers.ActController{},
|
||||
),
|
||||
),
|
||||
beego.NSNamespace("/jxshop",
|
||||
beego.NSInclude(
|
||||
&controllers.JxShopController{},
|
||||
),
|
||||
),
|
||||
)
|
||||
beego.AddNamespace(ns)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user