292 lines
14 KiB
Go
292 lines
14 KiB
Go
package controllers
|
||
|
||
import (
|
||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||
"git.rosy.net.cn/baseapi/utils"
|
||
"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/tasksch"
|
||
"git.rosy.net.cn/jx-callback/business/model"
|
||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||
"git.rosy.net.cn/jx-callback/globals/api"
|
||
"github.com/astaxie/beego"
|
||
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
||
)
|
||
|
||
type TempOpController struct {
|
||
beego.Controller
|
||
}
|
||
|
||
// @Title 将为份的商品在京东转成SPU
|
||
// @Description 将为份的商品在京东转成SPU
|
||
// @Param token header string true "认证token"
|
||
// @Param count formData int false "转换的数量,缺省0表示全部"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /Convert2JDSPU [post]
|
||
func (c *InitDataController) Convert2JDSPU() {
|
||
c.callConvert2JDSPU(func(params *tInitdataConvert2JDSPUParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = tempop.Convert2JDSPU(params.Ctx, params.Count, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 将京东商店为份的SPU转换
|
||
// @Description 将京东商店为份的SPU转换
|
||
// @Param token header string true "认证token"
|
||
// @Param step formData int true "门店列表"
|
||
// @Param storeIDs formData string false "门店列表"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /Change2JDSPU4Store [post]
|
||
func (c *InitDataController) Change2JDSPU4Store() {
|
||
c.callChange2JDSPU4Store(func(params *tInitdataChange2JDSPU4StoreParams) (retVal interface{}, errCode string, err error) {
|
||
var storeIDs []int
|
||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil {
|
||
retVal, err = tempop.Change2JDSPU4Store(params.Ctx, storeIDs, params.Step, params.IsAsync, params.IsContinueWhenError)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 将遗留JD订单合并
|
||
// @Description 将遗留JD订单合并
|
||
// @Param token header string true "认证token"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /TransferLegacyJdOrder [post]
|
||
func (c *InitDataController) TransferLegacyJdOrder() {
|
||
c.callTransferLegacyJdOrder(func(params *tInitdataTransferLegacyJdOrderParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = tempop.TransferLegacyJdOrder(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 将goods_order中缺失的订单从goods_order_original中恢复
|
||
// @Description 将goods_order中缺失的订单从goods_order_original中恢复
|
||
// @Param token header string true "认证token"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /CreateOrderFromOriginal [post]
|
||
func (c *InitDataController) CreateOrderFromOriginal() {
|
||
c.callCreateOrderFromOriginal(func(params *tInitdataCreateOrderFromOriginalParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = tempop.CreateOrderFromOriginal(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 拉取京东订单补齐本地
|
||
// @Description 拉取京东订单补齐本地
|
||
// @Param token header string true "认证token"
|
||
// @Param fromTime formData string true "开始时间"
|
||
// @Param toTime formData string true "结束时间"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /PullJdOrder [post]
|
||
func (c *InitDataController) PullJdOrder() {
|
||
c.callPullJdOrder(func(params *tInitdataPullJdOrderParams) (retVal interface{}, errCode string, err error) {
|
||
timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime)
|
||
if err != nil {
|
||
return retVal, "", err
|
||
}
|
||
retVal, err = tempop.PullJdOrder(params.Ctx, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 删除错误创建的SPU
|
||
// @Description 删除错误创建的SPU
|
||
// @Param token header string true "认证token"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /DeleteWrongSpu [delete]
|
||
func (c *InitDataController) DeleteWrongSpu() {
|
||
c.callDeleteWrongSpu(func(params *tInitdataDeleteWrongSpuParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = tempop.DeleteWrongSpu(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 将京东的SPU转为非SPU,保持转后的SKU商家自编号不变
|
||
// @Description 将京东的SPU转为非SPU,保持转后的SKU商家自编号不变
|
||
// @Param token header string true "认证token"
|
||
// @Param nameIDs formData string false "需要转换的nameID列表,缺省空表示全部"
|
||
// @Param count formData int false "转换的数量,缺省0表示全部(按ID排序)"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /TransformJdSpu2Sku [post]
|
||
func (c *InitDataController) TransformJdSpu2Sku() {
|
||
c.callTransformJdSpu2Sku(func(params *tInitdataTransformJdSpu2SkuParams) (retVal interface{}, errCode string, err error) {
|
||
var nameIDs []int
|
||
if err = jxutils.Strings2Objs(params.NameIDs, &nameIDs); err != nil {
|
||
return retVal, "", err
|
||
}
|
||
retVal, err = tempop.TransformJdSpu2Sku(params.Ctx, nameIDs, params.Count, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 重新处理京东差评
|
||
// @Description 重新处理京东差评
|
||
// @Param token header string true "认证token"
|
||
// @Param isForce formData bool false "是否强制处理"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /ReProcessJdBadComment [post]
|
||
func (c *InitDataController) ReProcessJdBadComment() {
|
||
c.callReProcessJdBadComment(func(params *tInitdataReProcessJdBadCommentParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = tempop.ReProcessJdBadComment(params.Ctx, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 刷新
|
||
// @Description 重新处理京东差评
|
||
// @Param token header string true "认证token"
|
||
// @Param fromTime formData string false "起始时间"
|
||
// @Param toTime formData string false "结束时间"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /RefreshEbaiBadComment [post]
|
||
func (c *InitDataController) RefreshEbaiBadComment() {
|
||
c.callRefreshEbaiBadComment(func(params *tInitdataRefreshEbaiBadCommentParams) (retVal interface{}, errCode string, err error) {
|
||
if timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime); err == nil {
|
||
retVal, err = tempop.RefreshEbaiBadComment(params.Ctx, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError)
|
||
}
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 测试打印
|
||
// @Description 测试打印
|
||
// @Param token header string true "认证token"
|
||
// @Param vendorID formData int true "打印机厂商ID"
|
||
// @Param id1 formData string true "id1"
|
||
// @Param id2 formData string false "id2"
|
||
// @Param msgTitle formData string false "消息标题"
|
||
// @Param msgContent formData string true "消息内容"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /PrintMsg [post]
|
||
func (c *TempOpController) PrintMsg() {
|
||
c.callPrintMsg(func(params *tTempopPrintMsgParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = tempop.PrintMsg(params.Ctx, params.VendorID, params.Id1, params.Id2, params.MsgTitle, params.MsgContent)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 刷新微信备注
|
||
// @Description 刷新微信备注
|
||
// @Param token header string true "认证token"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /UpdateAllWeiXinRemark [post]
|
||
func (c *TempOpController) UpdateAllWeiXinRemark() {
|
||
c.callUpdateAllWeiXinRemark(func(params *tTempopUpdateAllWeiXinRemarkParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = tempop.UpdateAllWeiXinRemark(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title XXXX
|
||
// @Description XXXX
|
||
// @Param token header string true "认证token"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /RetrieveEbaiShopLicence [post]
|
||
func (c *TempOpController) RetrieveEbaiShopLicence() {
|
||
c.callRetrieveEbaiShopLicence(func(params *tTempopRetrieveEbaiShopLicenceParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = tempop.RetrieveEbaiShopLicence(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 刷新美团配送价格
|
||
// @Description 刷新美团配送价格
|
||
// @Param token header string true "认证token"
|
||
// @Param isAsync formData bool false "是否异步操作"
|
||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /RefreshMtpsWaybillFee [post]
|
||
func (c *TempOpController) RefreshMtpsWaybillFee() {
|
||
c.callRefreshMtpsWaybillFee(func(params *tTempopRefreshMtpsWaybillFeeParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = tempop.RefreshMtpsWaybillFee(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 查询三方运单费用信息
|
||
// @Description 查询三方运单费用信息
|
||
// @Param token header string true "认证token"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /TestIt [get]
|
||
func (c *TempOpController) TestIt() {
|
||
c.callTestIt(func(params *tTempopTestItParams) (retVal interface{}, errCode string, err error) {
|
||
// retVal, err = cms.OpenRemoteStoreByJxStatus(params.Ctx, nil, nil, false, true, true)
|
||
// shopList, err := api.EbaiAPI.ShopList(ebaiapi.SysStatusAll)
|
||
shopList, err := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDEBAI}, nil, model.StoreStatusAll, model.StoreIsSyncYes, "")
|
||
task := tasksch.NewParallelTask("TestIt", nil, params.Ctx,
|
||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||
// shopID := batchItemList[0].(*ebaiapi.ShopInfo).ShopID
|
||
shopID := utils.Int2Str(batchItemList[0].(*model.StoreMap).StoreID)
|
||
skuInfo, err := api.EbaiAPI.SkuList(shopID, &ebaiapi.SkuListParams{})
|
||
if err == nil && skuInfo.Total > 500 {
|
||
errSkuCount := 0
|
||
for _, sku := range skuInfo.List {
|
||
if sku.CustomCatIDs == "" {
|
||
errSkuCount++
|
||
}
|
||
}
|
||
if errSkuCount > len(skuInfo.List)/3 {
|
||
retVal = []string{shopID}
|
||
}
|
||
}
|
||
return retVal, err
|
||
}, shopList)
|
||
task.Run()
|
||
retVal, err = task.GetResult(0)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 开启或结束所有平台商店的额外时间
|
||
// @Description 开启或结束所有平台商店的额外时间,并且修改所有商品库存为0或99999(开启:0 , 结束:99999)
|
||
// @Param token header string true "认证token"
|
||
// @Param startOrEndStore query bool true "开启或结束"
|
||
// @Param startTime query int false "开始营业时间(格式:930代表早上9点30分)"
|
||
// @Param endTime query int false "结束营业时间"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /TestStartOrEndOpStore [get]
|
||
func (c *TempOpController) TestStartOrEndOpStore() {
|
||
c.callTestStartOrEndOpStore(func(params *tTempopTestStartOrEndOpStoreParams) (retVal interface{}, errCode string, err error) {
|
||
misc.SetStoreOptime(int16(params.StartTime), int16(params.EndTime))
|
||
misc.StartOrEndOpStore(params.StartOrEndStore)
|
||
return retVal, "", err
|
||
})
|
||
}
|