Kaynağa Gözat

商品管理修改,门店商品修改

dq 6 yıl önce
ebeveyn
işleme
cce4c57fb7

+ 0 - 3
kmall-admin/src/main/java/com/kmall/admin/controller/ProductStoreRelaController.java

@@ -1,7 +1,6 @@
 package com.kmall.admin.controller;
 
 import com.kmall.admin.entity.ProductStoreRelaEntity;
-import com.kmall.admin.service.ProductService;
 import com.kmall.admin.service.ProductStoreRelaService;
 import com.kmall.common.utils.PageUtils;
 import com.kmall.common.utils.Query;
@@ -27,8 +26,6 @@ import java.util.Map;
 public class ProductStoreRelaController {
     @Autowired
     private ProductStoreRelaService productStoreRelaService;
-    @Autowired
-    private ProductService productService;
 
     /**
      * 查看列表

+ 5 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/GoodsDao.java

@@ -3,6 +3,9 @@ package com.kmall.admin.dao;
 import com.kmall.admin.entity.GoodsEntity;
 import com.kmall.common.dao.BaseDao;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * Dao
  *
@@ -14,4 +17,6 @@ public interface GoodsDao extends BaseDao<GoodsEntity> {
     Long queryMaxId();
 
     GoodsEntity queryObjectBySn(String goodsSn);
+
+    List<GoodsEntity> querySame(Map<String, Object> map);
 }

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

@@ -32,6 +32,8 @@ public interface GoodsService {
      */
     List<GoodsEntity> queryList(Map<String, Object> map);
 
+    List<GoodsEntity> querySame(Map<String, Object> map);
+
     /**
      * 分页统计总数
      *

+ 8 - 3
kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java

@@ -58,7 +58,6 @@ public class GoodsServiceImpl implements GoodsService {
         GoodsEntity entity = goodsDao.queryObject(id);
         entity.setAttributeEntityList(attributeEntities);
         entity.setProductEntityList(productEntityList);
-        entity.setAttributeCategory(categoryDao.queryObject(entity.getCategoryId()).getParentId());
         return entity;
     }
 
@@ -68,6 +67,11 @@ public class GoodsServiceImpl implements GoodsService {
     }
 
     @Override
+    public List<GoodsEntity> querySame(Map<String, Object> map) {
+        return goodsDao.querySame(map);
+    }
+
+    @Override
     public int queryTotal(Map<String, Object> map) {
         return goodsDao.queryTotal(map);
     }
@@ -122,7 +126,7 @@ public class GoodsServiceImpl implements GoodsService {
         map.put("sku", goods.getSku());
         map.put("goodsSn", goods.getGoodsSn());
         map.put("goodsBizType", goods.getGoodsBizType());
-        List<GoodsEntity> list = queryList(map);
+        List<GoodsEntity> list = querySame(map);
         if (list != null && list.size() != 0) {
             throw new RRException("已存在该商品编码或该货品业务类型下已存在此SKU!");
         }
@@ -235,7 +239,8 @@ public class GoodsServiceImpl implements GoodsService {
         map.put("sku", goods.getSku());
         map.put("goodsSn", goods.getGoodsSn());
         map.put("goodsBizType", goods.getGoodsBizType());
-        List<GoodsEntity> list = queryList(map);
+        map.put("id", goods.getId());
+        List<GoodsEntity> list = querySame(map);
         if (list != null && list.size() != 0) {
             throw new RRException("已存在该商品编码或该货品业务类型下已存在此SKU!");
         }

+ 7 - 5
kmall-admin/src/main/java/com/kmall/admin/service/impl/ProductStoreRelaServiceImpl.java

@@ -64,7 +64,7 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
         ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
         builder.put("storeId", "门店");
         builder.put("goodsId", "商品");
-        builder.put("goodsNumber", "库存");
+        builder.put("stockNum", "库存");
 
         GoodsEntity goodsEntity = goodsDao.queryObject(productStoreRela.getGoodsId());
         if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
@@ -78,6 +78,7 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
         }
 
         SysUserEntity user = ShiroUtils.getUserEntity();
+        ProductEntity product = productDao.queryObjectBySn(goodsEntity.getGoodsSn());
         if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
             // 添加商品规格
             GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
@@ -87,7 +88,6 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
             goodsSpecificationDao.save(goodsSpecification);
 
             // 修改产品
-            ProductEntity product = productDao.queryObjectBySn(goodsEntity.getGoodsSn());
             product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
             product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
             productDao.update(product);
@@ -95,7 +95,9 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
             productStoreRela.setRetailPrice(goodsEntity.getRetailPrice());
         }
 
-
+        productStoreRela.setProductId(product.getId());
+        productStoreRela.setGoodsBizType(goodsEntity.getGoodsBizType());
+        productStoreRela.setSku(goodsEntity.getSku());
         productStoreRela.setCreaterSn(user.getUserId().toString());
         productStoreRela.setCreateTime(new Date());
         productStoreRela.setModerSn(user.getUserId().toString());
@@ -109,13 +111,13 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
         ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
         builder.put("storeId", "门店");
         builder.put("goodsId", "商品");
-        builder.put("goodsNumber", "库存");
-        builder.put("retailPrice", "零售价");
+        builder.put("stockNum", "库存");
 
         GoodsEntity goodsEntity = goodsDao.queryObject(productStoreRela.getGoodsId());
         if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
             // 普通商品校验商品规格
             builder.put("specification", "规格");
+            builder.put("retailPrice", "零售价");
         }
         R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
         if (Integer.valueOf(r.get("code").toString()) != 0) {

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

@@ -113,8 +113,39 @@
         <if test="isDelete != null and isDelete != ''">
             AND mall_goods.is_Delete = #{isDelete}
         </if>
+        <choose>
+            <when test="sidx != null and sidx.trim() != ''">
+                order by ${sidx} ${order}
+            </when>
+            <otherwise>
+                order by mall_goods.id desc
+            </otherwise>
+        </choose>
+        <if test="offset != null and limit != null">
+            limit #{offset}, #{limit}
+        </if>
+    </select>
+
+    <select id="querySame" resultType="com.kmall.admin.entity.GoodsEntity">
+        select
+        mall_goods.*,
+        mall_category.name category_name,
+        mall_brand.name brand_name,
+        mall_freight.name freight_name,
+        case when mall_goods_group.id > 0 then 2 else 0 end as goodsType
+        from mall_goods
+        LEFT JOIN mall_category ON mall_goods.category_id = mall_category.id
+        LEFT JOIN mall_brand ON mall_brand.id = mall_goods.brand_id
+        left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
+        left join mall_freight on mall_goods.freight_id = mall_freight.id
+        WHERE 1=1
+        <!--  数据过滤  -->
+        ${filterSql}
         <if test="isSame != null and isSame != ''">
-            AND (mall_goods.sku = #{sku} AND mall_goods.goods_biz_type = #{goodsBizType}) OR mall_goods.goods_sn = #{goodsSn}
+            AND ((mall_goods.sku = #{sku} AND mall_goods.goods_biz_type = #{goodsBizType}) OR mall_goods.goods_sn = #{goodsSn})
+            <if test="id != null and id != ''">
+                AND mall_goods.id != #{id}
+            </if>
         </if>
         <choose>
             <when test="sidx != null and sidx.trim() != ''">

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

@@ -282,7 +282,7 @@
     </update>
 
     <select id="queryByGoodsId" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
-        selecta.*
+        select a.*
 		from mall_product_store_rela a
 		where a.goods_id = #{goodsId}
     </select>

+ 1 - 1
kmall-admin/src/main/webapp/WEB-INF/page/shop/storeProductStock.html

@@ -110,7 +110,7 @@
                     <i-option v-for="goods in goodss" :value="goods.id" :key="goods.id">{{goods.name}}</i-option>
                 </i-select>
             </Form-item>
-            <Form-item label="库存" prop="goodsNumber">
+            <Form-item label="库存" prop="stockNum">
                 <Input-number :min="0" :step="1" v-model="productStoreRela.stockNum" placeholder="总库存"
                               style="width: 268px;"/>
             </Form-item>

+ 3 - 3
kmall-admin/src/main/webapp/js/shop/goods.js

@@ -194,7 +194,7 @@ var vm = new Vue({
             vm.macros = [];
             vm.brands = [];
             vm.freights = [];
-            vm.attributeEntityList = [];
+            vm.attributeEntityList = [{'id': '', 'goodsId': '', 'attributeId': '', 'value': '', 'isDelete': 0}];
             vm.attributeCategories = [];
             vm.getMacro();
             vm.getBrand();
@@ -369,8 +369,8 @@ var vm = new Vue({
             $.get("../goods/info/" + id, function (r) {
                 vm.goods = r.goods;
                 // vm.getCategory();
-                vm.goods.category = r.goods.attributeCategory;
-                vm.changeCategories(vm.goods.category);
+                var opt = {}; opt.value = vm.goods.attributeCategory;
+                vm.changeCategories(opt);
                 if (r.goods.attributeEntityList.length > 0) {
                     vm.attributeEntityList = r.goods.attributeEntityList;
                 } else {

+ 17 - 3
kmall-admin/src/main/webapp/js/shop/storeProductStock.js

@@ -6,13 +6,26 @@ $(function () {
             {label: 'ID', name: 'id', index: 'id', hidden: true, key: true},
             {label: '门店', name: 'storeName', index: 'storeName'},
             {label: '商品类型', name: 'categoryName', index: 'categoryName', width: 80},
+            {
+                label: '货品业务类型', name: 'goodsBizType', index: 'goods_biz_type', width: 70,
+                formatter: function (value) {
+                    if (value == '00') {
+                        return '保税备货';
+                    } else if (value == '02') {
+                        return '保税展示补货';
+                    } else if (value == '10') {
+                        return '保税展示跨境';
+                    }
+                    return '普通货物';
+                }
+            },
             {label: '商品编码', name: 'goodsSn', index: 'goodsSn'},
             {label: '名称', name: 'goodsName', index: 'goodsName', width: 160},
             {label: '产品编码', name: 'productSn', index: 'productSn'},
             {label: '库存', name: 'stockNum', index: 'stockNum', width: 80},
             {label: '零售价格', name: 'retailPrice', index: 'retailPrice', width: 80},
-            {label: '市场价', name: 'marketPrice', index: 'marketPrice', width: 80},
-            {label: '库存价格', name: 'stockPrice', index: 'stockPrice', width: 80},
+            // {label: '市场价', name: 'marketPrice', index: 'marketPrice', width: 80},
+            // {label: '库存价格', name: 'stockPrice', index: 'stockPrice', width: 80},
             {
                 label: '销售量',
                 name: 'sellVolume',
@@ -89,7 +102,7 @@ var vm = new Vue({
         uploadList: [],
         imgName: '',
         visible: false,
-        productStoreRela: {},
+        productStoreRela: { stockNum: '', retailPrice: '' },
         ruleValidate: {
             /*storeId: [
                 {required: true, message: '门店不能为空'}
@@ -134,6 +147,7 @@ var vm = new Vue({
             vm.showList = false;
             vm.title = "新增";
             vm.uploadList = [];
+            vm.productStoreRela = { stockNum: '', retailPrice: '' };
             vm.getMacro();
             vm.getGoods();
         },