@ -647,119 +647,119 @@ public class OrderController {
public ResponseData fleetOilCardPay ( @RequestBody String reqBodyStr , HttpServletRequest request ) {
try {
// 用户
SessionObject sessionObject = userCenter . getSessionObject ( request ) ;
HighUserModel userInfoModel = ( HighUserModel ) sessionObject . getObject ( ) ;
if ( StringUtils . isBlank ( reqBodyStr ) ) {
log . error ( "orderToPay error!" , "参数错误" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . REQ_PARAMS_ERROR , "" ) ;
}
JSONObject jsonObject = JSONObject . parseObject ( reqBodyStr ) ;
String cardNo = jsonObject . getString ( "cardNo" ) ;
Long orderId = jsonObject . getLong ( "orderId" ) ;
String password = jsonObject . getString ( "password" ) ;
String carLicensePlate = jsonObject . getString ( "carLicensePlate" ) ;
if ( StringUtils . isBlank ( cardNo ) | | orderId = = null ) {
log . error ( "orderToPay error!" , "参数错误" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . REQ_PARAMS_ERROR , "" ) ;
}
// 查询用户支付密码
HighUserPayPassword userPayPassword = highUserPayPasswordService . getDetailByUser ( userInfoModel . getHighUser ( ) . getId ( ) ) ;
if ( userPayPassword = = null ) {
log . error ( "orderToPay error!" , "未设置支付密码" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . NOT_SET_USER_PAY_PWD , "" ) ;
}
if ( StringUtils . isBlank ( password ) ) {
log . error ( "orderToPay error!" , "未输入支付密码" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . NOT_ENTER_USER_PAY_PWD , "" ) ;
}
// 校验支付密码是否一直
if ( ! AESEncodeUtil . aesEncrypt ( password ) . equals ( userPayPassword . getPassword ( ) ) ) {
log . error ( "orderToPay error!" , "" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . USER_PAY_PWD_ERROR , "" ) ;
}
// 查询用户与卡号的关系
HighUserCard userCard = highUserCardService . getDetailByUserCardNo ( userInfoModel . getHighUser ( ) . getId ( ) , cardNo ) ;
if ( userCard = = null ) {
log . error ( "OrderController --> orderToPay() ERROR" , "未绑定卡号" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "未绑定卡号" ) ;
}
HighOrder order = highOrderService . getOrderById ( orderId ) ;
if ( order = = null ) {
log . error ( "OrderController --> orderToPay() ERROR" , "未找到订单信息" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . NOT_FOUND_ORDER , "" ) ;
}
//校验订单状态 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
if ( order . getOrderStatus ( ) ! = 1 ) {
log . error ( "OrderController --> orderToPay() ERROR" , "订单不处于待支付状态" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . ORDER_NO_STAY_PAY , "" ) ;
}
// 商品类型 1:卡卷 2:金币充值
for ( HighChildOrder childOrder : order . getHighChildOrderList ( ) ) {
if ( childOrder . getGoodsType ( ) = = 3 ) {
if ( highOrderService . getGasTheDayOrderNum ( order . getMemId ( ) ) > = 1 ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "已达到每日加油次数上限" ) ;
}
// 查询加油站
HighMerchantStoreModel store = merchantStoreService . getMerchantStoreById ( childOrder . getGoodsId ( ) ) ;
if ( store = = null ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "已达到每日加油次数上限" ) ;
}
// 来源类型 1:平台自建 2:团油
if ( store . getSourceType ( ) . equals ( 2 ) ) {
// 查询账号余额
JSONObject accountInfo2JD = TuanYouConfig . queryCompanyAccountInfo2JD ( ) ;
JSONArray result = accountInfo2JD . getJSONArray ( "result" ) ;
for ( Object accountObject : result ) {
JSONObject account = ( JSONObject ) accountObject ;
// 1:汽油:2:柴油;3:天然气
if ( account . getInteger ( "energyType" ) = = c hildOrder. getGasOilType ( ) ) {
// 支付金额 大于 团油账号余额
if ( order . getPayPrice ( ) . compareTo ( account . getBigDecimal ( "accountBalance" ) ) = = 1 ) {
log . error ( "OrderController --> orderToPay() ERROR" , "无法进行支付,请联系平台客服" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "无法进行支付,请联系平台客服" ) ;
}
}
}
}
// 来源类型 1:平台自建 2:团油
if ( store . getSourceType ( ) . equals ( MerchantStoreSourceType . type3 . getNumber ( ) ) ) {
BigDecimal account = new BigDecimal ( "0" ) ;
// 查询账号余额
HighMerchantAccount merAccount = merchantAccountService . getMerAccountDetail ( store . getMerchantId ( ) ) ;
if ( merAccount ! = null ) {
account = merAccount . getAmounts ( ) . subtract ( merchantAccountService . countMerGasOilAmount ( store . getMerchantId ( ) ) ) ;
}
// 客户加油金额 大于 商户账号余额
if ( order . getTotalPrice ( ) . compareTo ( account ) = = 1 ) {
log . error ( "OrderController --> orderToPay() ERROR" , "暂时无法进行支付,请联系平台客服" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "暂时无法进行支付,请联系平台客服" ) ;
}
}
}
}
highOrderService . fleetOilCardPayOrder ( userCard . getId ( ) , order . getId ( ) , carLicensePlate ) ;
new Thread ( ( ) - > {
// 查询订单信息
if ( order = = null ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . NOT_FOUND_ORDER , "" ) ;
}
HighUser highUser = highUserService . findByUserId ( order . getMemId ( ) ) ;
HighChildOrder presentation = highOrderService . getChildOrderByPresentation ( order . getId ( ) ) ;
WxMsgConfig . pushOneUser (
presentation . getGoodsName ( ) + "(" + GoodsType . getNameByType ( presentation . getGoodsType ( ) ) + ")" ,
String . valueOf ( order . getPayPrice ( ) ) ,
order . getOrderNo ( ) ,
order . getPayTime ( ) ,
PayType . getNameByType ( order . getPayType ( ) ) , order . getId ( ) ,
highUser . getOpenId ( ) ) ;
} ) . start ( ) ;
// SessionObject sessionObject = userCenter.getSessionObject(request);
// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
//
// if (StringUtils.isBlank(reqBodyStr)) {
// log.error("orderToPay error!", "参数错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
// JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
// String cardNo = jsonObject.getString("cardNo");
// Long orderId = jsonObject.getLong("orderId");
// String password = jsonObject.getString("password");
// String carLicensePlate = jsonObject.getString("carLicensePlate");
//
// if (StringUtils.isBlank(cardNo) || orderId == null) {
// log.error("orderToPay error!", "参数错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
// // 查询用户支付密码
// HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(userInfoModel.getHighUser().getId());
// if (userPayPassword == null) {
// log.error("orderToPay error!", "未设置支付密码");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, "");
// }
// if (StringUtils.isBlank(password)) {
// log.error("orderToPay error!", "未输入支付密码");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, "");
// }
// // 校验支付密码是否一直
// if (!AESEncodeUtil.aesEncrypt(password).equals(userPayPassword.getPassword())) {
// log.error("orderToPay error!", "");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, "");
// }
//
// // 查询用户与卡号的关系
// HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), cardNo);
// if (userCard == null) {
// log.error("OrderController --> orderToPay() ERROR", "未绑定卡号");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号");
// }
// HighOrder order = highOrderService.getOrderById(orderId);
// if(order == null) {
// log.error("OrderController --> orderToPay() ERROR", "未找到订单信息");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
// }
// //校验订单状态 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
// if(order.getOrderStatus() != 1) {
// log.error("OrderController --> orderToPay() ERROR", "订单不处于待支付状态");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, "");
// }
//
// // 商品类型 1:卡卷 2:金币充值
// for (HighChildOrder childOrder : order.getHighChildOrderList()) {
// if (childOrder.getGoodsType() = = 3) {
// if (highOrderService.getGasTheDayOrderNum(order.getMemId()) >= 1) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限");
// }
//
// // 查询加油站
// HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(childOrder.getGoodsId());
// if (store = = null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限");
// }
// // 来源类型 1:平台自建 2:团油
// if (store.getSourceType().equals(2)) {
// // 查询账号余额
// JSONObject accountInfo2JD = TuanYouConfig.queryCompanyAccountInfo2JD();
// JSONArray result = accountInfo2JD.getJSONArray("result");
// for (Object accountObject : result) {
// JSONObject account = (JSONObject)accountObject;
// // 1:汽油:2:柴油;3:天然气
// if (account.getInteger("energyType") = = c hildOrder.getGasOilType()) {
// // 支付金额 大于 团油账号余额
// if(order.getPayPrice().compareTo(account.getBigDecimal("accountBalance")) = = 1){
// log.error("OrderController --> orderToPay() ERROR", "无法进行支付,请联系平台客服");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法进行支付,请联系平台客服");
// }
// }
// }
// }
// // 来源类型 1:平台自建 2:团油
// if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) {
// BigDecimal account = new BigDecimal("0");
// // 查询账号余额
// HighMerchantAccount merAccount = merchantAccountService.getMerAccountDetail(store.getMerchantId());
// if (merAccount != null) {
// account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId()));
// }
// // 客户加油金额 大于 商户账号余额
// if(order.getTotalPrice().compareTo(account) = = 1) {
// log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服");
// }
// }
// }
// }
//
// highOrderService.fleetOilCardPayOrder(userCard.getId(), order.getId(), carLicensePlate);
//
// new Thread(() -> {
// // 查询订单信息
// if (order = = null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
// }
// HighUser highUser = highUserService.findByUserId(order.getMemId());
// HighChildOrder presentation = highOrderService.getChildOrderByPresentation(order.getId());
// WxMsgConfig.pushOneUser(
// presentation.getGoodsName() + "(" + GoodsType.getNameByType(presentation.getGoodsType()) + ")",
// String.valueOf(order.getPayPrice()),
// order.getOrderNo(),
// order.getPayTime(),
// PayType.getNameByType(order.getPayType()), order.getId(),
// highUser.getOpenId());
// }).start();
return ResponseMsgUtil . success ( "支付成功" ) ;
} catch ( Exception e ) {