Browse Source

20260414业绩调整

lijianlin/feature-20260401-现金管理四期
sunjiabei 5 days ago
parent
commit
114ca39852
  1. 58
      src/main/java/com/example/demo/Util/AppleTokenGenerator.java
  2. 6
      src/main/java/com/example/demo/Util/AuthKey_3J2S9VXU3V.p8
  3. 11
      src/main/java/com/example/demo/controller/cash/CashCollectionController.java
  4. 28
      src/main/java/com/example/demo/domain/DTO/PerformanceAdjustmentDTO.java
  5. 2
      src/main/java/com/example/demo/mapper/cash/CashCollectionMapper.java
  6. 3
      src/main/java/com/example/demo/service/cash/CashCollectionService.java
  7. 70
      src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java
  8. 12
      src/main/resources/cashMapper/CashCollectionMapper.xml

58
src/main/java/com/example/demo/Util/AppleTokenGenerator.java

@ -0,0 +1,58 @@
package com.example.demo.Util;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.io.Decoders;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Date;
public class AppleTokenGenerator {
// 你提供的真实信息已全部填好
private static final String KEY_ID = "3J2S9VXU3V";
private static final String ISSUER_ID = "69a6de7e-1f9a-47e3-e053-5b8c7c11a4d1";
private static final String P8_FILE_PATH = "E:/Work/newgold/gold-java/src/main/java/com/example/demo/Util/AuthKey_3J2S9VXU3V.p8";
public static String generateToken() {
try {
// 读取 P8 私钥内容
String p8Content = Files.readString(Paths.get(P8_FILE_PATH))
.replace("-----BEGIN PRIVATE KEY-----", "")
.replace("-----END PRIVATE KEY-----", "")
.replaceAll("\\s+", "");
// 解码私钥
byte[] keyBytes = Decoders.BASE64.decode(p8Content);
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance("EC");
PrivateKey privateKey = keyFactory.generatePrivate(spec);
// 生成苹果官方标准 JWT补全typ字段完全符合文档要求
return Jwts.builder()
.setHeaderParam("alg", "ES256")
.setHeaderParam("kid", KEY_ID)
.setHeaderParam("typ", "JWT") // 🔴 苹果官方强制要求之前漏了
.setIssuer(ISSUER_ID)
.setAudience("appstoreconnect-v1")
.setIssuedAt(new Date())
.setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 15)) // 15分钟有效期20分钟
.signWith(privateKey, SignatureAlgorithm.ES256)
.compact();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
// 运行直接输出可用 Token
public static void main(String[] args) {
String token = generateToken();
System.out.println("复制下面这一行直接用:");
System.out.println("Bearer " + token);
}
}

6
src/main/java/com/example/demo/Util/AuthKey_3J2S9VXU3V.p8

@ -0,0 +1,6 @@
-----BEGIN PRIVATE KEY-----
MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQge12P08wGtrp8dttS
6fA0dtL46GYnBYEumTnx3/g53qGgCgYIKoZIzj0DAQehRANCAATiWWs9qLs7eYCv
ZIfG0JYRrLjLqotAGdEtfTii1gh+IKK4snS499kwk+vKg1vHy2ZovyZDdvmW/z+i
WSzRu18f
-----END PRIVATE KEY-----

11
src/main/java/com/example/demo/controller/cash/CashCollectionController.java

@ -4,6 +4,7 @@ import com.example.demo.Util.JWTUtil;
import com.example.demo.Util.LanguageTranslationUtil; import com.example.demo.Util.LanguageTranslationUtil;
import com.example.demo.config.interfac.Log; import com.example.demo.config.interfac.Log;
import com.example.demo.domain.DTO.AddFundsDTO; import com.example.demo.domain.DTO.AddFundsDTO;
import com.example.demo.domain.DTO.PerformanceAdjustmentDTO;
import com.example.demo.domain.DTO.PerformanceDTO; import com.example.demo.domain.DTO.PerformanceDTO;
import com.example.demo.domain.entity.*; import com.example.demo.domain.entity.*;
import com.example.demo.domain.vo.cash.*; import com.example.demo.domain.vo.cash.*;
@ -531,6 +532,16 @@ public class CashCollectionController {
return Result.error("查询失败"); return Result.error("查询失败");
} }
} }
@PostMapping("/adjust")
public Result adjust(@RequestBody PerformanceAdjustmentDTO adjustDTO) {
try {
cashCollectionService.adjust(adjustDTO);
return Result.success("调整成功");
} catch (Exception e) {
return Result.error(e.getMessage());
}
}
/** /**
* 转换用户钱包 VO 的多语言字段 * 转换用户钱包 VO 的多语言字段
*/ */

28
src/main/java/com/example/demo/domain/DTO/PerformanceAdjustmentDTO.java

@ -0,0 +1,28 @@
package com.example.demo.domain.DTO;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
/**
* @program: gold-java
* @ClassName PerformanceAdjustmentDTO
* @description:
* @author: Double
* @create: 202604-03 09:56
* @Version 1.0
**/
@Data
public class PerformanceAdjustmentDTO {
private Integer submitterId; // 提交人ID
private String submitterMarket; // 提交人市场
private int[][] matrix = new int[6][6];
private Double weight; // 权重
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
private Date Time; // 时间
}

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

@ -130,6 +130,8 @@ public interface CashCollectionMapper {
@Param("sortWalletId") Integer sortWalletId); @Param("sortWalletId") Integer sortWalletId);
// 添加流水--其他收入 // 添加流水--其他收入
void addExFund(@Param("addFundsDTO") CashCollection addFundsDTO); void addExFund(@Param("addFundsDTO") CashCollection addFundsDTO);
void adjust(CashRecord cashRecord);
// 添加流水--iPay88手续费 // 添加流水--iPay88手续费
void addIpay88Fee(CashCollection cashCollection); void addIpay88Fee(CashCollection cashCollection);
} }

3
src/main/java/com/example/demo/service/cash/CashCollectionService.java

@ -1,6 +1,7 @@
package com.example.demo.service.cash; package com.example.demo.service.cash;
import com.example.demo.domain.DTO.AddFundsDTO; import com.example.demo.domain.DTO.AddFundsDTO;
import com.example.demo.domain.DTO.PerformanceAdjustmentDTO;
import com.example.demo.domain.DTO.PerformanceDTO; import com.example.demo.domain.DTO.PerformanceDTO;
import com.example.demo.domain.entity.CashRecord; import com.example.demo.domain.entity.CashRecord;
import com.example.demo.domain.entity.GOrder; import com.example.demo.domain.entity.GOrder;
@ -56,6 +57,8 @@ public interface CashCollectionService {
PageInfo<UserWalletVO> selectUserWallets(Integer jwcode, String market, Integer pageNum, Integer pageSize, String sortField, String sortOrder, Integer sortWalletId); PageInfo<UserWalletVO> selectUserWallets(Integer jwcode, String market, Integer pageNum, Integer pageSize, String sortField, String sortOrder, Integer sortWalletId);
// 添加流水--其他收入 // 添加流水--其他收入
String addExFund(CashCollection addFundsDTO); String addExFund(CashCollection addFundsDTO);
// 调整业绩
void adjust(PerformanceAdjustmentDTO adjustDTO);
//添加iPay88手续费 //添加iPay88手续费
String addIpay88Fee(CashCollection cashCollection); String addIpay88Fee(CashCollection cashCollection);
} }

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

@ -4,6 +4,7 @@ import com.example.demo.Util.JWTUtil;
import com.example.demo.Util.LanguageTranslationUtil; import com.example.demo.Util.LanguageTranslationUtil;
import com.example.demo.config.RabbitMQConfig; import com.example.demo.config.RabbitMQConfig;
import com.example.demo.domain.DTO.AddFundsDTO; import com.example.demo.domain.DTO.AddFundsDTO;
import com.example.demo.domain.DTO.PerformanceAdjustmentDTO;
import com.example.demo.domain.DTO.PerformanceDTO; import com.example.demo.domain.DTO.PerformanceDTO;
import com.example.demo.domain.entity.*; import com.example.demo.domain.entity.*;
import com.example.demo.domain.vo.cash.*; import com.example.demo.domain.vo.cash.*;
@ -748,6 +749,74 @@ public class CashCollectionServiceImpl implements CashCollectionService {
return "添加成功"; return "添加成功";
} }
@Override
public void adjust(PerformanceAdjustmentDTO adjustDTO) {
if (adjustDTO == null) {
throw new IllegalArgumentException("传参不能为空");
}
int[][] matrix = adjustDTO.getMatrix();
Double weight = adjustDTO.getWeight();
if (weight == null) {
throw new IllegalArgumentException("权重不能为空");
}
// Performance market codes and corresponding Chinese names
String[] performanceMarkets = {"4", "5", "13", "24018", "24022", "24016"};
String[] marketNames = {"新加坡", "马来西亚", "香港", "泰国", "越南", "加拿大"};
// Multiply each element in the matrix by the factor
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
// Calculate adjusted value and round to nearest integer
int adjustedValue = (int) (matrix[i][j] * weight);
matrix[i][j] = adjustedValue;
// Skip if value is 0
if (adjustedValue == 0) {
continue;
}
// Create order code with timestamp
String orderCode = "TZ_" + System.currentTimeMillis();
// Determine direction and create remark based on value sign
String fromMarket = performanceMarkets[i];
String toMarket = performanceMarkets[j];
String fromName = marketNames[i];
String toName = marketNames[j];
String remark;
if (adjustedValue > 0) {
// Positive value: row to column (转出方 to 转入方)
remark = fromName + "→" + toName + "调整金额:" + adjustedValue;
} else {
// Negative value: column to row (转入方 to 转出方)
remark = toName + "→" + fromName + "调整金额:" + -adjustedValue;
}
// Create CashRecord objects and call mapper adjust method twice
for (int k = 0; k < 2; k++) {
CashRecord cashRecord = new CashRecord();
cashRecord.setOrderCode(orderCode + "_" + k);
cashRecord.setSubmitterId(adjustDTO.getSubmitterId());
cashRecord.setSubmitterMarket(adjustDTO.getSubmitterMarket());
cashRecord.setRemark(remark);
if(k == 0){
cashRecord.setPerformanceMarket(fromMarket);
cashRecord.setReceivedAmount(new BigDecimal(-adjustedValue));
}else{
cashRecord.setPerformanceMarket(toMarket);
cashRecord.setReceivedAmount(new BigDecimal(adjustedValue));
}
// Call mapper adjust method
cashCollectionMapper.adjust(cashRecord);
}
}
}
}
/** /**
* 校验钱包 ID 和到账地区的对应关系 * 校验钱包 ID 和到账地区的对应关系
* @param walletId 钱包 ID * @param walletId 钱包 ID
@ -784,4 +853,5 @@ public class CashCollectionServiceImpl implements CashCollectionService {
throw new IllegalArgumentException("钱包 ID=" + walletId + " 对应的到账地区应为:" + marketName + "(" + expectedMarket + ")"); throw new IllegalArgumentException("钱包 ID=" + walletId + " 对应的到账地区应为:" + marketName + "(" + expectedMarket + ")");
} }
} }
} }

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

@ -630,5 +630,15 @@
SET flag = #{flag} SET flag = #{flag}
WHERE type_id = #{typeId} AND type = #{type} WHERE type_id = #{typeId} AND type = #{type}
</update> </update>
<insert id="adjust" parameterType="com.example.demo.domain.entity.CashRecord"
useGeneratedKeys="true" keyProperty="id">
insert into
cash_record_collection(order_type,jwcode,name,market,activity,performance_market,
order_code,goods_name,permanent_gold,free_gold,performance_market,
pay_type,pay_time,status,submitter_id,submitter_market,
voucher,remark,received_currency,payment_amount,received_amount,received_market)
values(1,90039082,"HomilyLink",24032,125,2,
#{orderCode},"业绩",0,0,#{performanceMarket},"业绩",#{payTime},
100,#{submitterId},#{submitterMarket},1,#{remark},3,0,#{receivedAmount},#{performanceMarket})
</insert>
</mapper> </mapper>
Loading…
Cancel
Save