1
This commit is contained in:
parent
ea722cb84a
commit
a7ca1bdc47
@ -60,117 +60,41 @@ class MallController extends BaseAuthedController {
|
|||||||
myself()->_rspData($out);
|
myself()->_rspData($out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sell()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function cancel()
|
public function cancel()
|
||||||
{
|
{
|
||||||
$idx = getReqVal('idx', '');
|
$goodsUuid = getReqVal('goods_uuid', '');
|
||||||
|
$goodsDb = Mall::findByGoodsUuid($goodsUuid);
|
||||||
$address = $this->_getAddress();
|
if (!$goodsDb) {
|
||||||
if (!$address) {
|
myself()->_resErr(1, 'goods not found');
|
||||||
$this->_rspErr(1, 'address not found');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ($goodDb['seller'] != myself()->_getAccountId()) {
|
||||||
$goods = $this->getGoodsByIdx($idx);
|
myself()->_resErr(1, 'goods not found');
|
||||||
if (!$goods) {
|
|
||||||
$this->_rspErr(1, 'goods not found, idx:' . $idx);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Mall::cancel($goodsDb['goods_uuid']);
|
||||||
if ($goods['owner_address'] != $address) {
|
myself()->_rspOk();
|
||||||
$this->_rspErr(1, 'not your goods, idx:' . $idx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn = $this->_getSelfMysql();
|
|
||||||
$r = SqlHelper::update(
|
|
||||||
$conn,
|
|
||||||
't_market_store',
|
|
||||||
array(
|
|
||||||
'idx' => $idx,
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'status' => 1,
|
|
||||||
'modifytime' => $this->_getNowTime(),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if ($r) {
|
|
||||||
$items = array(
|
|
||||||
array(
|
|
||||||
'item_id' => $goods['item_id'],
|
|
||||||
'item_num' => $goods['amount'],
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$awardService = new services\AwardService();
|
|
||||||
$propertyChgService = new services\PropertyChgService();
|
|
||||||
$this->_addItems($items, $awardService, $propertyChgService);
|
|
||||||
|
|
||||||
{
|
|
||||||
//埋点
|
|
||||||
$event = [
|
|
||||||
'name' => LogService::MARKET_CANCEL_SELL_GOLD,
|
|
||||||
'val' => $goods['amount']
|
|
||||||
];
|
|
||||||
LogService::productGold($event);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_rspData(
|
|
||||||
array(
|
|
||||||
'idx' => $idx,
|
|
||||||
'property_chg' => $propertyChgService->toDto(),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->_rspErr(1, 'cancel failed');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function modifyPrice()
|
public function modifyPrice()
|
||||||
{
|
{
|
||||||
$idx = getReqVal('idx', '');
|
$goodsUuid = getReqVal('goods_uuid', '');
|
||||||
$s_price = getReqVal('s_price', '');
|
$price = getReqVal('price', '');
|
||||||
if (empty($s_price)) {
|
$goodsDb = Mall::findByGoodsUuid($goodsUuid);
|
||||||
$this->_rspErr(1, 's_price not found');
|
if (!$goodsDb) {
|
||||||
|
myself()->_resErr(1, 'goods not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!is_numeric($s_price)) {
|
if ($goodDb['seller'] != myself()->_getAccountId()) {
|
||||||
$this->_rspErr(1, 's_price must be number');
|
myself()->_resErr(1, 'goods not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Mall::modifyPrice($goodsDb['goods_uuid'], $price);
|
||||||
$address = $this->_getAddress();
|
|
||||||
if (!$address) {
|
|
||||||
$this->_rspErr(1, 'address not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$goods = $this->getGoodsByIdx($idx);
|
|
||||||
if (!$goods) {
|
|
||||||
$this->_rspErr(1, 'goods not found, idx:' . $idx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($goods['owner_address'] != $address) {
|
|
||||||
$this->_rspErr(1, 'not your goods, idx:' . $idx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn = $this->_getSelfMysql();
|
|
||||||
$r = SqlHelper::update(
|
|
||||||
$conn,
|
|
||||||
't_market_store',
|
|
||||||
array(
|
|
||||||
'idx' => $idx,
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
's_price' => $s_price,
|
|
||||||
'modifytime' => $this->_getNowTime(),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if (!$r) {
|
|
||||||
$this->_rspErr(1, 'update price failed');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,10 +10,21 @@ class Mall extends BaseModel {
|
|||||||
const BUY_OK_STATE = 1;
|
const BUY_OK_STATE = 1;
|
||||||
const CANCEL_STATE = 2;
|
const CANCEL_STATE = 2;
|
||||||
|
|
||||||
public static function find($orderId){
|
public static function findByGoodsUuid($goodsUuid){
|
||||||
$row = SqlHelper::ormSelectOne(
|
$row = SqlHelper::ormSelectOne(
|
||||||
myself()->_getMysql(''),
|
myself()->_getMysql(''),
|
||||||
't_market',
|
't_mall',
|
||||||
|
array(
|
||||||
|
'goods_uuid' => $goodsUuid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function findByOrderId($orderId){
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getMysql(''),
|
||||||
|
't_mall',
|
||||||
array(
|
array(
|
||||||
'order_id' => $orderId
|
'order_id' => $orderId
|
||||||
)
|
)
|
||||||
@ -39,53 +50,29 @@ class Mall extends BaseModel {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function updatePrice($orderId, $price) {
|
public static function modifyPrice($goodsUuid, $price) {
|
||||||
self::internalUpdate(
|
|
||||||
$orderId,
|
|
||||||
array(
|
|
||||||
'update_price' => $price,
|
|
||||||
'update_time' => myself()->_getNowTime(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function buyOk($orderId) {
|
|
||||||
self::internalUpdate(
|
|
||||||
$orderId,
|
|
||||||
array(
|
|
||||||
'status' => self::BUY_OK_STATE,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function cancel($orderId) {
|
|
||||||
self::internalUpdate(
|
|
||||||
$orderId,
|
|
||||||
array(
|
|
||||||
'status' => self::CANCEL_STATE,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function internalUpdate($orderId, $fieldsKv){
|
|
||||||
SqlHelper::upsert
|
|
||||||
(myself()->_getMysql(''),
|
|
||||||
't_market',
|
|
||||||
array(
|
|
||||||
'order_id' => $orderId
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'order_id' => $orderId,
|
|
||||||
'createtime' => myself()->_getNowTime(),
|
|
||||||
'modifytime' => myself()->_getNowTime(),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
SqlHelper::update
|
SqlHelper::update
|
||||||
(myself()->_getMysql(''),
|
(myself()->_getMysql(''),
|
||||||
't_market',
|
't_mall',
|
||||||
array(
|
array(
|
||||||
'order_id' => $orderId
|
'goods_uuid' => $goodsUuid
|
||||||
),
|
),
|
||||||
$fieldsKv
|
array(
|
||||||
|
'price' => $price
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function cancel($goodsUuid) {
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getMysql(''),
|
||||||
|
't_mall',
|
||||||
|
array(
|
||||||
|
'goods_uuid' => $goodsUuid
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'status' => self::CANCEL_STATE
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user