mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-09 04:20:08 +08:00
update
This commit is contained in:
@@ -10,12 +10,10 @@ import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.OrderPileOccupy;
|
||||
import com.jsowell.pile.dto.GenerateOccupyOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryOccupyOrderDTO;
|
||||
import com.jsowell.pile.service.IPileBillingTemplateService;
|
||||
import com.jsowell.pile.service.OrderPileOccupyService;
|
||||
import com.jsowell.pile.vo.uniapp.OccupyOrderDetailVO;
|
||||
import com.jsowell.pile.vo.uniapp.OrderPileOccupyVO;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -108,4 +106,33 @@ public class OccupyOrderController extends BaseController {
|
||||
logger.info("查询占桩订单详情页 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户是否有未支付的占桩订单
|
||||
* https://api.jsowellcloud.com/uniapp/occupyOrder/getUnPayOccupyOrder
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getUnPayOccupyOrder")
|
||||
public RestApiResponse<?> getUnPayOccupyOrder(HttpServletRequest request) {
|
||||
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
RestApiResponse<?> response = null;
|
||||
logger.info("查询用户: {} 是否有未支付的占桩订单", memberId);
|
||||
try {
|
||||
OrderPileOccupy orderPileOccupy = orderPileOccupyService.queryUnPayOrderByMemberId(memberId);
|
||||
if (orderPileOccupy != null) {
|
||||
response = new RestApiResponse<>(ImmutableMap.of("occupyOrder", orderPileOccupy.getOccupyCode()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("查询用户: {} 是否有未支付的占桩订单 error,", memberId);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("查询用户: {} 是否有未支付的占桩订单 result:{}", memberId, response);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public interface OrderPileOccupyMapper {
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
List<OrderPileOccupy> queryUnPayOrderByMemberId(@Param("memberId") String memberId);
|
||||
List<OrderPileOccupy> queryHangUpOrderByMemberId(@Param("memberId") String memberId);
|
||||
|
||||
/**
|
||||
* 查询占桩订单列表
|
||||
@@ -106,4 +106,11 @@ public interface OrderPileOccupyMapper {
|
||||
* @param occupyCode
|
||||
*/
|
||||
OccupyOrderDetailVO getOccupyOrderDetail(String occupyCode);
|
||||
|
||||
/**
|
||||
* 通过memberId查询未支付状态订单
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
OrderPileOccupy queryUnPayOrderByMemberId(String memberId);
|
||||
}
|
||||
@@ -56,7 +56,14 @@ public interface OrderPileOccupyService{
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
List<OrderPileOccupy> queryUnPayOrderByMemberId(String memberId);
|
||||
List<OrderPileOccupy> queryHangUpOrderByMemberId(String memberId);
|
||||
|
||||
/**
|
||||
* 通过memberId查询未支付状态订单
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
OrderPileOccupy queryUnPayOrderByMemberId(String memberId);
|
||||
|
||||
Map<String, Object> payOccupyPileOrder(PayOrderDTO dto);
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.jsowell.pile.vo.base.PileInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.MemberVO;
|
||||
import com.jsowell.pile.vo.uniapp.OccupyOrderDetailVO;
|
||||
import com.jsowell.pile.vo.uniapp.OrderPileOccupyVO;
|
||||
import com.jsowell.pile.vo.uniapp.OrderVO;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import com.jsowell.pile.vo.web.OrderListVO;
|
||||
import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO;
|
||||
@@ -240,7 +239,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
}
|
||||
|
||||
// 占桩时长
|
||||
long occupyTime = DateUtils.intervalTime(startTime, endTime);
|
||||
long occupyTime = DateUtils.intervalTime(startTime, endTime); // 22
|
||||
if (freeTime > occupyTime) {
|
||||
log.info("计算占桩订单金额-站点:{}的占桩订单:{}, 免费时长:{}大于占桩时长:{}, 不收取占桩费用", orderPileOccupy.getStationId(), occupyCode, freeTime, occupyTime);
|
||||
return resultAmount;
|
||||
@@ -269,15 +268,16 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
continue;
|
||||
}
|
||||
long l = DateUtils.intervalTime(chargeStartTime, chargeEndTime);
|
||||
sumChargingTime = sumChargingTime + l;
|
||||
sumChargingTime = sumChargingTime + l; // 17
|
||||
}
|
||||
|
||||
/*
|
||||
计算应收金额
|
||||
应收金额 = (总占用时长 - (免费时长 + 充电时长)) * 占桩费率
|
||||
*/
|
||||
BigDecimal totalOccupyTime = new BigDecimal(occupyTime + "");
|
||||
BigDecimal totalFreeTime = new BigDecimal(freeTime).add(new BigDecimal(sumChargingTime));
|
||||
BigDecimal totalOccupyTime = new BigDecimal(occupyTime + ""); // 22
|
||||
BigDecimal totalFreeTime = new BigDecimal(freeTime).add(new BigDecimal(sumChargingTime)); // 27
|
||||
log.info("totalOccupyTime:{}, totalFreeTime:{}", totalOccupyTime, totalFreeTime);
|
||||
if (totalFreeTime.compareTo(totalOccupyTime) >= 0) {
|
||||
log.info("计算占桩订单金额-站点:{}的占桩订单:{}, 总免费时长:{}大于占桩时长:{}, 不收取占桩费用", orderPileOccupy.getStationId(), occupyCode, totalFreeTime, totalOccupyTime);
|
||||
return resultAmount;
|
||||
@@ -288,11 +288,27 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
return resultAmount;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
long l = DateUtils.intervalTime("2023-08-21 17:19:06", "2023-08-21 17:36:56");
|
||||
long l2 = DateUtils.intervalTime("2023-08-21 17:16:56", "2023-08-21 17:38:18");
|
||||
System.out.println(l2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据会员id查询挂起状态占桩订单
|
||||
*/
|
||||
@Override
|
||||
public List<OrderPileOccupy> queryUnPayOrderByMemberId(String memberId) {
|
||||
public List<OrderPileOccupy> queryHangUpOrderByMemberId(String memberId) {
|
||||
return orderPileOccupyMapper.queryHangUpOrderByMemberId(memberId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过memberId查询未支付状态订单
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public OrderPileOccupy queryUnPayOrderByMemberId(String memberId) {
|
||||
return orderPileOccupyMapper.queryUnPayOrderByMemberId(memberId);
|
||||
}
|
||||
|
||||
|
||||
@@ -818,7 +818,7 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryUnPayOrderByMemberId" resultMap="BaseResultMap">
|
||||
<select id="queryHangUpOrderByMemberId" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from order_pile_occupy
|
||||
@@ -887,5 +887,20 @@
|
||||
left join pile_station_info t2 on t1.station_id = t2.id
|
||||
where
|
||||
t1.member_id = #{memberId,jdbcType=VARCHAR}
|
||||
order by t1.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="queryUnPayOrderByMemberId" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from
|
||||
order_pile_occupy
|
||||
where
|
||||
del_flag = '0'
|
||||
and
|
||||
pay_status = '0'
|
||||
and member_id = #{memberId,jdbcType=VARCHAR}
|
||||
order by create_time desc
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user