12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- declare (strict_types = 1);
- namespace app\api\model\user;
- use app\api\service\User as UserService;
- use app\common\model\user\BalanceLog as BalanceLogModel;
- use Exception;
- use think\facade\Log;
- /**
- * 用户余额变动明细模型
- * Class BalanceLog
- * @package app\api\model\user
- */
- class BalanceLog extends BalanceLogModel
- {
- /**
- * 隐藏字段
- * @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();
- try {
- $log->save([
- 'user_id' => $userId,
- 'scene' => $scene,
- 'money' => $money,
- 'describe' => $describe,
- 'remark' => $remark,
- ]);
- }catch (Exception $e){
- Log::error('order_id::'.$remark.',desc::'.$describe.','.$e->getMessage());
- throw $e;
- //return false;
- }
- return true;
- }
- /**
- * 批量加入余额变更
- * @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;
- }
- }
|