Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into product
This commit is contained in:
commit
5dda2ccbc8
23
README.md
23
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
|
||||

|
||||
|
||||
## LICENSE
|
||||
|
||||
MIT
|
||||
source
|
||||
0 小程序
|
||||
1 收银台
|
||||
4 批发
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -1,20 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\product;
|
||||
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\product\ProductLists;
|
||||
use app\api\lists\product\ProductWholesaleLists;
|
||||
use app\api\lists\product\StoreProductLists;
|
||||
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 function lists(){
|
||||
public function lists()
|
||||
{
|
||||
|
||||
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());
|
||||
}
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
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' => []]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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('商品不存在');
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user