|
@@ -13,6 +13,7 @@ import com.zhongshu.reward.server.core.dao.WalletReceiptsDao;
|
|
import com.zhongshu.reward.server.core.domain.Wallet;
|
|
import com.zhongshu.reward.server.core.domain.Wallet;
|
|
import com.zhongshu.reward.server.core.domain.WalletReceipts;
|
|
import com.zhongshu.reward.server.core.domain.WalletReceipts;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
import org.jetbrains.annotations.Nullable;
|
|
@@ -23,7 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author wjf
|
|
* @author wjf
|
|
@@ -48,6 +48,7 @@ public class GoodsReceiptsService {
|
|
@Autowired
|
|
@Autowired
|
|
OrderService2 orderService2;
|
|
OrderService2 orderService2;
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 购物返利 todo// 1、获取产品库 返利规则 2、获取订单详情、获取商品详情
|
|
* 购物返利 todo// 1、获取产品库 返利规则 2、获取订单详情、获取商品详情
|
|
*/
|
|
*/
|
|
@@ -126,6 +127,10 @@ public class GoodsReceiptsService {
|
|
@Transactional
|
|
@Transactional
|
|
public void cancel(String orderNo, String payGoodsId, Long operateTime){
|
|
public void cancel(String orderNo, String payGoodsId, Long operateTime){
|
|
WalletReceipts walletReceipts = walletReceiptsDao.findByOutTradeNoAndPaymentGoodsIdAndStatus(orderNo, payGoodsId, ReceiptsStatus.WAIT);
|
|
WalletReceipts walletReceipts = walletReceiptsDao.findByOutTradeNoAndPaymentGoodsIdAndStatus(orderNo, payGoodsId, ReceiptsStatus.WAIT);
|
|
|
|
+ if (ObjectUtils.isEmpty(walletReceipts)){
|
|
|
|
+ log.info("无购物返利订单:{}", payGoodsId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
if (operateTime > walletReceipts.getEstimatedTime()){
|
|
if (operateTime > walletReceipts.getEstimatedTime()){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -140,12 +145,14 @@ public class GoodsReceiptsService {
|
|
@Transactional
|
|
@Transactional
|
|
public void settle(){
|
|
public void settle(){
|
|
//todo 查询到期入账的订单
|
|
//todo 查询到期入账的订单
|
|
- WalletReceipts walletReceipts = walletReceiptsDao.findTop1ById("");
|
|
|
|
-
|
|
|
|
- walletReceipts.setReceiptsTime(new Date().getTime());
|
|
|
|
- walletReceipts.setStatus(ReceiptsStatus.RECEIPTS);
|
|
|
|
- walletReceiptsDao.save(walletReceipts);
|
|
|
|
- walletDao.updateIncWaitAmount(walletReceipts.getWallet().getId(), walletReceipts.getTotal().negate());
|
|
|
|
- walletDao.updateIncAmount(walletReceipts.getWallet().getId(), walletReceipts.getTotal());
|
|
|
|
|
|
+ List<WalletReceipts> waitSettle = walletReceiptsDao.findByWaitSettle(ReceiptsStatus.WAIT, ReceiptsType.REBATE, new Date().getTime());
|
|
|
|
+ waitSettle.forEach(walletReceipts->{
|
|
|
|
+ walletReceipts.setReceiptsTime(new Date().getTime());
|
|
|
|
+ walletReceipts.setStatus(ReceiptsStatus.RECEIPTS);
|
|
|
|
+ walletReceiptsDao.save(walletReceipts);
|
|
|
|
+ walletDao.updateIncWaitAmount(walletReceipts.getWallet().getId(), walletReceipts.getTotal().negate());
|
|
|
|
+ walletDao.updateIncAmount(walletReceipts.getWallet().getId(), walletReceipts.getTotal());
|
|
|
|
+ log.info("结算商品返利:{}", walletReceipts.getId());
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|