This commit is contained in:
hujiabin 2024-07-11 16:44:23 +08:00
parent fc3aabebb6
commit 5b4e6113d1
7 changed files with 153 additions and 10 deletions

View File

@ -1442,6 +1442,7 @@ CREATE TABLE `t_ingame_mall` (
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品itemId',
`item_num` bigint NOT NULL DEFAULT '0' COMMENT '物品数量',
`price` bigint NOT NULL DEFAULT '0' COMMENT '价格',
`unit_price` decimal(10, 2) NOT NULL DEFAULT '0' COMMENT '单价',
`status` int(11) NOT NULL DEFAULT '0' COMMENT 'status',
`buyer` varchar(60) NOT NULL DEFAULT '' COMMENT '购买成功者',
`buy_ok_time` int(11) NOT NULL DEFAULT '0' COMMENT '购买成功时间',
@ -1867,3 +1868,18 @@ CREATE TABLE `t_gold_bullion_return` (
UNIQUE KEY `idx_token_id_net_id` (`token_id`, `net_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `t_server_task_battle_count`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_server_task_battle_count` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
`period` int(11) NOT NULL DEFAULT '0' COMMENT '周期',
`state` int(11) NOT NULL DEFAULT '0' COMMENT '1:总计数 2:循环计数',
`val` bigint(20) NOT NULL DEFAULT '0' COMMENT 'val',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

View File

@ -0,0 +1,25 @@
begin;
DROP TABLE IF EXISTS `t_hero_skin`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_hero_skin` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
`skin_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤id',
`hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄id',
`skin_state` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤状态 0=封装1=解封',
`get_from` int(11) NOT NULL DEFAULT '0' COMMENT '获得方式 0 = 系统赠送 1 = 金币购买',
`consume_num` int(11) NOT NULL DEFAULT '0' COMMENT '消耗货币的具体数量',
`try_expire_at` int(11) NOT NULL DEFAULT '0' COMMENT '试用截止时间',
`rand_attr` mediumblob COMMENT '随机属性',
`wealth_attr` mediumblob COMMENT '财富值属性',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `account_id_skinid` (`account_id`, `skin_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
insert into version (version) values(2024052101);
commit;

View File

@ -0,0 +1,18 @@
begin;
alter table t_ingame_mall add column `unit_price` decimal(10, 2) NOT NULL DEFAULT '0' COMMENT '单价';
CREATE TABLE `t_server_task_battle_count` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
`period` int(11) NOT NULL DEFAULT '0' COMMENT '周期',
`state` int(11) NOT NULL DEFAULT '0' COMMENT '1:总计数 2:循环计数',
`val` bigint(20) NOT NULL DEFAULT '0' COMMENT 'val',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
insert into version (version) values(2024052101);
commit;

View File

@ -83,7 +83,7 @@ class InGameMallController extends BaseAuthedController {
break;
case 2:
{
$orderBy = 'ORDER BY length(price) ' . $orderAsc . ', price ' . $orderAsc;
$orderBy = 'ORDER BY length(unit_price) ' . $orderAsc . ', unit_price ' . $orderAsc;
}
break;
}
@ -557,7 +557,8 @@ EOD;
myself()->_rspErr(1, 'Not the seller');
return;
}
InGameMall::modifyPrice($orderId, $priceBn);
$unitPrice = $priceBn / $goodsDb['item_num'];
InGameMall::modifyPrice($orderId, $priceBn,$unitPrice);
myself()->_rspOk();
}
@ -576,7 +577,7 @@ EOD;
break;
case 2:
{
$orderBy = 'ORDER BY length(price) ' . $orderAsc . ', price ' . $orderAsc;
$orderBy = 'ORDER BY length(unit_price) ' . $orderAsc . ', unit_price ' . $orderAsc;
}
break;
}
@ -622,7 +623,7 @@ EOD;
break;
case 2:
{
$orderBy = 'ORDER BY length(price) ' . $orderAsc . ', price ' . $orderAsc;
$orderBy = 'ORDER BY length(unit_price) ' . $orderAsc . ', unit_price ' . $orderAsc;
}
break;
}

View File

@ -46,13 +46,14 @@ class InGameMall extends BaseModel {
'item_num' => $itemNum,
'price' => $price,
'order1' => $orderField,
'unit_price' => $price/$itemNum,
'last_modify_price_time' => myself()->_getNowTime(),
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
));
}
public static function modifyPrice($orderId, $price)
public static function modifyPrice($orderId, $price,$unitPrice)
{
SqlHelper::update
(myself()->_getMysql(''),
@ -62,6 +63,7 @@ class InGameMall extends BaseModel {
),
array(
'price' => $price,
'unit_price' => $unitPrice,
'last_modify_price_time' => myself()->_getNowTime(),
)
);

View File

@ -0,0 +1,70 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class ServerTaskBattleCount extends BaseModel
{
const TOTAL_COUNT = 1; //总计数
const LOOP_COUNT = 2; //循环计数
public static function getV($period, $state, $defVal = 0)
{
$valData = self::internalGetV($period, $state, $defVal);
return $valData['val'];
}
public static function setV($period, $state, $defVal)
{
self::internalSetV($period, $state, $defVal);
}
public static function incV($period, $state, $val)
{
$oldVal = self::getV($period, $state);
self::internalSetV($period, $state, $oldVal + $val);
}
private static function internalGetV($period, $state, $defVal = 0){
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_server_task_battle_count',
array(
'account_id' => myself()->_getAccountId(),
'period' => $period,
'state' => $state,
)
);
return array(
'val' => $row ? $row['val'] : $defVal,
'modifytime' => $row ? $row['modifytime'] : myself()->_getNowTime(),
);
}
private static function internalSetV($period,$state, $val)
{
SqlHelper::upsert
(myself()->_getSelfMysql(),
't_server_task_battle_count',
array(
'account_id' => myself()->_getAccountId(),
'period' => $period,
'state' => $state
),
array(
'val' => $val,
'modifytime' => myself()->_getNowTime()
),
array(
'account_id' => myself()->_getAccountId(),
'period' => $period,
'state' => $state,
'val' => $val,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
}

View File

@ -4,7 +4,10 @@
namespace services;
require_once('mt/LootConfig.php');
require_once('mt/ServerTaskTime.php');
require_once('models/ServerTaskBattleCount.php');
use models\ServerTaskBattleCount;
use mt;
class LootService
@ -75,8 +78,13 @@ class LootService
}
private static function disposeDropContent4($lootMeta,&$depth,&$items) {
$totalTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,0);
$recycleTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,1);
$serverTaskMeta = mt\ServerTaskTime::getCurrentTime();
$period = $serverTaskMeta?$serverTaskMeta['id']:0;
// $totalTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,0);
$totalTimes = ServerTaskBattleCount::getV($period,ServerTaskBattleCount::TOTAL_COUNT);
// $recycleTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,1);
$recycleTimes = ServerTaskBattleCount::getV(0,ServerTaskBattleCount::LOOP_COUNT);
$contentArr = explode("|",$lootMeta['content']);
$initTimes = $contentArr[0];
$po = $contentArr[1];
@ -89,12 +97,15 @@ class LootService
}
$p = min($po + ($recycleTimes-1) * $pd,$pm) * 100 ;
$rnd = rand(1,100);
myself()->_incV(TN_TOTAL_LOOT_TIMES,0,1);
// myself()->_incV(TN_TOTAL_LOOT_TIMES,0,1);
ServerTaskBattleCount::incV($period,ServerTaskBattleCount::TOTAL_COUNT,1);
if ($rnd <= $p){
myself()->_setV(TN_TOTAL_LOOT_TIMES,1,1);
// myself()->_setV(TN_TOTAL_LOOT_TIMES,1,1);
ServerTaskBattleCount::setV(0,ServerTaskBattleCount::LOOP_COUNT,1);
self::disposeLootIndex($index1,$depth,$items);
}else{
myself()->_incV(TN_TOTAL_LOOT_TIMES,1,1);
// myself()->_incV(TN_TOTAL_LOOT_TIMES,1,1);
ServerTaskBattleCount::incV(0,ServerTaskBattleCount::LOOP_COUNT,1);
self::disposeLootIndex($index2,$depth,$items);
}
}