Merge branch 'master' of http://192.168.1.26:3000/dianliang/dl_admin
This commit is contained in:
commit
6e8ff5b9c6
@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
@ -49,7 +50,7 @@ public class PayApi {
|
||||
*/
|
||||
@ApiOperation(value = "统一下单-统一接口", notes = "统一下单-统一接口")
|
||||
@GetMapping("/prepayment")
|
||||
public PrepayWithRequestPaymentResponse transactions(String type, String orderNo) throws SignatureException, NoSuchAlgorithmException, InvalidKeyException, IOException {
|
||||
public PrepayWithRequestPaymentResponse transactions( String orderNo) {
|
||||
LambdaQueryWrapper<MemberOrder> queryWrapper =new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MemberOrder::getOrderNo,orderNo).last("limit 1");
|
||||
MemberOrder memberOrder = memberOrderService.getOne(queryWrapper);
|
||||
@ -89,6 +90,7 @@ public class PayApi {
|
||||
|
||||
@ApiOperation(value = "支付回调", notes = "支付回调")
|
||||
@PostMapping("/payNotify")
|
||||
@Anonymous
|
||||
public Map<String, String> payNotify(@RequestBody JSONObject jsonObject) throws GeneralSecurityException, IOException {
|
||||
String key = wechatPayConfig.getApiV3Key();
|
||||
String json = jsonObject.toString();
|
||||
|
||||
@ -33,9 +33,9 @@ public class WxApi {
|
||||
|
||||
@GetMapping("/getCodeUrl")
|
||||
@Anonymous
|
||||
public Map<String, String> getCodeUrl(String userType) {
|
||||
public Map<String, String> getCodeUrl(String userType,String url) {
|
||||
Map<String, String> res = new HashMap<>();
|
||||
res.put("codeUrl", weChatUtils.getCodeUrl("https://www.nuoyunr.com/#/pages/mine/member/member-card", userType));
|
||||
res.put("codeUrl", weChatUtils.getCodeUrl("https://www.ddtg.site/#/"+url, userType));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -228,8 +228,7 @@ public class BusiNoticeController extends BaseController
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
|
||||
{
|
||||
Page<BusiNotice> page = new Page<>(pageNum, pageSize);
|
||||
IPage<BusiNoticeVo> list = busiNoticeService.appFootprintList(query,page);
|
||||
List<BusiNoticeVo> list = busiNoticeService.appFootprintList(query);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
||||
@ -52,6 +52,10 @@ public class BusiNotice extends DlBaseEntity
|
||||
private String province;
|
||||
/** 城市 */
|
||||
private String city;
|
||||
/**
|
||||
* 是否急招0否1是
|
||||
*/
|
||||
private String isUrgent;
|
||||
//是否平台结算
|
||||
private Integer isPlatformFree;
|
||||
/** 稿费下限 */
|
||||
|
||||
@ -43,11 +43,10 @@ public class BusiNoticeSign extends DlBaseEntity
|
||||
private String nickname;
|
||||
|
||||
/** 报名用户头像 */
|
||||
@Excel(name = "报名用户头像")
|
||||
@Excel(name = "报名用户头像", cellType = Excel.ColumnType.IMAGE)
|
||||
private String avatar;
|
||||
|
||||
/** 是否超级报名 */
|
||||
@Excel(name = "是否超级报名")
|
||||
|
||||
private String isSuper;
|
||||
|
||||
/** 联系方式 */
|
||||
@ -59,18 +58,18 @@ public class BusiNoticeSign extends DlBaseEntity
|
||||
private String addrId;
|
||||
|
||||
/** 通告合作状态 */
|
||||
@Excel(name = "通告合作状态")
|
||||
|
||||
private String status;
|
||||
|
||||
/** 稿件内容 */
|
||||
private String content;
|
||||
|
||||
/** 稿件图片 */
|
||||
@Excel(name = "稿件图片")
|
||||
|
||||
private String images;
|
||||
|
||||
/** 已发布的文章链接 */
|
||||
@Excel(name = "已发布的文章链接")
|
||||
|
||||
private String articleRef;
|
||||
/**
|
||||
* 动态表单json
|
||||
|
||||
@ -49,7 +49,7 @@ public interface BusiNoticeMapper extends BaseMapper<BusiNotice> {
|
||||
* @param query 查询条件
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
**/
|
||||
IPage<BusiNoticeVo> appFootprintList(@Param("entity") AppNoticeQuery query, Page<BusiNotice> page);
|
||||
List<BusiNoticeVo> appFootprintList(@Param("entity") AppNoticeQuery query, @Param("num") Integer num);
|
||||
|
||||
/**
|
||||
* 小程序端查询订阅通告列表
|
||||
|
||||
@ -37,5 +37,11 @@ public class AppNoticeQuery {
|
||||
//'进行中', '已关闭'
|
||||
private String status;
|
||||
private String noticeId;
|
||||
//是否急招
|
||||
private String isUrgent;
|
||||
//是否平台结算
|
||||
private String isPlatformFree;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ public interface IBusiNoticeService extends IService<BusiNotice>
|
||||
* @param query 查询条件
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
**/
|
||||
IPage<BusiNoticeVo> appFootprintList(AppNoticeQuery query, Page<BusiNotice> page);
|
||||
List<BusiNoticeVo> appFootprintList(AppNoticeQuery query);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -33,10 +33,10 @@ import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.busi.query.BusiNoticeQuery;
|
||||
import com.ruoyi.constant.DictConstants;
|
||||
import com.ruoyi.member.domain.MemberApply;
|
||||
import com.ruoyi.member.domain.MemberPoints;
|
||||
import com.ruoyi.member.domain.MemberUser;
|
||||
import com.ruoyi.member.service.IMemberApplyService;
|
||||
import com.ruoyi.member.service.IMemberCardService;
|
||||
import com.ruoyi.member.service.IMemberUserService;
|
||||
import com.ruoyi.member.service.*;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysDictDataService;
|
||||
import com.ruoyi.system.service.ISysDictTypeService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
@ -83,6 +83,12 @@ public class BusiNoticeServiceImpl extends ServiceImpl<BusiNoticeMapper,BusiNoti
|
||||
@Resource
|
||||
private IMemberCardService cardService;
|
||||
|
||||
@Autowired
|
||||
private IMemberCouponService memberCouponService;
|
||||
@Autowired
|
||||
private IMemberPointsService memberPointsService;
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Override
|
||||
public IPage<BusiNoticeVo> queryListPage(BusiNoticeQuery query, Page<BusiNotice> page) {
|
||||
@ -125,6 +131,16 @@ public class BusiNoticeServiceImpl extends ServiceImpl<BusiNoticeMapper,BusiNoti
|
||||
//删除结尾的最后一个逗号
|
||||
data.setSimilarityIds(data.getSimilarityIds().substring(0, data.getSimilarityIds().length() - 1));
|
||||
}
|
||||
if(data.getApprovalStatus().equals("1")){
|
||||
//如果审核通过
|
||||
//从配置表中获取积分
|
||||
MemberPoints memberPoints =new MemberPoints();
|
||||
memberPoints.setUserId(SecurityUtils.getUserId());
|
||||
memberPoints.setType("1");
|
||||
memberPoints.setTitle("用户签到,送积分");
|
||||
memberPoints.setFromCode("fbgg");
|
||||
memberPointsService.savePoints(memberPoints);
|
||||
}
|
||||
this.save(data);
|
||||
}
|
||||
//保存表单数据
|
||||
@ -216,7 +232,12 @@ public class BusiNoticeServiceImpl extends ServiceImpl<BusiNoticeMapper,BusiNoti
|
||||
}else {
|
||||
this.saveVo(data);
|
||||
}
|
||||
cardService.dealMemberRights(userId,null,"add_notice",1);
|
||||
try {
|
||||
cardService.dealMemberRights(userId,null,"add_notice",1);
|
||||
}catch (Exception e){
|
||||
memberCouponService.saveCoupon( userId, "2", data.getId(), 1);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(data.getCustomForm())) {
|
||||
cardService.dealMemberRights(userId,null,"report_info_collect",1);
|
||||
}
|
||||
@ -251,6 +272,7 @@ public class BusiNoticeServiceImpl extends ServiceImpl<BusiNoticeMapper,BusiNoti
|
||||
* @param publishTakeDown 1发布0下架
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void publishTakeDown(String noticeId, String publishTakeDown) {
|
||||
BusiNotice data = this.getById(noticeId);
|
||||
if (publishTakeDown.equals("1")){
|
||||
@ -276,6 +298,13 @@ public class BusiNoticeServiceImpl extends ServiceImpl<BusiNoticeMapper,BusiNoti
|
||||
//删除结尾的最后一个逗号
|
||||
data.setSimilarityIds(data.getSimilarityIds().substring(0, data.getSimilarityIds().length() - 1));
|
||||
}
|
||||
//如果审核通过
|
||||
MemberPoints memberPoints =new MemberPoints();
|
||||
memberPoints.setUserId(SecurityUtils.getUserId());
|
||||
memberPoints.setType("1");
|
||||
memberPoints.setTitle("用户签到,送积分");
|
||||
memberPoints.setFromCode("fbgg");
|
||||
memberPointsService.savePoints(memberPoints);
|
||||
|
||||
}else {
|
||||
//如果是关闭 关闭状态
|
||||
@ -346,16 +375,17 @@ public class BusiNoticeServiceImpl extends ServiceImpl<BusiNoticeMapper,BusiNoti
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
**/
|
||||
@Override
|
||||
public IPage<BusiNoticeVo> appFootprintList(AppNoticeQuery query, Page<BusiNotice> page) {
|
||||
public List<BusiNoticeVo> appFootprintList(AppNoticeQuery query) {
|
||||
query.setUserId(SecurityUtils.getUserId());
|
||||
IPage<BusiNoticeVo> pageList = busiNoticeMapper.appFootprintList(query,page);
|
||||
List<String> idList = pageList.getRecords().stream().map(BusiNotice::getId).collect(Collectors.toList());
|
||||
Integer num = cardService.getCardRightsValue(SecurityUtils.getUserId(), "02", "history");
|
||||
List<BusiNoticeVo> pageList = busiNoticeMapper.appFootprintList(query,num);
|
||||
List<String> idList = pageList.stream().map(BusiNotice::getId).collect(Collectors.toList());
|
||||
if(!idList.isEmpty()){
|
||||
//查博主类型字典
|
||||
List<BaseCategory> categoryList = baseCategoryService.listByParentCode(DictConstants.BLOGGER_TYPES_KEY,null);
|
||||
//转map
|
||||
Map<String,String> categoryMap = categoryList.stream().collect(Collectors.toMap(BaseCategory::getCode,BaseCategory::getTitle));
|
||||
pageList.getRecords().forEach(item->{
|
||||
pageList.forEach(item->{
|
||||
//报名数量、浏览量、相关字典转换
|
||||
if(null==item.getViewNum()){
|
||||
item.setViewNum(0);
|
||||
|
||||
@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.busi.mapper.BusiNoticeSignMapper;
|
||||
import com.ruoyi.busi.domain.BusiNoticeSign;
|
||||
import com.ruoyi.busi.service.IBusiNoticeSignService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@ -49,6 +50,7 @@ public class BusiNoticeSignServiceImpl extends ServiceImpl<BusiNoticeSignMapper,
|
||||
* @param appNoticeSign 报名实体
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void userSign(AppNoticeSign appNoticeSign) throws Exception {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
//当前用户是否已报名该通告
|
||||
@ -63,7 +65,7 @@ public class BusiNoticeSignServiceImpl extends ServiceImpl<BusiNoticeSignMapper,
|
||||
busiNoticeSign.setUserId(loginUser.getUserId());
|
||||
busiNoticeSign.setNickname(sysUser.getNickName());
|
||||
busiNoticeSign.setAvatar(sysUser.getAvatar());
|
||||
busiNoticeSign.setStatus("0");
|
||||
busiNoticeSign.setStatus("01");
|
||||
busiNoticeSign.setFormData(JSONArray.toJSONString(appNoticeSign.getCustomForm()));
|
||||
busiNoticeSign.setCardId(cardInfo.getString("id"));
|
||||
busiNoticeSign.setPrice(cardInfo.getBigDecimal("price"));
|
||||
|
||||
@ -77,12 +77,17 @@ public class MemberBlacklistController extends BaseController {
|
||||
|
||||
/**
|
||||
* 新增黑名单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('member:blacklist:add')")
|
||||
*
|
||||
* @param memberBlacklist {@link MemberBlacklist}
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
* @author PQZ
|
||||
* @date 15:05 2025/4/23
|
||||
**/
|
||||
@Log(title = "黑名单", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@PostMapping("/saveBlack")
|
||||
public AjaxResult add(@RequestBody MemberBlacklist memberBlacklist) {
|
||||
return toAjax(memberBlacklistService.save(memberBlacklist));
|
||||
memberBlacklistService.save(memberBlacklist);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -47,6 +48,19 @@ public class MemberCouponController extends BaseController {
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前登录用户通告券
|
||||
* @author PQZ
|
||||
* @date 18:37 2025/4/24
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
**/
|
||||
@GetMapping("/getMemberCoupon")
|
||||
public AjaxResult getMemberCoupon() {
|
||||
//获取当前登录用户id
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return success(memberCouponService.getCoupon(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出用户通告券变动记录列表
|
||||
*/
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.member.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
@ -97,8 +98,10 @@ public class MemberOrderController extends BaseController {
|
||||
@Log(title = "订单", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/uniSaveOrder")
|
||||
public AjaxResult add(@RequestBody MemberOrder memberOrder) {
|
||||
memberOrderService.saveOrder(memberOrder);
|
||||
return success();
|
||||
String orderNo = memberOrderService.saveOrder(memberOrder);
|
||||
JSONObject res =new JSONObject();
|
||||
res.put("orderNo",orderNo);
|
||||
return success(res);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -60,7 +60,7 @@ public interface IMemberCardService extends IService<MemberCard> {
|
||||
* @author PQZ
|
||||
* @date 17:27 2025/3/31
|
||||
**/
|
||||
Integer getCardReport(Long userId, String userType);
|
||||
Integer getCardRightsValue(Long userId, String userType,String rightsCode);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -29,7 +29,7 @@ public interface IMemberCouponService extends IService<MemberCoupon> {
|
||||
* @author PQZ
|
||||
* @date 15:19 2025/3/28
|
||||
**/
|
||||
void saveCoupon(Long userId, String type, String noticeId, Integer couponNum);
|
||||
void saveCoupon(Long userId, String type, String noticeId, Integer couponNum) throws Exception;
|
||||
|
||||
/**
|
||||
* 查询剩余通告券
|
||||
@ -41,4 +41,5 @@ public interface IMemberCouponService extends IService<MemberCoupon> {
|
||||
**/
|
||||
Integer getCoupon(Long userId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -40,5 +40,5 @@ public interface IMemberOrderService extends IService<MemberOrder> {
|
||||
* @date 14:02 2025/4/8
|
||||
* @param memberOrder {@link MemberOrder}
|
||||
**/
|
||||
void saveOrder(MemberOrder memberOrder);
|
||||
String saveOrder(MemberOrder memberOrder);
|
||||
}
|
||||
|
||||
@ -26,13 +26,14 @@ public interface IMemberRightsService extends IService<MemberRights> {
|
||||
void dealRights(Long userId, String userType, List<CardRightsVO> rights);
|
||||
|
||||
/**
|
||||
* 根据卡id,用户id,权益编码查询权益值
|
||||
* @param userId 用户id
|
||||
* @param carId 卡id
|
||||
* @return java.lang.Integer
|
||||
* @author PQZ
|
||||
* @date 17:15 2025/3/31
|
||||
**/
|
||||
Integer getReport(Long userId, String carId);
|
||||
Integer getMemberRightsValue(Long userId, String carId,String rightsCode);
|
||||
|
||||
/**
|
||||
* 根据用户id,卡id,权益编码,更新剩余值
|
||||
|
||||
@ -67,7 +67,7 @@ public interface IMemberUserService extends IService<MemberUser> {
|
||||
* @author vinjor-M
|
||||
* @date 15:55 2025/3/26
|
||||
**/
|
||||
String wxLogin(String openid, String decryptResult);
|
||||
String wxLogin(String openid, String decryptResult,String unionId);
|
||||
|
||||
/**
|
||||
* uniApp保存会员信息
|
||||
|
||||
@ -225,13 +225,13 @@ public class MemberCardServiceImpl extends ServiceImpl<MemberCardMapper, MemberC
|
||||
* @date 17:27 2025/3/31
|
||||
**/
|
||||
@Override
|
||||
public Integer getCardReport(Long userId, String userType) {
|
||||
public Integer getCardRightsValue(Long userId, String userType,String rightsCode) {
|
||||
//查询当前用户在当前时间有无正在服役的会员卡
|
||||
List<MemberCard> memberCards = getMemberCards(userId, userType);
|
||||
if (memberCards.isEmpty()) {
|
||||
return 0;
|
||||
} else {
|
||||
return rightsService.getReport(memberCards.get(0).getUserId(), memberCards.get(0).getCardId());
|
||||
return rightsService.getMemberRightsValue(memberCards.get(0).getUserId(), memberCards.get(0).getCardId(),rightsCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import com.ruoyi.member.domain.MemberCoupon;
|
||||
import com.ruoyi.member.domain.MemberOrder;
|
||||
import com.ruoyi.member.mapper.MemberCouponMapper;
|
||||
import com.ruoyi.member.service.IMemberCouponService;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -16,7 +17,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户通告券变动记录Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author vinjor-m
|
||||
* @date 2025-03-17
|
||||
*/
|
||||
@ -35,8 +36,9 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper,Memb
|
||||
* @date 15:02 2025/3/28
|
||||
**/
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void dealMemberCoupon(MemberOrder order) {
|
||||
saveCoupon(order.getUserId(), "2",null,order.getGoodsNum());
|
||||
saveCoupon(order.getUserId(), "1",null,order.getGoodsNum());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,7 +52,13 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper,Memb
|
||||
* @date 15:19 2025/3/28
|
||||
**/
|
||||
@Override
|
||||
public void saveCoupon(Long userId, String type, String noticeId, Integer couponNum) {
|
||||
public void saveCoupon(Long userId, String type, String noticeId, Integer couponNum) throws Exception {
|
||||
if ("2".equals(type)){
|
||||
int initNum = getCoupon(userId);
|
||||
if (initNum == 0) {
|
||||
throw new Exception("暂无可用报名次数");
|
||||
}
|
||||
}
|
||||
//查询当前用户最新变动记录
|
||||
LambdaQueryWrapper<MemberCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper
|
||||
|
||||
@ -68,17 +68,19 @@ public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper, Membe
|
||||
LambdaQueryWrapper<MemberOrder> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(DlBaseEntity::getDelFlag, 0).eq(MemberOrder::getOrderNo, orderNo);
|
||||
MemberOrder memberOrder = getOne(lambdaQueryWrapper);
|
||||
/*2、处理不同类型订单*/
|
||||
if ("01".equals(memberOrder.getOrderType())) {
|
||||
cardService.dealMemberCard(memberOrder.getUserId(), memberOrder.getUserType(), memberOrder.getGoodsId(), memberOrder.getGoodsCycle(), memberOrder.getId());
|
||||
} else {
|
||||
couponService.dealMemberCoupon(memberOrder);
|
||||
if(memberOrder.getIsPay() != 1) {
|
||||
/*2、处理不同类型订单*/
|
||||
if ("01".equals(memberOrder.getOrderType())) {
|
||||
cardService.dealMemberCard(memberOrder.getUserId(), memberOrder.getUserType(), memberOrder.getGoodsId(), memberOrder.getGoodsCycle(), memberOrder.getId());
|
||||
} else {
|
||||
couponService.dealMemberCoupon(memberOrder);
|
||||
}
|
||||
/*3、处理订单表数据*/
|
||||
memberOrder.setPayTime(new Date());
|
||||
memberOrder.setIsPay(1);
|
||||
memberOrder.setPayWay("02");
|
||||
updateById(memberOrder);
|
||||
}
|
||||
/*3、处理订单表数据*/
|
||||
memberOrder.setPayTime(new Date());
|
||||
memberOrder.setIsPay(1);
|
||||
memberOrder.setPayWay("02");
|
||||
updateById(memberOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,7 +91,7 @@ public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper, Membe
|
||||
* @date 14:02 2025/4/8
|
||||
**/
|
||||
@Override
|
||||
public void saveOrder(MemberOrder memberOrder) {
|
||||
public String saveOrder(MemberOrder memberOrder) {
|
||||
//获取当前登录用户
|
||||
LoginUser securityUser = SecurityUtils.getLoginUser();
|
||||
memberOrder.setUserId(securityUser.getUserId());
|
||||
@ -97,7 +99,7 @@ public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper, Membe
|
||||
memberOrder.setOrderNo(generateOrderId());
|
||||
//保存订单数据
|
||||
save(memberOrder);
|
||||
|
||||
return memberOrder.getOrderNo();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.base.domain.BaseCategory;
|
||||
import com.ruoyi.base.service.IBaseCategoryService;
|
||||
import com.ruoyi.common.config.DlRightsConfig;
|
||||
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||
import com.ruoyi.member.domain.MemberPoints;
|
||||
@ -25,6 +27,8 @@ import java.util.List;
|
||||
public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, MemberPoints> implements IMemberPointsService {
|
||||
@Autowired
|
||||
private MemberPointsMapper memberPointsMapper;
|
||||
@Autowired
|
||||
private IBaseCategoryService categoryService;
|
||||
|
||||
|
||||
/**
|
||||
@ -50,6 +54,12 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
||||
**/
|
||||
@Override
|
||||
public void savePoints(MemberPoints memberPoints) {
|
||||
if(memberPoints.getFromCode() != null){
|
||||
List<BaseCategory> categoryList = categoryService.selectByCode(memberPoints.getFromCode());
|
||||
BaseCategory category = categoryList.get(0);
|
||||
memberPoints.setPoints(Integer.parseInt(category.getContent()));
|
||||
memberPoints.setTitle(category.getTitle());
|
||||
}
|
||||
//查询当前用户最近变动记录
|
||||
LambdaQueryWrapper<MemberPoints> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(DlBaseEntity::getDelFlag,0)
|
||||
@ -62,7 +72,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
|
||||
} else {
|
||||
//如果有记录则取最新记录中的剩余值进行计算后得出新值
|
||||
Integer oldBalance = list.get(0).getBalance();
|
||||
Integer newBalance;
|
||||
int newBalance;
|
||||
if ("1".equals(memberPoints.getType())) {
|
||||
newBalance = oldBalance + memberPoints.getPoints();
|
||||
} else {
|
||||
|
||||
@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -66,7 +67,7 @@ public class MemberRightsServiceImpl extends ServiceImpl<MemberRightsMapper, Mem
|
||||
* @date 17:15 2025/3/31
|
||||
**/
|
||||
@Override
|
||||
public Integer getReport(Long userId, String cardId) {
|
||||
public Integer getMemberRightsValue(Long userId, String cardId,String rightsCode) {
|
||||
LambdaQueryWrapper<MemberRights> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper
|
||||
.eq(MemberRights::getUserId, userId)
|
||||
@ -76,7 +77,7 @@ public class MemberRightsServiceImpl extends ServiceImpl<MemberRightsMapper, Mem
|
||||
return dlRightsConfig.getReport();
|
||||
} else {
|
||||
List<MemberRights> filterRights = rights.stream()
|
||||
.filter(item -> "report".equals(item.getRightsCode()))
|
||||
.filter(item -> rightsCode.equals(item.getRightsCode()))
|
||||
.collect(Collectors.toList());
|
||||
return filterRights.get(0).getRemaining();
|
||||
}
|
||||
@ -100,14 +101,21 @@ public class MemberRightsServiceImpl extends ServiceImpl<MemberRightsMapper, Mem
|
||||
.in(MemberRights::getCardId, cardIds)
|
||||
.eq(MemberRights::getRightsCode, rightsCode);
|
||||
try {
|
||||
MemberRights rights = getOne(lambdaQueryWrapper);
|
||||
if (!("02".equals(rights.getRightsType()) && rights.getRightsValue() == 0)) {
|
||||
int result = rights.getRemaining() - deplete;
|
||||
if (result == 0) {
|
||||
throw new Exception("今日次数已达上限");
|
||||
List<MemberRights> rights = list(lambdaQueryWrapper);
|
||||
//取出最大值
|
||||
if (!rights.isEmpty()) {
|
||||
List<MemberRights> maxRights = getRightsValueZeroOrMax(rights);
|
||||
MemberRights max = maxRights.get(0);
|
||||
if (!("02".equals(max.getRightsType()) && max.getRightsValue() == 0)) {
|
||||
int result = max.getRemaining() - deplete;
|
||||
if (result == 0) {
|
||||
throw new Exception("今日次数已达上限");
|
||||
}
|
||||
max.setRemaining(result);
|
||||
updateById(max);
|
||||
}
|
||||
rights.setRemaining(result);
|
||||
updateById(rights);
|
||||
} else {
|
||||
throw new Exception("未查询到权限");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new Exception(e.getMessage());
|
||||
@ -115,6 +123,35 @@ public class MemberRightsServiceImpl extends ServiceImpl<MemberRightsMapper, Mem
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 取出权益最大值
|
||||
* @author PQZ
|
||||
* @date 18:03 2025/4/24
|
||||
* @param rights {@link MemberRights}
|
||||
* @return java.util.List<com.ruoyi.member.domain.MemberRights>
|
||||
**/
|
||||
private List<MemberRights> getRightsValueZeroOrMax(List<MemberRights> rights) {
|
||||
// 先找 rightsValue==0 的数据
|
||||
List<MemberRights> zeroList = rights.stream()
|
||||
.filter(r -> r.getRightsValue() == 0)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!zeroList.isEmpty()) {
|
||||
// 有 0 的返回所有 0 的数据
|
||||
return zeroList;
|
||||
}
|
||||
|
||||
// 没 0,再找最大值
|
||||
int max = rights.stream()
|
||||
.mapToInt(MemberRights::getRightsValue)
|
||||
.max()
|
||||
.orElse(Integer.MIN_VALUE);
|
||||
|
||||
return rights.stream()
|
||||
.filter(r -> r.getRightsValue() == max)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务重置剩余值
|
||||
*
|
||||
|
||||
@ -116,7 +116,7 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
|
||||
//积分
|
||||
result.setPointsBalance(pointsService.getBloggerBalance(userId));
|
||||
//报名
|
||||
result.setReport(cardService.getCardReport(userId,"02"));
|
||||
result.setReport(cardService.getCardRightsValue(userId,"02","report"));
|
||||
//地址信息
|
||||
result.setAddresses(addressService.listByUserId(userId));
|
||||
//会员开通记录
|
||||
@ -141,9 +141,12 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
|
||||
//积分
|
||||
result.setPointsBalance(pointsService.getBloggerBalance(userId));
|
||||
//报名
|
||||
result.setReport(cardService.getCardReport(userId,"02"));
|
||||
result.setReport(cardService.getCardRightsValue(userId,"02","report"));
|
||||
} else {
|
||||
//通告券
|
||||
result.setCoupon(couponService.getCoupon(userId));
|
||||
//剩余发布通告额度
|
||||
result.setAddNotice(cardService.getCardRightsValue(userId,"01","add_notice"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -160,7 +163,7 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String wxLogin(String openid, String decryptResult) {
|
||||
public String wxLogin(String openid, String decryptResult,String unionid) {
|
||||
//字符串转json
|
||||
JSONObject jsonObject = JSONObject.parseObject(decryptResult);
|
||||
//手机号
|
||||
@ -171,6 +174,10 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
|
||||
if(null==wxUser){
|
||||
//根据openId没查到,再根据手机号查
|
||||
wxUser = userMapper.selectWxUserByOpenIdOrPhone(null,phone,null,null);
|
||||
if(null==wxUser&& StringUtils.isNotEmpty(unionid)){
|
||||
//根据openId没查到,再根据unionid查
|
||||
wxUser = userMapper.selectWxUserByOpenIdOrPhone(null,null,null,unionid);
|
||||
}
|
||||
}
|
||||
//如果查不到,则新增,查到了,则更新
|
||||
SysUser user = new SysUser();
|
||||
@ -183,6 +190,7 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
|
||||
user.setPhonenumber(phone);
|
||||
user.setSex("2");
|
||||
user.setCreateTime(DateUtils.getNowDate());
|
||||
user.setUnionId(unionid);
|
||||
//新增 用户
|
||||
userMapper.insertUser(user);
|
||||
//插入用户扩展信息表数据
|
||||
@ -202,6 +210,8 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
|
||||
if(!openid.equals(user.getOpenId())){
|
||||
user.setOpenId(openid);
|
||||
user.setUpdateTime(DateUtils.getNowDate());
|
||||
user.setUnionId(unionid);
|
||||
user.setPhonenumber(phone);
|
||||
userMapper.updateUser(user);
|
||||
}
|
||||
}
|
||||
@ -274,6 +284,7 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
|
||||
user = wxUser;
|
||||
if(!userInfo.get("openid").equals(user.getOpenId())){
|
||||
user.setWxOpenId((String) userInfo.get("openid"));
|
||||
user.setUnionId((String) userInfo.get("unionid"));
|
||||
user.setUpdateTime(DateUtils.getNowDate());
|
||||
userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
@ -40,6 +40,8 @@ public class MemberUserVO extends MemberUser {
|
||||
int report;
|
||||
/**剩余通告券*/
|
||||
int coupon;
|
||||
/**发布通告额度*/
|
||||
int addNotice;
|
||||
/**用户名*/
|
||||
String userName;
|
||||
/**类型名称*/
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package com.ruoyi.web.controller.cos;
|
||||
|
||||
import com.ruoyi.system.service.CosStsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: sts
|
||||
* @Author: 86187
|
||||
* @Date: 2025/03/20 16:34
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/cos")
|
||||
@RequiredArgsConstructor
|
||||
public class CosStsController {
|
||||
|
||||
private final CosStsService cosStsService;
|
||||
|
||||
/**
|
||||
* 获取cos临时密钥
|
||||
*
|
||||
* @return sts
|
||||
*/
|
||||
@GetMapping("/sts")
|
||||
@PermitAll
|
||||
public Map<String, Object> getCosSts() {
|
||||
return cosStsService.getTempKeys();
|
||||
}
|
||||
}
|
||||
@ -101,7 +101,7 @@ public class SysLoginController
|
||||
|
||||
if (StringUtils.hasText(decryptResult)){
|
||||
//如果解析成功,获取token
|
||||
String token = memberUserService.wxLogin(openid,decryptResult);
|
||||
String token = memberUserService.wxLogin(openid,decryptResult,jsonObject.getString("unionid"));
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
|
||||
@ -7,6 +7,7 @@ spring:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://124.222.105.7:3306/dl_notice?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
# url: jdbc:mysql://82.156.161.160:3306/dl_notice?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: dl_notice
|
||||
password: 123456
|
||||
# 从库数据源
|
||||
|
||||
@ -157,12 +157,12 @@ wxpay:
|
||||
# 微信支付V3-url前缀
|
||||
baseUrl: https://api.mch.weixin.qq.com/v3
|
||||
# 支付通知回调, pjm6m9.natappfree.cc 为内网穿透地址
|
||||
notifyUrl: https://www.nuoyunr.com/notice/notify/payNotify
|
||||
notifyUrl: https://3w823u8516.vicp.fun/noticeApi/payApi/payNotify
|
||||
# 退款通知回调, pjm6m9.natappfree.cc 为内网穿透地址
|
||||
refundNotifyUrl: https://www.nuoyunr.com/notice/notify/refundNotify
|
||||
refundNotifyUrl: https://www.ddtg.site/notice/notify/refundNotify
|
||||
# 密钥路径,resources根目录下
|
||||
privateKeyPath: D:/任务平台项目/dl_admin/ruoyi-admin/src/main/resources/apiclient_key.pem
|
||||
publicKeyPath: D:/任务平台项目/dl_admin/ruoyi-admin/src/main/resources/public_key.pem
|
||||
publicKeyPath: D:/任务平台项目/dl_admin/ruoyi-admin/src/main/resources/pub_key.pem
|
||||
#商户证书序列号
|
||||
serialNo: 7FCDB0E72D6A928013361ACB77FA3F0DCBD370E3
|
||||
publicKeyId: PUB_KEY_ID_0117124479362025041500321584003200
|
||||
@ -173,3 +173,11 @@ dl-rights:
|
||||
# 每月发布通告额度
|
||||
addNotice: 3
|
||||
report: 5
|
||||
#################### 腾讯COS相关配置 ####################
|
||||
cos:
|
||||
baseUrl: notice-1348525010.cos.ap-beijing.myqcloud.com
|
||||
accessKey: AKIDDbyY3Wr9D4i9LK6f085pLfleJlz60hAP
|
||||
secretKey: 82kJfnu11ulW5TghV5TecVYP3TghXAZl
|
||||
regionName: ap-beijing
|
||||
bucketName: notice-1348525010
|
||||
folderPrefix: /files
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
select main.id, main.user_id, main.title, main.platform_code, main.province, main.city, main.fee_down, main.fee_up, main.is_self_price, main.gift_detail,
|
||||
main.gift_price, main.end_date, main.brand, main.is_show_brand, main.need_num, main.fans_down, main.fans_up, main.is_eligible, main.pic, main.collect, main.detail, main.images,
|
||||
main.blogger_types, main.is_show_tel, main.wechat, main.tel, main.group_image, main.is_use_coupon, main.approval_status, main.approval_user_id, main.approval_time,
|
||||
main.approval_remark, main.creator, main.create_time, main.updater, main.update_time, main.del_flag,
|
||||
main.approval_remark, main.creator, main.create_time, main.updater, main.update_time, main.del_flag,main.is_platform_free,main.is_urgent,
|
||||
uTable.nick_name as userNickName,auditTable.nick_name as approvalUserName,ifnull(noticeView.view_num,0) as viewNum,
|
||||
bTable.title as platformName
|
||||
from dl_busi_notice main
|
||||
@ -25,6 +25,8 @@
|
||||
<if test="entity.city != null "> and main.city = #{entity.city}</if>
|
||||
<if test="entity.title != null and entity.title != ''"> and main.title like concat('%', #{entity.title}, '%')</if>
|
||||
<if test="entity.platformCode != null and entity.platformCode != ''"> and main.platform_code = #{entity.platformCode}</if>
|
||||
<if test="entity.isUrgent != null and entity.isUrgent != ''"> and main.is_urgent = #{entity.isUrgent}</if>
|
||||
<if test="entity.isPlatformFree != null and entity.isPlatformFree != ''"> and main.is_platform_free = #{entity.isPlatformFree}</if>
|
||||
|
||||
<if test="entity.params.beginFeeDown != null and entity.params.beginFeeDown != ''">
|
||||
and main.fee_down <![CDATA[>= ]]> #{entity.params.beginFeeDown}
|
||||
@ -74,7 +76,7 @@ order by dbns.create_time desc
|
||||
LEFT JOIN sys_user su ON dbn.user_id = su.user_id
|
||||
left join dl_busi_notice_sign sign on sign.notice_id = dbn.id and sign.del_flag = 0
|
||||
WHERE
|
||||
dbn.del_flag = 0
|
||||
dbn.del_flag = 0 and dbn.end_date >= CURDATE()
|
||||
AND (dbn.approval_status = '1')
|
||||
<if test="entity.gift!=null and entity.gift!=''">
|
||||
AND ( dbn.gift_detail IS NOT NULL AND dbn.gift_detail != '' )
|
||||
@ -82,6 +84,8 @@ order by dbns.create_time desc
|
||||
<if test="entity.platformCode!=null and entity.platformCode!=''">
|
||||
AND ( dbn.platform_code =#{entity.platformCode} )
|
||||
</if>
|
||||
<if test="entity.isUrgent != null and entity.isUrgent != ''"> and dbn.is_urgent = #{entity.isUrgent}</if>
|
||||
<if test="entity.isPlatformFree != null and entity.isPlatformFree != ''"> and dbn.is_platform_free = #{entity.isPlatformFree}</if>
|
||||
<if test="entity.bloggerType!=null and entity.bloggerType!=''">
|
||||
AND ( dbn.blogger_types LIKE CONCAT('%',#{entity.bloggerType},'%') )
|
||||
</if>
|
||||
@ -109,20 +113,20 @@ order by dbns.create_time desc
|
||||
</if>
|
||||
group by dbn.id
|
||||
ORDER BY
|
||||
<choose>
|
||||
<when test="entity.sortBy=='new'">
|
||||
-- 查最新的 --
|
||||
dbn.create_time DESC
|
||||
</when>
|
||||
<when test="entity.sortBy=='money'">
|
||||
-- 查高奖励 --
|
||||
dbn.fee_up DESC
|
||||
</when>
|
||||
<otherwise>
|
||||
-- 默认正序排列 --
|
||||
dbn.create_time DESC
|
||||
</otherwise>
|
||||
</choose>
|
||||
<choose>
|
||||
<when test="entity.sortBy=='new'">
|
||||
-- 查最新的 --
|
||||
dbn.create_time DESC
|
||||
</when>
|
||||
<when test="entity.sortBy=='money'">
|
||||
-- 查高奖励 --
|
||||
dbn.fee_up DESC
|
||||
</when>
|
||||
<otherwise>
|
||||
-- 默认正序排列 --
|
||||
dbn.create_time DESC
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
</select>
|
||||
<select id="selectByIdVo" resultType="com.ruoyi.busi.vo.BusiNoticeVo">
|
||||
@ -159,6 +163,8 @@ order by dbns.create_time desc
|
||||
<if test="entity.platformCode!=null and entity.platformCode!=''">
|
||||
AND ( dbn.platform_code =#{entity.platformCode} )
|
||||
</if>
|
||||
<if test="entity.isUrgent != null and entity.isUrgent != ''"> and dbn.is_urgent = #{entity.isUrgent}</if>
|
||||
<if test="entity.isPlatformFree != null and entity.isPlatformFree != ''"> and dbn.is_platform_free = #{entity.isPlatformFree}</if>
|
||||
<if test="entity.bloggerType!=null and entity.bloggerType!=''">
|
||||
AND ( dbn.blogger_types LIKE CONCAT('%',#{entity.bloggerType},'%') )
|
||||
</if>
|
||||
@ -200,6 +206,7 @@ order by dbns.create_time desc
|
||||
dbn.create_time ASC
|
||||
</otherwise>
|
||||
</choose>
|
||||
limit #{num}
|
||||
</select>
|
||||
<select id="subscribeList" resultType="com.ruoyi.busi.vo.BusiNoticeVo">
|
||||
SELECT
|
||||
@ -252,6 +259,8 @@ order by dbns.create_time desc
|
||||
<if test="entity.feeDown!=null">
|
||||
AND ( dbn.fee_down >=#{entity.feeDown} )
|
||||
</if>
|
||||
<if test="entity.isUrgent != null and entity.isUrgent != ''"> and dbn.is_urgent = #{entity.isUrgent}</if>
|
||||
<if test="entity.isPlatformFree != null and entity.isPlatformFree != ''"> and dbn.is_platform_free = #{entity.isPlatformFree}</if>
|
||||
group by dbn.id
|
||||
ORDER BY
|
||||
|
||||
|
||||
@ -70,13 +70,13 @@
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- JSON工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 阿里JSON解析器 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
@ -165,7 +165,12 @@
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
<artifactId>cos-sts_api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.tencent.cloud.CosStsClient;
|
||||
import com.tencent.cloud.Response;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* @Description: sts
|
||||
* @Author: 86187
|
||||
* @Date: 2025/03/20 16:18
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class CosStsService {
|
||||
// 你的腾讯云账号的 SecretId 和 SecretKey
|
||||
@Value("${cos.accessKey}")
|
||||
private String SECRET_ID;
|
||||
@Value("${cos.secretKey}")
|
||||
private String SECRET_KEY;
|
||||
|
||||
// 存储桶所属的地域,例如 "ap-shanghai"
|
||||
@Value("${cos.regionName}")
|
||||
private String REGION;
|
||||
|
||||
// 你的存储桶名,例如 "example-1250000000"
|
||||
@Value("${cos.bucketName}")
|
||||
private String BUCKET;
|
||||
|
||||
// 临时密钥有效期(单位秒),最长不超过 2 小时(7200 秒)
|
||||
private static final int DURATION_SECONDS = 1800;
|
||||
|
||||
public Map<String, Object> getTempKeys() {
|
||||
TreeMap<String, Object> config = new TreeMap<String, Object>();
|
||||
|
||||
try {
|
||||
// 云 api 密钥 SecretId
|
||||
config.put("secretId", SECRET_ID);
|
||||
// 云 api 密钥 SecretKey
|
||||
config.put("secretKey", SECRET_KEY);
|
||||
// 临时密钥有效时长,单位是秒
|
||||
config.put("durationSeconds", 1800);
|
||||
// 换成你的 bucket
|
||||
config.put("bucket", BUCKET);
|
||||
// 换成 bucket 所在地区
|
||||
config.put("region", REGION);
|
||||
|
||||
// 可以通过 allowPrefixes 指定前缀数组, 例子: a.jpg 或者 a/* 或者 * (使用通配符*存在重大安全风险, 请谨慎评估使用)
|
||||
config.put("allowPrefixes", new String[] {
|
||||
"*"
|
||||
});
|
||||
|
||||
// 密钥的权限列表。简单上传和分片需要以下的权限,其他权限列表请看 https://cloud.tencent.com/document/product/436/31923
|
||||
String[] allowActions = new String[] {
|
||||
// 简单上传
|
||||
"name/cos:PutObject",
|
||||
"name/cos:PostObject",
|
||||
// 分片上传
|
||||
"name/cos:InitiateMultipartUpload",
|
||||
"name/cos:ListMultipartUploads",
|
||||
"name/cos:ListParts",
|
||||
"name/cos:UploadPart",
|
||||
"name/cos:CompleteMultipartUpload"
|
||||
};
|
||||
config.put("allowActions", allowActions);
|
||||
|
||||
Response response = CosStsClient.getCredential(config);
|
||||
Map<String, Object> result= new HashMap<>();
|
||||
result.put("credentials", response.credentials);
|
||||
result.put("startTime", response.startTime);
|
||||
result.put("expiredTime", response.expiredTime);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalArgumentException("no valid secret !");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user