1
0
Quellcode durchsuchen

Merge branch 'featrue/收银端增加同条码多SKU选择' of qng/kmall-pt-general into master

杨波 vor 3 Jahren
Ursprung
Commit
a28d761785

+ 57 - 4
kmall-admin/src/main/java/com/kmall/admin/controller/GoodsController.java

@@ -571,9 +571,9 @@ public class GoodsController {
         return R.ok().put("goods", goods);
     }
 
-    @RequestMapping("/details/{prodBarcode}/{storeId}")
+    @RequestMapping("/details/{prodBarcode}/{storeId}/{sku}")
 //    @RequiresPermissions("goods:details") http://127.0.0.1:8080/goods/details/11111
-    public R details(@PathVariable("prodBarcode")String prodBarcode,@PathVariable("storeId")String storeId) {
+    public R details(@PathVariable("prodBarcode")String prodBarcode,@PathVariable("storeId")String storeId,@PathVariable("sku")String sku) {
         SysUserEntity user = ShiroUtils.getUserEntity();
         if(user == null) {
             return R.error("用户登录超时,请重新登录");
@@ -581,11 +581,31 @@ public class GoodsController {
         if (!user.getRoleType().equalsIgnoreCase("2")) {
             return R.error("该操作只允许店员账户操作");
         }
+        Map<String,Object> map = null;
+        try {
+            map = goodsService.calculateGoodsDetail(prodBarcode,storeId,sku);
+        } catch (Exception e) {
+            return R.error("系统异常,请联系管理员!e:"+e.getMessage());
+        }
+        if(map == null){
+            return R.error("商品信息不存在");
+        }
+        return R.ok().put("goodsDetails", map.get("goods")).put("map",map);
+    }
 
-
+    @RequestMapping("/detailsOld/{prodBarcode}/{storeId}")
+//    @RequiresPermissions("goods:details") http://127.0.0.1:8080/goods/details/11111
+    public R details(@PathVariable("prodBarcode")String prodBarcode,@PathVariable("storeId")String storeId) {
+        SysUserEntity user = ShiroUtils.getUserEntity();
+        if(user == null) {
+            return R.error("用户登录超时,请重新登录");
+        }
+        if (!user.getRoleType().equalsIgnoreCase("2")) {
+            return R.error("该操作只允许店员账户操作");
+        }
         Map<String,Object> map = null;
         try {
-            map = goodsService.calculateGoodsDetail(prodBarcode,storeId);
+            map = goodsService.calculateGoodsDetail(prodBarcode,storeId,null);
         } catch (Exception e) {
             return R.error("系统异常,请联系管理员!e:"+e.getMessage());
         }
@@ -597,6 +617,39 @@ public class GoodsController {
 
 
     /**
+     * 多sku可选
+     * @param prodBarcode
+     * @param storeId
+     * @return
+     */
+    @RequestMapping("/selectSkuDetails/{prodBarcode}/{storeId}")
+    public R selectSkuDetails(@PathVariable("prodBarcode")String prodBarcode,@PathVariable("storeId")String storeId) {
+        SysUserEntity user = ShiroUtils.getUserEntity();
+        if(user == null) {
+            return R.error("用户登录超时,请重新登录");
+        }
+        if (!user.getRoleType().equalsIgnoreCase("2")) {
+            return R.error("该操作只允许店员账户操作");
+        }
+
+        List<Map<String,Object>> mapList = null;
+        try {
+            mapList = goodsService.selectSkuDetails(prodBarcode,storeId);
+        } catch (Exception e) {
+            return R.error("系统异常,请联系管理员!e:"+e.getMessage());
+        }
+        if(mapList == null){
+            return R.error("商品信息不存在");
+        }
+        List<Object> objectList = new ArrayList<>();
+        for(Map<String,Object> map : mapList){
+            objectList.add(map.get("goods"));
+        }
+
+        return R.ok().put("goodsDetails", objectList).put("map",objectList);
+    }
+
+    /**
      * 根据商品编码或者条码查询商品信息(17.商品全景图)
      * @param keyword
      * @return

+ 3 - 2
kmall-admin/src/main/java/com/kmall/admin/dao/GoodsDao.java

@@ -27,7 +27,7 @@ public interface GoodsDao extends BaseDao<GoodsEntity> {
 
     GoodsEntity queryObjectByProdBarcodeAndStore(@Param("prodBarcode")String prodBarcode, @Param("storeId")Integer storeId);
 
-    GoodsDetailsDto queryGoodsDetailsByProdBarcode(@Param("prodBarcode") String prodBarcode, @Param("storeId")String storeId);
+    GoodsDetailsDto queryGoodsDetailsByProdBarcode(@Param("prodBarcode") String prodBarcode, @Param("storeId")String storeId, @Param("sku")String sku);
 
     List<GoodsEntity> querySame(Map<String, Object> map);
 
@@ -60,7 +60,7 @@ public interface GoodsDao extends BaseDao<GoodsEntity> {
      * @param storeId
      * @return
      */
-    List<GoodsEntity> queryListByBarcode(@Param("prodBarcode")String prodBarcode, @Param("storeId")Integer storeId);
+    List<GoodsEntity> queryListByBarcode(@Param("prodBarcode")String prodBarcode, @Param("storeId")Integer storeId, @Param("sku")String sku);
 
     List<GoodsEntity> queryByName(@Param("storeId")String storeId, @Param("goodsName")String goodsName);
 
@@ -89,4 +89,5 @@ public interface GoodsDao extends BaseDao<GoodsEntity> {
     List<GoodsEntity> syncGoodsRateGoode(List<Integer> ids);
 
 
+    List<GoodsDetailsDto> queryGoodsSkuList(@Param("prodBarcode") String prodBarcode, @Param("storeId")String storeId);
 }

+ 32 - 0
kmall-admin/src/main/java/com/kmall/admin/dto/GoodsDetailsDto.java

@@ -56,6 +56,38 @@ public class GoodsDetailsDto {
 
     private String storeId;
 
+    private String sku;
+
+    //商品市场价
+    private BigDecimal rmarketPrice;
+
+    //商品库存
+    private Integer goodsNumber;
+
+    public BigDecimal getRmarketPrice() {
+        return rmarketPrice;
+    }
+
+    public void setRmarketPrice(BigDecimal rmarketPrice) {
+        this.rmarketPrice = rmarketPrice;
+    }
+
+    public Integer getGoodsNumber() {
+        return goodsNumber;
+    }
+
+    public void setGoodsNumber(Integer goodsNumber) {
+        this.goodsNumber = goodsNumber;
+    }
+
+    public String getSku() {
+        return sku;
+    }
+
+    public void setSku(String sku) {
+        this.sku = sku;
+    }
+
     public String getStoreId() {
         return storeId;
     }

+ 3 - 2
kmall-admin/src/main/java/com/kmall/admin/service/GoodsService.java

@@ -142,7 +142,7 @@ public interface GoodsService {
      * @param storeId
      * @return
      */
-    GoodsDetailsDto queryGoodsDetailsByProdBarcode(String prodBarcode, String storeId);
+    GoodsDetailsDto queryGoodsDetailsByProdBarcode(String prodBarcode, String storeId,String sku);
 
 
     GoodsPanoramaDto searchGoodsPanoramaDtoByKeyword(String keyword);
@@ -169,7 +169,7 @@ public interface GoodsService {
      * @param storeId
      * @return
      */
-    Map<String,Object> calculateGoodsDetail(String prodBarcode, String storeId);
+    Map<String,Object> calculateGoodsDetail(String prodBarcode, String storeId,String sku);
 
     /**
      * 根据条形码查询商品
@@ -212,4 +212,5 @@ public interface GoodsService {
 
     void syncGoodsRateTask();
 
+    List<Map<String,Object>> selectSkuDetails(String prodBarcode, String storeId);
 }

+ 291 - 4
kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java

@@ -1751,8 +1751,8 @@ public class GoodsServiceImpl implements GoodsService {
     }
 
     @Override
-    public GoodsDetailsDto queryGoodsDetailsByProdBarcode(String prodBarcode, String storeId) {
-        return goodsDao.queryGoodsDetailsByProdBarcode(prodBarcode,storeId);
+    public GoodsDetailsDto queryGoodsDetailsByProdBarcode(String prodBarcode, String storeId,String sku) {
+        return goodsDao.queryGoodsDetailsByProdBarcode(prodBarcode,storeId,sku);
     }
 
 
@@ -1789,11 +1789,11 @@ public class GoodsServiceImpl implements GoodsService {
      */
     @Override
     @Transactional
-    public Map<String,Object> calculateGoodsDetail(String prodBarcode, String storeId) {
+    public Map<String,Object> calculateGoodsDetail(String prodBarcode, String storeId,String sku) {
         /**
          * 1.首先根据商品条码跟门店id查询是否有库存,没库存直接返回
          */
-        GoodsDetailsDto goods = queryGoodsDetailsByProdBarcode(prodBarcode,storeId);
+        GoodsDetailsDto goods = queryGoodsDetailsByProdBarcode(prodBarcode,storeId,sku);
         if(goods == null) {
             return null;
         }
@@ -2060,6 +2060,293 @@ public class GoodsServiceImpl implements GoodsService {
         return skuActivitiesMap;
     }
 
+    @Override
+    public List<Map<String,Object>> selectSkuDetails(String prodBarcode, String storeId) {
+        /**
+         * 1.首先根据商品条码跟门店id查询是否有库存,没库存直接返回
+         */
+        List<GoodsDetailsDto> goodsList = goodsDao.queryGoodsSkuList(prodBarcode,storeId);
+        List<Map<String,Object>> mapList = new ArrayList<>();
+         if (goodsList == null) {
+             return null;
+         }
+         for(GoodsDetailsDto goods : goodsList){
+             mapList.add(selectGetSkuDetails(goods,prodBarcode,storeId));
+         }
+         
+        return mapList;
+    }
+
+    public Map<String,Object> selectGetSkuDetails(GoodsDetailsDto goods,String prodBarcode, String storeId) {
+        /**
+         * 1.首先根据商品条码跟门店id查询是否有库存,没库存直接返回
+         */
+
+        goods.setDiscountedPrice(new BigDecimal(0));
+        BigDecimal retailPrice = goods.getRetailPrice();
+
+
+        goods.setActualPaymentAmount(retailPrice.setScale(2,RoundingMode.HALF_UP));
+
+        Map<String,Object> skuActivitiesMap = new HashMap<>();
+
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        /**
+         * 2.查询当前时间,该门店是否有活动,如果有活动,查询开启了哪些营销方式
+         * 参数: 当前时间  门店id
+         */
+        List<MkActivitiesEntity> mkActivitiesEntityList = mkActivitiesService.queryByNow(storeId,format.format(new Date()));
+
+        if(mkActivitiesEntityList == null || mkActivitiesEntityList.size() == 0){
+            // 计算税费
+            GoodsEntity goodsEntity = goodsDao.queryByBarcodeAndSku(prodBarcode, goods.getGoodsSn());
+            BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity,goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
+            goods.setGoodstaxes(tax.toString());
+            skuActivitiesMap.put("goods",goods);
+            return skuActivitiesMap;
+        }
+
+
+
+        // 遍历活动集合,查询有哪些活动是开启的
+        boolean daily = false,coupon = false,combinationPrice = false
+                ,discount = false,fullGift = false,fullReduction = false
+                ,getOneFree = false,promotion = false,halfPrice = false;
+
+        List<String> topicList = new ArrayList<>(); // 记录有哪些营销活动的topic
+        Map<String,String> mkaIdMap = new HashMap<>(); // 记录topic跟mkaId的关系
+        // 将所有的营销活动新增到list中
+        for(MkActivitiesEntity mkActivitiesEntity : mkActivitiesEntityList){
+            topicList.add(mkActivitiesEntity.getMkaTopic());
+            String mkaId = mkaIdMap.putIfAbsent(mkActivitiesEntity.getMkaTopic(), mkActivitiesEntity.getMkaId()+"");
+            if(StringUtils.isNotEmpty(mkaId)){
+//                mkaId = "'"+mkaId + "','" + mkActivitiesEntity.getMkaId()+"'";
+                mkaId += String.format(",%s",mkActivitiesEntity.getMkaId());
+                mkaIdMap.put(mkActivitiesEntity.getMkaTopic(),mkaId);
+            }
+        }
+        // 判断有哪些营销活动
+        if(topicList.contains("zhjsp")) // 组合价
+            combinationPrice = true;
+        if(topicList.contains("dz")) // 打折
+            discount = true;
+        if(topicList.contains("mz")) //满赠
+            fullGift = true;
+        if(topicList.contains("mj"))  // 满减
+            fullReduction = true;
+        if(topicList.contains("mysy")) // 买一送一
+            getOneFree = true;
+        if(topicList.contains("rchd")) // 日常活动
+            daily = true;
+        if(topicList.contains("yhq")) // 优惠券
+            coupon = true;
+        if(topicList.contains("lscx")) // 临时促销
+            promotion = true;
+        if(topicList.contains("drjbj"))
+            halfPrice = true;
+
+
+        // 获取未优惠前的商品价格
+        retailPrice = goods.getRetailPrice();
+
+
+        // 根据条码查询商品品牌名称 mall_brand  mall_product_store_rela  mall_goods
+        String brandName = goods.getBrand();
+
+        /**
+         * 优先级:临时促销 》买一送一=满赠 》 组合价=日常活动 》 打折=满减 》 优惠券
+         */
+
+        /**
+         * 组合价的做法就是将参与组合的条码带到收银端
+         * 现根据营销活动id跟条形码,查询有哪些参与该条码组合的商品
+         *
+         *
+         * TODO
+         */
+        if(combinationPrice){
+            String mkaId = mkaIdMap.get("zhjsp");
+            Map<String,Object> param = new HashMap<>();
+            param.put("mkaId",mkaId);
+            param.put("prodBarcode",prodBarcode);
+            List<MkActivitiesCombinationPriceEntity> combinationPriceList = combinationPriceService.queryList(param);
+            if(combinationPriceList != null && combinationPriceList.size() > 0) {
+                Map<String, List<MkActivitiesCombinationPriceEntity>> collect =
+                        combinationPriceList.stream().collect(Collectors.groupingBy(MkActivitiesCombinationPriceEntity::getCombinationType));
+
+                skuActivitiesMap.put("zhjsp",collect);
+            }
+        }
+
+
+
+        format = new SimpleDateFormat("yyyy-MM-dd");
+        String nowTime = format.format(new Date());
+        /**
+         * 满减可能是跟着条码,也可能跟着品牌
+         * 根据商品品牌跟商品条码去查询是否有优惠金额
+         *
+         * 满足金额   购买商品条码   赠品条码
+         *
+         */
+        Map<String,Object> fullReductionMap = new HashMap<>();
+        if(fullReduction){
+            String mkaId = mkaIdMap.get("mj");
+            MkActivitiesFullReductionEntity fullReductionEntity = fullReductionService.queryByCodeOrBrand(mkaId,prodBarcode,brandName,nowTime);
+            if(fullReductionEntity != null) {
+                if(!StringUtils.isNullOrEmpty(fullReductionEntity.getProductBrand())){
+                    // 跟着品牌走
+                    fullReductionMap.put(brandName,fullReductionEntity);
+                }else{
+                    // 跟着条码走
+                    fullReductionMap.put(fullReductionEntity.getBarcode(), fullReductionEntity);
+                }
+                skuActivitiesMap.put("mj",fullReductionMap);
+            }
+        }
+
+        /**
+         * 满赠可能是跟着条码,也可能跟着品牌
+         * 根据商品品牌跟商品条码去查询是否有满赠
+         * 1.先扫买的商品,然后查询出赠送的商品条码
+         * 2.先扫赠的商品,然后查询出符合条件的商品条码或者品牌
+         * 满足的金额   购买的商品条码或者品牌   赠送的商品条码
+         * TODO
+         */
+        Map<String,Object> fullGiftMap = new HashMap<>();
+        if(fullGift){
+            String mkaId = mkaIdMap.get("mz");
+            MkActivitiesFullGiftEntity giftEntity = fullGiftService.queryByCodeOrBrand(mkaId,prodBarcode,brandName,nowTime);
+            if(giftEntity != null) {
+                if(giftEntity.getProductBrand() != null){
+                    // 跟着品牌走
+                    fullGiftMap.put(brandName,giftEntity);
+                }else{
+                    // 跟着条码走
+                    fullGiftMap.put(giftEntity.getBarcode(), giftEntity);
+                }
+                skuActivitiesMap.put("mz",fullGiftMap);
+            }
+        }
+
+        /**
+         * 买一送一可能是跟着条码,也可能跟着品牌
+         * 根据商品品牌跟商品条码去查询是否有送的商品
+         * 有两个场景
+         * 1.先扫买的商品,然后查询出赠送的商品条码
+         * 2.先扫赠的商品,然后查询出符合条件的商品条码或者品牌
+         * 所以就需要一个map
+         * key为购买的商品条码或者商品品牌  value为赠送的商品条码
+         * 但是品牌是根据条码查询的,所以最终map里面的结构是
+         * key 商品条码 value 赠品条码
+         */
+        if(getOneFree){
+            String mkaId = mkaIdMap.get("mysy");
+            MkActivitiesGetOneFreeGoodsEntity getOneFreeGoodsEntity = getOneFreeGoodsService.queryByCodeOrBrand(mkaId,prodBarcode,brandName);
+            if(getOneFreeGoodsEntity != null){
+                if("无".equals(getOneFreeGoodsEntity.getProductBrand())){
+                    getOneFreeGoodsEntity.setBrand(false);
+                    skuActivitiesMap.put("mysy",getOneFreeGoodsEntity);
+                }else{
+                    getOneFreeGoodsEntity.setBrand(true);
+                    skuActivitiesMap.put("mysy",getOneFreeGoodsEntity);
+                }
+
+            }
+        }
+
+
+        // 第二份半价
+        if(halfPrice){
+            String mkaId = mkaIdMap.get("drjbj");
+            MkActivitiesHalfPriceEntity activitiesHalfPriceEntity = halfPriceService.queryByCodeOrBrand(mkaId,prodBarcode);
+            if(activitiesHalfPriceEntity != null){
+                skuActivitiesMap.put("drjbj",activitiesHalfPriceEntity);
+
+            }
+
+        }
+
+
+        // --------------------------------------------------------------------------------------
+
+        /**
+         * 优惠券跟着条形码走,一般是设置一个标识,然后最后输入优惠券码后,减扣对应的标识,所以返回一个map数组
+         */
+
+        if(coupon){
+            String mkaId = mkaIdMap.get("yhq");
+            MkActivitiesCouponEntity couponEntity =  couponService.queryByBarCode(mkaId,prodBarcode,nowTime);
+            if(couponEntity != null){ // 优惠券码,优惠金额
+                Map<String,Object> returnMap = new HashMap<>();
+                returnMap.put(couponEntity.getCouponSn() , couponEntity.getCouponPrice());
+                skuActivitiesMap.put("yhq",returnMap);
+            }
+        }
+
+
+        /**
+         * 打折的价格是与条形码对应的,所以需要根据条形码和营销方式id去查询活动价格
+         */
+
+        if(discount){
+            String mkaId = mkaIdMap.get("dz");
+            MkActivitiesDiscountEntity discountEntity =  discountService.queryByBarCode(mkaId,prodBarcode);
+            // TODO 可能会直接替代产品价格
+            if (discountEntity != null) {
+                goods.setActualPaymentAmount(discountEntity.getActivityPrice());
+                goods.setRetailPrice(discountEntity.getActivityPrice());
+
+                goods.setActivity("打折");
+            }
+        }
+
+
+        /**
+         * 日常活动跟着条形码走,优先级比临时促销低,但是高于正常价格
+         */
+        if(daily){
+            String mkaId = mkaIdMap.get("rchd");
+            MkDailyActivitiesEntity dailyActivitiesEntity = dailyActivitiesService.queryByBarCode(mkaId,prodBarcode);
+            if(dailyActivitiesEntity != null){
+                goods.setActualPaymentAmount(dailyActivitiesEntity.getActivityPrice());
+                goods.setRetailPrice(dailyActivitiesEntity.getActivityPrice());
+
+                goods.setActivity("日常活动");
+
+            }
+        }
+
+
+        /**
+         * 临时促销跟着条形码走,优先级应该最高,所以排到了最下面
+         */
+        if(promotion){
+            String mkaId = mkaIdMap.get("lscx");
+            MkActivitiesPromotionEntity promotionEntity = promotionService.queryByBarCode(mkaId,prodBarcode);
+            // 如果该商品存在临时促销,直接替换活动价格
+            if(promotionEntity != null){
+                goods.setActualPaymentAmount(promotionEntity.getActivityPrice());
+                goods.setRetailPrice(promotionEntity.getActivityPrice());
+
+                goods.setActivity("临时促销");
+
+            }
+        }
+
+        // 计算税费
+        GoodsEntity goodsEntity = goodsDao.queryByBarcodeAndSku(prodBarcode, goods.getGoodsSn());
+        BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity,goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
+        goods.setGoodstaxes(tax.toString());
+
+
+        skuActivitiesMap.put("goods",goods);
+        return skuActivitiesMap;
+    }
+
+
+
     /**
      * 根据条形码查询商品
      *

+ 2 - 2
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -1906,9 +1906,9 @@ public class OrderServiceImpl implements OrderService {
                 Integer goodsSellNumber = (Integer) goodsDto.get("sellVolume");
 
                 String prodBarcode = (String) goodsDto.get("prodBarcode");
-
+                String sku = (String) goodsDto.get("goodsSn");
                 Map<GoodsEntity, Integer> numberMap = new HashMap<>();
-                List<GoodsEntity> queryGoodsList = goodsDao.queryListByBarcode(prodBarcode, storeId);
+                List<GoodsEntity> queryGoodsList = goodsDao.queryListByBarcode(prodBarcode, storeId,sku);
                 if (queryGoodsList != null && queryGoodsList.size() != 0) {
                     for (GoodsEntity goodsEntity : queryGoodsList) {
                         // 如果当前还有需要购买的

+ 1 - 1
kmall-admin/src/main/java/com/kmall/admin/task/TestTask.java

@@ -43,7 +43,7 @@ public class TestTask {
 
     @Scheduled(cron = "0/5 * * * * ?")
     public void flushPickUpCode() {
-        logger.info("flushPickUpCode-----------------" );
+        //logger.info("flushPickUpCode-----------------" );
 
 
         WebSocketServer.broadcastInfo("broadcast");

+ 20 - 1
kmall-admin/src/main/resources/mybatis/mapper/GoodsDao.xml

@@ -259,10 +259,29 @@
         LEFT JOIN mall_goods_specification r ON r.goods_id = a.id
         left join mall_product_store_rela m on m.goods_id = a.id and r.goods_id = m.goods_id
         where a.prod_barcode = #{prodBarcode} and m.store_id = #{storeId}
+        <if test="sku != null and sku != ''">
+            and a.sku=#{sku}
+        </if>
         and m.stock_num > 0 order by m.stock_num desc
         limit 1
     </select>
 
+    <select id="queryGoodsSkuList" resultType="com.kmall.admin.dto.GoodsDetailsDto">
+        SELECT distinct
+        a.goods_sn as GoodsSn,m.retail_price as retailPrice,a.prod_barcode as prodBarcode,a.name,
+        a.brand,a.goods_desc as goodsDesc,a.goods_unit as goodsUnit,a.goods_rate as goodsRate,a.primary_pic_url ,
+        m.stock_num as stockNum,r.value as specification
+        ,a.hs_code as hsCode , a.legal_unit1_qty as legalUnit1Qty , a.legal_unit2_qty as legalUnit2Qty,
+        a.ciq_prod_model as ciqProdModel,a.to_be_restored,a.sku as sku,a.name,a.goods_number as goodsName,a.market_price as marketPrice
+        FROM
+            mall_goods a
+        LEFT JOIN mall_goods_specification r ON r.goods_id = a.id
+        left join mall_product_store_rela m on m.goods_id = a.id and r.goods_id = m.goods_id
+        where a.prod_barcode = #{prodBarcode} and m.store_id = #{storeId}
+        and m.stock_num > 0 order by m.stock_num desc
+
+    </select>
+
 
     <select id="queryObjectBySn" resultType="com.kmall.admin.entity.GoodsEntity">
         SELECT
@@ -800,7 +819,7 @@
             mall_goods a
         LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
         inner join mall_store s on r.store_id=s.id
-        where a.prod_barcode = #{prodBarcode}  and r.store_id = #{storeId}
+        where a.prod_barcode = #{prodBarcode}  and r.store_id = #{storeId} and a.sku = #{sku}
         and r.stock_num > 0 order by r.stock_num desc
     </select>
 

+ 82 - 0
kmall-admin/src/main/webapp/WEB-INF/page/sale/sale.html

@@ -21,6 +21,48 @@
             margin-left: 20px;
         }
 
+        .modal-contentNew {
+            position: relative;
+            background-color: #fff;
+            -webkit-background-clip: padding-box;
+            background-clip: padding-box;
+            border: 1px solid #999;
+            border: 1px solid rgba(0, 0, 0, .2);
+            border-radius: 6px;
+            outline: 0;
+            -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
+            box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
+
+            height: 260px;
+            width: 70%;
+            margin: auto;
+        }
+
+
+        .tableNew {
+            position: relative;
+            border-collapse: collapse !important;
+            left:0px;
+            top:-1001px;
+            width: 60%;
+            height: 128px;
+            background-color: #fff;
+            -webkit-background-clip: padding-box;
+            background-clip: padding-box;
+            border: 1px solid #999;
+            border: 1px solid rgba(0, 0, 0, .2);
+            border-radius: 6px;
+            outline: 0;
+            -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
+            box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
+            margin: auto;
+        }
+
+        .modal-footerNew{
+            position: relative;
+            left:125px;
+            top:-761px;
+        }
 
         .search_menu{
             /*border-top:5px solid #3388FF;*/
@@ -391,6 +433,46 @@
                     </div>
                 </div><!-- /.modal -->
             </div>
+
+
+            <!--            多sku选择框-->
+            <div>
+                <div id="orderSkuDetail" v-if="openSku" >
+                    <table id="goodsSkuDetailTable" class="tableNew table .table-striped ">
+                        <tr style="border: white;background-color: orange">
+                            <th>商品名称</th>
+                            <th>sku</th>
+                            <th>条码</th>
+                            <th>单价</th>
+                            <th>库存数</th>
+                            <th>实际支付价</th>
+                            <th>参与活动</th>
+                            <th>操作</th>
+                            <th><i class="glyphicon glyphicon-remove" @click="cancelNew"></i></th>
+                        </tr>
+                        <tr v-for="(item,i) in goodsSkuDetailList">
+                            <td>{{item.name}}</td>
+                            <td>{{item.sku}}</td>
+                            <td>{{item.prodBarcode}}</td>
+                            <td>{{item.retailPrice}}</td>
+                            <td>{{item.stockNum}}</td>
+                            <td>{{item.actualPaymentAmount}}</td>
+                            <td>{{item.activity}}</td>
+                            <td>
+                                <button type="button" v-if="openSku" style="margin:0 30px 0 -20px;font-size: 20px;" class="btn btn-primary" @click="saveNew(item.sku)" id="saveNew" data-dismiss="modal">确定</button>
+                            </td>
+                        </tr>
+                    </table>
+
+                </div>
+
+<!--                <div class="modal-footerNew">-->
+<!--                    <button type="button" v-if="openSku" style="margin:0 30px 0 20px;font-size: 25px;" class="btn btn-primary" @click="saveNew" id="saveNew" data-dismiss="modal">确定</button>-->
+<!--                    <button type="button" v-if="openSku" style="margin:0 30px 0 20px;font-size: 25px;" class="btn btn-primary" @click="cancelNew" id="cancelNew" data-dismiss="modal">取消</button>-->
+<!--                </div>-->
+            </div>
+
+
         </div>
     </div>
 </div>

+ 65 - 17
kmall-admin/src/main/webapp/js/sale/sale.js

@@ -28,7 +28,6 @@ function debounce(fn,delay){
     }
 }
 
-
 function calculateGoodsPrice(r){
 
     var rMap = r.map;
@@ -517,6 +516,7 @@ let vm = new Vue({
         sessionId:null,
         pickUpCodeList:[],
         goodsDetailList:[],
+        goodsSkuDetailList:[],
         orderEntity:{},
         orderProcessRecord:{},
         tax:0,
@@ -589,6 +589,7 @@ let vm = new Vue({
         delayResponse:false,
 
         canRefund:true,
+        openSku:false,
 
     },
     watch: {
@@ -662,25 +663,71 @@ let vm = new Vue({
             vm.storeId = sessionStorage.getItem("storeId");
             var thisGoods = {};
             var overflowLi = this.$refs.overflowLi;
-            $.get("../goods/details/"+vm.prodBarcode+"/"+vm.storeId, function (r) {
+            $.get("../goods/selectSkuDetails/"+vm.prodBarcode+"/"+vm.storeId, function (r) {
                 if (r.code == 0) {
+                    if(r.goodsDetails.length>1) {
+                        r.goodsDetails.sellVolume = 1;
+                        vm.openSku = true;
+                        vm.goodsSkuDetailList = JSON.parse(JSON.stringify(r.goodsDetails));
+                        //此时必须异步执行滚动条滑动至底部
+                        setTimeout(()=>{
+                            overflowLi.scrollTop = overflowLi.scrollHeight;
+                        },0)
+                    }else{
+                        vm.saveOld();
+                    }
 
-                    r.goodsDetails.sellVolume = 1;
-                    vm.goodsMap.set(r.goodsDetails.goodsSn,JSON.parse(JSON.stringify(r.goodsDetails)));
-                    vm.prodBarcode = '';
-                    calculateGoodsPrice(r);
-                    handle(r.goodsDetails,"add");
-
-                    //此时必须异步执行滚动条滑动至底部
-                    setTimeout(()=>{
-                        overflowLi.scrollTop = overflowLi.scrollHeight;
-                    },0)
                 } else {
                     alert(r.msg);
                 }
             });
 
         },
+        saveNew:function(value){
+            vm.storeId = sessionStorage.getItem("storeId");
+            var overflowLi = this.$refs.overflowLi;
+            // confirm('确定吗?', function () {
+                $.get("../goods/details/"+vm.prodBarcode+"/"+vm.storeId+"/"+value, function (r) {
+                    if (r.code == 0) {
+                            r.goodsDetails.sellVolume = 1;
+                            vm.goodsMap.set(r.goodsDetails.goodsSn,JSON.parse(JSON.stringify(r.goodsDetails)));
+                            vm.prodBarcode = '';
+                            calculateGoodsPrice(r);
+                            handle(r.goodsDetails,"add");
+                            vm.openSku = false;
+                            //此时必须异步执行滚动条滑动至底部
+                            setTimeout(()=>{
+                                overflowLi.scrollTop = overflowLi.scrollHeight;
+                            },0)
+                    } else {
+                        alert(r.msg);
+                    }
+                });
+            // })
+        },
+        saveOld:function(){
+            vm.storeId = sessionStorage.getItem("storeId");
+            var overflowLi = this.$refs.overflowLi;
+                $.get("../goods/detailsOld/"+vm.prodBarcode+"/"+vm.storeId, function (r) {
+                    if (r.code == 0) {
+                        r.goodsDetails.sellVolume = 1;
+                        vm.goodsMap.set(r.goodsDetails.goodsSn,JSON.parse(JSON.stringify(r.goodsDetails)));
+                        vm.prodBarcode = '';
+                        calculateGoodsPrice(r);
+                        handle(r.goodsDetails,"add");
+                        vm.openSku = false;
+                        //此时必须异步执行滚动条滑动至底部
+                        setTimeout(()=>{
+                            overflowLi.scrollTop = overflowLi.scrollHeight;
+                        },0)
+                    } else {
+                        alert(r.msg);
+                    }
+                });
+        },
+        cancelNew: function(){
+            vm.openSku=false;
+        },
         add:function(value){
             // 增加数量
             for(var i = 0 ; i < this.goodsList.length ; i++){
@@ -736,6 +783,9 @@ let vm = new Vue({
             }
 
         },
+        selectItem:function(value) {
+            console.log(value);
+        },
         deleteItem:function(value){
             console.log(value);
             // 删除这条记录
@@ -801,8 +851,6 @@ let vm = new Vue({
         },
         clearGoodsList:function(){
             confirm('确认清空吗?', function () {
-                vm.goodsList = [];
-                vm.customClearData();
                 alert("清空成功");
             })
 
@@ -1325,11 +1373,11 @@ function openWebSocket() {
         //无法使用wss,浏览器打开WebSocket时报错
         //ws对应http、wss对应https。
         //kmall测试环境
-        //webSocket = new WebSocket("ws://183.62.225.124:8080/ws/server/"+storeId);
+        webSocket = new WebSocket("ws://183.62.225.124:8080/ws/server/"+storeId);
         //kmall正式环境
-        webSocket = new WebSocket("ws://8.135.102.238:8080/ws/server/"+storeId);
+        //webSocket = new WebSocket("ws://8.135.102.238:8080/ws/server/"+storeId);
         //kmall本地环境
-        // webSocket = new WebSocket("ws://127.0.0.1:50/ws/server/"+163);
+        //webSocket = new WebSocket("ws://127.0.0.1:50/ws/server/"+163);
         // webSocket = new WebSocket("wss://cb.k1net.cn/ws/server/"+storeId);
         if (webSocket.readyState === webSocket.CONNECTING) {
             console.log('1.连接正在打开......');