链街Dcat后台
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.

54 lines
1.6 KiB

6 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\Admin\Repositories\ImsCjdcOrderMain as OrderMainModel;
  6. class ImsCjdcOrder extends Model
  7. {
  8. use HasDateTimeFormatter;
  9. protected $table = 'lanzu_order as order';
  10. public $timestamps = false;
  11. public function user()
  12. {
  13. return $this->hasOne('\App\Models\ImsCjdcUser','id','user_id');
  14. }
  15. public function store()
  16. {
  17. return $this->hasOne('\App\Models\LanzuStore','id','store_id');
  18. }
  19. public static function getOrdersData($goid,$oid)
  20. {
  21. $orders = ImsCjdcOrder::with('user')->with('store')
  22. ->where('order_main_id', $goid)->get()->toArray();
  23. if (!count($orders)){
  24. $orders = ImsCjdcOrder::with('user')->with('store')
  25. ->where('order_main_id', $oid)->get()->toArray();
  26. }
  27. if (count($orders)) {
  28. $show_refund = [];
  29. foreach ($orders as &$or) {
  30. if (substr($or['store']['logo'], 0, 4) != 'http') {
  31. $or['store']['logo'] = env('OSS_IMG_HOST') . '/' . $or['store']['logo'].'!thumbnail_100_q50';
  32. }
  33. $or['goods'] = LanzuOrderGoods::where('order_id', $or['id'])->get()->toArray();
  34. foreach ($or['goods'] as $goods){
  35. $show_refund[$goods['id']] = ['show_refund_2'=>true,'show_refund_3'=>false];
  36. }
  37. }
  38. }
  39. return ['orders'=>$orders,'show_refund'=>$show_refund];
  40. }
  41. public function orderMain()
  42. {
  43. return $this->belongsTo(new OrderMainModel,'order_main_id','global_order_id');
  44. }
  45. }