From 28cf328a098334b51a3e9d2d56f983fb8c862211 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期六, 23 五月 2020 09:54:38 +0800
Subject: [PATCH] 足迹、收藏订单兼容新需求

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java |   60 ++++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java
index 2f11736..f824710 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java
@@ -178,7 +178,6 @@
 		updateExtract.setId(id);
 		updateExtract.setState(Extract.STATE_PROCESSING);
 		extractMapper.updateByPrimaryKeySelective(updateExtract);
-		// TODO 鏂扮増閮ㄧ讲鍚庡垹闄�
 		// 鏀瑰彉璧勯噾璁板綍鐘舵��
 		UserMoneyDetail detail = userMoneyDetailService.selectByTypeAndUidAndIdentifyCode(
 				UserMoneyDetailTypeEnum.extract, find.getUserInfo().getId(), find.getId());
@@ -327,7 +326,7 @@
 		// 鏂扮増璧勯噾璇︽儏
 		UserMoneyDetail userMoneyDetail = null;
 		try {
-			userMoneyDetail = UserMoneyDetailFactory.createExtract(extract);
+			userMoneyDetail = UserMoneyDetailFactory.createExtract(extract, null);
 		} catch (UserMoneyDetailException e2) {
 			try {
 				LogHelper.errorDetailInfo(e2);
@@ -435,9 +434,9 @@
 		json.put("payee_type", "ALIPAY_LOGONID");
 		json.put("payee_account", extract.getAccount());
 		json.put("amount", extract.getMoney());
-		json.put("payer_show_name", appName + "App" + "鎻愮幇");
+		json.put("payer_show_name", appName);
 		json.put("payee_real_name", extract.getName());
-		json.put("remark", "鏉ヨ嚜" + appName + "App" + "鐨勬彁鐜�");
+		json.put("remark", "鏉ヨ嚜閲嶅簡蹇渷绉戞妧鏈夐檺鍏徃");
 		request.setBizContent(json.toString());
 		AlipayFundTransToaccountTransferResponse response = null;
 		try {
@@ -524,7 +523,7 @@
 	 * @param session
 	 */
 	@Transactional
-	private void extractSuccess(Extract extract) {
+	private void extractSuccess(Extract extract,String alipayNo) {
 		// 鑰佺増鏈姛鑳�
 		// List<MoneyRecord> list = moneyRecordDao.list("from MoneyRecord mr
 		// where mr.extract.id = " + extract.getId());
@@ -547,11 +546,25 @@
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
-		List<PayInfo> payInfoList = payInfoMapper.getListbyExtractId(extract.getId());
-		String alipayNo = "";
-		if (payInfoList != null && payInfoList.size() > 0)
-			alipayNo = payInfoList.get(0).getOrderId();
 
+		UserMoneyDetail detailNew = null;
+		try {
+			detailNew = UserMoneyDetailFactory.createExtract(extract, alipayNo);
+		} catch (UserMoneyDetailException e) {
+			e.printStackTrace();
+		}
+
+		// 澶栨樉璐︽埛鏄庣粏
+		UserMoneyDetail userMoneyDetail = userMoneyDetailMapper.selectByTypeAndUidAndIdentifyCode(
+				UserMoneyDetailTypeEnum.extractNew, extract.getUserInfo().getId(), extract.getId());
+		if (userMoneyDetail != null) {
+			UserMoneyDetail detail = new UserMoneyDetail(userMoneyDetail.getId());
+			detail.setShow(true);
+			detail.setUpdateTime(new Date());
+			if (detailNew != null)
+				detail.setDescInfo(detailNew.getDescInfo());
+			userMoneyDetailMapper.updateByPrimaryKeySelective(detail);
+		}
 		// 鏂扮増閫氱煡
 		userMoneyMsgNotificationService.extractSuccess(extract, alipayNo);
 	}
@@ -586,8 +599,10 @@
 		// 鑾峰彇鎻愮幇锛岃幏鍙栨彁鐜伴獙璇�
 		List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
 		typeList.add(UserMoneyDetailTypeEnum.extract);
+		typeList.add(UserMoneyDetailTypeEnum.extractNew);
 		typeList.add(UserMoneyDetailTypeEnum.extractReject);
 		typeList.add(UserMoneyDetailTypeEnum.extractVerify);
+		typeList.add(UserMoneyDetailTypeEnum.extractVerifyNew);
 		BigDecimal extractMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, new Date(0),
 				now);
 		extractMoney = extractMoney.abs();
@@ -607,7 +622,7 @@
 		BigDecimal after = hongBaoMoney.subtract(extractMoney.add(weiqaunMoney).add(balance).add(compensateMoney));
 
 		if (after.compareTo(new BigDecimal("0")) != 0)
-			throw new ExtractException(2, "缁撶畻璧勯噾寮傚父");
+			throw new ExtractException(2, "缁撶畻璧勯噾寮傚父锛�" + after);
 	}
 
 	@Override
@@ -656,7 +671,7 @@
 		if (response.isSuccess()) {
 			String code = response.getCode();
 			if ("10000".equals(code)) {
-				extractSuccess(extract);
+				extractSuccess(extract,response.getOrderId());
 			} else {
 				extractFail(extract, response.getSubMsg());
 			}
@@ -718,23 +733,13 @@
 			extractAuditRecordMapper.updateByPrimaryKeySelective(auditRecord);
 		}
 
-		// 澶栨樉璐︽埛鏄庣粏
-		UserMoneyDetail userMoneyDetail = userMoneyDetailMapper.selectByTypeAndUidAndIdentifyCode(
-				UserMoneyDetailTypeEnum.extract, extract.getUserInfo().getId(), extract.getId());
-		if (userMoneyDetail != null) {
-			UserMoneyDetail detail = new UserMoneyDetail(userMoneyDetail.getId());
-			detail.setShow(true);
-			detail.setUpdateTime(new Date());
-			userMoneyDetailMapper.updateByPrimaryKeySelective(detail);
-		}
-
 	}
 
 	@Transactional
 	@Override
 	public void testExtractSuccess(Long id) {
 		Extract extract = extractMapper.selectByPrimaryKey(id);
-		extractSuccess(extract);
+		extractSuccess(extract,null);
 		Long uid = extract.getUserInfo().getId();
 
 		// 鏇存柊瀹℃牳璁板綍
@@ -1345,4 +1350,15 @@
 		}
 	}
 
+	
+	@Override
+	public List<Extract> getExtractSucceedRecord(int page, int pageSize, Long uid) {
+		return extractMapper.getExtractSucceedRecord((page-1)*pageSize, pageSize, uid);
+	}
+	
+	@Override
+	public long countExtractSucceedRecord(Long uid) {
+       Long count = extractMapper.countExtractSucceedRecord(uid);
+       return count== null? 0 : count;
+	}
 }

--
Gitblit v1.8.0