- cms.GetStoresSkus
This commit is contained in:
@@ -27,6 +27,9 @@ const (
|
|||||||
|
|
||||||
// GetStoreSkus用
|
// GetStoreSkus用
|
||||||
type StoreSkuNameExt struct {
|
type StoreSkuNameExt struct {
|
||||||
|
StoreID int `orm:"column(store_id)"`
|
||||||
|
StoreName string
|
||||||
|
|
||||||
model.SkuName
|
model.SkuName
|
||||||
UnitPrice int `json:"unitPrice"`
|
UnitPrice int `json:"unitPrice"`
|
||||||
Skus []map[string]interface{} `orm:"-" json:"skus"`
|
Skus []map[string]interface{} `orm:"-" json:"skus"`
|
||||||
@@ -85,24 +88,27 @@ type StoreOpRequestInfo struct {
|
|||||||
UnitPrice int `json:"unitPrice"`
|
UnitPrice int `json:"unitPrice"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetStoreSkus(ctx *jxcontext.Context, storeID int, isFocus bool, keyword string, isBySku bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) {
|
||||||
|
return GetStoresSkus(ctx, []int{storeID}, isFocus, keyword, isBySku, params, offset, pageSize)
|
||||||
|
}
|
||||||
|
|
||||||
// 商品不可售,直接排除
|
// 商品不可售,直接排除
|
||||||
// 如果门店商品是可售状态,那么会忽略区域限制。否则有区域限制
|
// 如果门店商品是可售状态,那么会忽略区域限制。否则有区域限制
|
||||||
func GetStoreSkus(ctx *jxcontext.Context, storeID int, isFocus bool, keyword string, isBySku bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) {
|
func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword string, isBySku bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
sql := `
|
sql := `
|
||||||
FROM sku_name t1
|
FROM sku_name t1
|
||||||
JOIN sku t2 ON t1.id = t2.name_id AND t2.deleted_at = ?/* AND t2.status = ?*/
|
JOIN sku t2 ON t1.id = t2.name_id AND t2.deleted_at = ?/* AND t2.status = ?*/
|
||||||
LEFT JOIN store_sku_bind t4 ON t4.sku_id = t2.id AND t4.deleted_at = ? AND t4.store_id = ?
|
JOIN store t3 ON t3.id IN (` + dao.GenQuestionMarks(len(storeIDs)) + `)
|
||||||
JOIN store t3 ON t3.id = ?
|
LEFT JOIN store_sku_bind t4 ON t4.sku_id = t2.id AND t4.deleted_at = ? AND t4.store_id = t3.id
|
||||||
LEFT JOIN sku_name_place_bind t5 ON t1.id = t5.name_id AND t3.city_code = t5.place_code
|
LEFT JOIN sku_name_place_bind t5 ON t1.id = t5.name_id AND t3.city_code = t5.place_code
|
||||||
WHERE t1.deleted_at = ? AND (t1.is_global = 1 OR t5.id IS NOT NULL OR t4.status = ?)/* AND t1.status = ?*/
|
WHERE t1.deleted_at = ? AND (t1.is_global = 1 OR t5.id IS NOT NULL OR t4.status = ?)/* AND t1.status = ?*/
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
// model.SkuStatusNormal,
|
// model.SkuStatusNormal,
|
||||||
|
storeIDs,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
storeID,
|
|
||||||
storeID,
|
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
model.SkuStatusNormal,
|
model.SkuStatusNormal,
|
||||||
// model.SkuStatusNormal,
|
// model.SkuStatusNormal,
|
||||||
@@ -215,7 +221,9 @@ func GetStoreSkus(ctx *jxcontext.Context, storeID int, isFocus bool, keyword str
|
|||||||
t1.unit,
|
t1.unit,
|
||||||
t1.price,
|
t1.price,
|
||||||
t1.img,
|
t1.img,
|
||||||
t1.elm_img_hash_code`
|
t1.elm_img_hash_code,
|
||||||
|
t3.id,
|
||||||
|
t3.name`
|
||||||
if isBySku {
|
if isBySku {
|
||||||
sql += `,
|
sql += `,
|
||||||
t2.id`
|
t2.id`
|
||||||
@@ -237,6 +245,8 @@ func GetStoreSkus(ctx *jxcontext.Context, storeID int, isFocus bool, keyword str
|
|||||||
t1.price,
|
t1.price,
|
||||||
t1.img,
|
t1.img,
|
||||||
t1.elm_img_hash_code,
|
t1.elm_img_hash_code,
|
||||||
|
t3.id store_id,
|
||||||
|
t3.name store_name,
|
||||||
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"id":', t2.id, ',"comment":"', t2.comment, '","status":', t2.status, ',"createdAt":"',
|
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"id":', t2.id, ',"comment":"', t2.comment, '","status":', t2.status, ',"createdAt":"',
|
||||||
CONCAT(REPLACE(IF(t4.created_at IS NULL, '1970-01-01 00:00:00', t4.created_at)," ","T"),"+08:00"), '","updatedAt":"', CONCAT(REPLACE(IF(t4.updated_at IS NULL, '1970-01-01 00:00:00', t4.updated_at)," ","T"),"+08:00"),
|
CONCAT(REPLACE(IF(t4.created_at IS NULL, '1970-01-01 00:00:00', t4.created_at)," ","T"),"+08:00"), '","updatedAt":"', CONCAT(REPLACE(IF(t4.updated_at IS NULL, '1970-01-01 00:00:00', t4.updated_at)," ","T"),"+08:00"),
|
||||||
'","lastOperator":"', IF(t4.last_operator IS NULL, '', t4.last_operator), '","specQuality":', t2.spec_quality, ',"specUnit":"', t2.spec_unit, '","weight":', t2.weight,
|
'","lastOperator":"', IF(t4.last_operator IS NULL, '', t4.last_operator), '","specQuality":', t2.spec_quality, ',"specUnit":"', t2.spec_unit, '","weight":', t2.weight,
|
||||||
@@ -317,17 +327,17 @@ func GetStoreSkus(ctx *jxcontext.Context, storeID int, isFocus bool, keyword str
|
|||||||
toCount = params["stToCount"].(int)
|
toCount = params["stToCount"].(int)
|
||||||
}
|
}
|
||||||
// 不能用SQL筛除,否则不能区分是没有销量,还是不在条件中
|
// 不能用SQL筛除,否则不能区分是没有销量,还是不在条件中
|
||||||
if saleInfoList, err = GetStoresSkusSaleInfo(ctx, []int{storeID}, skuIDs, timeList[0], timeList[1], 0, math.MaxInt32); err != nil {
|
if saleInfoList, err = GetStoresSkusSaleInfo(ctx, storeIDs, skuIDs, timeList[0], timeList[1], 0, math.MaxInt32); err != nil {
|
||||||
dao.Rollback(db)
|
dao.Rollback(db)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, saleInfo := range saleInfoList {
|
for _, saleInfo := range saleInfoList {
|
||||||
saleInfoMap[int64(saleInfo.StoreID)*100000+int64(saleInfo.SkuID)] = saleInfo
|
saleInfoMap[int64(saleInfo.StoreID)*100000+int64(saleInfo.SkuID)] = saleInfo
|
||||||
}
|
}
|
||||||
storeID2 := int64(storeID) * 100000
|
|
||||||
var newSkuNames []*StoreSkuNameExt
|
var newSkuNames []*StoreSkuNameExt
|
||||||
for _, skuName := range skuNamesInfo.SkuNames {
|
for _, skuName := range skuNamesInfo.SkuNames {
|
||||||
var newSkus []map[string]interface{}
|
var newSkus []map[string]interface{}
|
||||||
|
storeID2 := int64(skuName.StoreID) * 100000
|
||||||
for _, sku := range skuName.Skus {
|
for _, sku := range skuName.Skus {
|
||||||
saleInfo := saleInfoMap[storeID2+utils.MustInterface2Int64(sku["id"])]
|
saleInfo := saleInfoMap[storeID2+utils.MustInterface2Int64(sku["id"])]
|
||||||
if saleInfo == nil && fromCount == 0 {
|
if saleInfo == nil && fromCount == 0 {
|
||||||
@@ -360,7 +370,7 @@ func GetStoreSkus(ctx *jxcontext.Context, storeID int, isFocus bool, keyword str
|
|||||||
for k, skuName := range skuNamesInfo.SkuNames {
|
for k, skuName := range skuNamesInfo.SkuNames {
|
||||||
nameIDs[k] = skuName.ID
|
nameIDs[k] = skuName.ID
|
||||||
}
|
}
|
||||||
pagedInfo, err2 := GetStoreOpRequests(ctx, utils.DefaultTimeValue, utils.DefaultTimeValue, "", []int{storeID}, nameIDs, nil, []int{model.RequestStatusNew}, 0, -1)
|
pagedInfo, err2 := GetStoreOpRequests(ctx, utils.DefaultTimeValue, utils.DefaultTimeValue, "", storeIDs, nameIDs, nil, []int{model.RequestStatusNew}, 0, -1)
|
||||||
if err = err2; err != nil {
|
if err = err2; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,42 @@ func (c *StoreSkuController) GetStoreSkus() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 得到商家商品信息
|
||||||
|
// @Description 得到商家商品信息,如下条件之间是与的关系。对于没有认领的商品,按城市限制。但对于已经认领的商品就不限制了,因为已经在平台上可售,可以操作(改价等等)
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param storeIDs query string true "门店ID"
|
||||||
|
// @Param isFocus query bool true "是否已关注(认领)"
|
||||||
|
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
||||||
|
// @Param nameIDs query string false "SkuName ID列表对象"
|
||||||
|
// @Param skuIDs query string false "Sku ID列表对象"
|
||||||
|
// @Param name query string false "商品名称(不要求完全一致)"
|
||||||
|
// @Param prefix query string false "商品前缀(不要求完全一致)"
|
||||||
|
// @Param categoryID query int false "商品所属类别ID"
|
||||||
|
// @Param unit query string false "商品单位"
|
||||||
|
// @Param jdID query int false "商品京东ID"
|
||||||
|
// @Param fromStatus query int false "查询起始状态(0:不可售,1:可售)"
|
||||||
|
// @Param toStatus query int false "查询结束状态(0:不可售,1:可售)"
|
||||||
|
// @Param stFromTime query string false "统计SKU开始时间"
|
||||||
|
// @Param stToTime query string false "统计SKU结束时间"
|
||||||
|
// @Param stFromCount query int false "统计SKU,结果集起始数量(包括)"
|
||||||
|
// @Param stToCount query int false "统计SKU,结果集结束数量(包括)"
|
||||||
|
// @Param isGetOpRequest query bool false "是否返回相应的待审核变动请求,缺省为false不返回"
|
||||||
|
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||||||
|
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
||||||
|
// @Param isBySku query bool false "是否按SKU分拆"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetStoresSkus [get]
|
||||||
|
func (c *StoreSkuController) GetStoresSkus() {
|
||||||
|
c.callGetStoresSkus(func(params *tStoreSkuGetStoresSkusParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
var storeIDs []int
|
||||||
|
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil {
|
||||||
|
retVal, err = cms.GetStoresSkus(params.Ctx, storeIDs, params.IsFocus, params.Keyword, params.IsBySku, params.MapData, params.Offset, params.PageSize)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// @Title 修改商家商品绑定
|
// @Title 修改商家商品绑定
|
||||||
// @Description 修改商家商品绑定,请换用UpdateStoresSkus
|
// @Description 修改商家商品绑定,请换用UpdateStoresSkus
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
)
|
)
|
||||||
@@ -45,8 +47,10 @@ func (c *DDAPIController) Sign() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
retVal = fmt.Sprintf("%x", sha1.Sum([]byte("jsapi_ticket="+ddapi.Ticket+
|
str := "jsapi_ticket=" + ddapi.Ticket +
|
||||||
"&noncestr="+params.NonceStr+"×tamp="+params.TimeStamp+"&url="+params.Url)))
|
"&noncestr=" + params.NonceStr + "×tamp=" + params.TimeStamp + "&url=" + params.Url
|
||||||
|
retVal = fmt.Sprintf("%x", sha1.Sum([]byte(str)))
|
||||||
|
globals.SugarLogger.Debugf("dingapi str:%s sign:%v", str, retVal)
|
||||||
}
|
}
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1114,6 +1114,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetStoresSkus",
|
||||||
|
Router: `/GetStoresSkus`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetStoresSkusSaleInfo",
|
Method: "GetStoresSkusSaleInfo",
|
||||||
|
|||||||
Reference in New Issue
Block a user