|
|
@@ -2,15 +2,15 @@ package com.zhongshu.card.server.core.service.payment;
|
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.github.microservice.auth.security.type.AuthType;
|
|
|
import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.github.microservice.models.hxz.*;
|
|
|
import com.github.microservice.models.type.OrderFromType;
|
|
|
import com.github.microservice.models.type.PaymentDeviceType;
|
|
|
import com.github.microservice.models.type.PaymentType;
|
|
|
-import com.zhongshu.card.client.model.payment.ExpenseFlowCount;
|
|
|
-import com.zhongshu.card.client.model.payment.ExpenseFlowModel;
|
|
|
-import com.zhongshu.card.client.model.payment.ExpenseFlowSearch;
|
|
|
-import com.zhongshu.card.client.model.payment.ExpenseRefundParam;
|
|
|
+import com.zhongshu.card.client.model.payment.*;
|
|
|
+import com.zhongshu.card.client.model.payment.statistic.BusinessMainStatisticModel;
|
|
|
+import com.zhongshu.card.client.model.payment.statistic.StatisticSearch;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
import com.zhongshu.card.client.ret.ResultMessage;
|
|
|
import com.zhongshu.card.client.service.payment.ExpenseFlowService;
|
|
|
@@ -27,8 +27,6 @@ import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
import com.zhongshu.card.server.core.domain.org.OrganizationRelation;
|
|
|
import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
|
import com.zhongshu.card.server.core.domain.payment.ExpenseFlow;
|
|
|
-import com.zhongshu.card.server.core.domain.payment.Wallet;
|
|
|
-import com.zhongshu.card.server.core.domain.payment.WalletRecharge;
|
|
|
import com.zhongshu.card.server.core.domain.school.CardInfo;
|
|
|
import com.zhongshu.card.server.core.domain.org.DeviceInfo;
|
|
|
import com.zhongshu.card.server.core.domain.school.DeviceBind;
|
|
|
@@ -51,6 +49,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author TRX
|
|
|
@@ -114,6 +115,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
|
|
|
expenseFlow.setYear(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyy));
|
|
|
expenseFlow.setMonth(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternMM));
|
|
|
+ expenseFlow.setWeek(DateUtils.getCurrentWeekInYear() + "");
|
|
|
expenseFlow.setPaymentTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
|
|
|
|
|
|
// 消费订单号
|
|
|
@@ -457,8 +459,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
result.setAmount(CommonUtil.turnMoney2Show(expenseFlow.getPayAmount()));
|
|
|
|
|
|
if (expenseFlow.getPaymentType() == PaymentType.UserWallet) {
|
|
|
- com.zhongshu.payment.client.ret.ResultContent<WalletModel> content = walletFeignService.getWallet(
|
|
|
- expenseFlow.getProjectOid(), WalletType.User, "", expenseFlow.getUserId());
|
|
|
+ com.zhongshu.payment.client.ret.ResultContent<WalletModel> content = walletFeignService.getWallet(expenseFlow.getProjectOid(), WalletType.User, "", expenseFlow.getUserId());
|
|
|
if (content.isSuccess()) {
|
|
|
WalletModel walletModel = content.getContent();
|
|
|
if (ObjectUtils.isNotEmpty(walletModel)) {
|
|
|
@@ -489,6 +490,49 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 商户订单查询
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @param pageable
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultContent<Page<ExpenseFlowModel>> pageBusMainOrder(ExpenseFlowSearch param, Pageable pageable) {
|
|
|
+ // 查询支付成功的
|
|
|
+ param.setIsPaySuccess(Boolean.TRUE);
|
|
|
+ // 用户搜索的商户
|
|
|
+ List<String> shopOids = getSearchAllShopOid(param);
|
|
|
+ if (ObjectUtils.isEmpty(shopOids)) {
|
|
|
+ return ResultContent.buildFail("请选择查询商户或所有的");
|
|
|
+ }
|
|
|
+ param.setShopOids(shopOids);
|
|
|
+ Page<ExpenseFlow> page = expenseFlowDao.page(pageable, param);
|
|
|
+ return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询搜索条件
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<String> getSearchAllShopOid(ExpenseFlowSearch param) {
|
|
|
+ List<String> shopOids = new ArrayList<String>();
|
|
|
+ if (param.getIsAllBusinessMain() != null && param.getIsAllBusinessMain()) {
|
|
|
+ // 查询当前用户所有的商户信息
|
|
|
+ List<Organization> orgs = organizationService.getUserAllOrgs(getCurrentUserId(), AuthType.BusinessMain);
|
|
|
+ if (ObjectUtils.isNotEmpty(orgs)) {
|
|
|
+ shopOids = orgs.stream().map(it -> it.getOid()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (StringUtils.isNotEmpty(param.getShopOid())) {
|
|
|
+ shopOids.add(param.getShopOid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return shopOids;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 统计用户支出总数
|
|
|
*
|
|
|
@@ -496,8 +540,8 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResultContent<ExpenseFlowCount> countPayment(ExpenseFlowSearch param) {
|
|
|
- return ResultContent.buildSuccess(expenseFlowDao.countPayment(param));
|
|
|
+ public ResultContent<ExpenseFlowCount> countUserPayment(ExpenseFlowSearch param) {
|
|
|
+ return ResultContent.buildSuccess(expenseFlowDao.countUserPayment(param));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -511,7 +555,46 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
param.setStartTime(DateUtils.getDayStartTime(System.currentTimeMillis()));
|
|
|
param.setEndTime(DateUtils.getDayEndTime(System.currentTimeMillis()));
|
|
|
param.setUserId(userId);
|
|
|
- return ResultContent.buildSuccess(expenseFlowDao.countPayment(param));
|
|
|
+ param.setIsPaySuccess(Boolean.TRUE);
|
|
|
+ return ResultContent.buildSuccess(expenseFlowDao.countUserPayment(param));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计商户的数据
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent<ExpenseFlowCount> countBuinessMainPayment(ExpenseFlowSearch param) {
|
|
|
+ // 查询支付成功的
|
|
|
+ param.setIsPaySuccess(Boolean.TRUE);
|
|
|
+ // 用户搜索的商户
|
|
|
+ List<String> shopOids = getSearchAllShopOid(param);
|
|
|
+ if (ObjectUtils.isEmpty(shopOids)) {
|
|
|
+ return ResultContent.buildFail("请选择查询商户或所有的");
|
|
|
+ }
|
|
|
+ param.setShopOids(shopOids);
|
|
|
+ ExpenseFlowCount flowCount = expenseFlowDao.countBuinessMainPayment(param);
|
|
|
+ return ResultContent.buildSuccess(flowCount);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商户首页统计
|
|
|
+ *
|
|
|
+ * @param statisticSearch
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent businessMainPageStatistic(StatisticSearch statisticSearch) {
|
|
|
+ BusinessMainStatisticModel statisticModel = new BusinessMainStatisticModel();
|
|
|
+
|
|
|
+ ExpenseFlowSearch param = new ExpenseFlowSearch();
|
|
|
+ param.setIsPaySuccess(Boolean.TRUE);
|
|
|
+ BeanUtils.copyProperties(statisticSearch, param);
|
|
|
+ // 统计模型,按 月、周
|
|
|
+ StatisticType statisticType = param.getStatisticType();
|
|
|
+
|
|
|
+
|
|
|
+ return ResultContent.buildSuccess(statisticModel);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -562,6 +645,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
expenseFlow.setApplicant(getCurrentUserId());
|
|
|
// 退款人
|
|
|
expenseFlow.setRefundUserId(getCurrentUserId());
|
|
|
+ expenseFlow.setRefundAMount(expenseFlow.getPayAmount());
|
|
|
expenseFlow.setOrderType(OrderType.REFUNDED);
|
|
|
expenseFlow.setRefundState(RefundState.Refunded);
|
|
|
expenseFlow.setRefuseRemark("退款成功");
|