Commit d6621473 authored by luhongguang's avatar luhongguang

Merge branch 'develop' of https://git.yidian-inc.com:8021/bp/goods into develop

parents 6f1de143 ff689edf
......@@ -15,4 +15,8 @@ class Code
const SIGN = 102000;
const GOODS = 108000;
const SHOP = 109000;
const DISTRIBUTOR = 110000;
const DISTRIBUTION = 111000;
}
\ No newline at end of file
<?php
namespace App\Exception\custom;
use App\Exception\BaseException;
/**
* Class TestException
* @package App\Exception\custom
*/
class TestException extends BaseException
{
/**
* Test 模块的错误码起始值
* 最终用户获取到的错误码,是 $base_code + 指定的 $cus 的 key
* @var int
*/
protected $base_code = Code::TEST;
protected $cus = [
0 => 'test error',
1 => 'test error2'
];
}
\ No newline at end of file
<?php
namespace App\Exception\custom;
use App\Exception\BaseException;
/**
* Class TestException
* @package App\Exception\custom
*/
class TestException extends BaseException
{
/**
* Test 模块的错误码起始值
* 最终用户获取到的错误码,是 $base_code + 指定的 $cus 的 key
* @var int
*/
protected $base_code = Code::TEST;
protected $cus = [
0 => 'test error',
1 => 'test error2'
];
}
\ No newline at end of file
<?php
namespace App\Exception\custom;
use App\Exception\BaseException;
/**
* Class DistributorException
* @package App\Exception\custom
*/
class DistributorException extends BaseException
{
protected $base_code = Code::DISTRIBUTOR;
protected $cus = [
0 => '参数不能为空',
1 => '修改失败',
];
}
\ No newline at end of file
<?php
namespace App\Models\distribution\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class Distribution extends MysqlBase
......
<?php
namespace App\Models\shop\mysql;
namespace App\Models\distribution\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class Distributor extends MysqlBase
{
const TABLE_NAME = 'shop';
const CONFIG_INDEX = 'goods';
const PRIMARY_KEY = 'shop_id';
const TABLE_NAME = 'distributor';
const CONFIG_INDEX = 'distribution';
const PRIMARY_KEY = 'id';
public static function getRecord($where, $colums = [])
{
......@@ -61,6 +58,9 @@ class Distributor extends MysqlBase
public static function getCount($where, $columns = "*")
{
if (empty($columns)) {
$columns = '*';
}
return self::count($columns, $where);
}
}
......@@ -6,18 +6,26 @@ use App\Exception\custom\ShopException;
class DistributionController extends Base
{
/**
*获取团列表
*
*/
public function get_distribution_listAction()
{
$params = $this->getRequest()->getRequest();
print_r( $params);
die();
$srt = DistributionService::addDistribution($params);
print_r($srt);
$distributionList = DistributionService::getDistributionList($params);
$this->success(['result' => $distributionList]);
}
/**
* 添加团
*/
public function add_distributionAction()
{
# code...
}
......
<?php
use App\Base\Base;
use App\Services\distribution\DistributorService;
use App\Exception\custom\DistributorException;
class DistributorController extends Base
{
/**
* 获取团长列表
* 后台管理
*
*/
public function distributor_listAction()
{
$params = $this->params;
$distributionList = DistributorService::distributorList($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
......@@ -12,7 +12,7 @@ class ShopController extends Base
*/
public function add_shopAction()
{
$params = $this->getRequest()->getRequest();
$params = $this->params;
$shop = ShopService::addShop($params);
if (!empty($shop)) {
$this->success();
......@@ -27,11 +27,45 @@ class ShopController extends Base
*/
public function get_shop_listAction()
{
$params = $this->getRequest()->getRequest();
$params = $this->params;
$subShopList = ShopService::getShopList($params);
$this->success(['result' => $subShopList]);
}
/**
* 店铺编辑接口
*
*/
public function update_shopAction()
{
$params = $this->params;
$where['stores_id'] = !empty($params['stores_id']) ? $params['stores_id'] : '';
$subShopList = ShopService::updateShop($params,$where);
}
/**
* 获取数据
*
*/
public function get_shop_infoAction($value='')
{
$params = $this->params;
$param['stores_id'] = !empty($params['stores_id']) ? $params['stores_id'] : '';
$subShopList = ShopService::getShopInfo($param);
}
/**
* 后台门店列表
*
*/
public function shop_listAction()
{
$params = $this->params;
$subShopList = ShopService::opShopList($params);
$this->success($subShopList);
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
namespace App\Services\distribution;
use App\Models\shop\mysql\Distribution;
use App\Models\distribution\mysql\Distribution;
use Api\PhpUtils\Validate\Validate;
use Api\PhpServices\Idgen\Idgen;
......@@ -23,7 +23,13 @@ class DistributionService
public static function getDistributionList($params)
{
$where['ORDER'] = ["create_time" => "DESC"];
$distributionList = Distribution::getRecords($where);
$count = Distribution::getCount(['']);
return $distributionList;
}
......
<?php
namespace App\Services\shop;
namespace App\Services\distribution;
use App\Models\shop\mysql\Shop;
use App\Models\shop\mysql\SubShop;
use App\Models\distribution\mysql\Distributor;
use Api\PhpUtils\Validate\Validate;
use Api\PhpServices\Idgen\Idgen;
// use Validate\ShopValidate;
use App\Exception\custom\ShopException;
use Api\PhpServices\Sensitive\Sensitive;
use App\Exception\custom\DistributorException;
class DistributorService
{
public static function addShop($params)
/**
* 查询
*
*/
public static function distributorList($params)
{
$life_account_id = !empty($params['life_account_id']) ? $params['life_account_id'] : '';
$phone = !empty($params['phone']) ? $params['phone'] : '';
$shop_id = !empty($params['shop_id']) ? $params['shop_id'] : '';
$name = !empty($params['name']) ? $params['name'] : '';
$address_lng = !empty($params['address_lng']) ? $params['address_lng'] : '';
$address_lat = !empty($params['address_lat']) ? $params['address_lat'] : '';
$address = !empty($params['address']) ? $params['address'] : '';
if (empty($life_account_id)) {
throw new ShopException(['cus'=>0]);
}
if (empty($phone)) {
throw new ShopException(['cus'=>1]);
}
// $is_mobile = ( new Validate)->isMobile($phone);
// if (empty($is_mobile)) {
// throw new ShopException(['cus'=>2]);
// }
if (empty($name)) {
throw new ShopException(['cus'=>3]);
}
if (self::utf8Strlen($name) > 20) {
throw new ShopException(['cus'=>8]);
}
$params['page'] = !empty($params['page']) ? $params['page'] : 1;
$limit = !empty($params['page_size']) ? $params['page_size'] : 20;
$page = ($params['page'] - 1) * $limit;
$detectParams = [
'businessId' => 1,
'text' => !empty($name) ? $name : '',
'scene' => 1,
];
$sensitive = (new Sensitive)->detect($detectParams);
if (!empty($sensitive['data'])) {
throw new ShopException(['cus'=>4]);
if (!empty($params['audit_status'])) {
$where['audit_status'] = $params['audit_status'];
}
//判断店铺重复
if (!self::isName($name)) {
throw new ShopException(['cus'=>6]);
if (!empty($params['audit_user_name'])) {
$where['audit_user_name'] = $params['audit_user_name'];
}
//判断手机号重复
if (!self::isPhone($phone)) {
throw new ShopException(['cus'=>7]);
}
$res = self::getIdgenId(1, 'goods', $count = 1);
$stores_id = !empty($res[0]) ? $res[0] : '';
$colums = [
'stores_id' => $stores_id,
'life_account_id' => $life_account_id,
'shop_id' => $shop_id,
'name' => $name,
'address_lng' => $address_lng,
'address_lat' => $address_lat,
'address' => $address,
'phone' => $phone,
'create_time' => date("Y-m-d H:i:s"),
];
$subShop = SubShop::insertRecord($colums);
return $subShop;
}
public static function getShopList($params)
{
$life_account_id = !empty($params['life_account_id']) ? $params['life_account_id'] : '';
$phone = !empty($params['phone']) ? $params['phone'] : '';
$shop_id = !empty($params['shop_id']) ? $params['shop_id'] : '';
$name = !empty($params['name']) ? $params['name'] : '';
$address_lng = !empty($params['address_lng']) ? $params['address_lng'] : '';
$address_lat = !empty($params['address_lat']) ? $params['address_lat'] : '';
$address = !empty($params['address']) ? $params['address'] : '';
$where['life_account_id'] = $life_account_id;
$where['ORDER'] = ["create_time" => "DESC"];
$subShopList = SubShop::getRecords($where);
return $subShopList;
$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 isName($name='')
public static function distributorInfo($params)
{
if (empty($name)) {
return false;
}
$colums = [
'name' => $name
];
$subShop = SubShop::getRecord($colums);
if (!empty($subShop)) {
return false;
}
return true;
$where['distributor_id'] = !empty($params['distributor_id']) ? $params['distributor_id'] : '';
$info = Distributor::getRecord($where);
return $info;
}
/**
* 门店手机号是否重复
* 更新数据
*
*/
public static function isPhone($phone='')
public static function updateDistributor($params,$where)
{
if (empty($phone)) {
return false;
}
$colums = [
'phone' => $phone
];
$subShop = SubShop::getRecord($colums);
if (!empty($subShop)) {
return false;
}
return true;
}
/**
*判断长度
*
*/
public static function utf8Strlen($string = null) {
// 将字符串分解为单元
preg_match_all("/./us", $string, $match);
// // 返回单元个数
return count($match[0]);
$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
......
......@@ -15,7 +15,10 @@ use Api\PhpServices\Sensitive\Sensitive;
class ShopService
{
/**
* 添加门店
*
*/
public static function addShop($params)
{
$life_account_id = !empty($params['life_account_id']) ? $params['life_account_id'] : '';
......@@ -85,7 +88,7 @@ class ShopService
public static function getShopList($params)
{
$life_account_id = !empty($params['life_account_id']) ? $params['life_account_id'] : '';
$life_account_id = !empty($params['life_account_id']) ? $params['life_account_id'] : 11;
$phone = !empty($params['phone']) ? $params['phone'] : '';
$shop_id = !empty($params['shop_id']) ? $params['shop_id'] : '';
$name = !empty($params['name']) ? $params['name'] : '';
......@@ -99,6 +102,79 @@ class ShopService
}
/**
* op后台查询查询
*
*/
public static function opShopList($params)
{
$params['page'] = !empty($params['page']) ? $params['page'] : 1;
$limit = !empty($params['page_size']) ? $params['page_size'] : 20;
$page = ($params['page'] - 1) * $limit;
$where['ORDER'] = ["create_time" => "DESC"];
$where['LIMIT'] = [$page, $limit];
$list = SubShop::getRecords($where);
unset($where['LIMIT']);
unset($where['ORDER']);
$count = SubShop::getCount($where);
$data = ['result' => $list,'count' => $count];
return $data;
}
/**
*
*
*/
public static function updateShop($params, $where)
{
$name = !empty($params['name']) ? $params['name'] : '';
$address_lng = !empty($params['address_lng']) ? $params['address_lng'] : '';
$address_lat = !empty($params['address_lat']) ? $params['address_lat'] : '';
$address = !empty($params['address']) ? $params['address'] : '';
$phone = !empty($params['phone']) ? $params['phone'] : '';
if (!empty($name)){
$detectParams = [
'businessId' => 1,
'text' => !empty($name) ? $name : '',
'scene' => 1,
];
$sensitive = (new Sensitive)->detect($detectParams);
if (!empty($sensitive['data'])) {
throw new ShopException(['cus'=>4]);
}
$colums['name'] = $name;
}
if (!empty($address_lng)) {
$colums['address_lng'] = $address_lng;
}
if (!empty($address_lat)) {
$colums['address_lat'] = $address_lat;
}
if (!empty($address)) {
$colums['address'] = $address;
}
if (!empty($phone)) {
$colums['phone'] = $phone;
}
$subShop = SubShop::updateRecord($colums, $where);
return $subShop;
}
public static function getShopInfo($params)
{
$subShopInfo = SubShop::getRecord($params);
return $subShopInfo;
}
/**
* 门店名称是否重复
*
......
......@@ -17,7 +17,7 @@ idgen.partner = "bp"
idgen.key = "5cfdb867e96374c7883b31d6928cc4cb"
[exception]
debug = false
debug = true
exception.user.code = -1
exception.user.msg = "error"
exception.sys.code = -1
......
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