|
@@ -2,11 +2,17 @@ package com.szwl.controller;
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.szwl.constant.OperationType;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
|
import com.szwl.model.entity.ReturnCoinRecord;
|
|
|
import com.szwl.model.entity.TEquipment;
|
|
|
+import com.szwl.model.entity.TSugarDo;
|
|
|
+import com.szwl.model.param.ReturnCoinParam;
|
|
|
+import com.szwl.model.param.SugarDoParam;
|
|
|
import com.szwl.model.utils.PushUtils;
|
|
|
import com.szwl.service.ReturnCoinRecordService;
|
|
|
import com.szwl.service.TEquipmentService;
|
|
@@ -55,6 +61,27 @@ public class ReturnCoinRecordController {
|
|
|
return R.ok(list);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "远程退币申请列表")
|
|
|
+ @PostMapping("/getList")
|
|
|
+ public ResponseModel<IPage<?>> getList(@RequestBody ReturnCoinParam param) {
|
|
|
+ Page<ReturnCoinRecord> page = new Page<>(param.getCurrent(), param.getSize(), true);
|
|
|
+ LambdaQueryWrapper<ReturnCoinRecord> query = Wrappers.lambdaQuery();
|
|
|
+ if (param.getStatus() != null) {
|
|
|
+ query.eq(ReturnCoinRecord::getStatus, param.getStatus());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getStartTime()) && StringUtils.isNotEmpty(param.getEndTime())) {
|
|
|
+ param.setStartTime(param.getStartTime() + " 00:00:00");
|
|
|
+ param.setEndTime(param.getEndTime() + " 23:59:59");
|
|
|
+ query.between(ReturnCoinRecord::getCreateDate, param.getStartTime(), param.getEndTime());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(param.getClientId())) {
|
|
|
+ query.eq(ReturnCoinRecord::getClientId, param.getClientId());
|
|
|
+ }
|
|
|
+ query.orderByDesc(ReturnCoinRecord::getCreateDate);
|
|
|
+ Page<ReturnCoinRecord> recordPage = returnCoinRecordService.page(page, query);
|
|
|
+ return R.ok(recordPage);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("远程退币申请")
|
|
|
@PostMapping("/apply")
|
|
|
public ResponseModel<?> apply(@RequestBody ReturnCoinRecord returnCoinRecord){
|
|
@@ -95,5 +122,47 @@ public class ReturnCoinRecordController {
|
|
|
tEquipmentService.sentMessage(clientId, PushUtils.buildJson("returnCoin", commonId + ":" + amount).toString());
|
|
|
return R.ok();
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation("远程退币申请")
|
|
|
+ @PostMapping("/applyReturn")
|
|
|
+ public ResponseModel<?> applyReturn(@RequestBody ReturnCoinRecord returnCoinRecord){
|
|
|
+ // 设备ID
|
|
|
+ Long equipmentId = returnCoinRecord.getEquipmentId();
|
|
|
+ // 用户ID
|
|
|
+ Long adminId = returnCoinRecord.getAdminId();
|
|
|
+ // 退币数量
|
|
|
+ Integer amount = returnCoinRecord.getAmount();
|
|
|
+ if (equipmentId == null || adminId == null || amount == null) {
|
|
|
+ return R.fail("参数错误");
|
|
|
+ }
|
|
|
+ if (amount <= 0) {
|
|
|
+ return R.fail("参数错误");
|
|
|
+ }
|
|
|
+ TEquipment equipment = tEquipmentService.getById(equipmentId);
|
|
|
+ if (equipment == null || equipment.getId() == null) {
|
|
|
+ return R.fail("找不到设备");
|
|
|
+ }
|
|
|
+ String clientId = equipment.getClientId();
|
|
|
+ String name = equipment.getName();
|
|
|
+ ReturnCoinRecord record = new ReturnCoinRecord();
|
|
|
+ long commonId = IDGenerator.commonID();
|
|
|
+ record.setId(commonId);
|
|
|
+ record.setCreateDate(new Date());
|
|
|
+ record.setModifyDate(new Date());
|
|
|
+ record.setAdminId(adminId);
|
|
|
+ record.setEquipmentId(equipmentId);
|
|
|
+ record.setAmount(amount);
|
|
|
+ record.setClientId(clientId);
|
|
|
+ if (StringUtils.isEmpty(name)) {
|
|
|
+ record.setName(clientId.substring(clientId.length() - 6));
|
|
|
+ } else {
|
|
|
+ record.setName(name);
|
|
|
+ }
|
|
|
+ record.setStatus(0);
|
|
|
+ returnCoinRecordService.save(record);
|
|
|
+ String message = PushUtils.buildJson(OperationType.RETURN_COIN.getCode(), commonId + ":" + amount).toString();
|
|
|
+ tEquipmentService.sendRemoteMessage(equipment.getClientId(), OperationType.RETURN_COIN, message, adminId);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
}
|
|
|
|