- 去除无用代码,主要是promotion相关的
This commit is contained in:
@@ -73,8 +73,6 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
|
|||||||
"vendorName": model.VendorChineseNames,
|
"vendorName": model.VendorChineseNames,
|
||||||
"orderStatus": model.OrderStatusName,
|
"orderStatus": model.OrderStatusName,
|
||||||
"waybillStatus": model.WaybillStatusName,
|
"waybillStatus": model.WaybillStatusName,
|
||||||
// "bankName": model.BankName,
|
|
||||||
"promotionStatusName": model.PromotionStatusName,
|
|
||||||
"orderTypeName": model.OrderTypeName,
|
"orderTypeName": model.OrderTypeName,
|
||||||
"taskStatusName": tasksch.TaskStatusName,
|
"taskStatusName": tasksch.TaskStatusName,
|
||||||
"opRequestTypeName": model.RequestTypeName,
|
"opRequestTypeName": model.RequestTypeName,
|
||||||
|
|||||||
@@ -433,11 +433,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
|||||||
storeIDs, skuIDs = GetStoreAndSkuIDsFromInfo(skuNamesInfo)
|
storeIDs, skuIDs = GetStoreAndSkuIDsFromInfo(skuNamesInfo)
|
||||||
}
|
}
|
||||||
beginTime := time.Now()
|
beginTime := time.Now()
|
||||||
if globals.EnableNewAct {
|
|
||||||
err = updateActPrice4StoreSkuNameNew(db, storeIDs, skuIDs, skuNamesInfo)
|
err = updateActPrice4StoreSkuNameNew(db, storeIDs, skuIDs, skuNamesInfo)
|
||||||
} else {
|
|
||||||
// err = updateActPrice4StoreSkuName(db, storeIDs, skuIDs, skuNamesInfo)
|
|
||||||
}
|
|
||||||
globals.SugarLogger.Debugf("GetStoresSkusNew updateActPrice4StoreSkuName:%v", time.Now().Sub(beginTime))
|
globals.SugarLogger.Debugf("GetStoresSkusNew updateActPrice4StoreSkuName:%v", time.Now().Sub(beginTime))
|
||||||
if !isFocus {
|
if !isFocus {
|
||||||
err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
|
err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +0,0 @@
|
|||||||
package promotion
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
testinit.Init()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCreateLocalPromotionFromRemote(t *testing.T) {
|
|
||||||
t.Log(createLocalPromotionFromRemote(14510904))
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package promotion
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/KenmyZhang/aliyun-communicate"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"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"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
DefGoodsOrderDays = 60
|
|
||||||
MaxBatchSize = 500
|
|
||||||
)
|
|
||||||
|
|
||||||
type tMobileInfo struct {
|
|
||||||
Mobile string
|
|
||||||
}
|
|
||||||
|
|
||||||
func SendAdvertingByGoodsOrder(ctx *jxcontext.Context, advertising string, days int, isAsync bool, userName string) (hint string, err error) {
|
|
||||||
globals.SugarLogger.Debugf("SendAdvertingByGoodsOrder advertising:%s, days:%d, isAsync:%t, userName:%s", advertising, days, isAsync, userName)
|
|
||||||
|
|
||||||
if days == 0 {
|
|
||||||
days = DefGoodsOrderDays
|
|
||||||
}
|
|
||||||
sqlParams := []interface{}{}
|
|
||||||
sql1 := `
|
|
||||||
SELECT IF(t1.consignee_mobile2 <> '', t1.consignee_mobile2, t1.consignee_mobile) mobile
|
|
||||||
FROM goods_order t1
|
|
||||||
LEFT JOIN black_client t2 ON IF(t1.consignee_mobile2 <> '', t1.consignee_mobile2, t1.consignee_mobile) = t2.mobile
|
|
||||||
WHERE IF(t1.consignee_mobile2 <> '', t1.consignee_mobile2, t1.consignee_mobile) <> '' AND t2.id IS NULL AND LENGTH(IF(t1.consignee_mobile2 <> '', t1.consignee_mobile2, t1.consignee_mobile)) = 11 AND LEFT(IF(t1.consignee_mobile2 <> '', t1.consignee_mobile2, t1.consignee_mobile), 1) = '1'
|
|
||||||
`
|
|
||||||
sql2 := `
|
|
||||||
SELECT buyer_mobile mobile
|
|
||||||
FROM jxorder t1
|
|
||||||
LEFT JOIN black_client t2 ON t1.buyer_mobile = t2.mobile
|
|
||||||
WHERE buyer_mobile IS NOT NULL AND buyer_mobile <> '' AND t2.id IS NULL AND LENGTH(buyer_mobile) = 11 AND LEFT(buyer_mobile, 1) = '1'
|
|
||||||
`
|
|
||||||
if days > 0 {
|
|
||||||
sql1 += " AND order_created_at > ?"
|
|
||||||
sql2 += " AND order_start_time > ?"
|
|
||||||
daysTime := time.Now().Add(-time.Duration(days) * 24 * time.Hour)
|
|
||||||
sqlParams = append(sqlParams, daysTime, daysTime)
|
|
||||||
}
|
|
||||||
|
|
||||||
var mobiles []*tMobileInfo
|
|
||||||
db := dao.GetDB()
|
|
||||||
if err = dao.GetRows(db, &mobiles, sql1+" UNION DISTINCT "+sql2, sqlParams...); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
index := 0
|
|
||||||
mobileNumbers := make([]string, len(mobiles))
|
|
||||||
for _, v := range mobiles {
|
|
||||||
if v.Mobile[:1] == "1" && strings.Index(v.Mobile, ",") == -1 {
|
|
||||||
mobileNumbers[index] = v.Mobile
|
|
||||||
index++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mobileNumbers = mobileNumbers[:index]
|
|
||||||
mobileNumbers = append(mobileNumbers, "18180948107")
|
|
||||||
|
|
||||||
smsClient := aliyunsmsclient.New("http://dysmsapi.aliyuncs.com/")
|
|
||||||
task := tasksch.NewParallelTask("SendAdvertingByGoodsOrder", tasksch.NewParallelConfig().SetBatchSize(MaxBatchSize), ctx,
|
|
||||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
|
||||||
numbers := make([]string, len(batchItemList))
|
|
||||||
for k, v := range batchItemList {
|
|
||||||
numbers[k] = v.(string)
|
|
||||||
}
|
|
||||||
numberStr := strings.Join(numbers, ",")
|
|
||||||
_, err = smsClient.Execute(globals.AliKey, globals.AliSecret, numberStr, "京西菜市", "SMS_109345355", string(utils.MustMarshal(map[string]interface{}{
|
|
||||||
"code": "code",
|
|
||||||
})))
|
|
||||||
if err != nil {
|
|
||||||
globals.SugarLogger.Infof("SendAdvertingByGoodsOrder numbers:%s failed with error:%v", numberStr, err)
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}, mobileNumbers)
|
|
||||||
tasksch.HandleTask(task, nil, true).Run()
|
|
||||||
|
|
||||||
if !isAsync {
|
|
||||||
_, err = task.GetResult(0)
|
|
||||||
}
|
|
||||||
return task.ID, err
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,7 @@ package tempop
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -13,7 +11,6 @@ import (
|
|||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"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/jxcontext"
|
||||||
@@ -21,7 +18,6 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel2"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
@@ -284,79 +280,79 @@ func Change2JDSPU4Store(ctx *jxcontext.Context, storeIDs []int, step int, isAsyn
|
|||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func TransferLegacyJdOrder(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
// func TransferLegacyJdOrder(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
sqlBatchCount := 1000
|
// sqlBatchCount := 1000
|
||||||
rootTask := tasksch.NewSeqTask("TransferLegacyJdOrder", ctx,
|
// rootTask := tasksch.NewSeqTask("TransferLegacyJdOrder", ctx,
|
||||||
func(rootTask *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
// func(rootTask *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
sql := `
|
// sql := `
|
||||||
SELECT t1.*
|
// SELECT t1.*
|
||||||
FROM jdorder t1
|
// FROM jdorder t1
|
||||||
LEFT JOIN goods_order_original t2 ON t2.vendor_order_id = t1.vendor_order_id
|
// LEFT JOIN goods_order_original t2 ON t2.vendor_order_id = t1.vendor_order_id
|
||||||
WHERE t2.id IS NULL AND LENGTH(t1.data) > 10 AND t1.cityname = 'all'
|
// WHERE t2.id IS NULL AND LENGTH(t1.data) > 10 AND t1.cityname = 'all'
|
||||||
ORDER BY t1.orderstatustime
|
// ORDER BY t1.orderstatustime
|
||||||
LIMIT ?
|
// LIMIT ?
|
||||||
`
|
// `
|
||||||
db := dao.GetDB()
|
// db := dao.GetDB()
|
||||||
var jdOrderList []*legacymodel2.Jdorder
|
// var jdOrderList []*legacymodel2.Jdorder
|
||||||
if err = dao.GetRows(db, &jdOrderList, sql, sqlBatchCount); err != nil {
|
// if err = dao.GetRows(db, &jdOrderList, sql, sqlBatchCount); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
if len(jdOrderList) > 0 {
|
// if len(jdOrderList) > 0 {
|
||||||
task := tasksch.NewParallelTask("TransferLegacyJdOrder2", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetBatchSize(40), ctx,
|
// task := tasksch.NewParallelTask("TransferLegacyJdOrder2", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetBatchSize(40), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
var orderDetailList []*model.GoodsOrderOriginal
|
// var orderDetailList []*model.GoodsOrderOriginal
|
||||||
for _, v := range batchItemList {
|
// for _, v := range batchItemList {
|
||||||
jdOrder := v.(*legacymodel2.Jdorder)
|
// jdOrder := v.(*legacymodel2.Jdorder)
|
||||||
var detail map[string]interface{}
|
// var detail map[string]interface{}
|
||||||
if err = utils.UnmarshalUseNumber([]byte(strings.Replace(strings.Replace(jdOrder.Data, "\n", "", -1), "\r", "", -1)), &detail); err != nil {
|
// if err = utils.UnmarshalUseNumber([]byte(strings.Replace(strings.Replace(jdOrder.Data, "\n", "", -1), "\r", "", -1)), &detail); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
resultList := detail["result"].(map[string]interface{})["resultList"].([]interface{})
|
// resultList := detail["result"].(map[string]interface{})["resultList"].([]interface{})
|
||||||
if len(resultList) > 0 {
|
// if len(resultList) > 0 {
|
||||||
originalData := resultList[0].(map[string]interface{})
|
// originalData := resultList[0].(map[string]interface{})
|
||||||
orgCode := originalData["orgCode"].(string)
|
// orgCode := originalData["orgCode"].(string)
|
||||||
if orgCode == "320406" {
|
// if orgCode == "320406" {
|
||||||
orderPurchaseTime := utils.Interface2String(originalData["orderPurchaseTime"])
|
// orderPurchaseTime := utils.Interface2String(originalData["orderPurchaseTime"])
|
||||||
if orderPurchaseTime == "" {
|
// if orderPurchaseTime == "" {
|
||||||
globals.SugarLogger.Debugf("TransferLegacyJdOrder abnormal order:%s", jdOrder.VendorOrderID)
|
// globals.SugarLogger.Debugf("TransferLegacyJdOrder abnormal order:%s", jdOrder.VendorOrderID)
|
||||||
orderPurchaseTime = utils.Interface2String(originalData["orderStartTime"])
|
// orderPurchaseTime = utils.Interface2String(originalData["orderStartTime"])
|
||||||
}
|
// }
|
||||||
if orderPurchaseTime != "" {
|
// if orderPurchaseTime != "" {
|
||||||
orderDetail := &model.GoodsOrderOriginal{
|
// orderDetail := &model.GoodsOrderOriginal{
|
||||||
VendorOrderID: jdOrder.VendorOrderID,
|
// VendorOrderID: jdOrder.VendorOrderID,
|
||||||
VendorID: model.VendorIDJD,
|
// VendorID: model.VendorIDJD,
|
||||||
AccountNo: orgCode,
|
// AccountNo: orgCode,
|
||||||
OrderCreatedAt: utils.Str2Time(orderPurchaseTime),
|
// OrderCreatedAt: utils.Str2Time(orderPurchaseTime),
|
||||||
OriginalData: string(utils.MustMarshal(originalData)),
|
// OriginalData: string(utils.MustMarshal(originalData)),
|
||||||
}
|
// }
|
||||||
orderDetailList = append(orderDetailList, orderDetail)
|
// orderDetailList = append(orderDetailList, orderDetail)
|
||||||
} else {
|
// } else {
|
||||||
globals.SugarLogger.Debugf("TransferLegacyJdOrder abnormal2 order:%s", jdOrder.VendorOrderID)
|
// globals.SugarLogger.Debugf("TransferLegacyJdOrder abnormal2 order:%s", jdOrder.VendorOrderID)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if len(orderDetailList) > 0 {
|
// if len(orderDetailList) > 0 {
|
||||||
err = dao.CreateMultiEntities(db, orderDetailList)
|
// err = dao.CreateMultiEntities(db, orderDetailList)
|
||||||
}
|
// }
|
||||||
return nil, err
|
// return nil, err
|
||||||
}, jdOrderList)
|
// }, jdOrderList)
|
||||||
// rootTask.AddChild(task).Run()
|
// // rootTask.AddChild(task).Run()
|
||||||
task.Run()
|
// task.Run()
|
||||||
_, err = task.GetResult(0)
|
// _, err = task.GetResult(0)
|
||||||
} else {
|
// } else {
|
||||||
rootTask.Cancel()
|
// rootTask.Cancel()
|
||||||
}
|
// }
|
||||||
return nil, err
|
// return nil, err
|
||||||
}, math.MaxInt32)
|
// }, math.MaxInt32)
|
||||||
tasksch.ManageTask(rootTask).Run()
|
// tasksch.ManageTask(rootTask).Run()
|
||||||
if !isAsync {
|
// if !isAsync {
|
||||||
_, err = rootTask.GetResult(0)
|
// _, err = rootTask.GetResult(0)
|
||||||
} else {
|
// } else {
|
||||||
hint = rootTask.ID
|
// hint = rootTask.ID
|
||||||
}
|
// }
|
||||||
return hint, err
|
// return hint, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TransferLegacyElmOrder(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func TransferLegacyElmOrder(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
// sqlBatchCount := 1000
|
// sqlBatchCount := 1000
|
||||||
@@ -595,77 +591,77 @@ type GoodsOrderOriginalEx struct {
|
|||||||
OrderStatus int
|
OrderStatus int
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateOrderFromOriginal(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
// func CreateOrderFromOriginal(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
sqlBatchCount := 5000
|
// sqlBatchCount := 5000
|
||||||
rootTask := tasksch.NewSeqTask("CreateOrderFromOriginal", ctx,
|
// rootTask := tasksch.NewSeqTask("CreateOrderFromOriginal", ctx,
|
||||||
func(rootTask *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
// func(rootTask *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
sql := `
|
// sql := `
|
||||||
SELECT t1.*, t3.order_status
|
// SELECT t1.*, t3.order_status
|
||||||
FROM goods_order_original t1
|
// FROM goods_order_original t1
|
||||||
LEFT JOIN goods_order t2 ON t2.vendor_order_id = t1.vendor_order_id
|
// LEFT JOIN goods_order t2 ON t2.vendor_order_id = t1.vendor_order_id
|
||||||
LEFT JOIN jxorder t3 ON t3.order_id = t1.vendor_order_id
|
// LEFT JOIN jxorder t3 ON t3.order_id = t1.vendor_order_id
|
||||||
WHERE t2.id IS NULL
|
// WHERE t2.id IS NULL
|
||||||
LIMIT ?;
|
// LIMIT ?;
|
||||||
`
|
// `
|
||||||
db := dao.GetDB()
|
// db := dao.GetDB()
|
||||||
var orderList []*GoodsOrderOriginalEx
|
// var orderList []*GoodsOrderOriginalEx
|
||||||
if err = dao.GetRows(db, &orderList, sql, sqlBatchCount); err != nil {
|
// if err = dao.GetRows(db, &orderList, sql, sqlBatchCount); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
if len(orderList) > 0 {
|
// if len(orderList) > 0 {
|
||||||
task := tasksch.NewParallelTask("CreateOrderFromOriginal", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetParallelCount(1), ctx,
|
// task := tasksch.NewParallelTask("CreateOrderFromOriginal", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetParallelCount(1), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
orderOriginal := batchItemList[0].(*GoodsOrderOriginalEx)
|
// orderOriginal := batchItemList[0].(*GoodsOrderOriginalEx)
|
||||||
globals.SugarLogger.Debugf("CreateOrderFromOriginal processing orderID:%s", orderOriginal.VendorOrderID)
|
// globals.SugarLogger.Debugf("CreateOrderFromOriginal processing orderID:%s", orderOriginal.VendorOrderID)
|
||||||
if handler := partner.GetPurchasePlatformFromVendorID(orderOriginal.VendorID); handler != nil {
|
// if handler := partner.GetPurchasePlatformFromVendorID(orderOriginal.VendorID); handler != nil {
|
||||||
var detail map[string]interface{}
|
// var detail map[string]interface{}
|
||||||
if err = utils.UnmarshalUseNumber([]byte(strings.Replace(strings.Replace(orderOriginal.OriginalData, "\n", "", -1), "\r", "", -1)), &detail); err != nil {
|
// if err = utils.UnmarshalUseNumber([]byte(strings.Replace(strings.Replace(orderOriginal.OriginalData, "\n", "", -1), "\r", "", -1)), &detail); err != nil {
|
||||||
globals.SugarLogger.Debugf("CreateOrderFromOriginal abnormal orderID:%s, error:%v", orderOriginal.VendorOrderID, err)
|
// globals.SugarLogger.Debugf("CreateOrderFromOriginal abnormal orderID:%s, error:%v", orderOriginal.VendorOrderID, err)
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
order := handler.Map2Order(detail)
|
// order := handler.Map2Order(detail)
|
||||||
if order.Status < model.OrderStatusEndBegin {
|
// if order.Status < model.OrderStatusEndBegin {
|
||||||
if orderOriginal.OrderStatus == 3 {
|
// if orderOriginal.OrderStatus == 3 {
|
||||||
order.Status = model.OrderStatusFinished
|
// order.Status = model.OrderStatusFinished
|
||||||
} else if orderOriginal.OrderStatus == 7 {
|
// } else if orderOriginal.OrderStatus == 7 {
|
||||||
order.Status = model.OrderStatusCanceled
|
// order.Status = model.OrderStatusCanceled
|
||||||
} else {
|
// } else {
|
||||||
order2, err2 := handler.GetOrder(order.VendorOrderID)
|
// order2, err2 := handler.GetOrder(order.VendorOrderID)
|
||||||
if err = err2; err == nil {
|
// if err = err2; err == nil {
|
||||||
order.Status = order2.Status
|
// order.Status = order2.Status
|
||||||
} else {
|
// } else {
|
||||||
err = nil // ignore get status error
|
// err = nil // ignore get status error
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if err == nil {
|
// if err == nil {
|
||||||
if _, err = orderman.FixedOrderManager.SaveOrder(order, false, dao.GetDB()); err != nil {
|
// if _, err = orderman.FixedOrderManager.SaveOrder(order, false, dao.GetDB()); err != nil {
|
||||||
globals.SugarLogger.Debugf("CreateOrderFromOriginal abnormal orderID:%s, error:%v", orderOriginal.VendorOrderID, err)
|
// globals.SugarLogger.Debugf("CreateOrderFromOriginal abnormal orderID:%s, error:%v", orderOriginal.VendorOrderID, err)
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
globals.SugarLogger.Debugf("CreateOrderFromOriginal abnormal orderID:%s, error:%v", orderOriginal.VendorOrderID, err)
|
// globals.SugarLogger.Debugf("CreateOrderFromOriginal abnormal orderID:%s, error:%v", orderOriginal.VendorOrderID, err)
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
globals.SugarLogger.Debugf("CreateOrderFromOriginal abnormal orderID:%s", orderOriginal.VendorOrderID)
|
// globals.SugarLogger.Debugf("CreateOrderFromOriginal abnormal orderID:%s", orderOriginal.VendorOrderID)
|
||||||
}
|
// }
|
||||||
return nil, err
|
// return nil, err
|
||||||
}, orderList)
|
// }, orderList)
|
||||||
// rootTask.AddChild(task).Run()
|
// // rootTask.AddChild(task).Run()
|
||||||
task.Run()
|
// task.Run()
|
||||||
_, err = task.GetResult(0)
|
// _, err = task.GetResult(0)
|
||||||
} else {
|
// } else {
|
||||||
rootTask.Cancel()
|
// rootTask.Cancel()
|
||||||
}
|
// }
|
||||||
return nil, err
|
// return nil, err
|
||||||
}, math.MaxInt32)
|
// }, math.MaxInt32)
|
||||||
tasksch.ManageTask(rootTask).Run()
|
// tasksch.ManageTask(rootTask).Run()
|
||||||
if !isAsync {
|
// if !isAsync {
|
||||||
_, err = rootTask.GetResult(0)
|
// _, err = rootTask.GetResult(0)
|
||||||
} else {
|
// } else {
|
||||||
hint = rootTask.ID
|
// hint = rootTask.ID
|
||||||
}
|
// }
|
||||||
return hint, err
|
// return hint, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TransformJdSpu2Sku(ctx *jxcontext.Context, skuNameIDs []int, count int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func TransformJdSpu2Sku(ctx *jxcontext.Context, skuNameIDs []int, count int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
package dao
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PromotionStoreSku struct {
|
|
||||||
model.PromotionSku
|
|
||||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func GenSkuPriceMapKey(storeID, skuID int) (key int64) {
|
|
||||||
return int64(storeID)*1000000 + int64(skuID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetPromotionSkuPriceMap(db *DaoDB, vendorID int, storeIDs, skuIDs []int, fromTime, toTime time.Time) (skuPriceMap map[int64]*PromotionStoreSku, err error) {
|
|
||||||
sql := `
|
|
||||||
SELECT t2.store_id, t3.*
|
|
||||||
FROM promotion t1
|
|
||||||
JOIN promotion_store t2 ON t2.promotion_id = t1.id
|
|
||||||
JOIN promotion_sku t3 ON t3.promotion_id = t1.id
|
|
||||||
WHERE t1.deleted_at = ? AND t1.vendor_id = ? AND NOT (t1.begin_at > ? OR t1.end_at < ?) AND (t1.status = ? OR t1.status = ?)`
|
|
||||||
sqlParams := []interface{}{
|
|
||||||
utils.DefaultTimeValue,
|
|
||||||
vendorID,
|
|
||||||
toTime,
|
|
||||||
fromTime,
|
|
||||||
model.PromotionStatusRemoteCreated,
|
|
||||||
}
|
|
||||||
if vendorID == model.VendorIDJX {
|
|
||||||
sqlParams = append(sqlParams, model.PromotionStatusLocalCreated)
|
|
||||||
} else {
|
|
||||||
sqlParams = append(sqlParams, model.PromotionStatusRemoteCreated)
|
|
||||||
}
|
|
||||||
if len(storeIDs) > 0 {
|
|
||||||
sql += " AND t2.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
|
||||||
sqlParams = append(sqlParams, storeIDs)
|
|
||||||
}
|
|
||||||
if len(skuIDs) > 0 {
|
|
||||||
sql += " AND t3.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
|
||||||
sqlParams = append(sqlParams, skuIDs)
|
|
||||||
}
|
|
||||||
sql += " ORDER BY t2.store_id, t3.sku_id, t3.price"
|
|
||||||
var skuPriceList []*PromotionStoreSku
|
|
||||||
if err = GetRows(db, &skuPriceList, sql, sqlParams...); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
skuPriceMap = make(map[int64]*PromotionStoreSku)
|
|
||||||
for _, v := range skuPriceList {
|
|
||||||
index := GenSkuPriceMapKey(v.StoreID, v.SkuID)
|
|
||||||
if true /*skuPriceMap[index] == nil || v.EarningPrice < skuPriceMap[index].EarningPrice*/ {
|
|
||||||
skuPriceMap[index] = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return skuPriceMap, err
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package legacymodel2
|
|
||||||
|
|
||||||
type Jdorder struct {
|
|
||||||
Id int `orm:"column(id);auto"`
|
|
||||||
Code string `orm:"column(code);size(2);null"`
|
|
||||||
Msg string `orm:"column(msg);size(100);null"`
|
|
||||||
Data string `orm:"column(data);null"`
|
|
||||||
Success int8 `orm:"column(success);null"`
|
|
||||||
Jdorderid int64 `orm:"column(jdorderid);null;unique"`
|
|
||||||
VendorOrderID string `orm:"column(vendor_order_id);size(48);unique" json:"vendorOrderID"`
|
|
||||||
Cityname string `orm:"column(cityname);size(20);null"`
|
|
||||||
Orderstatus int `orm:"column(orderstatus);null"`
|
|
||||||
Orderstatustime string `orm:"column(orderstatustime);size(50);null;index"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Jdorder) TableName() string {
|
|
||||||
return "jdorder"
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
PromotionStatusLocalCreated = 0 // 本地成功创建,
|
|
||||||
PromotionStatusRemoteFailed = 1 // 远程创建失败,
|
|
||||||
PromotionStatusRemoteCreated = 2 // 远程成功创建,
|
|
||||||
PromotionStatusCanceled = 3 // 被显示取消
|
|
||||||
PromotionStatusEnded = 4 // 已经超过活动时间,且被显示置为结束
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
PromotionCreateTypeByJX = 0
|
|
||||||
PromotionCreateTypeByVendor = 1
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
PromotionStatusName = map[int]string{
|
|
||||||
PromotionStatusLocalCreated: "未确认",
|
|
||||||
PromotionStatusRemoteFailed: "失败",
|
|
||||||
PromotionStatusRemoteCreated: "正常",
|
|
||||||
PromotionStatusCanceled: "取消",
|
|
||||||
PromotionStatusEnded: "结束",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
type Promotion struct {
|
|
||||||
ModelIDCULD
|
|
||||||
|
|
||||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
|
||||||
Name string `orm:"size(64)" json:"name"`
|
|
||||||
Advertising string `orm:"size(255)" json:"advertising"`
|
|
||||||
Type int `json:"type"`
|
|
||||||
Status int `json:"status"`
|
|
||||||
LimitDevice int8 `json:"limitDevice"`
|
|
||||||
LimitPin int8 `json:"limitPin"`
|
|
||||||
LimitDaily int8 `json:"limitDaily"`
|
|
||||||
LimitCount int `json:"limitCount"`
|
|
||||||
Source string `orm:"size(255)" json:"source"`
|
|
||||||
CreateType int8 `json:"createType"`
|
|
||||||
VendorPromotionID string `orm:"size(64);column(vendor_promotion_id);index" json:"vendorPromotionID"`
|
|
||||||
BeginAt time.Time `orm:"type(datetime);index" json:"beginAt"`
|
|
||||||
EndAt time.Time `orm:"type(datetime);index" json:"endAt"`
|
|
||||||
Remark string `orm:"type(text)" json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*Promotion) TableUnique() [][]string {
|
|
||||||
return [][]string{
|
|
||||||
[]string{"Name", "VendorID", "Type", "DeletedAt"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type PromotionStore struct {
|
|
||||||
ModelIDCULD
|
|
||||||
|
|
||||||
PromotionID int `orm:"column(promotion_id)" json:"promotionID"`
|
|
||||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*PromotionStore) TableUnique() [][]string {
|
|
||||||
return [][]string{
|
|
||||||
[]string{"PromotionID", "StoreID", "DeletedAt"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type PromotionSku struct {
|
|
||||||
ModelIDCULD
|
|
||||||
|
|
||||||
PromotionID int `orm:"column(promotion_id)" json:"promotionID"`
|
|
||||||
SkuID int `orm:"column(sku_id)" json:"skuID"`
|
|
||||||
PriceType int `json:"priceType"`
|
|
||||||
Price int `json:"price"` // 分,活动价,这个不是单价
|
|
||||||
LimitSkuCount int `json:"limitSkuCount"`
|
|
||||||
IsLock int8 `json:"isLock"` // 是否锁定门店商品信息
|
|
||||||
|
|
||||||
EarningPrice int `json:"earningPrice"` // 活动商品设置,结算给门店老板的钱
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*PromotionSku) TableUnique() [][]string {
|
|
||||||
return [][]string{
|
|
||||||
[]string{"PromotionID", "SkuID", "DeletedAt"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/promotion"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
@@ -110,10 +109,9 @@ func (c *DjswController) Token() {
|
|||||||
func (c *DjswController) StockIsHave() {
|
func (c *DjswController) StockIsHave() {
|
||||||
// globals.SugarLogger.Info(string(c.Ctx.Input.RequestBody))
|
// globals.SugarLogger.Info(string(c.Ctx.Input.RequestBody))
|
||||||
if c.Ctx.Input.Method() == http.MethodPost {
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
obj, callbackResponse := api.JdAPI.GetStoreStockCallbackMsg(getUsefulRequest(c.Ctx))
|
_, callbackResponse := api.JdAPI.GetStoreStockCallbackMsg(getUsefulRequest(c.Ctx))
|
||||||
if callbackResponse == nil {
|
if callbackResponse == nil {
|
||||||
// globals.SugarLogger.Debugf("StockIsHave, obj:%s", utils.Format4Output(obj, false))
|
// globals.SugarLogger.Debugf("StockIsHave, obj:%s", utils.Format4Output(obj, false))
|
||||||
callbackResponse = promotion.OnStoreStockMsg(obj)
|
|
||||||
}
|
}
|
||||||
c.Data["json"] = c.transferResponse("StockIsHave", callbackResponse)
|
c.Data["json"] = c.transferResponse("StockIsHave", callbackResponse)
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
@@ -126,11 +124,7 @@ func (c *DjswController) SinglePromoteCreate() {
|
|||||||
if c.Ctx.Input.Method() == http.MethodPost {
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
obj, callbackResponse := api.JdAPI.GetOrderCallbackMsg(getUsefulRequest(c.Ctx))
|
obj, callbackResponse := api.JdAPI.GetOrderCallbackMsg(getUsefulRequest(c.Ctx))
|
||||||
if callbackResponse == nil {
|
if callbackResponse == nil {
|
||||||
if globals.EnableNewAct {
|
|
||||||
callbackResponse = jd.OnActMsg(obj)
|
callbackResponse = jd.OnActMsg(obj)
|
||||||
} else {
|
|
||||||
callbackResponse = promotion.OnNewPromotionMsg(obj)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
c.Data["json"] = c.transferResponse("SinglePromoteCreate", callbackResponse)
|
c.Data["json"] = c.transferResponse("SinglePromoteCreate", callbackResponse)
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
|
|||||||
@@ -1,214 +0,0 @@
|
|||||||
package controllers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/promotion"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PromotionController struct {
|
|
||||||
beego.Controller
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 创建活动
|
|
||||||
// @Description 创建活动
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param vendorID formData int true "厂商ID,当前只支持,京东:0,京西(用于记录活动信息):99"
|
|
||||||
// @Param name formData string true "活动名,必须唯一(所以名子上最好带上日期)"
|
|
||||||
// @Param beginAt formData string true "开始日期"
|
|
||||||
// @Param endAt formData string true "结束日期"
|
|
||||||
// @Param type formData int true "活动类型,3:直降,4:限时抢购"
|
|
||||||
// @Param storeIDs formData string true "json数据,storeID列表[1,2,3]"
|
|
||||||
// @Param skuPrices formData string true "json数据,价格信息列表"
|
|
||||||
// @Param limitDaily formData int false "是否按日0-不限,1-限购 (限时抢需填)"
|
|
||||||
// @Param limitDevice formData int false "是否设备限购0-不限,1-限购"
|
|
||||||
// @Param limitPin formData int false "是否账号限购0-不限,1-限购"
|
|
||||||
// @Param limitCount formData int false "限购件数 0-不限,如账号限购、设备限购有一个为1,则限购件数必须大于0的整数"
|
|
||||||
// @Param isAsync formData bool false "是否异步,缺省否(暂时只支持同步)"
|
|
||||||
// @Param isContinueWhenError formData bool false "单个广告失败是否继续,缺省false"
|
|
||||||
// @Param advertising formData string false "广告语"
|
|
||||||
// @Param vendorPromotionID formData string false "厂商活动id,设置此字段表示关联京东活动,并不会真正去创建"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /CreatePromotion [post]
|
|
||||||
func (c *PromotionController) CreatePromotion() {
|
|
||||||
c.callCreatePromotion(func(params *tPromotionCreatePromotionParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
if globals.EnableNewAct {
|
|
||||||
if true { //params.VendorID == model.VendorIDJD {
|
|
||||||
return retVal, "", fmt.Errorf("请使用新版活动管理创建活动")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
beginAt, err := utils.TryStr2Time(params.BeginAt)
|
|
||||||
if err != nil {
|
|
||||||
return retVal, "", err
|
|
||||||
}
|
|
||||||
endAt, err := utils.TryStr2Time(params.EndAt)
|
|
||||||
if err != nil {
|
|
||||||
return retVal, "", err
|
|
||||||
}
|
|
||||||
promotionParams := &promotion.PromotionParams{
|
|
||||||
Name: params.Name,
|
|
||||||
BeginAt: beginAt,
|
|
||||||
EndAt: endAt,
|
|
||||||
Type: params.Type,
|
|
||||||
Advertising: params.Advertising,
|
|
||||||
}
|
|
||||||
if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &promotionParams.StoreIDs); err == nil {
|
|
||||||
if err = utils.UnmarshalUseNumber([]byte(params.SkuPrices), &promotionParams.SkuPrices); err == nil {
|
|
||||||
retVal, err = promotion.CreateJdPromotion(params.Ctx, params.VendorID, false, params.IsAsync, params.IsContinueWhenError, params.VendorPromotionID, promotionParams, params.MapData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
|
|
||||||
// // @Title 发送文件给门店
|
|
||||||
// // @Description 发送文件给门店,调用GET方法得到浏览器端参考的上传HTML实现,userfiles
|
|
||||||
// // @Param type formData int true "活动类型,3:直降,4:限时抢购"
|
|
||||||
// // @Param isAsync formData bool false "是否异常,缺省否(暂时只支持同步)"
|
|
||||||
// // @Success 200 {object} controllers.CallResult
|
|
||||||
// // @Failure 200 {object} controllers.CallResult
|
|
||||||
// // @router /CreatePromotionByExcel [post,get]
|
|
||||||
// func (c *PromotionController) CreatePromotionByExcel() {
|
|
||||||
// if c.Ctx.Input.IsGet() {
|
|
||||||
// w := c.Ctx.ResponseWriter
|
|
||||||
// // 上传页面
|
|
||||||
// w.Header().Add("Content-Type", "text/html")
|
|
||||||
// w.WriteHeader(200)
|
|
||||||
// html := `
|
|
||||||
// <form enctype="multipart/form-data" action="/v2/promotion/CreatePromotionByExcel" method="POST">
|
|
||||||
// Send this file: <input name="userfile" accept="*.xlsx" type="file" />
|
|
||||||
// <input type="text" name="type" />
|
|
||||||
// <input type="text" name="isAsync" />
|
|
||||||
// <input type="submit" value="Send File" />
|
|
||||||
// </form>
|
|
||||||
// `
|
|
||||||
// io.WriteString(w, html)
|
|
||||||
// } else if c.Ctx.Input.IsPost() {
|
|
||||||
// c.callCreatePromotionByExcel(func(params *tPromotionCreatePromotionByExcelParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
// r := c.Ctx.Request
|
|
||||||
// files := r.MultipartForm.File["userfile"]
|
|
||||||
// retVal, err = promotion.CreatePromotionByExcel(params.Ctx, params.IsAsync, params.Type, files[0], "userName") //params.Ctx.GetUserName())
|
|
||||||
// return retVal, "", err
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Title 根据历史订单信息发送活动消息
|
|
||||||
// @Description 根据历史订单信息发送活动消息
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param advertising formData string true "广告语"
|
|
||||||
// @Param days formData int false "多少天以内订单数据中的用户(-1:全部,0:60天,缺省0)"
|
|
||||||
// @Param isAsync formData bool false "是否异步,缺省否"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /SendAdvertingByGoodsOrder [post]
|
|
||||||
func (c *PromotionController) SendAdvertingByGoodsOrder() {
|
|
||||||
c.callSendAdvertingByGoodsOrder(func(params *tPromotionSendAdvertingByGoodsOrderParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
retVal, err = promotion.SendAdvertingByGoodsOrder(params.Ctx, params.Advertising, params.Days, params.IsAsync, params.Ctx.GetUserName())
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 查询活动
|
|
||||||
// @Description 查询活动
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param keyword query string false "关键字"
|
|
||||||
// @Param vendorID query int false "厂商ID,当前只支持京东:0 "
|
|
||||||
// @Param promotionID query int false "活动id"
|
|
||||||
// @Param vendorPromotionID query string false "厂商活动id"
|
|
||||||
// @Param days query int false "多少天内创建的,缺省7天"
|
|
||||||
// @Param name query string false "活动名,不完全匹配"
|
|
||||||
// @Param cityCode query int false "活动门店所属城市code"
|
|
||||||
// @Param beginAt query string false "开始日期,包括"
|
|
||||||
// @Param endAt query string false "结束日期,包括"
|
|
||||||
// @Param type query int false "活动类型,3:直降,4:限时抢购"
|
|
||||||
// @Param storeID query int false "包含门店"
|
|
||||||
// @Param skuID query int false "包含sku"
|
|
||||||
// @Param offset query int false "活动列表起始序号(以0开始,缺省为0)"
|
|
||||||
// @Param pageSize query int false "活动列表页大小(缺省为50,-1表示全部)"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /GetPromotions [get]
|
|
||||||
func (c *PromotionController) GetPromotions() {
|
|
||||||
c.callGetPromotions(func(params *tPromotionGetPromotionsParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
retVal, err = promotion.GetJdPromotions(params.Ctx, params.Keyword, params.MapData, params.Offset, params.PageSize)
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 取消活动
|
|
||||||
// @Description 取消活动
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param promotionID formData int true "活动id"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /CancelPromotion [put]
|
|
||||||
func (c *PromotionController) CancelPromotion() {
|
|
||||||
c.callCancelPromotion(func(params *tPromotionCancelPromotionParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
err = promotion.CancelJdPromotion(params.Ctx, params.PromotionID)
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 锁定解锁活动SKU
|
|
||||||
// @Description 锁定解锁活动SKU
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param promotionID formData int true "活动id"
|
|
||||||
// @Param isLock formData int true "锁定标志,0:不锁定,1:锁定"
|
|
||||||
// @Param skuIDs formData string false "缺省全部"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /LockPromotionSkus [put]
|
|
||||||
func (c *PromotionController) LockPromotionSkus() {
|
|
||||||
c.callLockPromotionSkus(func(params *tPromotionLockPromotionSkusParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
var skuIDs []int
|
|
||||||
if params.SkuIDs != "" {
|
|
||||||
if err = utils.UnmarshalUseNumber([]byte(params.SkuIDs), &skuIDs); err != nil {
|
|
||||||
return retVal, "", err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
retVal, err = promotion.LockPromotionSkus(params.Ctx, params.PromotionID, params.IsLock, skuIDs)
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 修改活动商品门店结算价
|
|
||||||
// @Description 修改活动商品门店结算价
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param promotionID formData int true "活动id"
|
|
||||||
// @Param skuPrices formData string true "json数据,价格信息列表(只有EarningPrice有效)"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /UpdatePromotionSkusEarningPrice [put]
|
|
||||||
func (c *PromotionController) UpdatePromotionSkusEarningPrice() {
|
|
||||||
c.callUpdatePromotionSkusEarningPrice(func(params *tPromotionUpdatePromotionSkusEarningPriceParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
var skuPriceList []*promotion.SkuPrice
|
|
||||||
if err = jxutils.Strings2Objs(params.SkuPrices, &skuPriceList); err == nil {
|
|
||||||
retVal, err = promotion.UpdatePromotionSkusEarningPrice(params.Ctx, params.PromotionID, skuPriceList)
|
|
||||||
}
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 从远程更新活动状态
|
|
||||||
// @Description 从远程更新活动状态
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param promotionID formData int true "活动id"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /RefreshPromotionStatus [put]
|
|
||||||
func (c *PromotionController) RefreshPromotionStatus() {
|
|
||||||
c.callRefreshPromotionStatus(func(params *tPromotionRefreshPromotionStatusParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
err = promotion.UpdatePromotionStatusFromRemote(params.Ctx, params.PromotionID)
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,8 @@ package controllers
|
|||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/tempop"
|
"git.rosy.net.cn/jx-callback/business/jxstore/tempop"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
@@ -10,8 +12,6 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TempOpController struct {
|
type TempOpController struct {
|
||||||
@@ -54,35 +54,35 @@ func (c *InitDataController) Change2JDSPU4Store() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title 将遗留JD订单合并
|
// // @Title 将遗留JD订单合并
|
||||||
// @Description 将遗留JD订单合并
|
// // @Description 将遗留JD订单合并
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Param isAsync formData bool false "是否异步操作"
|
// // @Param isAsync formData bool false "是否异步操作"
|
||||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
// // @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @router /TransferLegacyJdOrder [post]
|
// // @router /TransferLegacyJdOrder [post]
|
||||||
func (c *InitDataController) TransferLegacyJdOrder() {
|
// func (c *InitDataController) TransferLegacyJdOrder() {
|
||||||
c.callTransferLegacyJdOrder(func(params *tInitdataTransferLegacyJdOrderParams) (retVal interface{}, errCode string, err error) {
|
// c.callTransferLegacyJdOrder(func(params *tInitdataTransferLegacyJdOrderParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = tempop.TransferLegacyJdOrder(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
// retVal, err = tempop.TransferLegacyJdOrder(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||||||
return retVal, "", err
|
// return retVal, "", err
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @Title 将goods_order中缺失的订单从goods_order_original中恢复
|
// // @Title 将goods_order中缺失的订单从goods_order_original中恢复
|
||||||
// @Description 将goods_order中缺失的订单从goods_order_original中恢复
|
// // @Description 将goods_order中缺失的订单从goods_order_original中恢复
|
||||||
// @Param token header string true "认证token"
|
// // @Param token header string true "认证token"
|
||||||
// @Param isAsync formData bool false "是否异步操作"
|
// // @Param isAsync formData bool false "是否异步操作"
|
||||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
// // @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// // @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// // @Failure 200 {object} controllers.CallResult
|
||||||
// @router /CreateOrderFromOriginal [post]
|
// // @router /CreateOrderFromOriginal [post]
|
||||||
func (c *InitDataController) CreateOrderFromOriginal() {
|
// func (c *InitDataController) CreateOrderFromOriginal() {
|
||||||
c.callCreateOrderFromOriginal(func(params *tInitdataCreateOrderFromOriginalParams) (retVal interface{}, errCode string, err error) {
|
// c.callCreateOrderFromOriginal(func(params *tInitdataCreateOrderFromOriginalParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = tempop.CreateOrderFromOriginal(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
// retVal, err = tempop.CreateOrderFromOriginal(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||||||
return retVal, "", err
|
// return retVal, "", err
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @Title 拉取京东订单补齐本地
|
// @Title 拉取京东订单补齐本地
|
||||||
// @Description 拉取京东订单补齐本地
|
// @Description 拉取京东订单补齐本地
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ func Init() {
|
|||||||
orm.RegisterModel(&model.SkuCategory{})
|
orm.RegisterModel(&model.SkuCategory{})
|
||||||
// orm.RegisterModel(&model.DurableTask{}, &model.DurableTaskItem{})
|
// orm.RegisterModel(&model.DurableTask{}, &model.DurableTaskItem{})
|
||||||
|
|
||||||
orm.RegisterModel(&model.Promotion{}, &model.PromotionStore{}, &model.PromotionSku{})
|
|
||||||
orm.RegisterModel(&model.AuthBind{}, &model.User{})
|
orm.RegisterModel(&model.AuthBind{}, &model.User{})
|
||||||
|
|
||||||
orm.RegisterModel(&model.PageShop{})
|
orm.RegisterModel(&model.PageShop{})
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ var (
|
|||||||
|
|
||||||
StoreName string
|
StoreName string
|
||||||
|
|
||||||
EnableNewAct bool
|
|
||||||
EnableWXAuth2 bool
|
EnableWXAuth2 bool
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -88,7 +87,6 @@ func Init() {
|
|||||||
|
|
||||||
StoreName = beego.AppConfig.DefaultString("storeName", "京西菜市")
|
StoreName = beego.AppConfig.DefaultString("storeName", "京西菜市")
|
||||||
|
|
||||||
EnableNewAct = true
|
|
||||||
EnableWXAuth2 = beego.BConfig.RunMode == "beta"
|
EnableWXAuth2 = beego.BConfig.RunMode == "beta"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -12,7 +12,6 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch" // 导入缺省订单调度器
|
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch" // 导入缺省订单调度器
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/promotion"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasks"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasks"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
@@ -57,7 +56,6 @@ func Init() {
|
|||||||
buildTime = buildTime.Local()
|
buildTime = buildTime.Local()
|
||||||
}
|
}
|
||||||
cms.InitServiceInfo(Version, buildTime, GitCommit)
|
cms.InitServiceInfo(Version, buildTime, GitCommit)
|
||||||
promotion.Init()
|
|
||||||
|
|
||||||
if globals.IsProductEnv() {
|
if globals.IsProductEnv() {
|
||||||
ebai.CurPurchaseHandler.StartRefreshComment()
|
ebai.CurPurchaseHandler.StartRefreshComment()
|
||||||
|
|||||||
@@ -493,15 +493,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "CreateOrderFromOriginal",
|
|
||||||
Router: `/CreateOrderFromOriginal`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "DeleteWrongSpu",
|
Method: "DeleteWrongSpu",
|
||||||
@@ -565,15 +556,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "TransferLegacyJdOrder",
|
|
||||||
Router: `/TransferLegacyJdOrder`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:InitDataController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "TransformJdSpu2Sku",
|
Method: "TransformJdSpu2Sku",
|
||||||
@@ -988,69 +970,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "CancelPromotion",
|
|
||||||
Router: `/CancelPromotion`,
|
|
||||||
AllowHTTPMethods: []string{"put"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "CreatePromotion",
|
|
||||||
Router: `/CreatePromotion`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "GetPromotions",
|
|
||||||
Router: `/GetPromotions`,
|
|
||||||
AllowHTTPMethods: []string{"get"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "LockPromotionSkus",
|
|
||||||
Router: `/LockPromotionSkus`,
|
|
||||||
AllowHTTPMethods: []string{"put"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "RefreshPromotionStatus",
|
|
||||||
Router: `/RefreshPromotionStatus`,
|
|
||||||
AllowHTTPMethods: []string{"put"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "SendAdvertingByGoodsOrder",
|
|
||||||
Router: `/SendAdvertingByGoodsOrder`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "UpdatePromotionSkusEarningPrice",
|
|
||||||
Router: `/UpdatePromotionSkusEarningPrice`,
|
|
||||||
AllowHTTPMethods: []string{"put"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "AddCategory",
|
Method: "AddCategory",
|
||||||
|
|||||||
@@ -61,11 +61,6 @@ func init() {
|
|||||||
&controllers.FinancialController{},
|
&controllers.FinancialController{},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
beego.NSNamespace("/promotion",
|
|
||||||
beego.NSInclude(
|
|
||||||
&controllers.PromotionController{},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
beego.NSNamespace("/sync",
|
beego.NSNamespace("/sync",
|
||||||
beego.NSInclude(
|
beego.NSInclude(
|
||||||
&controllers.SyncController{},
|
&controllers.SyncController{},
|
||||||
|
|||||||
Reference in New Issue
Block a user