mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 10:16:14 +00:00
提交
This commit is contained in:
@@ -21,7 +21,7 @@ public final class TbGGift extends AbstractBean {
|
||||
tig = _buf.get("tig").getAsString();
|
||||
limit = _buf.get("limit").getAsInt();
|
||||
limitValue = _buf.get("limitValue").getAsInt();
|
||||
price = _buf.get("price").getAsInt();
|
||||
{ com.google.gson.JsonArray _json0_ = _buf.get("exchanges").getAsJsonArray(); int __n0 = _json0_.size(); exchanges = new cfg.TbGEntity.TResource[__n0]; int __index0=0; for(JsonElement __e0 : _json0_) { cfg.TbGEntity.TResource __v0; __v0 = cfg.TbGEntity.TResource.deserialize(__e0.getAsJsonObject()); exchanges[__index0++] = __v0; } }
|
||||
{ com.google.gson.JsonArray _json0_ = _buf.get("rewards").getAsJsonArray(); int __n0 = _json0_.size(); rewards = new cfg.TbGEntity.TReward[__n0]; int __index0=0; for(JsonElement __e0 : _json0_) { cfg.TbGEntity.TReward __v0; __v0 = cfg.TbGEntity.TReward.deserialize(__e0.getAsJsonObject()); rewards[__index0++] = __v0; } }
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ public final class TbGGift extends AbstractBean {
|
||||
*/
|
||||
public final int limitValue;
|
||||
/**
|
||||
* 价格
|
||||
* 兑换的资源
|
||||
*/
|
||||
public final int price;
|
||||
public final cfg.TbGEntity.TResource[] exchanges;
|
||||
/**
|
||||
* 奖励
|
||||
*/
|
||||
@@ -71,7 +71,7 @@ public final class TbGGift extends AbstractBean {
|
||||
+ "(format_field_name __code_style field.name):" + tig + ","
|
||||
+ "(format_field_name __code_style field.name):" + limit + ","
|
||||
+ "(format_field_name __code_style field.name):" + limitValue + ","
|
||||
+ "(format_field_name __code_style field.name):" + price + ","
|
||||
+ "(format_field_name __code_style field.name):" + exchanges + ","
|
||||
+ "(format_field_name __code_style field.name):" + rewards + ","
|
||||
+ "}";
|
||||
}
|
||||
|
@@ -224,7 +224,7 @@ public class GPlayerEquipController {
|
||||
if(Objects.isNull(nextForgingInfo)) return NewsResource.onFail("已满级");
|
||||
|
||||
//扣除材料
|
||||
ArrayList<ResourceUpdateOV> resources = new ArrayList<>(resourceService.deduct(player,nextForgingInfo.materials));
|
||||
ArrayList<ResourceUpdateOV> resources = new ArrayList<>(resourceService.deduct(player.getPlayerId(),nextForgingInfo.materials));
|
||||
|
||||
info.setForgingQuality(nextLevel);
|
||||
//保存升级结束时间
|
||||
|
@@ -7,6 +7,8 @@ import cn.jisol.game.controller.argsresolver.CurrentPlayer;
|
||||
import cn.jisol.game.controller.exception.ResourceNotException;
|
||||
import cn.jisol.game.data.ResourceId;
|
||||
import cn.jisol.game.data.TD;
|
||||
import cn.jisol.game.entity.data.GResource;
|
||||
import cn.jisol.game.entity.data.GReward;
|
||||
import cn.jisol.game.entity.table.GiftDayRecord;
|
||||
import cn.jisol.game.entity.table.GiftRecord;
|
||||
import cn.jisol.game.entity.table.Player;
|
||||
@@ -30,6 +32,7 @@ import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(value = "JNGameDemo - API", tags = {"礼包 - API"})
|
||||
@RestController
|
||||
@@ -71,7 +74,7 @@ public class GiftController {
|
||||
}
|
||||
}
|
||||
|
||||
resourceService.addResourceValue(player.getPlayerId(), ResourceId.GiftCoupons.id, (long) -gift.price);
|
||||
resourceService.deduct(player.getPlayerId(), gift.exchanges);
|
||||
|
||||
//发放奖励
|
||||
List<ResourceUpdateOV> ovs = resourceService.rewards(player.getPlayerId(), gift.rewards);
|
||||
@@ -81,8 +84,9 @@ public class GiftController {
|
||||
.playerId(player.getPlayerId())
|
||||
.giftCfgId(gift.id)
|
||||
.giftCfgName(gift.name)
|
||||
.giftCfgRewards(Arrays.asList(gift.rewards))
|
||||
.giftCfgPrice(gift.price)
|
||||
.giftCfgRewards(Arrays.stream(gift.rewards).map(GReward::toBuild).collect(Collectors.toList()))
|
||||
// .giftCfgRewards(Arrays.asList(gift.rewards))
|
||||
.giftCfgExchanges(Arrays.stream(gift.exchanges).map(GResource::toBuild).collect(Collectors.toList()))
|
||||
.giftBuyingTime(new Date().getTime())
|
||||
.build();
|
||||
|
||||
@@ -99,6 +103,17 @@ public class GiftController {
|
||||
|
||||
}
|
||||
|
||||
//查询所有充值记录
|
||||
@ApiImplicitParams({})
|
||||
@ApiOperation(value = "查询所有充值记录")
|
||||
@GetMapping("/record/all")
|
||||
public NewsContext<List<GiftRecord>> getGiftRecord(@CurrentPlayer Player player){
|
||||
return NewsContext.onSuccess("查询成功",giftRecordService.list(
|
||||
Wrappers.lambdaQuery(GiftRecord.class)
|
||||
.eq(GiftRecord::getPlayerId,player.getPlayerId())
|
||||
));
|
||||
}
|
||||
|
||||
//查询当天购买记录
|
||||
@ApiImplicitParams({})
|
||||
@ApiOperation(value = "查询当天购买记录")
|
||||
|
@@ -0,0 +1,28 @@
|
||||
package cn.jisol.game.entity.data;
|
||||
|
||||
import cfg.TbGEntity.TResource;
|
||||
import cfg.TbGEntity.TReward;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class GResource {
|
||||
/**
|
||||
* 资源Id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 资源数量
|
||||
*/
|
||||
private Integer value;
|
||||
|
||||
public static GResource toBuild(TResource reward){
|
||||
return GResource.builder()
|
||||
.id(reward.id)
|
||||
.value(reward.value)
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package cn.jisol.game.entity.data;
|
||||
|
||||
import cfg.TbGEntity.TReward;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class GReward {
|
||||
/**
|
||||
* 奖励类型
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 奖励Id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 奖励数量
|
||||
*/
|
||||
private Integer value;
|
||||
|
||||
public static GReward toBuild(TReward reward){
|
||||
return GReward.builder()
|
||||
.id(reward.id)
|
||||
.type(reward.type)
|
||||
.value(reward.value)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,19 +1,26 @@
|
||||
package cn.jisol.game.entity.table;
|
||||
|
||||
import cfg.TbGEntity.TResource;
|
||||
import cfg.TbGEntity.TReward;
|
||||
import cn.jisol.game.entity.data.GResource;
|
||||
import cn.jisol.game.entity.data.GReward;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Data
|
||||
@TableName("`gift_record`")
|
||||
@TableName(value = "`gift_record`",autoResultMap = true)
|
||||
public class GiftRecord {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@@ -23,9 +30,10 @@ public class GiftRecord {
|
||||
private String giftCfgName; //礼包名称
|
||||
|
||||
@TableField(typeHandler = FastjsonTypeHandler.class)
|
||||
private List<TReward> giftCfgRewards; //礼包奖励
|
||||
private List<GReward> giftCfgRewards; //礼包奖励
|
||||
@TableField(typeHandler = FastjsonTypeHandler.class)
|
||||
private List<GResource> giftCfgExchanges; //礼包价格
|
||||
|
||||
private Integer giftCfgPrice; //礼包价格
|
||||
private Long giftBuyingTime; //礼包购买时间戳
|
||||
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ public interface ResourceService extends IService<Resource> {
|
||||
public Resource initResource(Resource resource);
|
||||
|
||||
//扣除玩家材料
|
||||
public ArrayList<ResourceUpdateOV> deduct(Player player, cfg.TbGEntity.TResource[] materials);
|
||||
public ArrayList<ResourceUpdateOV> deduct(Long playerId, cfg.TbGEntity.TResource[] materials);
|
||||
|
||||
//扣除通用加速卷
|
||||
public ResourceUpdateOV deductSpeedUp(Player player, int type);
|
||||
|
@@ -22,11 +22,9 @@ import org.springframework.retry.RetryException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Service
|
||||
public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> implements ResourceService {
|
||||
@@ -104,12 +102,12 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ResourceUpdateOV> deduct(Player player, TResource[] materials) {
|
||||
public ArrayList<ResourceUpdateOV> deduct(Long playerId, TResource[] materials) {
|
||||
|
||||
ArrayList<ResourceUpdateOV> list = new ArrayList<>();
|
||||
|
||||
for (TResource res : materials) {
|
||||
Resource data = this.addResourceValue(player.getPlayerId(), res.id, -((long) res.value));
|
||||
Resource data = this.addResourceValue(playerId, res.id, -((long) res.value));
|
||||
if (Objects.isNull(data)) {
|
||||
throw new ResourceNotException("资源不够");
|
||||
} else {
|
||||
@@ -137,12 +135,16 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
|
||||
@Override
|
||||
public List<ResourceUpdateOV> rewards(Long playerId, TReward[] rewards) {
|
||||
return Arrays.stream(rewards).map(reward -> {
|
||||
if(reward.type == cfg.TbGEnum.TReward.Resource){
|
||||
return ResourceUpdateOV.onUpdate(this.addResourceValue(playerId, reward.id, (long) reward.value));
|
||||
}
|
||||
return null;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
//将同样的奖励合并
|
||||
Map<Integer,List<TReward>> rewardsGroup = Arrays.stream(rewards).collect(Collectors.groupingBy(item -> item.id));
|
||||
|
||||
return rewardsGroup.values().stream().map(
|
||||
(List<TReward> values) ->
|
||||
ResourceUpdateOV.onUpdate(addResourceValue(playerId,values.get(0).id, values.stream().mapToLong(item -> item.value).sum())
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -4,8 +4,8 @@ spring:
|
||||
datasource:
|
||||
username: pet_jisol_cn
|
||||
password: sThsBwjfDcaw2wJR
|
||||
url: jdbc:mysql://kyu.jisol.cn:3306/pet_jisol_cn?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&allowMultiQueries=true
|
||||
# url: jdbc:mysql://localhost:3306/pet_jisol_cn?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&allowMultiQueries=true
|
||||
# url: jdbc:mysql://kyu.jisol.cn:3306/pet_jisol_cn?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&allowMultiQueries=true
|
||||
url: jdbc:mysql://localhost:3306/pet_jisol_cn?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8&allowMultiQueries=true
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
jackson:
|
||||
serialization:
|
||||
|
@@ -5,22 +5,67 @@
|
||||
"tig": "金币礼包",
|
||||
"limit": 1,
|
||||
"limitValue": 0,
|
||||
"price": 6,
|
||||
"exchanges": [
|
||||
{
|
||||
"id": 90007,
|
||||
"value": 6
|
||||
}
|
||||
],
|
||||
"rewards": [
|
||||
{
|
||||
"type": 1,
|
||||
"id": 90002,
|
||||
"value": 20
|
||||
"id": 90001,
|
||||
"value": 1000
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 180002,
|
||||
"name": "好多金币礼包",
|
||||
"tig": "好多金币礼包",
|
||||
"limit": 1,
|
||||
"limitValue": 0,
|
||||
"exchanges": [
|
||||
{
|
||||
"id": 90007,
|
||||
"value": 6
|
||||
}
|
||||
],
|
||||
"rewards": [
|
||||
{
|
||||
"type": 1,
|
||||
"id": 90001,
|
||||
"value": 1000
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"id": 90001,
|
||||
"value": 1000
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"id": 90001,
|
||||
"value": 1000
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"id": 90001,
|
||||
"value": 1000
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 190001,
|
||||
"name": "限购金币礼包",
|
||||
"tig": "限购金币礼包",
|
||||
"name": "限购矿石礼包",
|
||||
"tig": "每日限购矿石礼包",
|
||||
"limit": 2,
|
||||
"limitValue": 1,
|
||||
"price": 6,
|
||||
"limitValue": 5,
|
||||
"exchanges": [
|
||||
{
|
||||
"id": 90007,
|
||||
"value": 6
|
||||
}
|
||||
],
|
||||
"rewards": [
|
||||
{
|
||||
"type": 1,
|
||||
@@ -31,11 +76,16 @@
|
||||
},
|
||||
{
|
||||
"id": 200001,
|
||||
"name": "每日限购金币礼包",
|
||||
"tig": "每日限购金币礼包",
|
||||
"name": "每日矿石礼包",
|
||||
"tig": "每日限购矿石礼包",
|
||||
"limit": 3,
|
||||
"limitValue": 1,
|
||||
"price": 6,
|
||||
"limitValue": 5,
|
||||
"exchanges": [
|
||||
{
|
||||
"id": 90007,
|
||||
"value": 6
|
||||
}
|
||||
],
|
||||
"rewards": [
|
||||
{
|
||||
"type": 1,
|
||||
|
@@ -6,12 +6,17 @@
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"tig": "限购金币礼包",
|
||||
"giftId": 190001
|
||||
"tig": "好多金币礼包",
|
||||
"giftId": 180002
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"tig": "每日限购金币礼包",
|
||||
"tig": "限购矿石礼包",
|
||||
"giftId": 190001
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"tig": "每日矿石礼包",
|
||||
"giftId": 200001
|
||||
}
|
||||
]
|
Reference in New Issue
Block a user