|
|
@ -8,7 +8,31 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.cainiao.link.consumer.LinkClient; |
|
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; |
|
|
|
import com.github.binarywang.wxpay.constant.WxPayErrorCode; |
|
|
|
import com.taobao.pac.sdk.cp.dataobject.request.GUOGUO_QUERY_LOGISTICS_DETAIL.GuoguoQueryLogisticsDetailRequest; |
|
|
|
import com.taobao.pac.sdk.cp.dataobject.request.GUOGUO_QUERY_LOGISTICS_DETAIL.LogisticsDetailOption; |
|
|
|
import com.taobao.pac.sdk.cp.dataobject.request.GUOGUO_QUERY_LOGISTICS_DETAIL.LogisticsDetailRequest; |
|
|
|
import com.taobao.pac.sdk.cp.dataobject.request.GUOGUO_QUERY_SEND_ORDER_FULL_DETAIL.AccessOption; |
|
|
|
import com.taobao.pac.sdk.cp.dataobject.request.GUOGUO_QUERY_SEND_ORDER_FULL_DETAIL.GuoguoCancelSendOrderRequest; |
|
|
|
import com.taobao.pac.sdk.cp.dataobject.request.GUOGUO_QUERY_SEND_ORDER_FULL_DETAIL.QueryOrderConditionDTO; |
|
|
|
import com.taobao.pac.sdk.cp.dataobject.response.GUOGUO_QUERY_LOGISTICS_DETAIL.GuoguoQueryLogisticsDetailResponse; |
|
|
|
import com.taobao.pac.sdk.cp.dataobject.response.GUOGUO_QUERY_SEND_ORDER_FULL_DETAIL.GuoguoCreateSendOrderResponse; |
|
|
|
import com.taobao.pac.sdk.cp.dataobject.response.GUOGUO_QUERY_SEND_ORDER_FULL_DETAIL.LogisticsDetailDTO; |
|
|
|
import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier; |
|
|
|
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner; |
|
|
|
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials; |
|
|
|
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; |
|
|
|
import com.wechat.pay.java.core.Config; |
|
|
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig; |
|
|
|
import com.wechat.pay.java.service.partnerpayments.jsapi.JsapiService; |
|
|
|
import com.wechat.pay.java.service.payments.nativepay.NativePayService; |
|
|
|
import com.wechat.pay.java.service.payments.nativepay.model.Amount; |
|
|
|
import com.wechat.pay.java.service.payments.nativepay.model.PrepayRequest; |
|
|
|
import com.wechat.pay.java.service.profitsharing.ProfitsharingService; |
|
|
|
import com.wechat.pay.java.service.profitsharing.model.CreateOrderReceiver; |
|
|
|
import com.wechat.pay.java.service.profitsharing.model.CreateOrderRequest; |
|
|
|
import io.swagger.models.auth.In; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -65,7 +89,9 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.security.PrivateKey; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
@ -100,6 +126,26 @@ public class OrderServiceImpl implements IOrderService { |
|
|
|
private String orderNotifyUrl; |
|
|
|
@Value("${weixin.replaceOrderNotifyUrl}") |
|
|
|
private String replaceOrderNotifyUrl; |
|
|
|
@Value("${weixin.mchId}") |
|
|
|
private String mchId; |
|
|
|
@Value("${weixin.mpAppId}") |
|
|
|
private String mpAppId; |
|
|
|
@Value("${weixin.mchKey}") |
|
|
|
private String mchKey; |
|
|
|
@Value("${weixin.keyPemPath}") |
|
|
|
private String keyPemPath; |
|
|
|
@Value("${weixin.serialNo}") |
|
|
|
private String serialNo; |
|
|
|
@Value("${weixin.apiV3Key}") |
|
|
|
private String apiV3Key; |
|
|
|
@Value("${cainiao.appKey}") |
|
|
|
private String appKey; |
|
|
|
@Value("${cainiao.appSecret}") |
|
|
|
private String appSecret; |
|
|
|
@Value("${cainiao.accountId}") |
|
|
|
private String accountId; |
|
|
|
@Value("${cainiao.accessCode}") |
|
|
|
private String accessCode; |
|
|
|
@Resource |
|
|
|
private IHotelOrderLogService hotelOrderLogService; |
|
|
|
@Resource |
|
|
@ -122,6 +168,9 @@ public class OrderServiceImpl implements IOrderService { |
|
|
|
private ISysUserRoleService sysUserRoleService; |
|
|
|
@Resource |
|
|
|
private ISysUserService sysUserService; |
|
|
|
private ProfitsharingService profitsharingService; |
|
|
|
private JsapiService jsapiService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1599,6 +1648,7 @@ public class OrderServiceImpl implements IOrderService { |
|
|
|
BigDecimal multiply = hotelOrderLog.getOrderPay(); |
|
|
|
|
|
|
|
multiply = multiply.multiply(new BigDecimal(100)); |
|
|
|
|
|
|
|
Object order = mpWxPayService.createOrder("酒店桌布", oConvertUtils.getIpAddrByRequest(req), hotelOrderLog.getId(), multiply.intValue(), orderNo, hanHaiMember.getAppletOpenid(),orderNotifyUrl,"{}"); |
|
|
|
|
|
|
|
HotelOrderLog hotelOrderLog1 = new HotelOrderLog(); |
|
|
@ -2636,6 +2686,7 @@ public class OrderServiceImpl implements IOrderService { |
|
|
|
//修改订单状态 |
|
|
|
HotelOrder hotelOrder1 = new HotelOrder(); |
|
|
|
hotelOrder1.setId(hotelOrder.getId()); |
|
|
|
hotelOrder1.setTransactionId(notify.getTransactionId()); |
|
|
|
if(hotelOrder.getType() == 0){ |
|
|
|
hotelOrder1.setStatus(1); |
|
|
|
}else if(hotelOrder.getType() == 1){ |
|
|
@ -3122,6 +3173,10 @@ public class OrderServiceImpl implements IOrderService { |
|
|
|
.eq(HotelMemberAccount::getUserId, hotelShop.getUserId()) |
|
|
|
.one(); |
|
|
|
|
|
|
|
HanHaiMember hanHaiMember1 = hanHaiMemberService.lambdaQuery() |
|
|
|
.eq(HanHaiMember::getId, hotelShop.getUserId()) |
|
|
|
.one(); |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal platformServiceRate = new BigDecimal(hotelConfService.getConf("platformServiceRate")); |
|
|
|
BigDecimal platformServicePrice = hotelOrder.getOrderPay().multiply(platformServiceRate); |
|
|
@ -3129,10 +3184,11 @@ public class OrderServiceImpl implements IOrderService { |
|
|
|
BigDecimal price = hotelMemberAccount.getShopBalance().add(shopPrice); |
|
|
|
|
|
|
|
|
|
|
|
HotelMemberAccount hotelMemberAccount1 = new HotelMemberAccount(); |
|
|
|
hotelMemberAccount1.setId(hotelMemberAccount.getId()); |
|
|
|
hotelMemberAccount1.setShopBalance(price); |
|
|
|
hotelMemberAccountService.updateById(hotelMemberAccount1); |
|
|
|
// HotelMemberAccount hotelMemberAccount1 = new HotelMemberAccount(); |
|
|
|
// hotelMemberAccount1.setId(hotelMemberAccount.getId()); |
|
|
|
// hotelMemberAccount1.setShopBalance(price); |
|
|
|
// hotelMemberAccountService.updateById(hotelMemberAccount1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HotelBalanceLog hotelBalanceLog = new HotelBalanceLog(); |
|
|
@ -3151,6 +3207,37 @@ public class OrderServiceImpl implements IOrderService { |
|
|
|
hotelOrder1.setStatus(15); |
|
|
|
hotelOrderService.updateById(hotelOrder1); |
|
|
|
|
|
|
|
|
|
|
|
//微信分账代码 |
|
|
|
// 初始化商户配置 |
|
|
|
Config config = |
|
|
|
new RSAAutoCertificateConfig.Builder() |
|
|
|
.merchantId(mchId) |
|
|
|
// 使用 com.wechat.pay.java.core.util 中的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名 |
|
|
|
.privateKeyFromPath(keyPemPath) |
|
|
|
.merchantSerialNumber(serialNo) |
|
|
|
.apiV3Key(apiV3Key) |
|
|
|
.build(); |
|
|
|
profitsharingService = new ProfitsharingService.Builder().config(config).build(); |
|
|
|
|
|
|
|
CreateOrderRequest createOrderRequest = new CreateOrderRequest(); |
|
|
|
// createOrderRequest.setSubMchid(mchId); |
|
|
|
createOrderRequest.setAppid(mpAppId); |
|
|
|
createOrderRequest.setTransactionId(hotelOrder.getTransactionId()); |
|
|
|
createOrderRequest.setOutOrderNo(hotelBalanceLog.getId()); |
|
|
|
createOrderRequest.setUnfreezeUnsplit(true); |
|
|
|
|
|
|
|
List<CreateOrderReceiver> createOrderReceivers = new ArrayList<>(); |
|
|
|
CreateOrderReceiver createOrderReceiver = new CreateOrderReceiver(); |
|
|
|
createOrderReceiver.setType("PERSONAL_OPENID"); |
|
|
|
createOrderReceiver.setAccount(hanHaiMember1.getAppletOpenid()); |
|
|
|
createOrderReceiver.setAmount(shopPrice.longValue()*100); |
|
|
|
createOrderReceiver.setDescription("分佣"); |
|
|
|
createOrderReceivers.add(createOrderReceiver); |
|
|
|
createOrderRequest.setReceivers(createOrderReceivers); |
|
|
|
profitsharingService.createOrder(createOrderRequest); |
|
|
|
|
|
|
|
|
|
|
|
for (HotelOrderDetail hotelOrderDetail:hotelOrderDetails){ |
|
|
|
//子 |
|
|
|
HotelLeaseLog hotelLeaseLog = hotelLeaseLogService.lambdaQuery() |
|
|
@ -3604,6 +3691,7 @@ public class OrderServiceImpl implements IOrderService { |
|
|
|
|
|
|
|
HotelOrder hotelOrder2 = new HotelOrder(); |
|
|
|
hotelOrder2.setId(hotelOrder.getId()); |
|
|
|
hotelOrder2.setTransactionId(notify.getTransactionId()); |
|
|
|
hotelOrder2.setStatus(15); |
|
|
|
hotelOrderService.updateById(hotelOrder2); |
|
|
|
|
|
|
@ -3701,6 +3789,27 @@ public class OrderServiceImpl implements IOrderService { |
|
|
|
return Result.OK(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<?> queryLogistics(QueryLogisticsReq queryLogisticsReq) { |
|
|
|
//通过 LinkClient Builder 构造一个 LinkClient |
|
|
|
com.cainiao.link.consumer.LinkClient linkClient = LinkClient.builder(appKey, appSecret).build(); |
|
|
|
|
|
|
|
GuoguoQueryLogisticsDetailRequest request = new GuoguoQueryLogisticsDetailRequest(); |
|
|
|
|
|
|
|
LogisticsDetailRequest logisticsDetailRequest = new LogisticsDetailRequest(); |
|
|
|
logisticsDetailRequest.setTdOrderId(15592780860652417L); |
|
|
|
LogisticsDetailOption logisticsDetailOption = new LogisticsDetailOption(); |
|
|
|
logisticsDetailOption.setAccessCode(accessCode); |
|
|
|
logisticsDetailOption.setAccessMethod("LINK"); |
|
|
|
|
|
|
|
request.setRequest(logisticsDetailRequest); |
|
|
|
request.setOption(logisticsDetailOption); |
|
|
|
|
|
|
|
GuoguoQueryLogisticsDetailResponse response = linkClient.execute(request, accountId, accessCode); |
|
|
|
log.info("包裹返回信息:"+response.toString()); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public Object testPay(String id){ |
|
|
|
HotelOrder hotelOrder = hotelOrderService.lambdaQuery() |
|
|
|
.eq(HotelOrder::getDelFlag, 0) |
|
|
|