|
|
|
@@ -10,10 +10,7 @@ import com.github.pagehelper.PageInfo; |
|
|
|
import com.simple.common.ErrorCode; |
|
|
|
import com.simple.common.ResultData; |
|
|
|
import com.simple.domain.po.*; |
|
|
|
import com.simple.enums.EnumPayDomain; |
|
|
|
import com.simple.enums.EnumProfitSharingReceiverType; |
|
|
|
import com.simple.enums.EnumProfitSharingStatus; |
|
|
|
import com.simple.enums.EnumProfitSharingType; |
|
|
|
import com.simple.enums.*; |
|
|
|
import com.simple.exception.MallinkException; |
|
|
|
import com.simple.mapper.*; |
|
|
|
import com.simple.pay.WxPayment; |
|
|
|
@@ -165,11 +162,11 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
record.setOrderId(wxPayOrder.getId()); |
|
|
|
record.setPayAmount(wxPayOrder.getPayAmount()); |
|
|
|
record.setMerchantId(wxOrder.getMerchantId()); |
|
|
|
record.setSharingStatus(EnumProfitSharingStatus.PROFIT_SHARING_UNKNOWN.getCode()); |
|
|
|
record.setCreateTime(currentDate); |
|
|
|
record.setUpdateTime(currentDate); |
|
|
|
record.setPayTimeStart(currentDate); |
|
|
|
record.setPayTimeEnd(currentDate); |
|
|
|
|
|
|
|
wxProfitSharingOrderMapper.insertSelective(record); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -214,34 +211,41 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
result.setPayAmount(total_amount); |
|
|
|
result.setCreateTime(currentDate); |
|
|
|
result.setUpdateTime(currentDate); |
|
|
|
result.setSharingStatus(EnumProfitSharingResultStatus.PROFIT_SHARING_RESULT_PENDING.getCode()); |
|
|
|
resultList.add(result); |
|
|
|
} |
|
|
|
|
|
|
|
wxProfitSharingP.setReceivers(receivers.toJSONString()); |
|
|
|
|
|
|
|
wxProfitSharingP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingP), payAccount.getApiKey())); |
|
|
|
|
|
|
|
logger.info("wxProfitSharingP :" + wxProfitSharingP.toString()); |
|
|
|
String response = WxProfitSharing.pushOrder(BeanUtils.toStringMap(wxProfitSharingP), payAccount.getCertPath(), payAccount.getMchId()); |
|
|
|
|
|
|
|
logger.info("response: " + response); |
|
|
|
Map<String, String> returnMap = WxPayment.xmlToMap(response); |
|
|
|
String return_code = returnMap.get("return_code"); |
|
|
|
|
|
|
|
if (!"SUCCESS".equals(return_code)) { |
|
|
|
record.setSharingStatus(EnumProfitSharingStatus.PROFIT_SHARING_REQ_FAILED.getCode()); |
|
|
|
record.setErrorMsg(returnMap.get("return_msg")); |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
wxProfitSharingOrderMapper.updateByPrimaryKey(record); |
|
|
|
throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(), returnMap.get("return_msg")); |
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(), returnMap.get("return_msg")); |
|
|
|
} |
|
|
|
|
|
|
|
//if (!WxPayment.verifyNotifyHMAC(returnMap,payAccount.getApiKey())){ |
|
|
|
// throw new MallinkException(ErrorCode.PROFIT_SHARING_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); |
|
|
|
//} |
|
|
|
if (!WxPayment.verifyNotifyHMAC(returnMap,payAccount.getApiKey())){ |
|
|
|
record.setErrorMsg("返回值校验失败"); |
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
String result_code = returnMap.get("result_code"); |
|
|
|
if (!"SUCCESS".equals(result_code)) { |
|
|
|
record.setSharingStatus(EnumProfitSharingStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
record.setErrorMsg(returnMap.get("result_msg")); |
|
|
|
wxProfitSharingOrderMapper.updateByPrimaryKey(record); |
|
|
|
throw new MallinkException(ErrorCode.PROFIT_SHARING_APPLY_FAILED.getCode(), returnMap.get("result_msg")); |
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_APPLY_FAILED.getCode(), returnMap.get("result_msg")); |
|
|
|
} |
|
|
|
|
|
|
|
record.setSharingOrderNo(returnMap.get("order_id")); |
|
|
|
@@ -268,7 +272,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
record.setOrderId(wxPayOrder.getId()); |
|
|
|
record = wxProfitSharingOrderMapper.selectOne(record); |
|
|
|
if (record == null) |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), ErrorCode.ORDER_IS_NOT_FIND.getMessage()); |
|
|
|
return new ResultData(ErrorCode.ORDER_IS_NOT_FIND.getCode(), ErrorCode.ORDER_IS_NOT_FIND.getMessage()); |
|
|
|
|
|
|
|
//分账查询提交 |
|
|
|
WxProfitSharingQueryP wxProfitSharingQueryP = new WxProfitSharingQueryP();; |
|
|
|
@@ -285,21 +289,21 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
Map<String, String> returnMap = WxPayment.xmlToMap(response); |
|
|
|
String return_code = returnMap.get("return_code"); |
|
|
|
if (!"SUCCESS".equals(return_code)) { |
|
|
|
throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), returnMap.get("return_msg")); |
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), returnMap.get("return_msg")); |
|
|
|
} |
|
|
|
|
|
|
|
if (!WxPayment.verifyNotify(returnMap,payAccount.getApiKey())){ |
|
|
|
throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); |
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
String out_order_no = returnMap.get("out_order_no"); |
|
|
|
if (!out_order_no.equals(record.getId().toString())){ |
|
|
|
throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); |
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_RETURN_INVALID.getCode(), ErrorCode.PROFIT_SHARING_RETURN_INVALID.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
String result_code = returnMap.get("result_code"); |
|
|
|
if (!"SUCCESS".equals(result_code)) { |
|
|
|
throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_APPLY_FAILED.getCode(), returnMap.get("result_msg")); |
|
|
|
return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_APPLY_FAILED.getCode(), returnMap.get("result_msg")); |
|
|
|
} |
|
|
|
|
|
|
|
record.setSharingStatus((Integer) statusMap.get(returnMap.get("status"))); |
|
|
|
@@ -337,7 +341,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new ResultData(returnMap); |
|
|
|
|
|
|
|
}catch (Exception e) { |
|
|
|
|