Merge remote-tracking branch 'origin/mark' into don
This commit is contained in:
@@ -150,13 +150,14 @@ func GetStoresOrderSaleInfo(db *DaoDB, storeIDList []int, fromTime time.Time, to
|
||||
}
|
||||
|
||||
// 用int64类型去取float型的数据库返回值,会取不到
|
||||
// order_finished_at
|
||||
sql := fmt.Sprintf(`
|
||||
SELECT IF(t1.jx_store_id > 0, t1.jx_store_id, t1.store_id) store_id, t1.vendor_id, IF(t1.status < ?, 0, t1.status) status,
|
||||
COUNT(*) count, SUM(t1.shop_price) shop_price, SUM(t1.vendor_price) vendor_price, SUM(t1.sale_price) sale_price, SUM(t1.actual_pay_price) actual_pay_price,
|
||||
CAST(SUM(IF(t1.earning_price <> 0, t1.earning_price, IF(t1.shop_price <> 0 && t1.shop_price < t1.sale_price, t1.shop_price, t1.sale_price) * IF(t5.pay_percentage > 0, t5.pay_percentage, %d) / 100)) AS SIGNED) earning_price
|
||||
FROM goods_order t1
|
||||
LEFT JOIN store t5 ON t5.id = IF(t1.jx_store_id <> 0, t1.jx_store_id, t1.store_id)
|
||||
WHERE t1.order_finished_at >= ? AND t1.order_finished_at <= ?
|
||||
WHERE t1.order_created_at >= ? AND t1.order_created_at <= ?
|
||||
`, model.DefaultEarningPricePercentage)
|
||||
sqlParams := []interface{}{
|
||||
model.OrderStatusEndBegin,
|
||||
@@ -228,6 +229,7 @@ func GetAfsOrderSkuInfo(db *DaoDB, vendorOrderID, afsOrderID string, vendorID in
|
||||
}
|
||||
|
||||
func GetStoreOrderSkuList(db *DaoDB, storeIDs []int, finishedAtBegin, finishedAtEnd time.Time, statusList []int) (skuList []*OrderSkuWithActualPayPrice, err error) {
|
||||
// order_finished_at
|
||||
sql := `
|
||||
SELECT t1.*,
|
||||
t2.actual_pay_price, t2.status, IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) store_id,
|
||||
@@ -235,12 +237,15 @@ func GetStoreOrderSkuList(db *DaoDB, storeIDs []int, finishedAtBegin, finishedAt
|
||||
FROM order_sku t1
|
||||
JOIN goods_order t2 ON t2.vendor_order_id = t1.vendor_order_id AND t2.vendor_id = t1.vendor_id
|
||||
LEFT JOIN store t3 ON t3.id = IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id)
|
||||
WHERE IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) IN (` + GenQuestionMarks(len(storeIDs)) + `) AND t2.order_finished_at >= ? AND t2.order_finished_at <= ?`
|
||||
WHERE t2.order_created_at >= ? AND t2.order_created_at <= ?`
|
||||
sqlParams := []interface{}{
|
||||
storeIDs,
|
||||
finishedAtBegin,
|
||||
finishedAtEnd,
|
||||
}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
if len(statusList) > 0 {
|
||||
sql += " AND t2.status IN (" + GenQuestionMarks(len(statusList)) + ")"
|
||||
sqlParams = append(sqlParams, statusList)
|
||||
@@ -276,13 +281,15 @@ func GetStoreAfsOrderSkuList(db *DaoDB, storeIDs []int, finishedAtBegin, finishe
|
||||
SELECT t1.*
|
||||
FROM order_sku_financial t1
|
||||
JOIN afs_order t2 ON t2.vendor_order_id = t1.vendor_order_id AND t2.vendor_id = t1.vendor_id
|
||||
WHERE t1.is_afs_order = 1
|
||||
AND IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) IN (` + GenQuestionMarks(len(storeIDs)) + `) AND t2.afs_finished_at >= ? AND t2.afs_finished_at <= ?`
|
||||
WHERE t1.is_afs_order = 1 AND t2.afs_finished_at >= ? AND t2.afs_finished_at <= ?`
|
||||
sqlParams := []interface{}{
|
||||
storeIDs,
|
||||
finishedAtBegin,
|
||||
finishedAtEnd,
|
||||
}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
if len(statusList) > 0 {
|
||||
sql += " AND t2.status IN (" + GenQuestionMarks(len(statusList)) + ")"
|
||||
sqlParams = append(sqlParams, statusList)
|
||||
|
||||
@@ -99,7 +99,7 @@ func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityN
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM store t1
|
||||
WHERE (t1.market_man_phone = ? OR t1.operator_phone = ?)
|
||||
WHERE (t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ?)
|
||||
UNION DISTINCT
|
||||
SELECT t1.*
|
||||
FROM store t1
|
||||
@@ -111,6 +111,7 @@ func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityN
|
||||
WHERE t1.deleted_at = ?
|
||||
ORDER BY t1.name`
|
||||
sqlParams := []interface{}{
|
||||
mobile,
|
||||
mobile,
|
||||
mobile,
|
||||
mobile,
|
||||
@@ -132,8 +133,8 @@ func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, shortRoleNameList
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if mobile != "" {
|
||||
sql += " OR t1.market_man_phone = ? OR t1.operator_phone = ?"
|
||||
sqlParams = append(sqlParams, mobile, mobile)
|
||||
sql += " OR t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ?"
|
||||
sqlParams = append(sqlParams, mobile, mobile, mobile)
|
||||
}
|
||||
if len(shortRoleNameList) > 0 {
|
||||
questionMarks := GenQuestionMarks(len(shortRoleNameList))
|
||||
|
||||
@@ -47,6 +47,12 @@ type StoreDetail2 struct {
|
||||
CityName string `json:"cityName"`
|
||||
}
|
||||
|
||||
type CityBrankBranch struct {
|
||||
CityCode int
|
||||
PayeeBankBranchName string `orm:"size(255)" json:"payeeBankBranchName"` // 开户支行
|
||||
PayeeBankCode string `orm:"size(8)" json:"payeeBankCode"` // 开户行代码
|
||||
}
|
||||
|
||||
func (s *StoreDetail) GetPricePerentage(price int) (pricePercentage int) {
|
||||
return pricePercentage
|
||||
}
|
||||
@@ -484,3 +490,26 @@ func GetStoreList(db *DaoDB, idList []int, mobileList []string, shortRoleName st
|
||||
err = GetRows(db, &storeList, sql, sqlParams...)
|
||||
return storeList, err
|
||||
}
|
||||
|
||||
func GetCityBankBranches(db *DaoDB, cityCode int, bankCode string) (list []*CityBrankBranch, err error) {
|
||||
sql := `
|
||||
SELECT payee_bank_code, city_code, payee_bank_branch_name
|
||||
FROM store
|
||||
WHERE payee_bank_branch_name <> ''`
|
||||
sqlParams := []interface{}{}
|
||||
if cityCode > 0 {
|
||||
sql += " AND city_code = ?"
|
||||
sqlParams = append(sqlParams, cityCode)
|
||||
} else {
|
||||
sql += " AND city_code <> 0"
|
||||
}
|
||||
if bankCode != "" {
|
||||
sql += " AND payee_bank_code = ?"
|
||||
sqlParams = append(sqlParams, bankCode)
|
||||
} else {
|
||||
sql += " AND payee_bank_code <> ''"
|
||||
}
|
||||
sql += " GROUP BY 1,2,3;"
|
||||
err = GetRows(db, &list, sql, sqlParams...)
|
||||
return list, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user