|
|
@@ -2,6 +2,8 @@
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
+use app\api\logic\OrderLogic;
|
|
|
+use app\api\logic\UserLogic;
|
|
|
use app\common\controller\Api;
|
|
|
use app\common\model\ProductOrder;
|
|
|
use app\common\model\LedgerSmhChangeModel;
|
|
|
@@ -72,26 +74,14 @@ class User extends Api
|
|
|
* param int $type_id 0总览 1转让中 2已转让 3存储中 4已赠送 5已提货
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function getNftList(ProductOrder $productOrder, ProductTransfer $productTransfer)
|
|
|
+ public function getNftList(ProductOrder $productOrder, ProductTransfer $productTransfer, UserLogic $userLogic)
|
|
|
{
|
|
|
$typeId = $this->request->post('type_id/d', 0);
|
|
|
$productId = $this->request->post('product_id/d', 0);
|
|
|
- $where = self::getNftWhere($typeId, $productId, $productOrder);
|
|
|
- $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.'.$this->lan.'_name as name,b.thum as img_url,a.price,a.status,a.order_no,a.type_id,c.'.$this->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', $this->auth->id)
|
|
|
- ->where($where)
|
|
|
- ->order('a.id DESC')
|
|
|
- ->paginate($this->pageSize);
|
|
|
- //地板价格
|
|
|
- foreach ($list as &$item) {
|
|
|
- if($item->price == 0) $item->floor_price = $productTransfer::getTransferMinPrice($item->product_id);
|
|
|
- }
|
|
|
+ //搜索条件
|
|
|
+ $where = $userLogic::getNftWhere($typeId, $productId, $productOrder);
|
|
|
+ //查询
|
|
|
+ $list = $userLogic::getUserNftList($productOrder, $productTransfer, $this->lan, $this->auth->id, $this->pageSize, $where);
|
|
|
$this->success('', $list);
|
|
|
}
|
|
|
|
|
|
@@ -100,18 +90,13 @@ class User extends Api
|
|
|
* param int $type_id 0总览 1转让中 2已转让 3存储中 4已赠送 5已提货
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function getMyNftList(ProductOrder $productOrder)
|
|
|
+ public function getMyNftList(ProductOrder $productOrder, UserLogic $userLogic)
|
|
|
{
|
|
|
$typeId = $this->request->post('type_id/d', 0);
|
|
|
- $where = self::getNftWhere($typeId, 0, $productOrder);
|
|
|
- $list = $productOrder->alias('a')
|
|
|
- ->join("product_list b", "b.id = a.product_id", "left")
|
|
|
- ->field('a.id as order_id,a.product_id,'.'b.'.$this->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', $this->auth->id)
|
|
|
- ->group('a.product_id')
|
|
|
- ->where($where)
|
|
|
- ->order('a.id DESC')
|
|
|
- ->paginate($this->pageSize);
|
|
|
+ //搜索条件
|
|
|
+ $where = $userLogic::getNftWhere($typeId, 0, $productOrder);
|
|
|
+ //查询
|
|
|
+ $list = $userLogic::getMyUserNftList($productOrder, $this->auth->id, $this->lan, $where, $this->pageSize);
|
|
|
$this->success('', $list);
|
|
|
}
|
|
|
|
|
|
@@ -119,28 +104,9 @@ class User extends Api
|
|
|
* 余额记录信息
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function getUserBalanceLog(LedgerTokenChangeModel $ledgerTokenChangeModel, LedgerWalletModel $ledgerWalletModel)
|
|
|
+ public function getUserBalanceLog(LedgerTokenChangeModel $ledgerTokenChangeModel, UserLogic $userLogic)
|
|
|
{
|
|
|
- // 启动事务
|
|
|
- Db::startTrans();
|
|
|
- try {
|
|
|
- $list['total'] = $ledgerTokenChangeModel::where('user_id', $this->auth->id)
|
|
|
- ->where('action', $ledgerTokenChangeModel::Share)
|
|
|
- ->sum("change_amount");
|
|
|
-
|
|
|
- $list['data'] = $ledgerTokenChangeModel::where('user_id', $this->auth->id)
|
|
|
- ->where('action', $ledgerTokenChangeModel::Share)
|
|
|
- ->order('id desc')
|
|
|
- ->paginate($this->pageSize);
|
|
|
-
|
|
|
- $list['statusList'] = $ledgerTokenChangeModel::getStatusList();
|
|
|
- // 提交事务
|
|
|
- Db::commit();
|
|
|
- } catch (Exception $e) {
|
|
|
- // 回滚事务
|
|
|
- Db::rollback();
|
|
|
- $this->error($e->getMessage());
|
|
|
- }
|
|
|
+ $list = $userLogic::getUserBalanceLog($ledgerTokenChangeModel, $this->auth->id, $this->pageSize);
|
|
|
$this->success('', $list);
|
|
|
}
|
|
|
|
|
|
@@ -148,16 +114,9 @@ class User extends Api
|
|
|
* 我的茶友
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function getChaList(UserModel $userModel)
|
|
|
+ public function getChaList(UserModel $userModel, UserLogic $userLogic)
|
|
|
{
|
|
|
- // 总推荐数
|
|
|
- $list['total'] = $userModel::where('parent_id', $this->auth->id)->count();
|
|
|
-
|
|
|
- // 直推列表
|
|
|
- $list['data'] = $userModel::where('parent_id', $this->auth->id)
|
|
|
- ->field("address,address_level,create_time,nickname,direct_super,REPLACE(phone, SUBSTRING(phone, 4, 4), '****') as phone")
|
|
|
- ->order('id desc')
|
|
|
- ->paginate($this->pageSize);
|
|
|
+ $list = $userLogic::getUserChaList($userModel, $this->auth->id, $this->pageSize);
|
|
|
$this->success('', $list);
|
|
|
}
|
|
|
|
|
|
@@ -199,88 +158,41 @@ class User extends Api
|
|
|
* 获取操作信息 购买、赠送、提货、转让
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function getOperateLog(ProductOrder $productOrder)
|
|
|
+ public function getOperateLog(ProductOrder $productOrder, UserLogic $userLogic)
|
|
|
{
|
|
|
$typeId = $this->request->post('type_id/d', 0);
|
|
|
$status = $this->request->post('status/d', 0);
|
|
|
$areaId = $this->request->post('area_id/s', 0);
|
|
|
- $where = self::getOperateWhere($typeId, $status, $areaId);
|
|
|
- $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.'.$this->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', $this->auth->id)
|
|
|
- ->where($where)
|
|
|
- ->order('a.id DESC')
|
|
|
- ->paginate($this->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();
|
|
|
+ //搜索条件
|
|
|
+ $where = $userLogic::getOperateWhere($typeId, $status, $areaId);
|
|
|
+ //查询
|
|
|
+ $list = $userLogic::getUserOperateLog($productOrder, $this->lan, $this->auth->id, $this->pageSize, $where);
|
|
|
$this->success('', $list);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Nft搜索条件
|
|
|
- * @return array
|
|
|
- */
|
|
|
- private static function getNftWhere(int $typeId, int $productId , object $productOrder): array
|
|
|
- {
|
|
|
- $where = [];
|
|
|
- switch ($typeId) {
|
|
|
- case 0:
|
|
|
- $where['a.status'] = ['=' , $productOrder::Paid];
|
|
|
- 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::Cancelled];
|
|
|
- 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;
|
|
|
+
|
|
|
+ //获取用户待支付订单数量
|
|
|
+ public function getWaitPayOrderCount(OrderLogic $orderLogic)
|
|
|
+ {
|
|
|
+ $count = $orderLogic::getWaitPayOrderCount($this->auth->id, config('market_transfer.lock_time'));
|
|
|
+ $this->success('', $count);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 操作记录搜索条件
|
|
|
- * @return array
|
|
|
- */
|
|
|
- private static function getOperateWhere(int $typeId, int $status, string $areaId)
|
|
|
+ //获取用户待支付订单
|
|
|
+ public function getWaitPayOrderList(OrderLogic $orderLogic)
|
|
|
{
|
|
|
- $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;
|
|
|
+ $list = $orderLogic::getWaitPayOrderList($this->auth->id, config('market_transfer.lock_time'), $this->pageSize, $this->lan);
|
|
|
+ $this->success('', $list);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ //取消用户待支付订单
|
|
|
+ public function setCancelWaitPayOrder(OrderLogic $orderLogic)
|
|
|
+ {
|
|
|
+ $transfer_id = $this->request->post('transfer_id/d', 0);
|
|
|
+ if(empty($transfer_id)) $this->error(__('Invalid parameters'));
|
|
|
+ $list = $orderLogic::setCancelWaitPayOrder($this->auth->id, $transfer_id);
|
|
|
+ $this->success('ok', $list);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|