Commit bad9392b authored by 耿鸿飞's avatar 耿鸿飞

feature:生活号 骑手排线

parent 1b9dd0d7
<?php
namespace App\Exception\custom;
use App\Exception\BaseException;
class DelivererException extends BaseException
{
protected $base_code = Code::DELIVERER;
protected $cus = [
0 => '骑手创建失败,请稍后重试',
];
}
\ No newline at end of file
<?php
namespace Validate;
/**
* Class GoodsAddValidate
*
* @package Validate
*/
class DelivererAddValidate extends BaseValidate
{
protected $rule = [
'name' => 'require|length:1,15',
'max_capacity' => 'require|between:1,1000',
'min_capacity' => 'require|between:1,1000',
'tool_type' => 'require|between:0,1',
];
protected $message = [
'name' => '请检查骑手名称,内容不能太长或者不填写',
'max_capacity' => '请填写骑手最大配送量,1--1000',
'min_capacity' => '请填写骑手最小配送量,1--1000',
'tool_type' => '请选择交通工具,电动车或者摩托车'
];
}
\ No newline at end of file
<?php
namespace Validate;
/**
* Class GoodsAddValidate
*
* @package Validate
*/
class DelivererDayAddValidate extends BaseValidate
{
protected $rule = [
'date' => 'require|length:1,15',
'uids' => 'require|length:1,1000',
];
protected $message = [
'date' => '请检查日期',
'uids' => '请填写骑手',
];
}
\ No newline at end of file
<?php
namespace App\Models\commerce\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class ActivityDao extends MysqlBase
{
const TABLE_NAME = 'hulk_HulkModelCore';
const CONFIG_INDEX = 'commerce';
}
\ No newline at end of file
<?php
namespace App\Models\commerce\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class GoodsClassifyCollectDao extends MysqlBase
{
const TABLE_NAME = 'hulk_HulkGoodsClassifyCollect';
const CONFIG_INDEX = 'commerce';
}
\ No newline at end of file
<?php
namespace App\Models\commerce\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class GoodsClassifyDao extends MysqlBase
{
const TABLE_NAME = 'hulk_HulkGoodsClassify';
const CONFIG_INDEX = 'commerce';
}
\ No newline at end of file
<?php
namespace App\Models\commerce\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class GoodsDao extends MysqlBase
{
const TABLE_NAME = 'hulk_HulkCore';
const CONFIG_INDEX = 'commerce';
}
\ No newline at end of file
<?php
namespace App\Models\commerce\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class OrderDao extends MysqlBase
{
const TABLE_NAME = 'hulk_HulkOrder';
const CONFIG_INDEX = 'commerce';
}
\ No newline at end of file
<?php
namespace App\Models\commerce\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class OrderItemDao extends MysqlBase
{
const TABLE_NAME = 'hulk_HulkOrderItem';
const CONFIG_INDEX = 'commerce';
}
\ No newline at end of file
<?php
namespace App\Models\commerce\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class StationCollectDao extends MysqlBase
{
const TABLE_NAME = 'hulk_HulkStationCollect';
const CONFIG_INDEX = 'commerce';
}
\ No newline at end of file
<?php
namespace App\Models\commerce\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class StationDao extends MysqlBase
{
const TABLE_NAME = 'hulk_HulkStation';
const CONFIG_INDEX = 'commerce';
}
\ No newline at end of file
<?php
namespace App\Models\merchant\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class DelivererDao extends MysqlBase
{
const TABLE_NAME = 'deliverer';
const CONFIG_INDEX = 'goods';
const PRIMARY_KEY = 'deliverer_id';
}
\ No newline at end of file
<?php
namespace App\Models\merchant\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class DelivererDayDao extends MysqlBase
{
const TABLE_NAME = 'deliverer_day';
const CONFIG_INDEX = 'goods';
const PRIMARY_KEY = 'deliverer_day_id';
}
\ No newline at end of file
<?php
class CommercePlanLineController extends \App\Base\Cli
{
public function RunAction(){
(new \App\Services\commerce\PlanLineService)->commerce('1NJF2Y');
}
}
\ No newline at end of file
<?php
class DelivererController extends \App\Base\Base
{
/**
* 添加配送员
* @author 耿鸿飞<15911185633>
* @date 2021/7/22 下午7:52
* @link http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=69521762#space-menu-link-content
* @api_link http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=70453886
* @throws \App\Exception\custom\DelivererException
* @throws \App\Exception\custom\ParamException
*/
public function add_delivererAction(){
(new \Validate\DelivererAddValidate())->validate();
$params = $this->params;
if (\App\Services\merchant\DelivererService::AddDeliverer($params)){
$this->success(['response' => 'ok']);
}
throw new \App\Exception\custom\DelivererException(['cus' => 0]);
}
/**
* 获取配送员列表
* @author 耿鸿飞<15911185633>
* @date 2021/7/22 下午7:52
* @link http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=69521762#space-menu-link-content
* @api_link http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=70453889
* @throws Exception
*/
public function list_day_delivererAction(){
$day = $this->params['date'] ?? '';
$delivererList = \App\Services\merchant\DelivererService::ListDeliverer($day);
$this->success(['response' => $delivererList]);
}
/**
* 保存每日的配送员
* @author 耿鸿飞<15911185633>
* @date 2021/7/22 下午7:52
* @link http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=69521762#space-menu-link-content
* @api_link http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=70453893
* @throws \App\Exception\custom\ParamException
*/
public function save_day_delivererAction(){
(new \Validate\DelivererDayAddValidate())->validate();
$params = $this->params;
\App\Services\merchant\DelivererService::SaveDelivererDay($params);
$this->success(['response' => 'ok']);
}
/**
* 获取日配送员列表
* @author 耿鸿飞<15911185633>
* @date 2021/7/22 下午7:51
* @link http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=69521762#space-menu-link-content
* @api_link http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=70453896
* @throws Exception
*/
public function list_day_deliverer_confAction(){
$list = \App\Services\merchant\DelivererService::ListDelivererConf($this->params);
//$this->success(['a' => \Yaf\Application::app()->environ()]);
$this->success(['response' => $list]);
}
}
\ No newline at end of file
This diff is collapsed.
<?php
namespace App\Services\merchant;
use App\Models\merchant\mysql\DelivererDao;
use App\Models\merchant\mysql\DelivererDayDao;
class DelivererService
{
/**
* 添加配送员
* @param $params
* @return bool
*/
public static function AddDeliverer($params){
$row = DelivererDao::get(['deliverer_id','deliverer_status'],['deliverer_name' => $params['name']]);
if ($row){
if($row['deliverer_status'] != 0){
return DelivererDao::update(['deliverer_status' => 0],['deliverer_id' => $row['deliverer_id']]) > 0;
}
return $row['deliverer_id'];
}
return DelivererDao::insert([
'deliverer_name' => $params['name'],
'deliverer_max_capacity' => intval($params['max_capacity']),
'deliverer_min_capacity' => intval($params['min_capacity']),
'deliverer_tool_type' => intval($params['tool_type']),
]) > 0;
}
/**
* 获取全部可用配送员列表
* @param string $date
* @return array
*/
public static function ListDeliverer($date = ''){
$delivererList = DelivererDao::select(['deliverer_id','deliverer_name','deliverer_max_capacity','deliverer_min_capacity','deliverer_tool_type'],['deliverer_status' => 0]);
$dayDelivererMap = [];
if ($date){
$dayDelivererMap = array_column(DelivererDayDao::select(['deliverer_id'],['deliverer_day_date' => $date,'deliverer_day_status' => 0]),null,'deliverer_id');
}
return array_map(function ($a) use($dayDelivererMap){
$a['checked'] = isset($dayDelivererMap[$a['deliverer_id']]) ? 1 : 0;
return $a;
},$delivererList);
}
/**
* 保存每日配送员设置
* @param $params
* @return bool
*/
public static function SaveDelivererDay($params){
$date = $params['date'];
DelivererDayDao::beginTransaction();
DelivererDayDao::delete(['deliverer_day_date' => $date]);
$uids = explode(',',$params['uids']);
foreach ($uids as $uid){
if (!$uid){
continue;
}
$ret = DelivererDayDao::insert([
'deliverer_day_date' => $date,
'deliverer_id' => $uid,
]);
if (!$ret){
DelivererDayDao::rollback();
return false;
}
}
return DelivererDayDao::commit();
}
/**
* 获取每日配送员列表
* @param $params
* @return array
*/
public static function ListDelivererConf($params){
$dateList = DelivererDayDao::select(['deliverer_day_date','deliverer_id'],['deliverer_day_status' => 0,'deliverer_day_date[>]' => date("Y-m-d",strtotime('-30 days'))]);
if(!$dateList){
return [];
}
$delivererIdList = array_unique(array_column($dateList,'deliverer_id'));
$delivererList = DelivererDao::select(['deliverer_id','deliverer_name','deliverer_max_capacity','deliverer_min_capacity','deliverer_tool_type'],['deliverer_id[in]' => $delivererIdList]);
$delivererMap = array_column($delivererList,null,'deliverer_id');
$retList = [];
foreach($dateList as $item){
if(!isset($retList[$item['deliverer_day_date']])){
$retList[$item['deliverer_day_date']] = [];
}
$retList[$item['deliverer_day_date']][] = $delivererMap[$item['deliverer_id']];
}
krsort($retList,SORT_STRING);
return $retList;
}
}
\ No newline at end of file
......@@ -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,Marketing,Tcc"
application.modules="Index,Test,Goods,Shop,Marketing,Tcc,Merchant"
appid = "goods"
;AES密钥
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment