商品审核修改
This commit is contained in:
@@ -4457,8 +4457,8 @@ func RefreshJdsSkusStatus(ctx *jxcontext.Context) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func GetStoreSkuAudit(ctx *jxcontext.Context, storeIDs, nameIDs, skuIDs, statuss, types []int, name, remark string, applyTimeStart, applyTimeEnd, auditTimeStart, auditTimeEnd string, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
pagedInfo, err = dao.GetStoreSkuAudit(dao.GetDB(), storeIDs, nameIDs, skuIDs, statuss, types, name, remark, utils.Str2Time(applyTimeStart), utils.Str2Time(applyTimeEnd), utils.Str2Time(auditTimeStart), utils.Str2Time(auditTimeEnd), pageSize, offset)
|
||||
func GetStoreSkuAudit(ctx *jxcontext.Context, storeIDs, nameIDs, skuIDs, statuss, types []int, name, remark, keyword string, applyTimeStart, applyTimeEnd, auditTimeStart, auditTimeEnd string, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
pagedInfo, err = dao.GetStoreSkuAudit(dao.GetDB(), storeIDs, nameIDs, skuIDs, statuss, types, name, remark, keyword, utils.Str2Time(applyTimeStart), utils.Str2Time(applyTimeEnd), utils.Str2Time(auditTimeStart), utils.Str2Time(auditTimeEnd), pageSize, offset)
|
||||
return pagedInfo, err
|
||||
}
|
||||
|
||||
@@ -4529,83 +4529,82 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
|
||||
return true, err
|
||||
}
|
||||
|
||||
func StoreSkuPriceAudit(ctx *jxcontext.Context, storeIDs, nameIDs []int, status, auditPrice int, remark string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func StoreSkuPriceAudit(ctx *jxcontext.Context, storeSkuAudits []*model.StoreSkuAudit, status int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
if status == model.StoreAuditStatusOnline {
|
||||
return "", fmt.Errorf("审核标志不正确!")
|
||||
}
|
||||
task := tasksch.NewParallelTask("StoreSkuPriceAudit", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeID := batchItemList[0].(int)
|
||||
for _, v := range nameIDs {
|
||||
storeAudits, err := dao.GetStoreSkuAuditLight(db, []int{storeID}, []int{v}, model.StoreAuditStatusOnline)
|
||||
if len(storeAudits) == 0 || err != nil {
|
||||
return retVal, fmt.Errorf("未查询到该门店该商品的待审核信息!storeID: %v, nameID: %v", storeID, v)
|
||||
}
|
||||
if len(storeAudits) > 1 {
|
||||
return retVal, fmt.Errorf("查询到该门店该商品的待审核信息大于1条!storeID: %v, nameID: %v", storeID, v)
|
||||
}
|
||||
// flag := false
|
||||
//审核通过
|
||||
if status == model.StoreAuditStatusCreated {
|
||||
// flag = true
|
||||
storeAudits[0].UserID = ctx.GetUserID()
|
||||
storeAudits[0].Status = model.StoreAuditStatusCreated
|
||||
storeAudits[0].Remark = remark
|
||||
storeAudits[0].AuditPrice = auditPrice
|
||||
_, err = dao.UpdateEntity(db, storeAudits[0], "UserID", "Status", "Remark", "AuditPrice")
|
||||
var skuBindInfos = []*StoreSkuBindInfo{
|
||||
&StoreSkuBindInfo{
|
||||
NameID: v,
|
||||
UnitPrice: storeAudits[0].UnitPrice,
|
||||
},
|
||||
}
|
||||
//证明填了额外的审核价格
|
||||
if auditPrice != 0 {
|
||||
skuBindInfos[0].UnitPrice = auditPrice
|
||||
}
|
||||
//如果是关注改价
|
||||
if storeAudits[0].Type == model.StoreSkuAuditTypeFocus {
|
||||
skuBindInfos[0].IsFocus = 1
|
||||
}
|
||||
var num int64
|
||||
db := dao.GetDB()
|
||||
skuIDs, err := updateStoresSkusWithoutSync(ctx, db, storeIDs, skuBindInfos, false)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
isAsync = asyncStoreSkuOpFilter(ctx, isAsync)
|
||||
num = int64(len(skuIDs))
|
||||
if num > 0 {
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, nil, 0, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
}
|
||||
// _, err = UpdateStoresSkus(ctx, 0, []int{storeID}, skuBindInfos, false, isAsync, isContinueWhenError)
|
||||
} else if status == model.StoreAuditStatusRejected {
|
||||
storeAudits[0].UserID = ctx.GetUserID()
|
||||
storeAudits[0].Status = model.StoreAuditStatusRejected
|
||||
storeAudits[0].Remark = remark
|
||||
_, err = dao.UpdateEntity(db, storeAudits[0], "UserID", "Status", "Remark")
|
||||
} else {
|
||||
return retVal, fmt.Errorf("审核标志不正确!")
|
||||
}
|
||||
if err == nil {
|
||||
// skuAndNames, err := dao.GetSkus(db, nil, []int{v}, nil, nil, nil)
|
||||
// if len(skuAndNames) > 0 && err == nil {
|
||||
// price := 0
|
||||
// if auditPrice != 0 {
|
||||
// price = auditPrice
|
||||
// } else {
|
||||
// price = storeAudits[0].UnitPrice
|
||||
// }
|
||||
// weixinmsg.NotifyStoreOpRequestStatus(flag, storeID, v, jxutils.ComposeSpuName(skuAndNames[0].Prefix, skuAndNames[0].Name, 0), storeAudits[0].OriginUnitPrice, price, remark)
|
||||
// }
|
||||
}
|
||||
storeAudit := batchItemList[0].(*model.StoreSkuAudit)
|
||||
storeAudits, err := dao.GetStoreSkuAuditLight(db, []int{storeAudit.StoreID}, []int{storeAudit.NameID}, model.StoreAuditStatusOnline)
|
||||
if len(storeAudits) == 0 || err != nil {
|
||||
return retVal, fmt.Errorf("未查询到该门店该商品的待审核信息!storeID: %v, nameID: %v", storeAudit.StoreID, storeAudit.NameID)
|
||||
}
|
||||
if len(storeAudits) > 1 {
|
||||
return retVal, fmt.Errorf("查询到该门店该商品的待审核信息大于1条!storeID: %v, nameID: %v", storeAudit.StoreID, storeAudit.NameID)
|
||||
}
|
||||
// flag := false
|
||||
//审核通过
|
||||
if status == model.StoreAuditStatusCreated {
|
||||
// flag = true
|
||||
storeAudits[0].UserID = ctx.GetUserID()
|
||||
storeAudits[0].Status = model.StoreAuditStatusCreated
|
||||
storeAudits[0].Remark = storeAudit.Remark
|
||||
storeAudits[0].AuditPrice = storeAudit.AuditPrice
|
||||
_, err = dao.UpdateEntity(db, storeAudits[0], "UserID", "Status", "Remark", "AuditPrice")
|
||||
var skuBindInfos = []*StoreSkuBindInfo{
|
||||
&StoreSkuBindInfo{
|
||||
NameID: storeAudit.NameID,
|
||||
UnitPrice: storeAudits[0].UnitPrice,
|
||||
},
|
||||
}
|
||||
//证明填了额外的审核价格
|
||||
if storeAudit.AuditPrice != 0 {
|
||||
skuBindInfos[0].UnitPrice = storeAudit.AuditPrice
|
||||
}
|
||||
//如果是关注改价
|
||||
if storeAudits[0].Type == model.StoreSkuAuditTypeFocus {
|
||||
skuBindInfos[0].IsFocus = 1
|
||||
}
|
||||
var num int64
|
||||
db := dao.GetDB()
|
||||
skuIDs, err := updateStoresSkusWithoutSync(ctx, db, []int{storeAudit.StoreID}, skuBindInfos, false)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
isAsync = asyncStoreSkuOpFilter(ctx, isAsync)
|
||||
num = int64(len(skuIDs))
|
||||
if num > 0 {
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, nil, 0, db, nil, []int{storeAudit.StoreID}, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
}
|
||||
// _, err = UpdateStoresSkus(ctx, 0, []int{storeID}, skuBindInfos, false, isAsync, isContinueWhenError)
|
||||
} else if status == model.StoreAuditStatusRejected {
|
||||
storeAudits[0].UserID = ctx.GetUserID()
|
||||
storeAudits[0].Status = model.StoreAuditStatusRejected
|
||||
storeAudits[0].Remark = storeAudit.Remark
|
||||
_, err = dao.UpdateEntity(db, storeAudits[0], "UserID", "Status", "Remark")
|
||||
} else {
|
||||
return retVal, fmt.Errorf("审核标志不正确!")
|
||||
}
|
||||
if err == nil {
|
||||
// skuAndNames, err := dao.GetSkus(db, nil, []int{v}, nil, nil, nil)
|
||||
// if len(skuAndNames) > 0 && err == nil {
|
||||
// price := 0
|
||||
// if auditPrice != 0 {
|
||||
// price = auditPrice
|
||||
// } else {
|
||||
// price = storeAudits[0].UnitPrice
|
||||
// }
|
||||
// weixinmsg.NotifyStoreOpRequestStatus(flag, storeID, v, jxutils.ComposeSpuName(skuAndNames[0].Prefix, skuAndNames[0].Name, 0), storeAudits[0].OriginUnitPrice, price, remark)
|
||||
// }
|
||||
}
|
||||
|
||||
return retVal, err
|
||||
}, storeIDs)
|
||||
}, storeSkuAudits)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if isAsync {
|
||||
hint = task.GetID()
|
||||
|
||||
@@ -1547,7 +1547,7 @@ type tStoreSkuAudit struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func GetStoreSkuAudit(db *DaoDB, storeIDs, nameIDs, skuIDs, statuss, types []int, name, remark string, applyTimeStart, applyTimeEnd, auditTimeStart, auditTimeEnd time.Time, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
func GetStoreSkuAudit(db *DaoDB, storeIDs, nameIDs, skuIDs, statuss, types []int, name, remark, keyword string, applyTimeStart, applyTimeEnd, auditTimeStart, auditTimeEnd time.Time, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
var requestList []*tStoreSkuAudit
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS a.*, c.name sku_name, c.prefix, c.unit, c.spec_quality, c.spec_unit, c.img, d.name store_name, b.name
|
||||
@@ -1590,6 +1590,10 @@ func GetStoreSkuAudit(db *DaoDB, storeIDs, nameIDs, skuIDs, statuss, types []int
|
||||
sql += " AND a.type IN (" + GenQuestionMarks(len(types)) + ")"
|
||||
sqlParams = append(sqlParams, types)
|
||||
}
|
||||
if keyword != "" {
|
||||
sql += " AND (b.name LIKE ? OR a.remark LIKE ? OR a.name_id LIKE ? OR a.user_id LIKE ? OR a.store_id LIKE ?)"
|
||||
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
|
||||
}
|
||||
sql += " LIMIT ? OFFSET ?"
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
@@ -825,6 +827,7 @@ func (c *StoreSkuController) SyncMatterC4ToGy() {
|
||||
// @Param nameIDs query string false "id列表对象,当前指skuname id"
|
||||
// @Param statuss query string false "审核状态"
|
||||
// @Param types query string false "改价类型,1是普通改价,2是关注"
|
||||
// @Param keyword query string false "关键字"
|
||||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
@@ -838,7 +841,7 @@ func (c *StoreSkuController) GetStoreSkuAudit() {
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.NameIDs, &nameIDs, params.Statuss, &statuss, params.Types, &types); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.GetStoreSkuAudit(params.Ctx, storeIDs, nameIDs, nil, statuss, types, params.Name, params.Remark, params.ApplyTimeStart, params.ApplyTimeEnd, params.AuditTimeStart, params.AuditTimeEnd, params.PageSize, params.Offset)
|
||||
retVal, err = cms.GetStoreSkuAudit(params.Ctx, storeIDs, nameIDs, nil, statuss, types, params.Name, params.Remark, params.Keyword, params.ApplyTimeStart, params.ApplyTimeEnd, params.AuditTimeStart, params.AuditTimeEnd, params.PageSize, params.Offset)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -846,11 +849,8 @@ func (c *StoreSkuController) GetStoreSkuAudit() {
|
||||
// @Title 审核商品
|
||||
// @Description 审核商品
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs formData string false "门店ID列表"
|
||||
// @Param nameIDs formData string false "id列表对象,当前指skuname id"
|
||||
// @Param auditPrice formData int false "录入的审核价格"
|
||||
// @Param payload formData string true "json数据,storeskuaudit对象"
|
||||
// @Param status formData int false "审核标志,1通过,-1 不通过"
|
||||
// @Param remark formData string false "审核不通过原因"
|
||||
// @Param isAsync formData bool false "是否异步,缺省是同步"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
@@ -858,11 +858,11 @@ func (c *StoreSkuController) GetStoreSkuAudit() {
|
||||
// @router /StoreSkuPriceAudit [post]
|
||||
func (c *StoreSkuController) StoreSkuPriceAudit() {
|
||||
c.callStoreSkuPriceAudit(func(params *tStoreSkuStoreSkuPriceAuditParams) (retVal interface{}, errCode string, err error) {
|
||||
var storeIDs, nameIDs []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.NameIDs, &nameIDs); err != nil {
|
||||
var storeSkuAudits []*model.StoreSkuAudit
|
||||
if err = jxutils.Strings2Objs(params.Payload, &storeSkuAudits); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.StoreSkuPriceAudit(params.Ctx, storeIDs, nameIDs, params.Status, params.AuditPrice, params.Remark, params.IsAsync, params.IsContinueWhenError)
|
||||
retVal, err = cms.StoreSkuPriceAudit(params.Ctx, storeSkuAudits, params.Status, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user