Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev
This commit is contained in:
commit
01ae705dbf
@ -32,6 +32,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
'=' => ['product_id', 'cate_id','store_id','status'],
|
'=' => ['product_id', 'cate_id','store_id','status'],
|
||||||
'%pipe_like%' => ['store_name_code'=>'store_name|bar_code'],
|
'%pipe_like%' => ['store_name_code'=>'store_name|bar_code'],
|
||||||
'%like%' => ['store_name'],
|
'%like%' => ['store_name'],
|
||||||
|
'<='=> ['stock'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +48,6 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$status = $this->params['status'] ?? '';
|
|
||||||
$class_all=$this->request->get('class_all');
|
$class_all=$this->request->get('class_all');
|
||||||
$where=[];
|
$where=[];
|
||||||
if($class_all){
|
if($class_all){
|
||||||
@ -69,17 +69,6 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->adminInfo['store_id']);
|
$query->where('store_id', $this->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
->when(!empty($status), function ($query) use ($status) {
|
|
||||||
if ($status == 1) {
|
|
||||||
$query->where('status', $status);
|
|
||||||
} elseif ($status == 2) {
|
|
||||||
$query->where('status', 0);
|
|
||||||
} elseif ($status == 3) {
|
|
||||||
$query->where('stock', '<=', 0);
|
|
||||||
} elseif ($status == 4) {
|
|
||||||
$query->where('stock', '<', 10)->where('stock', '>', 0);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['sort' => 'desc','stock'=>'desc','id' => 'desc'])
|
->order(['sort' => 'desc','stock'=>'desc','id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
@ -101,22 +90,10 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
*/
|
*/
|
||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
$status = $this->params['status'] ?? '';
|
|
||||||
return StoreBranchProduct::where($this->searchWhere)
|
return StoreBranchProduct::where($this->searchWhere)
|
||||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->adminInfo['store_id']);
|
$query->where('store_id', $this->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
->when(!empty($status), function ($query) use ($status) {
|
|
||||||
if ($status == 1) {
|
|
||||||
$query->where('status', $status);
|
|
||||||
} elseif ($status == 2) {
|
|
||||||
$query->where('status', 0);
|
|
||||||
} elseif ($status == 3) {
|
|
||||||
$query->where('stock', '<=', 0);
|
|
||||||
} elseif ($status == 4) {
|
|
||||||
$query->where('stock', '<', 10)->where('stock', '>', 0);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ use app\common\lists\ListsSearchInterface;
|
|||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
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_unit\StoreProductUnit;
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,6 +57,9 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id,cart_info')->limit(3)->select()
|
->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id,cart_info')->limit(3)->select()
|
||||||
->each(function ($v) use ($item) {
|
->each(function ($v) use ($item) {
|
||||||
$find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->withTrashed()->find();
|
$find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->withTrashed()->find();
|
||||||
|
if(empty($find)){
|
||||||
|
$find = StoreProduct::where('id', $v['product_id'])->withTrashed()->find();
|
||||||
|
}
|
||||||
$v['store_name'] = $find['store_name'];
|
$v['store_name'] = $find['store_name'];
|
||||||
$v['image'] = $find['image'];
|
$v['image'] = $find['image'];
|
||||||
// $v['price'] = $find['price'];
|
// $v['price'] = $find['price'];
|
||||||
|
@ -83,8 +83,11 @@ class OrderLogic extends BaseLogic
|
|||||||
foreach ($cart_select as $k => $v) {
|
foreach ($cart_select as $k => $v) {
|
||||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find();
|
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find();
|
||||||
if (!$find) {
|
if (!$find) {
|
||||||
unset($cart_select[$k]);
|
// unset($cart_select[$k]);
|
||||||
continue;
|
// continue;
|
||||||
|
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id';
|
||||||
|
$find = StoreProduct::where(['id' => $v['product_id']])->field($field)->withTrashed()->find();
|
||||||
|
$cart_select[$k]['status'] = 1;//缺货标识
|
||||||
}
|
}
|
||||||
unset($cart_select[$k]['id']);
|
unset($cart_select[$k]['id']);
|
||||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||||
@ -252,10 +255,10 @@ class OrderLogic extends BaseLogic
|
|||||||
$goods_list[$k]['uid'] = $uid;
|
$goods_list[$k]['uid'] = $uid;
|
||||||
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
||||||
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
|
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
|
||||||
$StoreBranchProduct = StoreBranchProduct::where('id', $v['branch_product_id'])->withTrashed()->find();
|
// $StoreBranchProduct = StoreBranchProduct::where('id', $v['branch_product_id'])->withTrashed()->find();
|
||||||
if ($StoreBranchProduct['stock'] - $v['cart_num'] <= 0) {
|
// if ($StoreBranchProduct['stock'] - $v['cart_num'] <= 0) {
|
||||||
Db::name('store_product_cate')->where(['cate_id' => $StoreBranchProduct['cate_id'], 'store_id' => $params['store_id']])->update(['count' => 0]);
|
// Db::name('store_product_cate')->where(['cate_id' => $StoreBranchProduct['cate_id'], 'store_id' => $params['store_id']])->update(['count' => 0]);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
(new StoreOrderCartInfo())->saveAll($goods_list);
|
(new StoreOrderCartInfo())->saveAll($goods_list);
|
||||||
$where = ['is_pay' => 0];
|
$where = ['is_pay' => 0];
|
||||||
@ -422,6 +425,9 @@ class OrderLogic extends BaseLogic
|
|||||||
$find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id'])
|
$find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id'])
|
||||||
->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) {
|
->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) {
|
||||||
$find = StoreBranchProduct::where('product_id', $item['product_id'])->where('store_id', $find['store_id'])->find();
|
$find = StoreBranchProduct::where('product_id', $item['product_id'])->where('store_id', $find['store_id'])->find();
|
||||||
|
if(empty($find)){
|
||||||
|
$find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find();
|
||||||
|
}
|
||||||
$item['store_name'] = $find['store_name'];
|
$item['store_name'] = $find['store_name'];
|
||||||
$item['image'] = $find['image'];
|
$item['image'] = $find['image'];
|
||||||
$item['price'] = $find['price'];
|
$item['price'] = $find['price'];
|
||||||
|
@ -142,7 +142,7 @@ class StoreOrderController extends BaseAdminController
|
|||||||
$params = $this->request->post();
|
$params = $this->request->post();
|
||||||
if (
|
if (
|
||||||
$auth_code == '' && $pay_type != PayEnum::CASH_PAY && $pay_type != PayEnum::PURCHASE_FUNDS
|
$auth_code == '' && $pay_type != PayEnum::CASH_PAY && $pay_type != PayEnum::PURCHASE_FUNDS
|
||||||
&& $pay_type != PayEnum::GIFT_FUNDS
|
&& $pay_type != PayEnum::GIFT_FUNDS && $pay_type != PayEnum::BALANCE_PAY
|
||||||
) {
|
) {
|
||||||
return $this->fail('支付条码不能为空');
|
return $this->fail('支付条码不能为空');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user