|
@@ -4,6 +4,7 @@ package com.ym.mec.biz.service.impl;
|
|
|
import static com.ym.mec.biz.dal.enums.GroupType.GOODS_SELL;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
@@ -11,6 +12,12 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.ym.mec.biz.dal.dto.ComplementGoodsDto;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.mapper.GoodsSubMapper;
|
|
|
+import com.ym.mec.common.dto.OrderCreate;
|
|
|
+import com.ym.mec.common.page.WrapperUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -25,13 +32,6 @@ import com.ym.mec.biz.dal.dao.SporadicChargeInfoDao;
|
|
|
import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
|
|
|
import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
|
|
|
import com.ym.mec.biz.dal.dao.StudentRepairDao;
|
|
|
-import com.ym.mec.biz.dal.entity.Goods;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
|
-import com.ym.mec.biz.dal.entity.SellOrder;
|
|
|
-import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
|
|
|
-import com.ym.mec.biz.dal.entity.SysUserCashAccountLog;
|
|
|
import com.ym.mec.biz.dal.enums.AccountType;
|
|
|
import com.ym.mec.biz.dal.enums.GoodsType;
|
|
|
import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
|
|
@@ -72,6 +72,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
private SporadicChargeInfoDao sporadicChargeInfoDao;
|
|
|
@Autowired
|
|
|
private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
|
|
|
+ @Autowired
|
|
|
+ private GoodsSubMapper goodsSubMapper;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, SellOrder> getDAO() {
|
|
@@ -511,6 +513,39 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
return sellAmount;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<OrderCreate.OrderItem> convertMallOrder(List<SellOrder> sellOrderList) {
|
|
|
+ List<OrderCreate.OrderItem> orderItems = new ArrayList<>();
|
|
|
+ for (SellOrder e : sellOrderList) {
|
|
|
+ Goods goods = goodsDao.get(e.getGoodsId());
|
|
|
+ BigDecimal totalPrice = e.getExpectAmount();
|
|
|
+ List<ComplementGoodsDto> goodsDtoList = JSON.parseArray(goods.getComplementGoodsJson(), ComplementGoodsDto.class);
|
|
|
+ //总金额按比例分配
|
|
|
+ //待分配
|
|
|
+ BigDecimal waitRemitFee = totalPrice;
|
|
|
+ BigDecimal totalAmount = WrapperUtil.sumList(goodsDtoList, ComplementGoodsDto::getOrganCostPrice);
|
|
|
+ for (int i = 0; i < goodsDtoList.size(); i++) {
|
|
|
+ ComplementGoodsDto goodsDto = goodsDtoList.get(i);
|
|
|
+ OrderCreate.OrderItem orderItemCreate = new OrderCreate.OrderItem();
|
|
|
+ orderItemCreate.setProductQuantity(1);
|
|
|
+ orderItemCreate.setProductSkuId(goodsDto.getSkuStockId().longValue());
|
|
|
+ //如果是最后一件商品
|
|
|
+ if (i == goodsDtoList.size() - 1) {
|
|
|
+ orderItemCreate.setRealAmount(waitRemitFee);
|
|
|
+ } else {
|
|
|
+ //获取比例
|
|
|
+ BigDecimal ratioAmount = goodsDto.getOrganCostPrice().divide(totalAmount, 6, RoundingMode.HALF_UP);
|
|
|
+ //获取分配的金额
|
|
|
+ BigDecimal multiply = ratioAmount.multiply(totalPrice).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ orderItemCreate.setRealAmount(multiply);
|
|
|
+ waitRemitFee = waitRemitFee.subtract(multiply);
|
|
|
+ }
|
|
|
+ orderItems.add(orderItemCreate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return orderItems;
|
|
|
+ }
|
|
|
+
|
|
|
public Map<String, BigDecimal> calcSellAmount(StudentPaymentOrder order,BigDecimal cloudBalanceIncome,BigDecimal cloudIncome) {
|
|
|
List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailDao.getOrderDetail(order.getId());
|
|
|
//总余额支付
|