提交代码

dev-discount
胡锐 3 years ago
parent da2e3c60d7
commit 183db0b5cd
  1. 128
      hai-bweb/src/main/java/com/bweb/controller/HighTyAgentOilStationController.java
  2. 6
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  3. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java

@ -1,6 +1,8 @@
package com.bweb.controller; package com.bweb.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.bweb.config.SysConst;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
@ -11,6 +13,7 @@ import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighTySalesman; import com.hai.entity.HighTySalesman;
import com.hai.enum_type.UserObjectTypeEnum; import com.hai.enum_type.UserObjectTypeEnum;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.TyOrderModel;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.BsOrganizationService; import com.hai.service.BsOrganizationService;
import com.hai.service.HighTyAgentOilStationService; import com.hai.service.HighTyAgentOilStationService;
@ -23,6 +26,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -368,4 +372,128 @@ public class HighTyAgentOilStationController {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }
@RequestMapping(value = "/excelOrder", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "导出订单")
public ResponseData excelOrder(@RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "goodsName", required = false) String goodsName,
@RequestParam(name = "salesmanName", required = false) String salesmanName,
@RequestParam(name = "agentName", required = false) String agentName,
@RequestParam(name = "orgName", required = false) String orgName) {
try {
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class);
if (userModel == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, "");
}
Map<String, Object> param = new HashMap<>();
param.put("orderNo", orderNo);
param.put("goodsName", goodsName);
if (userModel.getBsCompany() != null && userModel.getSecUser().getAdminFlag().equals(1)) {
param.put("companyId", userModel.getBsCompany().getId());
param.put("orgName", orgName);
param.put("agentName", agentName);
param.put("salesmanName", salesmanName);
} else if (userModel.getBsCompany() != null && userModel.getSecUser().getAdminFlag().equals(0)) {
param.put("orgId", userModel.getBsOrganization().getId());
param.put("agentName", agentName);
param.put("salesmanName", salesmanName);
} else if (userModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type6.getType())) {
param.put("agentId", userModel.getHighTyAgent().getId());
param.put("salesmanName", salesmanName);
} else if (userModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type7.getType())) {
param.put("salesmanId", userModel.getHighTySalesman().getId());
}
// 订单列表
List<TyOrderModel> orderList = highTyAgentOilStationService.getOrderList(param);
List<String> headList = new ArrayList<>();
if (userModel.getBsCompany() != null && userModel.getSecUser().getAdminFlag().equals(1)) {
headList.add("代理商公司");
}
if (userModel.getBsCompany() != null) {
headList.add("代理商");
}
if (userModel.getBsCompany() != null || userModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type6.getType())) {
headList.add("业务员");
}
headList.add("加油站");
headList.add("订单号");
headList.add("支付类型");
headList.add("加油金额");
headList.add("优惠金额");
headList.add("实付金额");
headList.add("油号");
headList.add("枪号");
headList.add("平台枪价");
headList.add("团油枪价");
headList.add("创建时间");
headList.add("支付时间");
List<List<Object>> dataList = new ArrayList<>();
List<Object> data;
for (TyOrderModel orderModel : orderList) {
data = new ArrayList<>();
if (userModel.getBsCompany() != null && userModel.getSecUser().getAdminFlag().equals(1)) {
data.add(orderModel.getOrgName());
}
if (userModel.getBsCompany() != null) {
data.add(orderModel.getAgentName());
}
if (userModel.getBsCompany() != null || userModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type6.getType())) {
data.add(orderModel.getSalesmanName());
}
data.add(orderModel.getGoodsName());
data.add(orderModel.getOrderNo());
data.add(orderModel.getPayType());
data.add(orderModel.getTotalPrice());
data.add(orderModel.getDeductionPrice());
data.add(orderModel.getPayRealPrice());
data.add(orderModel.getGasOilNo());
data.add(orderModel.getGasGunNo());
data.add(orderModel.getPlatformPrice());
data.add(orderModel.getGasPriceGun());
data.add(orderModel.getCreateTime());
data.add(orderModel.getPayTime());
dataList.add(data);
}
String fileUrl = SysConst.getSysConfig().getFileUrl() + "/temporary/";
String pathName = System.currentTimeMillis()+".xlsx";
File file = new File(fileUrl);
if (!file.exists()) {
file.mkdirs();
}
EasyExcel.write(fileUrl+pathName).head(generationHead(headList)).sheet("加油订单").doWrite(dataList);
return ResponseMsgUtil.success(pathName);
} catch (Exception e) {
log.error("HighTyAgentController --> getAgentList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
/**
* 生成头部
* @param headList
* @return
*/
private List<List<String>> generationHead(List<String> headList) {
List<List<String>> list = new ArrayList<>();
List<String> head;
for (String headStr : headList) {
head = new ArrayList<>();
head.add(headStr);
list.add(head);
}
return list;
}
} }

@ -259,9 +259,9 @@ public class HighOrderController {
childOrder.setGoodsActualPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP)); childOrder.setGoodsActualPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP));
// 团油的价格 // 团油的价格
// childOrder.setGasPriceGun(priceDetail.getBigDecimal("priceGun")); childOrder.setGasPriceGun(priceDetail.getBigDecimal("priceGun"));
// childOrder.setGasPriceVip(priceDetail.getBigDecimal("priceVip")); childOrder.setGasPriceVip(priceDetail.getBigDecimal("priceVip"));
// childOrder.setGoodsPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP)); childOrder.setGoodsPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP));
childOrder.setGoodsSpecName("默认"); childOrder.setGoodsSpecName("默认");
childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString())));

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save