Browse Source

Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix

master
Lemon 5 years ago
parent
commit
e17040441d
  1. 5
      app/Model/v3/Order.php
  2. 15
      app/Model/v3/OrderGoods.php
  3. 2
      app/Model/v3/OrderMain.php
  4. 18
      app/Service/v3/Implementations/OrderOnlineService.php
  5. 6
      app/Service/v3/Implementations/ShopCartService.php

5
app/Model/v3/Order.php

@ -27,4 +27,9 @@ class Order extends Model
{ {
return $this->belongsTo(User::class, 'user_id', 'id'); return $this->belongsTo(User::class, 'user_id', 'id');
} }
public function store()
{
return $this->belongsTo(Store::class, 'store_id', 'id');
}
} }

15
app/Model/v3/OrderGoods.php

@ -10,5 +10,20 @@ class OrderGoods extends Model
protected $casts = [ protected $casts = [
'spec' => 'array', 'spec' => 'array',
'tags' => 'array',
]; ];
protected $appends = [
'tags'
];
public function goods()
{
return $this->belongsTo(Goods::class, 'goods_id', 'id');
}
public function getTagsAttribute()
{
return Goods::query()->where(['id' => $this->attributes['goods_id']])->value('tags');
}
} }

2
app/Model/v3/OrderMain.php

@ -26,7 +26,7 @@ class OrderMain extends Model
public function getPayTimeTextAttribute() public function getPayTimeTextAttribute()
{ {
return date('Y-m-d H:i:s', $this->attributes['time_pay']);
return date('Y-m-d H:i:s', $this->attributes['pay_time']);
} }
public function getStateTextAttribute() public function getStateTextAttribute()

18
app/Service/v3/Implementations/OrderOnlineService.php

@ -2,6 +2,7 @@
namespace App\Service\v3\Implementations; namespace App\Service\v3\Implementations;
use App\Model\v3\Order;
use App\Model\v3\OrderMain; use App\Model\v3\OrderMain;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\OrderOnlineServiceInterface; use App\Service\v3\Interfaces\OrderOnlineServiceInterface;
@ -23,11 +24,16 @@ class OrderOnlineService implements OrderOnlineServiceInterface
public function detailByUser($orderMainId, $userId) public function detailByUser($orderMainId, $userId)
{ {
return OrderMain::query()
->where(['id' => $orderMainId])
->with(['orders' => function($query) {
return $query->with(['orderGoods']);
}])
->first()->toArray();
$orderMain = OrderMain::with(['market'])->find($orderMainId);
$orders = Order::query()
->where(['order_main_id' => $orderMainId, 'user_id' => $userId])
->with([
'orderGoods',
'store'
])
->get()->toArray();
return ['order_main' => $orderMain, 'orders' => $orders];
} }
} }

6
app/Service/v3/Implementations/ShopCartService.php

@ -16,6 +16,9 @@ class ShopCartService implements ShopCartServiceInterface
$query->with('goods'); $query->with('goods');
}])->whereIn('id',$storeIds) }])->whereIn('id',$storeIds)
->get(); ->get();
foreach ($res as &$k){
$k->subtotal = '99.90';
}
return $res; return $res;
} }
@ -31,6 +34,9 @@ class ShopCartService implements ShopCartServiceInterface
$query->with('goods'); $query->with('goods');
}])->whereIn('id',$storeIds) }])->whereIn('id',$storeIds)
->get(); ->get();
foreach ($res as &$k){
$k->subtotal = '99.90';
}
return $res; return $res;
} }

Loading…
Cancel
Save