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
afd3967c
Commit
afd3967c
authored
Jul 31, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:增加拼单活动
parent
2ea3809a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
221 additions
and
19 deletions
+221
-19
MarketingException.php
application/exception/custom/MarketingException.php
+1
-0
PindanGoodsSku.php
application/models/goods/mysql/PindanGoodsSku.php
+66
-0
Marketing.php
application/models/marketing/mysql/Marketing.php
+1
-1
MarketingPindan.php
application/models/marketing/mysql/MarketingPindan.php
+50
-0
Marketing.php
application/modules/Marketing/controllers/Marketing.php
+11
-13
MarketingService.php
application/services/marketing/MarketingService.php
+92
-5
No files found.
application/exception/custom/MarketingException.php
View file @
afd3967c
...
...
@@ -27,5 +27,6 @@ class MarketingException extends BaseException
13
=>
'商品在其他互动已勾选'
,
14
=>
'开始时间不能大于等于结束时间'
,
15
=>
'分润比例不能大于50%'
,
16
=>
'当前填写的拼单活动名称已经存在'
,
];
}
\ No newline at end of file
application/models/goods/mysql/PindanGoodsSku.php
0 → 100644
View file @
afd3967c
<?php
namespace
App\Models\goods\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
/**
* Class PindanGoodsSku
* 拼单商品sku信息表
* @package App\Models\goods\mysql
*/
class
PindanGoodsSku
extends
MysqlBase
{
const
TABLE_NAME
=
'pindan_goods_sku'
;
const
CONFIG_INDEX
=
'goods'
;
const
STATUS_AUDIT
=
0
;
//待审核
const
STATUS_PASS
=
1
;
//审核通过
const
STATUS_REJECT
=
2
;
//审核驳回
const
ONLINE_STATUS_NO_ONLINE
=
0
;
//未上架
const
ONLINE_STATUS_ONLINE
=
1
;
//已上架
const
ONLINE_STATUS_OFFLINE
=
2
;
//已下架
public
static
function
getRecord
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
get
(
$columns
,
$where
);
}
public
static
function
getRecords
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
select
(
$columns
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
selectMaster
(
$columns
,
$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
getCount
(
$where
,
$columns
=
"*"
)
{
return
self
::
count
(
$columns
,
$where
);
}
}
\ No newline at end of file
application/models/marketing/mysql/Marketing.php
View file @
afd3967c
...
...
@@ -13,7 +13,7 @@ class Marketing extends MysqlBase
const
MARKETING_TYPE_FENXIAO
=
1
;
const
MARKETING_TYPE_TUANGOU
=
2
;
const
MARKETING_TYPE_MIAOSHA
=
3
;
const
MARKETING_TYPE_
JIELONG
=
4
;
const
MARKETING_TYPE_
PINDAN
=
4
;
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
...
...
application/models/marketing/mysql/MarketingPindan.php
0 → 100644
View file @
afd3967c
<?php
namespace
App\Models\marketing\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
MarketingPindan
extends
MysqlBase
{
const
TABLE_NAME
=
'marketing_pindan'
;
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'marketing_pindan_id'
;
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
insertRecord
(
$colums
)
{
return
self
::
insert
(
$colums
);
}
public
static
function
updateRecord
(
$colums
,
$where
)
{
return
self
::
update
(
$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
);
}
}
application/modules/Marketing/controllers/Marketing.php
View file @
afd3967c
...
...
@@ -8,7 +8,7 @@ use \Validate\MarketingGoodsRateValidate;
class
MarketingController
extends
Base
{
public
function
get_marketing_listAction
()
{
$params
=
$this
->
params
;
...
...
@@ -16,10 +16,10 @@ class MarketingController extends Base
$distributionList
[
'result'
]
=
$list
;
$this
->
success
(
$distributionList
);
}
/**
* 营销列表
* 后台管理
*
*/
public
function
marketing_listAction
()
{
...
...
@@ -31,17 +31,16 @@ class MarketingController extends Base
/**
* 创建活动
* 后台管理
*
*/
public
function
add_marketingAction
()
{
$params
=
$this
->
params
;
$addMarketing
=
MarketingService
::
addMarketing
(
$params
);
if
(
!
empty
(
$addMarketing
))
{
$this
->
success
();
$this
->
success
();
}
}
/**
* op后台获取创建活动
* 需要勾选的商品
...
...
@@ -57,7 +56,6 @@ class MarketingController extends Base
}
/**
* 更新数据
* 后台管理
...
...
@@ -70,9 +68,9 @@ class MarketingController extends Base
$where
[
'marketing_id'
]
=
!
empty
(
$params
[
'marketing_id'
])
?
$params
[
'marketing_id'
]
:
''
;
$param
=
[];
if
(
empty
(
$where
[
'marketing_id'
]))
{
throw
new
MarketingException
([
'cus'
=>
6
]);
throw
new
MarketingException
([
'cus'
=>
6
]);
}
if
(
!
empty
(
$params
[
'marketing_name'
]))
{
$param
[
'marketing_name'
]
=
$params
[
'marketing_name'
];
}
...
...
@@ -104,17 +102,17 @@ class MarketingController extends Base
if
(
!
empty
(
$params
[
'end_time'
]))
{
$param
[
'end_time'
]
=
$params
[
'end_time'
];
}
$srt
=
MarketingService
::
updateMarketing
(
$param
,
$where
);
$srt
=
MarketingService
::
updateMarketing
(
$param
,
$where
);
if
(
!
empty
(
$srt
))
{
$this
->
success
();
}
else
{
}
else
{
throw
new
MarketingException
([
'cus'
=>
7
]);
}
}
/**
* 获取详情数据
* 后台管理
...
...
application/services/marketing/MarketingService.php
View file @
afd3967c
...
...
@@ -3,14 +3,16 @@
namespace
App\Services\marketing
;
use
App\Models\goods\mysql\PindanGoodsSku
;
use
App\Models\marketing\mysql\Marketing
;
use
App\Models\marketing\mysql\MarketingGoods
;
use
App\Models\goods\mysql\GoodsSku
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpServices\Idgen\Idgen
;
use
App\Exception\custom\MarketingException
;
use
Api\PhpServices\Sensitive\Sensitive
;
use
App\Models\marketing\mysql\MarketingPindan
;
use
App\Services\common\CommonService
;
use
Daemon\Goods
;
class
MarketingService
...
...
@@ -188,8 +190,8 @@ class MarketingService
return
[];
}
else
if
(
$marketingType
==
Marketing
::
MARKETING_TYPE_MIAOSHA
)
{
return
[];
}
else
if
(
$marketingType
==
Marketing
::
MARKETING_TYPE_
JIELONG
)
{
return
self
::
add
Jielong
Marketing
(
$params
);
}
else
if
(
$marketingType
==
Marketing
::
MARKETING_TYPE_
PINDAN
)
{
return
self
::
add
Pindan
Marketing
(
$params
);
}
}
...
...
@@ -351,9 +353,94 @@ class MarketingService
}
}
private
static
function
addJielongMarketing
(
$params
)
/**
* 增加拼单活动
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws MarketingException
*/
private
static
function
addPindanMarketing
(
$params
)
{
return
[];
$marketingName
=
!
empty
(
$params
[
'marketing_name'
])
?
$params
[
'marketing_name'
]
:
''
;
$pindanPic
=
!
empty
(
$params
[
'pindan_pic'
])
?
$params
[
'pindan_pic'
]
:
''
;
$pindanDesc
=
!
empty
(
$params
[
'pindan_desc'
])
?
$params
[
'pindan_desc'
]
:
''
;
$createUserEmail
=
!
empty
(
$params
[
'op_cur_user'
])
?
$params
[
'op_cur_user'
]
:
''
;
$startTime
=
!
empty
(
$params
[
'start_time'
])
?
$params
[
'start_time'
]
:
''
;
$endTime
=
!
empty
(
$params
[
'end_time'
])
?
$params
[
'end_time'
]
:
''
;
$type
=
Marketing
::
MARKETING_TYPE_PINDAN
;
$goodsSkuId
=
!
empty
(
$params
[
'goods_sku_id'
])
?
explode
(
","
,
$params
[
'goods_sku_id'
])
:
[];
$publishLifeAccountId
=
111
;
//重复判断
$marketing
=
Marketing
::
getRecord
([
"marketing_name"
=>
$marketingName
],
[
"marketing_id"
]);
if
(
!
empty
(
$marketing
))
{
$marketingPindan
=
MarketingPindan
::
getRecord
([
"marketing_id"
=>
$marketing
[
"marketing_id"
]]);
if
(
!
empty
(
$marketingPindan
)
&&
$publishLifeAccountId
==
$marketingPindan
[
"publish_life_account_id"
])
{
throw
new
MarketingException
([
'cus'
=>
16
]);
}
}
if
(
empty
(
$goodsSkuId
))
{
throw
new
MarketingException
([
'cus'
=>
12
]);
}
//获取商品的最大最小值
$skuInfoList
=
PindanGoodsSku
::
getRecordMaster
([
"pindan_goods_sku_id"
=>
$goodsSkuId
]
,
[
"pindan_goods_sku_id"
,
"goods_spu_id"
,
"price"
]);
$priceList
=
[];
foreach
(
$skuInfoList
as
$skuInfo
)
{
$priceList
[]
=
$skuInfo
[
"price"
];
}
$uniquePriceList
=
array_unique
(
$priceList
);
sort
(
$uniquePriceList
);
$minPrice
=
$priceList
[
0
];
$maxPrice
=
end
(
$priceList
);
Marketing
::
beginTransaction
();
$marketingParams
=
[
'marketing_name'
=>
$marketingName
,
'start_time'
=>
$startTime
,
'end_time'
=>
$endTime
,
'online_status'
=>
1
,
'marketing_type'
=>
$type
,
'update_user_email'
=>
$createUserEmail
,
'update_time'
=>
date
(
"Y-m-d H:i:s"
),
'create_time'
=>
date
(
"Y-m-d H:i:s"
),
];
$marketingId
=
Marketing
::
insertRecord
(
$marketingParams
);
if
(
empty
(
$marketingId
))
{
Marketing
::
rollback
();
throw
new
MarketingException
([
'cus'
=>
5
]);
}
$pindanParams
=
[
"marketing_id"
=>
$marketingId
,
"publish_life_account_id"
=>
$publishLifeAccountId
,
"pindan_pic"
=>
$pindanPic
,
"pindan_desc"
=>
$pindanDesc
,
"min_price"
=>
$minPrice
,
"max_price"
=>
$maxPrice
,
];
$pindanId
=
MarketingPindan
::
insertRecord
(
$pindanParams
);
if
(
empty
(
$pindanId
))
{
Marketing
::
rollback
();
throw
new
MarketingException
([
'cus'
=>
5
]);
}
$marketingGoods
=
[];
foreach
(
$skuInfoList
as
$key
=>
$skuInfo
)
{
$marketingGoods
[
$key
][
"goods_spu_id"
]
=
$skuInfo
[
"goods_spu_id"
];
$marketingGoods
[
$key
][
"goods_sku_id"
]
=
$skuInfo
[
"pindan_goods_sku_id"
];
$marketingGoods
[
$key
][
"marketing_id"
]
=
$marketingId
;
}
MarketingGoods
::
save
(
$marketingGoods
);
if
(
!
Marketing
::
commit
())
{
Marketing
::
rollback
();
throw
new
MarketingException
([
"cus"
=>
5
]);
}
return
$pindanId
;
}
/**
...
...
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