Accept Merge Request #172: (su -> mark)
Merge Request: 复制门店商品删除未关注 Created By: @苏尹岚 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/172
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
package act
|
package act
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
"mime/multipart"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
@@ -1300,3 +1303,42 @@ func SyncSpecialAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateActByExcel(ctx *jxcontext.Context, files []*multipart.FileHeader, vendorID int, vendorOrgCode string, mixType int, isFocus, isSync, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
|
if len(files) == 0 {
|
||||||
|
return "", errors.New("没有文件上传!")
|
||||||
|
}
|
||||||
|
fileHeader := files[0]
|
||||||
|
file, err := fileHeader.Open()
|
||||||
|
hint, err = CreateActByExcelBin(ctx, file, vendorID, vendorOrgCode, mixType, isFocus, isSync, isAsync, isContinueWhenError)
|
||||||
|
file.Close()
|
||||||
|
return hint, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateActByExcelBin(ctx *jxcontext.Context, reader io.Reader, vendorID int, vendorOrgCode string, mixType int, isFocus, isSync, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
|
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
|
switch step {
|
||||||
|
case 0:
|
||||||
|
//读取excel文件
|
||||||
|
// xlsx, err := excelize.OpenReader(reader)
|
||||||
|
// if err != nil {
|
||||||
|
// return "", err
|
||||||
|
// }
|
||||||
|
// rows, _ := xlsx.GetRows(xlsx.GetSheetName(1))
|
||||||
|
// for rowNum, row := range rows {
|
||||||
|
|
||||||
|
// }
|
||||||
|
case 1:
|
||||||
|
}
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
taskSeq := tasksch.NewSeqTask2("根据Excel创建活动-序列任务", ctx, isContinueWhenError, taskSeqFunc, 5)
|
||||||
|
tasksch.HandleTask(taskSeq, nil, true).Run()
|
||||||
|
if !isAsync {
|
||||||
|
_, err = taskSeq.GetResult(0)
|
||||||
|
hint = "1"
|
||||||
|
} else {
|
||||||
|
hint = taskSeq.GetID()
|
||||||
|
}
|
||||||
|
return hint, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -1603,6 +1603,28 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
num += num2
|
num += num2
|
||||||
|
//上方insert会无视目标门店中未关注的商品(以前关注,后来取消关注),所以这里批量删一下
|
||||||
|
sql2 := `
|
||||||
|
DELETE FROM store_sku_bind a
|
||||||
|
WHERE a.store_id = ? AND a.sku_id IN (
|
||||||
|
SELECT b.sku_id FROM (
|
||||||
|
SELECT store_id,sku_id,count(*)
|
||||||
|
FROM store_sku_bind
|
||||||
|
WHERE store_id = ?
|
||||||
|
GROUP BY 1,2
|
||||||
|
HAVING count(*) > 1)b
|
||||||
|
)
|
||||||
|
AND a.deleted_at <> ?
|
||||||
|
`
|
||||||
|
sqlParams2 := []interface{}{
|
||||||
|
toStoreID, toStoreID, utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
_, err = dao.ExecuteSQL(db, sql2, sqlParams2)
|
||||||
|
if err != nil {
|
||||||
|
errList.AddErr(err)
|
||||||
|
dao.Rollback(db)
|
||||||
|
break
|
||||||
|
}
|
||||||
globals.SugarLogger.Debugf("CopyStoreSkus fromStoreID:%d, toStoreID:%d, trackInfo:%s num3:%d", fromStoreID, toStoreID, ctx.GetTrackInfo(), num2)
|
globals.SugarLogger.Debugf("CopyStoreSkus fromStoreID:%d, toStoreID:%d, trackInfo:%s num3:%d", fromStoreID, toStoreID, ctx.GetTrackInfo(), num2)
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
}
|
}
|
||||||
@@ -1611,6 +1633,7 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
|
|||||||
mapAfter["ToStoreIDs"] = toStoreIDs
|
mapAfter["ToStoreIDs"] = toStoreIDs
|
||||||
mapAfter["CopyMode"] = copyMode
|
mapAfter["CopyMode"] = copyMode
|
||||||
mapAfter["IsScale"] = isScale
|
mapAfter["IsScale"] = isScale
|
||||||
|
mapAfter["PricePercentage"] = pricePercentage
|
||||||
mapBefore := make(map[string]interface{})
|
mapBefore := make(map[string]interface{})
|
||||||
mapBefore["FromStoreID"] = fromStoreID
|
mapBefore["FromStoreID"] = fromStoreID
|
||||||
err = AddEventDetail(db, ctx, model.OperateCopyStoreSkus, 0, model.ThingTypeSku, fromStoreID, BuildDiffData(mapBefore), BuildDiffData(mapAfter))
|
err = AddEventDetail(db, ctx, model.OperateCopyStoreSkus, 0, model.ThingTypeSku, fromStoreID, BuildDiffData(mapBefore), BuildDiffData(mapAfter))
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package event
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ var (
|
|||||||
"CreateQrOrBarCode": "CreateQrOrBarCode",
|
"CreateQrOrBarCode": "CreateQrOrBarCode",
|
||||||
"StatisticsReportForOrders": "StatisticsReportForOrders",
|
"StatisticsReportForOrders": "StatisticsReportForOrders",
|
||||||
}
|
}
|
||||||
|
regexpToken = regexp.MustCompile(`,"token":".*"`)
|
||||||
)
|
)
|
||||||
|
|
||||||
type CheckCookie struct {
|
type CheckCookie struct {
|
||||||
@@ -46,7 +48,9 @@ func AddOperateEvent(ctx *jxcontext.Context, accessUUID, jsonData string, errCod
|
|||||||
if accessUUID != "" {
|
if accessUUID != "" {
|
||||||
accessUUID = accessUUID[0:strings.Index(accessUUID, ",")]
|
accessUUID = accessUUID[0:strings.Index(accessUUID, ",")]
|
||||||
}
|
}
|
||||||
|
jsonData = strings.ReplaceAll(jsonData, regexpToken.FindString(jsonData), "")
|
||||||
jsonData = utils.LimitUTF8StringLen(jsonData, 3200)
|
jsonData = utils.LimitUTF8StringLen(jsonData, 3200)
|
||||||
|
errMsg = utils.LimitUTF8StringLen(errMsg, 3200)
|
||||||
event := &model.OperateEvent{
|
event := &model.OperateEvent{
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
LastOperator: ctx.GetUserName(),
|
LastOperator: ctx.GetUserName(),
|
||||||
|
|||||||
@@ -330,3 +330,25 @@ func (c *ActController) ForceUpdateVendorPrice() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 通过Excel创建活动
|
||||||
|
// @Description 通过Excel创建活动
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param vendorID formData int true "厂商ID,当前只支持,京东:0,京西(用于记录活动信息):99"
|
||||||
|
// @Param vendorOrgCode formData string false "厂商内组织代码"
|
||||||
|
// @Param mixType formData int true "数据处理方式:1(一行一条数据)2(门店与商品相乘)"
|
||||||
|
// @Param isFocus formData bool true "是否批量关注可售所有商品,默认是"
|
||||||
|
// @Param isSync formData bool true "是否同步所有未同步的商品,默认是"
|
||||||
|
// @Param isAsync formData bool false "是否异步"
|
||||||
|
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /CreateActByExcel [post]
|
||||||
|
func (c *ActController) CreateActByExcel() {
|
||||||
|
c.callCreateActByExcel(func(params *tActCreateActByExcelParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
r := c.Ctx.Request
|
||||||
|
files := r.MultipartForm.File["userfiles"]
|
||||||
|
retVal, err = act.CreateActByExcel(params.Ctx, files, params.VendorID, params.VendorOrgCode, params.MixType, params.IsFocus, params.IsSync, params.IsAsync, params.IsContinueWhenError)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "CreateActByExcel",
|
||||||
|
Router: `/CreateActByExcel`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "DeleteSkusFromAct",
|
Method: "DeleteSkusFromAct",
|
||||||
|
|||||||
Reference in New Issue
Block a user