Browse Source

小程序下单逻辑以及新增修改商品逻辑修改

hyq 6 years ago
parent
commit
c7d6f5b2b6

+ 3 - 2
kmall-admin/src/main/java/com/kmall/admin/controller/GoodsController.java

@@ -7,6 +7,7 @@ import com.kmall.admin.service.GoodsGalleryService;
 import com.kmall.admin.service.GoodsService;
 import com.kmall.admin.service.OfflineCartService;
 import com.kmall.admin.utils.ParamUtils;
+import com.kmall.common.constant.Dict;
 import com.kmall.common.constant.JxlsXmlTemplateName;
 import com.kmall.common.entity.SysUserEntity;
 import com.kmall.common.utils.PageUtils;
@@ -115,9 +116,9 @@ public class GoodsController {
     @RequestMapping("/queryAll")
     public R queryAll(@RequestParam Map<String, Object> params) {
         ParamUtils.setQueryPowerByRoleType(params, null, "merchSn", true);
-        params.put("isDelete", 0);
+        params.put("isDelete", Integer.parseInt(Dict.isDelete.item_0.getItem()));
+        params.put("isOnSale", Integer.parseInt(Dict.isOnSale.item_1.getItem()));
         List<GoodsEntity> list = goodsService.queryList(params);
-
         return R.ok().put("list", list);
     }
 

+ 9 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/GoodsEntity.java

@@ -174,6 +174,15 @@ public class GoodsEntity implements Serializable {
 
     //商户编号
     private String merchSn;
+    private String merchName;
+
+    public String getMerchName() {
+        return merchName;
+    }
+
+    public void setMerchName(String merchName) {
+        this.merchName = merchName;
+    }
 
     public String getMerchSn() {
         return merchSn;

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

@@ -83,6 +83,26 @@ public class ProductStoreRelaEntity implements Serializable {
 
     private String merchSn;
 
+    private String merchName;
+
+    private String goodsMerchSn;
+
+    public String getGoodsMerchSn() {
+        return goodsMerchSn;
+    }
+
+    public void setGoodsMerchSn(String goodsMerchSn) {
+        this.goodsMerchSn = goodsMerchSn;
+    }
+
+    public String getMerchName() {
+        return merchName;
+    }
+
+    public void setMerchName(String merchName) {
+        this.merchName = merchName;
+    }
+
     public String getMerchSn() {
         return merchSn;
     }

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

@@ -58,6 +58,8 @@ public class GoodsServiceImpl implements GoodsService {
     private MerchDao merchDao;
     @Autowired
     private ExportExceptionDataDao exportExceptionDataDao;
+    @Autowired
+    private CartDao cartDao;
 
     @Override
     public GoodsEntity queryObject(Integer id) {
@@ -317,17 +319,50 @@ 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());
-                    productStoreRela.setMarketPrice(goods.getMarketPrice());
+        List<ProductStoreRelaEntity> productStoreRelaEntityList = productStoreRelaDao.queryByGoodsId(goods.getId());
+        if (productStoreRelaEntityList != null && productStoreRelaEntityList.size() > 0) {
+            for (ProductStoreRelaEntity productStoreRela : productStoreRelaEntityList) {
+                //修改该商品的所属商户信息,如在该商户门店中有该上架的商品信息,则提示该商品不能修改
+                if(productStoreRela.getMerchSn().equalsIgnoreCase(goods.getMerchSn())
+                        && goods.getIsOnSale() == Integer.parseInt(Dict.isOnSale.item_1.getItem())) {
+                    if (goods.getRetailPrice() != null) {
+                        productStoreRela.setRetailPrice(goods.getRetailPrice());
+                    }
+                    if (goods.getMarketPrice() != null) {
+                        productStoreRela.setMarketPrice(goods.getMarketPrice());
+                    }
+                    productStoreRelaDao.update(productStoreRela);
+                }
+                if(!productStoreRela.getMerchSn().equalsIgnoreCase(goods.getMerchSn())
+                        && goods.getIsOnSale() == Integer.parseInt(Dict.isOnSale.item_0.getItem())) {
+                    if (goods.getRetailPrice() != null) {
+                        productStoreRela.setRetailPrice(goods.getRetailPrice());
+                    }
+                    if (goods.getMarketPrice() != null) {
+                        productStoreRela.setMarketPrice(goods.getMarketPrice());
+                    }
+                    productStoreRela.setMerchSn("");
                     productStoreRelaDao.update(productStoreRela);
+                }else{
+                    throw new RRException("商品编码为【"+goods.getGoodsSn()+"】的商品已上架在商户编号为【"+productStoreRela.getMerchSn()+"】的门店中,可先将该商品下架后再进行修改!");
                 }
             }
         }
 
+        Map cartMap = new HashMap();
+        cartMap.put("goodsId",goods.getId());
+        List<CartEntity> cartList = cartDao.queryList(cartMap);
+        if (cartList != null && cartList.size() > 0) {
+            for (CartEntity cartEntity : cartList) {
+                cartEntity.setRetailPrice(goods.getRetailPrice());
+                cartEntity.setMarketPrice(goods.getMarketPrice());
+                cartEntity.setSku(goods.getSku());
+                cartEntity.setGoodsName(goods.getName());
+                cartEntity.setGoodsSn(goods.getGoodsSn());
+                cartDao.update(cartEntity);
+            }
+        }
+
         // 修改商品轮播图
         goodsGalleryDao.deleteByGoodsId(goods.getId());
         for (int i=0;i<galleryEntityList.size();i++) {

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

@@ -35,6 +35,8 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
     private ProductDao productDao;
     @Autowired
     private GoodsGalleryDao goodsGalleryDao;
+    @Autowired
+    private CartDao cartDao;
 
     @Override
     public ProductStoreRelaEntity queryObject(Integer id) {
@@ -200,6 +202,21 @@ public class ProductStoreRelaServiceImpl implements ProductStoreRelaService {
             productStoreRela.setRetailPrice(goodsEntity.getRetailPrice());
         }
 
+        Map cartMap = new HashMap();
+        cartMap.put("goodsId",goodsEntity.getId());
+        List<CartEntity> cartList = cartDao.queryList(cartMap);
+        if (cartList != null && cartList.size() > 0) {
+            for (CartEntity cartEntity : cartList) {
+                cartEntity.setMarketPrice(productStoreRela.getMarketPrice());
+                cartEntity.setRetailPrice(productStoreRela.getRetailPrice());
+                cartEntity.setStockNum(productStoreRela.getStockNum());
+                cartEntity.setSku(goodsEntity.getSku());
+                cartEntity.setGoodsName(goodsEntity.getName());
+                cartEntity.setGoodsSn(goodsEntity.getGoodsSn());
+                cartDao.update(cartEntity);
+            }
+        }
+
         productStoreRela.setModerSn(user.getUserId().toString());
         productStoreRela.setModTime(new Date());
         return productStoreRelaDao.update(productStoreRela);

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

@@ -46,6 +46,9 @@
         <if test="merchSn != null and merchSn.trim() != ''">
             and d.merch_sn = #{merchSn}
         </if>
+        <if test="goodsId != null">
+            and a.goods_id = #{goodsId}
+        </if>
         <if test="userId != null">
             AND a.user_id = #{userId}
         </if>
@@ -76,6 +79,9 @@
         <if test="merchSn != null and merchSn.trim() != ''">
             and d.merch_sn = #{merchSn}
         </if>
+        <if test="goodsId != null">
+            and a.goods_id = #{goodsId}
+        </if>
         <if test="userId != null">
             AND mall_cart.user_id = #{userId}
         </if>

+ 8 - 2
kmall-admin/src/main/resources/mybatis/mapper/GoodsDao.xml

@@ -59,6 +59,7 @@
         <result property="storeName" column="store_name"/>
         <result property="productId" column="productId"/>
         <result property="storeId" column="storeId"/>
+        <result column="merch_name" property="merchName" />
     </resultMap>
 
     <select id="queryObject" resultType="com.kmall.admin.entity.GoodsEntity">
@@ -113,8 +114,10 @@
         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
+        case when mall_goods_group.id > 0 then 2 else 0 end as goodsType,
+        m.merch_name merchName
         from mall_goods
+        left join mall_merch m on mall_goods.merch_sn = m.merch_sn
         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
@@ -149,9 +152,12 @@
         <if test="categoryTwo != null and categoryTwo != ''">
             AND mall_goods.category_id = #{categoryTwo}
         </if>
-        <if test="isDelete != null and isDelete != ''">
+        <if test="isDelete != null">
             AND mall_goods.is_Delete = #{isDelete}
         </if>
+        <if test="isOnSale != null">
+            AND mall_goods.is_on_sale = #{isOnSale}
+        </if>
         <if test="goodsBizType != null and goodsBizType != ''">
             AND mall_goods.goods_biz_type = #{goodsBizType}
         </if>

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

@@ -29,6 +29,8 @@
         <result column="mod_time" property="modTime" />
         <result column="tstm" property="tstm" />
         <result column="list_pic_url" property="listPicUrl" />
+        <result column="merch_name" property="merchName" />
+        <result column="goods_merch_sn" property="goodsMerchSn" />
     </resultMap>
 
     <select id="queryObject" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
@@ -110,9 +112,12 @@
         c.goods_sn productSn,
         b.name goodsName,
         cg.name categoryName,
-        s.store_name storeName
+        s.store_name storeName,
+        m.merch_name,
+        b.merch_sn goods_merch_sn
         from mall_product_store_rela a
         left join mall_goods b on a.goods_id = b.id
+        left join mall_merch m on a.merch_sn = m.merch_sn
         left join mall_product c on a.product_id = c.id
         LEFT JOIN mall_category cg ON b.category_id = cg.id
         left join mall_store s on a.store_id = s.id

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

@@ -57,6 +57,13 @@
         <Row :gutter="16">
             <div class="search-group">
                 <i-col span="3">
+                    <i-select v-model="q.merchSn" placeholder="商户编号" filterable label-in-value>
+                        <i-option v-for="merch in queryMerch" :value="merch.merchSn"
+                                  :key="merch.merchSn">{{merch.merchName}}
+                        </i-option>
+                    </i-select>
+                </i-col>
+                <i-col span="3">
                     <i-input v-model="q.goodsSn" @on-enter="query" placeholder="商品编码"/>
                 </i-col>
                 <i-col span="3">

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

@@ -4,12 +4,13 @@ $(function () {
         datatype: "json",
         colModel: [
             {label: 'ID', name: 'id', index: 'id', hidden: true, key: true},
-            {label: '商品编码', name: 'goodsSn', index: 'goods_Sn', width: 60},
-            {label: 'SKU', name: 'sku', index: 'sku', width: 80},
-            {label: '商品类型', name: 'categoryName', index: 'category_id', width: 40},
-            {label: '名称', name: 'name', index: 'name', width: 160},
+            {label: '商户名称', name: 'merchName', index: 'merchName', width: 100, align: 'center'},
+            {label: '商品编码', name: 'goodsSn', index: 'goods_Sn', width: 60, align: 'center'},
+            {label: 'SKU', name: 'sku', index: 'sku', width: 80, align: 'center'},
+            {label: '商品类型', name: 'categoryName', index: 'category_id', width: 40, align: 'center'},
+            {label: '名称', name: 'name', index: 'name', width: 160, align: 'center'},
             {
-                label: '货品业务类型', name: 'goodsBizType', index: 'goods_biz_type', width: 70,
+                label: '货品业务类型', name: 'goodsBizType', index: 'goods_biz_type', width: 70, align: 'center',
                 formatter: function (value) {
                     if (value == '00') {
                         return '保税备货';
@@ -21,8 +22,8 @@ $(function () {
                     return '普通货物';
                 }
             },
-            {label: '零售价格', name: 'retailPrice', index: 'retail_price', width: 80},
-            {label: '市场价', name: 'marketPrice', index: 'market_price', width: 80},
+            {label: '零售价格', name: 'retailPrice', index: 'retail_price', width: 80, align: 'center'},
+            {label: '市场价', name: 'marketPrice', index: 'market_price', width: 80, align: 'center'},
             {
                 label: '上架', name: 'isOnSale', index: 'is_on_sale', width: 40, align: 'center',
                 formatter: function (value) {
@@ -45,16 +46,16 @@ $(function () {
                 }
             },*/
             {
-                label: '录入日期', name: 'addTime', index: 'add_time', width: 80,
+                label: '录入日期', name: 'addTime', index: 'add_time', width: 80, align: 'center',
                 formatter: function (value) {
                     return transDate(value, 'yyyy-MM-dd hh:mm:ss');
                 }
             }
         ],
         viewrecords: true,
-        height: 675,
-        rowNum: 15,
-        rowList: [15, 30, 50],
+        height: 575,
+        rowNum: 10,
+        rowList: [10, 30, 50],
         rownumbers: true,
         rownumWidth: 25,
         autowidth: true,
@@ -122,12 +123,13 @@ var vm = new Vue({
                 {required: true, message: '名称不能为空', trigger: 'blur'}
             ]*/
         },
-        q: {name: '', goodsSn: '', category: '', categoryTwo: ''},
+        q: {name: '', goodsSn: '', category: '', categoryTwo: '', merchSn: ''},
         attributes: [],
         attributeEntityList: [{'id': '', 'goodsId': '', 'attributeId': '', 'value': '', 'isDelete': 0}],
         productEntityList: [{'id': '', 'goodsId': '', 'goodsSpecificationIds': '', 'goodsSpecificationNameValue': '', 'goodsSn': '', 'goodsNumber': '', 'isDelete': 0, 'goodsDefault': 0}],
         queryCategories: [],//一级分类
         queryCategoriesTwo: [],
+        queryMerch: [],
         categories: [],//一级分类
         categoriesTwo: [],
         macros: [],//商品单位
@@ -176,7 +178,8 @@ var vm = new Vue({
                 name: '',
                 goodsSn: '',
                 category: '',
-                categoryTwo: ''
+                categoryTwo: '',
+                merchSn: ''
             }
         },
         query: function () {
@@ -413,7 +416,8 @@ var vm = new Vue({
                     'name': vm.q.name,
                     'goodsSn': vm.q.goodsSn,
                     'category': vm.q.category,
-                    'categoryTwo': vm.q.categoryTwo
+                    'categoryTwo': vm.q.categoryTwo,
+                    'merchSn': vm.q.merchSn
                 },
                 page: page
             }).trigger("reloadGrid");
@@ -472,6 +476,7 @@ var vm = new Vue({
                 vm.queryCategoriesTwo = r.list;
             });
         },
+
         getAttributes: function (opt) {
             var value = opt.value;
             $.get("../attribute/query?attributeCategoryId=" + value, function (r) {
@@ -616,6 +621,9 @@ var vm = new Vue({
         $.get("../category/getCategorySelect", function (r) {
             vm.queryCategories = r.list;
         });
+        $.get("../merch/queryAll", function (r) {
+            vm.queryMerch = r.list;
+        });
 
     }
 });

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

@@ -4,10 +4,12 @@ $(function () {
         datatype: "json",
         colModel: [
             {label: 'ID', name: 'id', index: 'id', hidden: true, key: true},
-            {label: '门店', name: 'storeName', index: 'storeName'},
-            {label: '商品类型', name: 'categoryName', index: 'categoryName', width: 80},
+            {label: '商品商户编号', name: 'goods_merch_sn', index: 'goods_merch_sn', hidden: true},
+            {label: '商户名称', name: 'merchName', index: 'merchName', width: 100, align: 'center'},
+            {label: '门店', name: 'storeName', index: 'storeName', width: 80, align: 'center'},
+            {label: '商品类型', name: 'categoryName', index: 'categoryName', width: 80, align: 'center'},
             {
-                label: '货品业务类型', name: 'goodsBizType', index: 'goods_biz_type', width: 70,
+                label: '货品业务类型', name: 'goodsBizType', index: 'goods_biz_type', width: 70, align: 'center',
                 formatter: function (value) {
                     if (value == '00') {
                         return '保税备货';
@@ -19,11 +21,11 @@ $(function () {
                     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: 'goodsSn', index: 'goodsSn', align: 'center'},
+            {label: '名称', name: 'goodsName', index: 'goodsName', width: 160, align: 'left'},
+            {label: '产品编码', name: 'productSn', index: 'productSn', width: 80, align: 'center'},
+            {label: '库存', name: 'stockNum', index: 'stockNum', width: 80, align: 'center'},
+            {label: '零售价格', name: 'retailPrice', index: 'retailPrice', width: 80, align: 'center'},
             // {label: '市场价', name: 'marketPrice', index: 'marketPrice', width: 80},
             // {label: '库存价格', name: 'stockPrice', index: 'stockPrice', width: 80},
             {
@@ -31,7 +33,7 @@ $(function () {
                 name: 'sellVolume',
                 index: 'a.sell_volume',
                 width: 80,
-                sortable: true,
+                sortable: true, align: 'center',
                 onSortCol: function (index, colindex, sortorder) {
                     //列排序事件
                     jQuery("#jqGrid").jqGrid('setGridParam', {page: $('#XtoPage').val()});
@@ -41,7 +43,8 @@ $(function () {
                 label: '操作', width: 60, align: 'center', sortable: false, formatter: function (value, col, row) {
                 let htmlStr = '';
                 if (row.goodsBizType == '02' || row.goodsBizType == '10') {
-                    htmlStr = '<button class="btn btn-outline btn-primary" onclick="vm.qrcodeCanvas(' + row.goodsId + ')"><i class="fa fa-qrcode"></i>二维码</button>';
+                    htmlStr = "<button class='btn btn-outline btn-primary' " +
+                        "onclick='vm.qrcodeCanvas(" + row.goodsId + ",\""+ row.storeId +"\",\""+row.goodsMerchSn+"\",\""+row.merchSn+"\")'><i class='fa fa-qrcode'></i>二维码</button>";
                 }
                 return htmlStr;
             }
@@ -312,11 +315,15 @@ var vm = new Vue({
         handleReset: function (name) {
             handleResetForm(this, name);
         },
-        qrcodeCanvas: function(id) {
+        qrcodeCanvas: function(id,storeId,goodsMerchSn,merchSn) {
+            if(merchSn != goodsMerchSn){
+                alert("商品所属商户与门店商品所属商户不一致,请修改为一致后再生成二维码!");
+                return;
+            }
             $("#qrcodeCanvas").html("");
             $("#qrcodeCanvas").qrcode({
                 render : "canvas",    //设置渲染方式,有table和canvas,使用canvas方式渲染性能相对来说比较好
-                text : "emato../goods/goods?id=" + id,    //扫描二维码后显示的内容,可以直接填一个网址,扫描二维码后自动跳向该链接
+                text : "emato../goods/goods?id=" + id +"&storeId="+storeId,    //扫描二维码后显示的内容,可以直接填一个网址,扫描二维码后自动跳向该链接
                 width : "100",               //二维码的宽度
                 height : "100",              //二维码的高度
                 background : "#ffffff",       //二维码的后景色

+ 8 - 8
kmall-api/src/main/java/com/kmall/api/api/ApiCartController.java

@@ -603,38 +603,38 @@ public class ApiCartController extends ApiBaseAction {
             if(org.apache.commons.lang.StringUtils.isEmpty(checkCart)){
                 if(vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_00.getItem())){
                     FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
-                    freightPrice00 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice00;
+                    freightPrice00 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice00) : freightPrice00;
                 }
                 if(vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_02.getItem())){
                     FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
-                    freightPrice02 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice02;
+                    freightPrice02 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice02) : freightPrice02;
                 }
                 if(vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_10.getItem())){
                     FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
-                    freightPrice10 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice10;
+                    freightPrice10 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice10) : freightPrice10;
                 }
                 if (vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_11.getItem())) {
                     FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
-                    freightPrice11 = freightEntity != null ? freightEntity.getDefaultFreight() : freightPrice11;
+                    freightPrice11 = freightEntity != null ? freightEntity.getDefaultFreight().add(freightPrice11) : freightPrice11;
                 }
             }else{
                 if(Dict.orderBizType.item_11.getItem().equalsIgnoreCase(checkCart)) {
                     if (vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_11.getItem())) {
                         FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
-                        freightPrice11 = freightEntity != null ? freightEntity.getDefaultFreight() : freightPrice11;
+                        freightPrice11 = freightEntity != null ? freightEntity.getDefaultFreight().add(freightPrice11) : freightPrice11;
                     }
                 }else{
                     if(vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_00.getItem())){
                         FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
-                        freightPrice00 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice00;
+                        freightPrice00 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice00) : freightPrice00;
                     }
                     if(vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_02.getItem())){
                         FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
-                        freightPrice02 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice02;
+                        freightPrice02 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice02) : freightPrice02;
                     }
                     if(vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_10.getItem())){
                         FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
-                        freightPrice10 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice10;
+                        freightPrice10 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice10) : freightPrice10;
                     }
                 }
             }

+ 8 - 8
kmall-api/src/main/java/com/kmall/api/service/ApiOrderService.java

@@ -232,45 +232,45 @@ public class ApiOrderService {
             if(org.apache.commons.lang.StringUtils.isEmpty(checkCart)){
                 if(Dict.orderBizType.item_11.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
                     FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(goodsItem.getGoods_id());
-                    freightPrice11 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice11;//查询商品运费信息
+                    freightPrice11 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice11) : freightPrice11;//查询商品运费信息
                     isBizType11 =true;
                 }
                 if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
                     FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(goodsItem.getGoods_id());
-                    freightPrice00 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice00;//查询商品运费信息
+                    freightPrice00 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice00) : freightPrice00;//查询商品运费信息
                     isBizType00 =true;
                 }
                 if(Dict.orderBizType.item_02.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
                     FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(goodsItem.getGoods_id());
-                    freightPrice02 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice02;//查询商品运费信息
+                    freightPrice02 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice02) : freightPrice02;//查询商品运费信息
                     isBizType02 =true;
                 }
                 if(Dict.orderBizType.item_10.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
                     FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(goodsItem.getGoods_id());
-                    freightPrice10 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice10;//查询商品运费信息
+                    freightPrice10 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice10) : freightPrice10;//查询商品运费信息
                     isBizType10 =true;
                 }
             }else{
                 if(checkCart.equalsIgnoreCase(Dict.orderBizType.item_11.getItem())){
                     if(Dict.orderBizType.item_11.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
                         FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(goodsItem.getGoods_id());
-                        freightPrice11 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice11;//查询商品运费信息
+                        freightPrice11 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice11) : freightPrice11;//查询商品运费信息
                         isBizType11 =true;
                     }
                 }else{
                     if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
                         FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(goodsItem.getGoods_id());
-                        freightPrice00 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice00;//查询商品运费信息
+                        freightPrice00 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice00) : freightPrice00;//查询商品运费信息
                         isBizType00 =true;
                     }
                     if(Dict.orderBizType.item_02.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
                         FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(goodsItem.getGoods_id());
-                        freightPrice02 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice02;//查询商品运费信息
+                        freightPrice02 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice02) : freightPrice02;//查询商品运费信息
                         isBizType02 =true;
                     }
                     if(Dict.orderBizType.item_10.getItem().equalsIgnoreCase(goodsItem.getGoodsBizType())){
                         FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(goodsItem.getGoods_id());
-                        freightPrice10 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice10;//查询商品运费信息
+                        freightPrice10 = freightEntity!=null ? freightEntity.getDefaultFreight().add(freightPrice10) : freightPrice10;//查询商品运费信息
                         isBizType10 =true;
                     }
                 }

+ 5 - 5
kmall-api/src/main/resources/mybatis/mapper/ApiGoodsMapper.xml

@@ -104,7 +104,7 @@
         psr1.stock_num,
         a.goods_desc,a.goods_biz_type,a.goods_rate
         from mall_goods a left join mall_merch m on a.merch_sn = m.merch_sn
-        LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id
+        LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
         where a.id = #{id} and psr1.store_id = #{storeId}
     </select>
 
@@ -118,7 +118,7 @@
         </if>
         ,psr1.stock_num
         from mall_goods a
-        LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id
+        LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
         LEFT JOIN mall_product b ON b.id = psr1.product_id
         left join mall_category c on a.category_id = c.id
         where 1 = 1 and a.is_delete != 1 and psr1.stock_num > 0 and a.is_on_sale = 1
@@ -187,7 +187,7 @@
             a.*,b.id as product_id
         </if>
         from mall_goods a
-        LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id
+        LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
         LEFT JOIN mall_product b ON b.id = psr1.product_id
         where 1 = 1 and b.id is not null and psr1.stock_num > 0 and a.is_delete != 1 and psr1.retail_price is not null and a.is_on_sale = 1
         <if test="is_new != null and is_new != ''">
@@ -243,7 +243,7 @@
         </if>
         FROM
         mall_goods a
-        LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id
+        LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
         LEFT JOIN mall_product b ON b.id = psr1.product_id
         <if test="is_group != null and is_group == true">
             left join mall_goods_group gg on gg.goods_id = a.id
@@ -311,7 +311,7 @@
     <select id="queryTotal" resultType="int">
         select count(*)
         from mall_goods a
-        left join mall_product_store_rela s on a.id = s.goods_id
+        left join mall_product_store_rela s on a.id = s.goods_id and a.merch_sn = s.merch_sn
         where 1 = 1 and a.is_on_sale = 1 AND s.stock_num > 0
         <if test="storeId != null and storeId != ''">
             and s.store_id = #{storeId}

+ 1 - 1
kmall-api/src/main/resources/mybatis/mapper/ApiProductStoreRelaDao.xml

@@ -99,7 +99,7 @@
 		cg.name categoryName,
 		s.store_name storeName
 		from mall_product_store_rela a
-		left join mall_goods b on a.goods_id = b.id
+		left join mall_goods b on a.goods_id = b.id and a.merch_sn = b.merch_sn
 		left join mall_product c on a.product_id = c.id
 		LEFT JOIN mall_category cg ON b.category_id = cg.id
 		left join mall_store s on a.store_id = s.id

+ 45 - 26
wx-mall/pages/index/index.js

@@ -318,13 +318,25 @@ Page({
         that.setData({
           goodsCode: that.code
         });
-
         if (that.scanType == 'QR_CODE') {//二维码
           that.substrValue = that.value.substring(0, 5);
           that.value = that.value.substring(5, that.value.length);
-          var goodId = that.value.substring(18, that.value.length);
-
-          if (that.substrValue != 'emato') {//../goods/goods?id=
+          // var goodId = that.value.substring(18, that.value.length);
+          var scanArray = that.value.split('&');
+          // console.log(scanArray.length);
+          if (scanArray.length < 2){
+            wx.showModal({
+              title: '',
+              content: '您所扫描的商品无效',
+              showCancel: false
+            });
+            return;
+          }
+          var goodId = scanArray[0].substring(18, that.value.length);
+          var storeId = scanArray[1].substring(8, that.value.length);
+          // console.log("storeId:" + storeId);
+          // console.log("goodId:" + goodId);
+          if (that.substrValue != 'emato') {//../goods/goods?id=&merchSn=
             wx.showModal({
               title: '',
               content: '您所扫描的商品无效',
@@ -337,29 +349,37 @@ Page({
                 }
               }
             });
-          } else {
-
-            util.request(api.GoodsDetail, { id: goodId, referrer: '' }).then(function (res) {
-              if (res.errno === 0) {
-                // 跳转页面
-                wx.navigateTo({
-                  url: that.value,
-                  success: function (e) {
-                    console.log('跳转成功');
-                  },
-                  fail: function (e) {
-                    console.log('跳转失败');
-                  }
-                })
-              } else {
-                wx.showModal({
-                  title: '扫描结果',
-                  content: '商品不存在',
-                  showCancel: false
-                });
-              }
+            return;
+          }
+          if (storeId != wx.getStorageSync('storeId')) {
+            wx.showModal({
+              title: '扫描结果',
+              content: '该商品不属于当前门店',
+              showCancel: false
             });
+            return;         
           }
+          util.request(api.GoodsDetail, { id: goodId, referrer: '' }).then(function (res) {
+            if (res.errno === 0) {
+              console.log(res);
+              // 跳转页面
+              wx.navigateTo({
+                url: that.value,
+                success: function (e) {
+                  console.log('跳转成功');
+                },
+                fail: function (e) {
+                  console.log('跳转失败');
+                }
+              })
+            } else {
+              wx.showModal({
+                title: '扫描结果',
+                content: '商品不存在',
+                showCancel: false
+              });
+            }
+          });
         }else{//其他码
           //弹框显示结果
           wx.showModal({
@@ -369,7 +389,6 @@ Page({
           });
         }
       },
-
       fail: function () {
         // 显示提示框
         wx.showToast({