| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace addons\Scratch\api\modules\v1\services;
- use addons\Scratch\common\enums\ScratchEnum;
- use addons\Scratch\common\models\ScratchCommissionLog;
- use addons\Scratch\common\models\ScratchLevelModel;
- use addons\Scratch\common\models\ScratchModel;
- use addons\Scratch\common\models\ScratchUserPartitionRelationshipModel;
- use common\components\Service;
- use common\enums\StatusEnum;
- use common\models\common\CapitalLog;
- use common\models\order\OrderDetail;
- /**
- * Class DefaultService
- * @package addons\Scratch\api\modules\v1\services
- */
- class DefaultService extends Service
- {
- /**
- * @param $mallId
- * @param $userData
- * @return mixed
- * @throws \ErrorException
- */
- public static function getInfo($mallId, $userData)
- {
- try {
- $Scratch = ScratchModel::getData($mallId, $userData->id);
- if (empty($Scratch)) {
- throw new \ErrorException('ccc');
- }
- $data = [
- 'id' => $userData->id ?? '',//会员id
- 'nickname' => $userData->nickname ?? '',//会员昵称
- 'mobile' => $userData->mobile ?? '',//手机号
- 'avatar_url' => $userData->avatar_url ?? '',//头像
- ];
- return $data;
- } catch (\ErrorException $errorException) {
- throw new \ErrorException($errorException->getMessage());
- } catch (\Exception $exception) {
- throw new \Exception($exception->getMessage());
- }
- }
- /**
- * @param $mallId
- * @param $userData
- * @param string $fromType
- * @param string $capitalType
- * @param int $page
- * @param int $limit
- * @param string[] $order
- * @return mixed
- * @throws \ErrorException
- */
- public static function getLogList($mallId, $userData, $fromType = [], $capitalType = '', $page = 1, $limit = 10, $order = 'id desc')
- {
- try {
- $params = [
- 'page' => $page,
- 'limit' => $limit,
- 'order' => $order,
- 'select' => 'id,change_num,source_table,source_table_id,from_type,capital_type,log_type',
- 'where' => [
- ['=', 'mall_id', $mallId],
- ['=', 'user_id', $userData->id],
- ['in', 'from_type', $fromType],
- ],
- ];
- if (!empty($capitalType)) {
- $params['where'][] = ['=', 'capital_type', ScratchEnum::getApiCapitalType($capitalType)];
- }
- $list = ScratchCommissionLog::listPage($params);
- return $list;
- } catch (\ErrorException $errorException) {
- throw new \ErrorException($errorException->getMessage());
- } catch (\Exception $exception) {
- throw new \Exception($exception->getMessage());
- }
- }
- }
|