作者 唐旭辉

修复bug

... ... @@ -795,6 +795,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List
listOrderQuery.OrderType,
listOrderQuery.PartnerOrCode,
listOrderQuery.PartnerCategory,
[2]string{listOrderQuery.CreateTimeBegin, listOrderQuery.CreateTimeEnd},
)
if err != nil {
return nil, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -117,7 +117,7 @@ type CustomOrderBonusForExcel struct {
//@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07"
//@return result 查询结果数据
func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, partnerOrCode string,
partnerCategory int) (result []CustomOrderBonusForExcel, err error) {
partnerCategory int, createTime [2]string) (result []CustomOrderBonusForExcel, err error) {
//导出分红列表所用的sql
sqlStr := `SELECT
t1.ID AS order_id,
... ... @@ -167,6 +167,14 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p
sqlStr += ` AND t1.partner_category @>'{"id":?}'`
param = append(param, partnerCategory)
}
if len(createTime[0]) > 0 {
param = append(param, createTime[0])
sqlStr += ` AND t1.create_time>=? `
}
if len(createTime[1]) > 0 {
param = append(param, createTime[1])
sqlStr += ` AND t1.create_time<=? `
}
sqlStr += ` ORDER BY t1.create_time DESC limit 10000 `
tx := dao.transactionContext.GetDB()
_, err = tx.Query(&result, sqlStr, param...)
... ...
... ... @@ -293,11 +293,12 @@ func (c *OrderDividendController) EditOrderRemarkBonus() {
func (c *OrderDividendController) ListOrderBonusForExcel() {
type Parameter struct {
SearchWord string `json:"searchWord"`
OrderType int `json:"orderType"`
PageSize int `json:"pageSize"`
PageNumber int `json:"pageNumber"`
PartnerCategoryId int `json:"partnerCategoryId"`
SearchWord string `json:"searchWord"`
OrderType int `json:"orderType"`
PageSize int `json:"pageSize"`
PageNumber int `json:"pageNumber"`
PartnerCategoryId int `json:"partnerCategoryId"`
CreateTime []string `json:"createTime"`
}
var (
param Parameter
... ... @@ -314,7 +315,32 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
c.ResponseError(errors.New("参数异常"))
return
}
var (
createTimeBegin string
createTimeEnd string
)
if len(param.CreateTime) > 0 {
if len(param.CreateTime[0]) > 0 {
t, err := time.ParseInLocation("2006-01-02", param.CreateTime[0], time.Local)
if err != nil {
c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误"))
return
}
createTimeBegin = t.Format("2006-01-02 15:04:05-07")
}
}
if len(param.CreateTime) > 1 {
if len(param.CreateTime[1]) > 0 {
t, err := time.ParseInLocation("2006-01-02", param.CreateTime[1], time.Local)
if err != nil {
c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误"))
return
}
//设定时间边界
t = t.Add(86399 * time.Second)
createTimeEnd = t.Format("2006-01-02 15:04:05-07")
}
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
dataResult, column, err := orderSrv.ListOrderBonusForExcel(
... ... @@ -323,6 +349,8 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
PartnerOrCode: param.SearchWord,
CompanyId: companyId,
PartnerCategory: param.PartnerCategoryId,
CreateTimeBegin: createTimeBegin,
CreateTimeEnd: createTimeEnd,
})
if err != nil {
c.ResponseError(err)
... ...