public async Task <IActionResult> BackStageGetOrderList(BackStageGetOrderListRequestDto requestDto) { var responseDto = await new OrderBiz().BackStageGetOrderListAsync(requestDto, UserID); return(Success(responseDto)); }
/// <summary> /// 后台-订单列表查询 /// </summary> /// <param name="requestDto"></param> /// <param name="userId"></param> /// <returns></returns> public async Task <BackStageGetOrderListResponseDto> BackStageGetOrderListAsync(BackStageGetOrderListRequestDto requestDto, string userId) { var sqlWhere = $" and od.merchant_guid='{userId}' "; if (!string.IsNullOrWhiteSpace(requestDto.OrderStatus.ToString()) && !requestDto.OrderStatus.ToString().ToLower().Equals("all")) { sqlWhere += " and od.order_status=@OrderStatus "; } if (!string.IsNullOrWhiteSpace(requestDto.OderNo)) { sqlWhere += $" and od.order_no ='{requestDto.OderNo}' "; } if (!string.IsNullOrWhiteSpace(requestDto.UserName)) { sqlWhere += " and u.nick_name=@UserName "; } if (!string.IsNullOrWhiteSpace(requestDto.Phone)) { sqlWhere += " and u.phone=@Phone "; } if (!string.IsNullOrWhiteSpace(requestDto.CampaignGuid)) { sqlWhere += " and cam.campaign_guid =@CampaignGuid "; } var isST = !string.IsNullOrWhiteSpace(requestDto.StartTime.ToString()); var isET = !string.IsNullOrWhiteSpace(requestDto.EndTime.ToString()); if (isST) { sqlWhere += $" and (od.creation_date >'{requestDto.StartTime}' )"; } if (isET) { sqlWhere += $" and (od.creation_date<'{requestDto.EndTime}' )"; } if (!string.IsNullOrWhiteSpace(requestDto.OrderReceiver)) { sqlWhere += $" and od.order_receiver like '%{requestDto.OrderReceiver}%' "; } if (!string.IsNullOrWhiteSpace(requestDto.ProductName)) { sqlWhere += $" and pro.product_name like '%{requestDto.ProductName}%' "; } var sql = $@"SELECT distinct od.order_guid, od.user_guid, u.nick_name, od.pay_type, od.paid_amount, od.order_status, od.creation_date FROM t_mall_order AS od LEFT JOIN t_mall_order_detail AS detail ON od.order_guid = detail.order_guid LEFT JOIN t_utility_user AS u ON od.user_guid = u.user_guid LEFT JOIN t_mall_product AS pro ON pro.product_guid = detail.product_guid LEFT JOIN t_mall_campaign AS cam ON cam.product_guid = pro.product_guid WHERE 1 = 1 and od.platform_type='{requestDto.PlatformType}' and od.enable={requestDto.Enable} {sqlWhere} ORDER BY od.creation_date " ; return(await MySqlHelper.QueryByPageAsync <BackStageGetOrderListRequestDto, BackStageGetOrderListResponseDto, BackStageGetOrderListItem>(sql, requestDto)); }