mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-19 18:45:03 +08:00
定时任务 订单分账逻辑
This commit is contained in:
@@ -1,17 +1,14 @@
|
|||||||
package com.jsowell.web.controller.pile;
|
package com.jsowell.web.controller.pile;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.jsowell.common.annotation.Log;
|
import com.jsowell.common.annotation.Log;
|
||||||
import com.jsowell.common.core.controller.BaseController;
|
import com.jsowell.common.core.controller.BaseController;
|
||||||
import com.jsowell.common.core.domain.AjaxResult;
|
import com.jsowell.common.core.domain.AjaxResult;
|
||||||
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
||||||
import com.jsowell.common.core.page.PageResponse;
|
|
||||||
import com.jsowell.common.core.page.TableDataInfo;
|
import com.jsowell.common.core.page.TableDataInfo;
|
||||||
import com.jsowell.common.enums.BusinessType;
|
import com.jsowell.common.enums.BusinessType;
|
||||||
import com.jsowell.common.exception.BusinessException;
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.PageUtils;
|
import com.jsowell.common.util.PageUtils;
|
||||||
import com.jsowell.common.util.SecurityUtils;
|
import com.jsowell.common.util.SecurityUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
|
||||||
import com.jsowell.common.util.poi.ExcelUtil;
|
import com.jsowell.common.util.poi.ExcelUtil;
|
||||||
import com.jsowell.pile.domain.PileMerchantInfo;
|
import com.jsowell.pile.domain.PileMerchantInfo;
|
||||||
import com.jsowell.pile.dto.CreateMerchantDTO;
|
import com.jsowell.pile.dto.CreateMerchantDTO;
|
||||||
@@ -22,7 +19,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +40,7 @@ public class PileMerchantInfoController extends BaseController {
|
|||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(PileMerchantInfo pileMerchantInfo) {
|
public TableDataInfo list(PileMerchantInfo pileMerchantInfo) {
|
||||||
startPage();
|
startPage();
|
||||||
List<PileMerchantInfo> list = pileMerchantInfoService.selectPileMerchantInfoList(pileMerchantInfo);
|
List<PileMerchantInfo> list = pileMerchantInfoService.selectPileMerchantInfoListWithAuth(pileMerchantInfo);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +52,7 @@ public class PileMerchantInfoController extends BaseController {
|
|||||||
@PreAuthorize("@ss.hasPermi('pile:merchant:list')")
|
@PreAuthorize("@ss.hasPermi('pile:merchant:list')")
|
||||||
@GetMapping("/getMerchantList")
|
@GetMapping("/getMerchantList")
|
||||||
public TableDataInfo getMerchantList(PileMerchantInfo pileMerchantInfo) {
|
public TableDataInfo getMerchantList(PileMerchantInfo pileMerchantInfo) {
|
||||||
List<PileMerchantInfo> list = pileMerchantInfoService.selectPileMerchantInfoList(pileMerchantInfo);
|
List<PileMerchantInfo> list = pileMerchantInfoService.selectPileMerchantInfoListWithAuth(pileMerchantInfo);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +63,7 @@ public class PileMerchantInfoController extends BaseController {
|
|||||||
@Log(title = "充电桩运营商信息", businessType = BusinessType.EXPORT)
|
@Log(title = "充电桩运营商信息", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, PileMerchantInfo pileMerchantInfo) {
|
public void export(HttpServletResponse response, PileMerchantInfo pileMerchantInfo) {
|
||||||
List<PileMerchantInfo> list = pileMerchantInfoService.selectPileMerchantInfoList(pileMerchantInfo);
|
List<PileMerchantInfo> list = pileMerchantInfoService.selectPileMerchantInfoListWithAuth(pileMerchantInfo);
|
||||||
ExcelUtil<PileMerchantInfo> util = new ExcelUtil<PileMerchantInfo>(PileMerchantInfo.class);
|
ExcelUtil<PileMerchantInfo> util = new ExcelUtil<PileMerchantInfo>(PileMerchantInfo.class);
|
||||||
util.exportExcel(response, list, "充电桩运营商信息数据");
|
util.exportExcel(response, list, "充电桩运营商信息数据");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,9 +136,18 @@ public interface IOrderBasicInfoService {
|
|||||||
|
|
||||||
List<OrderVO> getListByMemberIdAndOrderStatus(String memberId, List<String> orderStatusList, LocalDateTime dateTime, String stationId);
|
List<OrderVO> getListByMemberIdAndOrderStatus(String memberId, List<String> orderStatusList, LocalDateTime dateTime, String stationId);
|
||||||
|
|
||||||
void doPaymentConfirm(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount) throws BaseAdaPayException;
|
void orderSplittingOperations(String merchantId, String tradeDate);
|
||||||
|
|
||||||
void tempOrderRefund();
|
void doPaymentConfirm(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount) throws BaseAdaPayException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量查询订单
|
||||||
|
* @param orderCodeList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<OrderBasicInfo> queryOrderList(List<String> orderCodeList);
|
||||||
|
|
||||||
|
void tempOrderRefund();
|
||||||
|
|
||||||
void realTimeMonitorDataRedis2DB(String transactionCode, String orderCode);
|
void realTimeMonitorDataRedis2DB(String transactionCode, String orderCode);
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,11 @@ public interface IPileMerchantInfoService {
|
|||||||
* @param pileMerchantInfo 充电桩运营商信息
|
* @param pileMerchantInfo 充电桩运营商信息
|
||||||
* @return 充电桩运营商信息集合
|
* @return 充电桩运营商信息集合
|
||||||
*/
|
*/
|
||||||
public List<PileMerchantInfo> selectPileMerchantInfoList(PileMerchantInfo pileMerchantInfo);
|
List<PileMerchantInfo> selectPileMerchantInfoListWithAuth(PileMerchantInfo pileMerchantInfo);
|
||||||
|
|
||||||
/**
|
List<PileMerchantInfo> selectPileMerchantInfoList(PileMerchantInfo pileMerchantInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
* 新增充电桩运营商信息
|
* 新增充电桩运营商信息
|
||||||
*
|
*
|
||||||
* @param pileMerchantInfo 充电桩运营商信息
|
* @param pileMerchantInfo 充电桩运营商信息
|
||||||
|
|||||||
@@ -874,12 +874,14 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
* orderSplittingOperations
|
* orderSplittingOperations
|
||||||
* 只有开通结算账户的运营商才走分账逻辑
|
* 只有开通结算账户的运营商才走分账逻辑
|
||||||
*/
|
*/
|
||||||
private void orderSplittingOperations(String merchantId, String tradeDate) {
|
@Override
|
||||||
|
public void orderSplittingOperations(String merchantId, String tradeDate) {
|
||||||
// 查询运营商有没有开通结算账户
|
// 查询运营商有没有开通结算账户
|
||||||
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(merchantId);
|
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(merchantId);
|
||||||
if (adapayMemberAccount == null) {
|
if (adapayMemberAccount == null) {
|
||||||
logger.error("订单分账逻辑error, 运营商id:{}, 未配置结算账户", merchantId);
|
logger.error("订单分账逻辑error, 运营商id:{}, 未配置结算账户", merchantId);
|
||||||
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_MEMBER_IS_NULL_ERROR);
|
// throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_MEMBER_IS_NULL_ERROR);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据交易日期查询运营商下面所有站点的交易日报
|
// 根据交易日期查询运营商下面所有站点的交易日报
|
||||||
@@ -913,6 +915,13 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doPaymentConfirm(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount) throws BaseAdaPayException {
|
public void doPaymentConfirm(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount) throws BaseAdaPayException {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime dateTime = LocalDateTime.of(2023, 8, 1, 0, 0, 0);
|
||||||
|
if (now.isBefore(dateTime)) {
|
||||||
|
logger.info("当前时间:{}早于:{}, 此订单不进行分账处理, 订单信息:{}", DateUtils.formatDateTime(now), DateUtils.formatDateTime(dateTime), JSON.toJSONString(orderBasicInfo));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 查询订单的交易id
|
// 查询订单的交易id
|
||||||
AdapayCallbackRecord adapayCallbackRecord = adapayCallbackRecordService.selectByOrderCode(orderBasicInfo.getOrderCode());
|
AdapayCallbackRecord adapayCallbackRecord = adapayCallbackRecordService.selectByOrderCode(orderBasicInfo.getOrderCode());
|
||||||
if (adapayCallbackRecord == null) {
|
if (adapayCallbackRecord == null) {
|
||||||
@@ -967,6 +976,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
* @param orderCodeList
|
* @param orderCodeList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public List<OrderBasicInfo> queryOrderList(List<String> orderCodeList) {
|
public List<OrderBasicInfo> queryOrderList(List<String> orderCodeList) {
|
||||||
List<OrderBasicInfo> resultList = Lists.newArrayList();
|
List<OrderBasicInfo> resultList = Lists.newArrayList();
|
||||||
if (CollectionUtils.isEmpty(orderCodeList)) {
|
if (CollectionUtils.isEmpty(orderCodeList)) {
|
||||||
|
|||||||
@@ -59,13 +59,12 @@ public class PileMerchantInfoServiceImpl implements IPileMerchantInfoService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询充电桩运营商信息列表
|
* 查询充电桩运营商信息列表
|
||||||
*
|
* 带权限校验
|
||||||
* @param pileMerchantInfo 充电桩运营商信息
|
* @param pileMerchantInfo 充电桩运营商信息
|
||||||
* @return 充电桩运营商信息
|
* @return 充电桩运营商信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
// @DataScope(deptAlias = "t")
|
public List<PileMerchantInfo> selectPileMerchantInfoListWithAuth(PileMerchantInfo pileMerchantInfo) {
|
||||||
public List<PileMerchantInfo> selectPileMerchantInfoList(PileMerchantInfo pileMerchantInfo) {
|
|
||||||
AuthorizedDeptVO authorizedMap = SecurityUtils.getAuthorizedMap();
|
AuthorizedDeptVO authorizedMap = SecurityUtils.getAuthorizedMap();
|
||||||
if (authorizedMap == null) {
|
if (authorizedMap == null) {
|
||||||
// 为空表示没有权限,返回空数组
|
// 为空表示没有权限,返回空数组
|
||||||
@@ -73,7 +72,17 @@ public class PileMerchantInfoServiceImpl implements IPileMerchantInfoService {
|
|||||||
}
|
}
|
||||||
pileMerchantInfo.setStationDeptIds(authorizedMap.getStationDeptIds());
|
pileMerchantInfo.setStationDeptIds(authorizedMap.getStationDeptIds());
|
||||||
pileMerchantInfo.setMerchantDeptIds(authorizedMap.getMerchantDeptIds());
|
pileMerchantInfo.setMerchantDeptIds(authorizedMap.getMerchantDeptIds());
|
||||||
|
return selectPileMerchantInfoList(pileMerchantInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询充电桩运营商信息列表
|
||||||
|
* 无权限校验
|
||||||
|
* @param pileMerchantInfo 充电桩运营商信息
|
||||||
|
* @return 充电桩运营商信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<PileMerchantInfo> selectPileMerchantInfoList(PileMerchantInfo pileMerchantInfo) {
|
||||||
List<PileMerchantInfo> list = pileMerchantInfoMapper.selectPileMerchantInfoList(pileMerchantInfo);
|
List<PileMerchantInfo> list = pileMerchantInfoMapper.selectPileMerchantInfoList(pileMerchantInfo);
|
||||||
if (Objects.nonNull(list)) {
|
if (Objects.nonNull(list)) {
|
||||||
for (PileMerchantInfo p:list) {
|
for (PileMerchantInfo p:list) {
|
||||||
|
|||||||
@@ -807,7 +807,7 @@
|
|||||||
order by t1.trade_date DESC
|
order by t1.trade_date DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectByStationIdAndDate" resultMap="SettleOrderReportResult">
|
<select id="selectByStationIdAndDate" resultMap="BaseResultMap">
|
||||||
select <include refid="Base_Column_List" />
|
select <include refid="Base_Column_List" />
|
||||||
from settle_order_report
|
from settle_order_report
|
||||||
where del_flag = '0'
|
where del_flag = '0'
|
||||||
@@ -815,7 +815,7 @@
|
|||||||
and trade_date = #{date,jdbcType=VARCHAR}
|
and trade_date = #{date,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectByMerchantIdAndDate" resultMap="SettleOrderReportResult">
|
<select id="selectByMerchantIdAndDate" resultMap="BaseResultMap">
|
||||||
select <include refid="Base_Column_List" />
|
select <include refid="Base_Column_List" />
|
||||||
from settle_order_report
|
from settle_order_report
|
||||||
where del_flag = '0'
|
where del_flag = '0'
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ import com.jsowell.common.core.redis.RedisCache;
|
|||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
|
import com.jsowell.pile.domain.PileMerchantInfo;
|
||||||
import com.jsowell.pile.domain.PileStationInfo;
|
import com.jsowell.pile.domain.PileStationInfo;
|
||||||
import com.jsowell.pile.domain.ykcCommond.PublishPileBillingTemplateCommand;
|
import com.jsowell.pile.domain.ykcCommond.PublishPileBillingTemplateCommand;
|
||||||
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
||||||
import com.jsowell.pile.service.IOrderBasicInfoService;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.service.IPileBillingTemplateService;
|
|
||||||
import com.jsowell.pile.service.IPileStationInfoService;
|
|
||||||
import com.jsowell.pile.service.YKCPushCommandService;
|
|
||||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||||
import com.jsowell.thirdparty.amap.service.AMapService;
|
import com.jsowell.thirdparty.amap.service.AMapService;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -42,6 +40,9 @@ public class JsowellTask {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private YKCPushCommandService ykcPushCommandService;
|
private YKCPushCommandService ykcPushCommandService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPileMerchantInfoService pileMerchantInfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPileStationInfoService pileStationInfoService;
|
private IPileStationInfoService pileStationInfoService;
|
||||||
|
|
||||||
@@ -157,4 +158,24 @@ public class JsowellTask {
|
|||||||
// 删除缓存
|
// 删除缓存
|
||||||
redisCache.deleteObject(CacheConstants.PUSH_STATION_CONNECTOR);
|
redisCache.deleteObject(CacheConstants.PUSH_STATION_CONNECTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务,处理订单分账
|
||||||
|
* jsowellTask.processOrderSplitting()
|
||||||
|
*/
|
||||||
|
public void processOrderSplitting() {
|
||||||
|
// 查询运营商列表
|
||||||
|
List<PileMerchantInfo> pileMerchantInfos = pileMerchantInfoService.selectPileMerchantInfoList(null);
|
||||||
|
if (CollectionUtils.isEmpty(pileMerchantInfos)) {
|
||||||
|
log.info("定时任务,处理订单分账, 未查询到运营商列表,直接返回");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取日期
|
||||||
|
// LocalDate yesterday = LocalDate.now().plusDays(-1);
|
||||||
|
LocalDate yesterday = LocalDate.of(2023, 7, 8);
|
||||||
|
// 调分账方法
|
||||||
|
pileMerchantInfos.parallelStream().forEach(merchant -> {
|
||||||
|
orderBasicInfoService.orderSplittingOperations(merchant.getId()+"", yesterday.toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user