123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- /**
- * AccountOrderModel.php UTF-8
- *
- *
- * @date : 2018/6/13 14:33
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : luowei <lw@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huoAccountDeal\model;
- use huo\model\common\CommonModel;
- use huo\model\game\GameModel;
- use huo\model\member\MemberModel;
- use huo\model\member\MemGameModel;
- use huolib\constant\OrderConst;
- class AccountOrderModel extends CommonModel {
- protected $name = 'account_order';
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = true;
- public function mg() {
- return $this->belongsTo(MemGameModel::className(), 'ags_id', 'id');
- }
- public function game() {
- return $this->belongsTo(GameModel::className(), 'app_id', 'id');
- }
- public function goods() {
- return $this->belongsTo(AccountGoodsModel::className(), 'ags_id', 'id');
- }
- public function seller() {
- return $this->belongsTo(MemberModel::className(), 'sell_mem_id', 'id');
- }
- public function buyer() {
- return $this->belongsTo(MemberModel::className(), 'buy_mem_id', 'id');
- }
- public function addData($data) {
- if (empty($data)) {
- return false;
- }
- if ($_obj = self::create($data, true)) {
- return $_obj->id;
- } else {
- return false;
- }
- }
- public function updateData($_data, $am_id) {
- $_map['id'] = $am_id;
- $_rs = self::update($_data, $_map, true);
- if (false == $_rs) {
- return false;
- } else {
- return true;
- }
- }
- public function getSellCnt($mem_id) {
- return $this->where(['sell_mem_id' => $mem_id, 'status' => OrderConst::PAY_STATUS_SUC])->count();
- }
- public function getBuyCnt($mem_id) {
- return $this->where(['buy_mem_id' => $mem_id, 'status' => OrderConst::PAY_STATUS_SUC])->count();
- }
- public function getStatus($order_id) {
- $_map['order_id'] = $order_id;
- $_status = $this->where($_map)->value('status');
- if (false == $_status) {
- return false;
- }
- $_rdata['status'] = $_status;
- return $_rdata;
- }
- public function getInfoByOrderId($order_id) {
- $_map['order_id'] = $order_id;
- $_info = $this->where($_map)->find();
- if (false === $_info) {
- return false;
- }
- if (is_object($_info)) {
- return $_info->toArray();
- } else {
- return $_info;
- }
- }
- /**
- * @param $order_id
- *
- * @return array|false
- */
- public function getDetail($order_id) {
- $_map['order_id'] = $order_id;
- $_data = $this->where($_map)->find();
- if (false == $_data) {
- return false;
- }
- if (is_object($_data)) {
- $_data = $_data->toArray();
- }
- return $_data;
- }
- /**
- * @param array $data
- * @param string $id
- *
- * @return bool
- */
- public function updateOrder($data, $id) {
- $_map['id'] = $id;
- $_data = $data;
- $_rs = self::update($_data, $_map, true);
- if (false == $_rs) {
- return false;
- } else {
- return true;
- }
- }
- }
|