ソースを参照

Merge branch 'zx_saas_goods' of http://git.dayaedu.com/yonge/mec into zx_saas_goods

刘俊驰 1 年間 前
コミット
ac509cfba4
21 ファイル変更249 行追加31 行削除
  1. 15 1
      mec-application/src/main/java/com/ym/mec/web/controller/APIController.java
  2. 2 1
      mec-application/src/main/java/com/ym/mec/web/controller/MusicGroupCalenderRefundPeriodController.java
  3. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java
  4. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupCalenderRefundPeriodDao.java
  5. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SellOrderDao.java
  6. 20 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CooperationCalenderRefundUpdateDto.java
  7. 6 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/GoodsWrapper.java
  8. 3 0
      mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java
  9. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupCalenderRefundPeriodService.java
  10. 3 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java
  11. 84 19
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java
  12. 15 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupCalenderRefundPeriodServiceImpl.java
  13. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  14. 7 0
      mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml
  15. 6 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupCalenderRefundPeriodMapper.xml
  16. 3 0
      mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml
  17. 9 0
      mec-client-api/src/main/java/com/ym/mec/web/WebFeignService.java
  18. 12 1
      mec-client-api/src/main/java/com/ym/mec/web/fallback/WebFeignServiceFallback.java
  19. 0 2
      mec-common/common-core/src/main/java/com/ym/mec/common/entity/GoodsSubModel.java
  20. 13 0
      mec-common/common-core/src/main/java/com/ym/mec/common/entity/GoodsSubStockModel.java
  21. 39 0
      mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/PmsProductServiceImpl.java

+ 15 - 1
mec-application/src/main/java/com/ym/mec/web/controller/APIController.java

@@ -12,6 +12,7 @@ import com.ym.mec.biz.service.*;
 import com.ym.mec.biz.service.impl.GoodsServiceImpl;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.GoodsSubModel;
+import com.ym.mec.common.entity.GoodsSubStockModel;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.MallCreateOrderModel;
 import com.ym.mec.common.entity.OrderCancelModel;
@@ -164,11 +165,17 @@ public class APIController extends BaseController {
 	// 商城支付成功/失败修改订单状态
 	@PostMapping("/updateOrder")
 	public HttpResponseResult updateOrder(@RequestBody Map map) throws Exception {
-
 		studentPaymentOrderService.updateOrder(map);
 		return succeed();
 	}
 
+	// 同步商城订单发货状态
+	@PostMapping("/updateShippedStatus")
+	public HttpResponseResult updateShippedStatus(@RequestParam String orderNo) throws Exception {
+		studentPaymentOrderService.updateShippedStatus(orderNo);
+		return succeed();
+	}
+
 
 	/**
 	 * 商城取消订单接口
@@ -235,8 +242,15 @@ public class APIController extends BaseController {
 		return succeed(balance);
 	}
 
+	// 组合商品状态同步
 	@PostMapping("/api/goodsStatusSynchronize")
 	public HttpResponseResult<Boolean> goodsStatusSynchronize(List<GoodsSubModel> goodsSubModelList) {
 		return succeed(goodsService.goodsStatusSynchronize(goodsSubModelList));
 	}
+
+	// 组合商品库存同步
+	@PostMapping("/api/goodsStockCountSynchronize")
+	public HttpResponseResult<Boolean> goodsStockCountSynchronize(List<GoodsSubStockModel> goodsSubStockModels) {
+		return succeed(goodsService.goodsStockCountSynchronize(goodsSubStockModels));
+	}
 }

+ 2 - 1
mec-application/src/main/java/com/ym/mec/web/controller/MusicGroupCalenderRefundPeriodController.java

@@ -1,6 +1,7 @@
 package com.ym.mec.web.controller;
 
 import com.ym.mec.biz.dal.dto.CooperationCalenderRefundDto;
+import com.ym.mec.biz.dal.dto.CooperationCalenderRefundUpdateDto;
 import com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod;
 import com.ym.mec.biz.dal.page.CooperationRefundQueryInfo;
 import com.ym.mec.biz.service.MusicGroupCalenderRefundPeriodService;
@@ -56,7 +57,7 @@ public class MusicGroupCalenderRefundPeriodController extends BaseController {
     @PostMapping("/batchUpdate")
     @PreAuthorize("@pcs.hasPermissions('musicGroupCalenderRefundPeriod/batchUpdate')")
     @AuditLogAnnotation(operateName = "批量修改")
-    public HttpResponseResult batchUpdate(@RequestBody List<MusicGroupCalenderRefundPeriod> refundPeriods) {
+    public HttpResponseResult batchUpdate(@RequestBody List<CooperationCalenderRefundUpdateDto> refundPeriods) {
         musicGroupCalenderRefundPeriodService.batchUpdate(refundPeriods);
         return succeed();
     }

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java

@@ -205,4 +205,5 @@ public interface GoodsDao extends BaseDAO<Integer, Goods> {
 
     void updateStatus(@Param("goodIdList") List<Integer> goodIdList, @Param("status") Boolean status);
 
+    void updateStock(@Param("goodsList") List<Goods> goodsList);
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupCalenderRefundPeriodDao.java

@@ -29,4 +29,6 @@ public interface MusicGroupCalenderRefundPeriodDao extends BaseDAO<Integer, Musi
     void deleteByCalenderId(@Param("calenderId") Long calenderId);
 
     void batchUpdate(@Param("refundPeriods") List<MusicGroupCalenderRefundPeriod> refundPeriods);
+
+    List<MusicGroupCalenderRefundPeriod> queryByIds(@Param("periodsIds") List<Long> periodsIds);
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SellOrderDao.java

@@ -241,4 +241,6 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
     List<Map<Long, String>> getMallProductMap(@Param("productIdList") Set<String> productIdList, @Param("database") String database);
 
     List<String> getMallProductCategory(@Param("database") String database);
+
+    void updateShippedStatus(@Param("orderNo") String orderNo);
 }

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CooperationCalenderRefundUpdateDto.java

@@ -0,0 +1,20 @@
+package com.ym.mec.biz.dal.dto;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class CooperationCalenderRefundUpdateDto {
+
+    @ApiModelProperty(value = "回款周期编号",required = false)
+    private Long id;
+
+    @ApiModelProperty(value = "回款金额",required = false)
+    private BigDecimal refundAmount;
+
+    @ApiModelProperty(value = "修改原因",required = false)
+    private String memo;
+}

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/GoodsWrapper.java

@@ -185,9 +185,15 @@ public class GoodsWrapper {
         @ApiModelProperty("商城商品编号")
         private Integer mallGoodsId;
 
+        @ApiModelProperty("商城商品名称")
+        private String mallGoodsName;
+
         @ApiModelProperty("sku编号")
         private Integer sku;
 
+        @ApiModelProperty("销售价格")
+        private BigDecimal price;
+
         @ApiModelProperty("商品状态,1:上架、0:下架")
         private Boolean goodsStatus;
 

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.page.GoodsQueryInfo;
 import com.ym.mec.biz.dal.wrapper.GoodsWrapper;
 import com.ym.mec.common.dto.PmsProductDto;
 import com.ym.mec.common.entity.GoodsSubModel;
+import com.ym.mec.common.entity.GoodsSubStockModel;
 import com.ym.mec.common.page.PageInfo;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -140,4 +141,6 @@ public interface GoodsService extends BaseService<Integer, Goods> {
     PageInfo<PmsProductDto> queryGoodsSubByPage(GoodsWrapper.GoodsSubQuery query);
 
     Boolean goodsStatusSynchronize(List<GoodsSubModel> goodsSubModelList);
+
+    Boolean goodsStockCountSynchronize(List<GoodsSubStockModel> goodsSubStockModels);
 }

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupCalenderRefundPeriodService.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.CooperationCalenderRefundDto;
+import com.ym.mec.biz.dal.dto.CooperationCalenderRefundUpdateDto;
 import com.ym.mec.biz.dal.dto.CooperationRefundDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentBaseCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupCalenderRefundPeriod;
@@ -36,5 +37,5 @@ public interface MusicGroupCalenderRefundPeriodService extends BaseService<Integ
     */
     Boolean calcRefundAmount(Long calenderId,String orderNo, BigDecimal amount);
 
-    void batchUpdate(List<MusicGroupCalenderRefundPeriod> refundPeriods);
+    void batchUpdate(List<CooperationCalenderRefundUpdateDto> refundPeriods);
 }

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -274,4 +274,7 @@ public interface StudentPaymentOrderService extends BaseService<Long, StudentPay
     BigDecimal balance(Long userId);
 
     List<OperatingTotalIncomeDto> queryOperatingSummaryIncome(Map<String, Object> params);
+
+    //商品已发货
+    void updateShippedStatus(String orderNo);
 }

+ 84 - 19
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -23,6 +23,7 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dto.PmsProductDto;
 import com.ym.mec.common.dto.PmsProductQueryParamDto;
 import com.ym.mec.common.entity.GoodsSubModel;
+import com.ym.mec.common.entity.GoodsSubStockModel;
 import com.ym.mec.common.entity.UploadReturnBean;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
@@ -56,6 +57,7 @@ import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -262,9 +264,9 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 					throw new BizException("{}等商品还在销售中", goodsNames);
 				}
 			}
-			List<GoodsSub> goodsSubs = queryGoodsSub(goodsId);
+			List<GoodsWrapper.GoodsSub> goodsSubs = queryGoodsSub(goodsId);
 			if (!CollectionUtils.isEmpty(goodsSubs) && status == 1) {
-				long falseSize = goodsSubs.stream().map(GoodsSub::getGoodsStatus).filter(Boolean.FALSE::equals).count();
+				long falseSize = goodsSubs.stream().map(GoodsWrapper.GoodsSub::getGoodsStatus).filter(Boolean.FALSE::equals).count();
 				if (falseSize > 0) {
 					throw new BizException("存在已下架的子商品");
 				}
@@ -283,12 +285,35 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		goodsDao.update(goods);
 	}
 
-	private List<GoodsSub> queryGoodsSub(Integer goodsId) {
+	private List<GoodsWrapper.GoodsSub> queryGoodsSub(Integer goodsId) {
 		// 从管乐迷商城组合的商品
 		QueryWrapper<GoodsSub> queryWrapper = new QueryWrapper<>();
 		queryWrapper.eq("goods_id_", goodsId);
 		List<GoodsSub> goodsSubs = goodsSubMapper.selectList(queryWrapper);
-		return goodsSubs;
+		List<GoodsWrapper.GoodsSub> goodsSubList = goodsSubs.stream().map(next -> {
+			GoodsWrapper.GoodsSub goodsSub = new GoodsWrapper.GoodsSub();
+			goodsSub.setGoodsId(goodsId);
+			goodsSub.setMallGoodsId(next.getMallGoodsId());
+			goodsSub.setGoodsStatus(next.getGoodsStatus());
+			goodsSub.setSku(next.getSku());
+			goodsSub.setGoodsPrice(next.getGoodsPrice());
+			return goodsSub;
+		}).collect(Collectors.toList());
+		if (!CollectionUtils.isEmpty(goodsSubList)) {
+			List<String> goodIdList = goodsSubList.stream().map(next -> next.getMallGoodsId().toString()).distinct().collect(Collectors.toList());
+			PmsProductQueryParamDto build = PmsProductQueryParamDto.builder()
+					.productIds(String.join(",", goodIdList))
+					.pageSize(9999)
+					.pageNum(1).build();
+			Map<String, PmsProductDto> map = mallFeignService.getProductList(build)
+					.getRows().stream().collect(Collectors.toMap(next -> next.getGoodsId() + "_" + next.getSkuStockId(), Function.identity()));
+			goodsSubList.forEach(next -> {
+				PmsProductDto orDefault = map.getOrDefault(next.getMallGoodsId() + "_" + next.getSku(), new PmsProductDto());
+				next.setPrice(orDefault.getPrice());
+				next.setMallGoodsName(orDefault.getName());
+			});
+		}
+		return goodsSubList;
 	}
 
 	@Override
@@ -781,10 +806,9 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		if(StringUtils.isNotEmpty(goods.getFreeFeeShowOrganId())){
 			goods.setFreeFeeShowOrganName(StringUtils.join(organizationDao.findByOrganIds(goods.getFreeFeeShowOrganId()),","));
 		}
-		List<GoodsSub> goodsSubs = queryGoodsSub(goodsId);
 		GoodsWrapper.Goods detail = new GoodsWrapper.Goods();
 		BeanUtils.copyProperties(goods, detail);
-		detail.setGoodsSubList(JSON.parseArray(JSON.toJSONString(goodsSubs), GoodsWrapper.GoodsSub.class));
+		detail.setGoodsSubList(queryGoodsSub(goodsId));
 		return detail;
 	}
 
@@ -849,32 +873,73 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		if (CollectionUtils.isEmpty(goodsSubModelList)) {
 			return false;
 		}
-		log.info("开始同步商品状态:" + JSON.toJSONString(goodsSubModelList));
+		log.info(Thread.currentThread().getName() + "开始同步商品状态:" + JSON.toJSONString(goodsSubModelList));
 		List<Integer> goodIds = goodsSubModelList.stream().map(GoodsSubModel::getMallGoodsId).distinct().collect(Collectors.toList());
-		List<Integer> skus = goodsSubModelList.stream().map(GoodsSubModel::getSku).distinct().collect(Collectors.toList());
 		QueryWrapper<GoodsSub> queryWrapper = new QueryWrapper<>();
-		queryWrapper.in("goods_id_", goodIds)
-				.in("sku_", skus);
+		queryWrapper.in("mall_goods_id_", goodIds);
 		List<GoodsSub> goodsSubs = goodsSubMapper.selectList(queryWrapper);
 		if (CollectionUtils.isEmpty(goodsSubs)) {
 			return true;
 		}
-		Map<String, Boolean> keyStatusMap = goodsSubModelList.stream().collect(Collectors.toMap(next -> next.getMallGoodsId() + "_" + next.getSku(), GoodsSubModel::getGoodsStatus));
-		Set<String> keys = keyStatusMap.keySet();
-		goodsSubs.removeIf(next -> !keys.contains(next.getMallGoodsId() + "_" + next.getSku()));
-		if (CollectionUtils.isEmpty(goodsSubs)) {
-			return true;
-		}
-		log.info("开始同步商品状态:0/" + goodsSubs.size());
-		List<GoodsSub> goodsSubList = goodsSubs.stream().peek(next -> next.setGoodsStatus(keyStatusMap.get(next.getMallGoodsId() + "_" + next.getSku()))).collect(Collectors.toList());
+		Map<Integer, Boolean> keyStatusMap = goodsSubModelList.stream().collect(Collectors.toMap(GoodsSubModel::getMallGoodsId, GoodsSubModel::getGoodsStatus));
+		log.info(Thread.currentThread().getName() + "开始同步商品状态:0/" + goodsSubs.size());
+		List<GoodsSub> goodsSubList = goodsSubs.stream().peek(next -> next.setGoodsStatus(keyStatusMap.get(next.getMallGoodsId()))).collect(Collectors.toList());
 		// 下架的商品
 		List<GoodsSub> downGoods = goodsSubList.stream().filter(next -> Boolean.FALSE.equals(next.getGoodsStatus())).collect(Collectors.toList());
 		if(!CollectionUtils.isEmpty(downGoods)){
 			List<Integer> goodIdList = downGoods.stream().map(GoodsSub::getGoodsId).distinct().collect(Collectors.toList());
 			goodsDao.updateStatus(goodIdList, false);
 		}
-		Map<Boolean, List<Integer>> listMap = goodsSubList.stream().collect(Collectors.groupingBy(GoodsSub::getGoodsStatus, Collectors.mapping(next -> next.getId(), Collectors.toList())));
+		Map<Boolean, List<Integer>> listMap = goodsSubList.stream().collect(Collectors.groupingBy(GoodsSub::getGoodsStatus, Collectors.mapping(GoodsSub::getId, Collectors.toList())));
 		listMap.forEach((key, values) -> goodsSubMapper.updateStatus(values, key));
+		log.info(Thread.currentThread().getName() + "同步商品状态完成");
+		return true;
+	}
+
+	/**
+	 * 同步组合商品库存
+	 * @param goodsSubStockModels 商品库存信息
+	 * @return true/false
+	 */
+	@Transactional(rollbackFor = Exception.class)
+	@Override
+	public Boolean goodsStockCountSynchronize(List<GoodsSubStockModel> goodsSubStockModels) {
+		if(goodsSubStockModels.isEmpty()){
+			return false;
+		}
+		List<Integer> mallGoodIds = goodsSubStockModels.stream().map(GoodsSubStockModel::getMallGoodsId).distinct().collect(Collectors.toList());
+		List<Integer> skus = goodsSubStockModels.stream().map(GoodsSubStockModel::getSku).distinct().collect(Collectors.toList());
+
+		QueryWrapper<GoodsSub> queryWrapper = new QueryWrapper<>();
+		queryWrapper.in("mall_goods_id_", mallGoodIds).in("sku_", skus);
+		List<GoodsSub> goodsSubs = goodsSubMapper.selectList(queryWrapper);
+		if (CollectionUtils.isEmpty(goodsSubs)) {
+			return true;
+		}
+		Map<String, Integer> stockMap = goodsSubStockModels.stream().collect(Collectors.toMap(next -> next.getMallGoodsId() + "_" + next.getSku(), next -> next.getStock()));
+		Set<String> keys = stockMap.keySet();
+		goodsSubs.removeIf(next -> !keys.contains(next.getMallGoodsId() + "_" + next.getSku()));
+		if (CollectionUtils.isEmpty(goodsSubs)) {
+			return true;
+		}
+		List<Integer> goodIds = goodsSubs.stream().map(GoodsSub::getGoodsId).distinct().collect(Collectors.toList());
+		goodsDao.lockGoods(goodIds);
+		List<Goods> goodsList = goodsDao.findGoodsByIds(goodIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
+		Map<Integer, Integer> goodStockMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, Goods::getStockCount));
+
+		List<Goods> updateGoods = new ArrayList<>();
+		for (GoodsSub goodsSub : goodsSubs) {
+			Integer goodsId = goodsSub.getGoodsId();
+			String key = goodsSub.getMallGoodsId() + "_" + goodsSub.getSku();
+			Integer stock = stockMap.get(key);
+			int updateStock = Math.min(goodStockMap.get(goodsId), stock);
+
+			Goods goods = new Goods();
+			goods.setId(goodsId);
+			goods.setStockCount(updateStock);
+			updateGoods.add(goods);
+		}
+		goodsDao.updateStock(updateGoods);
 		return true;
 	}
 }

+ 15 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupCalenderRefundPeriodServiceImpl.java

@@ -4,6 +4,7 @@ import com.ym.mec.biz.dal.dao.MusicGroupCalenderRefundPeriodDao;
 import com.ym.mec.biz.dal.dao.MusicGroupDao;
 import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.dto.CooperationCalenderRefundDto;
+import com.ym.mec.biz.dal.dto.CooperationCalenderRefundUpdateDto;
 import com.ym.mec.biz.dal.dto.CooperationRefundDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentBaseCalender;
 import com.ym.mec.biz.dal.entity.MusicGroup;
@@ -190,14 +191,22 @@ public class MusicGroupCalenderRefundPeriodServiceImpl extends BaseServiceImpl<I
     }
 
     @Override
-    public void batchUpdate(List<MusicGroupCalenderRefundPeriod> refundPeriods) {
-        refundPeriods.forEach(e->{
-            e.setIncome(null);
-            e.setRefundDate(null);
-            if (e.getSubRefundAmount() == null || e.getSubRefundAmount().compareTo(BigDecimal.ZERO) == 0) {
+    public void batchUpdate(List<CooperationCalenderRefundUpdateDto> refundPeriods) {
+        List<Long> periodsIds = refundPeriods.stream().map(e -> e.getId()).collect(Collectors.toList());
+        List<MusicGroupCalenderRefundPeriod> periods = musicGroupCalenderRefundPeriodDao.queryByIds(periodsIds);
+        Map<Long, CooperationCalenderRefundUpdateDto> periodMap = refundPeriods.stream().collect(Collectors.toMap(e -> e.getId(), e -> e));
+        periods.forEach(e->{
+            CooperationCalenderRefundUpdateDto dto = periodMap.get(e.getId());
+            e.setRefundAmount(dto.getRefundAmount());
+            e.setMemo(dto.getMemo());
+            if (e.getRefundAmount().compareTo(e.getIncome()) <= 0) {
+                e.setSubRefundAmount(BigDecimal.ZERO);
                 e.setRefundFlag(true);
+            } else {
+                e.setSubRefundAmount(e.getRefundAmount().subtract(e.getIncome()));
+                e.setRefundFlag(false);
             }
         });
-        musicGroupCalenderRefundPeriodDao.batchUpdate(refundPeriods);
+        musicGroupCalenderRefundPeriodDao.batchUpdate(periods);
     }
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -2201,6 +2201,11 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         return incomeDtos;
     }
 
+    @Override
+    public void updateShippedStatus(String orderNo) {
+        sellOrderDao.updateShippedStatus(orderNo);
+    }
+
     public BigDecimal getActualAmount(BigDecimal price, StudentPaymentOrderExportDto row) {
         if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
             return price.multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);

+ 7 - 0
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -593,4 +593,11 @@
             #{item}
         </foreach>
     </update>
+
+    <update id="updateStock">
+        <foreach collection="goodsList" item="goods" separator=";">
+        UPDATE goods set stock_count_ = #{goods.stockCount}
+            where id_ = #{goods.id}
+        </foreach>
+    </update>
 </mapper>

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupCalenderRefundPeriodMapper.xml

@@ -209,4 +209,10 @@
 		left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
 		<include refid="queryCoopRefundSql"/>
 	</select>
+	<select id="queryByIds" resultMap="MusicGroupCalenderRefundPeriod">
+		SELECT * FROM music_group_calender_refund_period WHERE id_ IN
+		<foreach collection="periodsIds" item="id" open="(" close=")" separator=",">
+			#{id}
+		</foreach>
+	</select>
 </mapper>

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -268,6 +268,9 @@
             where id_ = #{sellOrder.id} and tenant_id_ = #{sellOrder.tenantId}
         </foreach>
     </update>
+    <update id="updateShippedStatus">
+        update sell_order SET delivery_time_ = NOW() where order_no_ = #{orderNo}
+    </update>
 
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
         insert into sell_order (organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_,

+ 9 - 0
mec-client-api/src/main/java/com/ym/mec/web/WebFeignService.java

@@ -2,6 +2,7 @@ package com.ym.mec.web;
 
 import com.ym.mec.common.config.FeignConfiguration;
 import com.ym.mec.common.entity.GoodsSubModel;
+import com.ym.mec.common.entity.GoodsSubStockModel;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.MallCreateOrderModel;
 import com.ym.mec.common.entity.OrderCancelModel;
@@ -56,6 +57,10 @@ public interface WebFeignService {
 	@PostMapping("/api/updateOrder")
 	HttpResponseResult updateOrder(@RequestBody Map map);
 
+	//商城发货状态同步
+	@PostMapping("/api/updateShippedStatus")
+	HttpResponseResult updateShippedStatus(@RequestParam("orderNo") String orderNo);
+
 	@PostMapping("/api/cancelOrder")
 	HttpResponseResult<OrderCancelModel> cancelOrder(@RequestParam("orderNo") String orderNo,@RequestParam("reason") String reason);
 
@@ -87,4 +92,8 @@ public interface WebFeignService {
 	// 商城商品状态更新,同步商品状态
 	@PostMapping("/api/goodsStatusSynchronize")
 	HttpResponseResult<Boolean> goodsStatusSynchronize(@RequestBody List<GoodsSubModel> goodsSubModelList);
+
+	// 商城商品库存更新,同步商品库存
+	@PostMapping("/api/goodsStockCountSynchronize")
+	HttpResponseResult<Boolean> goodsStockCountSynchronize(List<GoodsSubStockModel> goodsSubStockModels);
 }

+ 12 - 1
mec-client-api/src/main/java/com/ym/mec/web/fallback/WebFeignServiceFallback.java

@@ -1,6 +1,7 @@
 package com.ym.mec.web.fallback;
 
 import com.ym.mec.common.entity.GoodsSubModel;
+import com.ym.mec.common.entity.GoodsSubStockModel;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.MallCreateOrderModel;
 import com.ym.mec.common.entity.OrderCancelModel;
@@ -75,7 +76,12 @@ public class WebFeignServiceFallback implements WebFeignService {
 		return null;
 	}
 
-	@Override
+    @Override
+    public HttpResponseResult updateShippedStatus(String orderNo) {
+        return null;
+    }
+
+    @Override
 	public HttpResponseResult<OrderCancelModel> cancelOrder(String orderNo, String reason) {
 		return null;
 	}
@@ -115,4 +121,9 @@ public class WebFeignServiceFallback implements WebFeignService {
 	public HttpResponseResult<Boolean> goodsStatusSynchronize(List<GoodsSubModel> goodsSubModelList) {
 		return null;
 	}
+
+	@Override
+	public HttpResponseResult<Boolean> goodsStockCountSynchronize(List<GoodsSubStockModel> goodsSubStockModels) {
+		return null;
+	}
 }

+ 0 - 2
mec-common/common-core/src/main/java/com/ym/mec/common/entity/GoodsSubModel.java

@@ -7,7 +7,5 @@ public class GoodsSubModel {
 
     private Integer mallGoodsId;
 
-    private Integer sku;
-
     private Boolean goodsStatus;
 }

+ 13 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/entity/GoodsSubStockModel.java

@@ -0,0 +1,13 @@
+package com.ym.mec.common.entity;
+
+import lombok.Data;
+
+@Data
+public class GoodsSubStockModel {
+
+    private Integer mallGoodsId;
+
+    private Integer sku;
+
+    private Integer stock;
+}

+ 39 - 0
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/PmsProductServiceImpl.java

@@ -2,7 +2,10 @@ package com.yonge.cooleshow.admin.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import com.github.pagehelper.PageHelper;
+import com.ym.mec.common.entity.GoodsSubModel;
+import com.ym.mec.common.entity.GoodsSubStockModel;
 import com.ym.mec.common.exception.BizException;
+import com.ym.mec.web.WebFeignService;
 import com.yonge.cooleshow.admin.dao.*;
 import com.yonge.cooleshow.admin.dao.*;
 import com.yonge.cooleshow.admin.dto.HomeStatistical;
@@ -16,9 +19,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
+import javax.annotation.Resource;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
@@ -66,6 +71,8 @@ public class PmsProductServiceImpl implements PmsProductService {
     private PmsProductDao productDao;
     @Autowired
     private PmsProductVertifyRecordDao productVertifyRecordDao;
+    @Resource
+    private WebFeignService webFeignService;
 
     @Override
     public int create(PmsProductParam productParam) {
@@ -254,6 +261,15 @@ public class PmsProductServiceImpl implements PmsProductService {
 
     @Override
     public int updatePublishStatus(List<Long> ids, Integer publishStatus) {
+        // 商品状态同步
+        List<GoodsSubModel> collect = ids.stream().map(next -> {
+            GoodsSubModel goodsSubModel = new GoodsSubModel();
+            goodsSubModel.setMallGoodsId(next.intValue());
+            goodsSubModel.setGoodsStatus(1 == publishStatus);
+            return goodsSubModel;
+        }).collect(Collectors.toList());
+        webFeignService.goodsStatusSynchronize(collect);
+
         PmsProduct record = new PmsProduct();
         record.setPublishStatus(publishStatus);
         PmsProductExample example = new PmsProductExample();
@@ -281,6 +297,29 @@ public class PmsProductServiceImpl implements PmsProductService {
 
     @Override
     public int updateDeleteStatus(List<Long> ids, Integer deleteStatus) {
+        if (1 == deleteStatus) {
+            List<GoodsSubModel> collect = ids.stream().map(next -> {
+                GoodsSubModel goodsSubModel = new GoodsSubModel();
+                goodsSubModel.setMallGoodsId(next.intValue());
+                goodsSubModel.setGoodsStatus(false);
+                return goodsSubModel;
+            }).collect(Collectors.toList());
+            webFeignService.goodsStatusSynchronize(collect);
+            // 更新库存
+            PmsSkuStockExample example = new PmsSkuStockExample();
+            example.createCriteria().andProductIdIn(ids);
+            List<PmsSkuStock> pmsSkuStocks = skuStockMapper.selectByExample(example);
+            if (!CollectionUtils.isEmpty(pmsSkuStocks)) {
+                List<GoodsSubStockModel> stockModels = pmsSkuStocks.stream().map(next -> {
+                    GoodsSubStockModel stockModel = new GoodsSubStockModel();
+                    stockModel.setMallGoodsId(next.getProductId().intValue());
+                    stockModel.setSku(next.getId().intValue());
+                    stockModel.setStock(0);
+                    return stockModel;
+                }).collect(Collectors.toList());
+                webFeignService.goodsStockCountSynchronize(stockModels);
+            }
+        }
         PmsProduct record = new PmsProduct();
         record.setDeleteStatus(deleteStatus);
         PmsProductExample example = new PmsProductExample();