@ -163,6 +163,9 @@ public class HighOrderServiceImpl implements HighOrderService {
private ApiOrderRecordService apiOrderRecordService ;
@Resource
private ApiMemberProductService apiMemberProductService ;
@Override
@Transactional (
isolation = Isolation . SERIALIZABLE ,
@ -1452,6 +1455,12 @@ public class HighOrderServiceImpl implements HighOrderService {
highDiscountAgentCodeService . updateCode ( code ) ;
}
}
if ( order . getPayGold ( ) ! = null ) {
// 积分返回
highUserService . goldHandle ( order . getMemId ( ) , order . getPayGold ( ) , 1 , 3 , order . getId ( ) ) ;
}
updateOrder ( order ) ;
}
}
@ -1806,6 +1815,7 @@ public class HighOrderServiceImpl implements HighOrderService {
HighUser user = highUserService . findByUserId ( object . getLong ( "userId" ) ) ;
JSONObject jsonObject = null ;
JSONObject requestContent = null ;
// 积分抵扣金额
BigDecimal integralPrice = new BigDecimal ( 0 ) ;
@ -1820,7 +1830,9 @@ public class HighOrderServiceImpl implements HighOrderService {
JSONObject productDetail = thirdProductConfig . getThirdPartyByDetail ( object . getInteger ( "platformId" ) , object . getInteger ( "productType" ) , object . getLong ( "companyId" ) ) ;
// 1 星巴克 2 肯德基
highOrder . setProductType ( object . getInteger ( "productType" ) ) ;
// 1 星巴克 2 肯德基 3 会员充值
if ( object . getInteger ( "productType" ) = = 1 ) {
JSONObject userToken = QianZhuConfig . getTokenV2 ( user . getId ( ) . toString ( ) , user . getName ( ) , user . getPhone ( ) ) ;
@ -1864,9 +1876,9 @@ public class HighOrderServiceImpl implements HighOrderService {
List . add ( JSON . toJSONString ( contentMap ) ) ;
}
// 下单
jsonObject = QianZhuConfig . starbucksOrders ( user . getId ( ) . toString ( ) , object . getString ( "storeCode" ) , List . toString ( ) . replace ( " " , "" ) , object . getString ( "customerMobile" ) ) ;
// jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile"));
jsonObject = QianZhuConfig . starbucksOrders ( user . getId ( ) . toString ( ) , "50562" , List . toString ( ) . replace ( " " , "" ) , object . getString ( "customerMobile" ) ) ;
// 判断下单是否成功
if ( ! Objects . equals ( jsonObject . getString ( "code" ) , "200" ) ) {
@ -1880,7 +1892,7 @@ public class HighOrderServiceImpl implements HighOrderService {
// 根据订单号查询订单详情
JSONObject orderObject = QianZhuConfig . starbucksOrderByOrderNo ( jsonObject . getJSONObject ( "data" ) . getString ( "orderNo" ) ) ;
// 判断下单 是否成功
// 判断是否成功
if ( ! orderObject . getBoolean ( "success" ) ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , jsonObject . getString ( "message" ) ) ;
}
@ -1894,7 +1906,6 @@ public class HighOrderServiceImpl implements HighOrderService {
highOrder . setMemName ( user . getName ( ) ) ;
highOrder . setMemPhone ( user . getPhone ( ) ) ;
highOrder . setOrderStatus ( 1 ) ;
highOrder . setRemarks ( object . getString ( "userRemark" ) ) ;
highOrderMapper . insert ( highOrder ) ;
// 获取星巴克订单内容
@ -1906,6 +1917,8 @@ public class HighOrderServiceImpl implements HighOrderService {
childOrder . setOrderId ( highOrder . getId ( ) ) ;
childOrder . setChildOrdeStatus ( 1 ) ;
childOrder . setGoodsType ( 9 ) ;
childOrder . setStoreId ( object . getLong ( "storeCode" ) ) ;
childOrder . setGoodsId ( object . getLong ( "productId" ) ) ;
childOrder . setStoreAddress ( childObject . getString ( "storeAddress" ) ) ;
childOrder . setStoreName ( childObject . getString ( "storeName" ) ) ;
childOrder . setGoodsName ( childObject . getString ( "productName" ) ) ;
@ -1961,7 +1974,6 @@ public class HighOrderServiceImpl implements HighOrderService {
highOrder . setMemName ( user . getName ( ) ) ;
highOrder . setMemPhone ( user . getPhone ( ) ) ;
highOrder . setOrderStatus ( 1 ) ;
highOrder . setRemarks ( object . getString ( "userRemark" ) ) ;
highOrderMapper . insert ( highOrder ) ;
@ -1973,6 +1985,7 @@ public class HighOrderServiceImpl implements HighOrderService {
childOrder . setOrderId ( highOrder . getId ( ) ) ;
childOrder . setChildOrdeStatus ( 1 ) ;
childOrder . setGoodsType ( 4 ) ;
childOrder . setGoodsId ( object . getLong ( "productId" ) ) ;
childOrder . setStoreAddress ( orderObject . getJSONObject ( "data" ) . getJSONObject ( "kfcPlaceOrder" ) . getString ( "storeAddress" ) ) ;
childOrder . setStoreName ( orderObject . getJSONObject ( "data" ) . getJSONObject ( "kfcPlaceOrder" ) . getString ( "storeName" ) ) ;
childOrder . setGoodsName ( childObject . getString ( "productName" ) ) ;
@ -1993,6 +2006,45 @@ public class HighOrderServiceImpl implements HighOrderService {
highChildOrderMapper . insert ( childOrder ) ;
}
} else if ( object . getInteger ( "productType" ) = = 3 ) {
ApiMemberProduct memberProduct = apiMemberProductService . findById ( object . getLong ( "goodsId" ) ) ;
if ( memberProduct = = null ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "当前产品不可购买" ) ;
}
object . put ( "productId" , memberProduct . getProductId ( ) ) ;
// 插入订单内容
highOrder . setOrderNo ( "HF" + DateUtil . date2String ( new Date ( ) , "yyyyMMddHHmmss" ) + IDGenerator . nextId ( 5 ) ) ;
highOrder . setRegionId ( object . getString ( "regionId" ) ) ;
highOrder . setCompanyId ( object . getLong ( "companyId" ) ) ;
highOrder . setCreateTime ( new Date ( ) ) ;
highOrder . setMemId ( user . getId ( ) ) ;
highOrder . setMemName ( user . getName ( ) ) ;
highOrder . setMemPhone ( user . getPhone ( ) ) ;
highOrder . setOrderStatus ( 1 ) ;
// 计算实际支付金额
orderPayPrice = memberProduct . getCostPrice ( ) . add ( memberProduct . getCostPrice ( ) . multiply ( productDetail . getBigDecimal ( "priceDiscount" ) . divide ( new BigDecimal ( 100 ) ) ) ) . setScale ( 2 , RoundingMode . HALF_UP ) ;
// 计算市场价金额
marketPrice = memberProduct . getPrice ( ) ;
highOrderMapper . insert ( highOrder ) ;
HighChildOrder childOrder = new HighChildOrder ( ) ;
childOrder . setOrderId ( highOrder . getId ( ) ) ;
childOrder . setChildOrdeStatus ( 1 ) ;
childOrder . setGoodsType ( 10 ) ;
childOrder . setStoreId ( object . getLong ( "storeCode" ) ) ;
childOrder . setGoodsId ( memberProduct . getId ( ) ) ;
childOrder . setGoodsName ( memberProduct . getName ( ) ) ;
childOrder . setSaleCount ( 1 ) ;
childOrder . setGoodsPrice ( marketPrice ) ;
childOrder . setGoodsActualPrice ( orderPayPrice ) ;
childOrder . setTotalPrice ( orderPayPrice ) ;
highChildOrderMapper . insert ( childOrder ) ;
}
// 定义优惠券
@ -2080,7 +2132,7 @@ public class HighOrderServiceImpl implements HighOrderService {
highOrder . setDeductionPrice ( discountPrice ) ;
highOrder . setPayGold ( object . getInteger ( "integralNum" ) ) ;
// 使用优惠券 或者积分
// 使用优惠券
if ( highOrder . getMemDiscountId ( ) ! = null ) {
highOrder . setTotalPrice ( marketPrice ) ;
highOrder . setPayPrice ( marketPrice . subtract ( discountPrice ) ) ;
@ -2123,28 +2175,29 @@ public class HighOrderServiceImpl implements HighOrderService {
for ( HighChildOrder childOrder : highOrderList . getHighChildOrderList ( ) ) {
childOrder . setChildOrdeStatus ( 2 ) ;
}
// 推送订单记录
HighGasOrderPush highGasOrderPush = new HighGasOrderPush ( ) ;
// 1 星巴克 2 肯德基 3:第三方会员充值
if ( object . getInteger ( "productType" ) = = 1 ) {
QianZhuConfig . starbucksOrdersPay ( highOrder . getOrderNo ( ) ) ;
highGasOrderPush . setType ( OrderPushType . type8 . getType ( ) ) ;
requestContent = QianZhuConfig . starbucksOrdersPay ( highOrder . getOrderNo ( ) ) ;
} else if ( object . getInteger ( "productType" ) = = 2 ) {
QianZhuConfig . payKfcOrder ( highOrder . getOrderNo ( ) ) ;
}
highGasOrderPush . setType ( OrderPushType . type4 . getType ( ) ) ;
requestContent = QianZhuConfig . payKfcOrder ( highOrder . getOrderNo ( ) ) ;
} else if ( object . getInteger ( "productType" ) = = 3 ) {
highGasOrderPush . setType ( OrderPushType . type9 . getType ( ) ) ;
requestContent = QianZhuConfig . insertV2 ( object . getString ( "productId" ) , highOrder . getOrderNo ( ) , object . getString ( "customerMobile" ) ) ;
}
// 创建提交记录
BsRequestRecord requestRecord = new BsRequestRecord ( ) ;
requestRecord . setCreateTime ( new Date ( ) ) ;
requestRecord . setUpdateTime ( new Date ( ) ) ;
requestRecord . setOrderNo ( highOrder . getOrderNo ( ) ) ;
requestRecord . setRequestContent ( object . toJSONString ( ) ) ;
requestRecord . setOperatorId ( 0L ) ;
requestRecord . setOperatorName ( "系统生成" ) ;
requestRecord . setSourceId ( highOrder . getId ( ) . toString ( ) ) ;
requestRecord . setSourceType ( 1 ) ;
bsRequestRecordService . insertRequestRecord ( requestRecord ) ;
highGasOrderPush . setOrderNo ( highOrder . getOrderNo ( ) ) ;
highGasOrderPush . setCreateTime ( new Date ( ) ) ;
highGasOrderPush . setRequestContent ( highOrder . getOrderNo ( ) ) ;
highGasOrderPush . setReturnContent ( requestContent . toJSONString ( ) ) ;
highGasOrderPushMapper . insert ( highGasOrderPush ) ;
}
return highOrder ;
}
@ -2168,6 +2221,9 @@ public class HighOrderServiceImpl implements HighOrderService {
} else if ( order . getHighChildOrderList ( ) . get ( 0 ) . getGoodsType ( ) = = 9 ) {
goodsDesc = "购买星巴克产品" ;
tranDesc = goodsDesc + order . getPayRealPrice ( ) + "元" ;
} else if ( order . getHighChildOrderList ( ) . get ( 0 ) . getGoodsType ( ) = = 10 ) {
goodsDesc = "购买会员充值产品" ;
tranDesc = goodsDesc + order . getPayRealPrice ( ) + "元" ;
} else {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "暂时无法支付,请使用其他支付方式" ) ;
}
@ -2209,16 +2265,33 @@ public class HighOrderServiceImpl implements HighOrderService {
order . setPayType ( 4 ) ;
order . setPayTime ( new Date ( ) ) ; // 支付时间
updateOrder ( order ) ;
HighGasOrderPush orderPush = new HighGasOrderPush ( ) ;
JSONObject returnObject = new JSONObject ( ) ;
for ( HighChildOrder childOrder : order . getHighChildOrderList ( ) ) {
childOrder . setChildOrdeStatus ( 2 ) ;
}
if ( order . getHighChildOrderList ( ) . get ( 0 ) . getGoodsType ( ) = = 4 ) {
QianZhuConfig . payKfcOrder ( order . getOrderNo ( ) ) ;
orderPush . setType ( OrderPushType . type4 . getType ( ) ) ;
returnObject = QianZhuConfig . payKfcOrder ( order . getOrderNo ( ) ) ;
} else if ( order . getHighChildOrderList ( ) . get ( 0 ) . getGoodsType ( ) = = 9 ) {
QianZhuConfig . starbucksOrdersPay ( order . getOrderNo ( ) ) ;
orderPush . setType ( OrderPushType . type8 . getType ( ) ) ;
returnObject = QianZhuConfig . starbucksOrdersPay ( order . getOrderNo ( ) ) ;
} else if ( order . getHighChildOrderList ( ) . get ( 0 ) . getGoodsType ( ) = = 10 ) {
orderPush . setType ( OrderPushType . type9 . getType ( ) ) ;
ApiMemberProduct memberProduct = apiMemberProductService . findById ( order . getHighChildOrderList ( ) . get ( 0 ) . getGoodsId ( ) ) ;
returnObject = QianZhuConfig . insertV2 ( memberProduct . getProductId ( ) , order . getOrderNo ( ) , order . getRemarks ( ) ) ;
} else {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "暂时无法支付,请使用其他支付方式" ) ;
}
orderPush . setOrderNo ( order . getOrderNo ( ) ) ;
orderPush . setCreateTime ( new Date ( ) ) ;
orderPush . setRequestContent ( JSON . toJSONString ( dataMap ) ) ;
orderPush . setReturnContent ( returnObject . toJSONString ( ) ) ;
highGasOrderPushMapper . insert ( orderPush ) ;
}
@Override
@ -2285,7 +2358,7 @@ public class HighOrderServiceImpl implements HighOrderService {
}
// 工会卡退款
if ( order . getPayType ( ) = = 3 ) {
if ( order . getPayType ( ) = = 4 ) {
JSONObject jsonObject = HuiLianTongUnionCardConfig . refund ( "HFR" + new Date ( ) . getTime ( ) , order . getOrderNo ( ) ) ;
if ( jsonObject = = null ) {
@ -2310,7 +2383,7 @@ public class HighOrderServiceImpl implements HighOrderService {
}
// 商户预充值 帐户退款
if ( order . getPayType ( ) = = 6 ) {
if ( order . getPayType ( ) = = 7 ) {
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "orderNo" , order . getOrderNo ( ) ) ;
@ -2363,7 +2436,7 @@ public class HighOrderServiceImpl implements HighOrderService {
}
// 银联退款
if ( order . getPayType ( ) = = 4 ) {
if ( order . getPayType ( ) = = 5 ) {
// 订单退款
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" ) ) {