localizer
parent
bdaaa40e32
commit
67bc5e6d3d
|
|
@ -26,8 +26,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 设备信息表
|
||||
|
|
@ -177,6 +180,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
|
|||
|
||||
} */
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String, Object> report1(JSONObject data) {
|
||||
MapBuilder<String, Object> resBuilder = MapUtil.<String, Object>builder()
|
||||
.put("code", 0)
|
||||
|
|
@ -202,15 +206,34 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
|
|||
.put("data", dataBuilder.put("type", 0).build())
|
||||
.build();
|
||||
}
|
||||
Long deviceStationId = deviceInfoEntity.getStationId();
|
||||
Long orderStationId = orderPagingResult.getStationId();
|
||||
if (!Objects.equals(deviceStationId, orderStationId)) {
|
||||
// 播语音
|
||||
playVoice(sn, cid, "{}站点错误,请前往预约的站点", licensePlate);
|
||||
return resBuilder
|
||||
.put("data", dataBuilder.put("type", 0).build())
|
||||
.build();
|
||||
}
|
||||
|
||||
DeviceCode deviceCode = deviceInfoEntity.getDeviceCode();
|
||||
OrderStatus orderStatus = orderPagingResult.getOrderStatus();
|
||||
CheckStatus checkStatus = orderPagingResult.getCheckStatus();
|
||||
|
||||
if (deviceCode == DeviceCode.JinQianZhi && orderStatus == OrderStatus.QingYunZhong) {
|
||||
PaymentStatus paymentStatus = orderPagingResult.getPaymentStatus();
|
||||
/* if (paymentStatus == null) {
|
||||
OrderInfoEntity orderInfoEntity = orderInfoService.getById(orderPagingResult.getId());
|
||||
orderInfoService.settleForTransCompany(orderInfoEntity, 0);
|
||||
orderPagingResult = orderInfoService.detail(orderPagingResult.getId());
|
||||
paymentStatus = orderPagingResult.getPaymentStatus();
|
||||
} */
|
||||
if (paymentStatus == PaymentStatus.WeiZhiFu) {
|
||||
// 播语音
|
||||
playVoice(sn, cid, "{}请先支付", licensePlate);
|
||||
return resBuilder
|
||||
.put("data", dataBuilder.put("type", 0).build())
|
||||
.build();
|
||||
}
|
||||
|
||||
// 开门
|
||||
|
|
@ -283,6 +306,7 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
|
|||
.build();
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String, Object> report2(JSONObject data) {
|
||||
MapBuilder<String, Object> resBuilder = MapUtil.<String, Object>builder()
|
||||
.put("code", 0)
|
||||
|
|
@ -301,8 +325,25 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
|
|||
.put("data", dataBuilder.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
String cid = deviceInfoEntity.getCid();
|
||||
OrderPagingResult orderPagingResult = orderInfoService.detail(orderId);
|
||||
|
||||
if (orderPagingResult == null) {
|
||||
// 播语音
|
||||
playVoice(sn, cid, "{}无订单", licensePlate);
|
||||
return resBuilder
|
||||
.put("data", dataBuilder.build())
|
||||
.build();
|
||||
}
|
||||
Long deviceStationId = deviceInfoEntity.getStationId();
|
||||
Long orderStationId = orderPagingResult.getStationId();
|
||||
if (!Objects.equals(deviceStationId, orderStationId)) {
|
||||
// 播语音
|
||||
playVoice(sn, cid, "{}站点错误,请前往预约的站点", licensePlate);
|
||||
return resBuilder
|
||||
.put("data", dataBuilder.build())
|
||||
.build();
|
||||
}
|
||||
DeviceCode deviceCode = deviceInfoEntity.getDeviceCode();
|
||||
OrderInfoEntity orderInfo = orderInfoService.getById(orderId);
|
||||
if (orderInfo == null) {
|
||||
|
|
@ -324,7 +365,9 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
|
|||
}
|
||||
if (deviceCode == DeviceCode.Jin) {
|
||||
// 播语音
|
||||
playVoice(sn, cid, "{}称重完成,磅重{}吨", licensePlate, weight / 1000);
|
||||
BigDecimal weight_ = new BigDecimal(weight);
|
||||
BigDecimal v = weight_.divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP);
|
||||
playVoice(sn, cid, "{}称重完成,磅重{}吨", licensePlate, v.toPlainString());
|
||||
// 开门
|
||||
open(sn, cid);
|
||||
orderInfoService.truckComing(new TruckComingOrderParam()
|
||||
|
|
@ -336,6 +379,8 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
|
|||
}
|
||||
|
||||
if (deviceCode == DeviceCode.Chu) {
|
||||
BigDecimal weight_ = new BigDecimal(weight);
|
||||
BigDecimal v = weight_.divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP);
|
||||
try {
|
||||
orderInfoService.truckLeaving(new TruckLeavingOrderParam()
|
||||
.setOrderId(orderId)
|
||||
|
|
@ -344,11 +389,11 @@ public class DeviceInfoService extends ServiceImpl<DeviceInfoMapper, DeviceInfoE
|
|||
.setBodyPhoto(bodyPhoto),
|
||||
0);
|
||||
// 播语音
|
||||
playVoice(sn, cid, "{}称重完成,磅重{}吨", licensePlate, weight / 1000);
|
||||
playVoice(sn, cid, "{}称重完成,磅重{}吨", licensePlate, v.toPlainString());
|
||||
// 开门
|
||||
open(sn, cid);
|
||||
} catch (Exception e) {
|
||||
playVoice(sn, cid, "{}称重异常,磅重{}吨", licensePlate, weight / 1000);
|
||||
playVoice(sn, cid, "{}称重异常,磅重{}吨", licensePlate, v.toPlainString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.njzscloud.supervisory.order.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.google.common.base.Strings;
|
||||
import com.njzscloud.common.core.ex.ExceptionMsg;
|
||||
import com.njzscloud.common.core.ex.Exceptions;
|
||||
|
|
@ -13,7 +14,6 @@ import com.njzscloud.supervisory.money.pojo.entity.MoneyAccountEntity;
|
|||
import com.njzscloud.supervisory.money.pojo.entity.MoneyChangeDetailEntity;
|
||||
import com.njzscloud.supervisory.money.service.MoneyAccountService;
|
||||
import com.njzscloud.supervisory.money.service.MoneyChangeDetailService;
|
||||
import com.njzscloud.supervisory.order.contant.OrderStatus;
|
||||
import com.njzscloud.supervisory.order.contant.PaymentStatus;
|
||||
import com.njzscloud.supervisory.order.contant.PaymentWay;
|
||||
import com.njzscloud.supervisory.order.contant.SettlementWay;
|
||||
|
|
@ -23,13 +23,11 @@ import com.njzscloud.supervisory.order.pojo.entity.OrderInfoEntity;
|
|||
import com.njzscloud.supervisory.order.pojo.param.PaymentItemParam;
|
||||
import com.njzscloud.supervisory.order.pojo.param.PaymentParam;
|
||||
import com.njzscloud.supervisory.order.pojo.result.PaymentContextResult;
|
||||
import com.njzscloud.supervisory.order.pojo.dto.RefundRequestDto;
|
||||
import com.njzscloud.supervisory.order.service.OrderExpenseItemsService;
|
||||
import com.njzscloud.supervisory.order.service.OrderInfoService;
|
||||
import com.njzscloud.supervisory.order.service.WechatPayService;
|
||||
import com.njzscloud.supervisory.sys.user.pojo.entity.UserAccountEntity;
|
||||
import com.njzscloud.supervisory.sys.user.service.UserAccountService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
|
@ -171,7 +169,7 @@ public class PaymentController {
|
|||
orderInfoService.lambdaUpdate()
|
||||
.eq(OrderInfoEntity::getId, paymentParam.getOrderId())
|
||||
.set(OrderInfoEntity::getPaymentStatus, PaymentStatus.YiZhiFu)
|
||||
.set(OrderInfoEntity::getOrderStatus, OrderStatus.YiWanCheng.getVal())
|
||||
// .set(OrderInfoEntity::getOrderStatus, OrderStatus.YiWanCheng.getVal())
|
||||
.set(OrderInfoEntity::getPaymentCategory, paymentParam.getPaymentCategory())
|
||||
.set(OrderInfoEntity::getPayTime, LocalDateTime.now())
|
||||
.update();
|
||||
|
|
@ -247,7 +245,7 @@ public class PaymentController {
|
|||
orderInfoService.lambdaUpdate()
|
||||
.eq(OrderInfoEntity::getId, orderId)
|
||||
.set(OrderInfoEntity::getPaymentStatus, PaymentStatus.YiZhiFu)
|
||||
.set(OrderInfoEntity::getOrderStatus, OrderStatus.YiWanCheng.getVal())
|
||||
// .set(OrderInfoEntity::getOrderStatus, OrderStatus.YiWanCheng.getVal())
|
||||
.set(OrderInfoEntity::getSn, callbackDto.getResource().getCiphertext()) // 需要解密获取
|
||||
.set(OrderInfoEntity::getPayTime, LocalDateTime.now())
|
||||
.update();
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
Long transCompanyId = addOrderInfoParam.getTransCompanyId();
|
||||
OrderStatus orderStatus = transCompanyId == null ? OrderStatus.YiYuYue : OrderStatus.DaiPaiDan;
|
||||
|
||||
|
||||
Long goodsId = addOrderInfoParam.getGoodsId();
|
||||
|
||||
Long orderGoodsId = orderGoodsService.add(goodsId);
|
||||
|
|
@ -117,6 +118,10 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
.setGoodsId(orderGoodsId);
|
||||
this.save(orderInfoEntity);
|
||||
|
||||
if (transCompanyId != null) {
|
||||
settleForTransCompany(this.getById(orderInfoEntity.getId()), 0);
|
||||
}
|
||||
|
||||
Long orderId = orderInfoEntity.getId();
|
||||
OrderCategory orderCategory = addOrderInfoParam.getOrderCategory();
|
||||
if (orderCategory == OrderCategory.DuanBoChu) {
|
||||
|
|
@ -576,11 +581,15 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
Assert.isNull(orderInfo.getTransCompanyId(), () -> Exceptions.clierr("当前订单已分配清运公司,无需重复分配"));
|
||||
Assert.isTrue(orderInfo.getOrderStatus() == OrderStatus.YiYuYue, () -> Exceptions.clierr("当前订单状态,无法分配清运公司"));
|
||||
|
||||
Long orderInfoId = orderInfo.getId();
|
||||
this.updateById(new OrderInfoEntity()
|
||||
.setId(orderInfo.getId())
|
||||
.setId(orderInfoId)
|
||||
.setTransCompanyId(transCompanyId)
|
||||
.setOrderStatus(OrderStatus.DaiPaiDan)
|
||||
);
|
||||
OrderInfoEntity orderInfoEntity = this.getById(orderInfoId);
|
||||
settleForTransCompany(orderInfoEntity, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -712,7 +721,7 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
Assert.notNull(orderInfo, () -> Exceptions.clierr("订单不存在"));
|
||||
OrderStatus orderStatus = orderInfo.getOrderStatus();
|
||||
Assert.isTrue(orderStatus == OrderStatus.YiYuYue
|
||||
|| orderStatus == OrderStatus.DaiPaiDan
|
||||
|| orderStatus == OrderStatus.DaiPaiDan
|
||||
|| orderStatus == OrderStatus.DaiJieDan, () -> Exceptions.clierr("当前订单状态,无法取消"));
|
||||
this.updateById(new OrderInfoEntity()
|
||||
.setId(orderInfo.getId())
|
||||
|
|
@ -866,7 +875,8 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
* 2. 查询并按 scope 过滤付费项配置(all / customer_type=QiYe|GeTi / customer 包含 trans_company_id)
|
||||
* 3. 合并集合,计算金额(total_money=quantity*unit_price,settle_money=total_money+discount_money+revise_money),批量入库
|
||||
*/
|
||||
private void settleForTransCompany(OrderInfoEntity orderInfoEntity, Integer settleWeight) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void settleForTransCompany(OrderInfoEntity orderInfoEntity, Integer settleWeight) {
|
||||
Long orderId = orderInfoEntity.getId();
|
||||
OrderGoodsEntity orderGoods = orderGoodsService.getById(orderInfoEntity.getGoodsId());
|
||||
Assert.notNull(orderGoods, () -> Exceptions.clierr("订单产品不存在"));
|
||||
|
|
@ -875,17 +885,22 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
int quantityByStrategy = (orderGoods.getMoneyStrategy() == MoneyStrategy.Che) ? 1 : settleWeight;
|
||||
|
||||
// 第一步:复制产品信息为付费项记录
|
||||
OrderExpenseItemsEntity productItem = new OrderExpenseItemsEntity()
|
||||
.setExpenseItemCategory(ExpenseItemCategory.ChanPin.getVal())
|
||||
.setOrderId(orderId)
|
||||
.setOriginExpenseItemId(orderGoods.getId())
|
||||
.setExpenseItemName(orderGoods.getGoodsName())
|
||||
.setUnitPrice(orderGoods.getUnitPrice())
|
||||
.setUnit(orderGoods.getUnit())
|
||||
.setMoneyStrategy(orderGoods.getMoneyStrategy() == null ? null : orderGoods.getMoneyStrategy().getVal())
|
||||
.setMoneyConfigId(orderGoods.getMoneyConfigId())
|
||||
.setTaxRate(orderGoods.getTaxRate())
|
||||
.setQuantity(quantityByStrategy);
|
||||
BigDecimal unitPrice = orderGoods.getUnitPrice();
|
||||
OrderExpenseItemsEntity productItem = null;
|
||||
if (unitPrice != null && unitPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||
productItem = new OrderExpenseItemsEntity()
|
||||
.setExpenseItemCategory(ExpenseItemCategory.ChanPin.getVal())
|
||||
.setOrderId(orderId)
|
||||
.setOriginExpenseItemId(orderGoods.getId())
|
||||
.setExpenseItemName(orderGoods.getGoodsName())
|
||||
.setUnitPrice(unitPrice)
|
||||
.setUnit(orderGoods.getUnit())
|
||||
.setMoneyStrategy(orderGoods.getMoneyStrategy() == null ? null : orderGoods.getMoneyStrategy().getVal())
|
||||
.setMoneyConfigId(orderGoods.getMoneyConfigId())
|
||||
.setTaxRate(orderGoods.getTaxRate())
|
||||
.setQuantity(quantityByStrategy);
|
||||
}
|
||||
|
||||
|
||||
// 第二步:读取启用的付费项配置,并按 scope 过滤
|
||||
List<ExpenseItemsConfigEntity> configs = expenseItemsConfigService.list(Wrappers.<ExpenseItemsConfigEntity>lambdaQuery()
|
||||
|
|
@ -925,7 +940,10 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
.collect(Collectors.toList());
|
||||
|
||||
// 第三步:合并集合并计算金额,然后批量落库
|
||||
extraItems.add(0, productItem);
|
||||
if (productItem != null) extraItems.add(0, productItem);
|
||||
if (extraItems.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
BigDecimal totalDiscountMoney = BigDecimal.ZERO;
|
||||
BigDecimal totalReviseMoney = BigDecimal.ZERO;
|
||||
BigDecimal totalSettleMoney = BigDecimal.ZERO;
|
||||
|
|
@ -951,8 +969,10 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
totalTotalMoney = totalTotalMoney.add(totalMoney);
|
||||
}
|
||||
|
||||
|
||||
orderExpenseItemsService.saveBatch(extraItems);
|
||||
|
||||
|
||||
// 更新订单表的优惠金额; 手动修正金额;结算金额;总金额;
|
||||
this.lambdaUpdate()
|
||||
.eq(OrderInfoEntity::getId, orderId)
|
||||
|
|
@ -960,6 +980,7 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
.set(OrderInfoEntity::getReviseMoney, totalReviseMoney)
|
||||
.set(OrderInfoEntity::getSettleMoney, totalSettleMoney)
|
||||
.set(OrderInfoEntity::getTotalMoney, totalTotalMoney)
|
||||
.set(OrderInfoEntity::getPaymentStatus, PaymentStatus.WeiZhiFu)
|
||||
.update();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue