|
|
@ -9,11 +9,14 @@ import com.hai.config.WxOrderConfig; |
|
|
|
import com.hai.entity.ApiMerchants; |
|
|
|
import com.hai.entity.ApiMerchants; |
|
|
|
import com.hai.entity.ApiOrder; |
|
|
|
import com.hai.entity.ApiOrder; |
|
|
|
import com.hai.entity.ApiProductConfig; |
|
|
|
import com.hai.entity.ApiProductConfig; |
|
|
|
|
|
|
|
import com.hai.entity.HighOrder; |
|
|
|
import com.hai.model.OrderRefundModel; |
|
|
|
import com.hai.model.OrderRefundModel; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.openApi.service.ApiOrderService; |
|
|
|
import com.hai.openApi.service.ApiOrderService; |
|
|
|
import com.hai.order.model.RefundPriceModel; |
|
|
|
import com.hai.order.model.RefundPriceModel; |
|
|
|
|
|
|
|
import com.hai.order.service.OrderService; |
|
|
|
import com.hai.order.type.OrderProductType; |
|
|
|
import com.hai.order.type.OrderProductType; |
|
|
|
|
|
|
|
import com.hai.order.type.OrderRefundOpUserType; |
|
|
|
import com.hai.service.*; |
|
|
|
import com.hai.service.*; |
|
|
|
import com.v1.config.ToolConfig; |
|
|
|
import com.v1.config.ToolConfig; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.Api; |
|
|
@ -51,8 +54,9 @@ public class orderController { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private RedisTemplate redisTemplate; |
|
|
|
private RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private ApiOrderService orderService; |
|
|
|
private OrderService orderService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private ApiIpAddressService apiIpAddressService; |
|
|
|
private ApiIpAddressService apiIpAddressService; |
|
|
@ -60,6 +64,9 @@ public class orderController { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private ApiOrderService apiOrderService; |
|
|
|
private ApiOrderService apiOrderService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighOrderService highOrderService; |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/createOrder", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/createOrder", method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "创建订单") |
|
|
|
@ApiOperation(value = "创建订单") |
|
|
@ -80,7 +87,6 @@ public class orderController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
StringUtils.isBlank(object.getString("apiKey")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("productType")) || |
|
|
|
StringUtils.isBlank(object.getString("productType")) || |
|
|
|
StringUtils.isBlank(object.getString("timetable")) || |
|
|
|
StringUtils.isBlank(object.getString("timetable")) || |
|
|
|
StringUtils.isBlank(object.getString("orderNo")) || |
|
|
|
StringUtils.isBlank(object.getString("orderNo")) || |
|
|
@ -108,7 +114,7 @@ public class orderController { |
|
|
|
map.put("timetable" , object.getString("timetable")); |
|
|
|
map.put("timetable" , object.getString("timetable")); |
|
|
|
map.put("orderNo" , object.getString("orderNo")); |
|
|
|
map.put("orderNo" , object.getString("orderNo")); |
|
|
|
map.put("productType" , object.getString("productType")); |
|
|
|
map.put("productType" , object.getString("productType")); |
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
map.put("apiKey" , apiMerchants.getApiKey()); |
|
|
|
map.put("content" , object.getString("content")); |
|
|
|
map.put("content" , object.getString("content")); |
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
|
|
|
|
|
|
@ -162,7 +168,7 @@ public class orderController { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写下单手机号,就餐方式,下单信息,门店编码"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写下单手机号,就餐方式,下单信息,门店编码"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return ResponseMsgUtil.success(orderService.createOrder(object)); |
|
|
|
return ResponseMsgUtil.success(apiOrderService.createOrder(object)); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("HighOpenApiController --> createOrder() error!", e); |
|
|
|
log.error("HighOpenApiController --> createOrder() error!", e); |
|
|
@ -190,7 +196,6 @@ public class orderController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
StringUtils.isBlank(object.getString("apiKey")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("mchOrderNo")) || |
|
|
|
StringUtils.isBlank(object.getString("mchOrderNo")) || |
|
|
|
StringUtils.isBlank(object.getString("sign")) || |
|
|
|
StringUtils.isBlank(object.getString("sign")) || |
|
|
|
StringUtils.isBlank(object.getString("merchId")) |
|
|
|
StringUtils.isBlank(object.getString("merchId")) |
|
|
@ -208,7 +213,7 @@ public class orderController { |
|
|
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
map.put("mchOrderNo" , object.getString("mchOrderNo")); |
|
|
|
map.put("mchOrderNo" , object.getString("mchOrderNo")); |
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
map.put("apiKey" , apiMerchants.getApiKey()); |
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map, object.getString("sign"))) { |
|
|
|
if (!secConfigService.isSignVerify(map, object.getString("sign"))) { |
|
|
@ -225,7 +230,7 @@ public class orderController { |
|
|
|
|
|
|
|
|
|
|
|
object.put("orderNo" , apiOrder.getOrderNo()); |
|
|
|
object.put("orderNo" , apiOrder.getOrderNo()); |
|
|
|
|
|
|
|
|
|
|
|
ApiOrder order = orderService.payOrder(object); |
|
|
|
ApiOrder order = apiOrderService.payOrder(object); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(order); |
|
|
|
return ResponseMsgUtil.success(order); |
|
|
|
|
|
|
|
|
|
|
@ -258,7 +263,6 @@ public class orderController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
StringUtils.isBlank(object.getString("apiKey")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("mchOrderNo")) || |
|
|
|
StringUtils.isBlank(object.getString("mchOrderNo")) || |
|
|
|
StringUtils.isBlank(object.getString("sign")) || |
|
|
|
StringUtils.isBlank(object.getString("sign")) || |
|
|
|
StringUtils.isBlank(object.getString("merchId")) |
|
|
|
StringUtils.isBlank(object.getString("merchId")) |
|
|
@ -276,7 +280,7 @@ public class orderController { |
|
|
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
map.put("mchOrderNo" , object.getString("mchOrderNo")); |
|
|
|
map.put("mchOrderNo" , object.getString("mchOrderNo")); |
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
map.put("apiKey" , apiMerchants.getApiKey()); |
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map, object.getString("sign"))) { |
|
|
|
if (!secConfigService.isSignVerify(map, object.getString("sign"))) { |
|
|
@ -292,14 +296,80 @@ public class orderController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/refund", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "退款") |
|
|
|
|
|
|
|
public ResponseData refund(@RequestBody JSONObject object , HttpServletRequest request) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String ip = ""; |
|
|
|
|
|
|
|
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
|
|
|
|
|
|
|
|
if (request.getHeader("x-forwarded-for") == null) { |
|
|
|
|
|
|
|
ip = request.getRemoteAddr(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ip = request.getHeader("x-forwarded-for"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { |
|
|
|
|
|
|
|
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("mchOrderNo")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("sign")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("merchId")) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
log.error("createOrder error!", "请求参数校验失败!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (apiMerchants == null) { |
|
|
|
|
|
|
|
log.error("getRechargeProduct error!", "帐户错误!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("mchOrderNo" , object.getString("mchOrderNo")); |
|
|
|
|
|
|
|
map.put("apiKey" , apiMerchants.getApiKey()); |
|
|
|
|
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map, object.getString("sign"))) { |
|
|
|
|
|
|
|
log.error("createOrder error!", "签名校验失败!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ApiOrder apiOrder = apiOrderService.findByOrderNo(object.getString("mchOrderNo") , null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HighOrder order = highOrderService.getOrderByOrderNo(apiOrder.getOrderNo()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (order.getOrderStatus() != 2) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orderService.refundOrder(order, "商户退款退款", OrderRefundOpUserType.TYPE1, |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
"系统自动退款"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("退款成功"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("HighOpenApiController --> createOrder() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/externalOrderRefund", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/externalOrderRefund", method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "对外订单退款接口") |
|
|
|
@ApiOperation(value = "对外订单退款接口") |
|
|
|
public ResponseData externalOrderRefund(@RequestBody JSONObject object , HttpServletRequest request) { |
|
|
|
public ResponseData externalOrderRefund(@RequestBody JSONObject object , HttpServletRequest request) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
System.out.println(object); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String ip = ""; |
|
|
|
String ip = ""; |
|
|
|
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
|
|
|
|
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
|
|
|
|
if (request.getHeader("x-forwarded-for") == null) { |
|
|
|
if (request.getHeader("x-forwarded-for") == null) { |
|
|
@ -314,7 +384,6 @@ public class orderController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
StringUtils.isBlank(object.getString("apiKey")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("paySerialNo")) || |
|
|
|
StringUtils.isBlank(object.getString("paySerialNo")) || |
|
|
|
StringUtils.isBlank(object.getString("wxMchId")) || |
|
|
|
StringUtils.isBlank(object.getString("wxMchId")) || |
|
|
|
StringUtils.isBlank(object.getString("refundPrice")) || |
|
|
|
StringUtils.isBlank(object.getString("refundPrice")) || |
|
|
@ -338,7 +407,7 @@ public class orderController { |
|
|
|
map.put("wxMchId" , object.getString("wxMchId")); |
|
|
|
map.put("wxMchId" , object.getString("wxMchId")); |
|
|
|
map.put("payRealPrice" , object.getString("payRealPrice")); |
|
|
|
map.put("payRealPrice" , object.getString("payRealPrice")); |
|
|
|
map.put("refundPrice" , object.getString("refundPrice")); |
|
|
|
map.put("refundPrice" , object.getString("refundPrice")); |
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
map.put("apiKey" , apiMerchants.getApiKey()); |
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map, object.getString("sign"))) { |
|
|
|
if (!secConfigService.isSignVerify(map, object.getString("sign"))) { |
|
|
|