parent
39d7a77e8e
commit
6777bd7513
@ -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<String,Object> 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<String,Object> 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<HighOrderPre> 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); |
||||
} |
||||
} |
||||
|
||||
} |
@ -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; |
||||
} |
||||
} |
Loading…
Reference in new issue