Browse Source

2月5日,消息推送

dev
wangguorui 3 weeks ago
parent
commit
00bf932958
  1. 21
      src/main/java/com/example/demo/controller/cash/CashRefundController.java
  2. 6
      src/main/java/com/example/demo/mapper/cash/CashCollectionMapper.java
  3. 3
      src/main/java/com/example/demo/mapper/cash/CashRefundMapper.java
  4. 2
      src/main/java/com/example/demo/service/cash/RefundService.java
  5. 29
      src/main/java/com/example/demo/serviceImpl/cash/CashAuditServiceImpl.java
  6. 56
      src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java
  7. 20
      src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java
  8. 6
      src/main/resources/cashMapper/CashCollectionMapper.xml
  9. 6
      src/main/resources/cashMapper/CashRefundMapper.xml

21
src/main/java/com/example/demo/controller/cash/CashRefundController.java

@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
@ -240,35 +241,31 @@ public class CashRefundController {
} }
@PostMapping("/update") @PostMapping("/update")
public Result update(@RequestBody CashRecordDone cashRecordDone, @RequestHeader(defaultValue = "zh_CN") String lang)throws Exception {
public Result update(@RequestBody CashRecordDone cashRecordDone)throws Exception {
try { try {
if (cashRecordDone.getStatus() == null) { if (cashRecordDone.getStatus() == null) {
String errorMsg = languageTranslationUtil.translate("状态为空", lang);
return Result.error(errorMsg);
return Result.error("状态为空");
} }
if (cashRecordDone.getStatus() == 10) { if (cashRecordDone.getStatus() == 10) {
int result = refundService.withdraw(cashRecordDone); int result = refundService.withdraw(cashRecordDone);
String msg = result > 0 ? languageTranslationUtil.translate("操作成功", lang) : languageTranslationUtil.translate("操作失败", lang);
String msg = result > 0 ? "操作成功" : "操作失败";
return Result.success(msg); return Result.success(msg);
} }
else if (cashRecordDone.getStatus() == 11) { else if (cashRecordDone.getStatus() == 11) {
try { try {
int result = refundService.update(cashRecordDone, lang);
String msg = result > 0 ? languageTranslationUtil.translate("操作成功", lang) : languageTranslationUtil.translate("操作失败", lang);
int result = refundService.update(cashRecordDone);
String msg = result > 0 ? "操作成功" : "操作失败";
return Result.success(msg); return Result.success(msg);
} catch (Exception e) { } catch (Exception e) {
String errorMsg = languageTranslationUtil.translate(e.getMessage(), lang);
return Result.error(errorMsg);
return Result.error(e.getMessage());
} }
} }
else { else {
String errorMsg = languageTranslationUtil.translate("该订单状态无法支持此操作", lang);
return Result.error(errorMsg);
return Result.error("该订单状态无法支持此操作");
} }
} catch (Exception e) { } catch (Exception e) {
String errorMsg = languageTranslationUtil.translate("操作失败", lang);
return Result.error(errorMsg + ": " + e.getMessage());
return Result.error("操作失败" + ": " + e.getMessage());
} }
} }

6
src/main/java/com/example/demo/mapper/cash/CashCollectionMapper.java

@ -92,4 +92,10 @@ public interface CashCollectionMapper {
void updateGoldOrder(@Param("cashRecordCollection")CashRecord cashRecord); void updateGoldOrder(@Param("cashRecordCollection")CashRecord cashRecord);
//根据订单号查询商品名称 //根据订单号查询商品名称
String selectGoodsNameByCode(String orderCode); String selectGoodsNameByCode(String orderCode);
// 根据 typeId type 更新消息记录的 flag 字段
int updateMessageFlagByTypeIdAndType(@Param("typeId") Integer typeId,
@Param("type") Integer type,
@Param("flag") Integer flag);
} }

3
src/main/java/com/example/demo/mapper/cash/CashRefundMapper.java

@ -44,4 +44,7 @@ public interface CashRefundMapper {
List<FundsDTO> selectRefundCount(List<Integer> needQueryIds); List<FundsDTO> selectRefundCount(List<Integer> needQueryIds);
void updategold(String orderCode); void updategold(String orderCode);
// 新增方法根据订单ID更新消息表的flag字段
void updateMessageFlagByOrderId(Integer orderId);
} }

2
src/main/java/com/example/demo/service/cash/RefundService.java

@ -20,7 +20,7 @@ public interface RefundService {
//添加 //添加
int add(CashRecordRefund cashRecordRefund, String lang) throws Exception; int add(CashRecordRefund cashRecordRefund, String lang) throws Exception;
//修改 //修改
int update(CashRecordDone cashRecordDone, String lang) throws Exception;
int update(CashRecordDone cashRecordDone) throws Exception;
// //
int withdraw(CashRecordDone cashRecordDone); int withdraw(CashRecordDone cashRecordDone);
//审核 //审核

29
src/main/java/com/example/demo/serviceImpl/cash/CashAuditServiceImpl.java

@ -196,7 +196,7 @@ public class CashAuditServiceImpl implements CashAuditService {
//更新订单 //更新订单
cashAuditMapper.updateOrder(updateOrder); cashAuditMapper.updateOrder(updateOrder);
if (action == 1){ if (action == 1){
// 创建消息队列用于发送审核结果通知
// 创建消息队列1用于发送审核结果通知
Messages message1 = new Messages(); Messages message1 = new Messages();
message1.setJwcode(order.getJwcode()); message1.setJwcode(order.getJwcode());
message1.setName(order.getName()); message1.setName(order.getName());
@ -205,26 +205,41 @@ public class CashAuditServiceImpl implements CashAuditService {
message1.setTitle("现金管理--收款处理(负责人)"); message1.setTitle("现金管理--收款处理(负责人)");
message1.setType(0); message1.setType(0);
message1.setTypeId(order.getId()); message1.setTypeId(order.getId());
message1.setMarket(Integer.valueOf(order.getReceivedMarket()));
message1.setMarket(Integer.valueOf(order.getMarket()));
String marketName1 = marketMapper.getMarketNameById(String.valueOf(message1.getMarket())); String marketName1 = marketMapper.getMarketNameById(String.valueOf(message1.getMarket()));
message1.setMarketName(marketName1); message1.setMarketName(marketName1);
message1.setQueryId(86); message1.setQueryId(86);
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_COLLECTION_EXCHANGE, "cash.collection.save", message1); rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_COLLECTION_EXCHANGE, "cash.collection.save", message1);
}
// 创建消息队列2用于发送审核结果通知
Messages message2 = new Messages();
message2.setJwcode(order.getJwcode());
message2.setName(order.getName());
message2.setStatus(updateOrder.getStatus());
message2.setDesc("的收款记录需补充手续费,前往填写");
message2.setTitle("现金管理--收款处理");
message2.setType(0);
message2.setTypeId(order.getId());
message2.setMarket(Integer.valueOf(order.getMarket()));
String marketName2 = marketMapper.getMarketNameById(String.valueOf(message2.getMarket()));
message2.setMarketName(marketName2);
message2.setQueryId(74);
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_COLLECTION_EXCHANGE, "cash.collection.save", message2);
} else {
// 创建消息队列用于发送审核结果通知 // 创建消息队列用于发送审核结果通知
Messages message = new Messages(); Messages message = new Messages();
message.setJwcode(order.getJwcode()); message.setJwcode(order.getJwcode());
message.setName(order.getName()); message.setName(order.getName());
message.setStatus(updateOrder.getStatus()); message.setStatus(updateOrder.getStatus());
message.setDesc(action==1?"的收款记录需补充手续费,前往填写":"的现金收款申请已被驳回,前往查看驳回理由");
message.setTitle(action==1?"现金管理--收款处理":"现金管理--收款提交");
message.setDesc("的现金收款申请已被驳回,前往查看驳回理由");
message.setTitle("现金管理--收款提交");
message.setType(0); message.setType(0);
message.setTypeId(order.getId()); message.setTypeId(order.getId());
message.setMarket(Integer.valueOf(order.getReceivedMarket()));
message.setMarket(Integer.valueOf(order.getMarket()));
String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket()));
message.setMarketName(marketName); message.setMarketName(marketName);
message.setQueryId(action==1?74:60);
message.setQueryId(60);
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_COLLECTION_EXCHANGE, "cash.collection.save", message); rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_COLLECTION_EXCHANGE, "cash.collection.save", message);
}
return true; return true;
} }
} }

56
src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java

@ -144,7 +144,7 @@ public class CashCollectionServiceImpl implements CashCollectionService {
message.setTitle("现金管理--收款处理"); message.setTitle("现金管理--收款处理");
message.setType(0); message.setType(0);
message.setTypeId(cashRecord.getId()); message.setTypeId(cashRecord.getId());
message.setMarket(Integer.valueOf(cashRecord.getReceivedMarket()));
message.setMarket(Integer.valueOf(cashRecord.getMarket()));
String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket()));
message.setMarketName(marketName); message.setMarketName(marketName);
message.setQueryId(67); message.setQueryId(67);
@ -198,7 +198,7 @@ public class CashCollectionServiceImpl implements CashCollectionService {
message.setTitle("现金收款--现金收款"); message.setTitle("现金收款--现金收款");
message.setType(1); message.setType(1);
message.setTypeId(cashRecord.getId()); message.setTypeId(cashRecord.getId());
message.setMarket(Integer.valueOf(cashRecord.getReceivedMarket()));
message.setMarket(Integer.valueOf(cashRecord.getMarket()));
String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket()));
message.setMarketName(marketName); message.setMarketName(marketName);
message.setQueryId(67); message.setQueryId(67);
@ -209,6 +209,7 @@ public class CashCollectionServiceImpl implements CashCollectionService {
//撤回未审核的订单 //撤回未审核的订单
@Override @Override
public String cancel(String orderCode) { public String cancel(String orderCode) {
// 查询订单是否存在
CashRecord cashRecord = cashCollectionMapper.selectByOrderCode(orderCode); CashRecord cashRecord = cashCollectionMapper.selectByOrderCode(orderCode);
if (cashRecord == null) { if (cashRecord == null) {
throw new IllegalArgumentException("订单不存在"); throw new IllegalArgumentException("订单不存在");
@ -216,9 +217,28 @@ public class CashCollectionServiceImpl implements CashCollectionService {
if (cashRecord.getStatus() != 0) { if (cashRecord.getStatus() != 0) {
throw new IllegalArgumentException("订单状态不符合条件"); throw new IllegalArgumentException("订单状态不符合条件");
} }
//修改订单状态
// 更新订单状态为撤回状态5
int rows = cashCollectionMapper.updateStatus(orderCode, 5); int rows = cashCollectionMapper.updateStatus(orderCode, 5);
// 更新与该订单关联的消息记录的 flag 字段为 1
try {
// 根据订单ID查找关联的消息记录
Messages message = new Messages();
message.setTypeId(cashRecord.getId()); // 订单ID作为消息的 typeId
message.setType(0); // 消息类型为收款
// 更新消息的 flag 字段为 1
int messageRows = cashCollectionMapper.updateMessageFlagByTypeIdAndType(
message.getTypeId(), message.getType(), 1);
if (messageRows <= 0) {
log.warn("未找到与订单 {} 关联的消息记录", orderCode);
}
} catch (Exception e) {
log.error("更新消息状态失败,订单号:{}", orderCode, e);
// 可选择抛出异常或记录日志后继续执行
}
return rows > 0 ? "撤回成功" : "撤回失败"; return rows > 0 ? "撤回成功" : "撤回失败";
} }
@ -280,21 +300,20 @@ public class CashCollectionServiceImpl implements CashCollectionService {
//cashRecord.setMarket(cashCollectionMapper.getMarketByJwcode(cashRecord.getJwcode())); //cashRecord.setMarket(cashCollectionMapper.getMarketByJwcode(cashRecord.getJwcode()));
int rows = cashCollectionMapper.updateByOrderCode(cashRecord); int rows = cashCollectionMapper.updateByOrderCode(cashRecord);
if (rows > 0) { if (rows > 0) {
// 发送重新提交消息
CashCollectionMessage message = new CashCollectionMessage();
message.setId(cashRecord.getId());
message.setOrderCode(cashRecord.getOrderCode());
message.setStatus(0); // 重新提交后状态变为待审核
message.setStatusDescription("线下财务待审核");
message.setMessage("收款订单已重新提交");
message.setSubmitterId(cashRecord.getSubmitterId());
message.setTimestamp(LocalDateTime.now());
rabbitTemplate.convertAndSend(
RabbitMQConfig.CASH_COLLECTION_EXCHANGE,
"collection.created",
message
);
// 发送收款创建消息
Messages message = new Messages();
message.setJwcode(cashRecord.getJwcode());
message.setName(cashRecord.getName());
message.setStatus(cashRecord.getStatus());
message.setDesc("的现金收款申请待审核,前往审核");
message.setTitle("现金管理--收款处理");
message.setType(0);
message.setTypeId(cashRecord.getId());
message.setMarket(Integer.valueOf(cashRecord.getMarket()));
String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket()));
message.setMarketName(marketName);
message.setQueryId(67);
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_COLLECTION_EXCHANGE, "cash.collection.save", message);
} }
return rows > 0 ? "重新提交成功" : "重新提交失败"; return rows > 0 ? "重新提交成功" : "重新提交失败";
} }
@ -576,4 +595,5 @@ public class CashCollectionServiceImpl implements CashCollectionService {
return new PageInfo<>(performanceVOs); return new PageInfo<>(performanceVOs);
} }
} }

20
src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java

@ -215,7 +215,7 @@ public class CashRefundServiceImpl implements RefundService {
message.setTitle("现金退款--新增退款"); message.setTitle("现金退款--新增退款");
message.setType(0); message.setType(0);
message.setTypeId(cashRecordRefund.getId()); message.setTypeId(cashRecordRefund.getId());
message.setMarket(Integer.valueOf(cashRecordRefund.getSubmitterMarket()));
message.setMarket(Integer.valueOf(cashRecordRefund.getMarket()));
String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket()));
message.setMarketName(marketName); message.setMarketName(marketName);
message.setQueryId(103); message.setQueryId(103);
@ -226,7 +226,7 @@ public class CashRefundServiceImpl implements RefundService {
} }
@Override @Override
public int update(CashRecordDone cashRecordDone, @RequestHeader(defaultValue = "zh_CN") String lang) throws Exception {
public int update(CashRecordDone cashRecordDone) throws Exception {
if (cashRecordDone.getJwcode() == null) { if (cashRecordDone.getJwcode() == null) {
throw new RuntimeException("未输入精网号"); throw new RuntimeException("未输入精网号");
} }
@ -260,7 +260,7 @@ public class CashRefundServiceImpl implements RefundService {
message.setTitle("现金管理--退款审批"); message.setTitle("现金管理--退款审批");
message.setType(1); message.setType(1);
message.setTypeId(cashRecordDTO.getId()); message.setTypeId(cashRecordDTO.getId());
message.setMarket(Integer.valueOf(cashRecordDTO.getReceivedMarket()));
message.setMarket(cashRecordDTO.getMarket());
String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket()));
message.setMarketName(marketName); message.setMarketName(marketName);
message.setQueryId(103); message.setQueryId(103);
@ -271,7 +271,15 @@ public class CashRefundServiceImpl implements RefundService {
@Override @Override
public int withdraw(CashRecordDone cashRecordDone) { public int withdraw(CashRecordDone cashRecordDone) {
return cashRefundMapper.withdraw(cashRecordDone.getId());
// 撤回订单
int result = cashRefundMapper.withdraw(cashRecordDone.getId());
if (result > 0) {
// 更新与该订单关联的消息记录的flag字段为1
cashRefundMapper.updateMessageFlagByOrderId(cashRecordDone.getId());
}
return result;
} }
@Override @Override
@ -312,7 +320,7 @@ public class CashRefundServiceImpl implements RefundService {
} }
message.setType(1); message.setType(1);
message.setTypeId(cashRecordDTO.getId()); message.setTypeId(cashRecordDTO.getId());
message.setMarket(Integer.valueOf(cashRecordDTO.getReceivedMarket()));
message.setMarket(cashRecordDTO.getMarket());
String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket()));
message.setMarketName(marketName); message.setMarketName(marketName);
@ -435,7 +443,7 @@ public class CashRefundServiceImpl implements RefundService {
message.setTitle(cashRecordDTO.getStatus() != 32 ? "现金管理--执行明细填写":"现金管理--退款提交"); message.setTitle(cashRecordDTO.getStatus() != 32 ? "现金管理--执行明细填写":"现金管理--退款提交");
message.setType(1); message.setType(1);
message.setTypeId(cashRecordDTO.getId()); message.setTypeId(cashRecordDTO.getId());
message.setMarket(Integer.valueOf(cashRecordDTO.getReceivedMarket()));
message.setMarket(cashRecordDTO.getMarket());
String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket()));
message.setMarketName(marketName); message.setMarketName(marketName);
message.setQueryId(cashRecordDTO.getStatus() != 32 ? 115:99); message.setQueryId(cashRecordDTO.getStatus() != 32 ? 115:99);

6
src/main/resources/cashMapper/CashCollectionMapper.xml

@ -456,4 +456,10 @@
where order_code=#{orderNo} where order_code=#{orderNo}
</update> </update>
<update id="updateMessageFlagByTypeIdAndType">
UPDATE message
SET flag = #{flag}
WHERE type_id = #{typeId} AND type = #{type}
</update>
</mapper> </mapper>

6
src/main/resources/cashMapper/CashRefundMapper.xml

@ -520,5 +520,9 @@
</where> </where>
</select> </select>
<update id="updateMessageFlagByOrderId">
UPDATE message
SET flag = 1
WHERE type_id = #{orderId} AND type = 0
</update>
</mapper> </mapper>
Loading…
Cancel
Save