Просмотр исходного кода

Merge branch 'master' of http://git.izouma.com/xiongzhu/9th

panhui 4 лет назад
Родитель
Сommit
f192b82eee

+ 1 - 0
src/main/java/com/izouma/nineth/security/WebSecurityConfig.java

@@ -93,6 +93,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/user/code2openId").permitAll()
                 .antMatchers("/blindBoxItem/all").permitAll()
                 .antMatchers("/collection/recommend").permitAll()
+                .antMatchers("/order/**/status").permitAll()
                 // all other requests need to be authenticated
                 .anyRequest().authenticated().and()
                 // make sure we use stateless session; session won't be used to

+ 14 - 7
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -254,7 +254,10 @@ public class OrderService {
         Order order = orderRepo.findByIdAndDelFalse(id).orElseThrow(new BusinessException("订单不存在"));
         Collection collection = collectionRepo.findById(order.getCollectionId())
                 .orElseThrow(new BusinessException("藏品不存在"));
-        User invitor = userRepo.findById(order.getInvitor()).orElse(null);
+        User invitor = null;
+        if (order.getInvitor() != null) {
+            invitor = userRepo.findById(order.getInvitor()).orElse(null);
+        }
         if (order.getStatus() != OrderStatus.NOT_PAID) {
             throw new BusinessException("订单状态错误");
         }
@@ -265,6 +268,7 @@ public class OrderService {
         paymentParams.put("app_id", adapayProperties.getAppId());
         paymentParams.put("pay_channel", payChannel);
         paymentParams.put("goods_title", collection.getName());
+        paymentParams.put("goods_desc", collection.getName());
         paymentParams.put("time_expire", DateTimeFormatter.ofPattern("yyyyMMddHHmmss")
                 .format(LocalDateTime.now().plusMinutes(5)));
         paymentParams.put("notify_url", adapayProperties.getNotifyUrl() + "/order/" + order.getId());
@@ -288,7 +292,10 @@ public class OrderService {
             restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, "0",
                     -1, true);
         }
-        paymentParams.put("div_members", JSON.toJSONString(divMembers));
+        if (divMembers.size() > 1) {
+            paymentParams.put("div_members", JSON.toJSONString(divMembers));
+        }
+
         if (restAmount.compareTo(BigDecimal.ZERO) != 0) {
             log.error("分账出错 {}", JSON.toJSONString(divMembers, SerializerFeature.PrettyFormat));
             throw new BusinessException("分账出错");
@@ -309,13 +316,13 @@ public class OrderService {
 
         Map<String, Object> response = Payment.create(paymentParams);
         AdapayService.checkSuccess(response);
-        if (aliChannels.contains(payChannel)) {
-            return MapUtils.getMap(response, "expend");
-        }
 
-        switch (payChannel){
+        switch (payChannel) {
+            case "alipay_wap":
             case "alipay":
-                MapUtils.getString(MapUtils.getMap(response,"expend"),"pay_info");
+                return MapUtils.getString(MapUtils.getMap(response, "expend"), "pay_info");
+            case "alipay_qr":
+                return MapUtils.getString(MapUtils.getMap(response, "expend"), "qrcode_url");
         }
         return response;
     }

+ 9 - 0
src/main/java/com/izouma/nineth/web/OrderController.java

@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Optional;
 import java.util.stream.Collectors;
@@ -93,5 +94,13 @@ public class OrderController extends BaseController {
     public void refund(@RequestParam Long id) throws WxPayException {
         orderService.refund(id);
     }
+
+    @GetMapping("/{id}/status")
+    public Object status(@PathVariable Long id) {
+        Order order = orderRepo.findById(id).orElseThrow(new BusinessException("订单不存在"));
+        return new HashMap<>() {{
+            put("status", order.getStatus());
+        }};
+    }
 }
 

+ 24 - 4
src/main/java/com/izouma/nineth/web/OrderPayController.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
 import com.github.binarywang.wxpay.constant.WxPayConstants;
 import com.github.binarywang.wxpay.exception.WxPayException;
+import com.huifu.adapay.core.exception.BaseAdaPayException;
 import com.izouma.nineth.service.AssetService;
 import com.izouma.nineth.service.GiftOrderService;
 import com.izouma.nineth.service.OrderService;
@@ -30,13 +31,32 @@ public class OrderPayController {
     private final WxMpService      wxMpService;
     private final GiftOrderService giftOrderService;
 
-    @RequestMapping(value = "/alipay", method = RequestMethod.GET)
-    public String payOrderAlipay(Long id, Model model, @RequestHeader(value = "User-Agent") String userAgent) {
-        detectUA(userAgent, model);
-        orderService.payOrderAlipay(id, model);
+    @RequestMapping(value = "/alipay_h5", method = RequestMethod.GET)
+    @ResponseBody
+    public String payOrderAlipayH5(Long id, Model model) throws BaseAdaPayException {
+        return (String) orderService.payAdapay(id, "alipay_wap", null);
+    }
+
+    @RequestMapping(value = "/alipay_wx", method = RequestMethod.GET)
+    public String payOrderAlipayWx(Long id, Model model) throws BaseAdaPayException {
+        String payUrl = (String) orderService.payAdapay(id, "alipay_wap", null);
+        model.addAttribute("payUrl", payUrl);
+        model.addAttribute("orderId", id);
         return "AlipayHtml";
     }
 
+    @RequestMapping(value = "/alipay_qr", method = RequestMethod.GET)
+    @ResponseBody
+    public String payOrderAlipayQR(Long id, Model model) throws BaseAdaPayException {
+        return (String) orderService.payAdapay(id, "alipay_qr", null);
+    }
+
+    @RequestMapping(value = "/alipay_app", method = RequestMethod.GET)
+    @ResponseBody
+    public String payOrderAlipayApp(Long id, Model model) throws BaseAdaPayException {
+        return (String) orderService.payAdapay(id, "alipay", null);
+    }
+
     @RequestMapping(value = "/weixin_h5")
     public String payOrderWeixinH5(Long id, Model model, @RequestHeader(value = "User-Agent") String userAgent) throws EncoderException, WxPayException {
         detectUA(userAgent, model);

+ 3 - 0
src/main/pc-space/src/views/AssetDetail.vue

@@ -9,6 +9,7 @@
                             v-if="isVideo(item)"
                             :src="item.url"
                             :poster="getImg(changeImgs([item]), '', 1800)"
+                            style="width: 100%; height: 520px"
                             controls="controls"
                         >
                             您的浏览器不支持 video 标签。
@@ -1161,6 +1162,7 @@ export default {
                 width: 188px;
                 background: #fff;
                 border-radius: 4px;
+                z-index: 9999;
                 top: 40px;
                 left: 30px;
                 .span {
@@ -1192,6 +1194,7 @@ export default {
             .hoverTips1 {
                 position: absolute;
                 width: 188px;
+                z-index: 9999;
                 background: #fff;
                 border-radius: 4px;
                 top: 40px;

+ 4 - 1
src/main/pc-space/src/views/CollectionDetail.vue

@@ -9,6 +9,7 @@
                             v-if="isVideo(item)"
                             :src="item.url"
                             :poster="getImg(changeImgs([item]), '', 1800)"
+                            style="width: 100%; height: 520px"
                             controls="controls"
                         >
                             您的浏览器不支持 video 标签。
@@ -863,7 +864,7 @@ export default {
                 border-bottom: 10px solid #fff;
                 content: '';
                 display: block;
-                z-index: 999;
+                z-index: 9999;
                 position: absolute;
                 left: 12px; //给小三角定位,更具实际需求调整
                 top: -10px; //给小三角定位,更具实际需求调整
@@ -872,6 +873,7 @@ export default {
                 position: absolute;
                 width: 188px;
                 background: #fff;
+                z-index: 9999;
                 border-radius: 4px;
                 top: 40px;
                 left: -4px;
@@ -887,6 +889,7 @@ export default {
                 height: 0;
                 border-left: 7px solid transparent;
                 border-right: 7px solid transparent;
+                z-index: 9999;
                 border-bottom: 10px solid #fff;
                 content: '';
                 display: block;

+ 19 - 3
src/main/pc-space/src/views/user/AccountData.vue

@@ -45,9 +45,7 @@
         </div>
         <div class="userContent" v-if="active === '关注' || active === '粉丝'">
             <div class="borderUser"></div>
-            <!-- <el-divider content-position="right">
-                <img src="../../assets/copy_icon.png" alt="" />
-            </el-divider> -->
+            <!-- <img class="radio-img" src="../assets/sousuo_icon_sanjiao.png" alt="" :style="{ left: searchLeft }" /> -->
             <el-empty v-if="empty" description="还没有用户哦~"></el-empty>
             <div v-for="item in list" :key="item.id">
                 <div class="boxFollow">
@@ -234,6 +232,15 @@ export default {
     },
     computed: {
         ...mapState(['userInfo']),
+        searchLeft() {
+            return (
+                this.tabs.findIndex(item => {
+                    return item.value === this.searchType;
+                }) *
+                    (this.isChinese ? 68 : 90) +
+                'px'
+            );
+        },
         Phone() {
             return this.userInfo.phone.slice(0, 3) + ' **** ' + this.userInfo.phone.slice(7, 11);
         },
@@ -506,6 +513,15 @@ export default {
         color: #ccc;
         margin-top: 10px;
     }
+    .radio-img {
+        position: absolute;
+        bottom: 0;
+        left: 0;
+        width: 16px;
+        height: 10px;
+        transform: translate(26px, 12px);
+        transition: left ease-in-out 0.3s;
+    }
     .top {
         height: 146px;
         width: 970px;

+ 52 - 10
src/main/resources/static/AlipayHtml.html

@@ -62,7 +62,7 @@
         }
 
         #btn-zfb {
-            width: 80%;
+            width: 100%;
             margin: auto;
             background: #ffffff;
             line-height: 52px;
@@ -72,14 +72,49 @@
             font-size: 18px;
             letter-spacing: 3px;
             font-weight: 400;
-            border: 1px solid transparent;
             border-radius: 8px;
+            border: none;
+        }
+
+        #btn-zfb:active {
+            background: rgba(240, 240, 240, 1);
+        }
+
+        #btn-finish:active {
+            background: rgba(0, 0, 0, 0.03);
+        }
+
+        #btn-finish {
+            width: 100%;
+            line-height: 50px;
+            height: 52px;
+            outline: none;
+            font-size: 18px;
+            letter-spacing: 3px;
+            font-weight: 400;
+            border-radius: 8px;
+            margin: 20px auto 0 auto;
+            border: 2px solid #ffffff;
+            color: #ffffff;
+            background: none;
+        }
+
+        .btns {
+            width: 80%;
+            display: flex;
+            align-items: center;
+            justify-content: center;
             position: absolute;
-            top: 0;
-            bottom: 0;
             left: 0;
             right: 0;
-            display: none;
+            top: 0;
+            bottom: 0;
+            margin: auto;
+            flex-direction: column;
+        }
+
+        .btns a {
+            width: 100%;
         }
     </style>
 </head>
@@ -92,9 +127,16 @@
     <div class="overlay-text2">注:由于微信限制,需要在浏览器中打开才可以完成支付宝支付</div>
 </div>
 
-<a id="link">
-    <button id="btn-zfb">打开支付宝</button>
-</a>
+<div class="btn-wrapper" style="display: none">
+    <div class="btns">
+        <a id="link">
+            <button id="btn-zfb">打开支付宝</button>
+        </a>
+        <a id="">
+            <button id="btn-finish">我已完成支付</button>
+        </a>
+    </div>
+</div>
 <script>
     function GetQueryString(name) {
         var after = window.location.href.split("?")[1];
@@ -112,9 +154,9 @@
     window.onload = function () {
         console.log('onload');
         if (/micromessenger/i.test(navigator.userAgent)) {
-            $('#overlay').fadeIn();
+            $('.overlay').fadeIn();
         } else {
-            $('#btn-zfb').fadeIn();
+            $('.btn-wrapper').fadeIn();
         }
     }
 </script>

+ 141 - 65
src/main/resources/templates/AlipayHtml.ftlh

@@ -6,67 +6,138 @@
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
     <title>支付</title>
-    <!-- 引入样式文件 -->
-    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.4/lib/index.css">
-    <link rel="stylesheet" href="/static/aliAuthorize.css">
+    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
+    <style>
+        html {
+            width: 100%;
+            height: 100%;
+            padding: 0;
+            margin: 0;
+            font-family: -apple-system, SF UI Text, Arial, PingFang SC, Hiragino Sans GB, Microsoft YaHei, WenQuanYi Micro Hei, sans-serif;
+            font-size: 14px;
+            font-weight: 400;
+            line-height: 1.6;
+        }
+
+        body {
+            width: 100%;
+            height: 100%;
+            padding: 0;
+            margin: 0;
+            background: #1677ff url(/static/img/zfb.png) no-repeat top;
+            background-size: 100%;
+        }
+
+        .overlay .overlay-img {
+            width: 186px;
+            height: 210px;
+            margin-right: 15px;
+        }
+
+        .overlay .overlay-text1 {
+            width: 272px;
+            font-size: 16px;
+            font-weight: bold;
+            color: rgba(255, 255, 255, 1);
+            line-height: 22px;
+            margin: 15px auto 0;
+        }
+
+        .overlay .overlay-text2 {
+            width: 272px;
+            font-size: 13px;
+            color: rgba(255, 255, 255, 1);
+            line-height: 18px;
+            margin: 15px auto 0;
+        }
+
+        .overlay {
+            position: fixed;
+            top: 0;
+            right: 0;
+            bottom: 0;
+            left: 0;
+            background: rgba(0, 0, 0, 0.7);
+            display: none;
+        }
+
+        #btn-zfb {
+            width: 100%;
+            margin: auto;
+            background: #ffffff;
+            line-height: 52px;
+            height: 52px;
+            outline: none;
+            color: #1677ff;
+            font-size: 18px;
+            letter-spacing: 3px;
+            font-weight: 400;
+            border-radius: 8px;
+            border: none;
+        }
+
+        #btn-zfb:active {
+            background: rgba(240, 240, 240, 1);
+        }
+
+        #btn-finish:active {
+            background: rgba(0, 0, 0, 0.03);
+        }
+
+        #btn-finish {
+            width: 100%;
+            line-height: 50px;
+            height: 52px;
+            outline: none;
+            font-size: 18px;
+            letter-spacing: 3px;
+            font-weight: 400;
+            border-radius: 8px;
+            margin: 20px auto 0 auto;
+            border: 2px solid #ffffff;
+            color: #ffffff;
+            background: none;
+        }
+
+        .btns {
+            width: 80%;
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            position: absolute;
+            left: 0;
+            right: 0;
+            top: 0;
+            bottom: 0;
+            margin: auto;
+            flex-direction: column;
+        }
+
+        .btns a {
+            width: 100%;
+        }
+    </style>
 </head>
 
 <body>
-<#if errMsg??>
-    <div id="app" class="err">
-        <div class="err-msg"> ${errMsg}</div>
-        <div class="err-back" @click="onClickLeft">返回</div>
+<div class="overlay" id="overlay">
+    <div style="text-align: right"><img class="overlay-img" src="/static/img/zhifu_img_liulanqi_ios.png" alt=""/>
     </div>
-<#else>
-    <div id="app">
-
-        <#if weixin>
-            <van-nav-bar title="收银台" @click-left="onClickLeft" style="min-height: 46px">
-                <img class="back" src="/static/img/nav_icon_return.png" slot="left" alt/>
-            </van-nav-bar>
-        </#if>
-
-
-        <div class="container">
-            <img src="/static/img/icon_shouquan.png" alt="" class="icon">
-            <div class="text">正在跳转到支付宝</div>
-
-            <#--        <div class="btn">-->
-            <#--            <van-button type="default" block>点击跳转到支付宝</van-button>-->
-            <#--        </div>-->
-        </div>
-
-        <#if weixin>
-            <van-overlay class="overlay" show>
-                <div style="text-align: right">
-                    <#if android>
-                        <img class="overlay-img" src="/static/img/zhifu_img_liulanqi_and.png" alt=""/>
-                    <#elseif ios>
-                        <img class="overlay-img" src="/static/img/zhifu_img_liulanqi_ios.png" alt=""/>
-                    <#else>
-                        <img class="overlay-img" src="/static/img/zhifu_img_liulanqi_and.png" alt=""/>
-                    </#if>
-                </div>
-                <#if ios>
-                    <div class="overlay-text1">请点击右上角,选择“在Safari中打开”然后继续完成支付</div>
-                <#else>
-                    <div class="overlay-text1">请点击右上角,选择“在浏览器中打开”然后继续完成支付</div>
-                </#if>
-                <div class="overlay-text2">注:由于微信限制,需要在浏览器中打开才可以完成支付宝支付</div>
-            </van-overlay>
-        </#if>
-    </div>
-</#if>
-<#if !weixin && form??>
-    ${form?no_esc}
-</#if>
-<!-- 引入 Vue 和 Vant 的 JS 文件 -->
-<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
-<script src="https://cdn.jsdelivr.net/npm/vant@2.4/lib/vant.min.js"></script>
+    <div class="overlay-text1">请点击右上角,选择在默认浏览器中打开然后继续完成支付</div>
+    <div class="overlay-text2">注:由于微信限制,需要在浏览器中打开才可以完成支付宝支付</div>
+</div>
 
+<div class="btn-wrapper" style="display: none">
+    <div class="btns">
+        <a id="link" href="alipays://platformapi/startapp?saId=10000007&qrcode=${payUrl?no_esc}">
+            <button id="btn-zfb">打开支付宝</button>
+        </a>
+        <a id="" href="/9th/orders">
+            <button id="btn-finish">我已完成支付</button>
+        </a>
+    </div>
+</div>
 <script>
-    // 在 #app 标签下渲染一个按钮组件
-
     function GetQueryString(name) {
         var after = window.location.href.split("?")[1];
         if (after) {
@@ -80,18 +151,23 @@
         }
     }
 
-    new Vue({
-        el: '#app',
-        data: {},
-        mounted() {
-            document.getElementById('app').style.display = 'flex';
-        },
-        methods: {
-            onClickLeft: function () {
-                history.back();
+    setInterval(function () {
+        $.get('/order/${orderId}/status', function (data) {
+            console.log(data);
+            if (data.status !== 'NOT_PAID') {
+                window.location = '/9th/orders';
             }
+        });
+    }, 1000);
+
+    window.onload = function () {
+        console.log('onload');
+        if (/micromessenger/i.test(navigator.userAgent)) {
+            $('.overlay').fadeIn();
+        } else {
+            $('.btn-wrapper').fadeIn();
         }
-    });
+    }
 </script>
 </body>
 

+ 98 - 0
src/main/resources/templates/AlipayHtmlBak.ftlh

@@ -0,0 +1,98 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <title>支付</title>
+    <!-- 引入样式文件 -->
+    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.4/lib/index.css">
+    <link rel="stylesheet" href="/static/aliAuthorize.css">
+</head>
+
+<body>
+<#if errMsg??>
+    <div id="app" class="err">
+        <div class="err-msg"> ${errMsg}</div>
+        <div class="err-back" @click="onClickLeft">返回</div>
+    </div>
+<#else>
+    <div id="app">
+
+        <#if weixin>
+            <van-nav-bar title="收银台" @click-left="onClickLeft" style="min-height: 46px">
+                <img class="back" src="/static/img/nav_icon_return.png" slot="left" alt/>
+            </van-nav-bar>
+        </#if>
+
+
+        <div class="container">
+            <img src="/static/img/icon_shouquan.png" alt="" class="icon">
+            <div class="text">正在跳转到支付宝</div>
+
+            <#--        <div class="btn">-->
+            <#--            <van-button type="default" block>点击跳转到支付宝</van-button>-->
+            <#--        </div>-->
+        </div>
+
+        <#if weixin>
+            <van-overlay class="overlay" show>
+                <div style="text-align: right">
+                    <#if android>
+                        <img class="overlay-img" src="/static/img/zhifu_img_liulanqi_and.png" alt=""/>
+                    <#elseif ios>
+                        <img class="overlay-img" src="/static/img/zhifu_img_liulanqi_ios.png" alt=""/>
+                    <#else>
+                        <img class="overlay-img" src="/static/img/zhifu_img_liulanqi_and.png" alt=""/>
+                    </#if>
+                </div>
+                <#if ios>
+                    <div class="overlay-text1">请点击右上角,选择“在Safari中打开”然后继续完成支付</div>
+                <#else>
+                    <div class="overlay-text1">请点击右上角,选择“在浏览器中打开”然后继续完成支付</div>
+                </#if>
+                <div class="overlay-text2">注:由于微信限制,需要在浏览器中打开才可以完成支付宝支付</div>
+            </van-overlay>
+        </#if>
+    </div>
+</#if>
+<#if !weixin && form??>
+    ${form?no_esc}
+</#if>
+<!-- 引入 Vue 和 Vant 的 JS 文件 -->
+<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
+<script src="https://cdn.jsdelivr.net/npm/vant@2.4/lib/vant.min.js"></script>
+
+<script>
+    // 在 #app 标签下渲染一个按钮组件
+
+    function GetQueryString(name) {
+        var after = window.location.href.split("?")[1];
+        if (after) {
+            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+            var r = after.match(reg);
+            if (r != null) {
+                return decodeURIComponent(r[2]);
+            } else {
+                return null;
+            }
+        }
+    }
+
+    new Vue({
+        el: '#app',
+        data: {},
+        mounted() {
+            document.getElementById('app').style.display = 'flex';
+        },
+        methods: {
+            onClickLeft: function () {
+                history.back();
+            }
+        }
+    });
+</script>
+</body>
+
+</html>

+ 1 - 2
src/test/java/com/izouma/nineth/service/AdapayServiceTest.java

@@ -35,11 +35,10 @@ public class AdapayServiceTest extends ApplicationTests {
 
         paymentParams.put("app_id", "app_f8760acc-f4d8-46f6-8f70-d80e36517075");
         paymentParams.put("order_no", "jsdk_payment" + System.currentTimeMillis());
-        paymentParams.put("pay_channel", "alipay");
+        paymentParams.put("pay_channel", "alipay_wap");
         paymentParams.put("pay_amt", "0.10");
         paymentParams.put("goods_title", "your goods title");
         paymentParams.put("goods_desc", "your goods desc");
-        paymentParams.put("div_members", JSON.toJSONString(divMembers));
         paymentParams.put("notify_url", "http://9th.frp.izouma.com/notify/adapay/order/1");
         paymentParams.put("description", "orderId=1");