Commit 791db583 authored by 刘帅's avatar 刘帅

1.优化

parent 315d9b06
package com.propertyManagement.web.controller.business;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.propertyManagement.business.domain.WxClock;
import com.propertyManagement.business.domain.bo.WxClockBo;
import com.propertyManagement.business.domain.vo.WxClockVo;
import com.propertyManagement.business.domain.vo.WxClockVo2;
import com.propertyManagement.business.mapper.WxClockMapper;
import com.propertyManagement.business.service.IWxClockService;
import com.propertyManagement.business.support.util.AuthUtil;
import com.propertyManagement.common.annotation.Log;
import com.propertyManagement.common.annotation.RepeatSubmit;
import com.propertyManagement.common.core.controller.BaseController;
......@@ -22,7 +30,9 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 打卡
......@@ -38,6 +48,8 @@ public class WxClockController extends BaseController {
private final IWxClockService iWxClockService;
private final WxClockMapper wxClockMapper;
/**
* 查询打卡列表
*/
......@@ -47,6 +59,37 @@ public class WxClockController extends BaseController {
return iWxClockService.queryPageList(bo, pageQuery);
}
/**
* 查询打卡列表
*/
@GetMapping("/info")
public R<WxClockVo2> info(@NotNull Long accountId ,@NotNull(message = "日期不能为空") String date) {
WxClockVo2 wxClockVo2 = new WxClockVo2();
// 解析传入的日期参数
DateTime inputDate = DateUtil.parse(date, "yyyy-MM");
// 获取本月第一天和最后一天
DateTime beginOfMonth = DateUtil.beginOfMonth(inputDate);
DateTime endOfMonth = DateUtil.endOfMonth(inputDate);
// 生成本月所有日期列表
List<DateTime> dateTimes = DateUtil.rangeToList(beginOfMonth, endOfMonth, DateField.DAY_OF_MONTH);
// 并行处理提高效率
List<WxClockVo2.ClockRecord> clockRecordList = dateTimes.parallelStream()
.map(item -> {
String dateStr = DateUtil.format(item, "yyyy-MM-dd");
int count = Math.toIntExact(wxClockMapper.selectCount(Wrappers.<WxClock>lambdaQuery()
.apply("DATE(clock_time) = {0}", dateStr)
.eq(WxClock::getAccountId, accountId)));
return new WxClockVo2.ClockRecord(dateStr, count > 0 ? 1 : 0);
})
.collect(Collectors.toList());
// 计算打卡和缺卡天数
long clockDays = clockRecordList.stream().filter(r -> r.getClockState() == 1).count();
wxClockVo2.setClockDay((int) clockDays);
wxClockVo2.setNoRecordDay(clockRecordList.size() - (int) clockDays);
wxClockVo2.setClockRecordList(clockRecordList);
return R.ok(wxClockVo2);
}
/**
* 导出打卡列表
*/
......
......@@ -100,9 +100,5 @@ public class WxPayRecord extends BaseEntity {
* 平台支付流水号
*/
private String outTradeNo;
/**
* 通道支付流水号
*/
private String tradeNo;
}
......@@ -25,4 +25,14 @@ public class CodeLoginBo {
private double longitude; // 经度
private double latitude; // 纬度
/**
* 加密数据
*/
private String encryptedData;
/**
* 偏移量
*/
private String iv;
}
......@@ -133,10 +133,4 @@ public class WxPayRecordBo extends BaseEntity {
*/
private String outTradeNo;
/**
* 通道支付流水号
*/
private String tradeNo;
}
......@@ -96,7 +96,6 @@ public class WxProprietorLedgerBo extends BaseEntity {
* 出生日期
*/
@JsonFormat(pattern = "YYYY-MM-dd")
@NotNull(message = "出生日期不能为空", groups = { AddGroup.class, EditGroup.class })
private Date birthDate;
/**
......@@ -108,7 +107,6 @@ public class WxProprietorLedgerBo extends BaseEntity {
/**
* 户籍地
*/
@NotBlank(message = "户籍地不能为空", groups = { AddGroup.class, EditGroup.class })
private String registerAddress;
/**
......
......@@ -122,11 +122,5 @@ public class WxPayRecordVo implements Serializable {
@ExcelProperty(value = "平台支付流水号")
private String outTradeNo;
/**
* 通道支付流水号
*/
@ExcelProperty(value = "通道支付流水号")
private String tradeNo;
}
......@@ -3,7 +3,9 @@ package com.propertyManagement.business.service;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.propertyManagement.business.domain.WxFamilyMember;
import com.propertyManagement.business.domain.WxProprietorLedger;
......@@ -145,8 +147,14 @@ public class WxUserLoginService {
}
newUser.setOpenId(openId);
newUser.setMobile(phoneNumber);
if (StringUtils.isNotBlank(bo.getEncryptedData()) && StringUtils.isNotBlank(bo.getIv())) {
WxMaUserInfo userInfo = wxMaDormService.getUserService().getUserInfo(session.getSessionKey(), bo.getEncryptedData(), bo.getIv());
newUser.setNickName(userInfo.getNickName() + "_" + phoneNumber);
newUser.setAvatar(userInfo.getAvatarUrl());
}else {
newUser.setNickName(phoneNumber);
newUser.setAvatar("https://llwy-1356792742.cos.ap-beijing.myqcloud.com/%E5%88%A9%E9%BE%99%E7%89%A9%E4%B8%9A%20logo.png");
}
if (bo.getLongitude() > 0 && bo.getLatitude() > 0) {
newUser.setLongitude(bo.getLongitude());
newUser.setLatitude(bo.getLatitude());
......
......@@ -155,6 +155,9 @@ public class WxPayRecordServiceImpl implements IWxPayRecordService {
recordLambdaQueryWrapper.eq(WxPayRecord::getOrderId, orderId);
WxPayRecord record = baseMapper.selectOne(recordLambdaQueryWrapper);
record.setPayState(PayState.YES.getCode());
record.setPayChannelCode(payChannelCode);
record.setPayMchCode(payMchCode);
record.setPayAppCode(payAppCode);
baseMapper.updateById(record);
/**
* 更新订单状态
......@@ -258,7 +261,6 @@ public class WxPayRecordServiceImpl implements IWxPayRecordService {
lqw.eq(bo.getPayAmount() != null, WxPayRecord::getPayAmount, bo.getPayAmount());
lqw.eq(bo.getPayState() != null, WxPayRecord::getPayState, bo.getPayState());
lqw.eq(StringUtils.isNotBlank(bo.getOutTradeNo()), WxPayRecord::getOutTradeNo, bo.getOutTradeNo());
lqw.eq(StringUtils.isNotBlank(bo.getTradeNo()), WxPayRecord::getTradeNo, bo.getTradeNo());
return lqw;
}
......
......@@ -40,6 +40,7 @@
"axios": "0.24.0",
"clipboard": "2.0.8",
"core-js": "3.25.3",
"dayjs": "^1.11.13",
"echarts": "5.4.0",
"element-ui": "2.15.13",
"file-saver": "2.0.5",
......
......@@ -9,6 +9,15 @@ export function listClock(query) {
})
}
// 查询打卡列表
export function listClockInfo(params) {
return request({
url: '/business/clock/info',
method: 'get',
params: params
})
}
// 查询打卡详细
export function getClock(clockId) {
return request({
......
......@@ -114,8 +114,8 @@
<dict-tag :options="dict.type.account_type" :value="scope.row.clockUserRole"/>
</template>
</el-table-column>
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!-- <template slot-scope="scope">-->
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template slot-scope="scope">
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
......@@ -130,8 +130,14 @@
<!-- @click="handleDelete(scope.row)"-->
<!-- v-hasPermi="['business:clock:remove']"-->
<!-- >删除</el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleInfo(scope.row)"
>打卡记录</el-button>
</template>
</el-table-column>
</el-table>
<pagination
......@@ -187,16 +193,22 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<el-dialog :title="title" :visible.sync="open1" width="500px" append-to-body>
<info :accountId="accountId"/>
</el-dialog>
</div>
</template>
<script>
import { listClock, getClock, delClock, addClock, updateClock } from "@/api/business/clock";
import {listCommunityAll} from "@/api/business/community";
import Info from "./info/index.vue";
export default {
name: "Clock",
dicts: ['account_type'],
components: {Info},
data() {
return {
// 按钮loading
......@@ -220,6 +232,7 @@ export default {
title: "",
// 是否显示弹出层
open: false,
open1: false,
// 查询参数
queryParams: {
pageNum: 1,
......@@ -234,6 +247,7 @@ export default {
// 表单参数
form: {},
clockTime: [],
accountId: null,
// 表单校验
rules: {
userId: [
......@@ -328,6 +342,13 @@ export default {
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleInfo(row) {
this.reset();
this.open1 = true;
this.title = "打卡记录";
this.accountId = row.accountId
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
......
<template>
<div class="calendar-container">
<div class="calendar-header">
<div class="header-controls">
<el-date-picker
v-model="selectedDate"
type="month"
placeholder="选择月份"
format="yyyy年MM月"
value-format="yyyy-MM"
@change="handleDateChange"
/>
<h2>{{ currentMonth }}{{ currentYear }}</h2>
</div>
</div>
<div class="calendar-weekdays">
<div v-for="day in weekdays" :key="day" class="weekday">{{ day }}</div>
</div>
<div class="calendar-days">
<div
v-for="(day, index) in calendarDays"
:key="index"
:class="[
'day',
{ 'empty': !day.date },
{ 'today': isToday(day.date) },
{ 'clocked': day.clockState === 1 },
{ 'not-clocked': day.clockState === 0 }
]"
>
<div v-if="day.date" class="day-content">
<div class="day-number">{{ day.date.getDate() }}</div>
<div class="clock-status">
{{ day.clockState === 1 ? '' : day.clockState === 0 ? '' : '' }}
</div>
</div>
</div>
</div>
<div class="calendar-summary">
<div>已打卡: {{ clockSummary.clockDays }}</div>
<div>未打卡: {{ clockSummary.noRecordDays }}</div>
</div>
</div>
</template>
<script>
import { listClockInfo } from "@/api/business/clock";
import dayjs from "dayjs";
export default {
name: "ClockCalendar",
props: {
accountId: {
type: [String, Number],
required: true
}
},
data() {
const now = new Date();
return {
clockRecordList: [],
weekdays: ['', '', '', '', '', '', ''],
selectedDate: dayjs(now).format("YYYY-MM"), // 默认当前年月
clockSummary: {
clockDays: 0,
noRecordDays: 0
},
loading: false
};
},
computed: {
currentYear() {
return dayjs(this.selectedDate).year();
},
currentMonth() {
return dayjs(this.selectedDate).month() + 1;
},
calendarDays() {
if (!Array.isArray(this.clockRecordList)) {
return [];
}
const year = this.currentYear;
const month = this.currentMonth - 1; // JavaScript月份是0-11
const firstDay = new Date(year, month, 1);
const lastDay = new Date(year, month + 1, 0);
const firstDayOfWeek = firstDay.getDay();
const prevMonthDays = firstDayOfWeek;
const totalDays = lastDay.getDate();
const days = [];
// 添加空白格子
for (let i = 0; i < prevMonthDays; i++) {
days.push({});
}
// 添加当月日期
for (let i = 1; i <= totalDays; i++) {
const dateStr = `${year}-${(month + 1).toString().padStart(2, '0')}-${i.toString().padStart(2, '0')}`;
const record = this.clockRecordList.find(item => item.date === dateStr);
days.push({
date: new Date(year, month, i),
clockState: record ? record.clockState : null
});
}
return days;
}
},
watch: {
accountId: {
immediate: true,
handler(newVal) {
if (newVal) {
this.getList();
}
}
}
},
methods: {
isToday(date) {
if (!date) return false;
const today = new Date();
return date.getDate() === today.getDate() &&
date.getMonth() === today.getMonth() &&
date.getFullYear() === today.getFullYear();
},
handleDateChange() {
this.getList();
},
/** 查询打卡列表 */
getList() {
if (!this.accountId) return;
this.loading = true;
const params = {
accountId: this.accountId,
date: this.selectedDate // 传入当月第一天
};
listClockInfo(params).then(response => {
if (response.data) {
this.clockRecordList = response.data.clockRecordList || [];
this.clockSummary = {
clockDays: response.data.clockDay || 0,
noRecordDays: response.data.noRecordDay || 0
};
}
}).catch(error => {
console.error("获取打卡记录失败:", error);
this.clockRecordList = [];
this.clockSummary = { clockDays: 0, noRecordDays: 0 };
}).finally(() => {
this.loading = false;
});
}
}
};
</script>
<style scoped>
.calendar-container {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 0 auto;
border: 1px solid #ddd;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.calendar-header {
background-color: #4a90e2;
color: white;
padding: 15px;
text-align: center;
}
.header-controls {
display: flex;
justify-content: center;
align-items: center;
gap: 20px;
margin-bottom: 10px;
}
.header-controls h2 {
margin: 0;
}
.calendar-weekdays {
display: grid;
grid-template-columns: repeat(7, 1fr);
background-color: #f5f5f5;
padding: 10px 0;
text-align: center;
font-weight: bold;
}
.calendar-days {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 1px;
background-color: #eee;
}
.day {
min-height: 80px;
padding: 5px;
background-color: white;
position: relative;
}
.day.empty {
background-color: #f9f9f9;
}
.day-content {
display: flex;
flex-direction: column;
height: 100%;
}
.day-number {
font-size: 14px;
font-weight: bold;
margin-bottom: 5px;
}
.clock-status {
font-size: 20px;
margin-top: auto;
text-align: center;
}
.today {
background-color: #e6f7ff;
border: 1px solid #4a90e2;
}
.clocked {
background-color: #e8f5e9;
}
.clocked .clock-status {
color: #4caf50;
}
.not-clocked {
background-color: #ffebee;
}
.not-clocked .clock-status {
color: #f44336;
}
.calendar-summary {
display: flex;
justify-content: space-around;
padding: 10px;
background-color: #f5f5f5;
border-top: 1px solid #ddd;
}
</style>
......@@ -22,14 +22,14 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="登记车牌" prop="plateNumber">
<el-input
v-model="queryParams.plateNumber"
placeholder="请输入登记车牌"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="登记车牌" prop="plateNumber">-->
<!-- <el-input-->
<!-- v-model="queryParams.plateNumber"-->
<!-- placeholder="请输入登记车牌"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item label="订单类型" prop="orderType">
<el-select v-model="queryParams.orderType" placeholder="请选择订单类型" clearable>
<el-option
......@@ -50,7 +50,7 @@
/>
</el-select>
</el-form-item>
<el-form-item label="支付流水号" prop="outTradeNo">
<el-form-item label="流水号" prop="outTradeNo">
<el-input
v-model="queryParams.outTradeNo"
placeholder="请输入支付流水号"
......@@ -117,7 +117,7 @@
<el-table-column label="小区名称" align="center" prop="communityName" />
<el-table-column label="业主名称" align="center" prop="proprietorName" />
<el-table-column label="业主户号" align="center" prop="room" />
<el-table-column label="登记车牌" align="center" prop="plateNumber" />
<!-- <el-table-column label="登记车牌" align="center" prop="plateNumber" />-->
<el-table-column label="订单类型" align="center" prop="orderType">
<template slot-scope="scope">
<dict-tag :options="dict.type.wx_live_bill_type" :value="scope.row.orderType"/>
......
......@@ -448,15 +448,15 @@ export default {
yearMoney: [
{ required: true, message: "物业年费不能为空", trigger: "blur" }
],
birthDate: [
{ required: true, message: "出生日期不能为空", trigger: "blur" }
],
// birthDate: [
// { required: true, message: "出生日期不能为空", trigger: "blur" }
// ],
identityCard: [
{ required: true, message: "身份证号不能为空", trigger: "blur", validator: authIdentityCard }
],
registerAddress: [
{ required: true, message: "户籍地不能为空", trigger: "blur" }
],
// registerAddress: [
// { required: true, message: "户籍地不能为空", trigger: "blur" }
// ],
}
};
},
......@@ -558,7 +558,7 @@ export default {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.id != null) {
if (this.form.proprietorId != null) {
updateProprietorLedger(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment