|
|
@@ -2,6 +2,7 @@ package com.yc.ship.module.trade.service.otc.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
@@ -93,6 +94,7 @@ import com.yc.ship.module.system.api.dict.DictDataApi;
|
|
|
import com.yc.ship.module.system.api.dict.dto.DictDataRespDTO;
|
|
|
import com.yc.ship.module.system.api.notify.NotifyMessageSendApi;
|
|
|
import com.yc.ship.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
|
|
|
+import com.yc.ship.module.system.api.permission.PermissionApi;
|
|
|
import com.yc.ship.module.system.api.user.AdminUserApi;
|
|
|
import com.yc.ship.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import com.yc.ship.module.trade.api.dto.TradeOrderPayDTO;
|
|
|
@@ -110,6 +112,8 @@ import com.yc.ship.module.trade.dal.dataobject.invoice.InvoiceDO;
|
|
|
import com.yc.ship.module.trade.dal.dataobject.order.*;
|
|
|
import com.yc.ship.module.trade.dal.dataobject.orderjz.OrderJzDO;
|
|
|
import com.yc.ship.module.trade.dal.dataobject.orderpolicy.OrderPolicyDO;
|
|
|
+import com.yc.ship.module.trade.dal.dataobject.refund.RefundDO;
|
|
|
+import com.yc.ship.module.trade.dal.dataobject.refund.RefundRecordDO;
|
|
|
import com.yc.ship.module.trade.dal.dataobject.tradeOrderaudit.TradeOrderAuditDO;
|
|
|
import com.yc.ship.module.trade.dal.mysql.audituser.AuditUserMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.contract.ContractMapper;
|
|
|
@@ -117,6 +121,8 @@ import com.yc.ship.module.trade.dal.mysql.insurance.InsuranceMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.order.*;
|
|
|
import com.yc.ship.module.trade.dal.mysql.orderjz.OrderJzMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.orderpolicy.OrderPolicyMapper;
|
|
|
+import com.yc.ship.module.trade.dal.mysql.refund.RefundMapper;
|
|
|
+import com.yc.ship.module.trade.dal.mysql.refund.RefundRecordMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.tradeOrderaudit.TradeOrderAuditMapper;
|
|
|
import com.yc.ship.module.trade.enums.*;
|
|
|
import com.yc.ship.module.trade.framework.annotation.TradeOrderLog;
|
|
|
@@ -190,6 +196,8 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
@Resource
|
|
|
private DictDataApi dictDataApi;
|
|
|
@Resource
|
|
|
+ private PermissionApi permissionApi;
|
|
|
+ @Resource
|
|
|
private AdminUserApi adminUserApi;
|
|
|
@Resource
|
|
|
private ProductApi productApi;
|
|
|
@@ -241,6 +249,8 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
@Resource
|
|
|
private TradeOrderPayService tradeOrderPayService;
|
|
|
@Resource
|
|
|
+ private TradeOrderPayMapper tradeOrderPayMapper;
|
|
|
+ @Resource
|
|
|
private TradeOrderRepositoryService tradeOrderRepositoryService;
|
|
|
@Resource
|
|
|
private InvoiceService invoiceService;
|
|
|
@@ -314,6 +324,12 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
@Resource
|
|
|
private TradeRefundService tradeRefundService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RefundMapper refundMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private RefundRecordMapper refundRecordMapper;
|
|
|
+
|
|
|
@Resource
|
|
|
private TradeOrderBindMapper tradeOrderBindMapper;
|
|
|
|
|
|
@@ -3947,8 +3963,34 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
*/
|
|
|
@Override
|
|
|
public File exportTouristList(TradeOrderPageReqVO reqVO) {
|
|
|
- InputStream template = getClass().getClassLoader().getResourceAsStream("templates/tourist_template_operator.xlsx");
|
|
|
- return getFile(reqVO,template, 0);
|
|
|
+ // 根据当前登录用户角色加载不同模板
|
|
|
+ LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
|
|
+ boolean isDispatch = isDispatchRole(loginUser); // 计调角色判定
|
|
|
+ String templateName;
|
|
|
+ if (isDispatch) {
|
|
|
+ // 计调:使用计调模板
|
|
|
+ templateName = "templates/tourist_template_operator.xlsx";
|
|
|
+ } else {
|
|
|
+ // 销售(或其他角色):使用销售模板
|
|
|
+ templateName = "templates/tourist_template.xlsx";
|
|
|
+ }
|
|
|
+ InputStream template = getClass().getClassLoader().getResourceAsStream(templateName);
|
|
|
+ return getFile(reqVO, template, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断当前登录用户是否为计调角色
|
|
|
+ */
|
|
|
+ private boolean isDispatchRole(LoginUser loginUser) {
|
|
|
+ if (loginUser == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 读取 jd_role 字典的 label(角色码)列表
|
|
|
+ List<String> jdRoleCodes = dictDataApi.getDictDataLabelList("jd_role");
|
|
|
+ if (CollUtil.isEmpty(jdRoleCodes)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return permissionApi.hasAnyRoles(loginUser.getId(), jdRoleCodes.toArray(new String[0]));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -4322,6 +4364,8 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
|
|
|
item.put("visitorHome", StringUtils.isEmpty(visitor.getVisitorType()) ? "" : DictFrameworkUtils.getDictDataLabel(DictTypeConstants.TOUR_TYPE, visitor.getVisitorType())); // 游客入住类型
|
|
|
|
|
|
+ item.put("jdRemark", StringUtils.isEmpty(visitor.getJdRemark()) ? "" : visitor.getJdRemark()); // 游船计划
|
|
|
+
|
|
|
item.put("birthday", StringUtils.isEmpty(visitor.getBirthday()) ? "" : visitor.getBirthday()); // 生日
|
|
|
item.put("mobile", StringUtils.isEmpty(visitor.getMobile()) ? "" : visitor.getMobile()); // 手机号
|
|
|
item.put("jz", StringUtils.isEmpty(visitor.getJz()) ? "" : visitor.getJz()); // 是否接站
|
|
|
@@ -4487,4 +4531,54 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
|
|
|
|
|
|
return CommonResult.success(respVO);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TradeOrderDO> getOrderSimpleList(Long voyageId) {
|
|
|
+ return tradeOrderMapper.getValidSimpleOrderInfoByVoyageId(voyageId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.HAND_ORDER_REFUND)
|
|
|
+ public String createHandRefundRecord(TradeRefundHandCreateReqVO createReqVO) {
|
|
|
+ long id = IdWorker.getId();
|
|
|
+ RefundDO refundDO = RefundDO.builder().id(id).orderId(createReqVO.getOrderId())
|
|
|
+ .refundAmount(createReqVO.getRefundAmount()).refundReason("手动新增线下退款记录").build();
|
|
|
+ refundMapper.insert(refundDO);
|
|
|
+ RefundRecordDO refundRecordDO = RefundRecordDO.builder()
|
|
|
+ .id(IdWorker.getId())
|
|
|
+ .refundId(id)
|
|
|
+ .refundAmount(createReqVO.getRefundAmount())
|
|
|
+ .refundStatus(createReqVO.getRefundStatus())
|
|
|
+ .refundBackType(1)
|
|
|
+ .paymentType(createReqVO.getPaymentType())
|
|
|
+ .result("手动新增线下退款记录")
|
|
|
+ .refundType(0)
|
|
|
+ .merchantNo(createReqVO.getMerchantNo())
|
|
|
+ .paymentNo(createReqVO.getPaymentNo())
|
|
|
+ .refundNo(createReqVO.getRefundNo())
|
|
|
+ .refundTime(createReqVO.getRefundTime()).build();
|
|
|
+ refundRecordMapper.insert(refundRecordDO);
|
|
|
+ TradeOrderDO tradeOrderDO = tradeOrderMapper.selectById(createReqVO.getOrderId());
|
|
|
+ BigDecimal payAmount = tradeOrderDO.getPayAmount();
|
|
|
+ tradeOrderDO.setPayAmount(tradeOrderDO.getPayAmount().subtract(createReqVO.getRefundAmount()));
|
|
|
+ tradeOrderMapper.updateById(tradeOrderDO);
|
|
|
+ TradeOrderLogUtils.setOrderInfo(tradeOrderDO.getId(), tradeOrderDO.getOrderStatus(), tradeOrderDO.getOrderStatus(),
|
|
|
+ MapUtil.<String, Object>builder()
|
|
|
+ .put("oldPayAmount", payAmount)
|
|
|
+ .put("payAmount", tradeOrderDO.getPayAmount())
|
|
|
+ .put("refundAmount", createReqVO.getRefundAmount())
|
|
|
+ .build());
|
|
|
+ List<TradeOrderPayDO> tradeOrderPayDOS =
|
|
|
+ tradeOrderPayMapper.selectList(
|
|
|
+ TradeOrderPayDO::getOrderId, createReqVO.getOrderId(),
|
|
|
+ TradeOrderPayDO::getPayStatus, "1"
|
|
|
+ );
|
|
|
+ if(tradeOrderPayDOS!=null && !tradeOrderPayDOS.isEmpty()){
|
|
|
+ TradeOrderPayDO orderPayDO = tradeOrderPayDOS.get(0);
|
|
|
+ orderPayDO.setPayAmount(tradeOrderDO.getPayAmount());
|
|
|
+ tradeOrderPayMapper.updateById(orderPayDO);
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
}
|