GamePayChannelLogic.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\v1\logic\center;
  3. use plugin\saiadmin\basic\BaseLogic;
  4. use plugin\saiadmin\exception\ApiException;
  5. use plugin\saiadmin\utils\Helper;
  6. use app\v1\model\center\GamePayChannel;
  7. use support\think\Db;
  8. /**
  9. * 游戏支付渠道逻辑层
  10. */
  11. class GamePayChannelLogic extends BaseLogic
  12. {
  13. /**
  14. * 构造函数
  15. */
  16. public function __construct()
  17. {
  18. $this->model = new GamePayChannel();
  19. }
  20. /**
  21. * 获取支付主体
  22. * @return array
  23. */
  24. public function getPaySubject()
  25. {
  26. return Db::connect('db_center')->name('pay_channel')->where('status', 1)->select()->toArray();
  27. }
  28. /**
  29. * 添加数据
  30. * @param $data
  31. * @return mixed
  32. */
  33. public function add($data): mixed
  34. {
  35. $gameId = $data['game_id'];
  36. $result =$this->model->where('game_id',$gameId)->select();
  37. if($result->isEmpty()){
  38. $this->model->save($data);
  39. }else{
  40. throw new ApiException('该游戏支付渠道已存在');
  41. }
  42. return $this->model->getKey();
  43. }
  44. }