|
@@ -9,7 +9,7 @@ use think\Cache;
|
|
|
use think\Loader ;
|
|
use think\Loader ;
|
|
|
use fast\Asset;
|
|
use fast\Asset;
|
|
|
use app\common\model\ProductOrder;
|
|
use app\common\model\ProductOrder;
|
|
|
-use app\common\model\LedgerTeacChangeModel;
|
|
|
|
|
|
|
+use app\common\model\ProductLists;
|
|
|
use app\common\model\ProductPopular;
|
|
use app\common\model\ProductPopular;
|
|
|
use app\common\model\ProductTransfer;
|
|
use app\common\model\ProductTransfer;
|
|
|
|
|
|
|
@@ -51,6 +51,7 @@ class OrderLogic
|
|
|
return Loader::model('ProductOrder')->alias('a')
|
|
return Loader::model('ProductOrder')->alias('a')
|
|
|
->join("product_list b", "a.product_id = b.id", "left")
|
|
->join("product_list b", "a.product_id = b.id", "left")
|
|
|
->field('a.id,'.'b.'.$lan.'_name as name,b.thum as img_url,a.order_no')
|
|
->field('a.id,'.'b.'.$lan.'_name as name,b.thum as img_url,a.order_no')
|
|
|
|
|
+ ->where('b.is_show', ProductLists::Normal)
|
|
|
->where('a.product_id', $productId)
|
|
->where('a.product_id', $productId)
|
|
|
->where('a.user_id', $uid)
|
|
->where('a.user_id', $uid)
|
|
|
->where('a.status', ProductOrder::Paid)
|
|
->where('a.status', ProductOrder::Paid)
|
|
@@ -64,23 +65,21 @@ class OrderLogic
|
|
|
public static function getProductTransferOrder(string $orderId, int $uid, int $puid)//: array
|
|
public static function getProductTransferOrder(string $orderId, int $uid, int $puid)//: array
|
|
|
{
|
|
{
|
|
|
$productOrder = Loader::model('ProductOrder');
|
|
$productOrder = Loader::model('ProductOrder');
|
|
|
|
|
+ $productLists = Loader::model('ProductLists');
|
|
|
$productTransfer = Loader::model('ProductTransfer');
|
|
$productTransfer = Loader::model('ProductTransfer');
|
|
|
$userModel = Loader::model('UserModel');
|
|
$userModel = Loader::model('UserModel');
|
|
|
$ledgerWalletModel = Loader::model('LedgerWalletModel');
|
|
$ledgerWalletModel = Loader::model('LedgerWalletModel');
|
|
|
$ledgerTokenChangeModel = Loader::model('LedgerTokenChangeModel');
|
|
$ledgerTokenChangeModel = Loader::model('LedgerTokenChangeModel');
|
|
|
$result = $productTransfer::whereIn('id', $orderId)->where('status', ProductTransfer::Normal)->select();
|
|
$result = $productTransfer::whereIn('id', $orderId)->where('status', ProductTransfer::Normal)->select();
|
|
|
- if (count($result) != count(explode(",", $orderId))) {
|
|
|
|
|
- if(empty($order_info)) throw new Exception(__("订单不存在"));
|
|
|
|
|
- }
|
|
|
|
|
- //$totalAmount = 0; //总金额
|
|
|
|
|
|
|
+ if (count($result) != count(explode(",", $orderId))) if(empty($order_info)) throw new Exception(__("订单不存在"));
|
|
|
|
|
+
|
|
|
$time = time();
|
|
$time = time();
|
|
|
$endTime = config('market_transfer.lock_time');
|
|
$endTime = config('market_transfer.lock_time');
|
|
|
foreach ($result as $item) {
|
|
foreach ($result as $item) {
|
|
|
|
|
|
|
|
if($item->user_id == $uid) throw new Exception(__("不能购买自己寄售的商品"));
|
|
if($item->user_id == $uid) throw new Exception(__("不能购买自己寄售的商品"));
|
|
|
if($item->lock_uid != $uid && $item->lock_time + $endTime > $time) throw new Exception(__("茶权已被他人锁定,无法操作"));
|
|
if($item->lock_uid != $uid && $item->lock_time + $endTime > $time) throw new Exception(__("茶权已被他人锁定,无法操作"));
|
|
|
-
|
|
|
|
|
- //$totalAmount = bcadd($totalAmount, $item->price, 2);
|
|
|
|
|
|
|
+
|
|
|
//抢购订单
|
|
//抢购订单
|
|
|
$popular_order = $productOrder->where('id', $item->order_id)->find();
|
|
$popular_order = $productOrder->where('id', $item->order_id)->find();
|
|
|
|
|
|
|
@@ -95,7 +94,8 @@ class OrderLogic
|
|
|
//增加转让人余额
|
|
//增加转让人余额
|
|
|
$amount = bcsub($item->price, $item->fees, 2);
|
|
$amount = bcsub($item->price, $item->fees, 2);
|
|
|
$ledgerWalletModel->changeWalletAccount($item->user_id, Asset::TOKEN, $amount, $ledgerTokenChangeModel::Receive, $uid);
|
|
$ledgerWalletModel->changeWalletAccount($item->user_id, Asset::TOKEN, $amount, $ledgerTokenChangeModel::Receive, $uid);
|
|
|
- if($popular_order->popular_price > config('min_rwa_price')) {
|
|
|
|
|
|
|
+ $show = $productLists::where('id', $item->product_id)->value('is_show');
|
|
|
|
|
+ if(!empty($show) && $popular_order->popular_price > config('min_rwa_price')) {
|
|
|
//扣除转让人Rwa有效
|
|
//扣除转让人Rwa有效
|
|
|
$userModel::updateForRwaNum($item->user_id, $userModel::getByParentId($item->user_id), 1, '-');
|
|
$userModel::updateForRwaNum($item->user_id, $userModel::getByParentId($item->user_id), 1, '-');
|
|
|
//增加购买Rwa有效
|
|
//增加购买Rwa有效
|
|
@@ -110,8 +110,7 @@ class OrderLogic
|
|
|
$item->status = $productTransfer::Stop;
|
|
$item->status = $productTransfer::Stop;
|
|
|
$item->save();
|
|
$item->save();
|
|
|
}
|
|
}
|
|
|
- //$chabao = $ledgerWalletModel::getWalletChaBao($uid);
|
|
|
|
|
- //if(bccomp($totalAmount, $chabao, 2) > 0) throw new Exception(__("余额不足请前往充值"), 15001);
|
|
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|