zouxuan 5 years ago
parent
commit
d323e78f24

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SellStatus.java

@@ -22,6 +22,6 @@ public enum SellStatus implements BaseEnum<Integer, SellStatus> {
 
     @Override
     public Integer getCode() {
-        return null;
+        return code;
     }
 }

+ 32 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -7,6 +7,7 @@ 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.BasicUserDto;
+import com.ym.mec.biz.dal.dto.GoodsBatchNoDto;
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.dto.RepairGoodsDto;
 import com.ym.mec.biz.dal.entity.*;
@@ -739,6 +740,37 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         List<GoodsSellDto> goodsSellDtos = JSONObject.parseArray(goodsJson, GoodsSellDto.class);
         Map<Integer, List<GoodsSellDto>> collect = goodsSellDtos.stream().collect(Collectors.groupingBy(GoodsSellDto::getGoodsId));
         List<Integer> goodsId = goodsSellDtos.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
+
+        List<Integer> goodsIds = new ArrayList<>();
+        goodsSellDtos.forEach(e->{
+            for (int i = 0; i < e.getGoodsNum(); i++) {
+                goodsIds.add(e.getGoodsId());
+            }
+        });
+        List<GoodsSellDto> goodsSellDtoList = new ArrayList<>();
+        //扣减库存
+        List<GoodsProcurement> goodsBatchNoDtos = goodsService.subtractStock(goodsIds, AccountType.EXTERNAL);
+
+        Map<String, List<GoodsProcurement>> listMap = goodsBatchNoDtos.stream().collect(Collectors.groupingBy(GoodsProcurement::getBatchNo));
+        Set<String> listMapKeys = listMap.keySet();
+        listMapKeys.forEach(e->{
+            listMap.get(e).forEach(z->{
+                GoodsSellDto goodsSellDto1 = collect.get(z.getGoodsId()).get(0);
+                GoodsSellDto goodsSellDto = new GoodsSellDto();
+                if(StringUtils.isEmpty(z.getBatchNo())){
+                    goodsSellDto.setGoodsNum(1);
+                    goodsSellDto.setTotalGoodsPrice(goodsSellDto1.getGoodsPrice());
+                    goodsSellDto.setGoodsPrice(goodsSellDto1.getGoodsPrice());
+                    goodsSellDto.setGoodsId(goodsSellDto1.getGoodsId());
+                    goodsSellDto.setGoodsName(goodsSellDto1.getGoodsName());
+                    goodsSellDto.setGoodsType(goodsSellDto1.getGoodsType());
+                    goodsSellDto.setImage(goodsSellDto1.getImage());
+                }else {
+
+                }
+            });
+        });
+
         List<Goods> goodsByIds = goodsService.findGoodsByIds(StringUtils.join(goodsId, ","));
         Map<Integer, List<Goods>> goodsMap = goodsByIds.stream().collect(Collectors.groupingBy(Goods::getId));
         Map<String, BigDecimal> costMap = new HashMap<>(2);

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

@@ -16,7 +16,7 @@
         <result column="expect_amount_" property="expectAmount"/>
         <result column="actual_amount_" property="actualAmount"/>
         <result column="balance_amount_" property="balanceAmount"/>
-        <result column="type_" property="type"/>
+        <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="goods_id_" property="goodsId"/>
         <result column="goods_name_" property="goodsName"/>
         <result column="sell_cost_" property="sellCost"/>
@@ -29,7 +29,7 @@
         <result column="user_id_" property="userId"/>
         <result column="payment_channel_" property="paymentChannel"/>
         <result column="mer_no_" property="merNo"/>
-        <result column="status_" property="status"/>
+        <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="sell_time_" property="sellTime"/>
         <result column="create_ime_" property="createIme"/>
         <result column="update_time_" property="updateTime"/>