GreenUser.php 790 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\green\model;
  3. use think\Model;
  4. class GreenUser extends Model {
  5. //用户
  6. public function user(){
  7. return $this->hasOne('app\common\model\SystemUser','id','uid');
  8. }
  9. /**
  10. * 提现
  11. *
  12. * @param integer $miniapp_id
  13. * @param integer $uid
  14. * @param float $money
  15. * @return void
  16. */
  17. public static function cash(int $miniapp_id,int $uid,float $money){
  18. $info = self::where(['member_miniapp_id' => $miniapp_id, 'uid' => $uid])->find();
  19. if (empty($info)) {
  20. return;
  21. }
  22. $money = $money * 1000;
  23. if ($info->points < $money) {
  24. return;
  25. }
  26. $info->points = ['dec', $money];
  27. $info->update_time = time();
  28. return $info->save();
  29. }
  30. }