Browse Source

Merge branch 'dev'

# Conflicts:
#	src/main/java/com/izouma/nineth/service/MintOrderService.java
xiongzhu 4 years ago
parent
commit
622038c355

+ 11 - 5
pom.xml

@@ -287,11 +287,11 @@
         </dependency>
         <!-- 钉钉 -->
 
-        <dependency>
-            <groupId>com.github.whvcse</groupId>
-            <artifactId>easy-captcha</artifactId>
-            <version>1.6.2</version>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>com.github.whvcse</groupId>-->
+<!--            <artifactId>easy-captcha</artifactId>-->
+<!--            <version>1.6.2</version>-->
+<!--        </dependency>-->
 
         <dependency>
             <groupId>org.libjpegturbo</groupId>
@@ -420,6 +420,12 @@
             <version>2.0.1</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.pig4cloud.plugin</groupId>
+            <artifactId>captcha-spring-boot-starter</artifactId>
+            <version>2.2.2</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 6 - 3
src/main/java/com/izouma/nineth/dto/RecommendDTO.java

@@ -4,11 +4,14 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.time.LocalDateTime;
+
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
 public class RecommendDTO {
-    private Integer sort;
-    private Object obj;
-    private String type;
+    private Integer       sort;
+    private Object        obj;
+    private String        type;
+    private LocalDateTime createdAt;
 }

+ 5 - 0
src/main/java/com/izouma/nineth/repo/CollectionRepo.java

@@ -4,6 +4,7 @@ import com.izouma.nineth.domain.Collection;
 import com.izouma.nineth.dto.CollectionInfoDTO;
 import com.izouma.nineth.dto.CollectionStockAndSale;
 import com.izouma.nineth.dto.RecommendCollection;
+import com.izouma.nineth.enums.CollectionSource;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.CachePut;
 import org.springframework.cache.annotation.Cacheable;
@@ -18,6 +19,7 @@ import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Optional;
+import java.util.Set;
 
 public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpecificationExecutor<Collection> {
     @Query("update Collection t set t.del = true where t.id = ?1")
@@ -148,5 +150,8 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
     @Query("select c.vipQuota from Collection c where c.id = ?1")
     Integer getVipQuota(Long id);
 
+    @Query("select c.assetId from Collection  c where c.price >= ?1 and c.source = ?2 and c.createdAt <= ?3 and c.salable = ?4")
+    Set<Long> findResaleCollectionPriceOver20K(BigDecimal price, CollectionSource source, LocalDateTime startTime, boolean salable);
+
     List<Collection> findAllByNameLike(String name);
 }

+ 6 - 0
src/main/java/com/izouma/nineth/repo/OrderRepo.java

@@ -55,4 +55,10 @@ public interface OrderRepo extends JpaRepository<Order, Long>, JpaSpecificationE
     List<Object[]> sumPrice();
 
     List<Order> findByCreatedAtBetweenAndSourceAndStatusIn(LocalDateTime start, LocalDateTime end, CollectionSource source, Collection<OrderStatus> statuses);
+
+    @Query(nativeQuery = true, value = "select o.user_id  from order_info o " +
+            " WHERE o.created_at < ?2 and o.created_at > ?1 and o.status = 'CANCELLED' " +
+            "GROUP BY o.user_id " +
+            "HAVING count(*) > 20")
+    List<Long> checkBlackList(LocalDateTime start, LocalDateTime end);
 }

+ 37 - 4
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -28,6 +28,7 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 import javax.persistence.criteria.Predicate;
@@ -59,10 +60,12 @@ public class AssetService {
 
 
     public Page<Asset> all(PageQuery pageQuery) {
-        Page<Asset> all = assetRepo.findAll(JpaUtils.toSpecification(pageQuery, Asset.class), JpaUtils.toPageRequest(pageQuery));
+        Page<Asset> all = assetRepo
+                .findAll(JpaUtils.toSpecification(pageQuery, Asset.class), JpaUtils.toPageRequest(pageQuery));
         Map<String, Object> query = pageQuery.getQuery();
         if (query.containsKey("userId")) {
-            List<Long> orderId = orderRepo.findAllByUserIdAndOpenedFalse(Convert.convert(Long.class, query.get("userId")));
+            List<Long> orderId = orderRepo
+                    .findAllByUserIdAndOpenedFalse(Convert.convert(Long.class, query.get("userId")));
             return all.map(asset -> {
                 if (orderId.contains(asset.getOrderId())) {
                     asset.setOpened(false);
@@ -426,10 +429,12 @@ public class AssetService {
 
     public Page<UserHistory> userHistory(Long userId, PageQuery pageQuery) {
         Page<TokenHistory> page = tokenHistoryRepo.findAll(((root, criteriaQuery, criteriaBuilder) -> {
-            List<Predicate> and = JpaUtils.toPredicates(pageQuery, TokenHistory.class, root, criteriaQuery, criteriaBuilder);
+            List<Predicate> and = JpaUtils
+                    .toPredicates(pageQuery, TokenHistory.class, root, criteriaQuery, criteriaBuilder);
             Map<String, Object> query = pageQuery.getQuery();
             if (ObjectUtils.isEmpty(query.get("toUserId")) && ObjectUtils.isEmpty(query.get("fromUserId"))) {
-                and.add(criteriaBuilder.or(criteriaBuilder.equal(root.get("toUserId"), userId), criteriaBuilder.equal(root.get("fromUserId"), userId)));
+                and.add(criteriaBuilder.or(criteriaBuilder.equal(root.get("toUserId"), userId), criteriaBuilder
+                        .equal(root.get("fromUserId"), userId)));
             } else {
                 if (ObjectUtils.isNotEmpty(query.get("toUserId"))) {
                     and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("toUserId"), userId)));
@@ -527,4 +532,32 @@ public class AssetService {
         return url.replaceAll("https://raex-meta\\.oss-cn-shenzhen\\.aliyuncs\\.com",
                 "https://cdn.raex.vip");
     }
+
+
+    @Scheduled(cron = "0 0 0/1 * * ?")
+    public void offTheShelf() {
+        LocalDateTime lastTime = LocalDateTime.now().minusHours(120);
+        Set<Long> assetIds = collectionRepo
+                .findResaleCollectionPriceOver20K(BigDecimal
+                        .valueOf(20000L), CollectionSource.TRANSFER, lastTime, true);
+        assetIds.forEach(this::cancelConsignmentBySystem);
+    }
+
+
+    public void cancelConsignmentBySystem(Long id) {
+        Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+        if (asset.getPublicCollectionId() != null) {
+            List<Order> orders = orderRepo.findByCollectionId(asset.getPublicCollectionId());
+            if (orders.stream().anyMatch(o -> o.getStatus() != OrderStatus.CANCELLED)) {
+                throw new BusinessException("已有订单不可取消");
+            }
+            collectionRepo.findById(asset.getPublicCollectionId())
+                    .ifPresent(collection -> {
+                        collection.setSalable(false);
+                        collectionRepo.save(collection);
+                    });
+        }
+        asset.setConsignment(false);
+        assetRepo.save(asset);
+    }
 }

+ 16 - 5
src/main/java/com/izouma/nineth/service/CaptchaService.java

@@ -1,7 +1,7 @@
 package com.izouma.nineth.service;
 
 import com.izouma.nineth.dto.Captcha;
-import com.wf.captcha.SpecCaptcha;
+import com.pig4cloud.captcha.ArithmeticCaptcha;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.ehcache.UserManagedCache;
@@ -24,10 +24,21 @@ public class CaptchaService {
 
     public Captcha gen() throws IOException, FontFormatException {
         String key = UUID.randomUUID().toString();
-        SpecCaptcha specCaptcha = new SpecCaptcha(90 * 2, 32 * 2, 5);
-        specCaptcha.setFont(com.wf.captcha.base.Captcha.FONT_7, 24 * 2);
-        String code = specCaptcha.text().toLowerCase();
-        String image = specCaptcha.toBase64();
+//        SpecCaptcha specCaptcha = new SpecCaptcha(90 * 2, 32 * 2, 5);
+//        specCaptcha.setFont(com.wf.captcha.base.Captcha.FONT_7, 24 * 2);
+//        String code = specCaptcha.text().toLowerCase();
+//        String image = specCaptcha.toBase64();
+//        captchaCache.put(key, code);
+
+        // 算术类型
+        ArithmeticCaptcha captcha = new ArithmeticCaptcha(130, 48);
+        captcha.setFont(com.pig4cloud.captcha.base.Captcha.FONT_7, 24 * 2);
+        captcha.setLen(2);  // 几位数运算,默认是两位
+        captcha.getArithmeticString();  // 获取运算的公式:3+2=?
+        captcha.supportAlgorithmSign(2); // 可设置支持的算法:2 表示只生成带加减法的公式
+        captcha.setDifficulty(99); // 设置计算难度,参与计算的每一个整数的最大值
+        String code = captcha.text();  // 获取运算的结果:5
+        String image = captcha.toBase64();  // 输出验证码
         captchaCache.put(key, code);
         return new Captcha(key, image);
     }

+ 28 - 26
src/main/java/com/izouma/nineth/service/MintOrderService.java

@@ -102,7 +102,6 @@ public class MintOrderService {
         MintOrder order = mintOrderRepo.save(MintOrder.builder()
                 .userId(userId)
                 .phone(user.getPhone())
-//                .material(materials)
                 .consume(true)
                 .status(MintOrderStatus.AIR_DROP)
                 .build());
@@ -158,21 +157,25 @@ public class MintOrderService {
      */
 //    @Transactional
     public MintOrder create(User user, List<Long> assetId, Long mintActivityId, Long addressId) {
-        try {
-
-            // 参加的活动
-            MintActivity mintActivity = mintActivityRepo.findByIdAndDelFalse(mintActivityId)
-                    .orElseThrow(new BusinessException("无此铸造活动"));
+        // 参加的活动
+        MintActivity mintActivity = mintActivityRepo.findByIdAndDelFalse(mintActivityId)
+                .orElseThrow(new BusinessException("无此铸造活动"));
 
-            if (mintActivity.isScheduleSale()) {
-                if (mintActivity.getStartTime().isAfter(LocalDateTime.now())) {
-                    throw new BusinessException("当前还未开售");
-                }
-            }
-            if (!mintActivity.isOnShelf()) {
-                throw new BusinessException("活动已下架");
+        if (mintActivity.isScheduleSale()) {
+            if (mintActivity.getStartTime().isAfter(LocalDateTime.now())) {
+                throw new BusinessException("当前还未开售");
             }
+        }
+        if (!mintActivity.isOnShelf()) {
+            throw new BusinessException("活动已下架");
+        }
 
+        UserAddress userAddress = null;
+        if (addressId != null) {
+            userAddress = userAddressRepo.findById(addressId).orElseThrow(new BusinessException("地址信息不存在"));
+        }
+
+        try {
             int stock = Optional.ofNullable(mintActivityService.decreaseStock(mintActivityId, 1))
                     .map(Math::toIntExact)
                     .orElseThrow(new BusinessException("很遗憾,铸造活动已无库存"));
@@ -235,13 +238,16 @@ public class MintOrderService {
                     assetRepo.save(asset);
                 });
             } else {
+                // 转让的用户
+                userRepo.findByIdAndDelFalse(1435297L).orElseThrow(new BusinessException("无法铸造"));
+
                 // 消耗改为转赠
                 assets.forEach(asset -> {
+                    if (!asset.getUserId().equals(user.getId())) {
+                        throw new BusinessException("此藏品不属于你");
+                    }
                     // 取消公开展示
                     if (asset.isPublicShow()) {
-                        if (!asset.getUserId().equals(user.getId())) {
-                            throw new BusinessException("此藏品不属于你");
-                        }
                         if (asset.isConsignment()) {
                             if (asset.getPublicCollectionId() != null) {
                                 List<Order> orders = orderRepo.findByCollectionId(asset.getPublicCollectionId());
@@ -256,21 +262,21 @@ public class MintOrderService {
                         collectionRepo.delete(collection);
                         // 如果展厅有此藏品
                         showCollectionRepo.deleteAllByCollectionId(asset.getPublicCollectionId());
+                    }
+
+                });
 
+                // 统一处理
+                assets.forEach(asset -> {
+                    if (asset.isPublicShow()) {
                         asset.setPublicShow(false);
                         asset.setPublicCollectionId(null);
                     }
                     asset.setStatus(AssetStatus.MINTING);
                     assetRepo.save(asset);
                 });
-                // 转让的用户
-                userRepo.findByIdAndDelFalse(1435297L).orElseThrow(new BusinessException("无法铸造"));
             }
 
-            UserAddress userAddress = null;
-            if (addressId != null) {
-                userAddress = userAddressRepo.findById(addressId).orElseThrow(new BusinessException("地址信息不存在"));
-            }
 
             // 铸造订单
             MintOrder mintOrder = mintOrderRepo.save(MintOrder.builder()
@@ -304,8 +310,6 @@ public class MintOrderService {
 
             mintMaterialRepo.saveAll(materials);
 
-            //销量
-//        mintActivityService.increaseSale(mintActivityId, 1);
             if (mintOrder.getGasPrice().compareTo(BigDecimal.ZERO) == 0) {
                 this.mintNotify(mintOrder.getId(), PayMethod.WEIXIN, null);
             }
@@ -543,12 +547,10 @@ public class MintOrderService {
 
             // 加库存
             mintActivityService.increaseStock(order.getMintActivityId(), 1);
-//        mintActivityService.decreaseSale(order.getMintActivityId(), 1);
 
             rocketMQTemplate.syncSend(generalProperties.getUpdateStockTopic(), order.getMintActivityId(), 10000);
             log.info("取消订单{}", order.getId());
         } catch (Exception e) {
-            mintActivityService.decreaseStock(order.getMintActivityId(), 1);
             log.error("订单取消错误 orderId: " + order.getId(), e);
         }
         releaseOrderLock(order.getId());

+ 41 - 13
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -63,7 +63,9 @@ import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.Duration;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
@@ -215,9 +217,11 @@ public class OrderService {
             if (collection.getMaxCount() > 0) {
                 int count;
                 if (StringUtils.isNotBlank(collection.getCountId())) {
-                    count = orderRepo.countByUserIdAndCountIdAndStatusIn(userId, collection.getCountId(), Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
+                    count = orderRepo.countByUserIdAndCountIdAndStatusIn(userId, collection.getCountId(), Arrays
+                            .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
                 } else {
-                    count = orderRepo.countByUserIdAndCollectionIdAndStatusIn(userId, collectionId, Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
+                    count = orderRepo.countByUserIdAndCollectionIdAndStatusIn(userId, collectionId, Arrays
+                            .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
                 }
                 if (count >= collection.getMaxCount()) {
                     throw new BusinessException("限购" + collection.getMaxCount() + "件");
@@ -247,7 +251,9 @@ public class OrderService {
                 }
 
                 if (vip) {
-                    int purchase = orderRepo.countByUserIdAndCollectionIdAndVipTrueAndStatusIn(userId, collectionId, Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
+                    int purchase = orderRepo
+                            .countByUserIdAndCollectionIdAndVipTrueAndStatusIn(userId, collectionId, Arrays
+                                    .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
                     if (user.getVipPurchase() - purchase <= 0) {
                         throw new BusinessException("vip名额已使用完毕!");
                     }
@@ -293,7 +299,8 @@ public class OrderService {
                     .contactName(Optional.ofNullable(userAddress).map(UserAddress::getName).orElse(null))
                     .contactPhone(Optional.ofNullable(userAddress).map(UserAddress::getPhone).orElse(null))
                     .address(Optional.ofNullable(userAddress).map(u ->
-                                    u.getProvinceName() + " " + u.getCityName() + " " + u.getDistrictName() + " " + u.getAddress())
+                            u.getProvinceName() + " " + u.getCityName() + " " + u.getDistrictName() + " " + u
+                                    .getAddress())
                             .orElse(null))
                     .status(OrderStatus.NOT_PAID)
                     .assetId(collection.getAssetId())
@@ -476,7 +483,8 @@ public class OrderService {
         paymentParams.put("goods_desc", collection.getName());
         paymentParams.put("time_expire", DateTimeFormatter.ofPattern("yyyyMMddHHmmss")
                 .format(LocalDateTime.now().plusMinutes(3)));
-        paymentParams.put("notify_url", adapayProperties.getNotifyUrl() + "/order/" + adapayProperties.getMerchant() + "/" + order.getId());
+        paymentParams.put("notify_url", adapayProperties.getNotifyUrl() + "/order/" + adapayProperties
+                .getMerchant() + "/" + order.getId());
 
         List<Map<String, Object>> divMembers = new ArrayList<>();
         BigDecimal totalAmount = order.getTotalPrice().subtract(order.getGasPrice());
@@ -541,7 +549,8 @@ public class OrderService {
             case "alipay_qr":
                 return MapUtils.getString(MapUtils.getMap(response, "expend"), "qrcode_url");
             case "wx_pub":
-                JSONObject payParams = JSON.parseObject(MapUtils.getString(MapUtils.getMap(response, "expend"), "pay_info"));
+                JSONObject payParams = JSON
+                        .parseObject(MapUtils.getString(MapUtils.getMap(response, "expend"), "pay_info"));
                 payParams.put("timestamp", payParams.get("timeStamp"));
                 payParams.remove("timeStamp");
                 return payParams;
@@ -625,7 +634,8 @@ public class OrderService {
                         orderRepo.save(order);
                         throw new BusinessException("抽卡失败, 已退款 " + orderId);
                     }
-                    log.info("抽卡成功 orderId: {}, collectionId: {}, winCollectionId: {}", orderId, collection.getId(), winItem.getCollectionId());
+                    log.info("抽卡成功 orderId: {}, collectionId: {}, winCollectionId: {}", orderId, collection
+                            .getId(), winItem.getCollectionId());
                     order.setWinCollectionId(winItem.getCollectionId());
                     orderRepo.save(order);
 
@@ -667,7 +677,8 @@ public class OrderService {
 //                            }
 //                        }
                         Asset asset = assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售",
-                                collection.getTotal() > 1 ? collectionService.getNextNumber(order.getCollectionId()) : null);
+                                collection.getTotal() > 1 ? collectionService
+                                        .getNextNumber(order.getCollectionId()) : null);
 
                         if (collection.getType() == CollectionType.SHOWROOM) {
                             showroomService.save(asset);
@@ -922,9 +933,12 @@ public class OrderService {
     }
 
     public void calcSettle(LocalDateTime start, LocalDateTime end, OutputStream outputStream) {
-        List<Order> orders = orderRepo.findByCreatedAtBetweenAndSourceAndStatusIn(start, end, CollectionSource.TRANSFER, Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH));
+        List<Order> orders = orderRepo
+                .findByCreatedAtBetweenAndSourceAndStatusIn(start, end, CollectionSource.TRANSFER, Arrays
+                        .asList(OrderStatus.PROCESSING, OrderStatus.FINISH));
         List<Asset> assets = assetRepo.findAllById(orders.stream().map(Order::getAssetId).collect(Collectors.toSet()));
-        List<UserBankCard> bankCards = userBankCardRepo.findByUserIdIn(assets.stream().map(Asset::getUserId).collect(Collectors.toSet()));
+        List<UserBankCard> bankCards = userBankCardRepo
+                .findByUserIdIn(assets.stream().map(Asset::getUserId).collect(Collectors.toSet()));
         List<MarketSettlement> settlements = new ArrayList<>();
         for (Order order : orders) {
             BigDecimal amount = order.getTotalPrice()
@@ -934,10 +948,13 @@ public class OrderService {
                             .subtract(BigDecimal.valueOf(order.getRoyalties()))
                             .divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP))
                     .setScale(2, RoundingMode.HALF_UP);
-            Long userId = assets.stream().filter(a -> a.getId().equals(order.getAssetId())).map(Asset::getUserId).findAny().orElse(null);
+            Long userId = assets.stream().filter(a -> a.getId().equals(order.getAssetId())).map(Asset::getUserId)
+                    .findAny().orElse(null);
             if (userId != null) {
-                UserBankCard userBankCard = bankCards.stream().filter(b -> b.getUserId().equals(userId)).findAny().orElse(null);
-                MarketSettlement marketSettlement = settlements.stream().filter(s -> s.getUserId().equals(userId)).findAny().orElse(null);
+                UserBankCard userBankCard = bankCards.stream().filter(b -> b.getUserId().equals(userId)).findAny()
+                        .orElse(null);
+                MarketSettlement marketSettlement = settlements.stream().filter(s -> s.getUserId().equals(userId))
+                        .findAny().orElse(null);
                 if (marketSettlement == null) {
                     marketSettlement = new MarketSettlement(userId,
                             Optional.ofNullable(userBankCard).map(UserBankCard::getRealName).orElse(null),
@@ -952,4 +969,15 @@ public class OrderService {
         }
         EasyExcel.write(outputStream, MarketSettlement.class).sheet("sheet").doWrite(settlements);
     }
+
+    @Scheduled(cron = "0 0/10 * * * ?")
+    public void setBlackList() {
+        List<Long> userIds = orderRepo
+                .checkBlackList(LocalDate.now().atStartOfDay(), LocalDate.now().atTime(LocalTime.MAX));
+        userIds.forEach(userId -> {
+            redisTemplate.opsForValue().set(RedisKeys.BLACK_LIST + userId, 1, Duration.ofSeconds(60 * 120));
+        });
+
+    }
+
 }

+ 30 - 0
src/main/java/com/izouma/nineth/service/SandPayService.java

@@ -4,10 +4,13 @@ import cn.com.sandpay.cashier.sdk.*;
 import com.alibaba.fastjson.JSONObject;
 import com.izouma.nineth.config.SandPayProperties;
 import com.izouma.nineth.domain.GiftOrder;
+import com.izouma.nineth.domain.MintOrder;
 import com.izouma.nineth.domain.Order;
+import com.izouma.nineth.enums.MintOrderStatus;
 import com.izouma.nineth.enums.OrderStatus;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.GiftOrderRepo;
+import com.izouma.nineth.repo.MintOrderRepo;
 import com.izouma.nineth.repo.OrderRepo;
 import com.izouma.nineth.utils.DateTimeUtils;
 import lombok.AllArgsConstructor;
@@ -37,6 +40,7 @@ public class SandPayService {
     private final OrderRepo         orderRepo;
     private final GiftOrderRepo     giftOrderRepo;
     private final SandPayProperties sandPayProperties;
+    private final MintOrderRepo     mintOrderRepo;
 
     public JSONObject requestServer(JSONObject header, JSONObject body, String reqAddr) {
 
@@ -201,4 +205,30 @@ public class SandPayService {
 
         return res.getJSONObject("body").getString("qrCode");
     }
+
+    @Cacheable(value = "sandPay", key = "#orderId")
+    public String payMintOrder(Long orderId) {
+        MintOrder order = mintOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
+        if (order.getStatus() != MintOrderStatus.NOT_PAID) {
+            throw new BusinessException("订单状态错误");
+        }
+        JSONObject extend = new JSONObject();
+        extend.put("type", "mintOrder");
+        extend.put("id", orderId);
+
+        JSONObject res = requestAlipay(orderId.toString(), order.getGasPrice(), "铸造活动:" + order.getMintActivityId(),
+                "铸造活动:" + order.getMintActivityId(), order.getCreatedAt().plusMinutes(3), extend.toJSONString());
+        if (res == null)
+            throw new BusinessException("下单失败,请稍后再试");
+
+        if (!"000000".equals(res.getJSONObject("head").getString("respCode"))) {
+            String msg = res.getJSONObject("head").getString("respMsg");
+            if (msg.contains("超限")) {
+                throw new BusinessException("超过商户单日额度");
+            }
+            throw new BusinessException(msg);
+        }
+
+        return res.getJSONObject("body").getString("qrCode");
+    }
 }

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

@@ -559,15 +559,15 @@ public class UserService {
         }
         smsService.verify(phone, code);
 
-//        adapayMerchantService.createMemberForAll(userId.toString(), user.getPhone(), identityAuth.getRealName(), identityAuth.getIdNo());
-//        user.setMemberId(user.getId().toString());
-//        save(user);
-
-//        String accountId = adapayMerchantService.createSettleAccountForAll
-//                (user.getMemberId(), identityAuth.getRealName(),
-//                        identityAuth.getIdNo(), phone, bankNo);
-//        user.setSettleAccountId(Optional.ofNullable(accountId).orElse("1"));
-//        save(user);
+        adapayMerchantService.createMemberForAll(userId.toString(), user.getPhone(), identityAuth.getRealName(), identityAuth.getIdNo());
+        user.setMemberId(user.getId().toString());
+        save(user);
+
+        String accountId = adapayMerchantService.createSettleAccountForAll
+                (user.getMemberId(), identityAuth.getRealName(),
+                        identityAuth.getIdNo(), phone, bankNo);
+        user.setSettleAccountId(Optional.ofNullable(accountId).orElse("1"));
+        save(user);
 
         user.setSettleAccountId("1");
         save(user);

+ 5 - 3
src/main/java/com/izouma/nineth/web/CollectionController.java

@@ -64,7 +64,7 @@ public class CollectionController extends BaseController {
     @PostMapping("/create")
     public Collection create(@RequestBody CollectionInfoDTO record) {
         Collection collection = new Collection();
-        BeanUtils.copyProperties(record,collection);
+        BeanUtils.copyProperties(record, collection);
         collection = collectionService.create(collection);
         CollectionPrivilege collectionPrivilege = new CollectionPrivilege();
         BeanUtils.copyProperties(record, collectionPrivilege);
@@ -176,14 +176,16 @@ public class CollectionController extends BaseController {
             collectionDTO.setPrivileges(null);
             collectionDTO.setProperties(null);
 
-            return new RecommendDTO(rc.getRecommend().getSort(), collectionDTO, "collection");
+            return new RecommendDTO(rc.getRecommend().getSort(), collectionDTO, "collection", rc.getRecommend()
+                    .getCreatedAt());
         }).collect(Collectors.toList());
 
         List<RecommendDTO> news = newsRepo.recommend("LIST").stream().map(rn -> {
             if (StringUtils.isNotBlank(rn.getRecommend().getPic())) {
                 rn.getNews().setPic(rn.getRecommend().getPic());
             }
-            return new RecommendDTO(rn.getRecommend().getSort(), rn.getNews(), "news");
+            return new RecommendDTO(rn.getRecommend().getSort(), rn.getNews(), "news", rn.getRecommend()
+                    .getCreatedAt());
         }).collect(Collectors.toList());
 
         recommedDTOS.addAll(collectionDTOS);

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

@@ -93,8 +93,8 @@ public class IdentityAuthController extends BaseController {
     }
 
     @PostMapping("/my")
-    public String my(){
-        return identityAuthRepo.findFirstByUserId(SecurityUtils.getAuthenticatedUser().getId()).getStatus().toString();
+    public IdentityAuth my(){
+        return identityAuthRepo.findFirstByUserId(SecurityUtils.getAuthenticatedUser().getId());
     }
 }
 

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

@@ -109,7 +109,7 @@ public class OrderPayController {
     @RequestMapping(value = "/gift/alipay_wx", method = RequestMethod.GET)
     public String payGiftOrderAlipayWx(Long id, Model model) throws BaseAdaPayException {
 //        String payUrl = (String) giftOrderService.payAdapay(id, "alipay_wap", null);
-        String payUrl = sandPayService.payGiftOrder(id);;
+        String payUrl = sandPayService.payGiftOrder(id);
         model.addAttribute("payUrl", payUrl);
         model.addAttribute("orderId", id);
         return "AlipayHtml";
@@ -152,12 +152,14 @@ public class OrderPayController {
     @RequestMapping(value = "/mint/alipay_h5", method = RequestMethod.GET)
     @ResponseBody
     public String payMintOrderAlipayH5(Long id, Model model) throws BaseAdaPayException {
-        return (String) mintOrderService.payAdapay(id, "alipay_wap", null);
+//        return (String) mintOrderService.payAdapay(id, "alipay_wap", null);
+        return sandPayService.payMintOrder(id);
     }
 
     @RequestMapping(value = "/mint/alipay_wx", method = RequestMethod.GET)
     public String payMintOrderAlipayWx(Long id, Model model) throws BaseAdaPayException {
-        String payUrl = (String) mintOrderService.payAdapay(id, "alipay_wap", null);
+//        String payUrl = (String) mintOrderService.payAdapay(id, "alipay_wap", null);
+        String payUrl = sandPayService.payMintOrder(id);
         model.addAttribute("payUrl", payUrl);
         model.addAttribute("orderId", id);
         return "AlipayHtml2";

+ 4 - 0
src/main/java/com/izouma/nineth/web/SandPayController.java

@@ -7,6 +7,7 @@ import com.izouma.nineth.config.GeneralProperties;
 import com.izouma.nineth.enums.PayMethod;
 import com.izouma.nineth.event.OrderNotifyEvent;
 import com.izouma.nineth.service.GiftOrderService;
+import com.izouma.nineth.service.MintOrderService;
 import com.izouma.nineth.service.OrderService;
 import com.izouma.nineth.service.SandPayService;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
@@ -36,6 +37,7 @@ public class SandPayController {
     private GeneralProperties generalProperties;
     private RocketMQTemplate  rocketMQTemplate;
     private GiftOrderService  giftOrderService;
+    private MintOrderService  mintOrderService;
 
     @GetMapping(value = "/testpay", produces = "text/html")
     private String testpay() {
@@ -83,6 +85,8 @@ public class SandPayController {
                             case "gift":
                                 giftOrderService.giftNotify(id, PayMethod.ALIPAY, payOrderCode);
                                 break;
+                            case "mintOrder":
+                                mintOrderService.mintNotify(id, PayMethod.ALIPAY, payOrderCode);
                         }
                     }
                     return "respCode=000000";

+ 13 - 1
src/main/java/com/izouma/nineth/web/SmsController.java

@@ -2,6 +2,7 @@ package com.izouma.nineth.web;
 
 import com.izouma.nineth.config.Constants;
 import com.izouma.nineth.exception.BusinessException;
+import com.izouma.nineth.service.CaptchaService;
 import com.izouma.nineth.service.sms.SmsService;
 import lombok.AllArgsConstructor;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -16,16 +17,27 @@ import java.util.regex.Pattern;
 @RequestMapping("/sms")
 @AllArgsConstructor
 public class SmsController {
-    private SmsService                    smsService;
+    private SmsService     smsService;
+    private CaptchaService captchaService;
 
     @GetMapping("/sendVerify")
     public String sendVerify(@RequestParam String phone) {
+        //throw new BusinessException("此接口已停用,请重启APP或刷新网页");
         if (!Pattern.matches(Constants.Regex.PHONE, phone)) {
             throw new BusinessException("请输入正确的手机号");
         }
         return smsService.sendVerify(phone);
     }
 
+    @GetMapping("/sendSecureVerify")
+    public String sendVerify(@RequestParam String phone, @RequestParam String captcha, @RequestParam String captchaKey) {
+        if (!Pattern.matches(Constants.Regex.PHONE, phone)) {
+            throw new BusinessException("请输入正确的手机号");
+        }
+        captchaService.verify(captchaKey, captcha);
+        return smsService.sendVerify(phone);
+    }
+
     @GetMapping("/verify")
     public String verify(@RequestParam String phone, @RequestParam String code) throws SmsService.SmsVerifyException {
         return smsService.verify(phone, code);

+ 1 - 1
src/main/vue/src/views/AdminList.vue

@@ -71,7 +71,7 @@ export default {
         return {
             multipleMode: false,
             search: '',
-            url: '/user/all',
+            url: '/user/adminAll',
             downloading: false
         };
     },