Parcourir la source

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

dq il y a 6 ans
Parent
commit
840772692a

+ 2 - 18
kmall-admin/src/main/java/com/kmall/admin/controller/ProductStoreRelaController.java

@@ -65,24 +65,8 @@ public class ProductStoreRelaController {
     @RequiresPermissions("productstorerela:save")
     @ResponseBody
     public R save(@RequestBody ProductStoreRelaEntity productStoreRela) {
-//        if (null == productStoreRela.getProductId() && StringUtils.isNotEmpty(productStoreRela.getProductSn())) {
-//            ProductEntity productEntity = productService.queryObjectBySn(productStoreRela.getProductSn());
-//            productStoreRela.setProductId(productEntity.getId());
-//            productStoreRela.setGoodsId(productEntity.getGoodsId());
-//        }
-        if (null == productStoreRela.getProductId() || null == productStoreRela.getGoodsId()
-                || null == productStoreRela.getStoreId()) {
-            return R.error("信息不全,保存失败");
-        }
-        productStoreRela.setCreateTime(new Date());
-        productStoreRela.setModTime(new Date());
-        ProductStoreRelaEntity productStoreRelaDb = productStoreRelaService.queryByStoreIdProductId(productStoreRela.getStoreId(), productStoreRela.getProductId());
-        if (null != productStoreRelaDb) {
-            productStoreRela.setId(productStoreRelaDb.getId());
-            productStoreRelaService.update(productStoreRela);
-        } else {
-            productStoreRelaService.save(productStoreRela);
-        }
+        productStoreRelaService.save(productStoreRela);
+
         return R.ok();
     }
 

+ 4 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/ProductStoreRelaDao.java

@@ -4,6 +4,8 @@ import com.kmall.admin.entity.ProductStoreRelaEntity;
 import org.apache.ibatis.annotations.Param;
 import com.kmall.common.dao.BaseDao;
 
+import java.util.List;
+
 /**
  * Dao
  *
@@ -16,4 +18,6 @@ public interface ProductStoreRelaDao extends BaseDao<ProductStoreRelaEntity> {
     int deleteByGoodsId(Integer goodsId);
 
     ProductStoreRelaEntity queryByStoreIdProductId(@Param("storeId") Long storeId, @Param("productId") Long productId);
+
+    List<ProductStoreRelaEntity> queryByGoodsId(Long id);
 }

+ 11 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/ProductStoreRelaEntity.java

@@ -74,6 +74,9 @@ public class ProductStoreRelaEntity implements Serializable {
 
     private Date tstm;
 
+    // 规格
+    private String specification;
+
     public String getSku() {
         return sku;
     }
@@ -271,4 +274,12 @@ public class ProductStoreRelaEntity implements Serializable {
     public void setSellVolume(BigDecimal sellVolume) {
         this.sellVolume = sellVolume;
     }
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
 }

+ 16 - 6
kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java

@@ -93,7 +93,7 @@ public class GoodsServiceImpl implements GoodsService {
         builder.put("retailPrice", "零售价格");
         builder.put("isHot", "热销");
 
-        if (!Dict.orderBizType.item_11.equals(goods.getGoodsBizType())) {
+        if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
             // 海关信息,普通货物可不添加
             builder.put("sku", "SKU");
             builder.put("prodBarcode", "产品编码");
@@ -170,7 +170,7 @@ public class GoodsServiceImpl implements GoodsService {
         product.setGoodsId(id);
         product.setGoodsSn(goods.getGoodsSn());
         // 保税商品,普通货物暂不添加商品规格
-        if (!Dict.orderBizType.item_11.equals(goods.getGoodsBizType())) {
+        if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
             // 添加商品规格
             GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
             goodsSpecification.setGoodsId(id);
@@ -203,12 +203,12 @@ public class GoodsServiceImpl implements GoodsService {
         builder.put("primaryPicUrl", "商品主图");
         builder.put("listPicUrl", "商品列表图");
         builder.put("goodsRate", "商品税率");
-        builder.put("retailPrice", "零售价格");
         builder.put("isHot", "热销");
 
-        if (!Dict.orderBizType.item_11.equals(goods.getGoodsBizType())) {
+        if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
             // 海关信息,普通货物可不添加
             builder.put("sku", "SKU");
+            builder.put("retailPrice", "零售价");
             builder.put("prodBarcode", "产品编码");
             builder.put("brand", "产品品牌");
             builder.put("unitCode", "计量单位代码");
@@ -240,7 +240,6 @@ public class GoodsServiceImpl implements GoodsService {
             throw new RRException("已存在该商品编码或该货品业务类型下已存在此SKU!");
         }
 
-
         // 修改商品
         goods.setAttributeCategory(categoryDao.queryObject(goods.getCategoryId()).getParentId());
         goods.setIsDelete(0);
@@ -252,6 +251,17 @@ public class GoodsServiceImpl implements GoodsService {
         // 修改商品
         goodsDao.update(goods);
 
+        // 保税商品修改各个门店商品价格
+        if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
+            List<ProductStoreRelaEntity> productStoreRelaEntityList = productStoreRelaDao.queryByGoodsId(goods.getId());
+            if (productStoreRelaEntityList != null && productStoreRelaEntityList.size() > 0) {
+                for (ProductStoreRelaEntity productStoreRela : productStoreRelaEntityList) {
+                    productStoreRela.setRetailPrice(goods.getRetailPrice());
+                    productStoreRelaDao.update(productStoreRela);
+                }
+            }
+        }
+
         // 修改商品轮播图
         goodsGalleryDao.deleteByGoodsId(goods.getId());
         for (GoodsGalleryEntity galleryEntity : galleryEntityList) {
@@ -283,7 +293,7 @@ public class GoodsServiceImpl implements GoodsService {
         // 修改产品
         ProductEntity product = productDao.queryObjectBySn(goods.getGoodsSn());
         // 保税商品,普通货物暂不添加商品规格
-        if (!Dict.orderBizType.item_11.equals(goods.getGoodsBizType())) {
+        if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
             // 添加商品规格
             GoodsSpecificationEntity goodsSpecification = goodsSpecificationDao.queryByGoodsId(goods.getId());
             goodsSpecification.setValue(goods.getCiqProdModel());

+ 92 - 0
kmall-admin/src/main/java/com/kmall/admin/service/impl/ProductStoreRelaServiceImpl.java

@@ -1,11 +1,22 @@
 package com.kmall.admin.service.impl;
 
+import com.google.common.collect.ImmutableBiMap;
+import com.kmall.admin.dao.GoodsDao;
+import com.kmall.admin.dao.GoodsSpecificationDao;
+import com.kmall.admin.dao.ProductDao;
 import com.kmall.admin.dao.ProductStoreRelaDao;
+import com.kmall.admin.entity.GoodsEntity;
+import com.kmall.admin.entity.GoodsSpecificationEntity;
+import com.kmall.admin.entity.ProductEntity;
 import com.kmall.admin.entity.ProductStoreRelaEntity;
 import com.kmall.admin.service.ProductStoreRelaService;
+import com.kmall.api.contants.Dict;
+import com.kmall.common.entity.SysUserEntity;
+import com.kmall.common.utils.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -20,6 +31,12 @@ import java.util.Map;
 public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
     @Autowired
     private ProductStoreRelaDao productStoreRelaDao;
+    @Autowired
+    private GoodsDao goodsDao;
+    @Autowired
+    private GoodsSpecificationDao goodsSpecificationDao;
+    @Autowired
+    private ProductDao productDao;
 
     @Override
     public ProductStoreRelaEntity queryObject(Integer id) {
@@ -43,11 +60,86 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
 
     @Override
     public int save(ProductStoreRelaEntity productStoreRela) {
+        Map<String, Object> valideDate = MapBeanUtil.fromObject(productStoreRela);
+        ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
+        builder.put("storeId", "门店");
+        builder.put("goodsId", "商品");
+        builder.put("goodsNumber", "库存");
+
+        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) {
+            throw new RRException(r.get("msg").toString());
+        }
+
+        SysUserEntity user = ShiroUtils.getUserEntity();
+        if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
+            // 添加商品规格
+            GoodsSpecificationEntity goodsSpecification = new GoodsSpecificationEntity();
+            goodsSpecification.setGoodsId(goodsEntity.getId());
+            goodsSpecification.setValue(productStoreRela.getSpecification());
+            goodsSpecification.setSpecificationId(1);
+            goodsSpecificationDao.save(goodsSpecification);
+
+            // 修改产品
+            ProductEntity product = productDao.queryObjectBySn(goodsEntity.getGoodsSn());
+            product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
+            product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
+            productDao.update(product);
+        } else {
+            productStoreRela.setRetailPrice(goodsEntity.getRetailPrice());
+        }
+
+
+        productStoreRela.setCreaterSn(user.getUserId().toString());
+        productStoreRela.setCreateTime(new Date());
+        productStoreRela.setModerSn(user.getUserId().toString());
+        productStoreRela.setModTime(new Date());
         return productStoreRelaDao.save(productStoreRela);
     }
 
     @Override
     public int update(ProductStoreRelaEntity productStoreRela) {
+        Map<String, Object> valideDate = MapBeanUtil.fromObject(productStoreRela);
+        ImmutableBiMap.Builder builder = new ImmutableBiMap.Builder();
+        builder.put("storeId", "门店");
+        builder.put("goodsId", "商品");
+        builder.put("goodsNumber", "库存");
+        builder.put("retailPrice", "零售价");
+
+        GoodsEntity goodsEntity = goodsDao.queryObject(productStoreRela.getGoodsId());
+        if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
+            // 普通商品校验商品规格
+            builder.put("specification", "规格");
+        }
+        R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
+        if (Integer.valueOf(r.get("code").toString()) != 0) {
+            throw new RRException(r.get("msg").toString());
+        }
+
+        SysUserEntity user = ShiroUtils.getUserEntity();
+        if (Dict.orderBizType.item_11.getItem().equals(goodsEntity.getGoodsBizType())) {
+            // 添加商品规格
+            GoodsSpecificationEntity goodsSpecification = goodsSpecificationDao.queryByGoodsId(goodsEntity.getId());
+            goodsSpecification.setValue(productStoreRela.getSpecification());
+            goodsSpecificationDao.update(goodsSpecification);
+
+            // 修改产品
+            ProductEntity product = productDao.queryObjectBySn(goodsEntity.getGoodsSn());
+            product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
+            product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
+            productDao.update(product);
+        } else {
+            productStoreRela.setRetailPrice(goodsEntity.getRetailPrice());
+        }
+
+        productStoreRela.setModerSn(user.getUserId().toString());
+        productStoreRela.setModTime(new Date());
         return productStoreRelaDao.update(productStoreRela);
     }
 

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

@@ -118,7 +118,7 @@
         </foreach>
     </delete>
 
-    <select id="queryByGoodsId" resultMap="com.kmall.admin.entity.GoodsSpecificationEntity">
+    <select id="queryByGoodsId" resultType="com.kmall.admin.entity.GoodsSpecificationEntity">
         select *
 		from mall_goods_specification
 		where goods_id = #{goodsId}

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

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

+ 3 - 0
kmall-admin/src/main/webapp/WEB-INF/page/shop/goods.html

@@ -125,6 +125,9 @@
                     <Form-item label="名称" prop="name">
                         <i-input v-model="goods.name" placeholder="名称"/>
                     </Form-item>
+                    <Form-item label="商品单位" prop="goodsUnit">
+                        <i-input v-model="goods.goodsUnit" placeholder="商品单位" style="width: 268px;"/>
+                    </Form-item>
                     <!--<Form-item label="类别" prop="attributeCategory" style="width: 268px;">
                         <i-select v-model="goods.attributeCategory" filterable label-in-value>
                             <i-option v-for="attributeCategory in attributeCategories" :value="attributeCategory.id" :key="attributeCategory.id">{{attributeCategory.name}}

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

@@ -105,46 +105,22 @@
                     </i-option>
                 </i-select>
             </Form-item>
-
             <Form-item label="商品" prop="goodsId">
                 <i-select v-model="productStoreRela.goodsId" filterable @on-change="changeGoods" label-in-value>
                     <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="productId">
-                <i-select v-model="productStoreRela.productId" filterable>
-                    <i-option v-for="product in products" :value="product.id"
-                              :key="product.id">{{product.goodsSpecificationNameValue}}
-                    </i-option>
-                </i-select>
-            </Form-item>
-            <!---->
-            <!--<Form-item label="商品名称" prop="goodsName" v-show="productStoreRela && productStoreRela.id">-->
-            <!--<i-input v-model="productStoreRela.goodsName" placeholder="商品名称"/>-->
-            <!--</Form-item>-->
-            <!--<Form-item label="规格编码" prop="productSn">-->
-            <!--<i-input v-model="productStoreRela.productSn" placeholder="规格编码"/>-->
-            <!--</Form-item>-->
             <Form-item label="库存" prop="goodsNumber">
                 <Input-number :min="0" :step="1" v-model="productStoreRela.stockNum" placeholder="总库存"
-                              style="width: 188px;"/>
-            </Form-item>
-            <Form-item label="零售价格" prop="retailPrice">
-                <Input-number :min="0" :step="1" v-model="productStoreRela.retailPrice" placeholder="零售价格"
-                              style="width: 188px;"/>
+                              style="width: 268px;"/>
             </Form-item>
-            <Form-item label="市场价" prop="marketPrice">
-                <Input-number :min="0" :step="1" v-model="productStoreRela.marketPrice" placeholder="市场价"
-                              style="width: 188px;"/>
+            <Form-item v-if="showInput" label="规格" prop="specification">
+                <i-input v-model="productStoreRela.specification" placeholder="规格"/>
             </Form-item>
-            <Form-item label="库存价格" prop="stockPrice">
-                <Input-number :min="0" :step="1" v-model="productStoreRela.stockPrice" placeholder="库存价格"
-                              style="width: 188px;"/>
+            <Form-item  v-if="showInput" label="零售价" prop="retailPrice">
+                <Input-number :min="0.01" :step="0.01" v-model="productStoreRela.retailPrice" placeholder="零售价格"
+                              style="width: 268px;"/>
             </Form-item>
-            <!--<Form-item label="销售量" prop="sellVolume">-->
-                <!--<Input-number :min="0" :step="1" v-model="productStoreRela.sellVolume" placeholder="销售量"-->
-                              <!--style="width: 188px;"/>-->
-            <!--</Form-item>-->
         </i-form>
         <div style="padding-left: 20px">
             <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>

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

@@ -194,6 +194,7 @@ var vm = new Vue({
             vm.macros = [];
             vm.brands = [];
             vm.freights = [];
+            vm.attributeEntityList = [];
             vm.attributeCategories = [];
             vm.getMacro();
             vm.getBrand();

+ 7 - 21
kmall-admin/src/main/webapp/js/shop/storeProductStock.js

@@ -91,24 +91,9 @@ var vm = new Vue({
         visible: false,
         productStoreRela: {},
         ruleValidate: {
-            storeId: [
+            /*storeId: [
                 {required: true, message: '门店不能为空'}
-            ],
-            productSn: [
-                {required: true, message: '规格编码不能为空'}
-            ],
-            retailPrice: [
-                {required: true, message: '零售价格不能为空'}
-            ],
-            marketPrice: [
-                {required: true, message: '市场价格不能为空'}
-            ],
-            goodsId: [
-                {required: true, message: '商品不能为空'}
-            ],
-            productId: [
-                {required: true, message: '规格不能为空'}
-            ]
+            ]*/
         },
         q: {
             storeId: '',
@@ -120,16 +105,17 @@ var vm = new Vue({
         macros: [],//商品单位
         goodss: {},
         products: [],
+        showInput: false
     },
     methods: {
         changeGoods: function (opt) {
             var goodsId = opt.value;
             if (null != goodsId && '' != goodsId) {
-                $.get("../product/queryByGoodsId/" + goodsId, function (r) {
-                    vm.products = r.list;
+                $.get("../goods/info/" + goodsId, function (r) {
+                    if (r.goods.goodsBizType == 11) {
+                        vm.showInput = true;
+                    }
                 });
-            } else {
-                vm.products = [];
             }
         },
         reloadSearch: function () {

+ 4 - 4
kmall-admin/src/main/webapp/login.html

@@ -22,7 +22,7 @@
 <body class="signin hold-transition login-page">
 <div class="loginscreen animated fadeInDown signinpanel" id="loginBox" v-cloak>
     <div class="row">
-        <div class="col-md-7">
+        <!--<div class="col-md-7">
             <div class="signin-info">
                 <div class="logopanel m-b">
                     <h1>中网科技</h1>
@@ -45,8 +45,8 @@
                     <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i>优化退款功能和付款记录</li>
                 </ul>
             </div>
-        </div>
-        <div class="col-md-5">
+        </div>-->
+        <div class="col-md-5" style="margin-left: 450px;">
             <Card class="m-t text-center" style="background: rgba(109, 109, 109, 0.23);border: 0px solid #dddee1;">
                 <p style="padding: 0 20px 20px 20px;">登录管理平台</p>
                 <div class="form-group has-feedback">
@@ -73,7 +73,7 @@
         </div>
     </div>
     <div class="signup-footer">
-        <div class="pull-left">
+        <div class="pull-left" style="margin-left: 520px;">
             2018~2018 &copy; <a href="http://fly2you.cn" target="_blank">中网科技(深圳)有限公司
         </div>
     </div>

+ 1 - 1
kmall-admin/src/main/webapp/statics/css/login.css

@@ -2,7 +2,7 @@ html{height: 100%;}
 body.signin {
     background: #18c8f6;
     height: auto;
-    background:url("../img/login.jpg") no-repeat center fixed;
+    background:url("../img/login.jpeg") no-repeat center fixed;
     -webkit-background-size: cover;
     -moz-background-size: cover;
     -o-background-size: cover;