diff --git a/README.md b/README.md index 34c8bd475..4601ee877 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,5 @@ -# webman -High performance HTTP Service Framework for PHP based on [Workerman](https://github.com/walkor/workerman). - -# Manual (文档) - -https://www.workerman.net/doc/webman - -# Home page (主页) -https://www.workerman.net/webman - - -# Benchmarks (压测) - -https://www.techempower.com/benchmarks/#section=test&runid=9716e3cd-9e53-433c-b6c5-d2c48c9593c1&hw=ph&test=db&l=zg24n3-1r&a=2 -![image](https://user-images.githubusercontent.com/6073368/96447814-120fc980-1245-11eb-938d-6ea408716c72.png) - -## LICENSE - -MIT +source + 0 小程序 + 1 收银台 + 4 批发 \ No newline at end of file diff --git a/app/admin/lists/store_order/StoreOrderLists.php b/app/admin/lists/store_order/StoreOrderLists.php index 2ab7640cd..aa1db8e62 100644 --- a/app/admin/lists/store_order/StoreOrderLists.php +++ b/app/admin/lists/store_order/StoreOrderLists.php @@ -31,7 +31,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface public function setSearch(): array { return [ - '=' => ['order_id','store_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id','paid', 'status', 'is_writeoff','is_merge','uid'], + '=' => ['order_id','store_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id','paid', 'status', 'is_writeoff','is_merge','uid','source'], 'between_time' => 'create_time' ]; } @@ -63,7 +63,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface $query->whereIn('status', $status); } }) - ->field(['id', 'store_id', 'staff_id', 'order_id', 'paid', 'pay_price','total_price', 'pay_time', 'pay_type', 'status', 'uid','refund_status','create_time','delivery_name','delivery_id','refund_price']) + ->field(['id', 'store_id', 'staff_id', 'order_id', 'paid','source', 'pay_price','total_price', 'pay_time', 'pay_type', 'status', 'uid','refund_status','create_time','delivery_name','delivery_id','refund_price']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { @@ -85,6 +85,11 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface if ($item['paid'] == 0) { $item['status_name'] = '待支付'; } + if($item['source']==4){ + $item['source_name'] = '批发订单'; + }else{ + $item['source_name'] = '普通订单'; + } $product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info']) ->limit(3)->select(); foreach ($product as &$items) { diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php index efe0008f9..2d45aeb63 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -54,22 +54,21 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI return StoreOrderCartInfo::where($this->searchWhere) ->field('id,oid,uid,product_id,store_id,cart_num,price,total_price,create_time,attr_value_id')->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) { - $find=StoreProduct::where('id',$item['product_id'])->field('image,store_name')->find(); + $find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->find(); $attr_value=StoreProductAttrValue::where('id',$item['attr_value_id'])->find(); + $item['nickname']='无'; + $item['mobile']=''; if($find){ if($item['uid']>0){ $user=User::where('id',$item['uid'])->field('real_name,mobile')->find(); if($user){ + $item['mobile']=$user['mobile']; if($user['real_name']!=''){ $item['nickname']=$user['real_name']; }else{ $item['nickname']=$user['mobile']; } - }else{ - $item['nickname']='无'; } - }else{ - $item['nickname']='无'; } $item['image']=$find['image'];//商品图片 $item['system_store']=SystemStore::where('id',$item['store_id'])->value('name')??""; @@ -131,13 +130,14 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI $data=[ 'store_name' => '商品名称', 'system_store' => '门店', - 'nickname' => '用户', 'sku_name' => '规格', 'unit_name' => '单位', 'cate_name' => '分类', 'cart_num' => '数量', 'price' => '单价', 'total_price' => '总价', + 'nickname' => '用户', + 'mobile' => '手机', 'create_time' => '时间', ]; return $data; diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 85b0210f1..4be517aa9 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -32,7 +32,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa public function setSearch(): array { return [ - '=' => ['cate_id', 'is_show', 'bar_code'], + '=' => ['cate_id', 'is_show', 'bar_code','product_type'], '<=' => ['stock'], '%like%' => ['store_name'], ]; @@ -73,7 +73,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $item['bar_code_two'] = ''; } $item['bar_code'] = ''; - $item['unit_names'] = '称重商品'; } else { if (strlen($item['bar_code']) < 10) { $item['bar_code_two'] = $item['bar_code']; @@ -82,30 +81,28 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } $item['bar_code'] = ''; } - $item['unit_names'] = '标准商品'; } - + switch($item['product_type']){ + case 2: + $item['product_type_name'] = '兑换产品'; + break; + case 3: + $item['product_type_name'] = '赠品'; + break; + case 4: + $item['product_type_name'] = '活动产品'; + break; + case 5: + $item['product_type_name'] = '批发产品'; + break; + default: + $item['product_type_name'] = '普通商品'; + } $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name'); $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); $stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock'); $item['stock'] = bcadd($nums, $stock); - $cate_name = ''; - $category_top = StoreCategory::where('id', $item['top_cate_id'])->value('name'); - if ($category_top != '') { - $cate_name = '/' . $category_top; - } - if (!$category_top) { - $category_two = StoreCategory::where('id', $item['two_cate_id'])->value('name'); - if ($category_two != '') { - $cate_name = $cate_name . '/' . $category_two; - } - } - $category_three = StoreCategory::where('id', $item['cate_id'])->value('name'); - if ($category_three) { - $cate_name = $cate_name . '/' . $category_three; - } - $item['cate_name'] = $cate_name; - // $item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name'); + $item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name'); return $item; })?->toArray(); } @@ -158,8 +155,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa { $data = [ 'id' => '商品id', - 'unit_names' => '计价方式', 'store_name' => '商品名称', + 'product_type_name' => '商品类型', 'cate_name' => '分类', 'unit_name' => '单位', 'store_info' => '规格', @@ -168,7 +165,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa 'cost' => '商户', 'price' => '零售', 'bar_code' => '条码', - 'bar_code_two' => '自编码', ]; return $data; } diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 693c32e9f..b49a93c92 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -90,6 +90,28 @@ class StoreProductLogic extends BaseLogic } (new StoreProductAttrValue())->saveAll($arr); Db::commit(); + if($data['product_type']==5){ + return true; + } + if ($params['is_store_all'] == 1) { + $store_arr = SystemStore::where('is_show', 1)->column('id'); + foreach ($store_arr as $store_id) { + if ($store_id != 5) { + Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id, 'stock_type' => 1, 'admin_id' => Request()->adminId]); + } + } + } else { + if (is_array($params['store_arr']) && count($params['store_arr']) > 0) { + foreach ($params['store_arr'] as $key => $store_id) { + if ($store_id != 5) { + Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id, 'stock_type' => 1, 'admin_id' => Request()->adminId]); + } + } + } + } + if (getenv('STORE_ID')) { + Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => getenv('STORE_ID'), 'stock_type' => 1, 'admin_id' => Request()->adminId]); + } return true; } catch (\Throwable $e) { diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index b50eaa188..3a126f617 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -152,7 +152,9 @@ class OrderController extends BaseApiController return $this->fail('密码错误'); } } - + if ($pay_type == PayEnum::GIFT_FUNDS) { + return $this->fail('不能使用礼品券支付'); + } $order = OrderLogic::createOrder($cartId, $addressId, $user, $params); if ($order != false) { if ($order['pay_price'] <= 0) { diff --git a/app/api/controller/product/ProductController.php b/app/api/controller/product/ProductController.php index 2b4c4f771..f635d5222 100644 --- a/app/api/controller/product/ProductController.php +++ b/app/api/controller/product/ProductController.php @@ -1,20 +1,24 @@ dataLists(new ProductLists()); } @@ -22,29 +26,38 @@ class ProductController extends BaseApiController{ /** * 批发商品列表 */ - public function wholesale_lists(){ - + public function wholesale_lists() + { + if ($this->userId) { + $label_id = User::where('id', $this->userId)->value('label_id'); + if ($label_id != 99) { + return $this->fail('您没有权限访问该列表'); + } + } else { + return $this->fail('请登陆后访问'); + } return $this->dataLists(new ProductWholesaleLists()); } /** * 商品列表 */ - public function mer_list(){ - $this->request->__set('store_id',$this->request->userInfo['store_id']??0); + public function mer_list() + { + $this->request->__set('store_id', $this->request->userInfo['store_id'] ?? 0); return $this->dataLists(new ProductLists()); } /** * 商品列表 */ - public function store_lists(){ + public function store_lists() + { - $store_id=SystemStoreStaff::where('uid',$this->userId)->where('is_admin',1)->value('store_id'); - if($store_id>0){ - $this->request->__set('store_id',$store_id); + $store_id = SystemStoreStaff::where('uid', $this->userId)->where('is_admin', 1)->value('store_id'); + if ($store_id > 0) { + $this->request->__set('store_id', $store_id); return $this->dataLists(new StoreProductLists()); - }else{ - return $this->data(['lists'=>[]]); + } else { + return $this->data(['lists' => []]); } } - } diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 8a55d5939..f20607581 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -111,6 +111,7 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis } $this->off_activity = $off_activity; $this->searchWhere[] = ['is_show', '=', 1]; + $this->searchWhere[] = ['product_type', 'in', [0,4]]; // $this->searchWhere[] = ['stock', '>', 0]; return StoreProduct::where($this->searchWhere) ->field($fields) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index be622704e..67eeb8adb 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -92,13 +92,11 @@ class OrderLogic extends BaseLogic $off_activity = Config::where('name', 'off_activity')->value('value'); // $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; foreach ($cart_select as $k => $v) { - // if ($source == 2) { - // $field = 'product_id,product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; - // $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find(); - // } else { - // $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); - // } - $find = StoreProductAttrValue::where(['id' => $v['attr_value_id']])->find(); + if($source==0){ + $source=$v['source']; + } + $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); + if (!$find) { throw new BusinessException('商品不存在'); } diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index e03a0b68f..5d7939187 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -206,6 +206,9 @@ class StoreOrderController extends BaseAdminController $params['store_id'] = $this->request->adminInfo['store_id']; //当前登录的店铺id,用于判断是否是当前店铺的订单 $params['shipping_type'] =3; $params['source'] =1; + if ($pay_type == PayEnum::GIFT_FUNDS) { + return $this->fail('不能使用礼品券支付'); + } $order = OrderLogic::createOrder($cartId, $addressId, $user, $params); if ($order != false) { switch ($pay_type) {