commit
803c76f7c0
@ -20,6 +20,7 @@ use app\common\model\store_product_unit\StoreProductUnit;
|
|||||||
class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public $list;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 设置搜索条件
|
* @notes 设置搜索条件
|
||||||
@ -46,17 +47,25 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return BeforehandOrderCartInfo::where($this->searchWhere)
|
if($this->request->get('top_cate')){
|
||||||
|
$product_id=BeforehandOrderCartInfo::where($this->searchWhere)->column('product_id');
|
||||||
|
$ids=StoreProduct::where('id', 'in', $product_id)->where('top_cate_id',$this->request->get('top_cate'))->column('id');
|
||||||
|
if($ids){
|
||||||
|
$this->searchWhere[] = ['product_id','in',$ids];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$list = BeforehandOrderCartInfo::where($this->searchWhere)
|
||||||
->field(['id', 'bhoid', 'uid', 'is_buyer', 'buyer_uid', 'product_id', 'attr_value_id', 'is_pay', 'purchase', 'price', 'total_price', 'cart_num', 'mark'])
|
->field(['id', 'bhoid', 'uid', 'is_buyer', 'buyer_uid', 'product_id', 'attr_value_id', 'is_pay', 'purchase', 'price', 'total_price', 'cart_num', 'mark'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,unit')->withTrashed()->find();
|
$find = StoreProduct::where('id', $item['product_id'])->field('top_cate_id,store_name,image,unit')->withTrashed()->find();
|
||||||
$item->unit_name = StoreProductUnit::where('id', $find->unit)->value('name');
|
$item->unit_name = StoreProductUnit::where('id', $find->unit)->value('name');
|
||||||
$item['warehouse_stock'] = WarehouseProductStorege::where('product_id', $item['product_id'])->value('nums') ?? 0;
|
$item['warehouse_stock'] = WarehouseProductStorege::where('product_id', $item['product_id'])->value('nums') ?? 0;
|
||||||
$item['store_name'] = $find['store_name'];
|
$item['store_name'] = $find['store_name'];
|
||||||
$item['image'] = $find['image'];
|
$item['image'] = $find['image'];
|
||||||
$item['unit'] = $find['unit'];
|
$item['unit'] = $find['unit'];
|
||||||
|
$item['top_cate_id'] = $find['top_cate_id'];
|
||||||
if ($item->bhoid) {
|
if ($item->bhoid) {
|
||||||
$status = PurchaseProductOffer::where('order_id', $item->bhoid)->where('product_id', $item->product_id)->value('status');
|
$status = PurchaseProductOffer::where('order_id', $item->bhoid)->where('product_id', $item->product_id)->value('status');
|
||||||
if ($status == 1) {
|
if ($status == 1) {
|
||||||
@ -68,6 +77,8 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe
|
|||||||
return $item;
|
return $item;
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
|
$this->list = $list;
|
||||||
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ use app\common\logic\BaseLogic;
|
|||||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
|
use app\common\model\store_category\StoreCategory;
|
||||||
use app\common\model\store_order\StoreOrder;
|
use app\common\model\store_order\StoreOrder;
|
||||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
@ -424,6 +425,15 @@ class BeforehandOrderLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
return BeforehandOrder::findOrEmpty($params['id'])->toArray();
|
$res = BeforehandOrder::findOrEmpty($params['id'])->toArray();
|
||||||
|
|
||||||
|
$ids = BeforehandOrderCartInfo::where('bhoid', $params['id'])->column('product_id');
|
||||||
|
$top_cate_ids = StoreProduct::where('id', 'in', $ids)->column('top_cate_id');
|
||||||
|
if ($top_cate_ids) {
|
||||||
|
$top_cate_list = array_unique($top_cate_ids);
|
||||||
|
$arr = StoreCategory::where('id', 'in', $top_cate_list)->field('name,id')->select();
|
||||||
|
$res['top_cate'] = $arr?->toArray();
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace app\admin\logic\purchase_product_offer;
|
|||||||
|
|
||||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\beforehand_order\BeforehandOrder;
|
||||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
@ -30,13 +31,17 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
|
$mark=$params['mark'] ?? '';
|
||||||
|
if($mark==''){
|
||||||
|
$mark=BeforehandOrderCartInfo::where('bhoid',$params['order_id'])->where('product_id',$params['product_id'])->value('mark');
|
||||||
|
}
|
||||||
PurchaseProductOffer::create([
|
PurchaseProductOffer::create([
|
||||||
'order_id' => $params['order_id'],
|
'order_id' => $params['order_id'],
|
||||||
'product_id' => $params['product_id'],
|
'product_id' => $params['product_id'],
|
||||||
'unit' => $params['unit'],
|
'unit' => $params['unit'],
|
||||||
'is_buyer' => $params['is_buyer'],
|
'is_buyer' => $params['is_buyer'],
|
||||||
'need_num' => $params['need_num'],
|
'need_num' => $params['need_num'],
|
||||||
'mark' => $params['mark'] ?? '',
|
'mark' => $mark,
|
||||||
'buyer_id' => $params['buyer_id'],
|
'buyer_id' => $params['buyer_id'],
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user