@ -1,6 +1,7 @@
package com.hai.service.impl ;
package com.hai.service.impl ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import com.alibaba.fastjson.JSONObject ;
import com.alicp.jetcache.anno.CacheType ;
import com.alicp.jetcache.anno.CacheType ;
import com.alicp.jetcache.anno.Cached ;
import com.alicp.jetcache.anno.Cached ;
@ -47,6 +48,7 @@ import java.math.RoundingMode;
import java.text.SimpleDateFormat ;
import java.text.SimpleDateFormat ;
import java.util.* ;
import java.util.* ;
import java.util.concurrent.TimeUnit ;
import java.util.concurrent.TimeUnit ;
import java.util.concurrent.atomic.AtomicInteger ;
@Service ( "outRechargeOrderService" )
@Service ( "outRechargeOrderService" )
public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@ -414,19 +416,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
outRechargeOrderMapper . updateByPrimaryKey ( outRechargeOrder ) ;
outRechargeOrderMapper . updateByPrimaryKey ( outRechargeOrder ) ;
}
}
@Override
@Transactional ( propagation = Propagation . REQUIRES_NEW )
public void updateOrderList ( List < OutRechargeOrder > rechargeOrders ) throws Exception {
for ( OutRechargeOrder list : rechargeOrders ) {
// if (list.getStatus() == 3) {
// outRechargeOrderMapper.updateByPrimaryKey(list);
// } else if (list.getStatus() == 6) {
// rechargeOrderToRefund(list.getId());
// }
}
}
@Override
@Override
@Transactional ( propagation = Propagation . REQUIRES_NEW )
@Transactional ( propagation = Propagation . REQUIRES_NEW )
public void cancelOrder ( Long orderId ) {
public void cancelOrder ( Long orderId ) {
@ -495,12 +484,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrderMapper . selectOrderCount ( map ) ;
return outRechargeOrderMapper . selectOrderCount ( map ) ;
}
}
@Override
public Long CountOrder ( ) {
OutRechargeOrderExample example = new OutRechargeOrderExample ( ) ;
// example.createCriteria().andStatusEqualTo(2);
return outRechargeOrderMapper . countByExample ( example ) ;
}
@Override
@Override
public List < OutOrderModel > getListOrderCount ( Map < String , String > map ) throws Exception {
public List < OutOrderModel > getListOrderCount ( Map < String , String > map ) throws Exception {
@ -580,231 +563,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrderMapperExt . getListUserCount ( fTimeS , fTimeE ) ;
return outRechargeOrderMapperExt . getListUserCount ( fTimeS , fTimeE ) ;
}
}
@Override
public void hltUnionCardPay ( HighUserCard userCard , OutRechargeOrder order ) throws Exception {
String goodsDesc = "充值话费" ;
String tranDesc = order . getRechargeContent ( ) + "充值" + order . getPayRealPrice ( ) + "元话费" ;
String instCode = "11101527" ;
String businessType = "hisen_consume" ;
// 工会卡支付
JSONObject consumption = HuiLianTongUnionCardConfig . consumption ( order . getOrderNo ( ) , userCard . getCardNo ( ) , order . getPayRealPrice ( ) , businessType , instCode , goodsDesc , tranDesc ) ;
System . out . println ( "工会卡支付响应参数" + consumption . toJSONString ( ) ) ;
Map < String , Object > dataMap = new HashMap < > ( ) ;
dataMap . put ( "orderNo" , order . getOrderNo ( ) ) ;
dataMap . put ( "cardType" , "ghk" ) ;
dataMap . put ( "cardNo" , userCard . getCardNo ( ) ) ;
dataMap . put ( "checkPassword" , "N" ) ;
dataMap . put ( "tranAmount" , order . getPayRealPrice ( ) ) ;
dataMap . put ( "tranChannel" , "HiSen" ) ;
dataMap . put ( "businessType" , businessType ) ;
dataMap . put ( "instCode" , instCode ) ;
dataMap . put ( "goodsDesc" , goodsDesc ) ;
dataMap . put ( "tranDesc" , tranDesc ) ;
HighGasOrderPush payPush = new HighGasOrderPush ( ) ;
payPush . setType ( OrderPushType . type5 . getType ( ) ) ;
payPush . setOrderNo ( order . getOrderNo ( ) ) ;
payPush . setCreateTime ( new Date ( ) ) ;
payPush . setCode ( consumption . getString ( "respCode" ) ) ;
payPush . setRequestContent ( JSON . toJSONString ( dataMap ) ) ;
payPush . setReturnContent ( consumption . toJSONString ( ) ) ;
highGasOrderPushMapper . insert ( payPush ) ;
if ( ! consumption . getString ( "respCode" ) . equals ( "0000" ) ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , consumption . getString ( "respMessage" ) ) ;
}
JSONObject consumptionResult = HuiLianTongUnionCardConfig . resolveResponse ( consumption . getString ( "data" ) ) ;
if ( ! consumptionResult . getBoolean ( "success" ) ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , consumptionResult . getString ( "message" ) ) ;
}
order . setPaySerialNo ( consumptionResult . getString ( "orderId" ) ) ; // 支付流水号
order . setPayRealPrice ( order . getPayRealPrice ( ) ) ; // 实付金额
order . setPayStatus ( 102 ) ;
order . setRechargeStatus ( 204 ) ;
order . setLaborUnionCard ( userCard . getCardNo ( ) ) ;
order . setPayType ( 3 ) ;
order . setPayTime ( new Date ( ) ) ; // 支付时间
updateOrder ( order ) ;
outRechargeOrderService . pollRequest ( order ) ;
}
@Override
public List < OutRechargeOrder > getOutRechargeOrderList ( ) {
return outRechargeOrderMapper . getCloseOrder ( ) ;
}
@Override
@Override
public OrderCountModel rechargeOrderByIndex ( Integer code ) {
public OrderCountModel rechargeOrderByIndex ( Integer code ) {
return outRechargeOrderMapper . rechargeOrderByIndex ( code ) ;
return outRechargeOrderMapper . rechargeOrderByIndex ( code ) ;
}
}
@Override
@Override
public void rechargeOrderToRefund ( Long orderId ) throws Exception {
public void rechargeOrderToRefund ( Long orderId ) throws Exception {
OutRechargeOrder order = outRechargeOrderService . findByOrderId ( orderId ) ;
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if ( order . getPayStatus ( ) ! = 102 ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "无法退款,订单不处于已支付状态" ) ;
}
// 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值
if ( order . getRechargeStatus ( ) = = 201 ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "无法退款,订单处于充值中状态" ) ;
}
// 微信退款
if ( order . getPayType ( ) = = 2 ) {
Map < String , String > param = new HashMap < > ( ) ;
param . put ( "appid" , "wx637bd6f7314daa46" ) ;
param . put ( "mch_id" , "1289663601" ) ;
param . put ( "sub_mch_id" , "1614670195" ) ;
param . put ( "nonce_str" , WxUtils . makeNonStr ( ) ) ;
param . put ( "transaction_id" , order . getPaySerialNo ( ) ) ;
param . put ( "out_refund_no" , "HFR" + new Date ( ) . getTime ( ) ) ;
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 ( "sign_type" , "HMAC-SHA256" ) ;
String signStr = WxUtils . generateSignature ( param , "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants . SignType . HMACSHA256 ) ;
param . put ( "sign" , signStr ) ;
String resultXmL = doRefundRequest ( param . get ( "mch_id" ) , WxUtils . mapToXml ( param ) ) ;
OrderRefundModel orderRefundModel = XmlUtil . getObjectFromXML ( resultXmL , OrderRefundModel . class ) ;
if ( orderRefundModel . getResult_code ( ) . equals ( "SUCCESS" ) ) {
order . setPayStatus ( 105 ) ;
order . setRechargeStatus ( 203 ) ;
order . setRefundTime ( new Date ( ) ) ;
order . setOutRefundNo ( orderRefundModel . getOut_refund_no ( ) ) ;
order . setRefundId ( orderRefundModel . getRefund_id ( ) ) ;
order . setRefundFee ( new BigDecimal ( orderRefundModel . getRefund_fee ( ) ) . divide ( new BigDecimal ( "100" ) ) ) ;
outRechargeOrderService . updateOrder ( order ) ;
} else {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "退款失败!错误代码:" + orderRefundModel . getErr_code ( ) + ",错误描述" + orderRefundModel . getErr_code_des ( ) ) ;
}
}
// 工会卡退款
if ( order . getPayType ( ) = = 3 ) {
JSONObject jsonObject = HuiLianTongUnionCardConfig . refund ( "HFR" + new Date ( ) . getTime ( ) , order . getOrderNo ( ) ) ;
if ( jsonObject = = null ) {
jsonObject = HuiLianTongUnionCardConfig . refund ( "HFR" + new Date ( ) . getTime ( ) , order . getOrderNo ( ) ) ;
}
JSONObject dataObject = HuiLianTongUnionCardConfig . resolveResponse ( jsonObject . getString ( "data" ) ) ;
if ( dataObject . getBoolean ( "success" ) | | Objects . equals ( dataObject . getString ( "message" ) , "原交易已撤销,不可再次操作" ) ) {
order . setPayStatus ( 105 ) ;
order . setRechargeStatus ( 203 ) ;
order . setRefundTime ( new Date ( ) ) ;
order . setOutRefundNo ( "HFR" + new Date ( ) . getTime ( ) ) ;
order . setRefundFee ( order . getPayRealPrice ( ) ) ;
order . setRefundId ( dataObject . getString ( "orderId" ) ) ;
outRechargeOrderService . updateOrder ( order ) ;
} else {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , dataObject . getString ( "message" ) ) ;
}
// 商户预充值 帐户退款
if ( order . getPayType ( ) = = 6 ) {
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "orderNo" , order . getOrderNo ( ) ) ;
map . put ( "amountType" , 1 ) ;
map . put ( "sourceType" , 2 ) ;
if ( apiAmountRecordService . getApiAmountRecordByList ( map ) . size ( ) = = 1 ) {
ApiMerchants apiMerchants = apiMerchantsService . findByMchId ( order . getMerchId ( ) ) ;
// 插入金额记录
// 变更前金额
BigDecimal beforeAmount = apiMerchants . getAmounts ( ) ;
// 计算金额
apiMerchants . setAmounts ( apiMerchants . getAmounts ( ) . add ( order . getPayPrice ( ) ) ) ;
// 变更后金额
BigDecimal afterAmount = apiMerchants . getAmounts ( ) ;
apiMerchantsService . updateApiMerchants ( apiMerchants ) ;
ApiAmountRecord apiAmountRecord = new ApiAmountRecord ( ) ;
apiAmountRecord . setCreateTime ( new Date ( ) ) ;
apiAmountRecord . setUpdateTime ( new Date ( ) ) ;
apiAmountRecord . setMchId ( order . getMerchId ( ) ) ;
apiAmountRecord . setStatus ( 100 ) ;
apiAmountRecord . setAmount ( order . getPayPrice ( ) ) ;
apiAmountRecord . setAfterAmount ( afterAmount ) ;
apiAmountRecord . setBeforeAmount ( beforeAmount ) ;
apiAmountRecord . setAmountType ( 1 ) ;
apiAmountRecord . setSourceType ( 2 ) ;
apiAmountRecord . setSourceOrderNo ( order . getOrderNo ( ) ) ;
apiAmountRecord . setSourceId ( order . getId ( ) ) ;
apiAmountRecord . setSourceContent ( apiMerchants . getMerchantName ( ) + "|订单退款" + order . getPayPrice ( ) ) ;
apiAmountRecordService . insertAmountRecord ( apiAmountRecord ) ;
Map < String , Object > orderMap = new HashMap < > ( ) ;
orderMap . put ( "orderId" , order . getId ( ) ) ;
// 查询是否用重复订单
ApiOrderRecord apiOrderRecord = apiOrderRecordService . queryOrderResult ( orderMap ) ;
apiOrderRecord . setStatus ( 100 ) ;
apiOrderRecord . setRequestTime ( new Date ( ) ) ;
apiOrderRecordService . updateOrderRecord ( apiOrderRecord ) ;
}
}
}
// 银联退款
if ( order . getPayType ( ) = = 4 ) {
// 订单退款
JSONObject refund = UnionPayConfig . zwrefund ( UnionPayConfig . MER_ID2 , UnionPayConfig . TERM_ID2 , order . getOrderNo ( ) , order . getPaySerialNo ( ) , order . getPayRealPrice ( ) . multiply ( new BigDecimal ( "100" ) ) . longValue ( ) ) ;
if ( ! refund . getString ( "resultcode" ) . equals ( "W6" ) ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , refund . getString ( "returnmsg" ) ) ;
}
order . setPayStatus ( 105 ) ;
order . setRechargeStatus ( 203 ) ;
order . setRefundTime ( new Date ( ) ) ;
order . setOutRefundNo ( refund . getString ( "oriwtorderid" ) ) ;
order . setRefundFee ( order . getPayRealPrice ( ) ) ;
outRechargeOrderService . updateOrder ( order ) ;
}
if ( order . getMemDiscountId ( ) ! = null ) {
HighDiscountUserRel rel = highDiscountUserRelService . getRelById ( order . getMemDiscountId ( ) ) ;
if ( rel ! = null ) {
rel . setStatus ( 1 ) ; // 状态 0:已过期 1:未使用 2:已使用
rel . setUseTime ( null ) ;
highDiscountUserRelService . updateDiscountUserRel ( rel ) ;
HighDiscountAgentCode code = highDiscountAgentCodeService . getCodeById ( rel . getDiscountAgentCodeId ( ) ) ;
code . setStatus ( 2 ) ;
highDiscountAgentCodeService . updateCode ( code ) ;
}
}
// 退还积分
if ( order . getIntegralNum ( ) . compareTo ( new BigDecimal ( 0 ) ) > 0 ) {
String remark = "话费订单" + order . getOrderNo ( ) + "退款,退还积分:" + order . getIntegralNum ( ) . intValue ( ) ;
highUserService . goldHandle ( order . getUserId ( ) , order . getIntegralNum ( ) . intValue ( ) , 1 , 3 , order . getId ( ) , remark ) ;
if ( order . getPayRealPrice ( ) . compareTo ( new BigDecimal ( 0 ) ) = = 0 ) {
order . setPayStatus ( 105 ) ;
order . setRechargeStatus ( 203 ) ;
order . setRefundTime ( new Date ( ) ) ;
outRechargeOrderService . updateOrder ( order ) ;
}
}
}
}
@ -841,87 +606,51 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
outRechargeChildOrderService . updateOrder ( childOrder ) ;
outRechargeChildOrderService . updateOrder ( childOrder ) ;
}
}
public String doRefundRequest ( String mchId , String data ) throws Exception {
//小程序退款需要调用双向证书的认证
CloseableHttpClient httpClient = goodsOrderService . readCertificate ( mchId ) ;
try {
HttpPost httpost = new HttpPost ( "https://api.mch.weixin.qq.com/secapi/pay/refund" ) ; // 设置响应头信息
httpost . addHeader ( "Connection" , "keep-alive" ) ;
httpost . addHeader ( "Accept" , "*/*" ) ;
httpost . addHeader ( "Content-Type" , "text/xml" ) ;
httpost . addHeader ( "Host" , "api.mch.weixin.qq.com" ) ;
httpost . addHeader ( "X-Requested-With" , "XMLHttpRequest" ) ;
httpost . addHeader ( "Cache-Control" , "max-age=0" ) ;
httpost . addHeader ( "User-Agent" , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) " ) ;
httpost . setEntity ( new StringEntity ( data , "UTF-8" ) ) ;
CloseableHttpResponse response = httpClient . execute ( httpost ) ;
try {
HttpEntity entity = response . getEntity ( ) ;
String jsonStr = EntityUtils . toString ( response . getEntity ( ) , "UTF-8" ) ;
EntityUtils . consume ( entity ) ;
return jsonStr ;
} finally {
response . close ( ) ;
}
} catch ( Exception e ) {
throw new RuntimeException ( e ) ;
} finally {
httpClient . close ( ) ;
}
}
@Override
@Override
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
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 ) ;
// 添加查询是否存在充值中的子订单
List < OutRechargeChildOrder > childOrderList = outRechargeChildOrderService . getListRechargeChildOrder ( childOrderMap ) ;
List < OutRechargeChildOrder > childOrderList = outRechargeChildOrderService . getListRechargeChildOrder ( childOrderMap ) ;
// 定义新的子订单对象
// 定义新的子订单对象
OutRechargeChildOrder childOrder = new OutRechargeChildOrder ( ) ;
OutRechargeChildOrder childOrder = new OutRechargeChildOrder ( ) ;
// 1:尖椒 2:龙阅 3:畅停 4.嗨购
// 初始化充值平台 1:尖椒 2:龙阅 3:畅停 4.嗨购
int type = 0 ;
int platformType = 0 ;
// 定义新增子订单充值平台
int rechargePlatformType = 0 ;
// 判断子订单是否存在充值中订单
// 判断子订单是否存在充值中订单
if ( childOrderList . size ( ) > 0 ) {
if ( childOrderList . size ( ) > 0 ) {
// 修改之前的自订单充值记录
childOrder = childOrderList . get ( 0 ) ;
childOrder = childOrderList . get ( 0 ) ;
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 99 未配置平台查询方法
Integer status = getRechargeOrderLegality ( outRechargeOrder , childOrder ) ;
if ( status = = 0 | | status = = 3 | | status = = 99 ) {
return ;
} else if ( status = = 1 ) {
completeOrder ( outRechargeOrder , childOrder ) ;
}
childOrder . setStatus ( 103 ) ;
childOrder . setStatus ( 103 ) ;
childOrder . setUpdateTime ( new Date ( ) ) ;
childOrder . setUpdateTime ( new Date ( ) ) ;
outRechargeChildOrderService . updateOrder ( childOrder ) ;
outRechargeChildOrderService . updateOrder ( childOrder ) ;
type = childOrder . getRechargePlatform ( ) ;
pla tformT ype = childOrder . getRechargePlatform ( ) ;
} else {
// 查询充值状态为103充值失败的子订单
Map < String , Object > childOrderMap103 = new HashMap < > ( ) ;
childOrderMap103 . put ( "parent_order_id" , outRechargeOrder . getId ( ) ) ;
childOrderMap103 . put ( "status" , 103 ) ;
List < OutRechargeChildOrder > childOrderList103 = outRechargeChildOrderService . getListRechargeChildOrder ( childOrderMap103 ) ;
if ( childOrderList103 . size ( ) > 0 ) {
type = childOrderList103 . get ( 0 ) . getRechargePlatform ( ) ;
}
}
if ( type = = 3 ) {
type = 1 ;
} else {
type + + ;
}
}
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 ) ;
// 查询平台
// 查询平台
@ -930,7 +659,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
// 判断平台只定义一个那么类型就是唯一
// 判断平台只定义一个那么类型就是唯一
if ( string . length ( ) = = 1 ) {
if ( string . length ( ) = = 1 ) {
type = Integer . parseInt ( string ) ;
platformType = Integer . parseInt ( string ) ;
} else {
if ( platformType = = 0 ) {
platformType = Integer . parseInt ( rechargePlatform [ 0 ] ) ;
} else {
platformType = Integer . parseInt ( rechargePlatform [ ArrayUtils . arrayIndex ( rechargePlatform , String . valueOf ( platformType ) ) ] ) ;
}
}
}
// 定义查询充值产品编码
// 定义查询充值产品编码
@ -939,7 +675,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
for ( String s : rechargePlatform ) {
for ( String s : rechargePlatform ) {
// 尖椒充值
// 尖椒充值
if ( s . equals ( "1" ) & & type = = 1 ) {
if ( s . equals ( "1" ) & & pla tformT ype = = 1 ) {
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 ( ) ) ;
@ -951,14 +687,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else {
} else {
childOrder . setStatus ( 103 ) ;
childOrder . setStatus ( 103 ) ;
}
}
rechargePlatformType = 1 ;
childOrder . setRechargePlatform ( 1 ) ;
break ;
break ;
}
}
// 龙阅充值
// 龙阅充值
if ( s . equals ( "2" ) & & type = = 2 ) {
if ( s . equals ( "2" ) & & pla tformT ype = = 2 ) {
map . put ( "sourceId" , outRechargePrice . getId ( ) ) ;
map . put ( "sourceId" , outRechargePrice . getId ( ) ) ;
map . put ( "rechargePlatform" , type ) ;
map . put ( "rechargePlatform" , pla tformT ype) ;
BsRechargeCode rechargeCode = rechargeCodeService . findByMap ( map ) ;
BsRechargeCode rechargeCode = rechargeCodeService . findByMap ( map ) ;
object . put ( "out_trade_num" , orderNo ) ;
object . put ( "out_trade_num" , orderNo ) ;
object . put ( "product_id" , rechargeCode . getGoodsId ( ) ) ;
object . put ( "product_id" , rechargeCode . getGoodsId ( ) ) ;
@ -971,14 +707,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else {
} else {
childOrder . setStatus ( 103 ) ;
childOrder . setStatus ( 103 ) ;
}
}
rechargePlatformType = 2 ;
childOrder . setRechargePlatform ( 2 ) ;
break ;
break ;
}
}
// 城宇充值
// 城宇充值
if ( s . equals ( "3" ) & & type = = 3 ) {
if ( s . equals ( "3" ) & & pla tformT ype = = 3 ) {
map . put ( "sourceId" , outRechargePrice . getId ( ) ) ;
map . put ( "sourceId" , outRechargePrice . getId ( ) ) ;
map . put ( "rechargePlatform" , type ) ;
map . put ( "rechargePlatform" , pla tformT ype) ;
BsRechargeCode rechargeCode = rechargeCodeService . findByMap ( map ) ;
BsRechargeCode rechargeCode = rechargeCodeService . findByMap ( map ) ;
object . put ( "agentOrderId" , orderNo ) ;
object . put ( "agentOrderId" , orderNo ) ;
object . put ( "productId" , rechargeCode . getGoodsId ( ) ) ;
object . put ( "productId" , rechargeCode . getGoodsId ( ) ) ;
@ -990,14 +726,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else {
} else {
childOrder . setStatus ( 103 ) ;
childOrder . setStatus ( 103 ) ;
}
}
rechargePlatformType = 3 ;
childOrder . setRechargePlatform ( 3 ) ;
break ;
break ;
}
}
// 嗨购充值
// 嗨购充值
if ( s . equals ( "4" ) & & type = = 4 ) {
if ( s . equals ( "4" ) & & pla tformT ype = = 4 ) {
map . put ( "sourceId" , outRechargePrice . getId ( ) ) ;
map . put ( "sourceId" , outRechargePrice . getId ( ) ) ;
map . put ( "rechargePlatform" , type ) ;
map . put ( "rechargePlatform" , pla tformT ype) ;
BsRechargeCode rechargeCode = rechargeCodeService . findByMap ( map ) ;
BsRechargeCode rechargeCode = rechargeCodeService . findByMap ( map ) ;
object . put ( "orderid" , orderNo ) ;
object . put ( "orderid" , orderNo ) ;
object . put ( "product_id" , rechargeCode . getGoodsId ( ) ) ;
object . put ( "product_id" , rechargeCode . getGoodsId ( ) ) ;
@ -1010,7 +746,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else {
} else {
childOrder . setStatus ( 103 ) ;
childOrder . setStatus ( 103 ) ;
}
}
rechargePlatformType = 4 ;
childOrder . setRechargePlatform ( 4 ) ;
break ;
break ;
}
}
}
}
@ -1018,7 +754,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
childOrder . setOrderNo ( orderNo ) ;
childOrder . setOrderNo ( orderNo ) ;
childOrder . setCreateTime ( new Date ( ) ) ;
childOrder . setCreateTime ( new Date ( ) ) ;
childOrder . setParentOrderId ( outRechargeOrder . getId ( ) ) ;
childOrder . setParentOrderId ( outRechargeOrder . getId ( ) ) ;
childOrder . setRechargePlatform ( rechargePlatformType ) ;
childOrder . setUpdateTime ( new Date ( ) ) ;
childOrder . setUpdateTime ( new Date ( ) ) ;
outRechargeChildOrderService . insertOrder ( childOrder ) ;
outRechargeChildOrderService . insertOrder ( childOrder ) ;
@ -1057,20 +792,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
outRechargeChildOrderService . updateOrder ( childOrder ) ;
outRechargeChildOrderService . updateOrder ( childOrder ) ;
}
}
@Override
public Integer rechargeOrderNum ( Long userId ) {
OutRechargeOrderExample example = new OutRechargeOrderExample ( ) ;
OutRechargeOrderExample . Criteria criteria = example . createCriteria ( ) ;
criteria . andUserIdEqualTo ( userId ) ;
criteria . andPayStatusEqualTo ( 101 ) ;
return outRechargeOrderMapper . selectByExample ( example ) . size ( ) ;
}
@Override
public List < OutRechargeOrder > integralRebateRechargeOrder ( ) {
return outRechargeOrderMapper . integralRebateRechargeOrder ( ) ;
}
@Override
@Override
public void editOutRechargeOrder ( HighOrder orderData ) {
public void editOutRechargeOrder ( HighOrder orderData ) {
@ -1096,4 +817,85 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrderMapper . getApiRechargePhoneByList ( map ) ;
return outRechargeOrderMapper . getApiRechargePhoneByList ( map ) ;
}
}
@Override
public void rechargeOrderHandle ( OutRechargeOrder outRechargeOrder , OutRechargeChildOrder childOrder ) throws Exception {
if ( outRechargeOrder . getPayStatus ( ) = = 102 & & outRechargeOrder . getRechargeStatus ( ) ! = 202 ) {
if ( outRechargeOrder . getOutRechargeChildOrders ( ) . size ( ) = = 0 ) {
OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder ( ) ;
outRechargeChildOrder . setOrderNo ( "CZ" + DateUtil . date2String ( new Date ( ) , "yyyyMMddHHmmss" ) + IDGenerator . nextId ( 5 ) ) ;
outRechargeChildOrder . setParentOrderId ( outRechargeOrder . getId ( ) ) ;
outRechargeChildOrder . setUpdateTime ( new Date ( ) ) ;
outRechargeChildOrder . setCreateTime ( new Date ( ) ) ;
refundOrder ( outRechargeOrder . getId ( ) , outRechargeChildOrder ) ;
} else {
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
Integer status = getRechargeOrderLegality ( outRechargeOrder , childOrder ) ;
if ( status = = 2 | | status = = - 1 ) {
refundOrder ( outRechargeOrder . getId ( ) , childOrder ) ;
} else if ( status = = 1 ) {
completeOrder ( outRechargeOrder , childOrder ) ;
}
}
}
}
@Override
public Integer getRechargeOrderLegality ( OutRechargeOrder outRechargeOrder , OutRechargeChildOrder childOrder ) throws Exception {
JSONObject object = new JSONObject ( ) ;
// 龙阅
if ( childOrder . getRechargePlatform ( ) = = 2 ) {
object . put ( "out_trade_nums" , childOrder . getOrderNo ( ) ) ;
JSONObject jsonObject = RechargeConfig . checkOrderByLy ( object ) ;
JSONArray objectJSONArray = jsonObject . getJSONArray ( "data" ) ;
JSONObject objectData = new JSONObject ( ) ;
for ( Object objects : objectJSONArray ) {
objectData = ( JSONObject ) objects ;
}
if ( objectData . size ( ) = = 0 ) {
return 2 ;
} else {
// -1取消,0充值中 ,1充值成功,2充值失败,3部分成功
return objectData . getInteger ( "state" ) ;
}
}
// 嗨购
if ( childOrder . getRechargePlatform ( ) = = 4 ) {
object . put ( "orderid" , childOrder . getOrderNo ( ) ) ;
JSONObject jsonObject = RechargeConfig . checkOrderByHg ( object ) ;
if ( jsonObject . getJSONArray ( "data" ) = = null ) {
return - 1 ;
} else {
JSONArray objectJSONArray = jsonObject . getJSONArray ( "data" ) ;
JSONObject objectData ;
for ( Object objects : objectJSONArray ) {
objectData = ( JSONObject ) objects ;
// 充值中1成功2失败3已取消4部分充值5缓存订单
// -1取消,0充值中 ,1充值成功,2充值失败,3部分成功
if ( objectData . getInteger ( "status" ) = = 1 | | objectData . getInteger ( "status" ) = = 5 ) {
return 0 ;
} else if ( objectData . getInteger ( "status" ) = = 2 ) {
return 1 ;
} else if ( objectData . getInteger ( "status" ) = = 3 ) {
return - 1 ;
} else if ( objectData . getInteger ( "status" ) = = 4 ) {
return 3 ;
}
}
}
}
return 99 ;
}
}
}