feat:我的食堂权限

This commit is contained in:
dzc committed 2026-07-06 18:00:11 +08:00
1 parent 245efd3936
commit bf93bb740d
15 files changed
+307 -14

No files matched your search

@@ -0,0 +1,16 @@
package com.bsd.pjcloud.thirdparty.dto.jg;
import lombok.Data;
import java.util.List;
@Data
public class JgPusDto {
private String title;
private String subtitle;
private List<Long> userIds;
}
+6
View File
@@ -17,6 +17,12 @@
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-encrypt-api</artifactId>
</dependency>
<!-- 极光sdk -->
<dependency>
<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk</artifactId>
<version>5.3.1</version>
</dependency>
<!-- 支付宝SDK -->
<dependency>
<groupId>com.alipay.sdk</groupId>
@@ -6,6 +6,7 @@ import com.bsd.pjcloud.common.swagger.annotation.EnableOpenApi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* @author archetype auto
@@ -16,6 +17,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnablePjcloudFeignClients
@EnableDiscoveryClient
@EnablePjcloudResourceServer
@EnableScheduling
@SpringBootApplication
public class ThirdPartyApp {
public static void main(String[] args) {
@@ -0,0 +1,41 @@
package com.bsd.pjcloud.thirdparty.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "jg")
@Data
public class JgConfig {
private JgPush jgPush;
@Data
public static class JgPush {
/**
* 极光推送key
*/
private String appKey;
/**
* 极光推送secret
*/
private String masterSecret;
/**
* 通知默认大图标
*/
private String largeIcon;
/**
* 通知默认小图标
*/
private String smallIconUri;
}
}
@@ -0,0 +1,34 @@
package com.bsd.pjcloud.thirdparty.config.initconfig;
import cn.jiguang.sdk.api.PushApi;
import com.bsd.pjcloud.thirdparty.config.AppPlusPayConfig;
import com.bsd.pjcloud.thirdparty.config.JgConfig;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import feign.Logger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Slf4j
@Configuration
public class JgConfiguration {
private final JgConfig jgConfig;
public JgConfiguration(JgConfig jgConfig) {
this.jgConfig = jgConfig;
}
@Bean
public PushApi initJgPush() {
JgConfig.JgPush jgPush = this.jgConfig.getJgPush();
return new PushApi.Builder()
.setLoggerLevel(Logger.Level.FULL)
.setAppKey(jgPush.getAppKey())
.setMasterSecret(jgPush.getMasterSecret())
.build();
}
}
@@ -0,0 +1,50 @@
package com.bsd.pjcloud.thirdparty.job;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.thirdparty.dto.jg.JgPusDto;
import com.bsd.pjcloud.thirdparty.service.ThirdJgPushService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Slf4j
@RequiredArgsConstructor
public class ThirdAppJgPushJob {
private final ThirdJgPushService thirdJgPushService;
private final RemoteUserService remoteUserService;
private final List<Long> testUserIdList = List.of(2029755089492066305L, 2034824566572941314L);
// 早饭提醒(每天早上6点7点)
@Scheduled(cron = "0 0 6,7 * * ?")
public void breakfastReminder() {
pushToAllUsers("早餐提醒", "早餐时间就要到了,请尽快预约哦!!");
}
// 午饭提醒(每天中午10点11点)
@Scheduled(cron = "0 0 10,11 * * ?")
public void lunchReminder() {
pushToAllUsers("午餐提醒", "午餐间就要到了,请尽快预约哦!!");
}
// 晚餐提醒(每天下午5点6点)
@Scheduled(cron = "0 0 17,18 * * ?")
public void dinnerReminder() {
pushToAllUsers("晚餐提醒", "晚餐时间就要到了,请尽快预约哦!!");
}
private void pushToAllUsers(String title, String subtitle) {
JgPusDto jgPusDto = new JgPusDto();
jgPusDto.setTitle(title);
jgPusDto.setSubtitle(subtitle);
jgPusDto.setUserIds(testUserIdList);
thirdJgPushService.push(jgPusDto);
}
}
@@ -0,0 +1,12 @@
package com.bsd.pjcloud.thirdparty.service;
import com.bsd.pjcloud.thirdparty.dto.jg.JgPusDto;
/**
* 极光推送
*/
public interface ThirdJgPushService {
void push(JgPusDto jgPusDto);
}
@@ -0,0 +1,73 @@
package com.bsd.pjcloud.thirdparty.service.impl.jg;
import cn.jiguang.sdk.api.PushApi;
import cn.jiguang.sdk.bean.push.PushSendParam;
import cn.jiguang.sdk.bean.push.PushSendResult;
import cn.jiguang.sdk.bean.push.audience.Audience;
import cn.jiguang.sdk.bean.push.message.notification.NotificationMessage;
import cn.jiguang.sdk.constants.ApiConstants;
import com.bsd.pjcloud.thirdparty.config.JgConfig;
import com.bsd.pjcloud.thirdparty.dto.jg.JgPusDto;
import com.bsd.pjcloud.thirdparty.service.ThirdJgPushService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.HashMap;
import java.util.Map;
/**
* 极光推送
*/
@Service
@Validated
@Slf4j
@RequiredArgsConstructor
public class ThirdThirdJgPushServiceImpl implements ThirdJgPushService {
private final String TAG = "极光推送";
private final PushApi pushApi;
private final JgConfig jgConfig;
@Override
public void push(JgPusDto jgPusDto) {
PushSendParam param = new PushSendParam();
JgConfig.JgPush jgPush = jgConfig.getJgPush();
// start 通知内容 android start
NotificationMessage.Android android = new NotificationMessage.Android();
android.setAlert(jgPusDto.getTitle());
android.setTitle(jgPusDto.getSubtitle());
android.setLargeIcon(jgPush.getLargeIcon());
android.setSmallIcon(jgPush.getSmallIconUri());
// end 通知内容 android end
// start 通知内容 ios start
NotificationMessage.IOS iOS = new NotificationMessage.IOS();
Map<String, String> iOSAlert = new HashMap<>();
iOSAlert.put("title", jgPusDto.getTitle());
iOSAlert.put("subtitle", jgPusDto.getSubtitle());
// 通知级别
iOSAlert.put("interruption-level", "active");
iOS.setAlert(iOSAlert);
// end 通知内容 ios end
NotificationMessage notificationMessage = new NotificationMessage();
notificationMessage.setAlert(jgPusDto.getTitle());
notificationMessage.setAndroid(android);
notificationMessage.setIos(iOS);
Audience audience = new Audience();
audience.setAliasList(jgPusDto.getUserIds().stream().map(String::valueOf).toList());
param.setNotification(notificationMessage);
param.setAudience(audience);
param.setPlatform(ApiConstants.Platform.ALL);
PushSendResult result = pushApi.send(param);
log.info("|{}|极光推送返回,result:|{}|", TAG, result);
}
}
@@ -212,4 +212,11 @@ aliyun:
accessKeySecret: p4RIWlleFMH60cjuoeKl7YIBLS18v8
signName: 浙江资安信信息科技
template-codes:
verification: SMS_500945185
verification: SMS_500945185
jg:
jg-push:
app-key: 3877351c5811a35093f04476
master-secret: 2a253b41ac1eaa96558c56ef
large-icon: https://public-com.zianxin.com/logo/60x60.png
small-icon-uri: https://public-com.zianxin.com/logo/320x320.png
@@ -10,4 +10,8 @@ public class WalletMchDeptViewDto extends WalletMchDeptViewEntity {
private List<Long> mchIdList;
private List<Long> deptIdList;
private List<String> mchTypeList;
}
@@ -183,19 +183,12 @@ public class MchManageController {
public R<Page<MchManageVo>> appPageJoin(@ParameterObject Page page, @ParameterObject MchManageDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setVisibleMobile(YesNoEnum.YES.getCode());
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getDeptId())) {
UserInfo userInfo = remoteUserService.getInnerByUserId(user.getId()).getData();
MchManageVo targetMch = mchManageService.getViewsCanteenMchByDeptId(userInfo.getSysUser().getDeptId());
if (ObjectUtil.isNotEmpty(targetMch)) {
dto.setIds(List.of(targetMch.getId()));
} else {
List<SysDept> deptIdList = remoteDeptService.getDescendantList(userInfo.getSysUser().getDeptId()).getData();
if (ObjectUtil.isNotEmpty(deptIdList)) {
dto.setDeptIds(deptIdList.stream().map(SysDept::getDeptId).toList());
}
}
} else {
R.ok(new Page<>());
List<Long> selfMchIdList = mchManageService.getSelfCanteenMchIdList(user.getId(), List.of(MerchantTypeEnum.CANTEEN));
if (ObjectUtil.isNotEmpty(selfMchIdList)) {
List<Long> ids = dto.getIds();
if (ObjectUtil.isEmpty(ids)) ids = new ArrayList<>();
ids.addAll(selfMchIdList);
dto.setIds(ids);
}
return R.ok(mchManageService.pageJoin(page, dto));
}
@@ -16,4 +16,5 @@ public interface MchDeptViewMapper {
WalletMchDeptViewVo selectByDeptId(@Param("deptId") Long deptId, @Param("mchTypeList") List<String> mchTypeList);
List<Long> selectMchIdList(@Param("dto") WalletMchDeptViewDto dto);
}
@@ -62,6 +62,11 @@ public interface MchManageService extends IService<MchManageEntity> {
*/
String lbLogin(PjcloudUser user);
/**
* 获取用户的食堂商户列表
*/
List<Long> getSelfCanteenMchIdList(Long userId,List<MerchantTypeEnum> mchTypeList);
/**
* 判断用户是否能查看到所有食堂
*/
@@ -33,6 +33,7 @@ import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchSupType;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
import com.bsd.pjcloud.wallet.api.dto.mch.MchPaySettingDto;
import com.bsd.pjcloud.wallet.api.dto.mch.WalletMchDeptViewDto;
import com.bsd.pjcloud.wallet.api.entity.mch.MchManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
@@ -469,6 +470,32 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
return vo.getData();
}
@Override
public List<Long> getSelfCanteenMchIdList(Long userId, List<MerchantTypeEnum> mchTypeList) {
List<Long> mchIds = new ArrayList<>();
List<Long> deptIdList = new ArrayList<>();
UserInfo userInfo = remoteUserService.getInnerByUserId(userId).getData();
if (ObjectUtil.isEmpty(userInfo)) {
return mchIds;
}
deptIdList.add(userInfo.getSysUser().getDeptId());
// 查询下级部门
List<SysDept> descendantList = remoteDeptService.getDescendantList(userInfo.getSysUser().getDeptId()).getData();
if (ObjectUtil.isNotEmpty(descendantList)) {
List<Long> descendantIds = descendantList.stream().map(SysDept::getDeptId).toList();
if (ObjectUtil.isNotEmpty(descendantIds)) deptIdList.addAll(descendantIds);
}
WalletMchDeptViewDto dto = new WalletMchDeptViewDto();
dto.setDeptIdList(deptIdList);
dto.setMchTypeList(mchTypeList.stream().map(MerchantTypeEnum::getType).toList());
List<Long> selfMchIdList = mchDeptViewMapper.selectMchIdList(dto);
if (ObjectUtil.isEmpty(selfMchIdList)) {
return mchIds;
}
return selfMchIdList;
}
/**
* 判断用户是否能查看到所有食堂
*/
@@ -27,6 +27,18 @@
#{v}
</foreach>
</if>
<if test="dto.deptIdList != null and dto.deptIdList.size() != 0">
and a.deptId IN
<foreach collection="dto.deptIdList" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.mchTypeList != null and dto.mchTypeList.size() != 0">
and a.mchType IN
<foreach collection="dto.mchTypeList" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.mchName != null">
and a.mchName like concat('%',#{dto.mchName},'%')
</if>
@@ -69,4 +81,14 @@
order by a.level asc
limit 1
</select>
<select id="selectMchIdList" resultType="java.lang.Long">
select a.mchId
from v_all_mch_dept_tree a
<where>
<include refid="whereA"/>
</where>
group by a.mchId
order by a.mchId
</select>
</mapper>