|
@@ -14,10 +14,7 @@ import com.szwl.feign.bean.SzwlFeign;
|
|
|
import com.szwl.mapper.THuifuMchMapper;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.entity.*;
|
|
|
-import com.szwl.service.THuifuMchService;
|
|
|
-import com.szwl.service.THuifuTempOrderService;
|
|
|
-import com.szwl.service.TOrderDetailsService;
|
|
|
-import com.szwl.service.TOrderService;
|
|
|
+import com.szwl.service.*;
|
|
|
import com.szwl.utils.HuifuUtils;
|
|
|
import com.szwl.utils.IDGenerator;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -32,7 +29,7 @@ import java.util.TreeMap;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author wuhs
|
|
@@ -54,6 +51,9 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
@Autowired
|
|
|
SzwlFeign szwlFeign;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ WechatPayInfoService wechatPayInfoService;
|
|
|
+
|
|
|
@Override
|
|
|
public String uniPay(String orderNo, BigDecimal amount, String productName,
|
|
|
String productDesc, String notifyUrl, String frpCode,
|
|
@@ -64,19 +64,19 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
JSONObject request = new JSONObject();
|
|
|
request.put("req_seq_id", orderNo);
|
|
|
request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
request.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
|
|
|
} else {
|
|
|
request.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
|
|
|
}
|
|
|
- if(frpCode.equals("ALIPAY_NATIVE")) {
|
|
|
+ if (frpCode.equals("ALIPAY_NATIVE")) {
|
|
|
request.put("trade_type", "A_NATIVE");
|
|
|
}
|
|
|
- if(frpCode.equals("WEIXIN_XCX")) {
|
|
|
+ if (frpCode.equals("WEIXIN_XCX")) {
|
|
|
request.put("trade_type", "T_MINIAPP");
|
|
|
JSONObject wxData = new JSONObject();
|
|
|
- wxData.put("sub_appid",appid);
|
|
|
- wxData.put("open_id",openId);
|
|
|
+ wxData.put("sub_appid", appid);
|
|
|
+ wxData.put("open_id", openId);
|
|
|
request.put("wx_data", wxData);
|
|
|
}
|
|
|
request.put("trans_amt", amount);
|
|
@@ -94,16 +94,16 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
requestData.put("sign", sign);
|
|
|
requestData.put("data", request);
|
|
|
- System.out.println("请求体:"+ requestData);
|
|
|
+ System.out.println("请求体:" + requestData);
|
|
|
String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
JSONObject result = JSONObject.parseObject(success);
|
|
|
JSONObject data = result.getJSONObject("data");
|
|
|
String qrCode = data.getString("qr_code");
|
|
|
String payInfo = data.getString("pay_info");
|
|
|
- if(frpCode.equals("ALIPAY_NATIVE")){
|
|
|
+ if (frpCode.equals("ALIPAY_NATIVE")) {
|
|
|
return qrCode;
|
|
|
}
|
|
|
- if(frpCode.equals("WEIXIN_XCX")) {
|
|
|
+ if (frpCode.equals("WEIXIN_XCX")) {
|
|
|
return payInfo;
|
|
|
}
|
|
|
return null;
|
|
@@ -118,7 +118,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
request.put("req_seq_id", sn);
|
|
|
request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
String companyType = huifuTempOrder.getCompanyType();
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
request.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
|
|
|
} else {
|
|
|
request.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
|
|
@@ -130,8 +130,8 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
String client6 = clientId.substring(clientId.length() - 6);
|
|
|
String productName1 = "";
|
|
|
- if(huifuTempOrder.getProductNumber() > 1) {
|
|
|
- if(equipment.getMachineType() == null || equipment.getMachineType().equals("0")) {
|
|
|
+ if (huifuTempOrder.getProductNumber() > 1) {
|
|
|
+ if (equipment.getMachineType() == null || equipment.getMachineType().equals("0")) {
|
|
|
productName1 = "棉花糖-" + equipment.getName() + "-" + client6;
|
|
|
} else {
|
|
|
productName1 = "爆米花-" + equipment.getName() + "-" + client6;
|
|
@@ -146,12 +146,12 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
request.put("acct_split_bunch", huifuTempOrder.getAcctSplitBunch());
|
|
|
// 微信支付配置
|
|
|
JSONObject wxData = new JSONObject();
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
- wxData.put("sub_appid",HuifuConstant.SC_WX_SUB_APP_ID);
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ wxData.put("sub_appid", HuifuConstant.SC_WX_SUB_APP_ID);
|
|
|
} else {
|
|
|
- wxData.put("sub_appid",HuifuConstant.SZ_WX_SUB_APP_ID);
|
|
|
+ wxData.put("sub_appid", HuifuConstant.SZ_WX_SUB_APP_ID);
|
|
|
}
|
|
|
- wxData.put("open_id",openid);
|
|
|
+ wxData.put("open_id", openid);
|
|
|
request.put("wx_data", wxData);
|
|
|
// 签名:sign
|
|
|
String s = JSON.toJSONString(request);
|
|
@@ -163,7 +163,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
requestData.put("sign", sign);
|
|
|
requestData.put("data", request);
|
|
|
- System.out.println("请求体:"+ requestData);
|
|
|
+ System.out.println("请求体:" + requestData);
|
|
|
String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
// 拿到返回参数
|
|
|
JSONObject result = JSONObject.parseObject(success);
|
|
@@ -181,15 +181,15 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
String paySign = payInfoJson.getString("paySign");
|
|
|
// 测试链接:http://szwltest.sunzee.com.cn/shenze
|
|
|
String resultUrl = "";
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
- resultUrl = HuifuConstant.SC_JUMP_URL+"/#/popPayment?" +
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ resultUrl = HuifuConstant.SC_JUMP_URL + "/#/popPayment?" +
|
|
|
"sn=" + sn +
|
|
|
"&timeStamp=" + timeStamp +
|
|
|
"&nonceStr=" + nonceStr +
|
|
|
"&package=" + packageValue +
|
|
|
"&paySign=" + paySign;
|
|
|
} else {
|
|
|
- resultUrl = HuifuConstant.SZ_JUMP_URL+"/#/popPayment?" +
|
|
|
+ resultUrl = HuifuConstant.SZ_JUMP_URL + "/#/popPayment?" +
|
|
|
"sn=" + sn +
|
|
|
"&timeStamp=" + timeStamp +
|
|
|
"&nonceStr=" + nonceStr +
|
|
@@ -199,7 +199,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
log.info("微信支付链接:{}", resultUrl);
|
|
|
// 保存订单到数据库
|
|
|
TOrder tOrder = new TOrder();
|
|
|
- String[] ignoreProperties = {"id", "createDate","sn"};
|
|
|
+ String[] ignoreProperties = {"id", "createDate", "sn"};
|
|
|
BeanUtil.copyProperties(huifuTempOrder, tOrder, ignoreProperties);
|
|
|
tOrder.setId(IDGenerator.orderID());
|
|
|
tOrder.setSn(sn);
|
|
@@ -214,7 +214,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
orderDetails.setRefundStatus("0");
|
|
|
orderDetails.setEquipmentId(huifuTempOrder.getEquipmentId());
|
|
|
orderDetails.setMachineType(huifuTempOrder.getMachineType());
|
|
|
- if(huifuTempOrder.getProductNumber() != null && huifuTempOrder.getProductNumber() > 1) {
|
|
|
+ if (huifuTempOrder.getProductNumber() != null && huifuTempOrder.getProductNumber() > 1) {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
|
String[] products = huifuTempOrder.getNote().split(",");
|
|
@@ -264,7 +264,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
JSONObject request = new JSONObject();
|
|
|
request.put("req_seq_id", orderNo);
|
|
|
request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
request.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
|
|
|
} else {
|
|
|
request.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
|
|
@@ -277,7 +277,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
request.put("acct_split_bunch", acctSplitBunch.toJSONString());
|
|
|
// 安全信息
|
|
|
JSONObject riskCheckData = new JSONObject();
|
|
|
- riskCheckData.put("ip_addr","47.112.127.131");
|
|
|
+ riskCheckData.put("ip_addr", "47.112.127.131");
|
|
|
request.put("risk_check_data", riskCheckData);
|
|
|
// 签名:sign
|
|
|
String s = JSON.toJSONString(request);
|
|
@@ -289,14 +289,14 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
requestData.put("sign", sign);
|
|
|
requestData.put("data", request);
|
|
|
- System.out.println("请求体:"+ requestData);
|
|
|
- log.info("请求体:{}",requestData);
|
|
|
+ System.out.println("请求体:" + requestData);
|
|
|
+ log.info("请求体:{}", requestData);
|
|
|
String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
JSONObject result = JSONObject.parseObject(success);
|
|
|
JSONObject data = result.getJSONObject("data");
|
|
|
String transStat = data.getString("trans_stat");
|
|
|
String respDesc = data.getString("resp_desc");
|
|
|
- if(transStat.equals(HuifuConstant.TRANS_STAT_S) || transStat.equals(HuifuConstant.TRANS_STAT_P)) {
|
|
|
+ if (transStat.equals(HuifuConstant.TRANS_STAT_S) || transStat.equals(HuifuConstant.TRANS_STAT_P)) {
|
|
|
return HuifuConstant.RESP_CODE_0;
|
|
|
} else {
|
|
|
return respDesc;
|
|
@@ -312,7 +312,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
request.put("req_seq_id", sn);
|
|
|
request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
String companyType = order.getCompanyType();
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
request.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
|
|
|
} else {
|
|
|
request.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
|
|
@@ -324,8 +324,8 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
String client6 = clientId.substring(clientId.length() - 6);
|
|
|
String productName1 = "";
|
|
|
- if(order.getProductNumber() > 1) {
|
|
|
- if(equipment.getMachineType() == null || equipment.getMachineType().equals("0")) {
|
|
|
+ if (order.getProductNumber() > 1) {
|
|
|
+ if (equipment.getMachineType() == null || equipment.getMachineType().equals("0")) {
|
|
|
productName1 = "棉花糖-" + equipment.getName() + "-" + client6;
|
|
|
} else {
|
|
|
productName1 = "爆米花-" + equipment.getName() + "-" + client6;
|
|
@@ -339,12 +339,12 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
request.put("acct_split_bunch", order.getAcctSplitBunch());
|
|
|
// 微信支付配置
|
|
|
JSONObject wxData = new JSONObject();
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
- wxData.put("sub_appid",HuifuConstant.SC_WX_SUB_APP_ID);
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ wxData.put("sub_appid", HuifuConstant.SC_WX_SUB_APP_ID);
|
|
|
} else {
|
|
|
- wxData.put("sub_appid",HuifuConstant.SZ_WX_SUB_APP_ID);
|
|
|
+ wxData.put("sub_appid", HuifuConstant.SZ_WX_SUB_APP_ID);
|
|
|
}
|
|
|
- wxData.put("open_id",openid);
|
|
|
+ wxData.put("open_id", openid);
|
|
|
request.put("wx_data", wxData);
|
|
|
// 签名:sign
|
|
|
String s = JSON.toJSONString(request);
|
|
@@ -356,7 +356,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
requestData.put("sign", sign);
|
|
|
requestData.put("data", request);
|
|
|
- System.out.println("请求体:"+ requestData);
|
|
|
+ System.out.println("请求体:" + requestData);
|
|
|
String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
// 拿到返回参数
|
|
|
JSONObject result = JSONObject.parseObject(success);
|
|
@@ -372,16 +372,26 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
|
|
|
String packageValue = payInfoJson.getString("package");
|
|
|
// 获取paySign的值
|
|
|
String paySign = payInfoJson.getString("paySign");
|
|
|
+
|
|
|
+ // 保存支付参数
|
|
|
+ WechatPayInfo wechatPayInfo = new WechatPayInfo();
|
|
|
+ wechatPayInfo.setSn(sn);
|
|
|
+ wechatPayInfo.setTimeStamp(timeStamp);
|
|
|
+ wechatPayInfo.setNonceStr(nonceStr);
|
|
|
+ wechatPayInfo.setPackageValue(packageValue);
|
|
|
+ wechatPayInfo.setPaySign(paySign);
|
|
|
+ wechatPayInfoService.save(wechatPayInfo);
|
|
|
+
|
|
|
String resultUrl = "";
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
- resultUrl = HuifuConstant.SC_JUMP_URL+"/#/popPayment?" +
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ resultUrl = HuifuConstant.SC_JUMP_URL + "/#/popPayment?" +
|
|
|
"sn=" + sn +
|
|
|
"&timeStamp=" + timeStamp +
|
|
|
"&nonceStr=" + nonceStr +
|
|
|
"&package=" + packageValue +
|
|
|
"&paySign=" + paySign;
|
|
|
} else {
|
|
|
- resultUrl = HuifuConstant.SZ_JUMP_URL+"/#/popPayment?" +
|
|
|
+ resultUrl = HuifuConstant.SZ_JUMP_URL + "/#/popPayment?" +
|
|
|
"sn=" + sn +
|
|
|
"&timeStamp=" + timeStamp +
|
|
|
"&nonceStr=" + nonceStr +
|