|
@@ -162,11 +162,6 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
|
|
|
TbOrders orders = new TbOrders();
|
|
|
orders.setPurchaserId(purchaser.getId());
|
|
|
orders.setPurchaserName(purchaser.getName());
|
|
|
- orders.setIsPay(1);//支付成功
|
|
|
- orders.setPayTime(new Date());
|
|
|
- OrdersDto ordersDto = new OrdersDto();
|
|
|
- BeanUtils.copyProperties(orders,ordersDto);
|
|
|
- asyncServerInterface.sendLevelTwoOrdersDto(ordersDto, DataType.DATA_TYPE_FOUR.getCode()); // 发送航通
|
|
|
|
|
|
for (Long id : idArr) {
|
|
|
|
|
@@ -184,81 +179,111 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
|
|
|
PaymentTwoDto paymentTwoDto = this.getPaymentData(orderTwo,orderOne);
|
|
|
paymentServerInterface.sendMKT006_NoCommission(paymentTwoDto);
|
|
|
|
|
|
- //todo:给每个购买他商品的边民发一条支付成功消息,通知边民发起缴税申请以及缴费申请
|
|
|
+ //给每个购买他商品的边民发一条支付成功消息,通知边民发起缴税申请以及缴费申请
|
|
|
/* MessageDto dto = new MessageDto();
|
|
|
dto.setUrl("/pages/market/two/leader/order");
|
|
|
dto.setUserId(t.getLeaderId());
|
|
|
dto.setContents("你转售的《" + t.getGoodsName() + "》收购商已付款。请及时发起缴税申请以及缴费申请。");
|
|
|
adminInterface.messageSave(dto);*/
|
|
|
}
|
|
|
-
|
|
|
// 清空购物车
|
|
|
LambdaQueryWrapper<TbOrdersCart> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.in(TbOrdersCart::getOrderId, Arrays.asList(idArr));
|
|
|
int del = tbOrdersCartMapper.delete(wrapper);
|
|
|
-
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 采购商支付成功 ——> 边民缴税以及各服务费
|
|
|
+ * 收到采购商支付扣款回执:成功——> 边民缴税以及各服务费
|
|
|
* @param orderNo 二级市场边民订单-订单编号
|
|
|
*/
|
|
|
- boolean payTax(String orderNo) {
|
|
|
+ boolean payTax(String orderNo, Integer MKT008Status) {
|
|
|
LambdaQueryWrapper<TbOrders> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(TbOrders::getOrderNo, orderNo);
|
|
|
List<TbOrders> list = this.list(queryWrapper);
|
|
|
- if (list.size() <= 0) return false;
|
|
|
-
|
|
|
+ if (list.size() <= 0) new RuntimeException("收到采购商支付扣款回执:二级市场订单不存在");
|
|
|
TbOrders orderTwo = list.get(0);
|
|
|
- //if (orders.getPayTax() == 1) throw new RuntimeException("你已缴清费用");
|
|
|
|
|
|
OrderDto orderOne = levelOneServerInterface.getOrderDtoById(orderTwo.getLevelOneOrderId());
|
|
|
- if (null == orderOne) return false;
|
|
|
+ if (null == orderOne) new RuntimeException("收到采购商支付扣款回执:一级市场订单不存在");
|
|
|
|
|
|
- //todo 订单状态更新,系统将服务费自动分账,将分账信息自动发送至银行进行划扣
|
|
|
- List<TbItemRules> ruleList = new ArrayList<>();
|
|
|
- List<TbFeeItem> feeItemList = tbFeeItemService.getFeeItems();
|
|
|
- feeItemList.forEach(feeItem -> {
|
|
|
- ruleList.addAll(tbItemRulesService.getList(new SoMap().set("itemId", feeItem.getId())));
|
|
|
- });
|
|
|
- //目前逻辑为一个边民订单只有一个商品
|
|
|
- GoodsDto goods = levelOneServerInterface.getByGoodsId(orderOne.getGoodsId());
|
|
|
- //找出所有含有该商品的费项规则
|
|
|
- List<TbItemRules> newRuleList = ruleList.stream().filter(rule -> rule.getGoodsCodes().contains(goods.getCode())).collect(Collectors.toList());
|
|
|
- List<CompanyDto> companyDtoList = new ArrayList<>();
|
|
|
- for (TbItemRules ruleItem : newRuleList) {
|
|
|
- BigDecimal chargesPrice = BigDecimal.ZERO;
|
|
|
- BigDecimal TotalPrice = new BigDecimal(orderOne.getTotalPrice());
|
|
|
- BigDecimal Percent = new BigDecimal(ruleItem.getPercent());
|
|
|
- //类型(1=按交易额收取,2=按次收取,3=按吨)
|
|
|
- if ("1".equals(ruleItem.getFeeType())) {
|
|
|
- chargesPrice = TotalPrice.multiply(Percent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);//保留两位小数,四舍五入
|
|
|
- } else if ("2".equals(ruleItem.getFeeType())) {
|
|
|
- chargesPrice = ruleItem.getFeeMoney();
|
|
|
- } else if ("3".equals(ruleItem.getFeeType())) {
|
|
|
- chargesPrice = TotalPrice.multiply(Percent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);//保留两位小数,四舍五入
|
|
|
- }
|
|
|
- CompanyDto companyDto = new CompanyDto();
|
|
|
- List<TbFeeItem> feeItems = feeItemList.stream().filter(feeItem -> feeItem.getId().equals(ruleItem.getItemId())).collect(Collectors.toList());
|
|
|
- if (feeItems.size() > 0) {
|
|
|
- TbCompany company = companyService.getById(feeItems.get(0).getCompanyId());
|
|
|
- BeanUtils.copyProperties(company,companyDto);
|
|
|
- companyDto.setChargesPrice(chargesPrice);
|
|
|
+ if(2==MKT008Status) {//扣款失败
|
|
|
+ //todo 订单状态更新
|
|
|
+ orderTwo.setIsPay(2);//支付失败
|
|
|
+ orderTwo.setPayTime(new Date());
|
|
|
+ }
|
|
|
+ else if(1==MKT008Status) {//扣款成功
|
|
|
+ //todo 1、订单状态更新
|
|
|
+ orderTwo.setIsPay(1);//支付成功
|
|
|
+ orderTwo.setPayTime(new Date());
|
|
|
+
|
|
|
+ //todo 2、同步订单信息,发送航通
|
|
|
+ OrdersDto ordersDto = new OrdersDto();
|
|
|
+ BeanUtils.copyProperties(orderTwo,ordersDto);
|
|
|
+ asyncServerInterface.sendLevelTwoOrdersDto(ordersDto, DataType.DATA_TYPE_FOUR.getCode());
|
|
|
+
|
|
|
+ //todo 3、系统将服务费自动分账,将分账信息自动发送至银行进行划扣
|
|
|
+ List<TbItemRules> ruleList = new ArrayList<>();
|
|
|
+ List<TbFeeItem> feeItemList = tbFeeItemService.getFeeItems();
|
|
|
+ feeItemList.forEach(feeItem -> {
|
|
|
+ ruleList.addAll(tbItemRulesService.getList(new SoMap().set("itemId", feeItem.getId())));
|
|
|
+ });
|
|
|
+ //目前逻辑为一个边民订单只有一个商品
|
|
|
+ GoodsDto goods = levelOneServerInterface.getByGoodsId(orderOne.getGoodsId());
|
|
|
+ //找出所有含有该商品的费项规则
|
|
|
+ List<TbItemRules> newRuleList = ruleList.stream().filter(rule -> rule.getGoodsCodes().contains(goods.getCode())).collect(Collectors.toList());
|
|
|
+ List<CompanyDto> companyDtoList = new ArrayList<>();
|
|
|
+ for (TbItemRules ruleItem : newRuleList) {
|
|
|
+ BigDecimal chargesPrice = BigDecimal.ZERO;
|
|
|
+ BigDecimal TotalPrice = new BigDecimal(orderOne.getTotalPrice());
|
|
|
+ BigDecimal Percent = new BigDecimal(ruleItem.getPercent());
|
|
|
+ //类型(1=按交易额收取,2=按次收取,3=按吨)
|
|
|
+ if ("1".equals(ruleItem.getFeeType())) {
|
|
|
+ chargesPrice = TotalPrice.multiply(Percent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);//保留两位小数,四舍五入
|
|
|
+ } else if ("2".equals(ruleItem.getFeeType())) {
|
|
|
+ chargesPrice = ruleItem.getFeeMoney();
|
|
|
+ } else if ("3".equals(ruleItem.getFeeType())) {
|
|
|
+ chargesPrice = TotalPrice.multiply(Percent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);//保留两位小数,四舍五入
|
|
|
+ }
|
|
|
+ CompanyDto companyDto = new CompanyDto();
|
|
|
+ List<TbFeeItem> feeItems = feeItemList.stream().filter(feeItem -> feeItem.getId().equals(ruleItem.getItemId())).collect(Collectors.toList());
|
|
|
+ if (feeItems.size() > 0) {
|
|
|
+ TbCompany company = companyService.getById(feeItems.get(0).getCompanyId());
|
|
|
+ BeanUtils.copyProperties(company,companyDto);
|
|
|
+ companyDto.setChargesPrice(chargesPrice);
|
|
|
+ }
|
|
|
+ companyDtoList.add(companyDto);
|
|
|
}
|
|
|
- companyDtoList.add(companyDto);
|
|
|
+
|
|
|
+ PaymentTwoDto paymentTwoDto = this.getPaymentData(orderTwo,orderOne);
|
|
|
+ paymentTwoDto.setCompanyDtoList(companyDtoList);
|
|
|
+ paymentServerInterface.sendMKT006(paymentTwoDto);
|
|
|
}
|
|
|
|
|
|
- PaymentTwoDto paymentTwoDto = this.getPaymentData(orderTwo,orderOne);
|
|
|
- paymentTwoDto.setCompanyDtoList(companyDtoList);
|
|
|
- paymentServerInterface.sendMKT006(paymentTwoDto);
|
|
|
+ return updateById(orderTwo);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 收到边民缴税以及各服务费回执
|
|
|
+ * @param orderNo 二级市场边民订单-订单编号
|
|
|
+ */
|
|
|
+ boolean payTaxFromBank(String orderNo, Integer MKT008Status) {
|
|
|
+ LambdaQueryWrapper<TbOrders> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(TbOrders::getOrderNo, orderNo);
|
|
|
+ List<TbOrders> list = this.list(queryWrapper);
|
|
|
+ if (list.size() <= 0) new RuntimeException("收到边民缴税以及各服务费回执:二级市场订单不存在");
|
|
|
+ TbOrders orderTwo = list.get(0);
|
|
|
|
|
|
+ if(2==MKT008Status) {//缴费失败
|
|
|
+ //todo 订单状态更新
|
|
|
+ orderTwo.setPayTax(2);
|
|
|
+ orderTwo.setPayTaxTime(new Date());
|
|
|
+ }
|
|
|
+ else if(1==MKT008Status) {//缴费成功
|
|
|
+ //todo 订单状态更新
|
|
|
+ orderTwo.setPayTax(1);
|
|
|
+ orderTwo.setPayTaxTime(new Date());
|
|
|
+ orderTwo.setOrderFinish(1);//缴费成功订单完成
|
|
|
|
|
|
- //todo 订单状态更新
|
|
|
- orderTwo.setPayTax(1);
|
|
|
- orderTwo.setPayTaxTime(new Date());
|
|
|
- orderTwo.setOrderFinish(1);//缴费成功订单完成
|
|
|
- if (updateById(orderTwo)) {
|
|
|
//保存缴费记录
|
|
|
List<TbFeeItem> feeItems = tbFeeItemService.getFeeItems();
|
|
|
feeItems.stream().forEach(e -> {
|
|
@@ -280,9 +305,9 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
|
|
|
dto.setUserId(orderTwo.getPurchaserId());
|
|
|
dto.setContents("你购买的《" + orderTwo.getGoodsName() + "》边民已缴清税以及各服务费。");
|
|
|
adminInterface.messageSave(dto);
|
|
|
- return true;
|
|
|
}
|
|
|
- return false;
|
|
|
+
|
|
|
+ return updateById(orderTwo);
|
|
|
}
|
|
|
|
|
|
List<TbOrders> getDetailById(SoMap so) {
|