Merge branch 'pre' of http://139.159.177.244:3000/hurui/hai-server into pre
commit
f6a6bc9de0
@ -0,0 +1,329 @@ |
||||
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.config.WxOrderConfig; |
||||
import com.hai.entity.HighChildOrder; |
||||
import com.hai.entity.HighGoodsType; |
||||
import com.hai.entity.HighOrder; |
||||
import com.hai.entity.HighOrderPre; |
||||
import com.hai.model.*; |
||||
import com.hai.service.HighOrderPreService; |
||||
import com.hai.service.HighOrderService; |
||||
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; |
||||
|
||||
@Resource |
||||
private HighOrderService highOrderService; |
||||
|
||||
|
||||
@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<HighOrderPreModel> list = highOrderPreService.ExportPreOrderList(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); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "订单退款") |
||||
public ResponseData orderToRefund(@RequestParam(name = "orderId", required = false) Long orderId, |
||||
HttpServletRequest request) { |
||||
try { |
||||
|
||||
HighOrderPre highOrderPre = highOrderPreService.findByOrderId(orderId); |
||||
|
||||
HighChildOrder highChildOrder = highOrderService.getChildOrderById(highOrderPre.getChildOrderId()); |
||||
|
||||
HighOrder highOrder = highOrderService.getOrderById(orderId); |
||||
|
||||
if (highOrder == null) { |
||||
log.error("orderToRefund error!", "未找到订单"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单"); |
||||
} |
||||
|
||||
if (highOrder.getOrderStatus() != 6) { |
||||
log.error("orderToRefund error!", "无法退款,订单不处于退款中状态"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于退款中状态"); |
||||
} |
||||
|
||||
highOrderPreService.orderToRefund(highChildOrder , highOrder , highOrderPre); |
||||
|
||||
return ResponseMsgUtil.success("退款成功"); |
||||
|
||||
} catch (Exception e){ |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -1 +1 @@ |
||||
package com.bweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.pay.util.XmlUtil;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils;
import com.hai.config.*;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.*;
import com.hai.model.HighMerchantModel;
import com.hai.model.HighMerchantStoreModel;
import com.hai.model.ResponseData;
import com.hai.model.ResultProfitSharing;
import com.hai.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
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 javax.net.ssl.SSLContext;
import java.io.FileInputStream;
import java.math.BigDecimal;
import java.security.KeyStore;
import java.util.*;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/26 23:08
*/
@Controller
@RequestMapping(value = "/test")
@Api(value = "订单接口")
public class HighTestController {
private static Logger log = LoggerFactory.getLogger(HighTestController.class);
@Resource
private HighMerchantService highMerchantService;
@Resource
private HighMerchantStoreService highMerchantStoreService;
@Resource
private HighGasOilPriceService highGasOilPriceService;
@Resource
private HighOrderService highOrderService;
@Resource
private HighProfitSharingRecordService highProfitSharingRecordService;
@Resource
private HighGasOrderPushMapper highGasOrderPushMapper;
@Resource
private HuiLianTongConfig huiLianTongConfig;
@Resource
private UnionPayConfig unionPayConfig;
@RequestMapping(value = "/getBackendToken", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取访问令牌backendToken")
public ResponseData getBackendToken() {
try {
return ResponseMsgUtil.success(UnionUserConfig.getBackendToken());
} catch (Exception e) {
log.error("HighOrderController --> getBackendToken() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} |
||||
package com.bweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.pay.util.XmlUtil;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils;
import com.hai.config.*;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.*;
import com.hai.model.HighMerchantModel;
import com.hai.model.HighMerchantStoreModel;
import com.hai.model.ResponseData;
import com.hai.model.ResultProfitSharing;
import com.hai.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
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 javax.net.ssl.SSLContext;
import java.io.FileInputStream;
import java.math.BigDecimal;
import java.security.KeyStore;
import java.util.*;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/26 23:08
*/
@Controller
@RequestMapping(value = "/test")
@Api(value = "订单接口")
public class HighTestController {
private static Logger log = LoggerFactory.getLogger(HighTestController.class);
@Resource
private HighMerchantService highMerchantService;
@Resource
private HighMerchantStoreService highMerchantStoreService;
@Resource
private HighGasOilPriceService highGasOilPriceService;
@Resource
private HighOrderService highOrderService;
@Resource
private HighProfitSharingRecordService highProfitSharingRecordService;
@Resource
private HighGasOrderPushMapper highGasOrderPushMapper;
@Resource
private HuiLianTongConfig huiLianTongConfig;
@Resource
private UnionPayConfig unionPayConfig;
@RequestMapping(value = "/getBackendToken", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取访问令牌backendToken")
public ResponseData getBackendToken() {
try {
return ResponseMsgUtil.success(null);
} catch (Exception e) {
log.error("HighOrderController --> getBackendToken() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} |
@ -0,0 +1,162 @@ |
||||
package com.bweb.model; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
public class ExportHighPreOrderModel { |
||||
@ExcelProperty("预约订单号") |
||||
private String preOrderNo; |
||||
|
||||
@ExcelProperty("支付订单号") |
||||
private String orderNo; |
||||
|
||||
@ExcelProperty("商品名称") |
||||
private String goodsName; |
||||
|
||||
@ExcelProperty("支付金额") |
||||
private BigDecimal payRealPrice; |
||||
|
||||
@ExcelProperty("用户姓名") |
||||
private String preUserName; |
||||
|
||||
@ExcelProperty("用户电话") |
||||
private String preUserPhone; |
||||
|
||||
@ExcelProperty("预约用户备注") |
||||
private String preUserRemark; |
||||
|
||||
@ExcelProperty("预约失败说明") |
||||
private String statusFailDesc; |
||||
|
||||
@ExcelProperty("到达时间") |
||||
private Date reachTime; |
||||
|
||||
@ExcelProperty("到达地点") |
||||
private String reachAddress; |
||||
|
||||
@ExcelProperty("门店名称") |
||||
private String storeName; |
||||
|
||||
@ExcelProperty("门店地址") |
||||
private String address; |
||||
|
||||
@ExcelProperty("创建时间") |
||||
private Date createTime; |
||||
|
||||
@ExcelProperty("状态") |
||||
private String status; |
||||
|
||||
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 BigDecimal getPayRealPrice() { |
||||
return payRealPrice; |
||||
} |
||||
|
||||
public void setPayRealPrice(BigDecimal payRealPrice) { |
||||
this.payRealPrice = payRealPrice; |
||||
} |
||||
|
||||
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 String getStatusFailDesc() { |
||||
return statusFailDesc; |
||||
} |
||||
|
||||
public void setStatusFailDesc(String statusFailDesc) { |
||||
this.statusFailDesc = statusFailDesc; |
||||
} |
||||
|
||||
public Date getReachTime() { |
||||
return reachTime; |
||||
} |
||||
|
||||
public void setReachTime(Date reachTime) { |
||||
this.reachTime = reachTime; |
||||
} |
||||
|
||||
public String getReachAddress() { |
||||
return reachAddress; |
||||
} |
||||
|
||||
public void setReachAddress(String reachAddress) { |
||||
this.reachAddress = reachAddress; |
||||
} |
||||
|
||||
public String getStoreName() { |
||||
return storeName; |
||||
} |
||||
|
||||
public void setStoreName(String storeName) { |
||||
this.storeName = storeName; |
||||
} |
||||
|
||||
public String getAddress() { |
||||
return address; |
||||
} |
||||
|
||||
public void setAddress(String address) { |
||||
this.address = address; |
||||
} |
||||
|
||||
public Date getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(Date createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public String getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(String status) { |
||||
this.status = status; |
||||
} |
||||
} |
@ -0,0 +1,69 @@ |
||||
package com.cweb.controller; |
||||
|
||||
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.HighBrand; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.HighBrandService; |
||||
import com.hai.service.HighGoodsTypeService; |
||||
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.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Auther: 袁野 |
||||
* @Description: |
||||
* @Date: 2021/3/26 23:08 |
||||
*/ |
||||
@Controller |
||||
@RequestMapping(value = "/highBrand") |
||||
@Api(value = "品牌接口") |
||||
public class HighBrandController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class); |
||||
|
||||
|
||||
@Resource |
||||
private HighBrandService highBrandService; |
||||
|
||||
@RequestMapping(value = "/getBrandByList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取品牌列表") |
||||
public ResponseData getBrandByList(@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
||||
@RequestParam(name = "title", required = false) String title, |
||||
@RequestParam(name = "goodTypeId", required = false) String goodTypeId, |
||||
HttpServletRequest request) { |
||||
try { |
||||
|
||||
Map<String,String> map = new HashMap<>(); |
||||
map.put("title", title); |
||||
map.put("goodTypeId", goodTypeId); |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(highBrandService.getListBand(map))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getUserOrderList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,69 @@ |
||||
package com.cweb.controller; |
||||
|
||||
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.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.HighGoodsTypeService; |
||||
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.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Auther: 袁野 |
||||
* @Description: |
||||
* @Date: 2021/3/26 23:08 |
||||
*/ |
||||
@Controller |
||||
@RequestMapping(value = "/highGoodsType") |
||||
@Api(value = "商品类型接口") |
||||
public class HighGoodsTypeController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class); |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighGoodsTypeService highGoodsTypeService; |
||||
|
||||
@RequestMapping(value = "/getListGoodsType", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取商品类型列表") |
||||
public ResponseData getListGoodsType(@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
||||
@RequestParam(name = "title", required = false) String title, |
||||
HttpServletRequest request) { |
||||
try { |
||||
|
||||
Map<String,String> map = new HashMap<>(); |
||||
map.put("title", title); |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(highGoodsTypeService.getListGoodsType(map))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getUserOrderList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,137 @@ |
||||
package com.cweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
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.DateUtil; |
||||
import com.hai.common.utils.IDGenerator; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.config.TuanYouConfig; |
||||
import com.hai.entity.*; |
||||
import com.hai.model.HighMerchantStoreModel; |
||||
import com.hai.model.HighUserModel; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.service.*; |
||||
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.dao.DeadlockLoserDataAccessException; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @Auther: 胡锐 |
||||
* @Description: |
||||
* @Date: 2021/3/26 23:08 |
||||
*/ |
||||
@Controller |
||||
@RequestMapping(value = "/orderPre") |
||||
@Api(value = "预约订单接口") |
||||
public class HighOrderPreController { |
||||
private static Logger log = LoggerFactory.getLogger(HighOrderPreController.class); |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighOrderPreService highOrderPreService; |
||||
|
||||
|
||||
@RequestMapping(value = "/getUserOrderPreList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取用户预约订单") |
||||
public ResponseData getUserOrderPreList(@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "orderNo", required = false) String orderNo, |
||||
@RequestParam(name = "orderPreNo", required = false) String preOrderNo, |
||||
@RequestParam(name = "goodsName", required = false) String goodsName, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
||||
HttpServletRequest request) { |
||||
try { |
||||
|
||||
// 用户
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); |
||||
|
||||
Map<String,Object> map = new HashMap<>(); |
||||
map.put("preUserId", userInfoModel.getHighUser().getId()); |
||||
map.put("status", status); |
||||
map.put("orderNo", orderNo); |
||||
map.put("preOrderNo", preOrderNo); |
||||
map.put("goodsName", goodsName); |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(highOrderPreService.getListOrderPre(map))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getUserPreOrderList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getOrderPreById", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据预约订单id 查询预约订单详情") |
||||
public ResponseData getOrderPreById(@RequestParam(name = "orderPreId", required = true) Long orderPreId) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(highOrderPreService.findByOrderId(orderPreId)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getOrderById() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getPreByOrderIdId", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据订单id 查询预约订单详情") |
||||
public ResponseData getPreByOrderIdId(@RequestParam(name = "orderId", required = true) Long orderId) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(highOrderPreService.getPreByOrderId(orderId)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getPreByOrderIdId() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/orderComplete", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "订单完成") |
||||
public ResponseData orderComplete(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body == null || body.getLong("preOrderId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
highOrderPreService.orderComplete(body.getLong("preOrderId")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> orderComplete() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,487 @@ |
||||
package com.hai.common.utils; |
||||
|
||||
import com.google.gson.Gson; |
||||
import com.google.gson.GsonBuilder; |
||||
import com.sun.jersey.api.client.Client; |
||||
import com.sun.jersey.api.client.ClientResponse; |
||||
import com.sun.jersey.api.client.WebResource; |
||||
import com.sun.jersey.api.client.WebResource.Builder; |
||||
import com.sun.jersey.api.client.config.DefaultClientConfig; |
||||
import com.sun.jersey.client.urlconnection.HTTPSProperties; |
||||
import org.apache.commons.codec.binary.Base64; |
||||
|
||||
import javax.crypto.Cipher; |
||||
import javax.crypto.spec.SecretKeySpec; |
||||
import javax.net.ssl.*; |
||||
import javax.ws.rs.core.MediaType; |
||||
import java.security.*; |
||||
import java.security.cert.CertificateException; |
||||
import java.security.spec.InvalidKeySpecException; |
||||
import java.security.spec.KeySpec; |
||||
import java.security.spec.PKCS8EncodedKeySpec; |
||||
import java.security.spec.X509EncodedKeySpec; |
||||
import java.text.ParseException; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.*; |
||||
|
||||
public class UnionUtils { |
||||
private static Client c = null; |
||||
private static Client secureClient =null; |
||||
private static Gson gson = new GsonBuilder().disableHtmlEscaping().create(); |
||||
public static String DATE_FORMAT = "yyyy-MM-dd"; |
||||
/** |
||||
* 初始化设置 |
||||
*/ |
||||
static{ |
||||
initalizationJersyClient(); |
||||
initalizationSecureJersyClient(); |
||||
} |
||||
/** |
||||
* 设置调用参数 |
||||
*/ |
||||
private static void initalizationJersyClient(){ |
||||
try { |
||||
c = Client.create(); |
||||
c.setFollowRedirects(true); |
||||
c.setConnectTimeout(10000); |
||||
c.setReadTimeout(10000); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private static void initalizationSecureJersyClient(){ |
||||
try { |
||||
SSLContext context = SSLContext.getInstance("SSL"); |
||||
context.init(null, new TrustManager[] { new X509TrustManager() { |
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() { |
||||
return null; |
||||
} |
||||
public void checkClientTrusted( |
||||
java.security.cert.X509Certificate[] chain, String authType) |
||||
throws CertificateException {} |
||||
public void checkServerTrusted( |
||||
java.security.cert.X509Certificate[] chain, |
||||
String authType) throws CertificateException {} |
||||
} }, new SecureRandom()); |
||||
HostnameVerifier hv = new HostnameVerifier(){ |
||||
public boolean verify(String urlHostName, SSLSession session){ |
||||
return true; |
||||
} |
||||
}; |
||||
|
||||
HTTPSProperties prop = new HTTPSProperties(hv, context); |
||||
DefaultClientConfig dcc = new DefaultClientConfig(); |
||||
dcc.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, prop); |
||||
secureClient = Client.create(dcc); |
||||
secureClient.setFollowRedirects(true); |
||||
secureClient.setConnectTimeout(10000); |
||||
secureClient.setReadTimeout(10000); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 调用接口 |
||||
*/ |
||||
public static String sendPOSTRequest(String url, Object map, String contentTpye){ |
||||
if(null==c){ |
||||
initalizationJersyClient(); |
||||
} |
||||
Client client = null; |
||||
if(url.indexOf("https://") == 0){ |
||||
if(null==secureClient){ |
||||
initalizationJersyClient(); |
||||
} |
||||
client = secureClient; |
||||
}else{ |
||||
if(null==c){ |
||||
initalizationJersyClient(); |
||||
} |
||||
client = c; |
||||
} |
||||
WebResource resource = client.resource(url); |
||||
String resultStr = null; |
||||
try { |
||||
Builder builder = resource.accept("*/*"); |
||||
ClientResponse res = builder.type(contentTpye).entity(map).post(ClientResponse.class); |
||||
if(res.getStatus() != 200){ |
||||
throw new Exception("url:"+url+",response code:" + res.getStatus()); |
||||
} |
||||
resultStr = res.getEntity(String.class); |
||||
return resultStr; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 参数 转为json格式 |
||||
* @param url 调用地址 |
||||
* @param map 设置的参数 |
||||
* @return |
||||
*/ |
||||
public static String sendPostGson(String url, Map<String, String> map){ |
||||
String ps = gson.toJson(map); |
||||
|
||||
System.out.println("生成加密后的报文:"+ps); |
||||
return sendPOSTRequest(url, ps, MediaType.APPLICATION_JSON); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 使用公钥加密对称密钥 |
||||
* @param publicKey 公钥 |
||||
* @param symmetricKeyByte 对称密钥字节 |
||||
* @return 加密后的对称密钥字节 |
||||
* @throws Exception |
||||
*/ |
||||
public static byte[] encrypt(String publicKey, byte[] symmetricKeyByte) throws Exception { |
||||
byte[] encodedKey = Base64.decodeBase64(publicKey); |
||||
KeySpec keySpec = new X509EncodedKeySpec(encodedKey); |
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA"); |
||||
PublicKey pk = keyFactory.generatePublic(keySpec); |
||||
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); |
||||
cipher.init(Cipher.ENCRYPT_MODE, pk); |
||||
byte[] result = cipher.doFinal(symmetricKeyByte); |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 签名加密后的数据装载进map |
||||
* @param key 对称秘钥 |
||||
* @param params 待加密的字符串 |
||||
* @param encryptKeys 加密字段 |
||||
* @throws Exception |
||||
*/ |
||||
public static void encryptedParamMap(String key, Map<String, String> params, String ... encryptKeys) throws Exception{ |
||||
if(encryptKeys != null && encryptKeys.length > 0){ |
||||
for(String encryptKey : encryptKeys){ |
||||
params.put(encryptKey, getEncryptedValue(params.get(encryptKey), key)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 3DES加密 |
||||
* @param value 待加密的字符串 |
||||
* @param key 加密密钥 |
||||
* @return 加密后的字符串 |
||||
* @throws Exception |
||||
*/ |
||||
public static String getEncryptedValue(String value, String key) throws Exception { |
||||
if (null == value || "".equals(value)) { |
||||
return ""; |
||||
} |
||||
byte[] valueByte = value.getBytes(); |
||||
byte[] sl = encrypt3DES(valueByte, hexToBytes(key)); |
||||
String result = Base64.encodeBase64String(sl); |
||||
// String result = BytesUtil.bytesToHex(sl);
|
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 解密 |
||||
* @param value 待解密的字符串 |
||||
* @param key 解密秘钥 |
||||
* @return 解密后字符串 |
||||
* @throws Exception |
||||
*/ |
||||
public static String getDecryptedValue(String value, String key) throws Exception { |
||||
if (null == value || "".equals(value)) { |
||||
return ""; |
||||
} |
||||
byte[] valueByte = Base64.decodeBase64(value); |
||||
byte[] sl = decrypt3DES(valueByte, hexStr2Bytes(key)); |
||||
String result = new String(sl); |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 3DES解密 |
||||
* @param input |
||||
* @param key |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static byte[] decrypt3DES(byte[] input, byte[] key) throws Exception { |
||||
Cipher c = Cipher.getInstance("DESede/ECB/PKCS5Padding"); |
||||
c.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "DESede")); |
||||
return c.doFinal(input); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* bytes字符串转换为Byte值 |
||||
* @param src String Byte字符串,每个Byte之间没有分隔符(字符范围:0-9 A-F) |
||||
* @return byte[] |
||||
*/ |
||||
public static byte[] hexStr2Bytes(String src){ |
||||
/*对输入值进行规范化整理*/ |
||||
src = src.trim().replace(" ", "").toUpperCase(Locale.US); |
||||
//处理值初始化
|
||||
int m=0,n=0; |
||||
int iLen=src.length()/2; //计算长度
|
||||
byte[] ret = new byte[iLen]; //分配存储空间
|
||||
|
||||
for (int i = 0; i < iLen; i++){ |
||||
m=i*2+1; |
||||
n=m+1; |
||||
ret[i] = (byte)(Integer.decode("0x"+ src.substring(i*2, m) + src.substring(m,n)) & 0xFF); |
||||
} |
||||
return ret; |
||||
} |
||||
|
||||
/** |
||||
* 3DES加密 |
||||
* @param input 待加密的字节 |
||||
* @param key 密钥 |
||||
* @return 加密后的字节 |
||||
* @throws Exception |
||||
*/ |
||||
private static byte[] encrypt3DES(byte[] input, byte[] key) throws Exception { |
||||
Cipher c = Cipher.getInstance("DESede/ECB/PKCS5Padding"); |
||||
c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "DESede")); |
||||
return c.doFinal(input); |
||||
} |
||||
|
||||
/** |
||||
* 获取随机字符串 |
||||
* @return 随机字符串 |
||||
*/ |
||||
public static String createNonceStr(){ |
||||
String sl = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
||||
StringBuilder sb = new StringBuilder(); |
||||
for(int i = 0 ; i < 16 ; i ++){ |
||||
sb.append(sl.charAt(new Random().nextInt(sl.length()))); |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
|
||||
/** |
||||
* h获取32位随机数字字符串 |
||||
* @return |
||||
*/ |
||||
public static String createNonceNumber(){ |
||||
String sl = "0123456789"; |
||||
StringBuilder sb = new StringBuilder(); |
||||
for(int i = 0 ; i < 32 ; i ++){ |
||||
sb.append(sl.charAt(new Random().nextInt(sl.length()))); |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
/** |
||||
* 获取当前日期时间 |
||||
* |
||||
* @return |
||||
*/ |
||||
public static String getCurrentDateTime(String Dateformat) { |
||||
String datestr = null; |
||||
SimpleDateFormat df = new SimpleDateFormat(Dateformat); |
||||
datestr = df.format(new Date()); |
||||
return datestr; |
||||
} |
||||
|
||||
/** |
||||
* 在输入日期上增加(+)或减去(-)天数 |
||||
* |
||||
* @param date 输入日期 |
||||
*/ |
||||
public static Date addDay(Date date, int iday) { |
||||
Calendar cd = Calendar.getInstance(); |
||||
|
||||
cd.setTime(date); |
||||
|
||||
cd.add(Calendar.DAY_OF_MONTH, iday); |
||||
|
||||
return cd.getTime(); |
||||
} |
||||
/** |
||||
* 将日期格式日期转换为字符串格式 自定義格式 |
||||
* |
||||
* @param date |
||||
* @param dateformat |
||||
* @return |
||||
*/ |
||||
public static String dateToString(Date date, String dateformat) { |
||||
String datestr = null; |
||||
SimpleDateFormat df = new SimpleDateFormat(dateformat); |
||||
datestr = df.format(date); |
||||
return datestr; |
||||
} |
||||
|
||||
/** |
||||
* 将字符串日期转换为日期格式 |
||||
* |
||||
* @param datestr |
||||
* @return |
||||
*/ |
||||
public static Date stringToDate(String datestr) throws Exception{ |
||||
|
||||
if (datestr == null || datestr.equals("")) { |
||||
return null; |
||||
} |
||||
Date date = new Date(); |
||||
SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); |
||||
try { |
||||
date = df.parse(datestr); |
||||
} catch (ParseException e) { |
||||
date = stringToDate(datestr, "yyyyMMdd"); |
||||
} |
||||
return date; |
||||
} |
||||
|
||||
/** |
||||
* 将字符串日期转换为日期格式 |
||||
* 自定義格式 |
||||
* |
||||
* @param datestr |
||||
* @return |
||||
*/ |
||||
public static Date stringToDate(String datestr, String dateformat) throws Exception{ |
||||
Date date = new Date(); |
||||
SimpleDateFormat df = new SimpleDateFormat(dateformat); |
||||
date = df.parse(datestr); |
||||
return date; |
||||
} |
||||
/** |
||||
* 签名 |
||||
* @param param 待签名的参数 |
||||
* @param signKey 签名密钥 |
||||
* @return 签名结果字符串 |
||||
* @throws Exception |
||||
*/ |
||||
public static String sign(Map<String, String> param, String signKey) throws Exception { |
||||
String value = sortMap(param); |
||||
byte[] keyBytes = Base64.decodeBase64(signKey); |
||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes); |
||||
KeyFactory keyf = KeyFactory.getInstance("RSA"); |
||||
PrivateKey priKey = keyf.generatePrivate(keySpec); |
||||
Signature signature = Signature.getInstance("SHA256WithRSA"); |
||||
signature.initSign(priKey); |
||||
signature.update(value.getBytes()); |
||||
byte[] signed = signature.sign(); |
||||
String result = Base64.encodeBase64String(signed); |
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 排序 |
||||
* @param param 待排序的参数 |
||||
* @return 排序结果字符串 |
||||
*/ |
||||
public static String sortMap(Map<String, String> param){ |
||||
StringBuilder result = new StringBuilder(); |
||||
Collection<String> keySet = param.keySet(); |
||||
List<String> list = new ArrayList<String>(keySet); |
||||
Collections.sort(list); |
||||
for (int i = 0; i < list.size(); ++i) { |
||||
String key = list.get(i); |
||||
if("symmetricKey".equals(key)){ |
||||
continue; |
||||
} |
||||
// 非空字段需要参与签名
|
||||
// if(param.get(key) == null || "".equals(param.get(key).trim())){
|
||||
// continue;
|
||||
// }
|
||||
result.append(key).append("=").append(param.get(key)).append("&"); |
||||
} |
||||
return result.substring(0, result.length() - 1); |
||||
} |
||||
|
||||
|
||||
public static String sha256(byte[] data) { |
||||
try { |
||||
MessageDigest md = MessageDigest.getInstance("SHA-256"); |
||||
return bytesToHex(md.digest(data)); |
||||
|
||||
} catch (Exception ex) { |
||||
|
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 将byte数组转换成16进制字符串 |
||||
* |
||||
* @param bytes |
||||
* @return 16进制字符串 |
||||
*/ |
||||
public static String bytesToHex(byte[] bytes) { |
||||
String hexArray = "0123456789abcdef"; |
||||
StringBuilder sb = new StringBuilder(bytes.length * 2); |
||||
for (byte b : bytes) { |
||||
int bi = b & 0xff; |
||||
sb.append(hexArray.charAt(bi >> 4)); |
||||
sb.append(hexArray.charAt(bi & 0xf)); |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
|
||||
public static byte[] hexToBytes(String hex) { |
||||
return hexToBytes(hex.toCharArray()); |
||||
} |
||||
|
||||
public static byte[] hexToBytes(char[] hex) { |
||||
int length = hex.length / 2; |
||||
byte[] raw = new byte[length]; |
||||
for (int i = 0; i < length; i++) { |
||||
int high = Character.digit(hex[i * 2], 16); |
||||
int low = Character.digit(hex[i * 2 + 1], 16); |
||||
int value = (high << 4) | low; |
||||
if (value > 127) { |
||||
value -= 256; |
||||
} |
||||
raw[i] = (byte) value; |
||||
} |
||||
return raw; |
||||
} |
||||
|
||||
public static String createSign(Map<String, String> params){ |
||||
StringBuilder sb = new StringBuilder(); |
||||
// 将参数以参数名的字典升序排序
|
||||
Map<String, String> sortParams = new TreeMap<String, String>(params); |
||||
// 遍历排序的字典,并拼接"key=value"格式
|
||||
for (Map.Entry<String, String> entry : sortParams.entrySet()) { |
||||
String key = entry.getKey(); |
||||
String value = entry.getValue().trim(); |
||||
if (null != value && !"".equals(value)) |
||||
sb.append("&").append(key).append("=").append(value); |
||||
} |
||||
String stringA = sb.toString().replaceFirst("&",""); |
||||
String stringSignTemp = stringA ; |
||||
String signValue = sha256(stringSignTemp.getBytes()); |
||||
return signValue; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
/** |
||||
* 签名 |
||||
* @param param 待签名的参数 |
||||
* @param sign 签名结果字符串 |
||||
* @return 签名结果 |
||||
* @throws NoSuchAlgorithmException |
||||
* @throws InvalidKeySpecException |
||||
* @throws InvalidKeyException |
||||
* @throws SignatureException |
||||
*/ |
||||
public static boolean verify(Map<String, String> param, String sign,String rescissionPublicKey) throws Exception { |
||||
String value = sortMap(param); |
||||
byte[] keyBytes = Base64.decodeBase64(rescissionPublicKey); |
||||
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes); |
||||
KeyFactory keyf = KeyFactory.getInstance("RSA"); |
||||
PublicKey pubkey = keyf.generatePublic(keySpec); |
||||
Signature signature = Signature.getInstance("SHA256WithRSA"); |
||||
signature.initVerify(pubkey); |
||||
signature.update(value.getBytes()); |
||||
boolean result = signature.verify(Base64.decodeBase64(sign.getBytes())); |
||||
return result; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,194 @@ |
||||
package com.hai.model; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
public class HighOrderPreModel { |
||||
/** |
||||
* 预约订单号 |
||||
*/ |
||||
private String preOrderNo; |
||||
|
||||
/** |
||||
* 支付订单号 |
||||
*/ |
||||
private String orderNo; |
||||
|
||||
/** |
||||
* 实付金额 |
||||
*/ |
||||
private BigDecimal payRealPrice; |
||||
|
||||
|
||||
/** |
||||
* 商品名称 |
||||
*/ |
||||
private String goodsName; |
||||
|
||||
|
||||
/** |
||||
* 预约用户姓名 |
||||
*/ |
||||
private String preUserName; |
||||
|
||||
/** |
||||
* 预约用户手机号 |
||||
*/ |
||||
private String preUserPhone; |
||||
|
||||
/** |
||||
* 预约用户备注 |
||||
*/ |
||||
private String preUserRemark; |
||||
|
||||
/** |
||||
* 状态 1.预约中 2. 预约成功 3.预约完成 4.预约失败 5.预约取消 |
||||
*/ |
||||
private String status; |
||||
|
||||
/** |
||||
* 预约失败说明 |
||||
*/ |
||||
private String statusFailDesc; |
||||
|
||||
|
||||
/** |
||||
* 到达时间 |
||||
*/ |
||||
private Date reachTime; |
||||
|
||||
/** |
||||
* 到达地点 |
||||
*/ |
||||
private String reachAddress; |
||||
|
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 门店名称 |
||||
*/ |
||||
private String storeName; |
||||
|
||||
/** |
||||
* 门店地址 |
||||
*/ |
||||
private String address; |
||||
|
||||
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 BigDecimal getPayRealPrice() { |
||||
return payRealPrice; |
||||
} |
||||
|
||||
public void setPayRealPrice(BigDecimal payRealPrice) { |
||||
this.payRealPrice = payRealPrice; |
||||
} |
||||
|
||||
public String getGoodsName() { |
||||
return goodsName; |
||||
} |
||||
|
||||
public void setGoodsName(String goodsName) { |
||||
this.goodsName = goodsName; |
||||
} |
||||
|
||||
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 String getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(String status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
public String getStatusFailDesc() { |
||||
return statusFailDesc; |
||||
} |
||||
|
||||
public void setStatusFailDesc(String statusFailDesc) { |
||||
this.statusFailDesc = statusFailDesc; |
||||
} |
||||
|
||||
public Date getReachTime() { |
||||
return reachTime; |
||||
} |
||||
|
||||
public void setReachTime(Date reachTime) { |
||||
this.reachTime = reachTime; |
||||
} |
||||
|
||||
public String getReachAddress() { |
||||
return reachAddress; |
||||
} |
||||
|
||||
public void setReachAddress(String reachAddress) { |
||||
this.reachAddress = reachAddress; |
||||
} |
||||
|
||||
public Date getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(Date createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public String getStoreName() { |
||||
return storeName; |
||||
} |
||||
|
||||
public void setStoreName(String storeName) { |
||||
this.storeName = storeName; |
||||
} |
||||
|
||||
public String getAddress() { |
||||
return address; |
||||
} |
||||
|
||||
public void setAddress(String address) { |
||||
this.address = address; |
||||
} |
||||
} |
Loading…
Reference in new issue