|
@@ -1,89 +1,78 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import java.io.ByteArrayInputStream;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
-import java.util.Map.Entry;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
-import com.ym.mec.biz.dal.dto.ComplementGoodsDto;
|
|
|
+import com.ym.mec.biz.dal.dto.PageInfoOrder;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentPaymentRouteOrderDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
|
-import com.ym.mec.biz.service.*;
|
|
|
+import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
|
|
|
+import com.ym.mec.biz.service.MusicGroupCalenderRefundPeriodService;
|
|
|
+import com.ym.mec.biz.service.SellOrderService;
|
|
|
+import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
+import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
|
|
|
import com.ym.mec.common.api.CommonResult;
|
|
|
+import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.dto.OrderCreate;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
-import com.ym.mec.common.entity.OrderSkuSync;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.common.page.PageInfo;
|
|
|
+import com.ym.mec.common.page.QueryInfo;
|
|
|
+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.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.excel.POIUtil;
|
|
|
import com.ym.mec.util.ini.IniFileUtil;
|
|
|
-
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.ym.mec.biz.dal.dto.PageInfoOrder;
|
|
|
-import com.ym.mec.biz.dal.dto.StudentPaymentRouteOrderDto;
|
|
|
-import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
|
|
|
-import com.ym.mec.common.dal.BaseDAO;
|
|
|
-import com.ym.mec.common.exception.BizException;
|
|
|
-import com.ym.mec.common.page.PageInfo;
|
|
|
-import com.ym.mec.common.page.QueryInfo;
|
|
|
-import com.ym.mec.common.service.IdGeneratorService;
|
|
|
-import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
-import com.ym.mec.util.collection.MapUtil;
|
|
|
-
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.Map.Entry;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
@Service
|
|
|
public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, StudentPaymentRouteOrder> implements StudentPaymentRouteOrderService {
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysUserCashAccountDao sysUserCashAccountDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private IdGeneratorService idGeneratorService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SellOrderDao sellOrderDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private GoodsDao goodsDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SellOrderService sellOrderService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysUserFeignService sysUserFeignService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private TeacherDao teacherDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private MusicGroupCalenderRefundPeriodService musicGroupCalenderRefundPeriodService;
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private MallFeignService mallFeignService;
|
|
|
- @Autowired
|
|
|
- private MusicGroupPaymentCalenderAddressService musicGroupPaymentCalenderAddressService;
|
|
|
- @Autowired
|
|
|
- private MusicGroupPaymentCalenderGoodsService musicGroupPaymentCalenderGoodsService;
|
|
|
- @Autowired
|
|
|
- private SysPaymentConfigService sysPaymentConfigService;
|
|
|
- @Autowired
|
|
|
- private MusicGroupDao musicGroupDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, StudentPaymentRouteOrder> getDAO() {
|
|
@@ -210,29 +199,10 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
|
|
|
studentPaymentRouteOrder.setUpdateTime(nowDate);
|
|
|
studentPaymentRouteOrder.setAuditComment(memo);
|
|
|
studentPaymentRouteOrder.setAuditStatus(auditStatus);
|
|
|
- MusicGroupPaymentCalender musicGroupPaymentCalender = null;
|
|
|
- MusicGroupPaymentCalenderAddress address = null;
|
|
|
- MusicGroup musicGroup = null;
|
|
|
- //是否同步过商城的发货数据
|
|
|
- Boolean syncFlag = true;
|
|
|
- if (auditStatus == AuditStatusEnum.PASS) {
|
|
|
- if (studentPaymentRouteOrder.getCalenderId() != null) {
|
|
|
- musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(studentPaymentRouteOrder.getCalenderId());
|
|
|
- musicGroup = musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId());
|
|
|
- if(musicGroupPaymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.GOODS_PURCHASE){
|
|
|
- address = musicGroupPaymentCalenderAddressService.lambdaQuery().
|
|
|
- eq(MusicGroupPaymentCalenderAddress::getCalenderId, studentPaymentRouteOrder.getCalenderId()).one();
|
|
|
- StudentPaymentOrder addressOrder = studentPaymentOrderService.findOrderByOrderNo(address.getOrderNo());
|
|
|
- syncFlag = Objects.nonNull(addressOrder);
|
|
|
- if (!syncFlag){
|
|
|
- orderNo = address.getOrderNo();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- studentPaymentRouteOrder.setOrderNo(orderNo);
|
|
|
- }
|
|
|
+ studentPaymentRouteOrder.setOrderNo(orderNo);
|
|
|
studentPaymentRouteOrderDao.update(studentPaymentRouteOrder);
|
|
|
if (auditStatus == AuditStatusEnum.PASS) {
|
|
|
+ MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(studentPaymentRouteOrder.getCalenderId());
|
|
|
StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
|
|
|
studentPaymentOrder.setActualAmount(studentPaymentRouteOrder.getRouteAmount());
|
|
|
if(studentPaymentRouteOrder.getSchoolId() != null) {
|
|
@@ -275,7 +245,7 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
|
|
|
goodsIdList.add(goodsId);
|
|
|
}
|
|
|
}
|
|
|
- List<SellOrder> sellOrders = sellOrderService.initSellOrder(studentPaymentOrder, musicGroup==null?null:musicGroup.getId(), goodsIdList, null, false);
|
|
|
+ List<SellOrder> sellOrders = sellOrderService.initSellOrder(studentPaymentOrder, null, goodsIdList, null, false);
|
|
|
sellOrderService.batchInsert(sellOrders);
|
|
|
if(calender == null || calender.getPaymentType() != MusicGroupPaymentCalender.PaymentType.GOODS_PURCHASE){
|
|
|
OrderCreate mallOrder = new OrderCreate();
|
|
@@ -315,73 +285,6 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
|
|
|
if (studentPaymentRouteOrder.getCalenderId() == null) {
|
|
|
return true;
|
|
|
}
|
|
|
- //同步商城的发货数据
|
|
|
- if(!syncFlag){
|
|
|
- List<MusicGroupPaymentCalenderGoods> calenderGoods = musicGroupPaymentCalenderGoodsService.lambdaQuery()
|
|
|
- .eq(MusicGroupPaymentCalenderGoods::getCalenderId, studentPaymentRouteOrder.getCalenderId()).list();
|
|
|
- List<SellOrder> sellOrderList = new ArrayList<>();
|
|
|
- for (MusicGroupPaymentCalenderGoods calenderGood : calenderGoods) {
|
|
|
- //待分配金额
|
|
|
- for (Integer i = 0; i < calenderGood.getNum(); i++) {
|
|
|
- List<ComplementGoodsDto> goodsDtoList = JSON.parseArray(calenderGood.getChildGoodsJson(), ComplementGoodsDto.class);
|
|
|
- //获取总成本
|
|
|
- BigDecimal totalCostPrice = goodsDtoList.stream().map(e->e.getOrganCostPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- //待分配金额
|
|
|
- BigDecimal totalAmount = calenderGood.getSinglePrice();
|
|
|
- BigDecimal waitAmount = totalAmount;
|
|
|
- for (int j = 0; j < goodsDtoList.size(); j++) {
|
|
|
- ComplementGoodsDto goodsDto = goodsDtoList.get(j);
|
|
|
- //获取比例
|
|
|
- BigDecimal proportion = BigDecimal.ZERO;
|
|
|
- if (totalCostPrice.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- proportion = goodsDto.getOrganCostPrice().divide(totalCostPrice, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
- SellOrder sellOrder = new SellOrder();
|
|
|
- sellOrder.setGoodsSkuId(goodsDto.getSkuStockId());
|
|
|
- sellOrder.setOrganSellCost(goodsDto.getOrganCostPrice());
|
|
|
- sellOrder.setOrderId(studentPaymentOrder.getOrganId().longValue());
|
|
|
- sellOrder.setType(StringUtils.endsWithIgnoreCase("INSTRUMENT", calenderGood.getGoodsType()) ? SellTypeEnum.INSTRUMENT
|
|
|
- : StringUtils.endsWithIgnoreCase("ACCESSORIES", calenderGood.getGoodsType()) ? SellTypeEnum.ACCESSORIES
|
|
|
- : StringUtils.endsWithIgnoreCase("TEACHING", calenderGood.getGoodsType()) ? SellTypeEnum.TEACHING
|
|
|
- : StringUtils.endsWithIgnoreCase("STAFF", calenderGood.getGoodsType()) ? SellTypeEnum.STAFF
|
|
|
- : SellTypeEnum.OTHER);
|
|
|
- sellOrder.setOrderNo(orderNo);
|
|
|
- if (j == goodsDtoList.size() - 1) {
|
|
|
- sellOrder.setOrderAmount(waitAmount);
|
|
|
- } else {
|
|
|
- BigDecimal amount = totalAmount.multiply(proportion);
|
|
|
- waitAmount = waitAmount.subtract(amount);
|
|
|
- sellOrder.setOrderAmount(amount);
|
|
|
- }
|
|
|
- sellOrder.setActualAmount(sellOrder.getOrderAmount());
|
|
|
- sellOrder.setExpectAmount(sellOrder.getOrderAmount());
|
|
|
- sellOrder.setCouponRemitAmount(BigDecimal.ZERO);
|
|
|
- sellOrder.setBalanceAmount(BigDecimal.ZERO);
|
|
|
- sellOrder.setParentGoodsId(calenderGood.getGoodsId());
|
|
|
- sellOrder.setNum(1);
|
|
|
- sellOrder.setGoodsName(calenderGood.getGoodsName());
|
|
|
- sellOrder.setAccountType(AccountType.INTERNAL);
|
|
|
- sellOrder.setCooperationOrganId(musicGroup.getCooperationOrganId());
|
|
|
- sellOrder.setEduTeacherId(musicGroup.getEducationalTeacherId());
|
|
|
- sellOrder.setTransNo(studentPaymentOrder.getTransNo());
|
|
|
- sellOrder.setPaymentChannel(studentPaymentOrder.getPaymentChannel());
|
|
|
- sellOrder.setMerNo(studentPaymentOrder.getMerNos());
|
|
|
- sellOrder.setSellTime(studentPaymentOrder.getCreateTime());
|
|
|
- sellOrder.setTenantId(studentPaymentOrder.getTenantId());
|
|
|
- sellOrderList.add(sellOrder);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- sellOrderService.batchInsert(sellOrderList);
|
|
|
- if(address.getDeliveryFlag()){
|
|
|
- OrderSkuSync orderSkuSync = new OrderSkuSync();
|
|
|
- orderSkuSync.setOrderNo(orderNo);
|
|
|
- orderSkuSync.setSkuSyncList(JSONArray.parseArray(address.getDeliveryDetail(), OrderSkuSync.SkuSync.class));
|
|
|
- List<OrderSkuSync> orderSkuSyncs = new ArrayList<>();
|
|
|
- orderSkuSyncs.add(orderSkuSync);
|
|
|
- studentPaymentOrderService.updateShippedStatus(orderSkuSyncs);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
//根据学校缴费项id,确定缴费状态
|
|
|
// BigDecimal amount = studentPaymentRouteOrderDao.sumAmountByCalenderId(studentPaymentRouteOrder.getCalenderId());
|