Merge pull request 'dev' (#163) from dev into product
Reviewed-on: #163
This commit is contained in:
commit
e964187280
@ -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']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,12 +90,12 @@ class StoreBranchProductLogic extends BaseLogic
|
|||||||
$stock = bcadd($find['stock'], $params['nums'], 2);
|
$stock = bcadd($find['stock'], $params['nums'], 2);
|
||||||
$branchStock = bcadd($storeBranchProduct['stock'], $params['nums'], 2);
|
$branchStock = bcadd($storeBranchProduct['stock'], $params['nums'], 2);
|
||||||
|
|
||||||
StoreBranchProduct::where('id', $params['id'])->update(['stock' => $stock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)]);
|
StoreBranchProduct::where('id', $params['id'])->update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)]);
|
||||||
StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)]);
|
StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)]);
|
||||||
} else {
|
} else {
|
||||||
$branchStock = bcsub($storeBranchProduct['stock'], $params['nums'], 2);
|
$branchStock = bcsub($storeBranchProduct['stock'], $params['nums'], 2);
|
||||||
$stock = bcsub($find['stock'], $params['nums'], 2);
|
$stock = bcsub($find['stock'], $params['nums'], 2);
|
||||||
StoreBranchProduct::where('id', $params['id'])->update(['stock' => $stock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)]);
|
StoreBranchProduct::where('id', $params['id'])->update(['stock' => $branchStock, 'total_price' => bcmul($branchStock, $find['purchase'], 2)]);
|
||||||
StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)]);
|
StoreProduct::where('id', $params['product_id'])->update(['stock' => $stock, 'total_price' => bcmul($stock, $find['purchase'], 2)]);
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
@ -74,7 +74,6 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
|||||||
foreach ($list as $key => &$item) {
|
foreach ($list as $key => &$item) {
|
||||||
$find = StoreBranchProduct::where(['product_id' => $item['product_id'], 'store_id' => $item['store_id']])
|
$find = StoreBranchProduct::where(['product_id' => $item['product_id'], 'store_id' => $item['store_id']])
|
||||||
->field($field)
|
->field($field)
|
||||||
->withTrashed()
|
|
||||||
->find();
|
->find();
|
||||||
if ($find) {
|
if ($find) {
|
||||||
if ($off_activity == 1) {
|
if ($off_activity == 1) {
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -372,8 +372,8 @@ class WorkbenchLogic extends BaseLogic
|
|||||||
$dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime));
|
$dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime));
|
||||||
$data['visit_count'] = StoreVisit::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->count();
|
$data['visit_count'] = StoreVisit::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->count();
|
||||||
$data['visit_user_count'] = StoreVisit::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->group('uid')->count();
|
$data['visit_user_count'] = StoreVisit::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->group('uid')->count();
|
||||||
$data['add_cart_count'] = Cart::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->withTrashed()->group('product_id')->count();
|
$data['add_cart_count'] = Cart::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->group('product_id')->count();
|
||||||
$data['add_order_count'] = StoreOrderCartInfo::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->withTrashed()->group('product_id')->count();
|
$data['add_order_count'] = StoreOrderCartInfo::where('store_id', $storeId)->whereBetweenTime('create_time', $startTime, $endTime)->group('product_id')->count();
|
||||||
$data['pay_count'] = StoreOrder::alias('t1')
|
$data['pay_count'] = StoreOrder::alias('t1')
|
||||||
->join('store_order_cart_info t2', 't1.id = t2.oid')
|
->join('store_order_cart_info t2', 't1.id = t2.oid')
|
||||||
->where('t1.store_id', $storeId)
|
->where('t1.store_id', $storeId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user