- add PendingUnitPrice and PendingOpType in GetStoreSkus result, when param isGetOpRequest is true
- fix some API result to lower camel case
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -29,6 +30,9 @@ type StoreSkuNameExt struct {
|
|||||||
UnitPrice int `json:"unitPrice"`
|
UnitPrice int `json:"unitPrice"`
|
||||||
Skus []map[string]interface{} `orm:"-" json:"skus"`
|
Skus []map[string]interface{} `orm:"-" json:"skus"`
|
||||||
SkusStr string `json:"-"`
|
SkusStr string `json:"-"`
|
||||||
|
|
||||||
|
PendingOpType int8 `json:"pendingOpType"` // 取值同 StoreOpRequest.Type
|
||||||
|
PendingUnitPrice int `json:"pendingUnitPrice"` // 这个是待审核的价格申请
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStoreSkus用
|
// GetStoreSkus用
|
||||||
@@ -74,9 +78,9 @@ type SkuSaleInfo struct {
|
|||||||
|
|
||||||
type StoreOpRequestInfo struct {
|
type StoreOpRequestInfo struct {
|
||||||
model.StoreOpRequest
|
model.StoreOpRequest
|
||||||
StoreName string
|
StoreName string `json:"storeName"`
|
||||||
SkuNamePrefix string
|
SkuNamePrefix string `json:"skuNamePrefix"`
|
||||||
SkuNameName string
|
SkuNameName string `json:"skuNameName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商品不可售,直接排除
|
// 商品不可售,直接排除
|
||||||
@@ -339,6 +343,28 @@ func GetStoreSkus(ctx *jxcontext.Context, storeID int, isFocus bool, keyword str
|
|||||||
skuNamesInfo.SkuNames = newSkuNames[offset:endIndex]
|
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
|
||||||
|
}
|
||||||
|
requestList, err2 := GetStoreOpRequests(ctx, utils.DefaultTimeValue, utils.DefaultTimeValue, "", []int{storeID}, nameIDs, nil, []int{model.RequestStatusNew}, 0, -1)
|
||||||
|
if err = err2; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
@@ -454,6 +480,7 @@ func checkStoresSkusSaleCity(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs []i
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateStoresSkusWithoutSync(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (needSyncSkus []int, err error) {
|
func updateStoresSkusWithoutSync(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (needSyncSkus []int, err error) {
|
||||||
|
sort.Ints(storeIDs)
|
||||||
globals.SugarLogger.Debugf("updateStoresSkusWithoutSync, storeIDs:%v, skuBindInfos:%s", storeIDs, utils.Format4Output(skuBindInfos, false))
|
globals.SugarLogger.Debugf("updateStoresSkusWithoutSync, storeIDs:%v, skuBindInfos:%s", storeIDs, utils.Format4Output(skuBindInfos, false))
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if err = checkStoresSkusSaleCity(ctx, db, storeIDs, skuBindInfos); err != nil {
|
if err = checkStoresSkusSaleCity(ctx, db, storeIDs, skuBindInfos); err != nil {
|
||||||
@@ -973,7 +1000,7 @@ func RejectStoreOpRequests(ctx *jxcontext.Context, reqIDs []int, rejectReason st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 当前些函数只针对type为: RequestTypeChangePrice与RequestTypeFocusSkuName的查询才有效
|
// 当前些函数只针对type为: RequestTypeChangePrice与RequestTypeFocusSkuName的查询才有效
|
||||||
func GetStoreOpRequests(ctx *jxcontext.Context, fromTime, toTime time.Time, keyword string, params map[string]interface{}, offset, pageSize int) (requestList []*StoreOpRequestInfo, err error) {
|
func GetStoreOpRequests(ctx *jxcontext.Context, fromTime, toTime time.Time, keyword string, storeIDs, itemIDs, typeList, statusList []int, offset, pageSize int) (requestList []*StoreOpRequestInfo, err error) {
|
||||||
if globals.EnablePendingChange {
|
if globals.EnablePendingChange {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t1.id, t1.created_at, t1.updated_at, t1.last_operator, t1.deleted_at,
|
SELECT t1.id, t1.created_at, t1.updated_at, t1.last_operator, t1.deleted_at,
|
||||||
@@ -984,12 +1011,9 @@ func GetStoreOpRequests(ctx *jxcontext.Context, fromTime, toTime time.Time, keyw
|
|||||||
JOIN sku_name t3 ON t1.item_id = t3.id
|
JOIN sku_name t3 ON t1.item_id = t3.id
|
||||||
JOIN sku t4 ON t3.id = t4.name_id
|
JOIN sku t4 ON t3.id = t4.name_id
|
||||||
LEFT JOIN store_sku_bind t5 ON t1.store_id = t5.store_id AND t4.id = t5.sku_id AND t5.deleted_at = ?
|
LEFT JOIN store_sku_bind t5 ON t1.store_id = t5.store_id AND t4.id = t5.sku_id AND t5.deleted_at = ?
|
||||||
WHERE t1.created_at >= ? AND t1.created_at <= ?
|
WHERE 1 = 1`
|
||||||
`
|
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
fromTime,
|
|
||||||
toTime,
|
|
||||||
}
|
}
|
||||||
if keyword != "" {
|
if keyword != "" {
|
||||||
keywordLike := "%" + keyword + "%"
|
keywordLike := "%" + keyword + "%"
|
||||||
@@ -1001,36 +1025,31 @@ func GetStoreOpRequests(ctx *jxcontext.Context, fromTime, toTime time.Time, keyw
|
|||||||
}
|
}
|
||||||
sql += ")"
|
sql += ")"
|
||||||
}
|
}
|
||||||
if params["storeIDs"] != nil {
|
if fromTime != utils.DefaultTimeValue {
|
||||||
var storeIDs []int
|
sql += " AND t1.created_at >= ?"
|
||||||
if err = utils.UnmarshalUseNumber([]byte(params["storeIDs"].(string)), &storeIDs); err != nil {
|
sqlParams = append(sqlParams, fromTime)
|
||||||
return nil, err
|
}
|
||||||
|
if toTime != utils.DefaultTimeValue {
|
||||||
|
sql += " AND t1.created_at <= ?"
|
||||||
|
sqlParams = append(sqlParams, toTime)
|
||||||
}
|
}
|
||||||
if len(storeIDs) > 0 {
|
if len(storeIDs) > 0 {
|
||||||
sql += " AND t1.store_id IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
|
sql += " AND t1.store_id IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
|
||||||
sqlParams = append(sqlParams, storeIDs)
|
sqlParams = append(sqlParams, storeIDs)
|
||||||
}
|
}
|
||||||
}
|
if len(itemIDs) > 0 {
|
||||||
if params["types"] != nil {
|
sql += " AND t1.item_id IN (" + dao.GenQuestionMarks(len(itemIDs)) + ")"
|
||||||
var typeList []int
|
sqlParams = append(sqlParams, itemIDs)
|
||||||
if err = utils.UnmarshalUseNumber([]byte(params["types"].(string)), &typeList); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
if len(typeList) > 0 {
|
if len(typeList) > 0 {
|
||||||
sql += " AND t1.type IN (" + dao.GenQuestionMarks(len(typeList)) + ")"
|
sql += " AND t1.type IN (" + dao.GenQuestionMarks(len(typeList)) + ")"
|
||||||
sqlParams = append(sqlParams, typeList)
|
sqlParams = append(sqlParams, typeList)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if params["statuss"] != nil {
|
|
||||||
var statusList []int
|
|
||||||
if err = utils.UnmarshalUseNumber([]byte(params["statuss"].(string)), &statusList); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if len(statusList) > 0 {
|
if len(statusList) > 0 {
|
||||||
sql += " AND t1.status IN (" + dao.GenQuestionMarks(len(statusList)) + ")"
|
sql += " AND t1.status IN (" + dao.GenQuestionMarks(len(statusList)) + ")"
|
||||||
sqlParams = append(sqlParams, statusList)
|
sqlParams = append(sqlParams, statusList)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
sql += `
|
sql += `
|
||||||
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
|
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
|
||||||
LIMIT ? OFFSET ?`
|
LIMIT ? OFFSET ?`
|
||||||
|
|||||||
@@ -394,3 +394,18 @@ func BatchStr2Time(strTime ...string) (timeList []time.Time, err error) {
|
|||||||
func IsTimeEmpty(timeValue time.Time) bool {
|
func IsTimeEmpty(timeValue time.Time) bool {
|
||||||
return (timeValue == utils.DefaultTimeValue || timeValue == utils.ZeroTimeValue)
|
return (timeValue == utils.DefaultTimeValue || timeValue == utils.ZeroTimeValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// strAndObjAddPairs必须按字符串1,转换地址1,字符串2,转换地址2这样的格式传递
|
||||||
|
func Strings2Objs(strAndObjAddPairs ...interface{}) (err error) {
|
||||||
|
str := ""
|
||||||
|
for k, v := range strAndObjAddPairs {
|
||||||
|
if k%2 == 0 {
|
||||||
|
str, _ = v.(string)
|
||||||
|
} else if str != "" {
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(str), v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -84,19 +84,19 @@ func (*StoreSkuBind) TableUnique() [][]string {
|
|||||||
type StoreOpRequest struct {
|
type StoreOpRequest struct {
|
||||||
ModelIDCULD // DeletedAt用于表示请求操作结束,而并不一定是删除
|
ModelIDCULD // DeletedAt用于表示请求操作结束,而并不一定是删除
|
||||||
|
|
||||||
Type int8
|
Type int8 `json:"type"`
|
||||||
StoreID int `orm:"column(store_id)"`
|
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||||
ItemID int `orm:"column(item_id)"` // 这个根据type不同,可能是SKUNAME ID或SKU ID
|
ItemID int `orm:"column(item_id)" json:"itemID"` // 这个根据type不同,可能是SKUNAME ID或SKU ID
|
||||||
Status int8
|
Status int8 `json:"status"`
|
||||||
UserID string `orm:"size(48);column(user_id)"`
|
UserID string `orm:"size(48);column(user_id)" json:"userID"`
|
||||||
IntParam1 int
|
IntParam1 int `json:"intParam1"`
|
||||||
IntParam2 int
|
IntParam2 int `json:"intParam2"`
|
||||||
JsonParam string `orm:"size(3000)"`
|
JsonParam string `orm:"size(3000)" json:"jsonParam"`
|
||||||
Remark string `orm:"size(255)"`
|
Remark string `orm:"size(255)" json:"remark"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*StoreOpRequest) TableUnique() [][]string {
|
func (*StoreOpRequest) TableUnique() [][]string {
|
||||||
return [][]string{
|
return [][]string{
|
||||||
[]string{"StoreID", "Type", "ItemID", "DeletedAt"},
|
[]string{"DeletedAt", "StoreID", "Type", "ItemID"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ type StoreSkuController struct {
|
|||||||
// @Param stToTime query string false "统计SKU结束时间"
|
// @Param stToTime query string false "统计SKU结束时间"
|
||||||
// @Param stFromCount query int false "统计SKU,结果集起始数量(包括)"
|
// @Param stFromCount query int false "统计SKU,结果集起始数量(包括)"
|
||||||
// @Param stToCount query int false "统计SKU,结果集结束数量(包括)"
|
// @Param stToCount query int false "统计SKU,结果集结束数量(包括)"
|
||||||
|
// @Param isGetOpRequest query bool false "是否返回相应的待审核变动请求,缺省为false不返回"
|
||||||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||||||
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
@@ -220,11 +221,11 @@ func (c *StoreSkuController) GetStoresSkusSaleInfo() {
|
|||||||
// @Title 得到商家商品修改价格请求信息
|
// @Title 得到商家商品修改价格请求信息
|
||||||
// @Description 得到商家商品修改价格请求信息
|
// @Description 得到商家商品修改价格请求信息
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param fromTime query string true "申请开始时间"
|
// @Param fromTime query string false "申请开始时间"
|
||||||
// @Param toTime query string false "申请结束时间"
|
// @Param toTime query string false "申请结束时间"
|
||||||
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
||||||
// @Param storeIDs query string false "门店ID列表"
|
// @Param storeIDs query string false "门店ID列表"
|
||||||
// @Param itemIDs query string false "id列表对象"
|
// @Param itemIDs query string false "id列表对象,当前指skuname id"
|
||||||
// @Param types query string false "类型列表对象"
|
// @Param types query string false "类型列表对象"
|
||||||
// @Param statuss query string false "状态列表对象"
|
// @Param statuss query string false "状态列表对象"
|
||||||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||||||
@@ -236,11 +237,18 @@ func (c *StoreSkuController) GetStoreOpRequests() {
|
|||||||
c.callGetStoreOpRequests(func(params *tStoreSkuGetStoreOpRequestsParams) (retVal interface{}, errCode string, err error) {
|
c.callGetStoreOpRequests(func(params *tStoreSkuGetStoreOpRequestsParams) (retVal interface{}, errCode string, err error) {
|
||||||
var (
|
var (
|
||||||
timeList []time.Time
|
timeList []time.Time
|
||||||
|
storeIDs []int
|
||||||
|
typeList []int
|
||||||
|
statusList []int
|
||||||
|
itemIDs []int
|
||||||
)
|
)
|
||||||
if timeList, err = jxutils.BatchStr2Time(params.FromTime, params.ToTime); err != nil {
|
if timeList, err = jxutils.BatchStr2Time(params.FromTime, params.ToTime); err != nil {
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
}
|
}
|
||||||
retVal, err = cms.GetStoreOpRequests(params.Ctx, timeList[0], timeList[1], params.Keyword, params.MapData, params.Offset, params.PageSize)
|
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Types, &typeList, params.Statuss, &statusList, params.ItemIDs, &itemIDs); err != nil {
|
||||||
|
return retVal, "", err
|
||||||
|
}
|
||||||
|
retVal, err = cms.GetStoreOpRequests(params.Ctx, timeList[0], timeList[1], params.Keyword, storeIDs, itemIDs, typeList, statusList, params.Offset, params.PageSize)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user