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
* 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!
*
@ -1252,7 +1252,7 @@
* Call the given Closure / class@method and inject its dependencies.
*
* @param callable|string $callback
* @param \Illuminate\Container\array<string, mixed> $parameters
* @param array<string, mixed> $parameters
* @param string|null $defaultMethod
* @return mixed
* @throws \InvalidArgumentException
@ -11684,6 +11684,7 @@
/**
* Gets the decoded form or json request body.
*
* @throws JsonException When the body cannot be decoded to an array
* @static
*/
public static function getPayload()
@ -19129,6 +19130,27 @@
{
/** @var \Spatie\FlareClient\Flare $instance */
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 $messageLevel
* @param \Spatie\FlareClient\array<int, mixed> $metaData
* @param array<int, mixed> $metaData
* @return \Spatie\FlareClient\Flare
* @static
*/
@ -19322,7 +19344,7 @@
/**
*
*
* @param \Spatie\FlareClient\array<int, string> $fieldNames
* @param array<int, string> $fieldNames
* @return \Spatie\FlareClient\Flare
* @static
*/
@ -19398,7 +19420,7 @@
*
*
* @param string $groupName
* @param \Spatie\FlareClient\array<string, mixed> $properties
* @param array<string, mixed> $properties
* @return \Spatie\FlareClient\Flare
* @static
*/
@ -23099,8 +23121,8 @@ namespace {
/**
* Increment the given column's values by the given amounts.
*
* @param \Illuminate\Database\Query\array<string, float|int|numeric-string> $columns
* @param \Illuminate\Database\Query\array<string, mixed> $extra
* @param array<string, float|int|numeric-string> $columns
* @param array<string, mixed> $extra
* @return int
* @throws \InvalidArgumentException
* @static
@ -23114,8 +23136,8 @@ namespace {
/**
* Decrement the given column's values by the given amounts.
*
* @param \Illuminate\Database\Query\array<string, float|int|numeric-string> $columns
* @param \Illuminate\Database\Query\array<string, mixed> $extra
* @param array<string, float|int|numeric-string> $columns
* @param array<string, mixed> $extra
* @return int
* @throws \InvalidArgumentException
* @static

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

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

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

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

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

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

@ -11139,7 +11139,7 @@ h3.textt{
#card-steps .step {
display: none;
}
#card-steps .step.active {
#card-steps .step.active-step {
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 isSendSms = false;
var step = 1;
function nocomma(num) {
a = num.toString().replace(/\,/g, ''); // 1125, but a string, so convert it to number
return a.toString();
@ -270,6 +269,8 @@ jQuery(function ($) {
}
}, 500);
$(".next-step").bind('click', function () {
step++;
$(".step" + step).click();
@ -278,8 +279,8 @@ jQuery(function ($) {
$(".progress-step .step").click(function () {
$(".progress-step .step").removeClass('done');
$($(this).data('done')).addClass('done');
$("#card-steps .active").slideUp(300).removeClass('active');
$('#' + $(this).data('id')).slideDown(500).addClass('active');
$("#card-steps .active-step").slideUp(300).removeClass('active-step');
$('#' + $(this).data('id')).slideDown(500).addClass('active-step');
step = parseInt($(this).data('id').substr(4, 1));
if ($(this).data('id') == 'step3') {
$(".last-step").slideDown(300);
@ -289,18 +290,6 @@ jQuery(function ($) {
$(".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 {
.step{
display: none;
&.active{
&.active-step{
display: block;
}
}

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

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

@ -130,6 +130,14 @@
{{$pro->getPrice()}}
</span>
</b>
@if($pro->hasDiscount())
<del class="text-muted">
<span id="real-price">
{{number_format($pro->price)}}
</span>
{{config('app.currency_type')}}
</del>
@endif
</td>
</tr>
@if($pro->hasMeta('color'))
@ -392,5 +400,6 @@
<input type="hidden" id="qn" value="">
<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="discount" value="{{$pro->discountWithSign()}}">
@endsection

Loading…
Cancel
Save