@ -76,7 +76,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
private HighDiscountAgentCodeService highDiscountAgentCodeService ;
private HighDiscountAgentCodeService highDiscountAgentCodeService ;
@Resource
@Resource
private OutRechargeChildOrderService outRechargeChildOrderService ;
private OutRechargeChildOrderService outRechargeChildOrderService ;
@Resource
@Resource
private BsRequestRecordService bsRequestRecordService ;
private BsRequestRecordService bsRequestRecordService ;
@ -92,51 +92,53 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Override
@Override
public List < OutRechargeOrder > getListRechargeOrder ( Map < String , String > map ) {
public List < OutRechargeOrder > getListRechargeOrder ( Map < String , Object > map ) {
OutRechargeOrderExample example = new OutRechargeOrderExample ( ) ;
OutRechargeOrderExample example = new OutRechargeOrderExample ( ) ;
OutRechargeOrderExample . Criteria criteria = example . createCriteria ( ) ;
OutRechargeOrderExample . Criteria criteria = example . createCriteria ( ) ;
if ( MapUtils . getLong ( map , "userId" ) ! = null ) {
if ( MapUtils . getLong ( map , "userId" ) ! = null ) {
criteria . andUserIdEqualTo ( MapUtils . getLong ( map , "userId" ) ) ;
criteria . andUserIdEqualTo ( MapUtils . getLong ( map , "userId" ) ) ;
}
}
if ( MapUtils . getLong ( map , "companyId" ) ! = null ) {
criteria . andCompanyIdEqualTo ( MapUtils . getLong ( map , "companyId" ) ) ;
}
if ( MapUtils . getInteger ( map , "payType" ) ! = null ) {
if ( MapUtils . getInteger ( map , "payType" ) ! = null ) {
criteria . andPayTypeEqualTo ( MapUtils . getInteger ( map , "payType" ) ) ;
criteria . andPayTypeEqualTo ( MapUtils . getInteger ( map , "payType" ) ) ;
}
}
if ( MapUtils . getInteger ( map , "laborUnionCard" ) ! = null ) {
criteria . andLaborUnionCardEqualTo ( MapUtils . getString ( map , "laborUnionCard" ) ) ;
}
if ( MapUtils . getInteger ( map , "payStatus" ) ! = null ) {
criteria . andPayStatusEqualTo ( MapUtils . getInteger ( map , "payStatus" ) ) ;
}
if ( MapUtils . getInteger ( map , "rechargeType" ) ! = null ) {
criteria . andRechargeTypeEqualTo ( MapUtils . getInteger ( map , "rechargeType" ) ) ;
}
if ( MapUtils . getString ( map , "orderNo" ) ! = null ) {
if ( MapUtils . getString ( map , "orderNo" ) ! = null ) {
criteria . andOrderNoLike ( "%" + MapUtils . getString ( map , "orderNo" ) + "%" ) ;
criteria . andOrderNoLike ( "%" + MapUtils . getString ( map , "orderNo" ) + "%" ) ;
}
}
if ( MapUtils . getString ( map , "userPhone" ) ! = null ) {
if ( MapUtils . getString ( map , "userPhone" ) ! = null ) {
criteria . andUserPhoneEqualTo ( MapUtils . getString ( map , "userPhone" ) ) ;
criteria . andUserPhoneEqualTo ( MapUtils . getString ( map , "userPhone" ) ) ;
}
}
if ( MapUtils . getString ( map , "rechargeContent" ) ! = null ) {
if ( MapUtils . getString ( map , "rechargeContent" ) ! = null ) {
criteria . andRechargeContentLike ( "%" + MapUtils . getString ( map , "rechargeContent" ) + "%" ) ;
criteria . andRechargeContentLike ( "%" + MapUtils . getString ( map , "rechargeContent" ) + "%" ) ;
}
}
if ( MapUtils . getInteger ( map , "operatorType" ) ! = null ) {
if ( MapUtils . getString ( map , "phone" ) ! = null ) {
criteria . andOperatorTypeEqualTo ( MapUtils . getInteger ( map , "operatorType" ) ) ;
criteria . andUserPhoneEqualTo ( MapUtils . getString ( map , "phone" ) ) ;
}
if ( MapUtils . getInteger ( map , "status" ) ! = null ) {
criteria . andPayStatusEqualTo ( MapUtils . getInteger ( map , "status" ) ) ;
}
}
if ( MapUtils . getInteger ( map , "rechargeStatus" ) ! = null ) {
if ( MapUtils . getInteger ( map , "rechargeStatus" ) ! = null ) {
criteria . andRechargeStatusEqualTo ( MapUtils . getInteger ( map , "rechargeStatus" ) ) ;
criteria . andRechargeStatusEqualTo ( MapUtils . getInteger ( map , "rechargeStatus" ) ) ;
}
}
if ( StringUtils . isNotBlank ( MapUtils . getString ( map , "payTimeS" ) ) & & StringUtils . isNotBlank ( MapUtils . getString ( map , "payTimeE" ) ) ) {
if ( StringUtils . isNotBlank ( map . get ( "payTimeS" ) ) & & StringUtils . isNotBlank ( map . get ( "payTimeE" ) ) ) {
criteria . andPayTimeBetween (
criteria . andPayTimeBetween (
DateUtil . format ( map . get ( "payTimeS" ) , "yyyy-MM-dd HH:mm:ss" ) ,
DateUtil . format ( MapUtils . getString ( map , "payTimeS" ) , "yyyy-MM-dd HH:mm:ss" ) ,
DateUtil . format ( map . get ( "payTimeE" ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
DateUtil . format ( MapUtils . getString ( map , "payTimeE" ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
}
}
if ( StringUtils . isNotBlank ( map . get ( "createTimeS" ) ) & & StringUtils . isNotBlank ( map . get ( "createTimeE" ) ) ) {
if ( StringUtils . isNotBlank ( MapUtils . getString ( map , "createTimeS" ) ) & & StringUtils . isNotBlank ( MapUtils . getString ( map , "createTimeE" ) ) ) {
criteria . andCreateTimedBetween (
criteria . andCreateTimedBetween (
DateUtil . format ( map . get ( "createTimeS" ) , "yyyy-MM-dd HH:mm:ss" ) ,
DateUtil . format ( MapUtils . getString ( map , "createTimeS" ) , "yyyy-MM-dd HH:mm:ss" ) ,
DateUtil . format ( map . get ( "createTimeE" ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
DateUtil . format ( MapUtils . getString ( map , "createTimeE" ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
}
}
example . setOrderByClause ( "create_timed desc" ) ;
example . setOrderByClause ( "create_timed desc" ) ;
@ -158,7 +160,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Override
@Override
@Transactional (
@Transactional (
isolation = Isolation . SERIALIZABLE ,
isolation = Isolation . SERIALIZABLE ,
propagation = Propagation . REQUIRES_NEW )
propagation = Propagation . REQUIRES_NEW )
public OutRechargeOrder insertOrder ( JSONObject object ) throws Exception {
public OutRechargeOrder insertOrder ( JSONObject object ) throws Exception {
OutRechargeOrder outRechargeOrder = new OutRechargeOrder ( ) ;
OutRechargeOrder outRechargeOrder = new OutRechargeOrder ( ) ;
@ -173,7 +175,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
String rechargeContent = object . getString ( "rechargeContent" ) ;
String rechargeContent = object . getString ( "rechargeContent" ) ;
// 查询产品详情
// 查询产品详情
OutRechargePriceModel outRechargePrice = outRechargePriceService . findById ( goodsId , null ) ;
OutRechargePriceModel outRechargePrice = outRechargePriceService . findById ( goodsId , null ) ;
Map < String , Object > listMap = new HashMap < > ( ) ;
Map < String , Object > listMap = new HashMap < > ( ) ;
listMap . put ( "productType" , "3" ) ;
listMap . put ( "productType" , "3" ) ;
@ -184,7 +186,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
BsProductDiscount bsProductDiscount = bsConfigService . getProductDiscountByMap ( listMap ) ;
BsProductDiscount bsProductDiscount = bsConfigService . getProductDiscountByMap ( listMap ) ;
// 判断充值系统是否关闭
// 判断充值系统是否关闭
if ( ! secConfigService . isConfig ( "RECHARGE" , "1" ) ) {
if ( ! secConfigService . isConfig ( "RECHARGE" , "1" ) ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . RECHARGE_CLOSE , "" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . RECHARGE_CLOSE , "" ) ;
}
}
@ -215,7 +217,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if ( highDiscountUserRel . getHighDiscount ( ) . getDiscountType ( ) = = 1 ) {
if ( highDiscountUserRel . getHighDiscount ( ) . getDiscountType ( ) = = 1 ) {
// 如果商品支付总额 小于 满减价格
// 如果商品支付总额 小于 满减价格
if ( outRechargePrice . getRechargePrice ( ) . compareTo ( highDiscountUserRel . getHighDiscount ( ) . getDiscountCondition ( ) ) < 0 ) {
if ( outRechargePrice . getRechargePrice ( ) . compareTo ( highDiscountUserRel . getHighDiscount ( ) . getDiscountCondition ( ) ) < 0 ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . UN_MEMBER_ERROR , "订单未达到" + highDiscountUserRel . getHighDiscount ( ) . getDiscountCondition ( ) + "元,无法使用此优惠券" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . UN_MEMBER_ERROR , "订单未达到" + highDiscountUserRel . getHighDiscount ( ) . getDiscountCondition ( ) + "元,无法使用此优惠券" ) ;
}
}
// 计算支付金额 = 商品充值总额 - 满减额度
// 计算支付金额 = 商品充值总额 - 满减额度
payPrice = outRechargePrice . getRechargePrice ( ) . subtract ( highDiscountUserRel . getHighDiscount ( ) . getDiscountPrice ( ) ) ;
payPrice = outRechargePrice . getRechargePrice ( ) . subtract ( highDiscountUserRel . getHighDiscount ( ) . getDiscountPrice ( ) ) ;
@ -286,14 +288,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
}
outRechargeOrder . setUserId ( object . getLong ( "userId" ) ) ;
outRechargeOrder . setUserId ( user . getId ( ) ) ;
outRechargeOrder . setIntegralNum ( object . getBigDecimal ( "integralNum" ) ) ;
outRechargeOrder . setIntegralNum ( object . getBigDecimal ( "integralNum" ) ) ;
outRechargeOrder . setRechargeContent ( rechargeContent ) ;
outRechargeOrder . setRechargeContent ( rechargeContent ) ;
outRechargeOrder . setCompanyId ( outRechargePrice . getCompanyId ( ) ) ;
outRechargeOrder . setCompanyId ( outRechargePrice . getCompanyId ( ) ) ;
outRechargeOrder . setUserName ( object . getString ( "username" ) ) ;
outRechargeOrder . setUserName ( user . getName ( ) ) ;
outRechargeOrder . setRechargeType ( outRechargePrice . getRechargeType ( ) ) ;
outRechargeOrder . setRechargeType ( outRechargePrice . getRechargeType ( ) ) ;
outRechargeOrder . setUserPhone ( object . getString ( "phone" ) ) ;
outRechargeOrder . setUserPhone ( user . getPhone ( ) ) ;
outRechargeOrder . setOrderNo ( "RCG" + DateUtil . date2String ( new Date ( ) , "yyyyMMddHHmmss" ) + IDGenerator . nextId ( 5 ) ) ;
outRechargeOrder . setOrderNo ( "RCG" + DateUtil . date2String ( new Date ( ) , "yyyyMMddHHmmss" ) + IDGenerator . nextId ( 5 ) ) ;
outRechargeOrder . setCreateTimed ( new Date ( ) ) ;
outRechargeOrder . setCreateTimed ( new Date ( ) ) ;
outRechargeOrder . setGoodsId ( goodsId ) ;
outRechargeOrder . setGoodsId ( goodsId ) ;
outRechargeOrder . setRechargePrice ( outRechargePrice . getRechargePrice ( ) ) ;
outRechargeOrder . setRechargePrice ( outRechargePrice . getRechargePrice ( ) ) ;
@ -315,7 +317,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
outRechargeOrder . setPayStatus ( 102 ) ;
outRechargeOrder . setPayStatus ( 102 ) ;
outRechargeOrder . setPayTime ( new Date ( ) ) ;
outRechargeOrder . setPayTime ( new Date ( ) ) ;
outRechargeOrder . setPaySerialNo ( "22" + DateUtil . date2String ( new Date ( ) , "yyyyMMddHHmmss" ) + IDGenerator . nextId ( 5 ) ) ;
outRechargeOrder . setPaySerialNo ( "22" + DateUtil . date2String ( new Date ( ) , "yyyyMMddHHmmss" ) + IDGenerator . nextId ( 5 ) ) ;
} else {
} else {
// 201:充值中 202:充值成功 203:充值失败 204:未充值
// 201:充值中 202:充值成功 203:充值失败 204:未充值
outRechargeOrder . setRechargeStatus ( 204 ) ;
outRechargeOrder . setRechargeStatus ( 204 ) ;
@ -355,9 +357,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
}
@Override
@Override
@Transactional ( propagation = Propagation . REQUIRES_NEW )
@Transactional ( propagation = Propagation . REQUIRES_NEW )
public void updateOrderList ( List < OutRechargeOrder > rechargeOrders ) throws Exception {
public void updateOrderList ( List < OutRechargeOrder > rechargeOrders ) throws Exception {
for ( OutRechargeOrder list : rechargeOrders ) {
for ( OutRechargeOrder list : rechargeOrders ) {
// if (list.getStatus() == 3) {
// if (list.getStatus() == 3) {
// outRechargeOrderMapper.updateByPrimaryKey(list);
// outRechargeOrderMapper.updateByPrimaryKey(list);
// } else if (list.getStatus() == 6) {
// } else if (list.getStatus() == 6) {
@ -368,7 +370,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
}
@Override
@Override
@Transactional ( propagation = Propagation . REQUIRES_NEW )
@Transactional ( propagation = Propagation . REQUIRES_NEW )
public void cancelOrder ( Long orderId ) {
public void cancelOrder ( Long orderId ) {
OutRechargeOrder order = findByOrderId ( orderId ) ;
OutRechargeOrder order = findByOrderId ( orderId ) ;
if ( order ! = null & & order . getPayStatus ( ) = = 101 ) {
if ( order ! = null & & order . getPayStatus ( ) = = 101 ) {
@ -400,11 +402,12 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
}
@Override
@Override
@Transactional ( propagation = Propagation . REQUIRES_NEW )
@Transactional ( propagation = Propagation . REQUIRES_NEW )
public void finishOrder ( Long orderId ) {
public void finishOrder ( Long orderId ) {
OutRechargeOrder order = findByOrderId ( orderId ) ;
OutRechargeOrder order = findByOrderId ( orderId ) ;
if ( order ! = null ) {
if ( order ! = null ) {
// order.setStatus(3); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
order . setRechargeStatus ( 202 ) ; // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
order . setPayStatus ( 100 ) ; // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
order . setFinishTime ( new Date ( ) ) ;
order . setFinishTime ( new Date ( ) ) ;
updateOrder ( order ) ;
updateOrder ( order ) ;
}
}
@ -412,24 +415,24 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Override
@Override
public List < OutRechargeOrderModel > getOrderCount ( Map < String , Object > map ) throws Exception {
public List < OutRechargeOrderModel > getOrderCount ( Map < String , Object > map ) throws Exception {
if ( MapUtils . getLong ( map , "createTimeS" ) ! = null ) {
if ( MapUtils . getLong ( map , "createTimeS" ) ! = null ) {
map . put ( "createTimeS" , DateUtil . date2String ( new Date ( MapUtils . getLong ( map , "createTimeS" ) ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
map . put ( "createTimeS" , DateUtil . date2String ( new Date ( MapUtils . getLong ( map , "createTimeS" ) ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
}
}
if ( MapUtils . getLong ( map , "createTimeE" ) ! = null ) {
if ( MapUtils . getLong ( map , "createTimeE" ) ! = null ) {
map . put ( "createTimeE" , DateUtil . date2String ( new Date ( MapUtils . getLong ( map , "createTimeE" ) ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
map . put ( "createTimeE" , DateUtil . date2String ( new Date ( MapUtils . getLong ( map , "createTimeE" ) ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
}
}
if ( MapUtils . getLong ( map , "payTimeS" ) ! = null ) {
if ( MapUtils . getLong ( map , "payTimeS" ) ! = null ) {
map . put ( "payTimeS" , DateUtil . date2String ( new Date ( MapUtils . getLong ( map , "payTimeS" ) ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
map . put ( "payTimeS" , DateUtil . date2String ( new Date ( MapUtils . getLong ( map , "payTimeS" ) ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
}
}
if ( MapUtils . getLong ( map , "payTimeE" ) ! = null ) {
if ( MapUtils . getLong ( map , "payTimeE" ) ! = null ) {
map . put ( "payTimeE" , DateUtil . date2String ( new Date ( MapUtils . getLong ( map , "payTimeE" ) ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
map . put ( "payTimeE" , DateUtil . date2String ( new Date ( MapUtils . getLong ( map , "payTimeE" ) ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
}
}
return outRechargeOrderMapper . selectOrderCount ( map ) ;
return outRechargeOrderMapper . selectOrderCount ( map ) ;
}
}
@ -479,7 +482,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else {
} else {
fTimeE = DateUtil . date2String ( new Date ( ) , "yyyy-MM-dd HH:mm:ss" ) ;
fTimeE = DateUtil . date2String ( new Date ( ) , "yyyy-MM-dd HH:mm:ss" ) ;
}
}
return outRechargeOrderMapperExt . getListOrderCount ( fTimeS , fTimeE , status ) ;
return outRechargeOrderMapperExt . getListOrderCount ( fTimeS , fTimeE , status ) ;
}
}
@Override
@Override
@ -515,14 +518,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else {
} else {
fTimeE = DateUtil . date2String ( new Date ( ) , "yyyy-MM-dd HH:mm:ss" ) ;
fTimeE = DateUtil . date2String ( new Date ( ) , "yyyy-MM-dd HH:mm:ss" ) ;
}
}
return outRechargeOrderMapperExt . getListUserCount ( fTimeS , fTimeE ) ;
return outRechargeOrderMapperExt . getListUserCount ( fTimeS , fTimeE ) ;
}
}
@Override
@Override
public void hltUnionCardPay ( HighUserCard userCard , OutRechargeOrder order ) throws Exception {
public void hltUnionCardPay ( HighUserCard userCard , OutRechargeOrder order ) throws Exception {
String goodsDesc = "充值话费" ;
String goodsDesc = "充值话费" ;
String tranDesc = order . getRechargeContent ( ) + "充值" + order . getPayRealPrice ( ) + "元话费" ;
String tranDesc = order . getRechargeContent ( ) + "充值" + order . getPayRealPrice ( ) + "元话费" ;
String instCode = "11101290" ;
String instCode = "11101290" ;
String businessType = "hisen_consume" ;
String businessType = "hisen_consume" ;
@ -530,7 +533,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
JSONObject consumption = HuiLianTongUnionCardConfig . consumption ( order . getOrderNo ( ) , userCard . getCardNo ( ) , order . getPayRealPrice ( ) , businessType , instCode , goodsDesc , tranDesc ) ;
JSONObject consumption = HuiLianTongUnionCardConfig . consumption ( order . getOrderNo ( ) , userCard . getCardNo ( ) , order . getPayRealPrice ( ) , businessType , instCode , goodsDesc , tranDesc ) ;
System . out . println ( "工会卡支付响应参数" + consumption . toJSONString ( ) ) ;
System . out . println ( "工会卡支付响应参数" + consumption . toJSONString ( ) ) ;
Map < String , Object > dataMap = new HashMap < > ( ) ;
Map < String , Object > dataMap = new HashMap < > ( ) ;
dataMap . put ( "orderNo" , order . getOrderNo ( ) ) ;
dataMap . put ( "orderNo" , order . getOrderNo ( ) ) ;
dataMap . put ( "cardType" , "ghk" ) ;
dataMap . put ( "cardType" , "ghk" ) ;
dataMap . put ( "cardNo" , userCard . getCardNo ( ) ) ;
dataMap . put ( "cardNo" , userCard . getCardNo ( ) ) ;
@ -550,7 +553,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
payPush . setReturnContent ( consumption . toJSONString ( ) ) ;
payPush . setReturnContent ( consumption . toJSONString ( ) ) ;
highGasOrderPushMapper . insert ( payPush ) ;
highGasOrderPushMapper . insert ( payPush ) ;
if ( ! consumption . getString ( "respCode" ) . equals ( "0000" ) ) {
if ( ! consumption . getString ( "respCode" ) . equals ( "0000" ) ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , consumption . getString ( "respMessage" ) ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , consumption . getString ( "respMessage" ) ) ;
}
}
JSONObject consumptionResult = HuiLianTongUnionCardConfig . resolveResponse ( consumption . getString ( "data" ) ) ;
JSONObject consumptionResult = HuiLianTongUnionCardConfig . resolveResponse ( consumption . getString ( "data" ) ) ;
@ -609,23 +612,23 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else {
} else {
// 微信退款
// 微信退款
if ( order . getPayType ( ) = = 2 ) {
if ( order . getPayType ( ) = = 2 ) {
Map < String , String > param = new HashMap < > ( ) ;
Map < String , String > param = new HashMap < > ( ) ;
param . put ( "appid" , "wx637bd6f7314daa46" ) ;
param . put ( "appid" , "wx637bd6f7314daa46" ) ;
param . put ( "mch_id" , "1289663601" ) ;
param . put ( "mch_id" , "1289663601" ) ;
param . put ( "sub_mch_id" , "1614670195" ) ;
param . put ( "sub_mch_id" , "1614670195" ) ;
param . put ( "nonce_str" , WxUtils . makeNonStr ( ) ) ;
param . put ( "nonce_str" , WxUtils . makeNonStr ( ) ) ;
param . put ( "transaction_id" , order . getPaySerialNo ( ) ) ;
param . put ( "transaction_id" , order . getPaySerialNo ( ) ) ;
param . put ( "out_refund_no" , "HFR" + new Date ( ) . getTime ( ) ) ;
param . put ( "out_refund_no" , "HFR" + new Date ( ) . getTime ( ) ) ;
param . put ( "total_fee" , String . valueOf ( order . getPayRealPrice ( ) . multiply ( new BigDecimal ( "100" ) ) . intValue ( ) ) ) ;
param . put ( "total_fee" , String . valueOf ( order . getPayRealPrice ( ) . multiply ( new BigDecimal ( "100" ) ) . intValue ( ) ) ) ;
param . put ( "refund_fee" , String . valueOf ( order . getPayRealPrice ( ) . multiply ( new BigDecimal ( "100" ) ) . intValue ( ) ) ) ;
param . put ( "refund_fee" , String . valueOf ( order . getPayRealPrice ( ) . multiply ( new BigDecimal ( "100" ) ) . intValue ( ) ) ) ;
param . put ( "sign_type" , "HMAC-SHA256" ) ;
param . put ( "sign_type" , "HMAC-SHA256" ) ;
String signStr = WxUtils . generateSignature ( param , "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants . SignType . HMACSHA256 ) ;
String signStr = WxUtils . generateSignature ( param , "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants . SignType . HMACSHA256 ) ;
param . put ( "sign" , signStr ) ;
param . put ( "sign" , signStr ) ;
String resultXmL = doRefundRequest ( param . get ( "mch_id" ) , WxUtils . mapToXml ( param ) ) ;
String resultXmL = doRefundRequest ( param . get ( "mch_id" ) , WxUtils . mapToXml ( param ) ) ;
OrderRefundModel orderRefundModel = XmlUtil . getObjectFromXML ( resultXmL , OrderRefundModel . class ) ;
OrderRefundModel orderRefundModel = XmlUtil . getObjectFromXML ( resultXmL , OrderRefundModel . class ) ;
if ( orderRefundModel . getResult_code ( ) . equals ( "SUCCESS" ) ) {
if ( orderRefundModel . getResult_code ( ) . equals ( "SUCCESS" ) ) {
order . setPayStatus ( 105 ) ;
order . setPayStatus ( 105 ) ;
order . setRechargeStatus ( 203 ) ;
order . setRechargeStatus ( 203 ) ;
order . setRefundTime ( new Date ( ) ) ;
order . setRefundTime ( new Date ( ) ) ;
@ -634,16 +637,16 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
order . setRefundFee ( new BigDecimal ( orderRefundModel . getRefund_fee ( ) ) . divide ( new BigDecimal ( "100" ) ) ) ;
order . setRefundFee ( new BigDecimal ( orderRefundModel . getRefund_fee ( ) ) . divide ( new BigDecimal ( "100" ) ) ) ;
outRechargeOrderService . updateOrder ( order ) ;
outRechargeOrderService . updateOrder ( order ) ;
} else {
} else {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "退款失败!错误代码:" + orderRefundModel . getErr_code ( ) + ",错误描述" + orderRefundModel . getErr_code_des ( ) ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "退款失败!错误代码:" + orderRefundModel . getErr_code ( ) + ",错误描述" + orderRefundModel . getErr_code_des ( ) ) ;
}
}
}
}
// 工会卡退款
// 工会卡退款
if ( order . getPayType ( ) = = 3 ) {
if ( order . getPayType ( ) = = 3 ) {
JSONObject jsonObject = HuiLianTongUnionCardConfig . refund ( "HFR" + new Date ( ) . getTime ( ) , order . getOrderNo ( ) ) ;
JSONObject jsonObject = HuiLianTongUnionCardConfig . refund ( "HFR" + new Date ( ) . getTime ( ) , order . getOrderNo ( ) ) ;
if ( jsonObject = = null ) {
if ( jsonObject = = null ) {
jsonObject = HuiLianTongUnionCardConfig . refund ( "HFR" + new Date ( ) . getTime ( ) , order . getOrderNo ( ) ) ;
jsonObject = HuiLianTongUnionCardConfig . refund ( "HFR" + new Date ( ) . getTime ( ) , order . getOrderNo ( ) ) ;
}
}
JSONObject dataObject = HuiLianTongUnionCardConfig . resolveResponse ( jsonObject . getString ( "data" ) ) ;
JSONObject dataObject = HuiLianTongUnionCardConfig . resolveResponse ( jsonObject . getString ( "data" ) ) ;
@ -652,7 +655,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
order . setPayStatus ( 105 ) ;
order . setPayStatus ( 105 ) ;
order . setRechargeStatus ( 203 ) ;
order . setRechargeStatus ( 203 ) ;
order . setRefundTime ( new Date ( ) ) ;
order . setRefundTime ( new Date ( ) ) ;
order . setOutRefundNo ( "HFR" + new Date ( ) . getTime ( ) ) ;
order . setOutRefundNo ( "HFR" + new Date ( ) . getTime ( ) ) ;
order . setRefundFee ( order . getPayRealPrice ( ) ) ;
order . setRefundFee ( order . getPayRealPrice ( ) ) ;
order . setRefundId ( dataObject . getString ( "orderId" ) ) ;
order . setRefundId ( dataObject . getString ( "orderId" ) ) ;
outRechargeOrderService . updateOrder ( order ) ;
outRechargeOrderService . updateOrder ( order ) ;
@ -694,7 +697,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
}
public String doRefundRequest ( String mchId , String data ) throws Exception {
public String doRefundRequest ( String mchId , String data ) throws Exception {
//小程序退款需要调用双向证书的认证
//小程序退款需要调用双向证书的认证
CloseableHttpClient httpClient = goodsOrderService . readCertificate ( mchId ) ;
CloseableHttpClient httpClient = goodsOrderService . readCertificate ( mchId ) ;
@ -717,7 +720,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} finally {
} finally {
response . close ( ) ;
response . close ( ) ;
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {
throw new RuntimeException ( e ) ;
throw new RuntimeException ( e ) ;
} finally {
} finally {
httpClient . close ( ) ;
httpClient . close ( ) ;
@ -728,13 +731,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
public void pollRequest ( OutRechargeOrder outRechargeOrder ) throws Exception {
public void pollRequest ( OutRechargeOrder outRechargeOrder ) throws Exception {
// 查询充值产品
// 查询充值产品
OutRechargePriceModel outRechargePrice = outRechargePriceService . findById ( outRechargeOrder . getGoodsId ( ) , null ) ;
OutRechargePriceModel outRechargePrice = outRechargePriceService . findById ( outRechargeOrder . getGoodsId ( ) , null ) ;
// 查询充值子订单
// 查询充值子订单
Map < String , Object > childOrderMap = new HashMap < > ( ) ;
Map < String , Object > childOrderMap = new HashMap < > ( ) ;
childOrderMap . put ( "parent_order_id" , outRechargeOrder . getId ( ) ) ;
childOrderMap . put ( "parent_order_id" , outRechargeOrder . getId ( ) ) ;
childOrderMap . put ( "status" , 102 ) ;
childOrderMap . put ( "status" , 102 ) ;
List < OutRechargeChildOrder > childOrderList = outRechargeChildOrderService . getListRechargeChildOrder ( childOrderMap ) ;
List < OutRechargeChildOrder > childOrderList = outRechargeChildOrderService . getListRechargeChildOrder ( childOrderMap ) ;
@ -756,21 +759,21 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
JSONObject object = new JSONObject ( ) ;
JSONObject object = new JSONObject ( ) ;
String orderNo = "CZ" + DateUtil . date2String ( new Date ( ) , "yyyyMMddHHmmss" ) + IDGenerator . nextId ( 5 ) ;
String orderNo = "CZ" + DateUtil . date2String ( new Date ( ) , "yyyyMMddHHmmss" ) + IDGenerator . nextId ( 5 ) ;
String [ ] rechargePlatform = outRechargePrice . getRechargePlatform ( ) . split ( "-" ) ;
String [ ] rechargePlatform = outRechargePrice . getRechargePlatform ( ) . split ( "-" ) ;
for ( String s : rechargePlatform ) {
for ( String s : rechargePlatform ) {
// 尖椒充值
// 尖椒充值
if ( s . equals ( "1" ) & & ( type = = 2 | | type = = 0 ) ) {
if ( s . equals ( "1" ) & & ( type = = 2 | | type = = 0 ) ) {
object . put ( "out_order_id" , orderNo ) ;
object . put ( "out_order_id" , orderNo ) ;
object . put ( "amount" , outRechargePrice . getRechargePrice ( ) ) ;
object . put ( "amount" , outRechargePrice . getRechargePrice ( ) ) ;
object . put ( "mobile" , outRechargeOrder . getRechargeContent ( ) ) ;
object . put ( "mobile" , outRechargeOrder . getRechargeContent ( ) ) ;
if ( outRechargePrice . getRechargeType ( ) = = 1 ) {
if ( outRechargePrice . getRechargeType ( ) = = 1 ) {
object . put ( "is_fast" , 1 ) ;
object . put ( "is_fast" , 1 ) ;
}
}
JSONObject returnObject = RechargeConfig . rechargeOrderByJj ( object ) ;
JSONObject returnObject = RechargeConfig . rechargeOrderByJj ( object ) ;
object . put ( "return_content" , returnObject ) ;
object . put ( "return_content" , returnObject ) ;
if ( returnObject ! = null & & returnObject . getLong ( "code" ) = = 200 ) {
if ( returnObject ! = null & & returnObject . getLong ( "code" ) = = 200 ) {
childOrder . setStatus ( 102 ) ;
childOrder . setStatus ( 102 ) ;
} else {
} else {
@ -780,11 +783,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
break ;
break ;
}
}
if ( s . equals ( "2" ) & & ( type = = 1 | | type = = 0 ) ) {
if ( s . equals ( "2" ) & & ( type = = 1 | | type = = 0 ) ) {
object . put ( "out_trade_num" , orderNo ) ;
object . put ( "out_trade_num" , orderNo ) ;
object . put ( "product_id" , outRechargePrice . getGoodsId ( ) ) ;
object . put ( "product_id" , outRechargePrice . getGoodsId ( ) ) ;
object . put ( "mobile" , outRechargeOrder . getRechargeContent ( ) ) ;
object . put ( "mobile" , outRechargeOrder . getRechargeContent ( ) ) ;
JSONObject returnObject = RechargeConfig . rechargeOrderByLy ( object ) ;
JSONObject returnObject = RechargeConfig . rechargeOrderByLy ( object ) ;
object . put ( "return_content" , returnObject ) ;
object . put ( "return_content" , returnObject ) ;
if ( returnObject ! = null & & returnObject . getLong ( "errno" ) = = 0 ) {
if ( returnObject ! = null & & returnObject . getLong ( "errno" ) = = 0 ) {
childOrder . setStatus ( 102 ) ;
childOrder . setStatus ( 102 ) ;
} else {
} else {