fix(admin): 修复采购员设置采购信息权限问题并优化库存查询功能
- 在 PurchaseProductOfferController 中添加 admin_id 参数 - 在 PurchaseProductOfferLogic 中增加采购员权限验证 - 在 WarehouseLogic 中添加商品名称和分类筛选功能 - 在 IndexController 中添加利润计算和订单数据处理逻辑
This commit is contained in:
parent
492f7e77c2
commit
7f5eeeb71e
@ -74,6 +74,7 @@ class PurchaseProductOfferController extends BaseAdminController
|
|||||||
public function setProcureInfo()
|
public function setProcureInfo()
|
||||||
{
|
{
|
||||||
$params = $this->request->post();
|
$params = $this->request->post();
|
||||||
|
$params['admin_id']=$this->adminId;
|
||||||
PurchaseProductOfferLogic::setProcureInfo($params);
|
PurchaseProductOfferLogic::setProcureInfo($params);
|
||||||
return $this->success('设置成功', [], 1, 1);
|
return $this->success('设置成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
@ -111,9 +111,12 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function setProcureInfo(array $params): bool
|
public static function setProcureInfo(array $params): bool
|
||||||
{
|
{
|
||||||
|
$offer = PurchaseProductOffer::where(['id' => $params['id']])->find();
|
||||||
|
if($offer['buyer_id']!=$params['admin_id']){
|
||||||
|
throw new BusinessException('您不是当事采购员,无法设置采购信息');
|
||||||
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$offer = PurchaseProductOffer::where(['id' => $params['id']])->find();
|
|
||||||
$offer->save([
|
$offer->save([
|
||||||
'buyer_nums' => $params['buyer_nums'],
|
'buyer_nums' => $params['buyer_nums'],
|
||||||
'supplier_id' => $params['supplier_id'],
|
'supplier_id' => $params['supplier_id'],
|
||||||
|
@ -208,8 +208,15 @@ class WarehouseLogic extends BaseLogic
|
|||||||
public static function negativeInventory($parmas)
|
public static function negativeInventory($parmas)
|
||||||
{
|
{
|
||||||
if ($parmas['type'] == 1) {
|
if ($parmas['type'] == 1) {
|
||||||
$list = StoreProduct::where('stock', '<', 0)->page($parmas['page_no'], 15)->select()->toArray();
|
$where[]= ['stock', '<', 0];
|
||||||
$count = StoreProduct::where('stock', '<', 0)->count();
|
if($parmas['store_name']!=''){
|
||||||
|
$where[]=['store_name','like','%'.$parmas['store_name'].'%'];
|
||||||
|
}
|
||||||
|
if($parmas['top_cate_id']!=''){
|
||||||
|
$where[]=['top_cate_id','=',$parmas['top_cate_id']];
|
||||||
|
}
|
||||||
|
$list = StoreProduct::where($where)->page($parmas['page_no'], 15)->select()->toArray();
|
||||||
|
$count = StoreProduct::where($where)->count();
|
||||||
} elseif ($parmas['type'] == 2) {
|
} elseif ($parmas['type'] == 2) {
|
||||||
$where[] = ['stock', '<', 0];
|
$where[] = ['stock', '<', 0];
|
||||||
if (isset($parmas['store_id']) && $parmas['store_id'] > 0) {
|
if (isset($parmas['store_id']) && $parmas['store_id'] > 0) {
|
||||||
@ -220,6 +227,12 @@ class WarehouseLogic extends BaseLogic
|
|||||||
$store_arr = explode(',', $store_arr);
|
$store_arr = explode(',', $store_arr);
|
||||||
$where[] = ['store_id', 'not in', $store_arr];
|
$where[] = ['store_id', 'not in', $store_arr];
|
||||||
}
|
}
|
||||||
|
if($parmas['store_name']!=''){
|
||||||
|
$where[]=['store_name','like','%'.$parmas['store_name'].'%'];
|
||||||
|
}
|
||||||
|
if($parmas['top_cate_id']!=''){
|
||||||
|
$where[]=['top_cate_id','=',$parmas['top_cate_id']];
|
||||||
|
}
|
||||||
$list = StoreBranchProduct::where($where)->page($parmas['page_no'], 15)->select()
|
$list = StoreBranchProduct::where($where)->page($parmas['page_no'], 15)->select()
|
||||||
->each(function ($item) {
|
->each(function ($item) {
|
||||||
$item->remark = SystemStore::where('id', $item['store_id'])->value('name');
|
$item->remark = SystemStore::where('id', $item['store_id'])->value('name');
|
||||||
@ -227,7 +240,19 @@ class WarehouseLogic extends BaseLogic
|
|||||||
->toArray();
|
->toArray();
|
||||||
$count = StoreBranchProduct::where($where)->count();
|
$count = StoreBranchProduct::where($where)->count();
|
||||||
} elseif ($parmas['type'] == 3) {
|
} elseif ($parmas['type'] == 3) {
|
||||||
$list = WarehouseProductStorege::where('nums', '<', 0)->page($parmas['page_no'], 15)->select()
|
$where[]=['nums','<',0];
|
||||||
|
$where2=[];
|
||||||
|
if($parmas['store_name']!=''){
|
||||||
|
$where2[]=['store_name','like','%'.$parmas['store_name'].'%'];
|
||||||
|
}
|
||||||
|
if($parmas['top_cate_id']!=''){
|
||||||
|
$where2[]=['top_cate_id','=',$parmas['top_cate_id']];
|
||||||
|
}
|
||||||
|
if($where2){
|
||||||
|
$ids=StoreProduct::where($where2)->column('id');
|
||||||
|
$where[]=['product_id','in',$ids];
|
||||||
|
}
|
||||||
|
$list = WarehouseProductStorege::where($where)->page($parmas['page_no'], 15)->select()
|
||||||
->each(function ($item) {
|
->each(function ($item) {
|
||||||
$find = StoreProduct::where('id', $item['product_id'])->find();
|
$find = StoreProduct::where('id', $item['product_id'])->find();
|
||||||
$item->store_name = $find['store_name'];
|
$item->store_name = $find['store_name'];
|
||||||
@ -235,7 +260,7 @@ class WarehouseLogic extends BaseLogic
|
|||||||
$item->stock = $item['nums'];
|
$item->stock = $item['nums'];
|
||||||
$item->remark = Warehouse::where('id', $item['warehouse_id'])->value('name');
|
$item->remark = Warehouse::where('id', $item['warehouse_id'])->value('name');
|
||||||
})->toArray();
|
})->toArray();
|
||||||
$count = WarehouseProductStorege::where('nums', '<', 0)->count();
|
$count = WarehouseProductStorege::where($where)->count();
|
||||||
}
|
}
|
||||||
return ['lists' => $list, 'count' => $count];
|
return ['lists' => $list, 'count' => $count];
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,41 @@ class IndexController extends BaseApiController
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
d(1);
|
d(1);
|
||||||
|
$arr=Db::name('ceshi_copy')->select();
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
$data = [
|
||||||
|
|
||||||
$arr=StoreOrder::where('store_id',8)->where('paid',1)->field('id,pay_price,deduction_price,refund_price')->select()->toArray();
|
'cost' => $v['cost'],
|
||||||
|
'purchase' => $v['purchase'],
|
||||||
|
'price' => $v['price'],
|
||||||
|
'vip_price' => $v['price'],
|
||||||
|
|
||||||
|
];
|
||||||
|
$rose = 0;
|
||||||
|
//零售-供货
|
||||||
|
$rose_price = bcsub($v['price'], $v['purchase'], 2);
|
||||||
|
if ($rose_price > 0) {
|
||||||
|
//利润除于零售
|
||||||
|
$price_div = bcdiv($rose_price, $v['price'], 2);
|
||||||
|
$rose=bcmul($price_div, 100, 2);
|
||||||
|
}
|
||||||
|
$data['rose']=$rose;
|
||||||
|
StoreProduct::update($data, ['id' => $v['product_id']]);
|
||||||
|
//修改
|
||||||
|
StoreBranchProduct::where('product_id', $v['product_id'])->whereNotIn('store_id', [17, 18])->update([
|
||||||
|
'price' => $v['price'],
|
||||||
|
'vip_price' => $v['price'],
|
||||||
|
'cost' => $v['cost'],
|
||||||
|
'purchase' => $v['purchase'],
|
||||||
|
'rose' => $rose
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
d(11);
|
||||||
|
$pay_price=StoreOrder::where('store_id',3)->where('id','>=',1867)->where('id','<=',4826)->where('paid',1)->sum('pay_price');
|
||||||
|
$refund_price=StoreOrder::where('store_id',3)->where('id','>=',1867)->where('id','<=',4826)->where('paid',1)->sum('refund_price');
|
||||||
|
d($pay_price,$refund_price);
|
||||||
|
$arr=StoreOrder::where('store_id',3)->where('id','>',551)->where('paid',1)->field('id,pay_price,deduction_price,refund_price')->select()->toArray();
|
||||||
$data=[];
|
$data=[];
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
$total_price=StoreOrderCartInfo::where('oid', $v['id'])->sum('total_price');
|
$total_price=StoreOrderCartInfo::where('oid', $v['id'])->sum('total_price');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user