This commit is contained in:
mkm 2024-09-17 13:02:16 +08:00
commit 5dda2ccbc8
10 changed files with 97 additions and 72 deletions

View File

@ -1,20 +1,5 @@
# webman
High performance HTTP Service Framework for PHP based on [Workerman](https://github.com/walkor/workerman). source
0 小程序
# Manual (文档) 1 收银台
4 批发
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

View File

@ -31,7 +31,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
public function setSearch(): array public function setSearch(): array
{ {
return [ 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' 'between_time' => 'create_time'
]; ];
} }
@ -63,7 +63,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
$query->whereIn('status', $status); $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) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function ($item) { ->select()->each(function ($item) {
@ -85,6 +85,11 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
if ($item['paid'] == 0) { if ($item['paid'] == 0) {
$item['status_name'] = '待支付'; $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']) $product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info'])
->limit(3)->select(); ->limit(3)->select();
foreach ($product as &$items) { foreach ($product as &$items) {

View File

@ -54,22 +54,21 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
return StoreOrderCartInfo::where($this->searchWhere) 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) ->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) { ->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(); $attr_value=StoreProductAttrValue::where('id',$item['attr_value_id'])->find();
$item['nickname']='无';
$item['mobile']='';
if($find){ if($find){
if($item['uid']>0){ if($item['uid']>0){
$user=User::where('id',$item['uid'])->field('real_name,mobile')->find(); $user=User::where('id',$item['uid'])->field('real_name,mobile')->find();
if($user){ if($user){
$item['mobile']=$user['mobile'];
if($user['real_name']!=''){ if($user['real_name']!=''){
$item['nickname']=$user['real_name']; $item['nickname']=$user['real_name'];
}else{ }else{
$item['nickname']=$user['mobile']; $item['nickname']=$user['mobile'];
} }
}else{
$item['nickname']='无';
} }
}else{
$item['nickname']='无';
} }
$item['image']=$find['image'];//商品图片 $item['image']=$find['image'];//商品图片
$item['system_store']=SystemStore::where('id',$item['store_id'])->value('name')??""; $item['system_store']=SystemStore::where('id',$item['store_id'])->value('name')??"";
@ -131,13 +130,14 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
$data=[ $data=[
'store_name' => '商品名称', 'store_name' => '商品名称',
'system_store' => '门店', 'system_store' => '门店',
'nickname' => '用户',
'sku_name' => '规格', 'sku_name' => '规格',
'unit_name' => '单位', 'unit_name' => '单位',
'cate_name' => '分类', 'cate_name' => '分类',
'cart_num' => '数量', 'cart_num' => '数量',
'price' => '单价', 'price' => '单价',
'total_price' => '总价', 'total_price' => '总价',
'nickname' => '用户',
'mobile' => '手机',
'create_time' => '时间', 'create_time' => '时间',
]; ];
return $data; return $data;

View File

@ -32,7 +32,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['cate_id', 'is_show', 'bar_code'], '=' => ['cate_id', 'is_show', 'bar_code','product_type'],
'<=' => ['stock'], '<=' => ['stock'],
'%like%' => ['store_name'], '%like%' => ['store_name'],
]; ];
@ -73,7 +73,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
$item['bar_code_two'] = ''; $item['bar_code_two'] = '';
} }
$item['bar_code'] = ''; $item['bar_code'] = '';
$item['unit_names'] = '称重商品';
} else { } else {
if (strlen($item['bar_code']) < 10) { if (strlen($item['bar_code']) < 10) {
$item['bar_code_two'] = $item['bar_code']; $item['bar_code_two'] = $item['bar_code'];
@ -82,30 +81,28 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
} }
$item['bar_code'] = ''; $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'); $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
$nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
$stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock'); $stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock');
$item['stock'] = bcadd($nums, $stock); $item['stock'] = bcadd($nums, $stock);
$cate_name = ''; $item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('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');
return $item; return $item;
})?->toArray(); })?->toArray();
} }
@ -158,8 +155,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
{ {
$data = [ $data = [
'id' => '商品id', 'id' => '商品id',
'unit_names' => '计价方式',
'store_name' => '商品名称', 'store_name' => '商品名称',
'product_type_name' => '商品类型',
'cate_name' => '分类', 'cate_name' => '分类',
'unit_name' => '单位', 'unit_name' => '单位',
'store_info' => '规格', 'store_info' => '规格',
@ -168,7 +165,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
'cost' => '商户', 'cost' => '商户',
'price' => '零售', 'price' => '零售',
'bar_code' => '条码', 'bar_code' => '条码',
'bar_code_two' => '自编码',
]; ];
return $data; return $data;
} }

View File

@ -90,6 +90,28 @@ class StoreProductLogic extends BaseLogic
} }
(new StoreProductAttrValue())->saveAll($arr); (new StoreProductAttrValue())->saveAll($arr);
Db::commit(); 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; return true;
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -152,7 +152,9 @@ class OrderController extends BaseApiController
return $this->fail('密码错误'); return $this->fail('密码错误');
} }
} }
if ($pay_type == PayEnum::GIFT_FUNDS) {
return $this->fail('不能使用礼品券支付');
}
$order = OrderLogic::createOrder($cartId, $addressId, $user, $params); $order = OrderLogic::createOrder($cartId, $addressId, $user, $params);
if ($order != false) { if ($order != false) {
if ($order['pay_price'] <= 0) { if ($order['pay_price'] <= 0) {

View File

@ -1,20 +1,24 @@
<?php <?php
namespace app\api\controller\product; namespace app\api\controller\product;
use app\api\controller\BaseApiController; use app\api\controller\BaseApiController;
use app\api\lists\product\ProductLists; use app\api\lists\product\ProductLists;
use app\api\lists\product\ProductWholesaleLists; use app\api\lists\product\ProductWholesaleLists;
use app\api\lists\product\StoreProductLists; use app\api\lists\product\StoreProductLists;
use app\common\model\system_store\SystemStoreStaff; use app\common\model\system_store\SystemStoreStaff;
use app\common\model\user\User;
class ProductController extends BaseApiController{ class ProductController extends BaseApiController
{
public $notNeedLogin = ['lists']; public $notNeedLogin = ['lists'];
/** /**
* 商品列表 * 商品列表
*/ */
public function lists(){ public function lists()
{
return $this->dataLists(new ProductLists()); return $this->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()); return $this->dataLists(new ProductWholesaleLists());
} }
/** /**
* 商品列表 * 商品列表
*/ */
public function mer_list(){ public function mer_list()
$this->request->__set('store_id',$this->request->userInfo['store_id']??0); {
$this->request->__set('store_id', $this->request->userInfo['store_id'] ?? 0);
return $this->dataLists(new ProductLists()); 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'); $store_id = SystemStoreStaff::where('uid', $this->userId)->where('is_admin', 1)->value('store_id');
if($store_id>0){ if ($store_id > 0) {
$this->request->__set('store_id',$store_id); $this->request->__set('store_id', $store_id);
return $this->dataLists(new StoreProductLists()); return $this->dataLists(new StoreProductLists());
}else{ } else {
return $this->data(['lists'=>[]]); return $this->data(['lists' => []]);
} }
} }
} }

View File

@ -111,6 +111,7 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis
} }
$this->off_activity = $off_activity; $this->off_activity = $off_activity;
$this->searchWhere[] = ['is_show', '=', 1]; $this->searchWhere[] = ['is_show', '=', 1];
$this->searchWhere[] = ['product_type', 'in', [0,4]];
// $this->searchWhere[] = ['stock', '>', 0]; // $this->searchWhere[] = ['stock', '>', 0];
return StoreProduct::where($this->searchWhere) return StoreProduct::where($this->searchWhere)
->field($fields) ->field($fields)

View File

@ -92,13 +92,11 @@ class OrderLogic extends BaseLogic
$off_activity = Config::where('name', 'off_activity')->value('value'); $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'; // $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose';
foreach ($cart_select as $k => $v) { foreach ($cart_select as $k => $v) {
// if ($source == 2) { if($source==0){
// $field = 'product_id,product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; $source=$v['source'];
// $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 = StoreProduct::where(['id' => $v['product_id']])->field($field)->find();
// }
$find = StoreProductAttrValue::where(['id' => $v['attr_value_id']])->find();
if (!$find) { if (!$find) {
throw new BusinessException('商品不存在'); throw new BusinessException('商品不存在');
} }

View File

@ -206,6 +206,9 @@ class StoreOrderController extends BaseAdminController
$params['store_id'] = $this->request->adminInfo['store_id']; //当前登录的店铺id用于判断是否是当前店铺的订单 $params['store_id'] = $this->request->adminInfo['store_id']; //当前登录的店铺id用于判断是否是当前店铺的订单
$params['shipping_type'] =3; $params['shipping_type'] =3;
$params['source'] =1; $params['source'] =1;
if ($pay_type == PayEnum::GIFT_FUNDS) {
return $this->fail('不能使用礼品券支付');
}
$order = OrderLogic::createOrder($cartId, $addressId, $user, $params); $order = OrderLogic::createOrder($cartId, $addressId, $user, $params);
if ($order != false) { if ($order != false) {
switch ($pay_type) { switch ($pay_type) {