Komp / Max Produkt,
This commit is contained in:
parent
a4c76d06fa
commit
78f43169c8
19 changed files with 347 additions and 51 deletions
|
|
@ -2,13 +2,15 @@
|
|||
namespace App\Services;
|
||||
|
||||
|
||||
use App\Mail\MailCheckout;
|
||||
use App\User;
|
||||
use App\Models\Product;
|
||||
use App\Models\Setting;
|
||||
use App\Mail\MailCheckout;
|
||||
use App\Models\ProductBuy;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\UserPayCredit;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\UserCreditMargin;
|
||||
use App\Models\UserPayCredit;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class Payment
|
||||
|
|
@ -117,6 +119,23 @@ class Payment
|
|||
]);
|
||||
}
|
||||
|
||||
public static function addProductBuy(User $user, Product $product){
|
||||
|
||||
if($product->max_buy && $product->max_buy_num > 0){
|
||||
$ProductBuy = ProductBuy::where('auth_user_id', $user->id)->where('product_id', $product->id)->first();
|
||||
if(!$ProductBuy){
|
||||
ProductBuy::create([
|
||||
'auth_user_id' => $user->id,
|
||||
'product_id' => $product->id,
|
||||
'num' => 1,
|
||||
]);
|
||||
}else{
|
||||
$ProductBuy->num = $ProductBuy->num+1;
|
||||
$ProductBuy->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){
|
||||
$send_link = false;
|
||||
|
||||
|
|
@ -129,8 +148,14 @@ class Payment
|
|||
if($shopping_order->shopping_order_items && $shopping_order->auth_user_id){
|
||||
foreach($shopping_order->shopping_order_items as $shopping_order_item){
|
||||
if($shopping_order_item->product){
|
||||
//add product when buy
|
||||
$user = User::findOrFail($shopping_order->auth_user_id);
|
||||
|
||||
if($shopping_order_item->product->max_buy && $shopping_order_item->product->max_buy_num > 0){
|
||||
self::addProductBuy($user, $shopping_order_item->product);
|
||||
}
|
||||
//product action
|
||||
if($shopping_order_item->product->action){
|
||||
$user = User::findOrFail($shopping_order->auth_user_id);
|
||||
$user->save();
|
||||
$send_link = true;
|
||||
//new date
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue