记得上下班打卡 | git大法好,push需谨慎

Commit cb595393 authored by 张禹's avatar 张禹

Merge branch 'pre' into 'master'

Pre

See merge request !245
parents 8d5049a1 e82653ff
......@@ -116,9 +116,9 @@ public class ZxlnftSdkServiceImpl implements ZxlnftSdkService
}
log.info("nft003RegisterPersonPlatform--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) {
return null;
}
// if (StringUtils.isEmpty(response)) {
// return null;
// }
/**
* 构造返回结果
......@@ -488,10 +488,6 @@ public class ZxlnftSdkServiceImpl implements ZxlnftSdkService
}
log.info("nft014IdentityBindSubmitByTrusted--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) {
return null;
}
/**
* 构造返回结果
*/
......
......@@ -2,6 +2,7 @@ package com.liquidnet.common.third.zxlnft.util;
import com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.constant.ZxlErrorEnum;
import com.liquidnet.common.third.zxlnft.dto.*;
import com.liquidnet.common.third.zxlnft.dto.nft.*;
import com.liquidnet.common.third.zxlnft.exception.ZxlNftException;
......@@ -90,6 +91,8 @@ public class ZxlnftSdkUtil {
BeanUtil.copy(resp,respDto);
}catch(ZxlNftException e){
return ZxlnftResponseDto.failure(e.getCode()+","+e.getMessage());
}catch(Exception e){
return ZxlnftResponseDto.failure(ZxlErrorEnum.SERVER_INNER_ERROR.getCode(),ZxlErrorEnum.SERVER_INNER_ERROR.getMsg());
}
return ZxlnftResponseDto.success(respDto);
}
......@@ -316,6 +319,8 @@ public class ZxlnftSdkUtil {
BeanUtil.copy(resp,respDto);
}catch(ZxlNftException e){
return ZxlnftResponseDto.failure(e.getCode()+","+e.getMessage());
}catch(Exception e){
return ZxlnftResponseDto.failure(ZxlErrorEnum.SERVER_INNER_ERROR.getCode(),ZxlErrorEnum.SERVER_INNER_ERROR.getMsg());
}
return ZxlnftResponseDto.success(respDto);
}
......
......@@ -94,4 +94,12 @@ public interface GoblinNftExCodeMapper extends BaseMapper<GoblinNftExCode> {
* @return
*/
int updateCodeAdminUids(@Param("codes") String codes, @Param("adminUid") String adminUid);
/**
* excel导出打乱兑换码顺序
* @param goblinNftExCode
* @return
*/
List<GoblinNftExCode> selectGoblinNftCodeExcel(GoblinNftExCode goblinNftExCode);
}
......@@ -129,6 +129,58 @@
</select>
<select id="selectGoblinNftCodeExcel" parameterType="com.liquidnet.service.goblin.entity.GoblinNftExCode"
resultMap="BeseResult">
select
DISTINCT
gnec.code,gnec.code_id,gnec.sku_id,gnec.box_sku_id,gnec.activity_id,gnec.state,gnec.redeem_uid,gnec.redeem_at,gnec.admin_uid,gnec.created_at
from goblin_nft_ex_code gnec inner join goblin_nft_ex_sku gnes on gnec.sku_id = gnes.sku_id and gnes.activity_id
= gnec.activity_id
<where>
<if test="code != null and code != ''">
and gnec.code = #{code,jdbcType=VARCHAR}
</if>
<if test="activityId != null and activityId != ''">
and gnec.activity_id = #{activityId,jdbcType=VARCHAR}
</if>
<if test="state != null">
<choose>
<when test="state == 1">
and (now() BETWEEN gnes.ex_start_time and gnes.ex_stop_time) and
gnec.state =1
</when>
<when test="state == 2">
and gnec.state = 2
</when>
<when test="state == 3">
and (((now() &gt; gnes.ex_stop_time) AND gnec.state = 1) ||
gnec.state = 3)
</when>
</choose>
</if>
<if test="redeemUid != null and redeemUid != ''">
and gnec.redeem_uid = #{redeemUid,jdbcType=VARCHAR}
</if>
<if test="skuId != null and skuId != ''">
and gnec.sku_id in
<foreach collection="skuId.split(',')" item="sId" open="(" separator="," close=")">
#{sId,jdbcType=VARCHAR}
</foreach>
</if>
<if test="isDrivi != null">
<choose>
<when test="isDrivi == 1">
and gnec.admin_uid = ''
</when>
<when test="isDrivi == 2">
and gnec.admin_uid != ''
</when>
</choose>
</if>
</where>
ORDER BY gnec.code desc
</select>
<select id="selectCodeAvailableByActivityId" resultMap="BeseResult">
select DISTINCT gnec.code,
gnec.code_id,
......
......@@ -171,9 +171,13 @@ public class ZxinUserCommonBiz {
if(nft003Resp.isSuccess()){
userIdentification = nft003Resp.getData().getUserIdentification();
isRealNameAuthSuccess = true;
}else{
if(nft003Resp.getCode().equals(ZxlErrorEnum.SERVER_INNER_ERROR.getCode())){
throw new ZxlNftException(nft003Resp.getCode(),nft003Resp.getMessage());
}else{
throw new GalaxyNftUserException(nft003Resp.getCode(),nft003Resp.getMessage());
}
}
//如果实名认证成功,并且该身份证已经开通过数字账户
if(isRealNameAuthSuccess){
......@@ -291,8 +295,8 @@ public class ZxinUserCommonBiz {
//是否开通数字账户
boolean isOpenAccount = false;
//开通失败错误信息
String resultCode = null;
String resultMessage = null;
String resultCode = NftAccStatusEnum.StatusAcc.ING.getCode();
String resultMessage = NftAccStatusEnum.StatusAcc.ING.getMsg();
//实名成功+绑定区块链地址成功
if(isRealNameAuthSuccess && isBindBlockAddressSuccess){
......@@ -305,8 +309,13 @@ public class ZxinUserCommonBiz {
if(!isOpenAccount){
//实名失败
if(!isRealNameAuthSuccess){
if(StringUtil.isNotEmpty(bizFailDesc)){
resultCode = NftAccStatusEnum.StatusAcc.FAILURE1.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.FAILURE1.getMsg();
}else if(StringUtil.isNotEmpty(sysFailDesc)){
resultCode = NftAccStatusEnum.StatusAcc.FAILURE2.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.FAILURE2.getMsg();
}
}else{
//地址绑定失败
if(!isBindBlockAddressSuccess){
......@@ -350,7 +359,7 @@ public class ZxinUserCommonBiz {
}
//设置错误信息到redis
if(StringUtil.isNotEmpty(resultCode)&&!resultCode.equalsIgnoreCase(NftAccStatusEnum.StatusAcc.SUCCESS.getCode())){
if(StringUtil.isNotEmpty(resultCode)&&resultCode.equalsIgnoreCase(NftAccStatusEnum.StatusAcc.FAILURE1.getCode())){
//开户失败记录缓存 {goblin:nft:certmeta:{idType+idNo},{idname,mobile}}
dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA_JUNK.concat(reqDto.getIdCardType().concat(reqDto.getIdCard()))
,reqDto.getUserName().concat(",").concat(reqDto.getMobile()),openAccFailKeyExpireTime);
......
......@@ -284,7 +284,7 @@ public class GoblinNftExCodeServiceImpl implements IGoblinNftExCodeService {
// PageHelper.startPage(goblinNftExCodeParam.getPageNum(), 20, true);
List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectGoblinNftCode(goblinNftExCode);
List<GoblinNftExCode> goblinNftExCodes = goblinNftExCodeMapper.selectGoblinNftCodeExcel(goblinNftExCode);
StringBuffer skuIds = new StringBuffer();
StringBuffer acticityIds = new StringBuffer();
......
......@@ -106,10 +106,18 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
List<GoblinGoodsSku> goblinGoodsSkus = goblinGoodsSkuMapper.selectBySpuIds(spuIds.toString());
int countStockNumber = 0;
int checkNumberSku = 0;
// 是否存在概率为空
boolean isHit = false;
// 概率相加
BigDecimal hitRatioCount = new BigDecimal(0);
for (GoblinGoodsSku goblinGoodsSku : goblinGoodsSkus) {
if (goblinGoodsSku.getUnbox().equals("1")) {
continue;
}
// 判断开售、停售时间
LocalDateTime saleStartTime = goblinGoodsSku.getSaleStartTime();
LocalDateTime saleStopTime = goblinGoodsSku.getSaleStopTime();
......@@ -124,8 +132,15 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
if (!goblinGoodsSku.getSkuCanbuy().equals("1")) {
continue;
}
// 不能购买的 没库存的 概率是0的 过滤
if (getSkuAllStatusShow(goblinGoodsSku) && goblinRedisUtils.getSkuAllStatusStock(goblinGoodsSku) > 0 && goblinGoodsSku.getHitRatio() != null) {
if (getSkuAllStatusShow(goblinGoodsSku) && goblinRedisUtils.getSkuAllStatusStock(goblinGoodsSku) > 0) {
log.debug("skuId:"+goblinGoodsSku.getSkuId()+"----hitRatio:"+goblinGoodsSku.getHitRatio());
if (goblinGoodsSku.getHitRatio() == null) {
isHit = true;
} else {
hitRatioCount = hitRatioCount.add(goblinGoodsSku.getHitRatio());
}
countStockNumber += goblinRedisUtils.getSkuStock(goblinGoodsSku.getSkuId());
map.put(goblinGoodsSku.getSkuId(), goblinGoodsSku.getHitRatio());
checkNumberSku++;
......@@ -140,6 +155,12 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
ResponseDto.failure("配置库存大于sku总库存!");
}
if (isHit && hitRatioCount.doubleValue() < 100.00 && map.size() > 0) {
arrangeHitRatioMap(map, hitRatioCount);
}
}
......@@ -220,6 +241,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
return ResponseDto.success(true);
}
/**
* 获取每个sku的兑换码生成数量
* <p>
......@@ -284,50 +306,94 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
Map<String, Map<String, Object>> mapMap = new HashMap<>();
Map<String, Object> objectMap = new HashMap<>();
objectMap.put("hitRatio", 30);
objectMap.put("stock", 900);
objectMap.put("hitRatio", 3.33);
objectMap.put("stock", 100);
mapMap.put("1", objectMap);
Map<String, Object> objectMap1 = new HashMap<>();
objectMap1.put("hitRatio", 0.3);
objectMap1.put("stock", 9);
objectMap1.put("hitRatio", 57.7);
objectMap1.put("stock", 20);
mapMap.put("2", objectMap1);
Map<String, Object> objectMap2 = new HashMap<>();
objectMap2.put("hitRatio", 23.3);
objectMap2.put("stock", 697);
objectMap2.put("hitRatio", 9);
objectMap2.put("stock", 30);
mapMap.put("3", objectMap2);
Map<String, Object> objectMap3 = new HashMap<>();
objectMap3.put("hitRatio", 2.2);
objectMap3.put("stock", 66);
objectMap3.put("hitRatio", 1);
objectMap3.put("stock", 50);
mapMap.put("4", objectMap3);
Map<String, Object> objectMap4 = new HashMap<>();
/* Map<String, Object> objectMap4 = new HashMap<>();
objectMap4.put("hitRatio", 26.7);
objectMap4.put("stock", 797);
objectMap4.put("stock", 165);
mapMap.put("5", objectMap4);
Map<String, Object> objectMap5 = new HashMap<>();
objectMap5.put("hitRatio", 2.2);
objectMap5.put("stock", 66);
objectMap5.put("stock", 12);
mapMap.put("6", objectMap5);
Map<String, Object> objectMap6 = new HashMap<>();
objectMap6.put("hitRatio", 15.3);
objectMap6.put("stock", 458);
mapMap.put("7", objectMap6);
objectMap6.put("hitRatio", 15.6);
objectMap6.put("stock", 90);
mapMap.put("7", objectMap6);*/
Map<String, Integer> stockMap = new HashMap<>();
ArrayList<String> eliminateSkuIdList = CollectionUtil.arrayListString();
getStock(594, new BigDecimal(100), mapMap, stockMap, 2993, eliminateSkuIdList);
getStock(155, new BigDecimal(71.03), mapMap, stockMap, 179, eliminateSkuIdList);
for (String key : stockMap.keySet()) {
System.out.println("skuId" + key + "***********数量" + stockMap.get(key));
System.out.println("skuId:" + key + "***********数量:" + stockMap.get(key));
}
System.out.println("kkk");
/* Map<String, BigDecimal> hmap = new HashMap<>();
hmap.put("1", new BigDecimal(40));
hmap.put("2", new BigDecimal(49));
hmap.put("3", null);
hmap.put("4", null);
hmap.put("5", null);
arrangeHitRatioMap(hmap, new BigDecimal(89));
for (String key : hmap.keySet()) {
}*/
}
/**
* 整理map集合中存在空概率的值
*
* @param map,hitRatioCount
*/
private static void arrangeHitRatioMap(Map<String, BigDecimal> map, BigDecimal hitRatioCount) {
// 定义最大概率
BigDecimal maxHitRatio = new BigDecimal(100);
// 剩余概率
BigDecimal remainHitRatio = maxHitRatio.subtract(hitRatioCount);
// 获取值为空的数量
int number = 0;
for (String key : map.keySet()) {
if (map.get(key) == null) {
number++;
}
}
// 平均值
BigDecimal averageNumber = remainHitRatio.divide(BigDecimal.valueOf(number), 2, BigDecimal.ROUND_DOWN);
for (String key : map.keySet()) {
if (map.get(key) == null) {
map.put(key, averageNumber);
}
}
}
/**
* 获取单个sku库存
*
......@@ -351,11 +417,11 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
continue;
}
BigDecimal bigDecimal = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 2, BigDecimal.ROUND_HALF_UP)));
BigDecimal bigDecimal = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 5, BigDecimal.ROUND_HALF_UP)));
bigDecimalHashMap.put(key, bigDecimal);
// 要减去的库存
int subStock = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 2, BigDecimal.ROUND_HALF_UP))).setScale(0, BigDecimal.ROUND_UP).intValue();
int subStock = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 5, BigDecimal.ROUND_HALF_UP))).setScale(0, BigDecimal.ROUND_UP).intValue();
if (subStock > Integer.valueOf(stock.toString())) {
subNumber += Integer.valueOf(stock.toString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment