|
|
@@ -6,8 +6,7 @@ use think\Db;
|
|
|
use think\Loader ;
|
|
|
use app\common\controller\Api;
|
|
|
use app\common\model\ProductLists;
|
|
|
-use app\common\model\ProductMarket;
|
|
|
-use app\common\model\ProductOrder;
|
|
|
+use app\common\model\ProductTransfer;
|
|
|
use app\common\model\ProductsModel;
|
|
|
use app\common\model\ProductPopular;
|
|
|
use app\api\logic\OrderLogic;
|
|
|
@@ -64,23 +63,22 @@ class Product extends Api
|
|
|
* type_id 分类
|
|
|
* key_val 商品名称搜索
|
|
|
*/
|
|
|
- public function getTransferList(ProductMarket $productMarket, OrderLogic $orderLogic)
|
|
|
+ public function getTransferList(ProductTransfer $productTransfer, OrderLogic $orderLogic)
|
|
|
{
|
|
|
-
|
|
|
$sort = $this->request->post('sort/d', '');
|
|
|
$type_id = $this->request->post('type_id/s', '');
|
|
|
$key_val = $this->request->post('key_val/s', '');
|
|
|
- $order = 'a.price ASC';
|
|
|
- if($sort == 1) $order = 'a.price DESC';
|
|
|
- $map['product_market.status'] = $productMarket::Normal;
|
|
|
- if(!empty($type_id)) $map['product_market.type_id'] = $type_id;
|
|
|
- if(!empty($key_val)) $map['product_list.'.$this->lan.'_name'] = ['like', '%'.$key_val.'%'];
|
|
|
-
|
|
|
- $list = $productMarket
|
|
|
+ $order = 'price ASC';
|
|
|
+ if($sort == 1) $order = 'price desc';
|
|
|
+ $map['a.status'] = $productTransfer::Normal;
|
|
|
+ if(!empty($type_id)) $map['a.type_id'] = $type_id;
|
|
|
+ if(!empty($key_val)) $map['b.'.$this->lan.'_name'] = ['like', '%'.$key_val.'%'];
|
|
|
+
|
|
|
+ $list = $productTransfer
|
|
|
->alias('a')
|
|
|
->join("product_list b", "a.product_id = b.id", "left")
|
|
|
- ->field('a.id,'.'b.'.$this->lan.'_name as name,b.thum as img_url,a.price,a.product_id,a.type_id')
|
|
|
- ->where('a.status', $productMarket::Normal)
|
|
|
+ ->group('a.product_id')
|
|
|
+ ->field('a.id,'.'b.'.$this->lan.'_name as name,b.thum as img_url,min(a.price) as price,a.product_id,b.type_id')
|
|
|
->where($map)
|
|
|
->order($order)
|
|
|
->paginate($this->pageSize);
|
|
|
@@ -97,21 +95,23 @@ class Product extends Api
|
|
|
* type_id 分类
|
|
|
* key_val 商品名称搜索
|
|
|
*/
|
|
|
- public function getTransferCollectList(ProductMarket $productMarket, OrderLogic $orderLogic)
|
|
|
+ public function getTransferCollectList(ProductTransfer $productTransfer, OrderLogic $orderLogic)
|
|
|
{
|
|
|
$sort = $this->request->post('sort/d', '');
|
|
|
$type_id = $this->request->post('type_id/s', '');
|
|
|
$key_val = $this->request->post('key_val/s', '');
|
|
|
- $order = 'a.price ASC';
|
|
|
- if($sort == 1) $order = 'a.price DESC';
|
|
|
- $map['a.status'] = $productMarket::Normal;
|
|
|
+ $order = 'b.weigh desc';
|
|
|
+ if($sort == 1) $order = 'price DESC';
|
|
|
+ if($sort == 2) $order = 'price ASC';
|
|
|
+ $map['a.status'] = $productTransfer::Normal;
|
|
|
if(!empty($type_id)) $map['a.type_id'] = $type_id;
|
|
|
if(!empty($key_val)) $map['b.'.$this->lan.'_name'] = ['like', '%'.$key_val.'%'];
|
|
|
- $list = $productMarket->alias('a')
|
|
|
+ $list = $productTransfer->alias('a')
|
|
|
->join("product_list b", "a.product_id = b.id", "left")
|
|
|
- ->join("user_collect c", "c.market_id = a.id and c.user_id = {$this->auth->id}")
|
|
|
- ->field('a.id,'.'b.'.$this->lan.'_name as name,b.thum as img_url,a.price,a.product_id,a.type_id')
|
|
|
- ->where('a.status', $productMarket::Normal)
|
|
|
+ ->join("user_collect c", "c.product_id = a.product_id and c.user_id = {$this->auth->id}")
|
|
|
+ ->group('a.product_id')
|
|
|
+ ->field('a.id,'.'b.'.$this->lan.'_name as name,b.thum as img_url,min(a.price) as price,a.product_id,a.type_id')
|
|
|
+ ->where('a.status', $productTransfer::Normal)
|
|
|
->where($map)
|
|
|
->order($order)
|
|
|
->paginate($this->pageSize);
|
|
|
@@ -128,18 +128,19 @@ class Product extends Api
|
|
|
* type_id 分类
|
|
|
* key_val 商品名称搜索
|
|
|
*/
|
|
|
- public function getTransferDetail(ProductMarket $productMarket, OrderLogic $orderLogic)
|
|
|
+ public function getTransferDetail(ProductLists $productLists, OrderLogic $orderLogic)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
$ids = $this->request->post('ids/d', '');
|
|
|
- $list = $productMarket->with('products,producttransfer,collect')
|
|
|
- ->where('product_market.id', $ids)
|
|
|
- ->where('product_market.status', $productMarket::Normal)
|
|
|
+ $list = $productLists->with('producttransfer,collect')
|
|
|
+ ->where('product_list.id', $ids)
|
|
|
+ ->where('product_list.status', $productLists::Normal)
|
|
|
+ ->field('id,'.$this->lan .'_name as name,thum,details')
|
|
|
->find();
|
|
|
if(empty($list)) $this->error('数据不存在');
|
|
|
|
|
|
- $list->issue = $orderLogic::getProductIssue($list->product_id); //发行: 是产品的库存总量(卖出和没卖出的都算,最保险的计算方式是剩余库存量+所有用户的持有量;因为空投产品不是从库存出去的
|
|
|
- $list->circulation = $orderLogic::getProductCirculation($list->product_id); //流通: 所有用户的持有量
|
|
|
+ $list->issue = $orderLogic::getProductIssue($list->id); //发行: 是产品的库存总量(卖出和没卖出的都算,最保险的计算方式是剩余库存量+所有用户的持有量;因为空投产品不是从库存出去的
|
|
|
+ $list->circulation = $orderLogic::getProductCirculation($list->id); //流通: 所有用户的持有量
|
|
|
$this->success('', $list);
|
|
|
}
|
|
|
|
|
|
@@ -158,7 +159,7 @@ class Product extends Api
|
|
|
if($list){
|
|
|
$userCollect = Loader::model('UserCollect');
|
|
|
foreach ($list as &$item) {
|
|
|
- if($isCollect) $item['collect'] = $userCollect::where('user_id', $uid)->where('market_id', $item->id)->count();
|
|
|
+ if($isCollect) $item['collect'] = $userCollect::where('user_id', $uid)->where('product_id', $item->product_id)->count();
|
|
|
$item['issue'] = $orderLogic::getProductIssue($item->product_id); //发行: 是产品的库存总量(卖出和没卖出的都算,最保险的计算方式是剩余库存量+所有用户的持有量;因为空投产品不是从库存出去的
|
|
|
$item['circulation'] = $orderLogic::getProductCirculation($item->product_id); //流通: 所有用户的持有量
|
|
|
}
|