|
|
@ -15,10 +15,7 @@ import com.hai.common.pay.util.sdk.WXPayConstants; |
|
|
|
import com.hai.common.security.SessionObject; |
|
|
|
import com.hai.common.security.SessionObject; |
|
|
|
import com.hai.common.security.UserCenter; |
|
|
|
import com.hai.common.security.UserCenter; |
|
|
|
import com.hai.common.utils.*; |
|
|
|
import com.hai.common.utils.*; |
|
|
|
import com.hai.entity.HighChildOrder; |
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.entity.HighCoupon; |
|
|
|
|
|
|
|
import com.hai.entity.HighOrder; |
|
|
|
|
|
|
|
import com.hai.entity.OutRechargeOrder; |
|
|
|
|
|
|
|
import com.hai.model.HighUserModel; |
|
|
|
import com.hai.model.HighUserModel; |
|
|
|
import com.hai.model.OrderRefundModel; |
|
|
|
import com.hai.model.OrderRefundModel; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.ResponseData; |
|
|
@ -45,10 +42,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.*; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.SortedMap; |
|
|
|
|
|
|
|
import java.util.concurrent.ThreadLocalRandom; |
|
|
|
import java.util.concurrent.ThreadLocalRandom; |
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
@Controller |
|
|
@ -369,4 +363,81 @@ public class OutRechargeOrderController { |
|
|
|
httpClient.close(); |
|
|
|
httpClient.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "订单退款") |
|
|
|
|
|
|
|
public ResponseData wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Map<String,String> param = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
|
|
|
|
//param.put("sub_mch_id" , "1289663601");
|
|
|
|
|
|
|
|
param.put("sub_mch_id" , "1609882817"); // 个体黎杨珍
|
|
|
|
|
|
|
|
param.put("transaction_id" , "4200001165202106115006937316"); |
|
|
|
|
|
|
|
param.put("out_order_no" , String.valueOf(new Date().getTime())); |
|
|
|
|
|
|
|
param.put("nonce_str" , WxUtils.makeNonStr()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 分账金额
|
|
|
|
|
|
|
|
BigDecimal porofitSharingAmount = amount; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> receiversList = new ArrayList<>(); |
|
|
|
|
|
|
|
Map<String,Object> receiversMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
receiversMap.put("type", "MERCHANT_ID"); |
|
|
|
|
|
|
|
receiversMap.put("account", "1603942866");// 嗨加油
|
|
|
|
|
|
|
|
receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); |
|
|
|
|
|
|
|
receiversMap.put("description", "分给商户1289663601"); |
|
|
|
|
|
|
|
receiversList.add(receiversMap); |
|
|
|
|
|
|
|
param.put("receivers" , JSONObject.toJSONString(receiversList)); |
|
|
|
|
|
|
|
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); |
|
|
|
|
|
|
|
param.put("sign" , signStr); |
|
|
|
|
|
|
|
String resultXmL = this.doRefundRequest2(param.get("mch_id"),null, WxUtils.mapToXml(param)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 请求分账返回的结果
|
|
|
|
|
|
|
|
ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); |
|
|
|
|
|
|
|
return ResponseMsgUtil.success(resultProfitSharing); |
|
|
|
|
|
|
|
/* HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); |
|
|
|
|
|
|
|
sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); |
|
|
|
|
|
|
|
sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); |
|
|
|
|
|
|
|
sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); |
|
|
|
|
|
|
|
sharingRecord.setStatus(resultProfitSharing.getResult_code()); |
|
|
|
|
|
|
|
sharingRecord.setPrice(amount); |
|
|
|
|
|
|
|
sharingRecord.setCreateTime(new Date()); |
|
|
|
|
|
|
|
sharingRecord.setContent(resultXmL); |
|
|
|
|
|
|
|
highProfitSharingRecordService.insert(sharingRecord);*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("CmsContentController --> getCorporateAdvertising() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.success(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public String doRefundRequest2(String mchId, String url, String data) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//小程序退款需要调用双向证书的认证
|
|
|
|
|
|
|
|
CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|