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{
private static final long serialVersionUID = -4459816057299745181L;
private String shopName;
private Long bizAmount;
private Long shopId;
public Long getShopId() {
return shopId;
}
public void setShopId(Long shopId) {
this.shopId = shopId;
}
public String getShopName() {
return shopName;
}
......
......@@ -806,17 +806,24 @@ public class OrderServiceImpl implements IOrderService {
List<Long> bizAmount = new ArrayList<>();
SysUser sysUser = sysUserDao.selectByPrimaryKey(userId);
Criteria criteria = orderExample.createCriteria();
criteria.andActiveStatusEqualTo((byte) 8);
int userType = sysUser.getUserType();
Criteria criteria = orderExample.createCriteria();
// 当前用户:服务商或者门店
if (userType == 1) {
// SysMerchantExample merExample = new SysMerchantExample();
// merExample.createCriteria().andUserIdEqualTo(userId);
// SysMerchant merchant =
// sysMerchantDao.selectByExample(merExample).get(0);
criteria.andMerchantIdEqualTo(userId);
params.put("merchantId", userId);
// 数据权限
List<Integer> dataRight = new ArrayList<>();
if (userId == BizConstants.USER_TYPE_AMIN) {
// 超级管理员
dataRight = orderChannelDao.getDataRight(null, null);
} else {
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) {
Date currentTime = DateUtil.getCurrentTime();
......@@ -897,7 +904,7 @@ public class OrderServiceImpl implements IOrderService {
case "m":
bizAmountResp.setType("m");
currentDay = DateUtil.getCurrentDate().getDate();
// 本周第一天 日期
//本月第一天 日期
Date firstDayOfMonth = DateUtil.getPastMonthFirstDay(0);
// 统计本月每天订单量
for (int i = firstDayOfMonth.getDate(); i < currentDay; i++) {
......@@ -952,7 +959,7 @@ public class OrderServiceImpl implements IOrderService {
endDate.setSeconds(59);
} else {
endDate = new Date();
}
}
criteria.andCreateTimeGreaterThanOrEqualTo(beginDate).andCreateTimeLessThanOrEqualTo(endDate);
long businessAmount = orderDao.countByExample(orderExample);
bizAmount.add(businessAmount);
......@@ -972,8 +979,7 @@ public class OrderServiceImpl implements IOrderService {
} else {
// TODO 产品暂未明确传递时间跨度较大时如何处理业务量展示
params.put("beginTime", startDate);
params.put("endTime", endDate);
}
params.put("endTime", endDate);
}
bizAmountResp.setBizAmount(bizAmount);
......
......@@ -581,26 +581,26 @@
</where>
</select>
<select id="countByParams" parameterType="java.util.Map"
resultMap="OrderCountResultMap">
<select id="countByParams" parameterType="java.util.Map" resultMap="OrderCountResultMap">
SELECT
sm.shop_name,
sm.shop_name,so.shop_id,
count(1) AS biz_amount
FROM
sys_order so
LEFT JOIN
sys_merchant sm ON so.shop_id = sm.id
<where>
so.active_status = 8
and so.merchant_id =
#{merchantId,jdbcType=INTEGER}
1=1 and shop_id in
<foreach item="item" collection="ids" separator="," open="("
close=")" index=""> #{item, jdbcType=INTEGER}
</foreach>
<if test="beginTime != null">
and so.create_time &gt;= #{beginTime}
</if>
<if test="endTime != null">
and so.create_time &lt;= #{endTime}
</if>
</where>
GROUP BY shop_id
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!