|
@@ -30,6 +30,7 @@ import com.ym.mec.thirdparty.adapay.Payment;
|
|
|
import com.ym.mec.thirdparty.yqpay.*;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
+
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -43,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -84,6 +86,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
@Autowired
|
|
|
private GoodsDao goodsDao;
|
|
|
@Autowired
|
|
|
+ private GoodsService goodsService;
|
|
|
+ @Autowired
|
|
|
private StudentInstrumentService studentInstrumentService;
|
|
|
@Autowired
|
|
|
private ReplacementInstrumentActivityService replacementInstrumentActivityService;
|
|
@@ -109,6 +113,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
private SysUserFeignService sysUserFeignService;
|
|
|
@Autowired
|
|
|
private TenantConfigService tenantConfigService;
|
|
|
+ @Autowired
|
|
|
+ private GoodsProcurementDao goodsProcurementDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, StudentPaymentOrder> getDAO() {
|
|
@@ -793,6 +799,40 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
//处理关闭订单
|
|
|
order.setStatus(DealStatusEnum.CLOSE);
|
|
|
order.setMemo("关闭订单");
|
|
|
+
|
|
|
+ Date nowDate = new Date();
|
|
|
+ List<Goods> batchUpdateGoodsList = new ArrayList<Goods>();
|
|
|
+ //增加商品库存
|
|
|
+ List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(order.getId());
|
|
|
+ String goodsIds = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getMinuendStockGoodsIdList())).map(t -> t.getMinuendStockGoodsIdList()).collect(Collectors.joining(","));
|
|
|
+ if(StringUtils.isNotBlank(goodsIds)){
|
|
|
+ GoodsProcurement goodsProcurement = null;
|
|
|
+ List<GoodsProcurement> goodsProcurementList = new ArrayList<GoodsProcurement>();
|
|
|
+ List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIds);
|
|
|
+ for(Goods subGoods : goodsList){
|
|
|
+ subGoods.setStockCount(new AtomicInteger(subGoods.getStockCount()).incrementAndGet());
|
|
|
+ subGoods.setSellCount(new AtomicInteger(subGoods.getSellCount()).decrementAndGet());
|
|
|
+ subGoods.setUpdateTime(nowDate);
|
|
|
+ batchUpdateGoodsList.add(subGoods);
|
|
|
+
|
|
|
+ // 进货清单
|
|
|
+ goodsProcurement = goodsProcurementDao.getWithStockSurplusProcurement(subGoods.getId());
|
|
|
+ if(goodsProcurement != null){
|
|
|
+ goodsProcurement.setStockSoldNum(new AtomicInteger(goodsProcurement.getStockSoldNum()).decrementAndGet());
|
|
|
+ goodsProcurement.setUpdateTime(nowDate);
|
|
|
+ goodsProcurementList.add(goodsProcurement);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(goodsProcurementList.size() > 0){
|
|
|
+ goodsProcurementDao.batchUpdate(goodsProcurementList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(batchUpdateGoodsList.size() > 0){
|
|
|
+ goodsService.batchUpdate(batchUpdateGoodsList);
|
|
|
+ }
|
|
|
+
|
|
|
//如果是报名订单,订单关闭时需要更改已缴费学员数
|
|
|
cutSubjectPlan(order);
|
|
|
if (order.getBalancePaymentAmount() != null && order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|