|
|
|
@ -26,6 +26,7 @@ import com.hai.order.service.OrderService; |
|
|
|
|
import com.hai.order.service.OrderPayService; |
|
|
|
|
import com.hai.order.type.OrderProductType; |
|
|
|
|
import com.hai.order.type.OrderStatus; |
|
|
|
|
import com.hai.order.type.PlatformType; |
|
|
|
|
import com.hai.service.*; |
|
|
|
|
import com.web.config.SysConst; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
@ -50,6 +51,7 @@ import java.util.concurrent.ThreadLocalRandom; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 订单支付 |
|
|
|
|
* |
|
|
|
|
* @className: OrderPayController |
|
|
|
|
* @author: HuRui |
|
|
|
|
* @date: 2022/8/30 |
|
|
|
@ -103,7 +105,7 @@ public class OrderPayController { |
|
|
|
|
@Resource |
|
|
|
|
private SecConfigService secConfigService; |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/wechatPay",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value = "/wechatPay", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "微信支付") |
|
|
|
|
public ResponseData wechatPay(@RequestBody JSONObject body) { |
|
|
|
@ -122,7 +124,7 @@ public class OrderPayController { |
|
|
|
|
|
|
|
|
|
// 查询订单
|
|
|
|
|
HighOrder order = orderService.getOrderDetailByNo(body.getString("orderNo")); |
|
|
|
|
if(!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { |
|
|
|
|
if (!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { |
|
|
|
|
log.error("wxPay ERROR", "订单不处于待支付状态"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, ""); |
|
|
|
|
} |
|
|
|
@ -138,11 +140,19 @@ public class OrderPayController { |
|
|
|
|
WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); |
|
|
|
|
weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxPayMchAppId()); // 公众号id
|
|
|
|
|
weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxPayMchId()); // 商户号
|
|
|
|
|
if (PlatformType.TYPE2.getNumber().equals(body.getInteger("platformType"))) { |
|
|
|
|
if (openIdType != null && openIdType.equals(2)) { |
|
|
|
|
weChatPayReqInfo.setSub_appid(WxOrderConfig.APPID_QYX_MP); // 商户号公众号
|
|
|
|
|
} else { |
|
|
|
|
weChatPayReqInfo.setSub_appid(WxOrderConfig.APPID_QYX_MINI); // 嗨森逛小程序
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (openIdType != null && openIdType.equals(2)) { |
|
|
|
|
weChatPayReqInfo.setSub_appid(WxOrderConfig.APPID_HSG_MP); // 商户号公众号
|
|
|
|
|
} else { |
|
|
|
|
weChatPayReqInfo.setSub_appid(WxOrderConfig.APPID_HSG_MINI); // 嗨森逛小程序
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 订单产品类型
|
|
|
|
|
OrderProductType productType = OrderProductType.getDataByType(order.getProductType()); |
|
|
|
@ -150,6 +160,10 @@ public class OrderPayController { |
|
|
|
|
orderTitle = productType.getName(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (PlatformType.TYPE2.getNumber().equals(body.getInteger("platformType"))) { |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1648729281); |
|
|
|
|
} else { |
|
|
|
|
if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE1.getNumber())) { |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195); |
|
|
|
|
|
|
|
|
@ -168,7 +182,7 @@ public class OrderPayController { |
|
|
|
|
// GZ_SINOPEC_QUOTA 单日限购数量
|
|
|
|
|
SecConfig gzSinopecQuota = secConfigService.findByCodeType("GZ_SINOPEC_QUOTA"); |
|
|
|
|
if (gzSinopecQuota != null |
|
|
|
|
&& couponService.userBuySourceLimitNumber(order.getMemId(),4) >= Integer.parseInt(gzSinopecQuota.getCodeValue())) { |
|
|
|
|
&& couponService.userBuySourceLimitNumber(order.getMemId(), 4) >= Integer.parseInt(gzSinopecQuota.getCodeValue())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法支付,已达单日限购数量"); |
|
|
|
|
} |
|
|
|
|
if (order.getMemDiscountId() != null) { |
|
|
|
@ -179,6 +193,17 @@ public class OrderPayController { |
|
|
|
|
} else { |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195); |
|
|
|
|
} |
|
|
|
|
} else if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE5.getNumber())) { |
|
|
|
|
HighCoupon coupon = couponService.getCouponById(order.getHighChildOrderList().get(0).getGoodsId()); |
|
|
|
|
if (coupon.getCouponSource() != null && coupon.getCouponSource().equals(4)) { |
|
|
|
|
if (order.getMemDiscountId() != null) { |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195); |
|
|
|
|
} else { |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1634835264); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE6.getNumber())) { |
|
|
|
|
// 查询油站
|
|
|
|
@ -194,12 +219,12 @@ public class OrderPayController { |
|
|
|
|
|
|
|
|
|
if (store.getSourceType().equals(MerchantStoreSourceType.type1.getNumber())) { |
|
|
|
|
// 查询支付配置
|
|
|
|
|
HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type1, GasChannelPayPlatformType.type1 ); |
|
|
|
|
HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type1, GasChannelPayPlatformType.type1); |
|
|
|
|
if (gasChannelConfig == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); |
|
|
|
|
} |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); |
|
|
|
|
profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true)?"Y":"N"; |
|
|
|
|
profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; |
|
|
|
|
|
|
|
|
|
if (store.getSourceType().equals(1)) { |
|
|
|
|
// 预存类型 0:非预存 1:预存门店
|
|
|
|
@ -209,7 +234,7 @@ public class OrderPayController { |
|
|
|
|
if (merTripartitePlatform != null) { |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(merTripartitePlatform.getPlatformMerNumber()); |
|
|
|
|
// 是否分账
|
|
|
|
|
profitSharing = merTripartitePlatform.getProfitSharingStatus().equals(true)?"Y":"N"; |
|
|
|
|
profitSharing = merTripartitePlatform.getProfitSharingStatus().equals(true) ? "Y" : "N"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -217,40 +242,40 @@ public class OrderPayController { |
|
|
|
|
} else if (store.getSourceType().equals(MerchantStoreSourceType.type2.getNumber())) { |
|
|
|
|
|
|
|
|
|
// 查询支付配置
|
|
|
|
|
HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type2,GasChannelPayPlatformType.type1 ); |
|
|
|
|
HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type2, GasChannelPayPlatformType.type1); |
|
|
|
|
if (gasChannelConfig == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); |
|
|
|
|
} |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); |
|
|
|
|
profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true)?"Y":"N"; |
|
|
|
|
profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; |
|
|
|
|
|
|
|
|
|
} else if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { |
|
|
|
|
|
|
|
|
|
// 查询支付配置
|
|
|
|
|
HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type3,GasChannelPayPlatformType.type1 ); |
|
|
|
|
HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type3, GasChannelPayPlatformType.type1); |
|
|
|
|
if (gasChannelConfig == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); |
|
|
|
|
} |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); |
|
|
|
|
profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true)?"Y":"N"; |
|
|
|
|
profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; |
|
|
|
|
|
|
|
|
|
} else if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { |
|
|
|
|
// 查询支付配置
|
|
|
|
|
HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type4,GasChannelPayPlatformType.type1 ); |
|
|
|
|
HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type4, GasChannelPayPlatformType.type1); |
|
|
|
|
if (gasChannelConfig == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); |
|
|
|
|
} |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); |
|
|
|
|
profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true)?"Y":"N"; |
|
|
|
|
profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; |
|
|
|
|
|
|
|
|
|
} else if (store.getSourceType().equals(MerchantStoreSourceType.type5.getNumber())) { |
|
|
|
|
// 查询支付配置
|
|
|
|
|
HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type5,GasChannelPayPlatformType.type1 ); |
|
|
|
|
HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type5, GasChannelPayPlatformType.type1); |
|
|
|
|
if (gasChannelConfig == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); |
|
|
|
|
} |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); |
|
|
|
|
profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true)?"Y":"N"; |
|
|
|
|
profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); |
|
|
|
@ -267,9 +292,11 @@ public class OrderPayController { |
|
|
|
|
|
|
|
|
|
} else if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE12.getNumber())) { |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1609882817); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// weChatPayReqInfo.setOpenid(openId);
|
|
|
|
|
weChatPayReqInfo.setSub_openid(body.getString("openId")); |
|
|
|
@ -286,11 +313,11 @@ public class OrderPayController { |
|
|
|
|
weChatPayReqInfo.setTime_expire(DateUtil.date2String(DateUtil.addMinute(order.getCreateTime(), 10), "yyyyMMddHHmmss")); |
|
|
|
|
|
|
|
|
|
//附加数据,区分订单类型
|
|
|
|
|
Map<String,String> payMap = new HashMap<>(); |
|
|
|
|
Map<String, String> payMap = new HashMap<>(); |
|
|
|
|
payMap.put("app_id", weChatPayReqInfo.getSub_appid()); |
|
|
|
|
payMap.put("api_key", SysConst.getSysConfig().getWxPayApiKey()); |
|
|
|
|
payMap.put("unified_order_url", SysConst.getSysConfig().getWxPayUnifiedOrderUrl()); |
|
|
|
|
SortedMap<Object, Object> sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); |
|
|
|
|
SortedMap<Object, Object> sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo, payMap); |
|
|
|
|
|
|
|
|
|
order.setAccountMerchantNum(weChatPayReqInfo.getSub_mch_id()); |
|
|
|
|
order.setProfitSharingStatus(profitSharing.equals("Y")); |
|
|
|
@ -299,12 +326,12 @@ public class OrderPayController { |
|
|
|
|
return ResponseMsgUtil.success(sortedMap); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("OrderController -> create() error!",e); |
|
|
|
|
log.error("OrderController -> create() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/cardPay",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value = "/cardPay", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "卡支付") |
|
|
|
|
public ResponseData cardPay(@RequestBody JSONObject body) { |
|
|
|
@ -347,7 +374,7 @@ public class OrderPayController { |
|
|
|
|
} |
|
|
|
|
// 查询订单
|
|
|
|
|
HighOrder order = orderService.getOrderDetailByNo(body.getString("orderNo")); |
|
|
|
|
if(!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { |
|
|
|
|
if (!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { |
|
|
|
|
log.error("OrderController --> cardPay() ERROR", "订单不处于待支付状态"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, ""); |
|
|
|
|
} |
|
|
|
@ -369,7 +396,7 @@ public class OrderPayController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("OrderPayController -> cardPay() error!",e); |
|
|
|
|
log.error("OrderPayController -> cardPay() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -487,7 +514,7 @@ public class OrderPayController { |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/unionPay",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value = "/unionPay", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "银联支付") |
|
|
|
|
public ResponseData unionPay(@RequestBody JSONObject body, HttpServletRequest request) { |
|
|
|
@ -498,11 +525,11 @@ public class OrderPayController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HighOrder order = orderService.getOrderDetailByNo(body.getString("orderNo")); |
|
|
|
|
if(order == null) { |
|
|
|
|
if (order == null) { |
|
|
|
|
log.error("OrderController --> orderToPay() ERROR", "未找到订单信息"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); |
|
|
|
|
} |
|
|
|
|
if(!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { |
|
|
|
|
if (!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { |
|
|
|
|
log.error("OrderController --> orderToPay() ERROR", "订单不处于待支付状态"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, ""); |
|
|
|
|
} |
|
|
|
|