From 2f9365906f6e5203c3cff9cdb474c360180b80df Mon Sep 17 00:00:00 2001 From: jiangqs <343695869@qq.com> Date: 星期日, 04 六月 2023 16:06:30 +0800 Subject: [PATCH] 优化部分代码 --- ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberMapper.xml | 8 ++-- ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/management/MgtGoodsController.java | 5 -- ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml | 4 +- ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/goods/GoodsServiceImpl.java | 66 +++++++++++++++++++++++++++++--- 4 files changed, 65 insertions(+), 18 deletions(-) diff --git a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/management/MgtGoodsController.java b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/management/MgtGoodsController.java index baf2e93..e987015 100644 --- a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/management/MgtGoodsController.java +++ b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/management/MgtGoodsController.java @@ -3,18 +3,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.utils.SecurityUtils; -import com.ruoyi.goods.domain.dto.MerGoodsPageDto; import com.ruoyi.goods.domain.dto.MgtGoodsEditDto; import com.ruoyi.goods.domain.dto.MgtGoodsPageDto; -import com.ruoyi.goods.domain.vo.MerGoodsPageVo; import com.ruoyi.goods.domain.vo.MgtGoodsPageVo; import com.ruoyi.goods.domain.vo.MgtGoodsTotalVo; import com.ruoyi.goods.service.goods.GoodsService; import com.ruoyi.system.api.domain.dto.MgtBaseDto; -import com.ruoyi.system.api.domain.dto.MgtBaseGetDto; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -41,7 +37,6 @@ @RequestMapping(value = "/pageMgtGoods", method = RequestMethod.POST) @ApiOperation(value = "分页获取商品列表") public R<Page<MgtGoodsPageVo>> pageMgtGoods(@RequestBody MgtGoodsPageDto mgtGoodsPageDto) { - Long userId = SecurityUtils.getUserId(); Page<MgtGoodsPageVo> page = new Page<>(); page.setSize(mgtGoodsPageDto.getPageSize()); page.setCurrent(mgtGoodsPageDto.getPageNum()); diff --git a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/goods/GoodsServiceImpl.java b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/goods/GoodsServiceImpl.java index 06d8a08..29245d1 100644 --- a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/goods/GoodsServiceImpl.java +++ b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/goods/GoodsServiceImpl.java @@ -4,12 +4,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.core.utils.uuid.IdUtils; import com.ruoyi.goods.domain.dto.*; +import com.ruoyi.goods.domain.pojo.goods.GoodsTotal; import com.ruoyi.goods.domain.vo.*; import com.ruoyi.goods.mapper.goods.GoodsMapper; import com.ruoyi.goods.service.activity.ActivityGoodsService; import com.ruoyi.goods.service.goods.GoodsFileService; import com.ruoyi.goods.service.goods.GoodsService; +import com.ruoyi.goods.service.goods.GoodsTotalService; import com.ruoyi.goods.service.goods.ShopGoodsService; import com.ruoyi.system.api.constant.AppErrorConstant; import com.ruoyi.system.api.domain.poji.activity.ActivityGoods; @@ -53,6 +56,9 @@ @Resource private RemoteConfigService remoteConfigService; + + @Resource + private GoodsTotalService goodsTotalService; /** * 获取推荐商品列表 @@ -253,14 +259,60 @@ } /** - * 平台编辑商品 - * @param mgtGoodsEditDto - */ + * @description: editMgtGoods + * @param: mgtGoodsEditDto + * @return: void + * @author jqs34 + * @date: 2023/6/4 15:37 + */ @Override public void editMgtGoods(MgtGoodsEditDto mgtGoodsEditDto){ - - - - + Goods goods; + Boolean newGoods = false; + String goodsId = mgtGoodsEditDto.getGoodsId(); + // 判断是否有商品ID 没有则新建 + if(goodsId != null){ + goods = this.getById(goodsId); + }else{ + goods = new Goods(); + goodsId = IdUtils.simpleUUID(); + goods.setGoodsId(goodsId); + goods.setDelFlag(0); + goods.setCreateTime(DateUtils.getNowDate()); + goods.setCreateUserId(mgtGoodsEditDto.getUserId()); + newGoods = true; + } + goods.setUpdateTime(DateUtils.getNowDate()); + goods.setUpdateUserId(mgtGoodsEditDto.getUserId()); + goods.setGoodsStatus(mgtGoodsEditDto.getGoodsStatus()); + goods.setGoodsType(mgtGoodsEditDto.getGoodsType()); + goods.setGoodsClassId(mgtGoodsEditDto.getGoodsClassId()); + goods.setGoodsName(mgtGoodsEditDto.getGoodsName()); + goods.setCycleNumFlag(mgtGoodsEditDto.getCycleNumFlag()); + goods.setServiceNum(mgtGoodsEditDto.getServiceNum()); + goods.setGoodsIntroduction(mgtGoodsEditDto.getGoodsIntroduction()); + goods.setSalesPrice(mgtGoodsEditDto.getSalesPrice()); + goods.setMininumPrice(mgtGoodsEditDto.getMininumPrice()); + if(mgtGoodsEditDto.getSubscription()!=null&&mgtGoodsEditDto.getSubscription().compareTo(BigDecimal.valueOf(0))>0){ + goods.setSubscriptionFlag(1); + }else{ + goods.setSubscriptionFlag(0); + } + goods.setSubscription(mgtGoodsEditDto.getSubscription()); + goods.setGoodsDetail(mgtGoodsEditDto.getGoodsDetail()); + goods.setRecommendFlag(mgtGoodsEditDto.getRecommendFlag()); + goods.setGoodsNurses(mgtGoodsEditDto.getGoodsNurses()); + goods.setGoodsTags(mgtGoodsEditDto.getGoodsNurses()); + this.saveOrUpdate(goods); + //如果是新建商品创建商品统计 + if(newGoods){ + GoodsTotal goodsTotal = new GoodsTotal(); + goodsTotal.setGoodsId(goodsId); + goodsTotal.setBuyCount(0); + goodsTotal.setBuyNumCount(0); + goodsTotal.setBuyUserCount(0); + goodsTotal.setBuyMoneyTotal(new BigDecimal("0.00")); + goodsTotalService.saveOrUpdate(goodsTotal); + } } } diff --git a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberMapper.xml b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberMapper.xml index e53bf26..ad3b426 100644 --- a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberMapper.xml +++ b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberMapper.xml @@ -166,7 +166,7 @@ AND tm.gender = #{param.memberGender} </if> <if test="param.memberTag != null and param.memberTag != ''"> - AND FIND_IN_SET(tm.user_tags, #{param.memberTag}) + AND FIND_IN_SET(tm.user_tags, #{param.memberTag}) > 0 </if> <if test="param.startMemberDate!=null and param.startMemberDate!=''"> AND tm.create_time >= #{param.startMemberDate} @@ -218,7 +218,7 @@ INNER JOIN t_member_total tmt ON tm.member_id = tmt.member_id WHERE del_flag = 0 <if test="param.keyword != null and param.keyword != ''"> - AND (tm.member_no LIKE CONCAT('%',#{param.keyword},'%') OR tm.mobile LIKE CONCAT('%',#{param.keyword},'%') OR tm.real_name LIKE CONCAT('%',#{param.keyword},'%') OR tm.nick_name LIKE CONCAT('%',#{param.keyword},'%') OR FIND_IN_SET(tm.member_nurse,#{param.keyword})) + AND (tm.member_no LIKE CONCAT('%',#{param.keyword},'%') OR tm.mobile LIKE CONCAT('%',#{param.keyword},'%') OR tm.real_name LIKE CONCAT('%',#{param.keyword},'%') OR tm.nick_name LIKE CONCAT('%',#{param.keyword},'%') OR FIND_IN_SET(tm.member_nurse,#{param.keyword}) > 0) </if> <if test="param.belongDistrict != null and param.belongDistrict != ''"> AND tm.belong_district = #{param.belongDistrict} @@ -233,7 +233,7 @@ AND tmt.binding_flag = #{param.memberFlag} </if> <if test="param.goodsType != null and param.goodsType != ''"> - AND FIND_IN_SET(tm.goods_type,#{param.goodsType}) + AND FIND_IN_SET(tm.goods_type,#{param.goodsType}) > 0 </if> <if test="param.relationShopId != null and param.relationShopId != ''"> AND tm.relation_shop_id = #{param.relationShopId} @@ -272,7 +272,7 @@ AND tmt.total_pay_count <= #{param.endPayCount} </if> <if test="param.memberTag != null and param.memberTag != ''"> - AND FIND_IN_SET( tm.user_tags,#{param.memberTag}) + AND FIND_IN_SET( tm.user_tags,#{param.memberTag}) > 0 </if> ORDER BY tm.create_time DESC </select> diff --git a/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml b/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml index ba2e6b7..a1e47eb 100644 --- a/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml +++ b/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml @@ -350,13 +350,13 @@ AND ts.shop_source = #{param.shopSource} </if> <if test="param.shopCustomStatus!=null and param.shopCustomStatus!=''"> - AND AND FIND_IN_SET(#{param.shopCustomStatus},ts.shop_custom_status) + AND FIND_IN_SET(#{param.shopCustomStatus},ts.shop_custom_status) > 0 </if> <if test="param.expireFlag!=null and param.expireFlag!=''"> AND ts.shop_status = 2 </if> <if test="param.shopTags!=null and param.shopTags!=''"> - AND FIND_IN_SET(#{param.shopTags},ts.shop_tags) + AND FIND_IN_SET(#{param.shopTags},ts.shop_tags) > 0 </if> <if test="param.supportingCapacityFlag!=null and param.supportingCapacityFlag!=''"> AND ts.supporting_capacity_flag = #{param.supportingCapacityFlag} -- Gitblit v1.7.1