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
55e02dc7
Commit
55e02dc7
authored
Jun 23, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:set
parent
1d47974b
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1219 additions
and
142 deletions
+1219
-142
Code.php
application/exception/custom/Code.php
+1
-1
DistributorException.php
application/exception/custom/DistributorException.php
+13
-1
MarketingException.php
application/exception/custom/MarketingException.php
+21
-0
Distribution.php
application/models/marketing/mysql/Distribution.php
+0
-0
DistributionGoods.php
application/models/marketing/mysql/DistributionGoods.php
+0
-0
Distributor.php
application/models/marketing/mysql/Distributor.php
+2
-2
DistributorAuditRecord.php
...ication/models/marketing/mysql/DistributorAuditRecord.php
+66
-0
Marketing.php
application/models/marketing/mysql/Marketing.php
+115
-0
MarketingGoods.php
application/models/marketing/mysql/MarketingGoods.php
+115
-0
Distribution.php
application/modules/Marketing/controllers/Distribution.php
+0
-0
Distributor.php
application/modules/Marketing/controllers/Distributor.php
+155
-0
Marketing.php
application/modules/Marketing/controllers/Marketing.php
+25
-22
Marketinggoods.php
application/modules/Marketing/controllers/Marketinggoods.php
+36
-0
DistributionGoodsService.php
...cation/services/distribution/DistributionGoodsService.php
+0
-32
DistributorService.php
application/services/distribution/DistributorService.php
+0
-83
DistributionService.php
application/services/marketing/DistributionService.php
+0
-0
DistributorService.php
application/services/marketing/DistributorService.php
+389
-0
MarketingGoodsService.php
application/services/marketing/MarketingGoodsService.php
+80
-0
MarketingService.php
application/services/marketing/MarketingService.php
+200
-0
application.ini
conf/application.ini
+1
-1
No files found.
application/exception/custom/Code.php
View file @
55e02dc7
...
...
@@ -17,6 +17,6 @@ class Code
const
SHOP
=
109000
;
const
DISTRIBUTOR
=
110000
;
const
DISTRIBUTION
=
111000
;
const
MARKETING
=
112000
;
}
\ No newline at end of file
application/exception/custom/DistributorException.php
View file @
55e02dc7
...
...
@@ -18,6 +18,18 @@ class DistributorException extends BaseException
protected
$cus
=
[
0
=>
'参数不能为空'
,
1
=>
'修改失败'
,
2
=>
'您已经是团长了,不需要重复申请'
,
3
=>
'姓名不能为空'
,
4
=>
'姓名不合法'
,
5
=>
'申请失败'
,
6
=>
'手机号不能为空'
,
7
=>
'手机号错误'
,
8
=>
'已经是二级团长了,不能再申请了'
,
9
=>
'分享码不能为空'
,
10
=>
'分享码无效'
,
11
=>
'短信验证码不能为空'
,
12
=>
'类型不能为空'
,
13
=>
'姓名不能大于40字符'
,
14
=>
'用户id不能能为空'
,
];
}
\ No newline at end of file
application/exception/custom/MarketingException.php
0 → 100644
View file @
55e02dc7
<?php
namespace
App\Exception\custom
;
use
App\Exception\BaseException
;
class
MarketingException
extends
BaseException
{
protected
$base_code
=
Code
::
MARKETING
;
protected
$cus
=
[
0
=>
'活动名称不能为空'
,
1
=>
'活动名称不能大于40'
,
2
=>
'活动名称不合法'
,
3
=>
'(一级)佣金率不能为空'
,
4
=>
'(二级)佣金率不能为空'
,
5
=>
'创建失败'
,
];
}
\ No newline at end of file
application/models/
distribution
/mysql/Distribution.php
→
application/models/
marketing
/mysql/Distribution.php
View file @
55e02dc7
File moved
application/models/
distribution
/mysql/DistributionGoods.php
→
application/models/
marketing
/mysql/DistributionGoods.php
View file @
55e02dc7
File moved
application/models/
distribution
/mysql/Distributor.php
→
application/models/
marketing
/mysql/Distributor.php
View file @
55e02dc7
<?php
namespace
App\Models\
distribution
\mysql
;
namespace
App\Models\
marketing
\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Distributor
extends
MysqlBase
{
const
TABLE_NAME
=
'distributor'
;
const
CONFIG_INDEX
=
'
distribution
'
;
const
CONFIG_INDEX
=
'
marketing
'
;
const
PRIMARY_KEY
=
'id'
;
public
static
function
getRecord
(
$where
,
$colums
=
[])
...
...
application/models/marketing/mysql/DistributorAuditRecord.php
0 → 100644
View file @
55e02dc7
<?php
namespace
App\Models\marketing\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
DistributorAuditRecord
extends
MysqlBase
{
const
TABLE_NAME
=
'distributor_audit_record'
;
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'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
);
}
public
static
function
getRecords
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
select
(
$colums
,
$where
);
}
public
static
function
getCount
(
$where
,
$columns
=
"*"
)
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
count
(
$columns
,
$where
);
}
}
application/models/marketing/mysql/Marketing.php
0 → 100644
View file @
55e02dc7
<?php
namespace
App\Models\marketing\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Marketing
extends
MysqlBase
{
const
TABLE_NAME
=
'marketing'
;
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'marketing_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
);
}
public
static
function
getMarketingList
(
$data
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
select
(
$colums
,
$data
);
}
public
static
function
getRecords
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
if
(
!
empty
(
$where
[
'marketing_name'
]))
{
$where
[
'marketing_name'
]
=
$where
[
'marketing_name'
];
}
if
(
!
empty
(
$where
))
{
$data
=
self
::
formatWhere
(
$where
);
}
if
(
!
empty
(
$where
[
'LIMIT'
]))
{
$data
[
'LIMIT'
]
=
$where
[
'LIMIT'
];
}
if
(
!
empty
(
$where
[
'ORDER'
]))
{
$data
[
'ORDER'
]
=
$where
[
'ORDER'
];
}
return
self
::
select
(
$colums
,
$data
);
}
public
static
function
getCount
(
$where
,
$columns
=
"*"
)
{
if
(
!
empty
(
$where
))
{
$where
=
self
::
formatWhere
(
$where
);
}
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
count
(
$columns
,
$where
);
}
public
static
function
formatWhere
(
$where
)
{
$data
=
[];
if
(
!
empty
(
$where
[
'marketing_name'
]))
{
$data
[
'marketing_name[~]'
]
=
$where
[
'marketing_name'
];
}
if
(
!
empty
(
$where
[
'marketing_id'
]))
{
$data
[
'marketing_id'
]
=
$where
[
'marketing_id'
];
}
if
(
!
empty
(
$where
[
'online_status'
]))
{
$data
[
'online_status'
]
=
$where
[
'online_status'
];
}
return
$data
;
}
}
application/models/marketing/mysql/MarketingGoods.php
0 → 100644
View file @
55e02dc7
<?php
namespace
App\Models\marketing\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
MarketingGoods
extends
MysqlBase
{
const
TABLE_NAME
=
'marketing_goods'
;
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'id'
;
public
static
function
marketingGoodsList
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
select
(
$colums
,
$where
);
}
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
);
}
public
static
function
getRecords
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
if
(
!
empty
(
$where
[
'marketing_name'
]))
{
$where
[
'marketing_name'
]
=
$where
[
'marketing_name'
];
}
if
(
!
empty
(
$where
))
{
$data
=
self
::
formatWhere
(
$where
);
}
if
(
!
empty
(
$where
[
'LIMIT'
]))
{
$data
[
'LIMIT'
]
=
$where
[
'LIMIT'
];
}
if
(
!
empty
(
$where
[
'ORDER'
]))
{
$data
[
'ORDER'
]
=
$where
[
'ORDER'
];
}
return
self
::
select
(
$colums
,
$data
);
}
public
static
function
getCount
(
$where
,
$columns
=
"*"
)
{
if
(
!
empty
(
$where
))
{
$where
=
self
::
formatWhere
(
$where
);
}
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
count
(
$columns
,
$where
);
}
public
static
function
formatWhere
(
$where
)
{
$data
=
[];
if
(
!
empty
(
$where
[
'marketing_name'
]))
{
$data
[
'marketing_name[~]'
]
=
$where
[
'marketing_name'
];
}
if
(
!
empty
(
$where
[
'marketing_id'
]))
{
$data
[
'marketing_id'
]
=
$where
[
'marketing_id'
];
}
if
(
!
empty
(
$where
[
'online_status'
]))
{
$data
[
'online_status'
]
=
$where
[
'online_status'
];
}
return
$data
;
}
}
application/modules/
Distribution
/controllers/Distribution.php
→
application/modules/
Marketing
/controllers/Distribution.php
View file @
55e02dc7
File moved
application/modules/Marketing/controllers/Distributor.php
0 → 100644
View file @
55e02dc7
<?php
use
App\Base\Base
;
use
App\Services\Marketing\DistributorService
;
use
App\Exception\custom\DistributorException
;
use
Api\PhpUtils\Validate\Validate
;
class
DistributorController
extends
Base
{
/**
* 二级团长列表
*
*/
public
function
second_distributor_listAction
()
{
$params
=
$this
->
params
;
$distributionList
=
DistributorService
::
secondDistributor
(
$params
);
$this
->
success
(
$distributionList
);
}
/**
* 申请团长
*
*/
public
function
apply_distributorAction
()
{
$params
=
$this
->
params
;
$distributionList
=
DistributorService
::
applyDistributor
(
$params
);
$this
->
success
();
}
/**
* 申请二级团长
*
*/
public
function
apply_second_distributorAction
()
{
$params
=
$this
->
params
;
$distributionList
=
DistributorService
::
applySecondDistributor
(
$params
);
$this
->
success
();
}
/**
* 申请发送短信
*
*/
public
function
send_sms_codeAction
()
{
$params
=
$this
->
params
;
$mobile
=
!
empty
(
$params
[
'mobile'
])
?
$params
[
'mobile'
]
:
''
;
if
(
empty
(
$mobile
))
{
throw
new
DistributorException
([
'cus'
=>
6
]);
}
$is_mobile
=
(
new
Validate
)
->
isMobile
(
$mobile
);
if
(
empty
(
$is_mobile
))
{
throw
new
DistributorException
([
'cus'
=>
7
]);
}
$params
=
[
'mobile'
=>
!
empty
(
$mobile
)
?
$mobile
:
''
,
];
$send_data
=
DistributorService
::
sendSmsCode
(
$params
);
if
(
!
empty
(
$send_data
)
&&
$send_data
[
'status'
]
==
'success'
&&
$send_data
[
'code'
]
==
0
)
{
$res
=
[
'reason'
=>
'ok'
,
];
$this
->
success
(
$res
);
}
else
{
$this
->
failed
(
$send_data
[
'code'
],
$send_data
[
'reason'
],
'failed'
);
die
();
}
}
/**
* 获取是否是
*
*/
public
function
distributorAction
()
{
$params
=
$this
->
params
;
$info
=
DistributorService
::
distributor
(
$params
);
$this
->
success
([
'result'
=>
$info
]);
}
/**
* 获取团长列表
* 后台管理
*
*/
public
function
get_distributor_listAction
()
{
$params
=
$this
->
params
;
$distributionList
=
DistributorService
::
getDistributorList
(
$params
);
$this
->
success
(
$distributionList
);
}
/**
* 获取详情数据
* 后台管理
*
*/
public
function
distributor_infoAction
()
{
$params
=
$this
->
params
;
$distributorInfo
=
DistributorService
::
distributorInfo
(
$params
);
$this
->
success
([
'result'
=>
$distributorInfo
]);
}
/**
* 更新数据
* 后台管理
*
*/
public
function
update_distributorAction
()
{
$params
=
$this
->
params
;
$where
[
'distributor_id'
]
=
$params
[
'distributor_id'
];
if
(
!
empty
(
$params
[
'audit_status'
]))
{
$param
[
'audit_status'
]
=
$params
[
'audit_status'
];
}
if
(
!
empty
(
$params
[
'audit_user_name'
]))
{
$param
[
'audit_user_name'
]
=
$params
[
'audit_user_name'
];
}
$srt
=
DistributorService
::
updateDistributor
(
$param
,
$where
);
if
(
!
empty
(
$srt
))
{
$this
->
success
();
}
else
{
throw
new
DistributorException
([
'cus'
=>
1
]);
}
}
/**
* 添加团长
* 后台管理
*
*/
public
function
add_distributorAction
()
{
}
}
\ No newline at end of file
application/modules/
Distribution/controllers/Distributor
.php
→
application/modules/
Marketing/controllers/Marketing
.php
View file @
55e02dc7
<?php
use
App\Base\Base
;
use
App\Services\
distribution\Distributor
Service
;
use
App\Exception\custom\
Distributor
Exception
;
class
Distributor
Controller
extends
Base
use
App\Services\
Marketing\Marketing
Service
;
use
App\Exception\custom\
Marketing
Exception
;
class
Marketing
Controller
extends
Base
{
/**
*
获取团长
列表
*
营销
列表
* 后台管理
*
*/
public
function
distributor
_listAction
()
public
function
marketing
_listAction
()
{
$params
=
$this
->
params
;
$distributionList
=
DistributorService
::
distributor
List
(
$params
);
$distributionList
=
MarketingService
::
marketing
List
(
$params
);
$this
->
success
(
$distributionList
);
}
/**
*
获取详情数据
*
添加团长
* 后台管理
*
*/
public
function
distributor_info
Action
()
public
function
add_marketing
Action
()
{
$params
=
$this
->
params
;
$distributorInfo
=
DistributorService
::
distributorInfo
(
$params
);
$this
->
success
([
'result'
=>
$distributorInfo
]);
$addMarketing
=
MarketingService
::
addMarketing
(
$params
);
if
(
!
empty
(
$addMarketing
))
{
$this
->
success
();
}
}
/**
* 更新数据
* 后台管理
*
*/
public
function
update_
distributor
Action
()
public
function
update_
marketing
Action
()
{
$params
=
$this
->
params
;
$where
[
'
distributor_id'
]
=
$params
[
'distributor
_id'
];
$where
[
'
marketing_id'
]
=
$params
[
'marketing
_id'
];
if
(
!
empty
(
$params
[
'audit_status'
]))
{
$param
[
'audit_status'
]
=
$params
[
'audit_status'
];
...
...
@@ -49,7 +53,7 @@ class DistributorController extends Base
$param
[
'audit_user_name'
]
=
$params
[
'audit_user_name'
];
}
$srt
=
DistributorService
::
updateDistributor
(
$param
,
$where
);
$srt
=
MarketingService
::
updateMarketing
(
$param
,
$where
);
if
(
!
empty
(
$srt
))
{
$this
->
success
();
...
...
@@ -57,20 +61,19 @@ class DistributorController extends Base
throw
new
DistributorException
([
'cus'
=>
1
]);
}
}
/**
*
添加团长
*
获取详情数据
* 后台管理
*
*/
public
function
add_distributor
Action
()
public
function
marketing_info
Action
()
{
$params
=
$this
->
params
;
$marketingInfo
=
MarketingService
::
marketingInfo
(
$params
);
$this
->
success
([
'result'
=>
$marketingInfo
]);
}
}
\ No newline at end of file
application/modules/Marketing/controllers/Marketinggoods.php
0 → 100644
View file @
55e02dc7
<?php
use
App\Base\Base
;
use
App\Services\Marketing\MarketingGoodsService
;
use
App\Exception\custom\DistributorException
;
class
MarketingGoodsController
extends
Base
{
/**
* 获取全部生效营销活动商品列表
*
*/
public
function
marketing_goods_listAction
()
{
$params
=
$this
->
params
;
// $marketingList = Marketing::getMarketingList(['online_status' => 1,'start_time' => date("Y-m-d H:i:s"),'end_time' => date("Y-m-d H:i:s")]);
// print_r( $marketingList);
// die();
$distributionList
=
MarketingGoodsService
::
marketingGoodsList
(
$params
);
print_r
(
$distributionList
);
die
();
$this
->
success
(
$distributionList
);
}
}
\ No newline at end of file
application/services/distribution/DistributionGoodsService.php
deleted
100644 → 0
View file @
1d47974b
<?php
namespace
App\Services\goods
;
use
App\Models\goods\mysql\Category
;
class
CategoryService
{
public
static
function
getCategoryList
()
{
//todo::加上redis
$allCaregoryList
=
Category
::
getRecordList
([],
[
'category_id'
,
'parent_category_id'
,
'name'
,
'level'
]);
$data
=
[];
if
(
!
empty
(
$allCaregoryList
))
{
foreach
(
$allCaregoryList
as
$caregory
)
{
if
(
$caregory
[
"level"
]
==
Category
::
LEVEL_1
)
{
$data
[
"level_1"
][]
=
[
"category_id"
=>
$caregory
[
"category_id"
],
"name"
=>
$caregory
[
"name"
]
];
}
if
(
$caregory
[
"level"
]
==
Category
::
LEVEL_2
)
{
$data
[
"level_2"
][
$caregory
[
"parent_category_id"
]][]
=
[
"category_id"
=>
$caregory
[
"category_id"
],
"name"
=>
$caregory
[
"name"
]
];
}
}
}
return
$data
;
}
}
\ No newline at end of file
application/services/distribution/DistributorService.php
deleted
100644 → 0
View file @
1d47974b
<?php
namespace
App\Services\distribution
;
use
App\Models\distribution\mysql\Distributor
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpServices\Idgen\Idgen
;
use
App\Exception\custom\DistributorException
;
class
DistributorService
{
/**
* 查询
*
*/
public
static
function
distributorList
(
$params
)
{
$params
[
'page'
]
=
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
;
$limit
=
!
empty
(
$params
[
'page_size'
])
?
$params
[
'page_size'
]
:
20
;
$page
=
(
$params
[
'page'
]
-
1
)
*
$limit
;
if
(
!
empty
(
$params
[
'audit_status'
]))
{
$where
[
'audit_status'
]
=
$params
[
'audit_status'
];
}
if
(
!
empty
(
$params
[
'audit_user_name'
]))
{
$where
[
'audit_user_name'
]
=
$params
[
'audit_user_name'
];
}
$where
[
'ORDER'
]
=
[
"create_time"
=>
"DESC"
];
$where
[
'LIMIT'
]
=
[
$page
,
$limit
];
$list
=
Distributor
::
getRecords
(
$where
);
unset
(
$where
[
'LIMIT'
]);
unset
(
$where
[
'ORDER'
]);
$count
=
Distributor
::
getCount
(
$where
);
$data
=
[
'result'
=>
$list
,
'count'
=>
$count
];
return
$data
;
}
public
static
function
distributorInfo
(
$params
)
{
$where
[
'distributor_id'
]
=
!
empty
(
$params
[
'distributor_id'
])
?
$params
[
'distributor_id'
]
:
''
;
$info
=
Distributor
::
getRecord
(
$where
);
return
$info
;
}
/**
* 更新数据
*
*/
public
static
function
updateDistributor
(
$params
,
$where
)
{
$where
[
'distributor_id'
]
=
!
empty
(
$where
[
'distributor_id'
])
?
$where
[
'distributor_id'
]
:
''
;
$info
=
Distributor
::
updateRecord
(
$params
,
$where
);
return
$info
;
}
/**
* 通过发号器拿 id (非雪花)
* number,获取店铺shop_id用生活号id后两位,商品相关的这里是shop_id的后两位
* @param $number
* @param $type
* @param int $count
* @return array|mixed
*/
public
static
function
getIdgenId
(
$number
,
$type
,
$count
=
1
)
{
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
$type
,
'number'
=>
(
int
)
$number
,
"count"
=>
$count
]]);
return
$res
[
'id_datetime'
][
$type
]
??
[];
}
public
static
function
getSnowIdgenId
(
$type
,
$count
=
1
)
{
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[[
"type"
=>
$type
,
"count"
=>
$count
]],
[]);
return
$res
[
'id_snow'
][
$type
]
??
[];
}
}
\ No newline at end of file
application/services/
distribution
/DistributionService.php
→
application/services/
marketing
/DistributionService.php
View file @
55e02dc7
File moved
application/services/marketing/DistributorService.php
0 → 100644
View file @
55e02dc7
This diff is collapsed.
Click to expand it.
application/services/marketing/MarketingGoodsService.php
0 → 100644
View file @
55e02dc7
<?php
namespace
App\Services\marketing
;
use
App\Models\marketing\mysql\Marketing
;
use
App\Models\marketing\mysql\MarketingGoods
;
use
App\Models\goods\mysql\GoodsSku
;
use
App\Models\goods\mysql\GoodsSpu
;
use
App\Models\shop\mysql\SubShop
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpServices\Idgen\Idgen
;
use
App\Exception\custom\MarketingException
;
use
Api\PhpServices\Sensitive\Sensitive
;
class
MarketingGoodsService
{
public
static
function
marketingGoodsList
(
$params
)
{
$where
=
[];
$marketingWhere
=
[
"end_time[>]"
=>
date
(
"Y-m-d"
),
"online_status"
=>
1
,
];
$marketingList
=
Marketing
::
getMarketingList
(
$marketingWhere
);
$marketingId
=
array_column
(
$marketingList
,
'marketing_id'
);
$where
[
'marketing_id'
]
=
!
empty
(
$marketingId
)
?
$marketingId
:
[];
$data
=
MarketingGoods
::
marketingGoodsList
(
$where
);
$goodsSkuId
=
array_column
(
$data
,
'goods_sku_id'
);
$goodsSkuList
=
GoodsSku
::
getRecordMaster
([
'goods_sku_id'
=>
$goodsSkuId
]);
$goodsSkuList
=
array_column
(
$goodsSkuList
,
null
,
'goods_sku_id'
);
$shopId
=
[];
foreach
(
$data
as
$key
=>
$value
)
{
$shopId
[
$key
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'shop_id'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'shop_id'
]
:
''
;
}
$subShopList
=
SubShop
::
getRecords
([
'shop_id'
=>
$shopId
]);
print_r
(
$subShopList
);
die
();
$list
=
[];
foreach
(
$data
as
$key
=>
$value
)
{
$list
[
$key
]
=
$value
;
$list
[
$key
][
'life_account_id'
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'life_account_id'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'life_account_id'
]
:
''
;
$list
[
$key
][
'shop_id'
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'shop_id'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'shop_id'
]
:
''
;
$list
[
$key
][
'goods_name'
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'name'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'name'
]
:
''
;
$list
[
$key
][
'goods_desc'
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'desc'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'desc'
]
:
''
;
$list
[
$key
][
'goods_spu_id'
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'goods_spu_id'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'goods_spu_id'
]
:
''
;
$list
[
$key
][
'original_price'
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'original_price'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'original_price'
]
:
''
;
$list
[
$key
][
'price'
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'price'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'price'
]
:
''
;
$list
[
$key
][
'total_amount_order'
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'total_amount_order'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'total_amount_order'
]
:
''
;
$list
[
$key
][
'url'
]
=
!
empty
(
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'url'
])
?
$goodsSkuList
[
$value
[
'goods_sku_id'
]][
'url'
]
:
''
;
$shopId
=
!
empty
(
$list
[
$key
][
'shop_id'
])
?
$list
[
$key
][
'shop_id'
]
:
''
;
}
return
$list
;
}
}
application/services/marketing/MarketingService.php
0 → 100644
View file @
55e02dc7
<?php
namespace
App\Services\marketing
;
use
App\Models\marketing\mysql\Marketing
;
use
App\Models\marketing\mysql\MarketingGoods
;
use
Api\PhpUtils\Validate\Validate
;
use
Api\PhpServices\Idgen\Idgen
;
use
App\Exception\custom\MarketingException
;
use
Api\PhpServices\Sensitive\Sensitive
;
class
MarketingService
{
/**
* 查询
*
*/
public
static
function
marketingList
(
$params
)
{
$params
[
'page'
]
=
!
empty
(
$params
[
'page'
])
?
$params
[
'page'
]
:
1
;
$limit
=
!
empty
(
$params
[
'page_size'
])
?
$params
[
'page_size'
]
:
20
;
$page
=
(
$params
[
'page'
]
-
1
)
*
$limit
;
if
(
!
empty
(
$params
[
'marketing_name'
]))
{
$where
[
'marketing_name'
]
=
$params
[
'marketing_name'
];
}
if
(
!
empty
(
$params
[
'marketing_id'
]))
{
$where
[
'marketing_id'
]
=
$params
[
'marketing_id'
];
}
if
(
!
empty
(
$params
[
'online_status'
]))
{
$where
[
'online_status'
]
=
$params
[
'online_status'
];
}
$where
[
'ORDER'
]
=
[
"create_time"
=>
"DESC"
];
$where
[
'LIMIT'
]
=
[
$page
,
$limit
];
$list
=
Marketing
::
getRecords
(
$where
);
unset
(
$where
[
'LIMIT'
]);
unset
(
$where
[
'ORDER'
]);
$count
=
Marketing
::
getCount
(
$where
);
$data
=
[
'result'
=>
$list
,
'count'
=>
$count
];
return
$data
;
}
public
static
function
addMarketing
(
$params
){
$marketingName
=
!
empty
(
$params
[
'marketing_name'
])
?
$params
[
'marketing_name'
]
:
''
;
$firstCommissionRate
=
!
empty
(
$params
[
'first_commission_rate'
])
?
$params
[
'first_commission_rate'
]
:
''
;
$secondCommissionRate
=
!
empty
(
$params
[
'second_commission_rate'
])
?
$params
[
'second_commission_rate'
]
:
''
;
$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
=
!
empty
(
$params
[
'type'
])
?
$params
[
'type'
]
:
1
;
$goodsSkuId
=
!
empty
(
$params
[
'goods_sku_id'
])
?
explode
(
","
,
$params
[
'goods_sku_id'
])
:
[];
if
(
empty
(
$marketingName
))
{
throw
new
MarketingException
([
'cus'
=>
0
]);
}
// if (empty($firstCommissionRate)) {
// throw new MarketingException(['cus'=>3]);
// }
// if (empty($secondCommissionRate)) {
// throw new MarketingException(['cus'=>4]);
// }
if
(
self
::
utf8Strlen
(
$marketingName
)
>
40
)
{
throw
new
MarketingException
([
'cus'
=>
1
]);
}
$detectParams
=
[
'businessId'
=>
1
,
'text'
=>
!
empty
(
$marketingName
)
?
$marketingName
:
''
,
'scene'
=>
1
,
];
$sensitive
=
(
new
Sensitive
)
->
detect
(
$detectParams
);
if
(
!
empty
(
$sensitive
[
'data'
]))
{
throw
new
MarketingException
([
'cus'
=>
2
]);
}
// //判断重复
// if (!self::isName($name)) {
// throw new ShopException(['cus'=>6]);
// }
//$res = self::getIdgenId(1, 'goods', $count = 1);
//$stores_id = !empty($res[0]) ? $res[0] : '';
Marketing
::
beginTransaction
();
$colums
=
[
//'marketing_id' => $marketing_id,
'marketing_name'
=>
$marketingName
,
'first_commission_rate'
=>
$firstCommissionRate
,
'second_commission_rate'
=>
$secondCommissionRate
,
'create_user_email'
=>
$createUserEmail
,
'good_count'
=>
0
,
'start_time'
=>
$startTime
,
'end_time'
=>
$endTime
,
'online_status'
=>
1
,
'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
(
$colums
);
if
(
empty
(
$marketingId
))
{
Marketing
::
rollback
();
throw
new
MarketingException
([
'cus'
=>
5
]);
}
$colums
=
[];
$goodCount
=
!
empty
(
$goodsSkuId
)
?
count
(
$goodsSkuId
)
:
0
;
foreach
(
$goodsSkuId
as
$key
=>
$value
)
{
$colums
[
$key
][
'marketing_id'
]
=
$marketingId
;
$colums
[
$key
][
'goods_spu_id'
]
=
$value
;
$colums
[
$key
][
'goods_sku_id'
]
=
''
;
$colums
[
$key
][
'update_time'
]
=
date
(
"Y-m-d H:i:s"
);
$colums
[
$key
][
'create_time'
]
=
date
(
"Y-m-d H:i:s"
);
}
$info
=
MarketingGoods
::
insertRecord
(
$colums
);
if
(
empty
(
$info
))
{
Marketing
::
rollback
();
throw
new
MarketingException
([
'cus'
=>
5
]);
}
$srt
=
Marketing
::
updateRecord
([
'good_count'
=>
$goodCount
],
[
'marketing_id'
=>
$marketingId
]);
if
(
!
empty
(
$srt
))
{
Marketing
::
commit
();
return
$srt
;
}
else
{
Marketing
::
rollback
();
throw
new
MarketingException
([
'cus'
=>
5
]);
}
}
/**
* 更新数据
*
*/
public
static
function
updateMarketing
(
$params
,
$where
)
{
$where
[
'marketing_id'
]
=
!
empty
(
$where
[
'marketing_id'
])
?
$where
[
'marketing_id'
]
:
''
;
$info
=
Marketing
::
updateRecord
(
$params
,
$where
);
return
$info
;
}
public
static
function
marketingInfo
(
$params
)
{
$where
[
'marketing_id'
]
=
!
empty
(
$params
[
'marketing_id'
])
?
$params
[
'marketing_id'
]
:
''
;
$info
=
Marketing
::
getRecord
(
$where
);
return
$info
;
}
/**
*判断长度
*
*/
public
static
function
utf8Strlen
(
$string
=
null
)
{
// 将字符串分解为单元
preg_match_all
(
"/./us"
,
$string
,
$match
);
// // 返回单元个数
return
count
(
$match
[
0
]);
}
/**
* 通过发号器拿 id (非雪花)
* number,获取店铺shop_id用生活号id后两位,商品相关的这里是shop_id的后两位
* @param $number
* @param $type
* @param int $count
* @return array|mixed
*/
public
static
function
getIdgenId
(
$number
,
$type
,
$count
=
1
)
{
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
$type
,
'number'
=>
(
int
)
$number
,
"count"
=>
$count
]]);
return
$res
[
'id_datetime'
][
$type
]
??
[];
}
public
static
function
getSnowIdgenId
(
$type
,
$count
=
1
)
{
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[[
"type"
=>
$type
,
"count"
=>
$count
]],
[]);
return
$res
[
'id_snow'
][
$type
]
??
[];
}
}
\ No newline at end of file
conf/application.ini
View file @
55e02dc7
...
...
@@ -3,7 +3,7 @@ application.directory = APP_PATH
application.bootstrap
=
APP_PATH "/Bootstrap.php"
application.library
=
APP_PATH"/library"
application.library.namespace
=
""
application.modules
=
"Index,Test,Goods,Shop,
Distribution
"
application.modules
=
"Index,Test,Goods,Shop,
Marketing
"
appid
=
"goods"
;AES密钥
...
...
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