Browse Source

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

xuqiang 4 years ago
parent
commit
9045ca19ab

+ 2 - 0
src/main/java/com/izouma/nineth/repo/AssetRepo.java

@@ -24,4 +24,6 @@ public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationE
     List<Asset> findByCollectionIdAndStatusIn(Long collectionId, Iterable<AssetStatus> statuses);
 
     List<Asset> findByCreatedAtBefore(LocalDateTime localDateTime);
+
+    List<Asset> findByConsignmentTrue();
 }

+ 2 - 0
src/main/java/com/izouma/nineth/repo/UserBankCardRepo.java

@@ -8,4 +8,6 @@ import java.util.List;
 
 public interface UserBankCardRepo extends JpaRepository<UserBankCard, Long>, JpaSpecificationExecutor<UserBankCard> {
     List<UserBankCard> findByUserId(Long userId);
+
+    int deleteByUserId(Long userId);
 }

+ 21 - 9
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -276,23 +276,23 @@ public class OrderService {
         paymentParams.put("notify_url", adapayProperties.getNotifyUrl() + "/order/" + order.getId());
 
         List<Map<String, Object>> divMembers = new ArrayList<>();
-        BigDecimal restAmount = order.getTotalPrice().setScale(2, RoundingMode.HALF_UP);
+        BigDecimal totalAmount = order.getTotalPrice().subtract(order.getGasPrice());
+        BigDecimal restAmount = order.getTotalPrice().multiply(BigDecimal.valueOf(1));
 
         if (collection.getSource().equals(CollectionSource.TRANSFER)) {
             Asset asset = assetRepo.findById(collection.getAssetId()).orElseThrow(new BusinessException("无记录"));
             User owner = userRepo.findById(asset.getUserId()).orElseThrow(new BusinessException("拥有者用户不存在"));
-
-            restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, "0",
-                    collection.getServiceCharge() + collection.getRoyalties(), true);
-            restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, owner.getMemberId(),
-                    -1, false);
+            if (collection.getServiceCharge() + collection.getRoyalties() > 0) {
+                restAmount = divMoney(totalAmount, restAmount, divMembers, "0",
+                        collection.getServiceCharge() + collection.getRoyalties(), true);
+            }
+            restAmount = divMoney(restAmount, divMembers, owner.getMemberId(), restAmount, false);
         } else {
             if (invitor != null) {
-                restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, invitor.getMemberId(),
+                restAmount = divMoney(totalAmount, restAmount, divMembers, invitor.getMemberId(),
                         invitor.getShareRatio().intValue(), false);
             }
-            restAmount = divMoney(order.getTotalPrice(), restAmount, divMembers, "0",
-                    -1, true);
+            restAmount = divMoney(restAmount, divMembers, "0", restAmount, true);
         }
         if (divMembers.size() > 1) {
             paymentParams.put("div_members", JSON.toJSONString(divMembers));
@@ -354,6 +354,18 @@ public class OrderService {
         }
     }
 
+    public static BigDecimal divMoney(BigDecimal restAmount, List<Map<String, Object>> divMembers,
+                                      String memberId, BigDecimal divAmount, boolean feeFlag) {
+        if (divAmount.compareTo(BigDecimal.ZERO) > 0) {
+            Map<String, Object> divMem = new HashMap<>();
+            divMem.put("member_id", memberId);
+            divMem.put("amount", divAmount.toPlainString());
+            divMem.put("fee_flag", feeFlag ? "Y" : "N");
+            divMembers.add(divMem);
+        }
+        return restAmount.subtract(divAmount);
+    }
+
     @Transactional
     public void notifyOrder(Long orderId, PayMethod payMethod, String transactionId) {
         Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));

+ 1 - 0
src/main/java/com/izouma/nineth/service/UserService.java

@@ -447,6 +447,7 @@ public class UserService {
             adapayService.delSettleAccount(user.getMemberId(), user.getSettleAccountId());
             user.setSettleAccountId(null);
             userRepo.save(user);
+            userBankCardRepo.deleteByUserId(userId);
         } else {
             throw new BusinessException("未绑定");
         }

+ 4 - 0
src/main/java/com/izouma/nineth/service/sms/AliSmsService.java

@@ -43,6 +43,10 @@ public class AliSmsService implements SmsService {
 
     @Override
     public String sendVerify(String phone) {
+        if (smsSign.equals("身份验证")) {
+            accessKeyId = "LTAI5tEL3wr9XeiyseqKLrEK";
+            accessKeySecret = "I9JzOThjzeJMcpVf6melaMY3nt7ucU";
+        }
         smsRecordRepo.findLastByPhoneAndExpiresAtAfterAndExpiredFalse(phone, LocalDateTime.now()).ifPresent(record -> {
             if (record.getCreatedAt().plusMinutes(1L).isAfter(LocalDateTime.now())) {
                 long sec = record.getCreatedAt().plusMinutes(1L).toInstant(ZoneOffset.UTC)

+ 1 - 1
src/main/nine-space/.env.development

@@ -1 +1 @@
-VUE_APP_BASE_URL=http://192.168.50.120:8080
+VUE_APP_BASE_URL=https://nfttest.9space.vip/

+ 26 - 22
src/main/nine-space/src/components/Post.vue

@@ -2,12 +2,13 @@
     <div ref="share">
         <van-overlay :show="show" @click="show = false" z-index="99">
             <div class="wrapper">
-                <div class="img" ref="wrap">
-                    <img :src="img" v-if="img" alt="" />
+                <div class="img" ref="wrap" v-if="img" @click.stop="">
+                    <img :src="img" />
                 </div>
-                <div class="content" v-if="!img" ref="post" @click.stop>
+                <div class="content" v-if="!img" ref="post">
                     <!-- @load="loadImg" -->
-                    <img :src="detailImg" class="detailImg" />
+                    <img crossOrigin="anonymous" :src="banners" class="detailImg" />
+                    <!-- <van-image :src="detailImg" class="detailImg" fit="cover" /> -->
                     <div class="info">
                         <div class="name van-multi-ellipsis--l2">
                             {{ info.name }}
@@ -49,6 +50,7 @@ import html2canvas from 'html2canvas';
 import product from '../mixins/product';
 const path = require('path');
 import resolveUrl from 'resolve-url';
+import axios from 'axios';
 export default {
     mixins: [product],
     props: {
@@ -90,7 +92,7 @@ export default {
             }
         },
         banners() {
-            return this.getImg(this.changeImgs(this.info.pic || []), '', 1500);
+            return this.getImg(this.changeImgs(this.info.pic || []), '', 900);
         }
     },
     components: {
@@ -117,31 +119,33 @@ export default {
                     this.getImgBase64(this.info.minterAvatar, 'userImg');
                     setTimeout(() => {
                         this.loadImg();
-                    }, 100);
+                    }, 1000);
                 });
             }
         },
         loadImg() {
-            setTimeout(() => {
-                html2canvas(this.$refs.post, {
-                    useCORS: true,
-                    allowTaint: true,
-                    backgroundColor: null,
-                    scale: 3
-                }).then(canvas => {
-                    this.$toast.clear();
-                    // this.$refs.wrap.appendChild(canvas);
-                    this.img = canvas.toDataURL('image/png');
-                });
-            }, 100);
+            html2canvas(this.$refs.post, {
+                useCORS: true,
+                allowTaint: true,
+                backgroundColor: null,
+                scale: 3
+            }).then(canvas => {
+                this.$toast.clear();
+                console.log(canvas);
+                // this.$refs.wrap.appendChild(canvas);
+                this.img = canvas.toDataURL('image/png');
+            });
         },
         getImgBase64(img2, key) {
             let img = new Image();
-            img.src = img2;
-            img.setAttribute('crossOrigin', 'anonymous');
-            img.onload = () => {
-                this[key] = this.image2Base64(img);
+            img.crossOrigin = 'anonymous';
+            console.log(img);
+            let _this = this;
+            img.onload = function () {
+                let src = _this.image2Base64(img);
+                _this[key] = src;
             };
+            img.src = img2;
         },
         image2Base64(img) {
             let canvas = document.createElement('canvas');

+ 1 - 1
src/main/nine-space/src/main.js

@@ -56,7 +56,7 @@ http.http
             });
         });
     })
-    .catch(e => { });
+    .catch(e => {});
 
 createApp(App)
     .use(Vant)

+ 1 - 1
src/main/nine-space/src/mixins/product.js

@@ -56,7 +56,7 @@ export default {
             }
         },
         isSold() {
-            return this.info.sale === this.info.total
+            return this.info.sale === this.info.total;
         }
     },
     methods: {

+ 1 - 1
src/main/nine-space/src/views/Discover.vue

@@ -84,7 +84,7 @@
         <div class="box">
             <page-title title="更多藏品" :isLink="false"></page-title>
             <van-list
-                style="padding-bottom: 100px;"
+                style="padding-bottom: 100px"
                 class="box-list"
                 v-model:loading="loading"
                 :finished="finished"

+ 47 - 38
src/main/nine-space/src/views/Submit.vue

@@ -166,7 +166,7 @@ export default {
                             if (res.status === 'CANCELLED') {
                                 this.$router.back();
                             } else {
-                                this.$router.replace('/orderDetail?id' + res.id);
+                                this.$router.replace('/orderDetail?id=' + res.id);
                             }
                             // on close
                         });
@@ -212,14 +212,12 @@ export default {
                         this.$nextTick(() => {
                             if (this.payType === 'ALIPAY') {
                                 if (this.inWeixin) {
-                                    document.location.href = path.resolve(
-                                        this.$baseUrl,
-                                        '/payOrder/alipay_wx?id=' + res.id
-                                    );
+                                    window.open(path.resolve(this.$baseUrl, '/payOrder/alipay_wx?id=' + res.id));
                                 } else {
                                     this.$http
                                         .get(`/payOrder/${this.inApp ? 'alipay_app' : 'alipay_h5'}?id=${res.id}`)
                                         .then(res => {
+                                            this.$toast.clear();
                                             this.hrefUrl = 'alipays://platformapi/startapp?saId=10000007&qrcode=' + res;
                                             // window.open(
                                             //     'alipays://platformapi/startapp?saId=10000007&qrcode=' + res,
@@ -231,43 +229,54 @@ export default {
                                             if (!this.inApp) {
                                                 this.getOrder(true);
                                             }
+                                        })
+                                        .catch(e => {
+                                            if (e.error) {
+                                                this.$toast(e.error);
+                                            }
                                         });
                                 }
                             } else if (this.payType === 'WEIXIN') {
-                                if (this.inWeixin) {
-                                    this.$toast.loading('加载中');
-                                    this.$http
-                                        .post('/payOrder/weixin', {
-                                            id: res.id,
-                                            openId: localStorage.getItem('openId')
-                                        })
-                                        .then(res => {
-                                            console.log({
-                                                ...res,
-                                                package: res.package || res.packageValue
-                                            });
-                                            let _this = this;
-                                            wx.chooseWXPay({
-                                                ...res,
-                                                package: res.package || res.packageValue,
-                                                timestamp: res.timeStamp,
-                                                success(res) {
-                                                    _this.$toast.success('支付成功');
-                                                    setTimeout(() => {
-                                                        _this.$router.replace('/orders');
-                                                    }, 1000);
-                                                },
-                                                fail(e) {
-                                                    console.log(e);
-                                                    _this.$toast('支付失败,请稍后再试');
-                                                }
-                                            });
+                                this.$toast.loading('加载中');
+                                this.$http
+                                    .post('/payOrder/weixin', {
+                                        id: res.id
+                                    })
+                                    .then(res => {
+                                        this.$toast.clear();
+                                        this.hrefUrl = res.scheme_code;
+                                        this.$nextTick(() => {
+                                            document.getElementById('pay').click();
                                         });
-                                } else {
-                                    document.location.replace(
-                                        path.resolve(this.$baseUrl, 'payOrder/weixin_h5?id=' + res.id)
-                                    );
-                                }
+                                        if (this.inWeixin) {
+                                            this.getOrder(true);
+                                        }
+                                        // console.log({
+                                        //     ...res,
+                                        //     package: res.package || res.packageValue
+                                        // });
+                                        // let _this = this;
+                                        // wx.chooseWXPay({
+                                        //     ...res,
+                                        //     package: res.package || res.packageValue,
+                                        //     timestamp: res.timeStamp,
+                                        //     success(res) {
+                                        //         _this.$toast.success('支付成功');
+                                        //         setTimeout(() => {
+                                        //             _this.$router.replace('/orders');
+                                        //         }, 1000);
+                                        //     },
+                                        //     fail(e) {
+                                        //         console.log(e);
+                                        //         _this.$toast('支付失败,请稍后再试');
+                                        //     }
+                                        // });
+                                    })
+                                    .catch(e => {
+                                        if (e.error) {
+                                            this.$toast(e.error);
+                                        }
+                                    });
                             }
                         });
                     } else {

+ 2 - 2
src/main/nine-space/src/views/asset/Detail.vue

@@ -147,7 +147,7 @@
                     <div class="prive" v-if="init.length > 0">
                         <div class="prive1" :class="{ opened: item.opened }" v-for="(item, index) in init" :key="index">
                             <img v-if="!item.opened" class="img" :src="item.icon[0]" alt="" />
-                            <div style="margin-top: 4px;" v-if="item.icon[2]">
+                            <div style="margin-top: 4px" v-if="item.icon[2]">
                                 <img v-if="item.opened" class="img" :src="item.icon[2]" alt="" />
                             </div>
                             <!-- <img class="img" v-else :src="item.icon[0]" alt="" /> -->
@@ -194,7 +194,7 @@
                             <div class="text4">{{ item.createdAt.substr(0, 16) }}</div>
                         </div>
                     </div>
-                    <div v-else style="display: flex; justify-content: center;">暂无购买记录</div>
+                    <div v-else style="display: flex; justify-content: center">暂无购买记录</div>
                 </van-collapse-item>
             </van-collapse>
 

+ 5 - 3
src/main/nine-space/src/views/product/Detail.vue

@@ -250,6 +250,7 @@ import 'swiper/swiper.min.css';
 import 'swiper/swiper-bundle.min.css';
 
 import SwiperCore, { Pagination } from 'swiper';
+import Post from '../../components/Post.vue';
 
 SwiperCore.use([Pagination]);
 
@@ -261,7 +262,8 @@ export default {
         ProductTitle,
         ProductBanner,
         Swiper,
-        SwiperSlide
+        SwiperSlide,
+        Post
     },
     mixins: [product],
     data() {
@@ -524,7 +526,7 @@ export default {
             color: @text3;
             line-height: 20px;
             height: 20px;
-            background-color: #27272B;
+            background-color: #27272b;
             border-radius: 4px;
             padding: 0 10px;
 
@@ -545,7 +547,7 @@ export default {
                     }
                     &:last-child {
                         color: @prim;
-                        background-color: #27272B;
+                        background-color: #27272b;
                     }
                 }
 

+ 1 - 1
src/main/nine-space/src/views/user/Banks.vue

@@ -13,7 +13,7 @@
                     <div class="text1">{{ item.bankName }}</div>
                     <div class="text2">{{ getNum(item.bankNo) }}</div>
                 </div>
-                <div class="info2">{{ item.cardType }}</div>
+                <div class="info2">{{ item.cardTypeDesc }}</div>
             </div>
         </div>
     </div>

+ 7 - 2
src/test/java/com/izouma/nineth/service/AssetServiceTest.java

@@ -6,8 +6,6 @@ import com.izouma.nineth.repo.*;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import static org.junit.jupiter.api.Assertions.*;
-
 class AssetServiceTest extends ApplicationTests {
     @Autowired
     private OrderRepo         orderRepo;
@@ -65,4 +63,11 @@ class AssetServiceTest extends ApplicationTests {
     public void setHistory() {
         assetService.setHistory();
     }
+
+    @Test
+    public void cancelCon() {
+        for (Asset asset : assetRepo.findByConsignmentTrue()) {
+            assetService.cancelConsignment(asset.getId());
+        }
+    }
 }