作者 唐旭辉

修复bug

@@ -795,6 +795,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List @@ -795,6 +795,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List
795 listOrderQuery.OrderType, 795 listOrderQuery.OrderType,
796 listOrderQuery.PartnerOrCode, 796 listOrderQuery.PartnerOrCode,
797 listOrderQuery.PartnerCategory, 797 listOrderQuery.PartnerCategory,
  798 + [2]string{listOrderQuery.CreateTimeBegin, listOrderQuery.CreateTimeEnd},
798 ) 799 )
799 if err != nil { 800 if err != nil {
800 return nil, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 801 return nil, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
@@ -117,7 +117,7 @@ type CustomOrderBonusForExcel struct { @@ -117,7 +117,7 @@ type CustomOrderBonusForExcel struct {
117 //@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07" 117 //@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07"
118 //@return result 查询结果数据 118 //@return result 查询结果数据
119 func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, partnerOrCode string, 119 func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, partnerOrCode string,
120 - partnerCategory int) (result []CustomOrderBonusForExcel, err error) { 120 + partnerCategory int, createTime [2]string) (result []CustomOrderBonusForExcel, err error) {
121 //导出分红列表所用的sql 121 //导出分红列表所用的sql
122 sqlStr := `SELECT 122 sqlStr := `SELECT
123 t1.ID AS order_id, 123 t1.ID AS order_id,
@@ -167,6 +167,14 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p @@ -167,6 +167,14 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p
167 sqlStr += ` AND t1.partner_category @>'{"id":?}'` 167 sqlStr += ` AND t1.partner_category @>'{"id":?}'`
168 param = append(param, partnerCategory) 168 param = append(param, partnerCategory)
169 } 169 }
  170 + if len(createTime[0]) > 0 {
  171 + param = append(param, createTime[0])
  172 + sqlStr += ` AND t1.create_time>=? `
  173 + }
  174 + if len(createTime[1]) > 0 {
  175 + param = append(param, createTime[1])
  176 + sqlStr += ` AND t1.create_time<=? `
  177 + }
170 sqlStr += ` ORDER BY t1.create_time DESC limit 10000 ` 178 sqlStr += ` ORDER BY t1.create_time DESC limit 10000 `
171 tx := dao.transactionContext.GetDB() 179 tx := dao.transactionContext.GetDB()
172 _, err = tx.Query(&result, sqlStr, param...) 180 _, err = tx.Query(&result, sqlStr, param...)
@@ -293,11 +293,12 @@ func (c *OrderDividendController) EditOrderRemarkBonus() { @@ -293,11 +293,12 @@ func (c *OrderDividendController) EditOrderRemarkBonus() {
293 293
294 func (c *OrderDividendController) ListOrderBonusForExcel() { 294 func (c *OrderDividendController) ListOrderBonusForExcel() {
295 type Parameter struct { 295 type Parameter struct {
296 - SearchWord string `json:"searchWord"`  
297 - OrderType int `json:"orderType"`  
298 - PageSize int `json:"pageSize"`  
299 - PageNumber int `json:"pageNumber"`  
300 - PartnerCategoryId int `json:"partnerCategoryId"` 296 + SearchWord string `json:"searchWord"`
  297 + OrderType int `json:"orderType"`
  298 + PageSize int `json:"pageSize"`
  299 + PageNumber int `json:"pageNumber"`
  300 + PartnerCategoryId int `json:"partnerCategoryId"`
  301 + CreateTime []string `json:"createTime"`
301 } 302 }
302 var ( 303 var (
303 param Parameter 304 param Parameter
@@ -314,7 +315,32 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { @@ -314,7 +315,32 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
314 c.ResponseError(errors.New("参数异常")) 315 c.ResponseError(errors.New("参数异常"))
315 return 316 return
316 } 317 }
317 - 318 + var (
  319 + createTimeBegin string
  320 + createTimeEnd string
  321 + )
  322 + if len(param.CreateTime) > 0 {
  323 + if len(param.CreateTime[0]) > 0 {
  324 + t, err := time.ParseInLocation("2006-01-02", param.CreateTime[0], time.Local)
  325 + if err != nil {
  326 + c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误"))
  327 + return
  328 + }
  329 + createTimeBegin = t.Format("2006-01-02 15:04:05-07")
  330 + }
  331 + }
  332 + if len(param.CreateTime) > 1 {
  333 + if len(param.CreateTime[1]) > 0 {
  334 + t, err := time.ParseInLocation("2006-01-02", param.CreateTime[1], time.Local)
  335 + if err != nil {
  336 + c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误"))
  337 + return
  338 + }
  339 + //设定时间边界
  340 + t = t.Add(86399 * time.Second)
  341 + createTimeEnd = t.Format("2006-01-02 15:04:05-07")
  342 + }
  343 + }
318 companyId := c.GetUserCompany() 344 companyId := c.GetUserCompany()
319 orderSrv := orderService.NewOrderInfoService(nil) 345 orderSrv := orderService.NewOrderInfoService(nil)
320 dataResult, column, err := orderSrv.ListOrderBonusForExcel( 346 dataResult, column, err := orderSrv.ListOrderBonusForExcel(
@@ -323,6 +349,8 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { @@ -323,6 +349,8 @@ func (c *OrderDividendController) ListOrderBonusForExcel() {
323 PartnerOrCode: param.SearchWord, 349 PartnerOrCode: param.SearchWord,
324 CompanyId: companyId, 350 CompanyId: companyId,
325 PartnerCategory: param.PartnerCategoryId, 351 PartnerCategory: param.PartnerCategoryId,
  352 + CreateTimeBegin: createTimeBegin,
  353 + CreateTimeEnd: createTimeEnd,
326 }) 354 })
327 if err != nil { 355 if err != nil {
328 c.ResponseError(err) 356 c.ResponseError(err)