链街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.

56 lines
1.7 KiB

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
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 static $tableName = 'lanzu_order';
  12. public function user()
  13. {
  14. return $this->hasOne('\App\Models\ImsCjdcUser','id','user_id');
  15. }
  16. public function store()
  17. {
  18. return $this->hasOne('\App\Models\LanzuStore','id','store_id');
  19. }
  20. public static function getOrdersData($goid,$oid)
  21. {
  22. $orders = ImsCjdcOrder::with('user')->with('store')
  23. ->where('order_main_id', $goid)->get()->toArray();
  24. if (!count($orders)){
  25. $orders = ImsCjdcOrder::with('user')->with('store')
  26. ->where('order_main_id', $oid)->get()->toArray();
  27. }
  28. if (count($orders)) {
  29. $show_refund = [];
  30. foreach ($orders as &$or) {
  31. if (substr($or['store']['logo'], 0, 4) != 'http') {
  32. $or['store']['logo'] = env('OSS_IMG_HOST') . '/' . $or['store']['logo'].'!thumbnail_100_q50';
  33. }
  34. $or['goods'] = LanzuOrderGoods::where('order_id', $or['id'])->get()->toArray();
  35. foreach ($or['goods'] as $goods){
  36. $show_refund[$goods['id']] = ['show_refund_2'=>true,'show_refund_3'=>false];
  37. }
  38. }
  39. }
  40. return ['orders'=>$orders,'show_refund'=>$show_refund];
  41. }
  42. public function orderMain()
  43. {
  44. return $this->belongsTo(new OrderMainModel,'order_main_id','global_order_id');
  45. }
  46. }