소스 검색

微信移动端支付

guomengjiao 5 달 전
부모
커밋
bcf222c79b

+ 2 - 2
modules/report/src/main/java/com/jeesite/modules/report/entity/WebsiteUserOrder.java

@@ -24,7 +24,7 @@ import java.util.List;
 		@Column(name="website_user_id", attrName="websiteUserId", label="网站用户id"),
 		@Column(name="pay_date", attrName="payDate", label="支付日期"),
 		@Column(name="pay_status", attrName="payStatus", label="状态 0-待支付 1-支付成功 2-支付失败"),
-		@Column(name="pay_method", attrName="payMethod", label="支付方式 1-微信 2-支付宝"),
+		@Column(name="pay_method", attrName="payMethod", label="支付方式 wx、zfb、wx_h5、zfb_h5"),
 		@Column(name="pay_price", attrName="payPrice", label="支付单价"),
 		@Column(name="research_brief_report_id", attrName="researchBriefReportId", label="简报智库id"),
 	}, orderBy="a.update_date DESC"
@@ -91,7 +91,7 @@ public class WebsiteUserOrder extends DataEntity<WebsiteUserOrder> {
 		this.payStatus = payStatus;
 	}
 	
-	@Size(min=0, max=2, message="支付方式 1-微信 2-支付宝长度不能超过 2 个字符")
+	@Size(min=0, max=2, message="支付方式长度不能超过 2 个字符")
 	public String getPayMethod() {
 		return payMethod;
 	}

+ 8 - 8
modules/report/src/main/java/com/jeesite/modules/report/service/WebsiteUserOrderService.java

@@ -22,6 +22,7 @@ import com.wechat.pay.java.core.notification.RequestParam;
 import com.wechat.pay.java.service.payments.model.Transaction;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -179,11 +180,11 @@ public class WebsiteUserOrderService extends CrudService<WebsiteUserOrderDao, We
 			return R.fail("支付调用第三方失败");
 		}
 		super.save(websiteUserOrder);
-		return R.ok(payResult);
+		return R.ok("成功", payResult);
 	}
 
 	public String generateOrderNumber() {
-		String random = String.valueOf((new Random().nextDouble() * 9000) + 1000);
+		String random = String.valueOf(new Random().nextInt(9000) + 1000);
 		return "WUO" + DateUtils.formatDate(new Date(), "yyyyMMddHHmmss") + random;
 	}
 
@@ -254,12 +255,11 @@ public class WebsiteUserOrderService extends CrudService<WebsiteUserOrderDao, We
 					}
 				}
 				//查是否超时
-				if (DateUtils.getMinDistanceOfTwoDate(order.getCreateDate(), new Date()) > 10){
-					if (alipayUtil.payClose(order.getOrderNumber())) {
-						//支付宝订单关闭成功
-						order.setPayStatus(Constants.orderPayStatus.PAY_ERROR);
-						super.update(order);
-					}
+				if (DateUtils.getMinDistanceOfTwoDate(order.getCreateDate(), new Date()) > 10) {
+					alipayUtil.payClose(order.getOrderNumber());
+					//支付宝订单关闭成功
+					order.setPayStatus(Constants.orderPayStatus.PAY_ERROR);
+					super.update(order);
 				}
 			} catch (Exception e) {
 				logger.error("zfbPayQuery payQuery error", e);

+ 1 - 1
modules/report/src/main/java/com/jeesite/modules/report/util/AlipayUtil.java

@@ -90,7 +90,7 @@ public class AlipayUtil {
         model.setTimeoutExpress(timeout);
 
         alipayRequest.setBizModel(model);
-        AlipayTradePagePayResponse response = alipayClient.pageExecute(alipayRequest, "POST");
+        AlipayTradePagePayResponse response = alipayClient.pageExecute(alipayRequest, "GET");
         // 收到支付宝的响应,响应一个页面,浏览器显示这个页面,就会自动到支付宝的收银台页面
         logger.info("支付宝 pay 响应:{}", JSONObject.toJSONString(response));
         if (response.isSuccess()) {

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 3 - 3
web/src/main/resources/config/application.yml