admin
2024-07-09 1a43717440c8d112fc72b6344a5f6a26353ab56e
src/main/java/com/taoke/autopay/service/impl/KeyOrderServiceImpl.java
@@ -12,11 +12,14 @@
import com.taoke.autopay.service.KeyOrderService;
import com.taoke.autopay.service.WxUserOrderCountService;
import com.taoke.autopay.service.WxUserSettingService;
import com.taoke.autopay.utils.StringUtil;
import com.taoke.autopay.utils.TimeUtil;
import com.taoke.autopay.vo.SubmitKeyInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
/**
@@ -45,20 +48,23 @@
    @Transactional(rollbackFor = Exception.class)
    @Override
    public KeyOrder addKeyOrder(String key, Long uid, String day) throws KeyOrderException, WxOrderCountException {
    public KeyOrder addKeyOrder(SubmitKeyInfo keyInfo, Long uid, String day) throws KeyOrderException, WxOrderCountException {
        // 判断提交次数是否过量
        if (uid != null) {
            WxUserSettings settings = wxUserSettingService.selectByUid(uid);
            WxUserSettings settings = wxUserSettingService.getUserSettings(uid);
            wxUserOrderCountService.addOrderCount(uid, OrderCountTypeEnum.SUBMIT_TOKEN_COUNT, day, 1, settings.getTotalOrderCountPerDay());
        }
        String id = OrderFactory.createId(key);
        String id = OrderFactory.createId(keyInfo.getKey());
        KeyOrder order = keyOrderMapper.selectById(id);
        if (order != null) {
            throw new KeyOrderException("请勿重复提交口令");
        }
        order = new KeyOrder();
        order.setId(id);
        order.setKey(key);
        order.setKey(keyInfo.getKey());
        if(!StringUtil.isNullOrEmpty(keyInfo.getMoney())){
            order.setOrderMoney(new BigDecimal(keyInfo.getMoney()));
        }
        order.setUid(uid);
        order.setState(KeyOrder.STATE_NOT_PROCESS);
        order.setStateDesc("尚未处理");
@@ -139,8 +145,8 @@
    @Override
    public Long getCanDistributeUid() {
        // 最近1小时有活跃
        List<OrderDistributeCountInfo> list = keyOrderMapper.listDistributeUids(new Date(System.currentTimeMillis() - 1000 * 60 * 60L));
        // 最近1小时有活跃,且不算12以上未执行的数据
        List<OrderDistributeCountInfo> list = keyOrderMapper.listDistributeUids(new Date(System.currentTimeMillis() - 1000 * 60 * 60L),new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 12L));
        if (list == null || list.size() == 0) {
            return null;
        }