| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- namespace app\api\logic;
- use Exception;
- use think\Env;
- use think\Cache;
- use think\Loader ;
- use fast\Asset;
- use app\common\model\ProductOrder;
- use app\common\model\LedgerTeacChangeModel;
- use app\common\model\ProductPopular;
- use app\common\model\ProductTransfer;
- //用户逻辑
- class UserLogic
- {
- //获取用户分享余额记录信息
- public static function getUserBalanceLog(object $ledgerTokenChangeModel, int $uid, int $pageSize): array
- {
- //总收益
- $list['total'] = $ledgerTokenChangeModel::where('user_id', $uid)->where('action', $ledgerTokenChangeModel::Share)->sum("change_amount");
- $list['data'] = $ledgerTokenChangeModel::where('user_id', $uid)
- ->where('action', $ledgerTokenChangeModel::Share)
- ->order('id desc')
- ->paginate($pageSize);
- $list['statusList'] = $ledgerTokenChangeModel::getStatusList();
- return $list;
- }
- //获取用户发行Nft列表
- public static function getUserNftList(object $productOrder, object $productTransfer, string $lan, int $uid, int $pageSize, array $where): object
- {
- $list = $productOrder->alias('a')
- ->join("product_list b", "b.id = a.product_id", "left")
- ->join("products c", "c.id = b.type_id", "left")
- ->join("product_transfer z", "a.id = z.order_id AND a.status=2", "left") //转让
- ->join("product_area d", "d.id = a.area_id", "left") //地区
- ->field('a.id as order_id,a.product_id,'.'b.'.$lan.'_name as name,b.thum as img_url,a.price,a.status,a.order_no,a.type_id,c.'.$lan.'_title as title,
- z.price as transfer_price,d.address,b.min_transfer_fee,b.max_transfer_fee,b.gift_fee,b.freight,b.is_transfer,b.is_gift,b.is_freight,b.is_storage,b.is_buying')
- ->where('a.user_id', $uid)
- ->where($where)
- ->order('a.id DESC')
- ->paginate($pageSize);
- //地板价格
- foreach ($list as &$item) {
- if($item->price == 0) $item->floor_price = $productTransfer::getTransferMinPrice($item->product_id);
- }
- return $list;
- }
- //获取自己发行的Nft列表
- public static function getMyUserNftList(object $productOrder, int $uid, string $lan, array $where, int $pageSize): object
- {
- return $productOrder->alias('a')
- ->join("product_list b", "b.id = a.product_id", "left")
- ->field('a.id as order_id,a.product_id,'.'b.'.$lan.'_name as name,b.thum as img_url,a.price,a.status,a.type_id, count(a.num) as hold_num')
- ->where('a.user_id', $uid)
- ->group('a.product_id')
- ->where($where)
- ->order('a.id DESC')
- ->paginate($pageSize);
- }
- //获取我的茶友好列表
- public static function getUserChaList(object $userModel, int $uid, int $pageSize): array
- {
- // 总推荐数
- $list['total'] = $userModel::where('parent_id', $uid)->count();
-
- // 直推列表
- $list['data'] = $userModel::where('parent_id', $uid)
- ->field("address,address_level,create_time,nickname,direct_super,REPLACE(phone, SUBSTRING(phone, 4, 4), '****') as phone")
- ->order('id desc')
- ->paginate($pageSize);
- return $list;
- }
- public static function getUserOperateLog(object $productOrder, string $lan, int $uid, int $pageSize, array $where): array
- {
- $list['data'] = $productOrder->alias('a')
- ->join("product_list b", "b.id = a.product_id", "left")
- ->join("product_area d", "d.id = a.area_id", "left") //地区
- ->field('a.id as order_id,a.product_id,'.'b.'.$lan.'_name as name,b.thum as img_url,a.price,a.status,a.type_id,a.create_time,d.province,d.city,d.area,d.county')
- ->where('a.user_id', $uid)
- ->where($where)
- ->order('a.id DESC')
- ->paginate($pageSize);
- foreach ($list['data'] as &$item) {
- $item->address_id = '';
- if($item->province > 0) $item->address_id .= $item->province.'-';
- if($item->city > 0) $item->address_id .= $item->city.'-';
- if($item->area > 0) $item->address_id .= $item->area.'-';
- if($item->county > 0) $item->address_id .= $item->county.'-';
- $item->address_id = rtrim($item->address_id, '-');
- }
- $list['statusList'] = $productOrder::getStatusAll();
- return $list;
- }
- /**
- * 我的茶权搜索条件
- * @return array
- */
- public static function getNftWhere(int $typeId, int $productId , object $productOrder): array
- {
- $where = [];
- switch ($typeId) {
- case 0:
- //持有= 抢购+转让中+存储
- $where['a.status'] = ['in' , [$productOrder::Paid, $productOrder::Transferred, $productOrder::Freeze]];
- break;
- case 1:
- $where = ['a.type_id' => $productOrder::Transfer, 'a.status' => $productOrder::Transferred];
- break;
- case 2:
- $where = ['a.type_id' => $productOrder::Transfer, 'a.status' => $productOrder::Closure];
- break;
- case 3:
- $where = ['a.type_id' => $productOrder::Popular, 'a.status' => $productOrder::Closure];
- break;
- case 4:
- $where = ['a.type_id' => $productOrder::Giveaway, 'a.status' => $productOrder::Closure];
- break;
- case 5:
- $where = ['a.type_id' => $productOrder::Popular, 'a.status' => $productOrder::Shipped];
- break;
- }
- if($productId > 0) $where['a.product_id'] = ['=' , $productId];
- return $where;
- }
- /**
- * 操作记录搜索条件
- * @return array
- */
- public static function getOperateWhere(int $typeId, int $status, string $areaId)
- {
- $where = [];
- //类型
- if($typeId > 0 || $status > 0) $where = ['a.type_id' => $typeId, 'a.status' => $status];
- //编号Id
- if(!empty($areaId)){
- $arr = explode('-', $areaId);
- if(count($arr) > 0) {
- if(isset($arr[0])) $where['d.province'] = ['=', $arr[0]];
- if(isset($arr[1])) $where['d.city'] = ['=', $arr[1]];
- if(isset($arr[2])) $where['d.area'] = ['=', $arr[2]];
- if(isset($arr[3])) $where['d.county'] = ['=', $arr[3]];
- }
- }
- return $where;
- }
- }
|