aa
This commit is contained in:
@@ -264,7 +264,7 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetStoresSkusForStore(ctx *jxcontext.Context, storeID int, isFocus, isAct bool, keyword string, categoryID, status, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
func GetStoresSkusForStore(ctx *jxcontext.Context, storeID int, isFocus, isAct bool, keyword string, categoryID, status, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo2, err error) {
|
||||||
//权限
|
//权限
|
||||||
//if permission.IsRoled(ctx) {
|
//if permission.IsRoled(ctx) {
|
||||||
// if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
|
// if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
|
||||||
@@ -276,7 +276,7 @@ func GetStoresSkusForStore(ctx *jxcontext.Context, storeID int, isFocus, isAct b
|
|||||||
var (
|
var (
|
||||||
sqlParams []interface{}
|
sqlParams []interface{}
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
SkuNames []*dao.StoreSkuNameExt
|
SkuNames []*dao.StoreSkuNameExt2
|
||||||
)
|
)
|
||||||
sql := `
|
sql := `
|
||||||
SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, e.id store_id, c.unit_price
|
SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, e.id store_id, c.unit_price
|
||||||
@@ -376,7 +376,7 @@ func GetStoresSkusForStore(ctx *jxcontext.Context, storeID int, isFocus, isAct b
|
|||||||
txDB, _ := dao.Begin(db)
|
txDB, _ := dao.Begin(db)
|
||||||
defer dao.Commit(db, txDB)
|
defer dao.Commit(db, txDB)
|
||||||
if err = dao.GetRowsTx(txDB, &SkuNames, sql, sqlParams...); err == nil {
|
if err = dao.GetRowsTx(txDB, &SkuNames, sql, sqlParams...); err == nil {
|
||||||
skuNamesInfo = &dao.StoreSkuNamesInfo{
|
skuNamesInfo = &dao.StoreSkuNamesInfo2{
|
||||||
TotalCount: dao.GetLastTotalRowCount2(db, txDB),
|
TotalCount: dao.GetLastTotalRowCount2(db, txDB),
|
||||||
}
|
}
|
||||||
// skuNamesInfo.TotalCount = dao.GetLastTotalRowCount2(db, txDB)
|
// skuNamesInfo.TotalCount = dao.GetLastTotalRowCount2(db, txDB)
|
||||||
@@ -442,16 +442,16 @@ func GetStoresSkusForStore(ctx *jxcontext.Context, storeID int, isFocus, isAct b
|
|||||||
// }
|
// }
|
||||||
// storeName.Skus = append(storeName.Skus, &v.StoreSkuExt)
|
// storeName.Skus = append(storeName.Skus, &v.StoreSkuExt)
|
||||||
//}
|
//}
|
||||||
if err == nil {
|
//if err == nil {
|
||||||
if isFocus {
|
// if isFocus {
|
||||||
if err == nil {
|
// if err == nil {
|
||||||
storeIDs, skuIDs := GetStoreAndSkuIDsFromInfo(skuNamesInfo)
|
// storeIDs, skuIDs := GetStoreAndSkuIDsFromInfo(skuNamesInfo)
|
||||||
err = dao.UpdateActPrice4StoreSkuNameNew(db, storeIDs, skuIDs, skuNamesInfo, -1)
|
// err = dao.UpdateActPrice4StoreSkuNameNew(db, storeIDs, skuIDs, skuNamesInfo, -1)
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
|
// err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
return skuNamesInfo, err
|
return skuNamesInfo, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -644,7 +644,7 @@ func RefreshJDMembers(ctx *jxcontext.Context) (err error) {
|
|||||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageCookie", model.ConfigTypeCookie, ""); err == nil {
|
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageCookie", model.ConfigTypeCookie, ""); err == nil {
|
||||||
api.JdAPI.SetJdCookie(configs[0].Value)
|
api.JdAPI.SetJdCookie(configs[0].Value)
|
||||||
}
|
}
|
||||||
userMemebers, _ := dao.GetUserMember(db, "", "", "", model.VendorIDJD, 0, -1)
|
userMemebers, _ := dao.GetUserMemberWithoutDeleted(db, model.VendorIDJD)
|
||||||
for _, v := range userMemebers {
|
for _, v := range userMemebers {
|
||||||
memberMap[v.Mobile] = v
|
memberMap[v.Mobile] = v
|
||||||
}
|
}
|
||||||
@@ -709,17 +709,28 @@ func UserMemberReport(ctx *jxcontext.Context, vendorID int, keyword string, offs
|
|||||||
)
|
)
|
||||||
var list []*dao.UserMemberReportResult
|
var list []*dao.UserMemberReportResult
|
||||||
sql := `
|
sql := `
|
||||||
SELECT SQL_CALC_FOUND_ROWS a.mobile, IF(a.vendor_id = ?, c.name, b.consignee_name) name, IF(a.deleted_at = '1970-01-01 00:00:00',1,0) status, a.vendor_id,
|
SELECT a.mobile, IF(a.vendor_id = ?, b.name, t1.consignee_name) name, IF(a.deleted_at = ?, ?, ?) status, a.vendor_id, t1.buy_count, t1.buy_price,
|
||||||
COUNT(DISTINCT b.vendor_store_id) buy_count, COUNT(DISTINCT bb.vendor_store_id) finished_count, SUM(DISTINCT b.actual_pay_price) buy_price,
|
t1.good_comment_count, t1.bad_comment_count, t2.finished_count, t2.finished_price
|
||||||
SUM(DISTINCT b.actual_pay_price) finished_price, COUNT(d.score > 3) good_comment_count, COUNT(d.score < 3) bad_comment_count
|
FROM user_member a
|
||||||
FROM user_member a
|
LEFT JOIN user b ON a.mobile = b.mobile
|
||||||
LEFT JOIN goods_order b ON a.mobile = b.consignee_mobile2 AND a.vendor_id = b.vendor_id
|
LEFT JOIN (
|
||||||
LEFT JOIN goods_order bb ON a.mobile = bb.consignee_mobile2 AND bb.status = ? AND a.vendor_id = bb.vendor_id
|
SELECT a.mobile, MAX(b.consignee_name) consignee_name, COUNT(b.vendor_store_id) buy_count, SUM(ISNULL(b.actual_pay_price)) buy_price, COUNT(c.score > 3) good_comment_count, COUNT(c.score < 3) bad_comment_count
|
||||||
LEFT JOIN user c ON c.mobile = a.mobile
|
FROM user_member a
|
||||||
LEFT JOIN jx_bad_comments d ON d.order_id = b.vendor_order_id
|
LEFT JOIN goods_order b ON a.mobile = b.consignee_mobile2 AND a.vendor_id = b.vendor_id AND b.order_type = ? AND b.store_id <> ?
|
||||||
|
LEFT JOIN jx_bad_comments c ON c.order_id = b.vendor_order_id
|
||||||
|
GROUP BY 1
|
||||||
|
) t1 ON t1.mobile = a.mobile
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT a.mobile, COUNT(b.vendor_store_id) finished_count, SUM(ISNULL(b.actual_pay_price)) finished_price
|
||||||
|
FROM user_member a
|
||||||
|
LEFT JOIN goods_order b ON a.mobile = b.consignee_mobile2 AND a.vendor_id = b.vendor_id AND b.order_type = ? AND status = ? AND b.store_id <> ?
|
||||||
|
GROUP BY 1
|
||||||
|
)t2 ON t2.mobile = a.mobile
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
model.VendorIDJX, model.OrderStatusFinished,
|
model.VendorIDJX, utils.DefaultTimeValue, model.YES, model.NO,
|
||||||
|
model.OrderTypeNormal, model.MatterStoreID,
|
||||||
|
model.OrderTypeNormal, model.OrderStatusFinished, model.MatterStoreID,
|
||||||
}
|
}
|
||||||
if vendorID != -1 {
|
if vendorID != -1 {
|
||||||
sql += " AND a.vendor_id = ?"
|
sql += " AND a.vendor_id = ?"
|
||||||
@@ -731,7 +742,6 @@ func UserMemberReport(ctx *jxcontext.Context, vendorID int, keyword string, offs
|
|||||||
sqlParams = append(sqlParams, keywordLike, keywordLike)
|
sqlParams = append(sqlParams, keywordLike, keywordLike)
|
||||||
}
|
}
|
||||||
sql += `
|
sql += `
|
||||||
GROUP BY 1, 2, 3, 4
|
|
||||||
LIMIT ? OFFSET ?
|
LIMIT ? OFFSET ?
|
||||||
`
|
`
|
||||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||||
|
|||||||
@@ -317,3 +317,17 @@ func GetUserMember(db *DaoDB, userID, vendorOrderID, mobile string, vendorID, me
|
|||||||
err = GetRows(db, &userMembers, sql, sqlParams)
|
err = GetRows(db, &userMembers, sql, sqlParams)
|
||||||
return userMembers, err
|
return userMembers, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserMemberWithoutDeleted(db *DaoDB, vendorID int) (userMembers []*model.UserMember, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM user_member
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if vendorID != -1 {
|
||||||
|
sql += " AND vendor_id = ?"
|
||||||
|
sqlParams = append(sqlParams, vendorID)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &userMembers, sql, sqlParams)
|
||||||
|
return userMembers, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -186,12 +186,48 @@ type StoreSkuNameExt struct {
|
|||||||
AuditUnitPrice int `json:"auditUnitPrice"` //审核价格
|
AuditUnitPrice int `json:"auditUnitPrice"` //审核价格
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StoreSkuNameExt2 struct {
|
||||||
|
ID int `orm:"id" json:"id"`
|
||||||
|
|
||||||
|
Prefix string `orm:"size(255)" json:"prefix"`
|
||||||
|
Name string `orm:"size(255)" json:"name"`
|
||||||
|
|
||||||
|
CategoryID int `orm:"column(category_id);index" json:"categoryID"` // 标准类别
|
||||||
|
|
||||||
|
Unit string `orm:"size(8)" json:"unit"`
|
||||||
|
SpecQuality float32 `json:"-"` // 为份必然为500,这个主要作用只是用于确保SkuName的唯一性
|
||||||
|
SpecUnit string `orm:"size(8)" json:"-"` // 为份必然为克,这个主要作用只是用于确保SkuName的唯一性
|
||||||
|
Price int `json:"price"` // 单位为分,标准价,不为份的就为实际标准价,为份的为每市斤价,实际还要乘质量。todo 为份的确定必须有质量
|
||||||
|
Img string `orm:"size(512)" json:"img"`
|
||||||
|
Status int `orm:"default(1)" json:"status"` // skuname状态,取值同sku.Status
|
||||||
|
|
||||||
|
YbNameSuffix string `json:"ybNameSuffix"` //银豹商品后缀
|
||||||
|
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||||
|
StoreName string `json:"storeName"`
|
||||||
|
SkuID int `orm:"column(sku_id)" json:"skuID"`
|
||||||
|
PayPercentage int `json:"-"`
|
||||||
|
UnitPrice int `json:"unitPrice"`
|
||||||
|
Skus []*StoreSkuExt `orm:"-" json:"skus,omitempty"`
|
||||||
|
SkusStr string `json:"-"`
|
||||||
|
|
||||||
|
PendingUnitPrice int `json:"pendingUnitPrice"` // 这个是待审核的价格申请
|
||||||
|
RealMidUnitPrice int `json:"realMidUnitPrice"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
YbSkuName string `json:"ybSkuName"`
|
||||||
|
AuditUnitPrice int `json:"auditUnitPrice"` //审核价格
|
||||||
|
}
|
||||||
|
|
||||||
// GetStoreSkus用
|
// GetStoreSkus用
|
||||||
type StoreSkuNamesInfo struct {
|
type StoreSkuNamesInfo struct {
|
||||||
TotalCount int `json:"totalCount"`
|
TotalCount int `json:"totalCount"`
|
||||||
SkuNames []*StoreSkuNameExt `json:"skuNames"`
|
SkuNames []*StoreSkuNameExt `json:"skuNames"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StoreSkuNamesInfo2 struct {
|
||||||
|
TotalCount int `json:"totalCount"`
|
||||||
|
SkuNames []*StoreSkuNameExt2 `json:"skuNames"`
|
||||||
|
}
|
||||||
|
|
||||||
type StoreSkuVendorInfo struct {
|
type StoreSkuVendorInfo struct {
|
||||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user