Merge branch 'mark' of e.coding.net:rosydev/jx-callback into mark

This commit is contained in:
gazebo
2020-01-07 09:43:41 +08:00
11 changed files with 233 additions and 57 deletions

View File

@@ -1053,7 +1053,7 @@ func GetWayBillByOrderID(db *DaoDB, orderStatus, vendorID, waybillVendorID int,
return wayBillList, err
}
func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID string, fromTime, toTime time.Time, status, stype, IsReverse, offset, pageSize int) (orderSupplementFee []*model.OrderSupplementFee, totalCount int, err error) {
func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs, statuss []int, vendorOrderID string, fromTime, toTime time.Time, stype, IsReverse, offset, pageSize int) (orderSupplementFee []*model.OrderSupplementFee, totalCount int, err error) {
sql := `
SELECT SQL_CALC_FOUND_ROWS *
FROM order_supplement_fee
@@ -1083,9 +1083,9 @@ func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID stri
sql += " AND vendor_order_id = ?"
sqlParams = append(sqlParams, vendorOrderID)
}
if status >= 0 {
sql += " AND status = ?"
sqlParams = append(sqlParams, status)
if len(statuss) > 0 {
sql += " AND status IN (" + GenQuestionMarks(len(statuss)) + ")"
sqlParams = append(sqlParams, statuss)
}
if stype > 0 {
sql += " AND type = ?"
@@ -1096,8 +1096,7 @@ func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID stri
} else if IsReverse == 1 {
sql += " AND link_id <> 0"
}
sql += `
LIMIT ? OFFSET ?`
sql += " LIMIT ? OFFSET ?"
sqlParams = append(sqlParams, pageSize, offset)
Begin(db)
defer Commit(db)
@@ -1106,3 +1105,54 @@ func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID stri
}
return orderSupplementFee, totalCount, err
}
func GetOrdersSupplementNoPage(db *DaoDB, ID int, storIDs, vendorIDs, statuss []int, vendorOrderID string, fromTime, toTime time.Time, stype, IsReverse int) (orderSupplementFee []*model.OrderSupplementFee, err error) {
sql := `
SELECT *
FROM order_supplement_fee
WHERE 1=1
AND deleted_at = ?
`
sqlParams := []interface{}{
utils.DefaultTimeValue,
}
if !utils.IsTimeZero(fromTime) {
sql += " AND supplement_time >= ?"
sqlParams = append(sqlParams, fromTime)
}
if !utils.IsTimeZero(toTime) {
sql += " AND supplement_time <= ?"
sqlParams = append(sqlParams, toTime)
}
if len(storIDs) > 0 {
sql += " AND store_id IN (" + GenQuestionMarks(len(storIDs)) + ")"
sqlParams = append(sqlParams, storIDs)
}
if len(vendorIDs) > 0 {
sql += " AND vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")"
sqlParams = append(sqlParams, vendorIDs)
}
if vendorOrderID != "" {
sql += " AND vendor_order_id = ?"
sqlParams = append(sqlParams, vendorOrderID)
}
if len(statuss) > 0 {
sql += " AND status IN (" + GenQuestionMarks(len(statuss)) + ")"
sqlParams = append(sqlParams, statuss)
}
if stype > 0 {
sql += " AND type = ?"
sqlParams = append(sqlParams, stype)
}
if ID > 0 {
sql += " AND id = ?"
sqlParams = append(sqlParams, ID)
}
if IsReverse == -1 {
sql += " AND link_id = 0"
} else if IsReverse == 1 {
sql += " AND link_id <> 0"
}
err = GetRows(db, &orderSupplementFee, sql, sqlParams...)
return orderSupplementFee, err
}

View File

@@ -189,8 +189,11 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time
}
func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapshot []*model.PriceReferSnapshot, err error) {
sql := `
SELECT b.city_code,a.sku_id,c.name_id,
var sql string
sql1 := `
SELECT a.sku_id, c.name_id,
`
sql2 := `
MAX(a.jd_price) max_jd_price,
MIN(a.jd_price) min_jd_price,
ROUND(AVG(a.jd_price)) avg_jd_price,
@@ -220,6 +223,7 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
)t1 ON t1.sku_id = a.sku_id
WHERE a.deleted_at = ?
`
sql = sql1 + "b.city_code, " + sql2
sqlParams := []interface{}{
utils.DefaultTimeValue,
model.StoreStatusDisabled,
@@ -234,7 +238,19 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
sql += " AND b.city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
sqlParams = append(sqlParams, cityCodes)
}
sql += " GROUP BY 1,2,3"
sql += ` GROUP BY 1,2,3
UNION `
sql += sql1 + "0 city_code," + sql2
if len(skuIDs) > 0 {
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
sqlParams = append(sqlParams, skuIDs)
}
if len(cityCodes) > 0 {
sql += " AND b.city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
sqlParams = append(sqlParams, cityCodes)
}
sql += " GROUP BY 1,2"
sqlParams = append(sqlParams, sqlParams...)
if err = GetRows(db, &priceReferSnapshot, sql, sqlParams...); err == nil {
return priceReferSnapshot, nil
}
@@ -243,9 +259,9 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int, skuNameID int, snapDate time.Time, offset, pageSize int) (priceReferSnapshot []*PriceReferSnapshotExt, totalCount int, err error) {
sql := `
SELECT SQL_CALC_FOUND_ROWS a.*,b.name city_name
SELECT SQL_CALC_FOUND_ROWS a.*,IF(a.city_code = 0,'全国',b.name) city_name
FROM price_refer_snapshot a
JOIN place b ON a.city_code = b.code
LEFT JOIN place b ON a.city_code = b.code
WHERE 1=1
AND a.deleted_at = ?
`

View File

@@ -566,7 +566,7 @@ func GetStorePriceScore(db *DaoDB, storeIDs, vendorIDs []int, fromScore, toScore
func GetStorePriceScoreSnapshot(db *DaoDB, snapDate time.Time) (storePriceScoreSnapshot []*model.StorePriceScoreSnapshot, err error) {
sql := `
SELECT c.store_id,ROUND(count(c.unit_price/IF(d.pay_percentage < 50 , 70, d.pay_percentage) <= a.mid_unit_price or NULL)/count(*)*100,2) score
SELECT c.store_id,ROUND(count(c.unit_price/IF(d.pay_percentage < 50 , 70, d.pay_percentage)*100 <= a.mid_unit_price or NULL)/count(*)*100,2) score
FROM price_refer_snapshot a
JOIN store_sku_bind c ON c.sku_id = a.sku_id AND c.status = ? AND c.deleted_at = ?
JOIN store d ON c.store_id = d.id AND d.city_code = a.city_code AND d.deleted_at = ? AND d.status != ?

View File

@@ -138,6 +138,7 @@ type StoreSkuNameExt struct {
PendingOpType int8 `json:"pendingOpType"` // 取值同 StoreOpRequest.Type
PendingUnitPrice int `json:"pendingUnitPrice"` // 这个是待审核的价格申请
Status int
RealMidUnitPrice int `json:"realMidUnitPrice"`
}
// GetStoreSkus用
@@ -206,11 +207,12 @@ type StoreSkuExt struct {
type SkuNameAndPlace struct {
model.SkuName
CityCode int `json:"cityCode"`
CityName string `json:"cityName"`
Sequence int `json:"sequence"`
Count int `json:"count"`
Type int `json:"type"`
CityCode int `json:"cityCode"`
CityName string `json:"cityName"`
Sequence int `json:"sequence"`
Count int `json:"count"`
Type int `json:"type"`
Skus []*model.SkuAndName `json:"skus"`
}
type StoreSkuPriceAndWeight struct {

View File

@@ -347,8 +347,8 @@ type OrderPayRefund struct {
type OrderSupplementFee struct {
ModelIDCULD
StoreID int `orm:"column(store_id)" json:"storeID"`
VendorOrderID *string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"`
VendorID *string `orm:"column(vendor_id)" json:"vendorID"`
VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"`
VendorID *int `orm:"column(vendor_id);null" json:"vendorID"`
Status int `json:"status"` //账单状态,若已结账则不允许再修改 ,暂时 0为未结账1为已结账,-1为作废
LinkID int `orm:"column(link_id)" json:"linkID"` //作为冲账标志关联某条扣款记录
SupplementTime *time.Time `orm:"type(datetime);null" json:"supplementTime"`

View File

@@ -475,7 +475,7 @@ type PriceReferSnapshot struct {
func (*PriceReferSnapshot) TableUnique() [][]string {
return [][]string{
[]string{"CityCode", "SkuID", "SnapshotAt"},
[]string{"CityCode", "NameID", "SkuID", "SnapshotAt"},
}
}