Merge branch 'master' of http://git.lionquexpress.com/wuweihua/BMS
This commit is contained in:
@@ -42,6 +42,8 @@ public class PrcPriceSet extends BaseEntity
|
||||
private List<PrcPriceSetDetail> details;
|
||||
private List<PrcPriceSetVersion> versions;
|
||||
private List<PrcCustomerPriceSet> customers;
|
||||
/** viewers explicitly bound to this package */
|
||||
private List<PrcPriceSetUser> viewers;
|
||||
/** async save task id (not persisted) */
|
||||
private String saveTaskId;
|
||||
/** Y: ignored on save; library pull only via /detail/pullFromLibrary */
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import com.bms.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/** Package viewer bind: prc_price_set_user */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PrcPriceSetUser extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long psuId;
|
||||
private Long priceSetId;
|
||||
private Long userId;
|
||||
/** login account */
|
||||
private String userName;
|
||||
/** display only, not a table column */
|
||||
private String nickName;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PrcPriceSetUser;
|
||||
|
||||
public interface PrcPriceSetUserMapper
|
||||
{
|
||||
PrcPriceSetUser selectPrcPriceSetUserById(Long psuId);
|
||||
|
||||
List<PrcPriceSetUser> selectPrcPriceSetUserList(PrcPriceSetUser query);
|
||||
|
||||
int insertPrcPriceSetUser(PrcPriceSetUser row);
|
||||
|
||||
int deletePrcPriceSetUserByIds(Long[] psuIds);
|
||||
|
||||
int deleteByPriceSetId(Long priceSetId);
|
||||
|
||||
int countBySetAndUser(@Param("priceSetId") Long priceSetId, @Param("userId") Long userId);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.bms.price.domain.PrcPriceSet;
|
||||
import com.bms.price.domain.PrcPriceSetCheckItem;
|
||||
import com.bms.price.domain.PrcPriceSetDetail;
|
||||
import com.bms.price.domain.PrcPriceSetSaveTask;
|
||||
import com.bms.price.domain.PrcPriceSetUser;
|
||||
|
||||
/**
|
||||
* 价格套餐 服务层
|
||||
@@ -91,6 +92,12 @@ public interface IPrcPriceSetService
|
||||
|
||||
public int deleteCustomerByIds(Long[] customerPricesetIds);
|
||||
|
||||
public List<PrcPriceSetUser> selectViewerList(PrcPriceSetUser query);
|
||||
|
||||
public int insertViewer(PrcPriceSetUser row);
|
||||
|
||||
public int deleteViewerByIds(Long[] psuIds);
|
||||
|
||||
/** chain expire_time = next version effective_time, then refresh 0/3/1/2 */
|
||||
public int refreshAllVersionStatus();
|
||||
|
||||
|
||||
+67
@@ -18,6 +18,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.bms.common.annotation.DataScope;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.DateUtils;
|
||||
import com.bms.common.utils.MessageUtils;
|
||||
@@ -29,6 +30,7 @@ import com.bms.price.domain.BmsProductCountry;
|
||||
import com.bms.price.domain.PrcCustomerPriceSet;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
import com.bms.price.domain.PrcPriceSet;
|
||||
import com.bms.price.domain.PrcPriceSetUser;
|
||||
import com.bms.price.domain.PrcPriceSetCheckItem;
|
||||
import com.bms.price.domain.PrcPriceSetDetail;
|
||||
import com.bms.price.domain.PrcPriceSetProduct;
|
||||
@@ -42,9 +44,12 @@ import com.bms.price.mapper.PrcCustomerPriceSetMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetDetailMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetProductMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetUserMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetVersionMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeRelMapper;
|
||||
import com.bms.common.core.domain.entity.SysUser;
|
||||
import com.bms.system.mapper.SysUserMapper;
|
||||
import com.bms.price.service.IBmsProductService;
|
||||
import com.bms.price.service.IPrcPriceExcelFileService;
|
||||
import com.bms.price.service.IPrcPriceSetService;
|
||||
@@ -98,6 +103,12 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
@Autowired
|
||||
private PrcCustomerPriceSetMapper customerMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcPriceSetUserMapper priceSetUserMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Autowired
|
||||
private BmsProductCountryMapper productCountryMapper;
|
||||
|
||||
@@ -132,9 +143,19 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Price-set list data scope: bound customer's sales user (same as customer list),
|
||||
* package creator, or explicit viewer bind. Super admin skips filter in DataScopeAspect.
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "su", deptField = "dept_id", userAlias = "su", userField = "user_id",
|
||||
permission = "price:set:list")
|
||||
public List<PrcPriceSet> selectPrcPriceSetList(PrcPriceSet set)
|
||||
{
|
||||
if (set != null)
|
||||
{
|
||||
set.getParams().put("viewerUserId", SecurityUtils.getUserId());
|
||||
}
|
||||
List<PrcPriceSet> list = setMapper.selectPrcPriceSetList(set);
|
||||
for (PrcPriceSet item : list)
|
||||
{
|
||||
@@ -2223,6 +2244,49 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
return customerMapper.deletePrcCustomerPriceSetByIds(customerPricesetIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrcPriceSetUser> selectViewerList(PrcPriceSetUser query)
|
||||
{
|
||||
return priceSetUserMapper.selectPrcPriceSetUserList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertViewer(PrcPriceSetUser row)
|
||||
{
|
||||
if (row == null || row.getPriceSetId() == null || row.getUserId() == null)
|
||||
{
|
||||
throw new ServiceException("price set user bind requires priceSetId and userId");
|
||||
}
|
||||
requireSet(row.getPriceSetId());
|
||||
if (priceSetUserMapper.countBySetAndUser(row.getPriceSetId(), row.getUserId()) > 0)
|
||||
{
|
||||
throw new ServiceException("user already bound to this price set");
|
||||
}
|
||||
SysUser user = sysUserMapper.selectUserById(row.getUserId());
|
||||
if (user == null)
|
||||
{
|
||||
throw new ServiceException("user not found");
|
||||
}
|
||||
row.setUserName(user.getUserName());
|
||||
if (StringUtils.isEmpty(row.getCreateBy()))
|
||||
{
|
||||
row.setCreateBy(SecurityUtils.getUsername());
|
||||
}
|
||||
return priceSetUserMapper.insertPrcPriceSetUser(row);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteViewerByIds(Long[] psuIds)
|
||||
{
|
||||
if (psuIds == null || psuIds.length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return priceSetUserMapper.deletePrcPriceSetUserByIds(psuIds);
|
||||
}
|
||||
|
||||
private void replaceChildren(PrcPriceSet set)
|
||||
{
|
||||
saveOrUpdateVersion(set);
|
||||
@@ -2989,6 +3053,9 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
PrcCustomerPriceSet cquery = new PrcCustomerPriceSet();
|
||||
cquery.setPriceSetId(priceSetId);
|
||||
set.setCustomers(customerMapper.selectPrcCustomerPriceSetList(cquery));
|
||||
PrcPriceSetUser uquery = new PrcPriceSetUser();
|
||||
uquery.setPriceSetId(priceSetId);
|
||||
set.setViewers(priceSetUserMapper.selectPrcPriceSetUserList(uquery));
|
||||
}
|
||||
|
||||
private void fillVersionChildren(PrcPriceSetVersion version)
|
||||
|
||||
@@ -81,6 +81,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<!-- Data scope: customer sales / creator / explicit viewer bind.
|
||||
Super admin / DATA_SCOPE_ALL leaves params.dataScope empty. -->
|
||||
<if test="params != null and params.dataScope != null and params.dataScope != ''">
|
||||
AND (
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM prc_customer_price_set cps
|
||||
INNER JOIN ctr_customer c
|
||||
ON c.customer_id = cps.customer_id
|
||||
AND ifnull(c.del_flag, '0') = '0'
|
||||
INNER JOIN sys_user su
|
||||
ON su.del_flag = '0'
|
||||
AND (su.user_name = c.sales_user_id
|
||||
OR su.user_id = c.sales_user_id + 0)
|
||||
WHERE cps.price_set_id = s.price_set_id
|
||||
${params.dataScope}
|
||||
)
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
FROM sys_user su
|
||||
WHERE su.del_flag = '0'
|
||||
AND su.user_name = s.created_by
|
||||
${params.dataScope}
|
||||
)
|
||||
<if test="params.viewerUserId != null">
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
FROM prc_price_set_user psu
|
||||
WHERE psu.price_set_id = s.price_set_id
|
||||
AND psu.user_id = #{params.viewerUserId}
|
||||
)
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
order by s.price_set_id desc
|
||||
</select>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PrcPriceSetUserMapper">
|
||||
|
||||
<resultMap type="PrcPriceSetUser" id="PrcPriceSetUserResult">
|
||||
<id property="psuId" column="psu_id" />
|
||||
<result property="priceSetId" column="price_set_id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<result property="nickName" column="nick_name" />
|
||||
<result property="createBy" column="created_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectVo">
|
||||
select psu.psu_id, psu.price_set_id, psu.user_id, psu.user_name,
|
||||
u.nick_name, psu.created_by, psu.create_time
|
||||
from prc_price_set_user psu
|
||||
left join sys_user u on u.user_id = psu.user_id
|
||||
</sql>
|
||||
|
||||
<select id="selectPrcPriceSetUserById" parameterType="Long" resultMap="PrcPriceSetUserResult">
|
||||
<include refid="selectVo"/>
|
||||
where psu.psu_id = #{psuId}
|
||||
</select>
|
||||
|
||||
<select id="selectPrcPriceSetUserList" parameterType="PrcPriceSetUser" resultMap="PrcPriceSetUserResult">
|
||||
<include refid="selectVo"/>
|
||||
<where>
|
||||
<if test="priceSetId != null">AND psu.price_set_id = #{priceSetId}</if>
|
||||
<if test="userId != null">AND psu.user_id = #{userId}</if>
|
||||
<if test="userName != null and userName != ''">AND psu.user_name = #{userName}</if>
|
||||
</where>
|
||||
order by psu.psu_id asc
|
||||
</select>
|
||||
|
||||
<select id="countBySetAndUser" resultType="int">
|
||||
select count(1) from prc_price_set_user
|
||||
where price_set_id = #{priceSetId} and user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcPriceSetUser" parameterType="PrcPriceSetUser" useGeneratedKeys="true" keyProperty="psuId">
|
||||
insert into prc_price_set_user (price_set_id, user_id, user_name, created_by, create_time)
|
||||
values (#{priceSetId}, #{userId}, #{userName}, #{createBy}, sysdate())
|
||||
</insert>
|
||||
|
||||
<delete id="deletePrcPriceSetUserByIds" parameterType="Long">
|
||||
delete from prc_price_set_user where psu_id in
|
||||
<foreach collection="array" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByPriceSetId" parameterType="Long">
|
||||
delete from prc_price_set_user where price_set_id = #{priceSetId}
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user