检验二维码是否使用,增加二维码失效功能 & fixbug 未超过半小时只收一半钱
This commit is contained in:
@@ -26,4 +26,7 @@ public interface BarcodeMapper {
|
||||
|
||||
@NoPlatform
|
||||
Barcode checkCodeStatus(@Param("barcode") String barcode);
|
||||
|
||||
@NoPlatform
|
||||
Barcode checkIsUsed(@Param("barcode") String barcode);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ import org.apache.ibatis.annotations.Param;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户入场订单
|
||||
*/
|
||||
public interface BarcodeOrderTimeMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
@@ -33,4 +36,6 @@ public interface BarcodeOrderTimeMapper {
|
||||
List<MemberEnterOrderDTO> memberOrderEnterList(@Param("memberId") Integer memberId);
|
||||
|
||||
MemberEnterOrderDTO memberOrderEnterDetail(@Param("memberId") Integer memberId,@Param("enterId") Integer enterId);
|
||||
|
||||
List<MemberEnterOrderDTO> findAll(@Param("starTime") String starTime,@Param("endTime") String endTime,@Param("orderSn") String orderSn,@Param("state") Integer state);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ public interface MemberEnterVenueLogMapper {
|
||||
* @return 篮球进场订单集合
|
||||
*/
|
||||
List<MemberEnterVenueLog> findAlls(@Param("payStatus") Integer payStatus,@Param("memberId") Integer memberId,
|
||||
@Param("starTime") String starTime, @Param("endTime") String endTime,
|
||||
@Param("orderSn") String orderSn, @Param("payType") Integer payType, @Param("venueId")Integer venueId);
|
||||
|
||||
|
||||
@@ -78,4 +77,4 @@ public interface MemberEnterVenueLogMapper {
|
||||
|
||||
List<MemberEnterVenueLog> findMemberEnterLogByDate(@Param("memberId") Integer memberId,@Param("venueId") Integer venueId,@Param("date") String date);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.ydd.framework.core.common.utils.ValidationUtils;
|
||||
import com.ydd.framework.core.exception.ServiceException;
|
||||
import com.ydd.framework.core.service.impl.BaseServiceImpl;
|
||||
import com.ydd.oms.entity.enums.PayStatusEnum;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -156,15 +157,16 @@ public class VenueEnterService extends BaseServiceImpl {
|
||||
throw new ServiceException(ExceptionCodeTemplate.VENUE_ERROR);
|
||||
}
|
||||
// 按时出场选择按照分钟四舍五入到角扣款
|
||||
BigDecimal basePrice = venuePriceEnter.getPrice();
|
||||
price = venuePriceEnter.getPrice();
|
||||
int minutes = DateUtilCard.diffMinute(lastOrder.getOrderStart(), dateNow);
|
||||
int hours = minutes / 60;
|
||||
// 需要补收的价格
|
||||
price = price.multiply(new BigDecimal(hours - 1)); // 此处修改押金小时数
|
||||
int mod = new BigDecimal(minutes).divideAndRemainder(new BigDecimal(60))[1].intValue();
|
||||
if (hours >= 1 && mod <= 30) {
|
||||
if (hours >= 1 && mod <= 30 && basePrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 超过一个小时 且不满半小时,只收一半的钱
|
||||
price = price.subtract(price.divide(new BigDecimal(2)).setScale(1,BigDecimal.ROUND_HALF_UP));
|
||||
price = price.subtract(basePrice.divide(new BigDecimal(2)).setScale(1,BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
logger.info("用户出场$" + memberId + "$经过时间为" + minutes + "分钟,价格为:"+ price);
|
||||
if (price.compareTo(BigDecimal.ZERO) > 0 ) {
|
||||
@@ -175,6 +177,7 @@ public class VenueEnterService extends BaseServiceImpl {
|
||||
} else {
|
||||
// 不需要补交钱且需要退钱
|
||||
lastOrder.setPayMoney(price.abs().intValue());
|
||||
lastOrder.setSumPayMoney(price.abs().intValue());
|
||||
barcodeOrderTimeMapper.updateByPrimaryKey(lastOrder);
|
||||
result.setFlg(888);
|
||||
result.setMsg("如要继续订单,请在10分钟内进入,否则将结束订单");
|
||||
@@ -326,4 +329,29 @@ public class VenueEnterService extends BaseServiceImpl {
|
||||
return memberEnterOrderDTO;
|
||||
}
|
||||
|
||||
public void enterOrderAccount(Integer enterId, Integer payMoney) {
|
||||
BarcodeOrderTime barcodeOrder = barcodeOrderTimeMapper.selectByPrimaryKey(enterId);
|
||||
if (barcodeOrder == null) {
|
||||
throw new ServiceException("订单不存在!");
|
||||
}
|
||||
if (1 == barcodeOrder.getPaying()) {
|
||||
throw new ServiceException("订单正在结算,无法结算!");
|
||||
}
|
||||
if (barcodeOrder.getPayMoney() <=0 ) {
|
||||
throw new ServiceException("退款金额不能为负数!");
|
||||
}
|
||||
String orderSn = barcodeOrder.getOrderSn();
|
||||
String orderAddSn = barcodeOrder.getOrderAddSn();
|
||||
if (!StringUtils.isEmpty(orderAddSn)) {
|
||||
throw new ServiceException("订单多次支付(使用超时),无法进行退款!");
|
||||
}
|
||||
Order baseOrder = orderMapper.findByOrderSn(orderSn);
|
||||
if ((barcodeOrder.getSumPayMoney() + payMoney) > baseOrder.getPrice().intValue()) {
|
||||
throw new ServiceException("退款金额不能超过总支付金额!");
|
||||
}
|
||||
barcodeOrder.setSumPayMoney(barcodeOrder.getSumPayMoney() + payMoney);
|
||||
barcodeOrder.setPaying(1);
|
||||
barcodeOrder.setPayMoney(payMoney); // 此次支付金额
|
||||
barcodeOrderTimeMapper.updateByPrimaryKey(barcodeOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@ package com.sv.service.common;
|
||||
|
||||
import com.enums.BarCodeStatusEnum;
|
||||
import com.enums.EnterEnum;
|
||||
import com.sv.dto.api.BarcodeDTO;
|
||||
import com.sv.entity.Barcode;
|
||||
import com.sv.entity.BarcodeOrderTime;
|
||||
import com.sv.mapper.BarcodeMapper;
|
||||
import com.sv.mapper.BarcodeOrderTimeMapper;
|
||||
import com.sv.netty.utils.MakeCode;
|
||||
import com.ydd.framework.core.exception.ServiceException;
|
||||
import com.ydd.framework.core.service.impl.BaseServiceImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -27,6 +31,8 @@ public class BarcodeService extends BaseServiceImpl {
|
||||
|
||||
@Resource
|
||||
BarcodeMapper barcodeMapper;
|
||||
@Resource
|
||||
BarcodeOrderTimeMapper barcodeOrderTimeMapper;
|
||||
|
||||
public String newBarcode (String deviceName, String orderSn, EnterEnum enterEnum, Integer venueId, Integer memberId){
|
||||
String barcode = "";
|
||||
@@ -47,5 +53,21 @@ public class BarcodeService extends BaseServiceImpl {
|
||||
}
|
||||
return barcode;
|
||||
}
|
||||
|
||||
public BarcodeDTO isUsed(String barcode){
|
||||
BarcodeDTO barcodeDTO = new BarcodeDTO();
|
||||
barcodeDTO.setUsed(false);
|
||||
Barcode code = barcodeMapper.checkIsUsed(barcode);
|
||||
if (code == null) {
|
||||
logger.error("二维码不存在!!!");
|
||||
throw new ServiceException("二维码不存在!");
|
||||
}
|
||||
if (BarCodeStatusEnum.USED.value == code.getStatus()){
|
||||
barcodeDTO.setUsed(true);
|
||||
BarcodeOrderTime lastEnterOrder = barcodeOrderTimeMapper.findLastOrder(code.getMemberId(), code.getVenueId());
|
||||
barcodeDTO.setEnterId(lastEnterOrder.getId());
|
||||
}
|
||||
return barcodeDTO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.sv.service.oms;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.sv.entity.MemberEnterVenueLog;
|
||||
import com.sv.mapper.BarcodeOrderTimeMapper;
|
||||
import com.sv.mapper.MemberEnterVenueLogMapper;
|
||||
import com.ydd.framework.core.common.Pagination;
|
||||
import com.ydd.framework.core.service.impl.BaseServiceImpl;
|
||||
@@ -26,6 +27,8 @@ public class MemberEnterVenueLogService extends BaseServiceImpl {
|
||||
|
||||
@Resource
|
||||
private MemberEnterVenueLogMapper memberEnterVenueLogMapper;
|
||||
@Resource
|
||||
private BarcodeOrderTimeMapper barcodeOrderTimeMapper;
|
||||
|
||||
/**
|
||||
* 创建篮球进场订单
|
||||
@@ -95,6 +98,18 @@ public class MemberEnterVenueLogService extends BaseServiceImpl {
|
||||
return memberEnterVenueLogMapper.findById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询篮球进场订单
|
||||
*
|
||||
* @param orderId 篮球订单的订单主键
|
||||
* @return 篮球进场订单
|
||||
*/
|
||||
public Pagination findByOrderNo(Pagination pagination, String orderId) {
|
||||
PageHelper.startPage(pagination.getPage(), pagination.getPageSize());
|
||||
pagination.setQueryResult(memberEnterVenueLogMapper.findAlls(null,null,orderId,null,null));
|
||||
return pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询篮球进场订单
|
||||
*
|
||||
@@ -102,11 +117,12 @@ public class MemberEnterVenueLogService extends BaseServiceImpl {
|
||||
* @return 分页结果
|
||||
*/
|
||||
|
||||
public Pagination findPage(Pagination pagination, Integer payStatus, Integer memberId, String starTime,
|
||||
String endTime, String orderSn, Integer payType,Integer venueId) {
|
||||
public Pagination findPage(Pagination pagination, String starTime,
|
||||
String endTime, String orderSn, Integer state) {
|
||||
PageHelper.startPage(pagination.getPage(), pagination.getPageSize());
|
||||
PageHelper.orderBy("id desc");
|
||||
pagination.setQueryResult(memberEnterVenueLogMapper.findAlls(payStatus, memberId, starTime, endTime, orderSn, payType,venueId));
|
||||
pagination.setQueryResult(barcodeOrderTimeMapper.findAll(starTime,
|
||||
endTime, orderSn, state));
|
||||
// pagination.setQueryResult(memberEnterVenueLogMapper.findAlls(payStatus, memberId, starTime, endTime, orderSn, payType,venueId));
|
||||
return pagination;
|
||||
}
|
||||
|
||||
|
||||
@@ -187,4 +187,11 @@
|
||||
and status = 0
|
||||
</select>
|
||||
|
||||
<select id="checkIsUsed" resultMap="BaseResultMap" parameterType="String" >
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from sv_barcode
|
||||
where barcode = #{barcode,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -15,12 +15,13 @@
|
||||
<arg column="status" jdbcType="INTEGER" javaType="java.lang.Integer" />
|
||||
<arg column="paying" jdbcType="INTEGER" javaType="java.lang.Integer" />
|
||||
<arg column="pay_money" jdbcType="INTEGER" javaType="java.lang.Integer" />
|
||||
<arg column="sum_pay_money" jdbcType="INTEGER" javaType="java.lang.Integer" />
|
||||
<arg column="order_sn" jdbcType="VARCHAR" javaType="java.lang.String" />
|
||||
<arg column="order_add_sn" jdbcType="VARCHAR" javaType="java.lang.String" />
|
||||
</constructor>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List" >
|
||||
id, member_id, venue_id, created_time, modified_time, order_start, order_end, last_enter, last_out, status, paying, pay_money, order_sn,order_add_sn
|
||||
id, member_id, venue_id, created_time, modified_time, order_start, order_end, last_enter, last_out, status, paying, pay_money, sum_pay_money, order_sn,order_add_sn
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
|
||||
select
|
||||
@@ -35,12 +36,12 @@
|
||||
<insert id="insert" parameterType="com.sv.entity.BarcodeOrderTime" >
|
||||
insert into sv_barcode_order_time (id, member_id, venue_id,
|
||||
created_time, modified_time, order_start,
|
||||
order_end, last_enter, last_out, status,paying ,pay_money,order_sn,order_add_sn)
|
||||
order_end, last_enter, last_out, status,paying ,pay_money,sum_pay_money,order_sn,order_add_sn)
|
||||
values (#{id,jdbcType=INTEGER}, #{memberId,jdbcType=INTEGER}, #{venueId,jdbcType=INTEGER},
|
||||
#{createdTime,jdbcType=TIMESTAMP}, #{modifiedTime,jdbcType=TIMESTAMP}, #{orderStart,jdbcType=TIMESTAMP},
|
||||
#{orderEnd,jdbcType=TIMESTAMP}, #{lastEnter,jdbcType=TIMESTAMP}, #{lastOut,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER},
|
||||
#{paying,jdbcType=INTEGER},#{payMoney,jdbcType=INTEGER}, #{orderSn,jdbcType=VARCHAR}
|
||||
,#{orderAddSn,jdbcType=VARCHAR})
|
||||
#{paying,jdbcType=INTEGER},#{payMoney,jdbcType=INTEGER}, #{sumPayMoney,jdbcType=INTEGER},
|
||||
#{orderSn,jdbcType=VARCHAR},#{orderAddSn,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.sv.entity.BarcodeOrderTime" >
|
||||
insert into sv_barcode_order_time
|
||||
@@ -81,6 +82,9 @@
|
||||
<if test="payMoney != null" >
|
||||
pay_money,
|
||||
</if>
|
||||
<if test="sumPayMoney != null" >
|
||||
sum_pay_money,
|
||||
</if>
|
||||
<if test="orderSn != null" >
|
||||
order_sn,
|
||||
</if>
|
||||
@@ -125,6 +129,9 @@
|
||||
<if test="payMoney != null" >
|
||||
#{payMoney,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="sumPayMoney != null" >
|
||||
#{sumPayMoney,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="orderSn != null" >
|
||||
#{orderSn,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@@ -169,6 +176,9 @@
|
||||
<if test="payMoney != null" >
|
||||
pay_money = #{payMoney,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="sumPayMoney != null" >
|
||||
sum_pay_money = #{sumPayMoney,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="orderSn != null" >
|
||||
order_sn = #{orderSn,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@@ -191,6 +201,7 @@
|
||||
status = #{status,jdbcType=INTEGER},
|
||||
paying = #{paying,jdbcType=INTEGER},
|
||||
pay_money = #{payMoney,jdbcType=INTEGER},
|
||||
sum_pay_money = #{sumPayMoney,jdbcType=INTEGER},
|
||||
order_sn = #{orderSn,jdbcType=VARCHAR},
|
||||
order_add_sn = #{orderAddSn,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
@@ -271,7 +282,7 @@
|
||||
where ot.member_id = #{memberId,jdbcType=INTEGER} and (ot.order_sn = t.order_sn or ot.order_sn = t.order_add_sn)
|
||||
) as price,
|
||||
t.paying,
|
||||
t.pay_money as payMoney,
|
||||
IFNULL(t.sum_pay_money,0) as payMoney,
|
||||
t.order_sn as orderSn,
|
||||
t.`status`,
|
||||
t.created_time as createTime,
|
||||
@@ -284,4 +295,45 @@
|
||||
and t.id = #{enterId,jdbcType=INTEGER}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultType="com.sv.dto.api.MemberEnterOrderDTO">
|
||||
select
|
||||
t.id as id,
|
||||
(select ue.`name` from sv_venue ue where ue.id = t.venue_id) as lessonName,
|
||||
t.last_enter as lastEnter,
|
||||
t.order_start as startTime,
|
||||
t.last_out as endTime,
|
||||
m.nickname,
|
||||
m.mobile,
|
||||
(select IFNULL(sum(ot.price),0) from sv_order ot
|
||||
where ot.member_id = t.member_id and (ot.order_sn = t.order_sn or ot.order_sn = t.order_add_sn)
|
||||
) as price,
|
||||
t.paying,
|
||||
IFNULL(t.sum_pay_money,0) as payMoney,
|
||||
t.order_sn as orderSn,
|
||||
(case when t.`status` = 0 then t.paying else 2 end) as `status`,
|
||||
t.created_time as createTime,
|
||||
1 as payType
|
||||
from sv_barcode_order_time t LEFT JOIN sv_member m on t.member_id = m.id
|
||||
where 1=1
|
||||
<if test="state != null and state == 2">
|
||||
AND (t.status = 1 or t.paying = #{state})
|
||||
</if>
|
||||
<if test="state != null and state == 1">
|
||||
AND t.paying = #{state}
|
||||
</if>
|
||||
<if test="state != null and state == 0">
|
||||
AND t.paying = #{state} and t.status = 0
|
||||
</if>
|
||||
<if test="orderSn != ''">
|
||||
AND t.order_sn = #{orderSn}
|
||||
</if>
|
||||
<if test="starTime != ''">
|
||||
AND t.order_start >= #{starTime}
|
||||
</if>
|
||||
<if test="endTime != ''">
|
||||
AND t.order_start <= #{endTime}
|
||||
</if>
|
||||
order by t.order_start desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -122,12 +122,6 @@
|
||||
<if test="orderSn != ''">
|
||||
AND smevl.order_sn = #{orderSn}
|
||||
</if>
|
||||
<if test="starTime != ''">
|
||||
AND so.created_time >= #{starTime}
|
||||
</if>
|
||||
<if test="endTime != ''">
|
||||
AND so.created_time <= #{endTime}
|
||||
</if>
|
||||
<if test="payType != null">
|
||||
AND smevl.pay_type = #{payType}
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user