diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java index 418e9f4..a8c3351 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java @@ -131,6 +131,8 @@ public class TbProduct implements Serializable { private Integer stockNumber; + private Integer warnLine = 0; + @Transient private int orderCount; @@ -655,4 +657,12 @@ public class TbProduct implements Serializable { public void setStockNumber(Integer stockNumber) { this.stockNumber = stockNumber; } + + public Integer getWarnLine() { + return warnLine; + } + + public void setWarnLine(Integer warnLine) { + this.warnLine = warnLine; + } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java index 7852e47..fb8ef5b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductSku.java @@ -35,8 +35,6 @@ public class TbProductSku implements Serializable { private String coverImg; - private Integer warnLine; - private Double weight; private Float volume; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java index 178ca2a..0268498 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java @@ -426,7 +426,7 @@ public class OrderService { private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer shopId, Integer num) { log.info("下单,开始校验库存预警,商品信息:{}, {}, {}", product, productSku, num); - if (productSku.getWarnLine() == null) { + if (product.getWarnLine() == null) { return; } @@ -434,21 +434,15 @@ public class OrderService { return; } - if (productSku.getStockNumber() == null) { - productSku.setStockNumber((double) 0); - } if (product.getStockNumber() == null) { product.setStockNumber(0); } - if ( - (product.getIsDistribute() == 1 && product.getStockNumber() - num <= productSku.getWarnLine()) - || (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine() - ) { + if (product.getStockNumber() - num <= product.getWarnLine()) { List shopOpenIds = shopOpenIdMapper.selectStateByShopIdAndType(product.getShopId(), ShopWxMsgTypeEnum.STOCK_MSG.getType()); shopOpenIds.forEach(item -> { wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(), - product.getIsDistribute() == 1 ? product.getStockNumber()-num : (int) (productSku.getStockNumber() - num), item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopId); + product.getStockNumber() - num , item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopId); }); } } diff --git a/src/main/resources/mapper/TbProductMapper.xml b/src/main/resources/mapper/TbProductMapper.xml index 48feaa0..709b345 100644 --- a/src/main/resources/mapper/TbProductMapper.xml +++ b/src/main/resources/mapper/TbProductMapper.xml @@ -63,6 +63,7 @@ + @@ -81,7 +82,7 @@ created_at, updated_at, base_sales_number, real_sales_number, sales_number, thumb_count, store_count, furnish_meal, furnish_express, furnish_draw, furnish_vir, is_combo, is_show_cash, is_show_mall, is_need_examine, show_on_mall_status, show_on_mall_time, - show_on_mall_error_msg, enable_label, tax_config_id, spec_table_headers, stock_number + show_on_mall_error_msg, enable_label, tax_config_id, spec_table_headers, stock_number,warn_line images, video, notice, group_snap, spec_info, select_spec @@ -120,7 +121,7 @@ show_on_mall_status, show_on_mall_time, show_on_mall_error_msg, enable_label, tax_config_id, spec_table_headers, images, video, notice, - group_snap, spec_info, select_spec, stock_number + group_snap, spec_info, select_spec, stock_number,warn_line ) values (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=VARCHAR}, #{specId,jdbcType=INTEGER}, #{sourcePath,jdbcType=VARCHAR}, #{brandId,jdbcType=INTEGER}, #{merchantId,jdbcType=VARCHAR}, @@ -144,7 +145,7 @@ #{enableLabel,jdbcType=TINYINT}, #{taxConfigId,jdbcType=VARCHAR}, #{specTableHeaders,jdbcType=VARCHAR}, #{images,jdbcType=LONGVARCHAR}, #{video,jdbcType=LONGVARCHAR}, #{notice,jdbcType=LONGVARCHAR}, #{groupSnap,jdbcType=LONGVARCHAR}, #{specInfo,jdbcType=LONGVARCHAR}, #{selectSpec,jdbcType=LONGVARCHAR}, - #{stockNumber,jdbcType=INTEGER} + #{stockNumber,jdbcType=INTEGER},#{warnLine,jdbcType=INTEGER} ) @@ -351,6 +352,9 @@ stock_number, + + warn_line, + @@ -551,9 +555,12 @@ #{selectSpec,jdbcType=LONGVARCHAR}, - - #{stockNumber,jdbcType=INTEGER}, - + + #{stockNumber,jdbcType=INTEGER}, + + + #{warnLine,jdbcType=INTEGER}, + @@ -754,80 +761,84 @@ select_spec = #{selectSpec,jdbcType=LONGVARCHAR}, - - stock_number = #{stockNumber,jdbcType=INTEGER}, - + + stock_number = #{stockNumber,jdbcType=INTEGER}, + + + warn_line = #{warnLine,jdbcType=INTEGER}, + where id = #{id,jdbcType=INTEGER} update tb_product - set category_id = #{categoryId,jdbcType=VARCHAR}, - spec_id = #{specId,jdbcType=INTEGER}, - source_path = #{sourcePath,jdbcType=VARCHAR}, - brand_id = #{brandId,jdbcType=INTEGER}, - merchant_id = #{merchantId,jdbcType=VARCHAR}, - shop_id = #{shopId,jdbcType=VARCHAR}, - name = #{name,jdbcType=VARCHAR}, - short_title = #{shortTitle,jdbcType=VARCHAR}, - type = #{type,jdbcType=VARCHAR}, - pack_fee = #{packFee,jdbcType=DECIMAL}, - low_price = #{lowPrice,jdbcType=DECIMAL}, - low_member_price = #{lowMemberPrice,jdbcType=DECIMAL}, - unit_id = #{unitId,jdbcType=VARCHAR}, - unit_snap = #{unitSnap,jdbcType=VARCHAR}, - cover_img = #{coverImg,jdbcType=VARCHAR}, - share_img = #{shareImg,jdbcType=VARCHAR}, - video_cover_img = #{videoCoverImg,jdbcType=VARCHAR}, - sort = #{sort,jdbcType=INTEGER}, - limit_number = #{limitNumber,jdbcType=INTEGER}, - product_score = #{productScore,jdbcType=INTEGER}, - status = #{status,jdbcType=TINYINT}, - fail_msg = #{failMsg,jdbcType=VARCHAR}, - is_recommend = #{isRecommend,jdbcType=TINYINT}, - is_hot = #{isHot,jdbcType=TINYINT}, - is_new = #{isNew,jdbcType=TINYINT}, - is_on_sale = #{isOnSale,jdbcType=TINYINT}, - is_show = #{isShow,jdbcType=TINYINT}, - type_enum = #{typeEnum,jdbcType=VARCHAR}, - is_distribute = #{isDistribute,jdbcType=TINYINT}, - is_del = #{isDel,jdbcType=TINYINT}, - is_stock = #{isStock,jdbcType=TINYINT}, - is_pause_sale = #{isPauseSale,jdbcType=TINYINT}, - is_free_freight = #{isFreeFreight,jdbcType=TINYINT}, - freight_id = #{freightId,jdbcType=BIGINT}, - strategy_type = #{strategyType,jdbcType=VARCHAR}, - strategy_id = #{strategyId,jdbcType=INTEGER}, - is_vip = #{isVip,jdbcType=TINYINT}, - is_delete = #{isDelete,jdbcType=TINYINT}, - created_at = #{createdAt,jdbcType=BIGINT}, - updated_at = #{updatedAt,jdbcType=BIGINT}, - base_sales_number = #{baseSalesNumber,jdbcType=DOUBLE}, - real_sales_number = #{realSalesNumber,jdbcType=INTEGER}, - sales_number = #{salesNumber,jdbcType=INTEGER}, - thumb_count = #{thumbCount,jdbcType=INTEGER}, - store_count = #{storeCount,jdbcType=INTEGER}, - furnish_meal = #{furnishMeal,jdbcType=INTEGER}, - furnish_express = #{furnishExpress,jdbcType=INTEGER}, - furnish_draw = #{furnishDraw,jdbcType=INTEGER}, - furnish_vir = #{furnishVir,jdbcType=INTEGER}, - is_combo = #{isCombo,jdbcType=TINYINT}, - is_show_cash = #{isShowCash,jdbcType=TINYINT}, - is_show_mall = #{isShowMall,jdbcType=TINYINT}, - is_need_examine = #{isNeedExamine,jdbcType=TINYINT}, - show_on_mall_status = #{showOnMallStatus,jdbcType=TINYINT}, - show_on_mall_time = #{showOnMallTime,jdbcType=BIGINT}, - show_on_mall_error_msg = #{showOnMallErrorMsg,jdbcType=VARCHAR}, - enable_label = #{enableLabel,jdbcType=TINYINT}, - tax_config_id = #{taxConfigId,jdbcType=VARCHAR}, - spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR}, - images = #{images,jdbcType=LONGVARCHAR}, - video = #{video,jdbcType=LONGVARCHAR}, - notice = #{notice,jdbcType=LONGVARCHAR}, - group_snap = #{groupSnap,jdbcType=LONGVARCHAR}, - spec_info = #{specInfo,jdbcType=LONGVARCHAR}, - select_spec = #{selectSpec,jdbcType=LONGVARCHAR}, - stock_number = #{stockNumber,jdbcType=INTEGER} + set category_id = #{categoryId,jdbcType=VARCHAR}, + spec_id = #{specId,jdbcType=INTEGER}, + source_path = #{sourcePath,jdbcType=VARCHAR}, + brand_id = #{brandId,jdbcType=INTEGER}, + merchant_id = #{merchantId,jdbcType=VARCHAR}, + shop_id = #{shopId,jdbcType=VARCHAR}, + name = #{name,jdbcType=VARCHAR}, + short_title = #{shortTitle,jdbcType=VARCHAR}, + type = #{type,jdbcType=VARCHAR}, + pack_fee = #{packFee,jdbcType=DECIMAL}, + low_price = #{lowPrice,jdbcType=DECIMAL}, + low_member_price = #{lowMemberPrice,jdbcType=DECIMAL}, + unit_id = #{unitId,jdbcType=VARCHAR}, + unit_snap = #{unitSnap,jdbcType=VARCHAR}, + cover_img = #{coverImg,jdbcType=VARCHAR}, + share_img = #{shareImg,jdbcType=VARCHAR}, + video_cover_img = #{videoCoverImg,jdbcType=VARCHAR}, + sort = #{sort,jdbcType=INTEGER}, + limit_number = #{limitNumber,jdbcType=INTEGER}, + product_score = #{productScore,jdbcType=INTEGER}, + status = #{status,jdbcType=TINYINT}, + fail_msg = #{failMsg,jdbcType=VARCHAR}, + is_recommend = #{isRecommend,jdbcType=TINYINT}, + is_hot = #{isHot,jdbcType=TINYINT}, + is_new = #{isNew,jdbcType=TINYINT}, + is_on_sale = #{isOnSale,jdbcType=TINYINT}, + is_show = #{isShow,jdbcType=TINYINT}, + type_enum = #{typeEnum,jdbcType=VARCHAR}, + is_distribute = #{isDistribute,jdbcType=TINYINT}, + is_del = #{isDel,jdbcType=TINYINT}, + is_stock = #{isStock,jdbcType=TINYINT}, + is_pause_sale = #{isPauseSale,jdbcType=TINYINT}, + is_free_freight = #{isFreeFreight,jdbcType=TINYINT}, + freight_id = #{freightId,jdbcType=BIGINT}, + strategy_type = #{strategyType,jdbcType=VARCHAR}, + strategy_id = #{strategyId,jdbcType=INTEGER}, + is_vip = #{isVip,jdbcType=TINYINT}, + is_delete = #{isDelete,jdbcType=TINYINT}, + created_at = #{createdAt,jdbcType=BIGINT}, + updated_at = #{updatedAt,jdbcType=BIGINT}, + base_sales_number = #{baseSalesNumber,jdbcType=DOUBLE}, + real_sales_number = #{realSalesNumber,jdbcType=INTEGER}, + sales_number = #{salesNumber,jdbcType=INTEGER}, + thumb_count = #{thumbCount,jdbcType=INTEGER}, + store_count = #{storeCount,jdbcType=INTEGER}, + furnish_meal = #{furnishMeal,jdbcType=INTEGER}, + furnish_express = #{furnishExpress,jdbcType=INTEGER}, + furnish_draw = #{furnishDraw,jdbcType=INTEGER}, + furnish_vir = #{furnishVir,jdbcType=INTEGER}, + is_combo = #{isCombo,jdbcType=TINYINT}, + is_show_cash = #{isShowCash,jdbcType=TINYINT}, + is_show_mall = #{isShowMall,jdbcType=TINYINT}, + is_need_examine = #{isNeedExamine,jdbcType=TINYINT}, + show_on_mall_status = #{showOnMallStatus,jdbcType=TINYINT}, + show_on_mall_time = #{showOnMallTime,jdbcType=BIGINT}, + show_on_mall_error_msg = #{showOnMallErrorMsg,jdbcType=VARCHAR}, + enable_label = #{enableLabel,jdbcType=TINYINT}, + tax_config_id = #{taxConfigId,jdbcType=VARCHAR}, + spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR}, + images = #{images,jdbcType=LONGVARCHAR}, + video = #{video,jdbcType=LONGVARCHAR}, + notice = #{notice,jdbcType=LONGVARCHAR}, + group_snap = #{groupSnap,jdbcType=LONGVARCHAR}, + spec_info = #{specInfo,jdbcType=LONGVARCHAR}, + select_spec = #{selectSpec,jdbcType=LONGVARCHAR}, + stock_number = #{stockNumber,jdbcType=INTEGER}, + warn_line = #{warnLine,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER} @@ -891,7 +902,8 @@ enable_label = #{enableLabel,jdbcType=TINYINT}, tax_config_id = #{taxConfigId,jdbcType=VARCHAR}, spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR}, - stock_number = #{stockNumber,jdbcType=INTEGER} + stock_number = #{stockNumber,jdbcType=INTEGER}, + warn_line = #{warnLine,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER} diff --git a/src/main/resources/mapper/TbProductSkuMapper.xml b/src/main/resources/mapper/TbProductSkuMapper.xml index f8b1cfb..5844d62 100644 --- a/src/main/resources/mapper/TbProductSkuMapper.xml +++ b/src/main/resources/mapper/TbProductSkuMapper.xml @@ -15,7 +15,6 @@ - @@ -54,7 +53,7 @@ product_id, origin_price, cost_price, member_price, meal_price, sale_price, guide_price, strategy_price, stock_number, - cover_img, warn_line, weight, + cover_img, weight, volume, real_sales_number, first_shared, second_shared, created_at, updated_at, spec_info, spec_snap) @@ -62,7 +61,7 @@ #{productId,jdbcType=VARCHAR}, #{originPrice,jdbcType=DECIMAL}, #{costPrice,jdbcType=DECIMAL}, #{memberPrice,jdbcType=DECIMAL}, #{mealPrice,jdbcType=DECIMAL}, #{salePrice,jdbcType=DECIMAL}, #{guidePrice,jdbcType=DECIMAL}, #{strategyPrice,jdbcType=DECIMAL}, #{stockNumber,jdbcType=DOUBLE}, - #{coverImg,jdbcType=VARCHAR}, #{warnLine,jdbcType=INTEGER}, #{weight,jdbcType=DOUBLE}, + #{coverImg,jdbcType=VARCHAR}, #{weight,jdbcType=DOUBLE}, #{volume,jdbcType=REAL}, #{realSalesNumber,jdbcType=DOUBLE}, #{firstShared,jdbcType=DECIMAL}, #{secondShared,jdbcType=DECIMAL}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{specInfo,jdbcType=LONGVARCHAR}, #{specSnap,jdbcType=LONGVARCHAR}) @@ -109,9 +108,6 @@ cover_img, - - warn_line, - weight, @@ -180,9 +176,6 @@ #{coverImg,jdbcType=VARCHAR}, - - #{warnLine,jdbcType=INTEGER}, - #{weight,jdbcType=DOUBLE}, @@ -251,9 +244,6 @@ cover_img = #{coverImg,jdbcType=VARCHAR}, - - warn_line = #{warnLine,jdbcType=INTEGER}, - weight = #{weight,jdbcType=DOUBLE}, @@ -298,7 +288,6 @@ strategy_price = #{strategyPrice,jdbcType=DECIMAL}, stock_number = #{stockNumber,jdbcType=DOUBLE}, cover_img = #{coverImg,jdbcType=VARCHAR}, - warn_line = #{warnLine,jdbcType=INTEGER}, weight = #{weight,jdbcType=DOUBLE}, volume = #{volume,jdbcType=REAL}, real_sales_number = #{realSalesNumber,jdbcType=DOUBLE}, @@ -324,7 +313,6 @@ strategy_price = #{strategyPrice,jdbcType=DECIMAL}, stock_number = #{stockNumber,jdbcType=DOUBLE}, cover_img = #{coverImg,jdbcType=VARCHAR}, - warn_line = #{warnLine,jdbcType=INTEGER}, weight = #{weight,jdbcType=DOUBLE}, volume = #{volume,jdbcType=REAL}, real_sales_number = #{realSalesNumber,jdbcType=DOUBLE},