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
cd2be1bc
Commit
cd2be1bc
authored
Jul 31, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Plain Diff
update:处理冲突
parents
afd3967c
2167735e
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
632 additions
and
2 deletions
+632
-2
MarketingException.php
application/exception/custom/MarketingException.php
+6
-1
OtaValidate.php
application/library/Validate/OtaValidate.php
+48
-0
TakePlaceValidate.php
application/library/Validate/TakePlaceValidate.php
+60
-0
Ota.php
application/models/goods/mysql/Ota.php
+20
-0
MarketingTakePlace.php
application/models/marketing/mysql/MarketingTakePlace.php
+17
-0
TakePlace.php
application/models/marketing/mysql/TakePlace.php
+52
-0
Ota.php
application/modules/Goods/controllers/Ota.php
+74
-0
Spell.php
application/modules/Marketing/controllers/Spell.php
+64
-0
TakePlace.php
application/modules/Marketing/controllers/TakePlace.php
+74
-0
OtaService.php
application/services/goods/OtaService.php
+88
-0
MarketingService.php
application/services/marketing/MarketingService.php
+1
-1
TakePlaceService.php
application/services/marketing/TakePlaceService.php
+128
-0
No files found.
application/exception/custom/MarketingException.php
View file @
cd2be1bc
...
...
@@ -10,6 +10,9 @@ class MarketingException extends BaseException
{
protected
$base_code
=
Code
::
MARKETING
;
const
LIFE_ACCOUNT_NO_EXIST
=
16
;
const
RELATION_ALREADY_EXIST
=
17
;
protected
$cus
=
[
0
=>
'活动名称不能为空'
,
1
=>
'活动名称不能大于50'
,
...
...
@@ -27,6 +30,8 @@ class MarketingException extends BaseException
13
=>
'商品在其他互动已勾选'
,
14
=>
'开始时间不能大于等于结束时间'
,
15
=>
'分润比例不能大于50%'
,
16
=>
'当前填写的拼单活动名称已经存在'
,
self
::
LIFE_ACCOUNT_NO_EXIST
=>
'生活号不存在'
,
self
::
RELATION_ALREADY_EXIST
=>
'该关联记录已存在'
,
18
=>
'当前填写的拼单活动名称已经存在'
,
];
}
\ No newline at end of file
application/library/Validate/OtaValidate.php
0 → 100644
View file @
cd2be1bc
<?php
namespace
Validate
;
/**
* Class addValidate
*
* @package Validate
*/
class
OtaValidate
extends
\Validate\BaseValidate
{
protected
$rule
=
[
'ota_name'
=>
'require'
,
'ota_id'
=>
'require'
,
'offset'
=>
'egt:0'
,
'limit'
=>
'elt:100'
,
];
protected
$message
=
[
"ota_name"
=>
"供应商名称不能为空"
,
"ota_id"
=>
"ota_id不能为空"
,
"offset"
=>
"偏移量不能小于0"
,
"limit"
=>
"单次不能大于100条"
,
];
public
function
sceneList
()
{
return
$this
->
only
([
'offset'
,
'limit'
]);
}
public
function
sceneAdd
()
{
return
$this
->
only
([
'ota_name'
]);
}
public
function
sceneDelete
()
{
return
$this
->
only
([
'ota_id'
]);
}
public
function
sceneUpdate
()
{
return
$this
->
only
([
'ota_id'
]);
}
}
\ No newline at end of file
application/library/Validate/TakePlaceValidate.php
0 → 100644
View file @
cd2be1bc
<?php
namespace
Validate
;
/**
* Class addValidate
*
* @package Validate
*/
class
TakePlaceValidate
extends
\Validate\BaseValidate
{
protected
$rule
=
[
'take_place_id'
=>
'require'
,
'name'
=>
'require'
,
'address'
=>
'require'
,
'longitude'
=>
'require'
,
'latitude'
=>
'require'
,
'province'
=>
'require'
,
'city'
=>
'require'
,
'area'
=>
'require'
,
'offset'
=>
'egt:0'
,
'limit'
=>
'elt:100'
,
];
protected
$message
=
[
"take_place_id"
=>
"take_place_id不能为空"
,
"marketing_pindan_id"
=>
"marketing_pindan_id不能为空"
,
"name"
=>
"自提点名称不能为空"
,
"address"
=>
"详细地址不能为空"
,
"longitude"
=>
"经度不能为空"
,
"latitude"
=>
"纬度不能为空"
,
"province"
=>
"省不能为空"
,
"city"
=>
"市不能为空"
,
"area"
=>
"区不能为空"
,
"offset"
=>
"偏移量不能小于0"
,
"limit"
=>
"单次不能大于100条"
,
];
public
function
sceneList
()
{
return
$this
->
only
([
'offset'
,
'limit'
]);
}
public
function
sceneAdd
()
{
return
$this
->
only
([
'name'
,
'address'
,
'longitude'
,
'latitude'
,
'province'
,
'city'
,
'area'
]);
}
public
function
sceneDelete
()
{
return
$this
->
only
([
'take_place_id'
]);
}
public
function
sceneBindList
()
{
return
$this
->
append
([
'marketing_pindan_id'
=>
'require'
])
->
only
([
'marketing_pindan_id'
,
'offset'
,
'limit'
]);
}
}
\ No newline at end of file
application/models/goods/mysql/Ota.php
0 → 100644
View file @
cd2be1bc
<?php
namespace
App\Models\goods\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
/**
* 供应商
* Class Ota
* @package App\Models\goods\mysql
*/
class
Ota
extends
MysqlBase
{
const
TABLE_NAME
=
'ota'
;
const
CONFIG_INDEX
=
'goods'
;
const
PRIMARY_KEY
=
'id'
;
const
STATUS_NORMAL
=
0
;
// 正常
const
STATUS_DELETE
=
1
;
// 删除
}
application/models/marketing/mysql/MarketingTakePlace.php
0 → 100644
View file @
cd2be1bc
<?php
namespace
App\Models\marketing\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
/**
* 拼单活动和自提点关联
* Class MarketingTakePlace
* @package App\Models\marketing\mysql
*/
class
MarketingTakePlace
extends
MysqlBase
{
const
TABLE_NAME
=
'marketing_take_place'
;
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'marketing_take_place_id'
;
}
application/models/marketing/mysql/TakePlace.php
0 → 100644
View file @
cd2be1bc
<?php
namespace
App\Models\marketing\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
/**
* 自提点
* Class TakePlace
* @package App\Models\marketing\mysql
*/
class
TakePlace
extends
MysqlBase
{
const
TABLE_NAME
=
'take_place'
;
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'take_place_id'
;
const
STATUS_NORMAL
=
0
;
// 正常
const
STATUS_DELETE
=
1
;
// 删除
/**
* 获取
* @param $keywords
* @param int $offset
* @param int $limit
* @return mixed
*/
public
static
function
searchList
(
$keywords
,
$offset
=
0
,
$limit
=
20
)
{
if
(
$keywords
)
{
$where
=
[
'AND'
=>
[
'OR'
=>
[
'take_place_name[~]'
=>
$keywords
,
'contact_name[~]'
=>
$keywords
,
],
'is_delete'
=>
TakePlace
::
STATUS_NORMAL
,
],
];
}
else
{
$where
=
[
'is_delete'
=>
TakePlace
::
STATUS_NORMAL
];
}
$where
[
'ORDER'
]
=
[
'take_place_id'
=>
'DESC'
];
$where
[
'LIMIT'
]
=
[
$offset
,
$limit
];
// $e = TakePlace::debug();
$res
[
'list'
]
=
self
::
select
(
'*'
,
$where
);
$res
[
'total'
]
=
self
::
count
(
'*'
,
$where
);
return
$res
;
}
}
application/modules/Goods/controllers/Ota.php
0 → 100644
View file @
cd2be1bc
<?php
/**
* Author : Tengda
* Date : 2021/7/29
* Time : 11:12 上午
*/
use
App\Base\Base
;
use
App\Services\goods\OtaService
;
use
\Validate\Ota\getBindListValidate
;
use
Validate\otaValidate
;
class
OtaController
extends
Base
{
/**
* 供应商列表
*/
public
function
listAction
()
{
(
new
otaValidate
())
->
scene
(
'list'
)
->
validate
();
$name
=
$this
->
params
[
'ota_name'
]
??
''
;
$printerSn
=
$this
->
params
[
'printer_sn'
]
??
''
;
$printerKey
=
$this
->
params
[
'printer_key'
]
??
''
;
$offset
=
$this
->
params
[
'offset'
]
??
0
;
$limit
=
$this
->
params
[
'limit'
]
??
20
;
$res
=
OtaService
::
list
(
$name
,
$printerSn
,
$printerKey
,
$offset
,
$limit
);
$this
->
success
([
'data'
=>
$res
]);
}
/**
* 添加供应商
* @throws \App\Exception\custom\ParamException
*/
public
function
addAction
()
{
(
new
otaValidate
())
->
scene
(
'add'
)
->
validate
();
$res
=
OtaService
::
add
(
$this
->
params
);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
/**
* 删除一个供应商
* @throws \App\Exception\custom\ParamException
*/
public
function
deleteAction
()
{
(
new
otaValidate
())
->
scene
(
'delete'
)
->
validate
();
$res
=
OtaService
::
deleteOne
(
$this
->
params
[
'ota_id'
]);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
/**
* 更新供应商
* @throws Exception
*/
public
function
updateAction
()
{
(
new
otaValidate
())
->
scene
(
'update'
)
->
validate
();
$data
=
[];
$this
->
params
[
'ota_name'
]
&&
$data
[
'ota_name'
]
=
$this
->
params
[
'ota_name'
];
$this
->
params
[
'printer_sn'
]
&&
$data
[
'printer_sn'
]
=
$this
->
params
[
'printer_sn'
];
$this
->
params
[
'printer_key'
]
&&
$data
[
'printer_key'
]
=
$this
->
params
[
'printer_key'
];
$res
=
$data
?
OtaService
::
update
(
$this
->
params
[
'ota_id'
],
$data
)
:
true
;
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
}
\ No newline at end of file
application/modules/Marketing/controllers/Spell.php
0 → 100644
View file @
cd2be1bc
<?php
/**
* Author : Tengda
* Date : 2021/7/29
* Time : 17:59 下午
*/
use
App\Base\Base
;
//use App\Services\marketing\SpellService;
//use \Validate\Spell\detailValidate;
class
SpellController
extends
Base
{
public
function
detailAction
()
{
// (new detailValidate())->validate();
//
// $name = $this->params['name'] ?? '';
// $printerSn = $this->params['printer_sn'] ?? '';
// $printerKey = $this->params['printer_key'] ?? '';
// $offset = $this->params['offset'] ?? 0;
// $limit = $this->params['limit'] ?? 20;
// $res = TakePlaceService::list($name,$printerSn,$printerKey,$offset,$limit);
$data
=
[
'detail'
=>
[],
];
$this
->
success
([
'data'
=>
$data
]);
}
public
function
listAction
()
{
$data
=
[
'list'
=>
[
[
'uid'
=>
123
,
'username'
=>
'aaa'
,
'avator'
=>
'aaaaaa.jpg'
,
'id'
=>
1
,
'name'
=>
'一起拼一定赢'
,
'desc'
=>
'吃喝玩乐'
,
'create_time'
=>
'2021-07-29 20:03:08'
,
'sold_num'
=>
123
,
'min_price'
=>
15
,
'max_price'
=>
89
,
],
[
'uid'
=>
234
,
'username'
=>
'bbbbb'
,
'avator'
=>
'aaaaaa1.jpg'
,
'id'
=>
1
,
'name'
=>
'俺是打款就'
,
'desc'
=>
'吃喝玩乐'
,
'create_time'
=>
'2021-07-29 20:03:08'
,
'sold_num'
=>
345
,
'min_price'
=>
13
,
'max_price'
=>
99
,
]
],
'total'
=>
2
];
$this
->
success
([
'data'
=>
$data
]);
}
}
\ No newline at end of file
application/modules/Marketing/controllers/TakePlace.php
0 → 100644
View file @
cd2be1bc
<?php
/**
* Author : Tengda
* Date : 2021/7/29
* Time : 11:12 上午
*/
use
App\Base\Base
;
use
App\Services\marketing\TakePlaceService
;
use
Validate\TakePlaceValidate
;
class
TakePlaceController
extends
Base
{
/**
* 获取自提点列表
* http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=71671761
* @throws \App\Exception\custom\ParamException
*/
public
function
listAction
()
{
(
new
TakePlaceValidate
())
->
scene
(
'list'
)
->
validate
();
$keywords
=
$this
->
params
[
'keywords'
]
??
''
;
$offset
=
$this
->
params
[
'offset'
]
??
0
;
$limit
=
$this
->
params
[
'limit'
]
??
20
;
$res
=
TakePlaceService
::
searchList
(
$keywords
,
$offset
,
$limit
);
$this
->
success
([
'data'
=>
$res
]);
}
/**
* 添加自提点
* http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=71671759
* @throws \App\Exception\custom\ParamException
*/
public
function
addAction
()
{
(
new
takePlaceValidate
())
->
scene
(
'add'
)
->
validate
();
$res
=
TakePlaceService
::
add
(
$this
->
params
);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
/**
* 删除自提点
* @throws \App\Exception\custom\ParamException
*/
public
function
deleteAction
()
{
(
new
takePlaceValidate
())
->
scene
(
'delete'
)
->
validate
();
$res
=
TakePlaceService
::
delete
(
$this
->
params
[
'take_place_id'
]);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
/**
* 获取活动绑定的自提点列表
* @throws \App\Exception\custom\ParamException
*/
public
function
getBindListAction
()
{
(
new
takePlaceValidate
())
->
scene
(
'bindList'
)
->
validate
();
$marketingPindanId
=
$this
->
params
[
'marketing_pindan_id'
];
$offset
=
$this
->
params
[
'offset'
]
??
0
;
$limit
=
$this
->
params
[
'limit'
]
??
20
;
$data
=
TakePlaceService
::
getPindanTakePlaceList
(
$marketingPindanId
,
$offset
,
$limit
);
$this
->
success
([
'data'
=>
$data
]);
}
}
\ No newline at end of file
application/services/goods/OtaService.php
0 → 100644
View file @
cd2be1bc
<?php
namespace
App\Services\goods
;
use
App\Models\goods\mysql\Ota
;
class
OtaService
{
const
COLUMNS
=
[
'ota_id'
,
'ota_name'
,
'printer_sn'
,
'printer_key'
];
/**
* 获取供应商列表(op 后台)
* @param string $otaName
* @param string $contacts
* @param string $phone
* @param int $offset
* @param int $limit
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
list
(
$otaName
=
''
,
$printerSN
=
''
,
$printerKey
=
''
,
$offset
=
0
,
$limit
=
20
)
{
$otaName
&&
$where
[
'ota_name'
]
=
$otaName
;
$printerSN
&&
$where
[
"printer_sn"
]
=
$printerSN
;
$printerKey
&&
$where
[
'printer_key'
]
=
$printerKey
;
$where
[
'status'
]
=
Ota
::
STATUS_NORMAL
;
$where
[
'ORDER'
]
=
[
'ota_id'
=>
'DESC'
];
$where
[
'LIMIT'
]
=
[
$offset
,
$limit
];
// $e = Ota::debug();
$res
[
'list'
]
=
Ota
::
select
(
self
::
COLUMNS
,
$where
);
$res
[
'total'
]
=
Ota
::
count
(
'*'
,
$where
);
return
$res
;
}
/**
* 获取某个ota详情
* @param $OtaId
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
detail
(
$OtaId
)
{
return
Ota
::
get
(
self
::
COLUMNS
,[
'id'
=>
$OtaId
]);
}
public
static
function
add
(
$params
)
{
//@todo 检查商家是否已存在 -- 该商家已存在
//@todo 检查打印机是否已存在 -- 打印机已被(商家名称)绑定
$data
[
'ota_name'
]
=
$params
[
'ota_name'
];
$data
[
'printer_sn'
]
=
$params
[
'printer_sn'
];
$data
[
'printer_key'
]
=
$params
[
'printer_key'
];
return
Ota
::
insert
(
$data
);
}
/**
* 删除商家
* @param $otaId
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
deleteOne
(
$otaId
)
{
return
Ota
::
update
(
[
'is_delete'
=>
Ota
::
STATUS_DELETE
],
[
'ota_id'
=>
$otaId
]
);
}
/**
* @param $otaId
* @param $data
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
update
(
$otaId
,
$data
)
{
//@todo 检查字段是否匹配
return
Ota
::
update
(
$data
,
[
'ota_id'
=>
$otaId
]
);
}
}
\ No newline at end of file
application/services/marketing/MarketingService.php
View file @
cd2be1bc
...
...
@@ -376,7 +376,7 @@ class MarketingService
if
(
!
empty
(
$marketing
))
{
$marketingPindan
=
MarketingPindan
::
getRecord
([
"marketing_id"
=>
$marketing
[
"marketing_id"
]]);
if
(
!
empty
(
$marketingPindan
)
&&
$publishLifeAccountId
==
$marketingPindan
[
"publish_life_account_id"
])
{
throw
new
MarketingException
([
'cus'
=>
1
6
]);
throw
new
MarketingException
([
'cus'
=>
1
8
]);
}
}
...
...
application/services/marketing/TakePlaceService.php
0 → 100644
View file @
cd2be1bc
<?php
namespace
App\Services\marketing
;
use
Api\PhpUtils\Http\Request
;
use
App\Models\marketing\mysql\MarketingTakePlace
;
use
App\Models\marketing\mysql\TakePlace
;
use
App\Exception\custom\MarketingException
;
class
TakePlaceService
{
const
SELF_LIFE_ACCOUNT_ID
=
123123
;
/**
* 获取自提点列表(op 后台)
*
* 支持关键词(自提点名称/联系人)搜索
* @param string $keywords
* @param int $offset
* @param int $limit
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
searchList
(
$keywords
=
''
,
$offset
=
0
,
$limit
=
20
)
{
return
TakePlace
::
searchList
(
$keywords
,
$offset
,
$limit
);
}
/**
* 获取某个自提点详情
* 有删除自提点的情况,订单获取自提点详情时忽略自提点状态直接按id获取
* @param $takePlaceId
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
detail
(
$takePlaceId
)
{
return
TakePlace
::
get
(
'*'
,[
'take_place_id'
=>
$takePlaceId
]);
}
/**
* 添加自提点
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws MarketingException
*/
public
static
function
add
(
$params
)
{
//验证life_account_id
if
(
isset
(
$params
[
'life_account_id'
]))
{
$url
=
config
(
'interface'
,
'merchant.lifeaccount.get_life_account_by_id'
);
$lifeAccountRes
=
(
new
Request
())
->
get
(
$url
,
[
"life_account_id"
=>
$params
[
"life_account_id"
]]);
if
(
empty
(
$lifeAccountRes
[
"response"
][
"result"
]))
{
throw
new
MarketingException
([
'cus'
=>
MarketingException
::
LIFE_ACCOUNT_NO_EXIST
]);
}
}
$data
[
'life_account_id'
]
=
$params
[
'life_account_id'
]
??
self
::
SELF_LIFE_ACCOUNT_ID
;
$data
[
'take_place_name'
]
=
$params
[
'name'
];
$data
[
'longitude'
]
=
$params
[
'longitude'
];
$data
[
'latitude'
]
=
$params
[
'latitude'
];
$data
[
'address'
]
=
$params
[
'address'
];
$data
[
'contact_name'
]
=
$params
[
'contact_name'
]
??
''
;
$data
[
'phone'
]
=
$params
[
'phone'
]
??
''
;
$data
[
'province'
]
=
$params
[
'province'
];
$data
[
'city'
]
=
$params
[
'city'
];
$data
[
'area'
]
=
$params
[
'area'
];
return
TakePlace
::
insert
(
$data
);
}
/**
* 删除自提点
* @param $takePlaceId
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
delete
(
$takePlaceId
)
{
return
TakePlace
::
update
(
[
'is_delete'
=>
TakePlace
::
STATUS_DELETE
],
[
'take_place_id'
=>
$takePlaceId
]
);
}
/**
* 给拼单活动绑定自提点
* @param $marketingPindanId
* @param $takePlaceId
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
bindPindanTakePlace
(
$marketingPindanId
,
$takePlaceId
)
{
$data
=
[
'marketing_pindan_id'
=>
$marketingPindanId
,
'take_place_id'
=>
$takePlaceId
,
];
//检查关联是否已存在
if
(
!
empty
(
MarketingTakePlace
::
get
(
'*'
,
$data
)))
{
throw
new
MarketingException
([
'cus'
=>
MarketingException
::
RELATION_ALREADY_EXIST
]);
}
return
MarketingTakePlace
::
insert
(
$data
);
}
/**
* 获取拼单活动绑定的自提点列表
* @param $marketingPindanId
* @param int $offset
* @param int $limit
* @return array
*/
public
static
function
getPindanTakePlaceList
(
$marketingPindanId
,
$offset
=
0
,
$limit
=
20
)
{
$where
=
[
'marketing_pindan_id'
=>
$marketingPindanId
];
$where
[
'ORDER'
]
=
[
'marketing_take_place_id'
=>
'DESC'
];
$where
[
'LIMIT'
]
=
[
$offset
,
$limit
];
// $e = MarketingTakePlace::debug();
$relations
=
MarketingTakePlace
::
select
(
'*'
,
$where
);
$makePlaceIds
=
array_column
(
$relations
,
'take_place_id'
);
$where
=
[
'take_place_id'
=>
$makePlaceIds
,
'is_delete'
=>
TakePlace
::
STATUS_NORMAL
];
$takePlaces
=
TakePlace
::
select
(
'*'
,
$where
);
return
$takePlaces
?:
[];
}
}
\ 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