订单查询和商品列表更新查询逻辑
This commit is contained in:
parent
fa84702c3b
commit
3eb1fb30b8
@ -8,6 +8,8 @@ use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\retail\Cashierclass;
|
||||
use app\common\model\retail\Cashierinfo;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
|
||||
/**
|
||||
* 零售订单列表
|
||||
@ -45,12 +47,12 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
$userId=$this->request->userId;
|
||||
if(!$userId) return [];
|
||||
return Cashierclass::where($this->searchWhere)->where('uid',$userId)
|
||||
return StoreOrder::where($this->searchWhere)->where('uid',$userId)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->each(function($item){
|
||||
$item['goods_list']=Cashierinfo::where('pid',$item['id'])->with('goodsName')->field('goods,nums,price sell')->limit(3)->select();
|
||||
$item['goods_list']=StoreOrderCartInfo::where('oid',$item['id'])->with('goodsName')->field('product_id,cart_num')->limit(3)->select();
|
||||
$item['goods_count']=count(explode(',',$item['cart_id']));
|
||||
})
|
||||
->toArray();
|
||||
@ -64,7 +66,7 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Cashierclass::where($this->searchWhere)->count();
|
||||
return StoreOrder::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -112,26 +112,14 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
|
||||
}
|
||||
$where[]=['store_id','=',$store_id];
|
||||
$data =StoreBranchProduct::where($this->searchWhere)->where($where)
|
||||
->field(['id', 'product_id','cate_id','store_name', 'store_id','price', 'bar_code','image','sales','store_info','delete_time'])
|
||||
return StoreBranchProduct::where($this->searchWhere)->where($where)
|
||||
->field(['id', 'product_id','cate_id','store_name', 'store_id','price', 'bar_code','image','sales','store_info','delete_time','unit'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->with(['className'])
|
||||
->with(['className','unitName'])
|
||||
->order($order)
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($data as $k=> &$v){
|
||||
$info= StoreProduct::alias('p')
|
||||
->leftJoin('store_product_unit t','t.id = p.unit')
|
||||
->where('p.id',$v['product_id'])
|
||||
->field('p.unit,t.name,t.is_bulk')->find()??[];
|
||||
if($info){
|
||||
$v['unit_name'] = $info['name']??'';
|
||||
$v['is_bulk'] = $info['is_bulk']??'';
|
||||
}else{
|
||||
unset($data[$k]);
|
||||
}
|
||||
}
|
||||
return array_values($data);
|
||||
|
||||
// return StoreProduct::where($this->searchWhere)->where($where)
|
||||
// ->field(['id', 'cate_id','store_name','unit', 'ot_price', 'bar_code','image','sales','store_info'])
|
||||
// ->limit($this->limitOffset, $this->limitLength)
|
||||
@ -191,23 +179,12 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$where[]=['store_id','=',$store_id];
|
||||
|
||||
$data =StoreBranchProduct::where($this->searchWhere)->where($where)
|
||||
->field(['id', 'product_id'])
|
||||
->field(['id', 'product_id','cate_id','store_name', 'store_id','price', 'bar_code','image','sales','store_info','delete_time','unit'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->with(['className','unitName'])
|
||||
->order($order)
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($data as $k=> &$v){
|
||||
$info= StoreProduct::alias('p')
|
||||
->leftJoin('store_product_unit t','t.id = p.unit')
|
||||
->where('p.id',$v['product_id'])
|
||||
->field('p.unit,t.name,t.is_bulk')->find()??[];
|
||||
if($info){
|
||||
$v['unit_name'] = $info['name']??'';
|
||||
$v['is_bulk'] = $info['is_bulk']??'';
|
||||
}else{
|
||||
unset($data[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return count($data);
|
||||
}
|
||||
|
@ -23,6 +23,11 @@ class StoreBranchProduct extends BaseModel
|
||||
|
||||
|
||||
|
||||
public function unitName()
|
||||
{
|
||||
return $this->hasOne(StoreProductUnit::class,'id','unit')->bind(['unit_name'=>'name','is_bulk']);
|
||||
}
|
||||
|
||||
|
||||
public function className()
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace app\common\model\store_order_cart_info;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
class StoreOrderCartInfo extends BaseModel
|
||||
@ -14,6 +14,6 @@ class StoreOrderCartInfo extends BaseModel
|
||||
|
||||
public function goodsName()
|
||||
{
|
||||
return $this->hasOne(StoreProduct::class,'id','product_id')->bind(['store_name','image','unit','price']);
|
||||
return $this->hasOne(StoreBranchProduct::class,'id','product_id')->bind(['store_name','image','unit','price']);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user