微信打卡接口优化
This commit is contained in:
parent
23bdf241e4
commit
7952bdb03e
stdiet-admin/src/main/java/com/stdiet/web/controller
stdiet-custom/src/main
java/com/stdiet/custom
resources/mapper/custom
@ -2,7 +2,11 @@ package com.stdiet.web.controller;
|
||||
|
||||
import com.stdiet.common.config.AliyunOSSConfig;
|
||||
import com.stdiet.common.utils.oss.AliyunOSSUtils;
|
||||
import com.stdiet.custom.domain.SysWxUserInfo;
|
||||
import com.stdiet.custom.domain.SysWxUserLog;
|
||||
import com.stdiet.custom.mapper.SysCustomerPhysicalSignsMapper;
|
||||
import com.stdiet.custom.mapper.SysWxUserInfoMapper;
|
||||
import com.stdiet.custom.mapper.SysWxUserLogMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
@ -10,18 +14,36 @@ import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Order(value = 1)
|
||||
public class MyApplicationRunner implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private SysCustomerPhysicalSignsMapper sysCustomerPhysicalSignsMapper;
|
||||
private SysWxUserLogMapper sysWxUserLogMapper;
|
||||
|
||||
@Autowired
|
||||
private SysWxUserInfoMapper sysWxUserInfoMapper;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
System.out.println("项目启动调用方法");
|
||||
// String path = AliyunOSSUtils.uploadFileInputSteam(AliyunOSSConfig.casePrefix,"ceshi.png",new File("D:\\ceshi.png"));
|
||||
// System.out.println(path);
|
||||
/*System.out.println("项目启动调用方法");
|
||||
List<String> phoneList = sysWxUserLogMapper.getAllSysWxUserLogPhone();
|
||||
SysWxUserLog sysWxUserLog = new SysWxUserLog();
|
||||
if(phoneList.size() > 0){
|
||||
for (String phone : phoneList) {
|
||||
System.out.println(phone);
|
||||
SysWxUserInfo sysWxUserInfo = new SysWxUserInfo();
|
||||
sysWxUserInfo.setPhone(phone);
|
||||
List<SysWxUserInfo> list = sysWxUserInfoMapper.selectSysWxUserInfoList(sysWxUserInfo);
|
||||
if(list != null && list.size() > 0){
|
||||
sysWxUserLog.setOpenid(list.get(0).getOpenid());
|
||||
sysWxUserLog.setPhone(phone);
|
||||
sysWxUserLogMapper.updateSysWxUserLog(sysWxUserLog);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.itextpdf.io.util.DateTimeUtil;
|
||||
import com.stdiet.common.core.controller.BaseController;
|
||||
import com.stdiet.common.core.domain.AjaxResult;
|
||||
import com.stdiet.common.core.page.TableDataInfo;
|
||||
import com.stdiet.common.utils.DateUtils;
|
||||
import com.stdiet.common.utils.StringUtils;
|
||||
import com.stdiet.common.utils.oss.AliyunOSSUtils;
|
||||
import com.stdiet.common.utils.sign.AesUtils;
|
||||
@ -17,8 +18,9 @@ import com.stdiet.custom.service.ISysWxUserLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 微信小程序统一Controller
|
||||
@ -95,12 +97,7 @@ public class WechatAppletController extends BaseController {
|
||||
}else{
|
||||
sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo);
|
||||
}
|
||||
//查询是否下单
|
||||
SysCustomer param = new SysCustomer();
|
||||
param.setPhone(sysWxUserInfo.getPhone());
|
||||
int orderCount = sysOrderService.getOrderCountByCustomer(param);
|
||||
//返回订单数量
|
||||
return AjaxResult.success(orderCount);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,10 +106,34 @@ public class WechatAppletController extends BaseController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getPunchLogs")
|
||||
public TableDataInfo getPunchLogs(SysWxUserLog sysWxUserLog) {
|
||||
startPage();
|
||||
List<WxLogInfo> list = sysWxUserLogService.selectWxLogInfoList(sysWxUserLog);
|
||||
return getDataTable(list);
|
||||
public AjaxResult getPunchLogs(SysWxUserLog sysWxUserLog) {
|
||||
if(StringUtils.isEmpty(sysWxUserLog.getPhone()) && StringUtils.isEmpty(sysWxUserLog.getOpenid())){
|
||||
return AjaxResult.error(5001, "缺少参数");
|
||||
}
|
||||
//查询是否下单
|
||||
SysCustomer param = new SysCustomer();
|
||||
param.setPhone(sysWxUserLog.getPhone());
|
||||
int orderCount = sysOrderService.getOrderCountByCustomer(param);
|
||||
if(orderCount > 0){
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
//今日是否已打卡
|
||||
boolean isPunch = false;
|
||||
startPage();
|
||||
List<WxLogInfo> list = sysWxUserLogService.getWxLogInfoList(sysWxUserLog);
|
||||
if(list.size() > 0){
|
||||
WxLogInfo lastLog = list.get(0);
|
||||
if(lastLog.getDate() != null && ChronoUnit.DAYS.between(DateUtils.stringToLocalDate(lastLog.getDate(), "yyyy-MM-dd"), LocalDate.now()) == 0) {
|
||||
isPunch = true;
|
||||
}
|
||||
}
|
||||
Collections.reverse(list);
|
||||
TableDataInfo tableDataInfo = getDataTable(list);
|
||||
result.put("isPunch", isPunch);
|
||||
result.put("tableDataInfo", tableDataInfo);
|
||||
return AjaxResult.success(result);
|
||||
}else{
|
||||
return AjaxResult.error(5002, "未查询到相关订单信息");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,7 +156,7 @@ public class WechatAppletController extends BaseController {
|
||||
public AjaxResult addPunchLog(@RequestBody SysWxUserLog sysWxUserLog) {
|
||||
// 查询微信用户
|
||||
SysWxUserInfo userInfo = StringUtils.isEmpty(sysWxUserLog.getOpenid()) ? null : sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserLog.getOpenid());
|
||||
if (userInfo == null) {
|
||||
if (userInfo == null || StringUtils.isEmpty(userInfo.getPhone())) {
|
||||
return AjaxResult.error("不存在客户");
|
||||
}
|
||||
//查询今日是否已打卡
|
||||
|
@ -66,4 +66,10 @@ public interface SysWxUserLogMapper
|
||||
|
||||
public int checkWxLogInfoCount(String openid);
|
||||
|
||||
/**
|
||||
* 根据openid和手机号查询打卡记录
|
||||
* @return
|
||||
*/
|
||||
public List<WxLogInfo> getWxLogInfoList(SysWxUserLog sysWxUserLog);
|
||||
|
||||
}
|
@ -65,4 +65,10 @@ public interface ISysWxUserLogService
|
||||
public int deleteSysWxUserLogById(String openid);
|
||||
|
||||
public int checkWxLogInfoCount(String openid);
|
||||
|
||||
/**
|
||||
* 根据openid和手机号查询打卡记录
|
||||
* @return
|
||||
*/
|
||||
public List<WxLogInfo> getWxLogInfoList(SysWxUserLog sysWxUserLog);
|
||||
}
|
@ -100,5 +100,12 @@ public class SysWxUserLogServiceImpl implements ISysWxUserLogService {
|
||||
return sysWxUserLogMapper.checkWxLogInfoCount(openid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据openid和手机号查询打卡记录
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<WxLogInfo> getWxLogInfoList(SysWxUserLog sysWxUserLog){
|
||||
return sysWxUserLogMapper.getWxLogInfoList(sysWxUserLog);
|
||||
}
|
||||
}
|
@ -133,6 +133,7 @@
|
||||
<update id="updateSysWxUserLog" parameterType="SysWxUserLog">
|
||||
update sys_wx_user_log
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="openid != null">openid = #{openid},</if>
|
||||
<if test="weight != null">weight = #{weight},</if>
|
||||
<if test="appid != null">appid = #{appid},</if>
|
||||
<if test="phone != null">phone = #{phone},</if>
|
||||
@ -151,7 +152,7 @@
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where openid = #{openid}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysWxUserLogById" parameterType="String">
|
||||
@ -165,4 +166,11 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 根据openid或手机号查询对应打卡记录 -->
|
||||
<select id="getWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo">
|
||||
SELECT wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.water, wxlog.sport FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
|
||||
where wxinfo.openid = #{openid} or wxinfo.phone = #{phone}
|
||||
order by wxlog.log_time desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user