Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
41919cd2
Commit
41919cd2
authored
Jun 15, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:删除原门店和套餐代码
parent
78388986
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
305 deletions
+0
-305
Setmeal.php
application/models/goods/mysql/Setmeal.php
+0
-50
Stores.php
application/models/goods/mysql/Stores.php
+0
-50
Goods.php
application/modules/Goods/controllers/Goods.php
+0
-53
SetmealService.php
application/services/goods/SetmealService.php
+0
-99
StoresService.php
application/services/goods/StoresService.php
+0
-53
No files found.
application/models/goods/mysql/Setmeal.php
deleted
100644 → 0
View file @
78388986
<?php
namespace
App\Models\goods\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
/**
* Class Setmeal
* 套餐
* @package App\Models\goods\mysql
*/
class
Setmeal
extends
MysqlBase
{
const
TABLE_NAME
=
'setmeal'
;
const
CONFIG_INDEX
=
'goods'
;
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
get
(
$colums
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
selectMaster
(
$colums
,
$where
);
}
public
static
function
save
(
$data
,
$where
=
[])
{
if
(
empty
(
$where
))
{
return
self
::
insert
(
$data
);
}
return
self
::
update
(
$data
,
$where
);
}
public
static
function
deleteRecord
(
$where
)
{
return
self
::
delete
(
$where
);
}
public
static
function
getAll
(
$goodsSkuId
)
{
return
self
::
select
(
'*'
,
[
'goods_sku_id'
=>
$goodsSkuId
]);
}
}
\ No newline at end of file
application/models/goods/mysql/Stores.php
deleted
100644 → 0
View file @
78388986
<?php
namespace
App\Models\goods\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
/**
* Class Stores
* 门店
* @package App\Models\goods\mysql
*/
class
Stores
extends
MysqlBase
{
const
TABLE_NAME
=
'stores'
;
const
CONFIG_INDEX
=
'goods'
;
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
get
(
$colums
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
selectMaster
(
$colums
,
$where
);
}
public
static
function
save
(
$data
,
$where
=
[])
{
if
(
empty
(
$where
))
{
return
self
::
insert
(
$data
);
}
return
self
::
update
(
$data
,
$where
);
}
public
static
function
deleteRecord
(
$where
)
{
return
self
::
delete
(
$where
);
}
public
static
function
getAll
(
$lifeAccountId
)
{
return
self
::
select
(
'*'
,
[
'life_account_id'
=>
$lifeAccountId
]);
}
}
\ No newline at end of file
application/modules/Goods/controllers/Goods.php
View file @
41919cd2
...
@@ -99,59 +99,6 @@ class GoodsController extends Base
...
@@ -99,59 +99,6 @@ class GoodsController extends Base
}
}
/**
* 套餐列表
* todo::可能会去掉
*/
public
function
setmeal_listAction
()
{
(
new
SetmealListValidate
())
->
validate
();
$params
=
$this
->
params
;
$goodSkuId
=
$params
[
"goods_sku_id"
];
$list
=
SetmealService
::
getSetmealList
(
$goodSkuId
);
$this
->
success
([
"data"
=>
$list
]);
}
/**
* 编辑套餐, 只支持编辑,不支持增加(因为增加时候还没有skuid)
* 这里套餐能一次传多个过来,这里按套餐数组处理
*/
public
function
edit_setmealAction
()
{
(
new
EditSetmealValidate
())
->
validate
();
$params
=
$this
->
params
;
SetmealService
::
editSetmeal
(
$params
);
$this
->
success
();
}
/**
* 门店列表
* @throws \App\Exception\custom\ParamException
*/
public
function
stores_listAction
()
{
(
new
StoresListValidate
())
->
validate
();
$params
=
$this
->
params
;
$lifeAccountId
=
$params
[
"life_account_id"
];
$list
=
StoresService
::
getStoresList
(
$lifeAccountId
);
$this
->
success
([
"data"
=>
$list
]);
}
/**
* 编辑门店
*/
public
function
edit_storesAction
()
{
(
new
EditStoresValidate
())
->
validate
();
$params
=
$this
->
params
;
StoresService
::
editStores
(
$params
);
$this
->
success
();
}
/**
/**
* op后台:商品列表 (spu list)
* op后台:商品列表 (spu list)
*/
*/
...
...
application/services/goods/SetmealService.php
deleted
100644 → 0
View file @
78388986
<?php
namespace
App\Services\goods
;
use
App\Exception\custom\GoodsException
;
use
App\Models\goods\mysql\GoodsSpu
;
use
App\Models\goods\mysql\Setmeal
;
use
App\Models\goods\mysql\Stores
;
class
SetmealService
{
/**
* @param array $params
* 编辑套餐
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws GoodsException
*/
public
static
function
editSetmeal
(
$params
=
[])
{
$lifeAccountId
=
$params
[
"life_account_id"
];
$goodsSkuId
=
$params
[
"good_sku_id"
];
$setmealData
=
json_decode
(
$params
[
'setmeal_data'
],
true
);
Setmeal
::
beginTransaction
();
$updateData
=
$insertData
=
[];
foreach
(
$setmealData
as
$key
=>
$setmeal
)
{
if
(
empty
(
$setmeal
[
"name"
])
||
empty
(
$setmeal
[
"unit"
])
||
empty
(
$setmeal
[
"unit_number"
])
||
empty
(
$setmeal
[
"unit_price"
]))
{
throw
new
GoodsException
([
'cus'
=>
8
]);
}
if
(
!
empty
(
$setmeal
[
"setmeal_id"
]))
{
$updateData
[]
=
[
'setmeal_id'
=>
$setmeal
[
"setmeal_id"
],
'life_account_id'
=>
$lifeAccountId
,
'goods_sku_id'
=>
$goodsSkuId
,
'name'
=>
$setmeal
[
"name"
],
'unit'
=>
$setmeal
[
"unit"
],
'unit_number'
=>
$setmeal
[
"unit_number"
],
'unit_price'
=>
$setmeal
[
"unit_price"
]
*
100
,
];
}
else
{
$insertData
[]
=
[
'life_account_id'
=>
$lifeAccountId
,
'goods_sku_id'
=>
$goodsSkuId
,
'name'
=>
$setmeal
[
"name"
],
'unit'
=>
$setmeal
[
"unit"
],
'unit_number'
=>
$setmeal
[
"unit_number"
],
'unit_price'
=>
$setmeal
[
"unit_price"
]
*
100
,
];
}
}
if
(
!
empty
(
$insertData
))
{
$ids
=
GoodsService
::
getIdgenId
(
substr
(
$lifeAccountId
,
-
2
),
"goods"
,
count
(
$insertData
));
if
(
empty
(
$ids
))
{
throw
new
GoodsException
([
'cus'
=>
6
]);
}
foreach
(
$insertData
as
$insertKey
=>
$item
)
{
//判断重复
$setmeal
=
Setmeal
::
getRecordMaster
([
"goods_sku_id"
=>
$goodsSkuId
,
"name"
=>
$item
[
"name"
]]);
if
(
!
empty
(
$setmeal
))
{
throw
new
GoodsException
([
'cus'
=>
7
]);
}
$item
[
"setmeal_id"
]
=
$ids
[
$insertKey
];
Setmeal
::
save
(
$item
);
}
}
if
(
!
empty
(
$updateData
))
{
foreach
(
$updateData
as
$item
)
{
//todo::update去重
$where
=
[];
$where
[
"setmeal_id"
]
=
$item
[
"setmeal_id"
];
unset
(
$item
[
"setmeal_id"
]);
Setmeal
::
save
(
$item
,
$where
);
}
}
if
(
!
Setmeal
::
commit
())
{
Setmeal
::
rollback
();
throw
new
GoodsException
([
"cus"
=>
5
]);
}
}
/**
* @param $goodSkuId
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
getSetmealList
(
$goodSkuId
)
{
$list
=
Setmeal
::
getAll
(
$goodSkuId
);
if
(
!
empty
(
$list
))
{
foreach
(
$list
as
$key
=>
$item
)
{
$list
[
$key
][
"unit_price"
]
=
$item
[
"unit_price"
]
/
100
;
}
}
return
$list
;
}
}
\ No newline at end of file
application/services/goods/StoresService.php
deleted
100644 → 0
View file @
78388986
<?php
namespace
App\Services\goods
;
use
App\Exception\custom\GoodsException
;
use
App\Models\goods\mysql\Stores
;
class
StoresService
{
/**
* @param array $params
* 编辑门店
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws GoodsException
*/
public
static
function
editStores
(
$params
=
[])
{
$data
=
$where
=
[];
$lifeAccountId
=
$params
[
"life_account_id"
];
$name
=
$params
[
"name"
];
if
(
!
empty
(
$params
[
"stores_id"
]))
{
$where
[
"stores_id"
]
=
$params
[
"stores_id"
];
}
else
{
$stores
=
Stores
::
getRecordMaster
([
"life_account_id"
=>
$lifeAccountId
,
"name"
=>
$name
]);
if
(
!
empty
(
$stores
))
{
throw
new
GoodsException
([
'cus'
=>
4
]);
}
$res
=
GoodsService
::
getIdgenId
(
substr
(
$lifeAccountId
,
-
2
),
"goods"
);
if
(
empty
(
$res
))
{
throw
new
GoodsException
([
'cus'
=>
3
]);
}
$data
[
"stores_id"
]
=
$res
[
"0"
];
}
$data
[
"name"
]
=
$name
;
$data
[
"address_lng"
]
=
$params
[
"address_lng"
];
$data
[
"address_lat"
]
=
$params
[
"address_lat"
];
$data
[
"address"
]
=
$params
[
"address"
];
$data
[
"phone"
]
=
$params
[
"phone"
];
$data
[
"life_account_id"
]
=
$params
[
"life_account_id"
];
return
Stores
::
save
(
$data
,
$where
);
}
/**
* @param $lifeAccountId
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
getStoresList
(
$lifeAccountId
)
{
return
Stores
::
getAll
(
$lifeAccountId
);
}
}
\ No newline at end of file
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