|
@@ -14,10 +14,13 @@ import com.xy.device.EnumDeviceAlgorithmChargingHistoryStatus;
|
|
|
import com.xy.device.EnumDeviceAlgorithmChargingType;
|
|
|
import com.xy.dto.DeviceAlgorithmChargingDto;
|
|
|
import com.xy.dto.DeviceInfoDto;
|
|
|
+import com.xy.dto.be.MercDto;
|
|
|
import com.xy.entity.DeviceAlgorithmCharging;
|
|
|
import com.xy.entity.DeviceAlgorithmChargingHistory;
|
|
|
import com.xy.entity.SysDictRedis;
|
|
|
import com.xy.mapper.DeviceAlgorithmChargingMapper;
|
|
|
+import com.xy.mapper.entity.DeviceAlgorithmChargingChargingQueryParams;
|
|
|
+import com.xy.service.be.MercService;
|
|
|
import com.xy.utils.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -52,6 +55,8 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
|
|
|
private DeviceInfoService deviceInfoService;
|
|
|
|
|
|
+ private MercService mercService;
|
|
|
+
|
|
|
@PostMapping("page")
|
|
|
@ApiOperation("分页查询")
|
|
|
public R<PageBean<DeviceAlgorithmChargingDto.Vo>> page(@RequestBody @Validated DeviceAlgorithmChargingDto.Page page) {
|
|
@@ -130,6 +135,9 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
Map<String, SysDictRedis> algorithmMoonConfigMaps = SysDictUtils.get(EnumAlgorithmPayConfig.Code.CODE.getCode());
|
|
|
//获取类型字典
|
|
|
Map<String, SysDictRedis> deviceAlgorithmChargingTypeMaps = SysDictUtils.get(EnumDeviceAlgorithmChargingType.Code.CODE.getCode());
|
|
|
+ //查询商户信息
|
|
|
+ List<MercDto.Vo> mercs = mercService.list(new MercDto.SelectList().setMercIds(deviceAlgorithmChargingHistories.getProperty(DeviceAlgorithmChargingHistory::getMercId))).getData();
|
|
|
+ JMap<Long, MercDto.Vo> mercsMaps = new JArrayList<>(mercs).toMap(MercDto.Vo::getId).cover();
|
|
|
//处理有效期
|
|
|
deviceAlgorithmChargingHistories.forEach(deviceAlgorithmChargingHistory -> {
|
|
|
Integer type = deviceAlgorithmChargingHistory.getType();
|
|
@@ -170,8 +178,9 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
String stringAround1 = DataTime.getStringAround(0, 1, 0, 0, 0, 0, stringAround);
|
|
|
timeout = Integer.valueOf(DataTime.toString(DataTime.toLocal(stringAround1), "yyyyMMdd"));
|
|
|
}
|
|
|
+ MercDto.Vo merc = mercsMaps.get(deviceAlgorithmChargingHistory.getMercId());
|
|
|
DeviceAlgorithmCharging deviceAlgorithmChargingInfo = new DeviceAlgorithmCharging()
|
|
|
- .setMercId(deviceAlgorithmChargingHistory.getMercId())
|
|
|
+ .setMercCode(merc.getMercCode())
|
|
|
.setDeviceId(deviceAlgorithmChargingHistory.getDeviceId())
|
|
|
.setAlgorithmId(deviceAlgorithmChargingHistory.getAlgorithmId())
|
|
|
.setUnusedSize(moon.getSize())
|
|
@@ -186,8 +195,9 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
});
|
|
|
//处理无期限
|
|
|
infs.forEach(deviceAlgorithmChargingHistory -> {
|
|
|
+ MercDto.Vo merc = mercsMaps.get(deviceAlgorithmChargingHistory.getMercId());
|
|
|
DeviceAlgorithmCharging deviceAlgorithmChargingInfo = new DeviceAlgorithmCharging()
|
|
|
- .setMercId(deviceAlgorithmChargingHistory.getMercId())
|
|
|
+ .setMercCode(merc.getMercCode())
|
|
|
.setDeviceId(deviceAlgorithmChargingHistory.getDeviceId())
|
|
|
.setAlgorithmId(deviceAlgorithmChargingHistory.getAlgorithmId())
|
|
|
.setUnusedSize(deviceAlgorithmChargingHistory.getChargingSize())
|
|
@@ -201,8 +211,9 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
});
|
|
|
//处理赠送
|
|
|
gives.forEach(deviceAlgorithmChargingHistory -> {
|
|
|
+ MercDto.Vo merc = mercsMaps.get(deviceAlgorithmChargingHistory.getMercId());
|
|
|
DeviceAlgorithmCharging deviceAlgorithmChargingInfo = new DeviceAlgorithmCharging()
|
|
|
- .setMercId(deviceAlgorithmChargingHistory.getMercId())
|
|
|
+ .setMercCode(merc.getMercCode())
|
|
|
.setDeviceId(deviceAlgorithmChargingHistory.getDeviceId())
|
|
|
.setAlgorithmId(deviceAlgorithmChargingHistory.getAlgorithmId())
|
|
|
.setUnusedSize(deviceAlgorithmChargingHistory.getChargingSize())
|
|
@@ -225,16 +236,24 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
@Override
|
|
|
@ApiOperation("扣费")
|
|
|
public R<Map<Long, Integer>> charging(List<DeviceAlgorithmChargingDto.Charging> chargings) {
|
|
|
+ //查询商户信息
|
|
|
+ List<MercDto.Vo> mercs = mercService.list(new MercDto.SelectList().setMercIds(new JArrayList<>(chargings).getProperty(DeviceAlgorithmChargingDto.Charging::getMercId))).getData();
|
|
|
+ JMap<Long, MercDto.Vo> mercsMaps = new JArrayList<>(mercs).toMap(MercDto.Vo::getId).cover();
|
|
|
//封装默认返回值
|
|
|
Map<Long, Integer> map = new JHashMap<>(chargings.size());
|
|
|
chargings.forEach(charging -> map.put(charging.getMercDeviceAlgorithmChargingId(), charging.getSize()));
|
|
|
//查询数据
|
|
|
- List<DeviceAlgorithmCharging> queryList = new ArrayList<>(chargings.size());
|
|
|
+ List<DeviceAlgorithmChargingChargingQueryParams> queryList = new ArrayList<>(chargings.size());
|
|
|
for (DeviceAlgorithmChargingDto.Charging charging : chargings) {
|
|
|
- DeviceAlgorithmCharging deviceAlgorithmCharging = new DeviceAlgorithmCharging()
|
|
|
- .setDeviceId(charging.getDeviceId())
|
|
|
- .setAlgorithmId(charging.getAlgorithmId())
|
|
|
- .setBeginTime(charging.getAlgorithmDate());
|
|
|
+ MercDto.Vo merc = mercsMaps.get(charging.getMercId());
|
|
|
+ String mercCode = merc.getMercCode();
|
|
|
+ List<String> mercCodes = new ArrayList<>();
|
|
|
+ getMercCodes(mercCode, mercCodes);
|
|
|
+ DeviceAlgorithmChargingChargingQueryParams deviceAlgorithmCharging = new DeviceAlgorithmChargingChargingQueryParams()
|
|
|
+ .setMercCodes(mercCodes);
|
|
|
+ deviceAlgorithmCharging.setDeviceId(charging.getDeviceId());
|
|
|
+ deviceAlgorithmCharging.setAlgorithmId(charging.getAlgorithmId());
|
|
|
+ deviceAlgorithmCharging.setBeginTime(charging.getAlgorithmDate());
|
|
|
queryList.add(deviceAlgorithmCharging);
|
|
|
}
|
|
|
List<DeviceAlgorithmCharging> deviceAlgorithmChargingsList = baseMapper.chargingQuery(queryList);
|
|
@@ -309,4 +328,19 @@ public class DeviceAlgorithmChargingServiceImpl extends ServiceImpl<DeviceAlgori
|
|
|
}
|
|
|
return size;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析商户编码,获取上级及自身编码
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void getMercCodes(String mercCode, List<String> mercCodes) {
|
|
|
+ mercCodes.add(mercCode);
|
|
|
+ int length = mercCode.length();
|
|
|
+ if (length == 5) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String parentCode = mercCode.substring(0, length - 3);
|
|
|
+ getMercCodes(parentCode, mercCodes);
|
|
|
+ }
|
|
|
}
|