From 81a3369395a7cccceb7cd36f5238cc6fe2aa88e5 Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Fri, 19 Mar 2021 00:22:01 +0800 Subject: [PATCH] 优化代码 --- zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxScoreProductAction.java | 3 zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-list.html | 16 ++-- zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java | 14 ++-- zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopShoppingCartDao.xml | 16 +---- zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopProduct.java | 20 +++--- zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopProductDao.xml | 38 ++++++------ zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java | 1 zq-erp/src/main/resources/config/db/increment/推广员.sql | 10 +-- zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopShoppingCart.java | 12 --- zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopShoppingCartDao.java | 4 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductAttributeAction.java | 4 zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-form.html | 12 ++-- 12 files changed, 63 insertions(+), 87 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductAttributeAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductAttributeAction.java index 2adf5f8..07dbded 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductAttributeAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductAttributeAction.java @@ -28,9 +28,9 @@ @Autowired private ShopProductAttributeDao shopProductAttributeDao; - @RequestMapping("/getByCode/{shopId}/{attrCode}") + @RequestMapping("/getByCode/{attrCode}") @ResponseBody - public AjaxResult getProductAttributeByCode(@PathVariable("shopId") Long shopId, @PathVariable("attrCode") String attrCode){ + public AjaxResult getProductAttributeByCode(@PathVariable("attrCode") String attrCode){ if(!StringUtils.isNotBlank(attrCode)){ return new AjaxResult(AjaxResult.STATUS_FAIL,"属性编码不能为空"); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxScoreProductAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxScoreProductAction.java index 4e069b7..aa403fd 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxScoreProductAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxScoreProductAction.java @@ -48,8 +48,7 @@ shopProduct.setScoreCategoryId(scoreProductDto.getScoreCategoryId()); shopProduct.setDelFlag(AppConstance.DATA_USEABLE); shopProduct.setStatus(AppConstance.IS_PUTAWAY); - shopProduct.setAbleSales(ShopProduct.NOT_ABLE_SALES); - shopProduct.setMallType(ShopProduct.MALL_SCORE); + shopProduct.setAbleScorePay(ShopProduct.PAYFOR_SCORE); shopProduct.setCompanyId(HostInterceptor.getCompanyId()); List<ShopProduct> shopProducts = shopProductDao.selectByModelWx(shopProduct); shopProducts.forEach(item->item.setSkus(shopSkuDao.selectByPid(item.getId()))); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java index 00154cd..8b408f8 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java @@ -146,7 +146,6 @@ @ResponseBody public AjaxResult getShopProductShowList(@RequestBody ShopProduct shopProduct) { List<ShopProduct> shopProducts = null; - shopProduct.setMallType(ShopProduct.MALL_MICRO); //查询是否匹配优惠条件 ShopCoupon shopCoupon = shopCouponDao.getCouponByTitle(shopProduct.getTitle(),HostInterceptor.getCompanyId()); if (shopCoupon != null && shopProduct.getOffset() < 1) { diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java index 051afbe..0b31678 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java @@ -95,12 +95,12 @@ } @ApiOperation(value = "查询微商城购物车数量", notes = "") - @PostMapping(value = "/getUserCartCount/{shopId}/{cartType}") + @PostMapping(value = "/getUserCartCount/{shopId}") public @ResponseBody - AjaxResult getUserCartCount(@PathVariable("shopId") Long shopId,@PathVariable("cartType") Integer cartType) { + AjaxResult getUserCartCount(@PathVariable("shopId") Long shopId) { BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); - Integer userCartCount = shoppingCartDao.selectUserCartCount(shopId, loginUser.getOpenId(),cartType); + Integer userCartCount = shoppingCartDao.selectUserCartCount(shopId, loginUser.getOpenId()); if (userCartCount == null) { userCartCount = 0; } @@ -187,7 +187,7 @@ return new AjaxResult(AjaxResult.STATUS_FAIL, "保存失败"); } int userCartCount = shoppingCartDao.selectUserCartCount(shoppingCart.getShopId(), - loginUser.getOpenId(),shoppingCart.getCartType()); + loginUser.getOpenId()); AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, "保存成功"); result.putInMap("userCartCount", userCartCount); return result; @@ -267,12 +267,12 @@ * @param * @return */ - @PostMapping("/updateCartAllSelected/{shopId}/{isSelected}/{cartType}") + @PostMapping("/updateCartAllSelected/{shopId}/{isSelected}") @ResponseBody public AjaxResult updateCartAllSelected(@PathVariable("isSelected") Integer isSelected, - @PathVariable("shopId") Long shopId,@PathVariable("cartType") Integer cartType) { + @PathVariable("shopId") Long shopId) { BizUser user = redisUserLoginUtils.getLoginUser(BizUser.class); - shoppingCartDao.updateAllSelected(user.getOpenId(),shopId, isSelected,cartType); + shoppingCartDao.updateAllSelected(user.getOpenId(),shopId, isSelected); return new AjaxResult(AjaxResult.STATUS_SUCCESS, "修改成功"); } } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopProduct.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopProduct.java index 5057ab4..440cac1 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopProduct.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopProduct.java @@ -13,15 +13,15 @@ */ @Data public class ShopProduct extends EntityDTOExt { + /** + * 可用积分 + */ + public static final int PAYFOR_SCORE =1; + /** + * 不用积分 + */ + public static final int NOT_PAYFOR_SCORE =2; - /** - * 卖场-微商城 - */ - public static final int MALL_MICRO =1; - /** - * 卖场-积分商城 - */ - public static final int MALL_SCORE=2; /** * 可分销 */ @@ -80,9 +80,9 @@ private String imgMobile; /** - * 上架卖场 1 微商城,2 积分商城 + * 是否可用积分支付 1是,2不是 */ - private Integer mallType; + private Integer ableScorePay; /** diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopShoppingCart.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopShoppingCart.java index f8c275e..a9c2ae4 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopShoppingCart.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopShoppingCart.java @@ -59,10 +59,7 @@ * 用户是否选中 1选中 2未选中 */ private Integer isSelected; - /** - * 购物车类型 1微商城 2积分商城 - */ - private Integer cartType; + @@ -340,11 +337,4 @@ return shopCoupons; } - public Integer getCartType() { - return cartType; - } - - public void setCartType(Integer cartType) { - this.cartType = cartType; - } } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopShoppingCartDao.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopShoppingCartDao.java index e0824de..d8ef5de 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopShoppingCartDao.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopShoppingCartDao.java @@ -42,9 +42,9 @@ public ShopShoppingCart selectBuyLimit(@Param("cartProductId") Integer cartProductId,@Param("cartSkuId") Integer cartSkuId); - public Integer selectUserCartCount(@Param("shopId")Long shopId, @Param("openId")String openId,@Param("cartType") Integer cartType); + public Integer selectUserCartCount(@Param("shopId")Long shopId, @Param("openId")String openId); - public int updateAllSelected(@Param("openId") String openId, @Param("shopId") Long shopId, @Param("isSelected") Integer isSelected,@Param("cartType") Integer cartType); + public int updateAllSelected(@Param("openId") String openId, @Param("shopId") Long shopId, @Param("isSelected") Integer isSelected); /** * 删除用户选中的购物车明细 diff --git "a/zq-erp/src/main/resources/config/db/increment/\346\216\250\345\271\277\345\221\230.sql" "b/zq-erp/src/main/resources/config/db/increment/\346\216\250\345\271\277\345\221\230.sql" index 59a86bc..b719f98 100644 --- "a/zq-erp/src/main/resources/config/db/increment/\346\216\250\345\271\277\345\221\230.sql" +++ "b/zq-erp/src/main/resources/config/db/increment/\346\216\250\345\271\277\345\221\230.sql" @@ -188,15 +188,11 @@ ALTER TABLE `shop_product` ADD COLUMN `score_category_id` bigint(20) NULL COMMENT '积分商城分类ID' AFTER `company_id`, -ADD COLUMN `able_sales` int(2) NULL COMMENT '是否为分销产品' AFTER `score_category_id`, -ADD COLUMN `mall_type` int(2) NULL COMMENT '上架卖场' AFTER `able_sales`; +ADD COLUMN `able_sales` int(2) NULL COMMENT '是否为分销产品1是2不是' AFTER `score_category_id`, +ADD COLUMN `able_score_pay` int(2) NULL COMMENT '是否可用积分支付1是2不是' AFTER `able_sales`; -update shop_product set mall_type=1; +update shop_product set able_score_pay=1; update shop_product set able_sales=2; -ALTER TABLE `shop_shopping_cart` - ADD COLUMN `cart_type` int(2) NOT NULL COMMENT '购物车类型 1微商城 2积分商城' AFTER `company_id`; - -update shop_shopping_cart set cart_type=1; diff --git a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopProductDao.xml b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopProductDao.xml index 405abca..91c105d 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopProductDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopProductDao.xml @@ -42,7 +42,7 @@ <result property="couponId" column="couponId"></result> <result property="serviceTime" column="service_time"></result> <result property="companyId" column="company_id"/> - <result property="mallType" column="mall_type"/> + <result property="ableScorePay" column="able_score_pay"/> <result property="ableSales" column="able_sales"/> <result property="scoreCategoryId" column="score_category_id"/> @@ -84,7 +84,7 @@ <result property="couponId" column="couponId"></result> <result property="serviceTime" column="service_time"></result> <result property="companyId" column="company_id"/> - <result property="mallType" column="mall_type"/> + <result property="ableScorePay" column="able_score_pay"/> <result property="ableSales" column="able_sales"/> <result property="scoreCategoryId" column="score_category_id"/> </resultMap> @@ -121,7 +121,7 @@ service_time, shop_ids, company_id, - mall_type, + able_score_pay, able_sales, score_category_id @@ -160,7 +160,7 @@ #{item.serviceTime}, #{item.shopIds}, #{item.companyId}, - #{item.mallType}, + #{item.ableScorePay}, #{item.ableSales}, #{item.scoreCategoryId} @@ -252,8 +252,8 @@ and a.company_id = #{record.companyId} </if> - <if test="record.mallType != null and record.mallType !='' "> - and a.mall_type = #{record.mallType} + <if test="record.ableScorePay != null and record.ableScorePay !='' "> + and a.able_score_pay = #{record.ableScorePay} </if> <if test="record.ableSales != null and record.ableSales !='' "> and a.able_sales = #{record.ableSales} @@ -336,8 +336,8 @@ and b.attr_full_path like concat('%/',#{record.attrs},'/%') </if> - <if test="record.mallType != null and record.mallType !='' "> - and a.mall_type = #{record.mallType} + <if test="record.ableScorePay != null and record.ableScorePay !='' "> + and a.able_score_pay = #{record.ableScorePay} </if> <if test="record.ableSales != null and record.ableSales !='' "> and a.able_sales = #{record.ableSales} @@ -459,8 +459,8 @@ <if test="_parameter.containsKey('ableSales')"> able_sales = #{ableSales}, </if> - <if test="_parameter.containsKey('mallType')"> - mall_type = #{mallType}, + <if test="_parameter.containsKey('ableScorePay')"> + able_score_pay = #{ableScorePay}, </if> @@ -545,8 +545,8 @@ shop_ids = #{record.shopIds}, </if> - <if test="record.mallType != null and record.mallType !='' "> - mall_type = #{record.mallType}, + <if test="record.ableScorePay != null and record.ableScorePay !='' "> + able_score_pay = #{record.ableScorePay}, </if> <if test="record.ableSales != null and record.ableSales !='' "> able_sales = #{record.ableSales}, @@ -642,7 +642,7 @@ a.marked_price, b.attr_full_path, a.couponId, - a.mall_type, + a.able_score_pay, a.able_sales, a.score_category_id, (SELECT ROUND(SUM(ss.stock),2) from shop_sku ss where ss.p_id = a.id) as stockNum, @@ -685,7 +685,7 @@ a.marked_price, a.service_time, a.couponId, - a.mall_type, + a.able_score_pay, a.able_sales, a.score_category_id, (SELECT ROUND(SUM(ss.stock),2) from shop_sku ss where ss.p_id = a.id) as stockNum @@ -725,7 +725,7 @@ a.marked_price, b.attr_full_path, a.couponId, - a.mall_type, + a.able_score_pay, a.able_sales, a.score_category_id, a.service_time, @@ -793,7 +793,7 @@ b.attr_full_path, a.service_time, a.couponId, - a.mall_type, + a.able_score_pay, a.able_sales, a.score_category_id, (SELECT ROUND(SUM(s.stock),2) from shop_sku s where s.p_id = a.id) as stockNum, @@ -838,8 +838,8 @@ and find_in_set(#{record.shopIds}, a.shop_ids) </if> - <if test="record.mallType != null and record.mallType !='' "> - and a.mall_type = #{record.mallType} + <if test="record.ableScorePay != null and record.ableScorePay !='' "> + and a.able_score_pay = #{record.ableScorePay} </if> <if test="record.ableSales != null and record.ableSales !='' "> and a.able_sales = #{record.ableSales} @@ -906,7 +906,7 @@ is_special_price, marked_price, couponId, - a.mall_type, + a.able_score_pay, a.able_sales, a.score_category_id, (SELECT SUM(s.stock) from shop_sku s where s.p_id = a.id) as stockNum, diff --git a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopShoppingCartDao.xml b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopShoppingCartDao.xml index 2beb6dd..271fc01 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopShoppingCartDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopShoppingCartDao.xml @@ -27,7 +27,6 @@ <result property="isSelected" column="isSelected" /> <result property="shopId" column="shop_id" /> <result property="companyId" column="company_id" /> - <result property="cartType" column="cart_type" /> </resultMap> @@ -45,7 +44,6 @@ <result property="isSelected" column="isSelected" /> <result property="shopId" column="shop_id" /> <result property="companyId" column="company_id" /> - <result property="cartType" column="cart_type" /> </resultMap> @@ -62,8 +60,7 @@ cart_number, isSelected, shop_id, - company_id, - cart_type + company_id </sql> @@ -80,8 +77,7 @@ #{item.cartNumber}, #{item.isSelected}, #{item.shopId}, - #{item.companyId}, - #{item.cartType} + #{item.companyId} </sql> @@ -130,9 +126,6 @@ and c.company_id = #{record.companyId} </if> - <if test="record.cartType != null and record.cartType !='' "> - and c.cart_type = #{record.cartType} - </if> </if> @@ -223,7 +216,7 @@ <update id="updateAllSelected" > - update shop_shopping_cart set isSelected = #{isSelected} where shop_id=#{shopId} and cart_user_id=#{openId} and cart_type=#{cartType} + update shop_shopping_cart set isSelected = #{isSelected} where shop_id=#{shopId} and cart_user_id=#{openId} </update> @@ -345,7 +338,6 @@ and p.STATUS = 1 and p.del_flag = 2 and c.cart_user_id = #{cartUserId} - and c.cart_type = #{cartType} order by c.create_time desc </select> @@ -363,7 +355,7 @@ <select id="selectUserCartCount" resultType="java.lang.Integer" > select sum(cart_number) from shop_shopping_cart c LEFT JOIN shop_product p on p.id = c.cart_product_id -where c.shop_Id=#{shopId} and p.del_flag = 2 and cart_user_id=#{openId} and cart_type=#{cartType}; +where c.shop_Id=#{shopId} and p.del_flag = 2 and cart_user_id=#{openId} </select> <!-- 根据id 锁表查询--> diff --git a/zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-form.html b/zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-form.html index 3d20568..e6b0421 100644 --- a/zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-form.html +++ b/zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-form.html @@ -83,15 +83,15 @@ </div> </div> <div class="form-group"> - <label class="col-sm-2 control-label">上架卖场 + <label class="col-sm-2 control-label">是否积分抵 <span class="text-danger">*</span> </label> <div class="col-sm-4"> - <select th:field="${obj.mallType}" class="form-control select2 " size="1" - name="mallType" - id="mallType" style="width: 100%"> - <option value="1" th:selected="${obj.mallType == '1'}">微商城</option> - <option value="2" th:selected="${obj.mallType == '2'}">积分商城</option> + <select th:field="${obj.ableScorePay}" class="form-control select2 " size="1" + name="ableScorePay" + id="ableScorePay" style="width: 100%"> + <option value="2" th:selected="${obj.ableScorePay == '2'}">不可抵扣</option> + <option value="1" th:selected="${obj.ableScorePay == '1'}">可抵扣</option> </option> </select> </div> diff --git a/zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-list.html b/zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-list.html index e07f5e5..dbd6cc7 100644 --- a/zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-list.html +++ b/zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-list.html @@ -36,12 +36,12 @@ type="text" class="form-control"> </div> <div class="form-group"> - <label class="control-label">上架卖场</label> + <label class="control-label">积分抵扣</label> <select style="width:100px;" class="form-control select2" size="1" - name="mallType" > + name="ableScorePay" > <option value="">请选择</option> - <option value="1">微商城</option> - <option value="2">积分商城</option> + <option value="1">可抵扣</option> + <option value="2">不可抵扣</option> </select> </div> <div class="form-group"> @@ -122,7 +122,7 @@ <tr> <th data-checkbox="true"></th> <th data-formatter="MGrid.indexfn" data-align="center">序号</th> - <th data-field="mallType" data-align="center" data-formatter="mallType">上架卖场</th> + <th data-field="ableScorePay" data-align="center" data-formatter="ableScorePay">积分抵扣</th> <th data-field="title" data-align="center">产品名称</th> <th data-field="imgMobile" data-align="center" data-formatter="MGrid.getImage">产品图片</th> <th data-field="attrValues" data-align="center" data-formatter="formatAttr">产品属性</th> @@ -298,12 +298,12 @@ }); } - function mallType(value, row, index) { + function ableScorePay(value, row, index) { var html = ""; if (value ==1) { - html="微商城" + html="可抵扣" }else{ - html="积分商城" + html="不可抵扣" } return html; } -- Gitblit v1.9.1