1
0
Selaa lähdekoodia

取消批次号概念,增加品牌添加校验

xwh 4 vuotta sitten
vanhempi
commit
54e89e2a60

+ 5 - 0
kmall-admin/src/main/java/com/kmall/admin/controller/BrandController.java

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * Controller
@@ -75,6 +76,10 @@ public class BrandController {
             throw new RRException(r.get("msg").toString());
         }
 
+        BrandEntity brandEntity = brandService.queryByCategoryIdAndBrandNameAndMerchSn(brand.getCategoryId(),brand.getName(),brand.getMerchSn());
+        if (Objects.nonNull(brandEntity)){
+            throw new RRException("该分类下已经有该品牌名称");
+        }
         brandService.save(brand);
 
         return R.ok();

+ 2 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/BrandDao.java

@@ -25,4 +25,6 @@ public interface BrandDao extends BaseDao<BrandEntity> {
      * @return
      */
     String queryBrandName(@Param("prodBarcode") String prodBarcode, @Param("storeId") String storeId);
+
+    BrandEntity queryByCategoryIdAndBrandNameAndMerchSn(@Param("categoryId") Integer categoryId,@Param("name") String name,@Param("merchSn") String merchSn);
 }

+ 3 - 0
kmall-admin/src/main/java/com/kmall/admin/service/BrandService.java

@@ -83,4 +83,7 @@ public interface BrandService {
      * @return
      */
     String queryBrandName(String prodBarcode, String storeId);
+
+
+    BrandEntity queryByCategoryIdAndBrandNameAndMerchSn(Integer categoryId, String name, String merchSn);
 }

+ 5 - 0
kmall-admin/src/main/java/com/kmall/admin/service/impl/BrandServiceImpl.java

@@ -189,4 +189,9 @@ public class BrandServiceImpl implements BrandService {
     public String queryBrandName(String prodBarcode, String storeId) {
         return brandDao.queryBrandName(prodBarcode,storeId);
     }
+
+    @Override
+    public BrandEntity queryByCategoryIdAndBrandNameAndMerchSn(Integer categoryId, String name, String merchSn) {
+        return brandDao.queryByCategoryIdAndBrandNameAndMerchSn(categoryId,name,merchSn);
+    }
 }

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

@@ -879,15 +879,15 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
                     throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的底线价不可以大于零售价");
                 }
                 // 查询批次号是否存在
-                GoodsBatchEntity goodsBatchEntity = goodsBatchDao.queryByBatchSnAndSku(storeGoodsDto.getBatchSn(), goodsEntity.getSku());
-                if (goodsBatchEntity!=null){
-                    storeRelaEntity.setBatchSn(goodsBatchEntity.getBatchSn());
-                    Date batchExpireDate = goodsBatchEntity.getBatchExpireDate();
-                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                    storeRelaEntity.setBatchExpireDate(sdf.format(batchExpireDate));
-                }else{
-//                    throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的批次号不存在");
-                }
+//                GoodsBatchEntity goodsBatchEntity = goodsBatchDao.queryByBatchSnAndSku(storeGoodsDto.getBatchSn(), goodsEntity.getSku());
+//                if (goodsBatchEntity!=null){
+//                    storeRelaEntity.setBatchSn(goodsBatchEntity.getBatchSn());
+//                    Date batchExpireDate = goodsBatchEntity.getBatchExpireDate();
+//                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//                    storeRelaEntity.setBatchExpireDate(sdf.format(batchExpireDate));
+//                }else{
+////                    throw new RRException("商品[" + storeGoodsDto.getGoodsSn() + "]的批次号不存在");
+//                }
                 storeRelaEntity.setMarketPrice(new BigDecimal(storeGoodsDto.getMarketPrice()));
                 storeRelaEntity.setRetailPrice(new BigDecimal(storeGoodsDto.getRetailPrice()));
                 storeRelaEntity.setBottomLinePrice(storeGoodsDto.getBottomLinePrice());

+ 1 - 1
kmall-admin/src/main/resources/XmlTemplate/StoreGoodsDtoList.xml

@@ -15,7 +15,7 @@
                 <mapping row="1" col="6">StoreGoodsDto.retailPrice</mapping>
                 <mapping row="1" col="7">StoreGoodsDto.marketPrice</mapping>
                 <mapping row="1" col="8">StoreGoodsDto.bottomLinePrice</mapping>
-                <mapping row="1" col="9">StoreGoodsDto.batchSn</mapping>
+<!--                <mapping row="1" col="9">StoreGoodsDto.batchSn</mapping>-->
             </section>
             <loopbreakcondition>
                 <rowcheck offset="0">

+ 14 - 0
kmall-admin/src/main/resources/mybatis/mapper/BrandDao.xml

@@ -252,5 +252,19 @@
 	        goods.prod_barcode = #{prodBarcode}
 	        and brand.store_id = #{storeId}
     </select>
+    <select id="queryByCategoryIdAndBrandNameAndMerchSn" resultType="com.kmall.admin.entity.BrandEntity">
+        select *
+        from mall_brand
+        where 1=1
+        <if test="categoryId != null and categoryId != ''">
+            AND category_id = #{categoryId}
+        </if>
+        <if test="merchSn != null and merchSn.trim() != ''">
+            AND merch_sn = #{merchSn}
+        </if>
+        <if test="name != null and name.trim() != ''">
+            AND `name` = #{name}
+        </if>
+    </select>
 
 </mapper>

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

@@ -209,17 +209,17 @@
                     </i-option>
                 </i-select>
             </Form-item>-->
-            <Form-item v-if="showInput" label="批次编号" prop="batchSn">
-                <!--<i-input v-model="productStoreRela.batchSn" placeholder="批次编号" style="width: 268px;"/>-->
-                <i-select v-model="productStoreRela.batchSn" placeholder="批次编号" @on-change="changeBatch"
-                          label-in-value style="width: 268px;">
-                    <i-option v-for="batch in batchList" :value="batch.id" :key="batch.id">{{batch.batchSn}}
-                    </i-option>
-                </i-select>
-            </Form-item>
-            <Form-item v-if="showInput" label="批次到期日期" prop="batchExpireDate">
-                <i-input type='date' v-model="productStoreRela.batchExpireDate" placeholder="批次到期日期" style="width: 268px;"/>
-            </Form-item>
+<!--            <Form-item v-if="showInput" label="批次编号" prop="batchSn">-->
+<!--                &lt;!&ndash;<i-input v-model="productStoreRela.batchSn" placeholder="批次编号" style="width: 268px;"/>&ndash;&gt;-->
+<!--                <i-select v-model="productStoreRela.batchSn" placeholder="批次编号" @on-change="changeBatch"-->
+<!--                          label-in-value style="width: 268px;">-->
+<!--                    <i-option v-for="batch in batchList" :value="batch.id" :key="batch.id">{{batch.batchSn}}-->
+<!--                    </i-option>-->
+<!--                </i-select>-->
+<!--            </Form-item>-->
+<!--            <Form-item v-if="showInput" label="批次到期日期" prop="batchExpireDate">-->
+<!--                <i-input type='date' v-model="productStoreRela.batchExpireDate" placeholder="批次到期日期" style="width: 268px;"/>-->
+<!--            </Form-item>-->
             <Form-item v-if="showInputSpecification" label="规格" prop="specification">
                 <i-input v-model="productStoreRela.specification" placeholder="规格" style="width: 268px;"/>
             </Form-item>

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

@@ -25,10 +25,10 @@ $(function () {
             {label: '商品编码', name: 'goodsSn', index: 'goodsSn', width: 180, align: 'center'},
             {label: '名称', name: 'goodsName', index: 'goodsName', width: 500, align: 'left'},
             {label: '产品编码', name: 'productSn', index: 'productSn', width: 140, align: 'center'},
-            {label: '批次编号', name: 'batchSn', index: 'batchSn', width: 220, align: 'center'},
-            {label: '批次到期日期', name: 'batchExpireDate', index: 'batchExpireDate', width: 160, align: 'center',formatter: function (value) {
-                    return transDate(value,'yyyy-MM-dd hh:mm:ss');
-            }},
+            // {label: '批次编号', name: 'batchSn', index: 'batchSn', width: 220, align: 'center'},
+            // {label: '批次到期日期', name: 'batchExpireDate', index: 'batchExpireDate', width: 160, align: 'center',formatter: function (value) {
+            //         return transDate(value,'yyyy-MM-dd hh:mm:ss');
+            // }},
             {
                 label: '上架', name: 'isOnSale', index: 'is_on_sale', width: 80, align: 'center',
                 formatter: function (value) {

BIN
kmall-admin/src/main/webapp/statics/file/store_goods_export_yyyy_mm_dd_v1.0.0.xls