暂停记录优化,改成弹窗,证件验证方法优化

This commit is contained in:
xiezhijun 2021-01-14 17:40:19 +08:00
parent 0857197c65
commit c705665b45
10 changed files with 171 additions and 33 deletions

View File

@ -1,6 +1,5 @@
package com.stdiet.web.controller.custom;
import java.text.SimpleDateFormat;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@ -77,6 +76,10 @@ public class SysOrderPauseController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SysOrderPause sysOrderPause)
{
int count = sysOrderPauseService.getCountByOrderIdAndPauseDate(sysOrderPause);
if(count > 0){
return AjaxResult.error("时间范围重叠,请检查时间");
}
return toAjax(sysOrderPauseService.insertSysOrderPause(sysOrderPause));
}
@ -88,6 +91,10 @@ public class SysOrderPauseController extends BaseController
@PutMapping
public AjaxResult edit(@RequestBody SysOrderPause sysOrderPause)
{
int count = sysOrderPauseService.getCountByOrderIdAndPauseDate(sysOrderPause);
if(count > 0){
return AjaxResult.error("时间范围重叠,请检查时间");
}
return toAjax(sysOrderPauseService.updateSysOrderPause(sysOrderPause));
}

View File

@ -2,6 +2,7 @@ package com.stdiet.custom.mapper;
import java.util.List;
import com.stdiet.custom.domain.SysOrderPause;
import org.apache.ibatis.annotations.Param;
/**
* 订单服务暂停Mapper接口
@ -58,4 +59,11 @@ public interface SysOrderPauseMapper
* @return 结果
*/
public int deleteSysOrderPauseByIds(Long[] ids);
/**
* 根据订单ID时间范围查询数量
* @param sysOrderPause
* @return
*/
int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause);
}

View File

@ -58,4 +58,11 @@ public interface ISysOrderPauseService
* @return 结果
*/
public int deleteSysOrderPauseById(Long id);
/**
* 根据订单ID时间范围查询数量
* @param sysOrderPause
* @return
*/
int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause);
}

View File

@ -67,12 +67,9 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
SysOrderPause sysOrderPause = new SysOrderPause();
sysOrderPause.setOrderId(orderId);
List<SysOrderPause> pausesList = sysOrderPauseMapper.selectSysOrderPauseList(sysOrderPause);
//每年每月暂停天数key为年份加月份:2021年1月=20211
Map<String, Integer> everyYearMonthPauseDay = getEveryYearMonthPauseDay(pausesList);
//该笔订单暂停总天数
int pauseTotalDay = getTotalByMap(everyYearMonthPauseDay);
return getServerEndDate(DateUtils.dateToLocalDate(sysOrder.getStartTime()), sysOrder.getServeTimeId().intValue()/30, sysOrder.getGiveServeDay(), pauseTotalDay);
sysOrder.setOrderPauseList(pausesList);
SysOrderCommisionDayDetail sysOrderCommisionDayDetail = statisticsOrderMessage(sysOrder);
return sysOrderCommisionDayDetail.getServerEndDate();
}
return null;
}
@ -245,14 +242,16 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
int serverMonth = sysOrder.getServeTimeId().intValue()/30;
//赠送时长
int giveDay = sysOrder.getGiveServeDay().intValue();
//服务到期时间加赠送时间不加暂停时间
LocalDate serverEndDate = serverStartDate.plusMonths(serverMonth).plusDays(giveDay);
//订单金额
BigDecimal orderAmount = sysOrder.getAmount();
//每年每月暂停天数key为年份加月份:2021年1月=20211
Map<String, Integer> everyYearMonthPauseDay = getEveryYearMonthPauseDay(sysOrder.getOrderPauseList());
Map<String, Integer> everyYearMonthPauseDay = getEveryYearMonthPauseDay(sysOrder.getOrderPauseList(), serverStartDate, serverEndDate);
//该笔订单暂停总天数
int pauseTotalDay = getTotalByMap(everyYearMonthPauseDay);
//根据开始时间服务月数赠送天数暂停天数算出该笔订单服务到期时间
LocalDate serverEndDate = getServerEndDate(serverStartDate, serverMonth, giveDay, pauseTotalDay);
//服务到期时间加上暂停时间
serverEndDate = serverEndDate.plusDays(pauseTotalDay);
//计算每年每月服务天数
Map<String, Integer> everyYearMonthServerDay = getEveryYearMonthDayCount(serverStartDate, serverEndDate, everyYearMonthPauseDay);
//服务总天数
@ -282,25 +281,45 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
* 获取每年每月暂停天数
* @Param list 暂停记录集合
* */
public Map<String, Integer> getEveryYearMonthPauseDay(List<SysOrderPause> list){
public Map<String, Integer> getEveryYearMonthPauseDay(List<SysOrderPause> list, LocalDate serverStartDate, LocalDate serverEndDate){
Map<String, Integer> pauseMap = new TreeMap<>(new MyComparator());
if(list == null){
return pauseMap;
}
for (SysOrderPause sysOrderPause : list) {
if(sysOrderPause.getPauseStartDate() == null || sysOrderPause.getPauseEndDate() == null){
continue;
}
LocalDate pauseStartDate = DateUtils.dateToLocalDate(sysOrderPause.getPauseStartDate());
LocalDate pauseEndDate = DateUtils.dateToLocalDate(sysOrderPause.getPauseEndDate());
//判断暂停时间段是否在服务周期范围内
if(ChronoUnit.DAYS.between(pauseEndDate, serverStartDate) > 0 || ChronoUnit.DAYS.between(serverEndDate, pauseStartDate) > 0){
continue;
}
if(ChronoUnit.DAYS.between(pauseStartDate, serverStartDate) > 0){
pauseStartDate = serverStartDate;
}
if(ChronoUnit.DAYS.between(serverEndDate, pauseEndDate) > 0){
pauseEndDate = serverEndDate;
}
//根据暂停记录获取该条记录在每年每月的暂停天数
Map<String, Integer> orderYearMonthPauseDay = getEveryYearMonthDayCount(pauseStartDate, pauseEndDate, null);
int totalDay = 0;
//每条暂停记录的暂停天数进行汇总
for (String key : orderYearMonthPauseDay.keySet()) {
totalDay += orderYearMonthPauseDay.get(key).intValue();
if(pauseMap.containsKey(key)){
pauseMap.put(key, pauseMap.get(key) + orderYearMonthPauseDay.get(key));
}else{
pauseMap.put(key, orderYearMonthPauseDay.get(key));
}
}
//服务到期时间刷新
serverEndDate = serverEndDate.plusDays(totalDay);
}
/*for(String key : pauseMap.keySet()){
System.out.println(key+":"+pauseMap.get(key).intValue());
}*/
return pauseMap;
}
@ -422,5 +441,7 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
System.out.println(localDate.getDayOfMonth());
System.out.println(localDate.getDayOfWeek());
System.out.println(localDate.getDayOfYear());
System.out.println(ChronoUnit.DAYS.between(LocalDate.of(2021, 1,14), LocalDate.now()));
}
}

View File

@ -1,7 +1,10 @@
package com.stdiet.custom.service.impl;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.custom.service.ISysCommissionDayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysOrderPauseMapper;
@ -20,6 +23,9 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService
@Autowired
private SysOrderPauseMapper sysOrderPauseMapper;
@Autowired
private ISysCommissionDayService sysCommissionDayService;
/**
* 查询订单服务暂停
*
@ -93,4 +99,13 @@ public class SysOrderPauseServiceImpl implements ISysOrderPauseService
{
return sysOrderPauseMapper.deleteSysOrderPauseById(id);
}
/**
* 根据订单ID时间范围查询数量
* @param sysOrderPause
* @return
*/
public int getCountByOrderIdAndPauseDate(SysOrderPause sysOrderPause){
return sysOrderPauseMapper.getCountByOrderIdAndPauseDate(sysOrderPause);
}
}

View File

@ -18,6 +18,10 @@
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="baseSelectField">
id, order_id, pause_start_date, pause_end_date, reason, remarks, create_time, create_by, update_time, update_by, del_flag
</sql>
<sql id="selectSysOrderPauseVo">
select id, order_id, pause_start_date, pause_end_date, reason, remarks, create_time, create_by, update_time, update_by, del_flag from sys_order_pause sop
</sql>
@ -97,4 +101,15 @@
</foreach>
</update>
<!-- 根据订单ID、时间范围查询数量 -->
<select id="getCountByOrderIdAndPauseDate" parameterType="SysOrderPause" resultType="int">
select count(id) from sys_order_pause where del_flag = 0 and order_id = #{orderId}
AND (#{pauseStartDate} >= pause_start_date AND pause_end_date >= #{pauseStartDate}
OR #{pauseEndDate} >= pause_start_date AND pause_end_date >= #{pauseEndDate})
<if test="id != null">
and id <![CDATA[ <> ]]> #{id}
</if>
order by id desc
</select>
</mapper>

View File

@ -272,11 +272,15 @@ export function validatorIDCard(idcode, type) {
return {code: 1, msg: '校验通过'};
}
}else if(type === 4){
if(idcode != null && idcode != undefined && idcode.trim() != ""){
//暂时先放开
// 护照
// 规则: 14/15开头 + 7位数字, G + 8位数字, P + 7位数字, S/D + 7或8位数字,等
// 样本: 141234567, G12345678, P1234567
var reg = /^([a-zA-z]|[0-9]){5,17}$/;
if (reg.test(idcode) === false) {
return {code: -1, msg: '护照号不合规'};
} else {
return {code: 1, msg: '校验通过'};
}
return {code: -1, msg: '护照号格式不正确'};
}
else if (type === 5) {
// 军官证
@ -291,3 +295,7 @@ export function validatorIDCard(idcode, type) {
}
}
export function isPassPortCard(card) {
}

View File

@ -74,16 +74,16 @@
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="customerList" @selection-change="handleSelectionChange">
<el-table v-loading="loading" :data="customerList" stripe @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<!--<el-table-column label="序号" align="center" prop="id" />-->
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<el-table-column label="创建时间" align="center" prop="createTime" width="180" fixed="left">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="姓名" align="center" prop="name" width="120"/>
<el-table-column label="手机号" align="center" prop="phone" width="120"/>
<el-table-column label="姓名" align="center" prop="name" width="120" fixed="left"/>
<el-table-column label="手机号" align="center" prop="phone" width="120" fixed="left"/>
<el-table-column label="性别" align="center" prop="sign.sex" width="100">
<template slot-scope="scope">
{{scope.row.sign.sex == 0 ? `` : '女'}}
@ -218,7 +218,7 @@
<el-table-column label="售后营养师" align="center" prop="afterDietitian" />
<el-table-column label="销售人员" align="center" prop="salesman" />
<el-table-column label="负责人" align="center" prop="chargePerson" />-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120" fixed="right">
<template slot-scope="scope">
<el-button
size="mini"

View File

@ -255,6 +255,11 @@
<span>{{ parseTime(scope.row.becomeFanTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="开始时间" align="center" prop="startTime" width="120">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" width="120"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300" fixed="right">
<template slot-scope="scope">
@ -297,6 +302,15 @@
<span style="margin-right: 12px;">总计{{toThousands(this.totalAmount)}} </span>
</pagination>
<!-- 暂停记录管理 -->
<el-dialog :title="pauseTitle" v-if="openPause" :visible.sync="openPause" width="900px" append-to-body>
<span style="color:#E6A23C;font-family:PingFang SC">
注意事项
<br/>1日期包含当天2021-01-01到2021-01-07总共暂停七天2021-01-08继续服务
<br/>2每条暂停记录的时间范围不能重叠</span>
<orderPause v-bind:orderPauseId="orderPauseId"></orderPause>
</el-dialog>
<!-- 添加或修改销售订单对话框 -->
<el-dialog :title="title" :visible.sync="open" width="720px" append-to-body>
<el-row :gutter="15">
@ -554,6 +568,7 @@
<script>
import {addOrder, delOrder, exportOrder, getOptions, getOrder, listOrder, updateOrder} from "@/api/custom/order";
import dayjs from 'dayjs';
import orderPause from "./orderPause";
const beginTime = dayjs().startOf('month').format('YYYY-MM-DD');
const endTime = dayjs().format('YYYY-MM-DD');
@ -581,6 +596,10 @@
title: "",
//
open: false,
//
openPause: false,
pauseTitle: "暂停记录",
orderPauseId: null,
//
totalAmount: 0,
//
@ -716,6 +735,9 @@
}
};
},
components: {
orderPause
},
created() {
this.getList();
getOptions().then(response => {
@ -958,7 +980,10 @@
},
orderPauseManage(order) {
console.log(order.orderId);
this.$router.push({ name: 'orderPause', params: { 'orderId': order.orderId }})
this.pauseTitle = order.customer;
this.orderPauseId = order.orderId;
this.openPause = true;
//this.$router.push({ name: 'orderPause', params: { 'orderId': order.orderId }})
}
}
};

View File

@ -94,18 +94,28 @@
</template>
</el-table-column>
<el-table-column label="客户姓名" align="center" prop="customer" />-->
<el-table-column label="暂停开始日期" align="center" prop="pauseStartDate" width="180">
<el-table-column label="暂停开始日期" align="center" prop="pauseStartDate" width="120">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.pauseStartDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="暂停结束日期" align="center" prop="pauseEndDate" width="180">
<el-table-column label="暂停结束日期" align="center" prop="pauseEndDate" width="120">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.pauseEndDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="暂停理由" align="center" prop="reason" />
<el-table-column label="备注" align="center" prop="remarks" />
<el-table-column label="暂停理由" align="center" prop="reason">
<template slot-scope="scope">
<el-button v-show="scope.row.reason != null && scope.row.reason.length > 10" type="text" @click="openFormDialog('暂停理由', scope.row.reason)">点击查看</el-button>
<span v-show="scope.row.reason == null || scope.row.reason.length <= 10">{{scope.row.reason}}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remarks">
<template slot-scope="scope">
<el-button v-show="scope.row.remarks != null && scope.row.remarks.length > 10" type="text" @click="openFormDialog('备注', scope.row.remarks)">点击查看</el-button>
<span v-show="scope.row.remarks == null || scope.row.remarks.length <= 10">{{scope.row.remarks}}</span>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
@ -136,9 +146,18 @@
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:page-sizes="[5,10]"
@pagination="getList"
/>
<el-dialog :title="formDialog.title" :visible.sync="formDialog.show" width="30%" append-to-body center>
<span>{{formDialog.content}}</span>
<span slot="footer" class="dialog-footer">
<el-button @click="formDialog.show = false"> </el-button>
<!--<el-button type="primary" @click="experience_dialog = false"> </el-button>-->
</span>
</el-dialog>
<!-- 添加或修改订单服务暂停对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
@ -224,7 +243,7 @@
//
queryParams: {
pageNum: 1,
pageSize: 10,
pageSize: 5,
orderId: null,
createDate: null,
pauseEndDate: null
@ -245,15 +264,27 @@
reason: [
{required: true, message: "暂停理由不能为空", trigger: "blur"}
]
},
//
formDialog:{
title: "",
show: false,
content: ""
}
};
},
props: {
orderPauseId: {
type: Number,
default: 0
},
},
created() {
this.getList();
},
mounted() {
this.orderId = this.$route.params.orderId;
this.queryParams.orderId = this.orderId;
this.orderId = this.orderPauseId;
this.queryParams.orderId = this.orderPauseId;
},
methods: {
/** 查询订单服务暂停列表 */
@ -373,11 +404,12 @@
}).then(response => {
this.download(response.msg);
}).catch(function() {});
}
},
checkcDateScope(value){
console.log(value[0]);
return false;
openFormDialog(title, content){
this.formDialog.title = title;
this.formDialog.content = content;
this.formDialog.show = true;
}
}
};
</script>