首页调整、用户详情

This commit is contained in:
邱贞招 2025-02-24 11:02:48 +08:00
parent d12ea9a4a8
commit e10fb12fdd
26 changed files with 535 additions and 58 deletions

View File

@ -3,6 +3,7 @@ package com.ruoyi.web.controller.system;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.core.domain.entity.AsUser;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.vo.LabelVo;
@ -123,7 +124,7 @@ public class AsUserController extends BaseController
*/
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody AsUser user)
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) AsUser user)
{
if (!asUserService.checkUserNameUnique(user))
{

View File

@ -113,7 +113,7 @@ public class EtFeeRuleController extends BaseController
}
// 校验运营商
if (etFeeRule.getDeptId() == null) {
return "代理商为必填项";
etFeeRule.setDeptId(getDeptId());
}
// 校验说明
if (etFeeRule.getInstructions() == null || etFeeRule.getInstructions().trim().isEmpty()) {

View File

@ -69,6 +69,18 @@ public class EtOrderController extends BaseController
return getDataTable(list);
}
/**
* 查询充值/退款订单列表(视图)
*/
@PreAuthorize("@ss.hasPermi('system:order:list')")
@GetMapping("/rechargeList2")
public TableDataInfo rechargeList2(EtOrderQuery etOrder)
{
startPage();
List<RechargeVo> list = etOrderService.rechargeList2(etOrder);
return getDataTable(list);
}
/**
* 导出订单列表
*/

View File

@ -58,6 +58,12 @@ public class CacheConstants
*/
public static final String CACHE_DEVICE_KEY = "device:";
/**
* 首页缓存key
*/
public static final String CACHE_ADMIN_STATISTICS = "adminStatistics";
/**
* 首页数据 redis key
*/

View File

@ -122,6 +122,11 @@ public class ServiceConstants {
*/
public static final String ORDER_STATUS_DAMAGED = "6";
/**
* 订单状态:7-待官方审核
*/
public static final String ORDER_STATUS_OFFICIAL_REVIEW = "7";
/**----------------------------订单状态end----------------------------*/
/**----------------------------支付状态start----------------------------*/

View File

@ -5,6 +5,7 @@ import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.xss.Xss;
import lombok.ToString;
@ -116,6 +117,9 @@ public class AsUser extends BaseEntity
/** 运营区id */
private String areaId;
/** 运营区 */
private String areaName;
/** 是否认证0-未认证1-已认证 */
public String isAuthentication;
@ -187,6 +191,14 @@ public class AsUser extends BaseEntity
this.areaId = areaId;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
/** 最后一笔订单 */
private EtOrderDto latestOrder;
@ -292,7 +304,7 @@ public class AsUser extends BaseEntity
}
@Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空")
@NotBlank(message = "用户账号不能为空", groups = {ValidGroup.Create.class})
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
public String getUserName()
{

View File

@ -17,5 +17,5 @@ public class LocationVo {
private Integer s;//卫星数量
private Integer q;//质量
private Integer q;//电门 0-1-
}

View File

@ -226,10 +226,16 @@ public class SysLoginService
String phoneNumber = wxAuthService.getPhoneNumber(mobileCode, dept, url);
user = asUserService.selectUserByWxOpenid(openId);
if(ObjectUtils.isEmpty(user)){
user = asUserService.selectUserByPhone(phoneNumber);
}
if(ObjectUtils.isEmpty(user)){
// 用户不存在注册用户
user = registerUser(areaId, phoneNumber, openId, Constants.CUSTOM_LOGIN_WX,dept);
}else{
if(StrUtil.isBlank(user.getWxOpenid())){
user.setWxOpenid(openId);
}
if(dept.getIsUsePlatformApp().equals("true")){
user.setAppName("创享电动车");
user.setAppId(dept.getAppid());

View File

@ -21,6 +21,10 @@ public class EtOrderQuery extends BaseEntity
@Excel(name = "用户")
private String userName;
/** 用户id */
@Excel(name = "用户id")
private Long userId;
/** 类型 */
@Excel(name = "类型")
private String type;
@ -49,4 +53,8 @@ public class EtOrderQuery extends BaseEntity
@Excel(name = "是否退款")
private List<String> isRefund;
/** 运营区ids */
@Excel(name = "运营区ids")
private List<Long> areaIds;
}

View File

@ -76,4 +76,14 @@ public class EtReconciliation extends BaseEntity
@Excel(name = "平台服务费")
private BigDecimal platformServiceFee;
@Excel(name = "订单数")
private int orderCount;
@Excel(name = "提现服务费")
private BigDecimal withdrawServiceFee;
@Excel(name = "渠道成本")
private BigDecimal channelCost;
}

View File

@ -60,6 +60,11 @@ public class IndexAdminVo {
/** 还车待审核订单数 */
private Integer returnOrderCount=0;
/** 提现待审核数 */
private Integer withdrawReviewCount=0;
/** 扣款待审核数 */
private Integer deductionReviewCount=0;
/** 今日支付手续费 */
private BigDecimal todayHandlingFee= BigDecimal.ZERO;
/** 总支付手续费 */
@ -76,9 +81,12 @@ public class IndexAdminVo {
/** 运维统计 */
private OperationVo operationVo;
/** 统计list */
/** 收统计list */
private List<IncomeVo> incomeVoList;
/** 收入及成本 */
private List<IncomeCostVo> incomeCostList;
/**
* 营收统计 incomeVo
*/
@ -90,8 +98,23 @@ public class IndexAdminVo {
private BigDecimal orderFee;
/** 订单数 */
private Integer orderNum;
/** 退款金额 */
private BigDecimal refundFee;
}
// 收入及成本
@Data
public static class IncomeCostVo {
/** 日期 */
private String day;
private BigDecimal serviceFee; // 服务费
private BigDecimal handlingFee; // 手续费
private BigDecimal withdrawalFee; // 提现手续费
private BigDecimal channelCost; // 渠道成本
private BigDecimal platformProfit; // 平台盈利
}
/**
* 车辆统计
*/

View File

@ -25,6 +25,9 @@ public class SelfReconciliationVO {
//订单支付 包含押金抵扣
private BigDecimal orderPaid= BigDecimal.ZERO;
//订单数
private int orderCount= 0;
//押金充值
private BigDecimal depositPaid= BigDecimal.ZERO;
@ -52,6 +55,13 @@ public class SelfReconciliationVO {
// 平台服务费
private BigDecimal platformServiceFee= BigDecimal.ZERO;
// 提现服务费
private BigDecimal withdrawServiceFee= BigDecimal.ZERO;
//结算金额
private BigDecimal settlementAmount= BigDecimal.ZERO;
//渠道成本
private BigDecimal channelCost= BigDecimal.ZERO;
}

View File

@ -29,6 +29,14 @@ public interface EtCapitalFlowMapper
*/
public List<EtCapitalFlow> selectEtCapitalFlowList(EtCapitalFlow etCapitalFlow);
/**
* 查询资金流水列表
*
* @param etCapitalFlow 资金流水
* @return 资金流水集合
*/
public int selectCount(EtCapitalFlow etCapitalFlow);
/**
* 新增资金流水
*
@ -104,6 +112,14 @@ public interface EtCapitalFlowMapper
*/
BigDecimal getServiceFee2(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("sn") String sn, @Param("areaId") Long areaId,@Param("channelId") Long channelId);
/**
* 提现服务费
*
* @param areaId 运营区id
* @return
*/
BigDecimal getWithdrawServiceFee(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") Long areaId);
/**
* 骑行订单收入
*

View File

@ -8,6 +8,7 @@ import com.ruoyi.system.domain.EtOrderQuery;
import com.ruoyi.system.domain.IncomeQuery;
import com.ruoyi.system.domain.vo.IncomeVo;
import com.ruoyi.system.domain.vo.IndexVo;
import com.ruoyi.system.domain.vo.RechargeVo;
import org.apache.ibatis.annotations.Param;
/**
@ -66,6 +67,14 @@ public interface EtOrderMapper
*/
public List<EtOrder> selectEtOrderListNoRoute2(EtOrderQuery etOrder);
/**
* 查询充值记录从视图中获取
*
* @param etOrder 订单
* @return 订单集合
*/
List<RechargeVo> selectFromRechargeView(EtOrderQuery etOrder);
/**
* 新增订单
*
@ -224,7 +233,7 @@ public interface EtOrderMapper
/**
* 还车待审核订单数
*/
int getAuditOrderNum(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") String areaId);
int getAuditOrderNum(@Param("status") String status, @Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") String areaId);
/**
* 待审核还车押金扣款
@ -236,6 +245,10 @@ public interface EtOrderMapper
*/
int getOrderNum(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") Long areaId, @Param("areaIds") List<Long> areaIds);
/**
* 获取订单数
*/
int getOrderNum2(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") Long areaId, @Param("channelId") Long channelId);
/**
* 订单总金额
*/
@ -324,6 +337,11 @@ public interface EtOrderMapper
*/
BigDecimal getDepositAmount(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("areaId") Long areaId,@Param("channelId") Long channelId);
/**
* 获取渠道成本
*/
BigDecimal getCost(@Param("startDateStr") String startDateStr, @Param("endDateStr") String endDateStr, @Param("areaId") Long areaId,@Param("channelId") Long channelId);
// /**
// * 平台服务费
// */

View File

@ -44,6 +44,14 @@ public interface IEtCapitalFlowService
*/
public List<EtCapitalFlow> selectEtCapitalFlowList(EtCapitalFlow etCapitalFlow);
/**
* 查询数量
*
* @param etCapitalFlow 资金流水
* @return 资金流水集合
*/
public int selectCount(EtCapitalFlow etCapitalFlow);
/**
* 新增资金流水
*

View File

@ -193,6 +193,11 @@ public interface IEtOrderService
*/
List<RechargeVo> rechargeList(EtOrderQuery etOrder);
/**
* 查询充值/退款订单列表(视图)
*/
List<RechargeVo> rechargeList2(EtOrderQuery etOrder);
/**
* 获取当前正在骑行中的订单
*/
@ -272,6 +277,11 @@ public interface IEtOrderService
*/
IndexAdminVo admimStatistics();
/**
* 首页统计-数据库中获取
*/
IndexAdminVo getIndexAdminVo();
/**
* 首页统计-排行榜
*/

View File

@ -38,11 +38,15 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@ -1895,6 +1899,8 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
log.info("【还车关锁】远程关锁失败");
throw new ServiceException("远程关锁失败");
}
/** 3. 递归检查3次车辆状态*/
recursiveCheck(orderNo, lon, lat, device, token);
}else{
// 更新定位
device.setLongitude(lon);
@ -1980,6 +1986,35 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
}
}
private void recursiveCheck(String orderNo, String lon, String lat, AsDevice device, String token) {
// 定义一个递归检查并重试的函数
Runnable checkAndRetryLock = new Runnable() {
private int attempt = 0;
private static final int MAX_ATTEMPTS = 3; // 设置最大尝试次数为2次总共发送4次命令
@Override
public void run() {
LocationVo latestLocation2 = getLatestLocation2(device.getMac());
// 检查电门是否仍处于开启状态且没有正在进行的订单
if (!etOrderService.isInOrderBySn(device.getSn()) && latestLocation2.getQ() == 1) {
attempt++;
if (attempt <= MAX_ATTEMPTS) {
// 发送关锁命令
sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600,
"车辆锁同步关锁尝试" + attempt, orderNo, lon, lat);
// 如果尝试次数未达到上限则安排下一次尝试
Executors.newSingleThreadScheduledExecutor().schedule(this, 3, TimeUnit.SECONDS);
} else {
log.info("【还车关锁】多次尝试后依然无法关闭车辆锁");
}
}
}
};
// 初始调用
Executors.newSingleThreadScheduledExecutor().schedule(checkAndRetryLock, 3, TimeUnit.SECONDS);
}
// /** 押金抵扣 */
// private void depositDeduction(EtOrder order) {
//// EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleIdIncludeDelete(order.getRuleId());
@ -2417,6 +2452,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String latitude = device.getLatitude();
String longitude = device.getLongitude();
log.info("定位:{}{},=============运营区【{}】,边界:【{}】",longitude,latitude,area.getAreaName(),area.getBoundaryStr());
if(StrUtil.isBlank(area.getBoundary())){
return true;
}
Geometry geometry = GeoUtils.fromWkt(area.getBoundary());
inCircle = GeoUtils.isInCircle(longitude, latitude, geometry);
if(inCircle){
@ -2657,8 +2695,8 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn);
double[] latestLocation = getLatestLocation(device.getMac());
if(ObjectUtil.isNotNull(latestLocation)){
BigDecimal longitude1 = new BigDecimal(latestLocation[1]).setScale(8, RoundingMode.HALF_UP);
BigDecimal latitude1 = new BigDecimal(latestLocation[0]).setScale(8, RoundingMode.HALF_UP);
BigDecimal longitude1 = BigDecimal.valueOf(latestLocation[1]).setScale(8, RoundingMode.HALF_UP);
BigDecimal latitude1 = BigDecimal.valueOf(latestLocation[0]).setScale(8, RoundingMode.HALF_UP);
log.info("【判断是否在停车区】lon:{}lat:{}",longitude1,latitude1);
Boolean parkingZoneByLocation = isParkingZoneByLocation(longitude1.toString(), latitude1.toString(), Long.parseLong(areaId));
if(parkingZoneByLocation){
@ -2952,6 +2990,30 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
return null;
}
@SneakyThrows
public LocationVo getLatestLocation2(String mac) {
String token = Token.getToken();
DataPointRes datapoints = historyDatapoints(mac, token);
if(datapoints.getCode() == 0){
Data data = datapoints.getData();
List<Datastream> datastreams = data.getDevices();
for (Datastream datastream: datastreams) {
List<Datapoint> datapointList = datastream.getDatastreams();
if(ObjectUtil.isNotNull(datapointList)){
for (Datapoint datapoint:datapointList) {
if(datapoint.getId().equals(IotConstants.ONENET_LOCATION)){
String string = JSON.toJSONString(datapoint.getValue());
if(StrUtil.isNotBlank(string)){
return JSONObject.parseObject(string, LocationVo.class);
}
}
}
}
}
}
return null;
}
/** 计算电量和里程后更新设备*/
public int updateDevice(String at,LocationVo locationVo, AsDevice device, BigDecimal lon, BigDecimal lat) {
device.setLatitude(lat.toString());
@ -3013,7 +3075,11 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
device.setSignalStrength(locationVo.getCsq());
device.setSatellites(locationVo.getS());
device.setQuality(locationVo.getQ());
return updateLocation(device);
//开异步线程1.更新在线状态 2.记录在线离线日志
scheduledExecutorService.schedule(() -> {
updateLocation(device);
}, 0, TimeUnit.SECONDS);
return 1;
}
/** 无定位更新设备 */

View File

@ -45,6 +45,7 @@ import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.Comparator;
import java.util.Date;
@ -338,8 +339,8 @@ public class CallbackServiceImpl implements CallbackService {
private BigDecimal getCost(ChannelVO channel,BigDecimal payFee) {
// 获取到渠道成本
BigDecimal costRate = channel.getCostRate();
BigDecimal bigDecimal = costRate.divide(new BigDecimal(100), 6, BigDecimal.ROUND_HALF_UP);
BigDecimal cost = bigDecimal.multiply(payFee).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal bigDecimal = costRate.divide(new BigDecimal(100), 6, RoundingMode.HALF_UP);
BigDecimal cost = bigDecimal.multiply(payFee).setScale(2, RoundingMode.HALF_UP);
logger.info("【保存资金流水记录--订单支付】 成本==============bigDecimal====================="+bigDecimal);
logger.info("【保存资金流水记录--订单支付】 成本==============cost====================="+cost);
return cost;

View File

@ -72,6 +72,13 @@ public class EtCapitalFlowServiceImpl implements IEtCapitalFlowService
return etCapitalFlowMapper.selectEtCapitalFlowList(etCapitalFlow);
}
@Override
public int selectCount(EtCapitalFlow etCapitalFlow)
{
return etCapitalFlowMapper.selectCount(etCapitalFlow);
}
/**
* 新增资金流水
*

View File

@ -1,6 +1,5 @@
package com.ruoyi.system.service.impl;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
@ -32,11 +31,11 @@ import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.vo.*;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.*;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import com.wechat.pay.java.service.payments.model.Transaction;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -57,6 +56,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.ruoyi.common.constant.CacheConstants.CACHE_ADMIN_STATISTICS;
import static com.ruoyi.common.constant.ServiceConstants.ORDER_STATUS_OFFICIAL_REVIEW;
import static com.ruoyi.common.constant.ServiceConstants.ORDER_STATUS_TO_BE_AUDIT;
/**
* 订单Service业务层处理
*
@ -154,6 +157,9 @@ public class EtOrderServiceImpl implements IEtOrderService
@Autowired
private RedisCache redisCache;
@Resource
private EtReconciliationMapper reconciliationMapper;
/**
* 查询订单
*
@ -377,6 +383,12 @@ public class EtOrderServiceImpl implements IEtOrderService
return etOrders;
}
@Override
@DataScope(deptAlias = "d")
public List<RechargeVo> rechargeList2(EtOrderQuery etOrder) {
return etOrderMapper.selectFromRechargeView(etOrder);
}
/**
* 查询充值/退款订单列表
*/
@ -425,7 +437,7 @@ public class EtOrderServiceImpl implements IEtOrderService
rechargeVoList.add(rechargeVo);
});
}
//补充代码 根据isRefund判断,如果isRefund只存在"0",则只查询未退款(rechargeVo.isRefunded字段,布尔类型的)的记录,如果isRefund存在"1",则查询已退款的记录,如果isRefund为空或两个都有,则查询全部
//根据isRefund判断,如果isRefund只存在"0",则只查询未退款(rechargeVo.isRefunded字段,布尔类型的)的记录,如果isRefund存在"1",则查询已退款的记录,如果isRefund为空或两个都有,则查询全部
List<String> isRefund = etOrder.getIsRefund();
if (isRefund != null && isRefund.size() > 0) {
// 如果只包含 "0"则过滤未退款记录
@ -612,7 +624,7 @@ public class EtOrderServiceImpl implements IEtOrderService
if (x != null) return x;
EtOrder depositOrder = getDepositOrder(order.getUserId());
BigDecimal deposit = depositOrder.getTotalFee();
BigDecimal ridingFee = order.getTotalFee();
BigDecimal ridingFee = order.getPayFee();
BigDecimal afterDeductionFee;
String mark;
if(deposit.compareTo(ridingFee) <= 0){
@ -632,6 +644,8 @@ public class EtOrderServiceImpl implements IEtOrderService
order1.setPayType(ServiceConstants.PAY_TYPE_YJ);
order1.setMark(mark);
order1.setDepositDeduction(ServiceConstants.IS_DEPOSIT_DEDUCTION);
ChannelVO channelVO = etChannelService.selectSmChannelByChannelId(order.getPayChannel());
order1.setCost(getCost(channelVO,ridingFee));
int updateEtOrder = etOrderMapper.updateEtOrder(order1);
if(updateEtOrder == 0){
throw new ServiceException("押金抵扣失败,更新骑行订单失败");
@ -676,6 +690,13 @@ public class EtOrderServiceImpl implements IEtOrderService
redisLock.unlock(RedisLockKey.DEDUCTION, orderNo);
}
}
private BigDecimal getCost(ChannelVO channel,BigDecimal payFee) {
// 获取到渠道成本
BigDecimal costRate = channel.getCostRate();
BigDecimal bigDecimal = costRate.divide(new BigDecimal(100), 6, RoundingMode.HALF_UP);
return bigDecimal.multiply(payFee).setScale(2, RoundingMode.HALF_UP);
}
private @Nullable Integer isExistOutTradeNo(EtOrder order, String orderNo) {
// 押金抵扣时判断是否有outtradeno
@ -1029,7 +1050,7 @@ public class EtOrderServiceImpl implements IEtOrderService
indexVo.setUnpaidOrderCount(Integer.parseInt(etOrderMapper.getUnpaidOrder(null,null,areaId+"")));//待付款订单数
indexVo.setUnpaidOrderFee(new BigDecimal(etOrderMapper.getTotalUnpaid(null,null,areaId+"")));//待付款订单金额
indexVo.setReturnOrderCount(etOrderMapper.getAuditOrderNum(null,null,areaId+""));//还车待审核订单
indexVo.setReturnOrderCount(etOrderMapper.getAuditOrderNum("5",null,null,areaId+""));//还车待审核订单
indexVo.setRidingOrder(Integer.parseInt(etOrderMapper.getRidingOrder(null,null,areaId+"")));//骑行中订单
indexVo.setTodayRefundFee(new BigDecimal(etOrderMapper.getTotalRefund(startDateStr,endDateStr,areaId+"")));// 今日退款金额
indexVo.setFaultOrderCount(etFaultMapper.getAuditFaultNum(areaId));//待审核故障数量
@ -1085,7 +1106,7 @@ public class EtOrderServiceImpl implements IEtOrderService
@Override
public IndexAdminVo admimStatistics() {
// 定义缓存的键
String cacheKey = "adminStatistics";
String cacheKey = CACHE_ADMIN_STATISTICS;
// Redis 中获取缓存对象
IndexAdminVo cachedIndexAdminVo = redisCache.getCacheObject(cacheKey);
@ -1093,14 +1114,28 @@ public class EtOrderServiceImpl implements IEtOrderService
log.info("【首页统计】从缓存中获取数据:{}", JSON.toJSON(cachedIndexAdminVo));
return cachedIndexAdminVo; // 如果缓存存在则直接返回
}
log.info("【首页统计】从数据库中获取数据");
IndexAdminVo indexAdminVo = getIndexAdminVo();
// 将生成的对象保存到 Redis
redisCache.setCacheObject(cacheKey, indexAdminVo, 30, TimeUnit.MINUTES);
return indexAdminVo;
}
@Override
@NotNull
public IndexAdminVo getIndexAdminVo() {
/** 首页数据*/
IndexAdminVo indexAdminVo = createIndexAdminVo();
/** 营收统计*/
ArrayList<IndexAdminVo.IncomeVo> incomeVos = new ArrayList<>();
ArrayList<IndexAdminVo.IncomeCostVo> incomeCosts = new ArrayList<>();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtils.getNowDate());
calendar.add(Calendar.DAY_OF_MONTH, -1);
for (int i = 0; i < 13; i++) {
String formattedDate = dateFormat.format(calendar.getTime());
@ -1108,13 +1143,61 @@ public class EtOrderServiceImpl implements IEtOrderService
String endDateStr = formattedDate + " " + Constants.DATE_FORMAT_END_PEREND;
int orderCount = etOrderMapper.getOrderNum(startDateStr, endDateStr, null,null);
IndexAdminVo.IncomeVo incomeVo = new IndexAdminVo.IncomeVo();
EtReconciliation reconciliation = new EtReconciliation();
// 准备额外的查询参数
reconciliation.setDay(formattedDate);
List<EtReconciliation> etReconciliations = reconciliationMapper.selectEtReconciliationList(reconciliation);
Collections.reverse(etReconciliations);
IndexAdminVo.IncomeCostVo incomeCostVo = new IndexAdminVo.IncomeCostVo();
// 初始化统计变量
BigDecimal serviceFeeTotal = BigDecimal.ZERO;
BigDecimal handlingFeeTotal = BigDecimal.ZERO;
BigDecimal channelCostTotal = BigDecimal.ZERO;
BigDecimal withdrawServiceFeeFirst = BigDecimal.ZERO;
// 遍历 etReconciliations 进行统计
for (EtReconciliation item : etReconciliations) {
// 累加服务费
if (item.getPlatformServiceFee() != null) {
serviceFeeTotal = serviceFeeTotal.add(item.getPlatformServiceFee());
}
// 累加手续费假设 handlingCharge EtReconciliation 的一个属性
if (item.getHandlingCharge() != null) {
handlingFeeTotal = handlingFeeTotal.add(item.getHandlingCharge());
}
// 累加渠道成本
if (item.getChannelCost() != null) {
channelCostTotal = channelCostTotal.add(item.getChannelCost());
}
// 提现服务费只拿第一个值
if (item.getWithdrawServiceFee() != null) {
withdrawServiceFeeFirst = item.getWithdrawServiceFee();
}
}
// 计算平台盈利这里只是一个示例具体公式根据实际情况调整
BigDecimal platformProfit = serviceFeeTotal.subtract(handlingFeeTotal).subtract(channelCostTotal);
// 设置 IncomeCostVo 的值
incomeCostVo.setDay(formattedDate);
incomeCostVo.setServiceFee(serviceFeeTotal);
incomeCostVo.setHandlingFee(handlingFeeTotal);
incomeCostVo.setWithdrawalFee(withdrawServiceFeeFirst); // 设置提现手续费
incomeCostVo.setChannelCost(channelCostTotal);
incomeCostVo.setPlatformProfit(platformProfit);
incomeVo.setDay(formattedDate);
incomeVo.setOrderNum(orderCount);
incomeVo.setOrderFee(etOrderMapper.getOrderFee(startDateStr, endDateStr, null));
incomeVo.setRefundFee(etOrderMapper.getRefundFee(startDateStr, endDateStr, null,null,null));
incomeVos.add(incomeVo);
incomeCosts.add(incomeCostVo);
calendar.add(Calendar.DATE, -1);
}
indexAdminVo.setIncomeVoList(incomeVos);
indexAdminVo.setIncomeCostList(incomeCosts);
/** 车辆统计*/
IndexAdminVo.VehicleVo vehicleVo = new IndexAdminVo.VehicleVo();
@ -1136,10 +1219,6 @@ public class EtOrderServiceImpl implements IEtOrderService
operationVo.setBluetoothUnlockCount(operLogService.getBluetoothUnlockCount(todayStartDateStr, todayEndDateStr,BusinessStatus.SUCCESS.name()));//蓝牙解锁数
indexAdminVo.setOperationVo(operationVo);
log.info("【首页统计-总管理】indexAdminVo==={}",JSON.toJSON(indexAdminVo));
// 将生成的对象保存到 Redis
redisCache.setCacheObject(cacheKey, indexAdminVo, 30, TimeUnit.MINUTES);
return indexAdminVo;
}
@ -1245,9 +1324,15 @@ public class EtOrderServiceImpl implements IEtOrderService
indexAdminVo.setUnpaidOrderCount(Integer.parseInt(etOrderMapper.getUnpaidOrder(null,null,null)));//待付款订单数
indexAdminVo.setUnpaidOrderFee(new BigDecimal(etOrderMapper.getTotalUnpaid(null,null,null)));//待付款订单金额
indexAdminVo.setReturnOrderCount(etOrderMapper.getAuditOrderNum(null,null,null));//还车待审核订单
indexAdminVo.setReturnOrderCount(etOrderMapper.getAuditOrderNum(ORDER_STATUS_TO_BE_AUDIT,null,null,null));//还车待审核订单
indexAdminVo.setReturnOrderDeductFee(etOrderMapper.getReturnOrderDeductFee(null,null,null));// 待审核还车押金扣款
EtCapitalFlow etCapitalFlow = new EtCapitalFlow();
etCapitalFlow.setBusType(ServiceConstants.ORDER_TYPE_WITHDRAW);
etCapitalFlow.setStatus(ServiceConstants.FLOW_STATUS_APPLY);
indexAdminVo.setWithdrawReviewCount(etCapitalFlowService.selectCount(etCapitalFlow));// 提现待审核数
indexAdminVo.setDeductionReviewCount(etOrderMapper.getAuditOrderNum(ORDER_STATUS_OFFICIAL_REVIEW,null,null,null));//扣款待审核数
indexAdminVo.setTodayHandlingFee(etCapitalFlowMapper.getHandlingFee(startDateStr, endDateStr, null,null,null,null));// 今日支付手续费
indexAdminVo.setTotalHandlingFee(etCapitalFlowMapper.getHandlingFee(null, null, null,null,null,null));// 总手续费
@ -1960,8 +2045,7 @@ public class EtOrderServiceImpl implements IEtOrderService
*/
@Override
public EtOrder latestOrder2(EtOrder etOrder) {
EtOrder order = etOrderMapper.selectLatestOrder2(etOrder);
return order;
return etOrderMapper.selectLatestOrder2(etOrder);
}
/**
@ -1985,8 +2069,8 @@ public class EtOrderServiceImpl implements IEtOrderService
throw new ServiceException("订单未支付,不能退款");
}
SysDept sysDept = wxPayService.getDeptObjByAreaId(etOrder1.getAreaId());
BigDecimal subtract = sysDept.getBalance().subtract(etOrder1.getTotalFee());
if(subtract.compareTo(BigDecimal.ZERO) <= 0 && sysDept.getSeparateAccount().equals("N")){
BigDecimal subtract = sysDept.getBalance().subtract(etOrder1.getOperatorDividend());// 运营商分账的钱
if(subtract.compareTo(BigDecimal.ZERO) < 0 && sysDept.getSeparateAccount().equals("N")){
throw new ServiceException("余额不足,不能退款");
}
/** 1.退款*/

View File

@ -27,6 +27,7 @@ import com.ruoyi.common.utils.onenet.Token;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.vo.AsDeviceVO;
import com.ruoyi.system.domain.vo.IndexAdminVo;
import com.ruoyi.system.domain.vo.SelfReconciliationVO;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.*;
@ -54,6 +55,8 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
import static com.ruoyi.common.constant.CacheConstants.CACHE_ADMIN_STATISTICS;
/**
* 定时任务调度测试
*
@ -892,19 +895,27 @@ public class EtTask {
private SelfReconciliationVO buildSelfReconciliation(String startDateStr, String endDateStr, String formattedDate, Long aLong, Long channelId) {
SelfReconciliationVO selfReconciliationVO = new SelfReconciliationVO();
selfReconciliationVO.setDay(formattedDate);
BigDecimal totalFlowAmount = defaultIfNull(etOrderMapper.getTotalPaidFee(startDateStr, endDateStr, aLong,channelId),BigDecimal.ZERO);// 骑行订单收入 29835.51
BigDecimal totalFlowAmount = defaultIfNull(etOrderMapper.getTotalPaidFee(startDateStr, endDateStr, aLong,channelId),BigDecimal.ZERO);// 总流水收入 29835.51
BigDecimal totalAmount = defaultIfNull(etCapitalFlowMapper.getOrderPaidAmount(startDateStr, endDateStr, aLong,channelId),BigDecimal.ZERO);// 骑行订单收入 4712.51
int orderCount = etOrderMapper.getOrderNum2(startDateStr, endDateStr, aLong,channelId);
BigDecimal deductionAmount = defaultIfNull(etOrderMapper.getDepositDeductionAmount(startDateStr, endDateStr, aLong,channelId),BigDecimal.ZERO);// 押金抵扣金额 538
BigDecimal depositAmount = defaultIfNull(etOrderMapper.getDepositAmount(startDateStr, endDateStr, aLong,channelId),BigDecimal.ZERO);// 押金收入 25123
BigDecimal handlingFee = etCapitalFlowMapper.getHandlingFee2(startDateStr, endDateStr, null, aLong,channelId);//手续费,扣除掉退款部分的
BigDecimal platformServiceFee = etCapitalFlowMapper.getServiceFee2(startDateStr, endDateStr, null,aLong,channelId);//平台服务费 ,扣除掉退款部分的
BigDecimal withdrawServiceFee = etCapitalFlowMapper.getWithdrawServiceFee(startDateStr, endDateStr,aLong);//提现服务费 ,扣除掉提现失败部分的
BigDecimal cost = defaultIfNull(etOrderMapper.getCost(startDateStr, endDateStr, aLong,channelId),BigDecimal.ZERO);// 押金收入 25123
selfReconciliationVO.setOrderPaid(totalAmount);
selfReconciliationVO.setOrderCount(orderCount);
selfReconciliationVO.setTotalFlowAmount(totalFlowAmount);
selfReconciliationVO.setDeductionAmount(deductionAmount);
selfReconciliationVO.setDepositPaid(depositAmount);
selfReconciliationVO.setHandlingCharge(handlingFee);
selfReconciliationVO.setPlatformServiceFee(platformServiceFee);
if(channelId == 2){
selfReconciliationVO.setChannelCost(cost);
}
selfReconciliationVO.setWithdrawServiceFee(withdrawServiceFee);
/** 总支出*/
BigDecimal orderRefund = defaultIfNull(etOrderMapper.getRefundFee2(startDateStr, endDateStr, null, aLong,channelId), BigDecimal.ZERO);//订单退款
@ -941,6 +952,9 @@ public class EtTask {
etReconciliation.setSettlementAmount(selfReconciliationVO.getSettlementAmount());
etReconciliation.setCreateTime(DateUtils.getNowDate());
etReconciliation.setPayChannel(channelId);
etReconciliation.setOrderCount(selfReconciliationVO.getOrderCount());
etReconciliation.setChannelCost(selfReconciliationVO.getChannelCost());
etReconciliation.setWithdrawServiceFee(selfReconciliationVO.getWithdrawServiceFee());
int i1 = etReconciliationMapper.insertEtReconciliation(etReconciliation);
log.info("【平台对账】保存对账数据结果:【{}】",i1);
}
@ -972,4 +986,19 @@ public class EtTask {
}
}
}
/**
* 10分钟获取一次首页统计数据保存至缓存
* cron: 0 * /10 * * * ?
*/
public void getIndexAdminVo() {
log.info("【首页统计】从数据库中获取数据");
IndexAdminVo indexAdminVo = etOrderService.getIndexAdminVo();
// 将生成的对象保存到 Redis
redisCache.setCacheObject(CACHE_ADMIN_STATISTICS, indexAdminVo);
}
}

View File

@ -34,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="isSign" column="is_sign" />
<result property="sysUserId" column="sys_user_id" />
<result property="areaId" column="area_id" />
<result property="areaName" column="area_name" />
<result property="isAuthentication" column="is_authentication" />
<result property="appName" column="app_name" />
<result property="appId" column="appid" />
@ -45,8 +46,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select u.user_id, u.user_name, u.real_name, u.id_card, u.nick_name, u.email, u.avatar,
u.phonenumber, u.balance, u.birthday, u.password, u.pay_password, u.sex, u.status,
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.wxopenid,u.aliopenid,
u.is_sign,u.role,u.sys_role,u.sys_user_id,u.area_id,u.is_authentication,u.app_name,u.appid,u.vip_type,u.expiration_time
u.is_sign,u.role,u.sys_role,u.sys_user_id,u.area_id,oa.area_name, u.is_authentication,u.app_name,u.appid,u.vip_type,u.expiration_time
from et_user u
left join et_operating_area oa on oa.area_id = u.area_id
</sql>
<select id="selectUserList" parameterType="AsUser" resultMap="AsUserResult">

View File

@ -32,6 +32,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select flow_id, area_id, owner, owner_id, owner_phone, owner_type, order_no, out_trade_no, type, bus_type, status, amount, handling_charge, platform_service_fee, operator_dividend, operator_balance, partner_dividend, pay_type, create_time, model_id from et_capital_flow
</sql>
<sql id="searchCondition">
<if test="areaId != null "> and cf.area_id = #{areaId}</if>
<if test="orderNo != null and orderNo != ''"> and cf.order_no = #{orderNo}</if>
<if test="ownerId != null and ownerId != ''"> and cf.owner_id = #{ownerId}</if>
<if test="ownerPhone != null and ownerPhone != ''"> and cf.owner_phone like concat('%', #{ownerPhone}, '%')</if>
<if test="ownerType != null and ownerType != ''"> and cf.owner_type = #{ownerType}</if>
<if test="outTradeNo != null and outTradeNo != ''"> and cf.out_trade_no = #{outTradeNo}</if>
<if test="type != null and type != ''"> and cf.type = #{type}</if>
<if test="busType != null and busType != ''"> and cf.bus_type = #{busType}</if>
<if test="status != null and status != ''"> and cf.status = #{status}</if>
<if test="amount != null "> and cf.amount = #{amount}</if>
<if test="handlingCharge != null "> and cf.handling_charge = #{handlingCharge}</if>
<if test="operatorDividend != null "> and cf.operator_dividend = #{operatorDividend}</if>
<if test="operatorBalance != null "> and cf.operator_balance = #{operatorBalance}</if>
<if test="partnerDividend != null "> and cf.partner_dividend = #{partnerDividend}</if>
<if test="modelId != null "> and cf.model_id = #{modelId}</if>
<if test="payType != null and payType != ''"> and cf.pay_type = #{payType}</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND DATE(cf.create_time) &gt;= #{params.beginTime}
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND DATE(cf.create_time) &lt;= #{params.endTime}
</if>
<if test="typeList != null">
AND cf.bus_type IN
<foreach item="item" index="index" collection="typeList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</sql>
<select id="selectEtCapitalFlowList" parameterType="EtCapitalFlow" resultMap="EtCapitalFlowResult">
SELECT
cf.flow_id,
@ -63,39 +94,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN et_model m ON m.model_id = cf.model_id
WHERE
1 = 1
<if test="areaId != null "> and cf.area_id = #{areaId}</if>
<if test="orderNo != null and orderNo != ''"> and cf.order_no = #{orderNo}</if>
<if test="ownerId != null and ownerId != ''"> and cf.owner_id = #{ownerId}</if>
<if test="ownerPhone != null and ownerPhone != ''"> and cf.owner_phone like concat('%', #{ownerPhone}, '%')</if>
<if test="ownerType != null and ownerType != ''"> and cf.owner_type = #{ownerType}</if>
<if test="outTradeNo != null and outTradeNo != ''"> and cf.out_trade_no = #{outTradeNo}</if>
<if test="type != null and type != ''"> and cf.type = #{type}</if>
<if test="busType != null and busType != ''"> and cf.bus_type = #{busType}</if>
<if test="status != null and status != ''"> and cf.status = #{status}</if>
<if test="amount != null "> and cf.amount = #{amount}</if>
<if test="handlingCharge != null "> and cf.handling_charge = #{handlingCharge}</if>
<if test="operatorDividend != null "> and cf.operator_dividend = #{operatorDividend}</if>
<if test="operatorBalance != null "> and cf.operator_balance = #{operatorBalance}</if>
<if test="partnerDividend != null "> and cf.partner_dividend = #{partnerDividend}</if>
<if test="modelId != null "> and cf.model_id = #{modelId}</if>
<if test="payType != null and payType != ''"> and cf.pay_type = #{payType}</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND DATE(cf.create_time) &gt;= #{params.beginTime}
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND DATE(cf.create_time) &lt;= #{params.endTime}
</if>
<if test="typeList != null">
AND cf.bus_type IN
<foreach item="item" index="index" collection="typeList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<include refid="searchCondition"/>
<!-- 数据范围过滤 -->
${params.dataScope}
order by cf.create_time desc
</select>
<select id="selectCount" parameterType="EtCapitalFlow" resultType="int">
SELECT
count(1)
FROM
et_capital_flow cf
WHERE
1 = 1
<include refid="searchCondition"/>
order by cf.create_time desc
</select>
<select id="selectEtCapitalFlowByFlowId" parameterType="Long" resultMap="EtCapitalFlowResult">
<include refid="selectEtCapitalFlowVo"/>
where flow_id = #{flowId}
@ -195,6 +211,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="channelId != null ">and o.pay_channel = #{channelId}</if>
</select>
<select id="getWithdrawServiceFee" resultType="java.math.BigDecimal">
select
COALESCE(SUM(CASE WHEN f.bus_type = '5' THEN f.handling_charge ELSE 0 END), 0)
- COALESCE(SUM(CASE WHEN f.bus_type = '6' THEN f.handling_charge ELSE 0 END), 0) AS net_fee
from et_capital_flow f
where f.area_id != 14
<if test="timeStart != null and timeStart != ''">
AND DATE(f.create_time) &gt;= #{timeStart}
</if>
<if test="timeEnd != null and timeEnd != ''">
AND DATE(f.create_time) &lt;= #{timeEnd}
</if>
<if test="areaId != null and areaId != 0">and f.area_id = #{areaId}</if>
</select>
<select id="getTotalAmount" resultType="java.math.BigDecimal">
select sum(amount) from et_capital_flow f where type = 1 and bus_type = 1 and pay_type != 'yj'
<if test="timeStart != null and timeStart != ''">

View File

@ -356,11 +356,76 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''"> and o.status = #{status}</if>
<if test="paid != null and paid != ''"> and o.paid = #{paid}</if>
<if test="deptId != null and deptId != ''"> and d.dept_id = #{deptId}</if>
<if test="userId != null and userId != ''"> and u.user_id = #{userId}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by o.create_time desc
</select>
<select id="selectFromRechargeView" parameterType="EtOrderQuery" resultType="com.ruoyi.system.domain.vo.RechargeVo">
SELECT
r.order_no,
r.user_id,
r.out_trade_no,
r.user_name,
r.phonenumber,
r.total_fee,
r.deposit_deduction,
r.pay_time,
r.dept_id,
r.area_id,
r.create_time,
r.is_refunded,
r.recharge_type,
r.recharge_status
FROM v_recharge_record r
left join sys_dept d on d.dept_id = r.dept_id
WHERE 1 = 1
<!-- 运营区ID列表 -->
<if test="areaIds != null and areaIds.size() > 0">
AND area_id IN
<foreach collection="areaIds" item="areaId" open="(" separator="," close=")">
#{areaId}
</foreach>
</if>
<!-- 其他条件保持不变 -->
<if test="status != null and status != ''">
<choose>
<when test="status == '1'">
AND recharge_type = '2'
</when>
<when test="status == '2'">
AND recharge_type = '3'
</when>
</choose>
</if>
<if test="isRefund != null and isRefund.size() > 0">
<if test="isRefund.contains('0') and !isRefund.contains('1')">
AND is_refunded = 0
</if>
<if test="isRefund.contains('1') and !isRefund.contains('0')">
AND is_refunded = 1
</if>
</if>
<if test="userId != null">
AND user_id = #{userId}
</if>
<if test="deptId != null">
AND d.dept_id = #{deptId}
</if>
<if test="userName != null and userName != ''">
AND user_name like concat('%', #{userName}, '%')
</if>
<!-- 数据权限 -->
${params.dataScope}
ORDER BY create_time DESC
</select>
<select id="selectEtOrderByOrderId" parameterType="Long" resultMap="EtOrderResult">
select o.order_id,
o.area_id,
@ -630,7 +695,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!--还车待审核订单数-->
<select id="getAuditOrderNum" resultType="java.lang.Integer">
select COALESCE(count(1), 0) from et_order where status = 5 and type = 1
select COALESCE(count(1), 0) from et_order where type = 1
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="timeStart != null and timeStart != ''">
AND DATE(create_time) &gt;= #{timeStart}
</if>
@ -663,6 +731,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getOrderNum2" resultType="java.lang.Integer">
select COALESCE(count(1), 0) from et_order where type = 1
<if test="timeStart != null and timeStart != ''">
AND DATE(create_time) &gt;= #{timeStart}
</if>
<if test="timeEnd != null and timeEnd != ''">
AND DATE(create_time) &lt;= #{timeEnd}
</if>
<if test="channelId != 3 or (channelId == null)">and area_id != 14 </if>
<if test="areaId != null and areaId != 0"> and area_id = #{areaId}</if>
<if test="channelId != null ">AND pay_channel = #{channelId}</if>
</select>
<select id="getServiceFee" resultType="java.math.BigDecimal">
select COALESCE(SUM(total_fee), 0) from et_order where status = 4 and type = 1 and paid = 1
<if test="timeStart != null and timeStart != ''">
@ -743,6 +824,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="getCost" resultType="java.math.BigDecimal">
select COALESCE(SUM(cost), 0) from et_order o
<where>
<if test="areaId != null and areaId != 0"> and o.area_id = #{areaId}</if>
<if test="channelId != null ">AND o.pay_channel = #{channelId}</if>
<if test="startDateStr != null and startDateStr != ''">
AND DATE(o.create_time) &gt;= #{startDateStr}
</if>
<if test="endDateStr != null and endDateStr != ''">
AND DATE(o.create_time) &lt;= #{endDateStr}
</if>
<if test="channelId != 3 or (channelId == null)">and o.area_id != 14 </if>
AND o.status = 4 and o.type = 1 and o.paid = 1
</where>
</select>
<select id="getPlatformServiceFee" resultType="java.math.BigDecimal">
SELECT COALESCE
( SUM( dd.dividend_amount ), 0 )

View File

@ -21,11 +21,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="orderRefund" column="order_refund" />
<result property="orderSurplus" column="order_surplus" />
<result property="depositSurplus" column="deposit_surplus" />
<result property="orderCount" column="order_count" />
<result property="withdrawServiceFee" column="withdraw_service_fee" />
<result property="channelCost" column="channel_cost" />
</resultMap>
<sql id="selectEtReconciliationVo">
select reconciliation_id, order_paid, total_amount, deposit_paid, pay_channel, create_time, day, deposit_refund, deduction_amount,
handling_charge, user_receipts, settlement_amount, platform_service_fee, order_refund, order_surplus, deposit_surplus from et_reconciliation
handling_charge, user_receipts, settlement_amount, platform_service_fee, order_refund, order_surplus, deposit_surplus,
order_count, withdraw_service_fee, channel_cost from et_reconciliation
</sql>
<select id="selectEtReconciliationList" parameterType="EtReconciliation" resultMap="EtReconciliationResult">
@ -47,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND `day` &lt;= #{params.endTime}
</if>
<if test="day != null "> and day = #{day}</if>
</where>
order by `day` desc
</select>
@ -74,6 +79,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="depositSurplus != null">deposit_surplus,</if>
<if test="orderRefund != null">order_refund,</if>
<if test="orderSurplus != null">order_surplus,</if>
<if test="orderCount != null">order_count,</if>
<if test="withdrawServiceFee != null">withdraw_service_fee,</if>
<if test="channelCost != null">channel_cost,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderPaid != null">#{orderPaid},</if>
@ -91,6 +99,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="depositSurplus != null">#{depositSurplus},</if>
<if test="orderRefund != null">#{orderRefund},</if>
<if test="orderSurplus != null">#{orderSurplus},</if>
<if test="orderCount != null">#{orderCount},</if>
<if test="withdrawServiceFee != null">#{withdrawServiceFee},</if>
<if test="channelCost != null">#{channelCost},</if>
</trim>
</insert>
@ -112,6 +123,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="depositSurplus != null">deposit_surplus = #{depositSurplus},</if>
<if test="orderRefund != null">order_refund = #{orderRefund},</if>
<if test="orderSurplus != null">order_surplus = #{orderSurplus},</if>
<if test="orderCount != null">order_count = #{orderCount},</if>
<if test="withdrawServiceFee != null">withdraw_service</if>
<if test="channelCost != null">channel_cost = #{channelCost},</if>
</trim>
where reconciliation_id = #{reconciliationId}
</update>

View File

@ -46,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="refundResult != null "> and r.refund_result = #{refundResult}</if>
<if test="refundType != null "> and r.type = #{refundType}</if>
<if test="deptId != null and deptId != ''"> and d.dept_id = #{deptId}</if>
<if test="userId != null and userId != ''"> and u.user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and u.user_name like concat('%', #{userName}, '%')</if>
<!-- 数据范围过滤 -->
${params.dataScope}