|
@@ -87,7 +87,11 @@ class AuctionProc {
|
|
|
my_Assert(ctx()->baseInfo->cash >= $buyoutPrice, ErrCode::notenough_cash_msg);
|
|
|
//扣除钻石--交易费用 + 手续费
|
|
|
ctx()->base()->Consume_Cash($buyoutPrice);
|
|
|
- //ctx()->baseInfo->cash -= $buyoutPrice;
|
|
|
+ $sList = explode(',', $aucItem->contents);
|
|
|
+ if($aucItem->currpeopleid != null){//竞拍玩家邮件返回钻石
|
|
|
+ EmailProc::SendAuctionItemsBidCashFallback(req()->zoneid, req()->uid, $sList[0], 2, $aucItem->currprice-$aucItem->addstep);
|
|
|
+ }
|
|
|
+
|
|
|
//更新表里的交易状态
|
|
|
$aucItem->result = "完成";
|
|
|
$aucItem->currpeopleid = req()->uid;
|
|
@@ -97,12 +101,11 @@ class AuctionProc {
|
|
|
//更新拍品缓存
|
|
|
|
|
|
$obj = self::updateAuctionUserItemListCache();
|
|
|
-//发送邮件,给拍品
|
|
|
- $sList = explode(',', $aucItem->contents);
|
|
|
+//发送邮件,给拍品
|
|
|
EmailProc::SendAuctionItemsMail(req()->zoneid, req()->uid, $sList[0], $sList[1]);
|
|
|
|
|
|
EmailProc::SendAuctionCashMail(req()->zoneid, $aucItem->sellerid, $sList[0], 2, $buyoutPrice - intval($buyoutPrice * 0.05)); //上架玩家给钻石邮件
|
|
|
-
|
|
|
+
|
|
|
UserProc::updateUserInfo(); # 回写玩家数据
|
|
|
return Resp::ok(array(
|
|
|
"auction" => $obj->data,
|
|
@@ -111,7 +114,7 @@ class AuctionProc {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 取消出售
|
|
|
+ * 取消出售---增加回退竞拍者的竞价钱
|
|
|
*/
|
|
|
static function CancelAuction() {
|
|
|
list($uId) = req()->paras;
|
|
@@ -121,6 +124,9 @@ class AuctionProc {
|
|
|
$ctxList = explode(',', $aucItem->contents);
|
|
|
EmailProc::SendCantSellAuctionItemsMail(req()->zoneid, req()->uid, $ctxList[0], $ctxList[1]);
|
|
|
|
|
|
+ #回退竞拍者钻石
|
|
|
+ EmailProc::SendCantSellAuctionItemsBidCash(req()->zoneid, $aucItem->currpeopleid,$ctxList[0],2,$aucItem->currprice);
|
|
|
+
|
|
|
self::updateAuctionItemState($aucItem);
|
|
|
self::updateAuctionUserItemListCache();
|
|
|
|
|
@@ -133,11 +139,11 @@ class AuctionProc {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 上传拍品
|
|
|
+ * 上传拍品--7406
|
|
|
* @return type
|
|
|
*/
|
|
|
static function UploadAuctionItems() {
|
|
|
- list($itemId, $num, $bugoutPrice) = req()->paras; //上传拍品的 id 数量 竞拍价 一口价
|
|
|
+ list($itemId, $num, $bugoutPrice,$userBidPrice) = req()->paras; //上传拍品的 id 数量 竞拍价 一口价
|
|
|
|
|
|
$user = ctx();
|
|
|
|
|
@@ -146,15 +152,18 @@ class AuctionProc {
|
|
|
my_Assert($mo != null, ErrCode::err_const_no);
|
|
|
|
|
|
$sList = explode(',', $mo->buyoutPrice);
|
|
|
- my_Assert($bugoutPrice >= $sList[1], ErrCode::notenough_cash_msg);
|
|
|
-
|
|
|
+ $pList = explode(',', $mo->auctionPrice);
|
|
|
+ my_Assert($bugoutPrice >= $sList[1], ErrCode::auction_loadpricelow);
|
|
|
+ my_Assert($userBidPrice >= $pList[1], ErrCode::auction_loadpricelow);
|
|
|
+
|
|
|
StoreProc::removeItemFromStore($user->store, $itemId, $num);
|
|
|
|
|
|
$aucItem = new Ins_AuctionItemModel();
|
|
|
- $aucItem->addstep = 1;
|
|
|
+ $aucItem->addstep = 10;
|
|
|
$aucItem->contents = $itemId . "," . $num;
|
|
|
- $aucItem->startprice = 0;
|
|
|
- $aucItem->buyoutPrice = $sList[1] * $num;
|
|
|
+ $aucItem->startprice = $userBidPrice;
|
|
|
+ $aucItem->buyoutPrice = $bugoutPrice;
|
|
|
+ $aucItem->currprice = $userBidPrice;
|
|
|
$aucItem->startts = time();
|
|
|
$aucItem->endts = glc()->AuctionEndTs * 60 * 60 + time(); # 24小时
|
|
|
$aucItem->sellerid = req()->uid;
|
|
@@ -177,29 +186,78 @@ class AuctionProc {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 竞价
|
|
|
+ * 竞价--7407
|
|
|
*/
|
|
|
- static function UserAuctionBidItem() {
|
|
|
- list($uId) = req()->paras;
|
|
|
+ static function UserAuctionBidItem() {
|
|
|
+ $uId = req()->paras[0];
|
|
|
+// $price = req()->paras[1];
|
|
|
+
|
|
|
$aucItem = self::getAuctionItem($uId);
|
|
|
-
|
|
|
+
|
|
|
+ $ts = time();
|
|
|
+ my_Assert($aucItem->startts < $ts, ErrCode::auction_beforstart);
|
|
|
+ my_Assert($aucItem->endts > $ts, ErrCode::auction_end);
|
|
|
+ $curPrice = $aucItem->currprice;
|
|
|
+ //my_Assert($price >= $curPrice, ErrCode::auction_failprice);
|
|
|
+ my_Assert(ctx()->baseInfo->cash >= $aucItem->currprice, ErrCode::notenough_cash_msg);
|
|
|
+
|
|
|
+ #扣除竞价--钻石
|
|
|
+ ctx()->base(true)->Consume_Cash($aucItem->currprice);
|
|
|
+ #退回上一人的竞价
|
|
|
+ if ($aucItem->currpeopleid != null) {
|
|
|
+ $contentsList = explode(',', $aucItem->contents);
|
|
|
+ EmailProc::SendRefundAuctionCash($aucItem->zoneid,$aucItem->currpeopleid ,$contentsList[0], 2,$aucItem->currprice-$aucItem->addstep);
|
|
|
+ }
|
|
|
+ # 更新拍品信息
|
|
|
+ $aucItem->currpeopleid = req()->uid; # 更新拍品信息
|
|
|
+ $aucItem->currpeoplename = ctx()->baseInfo->name;
|
|
|
+ $aucItem->currprice = $aucItem->currprice + $aucItem->addstep;
|
|
|
+
|
|
|
+ $auchistory = json_decode($aucItem->auchistory);
|
|
|
+ if($auchistory == null){
|
|
|
+ $auchistory = new \stdClass();
|
|
|
+ }
|
|
|
+ $auchistory->$ts = array("uid" => req()->uid, "name" => ctx()->baseInfo->name, "price" => $curPrice);
|
|
|
+ $aucItem->auchistory = addslashes(json_encode($auchistory));
|
|
|
+ self::updateAuctionItem($aucItem);
|
|
|
+
|
|
|
+ $auctionDic = self::updateAuctionUserItemListCache(); # 更新缓存
|
|
|
+
|
|
|
UserProc::updateUserInfo(); # 回写玩家数据
|
|
|
return Resp::ok(array(
|
|
|
- "store" => $user->store,
|
|
|
- "auction" => $auctionDic, #拍品
|
|
|
+ "res"=>"ok",
|
|
|
+ "cash"=>ctx()->baseInfo->cash,
|
|
|
+ //"store" => ctx()->store,
|
|
|
+ "auction" => $auctionDic->data, #拍品
|
|
|
));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 结算
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
static function TriggerSettlement() {
|
|
|
$result = self::selectTimeoutAuctionItems();
|
|
|
if (count($result) > 0) {
|
|
|
foreach ($result as $aucItem) {
|
|
|
//发送流拍邮件
|
|
|
$sList = explode(',', $aucItem->contents);
|
|
|
- EmailProc::SendAuctionItemsStreamingMail(req()->zoneid, req()->uid, $sList[0], $sList[1]);
|
|
|
-
|
|
|
- //更新数据库信息
|
|
|
- $aucItem->result = "流拍";
|
|
|
+ $currpeopleid = $aucItem->currpeopleid;
|
|
|
+ $sellerId = $aucItem->sellerid;
|
|
|
+ $zoneid = $aucItem->zoneid;
|
|
|
+
|
|
|
+ if($currpeopleid != null){//结算拍品
|
|
|
+ $currprice = $aucItem->currprice;//最后的竞价的钱
|
|
|
+ $aucItem->result = "完成";
|
|
|
+ //给卖家钻石邮件
|
|
|
+ EmailProc::SendAuctionCashMail($zoneid, $sellerId, $sList[0], 2, $currprice);
|
|
|
+ //给买家拍品邮件
|
|
|
+ EmailProc::SendAuctionItemsMail($zoneid, $currpeopleid, $sList[0], $sList[1]);
|
|
|
+ } else {
|
|
|
+ $aucItem->result = "流拍";
|
|
|
+ EmailProc::SendAuctionItemsStreamingMail($zoneid, $sellerId, $sList[0], $sList[1]);
|
|
|
+ }
|
|
|
+
|
|
|
self::updateAuctionItemState($aucItem);
|
|
|
}
|
|
|
}
|
|
@@ -230,8 +288,8 @@ class AuctionProc {
|
|
|
*/
|
|
|
static function insertNewUserAuctionItem($aucItem) {
|
|
|
$paydb = daoInst();
|
|
|
- $sql = "INSERT INTO `tab_auctionitems` (contents,startprice,buyoutPrice,startts,endts,sellerid,sellername,auchistory,zoneid) VALUES ('%s',%d,%d,%d,%d,'%s','%s','{}',%d)";
|
|
|
- $query = sprintf($sql, $aucItem->contents, $aucItem->startprice, $aucItem->buyoutPrice, $aucItem->startts, #
|
|
|
+ $sql = "INSERT INTO `tab_auctionitems` (contents,startprice,addstep,buyoutPrice,currprice,startts,endts,sellerid,sellername,auchistory,zoneid) VALUES ('%s',%d,%d,%d,%d,%d,%d,'%s','%s','{}',%d)";
|
|
|
+ $query = sprintf($sql, $aucItem->contents, $aucItem->startprice, $aucItem->addstep, $aucItem->buyoutPrice,$aucItem->currprice, $aucItem->startts, #
|
|
|
$aucItem->endts, $aucItem->sellerid, $aucItem->sellername, $aucItem->zoneid);
|
|
|
$result = $paydb->exec($query);
|
|
|
return $result;
|
|
@@ -349,4 +407,16 @@ class AuctionProc {
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 竞拍信息回存
|
|
|
+ * @param type $aucItem
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
+ static function updateAuctionItem($aucItem) {
|
|
|
+ $sql = "UPDATE `tab_auctionitems` set currpeopleid = '%s',currpeoplename = '%s',currprice='%d',auchistory='%s' where itemid='%d'";
|
|
|
+ $query = sprintf($sql,$aucItem->currpeopleid,$aucItem->currpeoplename,$aucItem->currprice,$aucItem->auchistory,$aucItem->itemid);
|
|
|
+ $paydb = daoInst();
|
|
|
+ $result = $paydb->exec($query);
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
}
|