'支付宝', 2 => '微信']; const AUDIT = [0 => '待审核', 1 => '审核通过', 2 => '审核不通过']; const PAYSTATE = [0 => '待打款', 1 => '已打款', 2 => '打款失败', 3 => '打款中']; const PAY_TYPE = [1 => '支付宝', 2 => '微信']; protected $autoWriteTimestamp = false; protected $append = ['transaction_type_text', 'audit_text', 'pay_state_text', 'pay_type_text', 'admin_name']; protected $auto = ['create_time']; public function getAdminNameAttr($value) { $admin = UserStore::where('store_user_id', $this->admin_id)->find(); if ($admin) { return $admin->user_name ?? ''; } return ''; } public function getList($fc_user_id) { return $this->where('fc_user_id', '=', $fc_user_id) ->paginate(); } //已提现佣金 public function ytxyjAmountSum($user_id) { $amount = $this->where('user_id', $user_id)->where('audit', 'in', [0, 1])->where('pay_state', 'in', [0, 1])->sum('amount'); return $amount; } // public function getCreateTimeAttr($time) // { // return $time > 0 ? date("Y-m-d H:i:s", $time) : ''; // } public function getPayTypeTextAttr($value) { return self::PAY_TYPE[$this->pay_type] ?? '-'; } public function getTransactionTypeTextAttr($value) { return self::TRANSACTION_TYPE[$this->transaction_type] ?? '-'; } public function getAuditTextAttr($value) { return self::AUDIT[$this->audit] ?? '-'; } public function getPayStateTextAttr($value) { return self::PAYSTATE[$this->pay_state] ?? '-'; } /** * 关联用户 * @return \think\model\relation\hasOne */ public function user() { return $this->hasOne('app\common\model\User', 'user_id', 'user_id'); } public static function makeTransactionNo() { return "TX".date('YmdHis') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 3); } public static function makePayTransactionNo() { return "DK".date('YmdHis') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 4); } /** * 计算本次提现个人所得税 * @param $x *当月累计佣金提现 * @param $hasHandle *本月已缴个税 * @return int|string */ public static function calculatorTax($x,$hasHandle){ if (is_debug() == true){ /* $x1 = 0.8;$x2 = 2;$x3 = 8; $x4 = 16; $y1 = 0.8;$y2 = 1.2;$y3 = 2;*/ $x1 = 800;$x2 = 4000;$x3 = 25000; $x4 = 62500; $y1 = 800;$y2 = 2000;$y3 = 7000; }else{ $x1 = 800;$x2 = 4000;$x3 = 25000; $x4 = 62500; $y1 = 800;$y2 = 2000;$y3 = 7000; } $tax = 0; if ( $x <= $x1){ return $tax; } if ($x > $x1 && $x <= $x2){ $tax0 =helper::bcsub( $x ,$y1,4); $tax =helper::bcmul( $tax0 ,0.2,4); } if ($x > $x2 && $x <= $x3){ $tax = helper::bcmul( $x ,0.16,4); } if ($x > $x3 && $x <= $x4){ $tax0 =helper::bcmul( $x ,0.24,4); $tax =helper::bcsub( $tax0 ,$y2,4); } if ($x > $x4 ){ $tax0 =helper::bcmul( $x ,0.32,4); $tax =helper::bcsub( $tax0 ,$y3,4); } $tmpTax = helper::bcsub($tax , $hasHandle,4); //向上取两位小数0.111->0.12 return bcdiv(strval(ceil($tmpTax * 100)),"100",2); /* $tax = 0; if ( $x <= 800){ return $tax; } if ($x > 800 && $x <= 4000){ $tax0 =helper::bcsub( $x ,800,2); $tax =helper::bcmul( $tax0 ,0.2,2); } if ($x > 4000 && $x <= 25000){ $tax = helper::bcmul( $x ,0.16,2); } if ($x > 25000 && $x <= 62500){ $tax0 =helper::bcmul( $x ,0.24,2); $tax =helper::bcsub( $tax0 ,2000,2); } if ($x > 62500 ){ $tax0 =helper::bcmul( $x ,0.32,2); $tax =helper::bcsub( $tax0 ,7000,2); } return helper::bcsub($tax , $hasHandle,2);*/ } }