This commit is contained in:
hujiabin 2024-08-16 17:48:12 +08:00
parent 199d7af12d
commit 1958761e7a
7 changed files with 64 additions and 19 deletions

View File

@ -18,7 +18,7 @@ class InGameMall(object):
['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:上架时间 2:价格'],
['order_asc', 0, '排序方向, 0:从小到大 1:从大到小'],
['price_filter', '', '价格过滤(用|分割)'],
['type_filter', '', '类型过滤 1:英雄皮肤 2:芯片 3:英雄碎片 11:其它(材料、宝箱)'],
['type_filter', '', '类型过滤 1:英雄皮肤 2:芯片 3:英雄碎片 5:金币 11:其它(材料、宝箱)'],
['item_filter', '', 'itemId过滤(用|分割)'],
['quality_filter', '', '品质过滤'],
],

View File

@ -1440,12 +1440,13 @@ DROP TABLE IF EXISTS `t_ingame_mall`;
CREATE TABLE `t_ingame_mall` (
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`order_id` varchar(255) NOT NULL DEFAULT '' COMMENT '订单id',
`order_type` int(11) NOT NULL DEFAULT '0' COMMENT '1:英雄 2:芯片 3:碎片 4:宝箱',
`order_type` int(11) NOT NULL DEFAULT '0' COMMENT '1:英雄皮肤 2:芯片 3:英雄碎片 4:皮肤碎片 5:金币 11:其它',
`seller` varchar(60) NOT NULL DEFAULT '' COMMENT 'seller',
`seller_address` varchar(60) DEFAULT '' COMMENT 'seller_address',
`goods_uniid` varchar(50) NOT NULL DEFAULT '0' COMMENT '物品id',
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品itemId',
`item_num` bigint NOT NULL DEFAULT '0' COMMENT '物品数量',
`pay_type` int(11) NOT NULL DEFAULT '0' COMMENT '0:金币 1:砖石',
`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',

View File

@ -332,7 +332,7 @@ class BaseAuthedController extends BaseController {
return in_array($itemId, array(V_ITEM_GOLD, V_ITEM_DIAMOND, V_ITEM_EXP, V_ITEM_ACTIVE,V_ITEM_BCEG,V_ITEM_STAR));
}
public function _addVirtualItem($itemId, $itemNum,$awardService,$propertyChgService)
public function _addVirtualItem($itemId, $itemNum)
{
if ($itemNum <= 0){
return;

View File

@ -193,9 +193,11 @@ class InGameMallController extends BaseAuthedController {
$this->_rspErr(1, 'param item_id error');
return;
}
if (! $this->_isGoodsType($itemMeta['type'])){
$this->_rspErr(1, 'param item_id error');
return;
if ($itemId != V_ITEM_GOLD){
if (! $this->_isGoodsType($itemMeta['type'])){
$this->_rspErr(1, 'param item_id error');
return;
}
}
switch ($itemMeta['type']){
case \mt\Item::HERO_SKIN_TYPE : {
@ -234,7 +236,7 @@ class InGameMallController extends BaseAuthedController {
return;
}
$propertyChgService = new PropertyChgService();
if (\mt\Item::isBagItem($itemMeta['type'],$itemMeta['sub_type'])){
if (\mt\Item::isBagItem($itemMeta['type'],$itemMeta['sub_type']) || $itemId == V_ITEM_GOLD){
$costItems = array(
array(
'item_id' => $itemId,
@ -276,12 +278,18 @@ class InGameMallController extends BaseAuthedController {
$orderId = OrderId::gen();
$orderType = $this->_getGoodsType($itemMeta);
if ($orderType == InGameMall::GOLD_TYPE){
$payType = 1;
}else{
$payType = 0;
}
InGameMall::add(
$orderId,
$orderType,
$goodsUniid,
$itemId,
$amount,
$payType,
$priceBn,
$orderField
);
@ -305,9 +313,14 @@ class InGameMallController extends BaseAuthedController {
myself()->_rspErr(1, ' goods price error');
return;
}
if ($goodsDb['pay_type'] == 1){
$costItemId = V_ITEM_DIAMOND;
}else{
$costItemId = V_ITEM_GOLD;
}
$costItems = array(
array(
'item_id' => V_ITEM_GOLD,
'item_id' => $costItemId,
'item_num' => $goodsDb['price']
)
);
@ -327,11 +340,18 @@ class InGameMallController extends BaseAuthedController {
if (!$goods){
return;
}
if ($goods['pay_type'] == 1){
$payType = 'diamond';
$payItemId = V_ITEM_DIAMOND;
}else{
$payType = 'gold';
$payItemId = V_ITEM_GOLD;
}
$price = $goods['price'];
InGameMall::buyOk($goods['order_id'],myself()->_getAccountId());
$costItems = array(
array(
'item_id' => V_ITEM_GOLD,
'item_id' => $payItemId,
'item_num' => $price
)
);
@ -366,6 +386,11 @@ class InGameMallController extends BaseAuthedController {
$propertyChgService->addChip();
}
break;
case InGameMall::GOLD_TYPE:{
myself()->_addVirtualItem($goods['item_id'],$goods['item_num']);
$propertyChgService->addUserChg();
}
break;
default : {
Bag::addItem($goods['item_id'],$goods['item_num']);
@ -393,15 +418,17 @@ class InGameMallController extends BaseAuthedController {
$taxGold = ceil($price*$taxRate);
$falGold = $price - $taxGold;
$mailContent = <<<EOD
{$itemName} has been successfully sold
Transaction price: + {$price} gold
Service fee: - {$taxGold} gold
After selling {$itemName}, you received {$falGold} gold
Transaction price: + {$price} {$payType}
Service fee: - {$taxGold} {$payType}
After selling {$itemName}, you received {$falGold} {$payType}
EOD;
$attachments = array(
array(
'itemid' => V_ITEM_GOLD,
'itemid' => $payItemId,
'itemnum' => $falGold
)
);
@ -420,7 +447,7 @@ EOD;
'seller' =>$goods['seller'],
'buyer' =>myself()->_getAccountId(),
'change' => array(
'item_id' => V_ITEM_GOLD,
'item_id' => $payItemId,
'item_num' => $falGold
),
);
@ -645,7 +672,8 @@ EOD;
return;
}
$orderIdArr = explode("|",$orderIds);
$price = 0;
$goldPrice = 0;
$diamondPrice = 0;
foreach ($orderIdArr as $orderId) {
$goodsDb = InGameMall::findByOrderId($orderId);
if (!$goodsDb) {
@ -656,12 +684,21 @@ EOD;
myself()->_rspErr(1, 'cannot cancel the goods');
return;
}
$price += $goodsDb['price'];
if ($goodsDb['pay_type'] == 1){
$diamondPrice += $goodsDb['price'];
}else{
$goldPrice += $goodsDb['price'];
}
}
$costItems = array(
array(
'item_id' => V_ITEM_GOLD,
'item_num' => $price
'item_num' => $goldPrice
),
array(
'item_id' => V_ITEM_DIAMOND,
'item_num' => $diamondPrice
)
);
$lackItem = null;
@ -708,6 +745,9 @@ EOD;
if (!$itemMeta){
return 0;
}
if ($itemMeta['id'] == V_ITEM_GOLD){
return InGameMall::GOLD_TYPE;
}
switch ($itemMeta['type']){
case \mt\Item::HERO_SKIN_TYPE : {
return InGameMall::HERO_SKIN_TYPE;

View File

@ -14,8 +14,10 @@ class InGameMall extends BaseModel {
const CHIP_TYPE = 2;
const HERO_FRAGMENT_TYPE = 3;
const SKIN_FRAGMENT_TYPE = 4;
const GOLD_TYPE = 5;
const OTHER_TYPE = 11;
const SYSTEM_MALL_ACCOUNT = "kingsome";
public static function findByOrderId($orderId)
@ -30,7 +32,7 @@ class InGameMall extends BaseModel {
return $row;
}
public static function add($orderId, $orderType, $goodsUniid,$itemId, $itemNum, $price, $orderField)
public static function add($orderId, $orderType, $goodsUniid,$itemId, $itemNum, $payType,$price, $orderField)
{
SqlHelper::insert
(myself()->_getMysql(''),
@ -43,6 +45,7 @@ class InGameMall extends BaseModel {
'goods_uniid' => $goodsUniid,
'item_id' => $itemId,
'item_num' => $itemNum,
'pay_type' => $payType,
'price' => $price,
'order1' => $orderField,
'unit_price' => $price/$itemNum,

View File

@ -40,7 +40,7 @@ class AddItemsService extends BaseService
$awardService->addItem($item['item_id'], $item['item_num']);
}
if (myself()->_isVirtualItem($item['item_id'])) {
myself()->_addVirtualItem($item['item_id'], $item['item_num'],$awardService,$propertyService);
myself()->_addVirtualItem($item['item_id'], $item['item_num']);
$propertyService->addUserChg();
} else {
$itemMeta = Item::get($item['item_id']);

View File

@ -6,6 +6,7 @@ class ContributionService extends BaseService {
private static $ignoreCa = array(
'BlockChain@mintGoldBullion',
'InGameMall@sellS',
'InGameMall@buyS',
'InGameMall@shoppingCartBuyS',
);