|
@@ -9,7 +9,6 @@ import com.github.wxpay.sdk.WXPayConstants;
|
|
import com.github.wxpay.sdk.WXPayUtil;
|
|
import com.github.wxpay.sdk.WXPayUtil;
|
|
import com.miaxis.common.config.WxPayXcxConfigImpl;
|
|
import com.miaxis.common.config.WxPayXcxConfigImpl;
|
|
import com.miaxis.common.config.WxpayConfig;
|
|
import com.miaxis.common.config.WxpayConfig;
|
|
-import com.miaxis.common.core.domain.entity.SysUser;
|
|
|
|
import com.miaxis.common.core.domain.entity.UserInfo;
|
|
import com.miaxis.common.core.domain.entity.UserInfo;
|
|
import com.miaxis.common.exception.CustomException;
|
|
import com.miaxis.common.exception.CustomException;
|
|
import com.miaxis.common.utils.*;
|
|
import com.miaxis.common.utils.*;
|
|
@@ -25,7 +24,6 @@ import com.miaxis.wx.domain.WxExtractBank;
|
|
import com.miaxis.wx.domain.WxOrder;
|
|
import com.miaxis.wx.domain.WxOrder;
|
|
import com.miaxis.wx.dto.WxExtractBankDTO;
|
|
import com.miaxis.wx.dto.WxExtractBankDTO;
|
|
import com.miaxis.wx.dto.WxOrderProfitDTO;
|
|
import com.miaxis.wx.dto.WxOrderProfitDTO;
|
|
-import com.miaxis.wx.dto.WxOrderShareProfitDTO;
|
|
|
|
import com.miaxis.wx.mapper.WxOrderMapper;
|
|
import com.miaxis.wx.mapper.WxOrderMapper;
|
|
import com.miaxis.wx.service.IWxExtractBankService;
|
|
import com.miaxis.wx.service.IWxExtractBankService;
|
|
import com.miaxis.wx.service.IWxExtractService;
|
|
import com.miaxis.wx.service.IWxExtractService;
|
|
@@ -95,9 +93,9 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public boolean wxAddFenZhang(WxOrder wxOrder) throws Exception {
|
|
|
|
|
|
+ public boolean wxAddFenZhang(OrderInfo orderInfo) throws Exception {
|
|
//查询上级
|
|
//查询上级
|
|
- String account = getAccount(wxOrder);
|
|
|
|
|
|
+ String account = getAccount(orderInfo);
|
|
String url = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver";
|
|
String url = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver";
|
|
|
|
|
|
String nonceStr = RandomStringUtils.randomAlphanumeric(32);
|
|
String nonceStr = RandomStringUtils.randomAlphanumeric(32);
|
|
@@ -147,9 +145,9 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public boolean wxProfitsharing(WxOrder wxOrder) throws Exception {
|
|
|
|
|
|
+ public boolean wxProfitsharing(OrderInfo orderInfo) throws Exception {
|
|
//查询上级
|
|
//查询上级
|
|
- String account = getAccount(wxOrder);
|
|
|
|
|
|
+ String account = getAccount(orderInfo);
|
|
String url = "https://api.mch.weixin.qq.com/secapi/pay/profitsharing";
|
|
String url = "https://api.mch.weixin.qq.com/secapi/pay/profitsharing";
|
|
String nonceStr = RandomStringUtils.randomAlphanumeric(32);
|
|
String nonceStr = RandomStringUtils.randomAlphanumeric(32);
|
|
//用于签名
|
|
//用于签名
|
|
@@ -158,14 +156,14 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
sortMap.put("appid", xcxAppid);
|
|
sortMap.put("appid", xcxAppid);
|
|
sortMap.put("nonce_str", nonceStr);
|
|
sortMap.put("nonce_str", nonceStr);
|
|
sortMap.put("sign_type", "HMAC-SHA256");
|
|
sortMap.put("sign_type", "HMAC-SHA256");
|
|
- sortMap.put("transaction_id", wxOrder.getTransactionId());
|
|
|
|
- String orderCode = getOrderCode(wxOrder.getUserId()); //商户分账单号
|
|
|
|
|
|
+ sortMap.put("transaction_id", orderInfo.getTransactionId());
|
|
|
|
+ String orderCode = getOrderCode(orderInfo.getUserId()); //商户分账单号
|
|
sortMap.put("out_order_no", orderCode);
|
|
sortMap.put("out_order_no", orderCode);
|
|
|
|
|
|
|
|
|
|
//扣除手续费后
|
|
//扣除手续费后
|
|
- double commission = wxOrder.getTotal() * 0.01;
|
|
|
|
- double total = wxOrder.getTotal() - commission;
|
|
|
|
|
|
+ double commission = orderInfo.getTotal() * 0.01;
|
|
|
|
+ double total = orderInfo.getTotal() - commission;
|
|
int amount = (int) Math.floor(total * 0.3);
|
|
int amount = (int) Math.floor(total * 0.3);
|
|
|
|
|
|
Map<String, Object> receiverMap = new TreeMap<String, Object>();
|
|
Map<String, Object> receiverMap = new TreeMap<String, Object>();
|
|
@@ -194,17 +192,20 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
//throw new CustomException("微信分账出错");
|
|
//throw new CustomException("微信分账出错");
|
|
log.info("微信分账出错");
|
|
log.info("微信分账出错");
|
|
log.info(resMap.toString());
|
|
log.info(resMap.toString());
|
|
|
|
+ orderInfo.setProfitSharing(3);
|
|
|
|
+ orderInfoService.updateById(orderInfo);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
//更新成交订单表
|
|
//更新成交订单表
|
|
- OrderInfo orderInfo = orderInfoService.getByOutTradeNo(wxOrder.getOutTradeNo());
|
|
|
|
|
|
+ // OrderInfo orderInfo = orderInfoService.getByOutTradeNo(wxOrder.getOutTradeNo());
|
|
orderInfo.setOutSplitNo(orderCode);
|
|
orderInfo.setOutSplitNo(orderCode);
|
|
|
|
+ orderInfo.setProfitSharing(2);
|
|
orderInfoService.updateById(orderInfo);
|
|
orderInfoService.updateById(orderInfo);
|
|
OrderSplit orderSplit = new OrderSplit();
|
|
OrderSplit orderSplit = new OrderSplit();
|
|
orderSplit.setOutSplitNo(orderCode);
|
|
orderSplit.setOutSplitNo(orderCode);
|
|
orderSplit.setAmount(amount);
|
|
orderSplit.setAmount(amount);
|
|
- // orderSplit.setOpenId("o7N3j5XxUrgOKE4ulP-HseFpBCiM");
|
|
|
|
- orderSplit.setOpenId("obYLX6C7ln62silx-KP73Nd9jUB0");
|
|
|
|
|
|
+
|
|
|
|
+ orderSplit.setOpenId(account);
|
|
orderSplit.setDescription("分到个人");
|
|
orderSplit.setDescription("分到个人");
|
|
return orderSplitService.save(orderSplit);
|
|
return orderSplitService.save(orderSplit);
|
|
}
|
|
}
|
|
@@ -325,40 +326,17 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
return resMap.get("return_msg");
|
|
return resMap.get("return_msg");
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public List<WxOrder> selectWxOrderByWaitProfit() {
|
|
|
|
-
|
|
|
|
- // 获取当前时间
|
|
|
|
- Date currentDate = new Date();
|
|
|
|
- // 添加5分钟
|
|
|
|
- long fiveMinutesInMillis = 1 * 60 * 1000; // 5分钟的毫秒数
|
|
|
|
- Date nowDate = new Date(currentDate.getTime() - fiveMinutesInMillis);
|
|
|
|
-
|
|
|
|
- WxOrderProfitDTO wxOrderProfitDTO = new WxOrderProfitDTO();
|
|
|
|
-
|
|
|
|
- String nowDateStr = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", nowDate);
|
|
|
|
-
|
|
|
|
- wxOrderProfitDTO.setNowDate(nowDateStr);
|
|
|
|
- List<WxOrder> wxOrderList = wxOrderMapper.selectWxOrderByWaitProfit(nowDateStr);
|
|
|
|
- return wxOrderList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public List<WxOrder> selectWxOrderProfitList(WxOrderShareProfitDTO orderShareProfitDTO) {
|
|
|
|
- List<WxOrder> wxOrderList = wxOrderMapper.selectWxOrderProfitList(orderShareProfitDTO);
|
|
|
|
- return wxOrderList;
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询出上级unionId
|
|
* 查询出上级unionId
|
|
- * @param wxOrder
|
|
|
|
|
|
+ * @param orderInfo
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private String getAccount(WxOrder wxOrder) {
|
|
|
|
|
|
+ private String getAccount(OrderInfo orderInfo) {
|
|
String account = null;
|
|
String account = null;
|
|
- UserInfo userInfo = sysUserService.getStudentByUnionId(wxOrder.getUnionId());
|
|
|
|
|
|
+ UserInfo userInfo = sysUserService.getStudentByUnionId(orderInfo.getUnionId());
|
|
UserInfo pUserInfo = null;
|
|
UserInfo pUserInfo = null;
|
|
if (userInfo.getPUnionId() != null) {
|
|
if (userInfo.getPUnionId() != null) {
|
|
pUserInfo = sysUserService.getStudentByUnionId(userInfo.getPUnionId());
|
|
pUserInfo = sysUserService.getStudentByUnionId(userInfo.getPUnionId());
|