|
@@ -16,6 +16,7 @@ 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.biz.service.*;
|
|
|
import com.ym.mec.common.dto.OrderCreate;
|
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
@@ -42,11 +43,6 @@ import com.ym.mec.biz.dal.enums.ReturnFeeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.SellStatus;
|
|
|
import com.ym.mec.biz.dal.enums.SellTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
|
|
|
-import com.ym.mec.biz.service.GoodsService;
|
|
|
-import com.ym.mec.biz.service.SellOrderService;
|
|
|
-import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
|
|
|
-import com.ym.mec.biz.service.SysPaymentConfigService;
|
|
|
-import com.ym.mec.biz.service.SysUserCashAccountLogService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
|
|
@@ -73,7 +69,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
@Autowired
|
|
|
private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
|
|
|
@Autowired
|
|
|
- private GoodsSubMapper goodsSubMapper;
|
|
|
+ private GoodsSubService goodsSubService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, SellOrder> getDAO() {
|
|
@@ -517,24 +513,26 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
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);
|
|
|
+ List<GoodsSub> list = goodsSubService.lambdaQuery().eq(GoodsSub::getGoodsId, e.getGoodsId()).list();
|
|
|
+ if(CollectionUtils.isEmpty(list)){
|
|
|
+ throw new RuntimeException("子商品不存在,请联系管理员");
|
|
|
+ }
|
|
|
+ BigDecimal totalPrice = e.getExpectAmount().divide(new BigDecimal(e.getNum()), 2, RoundingMode.HALF_UP);
|
|
|
//总金额按比例分配
|
|
|
//待分配
|
|
|
BigDecimal waitRemitFee = totalPrice;
|
|
|
- BigDecimal totalAmount = WrapperUtil.sumList(goodsDtoList, ComplementGoodsDto::getOrganCostPrice);
|
|
|
- for (int i = 0; i < goodsDtoList.size(); i++) {
|
|
|
- ComplementGoodsDto goodsDto = goodsDtoList.get(i);
|
|
|
+ BigDecimal totalAmount = WrapperUtil.sumList(list, GoodsSub::getGoodsPrice);
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ GoodsSub goodsDto = list.get(i);
|
|
|
OrderCreate.OrderItem orderItemCreate = new OrderCreate.OrderItem();
|
|
|
- orderItemCreate.setProductQuantity(1);
|
|
|
- orderItemCreate.setProductSkuId(goodsDto.getSkuStockId().longValue());
|
|
|
+ orderItemCreate.setProductQuantity(e.getNum());
|
|
|
+ orderItemCreate.setProductSkuId(goodsDto.getSku().longValue());
|
|
|
//如果是最后一件商品
|
|
|
- if (i == goodsDtoList.size() - 1) {
|
|
|
+ if (i == list.size() - 1) {
|
|
|
orderItemCreate.setRealAmount(waitRemitFee);
|
|
|
} else {
|
|
|
//获取比例
|
|
|
- BigDecimal ratioAmount = goodsDto.getOrganCostPrice().divide(totalAmount, 6, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal ratioAmount = goodsDto.getGoodsPrice().divide(totalAmount, 6, RoundingMode.HALF_UP);
|
|
|
//获取分配的金额
|
|
|
BigDecimal multiply = ratioAmount.multiply(totalPrice).setScale(2, RoundingMode.HALF_UP);
|
|
|
orderItemCreate.setRealAmount(multiply);
|