|
@@ -16,6 +16,8 @@ import com.pj.api.wx.service.WxService;
|
|
|
import com.pj.current.config.JhConfig;
|
|
|
import com.pj.current.config.MyConfig;
|
|
|
import com.pj.current.config.PartConfig;
|
|
|
+import com.pj.project.tb_order.TbOrder;
|
|
|
+import com.pj.project.tb_order.TbOrderService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -25,6 +27,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -49,6 +52,8 @@ public class JhService {
|
|
|
|
|
|
@Resource
|
|
|
JhHttpUtils jhHttpUtils;
|
|
|
+ @Resource
|
|
|
+ private TbOrderService tbOrderService;
|
|
|
|
|
|
public JSONObject initPay(HttpServletRequest request) throws Exception {
|
|
|
String money = request.getParameter("money");
|
|
@@ -60,7 +65,7 @@ public class JhService {
|
|
|
Attach atchMap = new Attach();
|
|
|
atchMap.setC(c).setB(businessId).setA(a);
|
|
|
String out_trade_no = RandomUtil.randomString(30);
|
|
|
- StaticLog.info("outTradeNo:{}",out_trade_no);
|
|
|
+ StaticLog.info("outTradeNo:{}", out_trade_no);
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("attach", JSONUtil.toJsonStr(atchMap));
|
|
|
params.put("productType", jhConfig.getProductType());
|
|
@@ -85,7 +90,7 @@ public class JhService {
|
|
|
params.put("sign", sign);
|
|
|
String jsonParam = JSONUtil.toJsonStr(params);
|
|
|
String initPayUrl = jhConfig.getServerUrl() + "/uaps-web-gateway/cnpPay/initPay";
|
|
|
- String result = jhHttpUtils.postJson(initPayUrl,jsonParam);
|
|
|
+ String result = jhHttpUtils.postJson(initPayUrl, jsonParam);
|
|
|
StaticLog.info("调用聚合支付返回:{}", result);
|
|
|
JSONObject jsonResult = JSONUtil.parseObj(result);
|
|
|
if (StrUtil.equals("0000", jsonResult.get("resultCode").toString())) {
|
|
@@ -95,6 +100,12 @@ public class JhService {
|
|
|
StaticLog.info("re:{}", JSONUtil.toJsonStr(r));
|
|
|
JSONObject object = JSONUtil.parseObj(payMessage);
|
|
|
object.set("outTradeNo", out_trade_no);
|
|
|
+ TbOrder tbOrder = new TbOrder();
|
|
|
+ tbOrder.setAttach(JSONUtil.toJsonStr(atchMap))
|
|
|
+ .setOpenid(openid)
|
|
|
+ .setOrderTime(new Date())
|
|
|
+ .setOutTradeNo(out_trade_no).setPrice(money);
|
|
|
+ tbOrderService.save(tbOrder);
|
|
|
return object;
|
|
|
}
|
|
|
throw new Exception("支付信息有误");
|
|
@@ -109,21 +120,22 @@ public class JhService {
|
|
|
String paySecrit = jhConfig.getPaySecret();
|
|
|
String sign = MerchantApiUtil.getSign(params, paySecrit);
|
|
|
params.put("sign", sign);
|
|
|
- String result = jhHttpUtils.postForm(url,params);
|
|
|
+ String result = jhHttpUtils.postForm(url, params);
|
|
|
StaticLog.info("调用聚合支付查询支付接口返回:{}", result);
|
|
|
return JSONUtil.parseObj(result);
|
|
|
}
|
|
|
+
|
|
|
@Async
|
|
|
public void notifyResult(JhNotifyBO bo) {
|
|
|
StaticLog.info("聚合支付回调:{}", JSONUtil.toJsonStr(bo));
|
|
|
- if (!"SUCCESS".equals(bo.getTradeStatus().toUpperCase())){
|
|
|
+ if (!"SUCCESS".equals(bo.getTradeStatus().toUpperCase())) {
|
|
|
return;
|
|
|
}
|
|
|
- NotifyBO notifyBO=new NotifyBO();
|
|
|
+ NotifyBO notifyBO = new NotifyBO();
|
|
|
notifyBO.setOutTradeNo(bo.getOutTradeNo())
|
|
|
.setAttach(bo.getAttach())
|
|
|
.setTransactionId(bo.getBankTrxNo())
|
|
|
- .setTotalFee(NumberUtil.mul(bo.getOrderPrice(),100+"").toString());
|
|
|
+ .setTotalFee(NumberUtil.mul(bo.getOrderPrice(), 100 + "").toString());
|
|
|
wxService.WxNotify(notifyBO);
|
|
|
}
|
|
|
}
|