yonge 3 年之前
父節點
當前提交
951d66ad63

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentPaymentOrderExportDto.java

@@ -153,6 +153,9 @@ public class StudentPaymentOrderExportDto extends StudentPaymentOrder {
     //订单金额
     @ApiModelProperty(value = "订单金额",required = true)
     private BigDecimal orderAmount = BigDecimal.ZERO;
+    
+    //内部库存商品销售转化的收入
+    private BigDecimal translatedIncome = BigDecimal.ZERO;
 
     public enum TypeDesc implements BaseEnum<String, StudentPaymentOrderExportDto.TypeDesc> {
 
@@ -551,4 +554,12 @@ public class StudentPaymentOrderExportDto extends StudentPaymentOrder {
     public void setPayingStatus(Integer payingStatus) {
         this.payingStatus = payingStatus;
     }
+
+	public BigDecimal getTranslatedIncome() {
+		return translatedIncome;
+	}
+
+	public void setTranslatedIncome(BigDecimal translatedIncome) {
+		this.translatedIncome = translatedIncome;
+	}
 }

+ 42 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -26,6 +26,7 @@ import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.excel.POIUtil;
 import com.ym.mec.util.ini.IniFileUtil;
 import com.ym.mec.util.upload.UploadUtil;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,6 +39,7 @@ import org.springframework.util.CollectionUtils;
 
 import javax.annotation.PostConstruct;
 import javax.servlet.http.HttpServletResponse;
+
 import java.io.*;
 import java.lang.reflect.InvocationTargetException;
 import java.math.BigDecimal;
@@ -69,6 +71,8 @@ public class ExportServiceImpl implements ExportService {
     @Autowired
     private MusicGroupDao musicGroupDao;
     @Autowired
+    private SysConfigDao sysConfigDao;
+    @Autowired
     private StoragePluginContext storagePluginContext;
     @Autowired
     private ManagerDownloadDao managerDownloadDao;
@@ -2442,34 +2446,33 @@ public class ExportServiceImpl implements ExportService {
                             row.setMusicGroupCourseFee(row.getMusicGroupCourseFee().add(orderDetail.getPrice()));
                             break;
                         case MUSICAL:
+                        	BigDecimal income = orderDetail.getIncome();
+                        	//扣除内部库存的商品销售收入统计在云教练中
                         	if(StringUtils.equals(orderDetail.getIncomeItem(), OrderDetailTypeEnum.CLOUD_TEACHER.name())){
-                        		row.setCloudTeacherFee(row.getCloudTeacherFee().add(orderDetail.getIncome()));
-                        		break;
+                        		row.setTranslatedIncome(row.getTranslatedIncome().add(income.multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN)));
                         	}
                             if (orderDetail.getKitGroupPurchaseType() != null && orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
-                                BigDecimal leaseFee = orderDetail.getPrice();
+                                BigDecimal leaseFee = orderDetail.getPrice().subtract(income);
                                 if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
-                                    leaseFee = orderDetail.getPrice().multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
+                                    leaseFee = orderDetail.getPrice().subtract(income).multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
                                 }
                                 row.setLeaseFee(leaseFee);
                             } else {
-                                row.setMusicalFee(orderDetail.getPrice());
+                                row.setMusicalFee(orderDetail.getPrice().subtract(orderDetail.getIncome()));
                             }
                             break;
                         case ACCESSORIES:
                         case TEACHING:
                         	if(StringUtils.equals(orderDetail.getIncomeItem(), OrderDetailTypeEnum.CLOUD_TEACHER.name())){
-                        		row.setCloudTeacherFee(row.getCloudTeacherFee().add(orderDetail.getIncome()));
-                        		break;
+                        		row.setTranslatedIncome(row.getTranslatedIncome().add(orderDetail.getIncome().multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN)));
                         	}
-                            row.setTeachingFee(row.getTeachingFee().add(orderDetail.getPrice()));
+                            row.setTeachingFee(row.getTeachingFee().add(orderDetail.getPrice().subtract(orderDetail.getIncome())));
                             break;
                         case OTHER:
                         	if(StringUtils.equals(orderDetail.getIncomeItem(), OrderDetailTypeEnum.CLOUD_TEACHER.name())){
-                        		row.setCloudTeacherFee(row.getCloudTeacherFee().add(orderDetail.getIncome()));
-                        		break;
+                        		row.setTranslatedIncome(row.getTranslatedIncome().add(orderDetail.getIncome().multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN)));
                         	}
-                            row.setOtherFee(row.getOtherFee().add(orderDetail.getPrice()));
+                            row.setOtherFee(row.getOtherFee().add(orderDetail.getPrice().subtract(orderDetail.getIncome())));
                             break;
                         case MAINTENANCE:
                             BigDecimal maintenanceFee = BigDecimal.ZERO;
@@ -2625,11 +2628,14 @@ public class ExportServiceImpl implements ExportService {
                 }
             } else {
                 StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
-                BigDecimal childRepairFee = sellOrderDao.getChildRepair(row.getId());
-                row.setMusicalFee(feeByType.getMusicalFee());
-                row.setTeachingFee(feeByType.getTeachingFee().subtract(childRepairFee));
-                row.setMaintenanceProductFee(feeByType.getRepairFee().add(childRepairFee));
-                row.setOtherFee(feeByType.getOtherFee());
+                //兼容历史数据
+                if(row.getCreateTime().before(DateUtil.stringToDate("2022-06-15 00:00:00"))){
+	                BigDecimal childRepairFee = sellOrderDao.getChildRepair(row.getId());
+	                row.setMusicalFee(feeByType.getMusicalFee());
+	                row.setTeachingFee(feeByType.getTeachingFee().subtract(childRepairFee));
+	                row.setMaintenanceProductFee(feeByType.getRepairFee().add(childRepairFee));
+	                row.setOtherFee(feeByType.getOtherFee());
+                }
                 if (row.getGroupType().equals(GroupType.MUSIC)) {
                     StudentRegistration studentRegistration = studentRegistrationDao.findStudentByMusicGroupIdAndUserId(row.getMusicGroupId(), row.getUserId());
                     if (studentRegistration != null) {
@@ -2638,7 +2644,7 @@ public class ExportServiceImpl implements ExportService {
                         row.setCooperationOrganName(studentRegistration.getRemark());
                         row.setEduTeacher(studentRegistration.getName());
                     }
-                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(row.getTeachingFee()).subtract(row.getMaintenanceFee()).subtract(row.getMaintenanceProductFee()).subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()).subtract(row.getCloudTeacherFee()));
+                    //row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(row.getTeachingFee()).subtract(row.getMaintenanceFee()).subtract(row.getMaintenanceProductFee()).subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()).subtract(row.getCloudTeacherFee()));
                 } else if (row.getType().equals(OrderTypeEnum.REPAIR)) {
                     row.setRepairFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getOtherFee()));
                 } else if (row.getType().equals(OUTORDER)) {
@@ -2686,6 +2692,9 @@ public class ExportServiceImpl implements ExportService {
             row.setPaymentChannel(paymentChannel);
             row.setOrderAmount(row.getExpectAmount().add(row.getCouponRemitFee()));
         }
+        
+		//查询商品收款账户配置
+        String goodsSellReceiptMerNo = sysConfigDao.findConfigValue("goodsSellReceiptMerNo");
 
         Map<Long, List<StudentPaymentOrderExportDto>> orderMap = studentPaymentOrderExportDtos.stream().collect(Collectors.groupingBy(StudentPaymentOrderExportDto::getId));
         orderMap.forEach((orderId, orders) -> {
@@ -2709,6 +2718,22 @@ public class ExportServiceImpl implements ExportService {
                 if (order.getPayTime() == null || order.getPayTime().compareTo(endDate) < 0) {
                     break;
                 }
+                //如果有转化的销售服务
+                if(StringUtils.equals(order.getRouteMerNo(), goodsSellReceiptMerNo) && order.getTranslatedIncome().compareTo(order.getRouteAmount()) == 0){
+                	order.setMusicGroupCourseFee(BigDecimal.ZERO);
+                    order.setVipCourseFee(BigDecimal.ZERO);
+                    order.setPracticeCourseFee(BigDecimal.ZERO);
+                    order.setTheoryCourseFee(BigDecimal.ZERO);
+                    order.setDegreeFee(BigDecimal.ZERO);
+                    order.setMaintenanceFee(BigDecimal.ZERO);
+                    order.setCloudTeacherFee(order.getTranslatedIncome());
+                    order.setRepairFee(BigDecimal.ZERO);
+                    order.setMusicalFee(BigDecimal.ZERO);
+                    order.setTeachingFee(BigDecimal.ZERO);
+                    order.setOtherFee(BigDecimal.ZERO);
+                    order.setLeaseFee(BigDecimal.ZERO);
+                	continue;
+                }
                 if (order.getSaleAmount().compareTo(BigDecimal.ZERO) > 0 && order.getServiceAmount().compareTo(BigDecimal.ZERO) == 0) {
                     order.setMusicGroupCourseFee(BigDecimal.ZERO);
                     order.setVipCourseFee(BigDecimal.ZERO);

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

@@ -244,7 +244,7 @@ public class PayServiceImpl implements PayService {
         									if(subGoods.getStockCount() > 0){
         										groupPurchaseAmount = groupPurchaseAmount.add(subGoods.getGroupPurchasePrice());
         										subGoods.setStockCount(new AtomicInteger(subGoods.getStockCount()).decrementAndGet());
-            									subGoods.setSellCount(new AtomicInteger(subGoods.getStockCount()).incrementAndGet());
+            									subGoods.setSellCount(new AtomicInteger(subGoods.getSellCount()).incrementAndGet());
         										subGoods.setUpdateTime(date);
         										batchUpdateGoodsList.add(subGoods);
         										
@@ -264,7 +264,7 @@ public class PayServiceImpl implements PayService {
         								if(goods.getStockCount() > 0){
     										groupPurchaseAmount = groupPurchaseAmount.add(goods.getGroupPurchasePrice());
     										goods.setStockCount(new AtomicInteger(goods.getStockCount()).decrementAndGet());
-    										goods.setSellCount(new AtomicInteger(goods.getStockCount()).incrementAndGet());
+    										goods.setSellCount(new AtomicInteger(goods.getSellCount()).incrementAndGet());
     										goods.setUpdateTime(date);
     										batchUpdateGoodsList.add(goods);
     										

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

@@ -595,6 +595,8 @@
             <result column="detail_type_" property="type"/>
             <result column="detail_price_" property="price"/>
             <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
+            <result column="income_item_" property="incomeItem"/>
+            <result column="income_" property="income"/>
         </collection>
         <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
             <result column="goods_id" property="id"/>

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

@@ -289,7 +289,7 @@ calender_id_,create_time_,create_by_,update_time_,update_by_,tenant_id_,type_
     <select id="ExportQueryPage" resultMap="com.ym.mec.biz.dal.dao.StudentPaymentOrderDao.orderAndDetail"
             parameterType="map">
         SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
-        detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
+        detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,spod.income_item_,spod.income_,
         sci.charge_type_,g.id_ goods_id, g.name_ goods_name,o.name_ organ_name,spro.route_amount_
         routeAmount,spro.route_balance_amount_ routeBalance,spro.sale_amount_,spro.service_amount_,spro.service_fee_,
         spro.mer_no_ routeMerNo,spro.fee_flag_ feeFlag