소스 검색

更新小程序支付接口,更新获取微校token接口

liu 1 년 전
부모
커밋
4b4ec5e194

+ 12 - 1
src/main/java/com/template/component/WeiXiaoComponent.java

@@ -9,6 +9,9 @@ import com.template.config.WeixiaoConfig;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
@@ -101,7 +104,15 @@ public class WeiXiaoComponent {
 
         try {
             RestTemplate client = new RestTemplate();
-            ResponseEntity<String> tokenResponse = client.postForEntity(uri, tokenParams, String.class);
+
+            // wecode换取token
+            HttpHeaders headers = new HttpHeaders();
+            headers.setContentType(MediaType.APPLICATION_JSON);
+            HttpEntity<Map<String, String>> request = new HttpEntity<>(tokenParams, headers);
+
+            ResponseEntity<String> tokenResponse = client.postForEntity(uri, request, String.class);
+
+//            ResponseEntity<String> tokenResponse = client.postForEntity(uri, tokenParams, String.class);(需要加头部)
             String body = tokenResponse.getBody();
             log.info("微校请求token返回结果【{}】", body);
             ObjectMapper mapper = new ObjectMapper();

+ 3 - 2
src/main/java/com/template/controller/HouseOrderController.java

@@ -1843,8 +1843,8 @@ public class HouseOrderController implements HouseOrderAPI {
                         throw new Exception("支付失败!");
                     }
                 }
-//              已支付
-                ho.setOrderStatus("2");
+//              金额为0为待入住
+                ho.setOrderStatus("3");
 //               支付时间
                 ho.setPayTime(LocalDateTime.now().format(dateTimeFormatter));
 //                支付渠道
@@ -1856,6 +1856,7 @@ public class HouseOrderController implements HouseOrderAPI {
                 if (!updateHouseOrder) {
                     throw new Exception("支付失败!");
                 }
+                log.info("金额为0,待入住成功");
                 return CommonResult.ok("支付金额为0,不用走微信支付");
             }
         } catch (Exception e) {

+ 4 - 0
src/main/java/com/template/services/impl/HouseOrderServiceImpl.java

@@ -119,6 +119,8 @@ public class HouseOrderServiceImpl extends ServiceImpl<HouseOrderMapper, HouseOr
             if (ObjectUtils.isNotEmpty(scheduleList)) {
                 for (ClassSchedule classSchedule : scheduleList) {
                     String dateTime = classSchedule.getDateTime();
+                    String[] s = dateTime.split(" ");
+                    dateTime=s[0];
                     LocalDate parse = LocalDate.parse(dateTime, dateTimeFormatter2);
                     if (!localDate1.equals(parse)) {
                         if (ObjectUtils.isNotEmpty(housePrices1)) {
@@ -254,6 +256,8 @@ public class HouseOrderServiceImpl extends ServiceImpl<HouseOrderMapper, HouseOr
             if (ObjectUtils.isNotEmpty(scheduleList)) {
                 for (ClassSchedule classSchedule : scheduleList) {
                     String dateTime = classSchedule.getDateTime();
+                    String[] s = dateTime.split(" ");
+                    dateTime=s[0];
                     LocalDate parse = LocalDate.parse(dateTime, dateTimeFormatter2);
                     if (!localDate1.equals(parse)) {
                         if (ObjectUtils.isNotEmpty(housePrices1)) {