Merge pull request 'dev' (#327) from dev into main

Reviewed-on: #327
This commit is contained in:
mkm 2024-11-14 15:19:45 +08:00
commit a6a79fb4ef
6 changed files with 80 additions and 9 deletions

View File

@ -74,6 +74,7 @@ class PurchaseProductOfferController extends BaseAdminController
public function setProcureInfo()
{
$params = $this->request->post();
$params['admin_id']=$this->adminId;
PurchaseProductOfferLogic::setProcureInfo($params);
return $this->success('设置成功', [], 1, 1);
}

View File

@ -13,6 +13,7 @@ use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\model\supplier\Supplier;
use app\common\model\system_store\SystemStore;
use app\common\model\warehouse_order\WarehouseOrder;
use app\common\model\warehouse_product\WarehouseProduct;
@ -209,6 +210,7 @@ class WarehouseOrderController extends BaseAdminController
$value->unit_name = '';
}
$order['total_num'] += $value->nums;
$value->supplier_name= Supplier::where('id', $value->supplier_id)->value('mer_name');
}
$file_path = $xlsx->export($data, $order);
@ -222,6 +224,9 @@ class WarehouseOrderController extends BaseAdminController
{
$id = $this->request->post('id');
$type = $this->request->post('type');
if(in_array($type, [2,3])){
return $this->fail('暂不支持此操作');
}
$xlsx = new OrderDetail();
$order = WarehouseOrder::where('id', $id)->findOrEmpty();
$system_store = SystemStore::where('id', $order['store_id'])->value('name');
@ -249,8 +254,12 @@ class WarehouseOrderController extends BaseAdminController
// $value->total_price=bcmul($find['price'],$value['nums'],2);
// $total_price+=$value->total_price;
// }else{
if($type==1){
$value->price = $value['purchase'];
$value->total_price=bcmul($value['purchase'],$value['nums'],2);
$total_price+=$value->total_price;
}
// }
$value->cart_num = $value['nums'];

View File

@ -111,9 +111,12 @@ class PurchaseProductOfferLogic extends BaseLogic
*/
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();
try {
$offer = PurchaseProductOffer::where(['id' => $params['id']])->find();
$offer->save([
'buyer_nums' => $params['buyer_nums'],
'supplier_id' => $params['supplier_id'],

View File

@ -208,8 +208,15 @@ class WarehouseLogic extends BaseLogic
public static function negativeInventory($parmas)
{
if ($parmas['type'] == 1) {
$list = StoreProduct::where('stock', '<', 0)->page($parmas['page_no'], 15)->select()->toArray();
$count = StoreProduct::where('stock', '<', 0)->count();
$where[]= ['stock', '<', 0];
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) {
$where[] = ['stock', '<', 0];
if (isset($parmas['store_id']) && $parmas['store_id'] > 0) {
@ -220,6 +227,12 @@ class WarehouseLogic extends BaseLogic
$store_arr = explode(',', $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()
->each(function ($item) {
$item->remark = SystemStore::where('id', $item['store_id'])->value('name');
@ -227,7 +240,19 @@ class WarehouseLogic extends BaseLogic
->toArray();
$count = StoreBranchProduct::where($where)->count();
} 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) {
$find = StoreProduct::where('id', $item['product_id'])->find();
$item->store_name = $find['store_name'];
@ -235,7 +260,7 @@ class WarehouseLogic extends BaseLogic
$item->stock = $item['nums'];
$item->remark = Warehouse::where('id', $item['warehouse_id'])->value('name');
})->toArray();
$count = WarehouseProductStorege::where('nums', '<', 0)->count();
$count = WarehouseProductStorege::where($where)->count();
}
return ['lists' => $list, 'count' => $count];
}

View File

@ -54,8 +54,41 @@ class IndexController extends BaseApiController
public function index()
{
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=[];
foreach ($arr as $k => $v) {
$total_price=StoreOrderCartInfo::where('oid', $v['id'])->sum('total_price');

View File

@ -34,7 +34,7 @@ class WarehouseOrdeRentry
$sheet->setCellValue('G2', $order['code']??'');
$sheet->setCellValue('A3', '序号');
$sheet->setCellValue('B3', '商品名称');
$sheet->setCellValue('D3', '规格');
$sheet->setCellValue('D3', '供应商');
$sheet->setCellValue('F3', '单位');
$sheet->setCellValue('G3', '单价');
$sheet->setCellValue('H3', '数量');
@ -53,10 +53,10 @@ class WarehouseOrdeRentry
$spreadsheet->getDefaultStyle()->applyFromArray($defaultStyle);
foreach ($data as $k => $v) {
$sheet->setCellValue('A' . ($k + 4), $k+1 );
$sheet->setCellValue('A' . ($k + 4), $v['product_id'] );
$sheet->setCellValue('B' . ($k + 4), $v['store_name']);
$sheet->mergeCells('B' . ($k + 4) . ':C' . $k + 4);
$sheet->setCellValue('D' . ($k + 4), $v['store_info']);
$sheet->setCellValue('D' . ($k + 4), $v['supplier_name']);
$sheet->mergeCells('D' . ($k + 4) . ':E' . $k + 4);
$sheet->setCellValue('F' . ($k + 4), $v['unit_name']);
$sheet->setCellValue('G' . ($k + 4), $v['purchase']);