|  | @@ -4,6 +4,7 @@ import com.github.sd4324530.jtuple.Tuple2;
 | 
											
												
													
														|  |  import com.github.sd4324530.jtuple.Tuples;
 |  |  import com.github.sd4324530.jtuple.Tuples;
 | 
											
												
													
														|  |  import com.zanxiang.game.back.serve.pojo.entity.GameBackPolicy;
 |  |  import com.zanxiang.game.back.serve.pojo.entity.GameBackPolicy;
 | 
											
												
													
														|  |  import com.zanxiang.module.util.NumberUtil;
 |  |  import com.zanxiang.module.util.NumberUtil;
 | 
											
												
													
														|  | 
 |  | +import lombok.extern.slf4j.Slf4j;
 | 
											
												
													
														|  |  import org.apache.commons.lang3.RandomUtils;
 |  |  import org.apache.commons.lang3.RandomUtils;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import java.math.BigDecimal;
 |  |  import java.math.BigDecimal;
 | 
											
										
											
												
													
														|  | @@ -11,6 +12,7 @@ import java.util.Arrays;
 | 
											
												
													
														|  |  import java.util.Objects;
 |  |  import java.util.Objects;
 | 
											
												
													
														|  |  import java.util.function.Function;
 |  |  import java.util.function.Function;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +@Slf4j
 | 
											
												
													
														|  |  public class BackPolicyUtil {
 |  |  public class BackPolicyUtil {
 | 
											
												
													
														|  |      private static final long[] RECHARGE_LEVEL = {12 * 100L, 30 * 100L, 50 * 100L, 98 * 100L, 198 * 100L, 328 * 100L, 649 * 100L, 998 * 100L, 2998 * 100L};
 |  |      private static final long[] RECHARGE_LEVEL = {12 * 100L, 30 * 100L, 50 * 100L, 98 * 100L, 198 * 100L, 328 * 100L, 649 * 100L, 998 * 100L, 2998 * 100L};
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -26,8 +28,9 @@ public class BackPolicyUtil {
 | 
											
												
													
														|  |       * @param lastBackFunction 在指定最近订单数量内是否有订单回传过
 |  |       * @param lastBackFunction 在指定最近订单数量内是否有订单回传过
 | 
											
												
													
														|  |       * @return <是否回传, 回传金额>
 |  |       * @return <是否回传, 回传金额>
 | 
											
												
													
														|  |       */
 |  |       */
 | 
											
												
													
														|  | -    public static boolean backOrder(GameBackPolicy gameBackPolicy, long rechargeMoney, FirstOrder firstOrder, Function<Integer, Integer> lastBackFunction) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    public static boolean backOrder(String orderId, GameBackPolicy gameBackPolicy, long rechargeMoney, FirstOrder firstOrder, Function<Integer, Integer> lastBackFunction) {
 | 
											
												
													
														|  |          if (null == gameBackPolicy) {
 |  |          if (null == gameBackPolicy) {
 | 
											
												
													
														|  | 
 |  | +            log.error("订单 id[{}]通过回传策略[null]判断后,是否回传:{}.", orderId, true);
 | 
											
												
													
														|  |              return true;
 |  |              return true;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          Integer firstType;
 |  |          Integer firstType;
 | 
											
										
											
												
													
														|  | @@ -76,16 +79,21 @@ public class BackPolicyUtil {
 | 
											
												
													
														|  |              int backCount = Integer.parseInt(temp[0]);
 |  |              int backCount = Integer.parseInt(temp[0]);
 | 
											
												
													
														|  |              int ignoreCount = Integer.parseInt(temp[1]);
 |  |              int ignoreCount = Integer.parseInt(temp[1]);
 | 
											
												
													
														|  |              if (backCount == 0) {
 |  |              if (backCount == 0) {
 | 
											
												
													
														|  | 
 |  | +                log.error("订单 id[{}]通过回传策略[{}]判断后,是否回传:{}.", orderId, gameBackPolicy.getId(), false);
 | 
											
												
													
														|  |                  return false;
 |  |                  return false;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              if (ignoreCount == 0) {
 |  |              if (ignoreCount == 0) {
 | 
											
												
													
														|  | 
 |  | +                log.error("订单 id[{}]通过回传策略[{}]判断后,是否回传:{}.", orderId, gameBackPolicy.getId(), true);
 | 
											
												
													
														|  |                  return true;
 |  |                  return true;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              int isBackCount = lastBackFunction.apply(backCount + ignoreCount - 1);
 |  |              int isBackCount = lastBackFunction.apply(backCount + ignoreCount - 1);
 | 
											
												
													
														|  | 
 |  | +            log.error("订单 id[{}]通过回传策略[{}]判断后,是否回传:{}.", orderId, gameBackPolicy.getId(), (isBackCount < backCount));
 | 
											
												
													
														|  |              return isBackCount < backCount;
 |  |              return isBackCount < backCount;
 | 
											
												
													
														|  |          } else if (Objects.equals(backType, GameBackPolicy.POLICY_TYPE_RANDOM_RATE)) {
 |  |          } else if (Objects.equals(backType, GameBackPolicy.POLICY_TYPE_RANDOM_RATE)) {
 | 
											
												
													
														|  |              // 随机概率回传
 |  |              // 随机概率回传
 | 
											
												
													
														|  | -            return RandomUtils.nextInt(0, 100) <= NumberUtil.multiply100(new BigDecimal(backRate)).intValue();
 |  | 
 | 
											
												
													
														|  | 
 |  | +            boolean isBack = RandomUtils.nextInt(0, 100) <= NumberUtil.multiply100(new BigDecimal(backRate)).intValue();
 | 
											
												
													
														|  | 
 |  | +            log.error("订单 id[{}]通过回传策略[{}]判断后,是否回传:{}.", orderId, gameBackPolicy.getId(), isBack);
 | 
											
												
													
														|  | 
 |  | +            return isBack;
 | 
											
												
													
														|  |          } else {
 |  |          } else {
 | 
											
												
													
														|  |              throw new RuntimeException("回传策略[" + gameBackPolicy.getId() + "]配置错误,未知的回传类型:" + backType);
 |  |              throw new RuntimeException("回传策略[" + gameBackPolicy.getId() + "]配置错误,未知的回传类型:" + backType);
 | 
											
												
													
														|  |          }
 |  |          }
 |