diff --git a/app/api/controller/LoginController.php b/app/api/controller/LoginController.php index de0282ced..d58b2ab1f 100644 --- a/app/api/controller/LoginController.php +++ b/app/api/controller/LoginController.php @@ -3,6 +3,7 @@ namespace app\api\controller; use app\api\logic\LoginLogic; +use app\common\model\system_store\SystemStore; use app\api\validate\{LoginAccountValidate, WechatLoginValidate}; use app\common\model\user\UserAuth; use hg\apidoc\annotation as ApiDoc; @@ -48,6 +49,7 @@ class LoginController extends BaseApiController if (false === $res) { return $this->fail(LoginLogic::getError()); } + $res = LoginLogic::dealStaff($res); return $this->success('', $res); } diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index a1f004cdb..e48ff902d 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -9,7 +9,9 @@ use app\api\validate\OrderValidate; use app\common\enum\PayEnum; use app\common\logic\PaymentLogic; use app\common\logic\PayNotifyLogic; +use app\common\model\retail\Cashierclass; use app\common\model\store_order\StoreOrder; +use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\UserAddress; use Webman\RedisQueue\Redis; use hg\apidoc\annotation as ApiDoc; @@ -43,6 +45,9 @@ class OrderController extends BaseApiController return $this->fail('缺失参数'); } $res = OrderLogic::getOne($code); + if($res){ + $res = $res[0]; + } return $this->success('ok',$res); } @@ -446,4 +451,20 @@ class OrderController extends BaseApiController } + //收银端 + public function merchant_order_count() + { + $date = $this->request->get('date', date('Y-m-d')); + $store_id = SystemStoreStaff::where('phone',$this->userInfo['mobile'])->value('store_id'); + if(empty($store_id)){ + throw new \Exception('该用户未绑定店铺'); + } + $where[] = ['store_id', '=', $store_id]; + $where[] = ['paid', '=', 1]; + $where[] = ['pay_type', '<>', 9]; + $res = StoreOrder::where($where)->whereDay('create_time', $date)->count(); + return $this->success('ok', ['order_count' => $res]); + } + + } diff --git a/app/api/controller/product/ProductController.php b/app/api/controller/product/ProductController.php index 014a6da4f..d1d54fa36 100644 --- a/app/api/controller/product/ProductController.php +++ b/app/api/controller/product/ProductController.php @@ -16,11 +16,11 @@ class ProductController extends BaseApiController{ return $this->dataLists(new ProductLists()); } - /** + /** * 商品列表 */ public function mer_list(){ - $this->request->__set('mer_id',$this->request->userInfo['merchant']['mer_id']??0); + $this->request->__set('store_id',$this->request->userInfo['store_id']??0); return $this->dataLists(new ProductLists()); } diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index a7cc41cd5..bb6dc9537 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -112,13 +112,28 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface } $where[]=['store_id','=',$store_id]; - $data = StoreBranchProduct::where($this->searchWhere)->where($where) - ->field(['id', 'product_id','cate_id','store_name', 'store_id','price', 'bar_code','image','sales','store_info','delete_time','unit']) - ->limit($this->limitOffset, $this->limitLength) - ->with(['className','unitName']) - ->order($order) - ->select() - ->toArray(); + + $M_store_id=$this->request->__get('store_id'); + if($M_store_id){ + $where[]=['store_id','=',$M_store_id]; + $data = StoreBranchProduct::where($this->searchWhere)->where($where) + ->field(['id', 'product_id','cate_id','store_name', 'store_id','price', 'bar_code','image','sales','store_info','delete_time','unit']) + ->limit($this->limitOffset, $this->limitLength) + ->with(['className','unitName']) + ->order($order) + ->select() + ->toArray(); + + }else{ + $data = StoreBranchProduct::where($this->searchWhere)->where($where) + ->field(['id', 'product_id','cate_id','store_name', 'store_id','price', 'bar_code','image','sales','store_info','delete_time','unit']) + ->limit($this->limitOffset, $this->limitLength) + ->with(['className','unitName']) + ->order($order) + ->select() + ->toArray(); + + } foreach ($data as &$value){ $value['is_default'] = 0; if($store_id == 2){ @@ -126,8 +141,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface } } return $data; - - // return StoreProduct::where($this->searchWhere)->where($where) // ->field(['id', 'cate_id','store_name','unit', 'ot_price', 'bar_code','image','sales','store_info']) // ->limit($this->limitOffset, $this->limitLength) @@ -147,11 +160,9 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface public function count(): int { $class_all=$this->request->get('class_all'); - $order_param = $this->request->get('order'); $store_id = $this->request->get('store_id',2); $name = $this->request->get('name',''); $where=[]; - $order = []; if($class_all){ $arr=[]; $arr2=[]; @@ -164,18 +175,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface } } - if(!empty($order_param)){ - if($order_param == 'asc'){ - $order['price'] = 'asc'; - }elseif ($order_param == 'desc') { - $order['price'] = 'desc'; - }elseif ($order_param=='sales') { - $order['sales'] = 'desc'; - } - }else{ - $order['id'] = 'desc'; - } - if($name){ if(preg_match('/[\x{4e00}-\x{9fff}]+/u', $name)==1){ $where[] = ['store_name','like','%'.$name.'%']; @@ -186,15 +185,19 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface } $where[]=['store_id','=',$store_id]; - $data =StoreBranchProduct::where($this->searchWhere)->where($where) - ->field(['id', 'product_id','cate_id','store_name', 'store_id','price', 'bar_code','image','sales','store_info','delete_time','unit']) - ->limit($this->limitOffset, $this->limitLength) - ->with(['className','unitName']) - ->order($order) - ->select() - ->toArray(); + $M_store_id=$this->request->__get('store_id'); - return count($data); + if($M_store_id){ + $where[]=['store_id','=',$M_store_id]; + $data = StoreBranchProduct::where($this->searchWhere)->where($where) + ->count(); + + }else{ + $data =StoreBranchProduct::where($this->searchWhere)->where($where) + ->count(); + + } + return $data; } } \ No newline at end of file diff --git a/app/api/logic/LoginLogic.php b/app/api/logic/LoginLogic.php index 781c540df..2e76a4f4b 100644 --- a/app/api/logic/LoginLogic.php +++ b/app/api/logic/LoginLogic.php @@ -108,7 +108,7 @@ class LoginLogic extends BaseLogic 'mobile' => $userInfo['mobile'], 'nickname' => $userInfo['nickname'], 'supplier' => $userInfo['supplier']??null, - 'merchant' => $userInfo['merchant']??null, + 'store_id' => SystemStoreStaff::where('phone',$userInfo['mobile'])->value('store_id')??null, // 'sn' => $userInfo['sn'], 'token' => $userInfo['token'], ];