Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lzzzzl
/
liexin_scm_service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
72b348e9
authored
May 08, 2020
by
lzzzzl
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
新增修改
parent
2545e46b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
393 additions
and
43 deletions
app/Http/Controllers/ServicesController.php
app/Http/Model/CustomerModel.php
app/Http/Model/GoodsModel.php
app/Http/Model/LocationModel.php
app/Http/Model/StoreModel.php
app/Http/Model/SupplierModel.php
app/Http/Model/ZoneModel.php
scm_wms_common
app/Http/Controllers/ServicesController.php
View file @
72b348e9
...
@@ -76,6 +76,14 @@ class ServicesController extends Controller
...
@@ -76,6 +76,14 @@ class ServicesController extends Controller
}
}
/**
/**
* 获取仓库列表
*/
public
function
ApiStoreList
(
$request
)
{
$data
=
(
new
StoreModel
())
->
storeList
();
return
$this
->
apiReturn
(
$Errcode
=
0
,
$level
=
1
,
$dataArr
=
$data
);
}
/**
* 插入仓库信息
* 插入仓库信息
*/
*/
public
function
ApiInsertStoreInfo
(
$request
)
{
public
function
ApiInsertStoreInfo
(
$request
)
{
...
@@ -133,20 +141,29 @@ class ServicesController extends Controller
...
@@ -133,20 +141,29 @@ class ServicesController extends Controller
* 获取区域信息
* 获取区域信息
*/
*/
public
function
ApiZoneInfo
(
$request
)
{
public
function
ApiZoneInfo
(
$request
)
{
$params
=
$request
->
only
([
'limit'
,
'page'
,
'zone_sn'
,
'zone_name'
,
'store_name'
]);
$params
=
$request
->
only
([
'limit'
,
'page'
,
'zone_sn'
,
'zone_name'
,
'store_name'
,
'store_id'
]);
$arr
=
array
(
$arr
=
array
(
'limit'
=>
!
empty
(
$params
[
'limit'
])
?
$params
[
'limit'
]
:
10
,
'limit'
=>
!
empty
(
$params
[
'limit'
])
?
$params
[
'limit'
]
:
10
,
'page'
=>
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
,
'page'
=>
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
,
'zone_sn'
=>
!
empty
(
$params
[
'zone_sn'
])
?
$params
[
'zone_sn'
]
:
''
,
'zone_sn'
=>
!
empty
(
$params
[
'zone_sn'
])
?
$params
[
'zone_sn'
]
:
''
,
'zone_name'
=>
!
empty
(
$params
[
'zone_name'
])
?
$params
[
'zone_name'
]
:
''
,
'zone_name'
=>
!
empty
(
$params
[
'zone_name'
])
?
$params
[
'zone_name'
]
:
''
,
'store_name'
=>
!
empty
(
$params
[
'store_name'
])
?
$params
[
'store_name'
]
:
''
'store_name'
=>
!
empty
(
$params
[
'store_name'
])
?
$params
[
'store_name'
]
:
''
,
'store_id'
=>
$params
[
'store_id'
]
);
);
$data
=
(
new
ZoneModel
())
->
zoneInfo
(
$arr
);
$data
=
(
new
ZoneModel
())
->
zoneInfo
(
$arr
);
return
$this
->
apiReturn
(
$Errcode
=
0
,
$level
=
1
,
$dataArr
=
$data
);
return
$this
->
apiReturn
(
$Errcode
=
0
,
$level
=
1
,
$dataArr
=
$data
);
}
}
/**
/**
* 获取仓库列表
*/
public
function
ApiZoneList
(
$request
)
{
$data
=
(
new
ZoneModel
())
->
zoneList
();
return
$this
->
apiReturn
(
$Errcode
=
0
,
$level
=
1
,
$dataArr
=
$data
);
}
/**
* 插入仓库信息
* 插入仓库信息
*/
*/
public
function
ApiInsertZoneInfo
(
$request
)
{
public
function
ApiInsertZoneInfo
(
$request
)
{
...
@@ -201,13 +218,14 @@ class ServicesController extends Controller
...
@@ -201,13 +218,14 @@ class ServicesController extends Controller
* 获取货位信息
* 获取货位信息
*/
*/
public
function
ApiLocationInfo
(
$request
)
{
public
function
ApiLocationInfo
(
$request
)
{
$params
=
$request
->
only
([
'limit'
,
'page'
,
'location_name'
,
'zone_name'
]);
$params
=
$request
->
only
([
'limit'
,
'page'
,
'location_name'
,
'zone_name'
,
'store_id'
]);
$arr
=
array
(
$arr
=
array
(
'limit'
=>
!
empty
(
$params
[
'limit'
])
?
$params
[
'limit'
]
:
10
,
'limit'
=>
!
empty
(
$params
[
'limit'
])
?
$params
[
'limit'
]
:
10
,
'page'
=>
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
,
'page'
=>
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
,
'location_name'
=>
!
empty
(
$params
[
'location_name'
])
?
$params
[
'location_name'
]
:
''
,
'location_name'
=>
!
empty
(
$params
[
'location_name'
])
?
$params
[
'location_name'
]
:
''
,
'zone_name'
=>
!
empty
(
$params
[
'zone_name'
])
?
$params
[
'zone_name'
]
:
''
,
'zone_name'
=>
!
empty
(
$params
[
'zone_name'
])
?
$params
[
'zone_name'
]
:
''
,
'store_id'
=>
$params
[
'store_id'
]
);
);
$data
=
(
new
LocationModel
())
->
locInfo
(
$arr
);
$data
=
(
new
LocationModel
())
->
locInfo
(
$arr
);
return
$this
->
apiReturn
(
$Errcode
=
0
,
$level
=
1
,
$dataArr
=
$data
);
return
$this
->
apiReturn
(
$Errcode
=
0
,
$level
=
1
,
$dataArr
=
$data
);
...
@@ -287,12 +305,40 @@ class ServicesController extends Controller
...
@@ -287,12 +305,40 @@ class ServicesController extends Controller
*/
*/
public
function
ApiInsertGoodsInfo
(
$request
)
{
public
function
ApiInsertGoodsInfo
(
$request
)
{
$params
=
$request
->
only
([
'goods_name'
,
'goods_cn_name'
,
'brand_name'
,
'erp_goods_id'
,
'admin_name'
,
'admin_id'
]);
$params
=
$request
->
only
([
'goods_name'
,
'goods_cn_name'
,
'brand_name'
,
'erp_goods_id'
,
'admin_name'
,
'admin_id'
]);
if
(
empty
(
$params
[
'goods_name'
])
||
empty
(
$params
[
'
goods_cn_name'
])
||
empty
(
$params
[
'
brand_name'
])
||
empty
(
$params
[
'erp_goods_id'
])
||
empty
(
$params
[
'admin_id'
])
||
empty
(
$params
[
'admin_name'
]))
if
(
empty
(
$params
[
'goods_name'
])
||
empty
(
$params
[
'brand_name'
])
||
empty
(
$params
[
'erp_goods_id'
])
||
empty
(
$params
[
'admin_id'
])
||
empty
(
$params
[
'admin_name'
]))
return
$this
->
apiReturn
(
$Errcode
=
101
,
$level
=
1
,
$dataArr
=
[]);
return
$this
->
apiReturn
(
$Errcode
=
101
,
$level
=
1
,
$dataArr
=
[]);
$params
[
'add_time'
]
=
time
();
$params
[
'add_time'
]
=
time
();
$params
[
'update_time'
]
=
time
();
$params
[
'update_time'
]
=
time
();
$data
=
(
new
GoodsModel
())
->
InsertGoodsInfo
(
$params
);
$result
=
(
new
GoodsModel
())
->
InsertGoodsInfo
(
$params
);
if
(
!
$result
)
return
$this
->
apiReturn
(
$Errcode
=
102
,
$level
=
1
,
$dataArr
=
[]);
else
return
$this
->
apiReturn
(
$Errcode
=
100
,
$level
=
1
,
$dataArr
=
[]);
}
public
function
ApiUpdateGoodsInfo
(
$request
)
{
$params
=
$request
->
only
([
'goods_name'
,
'goods_cn_name'
,
'brand_name'
,
'erp_goods_id'
,
'admin_name'
,
'admin_id'
]);
if
(
empty
(
$params
[
'admin_id'
])
||
empty
(
$params
[
'admin_name'
])
||
empty
(
$params
[
'erp_goods_id'
]))
return
$this
->
apiReturn
(
$Errcode
=
101
,
$level
=
1
,
$dataArr
=
[]);
$arr
=
array
();
$arr
[
'admin_id'
]
=
$params
[
'admin_id'
];
$arr
[
'admin_name'
]
=
$params
[
'admin_name'
];
$arr
[
'erp_goods_id'
]
=
$params
[
'erp_goods_id'
];
$arr
[
'update_time'
]
=
time
();
if
(
!
empty
(
$params
[
'goods_name'
]))
$arr
[
'goods_name'
]
=
$params
[
'goods_name'
];
if
(
!
empty
(
$params
[
'goods_cn_name'
]))
$arr
[
'goods_cn_name'
]
=
$params
[
'goods_cn_name'
];
if
(
!
empty
(
$params
[
'brand_name'
]))
$arr
[
'brand_name'
]
=
$params
[
'brand_name'
];
$result
=
(
new
GoodsModel
())
->
updateGoodsInfo
(
$arr
);
if
(
!
$result
)
return
$this
->
apiReturn
(
$Errcode
=
103
,
$level
=
1
,
$dataArr
=
[]);
else
return
$this
->
apiReturn
(
$Errcode
=
100
,
$level
=
1
,
$dataArr
=
[]);
}
}
/**
/**
...
@@ -338,12 +384,12 @@ class ServicesController extends Controller
...
@@ -338,12 +384,12 @@ class ServicesController extends Controller
* 更新客户信息
* 更新客户信息
*/
*/
public
function
ApiUpdateCustomerInfo
(
$request
)
{
public
function
ApiUpdateCustomerInfo
(
$request
)
{
$params
=
$request
->
only
([
'
customer_id'
,
'
erp_client_sn'
,
'customer_name'
,
'erp_customer_id'
,
'admin_id'
,
'admin_name'
]);
$params
=
$request
->
only
([
'erp_client_sn'
,
'customer_name'
,
'erp_customer_id'
,
'admin_id'
,
'admin_name'
]);
if
(
empty
(
$params
[
'customer_id'
])
||
empty
(
$params
[
'admin_id'
])
||
empty
(
$params
[
'admin_name'
]))
if
(
empty
(
$params
[
'
erp_
customer_id'
])
||
empty
(
$params
[
'admin_id'
])
||
empty
(
$params
[
'admin_name'
]))
return
$this
->
apiReturn
(
$Errcode
=
101
,
$level
=
1
,
$dataArr
=
[]);
return
$this
->
apiReturn
(
$Errcode
=
101
,
$level
=
1
,
$dataArr
=
[]);
$arr
=
array
();
$arr
=
array
();
$arr
[
'
customer_id'
]
=
$params
[
'
customer_id'
];
$arr
[
'
erp_customer_id'
]
=
$params
[
'erp_
customer_id'
];
$arr
[
'admin_id'
]
=
$params
[
'admin_id'
];
$arr
[
'admin_id'
]
=
$params
[
'admin_id'
];
$arr
[
'admin_name'
]
=
$params
[
'admin_name'
];
$arr
[
'admin_name'
]
=
$params
[
'admin_name'
];
$arr
[
'update_time'
]
=
time
();
$arr
[
'update_time'
]
=
time
();
...
@@ -351,8 +397,6 @@ class ServicesController extends Controller
...
@@ -351,8 +397,6 @@ class ServicesController extends Controller
$arr
[
'erp_client_sn'
]
=
$params
[
'erp_client_sn'
];
$arr
[
'erp_client_sn'
]
=
$params
[
'erp_client_sn'
];
if
(
!
empty
(
$params
[
'customer_name'
]))
if
(
!
empty
(
$params
[
'customer_name'
]))
$arr
[
'customer_name'
]
=
$params
[
'customer_name'
];
$arr
[
'customer_name'
]
=
$params
[
'customer_name'
];
if
(
!
empty
(
$params
[
'erp_customer_id'
]))
$arr
[
'erp_customer_id'
]
=
$params
[
'erp_customer_id'
];
$result
=
(
new
CustomerModel
())
->
updateCustomerInfo
(
$arr
);
$result
=
(
new
CustomerModel
())
->
updateCustomerInfo
(
$arr
);
if
(
!
$result
)
if
(
!
$result
)
...
@@ -362,6 +406,29 @@ class ServicesController extends Controller
...
@@ -362,6 +406,29 @@ class ServicesController extends Controller
}
}
/**
/**
* 更新客户状态
*/
public
function
ApiUpdateCustomerStatus
(
$request
)
{
$params
=
$request
->
only
([
'status'
,
'erp_customer_id'
,
'admin_id'
,
'admin_name'
]);
if
(
empty
(
$params
[
'erp_customer_id'
])
||
empty
(
$params
[
'admin_id'
])
||
empty
(
$params
[
'admin_name'
])
||
$params
[
'status'
]
==
""
)
return
$this
->
apiReturn
(
$Errcode
=
101
,
$level
=
1
,
$dataArr
=
[]);
$arr
=
array
();
$arr
[
'erp_customer_id'
]
=
$params
[
'erp_customer_id'
];
$arr
[
'status'
]
=
(
int
)
$params
[
'status'
];
$arr
[
'admin_id'
]
=
$params
[
'admin_id'
];
$arr
[
'admin_name'
]
=
$params
[
'admin_name'
];
$arr
[
'update_time'
]
=
time
();
$result
=
(
new
CustomerModel
())
->
updateCustomerStatus
(
$arr
);
if
(
!
$result
)
return
$this
->
apiReturn
(
$Errcode
=
103
,
$level
=
1
,
$dataArr
=
[]);
else
return
$this
->
apiReturn
(
$Errcode
=
100
,
$level
=
1
,
$dataArr
=
[]);
}
/**
* 获取供应商信息
* 获取供应商信息
*/
*/
public
function
ApiSupplierInfo
(
$request
)
{
public
function
ApiSupplierInfo
(
$request
)
{
...
@@ -404,12 +471,12 @@ class ServicesController extends Controller
...
@@ -404,12 +471,12 @@ class ServicesController extends Controller
* 更新供应商信息
* 更新供应商信息
*/
*/
public
function
ApiUpdateSupplierInfo
(
$request
)
{
public
function
ApiUpdateSupplierInfo
(
$request
)
{
$params
=
$request
->
only
([
'
supplier_id'
,
'
erp_supplier_sn'
,
'supplier_name'
,
'erp_supplier_id'
,
'admin_id'
,
'admin_name'
]);
$params
=
$request
->
only
([
'erp_supplier_sn'
,
'supplier_name'
,
'erp_supplier_id'
,
'admin_id'
,
'admin_name'
]);
if
(
empty
(
$params
[
'supplier_id'
])
||
empty
(
$params
[
'admin_id'
])
||
empty
(
$params
[
'admin_name'
]))
if
(
empty
(
$params
[
'
erp_
supplier_id'
])
||
empty
(
$params
[
'admin_id'
])
||
empty
(
$params
[
'admin_name'
]))
return
$this
->
apiReturn
(
$Errcode
=
101
,
$level
=
1
,
$dataArr
=
[]);
return
$this
->
apiReturn
(
$Errcode
=
101
,
$level
=
1
,
$dataArr
=
[]);
$arr
=
array
();
$arr
=
array
();
$arr
[
'
supplier_id'
]
=
$params
[
'
supplier_id'
];
$arr
[
'
erp_supplier_id'
]
=
$params
[
'erp_
supplier_id'
];
$arr
[
'admin_id'
]
=
$params
[
'admin_id'
];
$arr
[
'admin_id'
]
=
$params
[
'admin_id'
];
$arr
[
'admin_name'
]
=
$params
[
'admin_name'
];
$arr
[
'admin_name'
]
=
$params
[
'admin_name'
];
$arr
[
'update_time'
]
=
time
();
$arr
[
'update_time'
]
=
time
();
...
@@ -417,9 +484,7 @@ class ServicesController extends Controller
...
@@ -417,9 +484,7 @@ class ServicesController extends Controller
$arr
[
'erp_supplier_sn'
]
=
$params
[
'erp_supplier_sn'
];
$arr
[
'erp_supplier_sn'
]
=
$params
[
'erp_supplier_sn'
];
if
(
!
empty
(
$params
[
'supplier_name'
]))
if
(
!
empty
(
$params
[
'supplier_name'
]))
$arr
[
'supplier_name'
]
=
$params
[
'supplier_name'
];
$arr
[
'supplier_name'
]
=
$params
[
'supplier_name'
];
if
(
!
empty
(
$params
[
'erp_supplier_id'
]))
$arr
[
'erp_supplier_id'
]
=
$params
[
'erp_supplier_id'
];
$result
=
(
new
SupplierModel
())
->
updateSupplierInfo
(
$arr
);
$result
=
(
new
SupplierModel
())
->
updateSupplierInfo
(
$arr
);
if
(
!
$result
)
if
(
!
$result
)
return
$this
->
apiReturn
(
$Errcode
=
103
,
$level
=
1
,
$dataArr
=
[]);
return
$this
->
apiReturn
(
$Errcode
=
103
,
$level
=
1
,
$dataArr
=
[]);
...
@@ -427,4 +492,48 @@ class ServicesController extends Controller
...
@@ -427,4 +492,48 @@ class ServicesController extends Controller
return
$this
->
apiReturn
(
$Errcode
=
100
,
$level
=
1
,
$dataArr
=
[]);
return
$this
->
apiReturn
(
$Errcode
=
100
,
$level
=
1
,
$dataArr
=
[]);
}
}
/**
* 更新供应商状态
*/
public
function
ApiUpdateSupplierStatus
(
$request
)
{
$params
=
$request
->
only
([
'status'
,
'erp_supplier_id'
,
'admin_id'
,
'admin_name'
]);
if
(
empty
(
$params
[
'erp_supplier_id'
])
||
empty
(
$params
[
'admin_id'
])
||
empty
(
$params
[
'admin_name'
])
||
$params
[
'status'
]
==
""
)
return
$this
->
apiReturn
(
$Errcode
=
101
,
$level
=
1
,
$dataArr
=
[]);
$arr
=
array
();
$arr
[
'erp_supplier_id'
]
=
$params
[
'erp_supplier_id'
];
$arr
[
'status'
]
=
(
int
)
$params
[
'status'
];
$arr
[
'admin_id'
]
=
$params
[
'admin_id'
];
$arr
[
'admin_name'
]
=
$params
[
'admin_name'
];
$arr
[
'update_time'
]
=
time
();
$result
=
(
new
SupplierModel
())
->
updateSupplierStatus
(
$arr
);
if
(
!
$result
)
return
$this
->
apiReturn
(
$Errcode
=
103
,
$level
=
1
,
$dataArr
=
[]);
else
return
$this
->
apiReturn
(
$Errcode
=
100
,
$level
=
1
,
$dataArr
=
[]);
}
/**
* 更新供应商状态
*/
public
function
ApiUpdateGoodsStatus
(
$request
)
{
$params
=
$request
->
only
([
'status'
,
'erp_goods_id'
,
'admin_id'
,
'admin_name'
]);
if
(
empty
(
$params
[
'erp_goods_id'
])
||
empty
(
$params
[
'admin_id'
])
||
empty
(
$params
[
'admin_name'
])
||
$params
[
'status'
]
==
""
)
return
$this
->
apiReturn
(
$Errcode
=
101
,
$level
=
1
,
$dataArr
=
[]);
$arr
=
array
();
$arr
[
'erp_goods_id'
]
=
$params
[
'erp_goods_id'
];
$arr
[
'status'
]
=
(
int
)
$params
[
'status'
];
$arr
[
'admin_id'
]
=
$params
[
'admin_id'
];
$arr
[
'admin_name'
]
=
$params
[
'admin_name'
];
$arr
[
'update_time'
]
=
time
();
$result
=
(
new
GoodsModel
())
->
updateGoodsStatus
(
$arr
);
if
(
!
$result
)
return
$this
->
apiReturn
(
$Errcode
=
103
,
$level
=
1
,
$dataArr
=
[]);
else
return
$this
->
apiReturn
(
$Errcode
=
100
,
$level
=
1
,
$dataArr
=
[]);
}
}
}
app/Http/Model/CustomerModel.php
View file @
72b348e9
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Http\Model
;
namespace
App\Http\Model
;
use
Common\Model\RedisModel
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Config
;
use
Config
;
use
DB
;
use
DB
;
...
@@ -15,6 +16,16 @@ class CustomerModel extends Model
...
@@ -15,6 +16,16 @@ class CustomerModel extends Model
protected
$table
=
'customer'
;
protected
$table
=
'customer'
;
public
$timestamps
=
false
;
public
$timestamps
=
false
;
public
function
__construct
(
$connection
=
false
)
{
parent
::
__construct
();
if
(
$connection
){
$this
->
connection
=
$connection
;
}
$this
->
redis
=
new
RedisModel
();
}
/**
/**
* 客户信息
* 客户信息
*/
*/
...
@@ -29,11 +40,15 @@ class CustomerModel extends Model
...
@@ -29,11 +40,15 @@ class CustomerModel extends Model
}
}
$data
=
$this
->
$data
=
$this
->
select
(
'erp_client_sn'
,
'customer_name'
,
'erp_customer_id'
)
->
select
(
'erp_client_sn'
,
'customer_name'
,
'erp_customer_id'
,
'status'
)
->
where
(
$map
)
->
where
(
$map
)
->
paginate
(
$limit
,[
'*'
],
'p'
,
$page
)
->
paginate
(
$limit
,[
'*'
],
'p'
,
$page
)
->
toArray
();
toArray
();
foreach
(
$data
[
'data'
]
as
$k
=>
$v
)
{
$data
[
'data'
][
$k
][
'status'
]
=
$v
[
'status'
]
=
0
?
'删除'
:
'存在'
;
}
return
$data
;
return
$data
;
}
}
...
@@ -41,13 +56,50 @@ class CustomerModel extends Model
...
@@ -41,13 +56,50 @@ class CustomerModel extends Model
* 写入客户信息
* 写入客户信息
*/
*/
public
function
insertCustomerInfo
(
$arr
)
{
public
function
insertCustomerInfo
(
$arr
)
{
return
$this
->
insert
(
$arr
);
$str
=
DB
::
connection
(
$this
->
connection
)
->
transaction
(
function
()
use
(
$arr
){
$erp_client_sn
=
$arr
[
'erp_client_sn'
];
$customer_id
=
$this
->
insertGetId
(
$arr
);
if
(
!
$customer_id
)
return
new
\Exception
(
"Error Processing Request"
);
$c2r
=
$this
->
cusId2Redis
(
$customer_id
,
json_encode
(
$arr
));
if
(
!
$c2r
)
return
new
\Exception
(
"Error Processing Request"
);
$sn2r
=
$this
->
cusSn2Redis
(
$erp_client_sn
,
$customer_id
);
if
(
!
$sn2r
)
return
new
\Exception
(
"Error Processing Request"
);
return
true
;
});
return
$str
;
}
}
/**
/**
* 更新客户信息
* 更新客户信息
*/
*/
public
function
updateCustomerInfo
(
$arr
)
{
public
function
updateCustomerInfo
(
$arr
)
{
return
$this
->
where
(
'customer_id'
,
'='
,
$arr
)
->
update
(
$arr
);
return
$this
->
where
(
'erp_customer_id'
,
'='
,
$arr
)
->
update
(
$arr
);
}
/**
* 更新客户状态
*/
public
function
updateCustomerStatus
(
$arr
)
{
return
$this
->
where
(
'erp_customer_id'
,
'='
,
$arr
)
->
update
(
$arr
);
}
/**
* 缓存客户信息
*/
private
function
cusId2Redis
(
$customer_id
,
$customer
)
{
return
$this
->
redis
->
hset
(
'scm_customer'
,
$customer_id
,
$customer
);
}
/**
* 缓存客户sn
*/
private
function
cusSn2Redis
(
$erp_client_sn
,
$customer_id
)
{
$encrypt_sn
=
md5
(
$erp_client_sn
);
return
$this
->
redis
->
hset
(
'scm_customer_erp_client_sn'
,
$encrypt_sn
,
$customer_id
);
}
}
}
}
\ No newline at end of file
app/Http/Model/GoodsModel.php
View file @
72b348e9
...
@@ -39,12 +39,16 @@ class GoodsModel extends Model
...
@@ -39,12 +39,16 @@ class GoodsModel extends Model
}
}
$data
=
$this
->
$data
=
$this
->
select
(
'goods_name'
,
'goods_cn_name'
,
'goods_sn'
,
'brand_name'
,
'erp_goods_id'
)
->
select
(
'goods_name'
,
'goods_cn_name'
,
'goods_sn'
,
'brand_name'
,
'erp_goods_id'
,
'status'
)
->
where
(
$map
)
->
where
(
$map
)
->
leftJoin
(
'brand'
,
'brand.brand_id'
,
'goods.
goods
_id'
)
->
leftJoin
(
'brand'
,
'brand.brand_id'
,
'goods.
brand
_id'
)
->
paginate
(
$limit
,[
'*'
],
'p'
,
$page
)
->
paginate
(
$limit
,[
'*'
],
'p'
,
$page
)
->
toArray
();
toArray
();
foreach
(
$data
[
'data'
]
as
$k
=>
$v
)
{
$data
[
'data'
][
$k
][
'status'
]
=
$v
[
'status'
]
=
0
?
'删除'
:
'存在'
;
}
return
$data
;
return
$data
;
}
}
...
@@ -58,41 +62,106 @@ class GoodsModel extends Model
...
@@ -58,41 +62,106 @@ class GoodsModel extends Model
$admin_id
=
$arr
[
'admin_id'
];
$admin_id
=
$arr
[
'admin_id'
];
$erp_id
=
$arr
[
'erp_goods_id'
];
$erp_id
=
$arr
[
'erp_goods_id'
];
$brand_exist
=
DB
::
connection
(
'mysql'
)
->
table
(
'brand'
)
->
select
(
'brand_id'
)
->
where
(
'brand_name'
,
'='
,
$brand_name
)
->
first
();
$brand_exist
=
DB
::
connection
(
'mysql'
)
->
table
(
'brand'
)
->
select
(
'brand_id'
)
->
where
(
'brand_name'
,
'='
,
$brand_name
)
->
first
();
// 品牌参数
$brand_params
=
array
(
'brand_name'
=>
$brand_name
,
'admin_name'
=>
$admin_name
,
'admin_id'
=>
$admin_id
,
'add_time'
=>
time
(),
'update_time'
=>
time
()
);
// 获取品牌ID,品牌不存在,则进行写入
// 获取品牌ID,品牌不存在,则进行写入
if
(
!
$brand_exist
)
{
if
(
!
$brand_exist
)
{
$brand_params
=
array
(
'brand_name'
=>
$brand_name
,
'admin_name'
=>
$admin_name
,
'admin_id'
=>
$admin_id
,
'add_time'
=>
time
(),
'update_time'
=>
time
()
);
$brand_id
=
DB
::
connection
(
'mysql'
)
->
table
(
'brand'
)
->
insertGetId
(
$brand_params
);
$brand_id
=
DB
::
connection
(
'mysql'
)
->
table
(
'brand'
)
->
insertGetId
(
$brand_params
);
// 缓存品牌
$this
->
brand2Redis
(
$brand_id
,
$brand_name
);
}
else
{
}
else
{
$brand_id
=
$brand_exist
->
brand_id
;
$brand_id
=
$brand_exist
->
brand_id
;
}
}
$arr
[
'brand_id'
]
=
$brand_id
;
$arr
[
'brand_id'
]
=
$brand_id
;
$arr
[
'goods_sn'
]
=
(
new
SnModel
())
->
sn
(
"goods_sn"
);
$arr
[
'goods_sn'
]
=
(
new
SnModel
())
->
sn
(
"goods_sn"
);
unset
(
$arr
[
'brand_name'
]);
unset
(
$arr
[
'brand_name'
]);
// 写入DB
// 写入DB
$goods_id
=
$this
->
insertGetId
(
$arr
);
$goods_id
=
$this
->
insertGetId
(
$arr
);
// 品牌不存在
if
(
!
$brand_exist
)
{
// 缓存品牌->品牌Id
$this
->
brandName2BrandId
(
$brand_name
,
$brand_id
);
// 缓存品牌id->品牌信息
$this
->
brandId2BrandInfo
(
$brand_id
,
json_encode
(
$brand_params
));
}
// ERPID GOODSID REDIS
// ERPID GOODSID REDIS
$this
->
erpId2GoodsId
(
$erp_id
,
$goods_id
);
$this
->
erpId2GoodsId
(
$erp_id
,
$goods_id
);
// GOODSID GOODS REDIS
// GOODSID GOODS REDIS
$this
->
goodsId2Goods
(
$goods_id
,
json_encode
(
$arr
));
$this
->
goodsId2Goods
(
$goods_id
,
json_encode
(
$arr
));
return
true
;
});
return
$str
;
}
/**
* 更新物料数据
*/
public
function
updateGoodsInfo
(
$arr
)
{
$str
=
DB
::
connection
(
$this
->
connection
)
->
transaction
(
function
()
use
(
$arr
){
$erp_goods_id
=
$arr
[
'erp_goods_id'
];
$admin_name
=
$arr
[
'admin_name'
];
$admin_id
=
$arr
[
'admin_id'
];
// 判断是否需要更新品牌
if
(
!
empty
(
$arr
[
'brand_name'
]))
{
$brand_name
=
$arr
[
'brand_name'
];
$brand_exist
=
DB
::
connection
(
'mysql'
)
->
table
(
'brand'
)
->
select
(
'brand_id'
)
->
where
(
'brand_name'
,
'='
,
$brand_name
)
->
first
();
$brand_params
=
array
(
'brand_name'
=>
$brand_name
,
'admin_name'
=>
$admin_name
,
'admin_id'
=>
$admin_id
,
'add_time'
=>
time
(),
'update_time'
=>
time
()
);
if
(
!
$brand_exist
)
{
$brand_id
=
DB
::
connection
(
'mysql'
)
->
table
(
'brand'
)
->
insertGetId
(
$brand_params
);
}
else
{
$brand_id
=
$brand_exist
->
brand_id
;
}
// 更新DB
unset
(
$arr
[
'brand_name'
]);
$arr
[
'brand_id'
]
=
$brand_id
;
$this
->
where
(
'erp_goods_id'
,
'='
,
$erp_goods_id
)
->
update
(
$arr
);
// 缓存品牌->品牌Id
$this
->
brandName2BrandId
(
$brand_name
,
$brand_id
);
// 缓存品牌id->品牌信息
$this
->
brandId2BrandInfo
(
$brand_id
,
json_encode
(
$brand_params
));
}
else
{
// 更新DB
$this
->
where
(
'erp_goods_id'
,
'='
,
$erp_goods_id
)
->
update
(
$arr
);
}
return
true
;
});
});
return
$str
;
}
/**
* 缓存品牌名(加密)、品牌Id
*/
private
function
brandName2BrandId
(
$brand_name
,
$brand_id
)
{
$encrypt_bn
=
md5
(
$brand_name
);
return
$this
->
redis
->
hset
(
'scm_brand_name'
,
$encrypt_bn
,
$brand_id
);
}
}
/**
/**
* 缓存品牌
* 缓存品牌
Id、品牌信息
*/
*/
private
function
brand2Redis
(
$brand_id
,
$brand_name
)
{
private
function
brandId2BrandInfo
(
$brand_id
,
$brand_info
)
{
$encrypt_bi
=
md5
(
$brand_id
);
return
$this
->
redis
->
hset
(
'scm_brand_info'
,
$brand_id
,
$brand_info
);
$this
->
redis
->
hset
(
'scm_brand'
,
$encrypt_bi
,
$brand_name
);
}
}
/**
/**
...
@@ -100,15 +169,20 @@ class GoodsModel extends Model
...
@@ -100,15 +169,20 @@ class GoodsModel extends Model
*/
*/
private
function
erpId2GoodsId
(
$erp_id
,
$goods_id
)
{
private
function
erpId2GoodsId
(
$erp_id
,
$goods_id
)
{
$encrypt_ei
=
md5
(
$erp_id
);
$encrypt_ei
=
md5
(
$erp_id
);
$this
->
redis
->
hset
(
'scm_goods_erp_id'
,
$encrypt_ei
,
$goods_id
);
return
$this
->
redis
->
hset
(
'scm_goods_erp_id'
,
$encrypt_ei
,
$goods_id
);
}
}
/**
/**
* GOODSID、GOODS 缓存
* GOODSID、GOODS 缓存
*/
*/
private
function
goodsId2Goods
(
$goods_id
,
$goods
)
{
private
function
goodsId2Goods
(
$goods_id
,
$goods
)
{
$encrypt_gi
=
md5
(
$goods_id
);
return
$this
->
redis
->
hset
(
'scm_goods_goods_id'
,
$goods_id
,
$goods
);
$this
->
redis
->
hset
(
'scm_goods_goods_id'
,
$encrypt_gi
,
$goods
);
}
}
/**
* 更新物料状态
*/
public
function
updateGoodsStatus
(
$arr
)
{
return
$this
->
where
(
'erp_goods_id'
,
'='
,
$arr
)
->
update
(
$arr
);
}
}
}
\ No newline at end of file
app/Http/Model/LocationModel.php
View file @
72b348e9
...
@@ -23,8 +23,10 @@ class LocationModel extends Model
...
@@ -23,8 +23,10 @@ class LocationModel extends Model
$page
=
$arr
[
'page'
];
$page
=
$arr
[
'page'
];
$location_name
=
$arr
[
'location_name'
];
$location_name
=
$arr
[
'location_name'
];
$zone_name
=
$arr
[
'zone_name'
];
$zone_name
=
$arr
[
'zone_name'
];
$store_id
=
$arr
[
'store_id'
];
$map
=
[];
$map
=
[];
$map
[]
=
[
'location.store_id'
,
'='
,
$store_id
];
if
(
!
empty
(
$zone_name
))
{
if
(
!
empty
(
$zone_name
))
{
$map
[]
=
[
'zone_name'
,
'='
,
$zone_name
];
$map
[]
=
[
'zone_name'
,
'='
,
$zone_name
];
}
}
...
@@ -33,9 +35,10 @@ class LocationModel extends Model
...
@@ -33,9 +35,10 @@ class LocationModel extends Model
}
}
$data
=
$this
->
$data
=
$this
->
select
(
'location_id'
,
'location_
name'
,
'zon
e_name'
)
->
select
(
'location_id'
,
'location_
sn'
,
'location_name'
,
'zone_name'
,
'stor
e_name'
)
->
where
(
$map
)
->
where
(
$map
)
->
leftJoin
(
'zone'
,
'zone.zone_id'
,
'location.zone_id'
)
->
leftJoin
(
'zone'
,
'zone.zone_id'
,
'location.zone_id'
)
->
leftJoin
(
'store'
,
'store.store_id'
,
'location.store_id'
)
->
paginate
(
$limit
,[
'*'
],
'p'
,
$page
)
->
paginate
(
$limit
,[
'*'
],
'p'
,
$page
)
->
toArray
();
toArray
();
...
...
app/Http/Model/StoreModel.php
View file @
72b348e9
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Http\Model
;
namespace
App\Http\Model
;
use
Common\Model\RedisModel
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Config
;
use
Config
;
use
DB
;
use
DB
;
...
@@ -15,6 +16,15 @@ class StoreModel extends Model
...
@@ -15,6 +16,15 @@ class StoreModel extends Model
protected
$table
=
'store'
;
protected
$table
=
'store'
;
public
$timestamps
=
false
;
public
$timestamps
=
false
;
public
function
__construct
(
$connection
=
false
)
{
parent
::
__construct
();
if
(
$connection
){
$this
->
connection
=
$connection
;
}
$this
->
redis
=
new
RedisModel
();
}
/**
/**
* 仓库基本信息
* 仓库基本信息
*/
*/
...
@@ -46,10 +56,33 @@ class StoreModel extends Model
...
@@ -46,10 +56,33 @@ class StoreModel extends Model
}
}
/**
/**
* 仓库列表
*/
public
function
storeList
()
{
$data
=
$this
->
select
(
'store_id'
,
'store_name'
)
->
get
();
return
$data
;
}
/**
* 写入仓库信息
* 写入仓库信息
*/
*/
public
function
insertStoreInfo
(
$arr
)
{
public
function
insertStoreInfo
(
$arr
)
{
return
$this
->
insert
(
$arr
);
$str
=
DB
::
connection
(
$this
->
connection
)
->
transaction
(
function
()
use
(
$arr
){
$erp_store_id
=
$arr
[
'erp_store_id'
];
$store_id
=
$this
->
insertGetId
(
$arr
);
if
(
!
$store_id
)
return
new
\Exception
(
"Error Processing Request"
);
$s2r
=
$this
->
storeId2Redis
(
$store_id
,
json_encode
(
$arr
));
if
(
!
$s2r
)
return
new
\Exception
(
"Error Processing Request"
);
$sn2r
=
$this
->
erpId2Redis
(
$erp_store_id
,
$store_id
);
if
(
!
$sn2r
)
return
new
\Exception
(
"Error Processing Request"
);
return
true
;
});
return
$str
;
}
}
/**
/**
...
@@ -57,6 +90,20 @@ class StoreModel extends Model
...
@@ -57,6 +90,20 @@ class StoreModel extends Model
*/
*/
public
function
updateStoreInfo
(
$arr
)
{
public
function
updateStoreInfo
(
$arr
)
{
return
$this
->
where
(
'store_id'
,
'='
,
$arr
)
->
update
(
$arr
);
return
$this
->
where
(
'store_id'
,
'='
,
$arr
)
->
update
(
$arr
);
}
/**
* 缓存仓库信息
*/
private
function
storeId2Redis
(
$store_id
,
$store
)
{
return
$this
->
redis
->
hset
(
'scm_store_info'
,
$store_id
,
$store
);
}
/**
* 缓存客户sn
*/
private
function
erpId2Redis
(
$erp_id
,
$store_id
)
{
$encrypt_ei
=
md5
(
$erp_id
);
return
$this
->
redis
->
hset
(
'scm_store_erp_id'
,
$encrypt_ei
,
$store_id
);
}
}
}
}
\ No newline at end of file
app/Http/Model/SupplierModel.php
View file @
72b348e9
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Http\Model
;
namespace
App\Http\Model
;
use
Common\Model\RedisModel
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Config
;
use
Config
;
use
DB
;
use
DB
;
...
@@ -15,6 +16,15 @@ class SupplierModel extends Model
...
@@ -15,6 +16,15 @@ class SupplierModel extends Model
protected
$table
=
'supplier'
;
protected
$table
=
'supplier'
;
public
$timestamps
=
false
;
public
$timestamps
=
false
;
public
function
__construct
(
$connection
=
false
)
{
parent
::
__construct
();
if
(
$connection
){
$this
->
connection
=
$connection
;
}
$this
->
redis
=
new
RedisModel
();
}
/**
/**
* 区域信息
* 区域信息
*/
*/
...
@@ -29,11 +39,15 @@ class SupplierModel extends Model
...
@@ -29,11 +39,15 @@ class SupplierModel extends Model
}
}
$data
=
$this
->
$data
=
$this
->
select
(
'erp_supplier_sn'
,
'supplier_name'
,
'erp_supplier_id'
)
->
select
(
'erp_supplier_sn'
,
'supplier_name'
,
'erp_supplier_id'
,
'status'
)
->
where
(
$map
)
->
where
(
$map
)
->
paginate
(
$limit
,[
'*'
],
'p'
,
$page
)
->
paginate
(
$limit
,[
'*'
],
'p'
,
$page
)
->
toArray
();
toArray
();
foreach
(
$data
[
'data'
]
as
$k
=>
$v
)
{
$data
[
'data'
][
$k
][
'status'
]
=
$v
[
'status'
]
=
0
?
'删除'
:
'存在'
;
}
return
$data
;
return
$data
;
}
}
...
@@ -41,14 +55,51 @@ class SupplierModel extends Model
...
@@ -41,14 +55,51 @@ class SupplierModel extends Model
* 写入供应商信息
* 写入供应商信息
*/
*/
public
function
insertSupplierInfo
(
$arr
)
{
public
function
insertSupplierInfo
(
$arr
)
{
return
$this
->
insert
(
$arr
);
$str
=
DB
::
connection
(
$this
->
connection
)
->
transaction
(
function
()
use
(
$arr
){
$erp_supplier_sn
=
$arr
[
'erp_supplier_sn'
];
$supplier_id
=
$this
->
insertGetId
(
$arr
);
if
(
!
$supplier_id
)
return
new
\Exception
(
"Error Processing Request"
);
$s2r
=
$this
->
supId2Redis
(
$supplier_id
,
json_encode
(
$arr
));
if
(
!
$s2r
)
return
new
\Exception
(
"Error Processing Request"
);
$sn2r
=
$this
->
supSn2Redis
(
$erp_supplier_sn
,
$supplier_id
);
if
(
!
$sn2r
)
return
new
\Exception
(
"Error Processing Request"
);
return
true
;
});
return
$str
;
}
}
/**
/**
* 更新供应商信息
* 更新供应商信息
*/
*/
public
function
updateSupplierInfo
(
$arr
)
{
public
function
updateSupplierInfo
(
$arr
)
{
return
$this
->
where
(
'supplier_id'
,
'='
,
$arr
)
->
update
(
$arr
);
return
$this
->
where
(
'erp_supplier_id'
,
'='
,
$arr
)
->
update
(
$arr
);
}
/**
* 更新供应商状态
*/
public
function
updateSupplierStatus
(
$arr
)
{
return
$this
->
where
(
'erp_supplier_id'
,
'='
,
$arr
)
->
update
(
$arr
);
}
/**
* 缓存供应商信息
*/
private
function
supId2Redis
(
$supplier_id
,
$supplier
)
{
return
$this
->
redis
->
hset
(
'scm_supplier'
,
$supplier_id
,
$supplier
);
}
/**
* 缓存供应商sn
*/
private
function
supSn2Redis
(
$erp_supplier_sn
,
$supplier_id
)
{
$encrypt_sn
=
md5
(
$erp_supplier_sn
);
return
$this
->
redis
->
hset
(
'scm_supplier_erp_supplier_sn'
,
$encrypt_sn
,
$supplier_id
);
}
}
}
}
\ No newline at end of file
app/Http/Model/ZoneModel.php
View file @
72b348e9
...
@@ -24,8 +24,10 @@ class ZoneModel extends Model
...
@@ -24,8 +24,10 @@ class ZoneModel extends Model
$zone_sn
=
$arr
[
'zone_sn'
];
$zone_sn
=
$arr
[
'zone_sn'
];
$zone_name
=
$arr
[
'zone_name'
];
$zone_name
=
$arr
[
'zone_name'
];
$store_name
=
$arr
[
'store_name'
];
$store_name
=
$arr
[
'store_name'
];
$store_id
=
$arr
[
'store_id'
];
$map
=
[];
$map
=
[];
$map
[]
=
[
'zone.store_id'
,
'='
,
$store_id
];
if
(
!
empty
(
$zone_sn
))
{
if
(
!
empty
(
$zone_sn
))
{
$map
[]
=
[
'zone_sn'
,
'='
,
$zone_sn
];
$map
[]
=
[
'zone_sn'
,
'='
,
$zone_sn
];
}
}
...
@@ -47,6 +49,14 @@ class ZoneModel extends Model
...
@@ -47,6 +49,14 @@ class ZoneModel extends Model
}
}
/**
/**
* 区域列表
*/
public
function
zoneList
()
{
$data
=
$this
->
select
(
'zone_id'
,
'zone_name'
)
->
get
();
return
$data
;
}
/**
* 写入仓库信息
* 写入仓库信息
*/
*/
public
function
insertZoneInfo
(
$arr
)
{
public
function
insertZoneInfo
(
$arr
)
{
...
...
scm_wms_common
@
65e023eb
Subproject commit 6
4218b258abb792578ff19cc0270d218625a734a
Subproject commit 6
5e023eb6471c8502f3306414c8982f58be7255b
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment