|
|
@@ -10,6 +10,7 @@ use app\common\model\LedgerWalletModel;
|
|
|
use app\common\model\UserArea;
|
|
|
use app\common\model\UserModel;
|
|
|
use app\common\model\LedgerTokenChangeModel;
|
|
|
+use app\common\model\ProductTransfer;
|
|
|
use app\common\model\OfflineRechargeRecordModel;
|
|
|
use app\api\logic\OrderLogic;
|
|
|
use app\api\logic\MarketLogic;
|
|
|
@@ -178,7 +179,7 @@ class Order extends Api
|
|
|
|
|
|
|
|
|
//赠送
|
|
|
- public function giveaway(ProductOrder $productOrder, UserModel $userModel, LedgerWalletModel $ledgerWalletModel)
|
|
|
+ public function giveaway(ProductOrder $productOrder, UserModel $userModel, LedgerWalletModel $ledgerWalletModel, ProductTransfer $productTransfer)
|
|
|
{
|
|
|
$params = $this->request->post();
|
|
|
$validate = \think\Loader::validate('Order');
|
|
|
@@ -193,9 +194,11 @@ class Order extends Api
|
|
|
$user = $userModel->getByAddress($params['address']);
|
|
|
if(empty($user)) throw new Exception(__("赠送用户不存在"));
|
|
|
if($user['id'] == $order_info['user_id']) throw new Exception(__("赠送用户不能是自己"));
|
|
|
-
|
|
|
+ //手续费
|
|
|
+ $price = $order_info->gift_fee> 0? $order_info['price']: $productTransfer::getTransferMinPrice($order_info->product_id);
|
|
|
+ $fees = bcmul($price, bcdiv($order_info->gift_fee, 100, 2), 2);
|
|
|
+ //余额记录
|
|
|
$chabao = $ledgerWalletModel::getWalletChaBao($this->auth->id);
|
|
|
- $fees = $order_info->gift_fee> 0? bcmul($order_info['price'], bcdiv($order_info->gift_fee, 100, 2), 2): 0;
|
|
|
if(bccomp($fees, $chabao, 2) > 0) throw new Exception(__("余额不足请前往充值"), 15001);
|
|
|
|
|
|
//添加记录
|