Procházet zdrojové kódy

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

panhui před 4 roky
rodič
revize
781b04f7e1

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

@@ -13,9 +13,11 @@ import com.github.binarywang.wxpay.constant.WxPayConstants;
 import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.huifu.adapay.core.exception.BaseAdaPayException;
+import com.huifu.adapay.model.AdapayCommon;
 import com.huifu.adapay.model.Payment;
 import com.izouma.nineth.config.AdapayProperties;
 import com.izouma.nineth.config.AlipayProperties;
+import com.izouma.nineth.config.GeneralProperties;
 import com.izouma.nineth.config.WxPayProperties;
 import com.izouma.nineth.domain.Collection;
 import com.izouma.nineth.domain.*;
@@ -32,7 +34,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.EncoderException;
 import org.apache.commons.codec.net.URLCodec;
 import org.apache.commons.collections.MapUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.context.event.EventListener;
 import org.springframework.core.env.Environment;
 import org.springframework.data.domain.Page;
@@ -72,6 +73,7 @@ public class OrderService {
     private RedisTemplate<String, Object> redisTemplate;
     private CommissionRecordRepo          commissionRecordRepo;
     private AdapayProperties              adapayProperties;
+    private GeneralProperties             generalProperties;
 
     public Page<Order> all(PageQuery pageQuery) {
         return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
@@ -302,9 +304,9 @@ public class OrderService {
         }
 
         if (wxChannels.contains(payChannel)) {
-            if (StringUtils.isBlank(openId)) {
-                throw new BusinessException("缺少openId");
-            }
+//            if (StringUtils.isBlank(openId)) {
+//                throw new BusinessException("缺少openId");
+//            }
             Map<String, Object> expend = new HashMap<>();
             expend.put("open_id", openId);
             expend.put("limit_pay", "1");
@@ -314,8 +316,15 @@ public class OrderService {
             paymentParams.put("expend", expend);
         }
 
-        Map<String, Object> response = Payment.create(paymentParams);
-        AdapayService.checkSuccess(response);
+        Map<String, Object> response;
+        if (wxChannels.contains(payChannel)) {
+            paymentParams.put("adapay_func_code", "wxpay.createOrder");
+            paymentParams.put("callback_url", generalProperties.getHost() + "/9th/orders");
+            response = AdapayCommon.requestAdapayUits(paymentParams);
+        } else {
+            response = Payment.create(paymentParams);
+            AdapayService.checkSuccess(response);
+        }
 
         switch (payChannel) {
             case "alipay_wap":
@@ -323,8 +332,9 @@ public class OrderService {
                 return MapUtils.getString(MapUtils.getMap(response, "expend"), "pay_info");
             case "alipay_qr":
                 return MapUtils.getString(MapUtils.getMap(response, "expend"), "qrcode_url");
+            default:
+                return MapUtils.getMap(response, "expend");
         }
-        return response;
     }
 
     public static BigDecimal divMoney(BigDecimal totalAmount, BigDecimal restAmount, List<Map<String, Object>> divMembers,

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

@@ -66,8 +66,8 @@ public class OrderPayController {
 
     @RequestMapping(value = "/weixin")
     @ResponseBody
-    public Object payOrderWeixin(@RequestParam Long id, @RequestParam String openId) throws WxPayException, EncoderException {
-        return orderService.payOrderWeixin(id, WxPayConstants.TradeType.JSAPI, openId);
+    public Object payOrderWeixin(@RequestParam Long id) throws BaseAdaPayException {
+        return orderService.payAdapay(id, "wx_lite", null);
     }
 
     @RequestMapping(value = "/weixin_pc")

+ 6 - 14
src/main/pc-space/src/components/PageHeader.vue

@@ -53,42 +53,34 @@ export default {
     },
     data() {
         return {
-            // tabs: ['铸造者', '收藏探索', '数字盲盒', '我的NFT', '了解更多'],
             active: '',
             show: false,
             activeName: '',
             lists: '',
-            // url: '/identityAuth/all',
             menus: [
                 {
                     label: '铸造者',
-                    value: '/casting',
-                    id: 1
+                    value: '/casting'
                 },
                 {
                     label: '收藏探索',
-                    value: '/collection',
-                    id: 2
+                    value: '/collection'
                 },
                 {
                     label: '数字盲盒',
-                    value: '/collection?type=BLIND_BOX',
-                    id: 3
+                    value: '/collection?type=BLIND_BOX'
                 },
                 {
                     label: '铸造商店',
-                    value: 'wait',
-                    id: 4
+                    value: 'wait'
                 },
                 {
                     label: '我的藏品',
-                    value: '/my',
-                    id: 5
+                    value: '/my'
                 },
                 {
                     label: '了解更多',
-                    value: 'wait',
-                    id: 6
+                    value: 'wait'
                 }
             ]
         };

+ 17 - 7
src/main/pc-space/src/views/Submit.vue

@@ -187,18 +187,19 @@ export default {
             gas: 0,
             id: 0,
             status: '',
+            payUrl: '',
             payUrl2: ''
         };
     },
     computed: {
         // 微信
-        payUrl() {
-            return resolveUrl(
-                this.$baseUrl,
-                'https://nfttest.9space.vip/wx/redirect?redirectUrl=https://nfttest.9space.vip/payOrder/weixin_pc?id=' +
-                    this.id
-            );
-        },
+        // payUrl() {
+        // return resolveUrl(
+        //     this.$baseUrl,
+        //     'https://nfttest.9space.vip/wx/redirect?redirectUrl=https://nfttest.9space.vip/payOrder/weixin?id=' +
+        //         this.id
+        // );
+        // },
         money() {
             let money = 0;
             if (this.info.price && !this.couponInfo) {
@@ -360,6 +361,15 @@ export default {
                             this.$router.replace('/collectionorder');
                         }, 1000);
                     }
+                    if (this.payMethods === 'WEIXIN') {
+                        this.$http
+                            .get('/payOrder/weixin', {
+                                id: res.id
+                            })
+                            .then(res => {
+                                this.payUrl = res.wx_h5_pay_url;
+                            });
+                    }
                     if (this.payMethods === 'ALIPAY') {
                         this.$http
                             .get('/payOrder/alipay_qr', {

+ 16 - 2
src/main/pc-space/src/views/user/Personal.vue

@@ -1,7 +1,7 @@
 <template>
     <div class="container center-content">
-        <!-- <div class="title">个人中心</div> -->
         <div class="content">
+            <!-- :default-active="NavActive" -->
             <el-menu
                 :default-openeds="openeds"
                 :collapse-transition="false"
@@ -49,9 +49,23 @@ export default {
         return {
             openeds: ['2'],
             uniqueOpened: false
+            // NavActive: ''
         };
     },
-    methods: {}
+    methods: {
+        handleSelect(index) {
+            this.NavActive = index;
+            console.log(this.NavActive);
+        }
+    }
+    // watch: {
+    //     $route(index) {
+    //         console.log(index);
+    //         let path = index.path;
+    //         // let path = index.path.substr(1);
+    //         this.handleSelect(path);
+    //     }
+    // }
 };
 </script>
 <style lang="less" scoped>

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

@@ -6,6 +6,7 @@ import com.huifu.adapay.core.exception.BaseAdaPayException;
 import com.huifu.adapay.model.AdapayCommon;
 import com.huifu.adapay.model.Payment;
 import com.izouma.nineth.ApplicationTests;
+import com.izouma.nineth.config.GeneralProperties;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -17,7 +18,9 @@ import java.util.Map;
 
 public class AdapayServiceTest extends ApplicationTests {
     @Autowired
-    private AdapayService adapayService;
+    private AdapayService     adapayService;
+    @Autowired
+    private GeneralProperties generalProperties;
 
     @Test
     public void testPay() throws BaseAdaPayException {
@@ -61,7 +64,7 @@ public class AdapayServiceTest extends ApplicationTests {
         params.put("goods_title", "Your goods_title");
         params.put("goods_desc", "Your goods_desc");
         params.put("description", "payment Discription");
-        params.put("callback_url", "http://localhost:8080/");
+        params.put("callback_url", generalProperties.getHost() + "/9th/orders");
         Map<String, Object> response = AdapayCommon.requestAdapayUits(params);
         System.out.println("payment result=" + JSON.toJSONString(response, SerializerFeature.PrettyFormat));
     }