From c886427f55fdcebdc5e795050a2355c4ad419c67 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 09 五月 2025 14:14:51 +0800
Subject: [PATCH] 缺失一个import
---
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardSv.java | 308 +++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 263 insertions(+), 45 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardSv.java
index 1b25e36..a0912b9 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardSv.java
@@ -3,35 +3,37 @@
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper;
+import com.dy.pipIrrGlobal.daoPr.PrIntakeVcMapper;
import com.dy.pipIrrGlobal.daoSe.*;
-import com.dy.pipIrrGlobal.pojoSe.SeVcRecharge;
-import com.dy.pipIrrGlobal.pojoSe.SeVcRefund;
-import com.dy.pipIrrGlobal.pojoSe.SeVcRefundItem;
-import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard;
+import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate;
+import com.dy.pipIrrGlobal.pojoPr.PrIntakeVc;
+import com.dy.pipIrrGlobal.pojoSe.*;
+import com.dy.pipIrrGlobal.voPr.VoIntakeSimple;
import com.dy.pipIrrGlobal.voSe.VoOrders;
+import com.dy.pipIrrGlobal.voSe.VoRechargeProfile;
import com.dy.pipIrrGlobal.voSe.VoVcRecharge;
import com.dy.pipIrrGlobal.voSe.VoVirtualCard;
-
-import com.dy.pipIrrSell.result.SellResultCode;
-import com.dy.pipIrrSell.virtualCard.dto.DtoVcRecharge;
-import com.dy.pipIrrSell.virtualCard.dto.DtoVirtualCard;
-import com.dy.pipIrrSell.virtualCard.enums.LastOperateENUM;
-import com.dy.pipIrrSell.virtualCard.enums.OrderStateENUM;
-
+import com.dy.pipIrrWechat.irrigatePlan.enums.OperateTypeENUM;
+import com.dy.pipIrrWechat.result.WechatResultCode;
+import com.dy.pipIrrWechat.virtualCard.dto.DtoRegist;
+import com.dy.pipIrrWechat.virtualCard.dto.DtoVirtualCard;
+import com.dy.pipIrrWechat.virtualCard.enums.LastOperateENUM;
+import com.dy.pipIrrWechat.virtualCard.enums.OrderStateENUM;
+import com.dy.pipIrrWechat.virtualCard.qo.QoVcRecharge;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* @author ZhuBaoMin
- * @date 2024-07-11 15:49
- * @LastEditTime 2024-07-11 15:49
+ * @date 2024-07-15 9:39
+ * @LastEditTime 2024-07-15 9:39
* @Description
*/
@@ -53,8 +55,24 @@
@Autowired
private SeClientMapper seClientMapper;
+ @Autowired
+ private SeVcOperateMapper seVcOperateMapper;
+
+ @Autowired
+ private SeRechargeProfileMapper seRechargeProfileMapper;
+
+ @Autowired
+ private PrIntakeMapper prIntakeMapper;
+
+ @Autowired
+ private PrIntakeVcMapper prIntakeVcMapper;
+
+ @Value("${vc.alarmValue}")
+ private Integer alarmValue;
+
/**
* 鏍规嵁鍐滄埛ID鑾峰彇5绾ц鏀垮尯鍒掍唬鐮侊紝娉ㄥ唽铏氭嫙鍗′娇鐢�
+ *
* @param clientId 鍐滄埛ID
* @return 5绾ц鏀垮尯鍒掍唬鐮�
*/
@@ -64,14 +82,16 @@
/**
* 鑾峰彇鍐滄埛鍏ㄩ儴铏氭嫙鍗�
+ *
* @return
*/
public List<VoVirtualCard> getVCs(Long clientId) {
- return seVirtualCardMapper.getVCs(clientId);
+ return seVirtualCardMapper.getVCs(alarmValue, clientId);
}
/**
* 鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞�
+ *
* @param vcId
* @return
*/
@@ -81,6 +101,7 @@
/**
* 娉ㄥ唽铏氭嫙鍗�
+ *
* @param po
* @return
*/
@@ -90,7 +111,30 @@
}
/**
+ * 鏍规嵁鍐滄埛ID鍙婅櫄鎷熷崱ID鑾峰彇姝e父鐘舵�佺殑铏氭嫙鍗″璞�
+ *
+ * @param clientId
+ * @param vcId
+ * @return
+ */
+ public SeVirtualCard getVcByClientIdAndVcId(Long clientId, Long vcId) {
+ return seVirtualCardMapper.getVcByClientIdAndVcId(clientId, vcId);
+ }
+
+ /**
+ * 鏍规嵁铏氭嫙鍗D娉ㄩ攢铏氭嫙鍗�
+ *
+ * @param clientId
+ * @param vcId
+ * @return
+ */
+ public Integer cancelVc(Long clientId, Long vcId) {
+ return seVirtualCardMapper.cancelVc(clientId, vcId);
+ }
+
+ /**
* 鏍规嵁琛屾斂鍖哄垝涓叉ā绯婃煡璇㈣櫄鎷熷崱缂栧彿锛屾敞鍐岃櫄鎷熷崱浣跨敤
+ *
* @param areaCode
* @return
*/
@@ -110,6 +154,7 @@
/**
* 淇敼铏氭嫙鍗�
* 鍏呭�笺�佹秷璐广�佺敵璇烽��娆俱�佸鏍搁��娆炬椂闇�瑕佷慨鏀硅櫄鎷熷崱鐨勶細浣欓銆佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂�
+ *
* @param po
* @return
*/
@@ -119,6 +164,7 @@
/**
* 鏍规嵁铏氭嫙鍗$紪鍙疯幏鍙栬櫄鎷熷崱瀵硅薄
+ *
* @param virtualId
* @return
*/
@@ -129,19 +175,22 @@
/**
* 娣诲姞铏氭嫙鍗″厖鍊艰褰�
* JSAPI涓嬪崟鍚庣敓鎴愰儴鍒嗗厖鍊艰褰�
+ *
* @param po
- * @return
+ * @return -1锛氳櫄鎷熷崱涓嶅瓨鍦紝0锛氭坊鍔犲厖鍊艰褰曞け璐�
*/
- public BaseResponse<Boolean> insertVCRecharge(DtoVirtualCard po) {
+ //public BaseResponse<Boolean> insertVCRecharge(DtoVirtualCard po) {
+ public Long insertVCRecharge(DtoVirtualCard po) {
String orderNumber = po.getOrderNumber();
Long virtualId = po.getVirtualId();
Long clientId = po.getClientId();
- Integer rechargeAmount = po.getRechargeAmount();
+ Double rechargeAmount = po.getRechargeAmount();
// 楠岃瘉璇ヨ櫄鎷熷崱璐︽埛鏄惁瀛樺湪骞跺彇鍑哄綋鍓嶈处鎴蜂綑棰�
SeVirtualCard seVirtualCard = seVirtualCardMapper.selectByPrimaryKey(virtualId);
- if(seVirtualCard == null) {
- return BaseResponseUtils.buildFail(SellResultCode.NO_ACCOUNT.getMessage());
+
+ if (seVirtualCard == null) {
+ return -1L;
}
Double money = seVirtualCard.getMoney();
@@ -154,15 +203,17 @@
seVcRecharge.setRechargeAmount(rechargeAmount);
seVcRecharge.setOrderTime(new Date());
seVcRecharge.setOrderState(OrderStateENUM.NON_PAYMENT.getCode());
- Integer rec = seVcRechargeMapper.insert(seVcRecharge);
- if(rec == null) {
- return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL.getMessage());
+ seVcRechargeMapper.insert(seVcRecharge);
+ Long rechargeId = seVcRecharge.getId();
+ if (rechargeId == null) {
+ return 0L;
}
- return BaseResponseUtils.buildSuccess(true) ;
+ return rechargeId;
}
/**
* 鏍规嵁璁㈠崟鍙疯幏鍙栬櫄鎷熷崱鍏呭�煎璞�
+ *
* @param orderNumber
* @return
*/
@@ -173,48 +224,50 @@
/**
* 淇敼铏氭嫙鍗″厖鍊艰褰�
* 寰俊鏀粯閫氱煡鍚庯細
- * 1. 鏇存柊鍏呭�艰〃锛氬厖鍊煎悗浣欓銆佹敮浠樺畬鎴愭椂闂淬�佽鍗曠姸鎬�
- * 2. 鏇存柊铏氭嫙鍗¤〃锛氳处鎴蜂綑棰濄�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂�
+ * 1. 鏇存柊鍏呭�艰〃锛氬厖鍊煎悗浣欓銆佹敮浠樺畬鎴愭椂闂淬�佽鍗曠姸鎬�
+ * 2. 鏇存柊铏氭嫙鍗¤〃锛氳处鎴蜂綑棰濄�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂�
+ *
* @param orderNumber 璁㈠崟缂栧彿
* @return
*/
@Transactional(rollbackFor = Exception.class)
public BaseResponse<Boolean> updateVCRecharge(String orderNumber, Date rechargeTime) {
SeVcRecharge seVcRecharge = seVcRechargeMapper.getVCRechargeByorderNumber(orderNumber);
- if(seVcRecharge == null) {
- return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_NOT_EXIST.getMessage());
+ if (seVcRecharge == null) {
+ return BaseResponseUtils.buildFail(WechatResultCode.RECHARGE_NOT_EXIST.getMessage());
}
Long virtualId = seVcRecharge.getVcId();
Double money = seVcRecharge.getMoney();
- Integer rechargeAmount = seVcRecharge.getRechargeAmount();
+ Double rechargeAmount = seVcRecharge.getRechargeAmount();
Double afterRrecharge = money + rechargeAmount;
seVcRecharge.setAfterRecharge(afterRrecharge);
seVcRecharge.setRechargeTime(rechargeTime);
seVcRecharge.setOrderState(OrderStateENUM.PAID.getCode());
Integer rec = seVcRechargeMapper.updateByPrimaryKeySelective(seVcRecharge);
- if(rec == null) {
- return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL.getMessage());
+ if (rec == null) {
+ return BaseResponseUtils.buildFail(WechatResultCode.RECHARGE_FAIL.getMessage());
}
SeVirtualCard seVirtualCard = seVirtualCardMapper.selectByPrimaryKey(virtualId);
- if(seVirtualCard == null) {
- return BaseResponseUtils.buildFail(SellResultCode.VIRTUAL_CARD_NOT_EXIST.getMessage());
+ if (seVirtualCard == null) {
+ return BaseResponseUtils.buildFail(WechatResultCode.VIRTUAL_CARD_NOT_EXIST.getMessage());
}
seVirtualCard.setMoney(afterRrecharge);
seVirtualCard.setLastOperate(LastOperateENUM.RECHARGE.getCode());
seVirtualCard.setLastOperateTime(new Date());
Integer rec2 = seVirtualCardMapper.updateByPrimaryKeySelective(seVirtualCard);
- if(rec2 == null) {
- return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL.getMessage());
+ if (rec2 == null) {
+ return BaseResponseUtils.buildFail(WechatResultCode.RECHARGE_FAIL.getMessage());
}
- return BaseResponseUtils.buildSuccess(true) ;
+ return BaseResponseUtils.buildSuccess(true);
}
/**
* 淇敼铏氭嫙鍗″厖鍊艰褰曪紙搴熷純锛�
* 寰俊灏忕▼搴忔敮浠橀�氱煡鍚庝慨鏀癸細浣欓銆佸厖鍊煎悗浣欓銆佸厖鍊煎畬鎴愭椂闂�
+ *
* @param po
* @return
*/
@@ -224,16 +277,18 @@
/**
* 鏍规嵁铏氭嫙鍗″彿鑾峰彇璁㈠崟鍒楄〃
+ *
* @param virtualId
* @return
*/
public List<VoOrders> selectOrders(Long virtualId) {
List<VoOrders> rsVo = seVcRechargeMapper.getOrders(virtualId);
- return rsVo ;
+ return rsVo;
}
/**
* 鏍规嵁閫�娆綢D鑾峰彇閫�娆惧璞�
+ *
* @param refundId
* @return
*/
@@ -243,6 +298,7 @@
/**
* 娣诲姞閫�娆剧敵璇�
+ *
* @param po
* @return
*/
@@ -253,6 +309,7 @@
/**
* 淇敼閫�娆捐褰�
+ *
* @param po
* @return
*/
@@ -262,6 +319,7 @@
/**
* 鏍规嵁璁㈠崟鍙疯幏鍙栧叾鍚勭瑪閫�娆鹃噾棰�
+ *
* @param orderNumber
* @return
*/
@@ -272,6 +330,7 @@
/**
* 娣诲姞閫�娆惧垎椤�
+ *
* @param po
* @return
*/
@@ -282,6 +341,7 @@
/**
* 缂栬緫閫�娆惧垎椤�
+ *
* @param po
* @return
*/
@@ -291,32 +351,35 @@
/**
* 鏍规嵁璁㈠崟鍙风敓鎴愰��娆惧崟鍙�
+ *
* @param orderNumber
* @return
*/
public String generateRefundNumber(String orderNumber) {
String refundNumber = seVcRefundItemMapper.getLastRefundNumber(orderNumber);
- if(refundNumber == null) {
+ if (refundNumber == null) {
refundNumber = orderNumber + "01";
return refundNumber;
}
- String a = String.format("%02d", (Integer.parseInt(refundNumber.substring(29,30).trim()) + 1));
- return a;
+ String a = String.format("%02d", (Integer.parseInt(refundNumber.substring(29, 30).trim()) + 1));
+ return a;
}
/**
* 鏍规嵁璁㈠崟鍙疯幏鍙栧厖鍊奸噾棰濓紝璋冪敤閫�娆剧敵璇锋帴鍙d娇鐢�
+ *
* @param orderNumber
* @return
*/
- public Integer getRechargeAmountByOrderNumber(String orderNumber) {
+ public Double getRechargeAmountByOrderNumber(String orderNumber) {
return seVcRechargeMapper.getRechargeAmountByOrderNumber(orderNumber);
}
/**
* 鏍规嵁閫�娆鹃�氱煡鎺ュ彛杩斿洖鐨勯��娆惧崟鍙峰弽鏌ラ��娆綢D锛屾煡璇㈣閫�娆綢D涓嬫湭閫�娆捐褰曟暟閲�
+ *
* @param refundNumber
* @return
*/
@@ -326,6 +389,7 @@
/**
* 鏍规嵁閫�娆惧崟鍙疯幏鍙栭��娆綢D锛岄��娆鹃�氱煡鍚庢洿鏂伴��娆捐〃鎵�闇�
+ *
* @param refundNumber
* @return
*/
@@ -335,10 +399,11 @@
/**
* 鑾峰彇铏氭嫙鍗″厖鍊艰褰�
+ *
* @param dtoVcRecharge
* @return
*/
- public QueryResultVo<List<VoVcRecharge>> getVcRechargeRecords(DtoVcRecharge dtoVcRecharge){
+ public QueryResultVo<List<VoVcRecharge>> getVcRechargeRecords(QoVcRecharge dtoVcRecharge) {
Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(dtoVcRecharge);
Long itemTotal = seVirtualCardMapper.getRechargeRecordCount(params);
@@ -351,5 +416,158 @@
return rsVo;
}
-}
+ /**
+ * 娣诲姞铏氭嫙鍗℃搷浣滆褰�
+ *
+ * @param po
+ * @return
+ */
+ public Long insertVcOperate(SeVcOperate po) {
+ seVcOperateMapper.insert(po);
+ return po.getId();
+ }
+
+ /**
+ * 鑾峰彇铏氭嫙鍗″父鐢ㄥ厖鍊奸噾棰濋厤缃�
+ *
+ * @return
+ */
+ public List<VoRechargeProfile> gerRechargeProfiles() {
+ return seRechargeProfileMapper.gerRechargeProfiles();
+ }
+
+ /**
+ * 娉ㄥ唽铏氭嫙鍗�
+ *
+ * @param clientId
+ * @return
+ */
+ public Map addVC(Long clientId, Double money) {
+ // 鑾峰彇5绾ц鏀垮尯鍒掍覆areaCode
+ Long areaCodeL = getAreaCodeById(clientId);
+ if (areaCodeL == null) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.AREA_CODE_MISTAKE.getMessage());
+ map.put("content", null);
+ return map;
+ }
+ String areaCode = String.valueOf(areaCodeL);
+
+ /**
+ * 鏍规嵁琛屾斂鍖哄垝涓诧紙areaCode锛夊湪铏氭嫙鍗¤〃涓拡瀵硅櫄鎷熷崱缂栧彿锛坴cNum锛夎繘琛屾ā绯婃煡璇�
+ * 濡傛灉5浣嶉『搴忓彿宸茬粡杈惧埌鏈�澶у�硷紝鎻愮ず鐢ㄦ埛鑱旂郴绯荤粺绠$悊鍛�
+ * 濡傛灉5浣嶉『搴忓彿鏈揪鍒版渶澶у�硷紝鍒欏姞1
+ * cardNum涓烘柊鐨勫崱鍙�
+ */
+ String vcNum = Optional.ofNullable(getVcCardNumOfMax(areaCode)).orElse("");
+ if (vcNum != null && vcNum.trim().length() > 0) {
+ Integer number = Integer.parseInt(vcNum.substring(12));
+ number = number + 1;
+ if (number > 65535) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.CARD_NUMBER_OVERRUN.getMessage());
+ map.put("content", null);
+ return map;
+ }
+ vcNum = vcNum.substring(0, 12) + String.format("%05d", number);
+ } else {
+ vcNum = areaCode + "00001";
+ }
+
+ // 鐢熸垚铏氭嫙鍗¤褰�
+ SeVirtualCard seVirtualCard = new SeVirtualCard();
+ seVirtualCard.setVcNum(Long.parseLong(vcNum));
+ seVirtualCard.setClientId(clientId);
+ seVirtualCard.setMoney(money);
+ seVirtualCard.setState((byte) 1);
+ seVirtualCard.setLastOperate(LastOperateENUM.OPEN_ACCOUNT.getCode());
+ seVirtualCard.setLastOperateTime(new Date());
+ seVirtualCard.setInUse((byte) 0);
+ seVirtualCard.setCreateTime(new Date());
+ Long vcId = insertVirtualCard(seVirtualCard);
+ if (vcId == null) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage());
+ map.put("content", null);
+ return map;
+ }
+
+ // 鐢熸垚铏氭嫙鍗℃搷浣滆褰曪紝娉ㄥ唽铏氭嫙鍗℃搷浣滀汉涓哄啘鎴�
+ SeVcOperate seVcOperate = new SeVcOperate();
+ seVcOperate.setVcId(vcId);
+ seVcOperate.setClientId(clientId);
+ seVcOperate.setOperateType(LastOperateENUM.OPEN_ACCOUNT.getCode());
+ seVcOperate.setOperator(clientId);
+ seVcOperate.setOperateTime(new Date());
+ Long vcOperateId = insertVcOperate(seVcOperate);
+ if (vcOperateId == null) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage());
+ map.put("content", null);
+ return map;
+ }
+
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "铏氭嫙鍗℃敞鍐屾垚鍔�");
+ map.put("content", vcId);
+ return map;
+ }
+
+ /**
+ * 鑾峰彇鏈粦瀹氳櫄鎷熷崱鐨勫彇姘村彛鍒楄〃锛岀粰鍙栨按鍙g粦铏氭嫙鍗′娇鐢�
+ *
+ * @return
+ */
+ public Map linkVcToIntake(Long clientId) {
+ // 楠岃瘉鏄惁瀛樺湪鍙栨按鍙f湭缁戣櫄鎷熷崱
+ List<VoIntakeSimple> list = prIntakeMapper.getNotLinkVcIntakes();
+ if (list == null || list.size() == 0) {
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "鎵�鏈夊彇姘村彛閮藉尮閰嶄簡铏氭嫙鍗�");
+ map.put("content", null);
+ return map;
+ }
+
+ // 閬嶅巻鎵�鏈夋湭缁戣櫄鎷熷崱鐨勫彇姘村彛
+ for (VoIntakeSimple voIntakeSimple : list) {
+ Long intakeId = voIntakeSimple.getIntakeId();
+
+ // 鍒涘缓铏氭嫙鍗�
+ Map map_result = addVC(clientId, 100000D);
+ if (map_result.get("success").equals(false)) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鐏岃櫄鎷熷崱娉ㄥ唽澶辫触");
+ map.put("content", null);
+ return map;
+ }
+ Long vcId = (Long) map_result.get("content");
+
+ // 鍙栨按鍙g粦铏氭嫙鍗�
+ PrIntakeVc intakeVc = new PrIntakeVc();
+ intakeVc.setIntakeId(intakeId);
+ intakeVc.setVcId(vcId);
+ Integer result = prIntakeVcMapper.insert(intakeVc);
+
+ if (result == null) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鍙栨按鍙g粦铏氭嫙鍗″け璐�");
+ map.put("content", null);
+ return map;
+ }
+ }
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "鍙栨按鍙g粦铏氭嫙鍗℃垚鍔�");
+ map.put("content", null);
+ return map;
+ }
+}
\ No newline at end of file
--
Gitblit v1.8.0