Browse Source

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

刘俊驰 1 year ago
parent
commit
e4b68ce6b2

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderAddress.java

@@ -58,6 +58,10 @@ public class MusicGroupPaymentCalenderAddress implements Serializable {
     @ApiModelProperty(value = "详细地址")
     private String address;
 
+    @TableField("delivery_detail_")
+    @ApiModelProperty(value = "商品发货明细,用于同步订单的发货信息")
+    private String deliveryDetail;
+
     @TableField("create_time_")
     @ApiModelProperty(value = "创建时间")
     private Date createTime;

+ 4 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -29,6 +29,7 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.mall.MallFeignService;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
@@ -491,7 +492,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         Organization organization = organizationDao.get(musicGroup.getOrganId());
         sendSeoMessageSource.sendSeoMessage(musicGroup.getOrganId(), new SysUserRoleEnum[]{ORGAN_MANAGER},
                 null, null, MessageTypeEnum.BACKSTAGE_PAYMENT_CALENDER_AUDIT, organization.getName(), musicGroup.getName());
-        
+        TenantContextHolder.setTenantId(organization.getTenantId());
         if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT && musicGroupPaymentCalender.getStatus() != AUDITING ){
             addStudent(musicGroupPaymentCalender, musicGroup);
             //将0元未缴费学员缴费状态更新为已缴费
@@ -513,6 +514,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         }
         ModelMap map = new ModelMap(1);
         map.put("musicGroupPaymentCalenderBatchNo", batchNo);
+        TenantContextHolder.clearTenantId();
         return BaseController.succeed(map);
     }
 
@@ -1003,7 +1005,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         Date date = new Date();
         for (String batchNo : split) {
             List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
-            if (musicGroupPaymentCalenders == null || musicGroupPaymentCalenders.size() == 0) {
+            if (CollectionUtils.isEmpty(musicGroupPaymentCalenders)) {
                 throw new BizException("缴费项目不存在");
             }
             MusicGroupPaymentCalender calender = musicGroupPaymentCalenders.get(0);

+ 4 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java

@@ -3,7 +3,10 @@ package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dao.GoodsDao;
+import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
+import com.ym.mec.biz.dal.dao.SysCouponCodeDao;
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
@@ -33,8 +36,6 @@ public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, Studen
     @Autowired
     private StudentGoodsSellDao studentGoodsSellDao;
     @Autowired
-    private SysConfigDao sysConfigDao;
-    @Autowired
     private SysTenantConfigService sysTenantConfigService;
     @Autowired
     private TenantInfoService tenantInfoService;

+ 74 - 69
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -19,6 +19,7 @@ import java.util.Optional;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.entity.OrderSkuSync;
 import org.apache.commons.collections.CollectionUtils;
@@ -56,21 +57,6 @@ import com.ym.mec.biz.dal.dto.SporadicChargeInfoDto;
 import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
-import com.ym.mec.biz.dal.entity.ActivityUserMapper;
-import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
-import com.ym.mec.biz.dal.entity.Goods;
-import com.ym.mec.biz.dal.entity.GoodsProcurement;
-import com.ym.mec.biz.dal.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
-import com.ym.mec.biz.dal.entity.SellOrder;
-import com.ym.mec.biz.dal.entity.StudentGoodsSell;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
-import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
-import com.ym.mec.biz.dal.entity.StudentRegistration;
-import com.ym.mec.biz.dal.entity.SysUserCashAccount;
-import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
-import com.ym.mec.biz.dal.entity.VipGroupActivity;
 import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
@@ -115,92 +101,101 @@ import com.ym.mec.thirdparty.yqpay.YqPayUtil;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 
+import javax.annotation.Resource;
+
 @Service
 public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, StudentPaymentOrder> implements StudentPaymentOrderService {
 
-    @Autowired
+    @Resource
     private StudentPaymentOrderDao studentPaymentOrderDao;
-    @Autowired
+    @Resource
     private YqPayFeignService yqPayFeignService;
-    @Autowired
+    @Resource
     private StudentRegistrationService studentRegistrationService;
-    @Autowired
+    @Resource
     @Lazy
     private VipGroupService vipGroupService;
-    @Autowired
+    @Resource
     private MusicGroupService musicGroupService;
-    @Autowired
+    @Resource
     private SporadicChargeInfoService sporadicChargeInfoService;
-    @Autowired
+    @Resource
     private PracticeGroupService practiceGroupService;
-    @Autowired
+    @Resource
     private SysUserCashAccountDao sysUserCashAccountDao;
-    @Autowired
+    @Resource
     private StudentRepairService studentRepairService;
-    @Autowired
+    @Resource
     private SysUserCashAccountService sysUserCashAccountService;
-    @Autowired
+    @Resource
     private SubjectChangeService subjectChangeService;
-    @Autowired
+    @Resource
     private DegreeRegistrationService degreeRegistrationService;
-    @Autowired
+    @Resource
     private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
-    @Autowired
+    @Resource
     private IdGeneratorService idGeneratorService;
-    @Autowired
+    @Resource
     private SysConfigDao sysConfigDao;
-    @Autowired
+    @Resource
     private GoodsDao goodsDao;
-    @Autowired
+    @Resource
     private GoodsService goodsService;
-    @Autowired
+    @Resource
     private StudentInstrumentService studentInstrumentService;
-    @Autowired
+    @Resource
     private ReplacementInstrumentActivityService replacementInstrumentActivityService;
-    @Autowired
+    @Resource
     private ChildrenDayReserveService childrenDayReserveService;
-    @Autowired
+    @Resource
     private MemberRankSettingService memberRankSettingService;
-    @Autowired
+    @Resource
     private PayService payService;
-    @Autowired
+    @Resource
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
-    @Autowired
+    @Resource
     private CloudTeacherOrderService cloudTeacherOrderService;
-    @Autowired
+    @Resource
     private SysCouponCodeService sysCouponCodeService;
-    @Autowired
+    @Resource
     private VipGroupActivityService vipGroupActivityService;
-    @Autowired
+    @Resource
     private ActivityUserMapperService activityUserMapperService;
-    @Autowired
+    @Resource
     private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
-    @Autowired
+    @Resource
     private SysUserFeignService sysUserFeignService;
-    @Autowired
+    @Resource
     private TenantConfigService tenantConfigService;
-    @Autowired
+    @Resource
     private GoodsProcurementDao goodsProcurementDao;
-    @Autowired
+    @Resource
     private SysPaymentConfigService sysPaymentConfigService;
-    @Autowired
+    @Resource
     private SellOrderDao sellOrderDao;
     @Lazy
-    @Autowired
+    @Resource
     private ContractService contractService;
-    @Autowired
+    @Resource
     private HfMerchantConfigService hfMerchantConfigService;
-    @Autowired
+    @Resource
     private StudentDao studentDao;
-    @Autowired
+    @Resource
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
-    
-    @Autowired
+    @Resource
     private YeepayPaymentService yeepayPaymentService;
-    @Autowired
+    @Resource
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
+    @Resource
+    private MusicGroupPaymentCalenderAddressService musicGroupPaymentCalenderAddressService;
+    @Resource
+    private StudentRepairDao studentRepairDao;
+    @Resource
+    private MusicGroupDao musicGroupDao;
+    @Resource
+    private StudentGoodsSellDao studentGoodsSellDao;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
     @Override
@@ -1305,14 +1300,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         return studentPaymentOrderDao.getMemberIngOrder(member, status);
     }
 
-    @Autowired
-    private StudentRepairDao studentRepairDao;
-    @Autowired
-    private MusicGroupDao musicGroupDao;
-
-    @Autowired
-    private StudentGoodsSellDao studentGoodsSellDao;
-
     @Override
     @Transactional
     public Map createOrder(MallCreateOrderModel model) throws Exception {
@@ -2218,9 +2205,27 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             return;
         }
         List<String> orderNos = orderSkuSyncs.stream().map(e -> e.getOrderNo()).collect(Collectors.toList());
+        Map<String, List<OrderSkuSync.SkuSync>> skuMap = orderSkuSyncs.stream().collect(Collectors.toMap(OrderSkuSync::getOrderNo, OrderSkuSync::getSkuSyncList));
         List<SellOrder> sellOrders = sellOrderDao.queryByOrganNos(orderNos);
+        //检查学校商品采购订单
+        List<MusicGroupPaymentCalenderAddress> calenderAddresses = musicGroupPaymentCalenderAddressService.lambdaQuery().
+                in(MusicGroupPaymentCalenderAddress::getOrderNo, orderNos).
+                eq(MusicGroupPaymentCalenderAddress::getDeliveryFlag, false).list();
+        if (CollectionUtils.isNotEmpty(calenderAddresses)) {
+            Map<String, MusicGroupPaymentCalenderAddress> addressMap = calenderAddresses.stream().
+                    collect(Collectors.toMap(MusicGroupPaymentCalenderAddress::getOrderNo, e -> e));
+            List<String> addressOrders = calenderAddresses.stream().map(MusicGroupPaymentCalenderAddress::getOrderNo).collect(Collectors.toList());
+            for (String addressOrder : addressOrders) {
+                MusicGroupPaymentCalenderAddress address = addressMap.get(addressOrder);
+                address.setDeliveryDetail(JSON.toJSONString(skuMap.get(addressOrder)));
+                address.setDeliveryFlag(true);
+            }
+            musicGroupPaymentCalenderAddressService.updateBatchById(calenderAddresses);
+            //如果有审核通过的外部订单,更新对应的商品信息
+
+        }
         if (CollectionUtils.isEmpty(sellOrders)) {
-            throw new BizException("订单不存在");
+            return;
         }
         sellOrders = sellOrders.stream().filter(e -> e.getDeliveryTime() == null).collect(Collectors.toList());
         if(CollectionUtils.isEmpty(sellOrders)){
@@ -2234,10 +2239,10 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                 continue;
             }
             //获取sku平均成本价
-            Map<Long,List<OrderSkuSync.SkuSync>> skuMap = orderSkuSync.getSkuSyncList().stream().collect(Collectors.groupingBy(OrderSkuSync.SkuSync::getSku));
-            Map<Long,BigDecimal> costMap = new HashMap<>(skuMap.keySet().size());
-            for (Long skuId : skuMap.keySet()) {
-                List<OrderSkuSync.SkuSync> skuSyncs = skuMap.get(skuId);
+            Map<Long,List<OrderSkuSync.SkuSync>> skuDetailMap = orderSkuSync.getSkuSyncList().stream().collect(Collectors.groupingBy(OrderSkuSync.SkuSync::getSku));
+            Map<Long,BigDecimal> costMap = new HashMap<>(skuDetailMap.keySet().size());
+            for (Long skuId : skuDetailMap.keySet()) {
+                List<OrderSkuSync.SkuSync> skuSyncs = skuDetailMap.get(skuId);
                 //汇总成本价
                 BigDecimal costPrice = skuSyncs.stream().map(e -> e.getPrice().multiply(new BigDecimal(e.getCount()))).reduce(BigDecimal.ZERO, BigDecimal::add);
                 //获取总数