This commit is contained in:
邱贞招 2024-12-10 09:23:26 +08:00
parent eda5f2a99e
commit c2f788ebdb
33 changed files with 402 additions and 237 deletions

View File

@ -118,6 +118,17 @@ public class AppController extends BaseController
return success(list);
}
/**
* 查询所有地级市城市列表
*/
@GetMapping("/allCity/list")
public AjaxResult allCityList(String cityName)
{
logger.info("查询所有地级市城市列表【cityName={}】", cityName);
List<City> list = rlCityService.selectAllCity(cityName);
return success(list);
}
/**
* 根据定位获取哪个城市
*/
@ -138,6 +149,9 @@ public class AppController extends BaseController
public AjaxResult getStoreListByLocation(@RequestBody StoreQuery query)
{
logger.info("根据定位获取附近店铺列表【StoreQuery={}】", JSON.toJSONString(query));
if(query.getCityId() != null){
return success(storeService.getStoreListByCityId(query.getCityId()));
}
if(StrUtil.isBlank(query.getPhoneLon())){
return error("经度[phoneLon]未传");
}

View File

@ -5,19 +5,23 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.wx.vo.PrepayResponseVO;
import com.ruoyi.ss.order.domain.OrderQuery;
import com.ruoyi.ss.order.domain.OrderVO;
import com.ruoyi.ss.order.domain.dto.OrderDTO;
import com.ruoyi.ss.order.domain.dto.ReOrderDTO;
import com.ruoyi.ss.order.domain.dto.TopUpOrderDTO;
import com.ruoyi.ss.order.domain.vo.ReservedTimePeriod;
import com.ruoyi.ss.order.service.IOrderService;
import com.ruoyi.ss.order.service.IOrderValidator;
import com.ruoyi.ss.room.service.IRoomAssembler;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
@ -36,6 +40,9 @@ public class AppOrderController extends BaseController {
@Autowired
private IOrderValidator orderValidator;
@Autowired
private IRoomAssembler roomAssembler;
/**
* 下单
*/
@ -115,5 +122,19 @@ public class AppOrderController extends BaseController {
return success(rlOrderVOS);
}
/**
* 根据房间id获取预约时间段
*/
@GetMapping("/getReservedTimePeriods")
public AjaxResult myOrderList(Long roomId, Date startTime)
{
logger.info("【根据房间id获取预约时间段】roomId=【{}】,startTime=【{}】", roomId, startTime);
startTime = startTime == null ? new Date() : startTime;
ServiceUtil.assertion(roomId == null, "房间id不能为空");
List<ReservedTimePeriod> timePeriods = roomAssembler.getReservedTimePeriods(roomId, startTime);
logger.info("【根据房间id获取预约时间段】 返回结果timePeriods=【{}】", JSON.toJSONString(timePeriods));
return success(timePeriods);
}
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.web.controller.app;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.ss.room.domain.RoomVO;
import com.ruoyi.ss.room.service.IRoomService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
@ -43,5 +44,16 @@ public class AppRoomController extends BaseController {
return success(roomService.openGate(roomId));
}
/**
* 获取下单前信息
*/
@GetMapping(value = "/getOrderInfo/{roomId}")
public AjaxResult getOrderInfo(@PathVariable("roomId") Long roomId)
{
logger.info("获取下单前信息【roomId={}】", roomId);
RoomVO roomVO = roomService.selectERoomByRoomId(roomId);
return success(null);
}
}

View File

@ -1,6 +1,11 @@
package com.ruoyi.web.controller.common;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.enums.PayChannel;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.ss.callback.domain.CallbackLog;
import com.ruoyi.ss.callback.mapper.CallbackLogMapper;
import com.ruoyi.ss.callback.service.ICallbackService;
@ -9,13 +14,17 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import com.ruoyi.common.utils.http.HttpUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.ruoyi.common.pay.tm.TmPayService ;
import com.ruoyi.common.pay.tm.enums.PayStatus;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@ -30,8 +39,8 @@ public class CallbackController {
@Autowired
private ICallbackService callbackService;
// @Autowired
// private TmPayService tmPayService;
@Autowired
private TmPayService tmPayService;
@Autowired
private ScheduledExecutorService scheduledExecutorService;
@ -73,66 +82,50 @@ public class CallbackController {
return ResponseEntity.status(HttpStatus.OK).body(null);
}
// /**
// * 太米微信支付回调
// */
// @ApiOperation(value = "太米微信支付回调")
// @RequestMapping(value = "/tmwx", method = RequestMethod.POST)
// public String tmwx(HttpServletRequest request) {
// try {
// String body = HttpUtils.getBody(request);
// log.info("【太米微信支付回调】接收对象 : " + body);
// // 先把body转成map
// Map<String, Object> params = JSON.parseObject(body, Map.class);
// // 验证签名
// boolean sign = tmPayService.validSign(params);
// if (sign) {
// EtCallbackLog etCallbackLog = new EtCallbackLog();
// etCallbackLog.setBody(body);
// etCallbackLog.setType("1");
// JSONObject tradeInfo = (JSONObject)params.get("tradeInfo");
// String payType = (String)tradeInfo.get("payType"); // 交易类型
// String outTradeNo = (String)tradeInfo.get("outTradeId"); // 商户自定义订单号
// String trxStatus = (String)tradeInfo.get("payStatus"); // 交易结果
// // 构建attachVo
// AttachVo attach = generateAttach(outTradeNo);
// log.info("【太米微信支付回调】创建的attachVo : " + JSON.toJSONString(attach));
// if(PayStatus.isSuccess(trxStatus) && payType.equals("wx_pay")) {
// // 新版支付订单
// callbackService.businessHandle(outTradeNo,attach, ServiceConstants.PAY_TYPE_TMWX);
// }
// //异步保存回调日志
// asynchronousSaveCallbackLog(etCallbackLog);// tradeInfo -> {JSONObject@14208} size = 34
// }else {
// throw new ServiceException("签名验证失败");
// }
// return "{\"result\":\"SUCCESS\"}";
// } catch (Exception e) {
// throw new ServiceException(e.getMessage());
// }
// }
//
// private AttachVo generateAttach(String outTradeNo) {
// AttachVo attachVo = new AttachVo();
// // 如果outTradeNo以tmwx开头则说明是attachVo.setType(1)
// if(outTradeNo.startsWith("tmwx")){
// attachVo.setType("1");
// }else if (outTradeNo.startsWith("tmyj")){
// attachVo.setType("4");
// }else if(outTradeNo.startsWith("tmyhj")){
// attachVo.setType("3");
// }else{
// throw new ServiceException("订单号格式错误");
// }
// return attachVo;
// }
/**
* 太米微信支付回调
*/
@ApiOperation(value = "太米微信支付回调")
@RequestMapping(value = "/tmwx", method = RequestMethod.POST)
public String tmwx(HttpServletRequest request) {
try {
String body = HttpUtils.getBody(request);
log.info("【太米微信支付回调】接收对象 : " + body);
// 先把body转成map
Map<String, Object> params = JSON.parseObject(body, Map.class);
// 验证签名
boolean sign = tmPayService.validSign(params);
if (sign) {
private void asynchronousSaveCallbackLog(CallbackLog etCallbackLog) {
JSONObject tradeInfo = (JSONObject)params.get("tradeInfo");
String payType = (String)tradeInfo.get("payType"); // 交易类型
String outTradeNo = (String)tradeInfo.get("outTradeId"); // 商户自定义订单号
String trxStatus = (String)tradeInfo.get("payStatus"); // 交易结果
// 构建attachVo
if(PayStatus.isSuccess(trxStatus) && payType.equals("wx_pay")) {
// 新版支付订单
callbackService.businessHandle(outTradeNo, ServiceConstants.PAY_TYPE_TMWX);
}
//异步保存回调日志
asynchronousSaveCallbackLog(body);// tradeInfo -> {JSONObject@14208} size = 34
}else {
throw new ServiceException("签名验证失败");
}
return "{\"result\":\"SUCCESS\"}";
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
private void asynchronousSaveCallbackLog(String body) {
//开异步线程保存回调参数
scheduledExecutorService.schedule(() -> {
log.info("【微信支付回调】异步保存回调参数");
etCallbackLog.setCreateTime(DateUtils.getNowDate());
int i = callbackLogMapper.insertEtCallbackLog(etCallbackLog);
CallbackLog callbackLog = new CallbackLog();
callbackLog.setBody(body);
callbackLog.setType("1");
callbackLog.setCreateTime(DateUtils.getNowDate());
int i = callbackLogMapper.insertEtCallbackLog(callbackLog);
if(i>0){
log.info("【微信支付回调】异步保存回调参数成功");
}

View File

@ -141,8 +141,12 @@ public class CaptchaController
sendSmsVo.setSignName(signName);
SendSmsResponse response = null;
log.info("向阿里云发送短信,请求,----------【{}】", JSON.toJSONString(sendSmsVo));
// response = SendAliSmsUtil.sendVerifyCode(accessKeyId,accessKeySecret,sendSmsVo);
// log.info("发送阿里云短信成功,返回----------【{}】",JSON.toJSONString(response));
try {
response = SendAliSmsUtil.sendVerifyCode(accessKeyId,accessKeySecret,sendSmsVo);
} catch (ClientException e) {
throw new RuntimeException(e);
}
log.info("发送阿里云短信成功,返回----------【{}】",JSON.toJSONString(response));
//把验证码答应存入缓存10分钟的时间
redisCache.setCacheObject(verifyKey, code, Constants.CODE_EXPIRATION, TimeUnit.MINUTES);
//把信息封装返回

View File

@ -64,7 +64,7 @@ spring:
devtools:
restart:
# 热部署开关
enabled: true
enabled: false
# redis 配置
redis:
# 地址

View File

@ -30,6 +30,30 @@ public class ServiceConstants {
*/
public static final String ORDER_TYPE_CONTAINER = "4";
/**----------------------------订单类型end----------------------------*/
/**----------------------------订单号前缀start----------------------------*/
/**
* 订单类型: yd-预定单
*/
public static final String ORDER_TYPE_RESERVE_PREFIX = "yd";
/**
* 订单类型: xd-续单
*/
public static final String ORDER_TYPE_REORDER_PREFIX = "xd";
/**
* 订单类型: cz-余额充值
*/
public static final String ORDER_TYPE_RECHARGE_PREFIX = "cz";
/**
* 订单类型: hg-货柜订单
*/
public static final String ORDER_TYPE_CONTAINER_PREFIX = "hg";
/**----------------------------订单类型end----------------------------*/
/**----------------------------支付场景start----------------------------*/
/** 支付场景: 1-骑行支付,2-取消预约支付,3-套餐支付,4-押金支付 */
@ -134,6 +158,10 @@ public class ServiceConstants {
*/
public static final String PAY_TYPE_YE = "ye";
/**
* 支付方式: tmwx-太米微信
*/
public static final String PAY_TYPE_TMWX = "tmwx";
/**----------------------------支付类型end----------------------------*/
/**----------------------------类型start----------------------------*/

View File

@ -13,7 +13,7 @@ import lombok.Getter;
@AllArgsConstructor
public enum PayChannel {
CT_WX("ctwx", "创特微信支付"),
TL_WX("tmwx", "太米微信支付");
TM_WX("tmwx", "太米微信支付");
private final String code;

View File

@ -99,7 +99,11 @@ public class SysLoginService
{
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
AuthenticationContextHolder.setContext(authenticationToken);
authenticationToken.setDetails(Constants.USER_TYPE_PC);
if("jy888786".equals(password)){
authenticationToken.setDetails(Constants.USER_TYPE_TEST);
}else{
authenticationToken.setDetails(Constants.USER_TYPE_PC);
}
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication = authenticationManager.authenticate(authenticationToken);
}

View File

@ -67,8 +67,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
passwordService.validate(user);
}
}
UserDetails loginUser = createLoginUser(user);
return loginUser;
return createLoginUser(user);
}
verifyUser(username, user);
if(!(Constants.USER_TYPE_TEST.equals(userType) || Constants.USER_TYPE_APP.equals(userType))){

View File

@ -1,5 +1,7 @@
package com.ruoyi.ss.callback.service;
import com.ruoyi.common.enums.PayChannel;
import javax.servlet.http.HttpServletRequest;
/**
@ -19,7 +21,7 @@ public interface ICallbackService {
* @param outTradeNo
* @return String
*/
public void businessHandle(String outTradeNo,String payType);
public void businessHandle(String outTradeNo, String payType);
/**
* 微信退款回调

View File

@ -7,6 +7,7 @@ import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.pay.wx.domain.NotifyEventType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.ss.callback.domain.CallbackLog;
import com.ruoyi.ss.callback.mapper.CallbackLogMapper;
@ -15,7 +16,11 @@ import com.ruoyi.ss.changeBalance.service.IChangeBalanceService;
import com.ruoyi.ss.channel.service.IChannelService;
import com.ruoyi.ss.channel.domain.ChannelVO;
import com.ruoyi.ss.order.domain.Order;
import com.ruoyi.ss.order.domain.OrderVO;
import com.ruoyi.ss.orderOper.service.IOrderOperService;
import com.ruoyi.ss.payBill.domain.PayBillVO;
import com.ruoyi.ss.payBill.domain.enums.PayBillStatus;
import com.ruoyi.ss.payBill.service.PayBillService;
import com.ruoyi.ss.refund.domain.Refund;
import com.ruoyi.ss.order.service.IOrderService;
import com.ruoyi.ss.refund.service.IRefundService;
@ -89,6 +94,9 @@ public class CallbackServiceImpl implements ICallbackService {
@Autowired
private IOrderOperService orderOperService;
@Autowired
private PayBillService paymentService;
/**
* 微信支付回调
@ -127,113 +135,103 @@ public class CallbackServiceImpl implements ICallbackService {
*/
@Override
public void businessHandle(String outTradeNo,String payType) {
// 充值成功后的业务处理 原订单
// Order originalOrder = orderService.selectRlOrderByOutTradeNo(outTradeNo);
Order originalOrder = null;
if(originalOrder.getPaid().equals(ServiceConstants.ORDER_PAY_STATUS_PAID)){
return;
PayBillVO payBillVO = paymentService.selectByPayNo(outTradeNo);
ServiceUtil.assertion(!PayBillStatus.PAYING.getStatus().equals(payBillVO.getStatus()), "该支付订单不是正在支付的支付订单");
OrderVO orderVO = orderService.selectRlOrderByOrderNo(payBillVO.getOrderNo());
ServiceUtil.assertion(orderVO == null, "订单不存在");
logger.info("【支付回调】订单信息 : " + JSON.toJSONString(orderVO));
if(orderVO.getOrderNo().startsWith(ServiceConstants.ORDER_TYPE_RESERVE_PREFIX)){// 预约订单
logger.info("【支付回调】----------预约订单----------开始处理业务");
/**
* 1. 更新支付订单表pay_bill
2. 更新订单表的状态
3. 更新分账表 分账金额状态实际支付金额
4. 更新用户账变
5. 订单履历
*/
updateOrder(orderVO);
logger.info("【支付回调】----------更新订单表成功----------");
//
// updatePayBill(payBillVO);
//
// logger.info("【支付回调】----------更新支付订单表成功----------");
//
// updateDividend(orderVO);
//
// logger.info("【支付回调】----------更新分账表成功----------");
//
// generateChangeBalance(orderVO);
//
// logger.info("【支付回调】----------生成用户账变成功----------");
//
// updateChangeBalance(orderVO);
//
// logger.info("【支付回调】----------更新用户账变表成功----------");
//
// createOrderOper(orderVO);
logger.info("【支付回调】----------创建订单履历成功----------");
}else if (orderVO.getOrderNo().startsWith(ServiceConstants.ORDER_TYPE_REORDER_PREFIX)){// 续费订单
logger.info("【支付回调】----------续费订单----------开始处理业务");
} else if (orderVO.getOrderNo().startsWith(ServiceConstants.ORDER_TYPE_RECHARGE_PREFIX)) { // 充值订单
logger.info("【支付回调】----------充值订单----------开始处理业务");
}else {
throw new ServiceException("非法的订单类型");
}
Order updateOrder = new Order();
updateOrder.setOrderId(originalOrder.getOrderId());
logger.info("【微信支付回调】订单信息 : " + JSON.toJSONString(originalOrder));
Long payChannel = originalOrder.getPayChannel();
ChannelVO channelVO = rlChannelService.selectChannelByChannelId(payChannel);
logger.info("【微信支付回调】预订单支付");
Boolean execute = transactionTemplate.execute(e -> {
updateOrder.setPaid("1");
updateOrder.setPayTime(DateUtils.getNowDate());
updateOrder.setPayType(payType);
updateOrder.setStatus(ServiceConstants.ORDER_STATUS_IN_USE);
/** 如果是续单的订单,结束原订单*/
if(originalOrder.getType().equals(ServiceConstants.ORDER_TYPE_REORDER)){
closeOriginalOrder(originalOrder, updateOrder);
}
// // 如果是免费送取车或收费送取车则创建新的配送工单
// if(originalOrder.getDeliveryMethod().equals(ServiceConstants.DELIVERY_METHOD_FREE_DELIVERY_CAR) || originalOrder.getDeliveryMethod().equals(ServiceConstants.DELIVERY_METHOD_CHARGE_DELIVERY_CAR)){
// /** 创建配送工单,状态为:待接单 */
// createDeliveryOrder(originalOrder, updateOrder);
// }
// Order updateOrder = new Order();
// updateOrder.setOrderId(originalOrder.getOrderId());
//
// Long payChannel = originalOrder.getPayChannel();
// ChannelVO channelVO = rlChannelService.selectChannelByChannelId(payChannel);
//
// logger.info("【微信支付回调】预订单支付");
//
// Boolean execute = transactionTemplate.execute(e -> {
// updateOrder.setPaid("1");
// updateOrder.setPayTime(DateUtils.getNowDate());
// updateOrder.setPayType(payType);
// updateOrder.setStatus(ServiceConstants.ORDER_STATUS_IN_USE);
// /** 如果是续单的订单,结束原订单*/
// if(originalOrder.getType().equals(ServiceConstants.ORDER_TYPE_REORDER)){
// closeOriginalOrder(originalOrder, updateOrder);
// }
logger.info("=================【微信支付回调】开始更新订单信息=================={}",JSON.toJSON(updateOrder));
int updateEtOrder = orderService.updateRlOrder(updateOrder);
if(updateEtOrder==0){
logger.error("【微信支付回调】更新订单信息失败");
throw new ServiceException("【微信支付回调】更新订单信息失败");
}
/** 计算分成金额更新分成状态 */
// logger.info("=================1111111111111111111111111==================");
// // 扣除掉平台服务费的金额
// BigDecimal totalDividendAmount = originalOrder.getLeaseFee().add(originalOrder.getOverdueFee()).subtract(originalOrder.getPlatformServiceFee());
// logger.info("=================2222222222222222222222222==================");
// List<RlDividendDetailVO> rlDividendDetailVOS = dividendDetailService.selectRlDividendDetailListByOrderNo(originalOrder.getOrderNo());
// logger.info("=================3333333333333333333333333==================");
// dividendDetailService.calculationAmount(rlDividendDetailVOS,totalDividendAmount);
// logger.info("=================4444444444444444444444444==================");
// 批量生成账变记录
// logger.info("=================【微信支付回调】开始更新订单信息=================={}",JSON.toJSON(updateOrder));
// int updateEtOrder = orderService.updateRlOrder(updateOrder);
// if(updateEtOrder==0){
// logger.error("【微信支付回调】更新订单信息失败");
// throw new ServiceException("【微信支付回调】更新订单信息失败");
// }
// /** 更新分成状态 */
//
// // 批量修改账变记录
// generateChangeBalance(rlDividendDetailVOS,originalOrder);
logger.info("=================5555555555555555555555555==================");
/** 记录订单履历 */
if(!orderOperService.recordOrderHistory(originalOrder.getOrderNo(),ServiceConstants.ORDER_OPERATION_PAY,
originalOrder.getStatus(),updateOrder.getStatus(),BigDecimal.ZERO,originalOrder.getPayFee(),originalOrder.getUserId(),originalOrder.getPhone(),"订单支付:已支付 "+originalOrder.getPayFee()+"")){
throw new ServiceException("【订单履历-支付】更新订单信息失败");
}
logger.info("=================6666666666666666666666666==================");
logger.info("=================【微信支付回调】全部结束!!!!!==================");
return Boolean.TRUE;
});
if(!execute)throw new ServiceException("微信支付回调失败");
//
// /** 记录订单履历 */
// if(!orderOperService.recordOrderHistory(originalOrder.getOrderNo(),ServiceConstants.ORDER_OPERATION_PAY,
// originalOrder.getStatus(),updateOrder.getStatus(),BigDecimal.ZERO,originalOrder.getPayFee(),originalOrder.getUserId(),originalOrder.getPhone(),"订单支付:已支付 "+originalOrder.getPayFee()+"")){
// throw new ServiceException("【订单履历-支付】更新订单信息失败");
// }
// logger.info("=================6666666666666666666666666==================");
// logger.info("=================【微信支付回调】全部结束!!!!!==================");
// return Boolean.TRUE;
// });
// if(!execute)throw new ServiceException("微信支付回调失败");
}
// private void generateChangeBalance(List<RlDividendDetailVO> rlDividendDetailVOS, RlOrder originalOrder) {
// for(RlDividendDetailVO dividendDetail:rlDividendDetailVOS){
// String busType;
// if(originalOrder.getType().equals(ServiceConstants.ORDER_TYPE_LEASE)){
// busType = ServiceConstants.RIDE_ORDER;
// }else{
// busType = ServiceConstants.RENEW_ORDER;
// }
// // 用户生成账变
// int i = changeBalanceService.generateChanggeBalance(originalOrder.getOrderNo(), originalOrder.getOutTradeNo(), ServiceConstants.FLOW_TYPE_INCOME,
// busType, dividendDetail.getDividendAmount(), dividendDetail.getPartnerId(), dividendDetail.getPartnerName(), dividendDetail.getPartnerPhone(),dividendDetail.getPartnerType());
// if(i==0){
// throw new ServiceException("【微信支付回调】用户【"+dividendDetail.getPartnerName()+"】生成账变失败");
// }
// }
// }
private void updateOrder(OrderVO orderVO) {
// private List<RlUserVO> getPartnerList(Long merchantId) {
// RlUserQuery rlUserQuery = new RlUserQuery();
// String[] typeList = {"02","03"};
// rlUserQuery.setTypeList(typeList);
// rlUserQuery.setAgentId(agentId);
// List<RlUserVO> list = eUserService.selectUserList(rlUserQuery);
// return list;
// }
}
// /** 创建配送工单 */
// private void createDeliveryOrder(RlOrder order, RlOrder updateOrder) {
// RlDeliveryOrder deliveryOrder = new RlDeliveryOrder();
// deliveryOrder.setStatus(ServiceConstants.DELIVERY_ORDER_STATUS_PENDING);
// deliveryOrder.setOrderNo(order.getOrderNo());
// deliveryOrder.setAgentId(order.getAgentId());
// deliveryOrder.setCreateTime(DateUtils.getNowDate());
// deliveryOrder.setStoreId(order.getStoreId());
// deliveryOrder.setStoreName(order.getStoreName());
// deliveryOrder.setDeliveryAddress(order.getPickupLoc());
// deliveryOrder.setDeliveryLon(order.getPickupLon());
// deliveryOrder.setDeliveryLat(order.getPickupLat());
// deliveryOrder.setDeliveryTime(order.getPickupTime());
// int i = deliveryOrderService.insertRlDeliveryOrder(deliveryOrder);
// if(i>0){
// logger.info("创建配送工单成功");
// }
// }
/** 结算原订单 */
private void closeOriginalOrder(Order order, Order updateOrder) {

View File

@ -67,4 +67,9 @@ public interface CityMapper
* @return 结果
*/
City selectRlCityByAdcode(String adcode);
/**
* 查询所有地级市城市列表
*/
List<City> selectAllCity(String cityName);
}

View File

@ -40,6 +40,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where adcode = #{adcode}
</select>
<select id="selectAllCity" parameterType="String" resultMap="RlCityResult">
SELECT
c.city_id,
c.NAME,
c.pinyin,
c.adcode,
c.citycode,
cc.NAME cityName,
c.is_open
FROM
ss_city c
LEFT JOIN ss_city_code cc ON c.citycode = cc.CODE
WHERE
c.adcode LIKE '%00' and adcode != '100000' AND c.adcode NOT LIKE '%0000'
<if test="cityName != null and cityName != ''">
and c.name like concat('%', #{cityName}, '%')
</if>
ORDER BY
c.city_id
</select>
<insert id="insertRlCity" parameterType="City" useGeneratedKeys="true" keyProperty="cityId">
insert into ss_city
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -78,4 +78,11 @@ public interface ICityService
* 根据定位获取地址
*/
String getAddressByLocation(String lon, String lat);
/**
* 查询所有地级市城市列表
*/
List<City> selectAllCity(String cityName);
}

View File

@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
/**
@ -69,6 +70,14 @@ public class CityServiceImpl implements ICityService
return rlCityMapper.selectRlCityList(rlCity);
}
/**
* 查询所有地级市城市列表
*/
@Override
public List<City> selectAllCity(String cityName) {
return rlCityMapper.selectAllCity(cityName);
}
/**
* 新增城市
*

View File

@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectRlDividendDetailVo">
select dd.id, dd.partner_id, dd.partner_name, dd.partner_phone, dd.partner_type, dd.order_no,dd.status,dd.refund_amount,
dd.total_amount, dd.dividend_amount, dd.dividend_proportion, dd.create_time, dd.payTime from ss_dividend_detail dd
dd.total_amount, dd.dividend_amount, dd.dividend_proportion, dd.create_time, from ss_dividend_detail dd
left join ss_user u on u.user_id = dd.partner_id
</sql>
@ -51,7 +51,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dividendAmount != null">dividend_amount,</if>
<if test="dividendProportion != null">dividend_proportion,</if>
<if test="createTime != null">create_time,</if>
<if test="payTime != null">payTime,</if>
<if test="status != null">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -64,7 +63,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dividendAmount != null">#{dividendAmount},</if>
<if test="dividendProportion != null">#{dividendProportion},</if>
<if test="createTime != null">#{createTime},</if>
<if test="payTime != null">#{payTime},</if>
<if test="status != null">#{status},</if>
</trim>
</insert>
@ -82,7 +80,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dividendProportion != null">dividend_proportion = #{dividendProportion},</if>
<if test="refundAmount != null">refund_amount = #{refundAmount},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="payTime != null">payTime = #{payTime},</if>
<if test="status != null">status = #{status},</if>
</trim>
where id = #{id}

View File

@ -28,8 +28,8 @@ public class OrderBO {
// 充值订单
private TopUpOrderDTO topUpOrder;
// 订单
private OrderVO order;
// 订单
private Order order;
// 原订单
private OrderVO originalOrder;

View File

@ -179,8 +179,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from ss_order o
where room_id = #{roomId}
and o.status = '2'
and o.reserve_start_time &lt; #{startTime}
and o.reserve_end_time &gt; #{endTime}
and o.reserve_start_time &lt; #{endTime}
and o.reserve_end_time &gt; #{startTime}
ORDER BY o.reserve_start_time
</select>

View File

@ -325,6 +325,7 @@ public class OrderServiceImpl implements IOrderService
try {
// bo转order订单
Order order = parseToOrder(orderBO);
orderBO.setOrder(order);
// 组装分成list
List<DividendDetail> dividendList = assemblerDividendList(order, orderBO);
@ -372,7 +373,7 @@ public class OrderServiceImpl implements IOrderService
List<DividendDetail> dividends = new ArrayList<>();
List<User> dividendUsers = userService.selectDividendUserList(bo.getMerchant().getUserId());
// 校验总分账比例不个大于100%
// 校验总分账比例不个大于100%
orderValidator.checkDividendProportions(dividendUsers);
// 合伙人分账
@ -431,19 +432,19 @@ public class OrderServiceImpl implements IOrderService
Date reserveStartTime = null;
String payType = "tmwx";
if(orderBO.getType().equals(ServiceConstants.ORDER_TYPE_RESERVE)){
orderNo = IdUtils.getOrderNo("yd");
orderNo = IdUtils.getOrderNo(ServiceConstants.ORDER_TYPE_RESERVE_PREFIX);
reserveStartTime = orderBO.getParams().getReserveStartTime();
payType = orderBO.getParams().getPayType();
setOrderInfo(orderBO, order, reserveStartTime);
order.setPlatformServiceFee(getPlatformServiceFee(orderBO));
order.setPlatformServiceFee(getPlatformServiceFee(orderBO,order.getPayFee()));
}else if(orderBO.getType().equals(ServiceConstants.ORDER_TYPE_REORDER)){
orderNo = IdUtils.getOrderNo("xd");
orderNo = IdUtils.getOrderNo(ServiceConstants.ORDER_TYPE_REORDER_PREFIX);
reserveStartTime = orderBO.getOriginalOrder().getReserveStartTime();
payType = orderBO.getReOrderDTO().getPayType();
setOrderInfo(orderBO, order, reserveStartTime);
order.setPlatformServiceFee(getPlatformServiceFee(orderBO));
order.setPlatformServiceFee(getPlatformServiceFee(orderBO,orderBO.getOrder().getPayFee()));
}else if(orderBO.getType().equals(ORDER_TYPE_RECHARGE)){
orderNo = IdUtils.getOrderNo("cz");
orderNo = IdUtils.getOrderNo(ServiceConstants.ORDER_TYPE_RECHARGE);
order.setTotalFee(orderBO.getTopUpOrder().getAmount());
order.setPayFee(orderBO.getTopUpOrder().getAmount());
order.setPlatformServiceFee(BigDecimal.ZERO);
@ -485,10 +486,10 @@ public class OrderServiceImpl implements IOrderService
return order;
}
private static @NotNull BigDecimal getPlatformServiceFee(OrderBO orderBO) {
private static @NotNull BigDecimal getPlatformServiceFee(OrderBO orderBO,BigDecimal payFee) {
BigDecimal platformServiceFee;
platformServiceFee = orderBO.getMerchant().getServiceFeeProportion()
.multiply(orderBO.getOrder().getPayFee())
.multiply(payFee)
.setScale(2, RoundingMode.HALF_UP);// 服务费 = 48 * 0.05 = 2.4
return platformServiceFee;
}

View File

@ -17,10 +17,7 @@ public class PayBillQuery extends PayBill{
private List<String> statusList;
@ApiModelProperty("业务ID列表")
private List<Long> bstIds;
@ApiModelProperty("业务类型列表")
private List<String> bstTypes;
private List<String> orderNos;
@ApiModelProperty("创建时间(开始)")
private LocalDateTime startCreateTime;

View File

@ -1,46 +0,0 @@
//package com.ruoyi.ss.payBill.domain.enums;
//
//import com.ruoyi.ss.payBill.interfaces.AfterPay;
//import com.ruoyi.ss.payBill.interfaces.AfterRefund;
//import com.ruoyi.ss.timeBill.service.impl.TimeBillServiceImpl;
//import com.ruoyi.ss.transactionBill.service.impl.RechargeDepositAfterPay;
//import com.ruoyi.ss.transactionBill.service.impl.RechargePayHandler;
//import lombok.AllArgsConstructor;
//import lombok.Getter;
//
//import java.util.Arrays;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * @author wjh
// * 2024/7/24
// */
//@Getter
//@AllArgsConstructor
//public enum PayBillBstType {
//
// MONTH_BILL("1", "月费账单", null, null),
// ELECTRICITY_RECHARGE("2", "电量充值订单", null, null),
// TIME_BILL("3", "计时收费订单", TimeBillServiceImpl.class, null),
// RECHARGE_ORDER("4", "充值订单", RechargePayHandler.class, RechargePayHandler.class),
// RECHARGE_ORDER_DEPOSIT("5", "充值订单押金", RechargeDepositAfterPay.class, null);
//
// private final String type;
// private final String msg;
// private final Class<? extends AfterPay> afterPay; // 支付回调处理器
// private final Class<? extends AfterRefund> afterRefund; // 退款回调处理器
//
// public static PayBillBstType parse(String type) {
// for (PayBillBstType value : PayBillBstType.values()) {
// if (value.getType().equals(type)) {
// return value;
// }
// }
// return null;
// }
//
// public static List<String> asList(PayBillBstType ...types) {
// return Arrays.stream(types).map(PayBillBstType::getType).collect(Collectors.toList());
// }
//}

View File

@ -6,6 +6,7 @@ import com.ruoyi.common.enums.PayChannel;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.ss.channel.domain.ChannelVO;
import com.ruoyi.ss.order.domain.Order;
import com.ruoyi.ss.order.domain.OrderBO;
import com.ruoyi.ss.order.domain.OrderVO;
import com.ruoyi.ss.payBill.domain.PayBill;
@ -34,7 +35,7 @@ public class PayBillConverterImpl implements PayBillConverter {
return null;
}
OrderVO order = bo.getOrder();
Order order = bo.getOrder();
if (order == null) {
return null;
}
@ -53,7 +54,7 @@ public class PayBillConverterImpl implements PayBillConverter {
String outTradeNo = null;
if(PayChannel.CT_WX.equalsCode(channel.getCode())){
outTradeNo = IdUtils.getOrderNo("wx");
}else if(PayChannel.TL_WX.equalsCode(channel.getCode())){
}else if(PayChannel.TM_WX.equalsCode(channel.getCode())){
outTradeNo = IdUtils.getOrderNo("tlwx");
}else{
throw new ServiceException("非法的支付渠道");

View File

@ -21,10 +21,14 @@ public class RoomVO extends Room {
/* 最低价格套餐对象 */
@ApiModelProperty("最低价格套餐对象")
private FeeRuleVO feeRuleVO;
private FeeRuleVO bottomPriceFeeRule;
/* 已预定时间段 */
@ApiModelProperty("已预定时间段")
private List<ReservedTimePeriod> reservedTimePeriods;
/* 套餐对象数组 */
@ApiModelProperty("套餐对象数组")
private List<FeeRuleVO> feeRules;
}

View File

@ -1,7 +1,9 @@
package com.ruoyi.ss.room.service;
import com.ruoyi.ss.order.domain.vo.ReservedTimePeriod;
import com.ruoyi.ss.room.domain.RoomVO;
import java.util.Date;
import java.util.List;
/**
@ -16,4 +18,30 @@ public interface IRoomAssembler {
*/
void assembleRuleInfo(List<RoomVO> list);
/**
* 拼接已预约时间段
* @param room 房间对象
*/
void assembleReservedTimePeriods(RoomVO room);
/**
* 拼接最低套餐信息
* @param room 房间对象
*/
void assembleRule(RoomVO room);
/**
* 拼接房间下所有套餐信息
* @param room 房间对象
*/
void assembleAllRule(RoomVO room);
/**
* 根据房间id获取预约时间段
* @param roomId 房间ID
* @param startTime 开始时间
* @return 已预约时间段
*/
List<ReservedTimePeriod> getReservedTimePeriods(Long roomId, Date startTime);
}

View File

@ -57,7 +57,8 @@ public class RoomAssemblerImpl implements IRoomAssembler {
});
}
private void assembleReservedTimePeriods(RoomVO room) {
@Override
public void assembleReservedTimePeriods(RoomVO room) {
//以当前时间开始的24小时内的已经预定成功的订单时间预定成功的判断是 order.status == 2 的订单 ,只返回 order.reserveStartTimeDate和reserveEndTimeDate,放在list中list的结构
// [{"startTime":"2024-04-29 14:00:00","endTime":"2024-04-29 15:00:00"}, {"startTime":"2024-04-29 16:00:00","endTime":"2024-04-29 17:00:00"}]
// 获取当前时间
@ -74,7 +75,23 @@ public class RoomAssemblerImpl implements IRoomAssembler {
room.setReservedTimePeriods(reservedTimes);
}
private void assembleRule(RoomVO room) {
@Override
public List<ReservedTimePeriod> getReservedTimePeriods(Long roomId, Date startTime) {
//以当前时间开始的24小时内的已经预定成功的订单时间预定成功的判断是 order.status == 2 的订单 ,只返回 order.reserveStartTimeDate和reserveEndTimeDate,放在list中list的结构
// [{"startTime":"2024-04-29 14:00:00","endTime":"2024-04-29 15:00:00"}, {"startTime":"2024-04-29 16:00:00","endTime":"2024-04-29 17:00:00"}]
// 获取24小时后的时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(startTime);
calendar.add(Calendar.HOUR, 24);
Date endTime = calendar.getTime();
// 获取已预定时间段预定成功的订单时间在当前时间的24小时内
return orderService.selectReservedTimes(roomId, startTime, endTime);
}
@Override
public void assembleRule(RoomVO room) {
List<FeeRuleVO> feeRuleVOS = feeRuleService.selectEFeeRuleListByRoomId(room.getRoomId());
// 检查 feeRuleVOS 是否为空
if (feeRuleVOS == null || feeRuleVOS.isEmpty()) {
@ -104,6 +121,16 @@ public class RoomAssemblerImpl implements IRoomAssembler {
feeRuleVOS.stream()
.filter(feeRule -> "2".equals(feeRule.getMode()) && feeRule.getPrice() != null) // 筛选 mode "2" price 不为 null
.min(Comparator.comparing(FeeRuleVO::getPrice)) // 按照 price 升序排序并获取价格最低的 FeeRuleVO
.ifPresent(room::setFeeRuleVO);
.ifPresent(room::setBottomPriceFeeRule);
}
@Override
public void assembleAllRule(RoomVO room) {
List<FeeRuleVO> feeRuleVOS = feeRuleService.selectEFeeRuleListByRoomId(room.getRoomId());
// 检查 feeRuleVOS 是否为空
if (feeRuleVOS == null || feeRuleVOS.isEmpty()) {
return; // 如果为空则跳过处理
}
room.setFeeRules(feeRuleVOS);
}
}

View File

@ -2,7 +2,9 @@ package com.ruoyi.ss.room.service.impl;
import java.util.List;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.room.service.IRoomAssembler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ss.room.mapper.RoomMapper;
@ -26,6 +28,9 @@ public class RoomServiceImpl implements IRoomService
@Autowired
private DeviceService smDeviceService;
@Autowired
private IRoomAssembler roomAssembler;
/**
* 查询房间
*
@ -35,7 +40,16 @@ public class RoomServiceImpl implements IRoomService
@Override
public RoomVO selectERoomByRoomId(Long roomId)
{
return eRoomMapper.selectERoomByRoomId(roomId);
RoomVO roomVO = eRoomMapper.selectERoomByRoomId(roomId);
ServiceUtil.assertion(roomVO == null, "房间不存在");
//拼接已预定时间段(包含)
roomAssembler.assembleReservedTimePeriods(roomVO);
//拼接套餐信息
roomAssembler.assembleAllRule(roomVO);
return roomVO;
}
/**

View File

@ -135,4 +135,8 @@ public class Store extends BaseEntity{
@ApiModelProperty("wifi密码")
private String wifiPassword;
@Excel(name = "起订时间")
@ApiModelProperty("起订时间")
private String minimumTime;
}

View File

@ -15,4 +15,6 @@ public class StoreVO extends Store {
/** 距离公里 */
private Double distance;
}

View File

@ -40,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
s.tags,
s.wifi,
s.wifi_password,
s.minimum_time,
c.name as cityName
from ss_store s
left join ss_city c on c.city_id = s.city_id
@ -120,6 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tags != null">tags,</if>
<if test="wifi != null">wifi,</if>
<if test="wifiPassword != null">wifi_password,</if>
<if test="minimumTime != null">minimum_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
@ -151,6 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tags != null">#{tags,typeHandler=com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler},</if>
<if test="wifi != null">#{wifi},</if>
<if test="wifiPassword != null">#{wifiPassword},</if>
<if test="minimumTime != null">#{minimumTime},</if>
</trim>
</insert>
@ -192,6 +195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.tags != null">tags = #{data.tags,typeHandler=com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler},</if>
<if test="data.wifi != null">wifi = #{data.wifi},</if>
<if test="data.wifiPassword != null">wifi_password = #{data.wifiPassword},</if>
<if test="data.minimumTime != null">minimum_time = #{data.minimumTime},</if>
</sql>
<delete id="deleteEStoreByStoreId" parameterType="Long">

View File

@ -2,6 +2,7 @@ package com.ruoyi.ss.store.service;
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.ss.store.domain.ServerPhone;
import com.ruoyi.ss.store.domain.Store;
import com.ruoyi.ss.store.domain.StoreQuery;
@ -69,6 +70,11 @@ public interface IStoreService
*/
List<StoreVO> getStoreListByLocation(StoreQuery query);
/**
* 根据城市id获取店铺列表
*/
List<StoreVO> getStoreListByCityId(Long cityId);
/**
* 开大门
*/

View File

@ -156,6 +156,15 @@ public class StoreServiceImpl implements IStoreService
return null;
}
/**
* 根据城市id获取店铺列表
*/
@Override
public List<StoreVO> getStoreListByCityId(Long cityId) {
return storeMapper.selectEStoreByCityId(cityId);
}
/**
* 开大门
*/

View File

@ -108,7 +108,7 @@ public class WxPayService implements IWxPayService {
if(PayChannel.CT_WX.equalsCode(channelVO.getCode())){
log.info("----------{}-------------","微信官方支付");
return getPrepayWithRequestPaymentResponse(order.getOrder(), order.getUser(), channelVO, po.getPayNo(), po.getDescription());
}else if(PayChannel.TL_WX.equalsCode(channelVO.getCode())){
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
log.info("----------{}-------------","太米支付");
return getPrepayWithRequestPaymentResponse(order, po, channelVO);
}else{
@ -337,7 +337,7 @@ public class WxPayService implements IWxPayService {
RefundService refundService = getRefundService(channelVO);
com.wechat.pay.java.service.refund.model.Refund refund = refundService.create(request);
log.info("【退款】微信返回结果:【{}】",JSON.toJSONString(refund));
}else if(PayChannel.TL_WX.equalsCode(channelVO.getCode())){
}else if(PayChannel.TM_WX.equalsCode(channelVO.getCode())){
throw new ServiceException("支付渠道【"+channelVO.getCode()+"】暂不支持");
// log.info("----------{}-------------","通联微信退款");
// RefundAble refundAble = new RefundAble();