You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
50 lines
1.5 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ImsCjdcOrder extends Model
|
|
{
|
|
use HasDateTimeFormatter;
|
|
protected $table = 'lanzu_order as order';
|
|
public $timestamps = false;
|
|
|
|
public function user()
|
|
{
|
|
return $this->hasOne('\App\Models\ImsCjdcUser','id','user_id');
|
|
}
|
|
|
|
public function store()
|
|
{
|
|
return $this->hasOne('\App\Models\LanzuStore','id','store_id');
|
|
}
|
|
|
|
public static function getOrdersData($goid,$oid)
|
|
{
|
|
|
|
$orders = ImsCjdcOrder::with('user')->with('store')
|
|
->where('order_main_id', $goid)->get()->toArray();
|
|
if (!count($orders)){
|
|
$orders = ImsCjdcOrder::with('user')->with('store')
|
|
->where('order_main_id', $oid)->get()->toArray();
|
|
}
|
|
if (count($orders)) {
|
|
$show_refund = [];
|
|
foreach ($orders as &$or) {
|
|
if (substr($or['store']['logo'], 0, 4) != 'http') {
|
|
$or['store']['logo'] = env('OSS_IMG_HOST') . '/' . $or['store']['logo'].'?thumbnail_28';
|
|
}
|
|
$or['goods'] = LanzuOrderGoods::where('order_id', $or['id'])->get()->toArray();
|
|
foreach ($or['goods'] as $goods){
|
|
$show_refund[$goods['id']] = ['show_refund_2'=>true,'show_refund_3'=>false];
|
|
}
|
|
}
|
|
}
|
|
return ['orders'=>$orders,'show_refund'=>$show_refund];
|
|
}
|
|
|
|
|
|
}
|