打卡通知
This commit is contained in:
parent
57927c78d6
commit
f66d22c4e0
@ -5,6 +5,7 @@ import com.stdiet.common.constant.HttpStatus;
|
||||
import com.stdiet.common.core.controller.BaseController;
|
||||
import com.stdiet.common.core.domain.AjaxResult;
|
||||
import com.stdiet.common.core.domain.entity.SysDictData;
|
||||
import com.stdiet.common.core.domain.entity.SysUser;
|
||||
import com.stdiet.common.core.page.TableDataInfo;
|
||||
import com.stdiet.common.exception.file.FileNameLengthLimitExceededException;
|
||||
import com.stdiet.common.utils.AliyunVideoUtils;
|
||||
@ -19,6 +20,7 @@ import com.stdiet.custom.dto.response.*;
|
||||
import com.stdiet.custom.page.WxLogInfo;
|
||||
import com.stdiet.custom.service.*;
|
||||
import com.stdiet.system.service.ISysDictTypeService;
|
||||
import com.stdiet.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -84,6 +86,8 @@ public class WechatAppletController extends BaseController {
|
||||
private ISysCustomerHealthyService sysCustomerHealthyService;
|
||||
@Autowired
|
||||
private ISysCustomerPhysicalSignsService sysCustomerPhysicalSignsService;
|
||||
@Autowired
|
||||
private ISysUserService iSysUserService;
|
||||
|
||||
/**
|
||||
* 查询微信小程序中展示的客户案例
|
||||
@ -193,7 +197,18 @@ public class WechatAppletController extends BaseController {
|
||||
@PostMapping(value = "/addPunchLog")
|
||||
public AjaxResult addPunchLog(@RequestBody SysWxUserLog sysWxUserLog) {
|
||||
if (sysWxUserLog.getId() == null) {
|
||||
return toAjax(sysWxUserLogService.insertSysWxUserLog(sysWxUserLog));
|
||||
int row = sysWxUserLogService.insertSysWxUserLog(sysWxUserLog);
|
||||
if (row > 0) {
|
||||
Long cusId = Long.parseLong(AesUtils.decrypt(sysWxUserLog.getCusId()));
|
||||
SysCustomer sysCustomer = iSysCustomerService.selectSysCustomerById(cusId);
|
||||
if (StringUtils.isNotNull(sysCustomer)) {
|
||||
SysUser sysUser = iSysUserService.selectUserById(sysCustomer.getAfterDietitian());
|
||||
if (StringUtils.isNotNull(sysUser)) {
|
||||
iWechatAppletService.postCustomerPunchNotice(sysCustomer.getName(), sysUser.getWxPublicOpenid());
|
||||
}
|
||||
}
|
||||
}
|
||||
return toAjax(row);
|
||||
}
|
||||
return toAjax(sysWxUserLogService.updateSysWxUserLog(sysWxUserLog));
|
||||
}
|
||||
@ -455,9 +470,13 @@ public class WechatAppletController extends BaseController {
|
||||
SysCustomerPhysicalSigns customerPhysicalSigns = sysCustomerPhysicalSignsService.selectSysCustomerPhysicalSignsByCusId(curWxUserInfo.getCusId());
|
||||
if (customerPhysicalSigns != null) {
|
||||
curWxUserInfo.setSex(customerPhysicalSigns.getSex().toString());
|
||||
curWxUserInfo.setHeight(customerPhysicalSigns.getTall());
|
||||
curWxUserInfo.setAge(customerPhysicalSigns.getAge());
|
||||
}
|
||||
} else {
|
||||
curWxUserInfo.setSex(customerHealthy.getSex().toString());
|
||||
curWxUserInfo.setHeight(customerHealthy.getTall());
|
||||
curWxUserInfo.setAge(Math.toIntExact(customerHealthy.getAge()));
|
||||
}
|
||||
|
||||
curWxUserInfo.setCustomerId(AesUtils.encrypt(curWxUserInfo.getCusId().toString()));
|
||||
|
@ -133,6 +133,16 @@ public class SysUser extends BaseEntity {
|
||||
@Excel(name = "岗位")
|
||||
private String postName;
|
||||
|
||||
private String wxPublicOpenid;
|
||||
|
||||
public void setWxPublicOpenid(String wxPublicOpenid) {
|
||||
this.wxPublicOpenid = wxPublicOpenid;
|
||||
}
|
||||
|
||||
public String getWxPublicOpenid() {
|
||||
return wxPublicOpenid;
|
||||
}
|
||||
|
||||
public SysUser() {
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,10 @@ public class SysWxUserInfo {
|
||||
|
||||
private String customerId;
|
||||
|
||||
private Integer height;
|
||||
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
|
@ -26,6 +26,8 @@ public class SysWxUserLog extends BaseEntity {
|
||||
*/
|
||||
private String openid;
|
||||
|
||||
private String cusId;
|
||||
|
||||
/**
|
||||
* 体重
|
||||
*/
|
||||
|
@ -7,4 +7,6 @@ public interface IWechatAppletService {
|
||||
public Integer postSubscribeMessage(Long cusId, Long planId, String name, String startDate, String endDate, String remark);
|
||||
|
||||
public Integer postSms(Long cusId, Long planId, String plan);
|
||||
|
||||
public Integer postCustomerPunchNotice(String name, String toUser);
|
||||
}
|
||||
|
@ -27,7 +27,9 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class WeChartAppletServiceImp implements IWechatAppletService {
|
||||
static final String WX_TEM_ID = "Ow0j0Jt4OJhjy6GruBstOMLTGjAVagM4hTZRLAaxqJo";
|
||||
static final String WX_LITE_SUBSCRIBE_TEM_ID = "Ow0j0Jt4OJhjy6GruBstOMLTGjAVagM4hTZRLAaxqJo";
|
||||
|
||||
static final String WX_PUBLIC_CUSTOMER_PUNCH_NOTICE_TEM_ID = "XapMBz6KsPW6_rK5__oxxaY8cSLyVYyoSljstZsITyo";
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
@ -51,6 +53,8 @@ public class WeChartAppletServiceImp implements IWechatAppletService {
|
||||
String appSecret = "";
|
||||
if (appId.equals("wx26be9b2aa525fc1e")) {
|
||||
appSecret = "de436c17e42e6fc0637bd0de169ea0c1";
|
||||
} else if (appId.equals("wx4a9c1fc9dba53202")) {
|
||||
appSecret = "fff029ade5d3575df755f4cf9e52f8da";
|
||||
}
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={appId}&secret={appSecret}";
|
||||
Map<String, String> param = new HashMap<>();
|
||||
@ -86,7 +90,7 @@ public class WeChartAppletServiceImp implements IWechatAppletService {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("access_token", accessToken);
|
||||
param.put("touser", sysWxUserInfo.getOpenid());
|
||||
param.put("template_id", WX_TEM_ID);
|
||||
param.put("template_id", WX_LITE_SUBSCRIBE_TEM_ID);
|
||||
param.put("page", "pages/recipes/index");
|
||||
|
||||
|
||||
@ -114,7 +118,7 @@ public class WeChartAppletServiceImp implements IWechatAppletService {
|
||||
postLog.setSendTime(DateUtils.getNowDate());
|
||||
postLog.setPlanId(planId);
|
||||
//
|
||||
dataParam.put("tmpId", WX_TEM_ID);
|
||||
dataParam.put("tmpId", WX_LITE_SUBSCRIBE_TEM_ID);
|
||||
postLog.setData(dataParam);
|
||||
wxSubscribePostLogService.insertWxSubscribePostLog(postLog);
|
||||
|
||||
@ -155,5 +159,52 @@ public class WeChartAppletServiceImp implements IWechatAppletService {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer postCustomerPunchNotice(String name, String toUser) {
|
||||
String accessToken = getAccessToken("wx4a9c1fc9dba53202");
|
||||
if (StringUtils.isNull(accessToken)) {
|
||||
return -1;
|
||||
}
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
|
||||
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("touser", toUser);
|
||||
param.put("template_id", WX_PUBLIC_CUSTOMER_PUNCH_NOTICE_TEM_ID);
|
||||
// param.put("url", "pages/recipes/index");
|
||||
// JSONObject miniData = new JSONObject();
|
||||
// miniData.put("appid", "");
|
||||
// miniData.put("pagepath", "");
|
||||
// param.put("miniprogram", miniData);
|
||||
|
||||
JSONObject dataParam = new JSONObject();
|
||||
dataParam.put("first", JSONObject.parse("{\"value\":\"完成打卡\"}"));
|
||||
dataParam.put("keyword1", JSONObject.parse("{\"value\":\"" + name + "\"}"));
|
||||
dataParam.put("keyword2", JSONObject.parse("{\"value\":\"" + DateUtils.getTime() + "\"}"));
|
||||
dataParam.put("keyword3", JSONObject.parse("{\"value\":\"成功\"}"));
|
||||
dataParam.put("remark", JSONObject.parse("{\"value\":\" \"}"));
|
||||
|
||||
param.put("data", dataParam);
|
||||
|
||||
restTemplate.getMessageConverters()
|
||||
.add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
||||
ResponseEntity<String> entity = restTemplate.postForEntity(url, param.toJSONString(), String.class);
|
||||
|
||||
JSONObject resultObj = JSONObject.parseObject(entity.getBody());
|
||||
|
||||
WxSubscribePostLog postLog = new WxSubscribePostLog();
|
||||
postLog.setAppid("wx4a9c1fc9dba53202");
|
||||
postLog.setOpenid(toUser);
|
||||
int errCode = resultObj.getInteger("errcode");
|
||||
postLog.setType(2);
|
||||
postLog.setResult(resultObj);
|
||||
postLog.setSendTime(DateUtils.getNowDate());
|
||||
//
|
||||
dataParam.put("tmpId", WX_PUBLIC_CUSTOMER_PUNCH_NOTICE_TEM_ID);
|
||||
postLog.setData(dataParam);
|
||||
wxSubscribePostLogService.insertWxSubscribePostLog(postLog);
|
||||
|
||||
return errCode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="wxPublicOpenid" column="wx_public_openid"/>
|
||||
<!-- <result property="postId" column="post_id" />-->
|
||||
<result property="postName" column="post_name"/>
|
||||
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user