|
|
@@ -20,6 +20,8 @@ import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.common.utils.ip.IpUtils;
|
|
|
import com.zhongzheng.common.utils.polyv.PolyvUtils;
|
|
|
import com.zhongzheng.common.utils.wxpay.*;
|
|
|
+import com.zhongzheng.modules.order.domain.Order;
|
|
|
+import com.zhongzheng.modules.order.service.IOrderService;
|
|
|
import com.zhongzheng.modules.polyv.bo.PolyvVideoAddBo;
|
|
|
import com.zhongzheng.modules.polyv.bo.PolyvVideoEditBo;
|
|
|
import com.zhongzheng.modules.polyv.bo.PolyvVideoQueryBo;
|
|
|
@@ -79,27 +81,27 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
|
|
|
private boolean autoReport = false;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IOrderService iOrderService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, String> payment(String polyvId) throws Exception {
|
|
|
+ public Map<String, String> payment(String out_trade_no,String openid,String body,String price) {
|
|
|
WxSmallConfig config = new WxSmallConfig(appid,mchid,key);
|
|
|
- WXPay wxpay = new WXPay(config);
|
|
|
- SnowflakeIdUtils idWorker = new SnowflakeIdUtils(3, 1);
|
|
|
- String out_trade_no = String.valueOf(idWorker.nextId());
|
|
|
- System.out.println(out_trade_no);
|
|
|
-
|
|
|
- Map<String, String> data = new HashMap<String, String>();
|
|
|
- data.put("body", "中正云课堂会员充值");
|
|
|
- data.put("out_trade_no", out_trade_no);
|
|
|
- data.put("device_info", "");
|
|
|
- data.put("fee_type", "CNY");
|
|
|
- data.put("total_fee", "1");
|
|
|
- data.put("openid", "owcQx5LtC4XAvz8Q9AQHO1ttTDiA");
|
|
|
- data.put("spbill_create_ip", IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
- data.put("notify_url", notifyUrl);
|
|
|
- data.put("trade_type", "JSAPI");
|
|
|
-
|
|
|
try {
|
|
|
+ WXPay wxpay = new WXPay(config);
|
|
|
+ SnowflakeIdUtils idWorker = new SnowflakeIdUtils(3, 1);
|
|
|
+
|
|
|
+ Map<String, String> data = new HashMap<String, String>();
|
|
|
+ data.put("body", body);
|
|
|
+ data.put("out_trade_no", out_trade_no);
|
|
|
+ data.put("device_info", "");
|
|
|
+ data.put("fee_type", "CNY");
|
|
|
+ data.put("total_fee", "1");
|
|
|
+ data.put("openid", openid);
|
|
|
+ data.put("spbill_create_ip", IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ data.put("notify_url", notifyUrl);
|
|
|
+ data.put("trade_type", "JSAPI");
|
|
|
Map<String, String> resp = wxpay.unifiedOrder(data);
|
|
|
|
|
|
Map<String, String> result = new HashMap<>();
|
|
|
@@ -119,6 +121,36 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void paymentCallBack(String notifyData) {
|
|
|
+ WxSmallConfig config = new WxSmallConfig(appid,mchid,key);
|
|
|
+ try {
|
|
|
+ WXPay wxpay = new WXPay(config);
|
|
|
+
|
|
|
+ Map<String, String> notifyMap = WXPayUtil.xmlToMap(notifyData); // 转换成map
|
|
|
+
|
|
|
+ if (wxpay.isPayResultNotifySignatureValid(notifyMap)) {
|
|
|
+ String out_trade_no = notifyMap.get("out_trade_no");
|
|
|
+ String transaction_id = notifyMap.get("transaction_id");
|
|
|
+ Order order = iOrderService.queryByOrderSn(out_trade_no);
|
|
|
+ if(order.getOrderStatus()==0){
|
|
|
+ order.setOrderStatus(1);
|
|
|
+ order.setPayTime(DateUtils.getNowTime());
|
|
|
+ order.setTransid(transaction_id);
|
|
|
+ order.setOrderGeneral(out_trade_no);
|
|
|
+ if(iOrderService.updateById(order)){
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 签名错误,如果数据里没有sign字段,也认为是签名错误
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 不需要证书的请求
|
|
|
* @param urlSuffix String
|