- add cities in GetOrders.

This commit is contained in:
gazebo
2018-10-10 10:16:54 +08:00
parent 1b15b864a8
commit 3a96150c3e
3 changed files with 20 additions and 7 deletions

View File

@@ -243,6 +243,8 @@ func (c *OrderManager) GetOrders(fromDateStr, toDateStr string, params map[strin
SELECT SQL_CALC_FOUND_ROWS t1.*, t2.status waybill_status, t2.courier_name, t2.courier_mobile
FROM goods_order t1
LEFT JOIN waybill t2 ON t1.vendor_waybill_id = t2.vendor_waybill_id AND t1.waybill_vendor_id = t2.waybill_vendor_id
`
sqlWhere := `
WHERE t1.order_created_at >= ? AND t1.order_created_at < ?
`
sqlParams := []interface{}{
@@ -252,21 +254,21 @@ func (c *OrderManager) GetOrders(fromDateStr, toDateStr string, params map[strin
if params["keyword"] != nil {
keyword := params["keyword"].(string)
keywordLike := "%" + keyword + "%"
sql += `
sqlWhere += `
AND (t1.store_name LIKE ? OR t1.vendor_order_id LIKE ? OR t1.vendor_store_id LIKE ?
OR t1.consignee_name LIKE ? OR t1.consignee_mobile LIKE ? OR t1.consignee_address LIKE ?
OR t2.vendor_waybill_id LIKE ? OR t2.courier_name LIKE ? OR t2.courier_mobile LIKE ?
`
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
sql += " OR t1.store_id = ? OR t1.jx_store_id = ?"
sqlWhere += " OR t1.store_id = ? OR t1.jx_store_id = ?"
sqlParams = append(sqlParams, keywordInt64, keywordInt64)
}
sql += ")"
sqlWhere += ")"
}
if params["vendorID"] != nil {
sql += " AND t1.vendor_id = ?"
sqlWhere += " AND t1.vendor_id = ?"
sqlParams = append(sqlParams, params["vendorID"])
}
if params["storeIDs"] != nil {
@@ -274,7 +276,7 @@ func (c *OrderManager) GetOrders(fromDateStr, toDateStr string, params map[strin
if err = utils.UnmarshalUseNumber([]byte(params["storeIDs"].(string)), &storeIDs); err != nil {
return nil, err
}
sql += " AND IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
sqlWhere += " AND IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
sqlParams = append(sqlParams, storeIDs)
}
if params["statuss"] != nil {
@@ -282,10 +284,20 @@ func (c *OrderManager) GetOrders(fromDateStr, toDateStr string, params map[strin
if err = utils.UnmarshalUseNumber([]byte(params["statuss"].(string)), &statuss); err != nil {
return nil, err
}
sql += " AND t1.status IN (" + dao.GenQuestionMarks(len(statuss)) + ")"
sqlWhere += " AND t1.status IN (" + dao.GenQuestionMarks(len(statuss)) + ")"
sqlParams = append(sqlParams, statuss)
}
if params["cities"] != nil {
var cities []int
if err = utils.UnmarshalUseNumber([]byte(params["cities"].(string)), &cities); err != nil {
return nil, err
}
sql += " JOIN store st ON t1.store_id = st.id"
sqlWhere += " AND st.city_code IN (" + dao.GenQuestionMarks(len(cities)) + ")"
sqlParams = append(sqlParams, cities)
}
sql += sqlWhere
sql += `
ORDER BY t1.vendor_order_id
LIMIT ? OFFSET ?

View File

@@ -36,7 +36,7 @@ func (c *FinancialController) SendFilesToStores() {
c.callSendFilesToStores(func(params *tFinancialSendFilesToStoresParams) (retVal interface{}, errCode string, err error) {
r := c.Ctx.Request
files := r.MultipartForm.File["userfiles"]
retVal, err = financial.SendFilesToStores(files, params.IsAsync, "test")
retVal, err = financial.SendFilesToStores(files, params.IsAsync, GetUserNameFromToken(params.Token))
return retVal, "", err
})
}

View File

@@ -213,6 +213,7 @@ func (c *OrderController) ExportMTWaybills() {
// @Param vendorID query int false "订单所属厂商"
// @Param storeIDs query string false "京西门店ID列表[1,2,3],缺省不限制"
// @Param statuss query string false "订单状态列表[1,2,3],缺省不限制"
// @Param cities query string false "城市code列表[1,2,3],缺省不限制"
// @Param offset query int false "结果起始序号以0开始缺省为0"
// @Param pageSize query int false "结果页大小缺省为500表示不限制"
// @Success 200 {object} controllers.CallResult