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

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