Explorar o código

feat: 人力家结算v3版本适配

shc hai 1 ano
pai
achega
7c5e4c14ac

+ 1 - 0
hnqz-common/hnqz-common-ding/src/main/java/com/qunzhixinxi/hnqz/common/ding/entity/EmployPayRequestV2.java

@@ -13,6 +13,7 @@ import java.util.Map;
 import java.util.Random;
 
 @Data
+@Deprecated
 public class EmployPayRequestV2 extends CommonRequest {
 
 	private static final String PATH = "/oapi/v2/employ/freelances/pay";

+ 82 - 0
hnqz-common/hnqz-common-ding/src/main/java/com/qunzhixinxi/hnqz/common/ding/entity/EmployPayRequestV3.java

@@ -0,0 +1,82 @@
+package com.qunzhixinxi.hnqz.common.ding.entity;
+
+
+import cn.hutool.core.date.DatePattern;
+import com.qunzhixinxi.hnqz.common.ding.config.DingConfig;
+import com.qunzhixinxi.hnqz.common.ding.sign.AccessSign;
+import com.qunzhixinxi.hnqz.common.ding.utils.JsonUtils;
+import com.qunzhixinxi.hnqz.common.ding.utils.SignUtils;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class EmployPayRequestV3 extends CommonRequest {
+
+	private static final String PATH = "/oapi/v3/employ/freelances/pay";
+
+	private static String[] statementTaskDescArr = {"通过不定时客户拜访,调查及了解客户信息及所需方向,根据所需定向推广业务管理系统",
+			"推广业务管理系统,使受众知晓及分享本系统",
+			"通过现有信息做推广任务,使客户了解要本产品【业务管理系统】信息",
+			"通过不同的方式推广业务管理系统、提升产品知名度,建立品牌形象"
+	};
+
+	/**
+	 * bizType
+	 *	79 软件开发服务
+	 *	66 信息系统服务
+	 *	77 技术咨询划服务
+	 *	30 市场推广服务
+	 *	70 其他咨询服务
+	 *	203 现场辅助服务
+	 * @param config
+	 * @param subjectName 结算主体
+	 * @param statementNo 结算单id
+	 * @param statementName 结算单名称
+	 * @param bizType 业务类型
+	 * @param taskStartTime 任务开始时间
+	 * @param taskEndTime 任务结束时间
+	 * @param list
+	 */
+	public EmployPayRequestV3(
+			DingConfig config,
+			String subjectName,
+			String statementNo,
+			String statementName,
+			Integer bizType,
+			List list,
+			LocalDateTime taskStartTime,
+			LocalDateTime taskEndTime) {
+
+		Map<String, Object> map = new HashMap<>();
+		map.put("subjectName", subjectName);
+		map.put("statementNo", statementNo);
+		map.put("statementName", statementName);
+		map.put("bizType", bizType);
+		int idx = (int) (Math.random() * 4);
+		map.put("statementTaskDesc", statementTaskDescArr[idx]);
+		map.put("statementTaskSettlementRules", "完成不同任务获得不同任务积分,根据不同任务给与0~30000积分,每个积分兑换0.5~2元,按次数结算");
+		map.put("freelances", list);
+		map.put("taskStartTime", DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN).format(taskStartTime));
+		map.put("taskEndTime", DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN).format(taskEndTime));
+
+		String bodyStr = JsonUtils.serializer(map);
+		String serviceSign = null;
+
+		try {
+			//签名
+			serviceSign = SignUtils.serviceSign(PATH, config.getAppSecret(), "POST", new HashMap<>(), bodyStr.getBytes());
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		this.body = bodyStr;
+		this.sign = new AccessSign(config.getAppId(), serviceSign);
+		this.queryUrl = String.format("%s%s", config.getQueryUrl(), PATH);
+	}
+
+}

+ 47 - 0
hnqz-common/hnqz-common-ding/src/main/java/com/qunzhixinxi/hnqz/common/ding/service/DingService.java

@@ -8,6 +8,7 @@ import com.qunzhixinxi.hnqz.common.ding.utils.JsonUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 
+import java.time.LocalDateTime;
 import java.util.List;
 
 @RequiredArgsConstructor
@@ -120,6 +121,7 @@ public class DingService {
 	 * "amount": "0.22"
 	 * }
 	 */
+	@Deprecated
 	public EmployPayResponse payV2(DingConfig config, String subjectName,
 								   String statementNo,
 								   String statementName,
@@ -141,6 +143,51 @@ public class DingService {
 		return response;
 	}
 
+	/**
+	 * 结算单推送
+	 *
+	 * @param subjectName   结算主体
+	 * @param statementNo   结算单id
+	 * @param statementName 结算单名称
+	 * @param bizType       业务类型
+	 * @param list          自由职业者
+	 * @param taskStartTime 任务开始时间
+	 * @param taskEndTime   任务结束时间
+	 * @return 示例:
+	 * {
+	 * "name": "张三",
+	 * "mobile": "15000998877",
+	 * "idCard": "350198765623418765"
+	 * "amount": "0.22"
+	 * }
+	 */
+	public EmployPayResponse payV3(DingConfig config, String subjectName,
+								   String statementNo,
+								   String statementName,
+								   Integer bizType,
+								   List list,
+								   LocalDateTime taskStartTime,
+								   LocalDateTime taskEndTime) {
+
+		EmployPayRequestV3 request = new EmployPayRequestV3(
+				config,
+				subjectName,
+				statementNo,
+				statementName,
+				bizType,
+				list,
+				taskStartTime,
+				taskEndTime);
+		log.info("人力家请求报文: {}", request.getBody());
+		String json = HttpClientUtils.doPost(request);
+		log.info("人力家返回数据: {}", json);
+		EmployPayResponse response = JsonUtils.deserializer(json, EmployPayResponse.class);
+		if (!response.isSuccess()) {
+			log.error("结算单推送失败, code: {}, message: {}", response.getCode(), response.getMsg());
+		}
+		return response;
+	}
+
 
 	/**
 	 * 结算单查询

+ 5 - 1
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/WmSettlementController.java

@@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.io.BufferedReader;
 import java.io.IOException;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -199,8 +200,11 @@ public class WmSettlementController {
 		String statementNo = "2222";
 		String statementName = "9月15日市场推广服务费用结算";
 		Integer bizType = 30;
+		LocalDateTime startTime = LocalDateTime.now().minusDays(10);
+		LocalDateTime endTime = LocalDateTime.now().plusDays(10);
 
-		return R.ok(dingService.payV2(config, subjectName, statementNo, statementName, bizType, list));
+
+		return R.ok(dingService.payV3(config, subjectName, statementNo, statementName, bizType, list, startTime, endTime));
 	}
 
 	@Autowired

+ 5 - 3
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmPayOffServiceImpl.java

@@ -2101,10 +2101,12 @@ public class WmPayOffServiceImpl extends ServiceImpl<WmPayOffMapper, WmPayOff> i
 				jsdMap.put("idCard", sysUser.getIdCardNumber());
 				jsdMap.put("name", sysUser.getRealname());
 				jsdList.add(jsdMap);
-
-				EmployPayResponse employPayResponse = dingService.payV2(config, subjectName,
+				LocalDateTime today = LocalDateTime.now();
+				LocalDateTime startTime = today.minusYears(1);
+				LocalDateTime endTime = today.plusDays(100);
+				EmployPayResponse employPayResponse = dingService.payV3(config, subjectName,
 						note.getSettleNo(), input.getScorePackageName(),
-						input.getInvoiceCategory(), jsdList);
+						input.getInvoiceCategory(), jsdList, startTime, endTime);
 
 				//提交结算接口失败
 				if (!employPayResponse.isSuccess()) {

+ 5 - 2
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmScorePackageSettleNoteServiceImpl.java

@@ -3241,9 +3241,12 @@ public class WmScorePackageSettleNoteServiceImpl extends ServiceImpl<WmScorePack
 		jsdMap.put("name", sysUser.getRealname());
 		jsdList.add(jsdMap);
 
-		EmployPayResponse employPayResponse = dingService.payV2(config, subjectName,
+		LocalDateTime today = LocalDateTime.now();
+		LocalDateTime startTime = today.minusYears(1);
+		LocalDateTime endTime = today.plusDays(100);
+		EmployPayResponse employPayResponse = dingService.payV3(config, subjectName,
 				note.getSettleNo(), wmScorePackage.getScorePackageName(),
-				note.getInvoiceType(), jsdList);
+				note.getInvoiceType(), jsdList, startTime, endTime);
 
 		LocalDateTime now = LocalDateTime.now();
 		note.setSubToGigTime(now);