master
15004070936 9 hours ago
parent 4e4851533f
commit e04740b87f

@ -79,5 +79,6 @@ public class ProductQuery {
private List<Long> brandIds; private List<Long> brandIds;
private List<Long> CategoryIds; private List<Long> CategoryIds;
private Long storeId;
private String tenantId;
} }

@ -2,6 +2,7 @@ package com.ruoyi.mall.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.mall.domain.Product; import com.ruoyi.mall.domain.Product;
import com.ruoyi.mall.domain.query.ProductQuery;
import java.util.List; import java.util.List;
@ -14,8 +15,8 @@ public interface ProductMapper extends BaseMapper<Product> {
/** /**
* *
* *
* @param product * @param query
* @return * @return
*/ */
List<Product> selectByEntity(Product product); List<Product> selectByEntity(ProductQuery query);
} }

@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.mall.domain.*; import com.ruoyi.mall.domain.*;
import com.ruoyi.mall.domain.query.ProductQuery; import com.ruoyi.mall.domain.query.ProductQuery;
@ -21,7 +23,6 @@ import com.ruoyi.mall.mapper.SkuMapper;
import com.ruoyi.system.domain.AppUser; import com.ruoyi.system.domain.AppUser;
import com.ruoyi.system.service.YjAppUserService; import com.ruoyi.system.service.YjAppUserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -86,64 +87,19 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
if (page != null) { if (page != null) {
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize()); PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
} }
QueryWrapper<Product> qw = new QueryWrapper<>(); SysUser loginUser=SecurityUtils.getLoginUser().getUser();
if (StringUtils.isNoneEmpty(query.getOrderField())){
if (StringUtils.isNotEmpty(query.getOrderSort()) && "desc".equalsIgnoreCase(query.getOrderSort())) {
qw.orderByDesc(query.getOrderField());
} else {
qw.orderByAsc(query.getOrderField());
}
}else {
qw.orderByDesc("publish_status");
qw.orderByAsc("sort");
}
Long categoryId = query.getCategoryId();
if (categoryId != null) {
qw.eq("category_id", categoryId);
}
Long brandId = query.getBrandId();
if (categoryId != null) {
qw.eq("brand_id", brandId);
}
Integer publishStatus = query.getPublishStatus();
if (publishStatus != null) {
qw.eq("publish_status", publishStatus);
}
String search = query.getSearch();
if (StringUtils.isNoneEmpty(search)){
qw.like("name", "%".concat(query.getSearch().trim()).concat("%"));
}
if (CollectionUtil.isNotEmpty(query.getExcludeProductIds())) {
qw.notIn("id",query.getExcludeProductIds());
}
if (CollectionUtil.isNotEmpty(query.getIds())) {
qw.in("id",query.getIds());
}
String nameLike = query.getNameLike();
if (StringUtils.isNoneEmpty(nameLike)){
qw.like("name", "%".concat(nameLike).concat("%"));
}
if (ObjectUtil.isNotEmpty(query.getIsCourse())){
qw.eq("is_course", query.getIsCourse());
}
if (ObjectUtil.isNotEmpty(query.getOutProductId())){ //租户管理员 查全部商品
qw.eq("out_product_id", query.getOutProductId()); if (loginUser.getRoles().stream().anyMatch(it -> it.getRoleId().equals(new Long(100)))){
} query.setTenantId(loginUser.tenantId);
}else {
if (StringUtils.isNotEmpty(query.getBrandNameLike())){ //店员 查本店
qw.like("brand_name", "%".concat(query.getBrandNameLike()).concat("%")); query.setStoreId(SecurityUtils.getDeptId());
}
if (StringUtils.isNotEmpty(query.getProductCategoryNameLike())){
qw.like("product_category_name", "%".concat(query.getProductCategoryNameLike()).concat("%"));
} }
qw.eq("store_id",SecurityUtils.getDeptId()); return productMapper.selectByEntity(query);
return productMapper.selectList(qw);
} }
public void getIds(ProductQuery query){ public void getIds(ProductQuery query){
@ -183,7 +139,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
*/ */
@Transactional @Transactional
public int insert(ProductVO productVO) { public int insert(ProductVO productVO) {
LoginUser loginUser= SecurityUtils.getLoginUser();
Product product = BeanUtil.toBean(productVO,Product.class); Product product = BeanUtil.toBean(productVO,Product.class);
product.setCreateTime(LocalDateTime.now()); product.setCreateTime(LocalDateTime.now());
product.setStoreId(SecurityUtils.getDeptId()); product.setStoreId(SecurityUtils.getDeptId());
@ -191,7 +147,14 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
setProductManager(productVO,product); setProductManager(productVO,product);
List<Sku> skuList = productVO.getSkuList(); List<Sku> skuList = productVO.getSkuList();
if(loginUser.getPermissions().contains("pms:review:list")
||loginUser.getPermissions().contains("*:*:*")){
if (ObjectUtil.isEmpty(productVO.getCategoryId())){
throw new RuntimeException("请选择商品分类");
}
}else {
product.setCategoryId(1l);//默认为场馆商品
}
productMapper.insert(product); productMapper.insert(product);
if(skuList!=null){ if(skuList!=null){

@ -47,7 +47,7 @@ public class YogaTask {
deptService.expireDept(); deptService.expireDept();
} }
/** /**
* * 00:05
*/ */
public void expireMemberCard() { public void expireMemberCard() {
memberCardService.expiredMemberCard(); memberCardService.expiredMemberCard();

@ -498,6 +498,7 @@ public class ScMemberCardServiceImpl extends ServiceImpl<ScMemberCardMapper, ScM
return updatedRows; return updatedRows;
} }
/** /**
* *
*/ */

@ -36,23 +36,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql> </sql>
<select id="selectByEntity" parameterType="Product" resultMap="ProductResult"> <select id="selectByEntity" parameterType="Product" resultMap="ProductResult">
<include refid="selectProductVo"/> select a.id,
a.brand_id,
a.category_id,
a.out_product_id,
a.name,
a.pic,
a.album_pics,
a.publish_status,
a.sort,
a.price,
a.unit,
a.weight,
a.detail_html,
a.detail_mobile_html,
a.is_course,
b.type_name as product_category_name,
c.name as brand_name
from mall_product a left join mall_product_category b on a.category_id = b.id
left join mall_brand c on a.brand_id = c.id
<where> <where>
<if test="brandId != null "> and brand_id = #{brandId}</if> <if test="brandId != null "> and a.brand_id = #{brandId}</if>
<if test="categoryId != null "> and category_id = #{categoryId}</if> <if test="categoryId != null "> and a.category_id = #{categoryId}</if>
<if test="outProductId != null and outProductId != ''"> and out_product_id = #{outProductId}</if> <if test="outProductId != null and outProductId != ''"> and a.out_product_id = #{outProductId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="nameLike != null and nameLike != ''"> and a.name like concat('%', #{nameLike}, '%')</if>
<if test="pic != null and pic != ''"> and pic = #{pic}</if> <if test="publishStatus != null "> and a.publish_status = #{publishStatus}</if>
<if test="albumPics != null and albumPics != ''"> and album_pics = #{albumPics}</if> <if test="isCourse != null "> and a.is_course = #{isCourse}</if>
<if test="publishStatus != null "> and publish_status = #{publishStatus}</if> <if test="storeId != null "> and a.store_id = #{storeId}</if>
<if test="sort != null "> and sort = #{sort}</if> <if test="tenantId != null and tenantId!= ''"> and a.tenant_id = #{tenantId}</if>
<if test="price != null "> and price = #{price}</if>
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
<if test="weight != null "> and weight = #{weight}</if>
<if test="detailHtml != null and detailHtml != ''"> and detail_html = #{detailHtml}</if>
<if test="detailMobileHtml != null and detailMobileHtml != ''"> and detail_mobile_html = #{detailMobileHtml}</if>
<if test="brandName != null and brandName != ''"> and brand_name like concat('%', #{brandName}, '%')</if>
<if test="productCategoryName != null and productCategoryName != ''"> and product_category_name like concat('%', #{productCategoryName}, '%')</if>
</where> </where>
order a.sort ASC
</select> </select>
</mapper> </mapper>

@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="applyStatus != null and applyStatus !=''"> <if test="applyStatus != null and applyStatus !=''">
and a.apply_status =#{applyStatus} and a.apply_status =#{applyStatus}
</if> </if>
ORDER BY a.apply_time DESC,a.sort ASC ORDER BY a.sort ASC
</select> </select>
<update id="onSaleProductShow" parameterType="int"> <update id="onSaleProductShow" parameterType="int">
@ -58,6 +58,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="expireProductShow" parameterType="int"> <update id="expireProductShow" parameterType="int">
UPDATE mall_product_show UPDATE mall_product_show
SET show_flag = '0', apply_status = '4' SET show_flag = '0', apply_status = '4'
WHERE show_end_time = DATE_SUB(CURDATE(), INTERVAL 1 DAY) and apply_status = '3'; WHERE show_end_time <![CDATA[ < ]]> CURDATE() and apply_status = '3';
</update> </update>
</mapper> </mapper>

@ -185,7 +185,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="expireDept" parameterType="int"> <update id="expireDept" parameterType="int">
UPDATE sys_dept UPDATE sys_dept
SET status = '1' SET status = '1'
WHERE expiry_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE expiry_date <![CDATA[ < ]]> CURDATE()
AND status = '0' AND status = '0'
and delete_flag = '0'; and delete_flag = '0';
</update> </update>

@ -36,7 +36,7 @@
<update id="expireTenant" parameterType="int"> <update id="expireTenant" parameterType="int">
UPDATE sys_tenant UPDATE sys_tenant
SET in_use = '1' SET in_use = '1'
WHERE end_time = DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE end_time <![CDATA[ < ]]> CURDATE()
and in_use='0' and in_use='0'
and delete_flag='0'; and delete_flag='0';
</update> </update>

Loading…
Cancel
Save