Sfoglia il codice sorgente

管乐迷商城改造

zouxuan 1 anno fa
parent
commit
c8f2e8ab86

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

@@ -98,4 +98,6 @@ public interface StudentPaymentRouteOrderDao extends BaseDAO<Long, StudentPaymen
     FeeFlagNumDto getCountFeeFlagNum(@Param("orderNo") String orderNo);
 
     List<FeeFlagNumDto> queryCountFeeFlagNum(@Param("orderNos") List<String> orderNos);
+
+    List<StudentPaymentRouteOrder> queryByOrderNos(@Param("outOrderNos") List<String> outOrderNos);
 }

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

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service;
 import java.util.List;
 import java.util.Map;
 
+import com.ym.mec.biz.dal.dao.GoodsDao;
 import com.ym.mec.biz.dal.page.GoodsQueryInfo;
 import com.ym.mec.biz.dal.wrapper.GoodsWrapper;
 import com.ym.mec.common.dto.BrandDto;
@@ -24,12 +25,12 @@ import com.ym.mec.common.service.BaseService;
 
 public interface GoodsService extends BaseService<Integer, Goods> {
 
+    GoodsDao getGoodsDao();
+
     List<Goods> exportGoods(GoodsQueryInfo queryInfo);
 
     void addGoods(List<GoodsWrapper.Goods> goodsList, Integer operatorId);
 
-//    void addGoodsProcurement(GoodsProcurement goodsProcurement);
-
     /**
      * @describe 更新商品状态
      * @author Joburgess

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysUserCashAccountService.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
 import com.ym.mec.biz.dal.dto.PayParamBasicDto;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.SysUserCashAccount;
@@ -9,6 +10,7 @@ import com.ym.mec.common.service.BaseService;
 import java.math.BigDecimal;
 
 public interface SysUserCashAccountService extends BaseService<Integer, SysUserCashAccount> {
+	SysUserCashAccountDao getDao();
 
 	/**
 	 * 更新指定用户的账户余额

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -89,6 +89,10 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		return goodsDao;
 	}
 
+	public GoodsDao getGoodsDao() {
+		return goodsDao;
+	}
+
 	@Override
 	public List<Goods> exportGoods(GoodsQueryInfo queryInfo) {
 		Map<String, Object> params = new HashMap<String, Object>();

+ 32 - 23
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -51,6 +51,7 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.enums.DealStatusEnum.CLOSE;
@@ -75,8 +76,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     @Resource
     private PracticeGroupService practiceGroupService;
     @Resource
-    private SysUserCashAccountDao sysUserCashAccountDao;
-    @Resource
     private StudentRepairService studentRepairService;
     @Resource
     private SysUserCashAccountService sysUserCashAccountService;
@@ -85,16 +84,12 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     @Resource
     private DegreeRegistrationService degreeRegistrationService;
     @Resource
-    private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
-    @Resource
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
     @Resource
     private IdGeneratorService idGeneratorService;
     @Resource
     private SysConfigDao sysConfigDao;
     @Resource
-    private GoodsDao goodsDao;
-    @Resource
     private GoodsService goodsService;
     @Resource
     private StudentInstrumentService studentInstrumentService;
@@ -147,8 +142,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     private MusicGroupDao musicGroupDao;
     @Resource
     private StudentGoodsSellDao studentGoodsSellDao;
-
-    @Autowired
+    @Resource
     private StudentPaymentOrderService studentPaymentOrderService;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -502,7 +496,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         
         HfMerchantConfig hfMerchantConfig = null;
         
-        List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderDao.getRouteOrders(order.getOrderNo());
+        List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderService.getDao().getRouteOrders(order.getOrderNo());
         
         PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(order.getPaymentChannel());
         
@@ -540,7 +534,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                     LOGGER.info("分账信息返回:{}", map);
                     routeOrder.setServiceFee(new BigDecimal(map.get("fee_amt").toString()));
                     routeOrder.setUpdateTime(date);
-                    studentPaymentRouteOrderDao.update(routeOrder);
+                    studentPaymentRouteOrderService.getDao().update(routeOrder);
                 } catch (Exception e) {
                 	LOGGER.error("分账失败 orderId:{}", order.getId(), e);
                     continue;
@@ -598,7 +592,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 
 			for (StudentPaymentRouteOrder spro : routeOrders) {
 
-				studentPaymentRouteOrderDao.update(spro);
+                studentPaymentRouteOrderService.getDao().update(spro);
 			}
 		}
         
@@ -727,7 +721,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         int count = this.findCount(params);
         count = count + jmCount;
 
-        BigDecimal totalUserBalance = sysUserCashAccountDao.getTotalUserBalance(params);
+        BigDecimal totalUserBalance = sysUserCashAccountService.getDao().getTotalUserBalance(params);
         pageInfo.setTotalUserBalance(totalUserBalance);
         if (count > 0) {
             pageInfo.setTotal(count);
@@ -830,7 +824,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                     }
                 }
                 if (StringUtils.isNotBlank(childGoodIds)) {
-                    studentPaymentOrderDetail.setChildGoodsList(goodsDao.findGoodsByIds(childGoodIds));
+                    studentPaymentOrderDetail.setChildGoodsList(goodsService.getGoodsDao().findGoodsByIds(childGoodIds));
                 }
                 if (studentPaymentOrderDetail.getType() == OrderDetailTypeEnum.CLOUD_TEACHER || studentPaymentOrderDetail.getType() == OrderDetailTypeEnum.CLOUD_TEACHER_PLUS) {
                     studentPaymentOrderDetail.setCloudTeacherOrderDto(cloudTeacherOrderService.queryOrderInfoByOrderId(studentPaymentOrderDetail.getPaymentOrderId()));
@@ -1372,7 +1366,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     }
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public void mallBuyOrderCallback(StudentPaymentOrder studentPaymentOrder) {
         Date nowDate = new Date();
         //更新订单信息
@@ -1410,7 +1404,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                         //如果有空的商品货号,不处理
                         if(count == 0l){
                             List<String> productSns = goodsOrderItemVOS.stream().map(e -> e.getProductSn()).distinct().collect(Collectors.toList());
-                            List<Goods> goodsList = goodsDao.findBySns(productSns);
+                            List<Goods> goodsList = goodsService.getGoodsDao().findBySns(productSns);
                             //如果有不匹配的商品货号,不处理
                             if(CollectionUtils.isEmpty(goodsList) || goodsList.size() < productSns.size()){
                                 return;
@@ -1572,7 +1566,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                         //如果有空的商品货号,不处理
                         if(count == 0l){
                             List<String> productSns = goodsOrderItemVOS.stream().map(e -> e.getProductSn()).distinct().collect(Collectors.toList());
-                            List<Goods> goodsList = goodsDao.findBySns(productSns);
+                            List<Goods> goodsList = goodsService.getGoodsDao().findBySns(productSns);
                             //如果有不匹配的商品货号,不处理
                             if(CollectionUtils.isEmpty(goodsList) || goodsList.size() < productSns.size()){
                                 return;
@@ -1819,6 +1813,17 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             feeByTypeMap = feeByType.stream().collect(Collectors.groupingBy(StudentPaymentOrderExportDto::getId));
             childRepairMap = MapUtil.convertIntegerMap(sellOrderDao.queryChildRepair(otherOrderIds));
         }
+        //获取外部订单
+        Map<String, StudentPaymentRouteOrder> routeOrderMap = new HashMap<>();
+        List<String> outOrderNos = studentPaymentOrderExportDtos.stream().filter(e -> e.getGroupType() == GroupType.OUTORDER && e.getType() == OrderTypeEnum.SCHOOL)
+        .map(e -> e.getOrderNo()).collect(Collectors.toList());
+        if(CollectionUtils.isNotEmpty(outOrderNos)){
+            List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderService.getDao().queryByOrderNos(outOrderNos);
+            if (CollectionUtils.isNotEmpty(routeOrders)){
+                routeOrderMap = routeOrders.stream().filter(e->e.getType() == OrderTypeEnum.SCHOOL_GOODS_PURCHASE)
+                        .collect(Collectors.toMap(StudentPaymentRouteOrder::getOrderNo, Function.identity()));
+            }
+        }
         //阳光、善学、坚韧、做更好的自己
 //        List<Integer> organIds = studentPaymentOrderExportDtos.stream().map(e -> e.getOrganId()).distinct().collect(Collectors.toList());
         Map<Integer, String> userOrganNameMap = this.getMap("organization","id_","name_",true,1,Integer.class,String.class);
@@ -2001,14 +2006,18 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                                 } else {
                                     //拆分导入订单
                                     if (row.getType() == OrderTypeEnum.OUTORDER || row.getType() == OrderTypeEnum.SCHOOL) {
-                                        if (row.getType() == OrderTypeEnum.SCHOOL) {
-                                            row.setMusicalFee(BigDecimal.ZERO);
-                                            row.setTeachingFee(BigDecimal.ZERO);
-                                            row.setMaintenanceProductFee(BigDecimal.ZERO);
-                                            row.setOtherFee(BigDecimal.ZERO);
-                                            row.setLargeMusicalFee(add);
+                                        if(routeOrderMap.get(row.getOrderNo()) != null){
+                                            row.setLargeMusicalFee(subtract);
+                                        }else {
+                                            if (row.getType() == OrderTypeEnum.SCHOOL) {
+                                                row.setMusicalFee(BigDecimal.ZERO);
+                                                row.setTeachingFee(BigDecimal.ZERO);
+                                                row.setMaintenanceProductFee(BigDecimal.ZERO);
+                                                row.setOtherFee(BigDecimal.ZERO);
+                                                row.setLargeMusicalFee(add);
+                                            }
+                                            row.setCourseSchoolBuyAmount(subtract);
                                         }
-                                        row.setCourseSchoolBuyAmount(subtract);
                                     } else if (row.getType() == OrderTypeEnum.OTHER) {
                                         row.setOtherFee(row.getOtherFee().add(subtract));
                                     } else {

+ 9 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysUserCashAccountServiceImpl.java

@@ -5,18 +5,18 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
 import com.ym.mec.biz.dal.dao.SysUserCashAccountDetailDao;
 import com.ym.mec.biz.dal.dao.SysUserCoursesAccountDetailDao;
-import com.ym.mec.biz.dal.dto.ActivityPayParamDto;
 import com.ym.mec.biz.dal.dto.PayParamBasicDto;
-import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
+import com.ym.mec.biz.dal.entity.SysUserCoursesAccountDetail;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.PlatformCashAccountStatusEnum;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
 import com.ym.mec.biz.service.SysMessageService;
 import com.ym.mec.biz.service.SysUserCashAccountService;
-import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
@@ -47,8 +47,6 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU
     private SysUserCoursesAccountDetailDao sysUserCoursesAccountDetailDao;
     @Autowired
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
-    @Autowired
-    private StudentPaymentOrderService studentPaymentOrderService;
 
     @Override
     public BaseDAO<Integer, SysUserCashAccount> getDAO() {
@@ -56,6 +54,11 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU
     }
 
     @Override
+    public SysUserCashAccountDao getDao() {
+        return sysUserCashAccountDao;
+    }
+
+    @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public boolean updateBalance(Integer userId, BigDecimal decimal) {
 

+ 3 - 2
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -774,7 +774,8 @@
         FROM student_payment_order spo
         LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
         LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
-        where DATE_FORMAT(spo.pay_time_,'%Y-%m') = #{month} AND spo.order_no_ NOT IN (select distinct order_no_ from sell_order where DATE_FORMAT(sell_time_,'%Y-%m') = #{month})
+        where DATE_FORMAT(spo.pay_time_,'%Y-%m') = #{month} AND spo.type_ != 'SCHOOL_GOODS_PURCHASE'
+        AND spo.order_no_ NOT IN (select distinct order_no_ from sell_order where DATE_FORMAT(sell_time_,'%Y-%m') = #{month})
         AND spo.tenant_id_ = 1 AND spo.status_ = 'SUCCESS'
     </select>
     <select id="ExportQueryPage2" resultMap="orderAndDetail" parameterType="map">
@@ -783,7 +784,7 @@
                sci.charge_type_ from student_payment_order spo
                                          LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
                                          LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
-        where spo.tenant_id_ = 1 AND spo.status_ = 'SUCCESS'
+        where spo.tenant_id_ = 1 AND spo.status_ = 'SUCCESS' AND spo.type_ != 'SCHOOL_GOODS_PURCHASE'
         AND spo.order_no_ IN (select distinct order_no_ from sell_order where DATE_FORMAT(delivery_time_,'%Y-%m') = #{month})
     </select>
     <resultMap id="SporadicChargeInfoDtoMap" type="com.ym.mec.biz.dal.dto.SporadicChargeInfoDto">

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

@@ -466,6 +466,12 @@ calender_id_,create_time_,create_by_,update_time_,update_by_,tenant_id_,type_
             #{orderNo}
         </foreach>
     </select>
+    <select id="queryByOrderNos" resultMap="StudentPaymentRouteOrder">
+        SELECT * FROM student_payment_route_order WHERE order_no_ IN
+        <foreach collection="outOrderNos" item="orderNo" open="(" close=")" separator=",">
+            #{orderNo}
+        </foreach>
+    </select>
 
 
 </mapper>