From cd9bd57600aeda42a7b06e015ea1e0b94dd37b75 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 07 四月 2025 17:32:33 +0800
Subject: [PATCH] 虚拟卡余额小于100时提示用户余额不足
---
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java | 251 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 246 insertions(+), 5 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java
index 3a5ce63..e2ef915 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java
@@ -1,13 +1,27 @@
package com.dy.pipIrrIrrigate.project;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.daoIr.IrProjectGroupMapper;
import com.dy.pipIrrGlobal.daoIr.IrProjectMapper;
import com.dy.pipIrrGlobal.pojoIr.IrProject;
+import com.dy.pipIrrGlobal.pojoIr.IrProjectGroup;
+import com.dy.pipIrrGlobal.voIr.VoProject;
+import com.dy.pipIrrGlobal.voIr.VoProjectDetail;
+import com.dy.pipIrrGlobal.voIr.VoProjectOne;
+import com.dy.pipIrrGlobal.voIr.VoProjectSimple;
+import com.dy.pipIrrIrrigate.project.dto.IrrigateProject;
import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.common.utils.PojoUtils;
+import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* @author :WuZeYu
@@ -21,14 +35,16 @@
@Autowired
private IrProjectMapper irProjectMapper;
+ @Autowired
+ private IrProjectGroupMapper irProjectGroupMapper;
+
/**
- * 娣诲姞椤圭洰
- *
+ * 娣诲姞椤圭洰锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純
* @param po
* @return
*/
public Integer addProject(IrProject po) {
- po.setOperateDt(new Date());
+ po.setOperateTime(new Date());
po.setDeleted((byte) 0);
if (po.getVillageId() != null) {
po.setTownId(irProjectMapper.getSupperByVillageId(po.getVillageId()));
@@ -56,8 +72,121 @@
}
/**
- * 鍒犻櫎椤圭洰
- *
+ * 娣诲姞椤圭洰锛岀洰鍓嶄娇鐢�
+ * @param po
+ * @return
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public Map addIrrigateProject(IrrigateProject po) {
+ String projectName = po.getProjectName();
+ String irrigateGroups = po.getIrrigateGroups();
+ Long operatorId = po.getOperator();
+
+ IrProject irProject = new IrProject();
+ irProject.setProjectName(projectName);
+ irProject.setProjectState((byte)1);
+ irProject.setOperator(operatorId);
+ irProject.setOperateTime(new Date());
+ irProject.setDeleted((byte)0);
+ irProjectMapper.insert(irProject);
+ Long projectId = irProject.getId();
+ if(projectId == null) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鍒涘缓鐏屾簤椤圭洰澶辫触");
+ map.put("content", null);
+ return map;
+ }
+
+ String[] irrigateGroupArr = irrigateGroups.split(",");
+ Integer sort = 1;
+ for(String irrigateGroupId : irrigateGroupArr) {
+ String trimmed = irrigateGroupId.trim();
+ if(trimmed.isEmpty()) {
+ continue;
+ }
+ try {
+ Long irrigateGroupIdLong = Long.parseLong(trimmed);
+ IrProjectGroup irProjectGroup = new IrProjectGroup();
+ irProjectGroup.setProjectId(projectId);
+ irProjectGroup.setGroupId(irrigateGroupIdLong);
+ irProjectGroup.setSort(sort++);
+ irProjectGroupMapper.insert(irProjectGroup);
+ } catch (NumberFormatException e) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鐏屾簤缁処D鏍煎紡閿欒");
+ map.put("content", null);
+ return map;
+ }
+ }
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "娣诲姞鐏屾簤椤圭洰鎴愬姛");
+ map.put("content", null);
+ return map;
+ }
+
+ /**
+ * 鍒犻櫎鐏屾簤椤圭洰锛岀洰鍓嶄娇鐢�
+ * @param projectId
+ * @return
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public Map deleteIrrigateProject(Long projectId) {
+ try {
+ irProjectGroupMapper.unbindGroup(projectId);
+ irProjectMapper.deleteByPrimaryKey(projectId);
+
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "鐏屾簤椤圭洰鍒犻櫎鎴愬姛");
+ map.put("content", null);
+ return map;
+ } catch (Exception e) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鐏屾簤椤圭洰鍒犻櫎澶辫触");
+ map.put("content", null);
+ return map;
+ }
+ }
+
+ /**
+ * 淇敼鐏屾簤椤圭洰锛岀洰鍓嶄娇鐢�
+ * @param po
+ * @return
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public Map updateIrrigateProject(IrrigateProject po) {
+ Long projectId = po.getProjectId();
+ Map map_deleteProject = ((ProjectSv) AopContext.currentProxy()).deleteIrrigateProject(projectId);
+ if(map_deleteProject.get("success").equals(false)) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", map_deleteProject.get("msg").toString());
+ map.put("content", null);
+ return map;
+ }
+
+ Map map_addProject = ((ProjectSv) AopContext.currentProxy()).addIrrigateProject(po);
+ if(map_addProject.get("success").equals(false)) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", map_addProject.get("msg").toString());
+ map.put("content", null);
+ return map;
+ }
+
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "淇敼鐏屾簤椤圭洰鎴愬姛");
+ map.put("content", null);
+ return map;
+ }
+
+ /**
+ * 鍒犻櫎椤圭洰锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純
* @param id
*/
public Integer deleteProject(Long id) {
@@ -67,4 +196,116 @@
}
return 1;
}
+
+ /**
+ * 淇敼椤圭洰淇℃伅
+ * @param po
+ * @return
+ */
+ public Integer updateProject(IrProject po){
+ po.setOperateTime(new Date());
+ if (po.getVillageId() != null) {
+ po.setTownId(irProjectMapper.getSupperByVillageId(po.getVillageId()));
+ po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
+ po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
+ po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
+ }
+ if (po.getTownId() != null) {
+ po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
+ po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
+ po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
+ }
+ if (po.getCountyId() != null) {
+ po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
+ po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
+ }
+ if (po.getCityId() != null) {
+ po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
+ }
+ int rows = irProjectMapper.updateByPrimaryKeySelective(po);
+ if (rows == 0){
+ return 0;
+ }
+ return 1;
+ }
+
+ /**
+ * 淇敼椤圭洰鐘舵��
+ * @param po
+ * @return
+ */
+ public Integer updateProjectState(IrProject po){
+ po.setOperateTime(new Date());
+ int rows = irProjectMapper.updateProjectState(po);
+ if (rows == 0){
+ return 0;
+ }
+ return 1;
+ }
+
+ /**
+ * 鑾峰彇涓�涓」鐩暟鎹�
+ * @param id
+ * @return
+ */
+ public VoProjectOne selectById(Long id){
+ VoProjectOne irProject = irProjectMapper.selectById(id);
+ return irProject;
+ }
+
+ /**
+ * 鍒嗛〉鏌ヨ椤圭洰锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純
+ * @param queryVo
+ * @return
+ */
+ public QueryResultVo<List<VoProject>> getProjects(QueryVo queryVo){
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+ Long itemTotal = irProjectMapper.getRecordCount(params);
+
+ QueryResultVo<List<VoProject>> rsVo = new QueryResultVo<>();
+ rsVo.pageSize = queryVo.pageSize;
+ rsVo.pageCurr = queryVo.pageCurr;
+ rsVo.calculateAndSet(itemTotal, params);
+ rsVo.obj = irProjectMapper.getProjects(params);
+ return rsVo;
+ }
+
+ /**
+ * 鍒嗛〉鏌ヨ椤圭洰锛屾柊鐗堟湰锛岀洰鍓嶄娇鐢�
+ * @param queryVo
+ * @return
+ */
+ public QueryResultVo<List<VoProjectSimple>> getSimpleProjects(QueryVo queryVo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+ Long itemTotal = irProjectMapper.getSimpleProjectsCount(params);
+
+ QueryResultVo<List<VoProjectSimple>> rsVo = new QueryResultVo<>();
+ rsVo.pageSize = queryVo.pageSize;
+ rsVo.pageCurr = queryVo.pageCurr;
+ rsVo.calculateAndSet(itemTotal, params);
+ rsVo.obj = irProjectMapper.getSimpleProjects(params);
+ return rsVo;
+ }
+
+ /**
+ * 鏍规嵁椤圭洰Id鑾峰彇椤圭洰璇︽儏锛岀紪杈戦」鐩俊鎭娇鐢�
+ * @param projectId
+ * @return
+ */
+ public Map getProjectDetail(Long projectId) {
+ try {
+ VoProjectDetail voProjectDetail = irProjectMapper.getProjectDetail(projectId);
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "鑾峰彇椤圭洰璇︽儏鎴愬姛");
+ map.put("content", voProjectDetail);
+ return map;
+ } catch (Exception e) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鑾峰彇椤圭洰璇︽儏澶辫触");
+ map.put("content", null);
+ return map;
+ }
+ }
}
--
Gitblit v1.8.0