Compare commits

...

6 Commits

Author SHA1 Message Date
A1Gard 33912bce1f fixed css after cherry-pick again 7 months ago
A1Gard 93fef5ff04 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	public/js/app.js
#	public/js/theme.js
#	resources/js/customer.js
#	resources/views/website/card.blade.php
7 months ago
A1Gard 369b69f7fc fixed discount bug on problem
fixed shopping card step bugs
7 months ago
A1Gard bd9fb9f5e8 accepted for cherry pick changed 7 months ago
A1Gard 232c6f1d76 improved security for impex
(cherry picked from commit f1149b712a)
7 months ago
A1Gard e8234d01fe fixed change price error
(cherry picked from commit 1f43d04cb8)
7 months ago

@ -4,7 +4,7 @@
/** /**
* A helper file for Laravel, to provide autocomplete information to your IDE * A helper file for Laravel, to provide autocomplete information to your IDE
* Generated for Laravel 9.52.8. * Generated for Laravel 9.52.14.
* *
* This file should not be included in your code, only analyzed by your IDE! * This file should not be included in your code, only analyzed by your IDE!
* *
@ -1252,7 +1252,7 @@
* Call the given Closure / class@method and inject its dependencies. * Call the given Closure / class@method and inject its dependencies.
* *
* @param callable|string $callback * @param callable|string $callback
* @param \Illuminate\Container\array<string, mixed> $parameters * @param array<string, mixed> $parameters
* @param string|null $defaultMethod * @param string|null $defaultMethod
* @return mixed * @return mixed
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
@ -11684,6 +11684,7 @@
/** /**
* Gets the decoded form or json request body. * Gets the decoded form or json request body.
* *
* @throws JsonException When the body cannot be decoded to an array
* @static * @static
*/ */
public static function getPayload() public static function getPayload()
@ -19129,6 +19130,27 @@
{ {
/** @var \Spatie\FlareClient\Flare $instance */ /** @var \Spatie\FlareClient\Flare $instance */
return $instance->filterReportsUsing($filterReportsCallable); return $instance->filterReportsUsing($filterReportsCallable);
}
/**
*
*
* @param array<class-string<ArgumentReducer>|ArgumentReducer>|\Spatie\Backtrace\Arguments\ArgumentReducers|null $argumentReducers
* @static
*/
public static function argumentReducers($argumentReducers)
{
/** @var \Spatie\FlareClient\Flare $instance */
return $instance->argumentReducers($argumentReducers);
}
/**
*
*
* @static
*/
public static function withStackFrameArguments($withStackFrameArguments = true)
{
/** @var \Spatie\FlareClient\Flare $instance */
return $instance->withStackFrameArguments($withStackFrameArguments);
} }
/** /**
* *
@ -19229,7 +19251,7 @@
* *
* @param string $name * @param string $name
* @param string $messageLevel * @param string $messageLevel
* @param \Spatie\FlareClient\array<int, mixed> $metaData * @param array<int, mixed> $metaData
* @return \Spatie\FlareClient\Flare * @return \Spatie\FlareClient\Flare
* @static * @static
*/ */
@ -19322,7 +19344,7 @@
/** /**
* *
* *
* @param \Spatie\FlareClient\array<int, string> $fieldNames * @param array<int, string> $fieldNames
* @return \Spatie\FlareClient\Flare * @return \Spatie\FlareClient\Flare
* @static * @static
*/ */
@ -19398,7 +19420,7 @@
* *
* *
* @param string $groupName * @param string $groupName
* @param \Spatie\FlareClient\array<string, mixed> $properties * @param array<string, mixed> $properties
* @return \Spatie\FlareClient\Flare * @return \Spatie\FlareClient\Flare
* @static * @static
*/ */
@ -23099,8 +23121,8 @@ namespace {
/** /**
* Increment the given column's values by the given amounts. * Increment the given column's values by the given amounts.
* *
* @param \Illuminate\Database\Query\array<string, float|int|numeric-string> $columns * @param array<string, float|int|numeric-string> $columns
* @param \Illuminate\Database\Query\array<string, mixed> $extra * @param array<string, mixed> $extra
* @return int * @return int
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @static * @static
@ -23114,8 +23136,8 @@ namespace {
/** /**
* Decrement the given column's values by the given amounts. * Decrement the given column's values by the given amounts.
* *
* @param \Illuminate\Database\Query\array<string, float|int|numeric-string> $columns * @param array<string, float|int|numeric-string> $columns
* @param \Illuminate\Database\Query\array<string, mixed> $extra * @param array<string, mixed> $extra
* @return int * @return int
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @static * @static

@ -603,6 +603,9 @@ function showMeta($key, $value)
*/ */
function time2persian($date, $format = 'Y/m/d') function time2persian($date, $format = 'Y/m/d')
{ {
if ($date == null){
return '-';
}
$dt = new TDate(); $dt = new TDate();
return $dt->PDate($format, $date); return $dt->PDate($format, $date);
} }

@ -112,6 +112,9 @@ class ProductController extends Controller
$discount->amount = $request->discount['amount']; $discount->amount = $request->discount['amount'];
$discount->expire = date('Y-m-d',floor($request->discount['expire']/1000)); $discount->expire = date('Y-m-d',floor($request->discount['expire']/1000));
// $discount->code = $request->discount['code']; // $discount->code = $request->discount['code'];
if ($discount->expire == '1970-01-01 00:00:00'){
$discount->expire = null;
}
$discount->type = $request->discount['type']; $discount->type = $request->discount['type'];
$discount->save(); $discount->save();
} }

@ -375,9 +375,15 @@ class ImpexController extends Controller
} }
public function login(){ public function login(){
if (!auth()->check()){
return abort(403);
}
return \Auth::guard('customer')->loginUsingId(Customer::inRandomOrder()->first()->id); return \Auth::guard('customer')->loginUsingId(Customer::inRandomOrder()->first()->id);
} }
public function loginas($tel){ public function loginas($tel){
if (!auth()->check()){
return abort(403);
}
return \Auth::guard('customer')->loginUsingId(Customer::whereMobile($tel)->first()->id); return \Auth::guard('customer')->loginUsingId(Customer::whereMobile($tel)->first()->id);
} }
} }

@ -85,7 +85,7 @@ class GatewayRedirectController
$proData = [ $proData = [
'count' => $buyCount, 'count' => $buyCount,
'quantity_id' => $id, 'quantity_id' => $id,
'price_total' => ($q->price * ($buyCount)), 'price_total' => ($product->getPurePriceDef($q->price) * ($buyCount)),
'data'=>json_encode($q), 'data'=>json_encode($q),
]; ];
$invoice->total_price += $proData['price_total']; $invoice->total_price += $proData['price_total'];
@ -107,16 +107,16 @@ class GatewayRedirectController
$product->save(); $product->save();
$proData = [ $proData = [
'count' => \request('count')[$item], 'count' => \request('count')[$item],
'price_total' => ($product->price * (\request('count')[$item])) 'price_total' => ($product->getPurePrice() * (\request('count')[$item]))
]; ];
if (isset(\request('data')[$item])){ if (isset(\request('data')[$item])){
$temp = json_decode(\request('data')[$item]); $temp = json_decode(\request('data')[$item]);
$qd = Quantity::find($temp->id); $qd = Quantity::find($temp->id);
$qd->count -= \request('count')[$item]; $qd->count -= \request('count')[$item];
$proData['data'] = \request('data')[$item]; $proData['data'] = \request('data')[$item];
$proData['price_total'] = $qd->price * \request('count')[$item]; $proData['price_total'] = $product->getPurePriceDef($qd->price) * \request('count')[$item];
$proData['quantity_id'] = $qd->id; $proData['quantity_id'] = $qd->id;
$product->price = $qd->price; $product->price = $product->getPurePriceDef($qd->price);
$qd->save(); $qd->save();
} }
$invoice->save(); $invoice->save();

@ -6,6 +6,7 @@ use Conner\Tagging\Taggable;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use phpDocumentor\Reflection\Types\Never_;
use Plank\Metable\Metable; use Plank\Metable\Metable;
use Spatie\Image\Manipulations; use Spatie\Image\Manipulations;
use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\HasMedia;
@ -116,6 +117,8 @@ use function App\Helpers\getSetting;
* @method static \Illuminate\Database\Eloquent\Builder|Product whereImageIndex($value) * @method static \Illuminate\Database\Eloquent\Builder|Product whereImageIndex($value)
* @property int $carat * @property int $carat
* @method static \Illuminate\Database\Eloquent\Builder|Product whereCarat($value) * @method static \Illuminate\Database\Eloquent\Builder|Product whereCarat($value)
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Discount> $activeDiscounts
* @property-read int|null $active_discounts_count
* @mixin \Eloquent * @mixin \Eloquent
*/ */
class Product extends Model implements HasMedia class Product extends Model implements HasMedia
@ -239,11 +242,34 @@ class Product extends Model implements HasMedia
return $this->hasMany(Discount::class, 'product_id', 'id'); return $this->hasMany(Discount::class, 'product_id', 'id');
} }
public function activeDiscounts()
{
return $this->hasMany(Discount::class, 'product_id', 'id')->where(function ($query) {
$query->where('expire', '>=', date('Y-m-d'))
->orWhereNull('expire');
});
}
public function discountWithSign()
{
if ($this->activeDiscounts()->count() > 0) {
$discount = $this->activeDiscounts()->first();
if ($discount->type == 'price') {
return ' - ' . $discount->amount;
} else {
return ' * ' . (( 100 - $discount->amount ) / 100);
}
} else {
return null;
}
}
public function getPurePrice() public function getPurePrice()
{ {
if ($this->discounts()->whereNull('code')->count() > 0) { if ($this->activeDiscounts()->whereNull('code')->count() > 0) {
$d = $this->discounts()->whereNull('code')->orderBy('id', 'desc')->first(); $d = $this->activeDiscounts()->whereNull('code')->orderBy('id', 'desc')->first();
if ($d->type == 'percent') { if ($d->type == 'percent') {
$price = $this->price - ($this->price * ($d->amount / 100)); $price = $this->price - ($this->price * ($d->amount / 100));
return $price; return $price;
@ -261,8 +287,8 @@ class Product extends Model implements HasMedia
*/ */
public function getPurePriceDef($def) public function getPurePriceDef($def)
{ {
if ($this->discounts()->whereNull('code')->count() > 0) { if ($this->activeDiscounts()->whereNull('code')->count() > 0) {
$d = $this->discounts()->whereNull('code')->orderBy('id', 'desc')->first(); $d = $this->activeDiscounts()->whereNull('code')->orderBy('id', 'desc')->first();
if ($d->type == 'percent') { if ($d->type == 'percent') {
$price = $def - ($def * ($d->amount / 100)); $price = $def - ($def * ($d->amount / 100));
return $price; return $price;
@ -280,6 +306,7 @@ class Product extends Model implements HasMedia
} }
return number_format($this->price) . ' ' . config('app.currency_type'); return number_format($this->price) . ' ' . config('app.currency_type');
} }
public function getPrice() public function getPrice()
{ {
if ($this->getPurePrice() == 0) { if ($this->getPurePrice() == 0) {

@ -10,7 +10,7 @@ class ProductObserver
// //
public function updated(Product $product){ public function updated(Product $product){
\Log::info('product update'); \Log::info('product update');
if ($product->wasChanged('price') && $p->price != null){ if ($product->wasChanged('price')){
\Log::info('product price update'); \Log::info('product price update');
$p = new Price(); $p = new Price();
$p->product_id = $product->id; $p->product_id = $product->id;

@ -11139,7 +11139,7 @@ h3.textt{
#card-steps .step { #card-steps .step {
display: none; display: none;
} }
#card-steps .step.active { #card-steps .step.active-step {
display: block; display: block;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,7 +1,6 @@
var data = require('./plugins/data'); var data = require('./plugins/data');
var isSendSms = false; var isSendSms = false;
var step = 1; var step = 1;
function nocomma(num) { function nocomma(num) {
a = num.toString().replace(/\,/g, ''); // 1125, but a string, so convert it to number a = num.toString().replace(/\,/g, ''); // 1125, but a string, so convert it to number
return a.toString(); return a.toString();
@ -270,6 +269,8 @@ jQuery(function ($) {
} }
}, 500); }, 500);
$(".next-step").bind('click', function () { $(".next-step").bind('click', function () {
step++; step++;
$(".step" + step).click(); $(".step" + step).click();
@ -278,8 +279,8 @@ jQuery(function ($) {
$(".progress-step .step").click(function () { $(".progress-step .step").click(function () {
$(".progress-step .step").removeClass('done'); $(".progress-step .step").removeClass('done');
$($(this).data('done')).addClass('done'); $($(this).data('done')).addClass('done');
$("#card-steps .active").slideUp(300).removeClass('active'); $("#card-steps .active-step").slideUp(300).removeClass('active-step');
$('#' + $(this).data('id')).slideDown(500).addClass('active'); $('#' + $(this).data('id')).slideDown(500).addClass('active-step');
step = parseInt($(this).data('id').substr(4, 1)); step = parseInt($(this).data('id').substr(4, 1));
if ($(this).data('id') == 'step3') { if ($(this).data('id') == 'step3') {
$(".last-step").slideDown(300); $(".last-step").slideDown(300);
@ -289,18 +290,6 @@ jQuery(function ($) {
$(".next-step").slideDown(300); $(".next-step").slideDown(300);
} }
}); });
if ($('.card-submit').length > 0){
if ($("input.transport:checked").length == 0){
$('.card-submit').removeAttr('disabled');
}else{
$("input.transport").bind('change',function () {
console.log('fire');
$('.card-submit').removeAttr('disabled');
});
}
}
}); });

@ -47,7 +47,7 @@
#card-steps { #card-steps {
.step{ .step{
display: none; display: none;
&.active{ &.active-step{
display: block; display: block;
} }
} }

@ -380,6 +380,12 @@ jQuery(function ($) {
}); });
try { try {
if ($('#qnt').length != 0) { if ($('#qnt').length != 0) {
let hasDiscount = false;
if ($("#discount").val() !== ''){
hasDiscount = true;
}
sizes = {}; sizes = {};
let qnt = JSON.parse($('#qnt').val()); let qnt = JSON.parse($('#qnt').val());
console.log(qnt); console.log(qnt);
@ -414,10 +420,13 @@ jQuery(function ($) {
txt = ''; txt = '';
let cl = ''; let cl = '';
for( const c of colors) { for( const c of colors) {
cl = colorNames[c.color]; let p = c.price;
// console.log(c.color,colorNames); if (hasDiscount){
p = eval(c.price + $("#discount").val())
}
txt += `<div data-id="${c.id}" txt += `<div data-id="${c.id}"
data-price="${c.price}" data-price="${p}"
data-real-price="${c.price}"
data-count="${c.count}" data-count="${c.count}"
data-image="${c.image}" data-image="${c.image}"
class="color"> class="color">
@ -436,6 +445,7 @@ jQuery(function ($) {
$(this).addClass('active'); $(this).addClass('active');
$("#qn").val($(this).data('id')); $("#qn").val($(this).data('id'));
$("#last-pricex").text(commafy($(this).data('price'))); $("#last-pricex").text(commafy($(this).data('price')));
$("#real-price").text(commafy($(this).data('real-price')));
$("#counting").text($(this).data('count')); $("#counting").text($(this).data('count'));
$(".product-count").attr('max',$(this).data('count')).val(1); $(".product-count").attr('max',$(this).data('count')).val(1);
}); });

@ -31,7 +31,7 @@
<div class="row"> <div class="row">
<div class="col-md-9"> <div class="col-md-9">
<div id="card-steps"> <div id="card-steps">
<div id="step1" class="step active"> <div id="step1" class="step active-step">
<div class="text-center" id="card"> <div class="text-center" id="card">
<table class="table table-hover table-responsive-lg" <table class="table table-hover table-responsive-lg"
id="card-table"> id="card-table">
@ -65,7 +65,9 @@
</a> </a>
</td> </td>
<td colspan="2"> <td colspan="2">
{{$pro->name}} <a href="{{route('product',$pro->slug)}}">
{{$pro->name}}
</a>
<input type="hidden" name="products[]" value="{{$pro->id}}"> <input type="hidden" name="products[]" value="{{$pro->id}}">
</td> </td>
<td colspan="2"> <td colspan="2">
@ -141,7 +143,9 @@
</a> </a>
</td> </td>
<td colspan="2"> <td colspan="2">
{{$qpro->product->name}} <a href="{{route('product',$qpro->product->slug)}}">
{{$pro->name}}
</a>
</td> </td>
<td colspan="2"> <td colspan="2">
@php($data = json_decode($qpro->data)) @php($data = json_decode($qpro->data))
@ -151,20 +155,21 @@
{{\App\Helpers\getColorName($data->color)}} {{\App\Helpers\getColorName($data->color)}}
</b> </b>
</span> </span>
{{-- <span class="badge bg-dark">--}} <span class="badge bg-dark">
{{-- {{$data->size}}--}} {{$data->size}}
{{-- </span>--}} </span>
</td> </td>
<td colspan="2" class="price-td" data-price="{{$qpro->price}}"> <td colspan="2" class="price-td"
data-price="{{$qpro->product->getPurePriceDef($qpro->price)}}">
@if($qpro->price == 0) @if($qpro->price == 0)
{{__("We call you about price soon.")}} {{__("We call you about price soon.")}}
@else @else
<span class="price"> <span class="price">
{{number_format($qpro->price)}} {{number_format($qpro->product->getPurePriceDef($qpro->price))}}
</span> </span>
{{config('app.currency_type')}} {{config('app.currency_type')}}
@endif @endif
@php($tot = $tot + $qpro->price) @php($tot = $tot + $qpro->product->getPurePriceDef($qpro->price))
</td> </td>
<td colspan="2"> <td colspan="2">
<div class="product-count"> <div class="product-count">
@ -194,19 +199,16 @@
@endforeach @endforeach
</table> </table>
</div> </div>
@if(\App\Helpers\getSetting('reserve') != null ) <div class="alert alert-success text-center">
شما می‌توانید محصولات را رزرو کنید , برای اینکار به مرحله بعدی بروید و
<div class="alert alert-success text-center"> <b>
شما می‌توانید محصولات را رزرو کنید , برای اینکار به مرحله بعدی بروید و گزینه فعال سازی
<b> حالت
گزینه فعال سازی رزرو
حالت </b>
رزرو
</b>
را انتخاب کنید را انتخاب کنید
</div> </div>
@endif
</div> </div>
<div id="step2" class="step"> <div id="step2" class="step">
@if(count($transports) > 0) @if(count($transports) > 0)
@ -221,7 +223,6 @@
<input id="tns{{$k}}" type="radio" name="transport_id" <input id="tns{{$k}}" type="radio" name="transport_id"
data-price="{{$t->price}}" data-price="{{$t->price}}"
value="{{$t->id}}" value="{{$t->id}}"
required
onclick="$('.product-count').change();" onclick="$('.product-count').change();"
@if ($t->is_default) checked @if ($t->is_default) checked
@endif class="form-check-input transport"> @endif class="form-check-input transport">
@ -269,17 +270,15 @@
@endforeach @endforeach
@endif @endif
</ul> </ul>
@if(\App\Helpers\getSetting('reserve') != null ) <div class="p-5 py-3" id="resv">
<div class="p-5 py-3" id="resv"> <div class="form-check form-switch">
<div class="form-check form-switch"> <input name="reserve" class="form-check-input" type="checkbox"
<input name="reserve" class="form-check-input" type="checkbox" role="switch"
role="switch" id="flexSwitchCheckDefault">
id="flexSwitchCheckDefault"> <label class="form-check-label"
<label class="form-check-label" for="flexSwitchCheckDefault">{{__("Reserve order for :H hours",['H'=>\App\Helpers\getSetting('reserve')])}}</label>
for="flexSwitchCheckDefault">{{__("Reserve order for :H hours",['H'=>\App\Helpers\getSetting('reserve')])}}</label>
</div>
</div> </div>
@endif </div>
@endif @endif
<div> <div>
@ -384,12 +383,12 @@
تکمیل اطلاعات تکمیل اطلاعات
</a> </a>
@else @else
<button type="submit" class="btn btn-success float-end my-2 w-100 card-submit" > <button type="submit" class="btn btn-success float-end me-3 ms-3">
<i class="far fa-credit-card"></i> <i class="far fa-credit-card"></i>
پرداخت از درگاه های آنلاین پرداخت از درگاه های آنلاین
</button> </button>
<button type="submit" class="btn btn-secondary float-end w-100 card-submit" name="nopay" <button type="submit" class="btn btn-secondary float-end " name="nopay"
value="no-payment" > value="no-payment">
<i class="far fa-credit-card"></i> <i class="far fa-credit-card"></i>
ثبت سفارش پرداخت اعتباری + آنلاین ثبت سفارش پرداخت اعتباری + آنلاین
</button> </button>

@ -130,6 +130,14 @@
{{$pro->getPrice()}} {{$pro->getPrice()}}
</span> </span>
</b> </b>
@if($pro->hasDiscount())
<del class="text-muted">
<span id="real-price">
{{number_format($pro->price)}}
</span>
{{config('app.currency_type')}}
</del>
@endif
</td> </td>
</tr> </tr>
@if($pro->hasMeta('color')) @if($pro->hasMeta('color'))
@ -392,5 +400,6 @@
<input type="hidden" id="qn" value=""> <input type="hidden" id="qn" value="">
<input type="hidden" id="qnt" value='{!! $pro->quantities()->orderBy('price')->get();!!}'> <input type="hidden" id="qnt" value='{!! $pro->quantities()->orderBy('price')->get();!!}'>
<input type="hidden" id="colors" value='{!! json_encode( \App\Helpers\getColors()) !!}'> <input type="hidden" id="colors" value='{!! json_encode( \App\Helpers\getColors()) !!}'>
<input type="hidden" id="discount" value="{{$pro->discountWithSign()}}">
@endsection @endsection

Loading…
Cancel
Save