|
@@ -4,11 +4,13 @@ import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import cn.hutool.log.StaticLog;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.injector.methods.SelectBatchByIds;
|
|
|
import com.pj.api.client.admin.AdminInterface;
|
|
|
import com.pj.api.client.async_server.AsyncServerInterface;
|
|
|
import com.pj.api.client.level_one_server.LevelOneServerInterface;
|
|
@@ -17,6 +19,7 @@ import com.pj.api.client.payment_server.PaymentServerInterface;
|
|
|
import com.pj.api.consts.FeignFactory;
|
|
|
import com.pj.api.dto.*;
|
|
|
import com.pj.common.core.exception.ServiceException;
|
|
|
+import com.pj.common.core.text.Convert;
|
|
|
import com.pj.common.core.utils.StringUtils;
|
|
|
import com.pj.current.config.SystemObject;
|
|
|
import com.pj.current.dto.APPLoginUserInfo;
|
|
@@ -75,7 +78,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
@Autowired
|
|
|
private TbOrderMapper tbOrderMapper;
|
|
|
@Autowired
|
|
|
- TbImportOrderMapper tbImportOrderMapper;
|
|
|
+ private TbImportOrderMapper tbImportOrderMapper;
|
|
|
/**
|
|
|
* 互市组
|
|
|
*/
|
|
@@ -153,6 +156,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
*
|
|
|
* @param orderId 一级市场订单ID
|
|
|
*/
|
|
|
+ @Deprecated
|
|
|
public boolean cancelOrder(Long orderId) {
|
|
|
//获取登录用户
|
|
|
APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
@@ -208,6 +212,34 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
return tbOrderList;
|
|
|
}
|
|
|
|
|
|
+ List<OrderVo> getPeopleOrderList(SoMap so) {
|
|
|
+ //获取登录用户,登录的用户也许边民,互市组组长,一级市场商家
|
|
|
+ APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
+ if (appLoginInfo.getUserType() != 2) throw new RuntimeException("当前登陆用户不是边民组长!");
|
|
|
+
|
|
|
+ TbPeople tbPeople = tbPeopleMapper.selectById(appLoginInfo.getFk());
|
|
|
+ if (tbPeople.getGroupId() == null) throw new RuntimeException("当前登陆用户不在互助组内!");
|
|
|
+
|
|
|
+ List<TbPeople> peopleList = tbPeopleService.lambdaQuery().eq(TbPeople::getGroupId, tbPeople.getGroupId()).list();
|
|
|
+ List<Long> idList = peopleList.stream().map(people -> people.getId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<TbOrder> tbOrderList = tbOrderMapper.getList(so);
|
|
|
+
|
|
|
+ List<TbOrder> list = tbOrderList.stream().filter(order -> idList.contains(order.getBuyUserId())).collect(Collectors.toList());
|
|
|
+ List<OrderVo> orderVoList = new ArrayList<>();
|
|
|
+ for (TbOrder tbOrder : list) {
|
|
|
+ OrderVo orderVo = new OrderVo();
|
|
|
+ BeanUtils.copyProperties(tbOrder, orderVo);
|
|
|
+ for (TbPeople people : peopleList) {
|
|
|
+ if (people.getId().compareTo(tbOrder.getBuyUserId()) == 0 || people.getId().equals(tbOrder.getBuyUserId())) {
|
|
|
+ orderVo.setPhone(people.getPhone());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderVoList.add(orderVo);
|
|
|
+ }
|
|
|
+ return orderVoList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取当前登陆人订单集合
|
|
|
*/
|
|
@@ -425,8 +457,10 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
BeanUtils.copyProperties(htTradeSettlement, paymentDto);
|
|
|
|
|
|
paymentDto.setTradeNo(tbOrder.getTradeNo());
|
|
|
+ paymentDto.setCodeTs(tbOrder.getCodeTs());
|
|
|
paymentDto.setBuyQty(tbOrder.getBuyQty());
|
|
|
paymentDto.setGrossWt(tbOrder.getGrossWt());
|
|
|
+ paymentDto.setNetWt(tbOrder.getNetWt());
|
|
|
paymentDto.setGoodsName(tbOrder.getGoodsNames());
|
|
|
paymentDto.setGoodsUnit(tbOrder.getGoodsUnit());
|
|
|
paymentDto.setDeclPrice(tbOrder.getDeclPrice());
|
|
@@ -437,27 +471,36 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
|
|
|
TbPeople tbPeople = tbPeopleService.getById(tbOrder.getBuyUserId());
|
|
|
StaticLog.info("tbPeople:{}", JSONUtil.toJsonStr(tbPeople));
|
|
|
- if (tbPeople != null) {
|
|
|
- paymentDto.setBankCode(tbPeople.getBankCode());
|
|
|
- paymentDto.setBankName(tbPeople.getBankName());
|
|
|
- paymentDto.setBorderName(tbPeople.getName());
|
|
|
- paymentDto.setBorderidno(tbPeople.getIdCard());
|
|
|
- paymentDto.setBorderTel(tbPeople.getPhone());
|
|
|
+ if (tbPeople == null) {
|
|
|
+ throw new AjaxError("查询不到边民信息");
|
|
|
}
|
|
|
+ if (StrUtil.isEmpty(tbPeople.getBankCode())) {
|
|
|
+ throw new AjaxError(tbPeople.getName() + "银行账号不完善");
|
|
|
+ }
|
|
|
+ paymentDto.setBankCode(tbPeople.getBankCode());
|
|
|
+ paymentDto.setBankName(tbPeople.getBankName());
|
|
|
+ paymentDto.setBankNo(tbPeople.getBankNo());
|
|
|
+ paymentDto.setBorderName(tbPeople.getName());
|
|
|
+ paymentDto.setBorderidno(tbPeople.getIdCard());
|
|
|
+ paymentDto.setBorderTel(tbPeople.getPhone());
|
|
|
+ paymentDto.setPapersType(tbPeople.getPapersType());
|
|
|
+ paymentDto.setBorderNationality(tbPeople.getNationality());
|
|
|
|
|
|
TbShop tbShop = tbShopService.findByCode(htTradeSettlement.getShopNo());
|
|
|
- StaticLog.info("tbShop:{}", JSONUtil.toJsonStr(tbShop));
|
|
|
- if (tbShop != null) {
|
|
|
- paymentDto.setOwnerName(tbShop.getOwnerName());
|
|
|
- paymentDto.setOwnerIdtype(tbShop.getOwnerIdtype());
|
|
|
- paymentDto.setBankAccount(tbShop.getBankAccount());
|
|
|
- paymentDto.setBank(tbShop.getBank());
|
|
|
- paymentDto.setOwnerTel(tbShop.getOwnerTel());
|
|
|
- paymentDto.setShopSccd(tbShop.getShopSccd());
|
|
|
- paymentDto.setNationality(tbShop.getNationality());
|
|
|
+ if (tbShop == null) {
|
|
|
+ throw new AjaxError("查询不到商铺信息");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ if (StrUtil.isEmpty(tbShop.getBankAccount())) {
|
|
|
+ throw new AjaxError(tbShop.getShopName() + "银行账号不完善");
|
|
|
+ }
|
|
|
+ StaticLog.info("tbShop:{}", JSONUtil.toJsonStr(tbShop));
|
|
|
+ paymentDto.setOwnerName(tbShop.getOwnerName());
|
|
|
+ paymentDto.setOwnerIdtype(tbShop.getOwnerIdtype());
|
|
|
+ paymentDto.setBankAccount(tbShop.getBankAccount());
|
|
|
+ paymentDto.setBank(tbShop.getBank());
|
|
|
+ paymentDto.setOwnerTel(tbShop.getOwnerTel());
|
|
|
+ paymentDto.setShopSccd(tbShop.getShopSccd());
|
|
|
+ paymentDto.setNationality(tbShop.getNationality());
|
|
|
return paymentDto;
|
|
|
}
|
|
|
|
|
@@ -488,9 +531,9 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
|
|
|
boolean update = super.updateById(tbOrder);
|
|
|
// TODO: 2023/8/28 边民发起支付申请,调用银行接口:验证边民支付信息,将货款先存入银行第三方账户,并给出回执
|
|
|
- PaymentDto paymentDto = this.getPaymentData(tbOrder);
|
|
|
+ /*PaymentDto paymentDto = this.getPaymentData(tbOrder);
|
|
|
StaticLog.info("\nsendSXB010——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
- paymentServerInterface.sendSXB010(paymentDto);
|
|
|
+ paymentServerInterface.sendSXB010(paymentDto);*/
|
|
|
|
|
|
return update;
|
|
|
}
|
|
@@ -499,17 +542,19 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
* 边民订单确认-收到银行扣款回执——SXB011——SXB012
|
|
|
*
|
|
|
* @param tradeNo 一级市场边民订单-订单编号
|
|
|
+ * @param note 回执内容
|
|
|
* @param SXB010Status 回执状态-1=扣款成功 2=扣款失败
|
|
|
*/
|
|
|
- public boolean confirmOrderFromBank(String tradeNo, Integer SXB010Status) {
|
|
|
+ public boolean confirmOrderFromBank(String tradeNo, String note, Integer SXB010Status) {
|
|
|
LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(TbOrder::getTradeNo, tradeNo);
|
|
|
List<TbOrder> tbOrderList = this.list(wrapper);
|
|
|
if (tbOrderList.size() <= 0) {
|
|
|
- throw new RuntimeException("边民订单确认-收到银行扣款回执:订单不存在");
|
|
|
+ log.error("收到银行回执:{},{},{},订单不存在", tradeNo, note, SXB010Status);
|
|
|
+ return false;
|
|
|
}
|
|
|
TbOrder tbOrder = tbOrderList.get(0);
|
|
|
-
|
|
|
+ tbOrder.setSxbNote(note);
|
|
|
// TODO: 2023/8/29 更新状态保存交易记录
|
|
|
if (2 == SXB010Status) {//扣款失败
|
|
|
tbOrder.setSxb010Status(2)
|
|
@@ -517,15 +562,17 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
} else if (1 == SXB010Status) {//扣款成功
|
|
|
tbOrder.setSxb010Status(1)
|
|
|
.setSxb010StatusTime(new Date());
|
|
|
-
|
|
|
- /*tbOrder.setPeopleConfirmTime(new Date())
|
|
|
- .setPeopleConfirmStatus(ConfirmStatus.CONFIRM_STATUS_ONE.getCode())
|
|
|
- .setUpdateTime(new Date());*/
|
|
|
- if ("1".equals(tbOrder.getDeclareType())) {
|
|
|
- // TODO: 2023/8/29 调用航通009接口,发送信息
|
|
|
- sendConfirmMsgToHt(tbOrder);
|
|
|
- //当declareType为边民时,不需要走后续两个确认,订单状态改为已完成
|
|
|
- //tbOrder.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
+ //如果已经过了卡三,则补发送一次通关报文给银行
|
|
|
+ if(tbOrder.getFinishStatus()==1){
|
|
|
+ HtTradeSettlement htTradeSettlement=htTradeSettlementService.getById(tbOrder.getSaleMainId());
|
|
|
+ //TODO: 2023/8/30 补发通关报文
|
|
|
+ PaymentDto paymentDto2 = new PaymentDto();
|
|
|
+ paymentDto2.setTradeNos(tradeNo);
|
|
|
+ paymentDto2.setVoyageNo(htTradeSettlement.getVoyageNo());
|
|
|
+ paymentDto2.setVeNo(tbOrder.getVeNo());
|
|
|
+ StaticLog.info("\n扣款成功,补发通关批文 sendSXB023——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto2));
|
|
|
+ paymentServerInterface.sendSXB023(paymentDto2);
|
|
|
+ //todo 补发结关信息
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -578,13 +625,12 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
|
|
|
//测试用,跳过银行接口
|
|
|
// wrapper.set(TbOrder::getFinishStatus, FinishStatus.FINISH_STATUS_ONE.getCode());//已完成->完成后可以进行转售
|
|
|
- wrapper.set(TbOrder::getFinishTime, new Date());
|
|
|
+// wrapper.set(TbOrder::getFinishTime, new Date());
|
|
|
|
|
|
wrapper.eq(TbOrder::getId, orderId);
|
|
|
boolean result = update(wrapper);
|
|
|
|
|
|
- if (result && !"1".equals(tbOrder.getDeclareType())
|
|
|
- && tbOrder.getPeopleConfirmStatus() == 1 && tbOrder.getCooperEntrustStatus() == 1) {
|
|
|
+ if (result && tbOrder.getPeopleConfirmStatus() == 1) {
|
|
|
// TODO: 2023/8/29 调用航通009接口,发送信息
|
|
|
sendConfirmMsgToHt(tbOrder);
|
|
|
}
|
|
@@ -594,14 +640,19 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
/**
|
|
|
* 发送009信息到航通
|
|
|
*/
|
|
|
- private void sendConfirmMsgToHt(TbOrder tbOrder) {
|
|
|
+ public void sendConfirmMsgToHt(TbOrder tbOrder) {
|
|
|
TbPeople tbPeople = tbPeopleService.getById(tbOrder.getBuyUserId());
|
|
|
+ if (tbPeople == null) {
|
|
|
+ StaticLog.info("\n--------------发送009信息到航通————边民不存在!!!");
|
|
|
+ throw new AjaxError("--------------发送009信息到航通,边民不存在");
|
|
|
+ }
|
|
|
PeopleConfirmDTO peopleConfirmDTO = new PeopleConfirmDTO();
|
|
|
peopleConfirmDTO.setBorderName(tbOrder.getBuyUserName());
|
|
|
peopleConfirmDTO.setIdno(tbPeople.getIdCard());
|
|
|
peopleConfirmDTO.setSettleBillNo(tbOrder.getSettleBillNo());
|
|
|
peopleConfirmDTO.setPreIeportNo(tbOrder.getPreIeportNo());
|
|
|
- log.info("sendConfirmMsgToHt:{}", JSONUtil.toJsonStr(peopleConfirmDTO));
|
|
|
+ peopleConfirmDTO.setBorderPutrecNo(tbOrder.getBorderPutrecNo());
|
|
|
+ StaticLog.info("\n--------------发送009信息到航通,sendConfirmMsgToHt:{}", JSONUtil.toJsonStr(peopleConfirmDTO));
|
|
|
FeignFactory.asyncServerInterface.sendConfirm(peopleConfirmDTO);
|
|
|
}
|
|
|
|
|
@@ -614,11 +665,23 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
TbPeople tbPeople = tbPeopleMapper.selectById(appLoginInfo.getFk());
|
|
|
if (tbPeople == null) throw new ServiceException("当前用户不存在,请联系管理员!");
|
|
|
- List<TbOrder> orderList = findByBuyUserId(appLoginInfo.getFk());
|
|
|
+ List<TbOrder> list = findByBuyUserId(appLoginInfo.getFk());
|
|
|
+
|
|
|
+ //互助社未确认关联的大订单时边民不能做订单确认
|
|
|
+ List<TbOrder> orderList = new ArrayList<>();
|
|
|
+ for (TbOrder order : list) {
|
|
|
+ QueryWrapper<HtTradeSettlement> htWrapper = new QueryWrapper<>();
|
|
|
+ htWrapper.lambda().eq(HtTradeSettlement::getId, order.getSaleMainId())
|
|
|
+ .eq(HtTradeSettlement::getHzsConfirmStatus, 1);
|
|
|
+ List<HtTradeSettlement> tradeSettlementList = htTradeSettlementService.list(htWrapper);
|
|
|
+ if (tradeSettlementList.size() > 0) {
|
|
|
+ orderList.add(order);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
OrderVo orderVo = new OrderVo();
|
|
|
//被委托订单,并且三个状态中有一个未确认
|
|
|
- List<TbOrder> declareList2 = orderList.stream().filter(item -> !"1".equals(item.getDeclareType()) &&
|
|
|
- (item.getPeopleConfirmStatus() == 0 || item.getCooperEntrustStatus() == 0 || item.getApplyConfirmStatus() == 0)).collect(Collectors.toList());
|
|
|
+ List<TbOrder> declareList2 = orderList.stream().filter(item -> item.getApplyConfirmStatus() == 0).collect(Collectors.toList());
|
|
|
if (declareList2.size() > 0) {
|
|
|
if (1 == cooper_entrust) {
|
|
|
List<Long> removeList = new ArrayList<>();
|
|
@@ -680,11 +743,14 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
return update;
|
|
|
}
|
|
|
|
|
|
- /** 订单补扣款 */
|
|
|
- public boolean deduction(Long id){
|
|
|
+ /**
|
|
|
+ * 订单补扣款——单个订单
|
|
|
+ */
|
|
|
+ public boolean deduction(Long id) {
|
|
|
TbOrder tbOrder = getById(id);
|
|
|
if (tbOrder == null) {
|
|
|
- throw new AjaxError("订单不存在");
|
|
|
+ StaticLog.error("\n---------补扣款失败:{}不存在", id);
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
PaymentDto paymentDto = this.getPaymentData(tbOrder);
|
|
@@ -694,21 +760,60 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
tbOrder.setDeductionCount(tbOrder.getDeductionCount() + 1);
|
|
|
tbOrder.setDeductionTime(new Date());
|
|
|
|
|
|
- boolean update = super.updateById(tbOrder);
|
|
|
- return update;
|
|
|
+ return super.updateById(tbOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单补扣款——按车,并且未扣款
|
|
|
+ */
|
|
|
+ public boolean deductionByVeNo(String veNo, Long id) {
|
|
|
+ LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(TbOrder::getVeNo, veNo);
|
|
|
+ wrapper.eq(TbOrder::getSaleMainId, id);
|
|
|
+ wrapper.ne(TbOrder::getSxb010Status, 1).orderByDesc(TbOrder::getCreateTime);
|
|
|
+ List<TbOrder> tbOrders = tbOrderMapper.selectList(wrapper);
|
|
|
+ if (!tbOrders.isEmpty()) {
|
|
|
+ for (TbOrder tbOrder : tbOrders) {
|
|
|
+ PaymentDto paymentDto = this.getPaymentData(tbOrder);
|
|
|
+ StaticLog.info("\n---订单补扣款——按车---sendSXB010——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
+ paymentServerInterface.sendSXB010(paymentDto);
|
|
|
+
|
|
|
+ tbOrder.setDeductionCount(tbOrder.getDeductionCount() + 1);
|
|
|
+ tbOrder.setDeductionTime(new Date());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return super.updateBatchById(tbOrders);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TbOrder> getDeductionByVeNoList(SoMap so) {
|
|
|
+ LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(TbOrder::getVeNo, so.getString("veNo"));
|
|
|
+ wrapper.eq(TbOrder::getSaleMainId, so.getLong("id"));
|
|
|
+ wrapper.ne(TbOrder::getSxb010Status, 1).orderByDesc(TbOrder::getCreateTime);
|
|
|
+ List<TbOrder> tbOrders = tbOrderMapper.selectList(wrapper);
|
|
|
+ return tbOrders;
|
|
|
}
|
|
|
|
|
|
/*----- 正常业务逻辑 rpc远程调用 -----*/
|
|
|
|
|
|
+ /**
|
|
|
+ * 航通发起的退单
|
|
|
+ *
|
|
|
+ * @param htDeclareChargebackDto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
//进出口申报单退单-逻辑处理
|
|
|
public boolean chargeback(HtDeclareChargebackDto htDeclareChargebackDto) {
|
|
|
//查询出被退单的所有边民订单
|
|
|
LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(TbOrder::getTradeAreaId, htDeclareChargebackDto.getFieldCode());
|
|
|
wrapper.eq(TbOrder::getPreNo, htDeclareChargebackDto.getBillNo());
|
|
|
+ wrapper.eq(TbOrder::getChargebacks, 0);
|
|
|
List<TbOrder> tbOrderList = this.list(wrapper);
|
|
|
|
|
|
if (tbOrderList.size() <= 0) {
|
|
|
+ log.error("进出口申报单退单:{}不存在", JSONUtil.toJsonStr(htDeclareChargebackDto));
|
|
|
return false;
|
|
|
}
|
|
|
// TODO: 2023/11/27 查验不通过,车辆不通过卡3,调用银行退款划扣申请,从银行第三方账户,退回至边民借记卡账户
|
|
@@ -717,23 +822,27 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
StaticLog.info("\nsendSXB013(进出口申报单退单)——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
paymentServerInterface.sendSXB013(paymentDto);
|
|
|
});
|
|
|
-
|
|
|
+ Date now = new Date();
|
|
|
//修改交易结算单(大订单)的查验结果
|
|
|
LambdaUpdateWrapper<HtTradeSettlement> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.set(HtTradeSettlement::getCheckPassStatus, 2);//查验结果[1=查验通过 2=查验不通过]
|
|
|
- updateWrapper.set(HtTradeSettlement::getCheckPassTime, new Date());//查验时间(不通过)
|
|
|
+ updateWrapper.set(HtTradeSettlement::getChargebacks, 1);
|
|
|
+ updateWrapper.set(HtTradeSettlement::getChargebacksTime, now);
|
|
|
updateWrapper.eq(HtTradeSettlement::getFieldCode, htDeclareChargebackDto.getFieldCode());
|
|
|
updateWrapper.eq(HtTradeSettlement::getDeclareId, htDeclareChargebackDto.getDeclareId());
|
|
|
+ updateWrapper.eq(HtTradeSettlement::getCheckPassStatus, 0);
|
|
|
boolean update = htTradeSettlementService.update(updateWrapper);
|
|
|
|
|
|
//修改边民订单的查验结果
|
|
|
LambdaUpdateWrapper<TbOrder> updateWrapper1 = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper1.set(TbOrder::getRefundStatus, 3);//退款中
|
|
|
- updateWrapper1.set(TbOrder::getRefundTime, new Date());//退款时间
|
|
|
- updateWrapper1.set(TbOrder::getCheckPassStatus, 2);//查验结果[1=查验通过 2=查验不通过]
|
|
|
- updateWrapper1.set(TbOrder::getCheckPassTime, new Date());//查验时间(不通过)
|
|
|
+ updateWrapper1.set(TbOrder::getRefundTime, now);//退款时间
|
|
|
+ updateWrapper1.set(TbOrder::getCheckPassTime, now);//查验时间(不通过)
|
|
|
+ updateWrapper1.set(TbOrder::getChargebacks, 1);
|
|
|
+ updateWrapper1.set(TbOrder::getChargebacksTime, now);
|
|
|
+
|
|
|
updateWrapper1.eq(TbOrder::getTradeAreaId, htDeclareChargebackDto.getFieldCode());
|
|
|
updateWrapper1.eq(TbOrder::getPreNo, htDeclareChargebackDto.getBillNo());
|
|
|
+ updateWrapper1.eq(TbOrder::getChargebacks, 0);
|
|
|
boolean update1 = this.update(updateWrapper1);
|
|
|
|
|
|
return update && update1;
|
|
@@ -745,7 +854,8 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
wrapper.eq(TbOrder::getTradeNo, tradeNo);
|
|
|
List<TbOrder> tbOrderList = this.list(wrapper);
|
|
|
if (tbOrderList.size() <= 0) {
|
|
|
- throw new RuntimeException("收到银行退款回执:订单不存在");
|
|
|
+ log.error("收到银行退款回执:{}不存在", tradeNo);
|
|
|
+ return false;
|
|
|
}
|
|
|
TbOrder tbOrder = tbOrderList.get(0);
|
|
|
|
|
@@ -757,45 +867,129 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
return updateById(tbOrder);
|
|
|
}
|
|
|
|
|
|
- // TODO: 2023/8/28 系统接收到航通007接口信息:车辆已出一级市场(系统接收到这个信息时,证明已经查验通过,不会有进出口申报单退单)
|
|
|
- public boolean orderFinish(HtPassCardDTO htPassCardDTO) {
|
|
|
- String billCode = htPassCardDTO.getBillCode();
|
|
|
- //获取出了一级市场的所有边民订单
|
|
|
- LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(TbOrder::getPreNo, billCode);
|
|
|
- List<TbOrder> tbOrders = tbOrderMapper.selectList(wrapper);
|
|
|
- if (tbOrders.isEmpty()) {
|
|
|
- throw new ServiceException(" ------接收到航通007车辆出卡三接口信息,当前获取到的一级市场的边民订单为空。 单证代码billCode = " + billCode + "\n");
|
|
|
+ /**
|
|
|
+ * 订单补推结关信息给银行
|
|
|
+ */
|
|
|
+ public boolean sendCXB001(Long id) {
|
|
|
+ TbOrder tbOrder = getById(id);
|
|
|
+ if (tbOrder == null) {
|
|
|
+ StaticLog.error("\n----------订单补推结关信息失败:{}不存在", id);
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- TbTradeArea area = tbTradeAreaService.getById(tbOrders.get(0).getTradeAreaId());
|
|
|
- String tradeNos = "";
|
|
|
- PaymentDto paymentDto = new PaymentDto();
|
|
|
- for (TbOrder tbOrder : tbOrders) {
|
|
|
- tradeNos += tbOrder.getTradeNo() + ",";
|
|
|
- //收到007结关信息后边民即可上架订单,不需等收到打款给外籍商户的成功回执SXB017才能完成订单
|
|
|
- tbOrder.setFinishTime(new Date());
|
|
|
- tbOrder.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
-
|
|
|
- //todo: 收到航通007报文即收到海关结关信息,转发结关信息给到银行
|
|
|
- paymentDto.setTradeNo(tbOrder.getTradeNo());
|
|
|
- paymentDto.setDeclTime(htPassCardDTO.getCheckTime());
|
|
|
- paymentDto.setFieldCode(area.getCode());
|
|
|
- StaticLog.info("\nsendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
- paymentServerInterface.sendCXB001(paymentDto);
|
|
|
- }
|
|
|
- this.updateBatchById(tbOrders);
|
|
|
+ HtTradeSettlement htTradeSettlement = htTradeSettlementService.getById(tbOrder.getSaleMainId());
|
|
|
|
|
|
+ //todo: 收到航通007报文即收到海关结关信息,转发结关信息给到银行
|
|
|
+ PaymentDto paymentDto = new PaymentDto();
|
|
|
+ paymentDto.setTradeNo(tbOrder.getTradeNo());
|
|
|
+ paymentDto.setDeclTime(htTradeSettlement.getDeclTime());
|
|
|
+ StaticLog.info("\nsendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
+ paymentServerInterface.sendCXB001(paymentDto);
|
|
|
|
|
|
- //todo: 调用银行接口发起划扣:将边民划扣至银行第三方账户的货款,支付至外籍商户的账户
|
|
|
+ //todo: 收到航通007报文即收到海关结关信息,转发通车批信息给到银行
|
|
|
PaymentDto paymentDto2 = new PaymentDto();
|
|
|
- paymentDto2.setTradeNos(tradeNos);
|
|
|
- paymentDto2.setVoyageNo(htPassCardDTO.getManifestId());
|
|
|
- paymentDto2.setVeNo(tbOrders.get(0).getVeNo());
|
|
|
- paymentDto2.setFieldCode(area.getCode());
|
|
|
+ paymentDto2.setTradeNos(tbOrder.getTradeNo());
|
|
|
+ paymentDto2.setVoyageNo(htTradeSettlement.getVoyageNo());
|
|
|
+ paymentDto2.setVeNo(tbOrder.getVeNo());
|
|
|
StaticLog.info("\nsendSXB023——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto2));
|
|
|
paymentServerInterface.sendSXB023(paymentDto2);
|
|
|
|
|
|
+
|
|
|
+ tbOrder.setFinishTime(new Date());
|
|
|
+ tbOrder.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
+
|
|
|
+ return updateById(tbOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单补推结关信息给银行——按车,并且未完成
|
|
|
+ */
|
|
|
+ public boolean sendCXB001ByVeNo(String veNo, Long id) {
|
|
|
+ LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(TbOrder::getVeNo, veNo);
|
|
|
+ wrapper.eq(TbOrder::getSaleMainId, id);
|
|
|
+ wrapper.orderByDesc(TbOrder::getCreateTime);
|
|
|
+ List<TbOrder> tbOrders = tbOrderMapper.selectList(wrapper);
|
|
|
+
|
|
|
+ if (!tbOrders.isEmpty()) {
|
|
|
+ HtTradeSettlement htTradeSettlement = htTradeSettlementService.getById(tbOrders.get(0).getSaleMainId());
|
|
|
+ String tradeNos = "";
|
|
|
+ PaymentDto paymentDto = new PaymentDto();
|
|
|
+ for (TbOrder tbOrder : tbOrders) {
|
|
|
+ tradeNos += tbOrder.getTradeNo() + ",";
|
|
|
+ //收到007结关信息后边民即可上架订单,不需等收到打款给外籍商户的成功回执SXB017才能完成订单
|
|
|
+ tbOrder.setFinishTime(new Date());
|
|
|
+ tbOrder.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
+
|
|
|
+ //todo: 收到航通007报文即收到海关结关信息,转发结关信息给到银行
|
|
|
+ paymentDto.setTradeNo(tbOrder.getTradeNo());
|
|
|
+ paymentDto.setDeclTime(htTradeSettlement.getDeclTime());
|
|
|
+ StaticLog.info("\nsendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
+ log.info("log sendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
+ paymentServerInterface.sendCXB001(paymentDto);
|
|
|
+ }
|
|
|
+ this.updateBatchById(tbOrders);
|
|
|
+
|
|
|
+ tradeNos = StringUtils.removeEnd(tradeNos, ",");
|
|
|
+ //todo: 收到航通007报文即收到海关结关信息,转发通车批信息给到银行
|
|
|
+ PaymentDto paymentDto2 = new PaymentDto();
|
|
|
+ paymentDto2.setTradeNos(tradeNos);
|
|
|
+ paymentDto2.setVoyageNo(htTradeSettlement.getVoyageNo());
|
|
|
+ paymentDto2.setVeNo(veNo);
|
|
|
+ StaticLog.info("\nsendSXB023——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto2));
|
|
|
+ paymentServerInterface.sendSXB023(paymentDto2);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TbOrder> getSendCXB001ByVeNoList(SoMap so) {
|
|
|
+ LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(TbOrder::getVeNo, so.getString("veNo"));
|
|
|
+ wrapper.eq(TbOrder::getSaleMainId, so.getLong("id"));
|
|
|
+ wrapper.orderByDesc(TbOrder::getCreateTime);
|
|
|
+ List<TbOrder> tbOrders = tbOrderMapper.selectList(wrapper);
|
|
|
+ return tbOrders;
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO: 2023/8/28 系统接收到航通007接口信息:车辆已出一级市场(系统接收到这个信息时,证明已经查验通过,不会有进出口申报单退单)
|
|
|
+ public boolean orderFinish(HtPassCardDTO htPassCardDTO) {
|
|
|
+ String billCodeStr = htPassCardDTO.getBillCode();
|
|
|
+ List<String> billCodeList = Arrays.stream(billCodeStr.split(",")).collect(Collectors.toList());
|
|
|
+ if (billCodeList.isEmpty()) {
|
|
|
+ StaticLog.error("Invalid bill code:{}", JSONUtil.toJsonStr(htPassCardDTO));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //获取出了一级市场的所有边民订单
|
|
|
+ LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(TbOrder::getPreIeportNo, billCodeList);
|
|
|
+ wrapper.ne(TbOrder::getFinishStatus, 1).orderByDesc(TbOrder::getCreateTime);
|
|
|
+ List<TbOrder> tbOrders = tbOrderMapper.selectList(wrapper);
|
|
|
+ if (!tbOrders.isEmpty()) {
|
|
|
+ String tradeNos = "";
|
|
|
+ PaymentDto paymentDto = new PaymentDto();
|
|
|
+ for (TbOrder tbOrder : tbOrders) {
|
|
|
+ tradeNos += tbOrder.getTradeNo() + ",";
|
|
|
+ //收到007结关信息后边民即可上架订单,不需等收到打款给外籍商户的成功回执SXB017才能完成订单
|
|
|
+ tbOrder.setFinishTime(new Date());
|
|
|
+ tbOrder.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
+
|
|
|
+ //todo: 收到航通007报文即收到海关结关信息,转发结关信息给到银行
|
|
|
+ paymentDto.setTradeNo(tbOrder.getTradeNo());
|
|
|
+ paymentDto.setDeclTime(htPassCardDTO.getCheckTime());
|
|
|
+ StaticLog.info("\nsendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
+ paymentServerInterface.sendCXB001(paymentDto);
|
|
|
+ }
|
|
|
+ this.updateBatchById(tbOrders);
|
|
|
+
|
|
|
+ tradeNos = StringUtils.removeEnd(tradeNos, ",");
|
|
|
+ //todo: 收到航通007报文即收到海关结关信息,转发通车批信息给到银行
|
|
|
+ PaymentDto paymentDto2 = new PaymentDto();
|
|
|
+ paymentDto2.setTradeNos(tradeNos);
|
|
|
+ paymentDto2.setVoyageNo(htPassCardDTO.getManifestId());
|
|
|
+ paymentDto2.setVeNo(tbOrders.get(0).getVeNo());
|
|
|
+ StaticLog.info("\nsendSXB023——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto2));
|
|
|
+ paymentServerInterface.sendSXB023(paymentDto2);
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -814,8 +1008,8 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
// 更新状态保存交易记录
|
|
|
if (2 == SXB023Status) {
|
|
|
tbOrderList.forEach(order -> {
|
|
|
- order.setTradeStatus(TradeStatus.TRADE_STATUS_Two.getCode()); //支付失败
|
|
|
- order.setTradeTime(new Date()); //支付回执时间
|
|
|
+ order.setTradeStatus(TradeStatus.TRADE_STATUS_Two.getCode()); //打款失败
|
|
|
+ order.setTradeTime(new Date()); //打款回执时间
|
|
|
order.setUpdateTime(new Date());
|
|
|
|
|
|
boolean result = updateById(order);
|
|
@@ -827,8 +1021,8 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
htTradeSettlement.setFinishStatus(1).setFinishTime(new Date());
|
|
|
htTradeSettlementService.updateById(htTradeSettlement);
|
|
|
tbOrderList.forEach(order -> {
|
|
|
- order.setTradeStatus(TradeStatus.TRADE_STATUS_ONE.getCode()); //已支付
|
|
|
- order.setTradeTime(new Date()); //支付回执时间
|
|
|
+ order.setTradeStatus(TradeStatus.TRADE_STATUS_ONE.getCode()); //打款成功
|
|
|
+ order.setTradeTime(new Date()); //打款回执时间
|
|
|
order.setPayType(0); //支付类型
|
|
|
order.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode()); //已完成->完成后可以进行转售
|
|
|
order.setFinishTime(new Date());
|
|
@@ -920,7 +1114,13 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
return false;
|
|
|
}
|
|
|
Integer orderCount = htTradeSettlement.getOrderCount();
|
|
|
- htTradeSettlement.setBeOrderCount((orderCount == null ? 0 : orderCount) + 1);
|
|
|
+ Integer beOrderCount = htTradeSettlement.getBeOrderCount();
|
|
|
+ orderCount = orderCount == null ? 0 : orderCount;
|
|
|
+ beOrderCount = beOrderCount == null ? 0 : beOrderCount;
|
|
|
+ if (beOrderCount >= orderCount) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ htTradeSettlement.setBeOrderCount(beOrderCount + 1);
|
|
|
htTradeSettlementService.updateById(htTradeSettlement);
|
|
|
return true;
|
|
|
}
|
|
@@ -973,13 +1173,13 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
|
|
|
public List<OrderDto> getOrderListByMainIds(String mainIds) {
|
|
|
List<Long> idList = Arrays.stream(mainIds.split(",")).mapToLong(Long::parseLong).boxed().collect(Collectors.toList());
|
|
|
- QueryWrapper<TbOrder>ew=new QueryWrapper<>();
|
|
|
- ew.in("sale_main_id",idList);
|
|
|
- List<TbOrder>list=list(ew);
|
|
|
- List<OrderDto>dtos=new ArrayList<>();
|
|
|
+ QueryWrapper<TbOrder> ew = new QueryWrapper<>();
|
|
|
+ ew.in("sale_main_id", idList);
|
|
|
+ List<TbOrder> list = list(ew);
|
|
|
+ List<OrderDto> dtos = new ArrayList<>();
|
|
|
for (TbOrder tbOrder : list) {
|
|
|
- OrderDto orderDto=new OrderDto();
|
|
|
- BeanUtils.copyProperties(tbOrder,orderDto);
|
|
|
+ OrderDto orderDto = new OrderDto();
|
|
|
+ BeanUtils.copyProperties(tbOrder, orderDto);
|
|
|
dtos.add(orderDto);
|
|
|
}
|
|
|
return dtos;
|
|
@@ -988,4 +1188,63 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
public List<TbOrder> getOnSaleList(SoMap so) {
|
|
|
return tbOrderMapper.getOnSaleList(so);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public Map<String, Object> staticsStatus(Long saleMainId) {
|
|
|
+ SoMap soMap = new SoMap();
|
|
|
+ soMap.put("saleMainId", saleMainId);
|
|
|
+ List<TbOrder> list = tbOrderMapper.getList(soMap);
|
|
|
+ int total = list.size();
|
|
|
+ List<TbOrder> upList = list.stream().filter(tbOrder -> !Objects.isNull(tbOrder.getUpPrice())).collect(Collectors.toList());
|
|
|
+ int upSize = upList.size();
|
|
|
+ double upTotalPrice = upList.stream().collect(Collectors.summarizingDouble(order -> order.getUpPrice().doubleValue())).getSum();
|
|
|
+ List<TbOrder> saleList = list.stream().filter(tbOrder -> tbOrder.getResaleStatus() == 1).collect(Collectors.toList());
|
|
|
+ int saleSize = saleList.size();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("upTotalPrice", upTotalPrice);
|
|
|
+ resultMap.put("upSize", upSize);
|
|
|
+ resultMap.put("notUpSize", total - upSize);
|
|
|
+ resultMap.put("saleSize", saleSize);
|
|
|
+ resultMap.put("notSaleSize", total - saleSize);
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void cancelSale(Long id) {
|
|
|
+ TbOrder tbOrder = getById(id);
|
|
|
+ if (tbOrder.getBeingOrder() == 1) {
|
|
|
+ throw new AjaxError("该订单在二级市场被下单,无法取消转售");
|
|
|
+ }
|
|
|
+ tbOrder.setResaleStatus(0);
|
|
|
+ HtTradeSettlement htTradeSettlement = htTradeSettlementService.getById(tbOrder.getSaleMainId());
|
|
|
+ htTradeSettlement.setOnSaleCount(htTradeSettlement.getOnSaleCount() - 1);
|
|
|
+ boolean result = FeignFactory.levelTwoServerInterface.removeOnSaleOrderByLevelOneOrderId(id);
|
|
|
+ if (!result) {
|
|
|
+ throw new AjaxError("无法撤销转售");
|
|
|
+ }
|
|
|
+ updateById(tbOrder);
|
|
|
+ htTradeSettlementService.updateById(htTradeSettlement);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void cancelSaleBatch(List<Long> ids) {
|
|
|
+ String idsStr = ids.stream().map(id -> id + "").collect(Collectors.joining(","));
|
|
|
+ List<TbOrder> orders = tbOrderMapper.selectBatchIds(ids);
|
|
|
+ TbOrder tbOrder = orders.get(0);
|
|
|
+ HtTradeSettlement htTradeSettlement = htTradeSettlementService.getById(tbOrder.getSaleMainId());
|
|
|
+ boolean result = FeignFactory.levelTwoServerInterface.removeOnSaleOrderByLevelOneOrderIds(idsStr);
|
|
|
+ if (!result) {
|
|
|
+ throw new AjaxError("无法撤销转售");
|
|
|
+ }
|
|
|
+ for (TbOrder order : orders) {
|
|
|
+ order.setResaleStatus(0);
|
|
|
+ htTradeSettlement.setOnSaleCount(htTradeSettlement.getOnSaleCount() - 1);
|
|
|
+ }
|
|
|
+ this.updateBatchById(orders);
|
|
|
+ htTradeSettlementService.updateById(htTradeSettlement);
|
|
|
+ }
|
|
|
+
|
|
|
+ public double sumUpPrice(Long htTradeSettlementId) {
|
|
|
+ return tbOrderMapper.sumUpPrice(htTradeSettlementId);
|
|
|
+ }
|
|
|
}
|