|
@@ -1,9 +1,12 @@
|
|
|
package com.szwl.controller;
|
|
|
|
|
|
|
|
|
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
import cn.com.crbank.ommo.bean.ResultMessage;
|
|
|
import cn.com.crbank.ommo.esclient.ElasticsearchRunner;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -11,11 +14,21 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.szwl.feign.SzwlFeign;
|
|
|
import com.szwl.feign.bean.TAdminParam;
|
|
|
import com.szwl.model.bean.ChartColumn;
|
|
|
+import com.szwl.model.bean.OrderDaoChuDTO;
|
|
|
+import com.szwl.model.bean.OrderVo;
|
|
|
+import com.szwl.model.bo.JsonMessage;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
|
import com.szwl.model.entity.*;
|
|
|
+import com.szwl.model.excel.CoinOrderTarget;
|
|
|
+import com.szwl.model.excel.OrderByAdminTarget;
|
|
|
+import com.szwl.model.excel.OrderByClientidTarget;
|
|
|
+import com.szwl.model.excel.OrderTarget;
|
|
|
+import com.szwl.model.query.Filter;
|
|
|
+import com.szwl.model.query.Pageable;
|
|
|
import com.szwl.model.query.StatisticsParam;
|
|
|
import com.szwl.model.utils.FgObjectUtil;
|
|
|
+import com.szwl.service.TAreaService;
|
|
|
import com.szwl.service.TCoinOrderService;
|
|
|
import com.szwl.service.TOrderService;
|
|
|
import com.szwl.service.es.EsTEquipmentService;
|
|
@@ -23,13 +36,22 @@ import com.szwl.service.es.EsTOrderService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.commons.lang.time.DateUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
@@ -49,6 +71,8 @@ public class TOrderController {
|
|
|
@Autowired
|
|
|
TOrderService orderService;
|
|
|
@Autowired
|
|
|
+ TAreaService areaService;
|
|
|
+ @Autowired
|
|
|
EsTOrderService esTOrderService;
|
|
|
@Autowired
|
|
|
EsTEquipmentService esTEquipmentService;
|
|
@@ -57,7 +81,7 @@ public class TOrderController {
|
|
|
@Autowired
|
|
|
SzwlFeign szwlFeign;
|
|
|
@GetMapping("/pageOrder")
|
|
|
- public ResponseModel<IPage<?>> pageAd(String adminId,String adminType,String type,String userName,String payType,String productNo,String clientId,String dateType, Date stratDate, Date endDate, long current, long size ) {
|
|
|
+ public ResponseModel<IPage<?>> pageOrder(String adminId,String adminType,String type,String userName,String payType,String productNo,String clientId,String dateType, Date stratDate, Date endDate, long current, long size ) {
|
|
|
//判断当前账号状态
|
|
|
TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(adminId));
|
|
|
//类型
|
|
@@ -254,6 +278,7 @@ public class TOrderController {
|
|
|
}
|
|
|
return "0";
|
|
|
}
|
|
|
+ @ApiOperation(value = "获取首页数据统计")
|
|
|
@PostMapping("/getStatistics")
|
|
|
public ResponseEntity<?> getStatistics(@RequestBody StatisticsParam param) {
|
|
|
// 判断是否为外国
|
|
@@ -267,6 +292,12 @@ public class TOrderController {
|
|
|
TEquipment equipment = R.getDataIfSuccess(szwlFeign.findById(param.getEquipmentId()));
|
|
|
param.setClientId(equipment.getClientId());
|
|
|
}
|
|
|
+ if(StringUtils.isNotEmpty(param.getClientId())){
|
|
|
+ //补全clientId
|
|
|
+ TEquipment tEquipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(param.getClientId()));
|
|
|
+ param.setClientId(tEquipment.getClientId());
|
|
|
+ param.setClientId(tEquipment.getClientId());
|
|
|
+ }
|
|
|
}else {
|
|
|
if(admin.getType()==2){
|
|
|
//商家
|
|
@@ -274,15 +305,65 @@ public class TOrderController {
|
|
|
//查机器
|
|
|
TEquipment equipment = R.getDataIfSuccess(szwlFeign.findById(param.getEquipmentId()));
|
|
|
param.setClientId(equipment.getClientId());
|
|
|
+
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(param.getClientId())){
|
|
|
+ param.setAdminId(null);
|
|
|
+ //判断是否是这个商家的
|
|
|
+ TEquipment tEquipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(param.getClientId()));
|
|
|
+ if(tEquipment.getAdminId().toString().equals(admin.getId().toString())){
|
|
|
+ param.setClientId(tEquipment.getClientId());
|
|
|
+ param.setEquipmentId(String.valueOf(tEquipment.getId()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if(admin.getType()==3){
|
|
|
//子账户只能查相对的机器的订单
|
|
|
- if(param.getEquipmentId()==null){
|
|
|
- //找出相对的clientId集合
|
|
|
+ //商家子账户
|
|
|
+ if(param.getEquipmentId()!=null){
|
|
|
+ //查机器
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findById(param.getEquipmentId()));
|
|
|
+ param.setClientId(equipment.getClientId());
|
|
|
|
|
|
- }else {
|
|
|
+ }else{
|
|
|
+ TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getId())));
|
|
|
+ if(adminEquipment.getType().equals("0")){
|
|
|
+ TAdmin admin1 = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
|
|
|
+ param.setAdminId(admin1.getId().toString());
|
|
|
+ }else {
|
|
|
+ List<String> list = R.getDataIfSuccess(szwlFeign.getClientIds(param.getAdminId()));
|
|
|
+ param.setClientIds(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(param.getClientId())){
|
|
|
+ param.setAdminId(null);
|
|
|
+ //判断是否是这个子账号的
|
|
|
+ TEquipment tEquipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(param.getClientId()));
|
|
|
+
|
|
|
+ TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getId())));
|
|
|
+ if(adminEquipment.getType().equals("0")){
|
|
|
+ TAdmin admin1 = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
|
|
|
+ if(tEquipment.getAdminId().toString().equals(admin1.getId())){
|
|
|
+ param.setAdminId(null);
|
|
|
+ param.setClientId(tEquipment.getClientId());
|
|
|
+ param.setEquipmentId(String.valueOf(tEquipment.getId()));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ int i = 0;
|
|
|
+ List<String> list = R.getDataIfSuccess(szwlFeign.getClientIds(param.getAdminId()));
|
|
|
+ if(list.size()>0){
|
|
|
+ for(String clientID:list){
|
|
|
+ if(clientID.equals(tEquipment.getClientId())){
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(i>0){
|
|
|
+ param.setClientId(tEquipment.getClientId());
|
|
|
+ param.setEquipmentId(String.valueOf(tEquipment.getId()));
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -368,6 +449,7 @@ public class TOrderController {
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
+ @ApiOperation(value = "机器销售排行统计")
|
|
|
@PostMapping("/getEquipmentStatistics")
|
|
|
public ResponseEntity<?> getEquipmentStatistics(@RequestBody StatisticsParam param) {
|
|
|
// 判断是否为外国
|
|
@@ -375,10 +457,41 @@ public class TOrderController {
|
|
|
log.info("param:{}", param);
|
|
|
FgObjectUtil.objectNullOrEmptySel(param, "chartType$");
|
|
|
ChartColumn chartColumn = new ChartColumn();
|
|
|
-// if(StringUtils.isNotEmpty(param.getIfForeign())&¶m.getIfForeign().equals("1")){
|
|
|
-// //国外查MYSQL
|
|
|
-// chartColumn = tOrderService.getEquipmentStatistics(param);
|
|
|
-// }else{
|
|
|
+ if(StringUtils.isNotEmpty(param.getIfForeign())&¶m.getIfForeign().equals("1")){
|
|
|
+ //国外
|
|
|
+// chartColumn = orderService.getEquipmentStatistics(param);
|
|
|
+ chartColumn = esTEquipmentService.getEquipmentStatistics(param);
|
|
|
+ }else{
|
|
|
+ //查去年的数据找数据库
|
|
|
+ String endDate = param.getEndDate();
|
|
|
+ String toYear = "2022-01-01 00:00:00";
|
|
|
+ Date date = new Date();
|
|
|
+ Date year = new Date();
|
|
|
+ SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ try {
|
|
|
+ //使用SimpleDateFormat的parse()方法生成Date
|
|
|
+ date = sf.parse(endDate);
|
|
|
+ year = sf.parse(toYear);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if(date.getTime()<year.getTime()){
|
|
|
+ chartColumn = orderService.getEquipmentStatistics(param);
|
|
|
+ }else {
|
|
|
+ if (ElasticsearchRunner.ES_RUNNING) {
|
|
|
+ try {
|
|
|
+ // 查es
|
|
|
+ chartColumn = esTEquipmentService.getEquipmentStatistics(param);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("使用es 查询发生错误:{}",e);
|
|
|
+ // 查 mysql
|
|
|
+// chartColumn = tOrderService.getStatistics(param);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 查 mysql
|
|
|
+// chartColumn = tOrderService.getStatistics(param);
|
|
|
+ }
|
|
|
+ }
|
|
|
// if (ElasticsearchRunner.ES_RUNNING) {
|
|
|
// try {
|
|
|
// // 查es
|
|
@@ -392,15 +505,15 @@ public class TOrderController {
|
|
|
// // 查 mysql
|
|
|
//// chartColumn = tOrderService.getEquipmentStatistics(param);
|
|
|
// }
|
|
|
-// }
|
|
|
- try {
|
|
|
- // 查es
|
|
|
- chartColumn = esTEquipmentService.getEquipmentStatistics(param);
|
|
|
- }catch (Exception e){
|
|
|
- log.error("使用es 查询发生错误:{}",e);
|
|
|
- // 查 mysql
|
|
|
-// chartColumn = tOrderService.getEquipmentStatistics(param);
|
|
|
}
|
|
|
+// try {
|
|
|
+// // 查es
|
|
|
+// chartColumn = esTEquipmentService.getEquipmentStatistics(param);
|
|
|
+// }catch (Exception e){
|
|
|
+// log.error("使用es 查询发生错误:{}",e);
|
|
|
+// // 查 mysql
|
|
|
+//// chartColumn = tOrderService.getEquipmentStatistics(param);
|
|
|
+// }
|
|
|
// if (ElasticsearchRunner.ES_RUNNING) {
|
|
|
// try {
|
|
|
// // 查es
|
|
@@ -422,5 +535,500 @@ public class TOrderController {
|
|
|
.setData(chartColumn)
|
|
|
.setMessage("SUCCESS"));
|
|
|
}
|
|
|
+
|
|
|
+ //查询线上订单
|
|
|
+ @ApiOperation(value = "查询线上订单")
|
|
|
+ @RequestMapping(value = "/findOrder", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
|
|
|
+ @ResponseBody
|
|
|
+ public Object findOrder(String clientId, String sn, String productName, String status, Date begin, Date end, Pageable pageable) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
+ if (StringUtils.isNotEmpty(sn)) {
|
|
|
+ query.like(TOrder::getSn,sn);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(productName)) {
|
|
|
+ query.like(TOrder::getProductName,productName);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(status)) {
|
|
|
+ if(status.equals("unpay")){
|
|
|
+ query.eq(TOrder::getStatus,0);
|
|
|
+ }
|
|
|
+ if(status.equals("pay")){
|
|
|
+ query.eq(TOrder::getStatus,1);
|
|
|
+ }
|
|
|
+ if(status.equals("refund")){
|
|
|
+ query.eq(TOrder::getStatus,3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (begin != null && end != null) {
|
|
|
+ query.gt(TOrder::getCreateDate,begin);
|
|
|
+ query.lt(TOrder::getCreateDate,end);
|
|
|
+ }
|
|
|
+ query.like(TOrder::getClientId,clientId);
|
|
|
+
|
|
|
+ int size = pageable.getPageSize();
|
|
|
+ int current = pageable.getPageNumber();
|
|
|
+ Page<TOrder> page = new Page<>(current, size, true);
|
|
|
+ IPage<TOrder> iPage = orderService.page(page, query);
|
|
|
+ long total = page.getTotal();
|
|
|
+ List<TOrder> content = iPage.getRecords();
|
|
|
+// List<Order> content = page.getContent();
|
|
|
+ ArrayList<OrderVo> orderVos = new ArrayList<>();
|
|
|
+ for (TOrder order : content) {
|
|
|
+ OrderVo orderVo = new OrderVo();
|
|
|
+ orderVo.setSn(order.getSn());
|
|
|
+ orderVo.setProductName(order.getProductName());
|
|
|
+ orderVo.setPrice(order.getPrice());
|
|
|
+ orderVo.setTrxNo(order.getTrxNo());
|
|
|
+ orderVo.setRefundTrxNo(order.getRefundTrxNo());
|
|
|
+ orderVo.setRefundAmount(order.getRefundAmount());
|
|
|
+ orderVo.setPayDate(order.getPayDate());
|
|
|
+ orderVo.setRefundDate(order.getRefundDate());
|
|
|
+ if(order.getStatus()==0){
|
|
|
+ orderVo.setStatus(OrderVo.Status.unpay);
|
|
|
+ }
|
|
|
+ if(order.getStatus()==1){
|
|
|
+ orderVo.setStatus(OrderVo.Status.pay);
|
|
|
+ }
|
|
|
+ if(order.getStatus()==3){
|
|
|
+ orderVo.setStatus(OrderVo.Status.refund);
|
|
|
+ }
|
|
|
+ orderVo.setCreateDate(order.getCreateDate());
|
|
|
+ orderVo.setFrp_code(order.getFrpCode());
|
|
|
+ orderVos.add(orderVo);
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("total", total);
|
|
|
+ jsonObject.put("orders", com.gexin.fastjson.JSON.toJSONString(orderVos));
|
|
|
+ return jsonObject.toJSONString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单数据导出
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "订单数据导出-查询")
|
|
|
+ @RequestMapping(value = "/orderSelect", method = RequestMethod.GET)
|
|
|
+ public String orderSelect(String type, String clientId, String username, String beginEndDate, long current, long size) {
|
|
|
+ if(size>50){
|
|
|
+ return "error";
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ Long adminId = null;
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ long time = end.getTime() - begin.getTime();
|
|
|
+ if(time>31*24*60*60*1000l){
|
|
|
+ return "error";
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(username)){
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdminByUsername(username));
|
|
|
+ adminId = admin.getId();
|
|
|
+ }
|
|
|
+ List<OrderDaoChuDTO> OrderDaoChuDTOList =orderService.orderDaoChu(begin,end,adminId,clientId,type,current,size);
|
|
|
+ for(OrderDaoChuDTO orderDaoChuDTO: OrderDaoChuDTOList){
|
|
|
+ String adminId1 = orderDaoChuDTO.getAdminId().toString();
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(adminId1));
|
|
|
+ if(admin==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ orderDaoChuDTO.setPhone(admin.getPhone());
|
|
|
+ orderDaoChuDTO.setUsername(admin.getUsername());
|
|
|
+ orderDaoChuDTO.setName(admin.getName());
|
|
|
+ if(!StringUtils.isEmpty(type)&&type.equals("2")){
|
|
|
+ //商户为单位
|
|
|
+ TAdmin parent = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
|
|
|
+ orderDaoChuDTO.setLastUsername(parent.getUsername());
|
|
|
+ TArea area = areaService.getById(admin.getAreaId());
|
|
|
+ if(area!=null){
|
|
|
+ orderDaoChuDTO.setAddress(area.getFullName());
|
|
|
+ }
|
|
|
+ List<String> stringList = R.getDataIfSuccess(szwlFeign.getClientIds(String.valueOf(admin.getId())));
|
|
|
+ orderDaoChuDTO.setEquipmentTotal(String.valueOf(stringList.size()));
|
|
|
+ }else {
|
|
|
+ //设备为单位
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(String.valueOf(orderDaoChuDTO.getClientId())));
|
|
|
+ if(equipment!=null){
|
|
|
+ if(StringUtils.isNotEmpty(equipment.getFullName())){
|
|
|
+ orderDaoChuDTO.setAddress(equipment.getFullName());
|
|
|
+ }
|
|
|
+ orderDaoChuDTO.setEquipmentType(equipment.getEquimentType());
|
|
|
+ orderDaoChuDTO.setCreateDate(equipment.getCreateDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ jsonObject.put("OrderDaoChuDTOList", OrderDaoChuDTOList);
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(type)&&type.equals("2")){
|
|
|
+ IPage<TAdmin> iPage = R.getDataIfSuccess(szwlFeign.pageAdmin2(current, size));
|
|
|
+
|
|
|
+ }else {
|
|
|
+ IPage<TEquipment> page = R.getDataIfSuccess(szwlFeign.pageEquipment2(current, size));
|
|
|
+ jsonObject.put("page", page);
|
|
|
+ }
|
|
|
+
|
|
|
+ return jsonObject.toJSONString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单数据导出
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "订单数据导出-导出")
|
|
|
+ @RequestMapping(value = "/orderExport", method = RequestMethod.GET)
|
|
|
+ public Object orderExport(HttpServletResponse response, String type, String clientId, String username, String beginEndDate, long current, long size) {
|
|
|
+ if(size>500){
|
|
|
+ return JsonMessage.success("页数过大");
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(beginEndDate)) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date begin = null;
|
|
|
+ Date end = null;
|
|
|
+ Long adminId = null;
|
|
|
+ try {
|
|
|
+ begin = simpleDateFormat.parse(beginEndDate.split(" - ")[0].trim());
|
|
|
+ end = simpleDateFormat.parse(beginEndDate.split(" - ")[1].trim());
|
|
|
+ long time = end.getTime() - begin.getTime();
|
|
|
+ if(time>31*24*60*60*1000l){
|
|
|
+ return JsonMessage.success("时间跨度过长");
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(username)){
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdminByUsername(username));
|
|
|
+ adminId = admin.getId();
|
|
|
+ }
|
|
|
+ List<OrderDaoChuDTO> OrderDaoChuDTOList =orderService.orderDaoChu(begin,end,adminId,clientId,type,current,size);
|
|
|
+ for(OrderDaoChuDTO orderDaoChuDTO: OrderDaoChuDTOList){
|
|
|
+ Long adminId1 = Long.valueOf(orderDaoChuDTO.getAdminId().toString());
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(adminId1.toString()));
|
|
|
+ if(admin==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ orderDaoChuDTO.setPhone(admin.getPhone());
|
|
|
+ orderDaoChuDTO.setUsername(admin.getUsername());
|
|
|
+ orderDaoChuDTO.setName(admin.getName());
|
|
|
+ if(!StringUtils.isEmpty(type)&&type.equals("2")){
|
|
|
+ //商户为单位
|
|
|
+ TAdmin parent = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
|
|
|
+ orderDaoChuDTO.setLastUsername(parent.getUsername());
|
|
|
+ TArea area = areaService.getById(admin.getAreaId());
|
|
|
+ if(area!=null){
|
|
|
+ orderDaoChuDTO.setAddress(area.getFullName());
|
|
|
+ }
|
|
|
+ List<String> stringList = R.getDataIfSuccess(szwlFeign.getClientIds(String.valueOf(admin.getId())));
|
|
|
+ orderDaoChuDTO.setEquipmentTotal(String.valueOf(stringList.size()));
|
|
|
+ }else {
|
|
|
+ //设备为单位
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(String.valueOf(orderDaoChuDTO.getClientId())));
|
|
|
+ if(equipment!=null){
|
|
|
+ if(StringUtils.isNotEmpty(equipment.getFullName())){
|
|
|
+ orderDaoChuDTO.setAddress(equipment.getFullName());
|
|
|
+ }
|
|
|
+ orderDaoChuDTO.setEquipmentType(equipment.getEquimentType());
|
|
|
+ orderDaoChuDTO.setCreateDate(equipment.getCreateDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ExportParams exportParams = new ExportParams("订单记录", "sheet1");
|
|
|
+ Workbook workbook = null;
|
|
|
+ if(!StringUtils.isEmpty(type)&&type.equals("2")){
|
|
|
+ List<OrderByAdminTarget> orderByAdminTargetList = new ArrayList<>();
|
|
|
+ for(OrderDaoChuDTO orderDaoChuDTO: OrderDaoChuDTOList){
|
|
|
+ OrderByAdminTarget orderByAdminTarget = new OrderByAdminTarget();
|
|
|
+ orderByAdminTarget.setUsername(orderDaoChuDTO.getUsername());
|
|
|
+ orderByAdminTarget.setAddress(orderDaoChuDTO.getAddress());
|
|
|
+ orderByAdminTarget.setEquipmentTotal(orderDaoChuDTO.getEquipmentTotal());
|
|
|
+ orderByAdminTarget.setLastUsername(orderDaoChuDTO.getLastUsername());
|
|
|
+ orderByAdminTarget.setPhone(orderDaoChuDTO.getPhone());
|
|
|
+ orderByAdminTarget.setPriceTotal(orderDaoChuDTO.getPriceTotal());
|
|
|
+ orderByAdminTarget.setName(orderDaoChuDTO.getName());
|
|
|
+ orderByAdminTargetList.add(orderByAdminTarget);
|
|
|
+ }
|
|
|
+ workbook = ExcelExportUtil.exportExcel(exportParams, OrderByAdminTarget.class, orderByAdminTargetList);
|
|
|
+ }else {
|
|
|
+ List<OrderByClientidTarget> orderByClientidTargetList = new ArrayList<>();
|
|
|
+ for(OrderDaoChuDTO orderDaoChuDTO: OrderDaoChuDTOList){
|
|
|
+ OrderByClientidTarget orderByClientidTarget = new OrderByClientidTarget();
|
|
|
+ orderByClientidTarget.setAddress(orderDaoChuDTO.getAddress());
|
|
|
+ orderByClientidTarget.setClientId(orderDaoChuDTO.getClientId());
|
|
|
+ orderByClientidTarget.setCreateDate(orderDaoChuDTO.getCreateDate());
|
|
|
+ orderByClientidTarget.setEquipmentType(orderDaoChuDTO.getEquipmentType());
|
|
|
+ orderByClientidTarget.setName(orderDaoChuDTO.getName());
|
|
|
+ orderByClientidTarget.setPhone(orderDaoChuDTO.getPhone());
|
|
|
+ orderByClientidTarget.setPriceTotal(orderDaoChuDTO.getPriceTotal());
|
|
|
+ orderByClientidTarget.setUsername(orderDaoChuDTO.getUsername());
|
|
|
+ orderByClientidTargetList.add(orderByClientidTarget);
|
|
|
+ }
|
|
|
+ workbook = ExcelExportUtil.exportExcel(exportParams, OrderByClientidTarget.class, orderByClientidTargetList);
|
|
|
+ }
|
|
|
+ if (workbook != null) {
|
|
|
+ OutputStream os = null;
|
|
|
+ try {
|
|
|
+ os = response.getOutputStream();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("订单记录数据导出" + format.format(new Date()) + ".xls", "UTF-8"));
|
|
|
+ workbook.write(os);
|
|
|
+ return JsonMessage.success("导出成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ os.close();
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return JsonMessage.success("导出成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/onlineExport", method = RequestMethod.GET)
|
|
|
+ public Object onlineExport(HttpServletResponse response, String adminId,String adminType,String type,String userName,String payType,String productNo,String clientId,String dateType, Date stratDate, Date endDate, long current, long size) {
|
|
|
+ //判断当前账号状态
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(adminId));
|
|
|
+ //类型
|
|
|
+ //0,线上
|
|
|
+ if(type.equals("0")){
|
|
|
+ LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
+ //adminType="all"时,代表查全部下级 子账户没有这个权限 公司人员默认查所有人
|
|
|
+ if(StringUtils.isNotEmpty(adminType)){
|
|
|
+ if(admin.getIsAdmined().equals("0")&&admin.getType()>1){
|
|
|
+ if(admin.getType()>1){
|
|
|
+ if(adminType.equals("all")){
|
|
|
+ //查找所有下级
|
|
|
+ List<Long> admidIdList = R.getDataIfSuccess(szwlFeign.getAdminIdList(adminId));
|
|
|
+ query.in(TOrder::getAdminId,admidIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(admin.getType()>1){
|
|
|
+ //登录账户为子账户 不查下级 只查对应机器的订单
|
|
|
+ TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getParentId())));
|
|
|
+ if(adminEquipment.getType().equals("0")){
|
|
|
+ //全部机器
|
|
|
+ TAdmin upAdmin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
|
|
|
+ query.eq(TOrder::getAdminId,upAdmin.getId());
|
|
|
+ }else {
|
|
|
+ String equipmentIds = adminEquipment.getEquipmentIds();
|
|
|
+ List<String> equipmentIdList = JSON.parseArray(equipmentIds, String.class);
|
|
|
+ query.in(TOrder::getClientId,equipmentIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ //判断当前账号状态 公司还是商家
|
|
|
+ if(admin.getType()>1){
|
|
|
+ //商家 判断是否子账户
|
|
|
+ if(admin.getIsAdmined().equals("0")){
|
|
|
+ //商家自己
|
|
|
+ query.eq(TOrder::getAdminId,adminId);
|
|
|
+ }else {
|
|
|
+ //商家 子账户
|
|
|
+ //登录账户为子账户 不查下级 只查对应机器的订单
|
|
|
+ TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getParentId())));
|
|
|
+ if(adminEquipment.getType().equals("0")){
|
|
|
+ //全部机器
|
|
|
+ TAdmin upAdmin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
|
|
|
+ query.eq(TOrder::getAdminId,upAdmin.getId());
|
|
|
+ }else {
|
|
|
+ String equipmentIds = adminEquipment.getEquipmentIds();
|
|
|
+ List<String> equipmentIdList = JSON.parseArray(equipmentIds, String.class);
|
|
|
+ query.in(TOrder::getClientId,equipmentIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(userName)){
|
|
|
+ TAdmin admin1 = R.getDataIfSuccess(szwlFeign.getAdminByUsername(userName));
|
|
|
+ query.eq(TOrder::getAdminId,admin1.getId());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(payType)){
|
|
|
+ query.eq(TOrder::getFrpCode,payType);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(productNo)){
|
|
|
+ query.eq(TOrder::getProductNo,productNo);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(clientId)){
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
+ //判断机器是否属于这个登陆账号
|
|
|
+ if(admin.getType()>1){
|
|
|
+ //商家
|
|
|
+ if(equipment.getAdminId().toString().equals(admin.getId().toString())){
|
|
|
+ query.eq(TOrder::getEquipmentId,equipment.getId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ query.eq(TOrder::getEquipmentId,equipment.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(dateType)){
|
|
|
+ if(dateType.equals("0")){
|
|
|
+ //创建时间
|
|
|
+ if(stratDate!=null&&endDate!=null){
|
|
|
+ query.gt(TOrder::getCreateDate,stratDate);
|
|
|
+ query.lt(TOrder::getCreateDate,endDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(dateType.equals("1")){
|
|
|
+ //退款时间
|
|
|
+ if(stratDate!=null&&endDate!=null){
|
|
|
+ query.gt(TOrder::getRefundDate,stratDate);
|
|
|
+ query.lt(TOrder::getRefundDate,endDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Page<TOrder> page = new Page<>(current, size, true);
|
|
|
+ IPage<TOrder> iPage = orderService.page(page, query);
|
|
|
+ List<TOrder> list = iPage.getRecords();
|
|
|
+ List<OrderTarget> orderTargetList = orderService.findById(admin, list);
|
|
|
+ ExportParams exportParams = new ExportParams("订单记录", "sheet1");
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams, OrderTarget.class, orderTargetList);
|
|
|
+
|
|
|
+ if (workbook != null) {
|
|
|
+ OutputStream os = null;
|
|
|
+ try {
|
|
|
+ os = response.getOutputStream();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("订单记录数据导出" + format.format(new Date()) + ".xls", "UTF-8"));
|
|
|
+ workbook.write(os);
|
|
|
+ return JsonMessage.success("导出成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ os.close();
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ //1,线下
|
|
|
+ if(type.equals("1")){
|
|
|
+ LambdaQueryWrapper<TCoinOrder> query = Wrappers.lambdaQuery();
|
|
|
+ //adminType="all"时,代表查全部下级 子账户没有这个权限 公司人员默认查所有人
|
|
|
+ if(StringUtils.isNotEmpty(adminType)){
|
|
|
+ if(admin.getIsAdmined().equals("0")&&admin.getType()>1){
|
|
|
+ if(admin.getType()>1){
|
|
|
+ if(adminType.equals("all")){
|
|
|
+ //查找所有下级
|
|
|
+ List<Long> admidIdList = R.getDataIfSuccess(szwlFeign.getAdminIdList(adminId));
|
|
|
+ query.in(TCoinOrder::getAdminId,admidIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(admin.getType()>1){
|
|
|
+ //登录账户为子账户 不查下级 只查对应机器的订单
|
|
|
+ TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getParentId())));
|
|
|
+ if(adminEquipment.getType().equals("0")){
|
|
|
+ //全部机器
|
|
|
+ TAdmin upAdmin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
|
|
|
+ query.eq(TCoinOrder::getAdminId,upAdmin.getId());
|
|
|
+ }else {
|
|
|
+ String equipmentIds = adminEquipment.getEquipmentIds();
|
|
|
+ List<String> equipmentIdList = JSON.parseArray(equipmentIds, String.class);
|
|
|
+ query.in(TCoinOrder::getClientId,equipmentIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ //判断当前账号状态 公司还是商家
|
|
|
+ if(admin.getType()>1){
|
|
|
+ //商家 判断是否子账户
|
|
|
+ if(admin.getIsAdmined().equals("0")){
|
|
|
+ //商家自己
|
|
|
+ query.eq(TCoinOrder::getAdminId,adminId);
|
|
|
+ }else {
|
|
|
+ //商家 子账户
|
|
|
+ //登录账户为子账户 不查下级 只查对应机器的订单
|
|
|
+ TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getParentId())));
|
|
|
+ if(adminEquipment.getType().equals("0")){
|
|
|
+ //全部机器
|
|
|
+ TAdmin upAdmin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
|
|
|
+ query.eq(TCoinOrder::getAdminId,upAdmin.getId());
|
|
|
+ }else {
|
|
|
+ String equipmentIds = adminEquipment.getEquipmentIds();
|
|
|
+ List<String> equipmentIdList = JSON.parseArray(equipmentIds, String.class);
|
|
|
+ query.in(TCoinOrder::getClientId,equipmentIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(userName)){
|
|
|
+ TAdmin admin1 = R.getDataIfSuccess(szwlFeign.getAdminByUsername(userName));
|
|
|
+ query.eq(TCoinOrder::getAdminId,admin1.getId());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(payType)){
|
|
|
+ query.eq(TCoinOrder::getPayType,payType);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(productNo)){
|
|
|
+ query.eq(TCoinOrder::getProductNo,productNo);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(clientId)){
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
+ //判断机器是否属于这个登陆账号
|
|
|
+ if(admin.getType()>1){
|
|
|
+ //商家
|
|
|
+ if(equipment.getAdminId().toString().equals(admin.getId().toString())){
|
|
|
+ query.eq(TCoinOrder::getClientId,equipment.getClientId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ query.eq(TCoinOrder::getClientId,equipment.getClientId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(stratDate!=null&&endDate!=null){
|
|
|
+ query.gt(TCoinOrder::getPayDate,stratDate);
|
|
|
+ query.lt(TCoinOrder::getPayDate,endDate);
|
|
|
+ }
|
|
|
+ Page<TCoinOrder> page = new Page<>(current, size, true);
|
|
|
+ IPage<TCoinOrder> iPage = coinOrderService.page(page, query);
|
|
|
+ List<TCoinOrder> list = iPage.getRecords();
|
|
|
+ List<CoinOrderTarget> coinOrderTargets = coinOrderService.findByCoinOrder(admin,list);
|
|
|
+ ExportParams exportParams = new ExportParams("线下订单记录", "sheet1");
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams, CoinOrderTarget.class, coinOrderTargets);
|
|
|
+
|
|
|
+ if (workbook != null) {
|
|
|
+ OutputStream os = null;
|
|
|
+ try {
|
|
|
+ os = response.getOutputStream();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("线下订单记录数据导出" + format.format(new Date()) + ".xls", "UTF-8"));
|
|
|
+ workbook.write(os);
|
|
|
+ return JsonMessage.success("导出成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ os.close();
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return JsonMessage.success("导出错误");
|
|
|
+ }
|
|
|
}
|
|
|
|