|
|
@@ -1,11 +1,13 @@
|
|
|
package com.cyksj.web.controller.manage.coupon;
|
|
|
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.annotation.Log;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.config.corp.WeChatCorpFactory;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
|
@@ -36,6 +38,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.constraints.Min;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/*
|
|
|
@@ -438,4 +441,24 @@ public class CouponController {
|
|
|
}
|
|
|
return corpUser.getUnionid();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送优惠券至用户
|
|
|
+ */
|
|
|
+ @PostMapping
|
|
|
+ @SaCheckPermission("coupon:send")
|
|
|
+ public Result<String> sendCouponToUser(Map<String, String> map) {
|
|
|
+ List<Long> userIds = null;
|
|
|
+ Long couponId = null;
|
|
|
+ try {
|
|
|
+ userIds = Jsons.parseList(map.get("userIds"), Long.class);
|
|
|
+ couponId = Long.parseLong(map.get("couponId"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+ final Long finalCouponId = couponId;
|
|
|
+ userIds.forEach(userId -> couponCommonService.sendCouponToUser(userId, finalCouponId, 0l, 0l, 0l, CouponUser.Channel.manual));
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
}
|