Commit aeeb83f7 authored by jianghaiming's avatar jianghaiming

update:修改

parent 4a42c6bb
......@@ -17,5 +17,7 @@ class MarketingException extends BaseException
3 => '(一级)佣金率不能为空',
4 => '(二级)佣金率不能为空',
5 => '创建失败',
6 => '活动id不能为空',
7 => '更新失败',
];
}
\ No newline at end of file
......@@ -84,6 +84,18 @@ class DistributorController extends Base
$info = DistributorService::distributor($params);
$this->success(['result' => $info]);
}
/**
* 获取待审核的团长列表
* 后台管理
*
*/
public function distributor_listAction()
{
$params = $this->params;
$distributionList = DistributorService::distributorList($params);
$this->success($distributionList);
}
/**
* 获取团长列表
......
......@@ -43,7 +43,11 @@ class MarketingController extends Base
{
$params = $this->params;
$where['marketing_id'] = $params['marketing_id'];
$where['marketing_id'] = !empty($params['marketing_id']) ? $params['marketing_id'] : '';
$param = [];
if (empty($where['marketing_id'])) {
throw new MarketingException(['cus' => 6]);
}
if (!empty($params['audit_status'])) {
$param['audit_status'] = $params['audit_status'];
......@@ -58,7 +62,7 @@ class MarketingController extends Base
if (!empty($srt)) {
$this->success();
}else{
throw new DistributorException(['cus'=>1]);
throw new MarketingException(['cus' => 7]);
}
}
......
......@@ -39,7 +39,7 @@ class ShopController extends Base
public function update_shopAction()
{
$params = $this->params;
$where['stores_id'] = !empty($params['stores_id']) ? $params['stores_id'] : '';
$where['sub_shop_id'] = !empty($params['sub_shop_id']) ? $params['sub_shop_id'] : '';
$subShopList = ShopService::updateShop($params,$where);
}
......@@ -50,7 +50,7 @@ class ShopController extends Base
public function get_shop_infoAction($value='')
{
$params = $this->params;
$param['stores_id'] = !empty($params['stores_id']) ? $params['stores_id'] : '';
$param['sub_shop_id'] = !empty($params['sub_shop_id']) ? $params['sub_shop_id'] : '';
$subShopList = ShopService::getShopInfo($param);
}
......
......@@ -21,19 +21,23 @@ class DistributorService
*/
public static function secondDistributor($params)
{
$params['page'] = !empty($params['page']) ? $params['page'] : 1;
$limit = !empty($params['page_size']) ? $params['page_size'] : 20;
$page = ($params['page'] - 1) * $limit;
//$params['page'] = !empty($params['page']) ? $params['page'] : 1;
$limit = !empty($params['num']) ? $params['num'] : 20;
//$page = ($params['page'] - 1) * $limit;
// if (!empty($params['user_id'])) {
// $where['user_id'] = $params['user_id'];
// }
if (!empty($params['user_id'])) {
$where['user_id'] = $params['user_id'];
$where['parent_user_id'] = $params['user_id'];
}
if (!empty($params['higher_user_id'])) {
$where['higher_user_id'] = $params['higher_user_id'];
if (!empty($params['last_id'])) {
$where['id[<]'] = $params['last_id'];
}
$where['LIMIT'] = [$page, $limit];
$where['LIMIT'] = $limit;
$where['ORDER'] = ["create_time" => "DESC"];
$list = Distributor::getRecords($where);
$last = end($list);
......@@ -51,8 +55,8 @@ class DistributorService
{
$userId = !empty($params['user_id']) ? $params['user_id'] : '';
$userName = !empty($params['user_name']) ? $params['user_name'] : '';
$type = !empty($params['type']) ? $params['type'] : '';
$info = Distributor::getRecord(['user_id' => $userId,'type' => $type]);
$distributorType = !empty($params['distributor_type']) ? $params['distributor_type'] : '';
$info = Distributor::getRecord(['user_id' => $userId,'distributor_type' => $distributorType]);
if (!empty($info)) {
throw new DistributorException(['cus'=>2]);
}
......@@ -86,8 +90,8 @@ class DistributorService
'user_name' => $userName,
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
'code' => $userCode,
'type' => $type
'distributor_code' => $userCode,
'distributor_type' => $distributorType
];
$id = Distributor::insertRecord($data);
......@@ -100,11 +104,11 @@ class DistributorService
$auditData = [
'user_id' => $userId,
'user_name' => $userName,
'type' => $type,
'distributor_type' => $distributorType,
'status' => 2,
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
'code' => $userCode,
'distributor_code' => $userCode,
];
$auditId = DistributorAuditRecord::insertRecord($auditData);
if (!empty($auditId)) {
......@@ -125,24 +129,24 @@ class DistributorService
$userId = !empty($params['user_id']) ? $params['user_id'] : '';
$userName = !empty($params['user_name']) ? $params['user_name'] : '';
$mobile = !empty($params['mobile']) ? $params['mobile'] : '';
$code = !empty($params['code']) ? $params['code'] : '';
$distributorCode = !empty($params['distributor_code']) ? $params['distributor_code'] : '';
$smsCode = !empty($params['sms_code']) ? $params['sms_code'] : '';
if (empty($smsCode)) {
throw new DistributorException(['cus'=>11]);
}
$jwUserId = '';
if (empty($code)) {
if (empty($distributorCode)) {
throw new DistributorException(['cus'=>9]);
}
$info = Distributor::getRecord(['code' => $code]);
$info = Distributor::getRecord(['distributor_code' => $distributorCode]);
if (empty($info)) {
throw new DistributorException(['cus'=>10]);
}
$higherUserId = !empty($info['user_id']) ? $info['user_id'] : '';
$type = !empty($info['type']) ? $info['type'] : '';
$parentUserId = !empty($info['user_id']) ? $info['user_id'] : '';
$distributorType = !empty($info['distributor_type']) ? $info['distributor_type'] : '';
if (empty($mobile)) {
throw new DistributorException(['cus'=>6]);
}
......@@ -162,7 +166,7 @@ class DistributorService
}
$info = Distributor::getRecord(['user_id' => $jwUserId]);
if (!empty($info) && $info['higher_user_id'] > 0) {
if (!empty($info) && $info['parent_user_id'] > 0) {
throw new DistributorException(['cus'=>8]);
}
......@@ -186,19 +190,19 @@ class DistributorService
}
Distributor::beginTransaction();
$userCode = $jwUserId . '_' . $type;
$userCode = $jwUserId . '_' . $distributorType;
if (empty($info)) {
// $res = self::getIdgenId(1, 'goods', $count = 1);
// $userCode = !empty($res[0]) ? $res[0] : '';
//新增
$data = [
'higher_user_id' => $higherUserId,
'parent_user_id' => $parentUserId,
'user_id' => $jwUserId,
'user_name' => $userName,
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
'code' => $userCode,
'type' => $type
'distributor_code' => $userCode,
'distributor_type' => $distributorType
];
$id = Distributor::insertRecord($data);
if (empty($id)) {
......@@ -208,12 +212,12 @@ class DistributorService
}else{
//编辑二级团长
$data = [
'higher_user_id' => $higherUserId,
'parent_user_id' => $parentUserId,
'user_name' => $userName,
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
];
$id = Distributor::updateRecord($data, ['user_id' => $jwUserId,'type' => $type]);
$id = Distributor::updateRecord($data, ['user_id' => $jwUserId,'distributor_type' => $distributorType]);
if (empty($id)) {
Distributor::rollback();
throw new DistributorException(['cus' => 5]);
......@@ -222,14 +226,14 @@ class DistributorService
//暂时默认通过,
$auditData = [
'higher_user_id' => $higherUserId,
'parent_user_id' => $parentUserId,
'user_id' => $jwUserId,
'user_name' => $userName,
'type' => $type,
'distributor_type' => $distributorType,
'status' => 2,
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
'code' => $userCode,
'distributor_code' => $userCode,
];
$auditId = DistributorAuditRecord::insertRecord($auditData);
if (!empty($auditId)) {
......@@ -293,10 +297,10 @@ class DistributorService
$info = Distributor::getRecord($where);
if (!empty($info)) {
$data['code'] = $info['code'];
$data['distributor_code'] = $info['distributor_code'];
$data['is_distributor'] = 1;
}else{
$data['code'] = $info['code'];
$data['distributor_code'] = $info['distributor_code'];
$data['is_distributor'] = 0;
}
return $data ;
......@@ -352,8 +356,10 @@ class DistributorService
}
/**
*判断长度
* 判断长度
*
* @param $string
* @return array|mixed
*/
public static function utf8Strlen($string = null) {
// 将字符串分解为单元
......@@ -365,6 +371,7 @@ class DistributorService
/**
* 通过发号器拿 id (非雪花)
* number,获取店铺shop_id用生活号id后两位,商品相关的这里是shop_id的后两位
*
* @param $number
* @param $type
* @param int $count
......
......@@ -15,12 +15,14 @@ class MarketingGoodsService
{
public static function marketingGoodsList($params)
{
$params['page'] = !empty($params['page']) ? $params['page'] : 1;
$limit = !empty($params['page_size']) ? $params['page_size'] : 20;
$page = ($params['page'] - 1) * $limit;
$limit = !empty($params['num']) ? $params['num'] : 20;
if (!empty($params['last_id'])) {
$where['id[<]'] = $params['last_id'];
}
$where['LIMIT'] = [$page, $limit];
$where['LIMIT'] = $limit;
$where['ORDER'] = ["create_time" => "DESC"];
$marketingWhere = [
......@@ -52,15 +54,15 @@ class MarketingGoodsService
$list[$i] = $value;
$list[$i]['life_account_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['life_account_id']) ? $goodsSkuList[$value['goods_sku_id']]['life_account_id'] : '';
$list[$i]['shop_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['shop_id']) ? $goodsSkuList[$value['goods_sku_id']]['shop_id'] : '';
$list[$i]['goods_name'] = !empty($goodsSkuList[$value['goods_sku_id']]['name']) ? $goodsSkuList[$value['goods_sku_id']]['name'] : '';
$list[$i]['goods_name'] = !empty($goodsSkuList[$value['goods_sku_id']]['goods_name']) ? $goodsSkuList[$value['goods_sku_id']]['goods_name'] : '';
$list[$i]['goods_desc'] = !empty($goodsSkuList[$value['goods_sku_id']]['desc']) ? $goodsSkuList[$value['goods_sku_id']]['desc'] : '';
$list[$i]['goods_spu_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['goods_spu_id']) ? $goodsSkuList[$value['goods_sku_id']]['goods_spu_id'] : '';
$list[$i]['original_price'] = !empty($goodsSkuList[$value['goods_sku_id']]['original_price']) ? $goodsSkuList[$value['goods_sku_id']]['original_price'] : '';
$list[$i]['price'] = !empty($goodsSkuList[$value['goods_sku_id']]['price']) ? $goodsSkuList[$value['goods_sku_id']]['price'] : '';
$list[$i]['total_amount_order'] = !empty($goodsSkuList[$value['goods_sku_id']]['total_amount_order']) ? $goodsSkuList[$value['goods_sku_id']]['total_amount_order'] : '';
$list[$i]['url'] = !empty($goodsSkuList[$value['goods_sku_id']]['url']) ? $goodsSkuList[$value['goods_sku_id']]['url'] : '';
$list[$i]['desc_pic_url'] = !empty($goodsSkuList[$value['goods_sku_id']]['desc_pic_url']) ? $goodsSkuList[$value['goods_sku_id']]['desc_pic_url'] : '';
$shopId = !empty($list[$i]['shop_id']) ? $list[$i]['shop_id'] : '';
$list[$i]['shop_name'] = !empty($subShopList[$shopId]['name']) ? $subShopList[$shopId]['name'] : '';
$list[$i]['shop_name'] = !empty($subShopList[$shopId]['shop_name']) ? $subShopList[$shopId]['shop_name'] : '';
$i++;
}
......
......@@ -25,9 +25,9 @@ class ShopService
$lifeAccountId = !empty($params['life_account_id']) ? $params['life_account_id'] : '';
$phone = !empty($params['phone']) ? $params['phone'] : '';
$name = !empty($params['name']) ? $params['name'] : '';
$addressLng = !empty($params['address_lng']) ? $params['address_lng'] : '';
$addressLat = !empty($params['address_lat']) ? $params['address_lat'] : '';
$name = !empty($params['shop_name']) ? $params['shop_name'] : '';
$longitude = !empty($params['longitude']) ? $params['longitude'] : '';
$latitude = !empty($params['latitude']) ? $params['latitude'] : '';
$address = !empty($params['address']) ? $params['address'] : '';
if (empty($lifeAccountId)) {
......@@ -38,11 +38,6 @@ class ShopService
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]);
}
......@@ -51,6 +46,7 @@ class ShopService
throw new ShopException(['cus' => 8]);
}
$detectParams = [
'businessId' => 1,
'text' => !empty($name) ? $name : '',
......@@ -60,7 +56,6 @@ class ShopService
if (!empty($sensitive['data'])) {
throw new ShopException(['cus' => 4]);
}
//判断店铺重复
if (!self::isName($name)) {
throw new ShopException(['cus' => 6]);
......@@ -80,9 +75,9 @@ class ShopService
'sub_shop_id' => $subShopId,
'life_account_id' => $lifeAccountId,
'shop_id' => $shopId,
'name' => $name,
'address_lng' => $addressLng,
'address_lat' => $addressLat,
'shop_name' => $name,
'longitude' => $longitude,
'latitude' => $latitude,
'address' => $address,
'phone' => $phone,
'create_time' => date("Y-m-d H:i:s"),
......@@ -96,9 +91,9 @@ class ShopService
$lifeAccountId = !empty($params['life_account_id']) ? $params['life_account_id'] : 11;
$phone = !empty($params['phone']) ? $params['phone'] : '';
$shopId = !empty($params['shop_id']) ? $params['shop_id'] : '';
$name = !empty($params['name']) ? $params['name'] : '';
$addressLng = !empty($params['address_lng']) ? $params['address_lng'] : '';
$addressLat = !empty($params['address_lat']) ? $params['address_lat'] : '';
$shop_name = !empty($params['shop_name']) ? $params['shop_name'] : '';
$longitude = !empty($params['longitude']) ? $params['longitude'] : '';
$latitude = !empty($params['latitude']) ? $params['latitude'] : '';
$address = !empty($params['address']) ? $params['address'] : '';
$where['life_account_id'] = $lifeAccountId;
......@@ -133,9 +128,9 @@ class ShopService
*/
public static function updateShop($params, $where)
{
$name = !empty($params['name']) ? $params['name'] : '';
$addressLng = !empty($params['address_lng']) ? $params['address_lng'] : '';
$addressLat = !empty($params['address_lat']) ? $params['address_lat'] : '';
$name = !empty($params['shop_name']) ? $params['shop_name'] : '';
$longitude = !empty($params['longitude']) ? $params['longitude'] : '';
$latitude = !empty($params['latitude']) ? $params['latitude'] : '';
$address = !empty($params['address']) ? $params['address'] : '';
$phone = !empty($params['phone']) ? $params['phone'] : '';
......@@ -151,13 +146,21 @@ class ShopService
}
$colums['name'] = $name;
}
$subShopInfo = SubShop::getRecord(['shop_name' => $name]);
if (!empty($subShopInfo) && $subShopInfo['sub_shop_id'] != $where['sub_shop_id']) {
throw new ShopException(['cus' => 6]);
}
if (!empty($addressLng)) {
$colums['address_lng'] = $addressLng;
if (!empty($longitude)) {
$colums['longitude'] = $longitude;
}
if (!empty($addressLat)) {
$colums['address_lat'] = $addressLat;
if (!empty($latitude)) {
$colums['latitude'] = $latitude;
}
if (!empty($address)) {
......@@ -190,7 +193,7 @@ class ShopService
return false;
}
$colums = [
'name' => $name
'shop_name' => $name
];
$subShop = SubShop::getRecord($colums);
if (!empty($subShop)) {
......
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