Merge pull request 'feat(warehouse_order): 根据不同类型计算总价' (#161) from dev into main
Reviewed-on: #161
This commit is contained in:
commit
c309ea8142
@ -237,6 +237,14 @@ class WarehouseOrderController extends BaseAdminController
|
|||||||
$value->store_name = $find['store_name'] ?? '';
|
$value->store_name = $find['store_name'] ?? '';
|
||||||
$value->store_info = $find['store_info'] ?? '';
|
$value->store_info = $find['store_info'] ?? '';
|
||||||
if($type==2){
|
if($type==2){
|
||||||
|
$value->price = $find['purchase'];
|
||||||
|
$value->total_price=bcmul($find['purchase'],$value['nums'],2);
|
||||||
|
$total_price+=$value->total_price;
|
||||||
|
}elseif($type==3){
|
||||||
|
$value->price = $find['cost'];
|
||||||
|
$value->total_price=bcmul($find['cost'],$value['nums'],2);
|
||||||
|
$total_price+=$value->total_price;
|
||||||
|
}elseif($type==4){
|
||||||
$value->price = $find['price'];
|
$value->price = $find['price'];
|
||||||
$value->total_price=bcmul($find['price'],$value['nums'],2);
|
$value->total_price=bcmul($find['price'],$value['nums'],2);
|
||||||
$total_price+=$value->total_price;
|
$total_price+=$value->total_price;
|
||||||
|
@ -26,7 +26,8 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['mer_name', 'phone'],
|
'=' => ['phone'],
|
||||||
|
'%like%'=>['mer_name']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ use app\api\validate\CartValidate;
|
|||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
use app\store\lists\cart\CartList;
|
use app\store\lists\cart\CartList;
|
||||||
use app\common\model\order\Cart;
|
use app\common\model\order\Cart;
|
||||||
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
use app\store\controller\BaseAdminController;
|
use app\store\controller\BaseAdminController;
|
||||||
|
|
||||||
|
|
||||||
@ -24,31 +25,38 @@ class CartController extends BaseAdminController
|
|||||||
{
|
{
|
||||||
$params = (new CartValidate())->post()->goCheck('StoreAdd');
|
$params = (new CartValidate())->post()->goCheck('StoreAdd');
|
||||||
$adminInfo = $this->adminInfo;
|
$adminInfo = $this->adminInfo;
|
||||||
$params['uid'] = $this->request->post('uid')??0;
|
$params['uid'] = $this->request->post('uid') ?? 0;
|
||||||
$params['staff_id'] = $adminInfo['admin_id'];
|
$params['staff_id'] = $adminInfo['admin_id'];
|
||||||
$params['store_id'] = $adminInfo['store_id'];
|
$params['store_id'] = $adminInfo['store_id'];
|
||||||
$result = Cart::where(['uid' => 0,'staff_id'=>$adminInfo['admin_id'], 'store_id' => $adminInfo['store_id'], 'product_id' => $params['product_id'], 'is_fail' => 0, 'is_pay' => 0])->find();
|
$result = Cart::where(['uid' => 0, 'staff_id' => $adminInfo['admin_id'], 'store_id' => $adminInfo['store_id'], 'product_id' => $params['product_id'], 'is_fail' => 0, 'is_pay' => 0])->find();
|
||||||
//判断起批发价
|
//判断起批发价
|
||||||
$batch = StoreBranchProduct::where(
|
$branchProduct = StoreBranchProduct::where(
|
||||||
['product_id'=>$params['product_id'],
|
[
|
||||||
'store_id' => $adminInfo['store_id']
|
'product_id' => $params['product_id'],
|
||||||
|
'store_id' => $adminInfo['store_id']
|
||||||
]
|
]
|
||||||
)->value('batch');
|
)->find();
|
||||||
if($params['cart_num'] < $batch){
|
if ($params['cart_num'] < $branchProduct['batch']) {
|
||||||
return $this->fail('起批发量低于最低值'.$batch);
|
return $this->fail('起批发量低于最低值' . $branchProduct['batch']);
|
||||||
}
|
}
|
||||||
$count = Cart::where(['uid' => $params['uid'], 'is_pay' => 0])->count();
|
$count = Cart::where(['uid' => $params['uid'], 'is_pay' => 0])->count();
|
||||||
if ($count > 100) {
|
if ($count > 100) {
|
||||||
return $this->fail('购物车商品不能大于100个,请先结算');
|
return $this->fail('购物车商品不能大于100个,请先结算');
|
||||||
}
|
}
|
||||||
|
if ($params['cart_num'] < 1) {
|
||||||
|
$is_bulk = StoreProductUnit::where('id', $branchProduct['unit'])->value('is_bulk');
|
||||||
|
if ($is_bulk == 0) {
|
||||||
|
return $this->fail('非计量商品,不能有小数');
|
||||||
|
}
|
||||||
|
}
|
||||||
//数量下单判断
|
//数量下单判断
|
||||||
// $stock = StoreBranchProduct::where(
|
// $stock = StoreBranchProduct::where(
|
||||||
// ['product_id'=>$params['product_id'],
|
// ['product_id'=>$params['product_id'],
|
||||||
// 'store_id'=>$params['store_id']
|
// 'store_id'=>$params['store_id']
|
||||||
// ])->value('stock')??0;
|
// ])->value('stock')??0;
|
||||||
// if ($params['cart_num'] >$stock) {
|
// if ($params['cart_num'] >$stock) {
|
||||||
// return $this->fail('库存数量不足');
|
// return $this->fail('库存数量不足');
|
||||||
// }
|
// }
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$res = CartLogic::edit($params);
|
$res = CartLogic::edit($params);
|
||||||
} else {
|
} else {
|
||||||
@ -96,6 +104,4 @@ class CartController extends BaseAdminController
|
|||||||
return $this->fail(CartLogic::getError());
|
return $this->fail(CartLogic::getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user