diff --git a/hai-order/src/main/java/com/web/controller/business/OrderOilCardController.java b/hai-order/src/main/java/com/web/controller/business/OrderOilCardController.java new file mode 100644 index 00000000..674543a2 --- /dev/null +++ b/hai-order/src/main/java/com/web/controller/business/OrderOilCardController.java @@ -0,0 +1,211 @@ +package com.web.controller.business; + +import com.alibaba.excel.EasyExcel; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighGasOrder; +import com.hai.enum_type.MerchantStoreSourceType; +import com.hai.enum_type.UserObjectTypeEnum; +import com.hai.enum_type.UserRoleTypeEnum; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.order.model.ExportGasOrderModel; +import com.hai.order.service.OrderService; +import com.hai.order.service.OrderServiceExt; +import com.hai.order.type.OrderOilStatus; +import com.hai.order.type.OrderPayType; +import com.hai.service.HighGasOrderService; +import com.web.config.SysConst; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import java.io.File; +import java.math.BigDecimal; +import java.util.*; + +@Controller +@RequestMapping(value = "oilCard") +@Api(value = "油卡充值业务") +public class OrderOilCardController { + + private static Logger log = LoggerFactory.getLogger(OrderOilCardController.class); + + @Resource + private UserCenter userCenter; + + @Resource + private OrderService orderService; + + @Resource + private OrderServiceExt orderServiceExt; + + @RequestMapping(value="/getOilCardOrderList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询油卡充值订单列表") + public ResponseData getOilCardOrderList(@RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "oilCardNo", required = false) String oilCardNo, + @RequestParam(name = "memPhone", required = false) String memPhone, + @RequestParam(name = "payType", required = false) Integer payType, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "payTimeS", required = false) Long payTimeS, + @RequestParam(name = "payTimeE", required = false) Long payTimeE, + @RequestParam(name = "refundTimeS", required = false) Long refundTimeS, + @RequestParam(name = "refundTimeE", required = false) Long refundTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize + ) { + try { + Map param = new HashMap<>(); + param.put("orderNo", orderNo); + param.put("memPhone", memPhone); + param.put("oilCardNo", oilCardNo); + param.put("payType", payType); + param.put("status", status); + param.put("createTimeS", createTimeS); + param.put("createTimeE", createTimeE); + param.put("payTimeS", payTimeS); + param.put("payTimeE", payTimeE); + param.put("refundTimeS", refundTimeS); + param.put("refundTimeE", refundTimeE); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(orderService.getOilCardOrderList(param))); + + } catch (Exception e) { + log.error("OrderOilCardController -> getOilCardOrderList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getOrderDetail",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询订单详情") + public ResponseData getOrderDetail(@RequestParam(name = "orderNo", required = true) String orderNo) { + try { + + return ResponseMsgUtil.success(orderService.getOrderDetailByNo(orderNo)); + + } catch (Exception e) { + log.error("OrderExtController -> getGasOrderDetail() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/exportOilCardOrder",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出油卡充值订单") + public ResponseData exportOilCardOrder(@RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "oilCardNo", required = false) String oilCardNo, + @RequestParam(name = "memPhone", required = false) String memPhone, + @RequestParam(name = "payType", required = false) Integer payType, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "payTimeS", required = false) Long payTimeS, + @RequestParam(name = "payTimeE", required = false) Long payTimeE, + @RequestParam(name = "refundTimeS", required = false) Long refundTimeS, + @RequestParam(name = "refundTimeE", required = false) Long refundTimeE) { + try { + + Map param = new HashMap<>(); + param.put("orderNo", orderNo); + param.put("memPhone", memPhone); + param.put("oilCardNo", oilCardNo); + param.put("payType", payType); + param.put("status", status); + param.put("createTimeS", createTimeS); + param.put("createTimeE", createTimeE); + param.put("payTimeS", payTimeS); + param.put("payTimeE", payTimeE); + param.put("refundTimeS", refundTimeS); + param.put("refundTimeE", refundTimeE); + + // 查询数据 + List> orderList = orderService.getOilCardOrderList(param); + + List> dataList = new ArrayList<>(); + List data; + + for (Map order : orderList) { + data = new ArrayList<>(); + data.add(MapUtils.getString(order, "orderNo")); + data.add(MapUtils.getString(order, "memPhone")); + data.add(MapUtils.getString(order, "oildCard")); + data.add(MapUtils.getString(order, "goodsActualPrice")); + data.add(MapUtils.getString(order, "givePrice")); + data.add(MapUtils.getString(order, "goodsPrice")); + data.add(MapUtils.getString(order, "payRealPrice")); + data.add(MapUtils.getString(order, "createTime")); + data.add(MapUtils.getString(order, "payTime")); + data.add(MapUtils.getString(order, "refundTime")); + data.add(MapUtils.getString(order, "orderStatus")); + dataList.add(data); + } + + List headList = new ArrayList<>();; + headList.add("交易单号"); + headList.add("客户电话"); + headList.add("油卡卡号"); + headList.add("充值金额"); + headList.add("赠送金额"); + headList.add("实际到账金额"); + headList.add("支付金额"); + headList.add("创建时间"); + headList.add("支付时间"); + headList.add("退款时间"); + headList.add("交易状态"); + + 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("OrderExtController -> exportGasOrderList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + /** + * 生成头部 + * @param headList + * @return + */ + private List> generationHead(List headList) { + List> list = new ArrayList<>(); + List head; + for (String headStr : headList) { + head = new ArrayList<>(); + head.add(headStr); + list.add(head); + } + return list; + } + +} diff --git a/hai-service/src/main/java/com/hai/config/ChongQingCNPCService.java b/hai-service/src/main/java/com/hai/config/ChongQingCNPCService.java index ea2f58cc..4428168b 100644 --- a/hai-service/src/main/java/com/hai/config/ChongQingCNPCService.java +++ b/hai-service/src/main/java/com/hai/config/ChongQingCNPCService.java @@ -54,6 +54,18 @@ public class ChongQingCNPCService { return request("sendCNPCTicket", map); } + /** + * 电子券作废 + * @param couponNo 电子券编号 + * @param random 随机数 + */ + public static JSONObject invalidCoupon(String couponNo, String random) throws Exception { + Map map = new HashMap<>(); + map.put("couponNo", couponNo); + map.put("random", random); + return request("invalidCoupon", map); + } + /** * 获取中石油跨界券核销码 * @param couponNo diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java index 82a3303e..049f79b8 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -1231,4 +1231,42 @@ public interface HighOrderMapperExt { }) Map HltCardNoTopUpStatistic(); + + @Select("") + List> getOilCardOrderList(@Param("param") Map param); + } diff --git a/hai-service/src/main/java/com/hai/order/service/OrderService.java b/hai-service/src/main/java/com/hai/order/service/OrderService.java index 1621eff3..3539fcdc 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderService.java @@ -146,4 +146,11 @@ public interface OrderService { * @Return com.alibaba.fastjson.JSONObject */ JSONObject createOrderCombine(CreateCombine createCombine) throws Exception; + + /** + * 查询油卡充值订单 + * @param param + * @return + */ + List> getOilCardOrderList(Map param) throws Exception; } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 18445eeb..95740730 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -1097,4 +1097,33 @@ public class OrderServiceImpl implements OrderService { return null; } + + @Override + public List> getOilCardOrderList(Map param) throws Exception { + if (MapUtils.getLong(param, "createTimeS") != null) { + param.put("createTimeS", DateUtil.date2String(new Date(MapUtils.getLong(param, "createTimeS")), DateUtil.Y_M_D_HMS)); + } + + if (MapUtils.getLong(param, "createTimeE") != null) { + param.put("createTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "createTimeE")), DateUtil.Y_M_D_HMS)); + } + + if (MapUtils.getLong(param, "payTimeS") != null) { + param.put("payTimeS", DateUtil.date2String(new Date(MapUtils.getLong(param, "payTimeS")), DateUtil.Y_M_D_HMS)); + } + + if (MapUtils.getLong(param, "payTimeE") != null) { + param.put("payTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "payTimeE")), DateUtil.Y_M_D_HMS)); + } + + if (MapUtils.getLong(param, "refundTimeS") != null) { + param.put("refundTimeS", DateUtil.date2String(new Date(MapUtils.getLong(param, "refundTimeS")), DateUtil.Y_M_D_HMS)); + } + + if (MapUtils.getLong(param, "refundTimeE") != null) { + param.put("refundTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "refundTimeE")), DateUtil.Y_M_D_HMS)); + } + + return orderMapper.getOilCardOrderList(param); + } }