提交 9f75fb04 authored 作者: huyufan's avatar huyufan

Merge remote-tracking branch 'origin/v5.7_break_contract_reverse_20231020' into test

# Conflicts: # performance-api/src/main/java/com/clx/performance/enums/integral/IntegralRecordEnum.java # performance-web/src/main/java/com/clx/performance/dao/OrderGoodsDao.java # performance-web/src/main/java/com/clx/performance/service/IntegralRecordService.java
...@@ -28,6 +28,7 @@ public enum IntegralRecordEnum { ...@@ -28,6 +28,7 @@ public enum IntegralRecordEnum {
ORDER_CHILD_CANCEL(21, "运单取消"), ORDER_CHILD_CANCEL(21, "运单取消"),
ORDER_CHILD_CANCEL_TIMEOUT(22, "运单取消超时"), ORDER_CHILD_CANCEL_TIMEOUT(22, "运单取消超时"),
ORDER_CHILD_PLATFORM_CANCEL(23, "平台取消"), ORDER_CHILD_PLATFORM_CANCEL(23, "平台取消"),
ORDER_CHILD_PLATFORM_COMPENSATION(25, "平台补偿"),
REPORT_TRUCK_INFO(50, "提交基础信息"), REPORT_TRUCK_INFO(50, "提交基础信息"),
REPORT_REFUEL(51, "油表上报"), REPORT_REFUEL(51, "油表上报"),
......
...@@ -89,4 +89,5 @@ public interface OrderGoodsDao extends BaseDao<OrderGoodsMapper, OrderGoods, Int ...@@ -89,4 +89,5 @@ public interface OrderGoodsDao extends BaseDao<OrderGoodsMapper, OrderGoods, Int
void updateSendSystemAddress(Integer ownerAddressId, Integer systemAddressId); void updateSendSystemAddress(Integer ownerAddressId, Integer systemAddressId);
void updateReceiveSystemAddress(Integer ownerAddressId, Integer systemAddressId); void updateReceiveSystemAddress(Integer ownerAddressId, Integer systemAddressId);
List<OrderGoodsAPPVO> getCancelOrderGoods(List<String> list);
} }
...@@ -49,6 +49,11 @@ public class IntegralRecordDaoImpl extends BaseDaoImpl<IntegraRecordMapper, Inte ...@@ -49,6 +49,11 @@ public class IntegralRecordDaoImpl extends BaseDaoImpl<IntegraRecordMapper, Inte
return baseMapper.sumByStatisticsIdAndTypes(statisticsId, typeList); return baseMapper.sumByStatisticsIdAndTypes(statisticsId, typeList);
} }
@Override
public int sumByStatisticsIdAndTypes(Integer statisticsId, List<Integer> typeList) {
return baseMapper.sumByStatisticsIdAndTypes(statisticsId, typeList);
}
@Override @Override
public Integer sumByStatisticsIdAndTypeAndTime(Integer statisticsId, Integer type, String beginTime, String endTime) { public Integer sumByStatisticsIdAndTypeAndTime(Integer statisticsId, Integer type, String beginTime, String endTime) {
return baseMapper.sumByStatisticsIdAndTypeAndTime(statisticsId, type, beginTime, endTime); return baseMapper.sumByStatisticsIdAndTypeAndTime(statisticsId, type, beginTime, endTime);
......
...@@ -224,7 +224,7 @@ public class OrderGoodsDaoImpl extends BaseDaoImpl<OrderGoodsMapper, OrderGoods, ...@@ -224,7 +224,7 @@ public class OrderGoodsDaoImpl extends BaseDaoImpl<OrderGoodsMapper, OrderGoods,
} }
@Override @Override
public List<OrderGoodsAPPVO> getCancelOrderGoods(List<OrderGoodsTruckBind> param) { public List<OrderGoodsAPPVO> getCancelOrderGoods(List<String> param) {
return baseMapper.getCancelOrderGoods(param); return baseMapper.getCancelOrderGoods(param);
} }
......
...@@ -30,6 +30,12 @@ public interface IntegraRecordMapper extends BaseMapper<IntegralRecord> { ...@@ -30,6 +30,12 @@ public interface IntegraRecordMapper extends BaseMapper<IntegralRecord> {
@SelectProvider(type = IntegralRecordSqlProvider.class, method = "pageByParam") @SelectProvider(type = IntegralRecordSqlProvider.class, method = "pageByParam")
IPage<IntegralRecordVO> pageByParam(@Param("page") Page<IntegralRecordVO> page, @Param("param") pageIntegralStatisticsDetailParam param); IPage<IntegralRecordVO> pageByParam(@Param("page") Page<IntegralRecordVO> page, @Param("param") pageIntegralStatisticsDetailParam param);
@Select("<script>select sum(integral) from integral_record where " +
" type in <foreach collection='list' item='item' open='(' separator=',' close=')'>#{item}</foreach> " +
" and statistics_id = #{statisticsId}" +
"</script>")
int sumByStatisticsIdAndTypes(@Param("statisticsId") Integer statisticsId, @Param("list") List<Integer> typeList);
@Select("select sum(integral) from integral_record where statistics_id = #{statisticsId} and type = #{type} and create_time >= #{beginTime} and create_time < #{endTime}") @Select("select sum(integral) from integral_record where statistics_id = #{statisticsId} and type = #{type} and create_time >= #{beginTime} and create_time < #{endTime}")
Integer sumByStatisticsIdAndTypeAndTime(@Param("statisticsId") Integer statisticsId, Integer sumByStatisticsIdAndTypeAndTime(@Param("statisticsId") Integer statisticsId,
@Param("type") Integer type, @Param("type") Integer type,
......
...@@ -81,5 +81,5 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> { ...@@ -81,5 +81,5 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
Integer updateOrderGoodsSetResidueWeightAndAlreadyWeightAndStatus(@Param(value = "residueWeight") BigDecimal residueWeight,@Param(value = "alreadyWeight") BigDecimal alreadyWeight,@Param(value = "status") Integer status,@Param(value = "id") Integer id); Integer updateOrderGoodsSetResidueWeightAndAlreadyWeightAndStatus(@Param(value = "residueWeight") BigDecimal residueWeight,@Param(value = "alreadyWeight") BigDecimal alreadyWeight,@Param(value = "status") Integer status,@Param(value = "id") Integer id);
@SelectProvider(type = OrderGoodsSqlProvider.class, method = "getCancelOrderGoods") @SelectProvider(type = OrderGoodsSqlProvider.class, method = "getCancelOrderGoods")
List<OrderGoodsAPPVO> getCancelOrderGoods(@Param(value = "param") List<OrderGoodsTruckBind> param); List<OrderGoodsAPPVO> getCancelOrderGoods(@Param(value = "param") List<String> param);
} }
...@@ -12,6 +12,8 @@ public interface IntegralRecordService { ...@@ -12,6 +12,8 @@ public interface IntegralRecordService {
void addRecord(AppIntegralRuleVO ruleInfo, String truckNo, Integer type, Integer integral, String remark); void addRecord(AppIntegralRuleVO ruleInfo, String truckNo, Integer type, Integer integral, String remark);
void addPlatformCompensationRecord(String truckNo);
IntegralRecord save(Integer statisticsId, LocalDateTime statisticsDate, String truckNo, Integer type, Integer integral, String remark); IntegralRecord save(Integer statisticsId, LocalDateTime statisticsDate, String truckNo, Integer type, Integer integral, String remark);
} }
...@@ -11,6 +11,7 @@ import com.clx.performance.model.IntegralTruck; ...@@ -11,6 +11,7 @@ import com.clx.performance.model.IntegralTruck;
import com.clx.performance.param.pc.IntegralRecordAddParam; import com.clx.performance.param.pc.IntegralRecordAddParam;
import com.clx.performance.service.IntegralMqService; import com.clx.performance.service.IntegralMqService;
import com.clx.performance.service.IntegralRecordService; import com.clx.performance.service.IntegralRecordService;
import com.clx.performance.service.integral.IntegralRuleService;
import com.clx.performance.utils.LocalDateTimeUtils; import com.clx.performance.utils.LocalDateTimeUtils;
import com.clx.performance.vo.pc.integral.AppIntegralRuleVO; import com.clx.performance.vo.pc.integral.AppIntegralRuleVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service; ...@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays;
@Slf4j @Slf4j
@Service @Service
...@@ -35,6 +37,8 @@ public class IntegralRecordServiceImpl implements IntegralRecordService { ...@@ -35,6 +37,8 @@ public class IntegralRecordServiceImpl implements IntegralRecordService {
@Autowired @Autowired
private IntegralMqService integralMqService; private IntegralMqService integralMqService;
@Autowired
private IntegralRuleService integralRuleService;
@Override @Override
public void addRecord(IntegralRecordAddParam param) { public void addRecord(IntegralRecordAddParam param) {
...@@ -99,6 +103,52 @@ public class IntegralRecordServiceImpl implements IntegralRecordService { ...@@ -99,6 +103,52 @@ public class IntegralRecordServiceImpl implements IntegralRecordService {
} }
@Override
public void addPlatformCompensationRecord(String truckNo) {
// 查找规则
AppIntegralRuleVO ruleInfo = integralRuleService.getRuleInfo();
Integer type = IntegralRecordEnum.Type.ORDER_CHILD_PLATFORM_COMPENSATION.getValue();
Integer integral = ruleInfo.getPlatformCompensationRule().getIntegralCancel();
String remark = IntegralRecordEnum.Type.ORDER_CHILD_PLATFORM_COMPENSATION.getMsg();
String statisticsDate = LocalDateTimeUtils.getWeekStart();
IntegralTruck truck = integralTruckDao.getByTruckNo(truckNo).orNull();
if (truck == null) {return;}
// 查找最新统计
IntegralStatistics statistics = integralStatisticsDao.selectByTruckNoAndStatisticsDate(truckNo, statisticsDate).orNull();
if (statistics == null) {return;}
int sum = integralRecordDao.sumByStatisticsIdAndTypes(statistics.getId(), Arrays.asList(IntegralRecordEnum.Type.ORDER_CHILD_PLATFORM_COMPENSATION.getValue()));
if (sum > ruleInfo.getPlatformCompensationRule().getIntegralCancelLimit()){
log.info("平台补偿超上限,本次无效, truckNo:{}, type:{}, integral:{}, remark:{}", truckNo, type, integral, remark);
return;
}
else if (sum+integral > ruleInfo.getPlatformCompensationRule().getIntegralCancelLimit()){
integral = ruleInfo.getPlatformCompensationRule().getIntegralCancelLimit()-sum;
}
else {
}
// 更新积分
statistics.setIntegral(statistics.getIntegral()+integral);
integralStatisticsDao.updateIntegral(statistics);
truck.setIntegral(statistics.getIntegral());
integralTruckDao.updateIntegral(truck);
// 新增积分记录
IntegralRecord record = save(statistics.getId(), statistics.getStatisticsDate(), statistics.getTruckNo(), type, integral, remark);
// 发送mq (新增积分记录)
integralMqService.integralRecordAdd(record.getStatisticsId(), record.getTruckNo(), record.getType(), record.getIntegral(), record.getRemark());
}
@Override @Override
public IntegralRecord save(Integer statisticsId, LocalDateTime statisticsDate, String truckNo, Integer type, Integer integral, String remark){ public IntegralRecord save(Integer statisticsId, LocalDateTime statisticsDate, String truckNo, Integer type, Integer integral, String remark){
IntegralRecord record = new IntegralRecord(); IntegralRecord record = new IntegralRecord();
......
...@@ -62,7 +62,7 @@ public class OrderGoodsTruckBindServiceImpl implements OrderGoodsTruckBindServic ...@@ -62,7 +62,7 @@ public class OrderGoodsTruckBindServiceImpl implements OrderGoodsTruckBindServic
return null; return null;
} }
return orderGoodsDao.getCancelOrderGoods(list); return orderGoodsDao.getCancelOrderGoods(list.stream().map(OrderGoodsTruckBind::getTruckNo).collect(Collectors.toList()));
} }
......
...@@ -15,6 +15,7 @@ import com.clx.performance.model.breakcontract.BreakContractDriverRule; ...@@ -15,6 +15,7 @@ import com.clx.performance.model.breakcontract.BreakContractDriverRule;
import com.clx.performance.param.app.breakcontract.DriverPageBreakContractDriverRecordParam; import com.clx.performance.param.app.breakcontract.DriverPageBreakContractDriverRecordParam;
import com.clx.performance.param.pc.breakcontract.carrier.BreakContractDriverRecordAddParam; import com.clx.performance.param.pc.breakcontract.carrier.BreakContractDriverRecordAddParam;
import com.clx.performance.param.pc.breakcontract.carrier.PageBreakContractDriverRecordParam; import com.clx.performance.param.pc.breakcontract.carrier.PageBreakContractDriverRecordParam;
import com.clx.performance.service.IntegralRecordService;
import com.clx.performance.service.breakcontract.BreakContractDriverRecordService; import com.clx.performance.service.breakcontract.BreakContractDriverRecordService;
import com.clx.performance.service.breakcontract.BreakContractMqService; import com.clx.performance.service.breakcontract.BreakContractMqService;
import com.clx.performance.service.impl.UniqueOrderNumService; import com.clx.performance.service.impl.UniqueOrderNumService;
...@@ -57,6 +58,8 @@ public class BreakContractDriverRecordServiceImpl implements BreakContractDrive ...@@ -57,6 +58,8 @@ public class BreakContractDriverRecordServiceImpl implements BreakContractDrive
private BreakContractMqService breakContractMqService; private BreakContractMqService breakContractMqService;
@Autowired @Autowired
private UniqueOrderNumService uniqueOrderNumService; private UniqueOrderNumService uniqueOrderNumService;
@Autowired
private IntegralRecordService integralRecordService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -101,6 +104,11 @@ public class BreakContractDriverRecordServiceImpl implements BreakContractDrive ...@@ -101,6 +104,11 @@ public class BreakContractDriverRecordServiceImpl implements BreakContractDrive
// 发送mq (违约记录新增) // 发送mq (违约记录新增)
breakContractMqService.driverRecordAdd(record.getId()); breakContractMqService.driverRecordAdd(record.getId());
// 保存平台补偿积分
if (Objects.equals(param.getBreakContractPartyType(), BreakContractRecordEnum.BreakContractPartyType.PLATFORM.getCode())) {
integralRecordService.addPlatformCompensationRecord(record.getTruckNo());
}
} }
@Override @Override
......
...@@ -256,8 +256,10 @@ public class OrderGoodsSqlProvider { ...@@ -256,8 +256,10 @@ public class OrderGoodsSqlProvider {
return sql; return sql;
} }
public String getCancelOrderGoods(@Param("param") PageOrderGoodsListParam param) { public String getCancelOrderGoods(@Param("param") List<String> param) {
String sql = " select a.id, a.order_no," + StringBuffer sqlList = new StringBuffer();
sqlList.append(" select a.id, a.order_no," +
" a.order_goods_no, a.order_goods_status, a.extract_weight, " + " a.order_goods_no, a.order_goods_status, a.extract_weight, " +
" if(a.residue_transport_weight < 0, '0', a.residue_transport_weight) as residue_transport_weight ,a.already_transport_weight, a.send_address_id, a.send_address_shorter,a.send_longitude," + " if(a.residue_transport_weight < 0, '0', a.residue_transport_weight) as residue_transport_weight ,a.already_transport_weight, a.send_address_id, a.send_address_shorter,a.send_longitude," +
" a.send_latitude,a.receive_address_id, a.receive_address_shorter,a.receive_longitude,a.receive_latitude," + " a.send_latitude,a.receive_address_id, a.receive_address_shorter,a.receive_longitude,a.receive_latitude," +
...@@ -269,11 +271,18 @@ public class OrderGoodsSqlProvider { ...@@ -269,11 +271,18 @@ public class OrderGoodsSqlProvider {
" date_format(a.modified_time, '%Y-%m-%d %H:%i:%s') as modified_time," + " date_format(a.modified_time, '%Y-%m-%d %H:%i:%s') as modified_time," +
"a.extract_way,a.need_truck_num,a.senior_logistics_manager_id,a.senior_logistics_manager_name,a.pending_order_freight," + "a.extract_way,a.need_truck_num,a.senior_logistics_manager_id,a.senior_logistics_manager_name,a.pending_order_freight," +
"a.user_no,a.user_name,a.stop_flag,a.batch_number,a.last_arrive_receive_time,a.last_load_time,a.last_order_time,a.vehicle_usage,ab.truck_no as truckNo" "a.user_no,a.user_name,a.stop_flag,a.batch_number,a.last_arrive_receive_time,a.last_load_time,a.last_order_time,a.vehicle_usage,ab.truck_no as truckNo"
+ "from order_goods a left join order_goods_truck_bind ab on ab.order_goods_no = a.order_goods_no" + " from order_goods a left join order_goods_truck_bind ab on ab.order_goods_no = a.order_goods_no where ab.truck_no in (");
;
if (!param.isEmpty()) {
return sql; for (int i = 0; i < param.size(); i++) {
sqlList.append("'" + param.get(i) + "'");
if (i < param.size() -1) {
sqlList.append(",");
}
}
}
sqlList.append(") order by ab.create_time desc");
return sqlList.toString();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论