|
@@ -7,6 +7,7 @@ import com.google.common.collect.Maps;
|
7
|
7
|
import com.huiju.estateagents.base.ResponseBean;
|
8
|
8
|
import com.huiju.estateagents.center.taUser.entity.TaUser;
|
9
|
9
|
import com.huiju.estateagents.center.taUser.mapper.TaUserMapper;
|
|
10
|
+import com.huiju.estateagents.common.CommConstant;
|
10
|
11
|
import com.huiju.estateagents.common.wxpay.WXPay;
|
11
|
12
|
import com.huiju.estateagents.common.wxpay.WXPayConstants;
|
12
|
13
|
import com.huiju.estateagents.common.wxpay.WXPayUtil;
|
|
@@ -111,11 +112,12 @@ public class WxPayServiceImpl implements WxPayServiceI {
|
111
|
112
|
*/
|
112
|
113
|
@Override
|
113
|
114
|
@Transactional(rollbackFor = Exception.class)
|
114
|
|
- public Map<String, String> wxUnifiedOrder(String orderNo, String type, String personId) throws Exception {
|
|
115
|
+ public Map<String, String> wxUnifiedOrder(String orderNo, String type, String personId, String clientIp) throws Exception {
|
115
|
116
|
//构建微信配置
|
116
|
117
|
WxConfig config = getWxConfig(1);
|
117
|
118
|
WXPay wxpay = new WXPay(config);
|
118
|
119
|
|
|
120
|
+ TaPerson person = taPersonMapper.selectById(personId);
|
119
|
121
|
|
120
|
122
|
Map<String, Object> orderPriceAndNotifyUrl = getOrderPriceAndNotifyUrl(type, orderNo, "wx");
|
121
|
123
|
|
|
@@ -129,29 +131,30 @@ public class WxPayServiceImpl implements WxPayServiceI {
|
129
|
131
|
data.put("device_info", "");
|
130
|
132
|
data.put("fee_type", "CNY");
|
131
|
133
|
//金额 后台计算
|
132
|
|
- data.put("total_fee", String.valueOf(orderPriceAndNotifyUrl.get("payPrice")));
|
|
134
|
+ data.put("total_fee",String.valueOf(orderPriceAndNotifyUrl.get("payPrice")));
|
133
|
135
|
//终端IP
|
134
|
|
- data.put("spbill_create_ip", "123.12.12.123");
|
|
136
|
+ data.put("spbill_create_ip", clientIp);
|
135
|
137
|
//回调地址
|
136
|
138
|
data.put("notify_url", String.valueOf(orderPriceAndNotifyUrl.get("notifyUrl")));
|
137
|
139
|
// 此处指定为APP支付
|
138
|
|
- data.put("trade_type", "APP");
|
|
140
|
+ data.put("trade_type", "JSAPI");
|
|
141
|
+ //openid
|
|
142
|
+ data.put("openid", person.getMiniOpenid());
|
139
|
143
|
Map<String, String> resp = wxpay.unifiedOrder(data);
|
140
|
144
|
log.info("下单成功:{}", resp);
|
141
|
145
|
if (resp.get("result_code").equalsIgnoreCase(WXPayConstants.FAIL)){
|
142
|
146
|
throw new Exception(resp.get("err_code_des"));
|
143
|
147
|
}
|
144
|
148
|
//插入下单记录表
|
145
|
|
-
|
|
149
|
+
|
146
|
150
|
//第二次重新生成签名
|
147
|
151
|
Map<String, String> secondSignData = new HashMap<String, String>();
|
148
|
152
|
long timestamp = Instant.now().getEpochSecond();
|
149
|
|
- secondSignData.put("appid", config.getAppID());
|
150
|
|
- secondSignData.put("partnerid", config.getMchID());
|
151
|
|
- secondSignData.put("prepayid", resp.get("prepay_id"));
|
152
|
|
- secondSignData.put("noncestr", resp.get("nonce_str"));
|
153
|
|
- secondSignData.put("timestamp", String.valueOf(timestamp));
|
154
|
|
- secondSignData.put("package", "Sign=WXPay");
|
|
153
|
+ secondSignData.put("appId", config.getAppID());
|
|
154
|
+ secondSignData.put("nonceStr", resp.get("nonce_str"));
|
|
155
|
+ secondSignData.put("timeStamp", String.valueOf(timestamp));
|
|
156
|
+ secondSignData.put("package", "prepay_id="+resp.get("prepay_id"));
|
|
157
|
+ secondSignData.put("signType", WXPayConstants.SignType.MD5.toString());
|
155
|
158
|
secondSignData.put("sign", WXPayUtil.generateSignature(secondSignData, config.getKey(), WXPayConstants.SignType.MD5));
|
156
|
159
|
|
157
|
160
|
log.info("订单: {},订单类型: {}, 状态变更为正在支付", orderNo, type);
|