BankAll.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 用户银行表 Table<ai_fastshop_bank>
  7. */
  8. namespace app\fastshop\model;
  9. use think\Model;
  10. class BankAll extends Model{
  11. protected $pk = 'id';
  12. protected $table = 'ai_fastshop_bank_all';
  13. protected $createTime = false;
  14. //用户
  15. public function user(){
  16. return $this->hasOne('app\common\model\SystemUser','id','uid');
  17. }
  18. /**
  19. * 增加有多少流水
  20. */
  21. public static function add(int $app_id,int $uid,float $money){
  22. $info = self::where(['uid' => $uid])->find();
  23. if(empty($info)){
  24. $data['uid'] = $uid;
  25. $data['account'] = $money;
  26. $data['member_miniapp_id'] = $app_id;
  27. return self::insert($data);
  28. }else{
  29. $info->account = ['inc',$money];
  30. return $info->save();
  31. }
  32. }
  33. }