GmOrderModel.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * GmOrderModel.php UTF-8
  4. * 玩家游戏币消费表
  5. *
  6. * @date : 2018/5/18 17:30
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\model\finance;
  13. use huo\model\common\CommonModel;
  14. use huo\model\game\GameModel;
  15. class GmOrderModel extends CommonModel {
  16. protected $name = 'gm_order';
  17. // 开启自动写入时间戳字段
  18. protected $autoWriteTimestamp = true;
  19. public function mem() {
  20. return $this->belongsTo('huo\model\member\MemberModel', 'mem_id', 'id')
  21. ->field('id,username,nickname,agent_id');
  22. }
  23. public function game() {
  24. return $this->belongsTo(GameModel::className(), 'app_id', 'id');
  25. }
  26. /**
  27. * 创建游戏币消费订单
  28. * @param array $data
  29. *
  30. * @return bool|array
  31. */
  32. public function createOrder($data) {
  33. $_data = $data;
  34. if ($_obj = self::create($_data, true)) {
  35. $_data['id'] = $_obj->id;
  36. return $_data;
  37. } else {
  38. return false;
  39. }
  40. }
  41. }