123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- declare (strict_types = 1);
- namespace app\api\model\user;
- use app\api\model\User;
- use app\api\service\User as UserService;
- use app\common\model\user\WithdrawMoneyLog as WithdrawMoneyLogModel;
- use Exception;
- use think\facade\Db;
- use think\facade\Log;
- /**
- * 用户余额变动明细模型
- * Class BalanceLog
- * @package app\api\model\user
- */
- class WithdrawMoneyLog extends WithdrawMoneyLogModel
- {
- /**
- * 隐藏字段
- * @var array
- */
- protected $hidden = [
- 'store_id',
- ];
- /**
- * 获取账单明细列表
- * @return \think\Paginator
- * @throws \app\common\exception\BaseException
- * @throws \think\db\exception\DbException
- */
- public function getList()
- {
- // 当前用户ID
- $userId = UserService::getCurrentLoginUserId();
- // 获取列表数据
- return $this->where('user_id', '=', $userId)
- ->order(['create_time' => 'desc'])
- ->paginate(15);
- }
- /**
- * 记录分佣明细
- * @param $userId
- * @param $scene
- * @param $money
- * @param string $describe
- * @param string $remark
- * @return bool
- * @throws Exception
- */
- /* public static function addNewLog($userId,$scene,$money,$describe='',$remark=''){
- $log = new self();
- $user = User::find($userId);
- try {
- $log->save([
- 'user_id' => $userId,
- 'scene' => $scene,
- 'money' => $money,
- 'describe' => $describe,
- 'remark' => $remark,
- ]);
- //提现余额也要累加计算
- $user->can_withdraw_money = Db::raw('can_withdraw_money+'.$money);
- //可提现金额
- $user->ktxyj_amount = Db::raw('ktxyj_amount+'.$money);
- $user->save();
- }catch (Exception $e){
- Log::error('order_id::'.$remark.',desc::'.$describe.','.$e->getMessage());
- throw $e;
- }
- $user = User::find($userId);
- return $user->can_withdraw_money;
- }*/
- public static function sumGiveOutOrder(){
- $userId = UserService::getCurrentLoginUserId();
- return self::where('user_id',$userId)->where('scene',50)->sum('money');
- }
- /**
- * 批量加入余额变更
- * @param $lists
- * @return bool
- * @throws Exception
- */
- public static function addNewLogBatch($lists){
- $log = new self();
- try {
- $log->saveAll($lists);
- }catch (Exception $e){
- throw $e;
- //return false;
- }
- return true;
- }
- }
|