From 6777bd7513d0f27af8dc4f392944c73f71519248 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Sun, 21 Nov 2021 19:37:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighOrderPreController.java | 291 ++++++++++++++++++ .../bweb/model/ExportHighPreOrderModel.java | 117 +++++++ .../com/hai/service/HighOrderPreService.java | 2 +- .../service/impl/HighOrderPreServiceImpl.java | 33 +- 4 files changed, 434 insertions(+), 9 deletions(-) create mode 100644 hai-bweb/src/main/java/com/bweb/controller/HighOrderPreController.java create mode 100644 hai-bweb/src/main/java/com/bweb/model/ExportHighPreOrderModel.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighOrderPreController.java b/hai-bweb/src/main/java/com/bweb/controller/HighOrderPreController.java new file mode 100644 index 00000000..5dbd74a2 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/HighOrderPreController.java @@ -0,0 +1,291 @@ +package com.bweb.controller; + +import com.alibaba.excel.EasyExcel; +import com.bweb.config.SysConst; +import com.bweb.model.ExportHighOrderModel; +import com.bweb.model.ExportHighPreOrderModel; +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.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighGoodsType; +import com.hai.entity.HighOrderPre; +import com.hai.model.HighOrderModel; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.HighOrderPreService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author Sum1Dream + * @ClassName HighOrderPreController + * @Description // 预约订单 + * @Date 2021/11/19 10:56 上午 + **/ +@Controller +@RequestMapping(value = "/highOrderPre") +@Api(value = "预约订单接口") +public class HighOrderPreController { + + private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class); + + @Autowired + private UserCenter userCenter; + + @Resource + private HighOrderPreService highOrderPreService; + + @RequestMapping(value = "/getListPreOrder", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取预约订单列表") + public ResponseData getListGoodsType(@RequestParam(name = "companyId", required = false) Long companyId, + @RequestParam(name = "merchantId", required = false) Long merchantId, + @RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "preOrderNo", required = false) String preOrderNo, + @RequestParam(name = "merchantStoreId", required = false) Long merchantStoreId, + @RequestParam(name = "userPhone", required = false) String userPhone, + @RequestParam(name = "preUserName", required = false) String preUserName, + @RequestParam(name = "goodsName", required = false) String goodsName, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize, + HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + Map map = new HashMap<>(); + + // 用户来源 0:超级管理员 1:公司 2:商户 3:门店 4. 代理商 + if(userInfoModel.getSecUser().getObjectType() == 0) { + map.put("companyId", companyId); + + } else if (userInfoModel.getSecUser().getObjectType() == 1) { + if (userInfoModel.getBsCompany().getId() == 3) { + map.put("companyId", 23); + } else if (userInfoModel.getBsCompany().getId() == 2) { + map.put("companyId", null); + }else { + map.put("companyId", userInfoModel.getBsCompany().getId()); + } + + } else if (userInfoModel.getSecUser().getObjectType() == 2) { + merchantId = userInfoModel.getMerchant().getId(); + } else if (userInfoModel.getSecUser().getObjectType() == 3) { + merchantStoreId = userInfoModel.getMerchantStore().getId(); + } + + map.put("merchantId", merchantId); + map.put("merchantStoreId" , merchantStoreId); + map.put("orderNo" , orderNo); + map.put("preOrderNo" , preOrderNo); + map.put("userPhone" , userPhone); + map.put("preUserName" , preUserName); + map.put("goodsName" , goodsName); + map.put("status" , status); + if (createTimeS != null) { + map.put("createTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeS)); + } + if (createTimeE != null) { + map.put("createTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeE)); + } + + PageHelper.startPage(pageNum,pageSize); + return ResponseMsgUtil.success(new PageInfo<>(highOrderPreService.getListOrderPre(map))); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getPreOrderById", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据id查询订单详情") + public ResponseData getPreOrderById(@RequestParam(name = "id", required = true) Long id) { + try { + + return ResponseMsgUtil.success(highOrderPreService.findByOrderId(id)); + + } catch (Exception e) { + log.error("HighOrderController --> getOrderById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/preOrderSuccess", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "预约成功") + public ResponseData preOrderSuccess(@RequestBody HighOrderPre highOrderPre, HttpServletRequest request) { + try { + //发布人员 + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + + if (StringUtils.isBlank(highOrderPre.getPreUserRemark()) + || highOrderPre.getReachTime() == null + || highOrderPre.getId() == null + || StringUtils.isBlank(highOrderPre.getReachAddress()) + ) { + log.error("HighAgentController -> insertAgent() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + HighOrderPre highOrderPres = highOrderPreService.findByOrderId(highOrderPre.getId()); + + // 校验订单是否合法 + if (highOrderPres == null || highOrderPres.getStatus() != 1) { + log.error("HighGoodsTypeController --> preOrderSuccess() error!", "当前状态不合法"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); + } + + highOrderPres.setUpdateTime(new Date()); + highOrderPres.setOpUserId(userInfoModel.getSecUser().getId()); + highOrderPres.setOpUserName(userInfoModel.getSecUser().getUserName()); + highOrderPres.setPreUserRemark(highOrderPre.getPreUserRemark()); + highOrderPres.setReachTime(highOrderPre.getReachTime()); + highOrderPres.setReachAddress(highOrderPre.getReachAddress()); + highOrderPres.setStatus(2); + highOrderPreService.updateOrderPre(highOrderPres); + + return ResponseMsgUtil.success("预约成功"); + + } catch (Exception e) { + log.error("HighAgentController --> insertAgent() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/preOrderFail", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "预约失败") + public ResponseData preOrderFail(@RequestBody HighOrderPre highOrderPre, HttpServletRequest request) { + try { + //发布人员 + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + + if (StringUtils.isBlank(highOrderPre.getStatusFailDesc()) + || highOrderPre.getId() == null + ) { + log.error("HighAgentController -> insertAgent() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + HighOrderPre highOrderPres = highOrderPreService.findByOrderId(highOrderPre.getId()); + + // 校验订单是否合法 + if (highOrderPres == null && highOrderPres.getStatus() != 1) { + log.error("HighGoodsTypeController --> preOrderSuccess() error!", "当前状态不合法"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); + } + + highOrderPres.setUpdateTime(new Date()); + highOrderPres.setOpUserId(userInfoModel.getSecUser().getId()); + highOrderPres.setOpUserName(userInfoModel.getSecUser().getUserName()); + highOrderPres.setStatusFailDesc(highOrderPre.getStatusFailDesc()); + + highOrderPres.setStatus(4); + highOrderPreService.updateOrderPre(highOrderPres); + + return ResponseMsgUtil.success("预约成功"); + + } catch (Exception e) { + log.error("HighAgentController --> insertAgent() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/exportListPreOrder", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出预约订单列表") + public ResponseData exportListGoodsType(@RequestParam(name = "companyId", required = false) Long companyId, + @RequestParam(name = "merchantId", required = false) Long merchantId, + @RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "preOrderNo", required = false) String preOrderNo, + @RequestParam(name = "merchantStoreId", required = false) Long merchantStoreId, + @RequestParam(name = "userPhone", required = false) String userPhone, + @RequestParam(name = "preUserName", required = false) String preUserName, + @RequestParam(name = "goodsName", required = false) String goodsName, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + Map map = new HashMap<>(); + + // 用户来源 0:超级管理员 1:公司 2:商户 3:门店 4. 代理商 + if(userInfoModel.getSecUser().getObjectType() == 0) { + map.put("companyId", companyId); + + } else if (userInfoModel.getSecUser().getObjectType() == 1) { + if (userInfoModel.getBsCompany().getId() == 3) { + map.put("companyId", 23); + } else if (userInfoModel.getBsCompany().getId() == 2) { + map.put("companyId", null); + }else { + map.put("companyId", userInfoModel.getBsCompany().getId()); + } + + } else if (userInfoModel.getSecUser().getObjectType() == 2) { + merchantId = userInfoModel.getMerchant().getId(); + } else if (userInfoModel.getSecUser().getObjectType() == 3) { + merchantStoreId = userInfoModel.getMerchantStore().getId(); + } + + map.put("merchantId", merchantId); + map.put("merchantStoreId" , merchantStoreId); + map.put("orderNo" , orderNo); + map.put("preOrderNo" , preOrderNo); + map.put("userPhone" , userPhone); + map.put("preUserName" , preUserName); + map.put("goodsName" , goodsName); + map.put("status" , status); + if (createTimeS != null) { + map.put("createTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeS)); + } + if (createTimeE != null) { + map.put("createTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeE)); + } + + String name = "/goodsOrder/预约商品订单" + System.currentTimeMillis() + ".xlsx"; + List list = highOrderPreService.getListOrderPre(map); + String fileName = SysConst.getSysConfig().getFileUrl() + name; + EasyExcel.write(fileName, ExportHighPreOrderModel.class).sheet("预约商品订单").doWrite(list); + return ResponseMsgUtil.success(name); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/hai-bweb/src/main/java/com/bweb/model/ExportHighPreOrderModel.java b/hai-bweb/src/main/java/com/bweb/model/ExportHighPreOrderModel.java new file mode 100644 index 00000000..7efd9cdc --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/model/ExportHighPreOrderModel.java @@ -0,0 +1,117 @@ +package com.bweb.model; + +import com.alibaba.excel.annotation.ExcelProperty; + +import java.math.BigDecimal; + +public class ExportHighPreOrderModel { + @ExcelProperty("预约订单号") + private String preOrderNo; + + @ExcelProperty("支付订单号") + private String orderNo; + + @ExcelProperty("商品名称") + private String goodsName; + + @ExcelProperty("支付金额") + private String payRealPrice; + + @ExcelProperty("预约时间") + private String preTime; + + @ExcelProperty("用户姓名") + private String preUserName; + + @ExcelProperty("用户电话") + private String preUserPhone; + + @ExcelProperty("预约用户备注") + private String preUserRemark; + + @ExcelProperty("到达时间") + private BigDecimal reachTime; + + @ExcelProperty("到达地点") + private BigDecimal reachAddress; + + public String getPreOrderNo() { + return preOrderNo; + } + + public void setPreOrderNo(String preOrderNo) { + this.preOrderNo = preOrderNo; + } + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public String getGoodsName() { + return goodsName; + } + + public void setGoodsName(String goodsName) { + this.goodsName = goodsName; + } + + public String getPayRealPrice() { + return payRealPrice; + } + + public void setPayRealPrice(String payRealPrice) { + this.payRealPrice = payRealPrice; + } + + public String getPreTime() { + return preTime; + } + + public void setPreTime(String preTime) { + this.preTime = preTime; + } + + public String getPreUserName() { + return preUserName; + } + + public void setPreUserName(String preUserName) { + this.preUserName = preUserName; + } + + public String getPreUserPhone() { + return preUserPhone; + } + + public void setPreUserPhone(String preUserPhone) { + this.preUserPhone = preUserPhone; + } + + public String getPreUserRemark() { + return preUserRemark; + } + + public void setPreUserRemark(String preUserRemark) { + this.preUserRemark = preUserRemark; + } + + public BigDecimal getReachTime() { + return reachTime; + } + + public void setReachTime(BigDecimal reachTime) { + this.reachTime = reachTime; + } + + public BigDecimal getReachAddress() { + return reachAddress; + } + + public void setReachAddress(BigDecimal reachAddress) { + this.reachAddress = reachAddress; + } +} diff --git a/hai-service/src/main/java/com/hai/service/HighOrderPreService.java b/hai-service/src/main/java/com/hai/service/HighOrderPreService.java index eabbaf38..3fd95f2a 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderPreService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderPreService.java @@ -13,7 +13,7 @@ public interface HighOrderPreService { * @Param [map] * @return java.util.List **/ - List getListOrderPre(Map map); + List getListOrderPre(Map map); /** * @Author Sum1Dream diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderPreServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderPreServiceImpl.java index 55ceef27..b2c288df 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderPreServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderPreServiceImpl.java @@ -21,7 +21,7 @@ public class HighOrderPreServiceImpl implements HighOrderPreService { private HighOrderPreMapper highOrderPreMapper; @Override - public List getListOrderPre(Map map) { + public List getListOrderPre(Map map) { HighOrderPreExample example = new HighOrderPreExample(); HighOrderPreExample.Criteria criteria = example.createCriteria(); @@ -29,8 +29,16 @@ public class HighOrderPreServiceImpl implements HighOrderPreService { criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); } - if (MapUtils.getInteger(map, "goodsType") != null) { - criteria.andGoodsTypeEqualTo(MapUtils.getInteger(map, "goodsType")); + if (MapUtils.getInteger(map, "companyId") != null) { + criteria.andCompanyIdEqualTo(MapUtils.getLong(map, "companyId")); + } + + if (MapUtils.getInteger(map, "merchantId") != null) { + criteria.andMerchantIdEqualTo(MapUtils.getLong(map, "merchantId")); + } + + if (MapUtils.getInteger(map, "merchantStoreId") != null) { + criteria.andMerchantStoreIdEqualTo(MapUtils.getLong(map, "merchantStoreId")); } if (MapUtils.getString(map, "orderNo") != null) { @@ -45,10 +53,19 @@ public class HighOrderPreServiceImpl implements HighOrderPreService { criteria.andPreUserPhoneEqualTo(MapUtils.getString(map, "userPhone")); } - if (StringUtils.isNotBlank(map.get("createTimeS")) && StringUtils.isNotBlank(map.get("createTimeE"))) { + if (MapUtils.getString(map, "preOrderNo") != null) { + criteria.andPreOrderNoLike("%" + MapUtils.getString(map, "preOrderNo") + "%"); + } + + if (MapUtils.getString(map, "preUserName") != null) { + criteria.andPreUserNameLike("%" + MapUtils.getString(map, "preUserName") + "%"); + } + + + if (MapUtils.getString(map , "createTimeS") !=null && MapUtils.getString(map , "createTimeE") != null) { criteria.andCreateTimeBetween( - DateUtil.format(map.get("createTimeS") , "yyyy-MM-dd HH:mm:ss") , - DateUtil.format(map.get("createTimeE") , "yyyy-MM-dd HH:mm:ss")); + DateUtil.format(MapUtils.getString(map , "createTimeS") , "yyyy-MM-dd HH:mm:ss") , + DateUtil.format(MapUtils.getString(map , "createTimeE") , "yyyy-MM-dd HH:mm:ss")); } return highOrderPreMapper.selectByExample(example); } @@ -65,11 +82,11 @@ public class HighOrderPreServiceImpl implements HighOrderPreService { @Override public void insertOrderPre(HighOrderPre highOrderPre) { - highOrderPreMapper.insert(highOrderPre); + highOrderPreMapper.insert(highOrderPre); } @Override public void updateOrderPre(HighOrderPre highOrderPre) { - highOrderPreMapper.updateByPrimaryKey(highOrderPre); + highOrderPreMapper.updateByPrimaryKey(highOrderPre); } }