Commit 451e2f26 by zhengxj

finish 数据权限限制 on 20190319 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@18697 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 4af92fd9
...@@ -41,6 +41,14 @@ public class ShopBizAmount implements Serializable{ ...@@ -41,6 +41,14 @@ public class ShopBizAmount implements Serializable{
private static final long serialVersionUID = -4459816057299745181L; private static final long serialVersionUID = -4459816057299745181L;
private String shopName; private String shopName;
private Long bizAmount; private Long bizAmount;
private Long shopId;
public Long getShopId() {
return shopId;
}
public void setShopId(Long shopId) {
this.shopId = shopId;
}
public String getShopName() { public String getShopName() {
return shopName; return shopName;
} }
......
...@@ -806,17 +806,24 @@ public class OrderServiceImpl implements IOrderService { ...@@ -806,17 +806,24 @@ public class OrderServiceImpl implements IOrderService {
List<Long> bizAmount = new ArrayList<>(); List<Long> bizAmount = new ArrayList<>();
SysUser sysUser = sysUserDao.selectByPrimaryKey(userId); SysUser sysUser = sysUserDao.selectByPrimaryKey(userId);
Criteria criteria = orderExample.createCriteria(); Criteria criteria = orderExample.createCriteria();
criteria.andActiveStatusEqualTo((byte) 8);
int userType = sysUser.getUserType();
// 当前用户:服务商或者门店 // 当前用户:服务商或者门店
if (userType == 1) { // 数据权限
// SysMerchantExample merExample = new SysMerchantExample(); List<Integer> dataRight = new ArrayList<>();
// merExample.createCriteria().andUserIdEqualTo(userId); if (userId == BizConstants.USER_TYPE_AMIN) {
// SysMerchant merchant = // 超级管理员
// sysMerchantDao.selectByExample(merExample).get(0); dataRight = orderChannelDao.getDataRight(null, null);
criteria.andMerchantIdEqualTo(userId); } else {
params.put("merchantId", userId); dataRight = orderChannelDao.getDataRight(userId, null);
}
// 用户数据权限先无数据
if (dataRight == null || dataRight.size() == 0) {
bizAmountResp.setBizAmount(null);
bizAmountResp.setType("m");
bizAmountResp.setShopBizAmount(null);
}
criteria.andShopIdIn(dataRight).andActiveStatusNotEqualTo((byte)9).andCanceledEqualTo((byte)1);
params.put("ids", dataRight);
// 按照小时计算 // 按照小时计算
if (startDate == null && endDate == null) { if (startDate == null && endDate == null) {
Date currentTime = DateUtil.getCurrentTime(); Date currentTime = DateUtil.getCurrentTime();
...@@ -897,7 +904,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -897,7 +904,7 @@ public class OrderServiceImpl implements IOrderService {
case "m": case "m":
bizAmountResp.setType("m"); bizAmountResp.setType("m");
currentDay = DateUtil.getCurrentDate().getDate(); currentDay = DateUtil.getCurrentDate().getDate();
// 本周第一天 日期 //本月第一天 日期
Date firstDayOfMonth = DateUtil.getPastMonthFirstDay(0); Date firstDayOfMonth = DateUtil.getPastMonthFirstDay(0);
// 统计本月每天订单量 // 统计本月每天订单量
for (int i = firstDayOfMonth.getDate(); i < currentDay; i++) { for (int i = firstDayOfMonth.getDate(); i < currentDay; i++) {
...@@ -952,7 +959,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -952,7 +959,7 @@ public class OrderServiceImpl implements IOrderService {
endDate.setSeconds(59); endDate.setSeconds(59);
} else { } else {
endDate = new Date(); endDate = new Date();
} }
criteria.andCreateTimeGreaterThanOrEqualTo(beginDate).andCreateTimeLessThanOrEqualTo(endDate); criteria.andCreateTimeGreaterThanOrEqualTo(beginDate).andCreateTimeLessThanOrEqualTo(endDate);
long businessAmount = orderDao.countByExample(orderExample); long businessAmount = orderDao.countByExample(orderExample);
bizAmount.add(businessAmount); bizAmount.add(businessAmount);
...@@ -972,8 +979,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -972,8 +979,7 @@ public class OrderServiceImpl implements IOrderService {
} else { } else {
// TODO 产品暂未明确传递时间跨度较大时如何处理业务量展示 // TODO 产品暂未明确传递时间跨度较大时如何处理业务量展示
params.put("beginTime", startDate); params.put("beginTime", startDate);
params.put("endTime", endDate); params.put("endTime", endDate);
}
} }
bizAmountResp.setBizAmount(bizAmount); bizAmountResp.setBizAmount(bizAmount);
......
...@@ -581,26 +581,26 @@ ...@@ -581,26 +581,26 @@
</where> </where>
</select> </select>
<select id="countByParams" parameterType="java.util.Map" <select id="countByParams" parameterType="java.util.Map" resultMap="OrderCountResultMap">
resultMap="OrderCountResultMap">
SELECT SELECT
sm.shop_name, sm.shop_name,so.shop_id,
count(1) AS biz_amount count(1) AS biz_amount
FROM FROM
sys_order so sys_order so
LEFT JOIN LEFT JOIN
sys_merchant sm ON so.shop_id = sm.id sys_merchant sm ON so.shop_id = sm.id
<where> <where>
so.active_status = 8 1=1 and shop_id in
and so.merchant_id = <foreach item="item" collection="ids" separator="," open="("
#{merchantId,jdbcType=INTEGER} close=")" index=""> #{item, jdbcType=INTEGER}
</foreach>
<if test="beginTime != null"> <if test="beginTime != null">
and so.create_time &gt;= #{beginTime} and so.create_time &gt;= #{beginTime}
</if> </if>
<if test="endTime != null"> <if test="endTime != null">
and so.create_time &lt;= #{endTime} and so.create_time &lt;= #{endTime}
</if> </if>
</where> </where>
GROUP BY shop_id GROUP BY shop_id
ORDER BY biz_amount DESC ORDER BY biz_amount DESC
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!