YqUserBidRelationService.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: z-yang
  5. * Date: 2019/1/19
  6. * Time: 10:08
  7. */
  8. namespace App\Modules\YunQi\Services;
  9. use App\Modules\YunQi\Models\YqUserBidRelation;
  10. class YqUserBidRelationService
  11. {
  12. public static function getByUidAndBid($uid,$bid){
  13. if(empty($uid) || empty($bid)){
  14. return false;
  15. }
  16. try{
  17. return YqUserBidRelation::where('uid',$uid)->where('from_bid',$bid)->select('id','to_bid')->first();
  18. }catch (\Exception $e){
  19. }
  20. return false;
  21. }
  22. public static function create($uid,$from_bid,$type,$to_bid){
  23. if(empty($uid) || empty($bid) || empty($type)){
  24. return false;
  25. }
  26. if(!self::getByUidAndBid($uid,$from_bid)){
  27. try{
  28. YqUserBidRelation::create([
  29. 'uid'=>$uid,
  30. 'from_bid'=>$from_bid,
  31. 'type'=>$type,
  32. 'to_bid'=>$to_bid
  33. ]);
  34. }catch (\Exception $e){
  35. }
  36. }
  37. return true;
  38. }
  39. }