开发微信打卡系统
This commit is contained in:
parent
b747473858
commit
efc07c6b90
@ -790,22 +790,23 @@ create table sys_wx_user_info (
|
||||
-- ----------------------------
|
||||
drop table if exists sys_wx_user_log;
|
||||
create table sys_wx_user_log (
|
||||
openid varchar(100) not null default 'manual' comment '微信openid',
|
||||
id BIGINT(20) not null auto_increment comment 'id',
|
||||
openid varchar(100) default 'manual' comment '微信openid',
|
||||
appid varchar(100) comment '微信appid',
|
||||
weight decimal(10,2) comment '体重',
|
||||
phone varchar(30) comment '电话',
|
||||
sleep_time datetime comment '睡觉时间',
|
||||
sleep_time varchar(10) comment '睡觉时间',
|
||||
avatar_url varchar(255) comment '用户头像',
|
||||
wakeup_time datetime comment '起床时间',
|
||||
wakeup_time varchar(10) comment '起床时间',
|
||||
sport char(1) comment '运动情况(Y是 N否)',
|
||||
diet char(1) comment '饮食情况(Y是 N否)',
|
||||
insomnia char(1) comment '熬夜失眠(Y是 N否)',
|
||||
defecation char(1) comment '排便情况',
|
||||
water tinyint comment '饮水量',
|
||||
water bigint(20) comment '饮水量',
|
||||
create_by varchar(64) default '' comment '创建者',
|
||||
create_time datetime comment '创建时间',
|
||||
update_by varchar(64) default '' comment '更新者',
|
||||
update_time datetime comment '更新时间',
|
||||
remark varchar(500) default null comment '备注',
|
||||
primary key (openid)
|
||||
primary key (id)
|
||||
) engine=innodb comment = '微信用户记录';
|
@ -1,25 +1,22 @@
|
||||
package com.stdiet.web.controller.custom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.stdiet.common.annotation.Log;
|
||||
import com.stdiet.common.core.controller.BaseController;
|
||||
import com.stdiet.common.core.domain.AjaxResult;
|
||||
import com.stdiet.common.enums.BusinessType;
|
||||
import com.stdiet.custom.domain.SysWxUserInfo;
|
||||
import com.stdiet.custom.service.ISysWxUserInfoService;
|
||||
import com.stdiet.common.utils.poi.ExcelUtil;
|
||||
import com.stdiet.common.core.page.TableDataInfo;
|
||||
import com.stdiet.common.enums.BusinessType;
|
||||
import com.stdiet.common.utils.StringUtils;
|
||||
import com.stdiet.common.utils.poi.ExcelUtil;
|
||||
import com.stdiet.custom.domain.SysOrder;
|
||||
import com.stdiet.custom.domain.SysWxUserInfo;
|
||||
import com.stdiet.custom.page.WxServeInfo;
|
||||
import com.stdiet.custom.service.ISysOrderService;
|
||||
import com.stdiet.custom.service.ISysWxUserInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信用户Controller
|
||||
@ -33,6 +30,9 @@ public class SysWxUserInfoController extends BaseController {
|
||||
@Autowired
|
||||
private ISysWxUserInfoService sysWxUserInfoService;
|
||||
|
||||
@Autowired
|
||||
private ISysOrderService sysOrderService;
|
||||
|
||||
/**
|
||||
* 查询微信用户列表
|
||||
*/
|
||||
@ -95,17 +95,41 @@ public class SysWxUserInfoController extends BaseController {
|
||||
return toAjax(sysWxUserInfoService.deleteSysWxUserInfoByIds(openids));
|
||||
}
|
||||
|
||||
@PostMapping("/wx/adduser")
|
||||
@PostMapping("/wx/serveinfo")
|
||||
public AjaxResult addUser(@RequestBody SysWxUserInfo sysWxUserInfo) {
|
||||
|
||||
// 查询微信用户
|
||||
SysWxUserInfo userInfo = sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserInfo.getOpenid());
|
||||
int resultCode = 0;
|
||||
if (userInfo == null) {
|
||||
resultCode = sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo);
|
||||
} else {
|
||||
sysWxUserInfo.setPhone(userInfo.getPhone());
|
||||
resultCode = sysWxUserInfoService.updateSysWxUserInfo(sysWxUserInfo);
|
||||
if (StringUtils.isNull(userInfo) && StringUtils.isEmpty(sysWxUserInfo.getPhone())
|
||||
|| StringUtils.isEmpty(userInfo.getPhone()) && StringUtils.isEmpty(sysWxUserInfo.getPhone())) {
|
||||
return AjaxResult.error(5001, "没有手机号");
|
||||
}
|
||||
return toAjax(resultCode);
|
||||
|
||||
// 插入/更新用户信息
|
||||
if (StringUtils.isNull(userInfo)) {
|
||||
sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo);
|
||||
} else {
|
||||
if (StringUtils.isNotEmpty(userInfo.getPhone())) {
|
||||
sysWxUserInfo.setPhone(userInfo.getPhone());
|
||||
}
|
||||
sysWxUserInfoService.updateSysWxUserInfo(sysWxUserInfo);
|
||||
}
|
||||
|
||||
// 查找订单记录
|
||||
SysOrder querySysOrder = new SysOrder();
|
||||
querySysOrder.setPhone(sysWxUserInfo.getPhone());
|
||||
List<SysOrder> list = sysOrderService.selectSysOrderList(querySysOrder);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
return AjaxResult.error(5002, "没有订单信息");
|
||||
}
|
||||
|
||||
WxServeInfo wxServeInfo = new WxServeInfo();
|
||||
wxServeInfo.setServeStatus(list.get(0).getStatus());
|
||||
wxServeInfo.setServeTime(list.get(0).getServeTime());
|
||||
wxServeInfo.setStartTime(list.get(list.size() - 1).getStartTime());
|
||||
wxServeInfo.setWeight(list.get(list.size() - 1).getWeight());
|
||||
|
||||
return AjaxResult.success(wxServeInfo);
|
||||
}
|
||||
}
|
@ -1,23 +1,23 @@
|
||||
package com.stdiet.web.controller.custom;
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.stdiet.common.annotation.Log;
|
||||
import com.stdiet.common.core.controller.BaseController;
|
||||
import com.stdiet.common.core.domain.AjaxResult;
|
||||
import com.stdiet.common.enums.BusinessType;
|
||||
import com.stdiet.custom.domain.SysWxUserLog;
|
||||
import com.stdiet.custom.service.ISysWxUserLogService;
|
||||
import com.stdiet.common.utils.poi.ExcelUtil;
|
||||
import com.stdiet.common.core.page.TableDataInfo;
|
||||
import com.stdiet.common.enums.BusinessType;
|
||||
import com.stdiet.common.utils.StringUtils;
|
||||
import com.stdiet.common.utils.poi.ExcelUtil;
|
||||
import com.stdiet.custom.domain.SysOrder;
|
||||
import com.stdiet.custom.domain.SysWxUserInfo;
|
||||
import com.stdiet.custom.domain.SysWxUserLog;
|
||||
import com.stdiet.custom.service.ISysOrderService;
|
||||
import com.stdiet.custom.service.ISysWxUserInfoService;
|
||||
import com.stdiet.custom.service.ISysWxUserLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信用户记录Controller
|
||||
@ -27,18 +27,21 @@ import com.stdiet.common.core.page.TableDataInfo;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/custom/wxUserLog")
|
||||
public class SysWxUserLogController extends BaseController
|
||||
{
|
||||
public class SysWxUserLogController extends BaseController {
|
||||
@Autowired
|
||||
private ISysWxUserLogService sysWxUserLogService;
|
||||
|
||||
@Autowired
|
||||
private ISysWxUserInfoService sysWxUserInfoService;
|
||||
|
||||
private ISysOrderService sysOrderService;
|
||||
|
||||
/**
|
||||
* 查询微信用户记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysWxUserLog sysWxUserLog)
|
||||
{
|
||||
public TableDataInfo list(SysWxUserLog sysWxUserLog) {
|
||||
startPage();
|
||||
List<SysWxUserLog> list = sysWxUserLogService.selectSysWxUserLogList(sysWxUserLog);
|
||||
return getDataTable(list);
|
||||
@ -50,8 +53,7 @@ public class SysWxUserLogController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:export')")
|
||||
@Log(title = "微信用户记录", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysWxUserLog sysWxUserLog)
|
||||
{
|
||||
public AjaxResult export(SysWxUserLog sysWxUserLog) {
|
||||
List<SysWxUserLog> list = sysWxUserLogService.selectSysWxUserLogList(sysWxUserLog);
|
||||
ExcelUtil<SysWxUserLog> util = new ExcelUtil<SysWxUserLog>(SysWxUserLog.class);
|
||||
return util.exportExcel(list, "wxUserLog");
|
||||
@ -62,8 +64,7 @@ public class SysWxUserLogController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:query')")
|
||||
@GetMapping(value = "/{openid}")
|
||||
public AjaxResult getInfo(@PathVariable("openid") String openid)
|
||||
{
|
||||
public AjaxResult getInfo(@PathVariable("openid") String openid) {
|
||||
return AjaxResult.success(sysWxUserLogService.selectSysWxUserLogById(openid));
|
||||
}
|
||||
|
||||
@ -73,8 +74,7 @@ public class SysWxUserLogController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:add')")
|
||||
@Log(title = "微信用户记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysWxUserLog sysWxUserLog)
|
||||
{
|
||||
public AjaxResult add(@RequestBody SysWxUserLog sysWxUserLog) {
|
||||
return toAjax(sysWxUserLogService.insertSysWxUserLog(sysWxUserLog));
|
||||
}
|
||||
|
||||
@ -84,8 +84,7 @@ public class SysWxUserLogController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:edit')")
|
||||
@Log(title = "微信用户记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysWxUserLog sysWxUserLog)
|
||||
{
|
||||
public AjaxResult edit(@RequestBody SysWxUserLog sysWxUserLog) {
|
||||
return toAjax(sysWxUserLogService.updateSysWxUserLog(sysWxUserLog));
|
||||
}
|
||||
|
||||
@ -95,17 +94,28 @@ public class SysWxUserLogController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:remove')")
|
||||
@Log(title = "微信用户记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{openids}")
|
||||
public AjaxResult remove(@PathVariable String[] openids)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable String[] openids) {
|
||||
return toAjax(sysWxUserLogService.deleteSysWxUserLogByIds(openids));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/wx/logs/{openid}")
|
||||
public TableDataInfo getLogInfo(@PathVariable("openid") String openid)
|
||||
{
|
||||
SysWxUserLog sysWxUserLog = new SysWxUserLog();
|
||||
sysWxUserLog.setOpenid(openid);
|
||||
List<SysWxUserLog> list = sysWxUserLogService.selectSysWxUserLogList(sysWxUserLog);
|
||||
return getDataTable(list);
|
||||
public AjaxResult getLogs(@PathVariable String openId) {
|
||||
SysWxUserLog querySysWxUserLog = new SysWxUserLog();
|
||||
querySysWxUserLog.setOpenid(openId);
|
||||
List<SysWxUserLog> list = sysWxUserLogService.selectSysWxUserLogList(querySysWxUserLog);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/wx/logs/add")
|
||||
public AjaxResult addLog(@RequestBody SysWxUserLog sysWxUserLog) {
|
||||
// 查询微信用户
|
||||
SysWxUserInfo userInfo = sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserLog.getOpenid());
|
||||
if(StringUtils.isNull(userInfo)) {
|
||||
return AjaxResult.error(5003, "没有用户信息");
|
||||
}
|
||||
// 提取有用值
|
||||
sysWxUserLog.setAvatarUrl(userInfo.getAvatarUrl());
|
||||
sysWxUserLog.setPhone(userInfo.getPhone());
|
||||
return add(sysWxUserLog);
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ import com.stdiet.common.core.domain.BaseEntity;
|
||||
* 微信用户记录对象 sys_wx_user_log
|
||||
*
|
||||
* @author wonder
|
||||
* @date 2020-11-28
|
||||
* @date 2020-11-29
|
||||
*/
|
||||
public class SysWxUserLog extends BaseEntity
|
||||
{
|
||||
@ -34,34 +34,32 @@ public class SysWxUserLog extends BaseEntity
|
||||
private String phone;
|
||||
|
||||
/** 睡觉时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "睡觉时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date sleepTime;
|
||||
@Excel(name = "睡觉时间")
|
||||
private String sleepTime;
|
||||
|
||||
/** 起床时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "起床时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date wakeupTime;
|
||||
@Excel(name = "起床时间")
|
||||
private String wakeupTime;
|
||||
|
||||
/** 运动情况 */
|
||||
@Excel(name = "运动情况")
|
||||
private Long sport;
|
||||
/** 运动情况(Y是 N否) */
|
||||
@Excel(name = "运动情况", readConverterExp = "Y=是,N=否")
|
||||
private String sport;
|
||||
|
||||
/** 用户头像 */
|
||||
@Excel(name = "用户头像")
|
||||
private String avatarUrl;
|
||||
|
||||
/** 饮食情况 */
|
||||
@Excel(name = "饮食情况")
|
||||
private Long diet;
|
||||
/** 饮食情况(Y是 N否) */
|
||||
@Excel(name = "饮食情况", readConverterExp = "Y=是,N=否")
|
||||
private String diet;
|
||||
|
||||
/** 熬夜失眠(Y是 N否) */
|
||||
@Excel(name = "熬夜失眠", readConverterExp = "Y=是,N=否")
|
||||
private String insomnia;
|
||||
|
||||
/** 排便情况 */
|
||||
@Excel(name = "排便情况")
|
||||
private Long defecation;
|
||||
/** 排便情况(Y是 N否) */
|
||||
@Excel(name = "排便情况", readConverterExp = "Y=是,N=否")
|
||||
private String defecation;
|
||||
|
||||
/** 饮水量 */
|
||||
@Excel(name = "饮水量")
|
||||
@ -103,30 +101,30 @@ public class SysWxUserLog extends BaseEntity
|
||||
{
|
||||
return phone;
|
||||
}
|
||||
public void setSleepTime(Date sleepTime)
|
||||
public void setSleepTime(String sleepTime)
|
||||
{
|
||||
this.sleepTime = sleepTime;
|
||||
}
|
||||
|
||||
public Date getSleepTime()
|
||||
public String getSleepTime()
|
||||
{
|
||||
return sleepTime;
|
||||
}
|
||||
public void setWakeupTime(Date wakeupTime)
|
||||
public void setWakeupTime(String wakeupTime)
|
||||
{
|
||||
this.wakeupTime = wakeupTime;
|
||||
}
|
||||
|
||||
public Date getWakeupTime()
|
||||
public String getWakeupTime()
|
||||
{
|
||||
return wakeupTime;
|
||||
}
|
||||
public void setSport(Long sport)
|
||||
public void setSport(String sport)
|
||||
{
|
||||
this.sport = sport;
|
||||
}
|
||||
|
||||
public Long getSport()
|
||||
public String getSport()
|
||||
{
|
||||
return sport;
|
||||
}
|
||||
@ -139,12 +137,12 @@ public class SysWxUserLog extends BaseEntity
|
||||
{
|
||||
return avatarUrl;
|
||||
}
|
||||
public void setDiet(Long diet)
|
||||
public void setDiet(String diet)
|
||||
{
|
||||
this.diet = diet;
|
||||
}
|
||||
|
||||
public Long getDiet()
|
||||
public String getDiet()
|
||||
{
|
||||
return diet;
|
||||
}
|
||||
@ -157,12 +155,12 @@ public class SysWxUserLog extends BaseEntity
|
||||
{
|
||||
return insomnia;
|
||||
}
|
||||
public void setDefecation(Long defecation)
|
||||
public void setDefecation(String defecation)
|
||||
{
|
||||
this.defecation = defecation;
|
||||
}
|
||||
|
||||
public Long getDefecation()
|
||||
public String getDefecation()
|
||||
{
|
||||
return defecation;
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.stdiet.custom.page;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WxCurUserLogInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.stdiet.custom.page;
|
||||
|
||||
import com.stdiet.common.utils.DateUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public class WxServeInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String serveTime;
|
||||
|
||||
private String serveStatus;
|
||||
|
||||
private String startTime;
|
||||
|
||||
private String weight;
|
||||
|
||||
public String getServeTime() {
|
||||
return serveTime;
|
||||
}
|
||||
|
||||
public void setServeTime(String serveTime) {
|
||||
this.serveTime = serveTime;
|
||||
}
|
||||
|
||||
public String getServeStatus() {
|
||||
return serveStatus;
|
||||
}
|
||||
|
||||
public void setServeStatus(String serveStatus) {
|
||||
if (serveStatus.equals("0")) {
|
||||
this.serveStatus = "进行中";
|
||||
} else if (serveStatus.equals("1")) {
|
||||
this.serveStatus = "暂停";
|
||||
} else if (serveStatus.equals("")) {
|
||||
this.serveStatus = "已完成";
|
||||
}
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTime);
|
||||
}
|
||||
|
||||
public String getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(BigDecimal weight) {
|
||||
this.weight = weight.toString() + "kg";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxServeInfo{" +
|
||||
"serveTime='" + serveTime + '\'' +
|
||||
", serveStatus='" + serveStatus + '\'' +
|
||||
", startTime='" + startTime + '\'' +
|
||||
", weight='" + weight + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -58,4 +58,6 @@ public interface ISysWxUserInfoService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysWxUserInfoById(String openid);
|
||||
|
||||
|
||||
}
|
@ -34,6 +34,7 @@
|
||||
<if test="appid != null and appid != ''"> and appid = #{appid}</if>
|
||||
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
|
||||
</where>
|
||||
order by create_time asc
|
||||
</select>
|
||||
|
||||
<select id="selectSysWxUserLogById" parameterType="String" resultMap="SysWxUserLogResult">
|
||||
|
@ -585,6 +585,9 @@
|
||||
],
|
||||
phone: [
|
||||
{required: true, message: "手机号不能为空", trigger: "blur"}
|
||||
],
|
||||
startTime: [
|
||||
{required: true, message: "开始时间不能为空", trigger: "blur"}
|
||||
]
|
||||
// payTypeId: [
|
||||
// {required: true, message: "收款方式不能为空", trigger: "blur"}
|
||||
|
Loading…
x
Reference in New Issue
Block a user