|
|
@@ -779,6 +779,66 @@ public class FsUserCourseServiceImpl implements IFsUserCourseService
|
|
|
return courseList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void processQwSopPhoneRedPacketMaterialTimer(Integer companyServerNum) {
|
|
|
+ QwCompany qwCompany= new QwCompany();
|
|
|
+ if (companyServerNum!=0){
|
|
|
+ qwCompany.setCompanyServerNum(companyServerNum);
|
|
|
+ }
|
|
|
+ // 获取所有企业微信配置
|
|
|
+ List<QwCompany> companies = iQwCompanyService.selectQwCompanyList(qwCompany);
|
|
|
+
|
|
|
+ // 遍历每个企业微信配置
|
|
|
+ for (QwCompany company : companies) {
|
|
|
+ String corpId = company.getCorpId();
|
|
|
+ if (corpId == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 遍历每个课程,上传图片到对应企业的素材库
|
|
|
+ try {
|
|
|
+ uploadPhoneRedPacketImage(corpId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("处理课程图片失败: corpId={}, error={}",
|
|
|
+ corpId, e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传课程图片到企业微信并缓存
|
|
|
+ *
|
|
|
+ * @param corpId 企业ID
|
|
|
+ * @throws Exception 上传过程中的异常
|
|
|
+ */
|
|
|
+ public void uploadPhoneRedPacketImage(String corpId) throws Exception {
|
|
|
+ File imageFile = null;
|
|
|
+ try {
|
|
|
+ String json = configService.selectConfigByKey("phoneRedPacket.config");
|
|
|
+ Map<String, Object> luckyBagConfig = JSON.parseObject(json, Map.class);
|
|
|
+ Object miniprogramPicUrl = luckyBagConfig.get("miniprogramPicUrl");
|
|
|
+
|
|
|
+ // 将图片URL转为本地临时文件
|
|
|
+ imageFile = urlToFile(String.valueOf(miniprogramPicUrl));
|
|
|
+ // 调用企业微信API上传图片
|
|
|
+ QwUploadResult result = qwApiService.upload(imageFile, "image", corpId);
|
|
|
+
|
|
|
+ if (result.getErrCode() == 0) {
|
|
|
+ // 上传成功,缓存mediaId
|
|
|
+ String cacheKey = String.format("phoneRedPacket:%s", corpId);
|
|
|
+ redisCache.setCacheObject(cacheKey, result.getMediaId());
|
|
|
+ } else {
|
|
|
+ log.error("上传图片失败: errMsg={}, corpId={}",
|
|
|
+ result.getErrMsg(), corpId);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ // 清理临时文件
|
|
|
+ if (imageFile != null && imageFile.exists()) {
|
|
|
+ imageFile.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private Graphics2D initializeGraphics(BufferedImage combined) {
|
|
|
Graphics2D graphics = combined.createGraphics();
|