This commit is contained in:
hucs
2024-07-30 10:57:01 +08:00
parent 97613cca71
commit f48e2d8fe4
6 changed files with 495 additions and 7 deletions

View File

@@ -0,0 +1,33 @@
package com.starry.admin.modules.weichat.controller;
import com.starry.admin.utils.SmsUtils;
import com.starry.common.result.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 动态接口
*
* @author admin
* @since 2024/5/20 下午11:19
**/
@Slf4j
@RestController
@RequestMapping("/wx/sms")
public class WxSmsController {
@Resource
private SmsUtils smsUtils;
@GetMapping("/send")
public R sendSms(@RequestParam("phone") String phone) {
smsUtils.sendSmsApi(phone);
return R.ok();
}
}

View File

@@ -1,11 +1,14 @@
package com.starry.admin.modules.weichat.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.common.play.wx.WeChatConstants;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserReviewInfoEntity;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
@@ -23,6 +26,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@@ -109,4 +113,29 @@ public class WxCustomMpService {
}
}
public void sendCheckMessage(PlayClerkUserReviewInfoEntity entity, PlayClerkUserInfoEntity userInfo, String reviewState) {
String touser = userInfo.getOpenid();
String template_id = "U51bGIGq6NsoF-zS-THOs8u-ogtMo0um_tdJoDhBd0A";
String tenantKey = tenantService.selectSysTenantByTenantId(userInfo.getTenantId()).getTenantKey();
String url = "http://" + tenantKey + ".july.hucs.top/clerk/";
WxMpTemplateMessage templateMessage = new WxMpTemplateMessage();
templateMessage.setTemplateId(template_id);
templateMessage.setToUser(touser);
templateMessage.setUrl(url);
List<WxMpTemplateData> data = new ArrayList<>();
data.add(new WxMpTemplateData("short_thing7", reviewState.equals("1") ? "通过" : "拒绝"));
data.add(new WxMpTemplateData("thing2", entity.getNickname()));
data.add(new WxMpTemplateData("thing11", entity.getWeiChatCode()));
data.add(new WxMpTemplateData("time8", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")));
templateMessage.setData(data);
try {
proxyWxMpService().getTemplateMsgService().sendTemplateMsg(templateMessage);
} catch (WxErrorException e) {
log.error(e.getMessage(), e);
}
}
}