|
|
@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -53,6 +54,8 @@ public class UserInvoiceApplyRecordServiceImpl implements UserInvoiceApplyRecord
|
|
|
|
|
|
private final VipOrderDonMapper vipOrderDonMapper;
|
|
|
|
|
|
+ private static final long CODEX_INVOICE_WAIT_MILLIS = 7 * Constant.DAY_MILLS;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
public Long applyOrderInvoice(UserInvoiceOrderReq req) {
|
|
|
@@ -95,8 +98,10 @@ public class UserInvoiceApplyRecordServiceImpl implements UserInvoiceApplyRecord
|
|
|
.in(OrderDon::getId, orderIds)
|
|
|
.in(OrderDon::getUserId, userIdList)
|
|
|
.notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
- .select(OrderDon::getId, OrderDon::getMoney, OrderDon::getShopId));
|
|
|
+ .select(OrderDon::getId, OrderDon::getMoney, OrderDon::getShopId,
|
|
|
+ OrderDon::getGoodsId, OrderDon::getPayTime, OrderDon::getCreatedTime));
|
|
|
for (OrderDon o : orderDonList) {
|
|
|
+ checkCodexInvoiceTime(o.getGoodsId(), o.getPayTime(), o.getCreatedTime());
|
|
|
invoiceApplyRecord.setMoney(invoiceApplyRecord.getMoney().add(o.getMoney()));
|
|
|
shopIdSet.add(o.getShopId());
|
|
|
}
|
|
|
@@ -106,8 +111,10 @@ public class UserInvoiceApplyRecordServiceImpl implements UserInvoiceApplyRecord
|
|
|
.in(UpgradeOrderDon::getId, orderIds)
|
|
|
.in(UpgradeOrderDon::getUserId, userIdList)
|
|
|
.notIn(UpgradeOrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
- .select(UpgradeOrderDon::getId, UpgradeOrderDon::getMoney, UpgradeOrderDon::getShopId));
|
|
|
+ .select(UpgradeOrderDon::getId, UpgradeOrderDon::getMoney, UpgradeOrderDon::getShopId,
|
|
|
+ UpgradeOrderDon::getGoodsId, UpgradeOrderDon::getPayTime, UpgradeOrderDon::getCreatedTime));
|
|
|
for (UpgradeOrderDon o : upgradeOrderDons) {
|
|
|
+ checkCodexInvoiceTime(o.getGoodsId(), o.getPayTime(), o.getCreatedTime());
|
|
|
invoiceApplyRecord.setMoney(invoiceApplyRecord.getMoney().add(o.getMoney()));
|
|
|
shopIdSet.add(o.getShopId());
|
|
|
}
|
|
|
@@ -160,4 +167,14 @@ public class UserInvoiceApplyRecordServiceImpl implements UserInvoiceApplyRecord
|
|
|
redisService.del(key);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void checkCodexInvoiceTime(Long goodsId, Date payTime, Date createdTime) {
|
|
|
+ if (!Constant.CODEX_GOODS_ID.equals(goodsId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Date purchaseTime = payTime == null ? createdTime : payTime;
|
|
|
+ if (purchaseTime == null || System.currentTimeMillis() - purchaseTime.getTime() < CODEX_INVOICE_WAIT_MILLIS) {
|
|
|
+ throw BusinessRuntimeException.getInstance("Codex包月API订单购买满7天后才可申请开票");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|