初始上传
This commit is contained in:
50
addon/fenxiao/api/controller/Account.php
Executable file
50
addon/fenxiao/api/controller/Account.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\api\controller;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoAccount;
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
use app\api\controller\BaseApi;
|
||||
|
||||
/**
|
||||
* 分销商流水
|
||||
*/
|
||||
class Account extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 分销商流水分页
|
||||
* @return false|string
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$model = new FenxiaoModel();
|
||||
$fenxiao_info = $model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id')[ 'data' ];
|
||||
if (!empty($fenxiao_info[ 'fenxiao_id' ])) {
|
||||
$condition = [
|
||||
[ 'fenxiao_id', '=', $fenxiao_info[ 'fenxiao_id' ] ]
|
||||
];
|
||||
|
||||
$account_model = new FenxiaoAccount();
|
||||
$list = $account_model->getFenxiaoAccountPageList($condition, $page, $page_size);
|
||||
return $this->response($list);
|
||||
}
|
||||
return $this->response($this->error('', 'FENXIAO_NOT_EXIST'));
|
||||
}
|
||||
|
||||
}
|
||||
99
addon/fenxiao/api/controller/Apply.php
Executable file
99
addon/fenxiao/api/controller/Apply.php
Executable file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\api\controller;
|
||||
|
||||
use addon\fenxiao\model\Config;
|
||||
use addon\fenxiao\model\FenxiaoApply;
|
||||
use addon\fenxiao\model\Fenxiao;
|
||||
use app\api\controller\BaseApi;
|
||||
|
||||
/**
|
||||
* 申请分销商
|
||||
*/
|
||||
class Apply extends BaseApi
|
||||
{
|
||||
/**
|
||||
* 判断分销商名称是否存在
|
||||
*/
|
||||
public function existFenxiaoName()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$fenxiao_name = $this->params['fenxiao_name'] ?? '';//分销商名称
|
||||
if (empty($fenxiao_name)) {
|
||||
return $this->response($this->error('', 'REQUEST_FENXIAO_NAME'));
|
||||
}
|
||||
|
||||
$apply_model = new FenxiaoApply();
|
||||
$res = $apply_model->existFenxiaoName($fenxiao_name, $this->site_id);
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请成为分销商
|
||||
*/
|
||||
public function applyFenxiao()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$fenxiao_name = $this->params['fenxiao_name'] ?? '';//分销商名称
|
||||
$mobile = $this->params['mobile'] ?? '';//联系电话
|
||||
|
||||
$config = new Config();
|
||||
$basics_config = $config->getFenxiaoBasicsConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
if (!$basics_config[ 'level' ]) return $this->response($this->error('', '未开启分销功能'));
|
||||
|
||||
if ($basics_config[ 'is_apply' ] == 1) {
|
||||
if (empty($fenxiao_name)) {
|
||||
return $this->response($this->error('', 'REQUEST_FENXIAO_NAME'));
|
||||
}
|
||||
if (empty($mobile)) {
|
||||
return $this->response($this->error('', 'REQUEST_MOBILE'));
|
||||
}
|
||||
$apply_model = new FenxiaoApply();
|
||||
$res = $apply_model->applyFenxiao($this->member_id, $this->site_id, $fenxiao_name, $mobile);
|
||||
} else if ($basics_config[ 'is_apply' ] == 0) {
|
||||
$apply_model = new Fenxiao();
|
||||
$res = $apply_model->autoBecomeFenxiao($this->member_id, $this->site_id);
|
||||
} else {
|
||||
return $this->response($this->error('', '未开启分销商申请'));
|
||||
}
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
public function info()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$apply_model = new Fenxiao();
|
||||
$apply_model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'apply_id,fenxiao_name,parent,member_id,mobile,nickname,headimg,level_id,level_name,status');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取申请分销商状态
|
||||
* @return false|string
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$apply_model = new FenxiaoApply();
|
||||
$res = $apply_model->getFenxiaoApplyInfo([ [ 'member_id', '=', $this->member_id ] ], 'status');
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
}
|
||||
127
addon/fenxiao/api/controller/Config.php
Executable file
127
addon/fenxiao/api/controller/Config.php
Executable file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\api\controller;
|
||||
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\fenxiao\model\Config as ConfigModel;
|
||||
use app\model\goods\Goods;
|
||||
use app\model\system\Document;
|
||||
|
||||
/**
|
||||
* 分销相关配置
|
||||
*/
|
||||
class Config extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 提现配置
|
||||
*/
|
||||
public function withdraw()
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getFenxiaoWithdrawConfig($this->site_id);
|
||||
return $this->response($this->success($res[ 'data' ][ 'value' ]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字设置
|
||||
* @return false|string
|
||||
*/
|
||||
public function words()
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getFenxiaoWordsConfig($this->site_id);
|
||||
return $this->response($this->success($res[ 'data' ][ 'value' ]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请协议
|
||||
* @return false|string
|
||||
*/
|
||||
public function agreement()
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$agreement = $config->getFenxiaoAgreementConfig($this->site_id);
|
||||
$res = [];
|
||||
$res[ 'agreement' ] = $agreement[ 'data' ][ 'value' ];
|
||||
if ($agreement[ 'data' ][ 'value' ][ 'is_agreement' ] == 1) {
|
||||
$document_model = new Document();
|
||||
$document = $document_model->getDocument([ [ 'site_id', '=', $this->site_id ], [ 'app_module', '=', 'shop' ], [ 'document_key', '=', 'FENXIAO_AGREEMENT'] ]);
|
||||
$res[ 'document' ] = $document[ 'data' ];
|
||||
}
|
||||
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销基本设置
|
||||
* @return false|string
|
||||
*/
|
||||
public function basics()
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getFenxiaoBasicsConfig($this->site_id);
|
||||
return $this->response($this->success($res[ 'data' ][ 'value' ]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商资格设置
|
||||
* @return false|string
|
||||
*/
|
||||
public function fenxiao()
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getFenxiaoConfig($this->site_id);
|
||||
$res[ 'data' ][ 'value' ][ 'goods_list' ] = [];
|
||||
// 购买指定商品
|
||||
if ($res[ 'data' ][ 'value' ][ 'fenxiao_condition' ] == 4) {
|
||||
$page = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? 10;
|
||||
$condition[] = [ 'gs.goods_state', '=', 1 ];
|
||||
$condition[] = [ 'gs.is_delete', '=', 0 ];
|
||||
$condition[] = [ 'gs.site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'gs.goods_id', 'in', $res[ 'data' ][ 'value' ][ 'goods_ids' ] ];
|
||||
|
||||
$field = 'gs.goods_id,gs.sku_id,gs.sku_name,gs.price,gs.market_price,gs.discount_price,gs.stock,(g.sale_num + g.virtual_sale) as sale_num,gs.sku_image,gs.goods_name,gs.site_id,gs.is_free_shipping,gs.introduction,gs.promotion_type,g.goods_image,gs.unit';
|
||||
$alias = 'gs';
|
||||
$join = [
|
||||
[ 'goods g', 'gs.sku_id = g.sku_id', 'inner' ]
|
||||
];
|
||||
$goods = new Goods();
|
||||
$list = $goods->getGoodsSkuPageList($condition, $page, $page_size, '', $field, $alias, $join);
|
||||
$res[ 'data' ][ 'value' ][ 'goods_list' ] = $list[ 'data' ][ 'list' ];
|
||||
}
|
||||
|
||||
return $this->response($this->success($res[ 'data' ][ 'value' ]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上下级关系设置
|
||||
* @return false|string
|
||||
*/
|
||||
public function relation()
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getFenxiaoRelationConfig($this->site_id);
|
||||
return $this->response($this->success($res[ 'data' ][ 'value' ]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 推广规则
|
||||
* @return false|string
|
||||
*/
|
||||
public function promoteRule()
|
||||
{
|
||||
$document_model = new Document();
|
||||
$document = $document_model->getDocument([ [ 'site_id', '=', $this->site_id ], [ 'app_module', '=', 'shop' ], [ 'document_key', '=', 'FENXIAO_PROMOTE_RULE'] ]);
|
||||
return $this->response($document);
|
||||
}
|
||||
}
|
||||
407
addon/fenxiao/api/controller/Fenxiao.php
Executable file
407
addon/fenxiao/api/controller/Fenxiao.php
Executable file
@@ -0,0 +1,407 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\api\controller;
|
||||
|
||||
use addon\fenxiao\model\Config;
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
use addon\fenxiao\model\FenxiaoLevel;
|
||||
use addon\fenxiao\model\FenxiaoOrder as FenxiaoOrderModel;
|
||||
use addon\fenxiao\model\Poster;
|
||||
use addon\fenxiao\model\PosterTemplate as PosterTemplateModel;
|
||||
use app\api\controller\BaseApi;
|
||||
use app\model\member\Member;
|
||||
use Carbon\Carbon;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 分销相关信息
|
||||
*/
|
||||
class Fenxiao extends BaseApi
|
||||
{
|
||||
/**
|
||||
* 获取分销商信息
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$condition = [
|
||||
[ 'f.member_id', '=', $this->member_id ]
|
||||
];
|
||||
|
||||
$model = new FenxiaoModel();
|
||||
$info = $model->getFenxiaoDetailInfo($condition);
|
||||
if (empty($info[ 'data' ])) {
|
||||
$res = $model->autoBecomeFenxiao($this->member_id, $this->site_id);
|
||||
if (isset($res[ 'code' ]) && $res[ 'code' ] >= 0) {
|
||||
$info = $model->getFenxiaoDetailInfo($condition);
|
||||
}
|
||||
} else {
|
||||
$member = new Member();
|
||||
//$info[ 'data' ][ 'one_child_num' ] = $member->getMemberCount([ [ 'fenxiao_id', '=', $info[ 'data' ][ 'fenxiao_id' ] ], [ 'is_fenxiao', '=', 0 ] ])[ 'data' ];
|
||||
|
||||
$condition_result = $model->geFenxiaoNextLevel($this->member_id, $this->site_id);
|
||||
$info[ 'data' ][ 'condition' ] = $condition_result[ 'data' ];
|
||||
}
|
||||
|
||||
if (!empty($info[ 'data' ])) {
|
||||
$fenxiao_order_model = new FenxiaoOrderModel();
|
||||
|
||||
// 今日收入
|
||||
$compare_today = Carbon::today()->timestamp;
|
||||
$compare_tomorrow = Carbon::tomorrow()->timestamp;
|
||||
|
||||
$commission = 0;
|
||||
$one_commission = $fenxiao_order_model->getFenxiaoOrderInfo([ [ 'one_fenxiao_id', '=', $info[ 'data' ][ 'fenxiao_id' ] ], [ 'create_time', 'between', [ $compare_today, $compare_tomorrow ] ], [ 'is_settlement', '=', 1 ] ], 'sum(one_commission) as commission');
|
||||
$two_commission = $fenxiao_order_model->getFenxiaoOrderInfo([ [ 'two_fenxiao_id', '=', $info[ 'data' ][ 'fenxiao_id' ] ], [ 'create_time', 'between', [ $compare_today, $compare_tomorrow ] ], [ 'is_settlement', '=', 1 ] ], 'sum(two_commission) as commission');
|
||||
$three_commission = $fenxiao_order_model->getFenxiaoOrderInfo([ [ 'three_fenxiao_id', '=', $info[ 'data' ][ 'fenxiao_id' ] ], [ 'create_time', 'between', [ $compare_today, $compare_tomorrow ] ], [ 'is_settlement', '=', 1 ] ], 'sum(three_commission) as commission');
|
||||
|
||||
if (!empty($one_commission[ 'data' ][ 'commission' ])) $commission += $one_commission[ 'data' ][ 'commission' ];
|
||||
if (!empty($two_commission[ 'data' ][ 'commission' ])) $commission += $two_commission[ 'data' ][ 'commission' ];
|
||||
if (!empty($three_commission[ 'data' ][ 'commission' ])) $commission += $three_commission[ 'data' ][ 'commission' ];
|
||||
|
||||
$info[ 'data' ][ 'today_commission' ] = $commission;
|
||||
|
||||
// 总销售额
|
||||
$fenxiao_order_info = $fenxiao_order_model->getFenxiaoOrderInfoNew([ [ 'fo.one_fenxiao_id|fo.two_fenxiao_id|fo.three_fenxiao_id', '=', $info[ 'data' ][ 'fenxiao_id' ] ], ['', 'exp', Db::raw('fo.is_refund=0 or (o.order_status=10 and fo.is_refund=1) ') ] ], 'sum(fo.real_goods_money) as real_goods_money');
|
||||
|
||||
$fenxiao_order_info = $fenxiao_order_info[ 'data' ];
|
||||
if (empty($fenxiao_order_info[ 'real_goods_money' ])) {
|
||||
$fenxiao_order_info[ 'real_goods_money' ] = 0;
|
||||
}
|
||||
$info[ 'data' ][ 'today_order_money' ] = $fenxiao_order_info[ 'real_goods_money' ];
|
||||
|
||||
$info[ 'data' ][ 'in_progress_money' ] = 0;
|
||||
$one_in_progress_commission = $fenxiao_order_model->getFenxiaoOrderInfo([ [ 'one_fenxiao_id', '=', $info[ 'data' ][ 'fenxiao_id' ] ], [ 'is_settlement', '=', 0 ], [ 'is_refund', '=', 0 ] ], 'sum(one_commission) as commission');
|
||||
$two_in_progress_commission = $fenxiao_order_model->getFenxiaoOrderInfo([ [ 'two_fenxiao_id', '=', $info[ 'data' ][ 'fenxiao_id' ] ], [ 'is_settlement', '=', 0 ], [ 'is_refund', '=', 0 ] ], 'sum(two_commission) as commission');
|
||||
$three_in_progress_commission = $fenxiao_order_model->getFenxiaoOrderInfo([ [ 'three_fenxiao_id', '=', $info[ 'data' ][ 'fenxiao_id' ] ], [ 'is_settlement', '=', 0 ], [ 'is_refund', '=', 0 ] ], 'sum(three_commission) as commission');
|
||||
|
||||
if (!empty($one_in_progress_commission[ 'data' ][ 'commission' ])) $info[ 'data' ][ 'in_progress_money' ] += $one_in_progress_commission[ 'data' ][ 'commission' ];
|
||||
if (!empty($two_in_progress_commission[ 'data' ][ 'commission' ])) $info[ 'data' ][ 'in_progress_money' ] += $two_in_progress_commission[ 'data' ][ 'commission' ];
|
||||
if (!empty($three_in_progress_commission[ 'data' ][ 'commission' ])) $info[ 'data' ][ 'in_progress_money' ] += $three_in_progress_commission[ 'data' ][ 'commission' ];
|
||||
}
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取推荐人分销商信息
|
||||
*/
|
||||
public function sourceInfo()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$member = new Member();
|
||||
$member_info = $member->getMemberInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id');
|
||||
$fenxiao_id = $member_info[ 'data' ][ 'fenxiao_id' ] ?? 0;
|
||||
|
||||
if (empty($fenxiao_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_SOURCE_MEMBER'));
|
||||
}
|
||||
$condition = [
|
||||
[ 'fenxiao_id', '=', $fenxiao_id ]
|
||||
];
|
||||
|
||||
$model = new FenxiaoModel();
|
||||
$info = $model->getFenxiaoInfo($condition, 'fenxiao_name');
|
||||
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模板id
|
||||
* @return false|string
|
||||
*/
|
||||
public function posterTemplateIds()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'template_type', '=', 'fenxiao' ],
|
||||
[ 'template_status', '=', 1 ],
|
||||
];
|
||||
$condition[] = [ 'template_type', '=', 'fenxiao' ];
|
||||
$poster_template_model = new PosterTemplateModel();
|
||||
$list = $poster_template_model->getPosterTemplateList($condition, 'template_id', 'template_id asc')[ 'data' ];
|
||||
$id_arr = array_column($list, 'template_id');
|
||||
if (empty($id_arr)) $id_arr = [ 'default' ];
|
||||
|
||||
return $this->response($this->success($id_arr));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销海报
|
||||
* @return \app\api\controller\false|string
|
||||
*/
|
||||
public function poster()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$qrcode_param = $this->params['qrcode_param'] ?? '';//二维码
|
||||
|
||||
if (empty($qrcode_param)) {
|
||||
return $this->response($this->error('', 'REQUEST_QRCODE_PARAM'));
|
||||
}
|
||||
|
||||
$qrcode_param = json_decode($qrcode_param, true);
|
||||
$qrcode_param[ 'source_member' ] = $this->member_id;
|
||||
|
||||
$poster = new Poster();
|
||||
$param = $this->params;
|
||||
$param[ 'qrcode_param' ] = $qrcode_param;
|
||||
$res = $poster->getFenxiaoPoster($param);
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销海报
|
||||
* @return \app\api\controller\false|string
|
||||
*/
|
||||
public function posterList()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'template_type', '=', 'fenxiao' ],
|
||||
[ 'template_status', '=', 1 ],
|
||||
];
|
||||
$condition[] = [ 'template_type', '=', 'fenxiao' ];
|
||||
$poster_template_model = new PosterTemplateModel();
|
||||
$list = $poster_template_model->getPosterTemplateList($condition, 'template_id', 'template_id asc')[ 'data' ];
|
||||
$id_arr = array_column($list, 'template_id');
|
||||
$id_arr = $id_arr ?: ['default'];
|
||||
$qrcode_param = $this->params['qrcode_param'] ?? '';//二维码
|
||||
$qrcode_param = [json_decode($qrcode_param, true)];
|
||||
$qrcode_param[ 'source_member' ] = $this->member_id;
|
||||
$poster = new Poster();
|
||||
$param = $this->params;
|
||||
$param[ 'qrcode_param' ] = $qrcode_param;
|
||||
$path = [];
|
||||
foreach ($id_arr as $k => $v){
|
||||
$param['template_id'] = $v;
|
||||
$res = $poster->getFenxiaoPoster($param)['data']['path'] ?? '';
|
||||
if($res) $path[] = $res;
|
||||
}
|
||||
return $this->response($this->success($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商等级信息
|
||||
*/
|
||||
public function level()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$level = $this->params[ 'level' ] ?? 0;
|
||||
|
||||
$condition = [
|
||||
[ 'level_id', '=', $level ]
|
||||
];
|
||||
$model = new FenxiaoLevel();
|
||||
$info = $model->getLevelInfo($condition);
|
||||
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商我的团队
|
||||
*/
|
||||
public function team()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$page = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
||||
$level = $this->params[ 'level' ] ?? 1;
|
||||
$is_pay = $this->params[ 'is_pay' ] ?? 0;
|
||||
|
||||
$model = new FenxiaoModel();
|
||||
$fenxiao_info = $model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id');
|
||||
if (empty($fenxiao_info[ 'data' ])) return $this->response($this->error('', 'MEMBER_NOT_IS_FENXIAO'));
|
||||
|
||||
$list = $model->getFenxiaoTeam($level, $fenxiao_info[ 'data' ][ 'fenxiao_id' ], $page, $page_size, $is_pay);
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询我的团队的数量
|
||||
*/
|
||||
public function teamNum()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$model = new FenxiaoModel();
|
||||
$fenxiao_info = $model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id');
|
||||
if (empty($fenxiao_info[ 'data' ])) return $this->response($this->error('', 'MEMBER_NOT_IS_FENXIAO'));
|
||||
|
||||
$data = $model->getFenxiaoTeamNum($fenxiao_info[ 'data' ][ 'fenxiao_id' ], $this->site_id);
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下级分销商订单
|
||||
* @return false|string
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$model = new FenxiaoModel();
|
||||
$fenxiao_info = $model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id');
|
||||
if (empty($fenxiao_info[ 'data' ])) return $this->response($this->error('', 'MEMBER_NOT_IS_FENXIAO'));
|
||||
$fenxiao_info = $fenxiao_info[ 'data' ];
|
||||
|
||||
$page = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
||||
$fenxiao_id = $this->params[ 'fenxiao_id' ] ?? 0;
|
||||
$sub_member_id = $this->params[ 'sub_member_id' ] ?? 0;
|
||||
$condition = [];
|
||||
|
||||
if (!empty($fenxiao_id)) {
|
||||
$sub_fenxiao_info = $model->getFenxiaoInfo([ [ 'fenxiao_id', '=', $fenxiao_id ] ], 'fenxiao_id,member_id')[ 'data' ];
|
||||
if (empty($sub_fenxiao_info)) return $this->response($this->error('', 'MEMBER_NOT_IS_FENXIAO'));
|
||||
|
||||
$condition = [
|
||||
[ '', 'exp', Db::raw("( (fo.one_fenxiao_id = {$fenxiao_info['fenxiao_id']} AND fo.two_fenxiao_id = {$fenxiao_id}) OR (fo.two_fenxiao_id = {$fenxiao_info['fenxiao_id']} AND fo.three_fenxiao_id = {$fenxiao_id})) OR fo.member_id = {$sub_fenxiao_info['member_id']}") ]
|
||||
];
|
||||
} elseif (!empty($sub_member_id)) {
|
||||
$is_sub_member = model('member')->getCount([ [ 'member_id', '=', $sub_member_id ], [ 'fenxiao_id', '=', $fenxiao_info[ 'fenxiao_id' ] ] ]);
|
||||
if (!$is_sub_member) return $this->response($this->error('', 'NOT_EXIST_FENXIAO_RELATION'));
|
||||
|
||||
$condition = [
|
||||
[ 'fo.one_fenxiao_id', '=', $fenxiao_info[ 'fenxiao_id' ] ],
|
||||
[ 'fo.member_id', '=', $sub_member_id ]
|
||||
];
|
||||
}
|
||||
|
||||
$order_model = new FenxiaoOrderModel();
|
||||
$list = $order_model->getFenxiaoOrderPageList($condition, $page, $page_size, 'fo.fenxiao_order_id desc');
|
||||
if (!empty($list[ 'data' ][ 'list' ])) {
|
||||
foreach ($list[ 'data' ][ 'list' ] as $k => $item) {
|
||||
if ($item[ 'one_fenxiao_id' ] == $fenxiao_info[ 'fenxiao_id' ]) {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission' ] = $item[ 'one_commission' ];
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission_level' ] = 1;
|
||||
} elseif ($item[ 'two_fenxiao_id' ] == $fenxiao_info[ 'fenxiao_id' ]) {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission' ] = $item[ 'two_commission' ];
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission_level' ] = 2;
|
||||
} elseif ($item[ 'three_fenxiao_id' ] == $fenxiao_info[ 'fenxiao_id' ]) {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission' ] = $item[ 'three_commission' ];
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission_level' ] = 3;
|
||||
}
|
||||
$list[ 'data' ][ 'list' ][ $k ] = array_diff_key($list[ 'data' ][ 'list' ][ $k ], [ 'one_fenxiao_id' => '', 'one_rate' => '', 'one_commission' => '', 'one_fenxiao_name' => '', 'two_fenxiao_id' => '', 'two_rate' => '', 'two_commission' => '', 'two_fenxiao_name' => '', 'three_fenxiao_id' => '', 'three_rate' => '', 'three_commission' => '', 'three_fenxiao_name' => '' ]);
|
||||
}
|
||||
}
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 排行榜
|
||||
*/
|
||||
public function rankingList()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$type = $this->params[ 'type' ] ?? 'profit'; // 排行榜 profit:按受益 invited_num:按邀请人数
|
||||
$page = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$model = new FenxiaoModel();
|
||||
|
||||
$condition = [
|
||||
[ 'f.site_id', '=', $this->site_id ],
|
||||
[ 'f.is_delete', '=', 0 ]
|
||||
];
|
||||
|
||||
$order = $type == 'profit' ? 'f.total_commission desc' : Db::raw('(f.one_child_num) desc');
|
||||
$field = 'f.total_commission, (f.one_child_num) as child_num, m.nickname,m.headimg';
|
||||
|
||||
$data = $model->getFenxiaoPageLists($condition, $page, $page_size, $order, $field, 'f', [ [ 'member m', 'm.member_id = f.member_id', 'inner' ] ]);
|
||||
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取排名
|
||||
* @return false|string
|
||||
*/
|
||||
public function ranking()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$type = $this->params[ 'type' ] ?? 'invited_num'; // 排行榜 profit:按受益 invited_num:按邀请人数
|
||||
|
||||
$model = new FenxiaoModel();
|
||||
$fenxiao_info = $model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id')[ 'data' ];
|
||||
if (empty($fenxiao_info)) return $this->response($this->error('', 'MEMBER_NOT_IS_FENXIAO'));
|
||||
|
||||
$order = $type == 'profit' ? 'total_commission' : '(one_child_num + one_child_fenxiao_num)';
|
||||
|
||||
$data = $model->getFenxiaoRanking($this->site_id, $fenxiao_info[ 'fenxiao_id' ], $order);
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 子级分销商
|
||||
*/
|
||||
public function childFenxiao()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$page = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$model = new FenxiaoModel();
|
||||
$fenxiao_info = $model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id')[ 'data' ];
|
||||
if (empty($fenxiao_info)) return $this->response($this->error('', 'MEMBER_NOT_IS_FENXIAO'));
|
||||
|
||||
$parent_fenxiao_id = [ $fenxiao_info[ 'fenxiao_id' ] ]; // 上级分销商id集合
|
||||
|
||||
// 查询分销基础配置
|
||||
$config_model = new Config();
|
||||
$fenxiao_basic_config = $config_model->getFenxiaoBasicsConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$level = $fenxiao_basic_config[ 'level' ];
|
||||
|
||||
if ($level == 2) {
|
||||
|
||||
// 二级分销商id集合
|
||||
$one_level_fenxiao = model('fenxiao')->getColumn([ [ 'parent', '=', $fenxiao_info[ 'fenxiao_id' ] ] ], 'fenxiao_id');
|
||||
if (!empty($one_level_fenxiao)) {
|
||||
$parent_fenxiao_id = array_merge($parent_fenxiao_id, $one_level_fenxiao);
|
||||
}
|
||||
}
|
||||
|
||||
$condition = [
|
||||
[ 'f.site_id', '=', $this->site_id ],
|
||||
[ 'f.parent', 'in', $parent_fenxiao_id ],
|
||||
[ 'm.is_delete', '=', 0 ]
|
||||
];
|
||||
$field = 'm.nickname,m.headimg,m.member_id,m.order_num,m.order_money,f.fenxiao_id,f.audit_time,f.level_name,m.is_fenxiao,m.bind_fenxiao_time,f.one_child_num,f.one_child_fenxiao_num';
|
||||
$join = [ [ 'member m', 'm.member_id = f.member_id', 'inner' ] ];
|
||||
|
||||
$res = $model->getFenxiaoPageLists($condition, $page, $page_size, 'f.audit_time desc', $field, 'f', $join);
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
169
addon/fenxiao/api/controller/Goods.php
Executable file
169
addon/fenxiao/api/controller/Goods.php
Executable file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\api\controller;
|
||||
|
||||
use addon\fenxiao\model\Config as ConfigModel;
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
use addon\fenxiao\model\FenxiaoGoodsCollect as FenxiaoGoodsCollectModel;
|
||||
use addon\fenxiao\model\FenxiaoGoodsSku as FenxiaoGoodsSkuModel;
|
||||
use app\api\controller\BaseApi;
|
||||
|
||||
/**
|
||||
* 分销商品
|
||||
*/
|
||||
class Goods extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 分销商品详情
|
||||
* @param int $id
|
||||
* @return false|string
|
||||
*/
|
||||
public function detail($id = 0)
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$sku_id = $this->params['sku_id'] ?? 0;
|
||||
if (!empty($id)) {
|
||||
$sku_id = $id;
|
||||
}
|
||||
if (empty($sku_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_SKU_ID'));
|
||||
}
|
||||
|
||||
$config = new ConfigModel();
|
||||
|
||||
$words_config = $config->getFenxiaoWordsConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
|
||||
$data = [
|
||||
'words_account' => $words_config[ 'account' ],
|
||||
'commission_money' => 0.00
|
||||
];
|
||||
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id,level_id')[ 'data' ];
|
||||
if (empty($fenxiao_info)) return $this->response($this->error());
|
||||
|
||||
$fenxiao_goods_sku_model = new FenxiaoGoodsSkuModel();
|
||||
$data[ 'commission_money' ] = $fenxiao_goods_sku_model->getSkuFenxiaoCommission($sku_id, $fenxiao_info[ 'level_id' ])[ 'data' ];
|
||||
|
||||
$basics = $config->getFenxiaoBasicsConfig($this->site_id);
|
||||
$data[ 'is_commission_money' ] = $basics[ 'data' ][ 'value' ][ 'is_commission_money' ];
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商品分页列表
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$keyword = $this->params['keyword'] ?? '';//关键词
|
||||
$category_id = $this->params['category_id'] ?? 0;//分类
|
||||
$min_price = $this->params['min_price'] ?? 0;//价格区间,小
|
||||
$max_price = $this->params['max_price'] ?? 0;//价格区间,大
|
||||
$is_free_shipping = $this->params['is_free_shipping'] ?? 0;//是否免邮
|
||||
$order = $this->params['order'] ?? 'create_time';//排序(综合、销量、价格)
|
||||
$sort = $this->params['sort'] ?? 'desc';//升序、降序
|
||||
$goods_id_arr = $this->params['goods_id_arr'] ?? '';//goods_id数组
|
||||
|
||||
$condition = [
|
||||
[ 'g.is_fenxiao', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
[ 'g.site_id', '=', $this->site_id ]
|
||||
];
|
||||
|
||||
if (!empty($keyword)) {
|
||||
$condition[] = [ 'g.goods_name|g.keywords', 'like', '%' . $keyword . '%' ];
|
||||
}
|
||||
|
||||
if (!empty($category_id)) {
|
||||
$condition[] = [ 'g.category_id', 'like', '%,' . $category_id . ',%' ];
|
||||
}
|
||||
|
||||
if (!empty($goods_id_arr)) {
|
||||
$condition[] = [ 'g.goods_id', 'in', $goods_id_arr ];
|
||||
}
|
||||
|
||||
if ($min_price != '' && $max_price != '') {
|
||||
$condition[] = [ 'g.discount_price', 'between', [ $min_price, $max_price ] ];
|
||||
} elseif ($min_price != '') {
|
||||
$condition[] = [ 'g.discount_price', '>=', $min_price ];
|
||||
} elseif ($max_price != '') {
|
||||
$condition[] = [ 'g.discount_price', '<=', $max_price ];
|
||||
}
|
||||
|
||||
if (!empty($is_free_shipping)) {
|
||||
$condition[] = [ 'g.is_free_shipping', '=', $is_free_shipping ];
|
||||
}
|
||||
|
||||
// 非法参数进行过滤
|
||||
if ($sort != 'desc' && $sort != 'asc') {
|
||||
$sort = '';
|
||||
}
|
||||
|
||||
// 非法参数进行过滤
|
||||
if ($order != '') {
|
||||
if ($order != 'sale_num' && $order != 'discount_price') {
|
||||
$order = 'gs.create_time';
|
||||
} elseif ($order != 'sale_num') {
|
||||
$order = 'gs.' . $order;
|
||||
} else {
|
||||
$order = 'sale_sort';
|
||||
}
|
||||
$order_by = $order . ' ' . $sort;
|
||||
} else {
|
||||
$order_by = 'g.sort desc,g.create_time desc';
|
||||
}
|
||||
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id,level_id')[ 'data' ];
|
||||
|
||||
// $fenxiao_level = new FenxiaoLevel();
|
||||
// $level_info = $fenxiao_level->getLevelInfo([ [ 'level_id', '=', $fenxiao_info[ 'level_id' ] ] ], 'one_rate')[ 'data' ];
|
||||
|
||||
$fenxiao_goods_sku_model = new FenxiaoGoodsSkuModel();
|
||||
$list = $fenxiao_goods_sku_model->getFenxiaoGoodsSkuPageList($condition, $page, $page_size, $order_by);
|
||||
|
||||
$fenxiao_goods_collect_model = new FenxiaoGoodsCollectModel();
|
||||
|
||||
// 计算佣金
|
||||
foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
|
||||
$collection_info = $fenxiao_goods_collect_model->getCollectInfo([
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
[ 'goods_id', '=', $v[ 'goods_id' ] ],
|
||||
[ 'fenxiao_id', '=', $fenxiao_info[ 'fenxiao_id' ] ],
|
||||
], 'collect_id');
|
||||
|
||||
// 查询是否关注该分销商品
|
||||
$collection_info = $collection_info[ 'data' ];
|
||||
if (!empty($collection_info)) {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'is_collect' ] = 1;
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'collect_id' ] = $collection_info[ 'collect_id' ];
|
||||
} else {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'is_collect' ] = 0;
|
||||
}
|
||||
|
||||
$sku_commission_info = $fenxiao_goods_sku_model->getSkuFenxiaoCommission($v[ 'sku_id' ], $fenxiao_info[ 'level_id' ]);
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission_money' ] = $sku_commission_info[ 'data' ];
|
||||
}
|
||||
|
||||
return $this->response($list);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
138
addon/fenxiao/api/controller/Goodscollect.php
Executable file
138
addon/fenxiao/api/controller/Goodscollect.php
Executable file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\api\controller;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoGoodsSku;
|
||||
use addon\fenxiao\model\FenxiaoLevel;
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
use addon\fenxiao\model\FenxiaoGoodsCollect as FenxiaoGoodsCollectModel;
|
||||
|
||||
/**
|
||||
* 分销商关注商品
|
||||
*/
|
||||
class Goodscollect extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 添加分销商关注商品
|
||||
* @return false|string
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$goods_id = $this->params['goods_id'] ?? 0;
|
||||
$sku_id = $this->params['sku_id'] ?? 0;
|
||||
|
||||
if (empty($goods_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_GOODS_ID'));
|
||||
}
|
||||
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id')[ 'data' ];
|
||||
|
||||
$data = [
|
||||
'member_id' => $this->member_id,
|
||||
'fenxiao_id' => $fenxiao_info[ 'fenxiao_id' ],
|
||||
'goods_id' => $goods_id,
|
||||
'sku_id' => $sku_id,
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
$fenxiao_goods_sku_model = new FenxiaoGoodsCollectModel();
|
||||
$res = $fenxiao_goods_sku_model->addCollect($data);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分销商关注商品
|
||||
* @return false|string
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$collect_id = $this->params['collect_id'] ?? 0;
|
||||
|
||||
if (empty($collect_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_COLLECT_ID'));
|
||||
}
|
||||
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id')[ 'data' ];
|
||||
$condition = [
|
||||
[ 'fenxiao_id', '=', $fenxiao_info[ 'fenxiao_id' ] ],
|
||||
[ 'collect_id', '=', $collect_id ]
|
||||
];
|
||||
$fenxiao_goods_sku_model = new FenxiaoGoodsCollectModel();
|
||||
$res = $fenxiao_goods_sku_model->deleteCollect($condition);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商关注商品分页列表
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
// 获取当前用户的分销等级
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id,level_id')[ 'data' ];
|
||||
|
||||
$fenxiao_level = new FenxiaoLevel();
|
||||
$level_info = $fenxiao_level->getLevelInfo([ [ 'level_id', '=', $fenxiao_info[ 'level_id' ] ] ], 'one_rate')[ 'data' ];
|
||||
|
||||
$condition = [
|
||||
[ 'g.is_fenxiao', '=', 1 ],
|
||||
[ 'g.site_id', '=', $this->site_id ],
|
||||
[ 'gs.goods_state', '=', 1 ],
|
||||
[ 'gs.is_delete', '=', 0 ],
|
||||
[ 'fgc.member_id', '=', $this->member_id ]
|
||||
];
|
||||
|
||||
$fenxiao_goods_collect_model = new FenxiaoGoodsCollectModel();
|
||||
$list = $fenxiao_goods_collect_model->getCollectPageList($condition, $page, $page_size);
|
||||
$fenxiao_goods_sku_model = new FenxiaoGoodsSku();
|
||||
|
||||
// 计算佣金比率
|
||||
foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
|
||||
$discount_price = $v[ 'fenxiao_price' ] > 0 ? $v[ 'fenxiao_price' ] : $v[ 'discount_price' ];
|
||||
|
||||
$money = 0;
|
||||
if ($v[ 'fenxiao_type' ] == 1) {
|
||||
// 默认规则
|
||||
$money = number_format($discount_price * $level_info[ 'one_rate' ] / 100, 2, '.', '');
|
||||
} else {
|
||||
// 自定义规则
|
||||
$fenxiao_goods_sku_info = $fenxiao_goods_sku_model->getFenxiaoGoodsSkuInfo([ [ 'sku_id', '=', $v[ 'sku_id' ] ], [ 'level_id', '=', $fenxiao_info[ 'level_id' ] ] ], 'one_money,one_rate');
|
||||
if (!empty($fenxiao_goods_sku_info[ 'data' ])) {
|
||||
$fenxiao_goods_sku_info = $fenxiao_goods_sku_info[ 'data' ];
|
||||
$money = $fenxiao_goods_sku_info[ 'one_money' ];
|
||||
if ($fenxiao_goods_sku_info[ 'one_rate' ] > 0) {
|
||||
$money = number_format($discount_price * $fenxiao_goods_sku_info[ 'one_rate' ] / 100, 2, '.', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission_money' ] = $money;
|
||||
}
|
||||
|
||||
return $this->response($list);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
42
addon/fenxiao/api/controller/Level.php
Executable file
42
addon/fenxiao/api/controller/Level.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\api\controller;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoLevel;
|
||||
use app\api\controller\BaseApi;
|
||||
|
||||
|
||||
/**
|
||||
* 分销等级
|
||||
*/
|
||||
class Level extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 分销商等级列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$condition = [
|
||||
[ 'status', '=', 1 ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'is_default', '=', 0 ]
|
||||
];
|
||||
$model = new FenxiaoLevel();
|
||||
$info = $model->getLevelList($condition, 'level_id,level_num,level_name,one_rate,two_rate,three_rate,upgrade_type,fenxiao_order_num,fenxiao_order_meney,one_fenxiao_order_num,one_fenxiao_order_money,order_num,order_money,child_num,child_fenxiao_num,one_child_num,one_child_fenxiao_num,one_fenxiao_total_order', 'level_num asc,one_rate asc');
|
||||
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
}
|
||||
114
addon/fenxiao/api/controller/Order.php
Executable file
114
addon/fenxiao/api/controller/Order.php
Executable file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\api\controller;
|
||||
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\fenxiao\model\FenxiaoOrder as FenxiaoOrderModel;
|
||||
use addon\fenxiao\model\Fenxiao;
|
||||
|
||||
/**
|
||||
* 分销订单
|
||||
*/
|
||||
class Order extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 信息
|
||||
* @return false|string
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$model = new Fenxiao();
|
||||
$fenxiao_info = $model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id');
|
||||
if (empty($fenxiao_info[ 'data' ])) return $this->response($this->error('', 'MEMBER_NOT_IS_FENXIAO'));
|
||||
|
||||
$fenxiao_order_id = $this->params['fenxiao_order_id'] ?? 0;
|
||||
if (empty($fenxiao_order_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_FENXIAO_ORDER_ID'));
|
||||
}
|
||||
$order_model = new FenxiaoOrderModel();
|
||||
$condition = [
|
||||
[ 'one_fenxiao_id|two_fenxiao_id|three_fenxiao_id', '=', $fenxiao_info[ 'data' ][ 'fenxiao_id' ] ],
|
||||
[ 'fenxiao_order_id', '=', $fenxiao_order_id ]
|
||||
];
|
||||
$res = $order_model->getFenxiaoOrderInfo($condition);
|
||||
if (!empty($res[ 'data' ])) {
|
||||
if ($res[ 'data' ][ 'one_fenxiao_id' ] == $fenxiao_info[ 'data' ][ 'fenxiao_id' ]) {
|
||||
$res[ 'data' ][ 'commission' ] = $res[ 'data' ][ 'one_commission' ];
|
||||
$res[ 'data' ][ 'commission_rate' ] = $res[ 'data' ][ 'one_rate' ];
|
||||
$res[ 'data' ][ 'commission_level' ] = 1;
|
||||
} elseif ($res[ 'data' ][ 'two_fenxiao_id' ] == $fenxiao_info[ 'data' ][ 'fenxiao_id' ]) {
|
||||
$res[ 'data' ][ 'commission' ] = $res[ 'data' ][ 'two_commission' ];
|
||||
$res[ 'data' ][ 'commission_rate' ] = $res[ 'data' ][ 'two_rate' ];
|
||||
$res[ 'data' ][ 'commission_level' ] = 2;
|
||||
} elseif ($res[ 'data' ][ 'three_fenxiao_id' ] == $fenxiao_info[ 'data' ][ 'fenxiao_id' ]) {
|
||||
$res[ 'data' ][ 'commission' ] = $res[ 'data' ][ 'three_commission' ];
|
||||
$res[ 'data' ][ 'commission_rate' ] = $res[ 'data' ][ 'three_rate' ];
|
||||
$res[ 'data' ][ 'commission_level' ] = 3;
|
||||
}
|
||||
$res[ 'data' ] = array_diff_key($res[ 'data' ], [ 'member_id' => '', 'member_name' => '', 'member_mobile' => '', 'full_address' => '', 'one_fenxiao_id' => '', 'one_rate' => '', 'one_commission' => '', 'one_fenxiao_name' => '', 'two_fenxiao_id' => '', 'two_rate' => '', 'two_commission' => '', 'two_fenxiao_name' => '', 'three_fenxiao_id' => '', 'three_rate' => '', 'three_commission' => '', 'three_fenxiao_name' => '' ]);
|
||||
}
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$model = new Fenxiao();
|
||||
$fenxiao_info = $model->getFenxiaoInfo([ [ 'member_id', '=', $this->member_id ] ], 'fenxiao_id');
|
||||
if (empty($fenxiao_info[ 'data' ])) return $this->response($this->error('', 'MEMBER_NOT_IS_FENXIAO'));
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$is_settlement = $this->params['is_settlement'] ?? 0;// 结算状态 0 全部 1 待结算 2 已结算 3 已退款
|
||||
|
||||
$condition = [
|
||||
[ 'fo.one_fenxiao_id|fo.two_fenxiao_id|fo.three_fenxiao_id', '=', $fenxiao_info[ 'data' ][ 'fenxiao_id' ] ]
|
||||
];
|
||||
if (!empty($is_settlement)) {
|
||||
if ($is_settlement == 3) {
|
||||
$condition[] = [ 'fo.is_refund', '=', 1 ];
|
||||
}
|
||||
if (in_array($is_settlement, [ 1, 2 ])) {
|
||||
$condition[] = [ 'fo.is_settlement', '=', $is_settlement - 1 ];
|
||||
$condition[] = [ 'fo.is_refund', '=', 0 ];
|
||||
}
|
||||
}
|
||||
|
||||
$order_model = new FenxiaoOrderModel();
|
||||
$list = $order_model->getFenxiaoOrderPageList($condition, $page, $page_size, 'fo.fenxiao_order_id desc');
|
||||
if (!empty($list[ 'data' ][ 'list' ])) {
|
||||
foreach ($list[ 'data' ][ 'list' ] as $k => $item) {
|
||||
if ($item[ 'one_fenxiao_id' ] == $fenxiao_info[ 'data' ][ 'fenxiao_id' ]) {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission' ] = $item[ 'one_commission' ];
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission_level' ] = 1;
|
||||
} elseif ($item[ 'two_fenxiao_id' ] == $fenxiao_info[ 'data' ][ 'fenxiao_id' ]) {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission' ] = $item[ 'two_commission' ];
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission_level' ] = 2;
|
||||
} elseif ($item[ 'three_fenxiao_id' ] == $fenxiao_info[ 'data' ][ 'fenxiao_id' ]) {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission' ] = $item[ 'three_commission' ];
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'commission_level' ] = 3;
|
||||
}
|
||||
$list[ 'data' ][ 'list' ][ $k ] = array_diff_key($list[ 'data' ][ 'list' ][ $k ], [ 'one_fenxiao_id' => '', 'one_rate' => '', 'one_commission' => '', 'one_fenxiao_name' => '', 'two_fenxiao_id' => '', 'two_rate' => '', 'two_commission' => '', 'two_fenxiao_name' => '', 'three_fenxiao_id' => '', 'three_rate' => '', 'three_commission' => '', 'three_fenxiao_name' => '' ]);
|
||||
}
|
||||
}
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
}
|
||||
122
addon/fenxiao/api/controller/Withdraw.php
Executable file
122
addon/fenxiao/api/controller/Withdraw.php
Executable file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\api\controller;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoWithdraw;
|
||||
use app\api\controller\BaseApi;
|
||||
use app\model\member\Member;
|
||||
|
||||
/**
|
||||
* 分销提现
|
||||
*/
|
||||
class Withdraw extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 提现记录分页
|
||||
* @return false|string
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$status = $this->params['status'] ?? 0;// 当前状态 1待审核 2待转账 3已转账 -1 已拒绝
|
||||
|
||||
$condition = [
|
||||
[ 'member_id', '=', $this->member_id ]
|
||||
];
|
||||
if (!empty($status)) {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
|
||||
$order = 'id desc';
|
||||
$withdraw_model = new FenxiaoWithdraw();
|
||||
$list = $withdraw_model->getFenxiaoWithdrawPageList($condition, $page, $page_size, $order);
|
||||
foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
|
||||
$list[ 'data' ][ 'list' ][ $k ] = $withdraw_model->tran($v);
|
||||
}
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转账方式
|
||||
* @return false|string
|
||||
*/
|
||||
public function transferType()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$member_model = new Member();
|
||||
$member_info = $member_model->getMemberInfo([ [ 'member_id', '=', $token[ 'data' ][ 'member_id' ] ] ], 'site_id,wx_openid,weapp_openid');
|
||||
$withdraw_config_model = new \addon\fenxiao\model\Config();
|
||||
$transfer_type_list = $withdraw_config_model->getTransferType($member_info[ 'data' ][ 'site_id' ]);
|
||||
if (empty($member_info[ 'data' ][ 'wx_openid' ]) && empty($member_info[ 'data' ][ 'weapp_openid' ])) {
|
||||
unset($transfer_type_list[ 'wechatpay' ]);
|
||||
}
|
||||
return $this->response($this->success($transfer_type_list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请提现
|
||||
* @return mixed
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$apply_money = $this->params[ 'apply_money' ] ?? 0;
|
||||
$transfer_type = $this->params[ 'transfer_type' ] ?? '';//提现方式
|
||||
$realname = $this->params[ 'realname' ] ?? '';//真实姓名
|
||||
$bank_name = $this->params[ 'bank_name' ] ?? '';//银行名称
|
||||
$account_number = $this->params[ 'account_number' ] ?? '';//账号名称
|
||||
$mobile = $this->params[ 'mobile' ] ?? '';//手机号
|
||||
$app_type = $this->params[ 'app_type' ];
|
||||
$fenxiao_withdraw_model = new FenxiaoWithdraw();
|
||||
$data = array (
|
||||
'member_id' => $this->member_id,
|
||||
'transfer_type' => $transfer_type,
|
||||
'realname' => $realname,
|
||||
'bank_name' => $bank_name,
|
||||
'account_number' => $account_number,
|
||||
'apply_money' => $apply_money,
|
||||
'mobile' => $mobile,
|
||||
'app_type' => $app_type
|
||||
);
|
||||
$result = $fenxiao_withdraw_model->apply($data, $this->site_id);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现详情
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params[ 'id' ] ?? 0;
|
||||
$fenxiao_withdraw_model = new FenxiaoWithdraw();
|
||||
$params = array (
|
||||
'id' => $id,
|
||||
'site_id' => $this->site_id
|
||||
);
|
||||
$result = $fenxiao_withdraw_model->getFenxiaoWithdrawDetail($params);
|
||||
return $this->response($result);
|
||||
}
|
||||
|
||||
}
|
||||
18
addon/fenxiao/api/lang/code.php
Executable file
18
addon/fenxiao/api/lang/code.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'REQUEST_FENXIAO_NAME' => -1,
|
||||
'REQUEST_QRCODE_PARAM' => -1,
|
||||
'REQUEST_MONEY' => -1,
|
||||
'REQUEST_FENXIAO_ORDER_ID' => -1,
|
||||
'REQUEST_SOURCE_MEMBER' => -1,
|
||||
'REQUEST_LEVEL_ID' => -1,
|
||||
'MEMBER_NOT_IS_FENXIAO' => -1,
|
||||
'FENXIAO_NOT_EXIST' => -1,
|
||||
'REQUEST_FENXIAO_ID' => -1,
|
||||
'REQUEST_COLLECT_ID' => -1,
|
||||
'GOODS_COLLECT_IS_EXIST' => -1,
|
||||
'APPLYING' => 1,
|
||||
'ALREADY_DISTRIBUTOR' => 1,
|
||||
'NOT_EXIST_FENXIAO_RELATION' => -1
|
||||
];
|
||||
4
addon/fenxiao/api/lang/en-us.php
Executable file
4
addon/fenxiao/api/lang/en-us.php
Executable file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
];
|
||||
18
addon/fenxiao/api/lang/zh-cn.php
Executable file
18
addon/fenxiao/api/lang/zh-cn.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'REQUEST_FENXIAO_NAME' => '缺少参数fenxiao_name',
|
||||
'REQUEST_QRCODE_PARAM' => '缺少参数qrcode_param',
|
||||
'REQUEST_MONEY' => '缺少参数money',
|
||||
'REQUEST_FENXIAO_ORDER_ID' => '缺少参数fenxiao_order_id',
|
||||
'REQUEST_SOURCE_MEMBER' => '缺少参数source_member',
|
||||
'REQUEST_LEVEL_ID' => '缺少参数level_id',
|
||||
'MEMBER_NOT_IS_FENXIAO' => '该会员还不是分销商',
|
||||
'FENXIAO_NOT_EXIST' => '分销商不存在',
|
||||
'REQUEST_FENXIAO_ID' => '缺少参数fenxiao_id',
|
||||
'REQUEST_COLLECT_ID' => '缺少参数collect_id',
|
||||
'GOODS_COLLECT_IS_EXIST' => '已关注该分销商品',
|
||||
'APPLYING' => '审核中',
|
||||
'ALREADY_DISTRIBUTOR' => '已是分销商',
|
||||
'NOT_EXIST_FENXIAO_RELATION' => '查询用户与您不存在分销关系'
|
||||
];
|
||||
28
addon/fenxiao/component/controller/FenxiaoGoodsList.php
Executable file
28
addon/fenxiao/component/controller/FenxiaoGoodsList.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace addon\fenxiao\component\controller;
|
||||
|
||||
use app\component\controller\BaseDiyView;
|
||||
use app\model\goods\GoodsCategory;
|
||||
|
||||
/**
|
||||
* 分销商品·组件
|
||||
*
|
||||
*/
|
||||
class FenxiaoGoodsList extends BaseDiyView
|
||||
{
|
||||
|
||||
/**
|
||||
* 设计界面
|
||||
*/
|
||||
public function design()
|
||||
{
|
||||
$site_id = request()->siteid();
|
||||
$goods_category_model = new GoodsCategory();
|
||||
$category_condition[] = [ 'site_id', '=', $site_id ];
|
||||
$category_list = $goods_category_model->getCategoryTree($category_condition)[ 'data' ];
|
||||
$this->assign('category_list', $category_list);
|
||||
|
||||
return $this->fetch('goods_list/design.html');
|
||||
}
|
||||
}
|
||||
38
addon/fenxiao/component/view/goods_list/css/design.css
Executable file
38
addon/fenxiao/component/view/goods_list/css/design.css
Executable file
@@ -0,0 +1,38 @@
|
||||
/* 选择商品分类弹出框 */
|
||||
.goods-category-layer {display: none;}
|
||||
.layui-layer-content .category-wrap .category-item, .layui-layer-content .category-head {height: 30px;line-height: 30px;border: 1px solid #ededed;border-radius: 5px;padding: 0 15px;margin: 0 15px 10px 0;box-sizing: border-box;color: #666;font-size: 12px;}
|
||||
.layui-layer-content .category-head {background: #eee;height: 40px;line-height: 40px;}
|
||||
.layui-layer-content .category-wrap {overflow-y: scroll;height: calc(100% - 45px);}
|
||||
.layui-layer-content .category-wrap::-webkit-scrollbar {display: none;}
|
||||
.layui-layer-content .category-wrap .category-item {cursor: pointer;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}
|
||||
|
||||
/* 样式:单列(一行一列) */
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item{overflow: hidden;display: flex;margin-bottom: 10px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item:last-of-type{margin-bottom: 0;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item .goods-img{width: 130px;height: 130px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item .goods-img img{max-width: 100%;max-height: 100%;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item .info-wrap{width: calc(100% - 130px);padding: 10px;flex: 1;display: flex;flex-direction: column;box-sizing: border-box;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item .info-wrap .pro-info{display: flex;justify-content: space-between;align-items: center;margin-top:auto;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item .info-wrap .pro-info .sale{margin-top: 5px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item .info-wrap .pro-info .discount-price{display: flex;justify-content: space-between;flex-direction: column;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item .info-wrap .pro-info .discount-price .price-wrap{margin-bottom: 5px;font-weight: bold;font-size: 0;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item .info-wrap .pro-info .discount-price .price-wrap .unit{font-size: 12px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item .info-wrap .pro-info .discount-price .price-wrap .price{font-size: 16px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item .info-wrap .pro-info .delete-price{text-decoration: line-through;flex: 1;line-height: 14px;font-size: 12px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of1 .goods-item button{height: 25px;line-height: 25px;}
|
||||
|
||||
/* 样式:两列(一行两列) */
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2{display: flex;flex-wrap: wrap;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item{overflow: hidden;margin-right: 10px;margin-top: 10px;width: calc(50% - 5px);display: flex;flex-direction: column;box-sizing: border-box;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item:nth-child(2n){margin-right: 0;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item:nth-of-type(1), .component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item:nth-of-type(2){margin-top: 0;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item .goods-img{width: calc(100% + 2px);height: 160px;text-align: center;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item .goods-img img{width: 100%;height: 100%;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item .info-wrap .goods-name{margin-bottom: 5px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item .info-wrap{display: flex;flex-direction: column;flex: 1;padding: 10px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item .info-wrap .pro-info{margin-top: auto;display: flex;justify-content: space-between;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item .info-wrap .pro-info .discount-price .price-wrap{margin-bottom: 5px;font-size: 0;font-weight: bold;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item .info-wrap .pro-info .discount-price .price-wrap .unit{font-size: 12px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item .info-wrap .pro-info .discount-price .price-wrap .price{font-size: 16px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item .info-wrap .pro-info .delete-price{text-decoration: line-through;flex: 1;line-height: 14px;font-size: 12px;}
|
||||
.component-fenxiao-goods .fenxiao-list.row1-of2 .goods-item button{height: 25px;line-height: 25px;}
|
||||
363
addon/fenxiao/component/view/goods_list/design.html
Executable file
363
addon/fenxiao/component/view/goods_list/design.html
Executable file
@@ -0,0 +1,363 @@
|
||||
<nc-component :data="data[index]" class="component-fenxiao-goods">
|
||||
|
||||
<!-- 预览 -->
|
||||
<template slot="preview">
|
||||
|
||||
<div :class="['fenxiao-list',nc.template,nc.style]" :style="{ backgroundColor: nc.componentBgColor,
|
||||
borderTopLeftRadius: (nc.componentAngle == 'round' ? nc.topAroundRadius + 'px' : 0),
|
||||
borderTopRightRadius: (nc.componentAngle == 'round' ? nc.topAroundRadius + 'px' : 0),
|
||||
borderBottomLeftRadius: (nc.componentAngle == 'round' ? nc.bottomAroundRadius + 'px' : 0),
|
||||
borderBottomRightRadius: (nc.componentAngle == 'round' ? nc.bottomAroundRadius + 'px' : 0)
|
||||
}">
|
||||
<template v-if="nc.tempData.previewList && Object.keys(nc.tempData.previewList).length">
|
||||
<div class="goods-item" v-for="(item, previewIndex) in nc.tempData.previewList" :key="previewIndex"
|
||||
:style="{
|
||||
borderTopLeftRadius: (nc.elementAngle == 'round' ? nc.topElementAroundRadius + 'px' : 0),
|
||||
borderTopRightRadius: (nc.elementAngle == 'round' ? nc.topElementAroundRadius + 'px' : 0),
|
||||
borderBottomLeftRadius: (nc.elementAngle == 'round' ? nc.bottomElementAroundRadius + 'px' : 0),
|
||||
borderBottomRightRadius: (nc.elementAngle == 'round' ? nc.bottomElementAroundRadius + 'px' : 0),
|
||||
backgroundColor: nc.elementBgColor,
|
||||
boxShadow: nc.ornament.type == 'shadow' ? ('0 0 5px ' + nc.ornament.color) : '',
|
||||
border: nc.ornament.type == 'stroke' ? '1px solid ' + nc.ornament.color : ''}">
|
||||
<div class="goods-img" :style="{ borderRadius: nc.imgAroundRadius + 'px' }">
|
||||
<img :style="{ borderRadius: nc.imgAroundRadius + 'px' }" :src="changeImgUrl('public/static/img/default_img/square.png')"/>
|
||||
</div>
|
||||
|
||||
<div class="info-wrap" v-if="nc.goodsNameStyle.control || nc.priceStyle.mainControl || nc.priceStyle.lineControl || nc.btnStyle.control">
|
||||
|
||||
<div class="goods-name" v-if="nc.goodsNameStyle.control" :style="{ color : nc.goodsNameStyle.color,fontWeight : nc.goodsNameStyle.fontWeight ? 'bold' : '' }" :class="[{'using-hidden' : nc.nameLineMode == 'single'},{'multi-hidden' : nc.nameLineMode == 'multiple'}]">{{ item.goods_name }}</div>
|
||||
|
||||
<div class="pro-info">
|
||||
<div class="discount-price">
|
||||
<div class="price-wrap" v-if="nc.priceStyle.mainControl">
|
||||
<span class="unit" :style="{ color : nc.priceStyle.mainColor }">赚 ¥</span>
|
||||
<span class="price" :style="{ color : nc.priceStyle.mainColor }">{{item.fenxiao_price}}</span>
|
||||
</div>
|
||||
<div class="delete-price" v-if="nc.priceStyle.lineControl" :style="{ color : nc.priceStyle.lineColor }">¥{{item.discount_price}}</div>
|
||||
</div>
|
||||
|
||||
<button v-if="nc.btnStyle.control" class="layui-btn" :style="{ background : 'linear-gradient(to right,' + nc.btnStyle.bgColorStart + ',' + nc.btnStyle.bgColorEnd + ')', color : nc.btnStyle.textColor,borderRadius : nc.btnStyle.aroundRadius + 'px' }">{{ nc.btnStyle.text }}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<!-- 内容编辑 -->
|
||||
<template slot="edit-content">
|
||||
<template v-if="nc.lazyLoad">
|
||||
<fenxiao-goods-list-sources></fenxiao-goods-list-sources>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>商品风格</h3>
|
||||
<div class="layui-form-item list-style" v-if="nc.tempData.templateList">
|
||||
<label class="layui-form-label sm">风格</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="source">{{ nc.tempData.templateList[nc.template].text }}</div>
|
||||
<div class="template-selected">
|
||||
<div v-for="(item,templateKey) in nc.tempData.templateList" :key="templateKey" class="source-item" :title="item.text"
|
||||
@click="nc.tempData.methods.selectTemplate(templateKey)"
|
||||
:class="[(nc.template == templateKey) ? 'text-color border-color' : '' ]">
|
||||
<i class='iconfont' :class='item.icon'></i>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 暂时只有一种样式,先隐藏 -->
|
||||
<!-- <div class="style-selected">-->
|
||||
<!-- <div v-for="(item,styleIndex) in nc.tempData.templateList[nc.template].styleList" :key="styleIndex" @click="nc.tempData.methods.selectTemplate('',item)" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.style==item.value) }">-->
|
||||
<!-- <i class="layui-anim layui-icon">{{ nc.style == item.value ? "" : "" }}</i>-->
|
||||
<!-- <div>{{item.text}}</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>商品数据</h3>
|
||||
<div class="layui-form-item" v-if="nc.tempData.goodsSources">
|
||||
<label class="layui-form-label sm">数据来源</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="source-selected">
|
||||
<div class="source">{{ nc.tempData.goodsSources[nc.sources].text }}</div>
|
||||
<div v-for="(item,sourcesKey) in nc.tempData.goodsSources" :key="sourcesKey" class="source-item" :title="item.text" @click="nc.sources=sourcesKey" :class="{ 'text-color border-color' : (nc.sources == sourcesKey) }">
|
||||
<i class='iconfont' :class='item.icon'></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.sources == 'category'">
|
||||
<label class="layui-form-label sm">商品分类</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="selected-style" @click="nc.tempData.methods.selectCategory()">
|
||||
<span :class="{ 'text-color' : nc.categoryId > 0 }">{{ nc.categoryName }}</span>
|
||||
<i class="iconfont iconyoujiantou"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.sources == 'diy'">
|
||||
<label class="layui-form-label sm">手动选择</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="selected-style" @click="nc.tempData.methods.addGoods()">
|
||||
<span v-if="nc.goodsId.length == 0">请选择</span>
|
||||
<span v-if="nc.goodsId.length > 0" class="text-color">已选{{ nc.goodsId.length }}个</span>
|
||||
<i class="iconfont iconyoujiantou"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<slide :data="{ field : 'count', label: '商品数量', min:1, max: 50}" v-if="nc.sources != 'diy'"></slide>
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title" v-show="nc.btnStyle.support">
|
||||
<h3>购买按钮</h3>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">是否显示</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.btnStyle.control = !nc.btnStyle.control" :class="{ 'layui-form-checked' : nc.btnStyle.control }">
|
||||
<span>{{ nc.btnStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.btnStyle.control">
|
||||
<label class="layui-form-label sm">文字</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" v-model="nc.btnStyle.text" maxlength="6" placeholder="请输入按钮文字" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>显示内容</h3>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">商品名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.goodsNameStyle.control = !nc.goodsNameStyle.control" :class="{ 'layui-form-checked' : nc.goodsNameStyle.control }">
|
||||
<span>{{ nc.goodsNameStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">佣金</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.priceStyle.mainControl = !nc.priceStyle.mainControl" :class="{ 'layui-form-checked' : nc.priceStyle.mainControl }">
|
||||
<span>{{ nc.priceStyle.mainControl ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-show="nc.priceStyle.lineSupport">
|
||||
<label class="layui-form-label sm">划线价</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.priceStyle.lineControl = !nc.priceStyle.lineControl" :class="{ 'layui-form-checked' : nc.priceStyle.lineControl }">
|
||||
<span>{{ nc.priceStyle.lineControl ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<!-- 商品分类选择弹框 -->
|
||||
<script type="text/html" class="goods-category-layer">
|
||||
<div class="goods-category-list layui-form">
|
||||
<table class="layui-table pithy-table">
|
||||
<colgroup>
|
||||
<col width="5%">
|
||||
<col width="3%">
|
||||
<col width="37%">
|
||||
<col width="25%">
|
||||
<col width="30%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th>分类名称</th>
|
||||
<th>简称</th>
|
||||
<th>图片</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{if condition="$category_list"}
|
||||
{foreach name="$category_list" item="vo"}
|
||||
<tr class='category-line'>
|
||||
<td><input type="checkbox" name="category_select_id" data-category_select_id = "{$vo['category_id']}" lay-skin="primary" value='{:json_encode($vo)}' lay-filter="category_select_id" {if !empty($link_array.category_id) && $link_array.category_id == $v['category_id']}checked{/if}></td>
|
||||
<td>
|
||||
{notempty name="$vo['child_list']"}
|
||||
<span class="switch text-color js-switch" data-category-id="{$vo['category_id']}" data-level="{$vo['level']}" data-open="0">+</span>
|
||||
{/notempty}
|
||||
</td>
|
||||
<td class="category-name">{$vo['category_name']}</td>
|
||||
<td>{$vo['short_name']}</td>
|
||||
<td>
|
||||
{notempty name="$vo['image']"}
|
||||
<div class="img-box">
|
||||
<img layer-src src="{:img($vo['image'])}"/>
|
||||
</div>
|
||||
{/notempty}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{notempty name="$vo['child_list']"}
|
||||
{foreach name="$vo['child_list']" item="second"}
|
||||
<tr class='category-line' data-category-id-1="{$second['category_id_1']}" style="display:none;">
|
||||
<td><input type="checkbox" name="category_select_id" lay-skin="primary"data-category_select_id = "{$second['category_id']}" value='{:json_encode($second)}' lay-filter="category_select_id"{if !empty($link_array.category_id) && $link_array.category_id == $second['category_id']}checked{/if}></td>
|
||||
<td></td>
|
||||
<td style="padding-left: 20px;">
|
||||
<span class="switch text-color js-switch" data-category-id="{$second['category_id']}" data-level="{$second['level']}" data-open="1" style="padding-right: 20px;">-</span>
|
||||
<span class="category-name">{$second['category_name']}</span>
|
||||
</td>
|
||||
<td>{$second['short_name']}</td>
|
||||
<td>
|
||||
{notempty name="$second['image']"}
|
||||
<img layer-src src="{:img($second['image'])}"/>
|
||||
{/notempty}
|
||||
</td>
|
||||
</tr>
|
||||
{notempty name="$second['child_list']"}
|
||||
{foreach name="$second['child_list']" item="third"}
|
||||
<tr class='category-line'data-category-id-1="{$third['category_id_1']}" data-category-id-2="{$third['category_id_2']}" style="display:none;">
|
||||
<td><input type="checkbox" name="category_select_id" lay-skin="primary" value='{:json_encode($third)}' data-category_select_id = '{$third['category_id']}'lay-filter="category_select_id"{if !empty($link_array.category_id) && $link_array.category_id == $third['category_id']}checked{/if}></td>
|
||||
<td></td>
|
||||
<td style="padding-left: 80px;">
|
||||
<span class="category-name">{$third['category_name']}</span>
|
||||
</td>
|
||||
<td>{$third['short_name']}</td>
|
||||
<td>
|
||||
{notempty name="$third['image']"}
|
||||
<img layer-src src="{:img($third['image'])}"/>
|
||||
{/notempty}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{/notempty}
|
||||
{/foreach}
|
||||
{/notempty}
|
||||
{/foreach}
|
||||
{else/}
|
||||
<tr>
|
||||
<td colspan="9" style="text-align: center">无数据</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</script>
|
||||
</template>
|
||||
|
||||
<!-- 样式编辑 -->
|
||||
<template slot="edit-style">
|
||||
<template v-if="nc.lazyLoad">
|
||||
<div class="template-edit-title">
|
||||
<h3>商品样式</h3>
|
||||
|
||||
<div class="layui-form-item tag-wrap">
|
||||
<label class="layui-form-label sm">边框</label>
|
||||
<div class="layui-input-block">
|
||||
<div v-for="(item,ornamentIndex) in nc.tempData.ornamentList" :key="ornamentIndex" @click="nc.ornament.type=item.type" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.ornament.type==item.type) }">
|
||||
<i class="layui-anim layui-icon">{{ nc.ornament.type == item.type ? "" : "" }}</i>
|
||||
<div>{{item.text}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<color v-if="nc.ornament.type != 'default'" :data="{ field : 'color', 'label' : '边框颜色', parent : 'ornament', defaultColor : '#EDEDED' }"></color>
|
||||
|
||||
<slide :data="{ field : 'imgAroundRadius', label: '图片圆角', min:0, max: 50 }"></slide>
|
||||
|
||||
<div class="layui-form-item" v-show="nc.goodsNameStyle.control">
|
||||
<label class="layui-form-label sm">商品名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.goodsNameStyle.fontWeight = !nc.goodsNameStyle.fontWeight" :class="{ 'layui-form-checked' : nc.goodsNameStyle.fontWeight }">
|
||||
<span>加粗</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
<div v-for="(item,nameLineIndex) in nc.tempData.nameLineModeList" :key="nameLineIndex" @click="nc.nameLineMode=item.value" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.nameLineMode==item.value) }">
|
||||
<i class="layui-anim layui-icon">{{ nc.nameLineMode == item.value ? "" : "" }}</i>
|
||||
<div>{{item.text}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<color :data="{ field : 'elementBgColor', 'label' : '商品背景' }"></color>
|
||||
|
||||
<slide v-show="nc.elementAngle == 'round'" :data="{ field : 'topElementAroundRadius', label : '上圆角', max : 50 }"></slide>
|
||||
<slide v-show="nc.elementAngle == 'round'" :data="{ field : 'bottomElementAroundRadius', label : '下圆角', max : 50 }"></slide>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">色调</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.theme='default'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.theme == 'default') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.theme == 'default' ? "" : "" }}</i>
|
||||
<div>跟随主题风格</div>
|
||||
</div>
|
||||
<div @click="nc.theme='diy'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.theme == 'diy') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.theme == 'diy' ? "" : "" }}</i>
|
||||
<div>自定义</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="nc.theme == 'diy'">
|
||||
<color :data="{ field : 'color', 'label' : '商品名称', parent : 'goodsNameStyle', defaultColor : '#303133' }"></color>
|
||||
<color :data="{ field : 'mainColor', 'label' : '佣金', parent : 'priceStyle', defaultColor : '#FF6A00' }"></color>
|
||||
<div v-show="nc.priceStyle.lineSupport">
|
||||
<color :data="{ field : 'lineColor', 'label' : '划线价', parent : 'priceStyle', defaultColor : '#999CA7' }"></color>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title" v-show="nc.btnStyle.support && nc.btnStyle.control">
|
||||
<h3>购买按钮</h3>
|
||||
|
||||
<slide :data="{ field : 'aroundRadius', label: '圆角', min:0, max: 50, parent: 'btnStyle' }"></slide>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">色调</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.btnStyle.theme='default'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.btnStyle.theme == 'default') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.btnStyle.theme == 'default' ? "" : "" }}</i>
|
||||
<div>跟随主题风格</div>
|
||||
</div>
|
||||
<div @click="nc.btnStyle.theme='diy'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.btnStyle.theme == 'diy') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.btnStyle.theme == 'diy' ? "" : "" }}</i>
|
||||
<div>自定义</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="nc.btnStyle.theme == 'diy'">
|
||||
<color :data="{ field : 'bgColorStart,bgColorEnd', 'label' : '背景颜色', parent : 'btnStyle', defaultColor : '#FF7B1D,#FF1544' }"></color>
|
||||
<color :data="{ field : 'textColor', 'label' : '文字颜色', parent : 'btnStyle', defaultColor : '#FFFFFF' }"></color>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- 资源 -->
|
||||
<template slot="resource">
|
||||
<js>
|
||||
var fenxiaoResourcePath = "{$resource_path}"; // http路径
|
||||
var fenxiaoRelativePath = "{$relative_path}"; // 相对路径
|
||||
</js>
|
||||
<css src="{$resource_path}/css/design.css"></css>
|
||||
<js src="{$resource_path}/js/design.js"></js>
|
||||
</template>
|
||||
|
||||
</nc-component>
|
||||
BIN
addon/fenxiao/component/view/goods_list/img/style1.png
Executable file
BIN
addon/fenxiao/component/view/goods_list/img/style1.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 194 KiB |
BIN
addon/fenxiao/component/view/goods_list/img/style2.png
Executable file
BIN
addon/fenxiao/component/view/goods_list/img/style2.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 169 KiB |
BIN
addon/fenxiao/component/view/goods_list/img/style3.png
Executable file
BIN
addon/fenxiao/component/view/goods_list/img/style3.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 180 KiB |
185
addon/fenxiao/component/view/goods_list/js/design.js
Executable file
185
addon/fenxiao/component/view/goods_list/js/design.js
Executable file
@@ -0,0 +1,185 @@
|
||||
var fenxiaoListHtml = '<div style="display:none;"></div>';
|
||||
|
||||
Vue.component("fenxiao-goods-list-sources", {
|
||||
template: fenxiaoListHtml,
|
||||
data: function () {
|
||||
return {
|
||||
data: this.$parent.data,
|
||||
goodsSources: {
|
||||
initial: {
|
||||
text: "默认",
|
||||
icon: "iconmofang"
|
||||
},
|
||||
category: {
|
||||
text: "商品分类",
|
||||
icon: "iconshangpinfenlei"
|
||||
},
|
||||
diy: {
|
||||
text: "手动选择",
|
||||
icon: "iconshoudongxuanze"
|
||||
},
|
||||
},
|
||||
templateList: {
|
||||
"row1-of1": {
|
||||
text: "单列",
|
||||
icon: "iconiPhone86",
|
||||
styleList: [
|
||||
{
|
||||
text: "样式1",
|
||||
value: "style-1",
|
||||
cartSupport: true, // 是否支持按钮
|
||||
lineSupport:true, // 是否支持划线价
|
||||
},
|
||||
],
|
||||
},
|
||||
"row1-of2": {
|
||||
text: "两列",
|
||||
icon: "iconyihanglianglie",
|
||||
styleList: [
|
||||
{
|
||||
text: "样式1",
|
||||
value: "style-1",
|
||||
cartSupport: true, // 是否支持按钮
|
||||
lineSupport:true, // 是否支持划线价
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
ornamentList: [
|
||||
{
|
||||
type: 'default',
|
||||
text: '默认',
|
||||
},
|
||||
{
|
||||
type: 'shadow',
|
||||
text: '投影',
|
||||
},
|
||||
{
|
||||
type: 'stroke',
|
||||
text: '描边',
|
||||
},
|
||||
],
|
||||
nameLineModeList: [
|
||||
{
|
||||
text: "单行",
|
||||
value: "single"
|
||||
},
|
||||
{
|
||||
text: "多行",
|
||||
value: "multiple"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
created:function() {
|
||||
if(!this.$parent.data.verify) this.$parent.data.verify = [];
|
||||
this.$parent.data.verify.push(this.verify);//加载验证方法
|
||||
|
||||
this.$parent.data.ignore = ['textColor']; //加载忽略内容 -- 其他设置中的属性设置
|
||||
this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载
|
||||
|
||||
var previewList = {};
|
||||
for (var i = 1; i < 5; i++) {
|
||||
previewList["goods_id_" + ns.gen_non_duplicate(i)] = {
|
||||
goods_name: "分销商品",
|
||||
discount_price: (Math.random() * 100 * i + 10).toFixed(2), // 随机价格
|
||||
fenxiao_price: (Math.random() * 10 * i + 10).toFixed(0), // 随机价格
|
||||
};
|
||||
}
|
||||
|
||||
// 组件所需的临时数据
|
||||
this.$parent.data.tempData = {
|
||||
goodsSources: this.goodsSources,
|
||||
templateList: this.templateList,
|
||||
ornamentList: this.ornamentList,
|
||||
nameLineModeList: this.nameLineModeList,
|
||||
previewList: previewList,
|
||||
methods: {
|
||||
addGoods: this.addGoods,
|
||||
selectCategory: this.selectCategory,
|
||||
selectTemplate: this.selectTemplate
|
||||
},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
verify : function (index) {
|
||||
var res = { code : true, message : "" };
|
||||
if (vue.data[index].sources == 'category' && vue.data[index].categoryId == 0){
|
||||
res.code = false;
|
||||
res.message = "请选择商品分类";
|
||||
}
|
||||
return res;
|
||||
},
|
||||
addGoods: function () {
|
||||
var self = this;
|
||||
goodsSelect(function (res) {
|
||||
self.$parent.data.goodsId = res;
|
||||
}, self.$parent.data.goodsId, {mode: "spu", promotion: "fenxiao", disabled: 0, post: ns.appModule});
|
||||
},
|
||||
selectCategory() {
|
||||
var self = this;
|
||||
layui.use(['form'], function () {
|
||||
var form = layui.form;
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '选择分类',
|
||||
area: ['630px', '430px'],
|
||||
btn: ['确定', '返回'],
|
||||
content: $(".draggable-element[data-index='" + self.data.index + "'] .edit-attribute .goods-category-layer").html(),
|
||||
success: function (layero, index) {
|
||||
$(".js-switch").click(function () {
|
||||
var category_id = $(this).attr("data-category-id");
|
||||
var level = $(this).attr("data-level");
|
||||
var open = parseInt($(this).attr("data-open").toString());
|
||||
|
||||
if (open) {
|
||||
$(".goods-category-list .layui-table tr[data-category-id-" + level + "='" + category_id + "']").hide();
|
||||
$(this).text("+");
|
||||
} else {
|
||||
$(".goods-category-list .layui-table tr[data-category-id-" + level + "='" + category_id + "']").show();
|
||||
$(this).text("-");
|
||||
}
|
||||
$(this).attr("data-open", (open ? 0 : 1));
|
||||
});
|
||||
|
||||
form.on('checkbox(category_select_id)', function (data) {
|
||||
if (data.elem.checked) {
|
||||
$("input[name='category_select_id']:checked").prop("checked", false);
|
||||
$(data.elem).prop("checked", true);
|
||||
form.render();
|
||||
}
|
||||
});
|
||||
|
||||
$("input[name='category_select_id']:checked").prop("checked", false);
|
||||
if (self.data.categoryId) {
|
||||
$('.layui-layer-content [data-category_select_id="' + self.data.categoryId + '"]').prop("checked", true);
|
||||
}
|
||||
|
||||
form.render();
|
||||
},
|
||||
yes: function (index, layero) {
|
||||
var selected = $(".layui-layer-content input[name='category_select_id']:checked");
|
||||
if (selected.length === 0) {
|
||||
layer.msg('请选择商品分类');
|
||||
return;
|
||||
}
|
||||
self.data.categoryName = selected.parents('tr').find('.category-name').text();
|
||||
self.data.categoryId = selected.attr('data-category_select_id');
|
||||
layer.closeAll()
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
selectTemplate(template, item) {
|
||||
if (template) {
|
||||
this.$parent.data.template = template;
|
||||
item = this.templateList[template].styleList[0];
|
||||
}
|
||||
this.$parent.data.style = item.value;
|
||||
this.$parent.data.btnStyle.support = item.cartSupport;
|
||||
this.$parent.data.btnStyle.control = item.cartSupport;
|
||||
this.$parent.data.priceStyle.lineSupport = item.lineSupport;
|
||||
this.$parent.data.priceStyle.lineControl = item.lineSupport;
|
||||
},
|
||||
}
|
||||
});
|
||||
124
addon/fenxiao/config/diy_view.php
Executable file
124
addon/fenxiao/config/diy_view.php
Executable file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [
|
||||
// [
|
||||
// 'title' => '分销市场',
|
||||
// 'name' => 'DIY_FENXIAO_MARKET',
|
||||
// 'path' => '/pages_tool/index/diy?name=DIY_FENXIAO_MARKET',
|
||||
// 'value' => '',
|
||||
// ]
|
||||
],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [
|
||||
// [
|
||||
// 'name' => 'FenxiaoGoodsList',
|
||||
// 'title' => '分销商品',
|
||||
// 'type' => 'PROMOTION',
|
||||
// 'value' => '{"style":"style-1","sources":"initial","count":6,"goodsId":[],"nameLineMode":"single","template":"row1-of2","categoryId":0,"categoryName":"请选择","goodsNameStyle":{"color":"#303133","control":true,"fontWeight":false},"imgAroundRadius":0,"btnStyle":{"text":"关注","textColor":"#FFFFFF","theme":"default","aroundRadius":25,"control":true,"support":true,"bgColorStart":"#FC6731","bgColorEnd":"#FF4444"},"priceStyle":{"mainColor":"#FF4444","mainControl":true,"lineColor":"#999CA7","lineControl":true,"lineSupport":true},"ornament":{"type":"default","color":"#EDEDED"},"theme":"default"}',
|
||||
// 'sort' => '30008',
|
||||
// 'support_diy_view' => 'DIY_FENXIAO_MARKET',
|
||||
// 'max_count' => 0,
|
||||
// 'icon' => 'iconfont iconfenxiaoshangpin'
|
||||
// ]
|
||||
],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [
|
||||
[
|
||||
'name' => 'DISTRIBUTION',
|
||||
'title' => '分销',
|
||||
'parent' => 'MARKETING_LINK',
|
||||
'wap_url' => '',
|
||||
'web_url' => '',
|
||||
'sort' => 2,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'DISTRIBUTION_CENTRE',
|
||||
'title' => '分销中心',
|
||||
'wap_url' => '/pages_promotion/fenxiao/index',
|
||||
'web_url' => '',
|
||||
'sort' => 0
|
||||
],
|
||||
[
|
||||
'name' => 'WITHDRAWAL_SUBSIDIARY',
|
||||
'title' => '提现明细',
|
||||
'wap_url' => '/pages_promotion/fenxiao/withdraw_list',
|
||||
'web_url' => '',
|
||||
'sort' => 0
|
||||
],
|
||||
[
|
||||
'name' => 'DISTRIBUTION_ORDER',
|
||||
'title' => '分销订单',
|
||||
'wap_url' => '/pages_promotion/fenxiao/order',
|
||||
'web_url' => '',
|
||||
'sort' => 0
|
||||
],
|
||||
// [
|
||||
// 'name' => 'DISTRIBUTION_MARKET',
|
||||
// 'title' => '分销市场',
|
||||
// 'wap_url' => '/pages_tool/index/diy?name=DIY_FENXIAO_MARKET',
|
||||
// 'web_url' => '',
|
||||
// 'sort' => 0
|
||||
// ],
|
||||
[
|
||||
'name' => 'DISTRIBUTION_GOODS',
|
||||
'title' => '分销商品',
|
||||
'wap_url' => '/pages_promotion/fenxiao/goods_list',
|
||||
'web_url' => '',
|
||||
'sort' => 0
|
||||
],
|
||||
[
|
||||
'name' => 'DISTRIBUTION_TEAM',
|
||||
'title' => '分销团队',
|
||||
'wap_url' => '/pages_promotion/fenxiao/team',
|
||||
'web_url' => '',
|
||||
'sort' => 0
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_POSTER',
|
||||
'title' => '推广海报',
|
||||
'wap_url' => '/pages_promotion/fenxiao/promote_code',
|
||||
'web_url' => '',
|
||||
'sort' => 0
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'DISTRIBUTION_GOODS',
|
||||
'title' => '分销商品',
|
||||
'parent' => 'COMMODITY',
|
||||
'wap_url' => '',
|
||||
'web_url' => '',
|
||||
'child_list' => []
|
||||
],
|
||||
],
|
||||
|
||||
// 自定义图标库
|
||||
'icon_library' => [],
|
||||
|
||||
// uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
|
||||
'component' => [],
|
||||
|
||||
// uni-app 页面,多个逗号隔开
|
||||
'pages' => [],
|
||||
|
||||
// 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
|
||||
'info' => [],
|
||||
|
||||
// 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
|
||||
'theme' => [],
|
||||
|
||||
// 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
|
||||
'data' => []
|
||||
];
|
||||
95
addon/fenxiao/config/event.php
Executable file
95
addon/fenxiao/config/event.php
Executable file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\fenxiao\event\ShowPromotion',
|
||||
],
|
||||
'PromotionType' => [
|
||||
'addon\fenxiao\event\PromotionType',
|
||||
],
|
||||
'OrderComplete' => [
|
||||
'addon\fenxiao\event\OrderSettlement',
|
||||
'addon\fenxiao\event\OrderComplete'
|
||||
],
|
||||
'OrderRefundFinish' => [
|
||||
'addon\fenxiao\event\OrderGoodsRefund',
|
||||
],
|
||||
'AlterShareRelation' => [
|
||||
'addon\fenxiao\event\AlterShareRelation',
|
||||
],
|
||||
'OrderCreateAfter' => [
|
||||
'addon\fenxiao\event\OrderCreateAfter',
|
||||
],
|
||||
'PresaleOrderCreate' => [
|
||||
'addon\fenxiao\event\PresaleOrderCreate',
|
||||
],
|
||||
'OrderPayAfter' => [
|
||||
'addon\fenxiao\event\OrderPayAfter',
|
||||
],
|
||||
'MemberAccountFromType' => [
|
||||
'addon\fenxiao\event\MemberAccountFromType',
|
||||
],
|
||||
|
||||
'MemberRegister' => [
|
||||
'addon\fenxiao\event\MemberRegister',
|
||||
],
|
||||
'FenxiaoUpgrade' => [
|
||||
'addon\fenxiao\event\FenxiaoUpgrade',
|
||||
],
|
||||
'AddSite' => [
|
||||
'addon\fenxiao\event\AddSiteDiyView',//增加默认自定义数据:主页主页、商品分类、底部导航
|
||||
'addon\fenxiao\event\AddSiteFenxiaoLevel',//增加默认分销等级:普通分销商
|
||||
],
|
||||
|
||||
// 商品列表
|
||||
'GoodsListPromotion' => [
|
||||
'addon\fenxiao\event\GoodsListPromotion',
|
||||
],
|
||||
// 商品分类
|
||||
'GoodsListCategoryIds' => [
|
||||
'addon\fenxiao\event\GoodsListCategoryIds',
|
||||
],
|
||||
// 会员注销
|
||||
'MemberCancel' => [
|
||||
'addon\fenxiao\event\MemberCancel',
|
||||
],
|
||||
|
||||
//微信分享数据
|
||||
'WchatShareData' => [
|
||||
'addon\fenxiao\event\WchatShareData',
|
||||
],
|
||||
//微信分享配置
|
||||
'WchatShareConfig' => [
|
||||
'addon\fenxiao\event\WchatShareConfig',
|
||||
],
|
||||
//小程序分享数据
|
||||
'WeappShareData' => [
|
||||
'addon\fenxiao\event\WeappShareData',
|
||||
],
|
||||
//小程序分享配置
|
||||
'WeappShareConfig' => [
|
||||
'addon\fenxiao\event\WeappShareConfig',
|
||||
],
|
||||
|
||||
//统计写入
|
||||
'AddStat' => [
|
||||
'addon\fenxiao\event\AddStat',
|
||||
],
|
||||
//转账结果通知
|
||||
'PayTransferNotify' => [
|
||||
'addon\fenxiao\event\WithdrawTransferNotify',
|
||||
],
|
||||
'PayTransferCheck' => [
|
||||
'addon\fenxiao\event\WithdrawTransferCheck',
|
||||
],
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
20
addon/fenxiao/config/info.php
Executable file
20
addon/fenxiao/config/info.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'fenxiao',
|
||||
'title' => '分销',
|
||||
'description' => '分销',
|
||||
'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
330
addon/fenxiao/config/menu_shop.php
Executable file
330
addon/fenxiao/config/menu_shop.php
Executable file
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 店铺端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO',
|
||||
'title' => '分销管理',
|
||||
'url' => 'fenxiao://shop/fenxiao/index',
|
||||
'parent' => 'PROMOTION_CENTER',
|
||||
'picture' => 'addon/fenxiao/shop/view/public/img/distribution_new.png',
|
||||
'picture_selected' => 'addon/fenxiao/shop/view/public/img/distribution_select.png',
|
||||
'is_show' => 1,
|
||||
'sort' => 100,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_INDEX',
|
||||
'title' => '分销概况',
|
||||
'url' => 'fenxiao://shop/fenxiao/index',
|
||||
'is_show' => 1,
|
||||
'sort' => 1,
|
||||
'child_list' => []
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_ROOT',
|
||||
'title' => '分销商',
|
||||
'url' => 'fenxiao://shop/fenxiao/lists',
|
||||
'is_show' => 1,
|
||||
'is_control' => 1,
|
||||
'sort' => 2,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_DETAIL',
|
||||
'title' => '分销商信息',
|
||||
'url' => 'fenxiao://shop/fenxiao/detail',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_TEAM',
|
||||
'title' => '分销商团队',
|
||||
'url' => 'fenxiao://shop/fenxiao/team',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_ACCOUNT',
|
||||
'title' => '账户明细',
|
||||
'url' => 'fenxiao://shop/fenxiao/account',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_ORDERMANAGE',
|
||||
'title' => '订单管理',
|
||||
'url' => 'fenxiao://shop/fenxiao/order',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_ORDERMANAGEDETAIL',
|
||||
'title' => '订单详情',
|
||||
'url' => 'fenxiao://shop/fenxiao/orderdetail',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_ADD',
|
||||
'title' => '添加分销商',
|
||||
'url' => 'fenxiao://shop/fenxiao/add',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_FROZEN',
|
||||
'title' => '冻结',
|
||||
'url' => 'fenxiao://shop/fenxiao/frozen',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_UNFROZEN',
|
||||
'title' => '恢复正常',
|
||||
'url' => 'fenxiao://shop/fenxiao/unfrozen',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_CHANGE_LEVEL',
|
||||
'title' => '变更上级分销商',
|
||||
'url' => 'fenxiao://shop/fenxiao/confirmChange',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_APPLY',
|
||||
'title' => '分销商申请',
|
||||
'url' => 'fenxiao://shop/fenxiao/apply',
|
||||
'is_show' => 1,
|
||||
'sort' => 3,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_PASS',
|
||||
'title' => '审核通过',
|
||||
'url' => 'fenxiao://shop/fenxiao/pass',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_REFUSE',
|
||||
'title' => '审核拒绝',
|
||||
'url' => 'fenxiao://shop/fenxiao/refuse',
|
||||
'is_show' => 0,
|
||||
'is_control' => 1,
|
||||
'type' => 'button',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_GOODS_LIST',
|
||||
'title' => '分销商品',
|
||||
'url' => 'fenxiao://shop/goods/lists',
|
||||
'is_show' => 1,
|
||||
'sort' => 4,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_GOODS_DETAIL',
|
||||
'title' => '商品详情',
|
||||
'url' => 'fenxiao://shop/goods/detail',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_GOODS_CONFIG',
|
||||
'title' => '商品设置',
|
||||
'url' => 'fenxiao://shop/goods/config',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_GOODS_MODIFY',
|
||||
'title' => '状态设置',
|
||||
'url' => 'fenxiao://shop/goods/modify',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_SET_GOODS_IS_FENXIAO',
|
||||
'title' => '是否参与分销',
|
||||
'url' => 'fenxiao://shop/goods/setGoodsIsFenxiao',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_ORDER',
|
||||
'title' => '分销订单',
|
||||
'url' => 'fenxiao://shop/order/lists',
|
||||
'is_show' => 1,
|
||||
'sort' => 5,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_ORDER_DETAIL',
|
||||
'title' => '订单详情',
|
||||
'url' => 'fenxiao://shop/order/detail',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_LEVEL',
|
||||
'title' => '分销等级',
|
||||
'url' => 'fenxiao://shop/level/lists',
|
||||
'is_show' => 1,
|
||||
'is_control' => 1,
|
||||
'sort' => 6,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_LEVEL_ADD',
|
||||
'title' => '添加等级',
|
||||
'url' => 'fenxiao://shop/level/add',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_LEVEL_EDIT',
|
||||
'title' => '编辑等级',
|
||||
'url' => 'fenxiao://shop/level/edit',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_LEVEL_STATUS',
|
||||
'title' => '等级状态设置',
|
||||
'url' => 'fenxiao://shop/level/status',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_LEVEL_DELETE',
|
||||
'title' => '删除等级',
|
||||
'url' => 'fenxiao://shop/level/delete',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_CONFIG',
|
||||
'title' => '分销设置',
|
||||
'url' => 'fenxiao://shop/config/basics',
|
||||
'is_show' => 1,
|
||||
'is_control' => 1,
|
||||
'sort' => 7,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_BASICS',
|
||||
'title' => '基础设置',
|
||||
'url' => 'fenxiao://shop/config/basics',
|
||||
'is_show' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_AGREEMENT',
|
||||
'title' => '申请协议',
|
||||
'url' => 'fenxiao://shop/config/agreement',
|
||||
'is_show' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_SETTLEMENT',
|
||||
'title' => '提现设置',
|
||||
'url' => 'fenxiao://shop/config/settlement',
|
||||
'is_show' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_WORDS',
|
||||
'title' => '文字设置',
|
||||
'url' => 'fenxiao://shop/config/words',
|
||||
'is_show' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_PEOMOTE_RULE',
|
||||
'title' => '推广活动',
|
||||
'url' => 'fenxiao://shop/config/promoterule',
|
||||
'is_show' => 1,
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_POSTER_TEMPLATE',
|
||||
'title' => '分销海报',
|
||||
'url' => 'fenxiao://shop/postertemplate/lists',
|
||||
'is_show' => 1,
|
||||
'is_control' => 1,
|
||||
'sort' => 11,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_POSTER_TEMPLATE_ADD',
|
||||
'title' => '添加海报',
|
||||
'url' => 'fenxiao://shop/postertemplate/addpostertemplate',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_POSTER_TEMPLATE_EDIT',
|
||||
'title' => '编辑海报',
|
||||
'url' => 'fenxiao://shop/postertemplate/editpostertemplate',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_WITHDRAW',
|
||||
'title' => '分销提现',
|
||||
'url' => 'fenxiao://shop/withdraw/lists',
|
||||
'parent' => 'ACCOUNT_MANAGE',
|
||||
'picture' => 'app/shop/view/public/img/icon_new/member_withdraw_new.png',
|
||||
'picture_selected' => 'app/shop/view/public/img/icon_new/member_withdraw_select.png',
|
||||
'is_show' => 1,
|
||||
'is_control' => 1,
|
||||
'sort' => 4,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_WITHDRAW_DETAIL',
|
||||
'title' => '佣金提现详情',
|
||||
'url' => 'fenxiao://shop/withdraw/detail',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_WITHDRAW_PASS',
|
||||
'title' => '审核通过',
|
||||
'url' => 'fenxiao://shop/withdraw/withdrawpass',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_FENXIAO_WITHDRAW_REFUSE',
|
||||
'title' => '审核拒绝',
|
||||
'url' => 'fenxiao://shop/withdraw/withdrawrefuse',
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
1
addon/fenxiao/data/install.sql
Executable file
1
addon/fenxiao/data/install.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
1
addon/fenxiao/data/uninstall.sql
Executable file
1
addon/fenxiao/data/uninstall.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
23
addon/fenxiao/event/AddSiteDiyView.php
Executable file
23
addon/fenxiao/event/AddSiteDiyView.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
|
||||
/**
|
||||
* 增加默认自定义数据:分销市场
|
||||
*/
|
||||
class AddSiteDiyView
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
56
addon/fenxiao/event/AddSiteFenxiaoLevel.php
Executable file
56
addon/fenxiao/event/AddSiteFenxiaoLevel.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoLevel as FenxiaoLevelModel;
|
||||
|
||||
/**
|
||||
* 增加默认分销商等级
|
||||
*/
|
||||
class AddSiteFenxiaoLevel
|
||||
{
|
||||
|
||||
public function handle($param)
|
||||
{
|
||||
if (!empty($param[ 'site_id' ])) {
|
||||
|
||||
$model = new FenxiaoLevelModel();
|
||||
$default_level = $model->getLevelInfo([ [ 'site_id', '=', $param[ 'site_id' ] ], [ 'is_default', '=', 1 ] ], 'level_id');
|
||||
|
||||
if (empty($default_level[ 'data' ])) {
|
||||
$data = [
|
||||
'site_id' => $param[ 'site_id' ],
|
||||
'level_name' => '默认等级',
|
||||
'level_num' => 0,
|
||||
'one_rate' => 10.00,
|
||||
'two_rate' => 5.00,
|
||||
'three_rate' => '',
|
||||
'upgrade_type' => '2',
|
||||
'fenxiao_order_num' => '',
|
||||
'fenxiao_order_meney' => '',
|
||||
'one_fenxiao_order_num' => '',
|
||||
'one_fenxiao_order_money' => '',
|
||||
'one_fenxiao_total_order' => '',
|
||||
'order_num' => '',
|
||||
'order_money' => '',
|
||||
'child_num' => '',
|
||||
'child_fenxiao_num' => '',
|
||||
'one_child_num' => '',
|
||||
'one_child_fenxiao_num' => '',
|
||||
'is_default' => 1
|
||||
];
|
||||
$res = $model->addLevel($data);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
39
addon/fenxiao/event/AddStat.php
Executable file
39
addon/fenxiao/event/AddStat.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoStat;
|
||||
|
||||
/**
|
||||
* 分销统计
|
||||
*/
|
||||
class AddStat
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$type = $params[ 'type' ];
|
||||
$stat_model = new FenxiaoStat();
|
||||
if ($type == 'add_fenxiao_member') {
|
||||
$res = $stat_model->addFenxiaoMemberStat($params[ 'data' ]);
|
||||
return $res;
|
||||
}
|
||||
if ($type == 'fenxiao_order') {
|
||||
$res = $stat_model->addFenxiaoOrderStat($params[ 'data' ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
34
addon/fenxiao/event/AlterShareRelation.php
Executable file
34
addon/fenxiao/event/AlterShareRelation.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class AlterShareRelation
|
||||
{
|
||||
/**
|
||||
* 用户分销上下级关系
|
||||
* @param $param
|
||||
* @return array|void
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
return $fenxiao_model->bindRelation([
|
||||
'site_id' => $param[ 'site_id' ],
|
||||
'member_id' => $param[ 'member_id' ],
|
||||
'action' => 'alter_share_relation',
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
addon/fenxiao/event/FenxiaoUpgrade.php
Executable file
31
addon/fenxiao/event/FenxiaoUpgrade.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\Fenxiao;
|
||||
|
||||
/**
|
||||
* 分销商升级
|
||||
*/
|
||||
class FenxiaoUpgrade
|
||||
{
|
||||
/**
|
||||
* 分销商升级
|
||||
* @param $fenxiao_id
|
||||
*/
|
||||
public function handle($fenxiao_id)
|
||||
{
|
||||
if (!empty($fenxiao_id)) {
|
||||
$fenxiao = new Fenxiao();
|
||||
$fenxiao->fenxiaoUpgrade($fenxiao_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
41
addon/fenxiao/event/GoodsListCategoryIds.php
Executable file
41
addon/fenxiao/event/GoodsListCategoryIds.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
class GoodsListCategoryIds
|
||||
{
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (empty($param[ 'promotion' ]) || $param[ 'promotion' ] != 'fenxiao') return [];
|
||||
|
||||
$condition = [
|
||||
[ 'is_delete', '=', 0 ],
|
||||
[ 'site_id', '=', $param[ 'site_id' ] ],
|
||||
[ 'is_fenxiao', '=', 1 ],
|
||||
[ 'goods_state', '=', 1 ]
|
||||
];
|
||||
|
||||
$model = new GoodsModel();
|
||||
$res = $model->getGoodsCategoryIds($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
61
addon/fenxiao/event/GoodsListPromotion.php
Executable file
61
addon/fenxiao/event/GoodsListPromotion.php
Executable file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
*/
|
||||
class GoodsListPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (empty($param[ 'promotion' ]) || $param[ 'promotion' ] != 'fenxiao') return [];
|
||||
|
||||
$alias = 'g';
|
||||
$join = [];
|
||||
|
||||
$condition = [
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
[ 'g.site_id', '=', $param[ 'site_id' ] ],
|
||||
[ 'g.is_fenxiao', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ]
|
||||
];
|
||||
|
||||
if (!empty($param[ 'goods_name' ])) {
|
||||
$condition[] = [ 'g.goods_name', 'like', '%' . $param[ 'goods_name' ] . '%' ];
|
||||
}
|
||||
if (!empty($param[ 'select_type' ]) && $param[ 'select_type' ] == 'selected' && isset($param[ 'goods_ids' ])) {
|
||||
$condition[] = [ 'g.goods_id', 'in', $param[ 'goods_ids' ] ];
|
||||
}
|
||||
if (!empty($param[ 'category_id' ])) {
|
||||
$condition[] = [ 'g.category_id', 'like', '%,' . $param[ 'category_id' ] . ',%' ];
|
||||
}
|
||||
if (!empty($param[ 'label_id' ])) {
|
||||
$condition[] = [ 'g.label_id', '=', $param[ 'label_id' ] ];
|
||||
}
|
||||
if (!empty($param[ 'goods_class' ])) {
|
||||
$condition[] = [ 'g.goods_class', '=', $param[ 'goods_class' ] ];
|
||||
}
|
||||
|
||||
$model = new GoodsModel();
|
||||
$field = 'g.goods_id,g.goods_name,g.goods_class_name,g.goods_image,g.price,g.goods_stock,g.create_time,g.is_virtual,g.sku_id';
|
||||
$list = $model->getGoodsPageList($condition, $param[ 'page' ], $param[ 'page_size' ], 'g.create_time desc', $field, $alias, $join);
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
57
addon/fenxiao/event/Install.php
Executable file
57
addon/fenxiao/event/Install.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoLevel as FenxiaoLevelModel;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site_id = request()->siteid();
|
||||
$model = new FenxiaoLevelModel();
|
||||
$default_level = $model->getLevelInfo([ [ 'site_id', '=', $site_id ], [ 'is_default', '=', 1 ] ], 'level_id');
|
||||
|
||||
if (empty($default_level[ 'data' ])) {
|
||||
$data = [
|
||||
'site_id' => $site_id,
|
||||
'level_name' => '默认等级',
|
||||
'level_num' => 0,
|
||||
'one_rate' => '',
|
||||
'two_rate' => '',
|
||||
'three_rate' => '',
|
||||
'upgrade_type' => '2',
|
||||
'fenxiao_order_num' => '',
|
||||
'fenxiao_order_meney' => '',
|
||||
'one_fenxiao_order_num' => '',
|
||||
'one_fenxiao_order_money' => '',
|
||||
'one_fenxiao_total_order' => '',
|
||||
'order_num' => '',
|
||||
'order_money' => '',
|
||||
'child_num' => '',
|
||||
'child_fenxiao_num' => '',
|
||||
'one_child_num' => '',
|
||||
'one_child_fenxiao_num' => '',
|
||||
'is_default' => 1
|
||||
];
|
||||
$res = $model->addLevel($data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
35
addon/fenxiao/event/MemberAccountFromType.php
Executable file
35
addon/fenxiao/event/MemberAccountFromType.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
/**
|
||||
* 会员账户变化来源类型
|
||||
*/
|
||||
class MemberAccountFromType
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$from_type = [
|
||||
'balance_money' => [
|
||||
'fenxiao' => [
|
||||
'type_name' => '分销佣金',
|
||||
'type_url' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
if ($data == '') {
|
||||
return $from_type;
|
||||
} else {
|
||||
return $from_type[$data] ?? [];
|
||||
}
|
||||
}
|
||||
}
|
||||
31
addon/fenxiao/event/MemberCancel.php
Executable file
31
addon/fenxiao/event/MemberCancel.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\Fenxiao;
|
||||
|
||||
/**
|
||||
* 会员注销
|
||||
*/
|
||||
class MemberCancel
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$fenxiao_model = new Fenxiao();
|
||||
$res = $fenxiao_model->CronMemberCancel($param[ 'member_id' ], $param[ 'site_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
32
addon/fenxiao/event/MemberRegister.php
Executable file
32
addon/fenxiao/event/MemberRegister.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\Fenxiao;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class MemberRegister
|
||||
{
|
||||
/**
|
||||
* 会员注册
|
||||
* @param $param
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (isset($param['member_id']) && !empty($param['member_id'])) {
|
||||
$fenxiao = new Fenxiao();
|
||||
$fenxiao->memberRegister($param['member_id'], $param['site_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
addon/fenxiao/event/OrderComplete.php
Executable file
35
addon/fenxiao/event/OrderComplete.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
use app\model\order\OrderCommon;
|
||||
|
||||
/**
|
||||
* 订单完成事件
|
||||
*/
|
||||
class OrderComplete
|
||||
{
|
||||
/**
|
||||
* 订单创建后绑定上下线关系
|
||||
* @param $param
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$order_id = $param[ 'order_id' ];
|
||||
$order_model = new OrderCommon();
|
||||
$order_info = $order_model->getOrderInfo([ [ 'order_id', '=', $order_id ] ])[ 'data' ];
|
||||
if (!empty($order_info)) {
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$fenxiao_model->autoBecomeFenxiao($order_info[ 'member_id' ], $order_info[ 'site_id' ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
addon/fenxiao/event/OrderCreateAfter.php
Executable file
38
addon/fenxiao/event/OrderCreateAfter.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
use app\model\order\OrderCommon;
|
||||
|
||||
/**
|
||||
* 订单创建事件
|
||||
*/
|
||||
class OrderCreateAfter
|
||||
{
|
||||
/**
|
||||
* 订单创建后绑定上下线关系
|
||||
* @param $param
|
||||
* @return array|void
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$order_info = $param['create_data'] ?? [];
|
||||
if (!empty($order_info)) {
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
return $fenxiao_model->bindRelation([
|
||||
'site_id' => $order_info[ 'site_id' ],
|
||||
'member_id' => $order_info[ 'member_id' ],
|
||||
'action' => 'order_create',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
addon/fenxiao/event/OrderGoodsRefund.php
Executable file
32
addon/fenxiao/event/OrderGoodsRefund.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoOrder;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class OrderGoodsRefund
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function handle($data)
|
||||
{
|
||||
$order_model = new FenxiaoOrder();
|
||||
$res = $order_model->refund($data);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
41
addon/fenxiao/event/OrderPayAfter.php
Executable file
41
addon/fenxiao/event/OrderPayAfter.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoOrder;
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class OrderPayAfter
|
||||
{
|
||||
|
||||
/**
|
||||
* 订单结算
|
||||
*/
|
||||
public function handle($order)
|
||||
{
|
||||
//先检测是否需要绑定上下线
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$fenxiao_model->bindRelation([
|
||||
'site_id' => $order['site_id'],
|
||||
'member_id' => $order['member_id'],
|
||||
'action' => 'order_pay',
|
||||
]);
|
||||
// 自动成为分销商
|
||||
$fenxiao_model->autoBecomeFenxiao($order['member_id'], $order['site_id']);
|
||||
$fenxiao_order = new FenxiaoOrder();
|
||||
return $fenxiao_order->calculate($order);
|
||||
}
|
||||
}
|
||||
34
addon/fenxiao/event/OrderSettlement.php
Executable file
34
addon/fenxiao/event/OrderSettlement.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoOrder;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class OrderSettlement
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function handle($data)
|
||||
{
|
||||
$fenxiao_order_model = new FenxiaoOrder();
|
||||
$fenxiao_order_model->settlement($data['order_id']);
|
||||
$res = $fenxiao_order_model->calculateOrder($data['order_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
40
addon/fenxiao/event/PresaleOrderCreate.php
Executable file
40
addon/fenxiao/event/PresaleOrderCreate.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
use addon\presale\model\PresaleOrder;
|
||||
|
||||
/**
|
||||
* 预售订单创建
|
||||
*/
|
||||
class PresaleOrderCreate
|
||||
{
|
||||
/**
|
||||
* 订单创建后绑定上下线关系
|
||||
* @param $param
|
||||
* @return array|void
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
$id = $param[ 'id' ];
|
||||
$order_model = new PresaleOrder();
|
||||
$order_info = $order_model->getPresaleOrderInfo([ [ 'id', '=', $id ] ])[ 'data' ];
|
||||
if (!empty($order_info)) {
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
return $fenxiao_model->bindRelation([
|
||||
'site_id' => $order_info[ 'site_id' ],
|
||||
'member_id' => $order_info[ 'member_id' ],
|
||||
'action' => 'order_create',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
addon/fenxiao/event/PromotionType.php
Executable file
26
addon/fenxiao/event/PromotionType.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class PromotionType
|
||||
{
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ "name" => "分销", "type" => "fenxiao" ];
|
||||
}
|
||||
}
|
||||
46
addon/fenxiao/event/ShowPromotion.php
Executable file
46
addon/fenxiao/event/ShowPromotion.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'fenxiao',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'member',
|
||||
//展示主题
|
||||
'title' => '分销',
|
||||
//展示介绍
|
||||
'description' => '让客户为您推广销售',
|
||||
//展示图标
|
||||
'icon' => 'addon/fenxiao/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'fenxiao://shop/fenxiao/index',
|
||||
]
|
||||
]
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
25
addon/fenxiao/event/UnInstall.php
Executable file
25
addon/fenxiao/event/UnInstall.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
27
addon/fenxiao/event/WchatShareConfig.php
Executable file
27
addon/fenxiao/event/WchatShareConfig.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\share\WchatShare as ShareModel;
|
||||
|
||||
|
||||
/**
|
||||
* 获取分享配置
|
||||
*/
|
||||
class WchatShareConfig
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
$share_model = new ShareModel();
|
||||
return $share_model->getShareConfig($param);
|
||||
}
|
||||
|
||||
}
|
||||
28
addon/fenxiao/event/WchatShareData.php
Executable file
28
addon/fenxiao/event/WchatShareData.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\share\WchatShare as ShareModel;
|
||||
|
||||
|
||||
/**
|
||||
* 获取分享数据
|
||||
*/
|
||||
class WchatShareData
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
$share_model = new ShareModel();
|
||||
return $share_model->getShareData($param);
|
||||
}
|
||||
|
||||
}
|
||||
28
addon/fenxiao/event/WeappShareConfig.php
Executable file
28
addon/fenxiao/event/WeappShareConfig.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\share\WeappShare as ShareModel;
|
||||
|
||||
|
||||
/**
|
||||
* 获取分享配置
|
||||
*/
|
||||
class WeappShareConfig
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
$share_model = new ShareModel();
|
||||
return $share_model->getShareConfig($param);
|
||||
}
|
||||
|
||||
}
|
||||
28
addon/fenxiao/event/WeappShareData.php
Executable file
28
addon/fenxiao/event/WeappShareData.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\share\WeappShare as ShareModel;
|
||||
|
||||
|
||||
/**
|
||||
* 获取分享数据
|
||||
*/
|
||||
class WeappShareData
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
$share_model = new ShareModel();
|
||||
return $share_model->getShareData($param);
|
||||
}
|
||||
|
||||
}
|
||||
29
addon/fenxiao/event/WithdrawTransferCheck.php
Executable file
29
addon/fenxiao/event/WithdrawTransferCheck.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoWithdraw;
|
||||
|
||||
|
||||
/**
|
||||
* 提现转账通知
|
||||
*/
|
||||
class WithdrawTransferCheck
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
if($param['from_type'] == 'fenxiao_withdraw'){
|
||||
$model = new FenxiaoWithdraw();
|
||||
return $model->transferCheck($param['relate_tag']);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
addon/fenxiao/event/WithdrawTransferNotify.php
Executable file
29
addon/fenxiao/event/WithdrawTransferNotify.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\event;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoWithdraw;
|
||||
|
||||
|
||||
/**
|
||||
* 提现转账通知
|
||||
*/
|
||||
class WithdrawTransferNotify
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
if($param['from_type'] == 'fenxiao_withdraw'){
|
||||
$model = new FenxiaoWithdraw();
|
||||
return $model->transferNotify($param);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
addon/fenxiao/icon.png
Executable file
BIN
addon/fenxiao/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
337
addon/fenxiao/model/Config.php
Executable file
337
addon/fenxiao/model/Config.php
Executable file
@@ -0,0 +1,337 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\system\Config as ConfigModel;
|
||||
use app\model\BaseModel;
|
||||
use app\model\system\Document;
|
||||
|
||||
|
||||
/**
|
||||
* 微信小程序配置
|
||||
*/
|
||||
class Config extends BaseModel
|
||||
{
|
||||
/******************************************************************** 分销基本配置 start ****************************************************************************/
|
||||
/**
|
||||
* 设置分销基本配置
|
||||
* @param $data
|
||||
* @param $is_use
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function setFenxiaoBasicsConfig($data, $is_use, $site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
|
||||
//分销基本设置
|
||||
$basics_data = [
|
||||
'level' => $data[ 'level' ],//分销层级
|
||||
'internal_buy' => $data[ 'internal_buy' ],//分销内购
|
||||
'is_examine' => $data[ 'is_examine' ],//是否需要审核
|
||||
'self_purchase_rebate' => $data[ 'self_purchase_rebate' ],//是否开启分销商自购返佣
|
||||
'is_apply' => $data[ 'is_apply' ],//是否开启分销申请
|
||||
'is_commission_money' => $data[ 'is_commission_money' ],//是否开启商品详情一级佣金
|
||||
];
|
||||
$config->setConfig($basics_data, '分销基本配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_BASICS_CONFIG' ] ]);
|
||||
//分销商设置
|
||||
$fenxiao_data = [
|
||||
'fenxiao_condition' => $data[ 'fenxiao_condition' ],//成为分销商条件(0无条件 1申请 2消费次数 3消费金额 4购买商品)
|
||||
'consume_count' => $data[ 'consume_count' ],//消费次数
|
||||
'consume_money' => $data[ 'consume_money' ],//消费金额
|
||||
'goods_ids' => $data[ 'goods_ids' ],//指定商品id
|
||||
'consume_condition' => $data[ 'consume_condition' ],//消费条件(1付款后 2订单完成)
|
||||
'perfect_info' => $data[ 'perfect_info' ],//完善资料
|
||||
];
|
||||
$config->setConfig($fenxiao_data, '分销商配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_CONFIG' ] ]);
|
||||
// 分销默认等级佣金比率
|
||||
( new FenxiaoLevel() )->editLevel([
|
||||
'one_rate' => $data[ 'one_rate' ],
|
||||
'two_rate' => $data[ 'two_rate' ],
|
||||
'three_rate' => $data[ 'three_rate' ]
|
||||
], [ [ 'site_id', '=', $site_id ], [ 'is_default', '=', 1 ] ]);
|
||||
//上下级关系
|
||||
$relation_data = [
|
||||
'child_condition' => $data[ 'child_condition' ],//成为下线条件
|
||||
];
|
||||
$res = $config->setConfig($relation_data, '分销上下级关系配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_RELATION_CONFIG' ] ]);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销基本设置
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoBasicsConfig($site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_BASICS_CONFIG' ] ]);
|
||||
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'level' => 2,//分销层级
|
||||
'internal_buy' => 0,//分销内购
|
||||
'is_examine' => 0,//是否需要审核
|
||||
'is_apply' => 0,//分销商申请方式
|
||||
'is_commission_money' => 1,//是否开启商品详情一级佣金
|
||||
];
|
||||
}
|
||||
$res[ 'data' ][ 'value' ][ 'is_commission_money' ] = $res[ 'data' ][ 'value' ][ 'is_commission_money' ] ?? 1;
|
||||
$res[ 'data' ][ 'value' ][ 'self_purchase_rebate' ] = $res[ 'data' ][ 'value' ][ 'self_purchase_rebate' ] ?? 1;
|
||||
$res[ 'data' ][ 'value' ][ 'is_apply' ] = $res[ 'data' ][ 'value' ][ 'is_apply' ] ?? 1;
|
||||
$res[ 'data' ][ 'value' ][ 'level' ] = $res[ 'data' ][ 'value' ][ 'level' ] == 3 ? 2 : $res[ 'data' ][ 'value' ][ 'level' ];
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商设置
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoConfig($site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_CONFIG' ] ]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'fenxiao_condition' => 0,//成为分销商条件(0无条件 2消费次数 3消费金额 4购买商品)
|
||||
'is_agreement' => 0,//显示申请协议
|
||||
'agreement_title' => '',//协议标题
|
||||
'agreement_content' => '',//协议内容
|
||||
'consume_count' => 0,//消费次数
|
||||
'consume_money' => 0,//消费次数
|
||||
'consume_condition' => 1,//消费条件(1付款后 2订单完成)
|
||||
'img' => '',//申请页面顶部图片
|
||||
'perfect_info' => '',//完善资料
|
||||
];
|
||||
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上下级关系
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoRelationConfig($site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_RELATION_CONFIG' ] ]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'child_condition' => 1,//成为下线条件 1:首次点击分享链接 2:首次下单 3:首次付款
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/******************************************************************** 分销基本配置 end ****************************************************************************/
|
||||
|
||||
/******************************************************************** 分销协议配置 start ****************************************************************************/
|
||||
|
||||
/**
|
||||
* 设置分销协议配置
|
||||
* @param $data
|
||||
* @param $is_use
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function setFenxiaoAgreementConfig($data, $is_use, $site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
|
||||
$agreement_config = [
|
||||
'is_agreement' => $data[ 'is_agreement' ],//是否显示申请协议
|
||||
'img' => $data[ 'img' ],//申请页面顶部图片
|
||||
];
|
||||
$res = $config->setConfig($agreement_config, '分销协议配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_AGREEMENT_CONFIG' ] ]);
|
||||
|
||||
$document = new Document();
|
||||
$document->setDocument($data[ 'agreement_title' ], $data[ 'agreement_content' ], [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'document_key', '=', "FENXIAO_AGREEMENT" ] ]);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销协议配置
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoAgreementConfig($site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_AGREEMENT_CONFIG' ] ]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'is_agreement' => 0,//显示申请协议
|
||||
'img' => 'public/static/img/fenxiao/apply_top_gg.png',//申请页面顶部图片
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/******************************************************************** 分销协议配置 end ****************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************** 分销结算配置 start ****************************************************************************/
|
||||
|
||||
/**
|
||||
* 设置分销结算配置
|
||||
* @param $data
|
||||
* @param $is_use
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function setFenxiaoSettlementConfig($data, $is_use, $site_id)
|
||||
{
|
||||
|
||||
$config = new ConfigModel();
|
||||
//分销商结算配置
|
||||
$settlement_data = [
|
||||
'account_type' => $data[ 'account_type' ],//佣金计算方式
|
||||
];
|
||||
|
||||
$config->setConfig($settlement_data, '分销结算配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_SETTLEMENT_CONFIG' ] ]);
|
||||
//分销商提现配置
|
||||
$withdraw_data = [
|
||||
'withdraw' => $data[ 'withdraw' ],//最低提现额度
|
||||
'withdraw_rate' => $data[ 'withdraw_rate' ],//佣金提现手续费
|
||||
// 'min_no_fee' => $data['min_no_fee'],//最低免手续费区间
|
||||
// 'max_no_fee' => $data['max_no_fee'],//最高免手续费区间
|
||||
'withdraw_status' => $data[ 'withdraw_status' ],//提现审核
|
||||
'settlement_day' => $data[ 'settlement_day' ],//天数
|
||||
'withdraw_type' => $data[ 'withdraw_type' ],//账户类型 alipay 支付宝 bank 银行卡
|
||||
|
||||
'transfer_type' => $data[ 'transfer_type' ],//提现方式
|
||||
'max' => $data[ 'max' ],//提现方式
|
||||
'is_auto_transfer' => $data[ 'is_auto_transfer' ], // 是否自动转账 1 手动转账 2 自动转账
|
||||
];
|
||||
|
||||
$res = $config->setConfig($withdraw_data, '分销提现配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_WITHDRAW_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商结算配置
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoSettlementConfig($site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_SETTLEMENT_CONFIG' ] ]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'account_type' => 0
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商提现配置
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoWithdrawConfig($site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_WITHDRAW_CONFIG' ] ]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'withdraw' => 0,//最低提现额度
|
||||
'withdraw_rate' => 0,//佣金提现手续费
|
||||
'min_no_fee' => 0,//最低免手续费区间
|
||||
'max_no_fee' => 0,//最高免手续费区间
|
||||
'withdraw_status' => 1,//提现审核
|
||||
'withdraw_type' => 0,//提现方式
|
||||
'is_auto_transfer' => 0,
|
||||
'transfer_type' => '',
|
||||
'max' => 0
|
||||
];
|
||||
}
|
||||
$value = $res[ 'data' ][ 'value' ];
|
||||
if (!isset($value[ 'transfer_type' ])) {
|
||||
$value[ 'transfer_type' ] = 'balance';
|
||||
}
|
||||
if (!isset($value[ 'max' ])) {
|
||||
$value[ 'max' ] = 0;
|
||||
}
|
||||
if (!isset($value[ 'is_auto_transfer' ])) {
|
||||
$value[ 'is_auto_transfer' ] = 0;
|
||||
}
|
||||
$res[ 'data' ][ 'value' ] = $value;
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账方式
|
||||
* @param int $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getTransferType($site_id = 0)
|
||||
{
|
||||
$fenxiao_withdraw_model = new FenxiaoWithdraw();
|
||||
$transfer_type_list = $fenxiao_withdraw_model->getTransferType($site_id);
|
||||
$config = $this->getFenxiaoWithdrawConfig($site_id)[ "data" ][ 'value' ] ?? [];
|
||||
$data = [];
|
||||
$support_type = explode(",", $config[ "transfer_type" ]);
|
||||
foreach ($transfer_type_list as $k => $v) {
|
||||
if (in_array($k, $support_type)) {
|
||||
$data[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/******************************************************************** 分销结算配置 end ****************************************************************************/
|
||||
|
||||
/******************************************************************** 分销文字配置 start ****************************************************************************/
|
||||
|
||||
/**
|
||||
* 设置分销文字配置
|
||||
* @param $data
|
||||
* @param $is_use
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function setFenxiaoWordsConfig($data, $is_use, $site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '分销文字配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_WORDS_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销文字配置
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoWordsConfig($site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_WORDS_CONFIG' ] ]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'concept' => '分销',// 分销概念
|
||||
'fenxiao_name' => '分销商',// 分销商名称
|
||||
'withdraw' => '提现',// 提现名称
|
||||
'account' => '佣金',// 佣金
|
||||
'my_team' => '团队',// 我的团队
|
||||
'child' => '下线',// 下线
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/******************************************************************** 分销文字配置 end ****************************************************************************/
|
||||
|
||||
}
|
||||
826
addon/fenxiao/model/Fenxiao.php
Executable file
826
addon/fenxiao/model/Fenxiao.php
Executable file
@@ -0,0 +1,826 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use addon\fenxiao\model\Config as ConfigModel;
|
||||
use app\model\BaseModel;
|
||||
use app\model\member\Member;
|
||||
use app\model\order\OrderCommon;
|
||||
use app\model\system\Stat;
|
||||
|
||||
/**
|
||||
* 分销
|
||||
*/
|
||||
class Fenxiao extends BaseModel
|
||||
{
|
||||
|
||||
public $fenxiao_status_zh = [
|
||||
1 => '正常',
|
||||
-1 => '冻结',
|
||||
];
|
||||
|
||||
/**
|
||||
* 添加分销商
|
||||
* @param $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function addFenxiao($data)
|
||||
{
|
||||
$fenxiao_info = model('fenxiao')->getInfo(
|
||||
[ [ 'member_id', '=', $data[ 'member_id' ] ], [ 'is_delete', '=', 0 ] ],
|
||||
'fenxiao_id'
|
||||
);
|
||||
if (!empty($fenxiao_info)) return $this->error('', '已经是分销商了');
|
||||
|
||||
$data[ 'fenxiao_no' ] = date('YmdHi') . rand(1000, 9999);
|
||||
$data[ 'create_time' ] = time();
|
||||
$data[ 'audit_time' ] = time();
|
||||
|
||||
model('fenxiao')->startTrans();
|
||||
try {
|
||||
|
||||
if (!empty($data[ 'parent' ])) {
|
||||
//添加上级分销商一级下线人数
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $data[ 'parent' ] ], [ 'is_delete', '=', 0 ] ], 'one_child_fenxiao_num');
|
||||
//获取上上级分销商id
|
||||
$grand_parent_id = model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $data[ 'parent' ] ], [ 'is_delete', '=', 0 ] ], 'parent');
|
||||
|
||||
if (!empty($grand_parent_id) && $grand_parent_id[ 'parent' ] != 0) {
|
||||
//添加上上级分销商二级下线人数
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $grand_parent_id[ 'parent' ] ] ], 'two_child_fenxiao_num');
|
||||
|
||||
$data[ 'grand_parent' ] = $grand_parent_id[ 'parent' ];
|
||||
}
|
||||
|
||||
// 分销商检测升级
|
||||
event('FenxiaoUpgrade', $data[ 'parent' ]);
|
||||
}
|
||||
|
||||
$res = model('fenxiao')->add($data);
|
||||
//修改会员信息
|
||||
model('member')->update([ 'fenxiao_id' => $res, 'is_fenxiao' => 1 ], [ [ 'member_id', '=', $data[ 'member_id' ] ] ]);
|
||||
|
||||
$stat_model = new Stat();
|
||||
$stat_model->switchStat([ 'type' => 'add_fenxiao_member', 'data' => [ 'site_id' => $data[ 'site_id' ] ] ]);
|
||||
|
||||
model('fenxiao')->commit();
|
||||
return $this->success($res);
|
||||
} catch (\Exception $e) {
|
||||
model('fenxiao')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 冻结
|
||||
* @param $fenxiao_id
|
||||
* @return array
|
||||
*/
|
||||
public function frozen($fenxiao_id)
|
||||
{
|
||||
$data = [
|
||||
'status' => -1,
|
||||
'lock_time' => time()
|
||||
];
|
||||
|
||||
$res = model('fenxiao')->update($data, [ [ 'fenxiao_id', '=', $fenxiao_id ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解冻
|
||||
* @param $fenxiao_id
|
||||
* @return array
|
||||
*/
|
||||
public function unfrozen($fenxiao_id)
|
||||
{
|
||||
$data = [
|
||||
'status' => 1,
|
||||
'lock_time' => time()
|
||||
];
|
||||
|
||||
$res = model('fenxiao')->update($data, [ [ 'fenxiao_id', '=', $fenxiao_id ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商详细信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoInfo($condition = [], $field = '*')
|
||||
{
|
||||
$condition[] = [ 'is_delete', '=', 0 ];
|
||||
$res = model('fenxiao')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商详细信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoDetailInfo($condition = [])
|
||||
{
|
||||
$condition[] = [ 'f.is_delete', '=', 0 ];
|
||||
|
||||
$field = 'f.*,pf.fenxiao_name as parent_name,nm.username,nm.nickname,nm.headimg,nm.order_num,nm.order_money,fl.level_num';
|
||||
$alias = 'f';
|
||||
$join = [
|
||||
[
|
||||
'fenxiao pf',
|
||||
'pf.fenxiao_id = f.parent',
|
||||
'left'
|
||||
],
|
||||
[
|
||||
'member nm',
|
||||
'nm.member_id = f.member_id',
|
||||
'left'
|
||||
],
|
||||
[
|
||||
'fenxiao_level fl',
|
||||
'f.level_id = fl.level_id',
|
||||
'left'
|
||||
]
|
||||
];
|
||||
$res = model('fenxiao')->getInfo($condition, $field, $alias, $join);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取分销列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoList($condition = [], $field = '*', $order = '', $limit = null)
|
||||
{
|
||||
$condition[] = [ 'is_delete', '=', 0 ];
|
||||
$list = model('fenxiao')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $site_id = 0)
|
||||
{
|
||||
$condition[] = [ 'f.is_delete', '=', 0 ];
|
||||
$field = 'f.*,pf.fenxiao_name as parent_name,m.username,m.nickname,m.mobile as member_mobile,m.headimg';
|
||||
$alias = 'f';
|
||||
$join = [
|
||||
[
|
||||
'fenxiao pf',
|
||||
'pf.fenxiao_id = f.parent',
|
||||
'left'
|
||||
],
|
||||
[
|
||||
'member m',
|
||||
'm.member_id = f.member_id',
|
||||
'left'
|
||||
]
|
||||
];
|
||||
$list = model('fenxiao')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
$id_array = [];
|
||||
foreach ($list[ 'list' ] as $k => $v) {
|
||||
$id_array[] = $v['fenxiao_id'];
|
||||
}
|
||||
|
||||
// 查询分销基础配置
|
||||
$config_model = new Config();
|
||||
$fenxiao_basic_config = $config_model->getFenxiaoBasicsConfig($site_id)[ 'data' ][ 'value' ];
|
||||
$level = $fenxiao_basic_config[ 'level' ];
|
||||
|
||||
switch ( $level ) {
|
||||
case 1:
|
||||
$member_array = [];
|
||||
$member_count_array = model('member')->getList([['fenxiao_id', 'in', $id_array]], 'count(*) as count, fenxiao_id', '', '', '', 'fenxiao_id');
|
||||
if (!empty($member_count_array)){
|
||||
$member_key = array_column($member_count_array, 'fenxiao_id');
|
||||
$member_array = array_combine($member_key, $member_count_array);
|
||||
}
|
||||
|
||||
foreach ($list[ 'list' ] as $k => $v) {
|
||||
$count = 0;
|
||||
if(isset($member_array[ $v['fenxiao_id'] ])) $count = $member_array[ $v['fenxiao_id'] ][ 'count' ];
|
||||
$list[ 'list' ][ $k ][ 'team_num' ] = $count;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
$team_array = [];
|
||||
$team_list_array = model('fenxiao')->getList([[ 'parent', 'in', $id_array]], 'fenxiao_id, parent');
|
||||
|
||||
if(!empty($team_list_array)){
|
||||
$team_id_array = [];
|
||||
foreach ($team_list_array as $team_k => $team_v) {
|
||||
$team_id_array[] = $team_v['fenxiao_id'];
|
||||
$team_array[$team_v['parent']][] = $team_v;
|
||||
}
|
||||
$id_array = array_merge($id_array, $team_id_array);
|
||||
}
|
||||
|
||||
$member_array = [];
|
||||
$member_count_array = model('member')->getList([['fenxiao_id', 'in', $id_array]], 'count(*) as count, fenxiao_id', '', '', '', 'fenxiao_id');
|
||||
if (!empty($member_count_array)){
|
||||
$member_key = array_column($member_count_array, 'fenxiao_id');
|
||||
$member_array = array_combine($member_key, $member_count_array);
|
||||
}
|
||||
|
||||
foreach ($list[ 'list' ] as $k => $v) {
|
||||
$count = 0;
|
||||
$num = 0;
|
||||
if(isset($member_array[ $v['fenxiao_id'] ])) $count = $member_array[ $v['fenxiao_id'] ][ 'count' ];
|
||||
|
||||
if(isset($team_array[$v['fenxiao_id']])){
|
||||
foreach ($team_array[$v['fenxiao_id']] as $key => $val){
|
||||
if(isset($member_array[ $val['fenxiao_id'] ])) $num += $member_array[ $val['fenxiao_id'] ][ 'count' ];
|
||||
}
|
||||
}
|
||||
$list[ 'list' ][ $k ][ 'team_num' ] = $count + $num;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销分页列表2
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoPageLists($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = 'a', $join = null)
|
||||
{
|
||||
$list = model('fenxiao')->pageList($condition, $field, $order, $page, $page_size, $alias, $join, '');
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商团队
|
||||
* @param $level
|
||||
* @param $fenxiao_id
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param int $is_pay
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoTeam($level, $fenxiao_id, $page = 1, $page_size = PAGE_LIST_ROWS, $is_pay = 0)
|
||||
{
|
||||
$condition = '';
|
||||
|
||||
// 下级分销商id集合
|
||||
$one_level_fenxiao = model('fenxiao')->getColumn([ [ 'parent', '=', $fenxiao_id ] ], 'fenxiao_id');
|
||||
|
||||
switch ( $level ) {
|
||||
// 一级分销
|
||||
case 1:
|
||||
// 直属会员 + 直属下级分销商
|
||||
$or = " OR (f.parent = {$fenxiao_id}) ";
|
||||
$condition = "( (m.fenxiao_id = {$fenxiao_id} AND m.is_fenxiao = 0) " . $or . ') AND m.is_delete = 0';
|
||||
break;
|
||||
// 二级分销
|
||||
case 2:
|
||||
// 直属下级分销商的下级分销商 + 直属下级分销商的会员
|
||||
if (!empty($one_level_fenxiao)) {
|
||||
$or = ' OR (f.parent in (' . implode(',',$one_level_fenxiao) . ') ) ';
|
||||
$condition = '( (m.is_fenxiao = 0 AND m.fenxiao_id in (' . implode(',', $one_level_fenxiao) . ') )' . $or . ') AND m.is_delete = 0';
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (empty($condition)) return $this->success([
|
||||
'page_count' => 1,
|
||||
'count' => 0,
|
||||
'list' => []
|
||||
]);
|
||||
|
||||
if ($is_pay) $condition .= ' AND m.order_num > 0';
|
||||
$condition .= '';
|
||||
|
||||
$field = 'm.member_id,m.nickname,m.headimg,m.is_fenxiao,m.reg_time,m.order_money,m.order_complete_money,m.order_num,m.order_complete_num,m.bind_fenxiao_time,f.fenxiao_id,f.fenxiao_no,f.fenxiao_name,f.audit_time,f.level_name,f.one_child_num,f.one_child_fenxiao_num';
|
||||
$alias = 'm';
|
||||
$join = [
|
||||
[ 'fenxiao f', 'm.member_id = f.member_id', 'left' ]
|
||||
];
|
||||
|
||||
$list = model('member')->pageList($condition, $field, 'm.bind_fenxiao_time desc', $page, $page_size, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询我的团队的数量
|
||||
* @param $fenxiao_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoTeamNum($fenxiao_id, $site_id)
|
||||
{
|
||||
// 查询分销基础配置
|
||||
$config_model = new Config();
|
||||
$fenxiao_basic_config = $config_model->getFenxiaoBasicsConfig($site_id)[ 'data' ][ 'value' ];
|
||||
$level = $fenxiao_basic_config[ 'level' ];
|
||||
|
||||
$return = [
|
||||
'num' => 0, // 总人数
|
||||
'member_num' => 0, // 会员人数
|
||||
'fenxiao_num' => 0 // 分销商人数
|
||||
];
|
||||
|
||||
//递归查询
|
||||
$calc_level = 1;
|
||||
$parent_fenxiao_ids = [$fenxiao_id];
|
||||
while($calc_level <= $level){
|
||||
if(!empty($parent_fenxiao_ids)){
|
||||
$member_num = model('member')->getCount([ [ 'fenxiao_id', 'in', $parent_fenxiao_ids ], [ 'is_fenxiao', '=', 0 ], [ 'is_delete', '=', 0 ] ]);
|
||||
$fenxiao_list = model('fenxiao')->getList([ [ 'parent', 'in', $parent_fenxiao_ids ], [ 'is_delete', '=', 0 ] ], 'fenxiao_id');
|
||||
$fenxiao_ids = array_column($fenxiao_list, 'fenxiao_id');
|
||||
$fenxiao_num = count($fenxiao_ids);
|
||||
|
||||
//会员数量
|
||||
$return['member_num'] += $member_num;
|
||||
$return['member_num_'.$calc_level] = $member_num;
|
||||
//分销商数量
|
||||
$return['fenxiao_num'] += $fenxiao_num;
|
||||
$return['fenxiao_num_'.$calc_level] = $fenxiao_num;
|
||||
//总数量
|
||||
$return['num_'.$calc_level] = $member_num + $fenxiao_num;
|
||||
$return['num'] += $member_num + $fenxiao_num;
|
||||
|
||||
$parent_fenxiao_ids = $fenxiao_ids;
|
||||
}else{
|
||||
$return['member_num_'.$calc_level] = 0;
|
||||
$return['fenxiao_num_'.$calc_level] = 0;
|
||||
$return['num_'.$calc_level] = 0;
|
||||
}
|
||||
|
||||
$calc_level ++;
|
||||
}
|
||||
$return['level'] = $level;
|
||||
|
||||
return $this->success($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员注册之后
|
||||
* @param $member_id
|
||||
* @param $site_id
|
||||
*/
|
||||
public function memberRegister($member_id, $site_id)
|
||||
{
|
||||
//如果有推荐人则要修改分享关系
|
||||
$member_model = new Member();
|
||||
$member_info = $member_model->getMemberInfo([ [ 'member_id', '=', $member_id ] ], 'source_member')[ 'data' ];
|
||||
if (!empty($member_info[ 'source_member' ])) {
|
||||
$member_model->alterShareRelation($member_id, $member_info[ 'source_member' ], $site_id);
|
||||
}
|
||||
$this->autoBecomeFenxiao($member_id, $site_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动成为分销商
|
||||
* @param $member_id
|
||||
* @param $site_id
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function autoBecomeFenxiao($member_id, $site_id)
|
||||
{
|
||||
$member_info = model('member')->getInfo([ [ 'member_id', '=', $member_id ], [ 'site_id', '=', $site_id ], [ 'is_delete', '=', 0 ] ], 'order_num,order_complete_num,order_money,order_complete_money,is_fenxiao');
|
||||
if (empty($member_info)) return $this->error('', '未查询到会员信息');
|
||||
|
||||
$fenxiao_info = $this->getFenxiaoDetailInfo([ [ 'f.member_id', '=', $member_id ] ])[ 'data' ];
|
||||
if (!empty($fenxiao_info) && $member_info[ 'is_fenxiao' ]) return $this->error('', '已经是分销商');
|
||||
|
||||
try {
|
||||
$config = new Config();
|
||||
|
||||
// 分销商基础设置
|
||||
$basics_config = $config->getFenxiaoBasicsConfig($site_id)[ 'data' ][ 'value' ];
|
||||
if (!$basics_config[ 'level' ]) return $this->error('', '未开启分销');
|
||||
if ($basics_config[ 'is_apply' ] != 0) return $this->error('', '成为分销商需进行申请');
|
||||
|
||||
// 成为分销商的资格
|
||||
$fenxiao_config = $config->getFenxiaoConfig($site_id)[ 'data' ][ 'value' ];
|
||||
|
||||
switch ( $fenxiao_config[ 'fenxiao_condition' ] ) {
|
||||
case 2:
|
||||
// 消费次数
|
||||
if ($fenxiao_config[ 'consume_condition' ] == 1 && $member_info[ 'order_num' ] < $fenxiao_config[ 'consume_count' ]) return $this->error('', '未满足成为分销商的条件');
|
||||
if ($fenxiao_config[ 'consume_condition' ] == 2 && $member_info[ 'order_complete_num' ] < $fenxiao_config[ 'consume_count' ]) return $this->error('', '未满足成为分销商的条件');
|
||||
break;
|
||||
case 3:
|
||||
// 消费金额
|
||||
if ($fenxiao_config[ 'consume_condition' ] == 1 && bccomp($member_info[ 'order_money' ], $fenxiao_config[ 'consume_money' ], 2) == -1) return $this->error('', '未满足成为分销商的条件');
|
||||
if ($fenxiao_config[ 'consume_condition' ] == 2 && bccomp($member_info[ 'order_complete_money' ], $fenxiao_config[ 'consume_money' ], 2) == -1) return $this->error('', '未满足成为分销商的条件');
|
||||
break;
|
||||
case 4:
|
||||
// 购买指定商品
|
||||
$condition = [
|
||||
[ 'og.goods_id', 'in', $fenxiao_config[ 'goods_ids' ] ],
|
||||
[ 'og.member_id', '=', $member_id ]
|
||||
];
|
||||
if ($fenxiao_config[ 'consume_condition' ] == 1) $condition[] = [ 'pay_status', '=', 1 ];
|
||||
if ($fenxiao_config[ 'consume_condition' ] == 2) $condition[] = [ 'order_status', '=', OrderCommon::ORDER_COMPLETE ];
|
||||
$count = model('order_goods')->getCount($condition, 'order_goods_id', 'og', [ [ 'order o', 'o.order_id = og.order_id', 'inner' ] ]);
|
||||
if (!$count) return $this->error('', '未满足成为分销商的条件');
|
||||
break;
|
||||
}
|
||||
return $this->directlyBecomeFenxiao($member_id);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', 'File:' . $e->getFile() . ',Line:' . $e->getLine() . ',Message:' . $e->getMessage() . ',Code:' . $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员直接成为分销商
|
||||
* @param $member_id
|
||||
* @return mixed
|
||||
*/
|
||||
private function directlyBecomeFenxiao($member_id)
|
||||
{
|
||||
//获取用户信息
|
||||
$member_field = 'member_id,site_id,source_member,fenxiao_id,nickname,headimg,mobile,reg_time,order_money,order_complete_money,order_num,order_complete_num';
|
||||
$member_info = model('member')->getInfo([ [ 'member_id', '=', $member_id ] ], $member_field);
|
||||
|
||||
if (!empty($member_info)) {
|
||||
$parent = 0;
|
||||
if (!empty($member_info[ 'fenxiao_id' ])) {
|
||||
$fenxiao_info = model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $member_info[ 'fenxiao_id' ] ], [ 'is_delete', '=', 0 ] ], 'fenxiao_id');
|
||||
if (!empty($fenxiao_info)) $parent = $fenxiao_info[ 'fenxiao_id' ];
|
||||
}
|
||||
|
||||
//获取分销等级信息
|
||||
$level_model = new FenxiaoLevel();
|
||||
$level_info = $level_model->getLevelInfo([ [ 'site_id', '=', $member_info[ 'site_id' ] ], [ 'is_default', '=', 1 ] ], 'level_id,level_name');
|
||||
|
||||
$data = [
|
||||
'site_id' => $member_info[ 'site_id' ],
|
||||
'fenxiao_name' => $member_info[ 'nickname' ],
|
||||
'mobile' => $member_info[ 'mobile' ],
|
||||
'member_id' => $member_info[ 'member_id' ],
|
||||
'parent' => $parent,
|
||||
'level_id' => $level_info[ 'data' ][ 'level_id' ],
|
||||
'level_name' => $level_info[ 'data' ][ 'level_name' ]
|
||||
];
|
||||
$res = $this->addFenxiao($data);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定上下线关系
|
||||
* TODO 订单创建对返回结果进行检测 不可返回失败
|
||||
* @param $param
|
||||
* @return array|void
|
||||
*/
|
||||
public function bindRelation($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ] ?? 0;
|
||||
$member_id = $param[ 'member_id' ] ?? 0;
|
||||
$action = $param[ 'action' ] ?? '';
|
||||
|
||||
$config = [
|
||||
'alter_share_relation' => 1,//对应 首次点击链接后绑定
|
||||
'order_create' => 2,//对应 首次下单后绑定
|
||||
'order_pay' => 3,//对应 首次付款后绑定
|
||||
];
|
||||
if (!isset($config[ $action ])) return;
|
||||
|
||||
//检测触发场景和设置是否匹配
|
||||
$config_model = new ConfigModel();
|
||||
$child_condition = $config_model->getFenxiaoRelationConfig($site_id)[ 'data' ][ 'value' ][ 'child_condition' ];
|
||||
if ($child_condition != $config[ $action ]) return;
|
||||
|
||||
//检测用户
|
||||
$member_info = model('member')->getInfo([
|
||||
[ 'member_id', '=', $member_id ],
|
||||
], 'share_member,fenxiao_id');
|
||||
if (empty($member_info)) return;
|
||||
//如果已经是分销商 不可以再修改关系
|
||||
if (!empty($member_info[ 'fenxiao_id' ])) return;
|
||||
|
||||
// 查询推荐人是否是分销商
|
||||
$fenxiao_info = model('fenxiao')->getInfo([
|
||||
[ 'member_id', '=', $member_info[ 'share_member' ] ],
|
||||
[ 'is_delete', '=', 0 ],
|
||||
], 'fenxiao_id');
|
||||
if (empty($fenxiao_info)) return;
|
||||
|
||||
model('member')->startTrans();
|
||||
try {
|
||||
$member_data = [
|
||||
'fenxiao_id' => $fenxiao_info[ 'fenxiao_id' ],
|
||||
'bind_fenxiao_time' => time()
|
||||
];
|
||||
model('member')->update($member_data, [ [ 'member_id', '=', $member_id ] ]);
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $fenxiao_info[ 'fenxiao_id' ] ] ], 'one_child_num');
|
||||
|
||||
// 分销商检测升级
|
||||
event('FenxiaoUpgrade', $fenxiao_info[ 'fenxiao_id' ]);
|
||||
|
||||
model('member')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('member')->rollback();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商检测升级
|
||||
* @param $fenxiao_id
|
||||
*/
|
||||
public function fenxiaoUpgrade($fenxiao_id)
|
||||
{
|
||||
$join = [
|
||||
[ 'member m', 'f.member_id = m.member_id', 'inner' ],
|
||||
[ 'fenxiao_level fl', 'f.level_id = fl.level_id', 'inner' ]
|
||||
];
|
||||
$fenxiao_info = model('fenxiao')->getInfo([ [ 'f.fenxiao_id', '=', $fenxiao_id ], [ 'f.status', '=', 1 ], [ 'f.is_delete', '=', 0 ] ], 'f.level_id,m.order_num,m.order_money,f.one_fenxiao_order_num,f.one_fenxiao_order_money,f.one_fenxiao_total_order,f.one_child_num,f.one_child_fenxiao_num,fl.one_rate,fl.level_num,f.site_id', 'f', $join);
|
||||
if (!empty($fenxiao_info)) {
|
||||
$level_list = model('fenxiao_level')->getList([ [ 'site_id', '=', $fenxiao_info[ 'site_id' ] ], [ 'level_num', '>', $fenxiao_info[ 'level_num' ] ] ], '*', 'level_num asc,one_rate asc');
|
||||
if (!empty($level_list)) {
|
||||
$upgrade_level = null;
|
||||
foreach ($level_list as $item) {
|
||||
if ($item[ 'upgrade_type' ] == 2) {
|
||||
if ($fenxiao_info[ 'order_num' ] >= $item[ 'order_num' ] && $fenxiao_info[ 'order_money' ] >= $item[ 'order_money' ] && $fenxiao_info[ 'one_fenxiao_order_num' ] >= $item[ 'one_fenxiao_order_num' ] && $fenxiao_info[ 'one_fenxiao_total_order' ] >= $item[ 'one_fenxiao_total_order' ] && $fenxiao_info[ 'one_fenxiao_order_money' ] >= $item[ 'one_fenxiao_order_money' ] && $fenxiao_info[ 'one_child_num' ] >= $item[ 'one_child_num' ] && $fenxiao_info[ 'one_child_fenxiao_num' ] >= $item[ 'one_child_fenxiao_num' ]) {
|
||||
$upgrade_level = $item;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (( $fenxiao_info[ 'order_num' ] >= $item[ 'order_num' ] && $item[ 'order_num' ] > 0 ) || ( $fenxiao_info[ 'order_money' ] >= $item[ 'order_money' ] && $item[ 'order_money' ] > 0 ) || ( $fenxiao_info[ 'one_fenxiao_order_num' ] >= $item[ 'one_fenxiao_order_num' ] && $item[ 'one_fenxiao_order_num' ] > 0 ) || ( $fenxiao_info[ 'one_fenxiao_order_money' ] >= $item[ 'one_fenxiao_order_money' ] && $item[ 'one_fenxiao_order_money' ] > 0 ) || ( $fenxiao_info[ 'one_fenxiao_total_order' ] >= $item[ 'one_fenxiao_total_order' ] && $item[ 'one_fenxiao_total_order' ] > 0 ) || ( $fenxiao_info[ 'one_child_num' ] >= $item[ 'one_child_num' ] && $item[ 'one_child_num' ] > 0 ) || ( $fenxiao_info[ 'one_child_fenxiao_num' ] >= $item[ 'one_child_fenxiao_num' ] && $item[ 'one_child_fenxiao_num' ] > 0 )) {
|
||||
$upgrade_level = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($upgrade_level) {
|
||||
model('fenxiao')->update([ 'level_id' => $upgrade_level[ 'level_id' ], 'level_name' => $upgrade_level[ 'level_name' ] ], [ [ 'fenxiao_id', '=', $fenxiao_id ] ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个可升级的分销商等级 及当前分销商已达成的条件
|
||||
* @param $member_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function geFenxiaoNextLevel($member_id, $site_id)
|
||||
{
|
||||
$array = [];
|
||||
$join = [
|
||||
[ 'member m', 'f.member_id = m.member_id', 'inner' ],
|
||||
[ 'fenxiao_level fl', 'f.level_id = fl.level_id', 'inner' ]
|
||||
];
|
||||
$fenxiao_info = model('fenxiao')->getInfo(
|
||||
[ [ 'f.member_id', '=', $member_id ], [ 'f.site_id', '=', $site_id ], [ 'f.status', '=', 1 ], [ 'f.is_delete', '=', 0 ] ],
|
||||
'f.level_id,m.order_num,m.order_money,f.one_fenxiao_order_num,f.one_fenxiao_order_money,f.one_child_num,f.one_child_fenxiao_num,fl.one_rate,fl.level_num', 'f', $join
|
||||
);
|
||||
$array[ 'fenxiao' ] = $fenxiao_info;
|
||||
$last_level = [];
|
||||
if (!empty($fenxiao_info)) {
|
||||
$last_level = model('fenxiao_level')->getFirstData([ [ 'site_id', '=', $site_id ], [ 'level_num', '>=', $fenxiao_info[ 'level_num' ] ], [ 'level_id', '<>', $fenxiao_info[ 'level_id' ] ] ], '*', 'level_num asc,one_rate asc');
|
||||
}
|
||||
$array[ 'last_level' ] = $last_level;
|
||||
return $this->success($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更上下级关系
|
||||
* @param $member_id
|
||||
* @param $parent
|
||||
* @return array
|
||||
*/
|
||||
public function changeParentFenxiao($member_id, $parent)
|
||||
{
|
||||
if ($member_id == '' || $member_id == 0) {
|
||||
return $this->error('', '参数member_id不能为空');
|
||||
}
|
||||
if ($parent == '' || $parent == 0) {
|
||||
return $this->error('', '上级分销商不能为空');
|
||||
}
|
||||
|
||||
//获取上级分销商id
|
||||
$parent_info = model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $parent ], [ 'is_delete', '=', 0 ] ]);
|
||||
if (empty($parent_info)) {
|
||||
return $this->error('', '上级分销商不存在');
|
||||
}
|
||||
|
||||
//用户信息
|
||||
$member_info = model('member')->getInfo([ [ 'member_id', '=', $member_id ] ], 'fenxiao_id,is_fenxiao');
|
||||
if (empty($member_info)) {
|
||||
return $this->error('', '用户不存在');
|
||||
}
|
||||
|
||||
model('fenxiao')->startTrans();
|
||||
try {
|
||||
|
||||
if ($member_info[ 'is_fenxiao' ] == 1) {//是分销商
|
||||
|
||||
$fenxiao_info = model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $member_info[ 'fenxiao_id' ] ], [ 'is_delete', '=', 0 ] ], 'parent');
|
||||
//修改原有上级分销商团队人数
|
||||
if ($fenxiao_info[ 'parent' ] > 0) {
|
||||
//获取原有上级分销商信息
|
||||
model('fenxiao')->setDec([ [ 'fenxiao_id', '=', $fenxiao_info[ 'parent' ] ] ], 'one_child_fenxiao_num');
|
||||
}
|
||||
|
||||
//修改变更后的上级分销商团队人数
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $parent ] ], 'one_child_fenxiao_num');
|
||||
//修改上级分销商
|
||||
model('fenxiao')->update([ 'parent' => $parent, 'grand_parent' => $parent_info[ 'parent' ] ], [ [ 'fenxiao_id', '=', $member_info[ 'fenxiao_id' ] ] ]);
|
||||
} else {
|
||||
//不是分销商
|
||||
|
||||
//修改上级分销商
|
||||
model('member')->update([ 'fenxiao_id' => $parent ], [ [ 'member_id', '=', $member_id ] ]);
|
||||
//修改变更后的上级分销商团队人数
|
||||
model('fenxiao')->update([ 'one_child_num' => $parent_info[ 'one_child_num' ] + 1 ], [ [ 'fenxiao_id', '=', $parent ] ]);
|
||||
|
||||
}
|
||||
|
||||
model('fenxiao')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('fenxiao')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消上级分销商
|
||||
* @param $member_id
|
||||
* @return array
|
||||
*/
|
||||
public function cancelParentFenxiao($member_id)
|
||||
{
|
||||
if ($member_id == '' || $member_id == 0) {
|
||||
return $this->error('', '参数member_id不能为空');
|
||||
}
|
||||
|
||||
//用户信息
|
||||
$member_info = model('member')->getInfo([ [ 'member_id', '=', $member_id ] ], 'fenxiao_id,is_fenxiao');
|
||||
if (empty($member_info)) {
|
||||
return $this->error('', '用户不存在');
|
||||
}
|
||||
|
||||
model('fenxiao')->startTrans();
|
||||
try {
|
||||
|
||||
if ($member_info[ 'is_fenxiao' ] == 1) {//是分销商
|
||||
|
||||
$fenxiao_info = model('fenxiao')->getInfo(
|
||||
[ [ 'fenxiao_id', '=', $member_info[ 'fenxiao_id' ] ], [ 'is_delete', '=', 0 ] ],
|
||||
'parent'
|
||||
);
|
||||
//修改原有上级分销商团队人数
|
||||
if ($fenxiao_info[ 'parent' ] > 0) {
|
||||
//获取原有上级分销商信息
|
||||
model('fenxiao')->setDec([ [ 'fenxiao_id', '=', $fenxiao_info[ 'parent' ] ] ], 'one_child_fenxiao_num');
|
||||
}
|
||||
//修改上级分销商
|
||||
model('fenxiao')->update([ 'parent' => '0' ], [ [ 'fenxiao_id', '=', $member_info[ 'fenxiao_id' ] ] ]);
|
||||
}
|
||||
model('fenxiao')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
model('fenxiao')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上级分销商名称
|
||||
* @param $fenxiao_id
|
||||
* @param int $type 1-上级
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function getParentFenxiaoName($fenxiao_id, $type = 1)
|
||||
{
|
||||
if ($fenxiao_id == 0) {
|
||||
return '';
|
||||
}
|
||||
if ($type == 1) {
|
||||
$fenxiao_name = model('fenxiao')->getValue([ [ 'fenxiao_id', '=', $fenxiao_id ] ], 'fenxiao_name');
|
||||
return $fenxiao_name;
|
||||
} else {
|
||||
|
||||
$parent = model('fenxiao')->getValue([ [ 'fenxiao_id', '=', $fenxiao_id ] ], 'parent');
|
||||
if ($parent == 0) {
|
||||
return '';
|
||||
} else {
|
||||
$fenxiao_name = model('fenxiao')->getValue([ [ 'fenxiao_id', '=', $parent ] ], 'fenxiao_name');
|
||||
return $fenxiao_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询上级分销商名称列表(用于会员列表查询)
|
||||
* @param $fenxiao_id
|
||||
*/
|
||||
public function getParentFenxiaoNameList($fenxiao_ids)
|
||||
{
|
||||
$fenxiao_name_list = model('fenxiao')->getList([ [ 'fenxiao_id', 'in', $fenxiao_ids ] ], 'fenxiao_id, fenxiao_name');
|
||||
return $fenxiao_name_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员注销删除分销商
|
||||
* @param $member_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function CronMemberCancel($member_id, $site_id)
|
||||
{
|
||||
$info = model('fenxiao')->getInfo([ [ 'member_id', '=', $member_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
if (empty($info)) {
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
//冻结账户并删除
|
||||
$data = [
|
||||
'status' => -1,
|
||||
'lock_time' => time(),
|
||||
'is_delete' => 1
|
||||
];
|
||||
|
||||
$res = model('fenxiao')->update($data, [ [ 'fenxiao_id', '=', $info[ 'fenxiao_id' ] ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更分销商等级
|
||||
* @param $data
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function changeFenxiaoLevel($data, $condition)
|
||||
{
|
||||
$result = model('fenxiao')->update($data, $condition);
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销等级分销商数量
|
||||
* @param $condition
|
||||
* @return int|mixed
|
||||
*/
|
||||
public function getFenxiaoMemberCount($condition)
|
||||
{
|
||||
$condition[] = [ 'is_delete', '=', 0 ];
|
||||
$count = model('fenxiao')->getCount($condition);
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商排名
|
||||
* @param $site_id
|
||||
* @param $fenxiao_id
|
||||
* @param $order
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoRanking($site_id, $fenxiao_id, $order)
|
||||
{
|
||||
$prefix = config('database.connections.mysql.prefix');
|
||||
$version = model('fenxiao')->query('SELECT VERSION() as version')[ 0 ][ 'version' ];
|
||||
|
||||
if (substr($version, 0, 1) == 8) {
|
||||
$query = "SELECT * FROM (select *,row_number() OVER(order by {$order} DESC) as rownum from {$prefix}fenxiao nf) AS f WHERE f.fenxiao_id = {$fenxiao_id}";
|
||||
} else {
|
||||
$query = "SELECT b.rownum FROM (SELECT t.*, @rownum := @rownum + 1 AS rownum FROM (SELECT @rownum := 0) r,(SELECT * FROM {$prefix}fenxiao WHERE site_id = {$site_id} ORDER BY {$order} DESC,fenxiao_id ASC) AS t) AS b WHERE b.fenxiao_id = {$fenxiao_id};";
|
||||
}
|
||||
$data = model('fenxiao')->query($query);
|
||||
$data = empty($data) ? 0 : $data[ 0 ][ 'rownum' ];
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
// todo 删除分销商
|
||||
|
||||
}
|
||||
108
addon/fenxiao/model/FenxiaoAccount.php
Executable file
108
addon/fenxiao/model/FenxiaoAccount.php
Executable file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
|
||||
/**
|
||||
* 分销
|
||||
*/
|
||||
class FenxiaoAccount extends BaseModel
|
||||
{
|
||||
public $type = [
|
||||
'withdraw' => '提现',
|
||||
'order' => '订单结算',
|
||||
];
|
||||
|
||||
/**
|
||||
* 添加账户流水
|
||||
* @param $fenxiao_id
|
||||
* @param $fenxiao_name
|
||||
* @param $type
|
||||
* @param $money
|
||||
* @param $relate_id
|
||||
* @return array
|
||||
*/
|
||||
public function addAccount($fenxiao_id, $fenxiao_name, $type, $money, $relate_id)
|
||||
{
|
||||
$account_no = date('YmdHi') . rand(1000, 9999);
|
||||
$data = array (
|
||||
'fenxiao_id' => $fenxiao_id,
|
||||
'fenxiao_name' => $fenxiao_name,
|
||||
'account_no' => $account_no,
|
||||
'money' => $money,
|
||||
'type' => $type,
|
||||
'type_name' => $this->type[ $type ],
|
||||
'relate_id' => $relate_id,
|
||||
'create_time' => time(),
|
||||
);
|
||||
|
||||
$res = model('fenxiao_account')->add($data);
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $fenxiao_id ] ], 'account', $money);
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商账户流水信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoAccountInfo($condition = [], $field = '*')
|
||||
{
|
||||
$list = model('fenxiao_account')->getInfo($condition, $field);
|
||||
return $this->success($list);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商账户流水分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoAccountPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'create_time desc', $field = '*')
|
||||
{
|
||||
$list = model('fenxiao_account')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分销商账户流水(不扣账户)
|
||||
* @param $fenxiao_id
|
||||
* @param $fenxiao_name
|
||||
* @param string $type
|
||||
* @param $money
|
||||
* @param $relate_id
|
||||
* @return array
|
||||
*/
|
||||
public function addAccountLog($fenxiao_id, $fenxiao_name, $type, $money, $relate_id)
|
||||
{
|
||||
$account_no = date('YmdHi') . rand(1000, 9999);
|
||||
$data = array (
|
||||
'fenxiao_id' => $fenxiao_id,
|
||||
'fenxiao_name' => $fenxiao_name,
|
||||
'account_no' => $account_no,
|
||||
'money' => $money,
|
||||
'type' => $type,
|
||||
'type_name' => $this->type[ $type ],
|
||||
'relate_id' => $relate_id,
|
||||
'create_time' => time(),
|
||||
);
|
||||
$res = model('fenxiao_account')->add($data);
|
||||
return $this->success($res);
|
||||
}
|
||||
}
|
||||
310
addon/fenxiao/model/FenxiaoApply.php
Executable file
310
addon/fenxiao/model/FenxiaoApply.php
Executable file
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\member\Member;
|
||||
|
||||
|
||||
/**
|
||||
* 分销
|
||||
*/
|
||||
class FenxiaoApply extends BaseModel
|
||||
{
|
||||
|
||||
public $fenxiao_status_zh = [
|
||||
1 => '待审核',
|
||||
2 => '已审核',
|
||||
-1 => '拒绝',
|
||||
];
|
||||
|
||||
/**
|
||||
* 判断分销商名称是否存在
|
||||
* @param $fenxiao_name
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function existFenxiaoName($fenxiao_name, $site_id)
|
||||
{
|
||||
$res = model('fenxiao_apply')->getCount([ [ 'fenxiao_name', '=', $fenxiao_name ], [ 'site_id', '=', $site_id ] ]);
|
||||
if ($res > 0) {
|
||||
return $this->error('', '该分销商名称已存在');
|
||||
}
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请成为分销商
|
||||
* @param $member_id
|
||||
* @param $site_id
|
||||
* @param string $fenxiao_name
|
||||
* @param string $mobile
|
||||
* @return array|int|mixed|string
|
||||
*/
|
||||
public function applyFenxiao($member_id, $site_id, $fenxiao_name = '', $mobile = '')
|
||||
{
|
||||
//判断该用户是否已经申请
|
||||
$apply_info = model('fenxiao_apply')->getInfo([ [ 'member_id', '=', $member_id ] ], 'apply_id,status');
|
||||
if (!empty($apply_info) && $apply_info[ 'status' ] != -1) {
|
||||
return $this->error('', '已经申请过,请不要重复申请');
|
||||
}
|
||||
|
||||
// 分销商基础设置
|
||||
$config = new Config();
|
||||
$basics_config = $config->getFenxiaoBasicsConfig($site_id)[ 'data' ][ 'value' ];
|
||||
|
||||
if (!$basics_config[ 'level' ]) return $this->error('', '未开启分销');
|
||||
|
||||
//获取分销配置信息
|
||||
$fenxiao_config = $config->getFenxiaoConfig($site_id)[ 'data' ][ 'value' ];
|
||||
|
||||
//获取用户信息
|
||||
$member_model = new Member();
|
||||
$member_field = 'source_member,fenxiao_id,nickname,headimg,reg_time,order_money,order_complete_money,order_num,order_complete_num';
|
||||
$member_info = $member_model->getMemberInfo([ [ 'member_id', '=', $member_id ] ], $member_field);
|
||||
|
||||
// 判断用户是否可以成为申请分销商
|
||||
if ($fenxiao_config[ 'fenxiao_condition' ] == 2) {
|
||||
if ($fenxiao_config[ 'consume_condition' ] == 1 && $fenxiao_config[ 'consume_count' ] > $member_info[ 'data' ][ 'order_num' ]) {
|
||||
return $this->error('', '您的消费次数未满足申请条件');
|
||||
} elseif ($fenxiao_config[ 'consume_condition' ] == 2 && $fenxiao_config[ 'consume_count' ] > $member_info[ 'data' ][ 'order_complete_num' ]) {
|
||||
return $this->error('', '您的消费次数未满足申请条件');
|
||||
}
|
||||
} elseif ($fenxiao_config[ 'fenxiao_condition' ] == 3) {
|
||||
if ($fenxiao_config[ 'consume_condition' ] == 1 && $fenxiao_config[ 'consume_money' ] > $member_info[ 'data' ][ 'order_money' ]) {
|
||||
return $this->error('', '您的消费金额未满足申请条件');
|
||||
} elseif ($fenxiao_config[ 'consume_condition' ] == 2 && $fenxiao_config[ 'consume_money' ] > $member_info[ 'data' ][ 'order_complete_money' ]) {
|
||||
return $this->error('', '您的消费金额未满足申请条件');
|
||||
}
|
||||
} elseif ($fenxiao_config[ 'fenxiao_condition' ] == 4) { //购买指定商品
|
||||
//获取用户购买商品是否在成为分销商指定商品区域
|
||||
$alias = 'og';
|
||||
$condition[] = [ 'og.member_id', '=', $member_id ];
|
||||
$condition[] = [ 'og.site_id', '=', $site_id ];
|
||||
$condition[] = [ 'og.goods_id', 'in', $fenxiao_config[ 'goods_ids' ] ];
|
||||
$field = 'o.order_status,og.goods_id';
|
||||
$join = [
|
||||
[
|
||||
'order o',
|
||||
'o.order_id = og.order_id',
|
||||
'inner'
|
||||
]
|
||||
];
|
||||
if ($fenxiao_config[ 'consume_condition' ] == 1) {
|
||||
$condition[] = [ 'o.pay_status', '=', 1 ];
|
||||
$order_data = model('order_goods')->getList($condition, $field, '', $alias, $join);
|
||||
if (empty($order_data)) {
|
||||
return $this->error('', '您还未满足申请条件');
|
||||
}
|
||||
} elseif ($fenxiao_config[ 'consume_condition' ] == 2) {
|
||||
$condition[] = [ 'o.order_status', '=', '10' ];
|
||||
$order_data = model('order_goods')->getList($condition, $field, '', $alias, $join);
|
||||
if (empty($order_data)) {
|
||||
return $this->error('', '您还未满足申请条件');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($fenxiao_name)) $fenxiao_name = $member_info[ 'data' ][ 'nickname' ];
|
||||
|
||||
//获取分销等级信息
|
||||
$level_model = new FenxiaoLevel();
|
||||
$level_info = $level_model->getLevelInfo([ [ 'site_id', '=', $site_id ], [ 'is_default', '=', 1 ] ], 'level_id,level_name');
|
||||
|
||||
// 成为分销商是否需要审核
|
||||
if ($basics_config[ 'is_examine' ]) {
|
||||
$apply_data = [
|
||||
'site_id' => $site_id,
|
||||
'fenxiao_name' => $fenxiao_name,
|
||||
'parent' => $member_info[ 'data' ][ 'fenxiao_id' ],
|
||||
'member_id' => $member_id,
|
||||
'mobile' => $mobile,
|
||||
'nickname' => $member_info[ 'data' ][ 'nickname' ],
|
||||
'headimg' => $member_info[ 'data' ][ 'headimg' ],
|
||||
'level_id' => $level_info[ 'data' ][ 'level_id' ],
|
||||
'level_name' => $level_info[ 'data' ][ 'level_name' ],
|
||||
'order_complete_money' => $member_info[ 'data' ][ 'order_complete_money' ],
|
||||
'order_complete_num' => $member_info[ 'data' ][ 'order_complete_num' ],
|
||||
'reg_time' => $member_info[ 'data' ][ 'reg_time' ],
|
||||
'create_time' => time(),
|
||||
'status' => 1
|
||||
];
|
||||
if (!empty($apply_info)) {
|
||||
$res = model('fenxiao_apply')->update($apply_data, [ [ 'member_id', '=', $member_id ] ]);
|
||||
} else {
|
||||
$res = model('fenxiao_apply')->add($apply_data);
|
||||
}
|
||||
return $this->success($res);
|
||||
} else {
|
||||
$fenxiao_data = [
|
||||
'site_id' => $site_id,
|
||||
'fenxiao_name' => $fenxiao_name,
|
||||
'mobile' => $mobile,
|
||||
'member_id' => $member_id,
|
||||
'parent' => $member_info[ 'data' ][ 'fenxiao_id' ],
|
||||
'level_id' => $level_info[ 'data' ][ 'level_id' ],
|
||||
'level_name' => $level_info[ 'data' ][ 'level_name' ]
|
||||
];
|
||||
$fenxiao_model = new Fenxiao();
|
||||
$res = $fenxiao_model->addFenxiao($fenxiao_data);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员添加分销商
|
||||
*/
|
||||
public function addFenxiao($fenxiao_data)
|
||||
{
|
||||
if (empty($fenxiao_data[ 'fenxiao_name' ])) {
|
||||
return $this->error('', '分销商名称不能为空');
|
||||
}
|
||||
if (empty($fenxiao_data[ 'level_id' ])) {
|
||||
return $this->error('', '请选择分销商等级');
|
||||
}
|
||||
if (empty($fenxiao_data[ 'member_id' ])) {
|
||||
return $this->error('', '请选择关联会员');
|
||||
}
|
||||
|
||||
//判断该用户是否已经申请
|
||||
$apply_info = model('fenxiao_apply')->getInfo([ [ 'member_id', '=', $fenxiao_data[ 'member_id' ] ] ], 'apply_id,status');
|
||||
if (!empty($apply_info) && $apply_info[ 'status' ] != -1) {
|
||||
return $this->error('', '已经申请过,请不要重复申请');
|
||||
}
|
||||
|
||||
// 分销商基础设置
|
||||
$config = new Config();
|
||||
//获取分销配置信息
|
||||
$fenxiao_config = $config->getFenxiaoConfig($fenxiao_data[ 'site_id' ])[ 'data' ][ 'value' ];
|
||||
|
||||
//获取用户信息
|
||||
$member_model = new Member();
|
||||
$member_field = 'source_member,fenxiao_id,nickname,headimg,reg_time,order_money,order_complete_money,order_num,order_complete_num';
|
||||
$member_info = $member_model->getMemberInfo([ [ 'member_id', '=', $fenxiao_data[ 'member_id' ] ] ], $member_field);
|
||||
if (empty($member_info)) return $this->error('', '未获取到会员信息');
|
||||
|
||||
//获取分销等级信息
|
||||
$level_model = new FenxiaoLevel();
|
||||
$level_info = $level_model->getLevelInfo([ [ 'site_id', '=', $fenxiao_data[ 'site_id' ] ], [ 'level_id', '=', $fenxiao_data[ 'level_id' ] ] ], 'level_name');
|
||||
$fenxiao_data[ 'level_name' ] = $level_info[ 'data' ][ 'level_name' ];
|
||||
|
||||
$fenxiao_model = new Fenxiao();
|
||||
return $fenxiao_model->addFenxiao($fenxiao_data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核通过
|
||||
* @param $apply_id
|
||||
* @param $site_id
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function pass($apply_id, $site_id)
|
||||
{
|
||||
$info = model('fenxiao_apply')->getInfo([ [ 'apply_id', '=', $apply_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
if ($info[ 'status' ] == 2) {
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
model('fenxiao_apply')->startTrans();
|
||||
try {
|
||||
$data = [
|
||||
'status' => 2,
|
||||
'update_time' => time(),
|
||||
];
|
||||
$res = model('fenxiao_apply')->update($data, [ [ 'apply_id', '=', $apply_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
|
||||
$fenxiao_data = [
|
||||
'site_id' => $info[ 'site_id' ],
|
||||
'fenxiao_name' => $info[ 'fenxiao_name' ],
|
||||
'mobile' => $info[ 'mobile' ],
|
||||
'member_id' => $info[ 'member_id' ],
|
||||
'parent' => $info[ 'parent' ],
|
||||
'level_id' => $info[ 'level_id' ],
|
||||
'level_name' => $info[ 'level_name' ]
|
||||
];
|
||||
|
||||
$fenxiao_model = new Fenxiao();
|
||||
$result = $fenxiao_model->addFenxiao($fenxiao_data);
|
||||
if ($result[ 'code' ] != 0) {
|
||||
model('fenxiao_apply')->rollback();
|
||||
return $result;
|
||||
}
|
||||
|
||||
model('fenxiao_apply')->commit();
|
||||
|
||||
return $this->success($res);
|
||||
} catch (\Exception $e) {
|
||||
model('fenxiao_apply')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核不通过
|
||||
* @param $apply_id
|
||||
* @return array
|
||||
*/
|
||||
public function refuse($apply_id)
|
||||
{
|
||||
$data = [
|
||||
'status' => -1,
|
||||
'update_time' => time()
|
||||
];
|
||||
|
||||
$res = model('fenxiao_apply')->update($data, [ [ 'apply_id', '=', $apply_id ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商申请信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoApplyInfo($condition = [], $field = '*')
|
||||
{
|
||||
$res = model('fenxiao_apply')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商申请分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @param string $alias
|
||||
* @param array $join
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoApplyPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = 'a', $join = [])
|
||||
{
|
||||
$list = model('fenxiao_apply')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商申请数量
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoApplyCount($condition = [], $field = 'id')
|
||||
{
|
||||
$count = model('fenxiao_apply')->getCount($condition, $field);
|
||||
return $this->success($count);
|
||||
}
|
||||
|
||||
}
|
||||
82
addon/fenxiao/model/FenxiaoData.php
Executable file
82
addon/fenxiao/model/FenxiaoData.php
Executable file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
|
||||
/**
|
||||
* 分销数据
|
||||
*/
|
||||
class FenxiaoData extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 分销商账户统计
|
||||
* @param $site_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFenxiaoAccountData($site_id)
|
||||
{
|
||||
$field = 'sum(account) as account,sum(account_withdraw) as account_withdraw,sum(account_withdraw_apply) as account_withdraw_apply';
|
||||
$res = model('fenxiao')->getInfo([ [ 'status', 'in', '1,-1' ], [ 'site_id', '=', $site_id ], [ 'is_delete', '=', 0 ] ], $field);
|
||||
|
||||
if (empty($res) || $res[ 'account' ] == null) {
|
||||
$res[ 'account' ] = '0.00';
|
||||
}
|
||||
|
||||
if (empty($res) || $res[ 'account_withdraw' ] == null) {
|
||||
$res[ 'account_withdraw' ] = '0.00';
|
||||
}
|
||||
if (empty($res) || $res[ 'account_withdraw_apply' ] == null) {
|
||||
$res[ 'account_withdraw_apply' ] = '0.00';
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商申请人数
|
||||
* @param $site_id
|
||||
* @return int|mixed
|
||||
*/
|
||||
public function getFenxiaoApplyCount($site_id)
|
||||
{
|
||||
$count = model('fenxiao_apply')->getCount([ [ 'status', '=', 1 ], [ 'site_id', '=', $site_id ] ]);
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商人数
|
||||
* @param $site_id
|
||||
* @return int|mixed
|
||||
*/
|
||||
public function getFenxiaoCount($site_id)
|
||||
{
|
||||
$count = model('fenxiao')->getCount([ [ 'site_id', '=', $site_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计分销订单总金额
|
||||
* @param $site_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFenxiaoOrderSum($site_id)
|
||||
{
|
||||
$field = 'sum(real_goods_money) as real_goods_money';
|
||||
$res = model('fenxiao_order')->getInfo([ [ 'site_id', '=', $site_id ] ], $field);
|
||||
if ($res[ 'real_goods_money' ] == null) {
|
||||
$res[ 'real_goods_money' ] = '0.00';
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
219
addon/fenxiao/model/FenxiaoGoods.php
Executable file
219
addon/fenxiao/model/FenxiaoGoods.php
Executable file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
use app\model\BaseModel;
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
|
||||
/**
|
||||
* 分销商品 addon\fenxiao\model\FenxiaoGoods
|
||||
*/
|
||||
class FenxiaoGoods extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 修改分销商品
|
||||
* @param $data
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function editGoodsFenxiao($data, $condition)
|
||||
{
|
||||
$re = model('goods')->update($data, $condition);
|
||||
return $this->success($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分销状态
|
||||
* @param $goods_id
|
||||
* @param $is_fenxiao
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function modifyGoodsFenxiaoStatus($goods_id, $is_fenxiao, $site_id)
|
||||
{
|
||||
$fenxiao_goods_skus = model('fenxiao_goods_sku')->getList([['goods_id', '=', $goods_id]]);
|
||||
model('goods')->startTrans();
|
||||
try {
|
||||
if (empty($fenxiao_goods_skus)) {
|
||||
$level_list = model('fenxiao_level')->getList([['site_id', '=', $site_id], ['status', '=', 1]]);
|
||||
$goods_model = new GoodsModel();
|
||||
$goods_info = $goods_model->getGoodsDetail($goods_id);
|
||||
$fenxiao_goods_sku_data = [];
|
||||
foreach ($level_list as $level) {
|
||||
foreach ($goods_info['data']['sku_data'] as $sku) {
|
||||
$fenxiao_sku = [
|
||||
'goods_id' => $goods_id,
|
||||
'level_id' => $level['level_id'],
|
||||
'sku_id' => $sku['sku_id'],
|
||||
'one_rate' => $level['one_rate'],
|
||||
'one_money' => 0,
|
||||
'two_rate' => $level['two_rate'],
|
||||
'two_money' => 0,
|
||||
'three_rate' => $level['three_rate'],
|
||||
'three_money' => 0,
|
||||
];
|
||||
$fenxiao_goods_sku_data[] = $fenxiao_sku;
|
||||
}
|
||||
}
|
||||
model('fenxiao_goods_sku')->addList($fenxiao_goods_sku_data);
|
||||
}
|
||||
|
||||
model('goods')->update(['is_fenxiao' => $is_fenxiao], [['goods_id', '=', $goods_id], ['site_id', '=', $site_id]]);
|
||||
model('goods')->commit();
|
||||
return $this->success(1);
|
||||
} catch (\Exception $e) {
|
||||
model('goods')->rollback();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消参与分销
|
||||
* @param $goods_ids
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function modifyGoodsIsFenxiao($goods_ids, $is_fenxiao, $site_id)
|
||||
{
|
||||
$res = model('goods')->update(['is_fenxiao' => $is_fenxiao], [['goods_id', 'in', $goods_ids], ['site_id', '=', $site_id]]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商品分销详情
|
||||
* @param $goods_sku_detail_array
|
||||
*/
|
||||
public function getGoodsFenxiaoDetailInApi($goods_sku_detail_array, $member_id, $site_id, $discount_price = 0)
|
||||
{
|
||||
$config = new Config();
|
||||
$words_config = $config->getFenxiaoWordsConfig($site_id)['data']['value'];
|
||||
$basic_config = $config->getFenxiaoBasicsConfig($site_id)['data']['value'];
|
||||
$data = [
|
||||
'words_account' => $words_config['account'],
|
||||
'commission_money' => 0.00,
|
||||
'is_commission_money' => $basic_config['is_commission_money'],
|
||||
];
|
||||
$goods_sku_detail_array['goods_sku_detail']['fenxiao_detail'] = $data;
|
||||
//检测当前用户是否是分销商以及分销商等级
|
||||
$member_info = $goods_sku_detail_array['member_info'];
|
||||
$goods_sku_detail = $goods_sku_detail_array['goods_sku_detail'];
|
||||
if ($member_info['is_fenxiao'] == 0 || $goods_sku_detail['is_fenxiao'] == 0) {
|
||||
|
||||
return $goods_sku_detail_array;
|
||||
}
|
||||
//查询分销商等级
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo([['member_id', '=', $member_id]], 'fenxiao_id,level_id')['data'];
|
||||
if (empty($fenxiao_info)) return $goods_sku_detail_array;
|
||||
// $discount_price = $goods_sku_detail['fenxiao_price'] > 0 ? $goods_sku_detail['fenxiao_price'] : $goods_sku_detail['discount_price'];
|
||||
if ($goods_sku_detail['fenxiao_price'] > 0) {
|
||||
$discount_price = $goods_sku_detail['fenxiao_price'];
|
||||
} else {
|
||||
if ($discount_price == 0) {
|
||||
if (!empty($goods_sku_detail['member_price'])) {
|
||||
$discount_price = min($goods_sku_detail['member_price'], $goods_sku_detail['discount_price']);
|
||||
} else {
|
||||
$discount_price = $goods_sku_detail['discount_price'];
|
||||
}
|
||||
} else {
|
||||
$discount_price = $discount_price; // 特殊营销活动直接指定计算价格
|
||||
}
|
||||
}
|
||||
if ($goods_sku_detail['fenxiao_type'] == 1) {
|
||||
$fenxiao_level = new FenxiaoLevel();
|
||||
$level_info = $fenxiao_level->getLevelInfo([['level_id', '=', $fenxiao_info['level_id']]], 'one_rate')['data'];
|
||||
if (!empty($level_info)) {
|
||||
$data['commission_money'] = number_format($discount_price * $level_info['one_rate'] / 100, 2, '.', '');
|
||||
}
|
||||
} else {
|
||||
$fenxiao_sku_info = model('fenxiao_goods_sku')->getInfo([['level_id', '=', $fenxiao_info['level_id']], ['sku_id', '=', $goods_sku_detail['sku_id']]], 'one_money, one_rate');
|
||||
if (!empty($fenxiao_sku_info)) {
|
||||
$data['commission_money'] = $fenxiao_sku_info['one_money'];
|
||||
if ($fenxiao_sku_info['one_rate'] > 0) {
|
||||
$data['commission_money'] = number_format($discount_price * $fenxiao_sku_info['one_rate'] / 100, 2, '.', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
$goods_sku_detail_array['goods_sku_detail']['fenxiao_detail'] = $data;
|
||||
return $goods_sku_detail_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商品规格列表分销信息
|
||||
* @param $goods_sku_list
|
||||
* @param $member_id
|
||||
* @param $site_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getGoodsSkuListFenxiaoInApi($goods_sku_list, $member_id, $site_id)
|
||||
{
|
||||
$config = new Config();
|
||||
$words_config = $config->getFenxiaoWordsConfig($site_id)['data']['value'];
|
||||
$basic_config = $config->getFenxiaoBasicsConfig($site_id)['data']['value'];
|
||||
$data = [
|
||||
'words_account' => $words_config['account'],
|
||||
'commission_money' => 0.00,
|
||||
'is_commission_money' => $basic_config['is_commission_money'],
|
||||
];
|
||||
//组装数据
|
||||
foreach ($goods_sku_list as $k => $v) {
|
||||
$goods_sku_list[$k]['fenxiao_detail'] = $data;
|
||||
}
|
||||
//检测当前用户是否是分销商以及分销商等级
|
||||
$goods_sku_info = $goods_sku_list[0];
|
||||
$member_info = $goods_sku_list[0]['member_info'];
|
||||
if ($member_info['is_fenxiao'] == 0 || $goods_sku_info['is_fenxiao'] == 0) {
|
||||
return $goods_sku_list;
|
||||
}
|
||||
//查询分销商等级
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo([['member_id', '=', $member_id]], 'fenxiao_id,level_id')['data'];
|
||||
if (empty($fenxiao_info)) return $goods_sku_list;
|
||||
|
||||
if ($goods_sku_info['fenxiao_type'] == 1) {
|
||||
$fenxiao_level = new FenxiaoLevel();
|
||||
$level_info = $fenxiao_level->getLevelInfo([['level_id', '=', $fenxiao_info['level_id']]], 'one_rate')['data'];
|
||||
if (!empty($level_info)) {
|
||||
foreach ($goods_sku_list as $k => $v) {
|
||||
|
||||
if ($v['fenxiao_price'] > 0) {
|
||||
$discount_price = $v['fenxiao_price'];
|
||||
} else {
|
||||
if (!empty($v['member_price'])) {
|
||||
$discount_price = min($v['member_price'], $v['discount_price']);
|
||||
} else {
|
||||
$discount_price = $v['discount_price'];
|
||||
}
|
||||
}
|
||||
// $discount_price = $v['fenxiao_price'] > 0 ? $v['fenxiao_price'] : $v['discount_price'];
|
||||
$goods_sku_list[$k]['fenxiao_detail']['commission_money'] = number_format($discount_price * $level_info['one_rate'] / 100, 2, '.', '');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$fenxiao_sku_list = model('fenxiao_goods_sku')->getList([['level_id', '=', $fenxiao_info['level_id']], ['goods_id', '=', $goods_sku_info['goods_id']]], 'sku_id, one_money, one_rate');
|
||||
$fenxiao_sku_list = array_column($fenxiao_sku_list, null, 'sku_id');
|
||||
foreach ($goods_sku_list as $k => $v) {
|
||||
$fenxiao_sku_info = $fenxiao_sku_list[$v['sku_id']] ?? [];
|
||||
if (!empty($fenxiao_sku_info)) {
|
||||
$discount_price = $v['fenxiao_price'] > 0 ? $v['fenxiao_price'] : $v['discount_price'];
|
||||
$goods_sku_list[$k]['fenxiao_detail']['commission_money'] = $fenxiao_sku_info['one_money'];
|
||||
if ($fenxiao_sku_info['one_rate'] > 0) {
|
||||
$goods_sku_list[$k]['fenxiao_detail']['commission_money'] = number_format($discount_price * $fenxiao_sku_info['one_rate'] / 100, 2, '.', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return $goods_sku_list;
|
||||
}
|
||||
}
|
||||
83
addon/fenxiao/model/FenxiaoGoodsCollect.php
Executable file
83
addon/fenxiao/model/FenxiaoGoodsCollect.php
Executable file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
|
||||
/**
|
||||
* 分销商关注商品
|
||||
*/
|
||||
class FenxiaoGoodsCollect extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 添加分销商关注商品
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function addCollect($data)
|
||||
{
|
||||
$res = model('fenxiao_goods_collect')->getCount([ [ 'member_id', '=', $data[ 'member_id' ] ], [ 'goods_id', '=', $data[ 'goods_id' ] ] ]);
|
||||
if (empty($res)) {
|
||||
$data[ 'create_time' ] = time();
|
||||
$collect_id = model('fenxiao_goods_collect')->add($data);
|
||||
return $this->success($collect_id);
|
||||
} else {
|
||||
return $this->error('', 'GOODS_COLLECT_IS_EXIST');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分销商关注商品
|
||||
* @param array $condition
|
||||
* @return array
|
||||
*/
|
||||
public function deleteCollect($condition = [])
|
||||
{
|
||||
$res = model('fenxiao_goods_collect')->delete($condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商关注商品数信息
|
||||
* @param $condition
|
||||
* @param $field
|
||||
* @return array
|
||||
*/
|
||||
public function getCollectInfo($condition, $field = '*')
|
||||
{
|
||||
$res = model('fenxiao_goods_collect')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商关注商品分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @return array
|
||||
*/
|
||||
public function getCollectPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'fgc.create_time desc', $field = 'fgc.collect_id,fgc.member_id,fgc.fenxiao_id,fgc.create_time,gs.sku_id,gs.sku_name,gs.discount_price,gs.stock,gs.sale_num,gs.sku_image,gs.site_id,gs.fenxiao_price,g.goods_image,g.fenxiao_type')
|
||||
{
|
||||
$alias = 'fgc';
|
||||
$join = [
|
||||
[ 'goods_sku gs', 'fgc.sku_id = gs.sku_id', 'inner' ],
|
||||
[ 'goods g', 'fgc.goods_id = g.goods_id', 'inner' ]
|
||||
];
|
||||
|
||||
$list = model('fenxiao_goods_collect')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
}
|
||||
188
addon/fenxiao/model/FenxiaoGoodsSku.php
Executable file
188
addon/fenxiao/model/FenxiaoGoodsSku.php
Executable file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
|
||||
/**
|
||||
* 分销
|
||||
*/
|
||||
class FenxiaoGoodsSku extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 添加分销商品
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function addSku($data)
|
||||
{
|
||||
$res = model('fenxiao_goods_sku')->add($data);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑分销商品
|
||||
* @param $data
|
||||
* @param array $condition
|
||||
* @return array
|
||||
*/
|
||||
public function editSku($data, $condition = [])
|
||||
{
|
||||
$data[ 'update_time' ] = time();
|
||||
$res = model('fenxiao_goods_sku')->update($data, $condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分销商品
|
||||
* @param array $condition
|
||||
* @return array
|
||||
*/
|
||||
public function deleteSku($condition = [])
|
||||
{
|
||||
$res = model('fenxiao_goods_sku')->delete($condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商品详情
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoGoodsSkuDetail($condition = [], $field = 'fgs.goods_sku_id,fgs.goods_id,fgs.sku_id,fgs.level_id,fgs.one_rate,fgs.one_money,fgs.two_rate,fgs.two_money,fgs.three_rate,fgs.three_money,gs.discount_price,gs.fenxiao_price')
|
||||
{
|
||||
$alias = 'fgs';
|
||||
$join = [
|
||||
[ 'goods_sku gs', 'fgs.sku_id = gs.sku_id', 'inner' ],
|
||||
[ 'goods g', 'g.goods_id = gs.goods_id', 'inner' ]
|
||||
];
|
||||
$list = model('fenxiao_goods_sku')->getInfo($condition, $field, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销sku列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getSkuList($condition = [], $field = '*', $order = '', $limit = null)
|
||||
{
|
||||
$list = model('fenxiao_goods_sku')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商品分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoGoodsSkuPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'g.create_time desc', $field = 'g.goods_id,g.label_name,g.goods_name,g.goods_image,g.sku_id,gs.sku_name,gs.discount_price,gs.price,gs.stock,gs.sale_num,gs.sku_image,gs.fenxiao_price,g.fenxiao_type,(g.sale_num + g.virtual_sale) as sale_sort')
|
||||
{
|
||||
$alias = 'g';
|
||||
$join = [
|
||||
[ 'goods_sku gs', 'g.sku_id = gs.sku_id', 'inner' ],
|
||||
];
|
||||
$res = model('goods')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
foreach ($res[ 'list' ] as $k => $v) {
|
||||
if (isset($v[ 'goods_stock' ])) {
|
||||
$res[ 'list' ][ $k ][ 'goods_stock' ] = numberFormat($res[ 'list' ][ $k ][ 'goods_stock' ]);
|
||||
}
|
||||
if (isset($v[ 'sale_num' ])) {
|
||||
$res[ 'list' ][ $k ][ 'sale_num' ] = numberFormat($res[ 'list' ][ $k ][ 'sale_num' ]);
|
||||
}
|
||||
if (isset($v[ 'virtual_sale' ])) {
|
||||
$res[ 'list' ][ $k ][ 'virtual_sale' ] = numberFormat($res[ 'list' ][ $k ][ 'virtual_sale' ]);
|
||||
}
|
||||
if (isset($v[ 'real_stock' ])) {
|
||||
$res[ 'list' ][ $k ][ 'real_stock' ] = numberFormat($res[ 'list' ][ $k ][ 'real_stock' ]);
|
||||
}
|
||||
if (isset($v[ 'stock' ])) {
|
||||
$res[ 'list' ][ $k ][ 'stock' ] = numberFormat($res[ 'list' ][ $k ][ 'stock' ]);
|
||||
}
|
||||
if (isset($v[ 'sale_sort' ])) {
|
||||
$res[ 'list' ][ $k ][ 'sale_sort' ] = numberFormat($res[ 'list' ][ $k ][ 'sale_sort' ]);
|
||||
}
|
||||
}
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加分销商品
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function addSkuList($data)
|
||||
{
|
||||
$re = model('fenxiao_goods_sku')->addList($data);
|
||||
return $this->success($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商品信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoGoodsSkuInfo($condition = [], $field = '*')
|
||||
{
|
||||
$res = model('fenxiao_goods_sku')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品一级分销佣金
|
||||
* @param $sku_id
|
||||
* @param $level_id
|
||||
* @return array
|
||||
*/
|
||||
public function getSkuFenxiaoCommission($sku_id, $level_id)
|
||||
{
|
||||
$commission = 0.00;
|
||||
|
||||
$condition = [ [ 'gs.sku_id', '=', $sku_id ], [ 'g.is_fenxiao', '=', 1 ] ];
|
||||
$join = [
|
||||
[ 'goods g', 'g.goods_id = gs.goods_id', 'inner' ]
|
||||
];
|
||||
$sku_info = model('goods_sku')->getInfo($condition, 'g.fenxiao_type,gs.fenxiao_price,gs.discount_price', 'gs', $join);
|
||||
|
||||
if (!empty($sku_info)) {
|
||||
$discount_price = $sku_info[ 'fenxiao_price' ] > 0 ? $sku_info[ 'fenxiao_price' ] : $sku_info[ 'discount_price' ];
|
||||
// 默认规则
|
||||
if ($sku_info[ 'fenxiao_type' ] == 1) {
|
||||
$fenxiao_level = new FenxiaoLevel();
|
||||
$level_info = $fenxiao_level->getLevelInfo([ [ 'level_id', '=', $level_id ] ], 'one_rate')[ 'data' ];
|
||||
if (!empty($level_info)) {
|
||||
$commission = number_format($discount_price * $level_info[ 'one_rate' ] / 100, 2, '.', '');
|
||||
}
|
||||
} else {
|
||||
$fenxiao_sku_info = $this->getFenxiaoGoodsSkuInfo([ [ 'level_id', '=', $level_id ], [ 'sku_id', '=', $sku_id ] ])[ 'data' ];
|
||||
if (!empty($fenxiao_sku_info)) {
|
||||
$commission = $fenxiao_sku_info[ 'one_money' ];
|
||||
if ($fenxiao_sku_info[ 'one_rate' ] > 0) {
|
||||
$commission = number_format($discount_price * $fenxiao_sku_info[ 'one_rate' ] / 100, 2, '.', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($commission);
|
||||
}
|
||||
}
|
||||
182
addon/fenxiao/model/FenxiaoLevel.php
Executable file
182
addon/fenxiao/model/FenxiaoLevel.php
Executable file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
|
||||
/**
|
||||
* 分销
|
||||
*/
|
||||
class FenxiaoLevel extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 添加分销等级
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function addLevel($data)
|
||||
{
|
||||
$data[ 'create_time' ] = time();
|
||||
$data[ 'status' ] = 1;
|
||||
|
||||
$res = model('fenxiao_level')->add($data);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑分销等级
|
||||
* @param $data
|
||||
* @param array $condition
|
||||
* @return array
|
||||
*/
|
||||
public function editLevel($data, $condition = [])
|
||||
{
|
||||
$data[ 'update_time' ] = time();
|
||||
|
||||
$res = model('fenxiao_level')->update($data, $condition);
|
||||
if ($res) {
|
||||
if (isset($data[ 'level_name' ]) && $data[ 'level_name' ] != '') {
|
||||
model('fenxiao')->update([ 'level_name' => $data[ 'level_name' ] ], $condition);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分销等级
|
||||
* @param $level_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function deleteLevel($level_id, $site_id)
|
||||
{
|
||||
$fenxiao_model = new Fenxiao();
|
||||
$fenxiao_list = $fenxiao_model->getFenxiaoList([ [ 'level_id', '=', $level_id ] ], 'fenxiao_id');
|
||||
if (empty($fenxiao_list[ 'data' ])) {
|
||||
$res = model('fenxiao_level')->delete([ [ 'level_id', '=', $level_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error('', '该分销等级存在其他分销商,无法删除');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销等级信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getLevelInfo($condition = [], $field = '*')
|
||||
{
|
||||
$res = model('fenxiao_level')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getLevelColumn($condition = [], $field = 'level_id')
|
||||
{
|
||||
$list = model('fenxiao_level')->getColumn($condition, $field);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商等级列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getLevelList($condition = [], $field = '*', $order = '', $limit = null)
|
||||
{
|
||||
$list = model('fenxiao_level')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商等级分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getLevelPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
|
||||
{
|
||||
$list = model('fenxiao_level')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最低的分销商等级
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getMinLevel($condition = [], $field = '*')
|
||||
{
|
||||
$info = model('fenxiao_level')->getFirstData($condition, $field, 'level_num asc,one_rate asc');
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 某项排序的第一个
|
||||
* @param $condition
|
||||
* @param $field
|
||||
* @param $order
|
||||
* @return array
|
||||
*/
|
||||
public function getLevelFirst($condition, $field, $order)
|
||||
{
|
||||
$first = model('fenxiao_level')->getFirstData($condition, $field, $order);
|
||||
return $this->success($first);
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台端获取分销商列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
*/
|
||||
public function getLevelPageListInAdmin($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
|
||||
{
|
||||
$list = $this->getLevelPageList($condition, $page, $page_size, $order, $field);
|
||||
if (!empty($list[ 'data' ][ 'list' ])) {
|
||||
$level_id_arr = [];
|
||||
foreach ($list[ 'data' ][ 'list' ] as $key => $val) {
|
||||
$level_id_arr[] = $val['level_id'];
|
||||
}
|
||||
$level_ids = implode(',', $level_id_arr);
|
||||
|
||||
$fenxiao_list = model('fenxiao')->getList([['level_id', 'in', $level_ids]], 'level_id, count(*) as count', '', '', '', 'level_id');
|
||||
|
||||
if(!empty($fenxiao_list)) {
|
||||
$key = array_column($fenxiao_list, 'level_id');
|
||||
$fenxiao_list = array_combine($key, $fenxiao_list);
|
||||
}
|
||||
foreach ($list[ 'data' ][ 'list' ] as $key => $val) {
|
||||
$list[ 'data' ][ 'list' ][ $key ][ 'fenxiao_num' ] = $fenxiao_list['level_id'] ?? 0;
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
580
addon/fenxiao/model/FenxiaoOrder.php
Executable file
580
addon/fenxiao/model/FenxiaoOrder.php
Executable file
@@ -0,0 +1,580 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\dict\order_refund\OrderRefundDict;
|
||||
use app\model\BaseModel;
|
||||
use app\model\message\Message;
|
||||
use app\model\system\Stat;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* 分销商品
|
||||
*/
|
||||
class FenxiaoOrder extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 分销订单计算
|
||||
* @param $order
|
||||
* @return array
|
||||
*/
|
||||
public function calculate($order)
|
||||
{
|
||||
//获取分销基础配置
|
||||
$config_model = new Config();
|
||||
$fenxiao_basic_config = $config_model->getFenxiaoBasicsConfig($order[ 'site_id' ])['data'] ?? [];
|
||||
$level_config = $fenxiao_basic_config[ 'value' ][ 'level' ];
|
||||
if (empty($level_config)) {
|
||||
return $this->success();
|
||||
}
|
||||
//检测分销商上级关系
|
||||
$member_info = model('member')->getInfo([ [ 'member_id', '=', $order[ 'member_id' ] ] ], 'fenxiao_id,is_fenxiao');
|
||||
//如果没有分销商直接返回不计算,没有考虑首次付款上下级绑定
|
||||
if (empty($member_info)) {
|
||||
return $this->success();
|
||||
}
|
||||
if ($member_info[ 'fenxiao_id' ] == 0) {
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
$fenxiao_id = $member_info[ 'fenxiao_id' ];
|
||||
$fenxiao_info = model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $fenxiao_id ], [ 'is_delete', '=', 0 ] ]);
|
||||
if (empty($fenxiao_info)) {
|
||||
return $this->success();
|
||||
}
|
||||
// 如果购买人是分销商 并且未开启分销商自购
|
||||
if ($member_info[ 'is_fenxiao' ] && $fenxiao_basic_config[ 'value' ][ 'self_purchase_rebate' ] == 0) {
|
||||
if (empty($fenxiao_info[ 'parent' ])) return $this->success();
|
||||
$fenxiao_info = model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $fenxiao_info[ 'parent' ] ], [ 'is_delete', '=', 0 ] ]);
|
||||
if (empty($fenxiao_info)) return $this->success();
|
||||
}
|
||||
|
||||
//判断几级分销
|
||||
$parent_fenxiao_info = $level_config >= 2 ? model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $fenxiao_info[ 'parent' ] ], [ 'is_delete', '=', 0 ] ], 'fenxiao_id, fenxiao_name, status, parent') : [];
|
||||
$grand_parent_fenxiao_info = $level_config >= 3 && !empty($parent_fenxiao_info[ 'parent' ]) ? model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $parent_fenxiao_info[ 'parent' ] ], [ 'is_delete', '=', 0 ] ], 'fenxiao_id, fenxiao_name, status') : [];
|
||||
$order_goods = model('order_goods')->getList([ [ 'order_id', '=', $order[ 'order_id' ] ], [ 'is_fenxiao', '=', 1 ] ], 'order_goods_id, goods_id, sku_id, sku_name, sku_image, sku_no, is_virtual, price, cost_price, num, goods_money, cost_money, delivery_no, delivery_status, real_goods_money');
|
||||
if (empty($order_goods)) return $this->success();
|
||||
|
||||
model('fenxiao_order')->delete([ [ 'order_id', '=', $order[ 'order_id' ] ] ]);
|
||||
//获取分销等级
|
||||
foreach ($order_goods as $k => $v) {
|
||||
$v[ 'num' ] = numberFormat($v[ 'num' ]);
|
||||
|
||||
//商品信息管理
|
||||
$goods_info = model('goods')->getInfo([ [ 'goods_id', '=', $v[ 'goods_id' ] ] ], 'is_fenxiao, fenxiao_type');
|
||||
if ($goods_info[ 'is_fenxiao' ] != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sku_info = model('goods_sku')->getInfo([ [ 'sku_id', '=', $v[ 'sku_id' ] ] ], 'fenxiao_price');
|
||||
if (!empty($sku_info) && $sku_info[ 'fenxiao_price' ] > 0) $v[ 'real_goods_money' ] = $sku_info[ 'fenxiao_price' ] * $v[ 'num' ];
|
||||
|
||||
$commission = 0;
|
||||
$commission_rate = 0;
|
||||
$order_fenxiao_data = [
|
||||
'one_rate' => 0,
|
||||
'one_commission' => 0,
|
||||
'two_rate' => 0,
|
||||
'two_commission' => 0,
|
||||
'three_rate' => 0,
|
||||
];
|
||||
|
||||
if ($goods_info[ 'fenxiao_type' ] == 2) {
|
||||
// 自定义分销规则
|
||||
$fenxiao_level = model('fenxiao_goods_sku')->getInfo([ [ 'goods_id', '=', $v[ 'goods_id' ] ], [ 'sku_id', '=', $v[ 'sku_id' ] ], [ 'level_id', '=', $fenxiao_info[ 'level_id' ] ] ]);
|
||||
if (empty($fenxiao_level)) continue;
|
||||
|
||||
if ($fenxiao_info[ 'status' ] == 1) {
|
||||
if ($fenxiao_level[ 'one_rate' ] > 0) {
|
||||
$commission_rate += $order_fenxiao_data[ 'one_rate' ] = $fenxiao_level[ 'one_rate' ];
|
||||
$commission += $order_fenxiao_data[ 'one_commission' ] = $fenxiao_level[ 'one_rate' ] * $v[ 'real_goods_money' ] / 100;
|
||||
} else {
|
||||
$commission_rate += $order_fenxiao_data[ 'one_rate' ] = round($fenxiao_level[ 'one_money' ] * $v[ 'num' ] / $v[ 'real_goods_money' ], 2);
|
||||
$commission += $order_fenxiao_data[ 'one_commission' ] = $fenxiao_level[ 'one_money' ] * $v[ 'num' ];
|
||||
}
|
||||
}
|
||||
if (!empty($parent_fenxiao_info) && $parent_fenxiao_info[ 'status' ] == 1) {
|
||||
if ($fenxiao_level[ 'two_rate' ] > 0) {
|
||||
$commission_rate += $order_fenxiao_data[ 'two_rate' ] = $fenxiao_level[ 'two_rate' ];
|
||||
$commission += $order_fenxiao_data[ 'two_commission' ] = $fenxiao_level[ 'two_rate' ] * $v[ 'real_goods_money' ] / 100;
|
||||
} else {
|
||||
$commission_rate += $order_fenxiao_data[ 'two_rate' ] = round($fenxiao_level[ 'two_money' ] * $v[ 'num' ] / $v[ 'real_goods_money' ], 2);
|
||||
$commission += $order_fenxiao_data[ 'two_commission' ] = $fenxiao_level[ 'two_money' ] * $v[ 'num' ];
|
||||
}
|
||||
}
|
||||
if (!empty($grand_parent_fenxiao_info) && $grand_parent_fenxiao_info[ 'status' ] == 1) {
|
||||
if ($fenxiao_level[ 'three_rate' ] > 0) {
|
||||
$commission_rate += $order_fenxiao_data[ 'three_rate' ] = $fenxiao_level[ 'three_rate' ];
|
||||
$commission += $order_fenxiao_data[ 'three_commission' ] = $fenxiao_level[ 'three_rate' ] * $v[ 'real_goods_money' ] / 100;
|
||||
} else {
|
||||
$commission_rate += $order_fenxiao_data[ 'three_rate' ] = round($fenxiao_level[ 'three_money' ] * $v[ 'num' ] / $v[ 'real_goods_money' ], 2);
|
||||
$commission += $order_fenxiao_data[ 'three_commission' ] = $fenxiao_level[ 'three_money' ] * $v[ 'num' ];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 默认规则
|
||||
$fenxiao_level = model('fenxiao_level')->getInfo([ [ 'level_id', '=', $fenxiao_info[ 'level_id' ] ] ]);
|
||||
if ($fenxiao_info[ 'status' ] == 1) {
|
||||
if ($fenxiao_level[ 'one_rate' ] > 0) {
|
||||
$commission_rate += $order_fenxiao_data[ 'one_rate' ] = $fenxiao_level[ 'one_rate' ];
|
||||
$commission += $order_fenxiao_data[ 'one_commission' ] = $fenxiao_level[ 'one_rate' ] * $v[ 'real_goods_money' ] / 100;
|
||||
} else {
|
||||
$order_fenxiao_data[ 'one_rate' ] = 0;
|
||||
$order_fenxiao_data[ 'one_commission' ] = 0;
|
||||
}
|
||||
}
|
||||
if (!empty($parent_fenxiao_info) && $parent_fenxiao_info[ 'status' ] == 1) {
|
||||
if ($fenxiao_level[ 'two_rate' ] > 0) {
|
||||
$commission_rate += $order_fenxiao_data[ 'two_rate' ] = $fenxiao_level[ 'two_rate' ];
|
||||
$commission += $order_fenxiao_data[ 'two_commission' ] = $fenxiao_level[ 'two_rate' ] * $v[ 'real_goods_money' ] / 100;
|
||||
} else {
|
||||
$order_fenxiao_data[ 'two_rate' ] = 0;
|
||||
$order_fenxiao_data[ 'two_commission' ] = 0;
|
||||
}
|
||||
}
|
||||
if (!empty($grand_parent_fenxiao_info) && $grand_parent_fenxiao_info[ 'status' ] == 1) {
|
||||
if ($fenxiao_level[ 'three_rate' ] > 0) {
|
||||
$commission_rate += $order_fenxiao_data[ 'three_rate' ] = $fenxiao_level[ 'three_rate' ];
|
||||
$commission += $order_fenxiao_data[ 'three_commission' ] = $fenxiao_level[ 'three_rate' ] * $v[ 'real_goods_money' ] / 100;
|
||||
} else {
|
||||
$order_fenxiao_data[ 'three_rate' ] = 0;
|
||||
$order_fenxiao_data[ 'three_commission' ] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//启动分销
|
||||
$data = [
|
||||
'order_id' => $order[ 'order_id' ],
|
||||
'order_no' => $order[ 'order_no' ],
|
||||
'order_goods_id' => $v[ 'order_goods_id' ],
|
||||
'site_id' => $order[ 'site_id' ],
|
||||
'site_name' => $order[ 'site_name' ],
|
||||
'goods_id' => $v[ 'goods_id' ],
|
||||
'sku_id' => $v[ 'sku_id' ],
|
||||
'sku_name' => $v[ 'sku_name' ],
|
||||
'sku_image' => $v[ 'sku_image' ],
|
||||
'price' => $v[ 'price' ],
|
||||
'num' => $v[ 'num' ],
|
||||
'real_goods_money' => $v[ 'real_goods_money' ],
|
||||
'member_id' => $order[ 'member_id' ],
|
||||
'member_name' => $order[ 'name' ] ?? '',
|
||||
'member_mobile' => $order[ 'mobile' ] ?? '',
|
||||
'full_address' => $order[ 'full_address' ] ?? '' . $order[ 'address' ] ?? '',
|
||||
'commission' => $commission,
|
||||
'commission_rate' => $commission_rate,
|
||||
'one_fenxiao_id' => $fenxiao_info[ 'fenxiao_id' ],
|
||||
'one_rate' => empty($order_fenxiao_data[ 'one_rate' ]) ? 0 : $order_fenxiao_data[ 'one_rate' ],
|
||||
'one_commission' => empty($order_fenxiao_data[ 'one_commission' ]) ? 0 : $order_fenxiao_data[ 'one_commission' ],
|
||||
'one_fenxiao_name' => $fenxiao_info[ 'fenxiao_name' ],
|
||||
'two_fenxiao_id' => empty($parent_fenxiao_info) ? 0 : $parent_fenxiao_info[ 'fenxiao_id' ],
|
||||
'two_rate' => empty($order_fenxiao_data[ 'two_rate' ]) ? 0 : $order_fenxiao_data[ 'two_rate' ],
|
||||
'two_commission' => empty($order_fenxiao_data[ 'two_commission' ]) ? 0 : $order_fenxiao_data[ 'two_commission' ],
|
||||
'two_fenxiao_name' => empty($parent_fenxiao_info) ? '' : $parent_fenxiao_info[ 'fenxiao_name' ],
|
||||
'three_fenxiao_id' => empty($grand_parent_fenxiao_info) ? '' : $grand_parent_fenxiao_info[ 'fenxiao_id' ],
|
||||
'three_rate' => empty($order_fenxiao_data[ 'three_rate' ]) ? 0 : $order_fenxiao_data[ 'three_rate' ],
|
||||
'three_commission' => empty($order_fenxiao_data[ 'three_commission' ]) ? 0 : $order_fenxiao_data[ 'three_commission' ],
|
||||
'three_fenxiao_name' => empty($grand_parent_fenxiao_info) ? '' : $grand_parent_fenxiao_info[ 'fenxiao_name' ],
|
||||
'create_time' => time()
|
||||
];
|
||||
model('fenxiao_order')->add($data);
|
||||
}
|
||||
// 分销商检测升级
|
||||
event('FenxiaoUpgrade', $member_info[ 'fenxiao_id' ]);
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
* @param $order_goods_id
|
||||
* @return array
|
||||
*/
|
||||
public function refund($data)
|
||||
{
|
||||
$order_goods_info = $data['order_goods_info'];
|
||||
if ($order_goods_info[ 'refund_mode' ] == OrderRefundDict::refund) {
|
||||
$res = model('fenxiao_order')->update([ 'is_refund' => 1 ], [ [ 'order_goods_id', '=', $order_goods_info['order_goods_id'] ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单结算
|
||||
* @param $order_id
|
||||
* @return array
|
||||
*/
|
||||
public function settlement($order_id)
|
||||
{
|
||||
//获取未退款的和未结算的分销订单
|
||||
$fenxiao_orders = model('fenxiao_order')->getList([ [ 'order_id', '=', $order_id ], [ 'is_settlement', '=', 0 ], [ 'is_refund', '=', 0 ] ], '*');
|
||||
//同时修改分销订单状态为已结算
|
||||
model('fenxiao_order')->startTrans();
|
||||
try {
|
||||
model('fenxiao_order')->update([ 'is_settlement' => 1 ], [ [ 'order_id', '=', $order_id ] ]);
|
||||
$commission = 0;
|
||||
$fenxiao_account = new FenxiaoAccount();
|
||||
$site_id = 0;
|
||||
foreach ($fenxiao_orders as $fenxiao_order) {
|
||||
$site_id = $fenxiao_order[ 'site_id' ];
|
||||
$commission += $fenxiao_order[ 'one_commission' ];
|
||||
$fenxiao_account->addAccount($fenxiao_order[ 'one_fenxiao_id' ], $fenxiao_order[ 'one_fenxiao_name' ], 'order', $fenxiao_order[ 'one_commission' ], $fenxiao_order[ 'fenxiao_order_id' ]);
|
||||
|
||||
// 分销佣金发放通知
|
||||
( new Message() )->sendMessage([
|
||||
'keywords' => 'COMMISSION_GRANT',
|
||||
'order_id' => $fenxiao_order[ 'fenxiao_order_id' ],
|
||||
'site_id' => $fenxiao_order[ 'site_id' ],
|
||||
'level' => 'one',
|
||||
]);
|
||||
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $fenxiao_order[ 'one_fenxiao_id' ] ] ], 'total_commission', $fenxiao_order[ 'one_commission' ]);
|
||||
|
||||
if ($fenxiao_order[ 'two_commission' ] > 0) {
|
||||
$commission += $fenxiao_order[ 'two_commission' ];
|
||||
$fenxiao_account->addAccount($fenxiao_order[ 'two_fenxiao_id' ], $fenxiao_order[ 'two_fenxiao_name' ], 'order', $fenxiao_order[ 'two_commission' ], $fenxiao_order[ 'fenxiao_order_id' ]);
|
||||
|
||||
// 分销佣金发放通知
|
||||
( new Message() )->sendMessage([
|
||||
'keywords' => 'COMMISSION_GRANT',
|
||||
'order_id' => $fenxiao_order[ 'fenxiao_order_id' ],
|
||||
'site_id' => $fenxiao_order[ 'site_id' ],
|
||||
'level' => 'two',
|
||||
]);
|
||||
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $fenxiao_order[ 'two_fenxiao_id' ] ] ], 'total_commission', $fenxiao_order[ 'two_commission' ]);
|
||||
}
|
||||
if ($fenxiao_order[ 'three_commission' ] > 0) {
|
||||
$commission += $fenxiao_order[ 'three_commission' ];
|
||||
$fenxiao_account->addAccount($fenxiao_order[ 'three_fenxiao_id' ], $fenxiao_order[ 'three_fenxiao_name' ], 'order', $fenxiao_order[ 'three_commission' ], $fenxiao_order[ 'fenxiao_order_id' ]);
|
||||
|
||||
// 分销佣金发放通知
|
||||
( new Message() )->sendMessage([
|
||||
'keywords' => 'COMMISSION_GRANT',
|
||||
'order_id' => $fenxiao_order[ 'fenxiao_order_id' ],
|
||||
'site_id' => $fenxiao_order[ 'site_id' ],
|
||||
'level' => 'three',
|
||||
]);
|
||||
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $fenxiao_order[ 'three_fenxiao_id' ] ] ], 'total_commission', $fenxiao_order[ 'three_commission' ]);
|
||||
}
|
||||
|
||||
}
|
||||
$stat_model = new Stat();
|
||||
$stat_model->switchStat([ 'type' => 'fenxiao_order', 'data' => [ 'order_id' => $order_id, 'site_id' => $site_id ] ]);
|
||||
//增加订单佣金结算
|
||||
model('order')->setInc([ [ 'order_id', '=', $order_id ] ], 'commission', $commission);
|
||||
model('fenxiao_order')->commit();
|
||||
return $this->success();
|
||||
} catch ( Exception $e) {
|
||||
model('fenxiao_order')->rollback();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算对应分销商的第一次订单数量&&金额
|
||||
* @param $order_id
|
||||
* @return array
|
||||
*/
|
||||
public function calculateOrder($order_id)
|
||||
{
|
||||
$fenxiao_order_info = model('fenxiao_order')->getFirstData([ [ 'order_id', '=', $order_id ] ], 'one_fenxiao_id');
|
||||
if (!empty($fenxiao_order_info)) {
|
||||
$one_commission_sum = model('fenxiao_order')->getSum([ [ 'order_id', '=', $order_id ] ], 'one_commission');
|
||||
$one_fenxiao_total_order = model('fenxiao_order')->getSum([ [ 'order_id', '=', $order_id ] ], 'real_goods_money');
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $fenxiao_order_info[ 'one_fenxiao_id' ] ] ], 'one_fenxiao_order_num');
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $fenxiao_order_info[ 'one_fenxiao_id' ] ] ], 'one_fenxiao_order_money', $one_commission_sum);
|
||||
model('fenxiao')->setInc([ [ 'fenxiao_id', '=', $fenxiao_order_info[ 'one_fenxiao_id' ] ] ], 'one_fenxiao_total_order', $one_fenxiao_total_order);
|
||||
// 分销商检测升级
|
||||
event('FenxiaoUpgrade', $fenxiao_order_info[ 'one_fenxiao_id' ]);
|
||||
}
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销订单列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoOrderPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'fo.order_id DESC')
|
||||
{
|
||||
$field = '
|
||||
fo.fenxiao_order_id,fo.order_no,fo.site_id,fo.site_name,fo.sku_id,fo.sku_name,fo.sku_image,fo.price,fo.num,fo.real_goods_money,fo.member_name,
|
||||
fo.member_mobile,fo.one_fenxiao_name,fo.is_settlement,fo.commission,fo.is_refund,
|
||||
o.order_status_name,o.create_time,fo.one_fenxiao_id,fo.two_fenxiao_id,fo.three_fenxiao_id,fo.one_commission,fo.two_commission,fo.three_commission';
|
||||
|
||||
$alias = 'fo';
|
||||
$join = [
|
||||
[
|
||||
'order o',
|
||||
'fo.order_id = o.order_id',
|
||||
'inner'
|
||||
]
|
||||
];
|
||||
$list = model('fenxiao_order')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单信息
|
||||
* @param $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoOrderInfo($condition, $field = '*')
|
||||
{
|
||||
$fenxiao_order_info = model('fenxiao_order')->getInfo($condition, $field);
|
||||
return $this->success($fenxiao_order_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单信息
|
||||
* @param $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoOrderInfoNew($condition, $field = '*')
|
||||
{
|
||||
$alias = 'fo';
|
||||
$join = [
|
||||
[
|
||||
'order o',
|
||||
'o.order_id = fo.order_id',
|
||||
'left'
|
||||
]
|
||||
];
|
||||
$fenxiao_order_info = model('fenxiao_order')->getInfo($condition, $field, $alias, $join);
|
||||
return $this->success($fenxiao_order_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分销订单列表(管理端调用)
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoOrderPage($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'order_id DESC')
|
||||
{
|
||||
$field = 'order_id,order_no,site_name,member_name,create_time,is_settlement,fenxiao_order_id';
|
||||
$list = model('fenxiao_order')->pageList($condition, $field, $order, $page, $page_size, 'fo', [], 'order_id');
|
||||
if (!empty($list[ 'list' ])) {
|
||||
$order_id_arr = [];
|
||||
foreach ($list['list'] as $k => $v)
|
||||
{
|
||||
$order_id_arr[] = $v['order_id'];
|
||||
}
|
||||
$order_ids = implode(',', $order_id_arr);
|
||||
$order_list = model('order')->getList([ [ 'order_id', 'in', $order_ids ] ], 'order_id,name,full_address,mobile,order_status_name');
|
||||
$order_goods_list = model('fenxiao_order')->getList([ [ 'order_id', 'in', $order_ids ] ]);
|
||||
foreach ($list[ 'list' ] as $k => $item) {
|
||||
foreach ($order_list as $k_order => $v_order)
|
||||
{
|
||||
if($item['order_id'] == $v_order['order_id'])
|
||||
{
|
||||
$list[ 'list' ][ $k ] = array_merge($list[ 'list' ][ $k ], $v_order);
|
||||
}
|
||||
}
|
||||
$list[ 'list' ][ $k ][ 'order_goods' ] = [];
|
||||
foreach ($order_goods_list as $k_order_goods => $v_order_goods)
|
||||
{
|
||||
if($item['order_id'] == $v_order_goods['order_id'])
|
||||
{
|
||||
$list[ 'list' ][ $k ][ 'order_goods' ][] = $v_order_goods;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销订单详情
|
||||
* @param $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoOrderDetail($condition, $field = '*')
|
||||
{
|
||||
$order_info = model('order')->getInfo($condition, $field);
|
||||
if (!empty($order_info)) {
|
||||
$order_goods = model('fenxiao_order')->getList([ [ 'order_id', '=', $order_info[ 'order_id' ] ] ]);
|
||||
$member_info = model('member')->getInfo([ 'member_id' => $order_info[ 'member_id' ] ], 'nickname');
|
||||
$order_info[ 'order_goods' ] = $order_goods;
|
||||
$order_info[ 'nickname' ] = $member_info[ 'nickname' ];
|
||||
}
|
||||
return $this->success($order_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销订单数量
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoOrderCount($condition)
|
||||
{
|
||||
$count = model('fenxiao_order')->getCount($condition);
|
||||
return $this->success($count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销订单总和
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $alias
|
||||
* @param null $join
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoOrderSum(array $condition, $field = '', $alias = 'a', $join = null)
|
||||
{
|
||||
$data = model('fenxiao_order')->getSum($condition, $field, $alias, $join);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单数据并导出
|
||||
* @param $condition
|
||||
* @param int $site_id
|
||||
*/
|
||||
public function orderExport($condition, $site_id = 0)
|
||||
{
|
||||
$field = [
|
||||
'order_no' => '订单编号',
|
||||
'site_name' => '站点名称',
|
||||
'sku_name' => '商品名称',
|
||||
'member_name' => '购买人',
|
||||
'member_mobile' => '购买人电话',
|
||||
'commission' => '总佣金',
|
||||
'one_rate' => '一级分销比例',
|
||||
'one_commission' => '一级分销佣金',
|
||||
'one_fenxiao_name' => '一级分销商名',
|
||||
'two_rate' => '二级分销比例',
|
||||
'two_commission' => '二级分销佣金',
|
||||
'two_fenxiao_name' => '二级分销商名',
|
||||
'three_rate' => '三级分销比例',
|
||||
'three_commission' => '三级分销佣金',
|
||||
'three_fenxiao_name' => '三级分销商名',
|
||||
'is_settlement' => '是否结算',
|
||||
'is_refund' => '是否退款',
|
||||
'province_name' => '省',
|
||||
'city_name' => '市',
|
||||
'district_name' => '县',
|
||||
'full_address' => '详细地址',
|
||||
'order_status_name' => '订单状态'
|
||||
];
|
||||
|
||||
$fields = 'fo.*,o.address,o.full_address,o.order_status_name';
|
||||
$alias = 'fo';
|
||||
$join = [
|
||||
[
|
||||
'order o',
|
||||
'o.order_id = fo.order_id',
|
||||
'left'
|
||||
]
|
||||
];
|
||||
|
||||
$list = model('fenxiao_order')->getList($condition, $fields, '', $alias, $join);
|
||||
$head_html = [];
|
||||
$line_html = [];
|
||||
foreach ($field as $k => $v) {
|
||||
$head_html[] = $v;
|
||||
$line_html[] = $k;
|
||||
}
|
||||
|
||||
$temp_line = implode(',', $head_html) . "\n";
|
||||
$html = str_replace("\n", '', $temp_line) . "\n";
|
||||
$line = implode(',', $line_html);
|
||||
$html .= str_replace("\n", '', $line) . "\n";
|
||||
|
||||
$temp = [];
|
||||
foreach ($line_html as $temp_line_k => $temp_line_v) {
|
||||
$temp[] = "{\$$temp_line_v}";
|
||||
}
|
||||
|
||||
$tempLine = implode(',', $temp) . "\n";
|
||||
|
||||
foreach ($list as $item) {
|
||||
$new_line_value = $tempLine;
|
||||
$address_arr = explode('-', $item[ 'full_address' ]);
|
||||
$item[ 'province_name' ] = !empty($address_arr[ 0 ]) ? $address_arr[ 0 ] : '';
|
||||
$item[ 'city_name' ] = !empty($address_arr[ 1 ]) ? $address_arr[ 1 ] : '';
|
||||
$item[ 'district_name' ] = !empty($address_arr[ 2 ]) ? $address_arr[ 2 ] : '';
|
||||
$item[ 'is_settlement' ] = $item[ 'is_settlement' ] == 0 ? '否' : '是';
|
||||
$item[ 'is_refund' ] = $item[ 'is_refund' ] == 0 ? '否' : '是';
|
||||
|
||||
foreach ($item as $key => $val) {
|
||||
if ($key == 'full_address') {
|
||||
$address = $item[ 'address' ] ?? '';
|
||||
$val = $val . $address;
|
||||
}
|
||||
|
||||
//CSV比较简单,记得转义 逗号就好
|
||||
$values = str_replace(',', '\\', $val . "\t");
|
||||
$values = str_replace("\n", '', $values);
|
||||
$new_line_value = str_replace("{\$$key}", $values, $new_line_value);
|
||||
|
||||
}
|
||||
|
||||
$html .= $new_line_value;
|
||||
}
|
||||
|
||||
$filename = date('YmdHis') . '.csv'; //设置文件名
|
||||
header('Content-type:text/csv');
|
||||
header('Content-Disposition:attachment;filename=' . $filename);
|
||||
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
|
||||
header('Expires:0');
|
||||
header('Pragma:public');
|
||||
exit(mb_convert_encoding($html, 'GBK', 'UTF-8'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 给csv写入新的数据
|
||||
* @param $item_list
|
||||
* @param $field_key
|
||||
* @param $temp_line
|
||||
* @param $fp
|
||||
*/
|
||||
public function itemExport($item_list, $field_key, $temp_line, $fp)
|
||||
{
|
||||
$item_list = $item_list->toArray();
|
||||
foreach ($item_list as $k => $item_v) {
|
||||
$new_line_value = $temp_line;
|
||||
//省市县
|
||||
$address_arr = explode('-', $item_v[ 'full_address' ]);
|
||||
|
||||
$item_v[ 'province_name' ] = $address_arr[ 0 ] ?: '';
|
||||
$item_v[ 'city_name' ] = $address_arr[ 1 ] ?: '';
|
||||
$item_v[ 'district_name' ] = $address_arr[ 2 ] ?: '';
|
||||
|
||||
foreach ($item_v as $key => $value) {
|
||||
|
||||
if ($key == 'full_address') {
|
||||
$address = $item_v[ 'address' ] ?? '';
|
||||
$value = $value . $address;
|
||||
}
|
||||
//CSV比较简单,记得转义 逗号就好
|
||||
$values = str_replace(',', '\\', $value . "\t");
|
||||
$values = str_replace("\n", '', $values);
|
||||
$new_line_value = str_replace("{\$$key}", $values, $new_line_value);
|
||||
}
|
||||
//写入第一行表头
|
||||
fwrite($fp, $new_line_value);
|
||||
dump($new_line_value);
|
||||
exit;
|
||||
//销毁变量, 防止内存溢出
|
||||
unset($new_line_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
96
addon/fenxiao/model/FenxiaoStat.php
Executable file
96
addon/fenxiao/model/FenxiaoStat.php
Executable file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\system\Stat;
|
||||
|
||||
/**
|
||||
* 分销订单统计
|
||||
*/
|
||||
class FenxiaoStat extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 写入新增分销商统计数据
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
public function addFenxiaoMemberStat($params)
|
||||
{
|
||||
$site_id = $params[ 'site_id' ] ?? 0;
|
||||
$stat_data = array (
|
||||
'site_id' => $site_id,
|
||||
'add_fenxiao_member_count' => 1
|
||||
);
|
||||
|
||||
$stat_model = new Stat();
|
||||
|
||||
$result = $stat_model->addShopStat($stat_data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销订单总额统计
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
public function addFenxiaoOrderStat($params)
|
||||
{
|
||||
$order_id = $params[ 'order_id' ];
|
||||
$site_id = $params[ 'site_id' ] ?? 0;
|
||||
$order_condition = array (
|
||||
[ 'order_id', '=', $order_id ],
|
||||
[ 'site_id', '=', $site_id ]
|
||||
);
|
||||
$order_info = model('order')->getInfo($order_condition);
|
||||
if (empty($order_info))
|
||||
return $this->error();
|
||||
|
||||
$order_money = $order_info[ 'order_money' ];
|
||||
$refund_money = $order_info[ 'refund_money' ];
|
||||
$stat_data = array (
|
||||
'site_id' => $site_id,
|
||||
'fenxiao_order_count' => 1,
|
||||
'fenxiao_order_total_money' => $order_money - $refund_money,
|
||||
);
|
||||
$stat_model = new Stat();
|
||||
|
||||
$result = $stat_model->addShopStat($stat_data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销佣金账户
|
||||
* @param int $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoAccountSum($site_id = 0)
|
||||
{
|
||||
$field = '
|
||||
sum(account) as account,
|
||||
sum(account_withdraw_apply) as account_withdraw_apply,
|
||||
sum(account_withdraw) as account_withdraw
|
||||
';
|
||||
$info = model('fenxiao')->getInfo([ [ 'site_id', '=', $site_id ] ], $field);
|
||||
if ($info[ 'account' ] == null) {
|
||||
$info[ 'account' ] = '0.00';
|
||||
}
|
||||
if ($info[ 'account_withdraw_apply' ] == null) {
|
||||
$info[ 'account_withdraw_apply' ] = '0.00';
|
||||
}
|
||||
if ($info[ 'account_withdraw' ] == null) {
|
||||
$info[ 'account_withdraw' ] = '0.00';
|
||||
}
|
||||
return $this->success($info);
|
||||
}
|
||||
}
|
||||
960
addon/fenxiao/model/FenxiaoWithdraw.php
Executable file
960
addon/fenxiao/model/FenxiaoWithdraw.php
Executable file
@@ -0,0 +1,960 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\member\Member;
|
||||
use app\model\member\MemberAccount;
|
||||
use app\model\message\Message;
|
||||
use app\model\message\Sms;
|
||||
use app\model\shop\ShopAcceptMessage;
|
||||
use addon\wechat\model\Message as WechatMessage;
|
||||
use app\model\member\Member as MemberModel;
|
||||
use addon\weapp\model\Message as WeappMessage;
|
||||
use app\model\system\Pay;
|
||||
use app\model\system\PayTransfer;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 分销商提现
|
||||
*/
|
||||
class FenxiaoWithdraw extends BaseModel
|
||||
{
|
||||
//提现类型
|
||||
public $withdraw_type = [
|
||||
'balance' => '余额',
|
||||
'weixin' => '微信',
|
||||
'alipay' => '支付宝',
|
||||
'bank' => '银行卡',
|
||||
];
|
||||
|
||||
const STATUS_WAIT_AUDIT = 1;//待审核
|
||||
const STATUS_WAIT_TRANSFER = 2;//待转账
|
||||
const STATUS_SUCCESS = 3;//转账成功
|
||||
const STATUS_IN_PROCESS = 4;//转账中
|
||||
const STATUS_REFUSE = -1;//审核拒绝
|
||||
const STATUS_FAIL = -2;//转账失败
|
||||
|
||||
public $status = array (
|
||||
self::STATUS_WAIT_AUDIT => '待审核',
|
||||
self::STATUS_WAIT_TRANSFER => '待转账',
|
||||
self::STATUS_SUCCESS => '已转账',
|
||||
self::STATUS_IN_PROCESS => '转账中',
|
||||
self::STATUS_REFUSE => '已拒绝',
|
||||
self::STATUS_FAIL => '转账失败',
|
||||
);
|
||||
|
||||
public function getTransferType($site_id)
|
||||
{
|
||||
$pay_model = new Pay();
|
||||
$transfer_type_list = $pay_model->getTransferType($site_id);
|
||||
$transfer_type_list[ 'balance' ] = '余额';
|
||||
return $transfer_type_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商申请提现
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function addFenxiaoWithdraw($data)
|
||||
{
|
||||
//获取分销商信息
|
||||
$fenxiao_model = new Fenxiao();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'fenxiao_id,fenxiao_name,account');
|
||||
if (empty($fenxiao_info[ 'data' ])) {
|
||||
return $this->error('该分销商不存在');
|
||||
}
|
||||
|
||||
if ($fenxiao_info[ 'data' ][ 'account' ] < $data[ 'money' ]) {
|
||||
return $this->error('', '提现金额大于可提现金额');
|
||||
}
|
||||
//获取提现配置信息
|
||||
$config_model = new Config();
|
||||
$config_info = $config_model->getFenxiaoWithdrawConfig($data[ 'site_id' ])[ 'data' ][ 'value' ];
|
||||
if ($config_info[ 'withdraw' ] > $data[ 'money' ]) {
|
||||
return $this->error('', '提现金额小于最低提现金额');
|
||||
}
|
||||
if ($data[ 'money' ] >= $config_info[ 'min_no_fee' ] && $data[ 'money' ] <= $config_info[ 'max_no_fee' ]) {
|
||||
$data[ 'withdraw_rate' ] = 0;
|
||||
$data[ 'withdraw_rate_money' ] = 0;
|
||||
$data[ 'real_money' ] = $data[ 'money' ];
|
||||
} else {
|
||||
$data[ 'withdraw_rate' ] = $config_info[ 'withdraw_rate' ];
|
||||
if ($config_info[ 'withdraw_rate' ] == 0) {
|
||||
$data[ 'withdraw_rate' ] = 0;
|
||||
$data[ 'withdraw_rate_money' ] = 0;
|
||||
$data[ 'real_money' ] = $data[ 'money' ];
|
||||
} else {
|
||||
$data[ 'withdraw_rate' ] = $config_info[ 'withdraw_rate' ];
|
||||
$data[ 'withdraw_rate_money' ] = round($data[ 'money' ] * $config_info[ 'withdraw_rate' ] / 100, 2);
|
||||
$data[ 'real_money' ] = $data[ 'money' ] - $data[ 'withdraw_rate_money' ];
|
||||
}
|
||||
}
|
||||
|
||||
$data[ 'withdraw_no' ] = date('YmdHis') . rand(1000, 9999);
|
||||
$data[ 'create_time' ] = time();
|
||||
|
||||
model('fenxiao_withdraw')->startTrans();
|
||||
try {
|
||||
|
||||
$data[ 'fenxiao_id' ] = $fenxiao_info[ 'data' ][ 'fenxiao_id' ];
|
||||
$data[ 'fenxiao_name' ] = $fenxiao_info[ 'data' ][ 'fenxiao_name' ];
|
||||
|
||||
$res = model('fenxiao_withdraw')->add($data);
|
||||
|
||||
//修改分销商提现中金额
|
||||
model('fenxiao')->setInc([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'account_withdraw_apply', $data[ 'money' ]);
|
||||
//修改分销商可提现金额
|
||||
model('fenxiao')->setDec([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'account', $data[ 'money' ]);
|
||||
|
||||
//判断是否需要审核
|
||||
if ($config_info[ 'withdraw_status' ] == 2) {//不需要
|
||||
$result = $this->withdrawPass($res, $data[ 'site_id' ]);
|
||||
if ($result[ 'code' ] < 0) {
|
||||
model('fenxiao_withdraw')->rollback();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
model('fenxiao_withdraw')->commit();
|
||||
|
||||
//申请提现发送消息
|
||||
$data[ 'keywords' ] = 'FENXIAO_WITHDRAWAL_APPLY';
|
||||
$message_model = new Message();
|
||||
$message_model->sendMessage($data);
|
||||
|
||||
return $this->success($res);
|
||||
} catch (\Exception $e) {
|
||||
model('fenxiao_withdraw')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现审核通过
|
||||
* @param $ids
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function withdrawPass($ids, $site_id)
|
||||
{
|
||||
model('fenxiao_withdraw')->startTrans();
|
||||
try {
|
||||
|
||||
$withdraw_list = $this->getFenxiaoWithdrawList([ [ 'id', 'in', $ids ] ], '*');
|
||||
foreach ($withdraw_list[ 'data' ] as $k => $v) {
|
||||
if ($v[ 'status' ] == self::STATUS_WAIT_AUDIT) {
|
||||
$this->agree([ 'id' => $v[ 'id' ], 'site_id' => $site_id ]);
|
||||
}
|
||||
}
|
||||
model('fenxiao_withdraw')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('fenxiao_withdraw')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现详情
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoWithdrawInfo($condition = [], $field = '*')
|
||||
{
|
||||
$res = model('fenxiao_withdraw')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现详情
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoWithdrawDetail($params)
|
||||
{
|
||||
$id = $params[ 'id' ];
|
||||
$site_id = $params[ 'site_id' ] ?? 0;
|
||||
$member_id = $params[ 'member_id' ] ?? 0;
|
||||
$condition = array (
|
||||
[ 'id', '=', $id ]
|
||||
);
|
||||
if ($site_id > 0) {
|
||||
$condition[] = [ 'site_id', '=', $site_id ];
|
||||
}
|
||||
if ($member_id > 0) {
|
||||
$condition[] = [ 'member_id', '=', $member_id ];
|
||||
}
|
||||
$info = model('fenxiao_withdraw')->getInfo($condition, '*');
|
||||
if (!empty($info)) {
|
||||
$info = $this->tran($info);
|
||||
}
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
public function tran($data)
|
||||
{
|
||||
$status = $data[ 'status' ] ?? 0;
|
||||
if ($status != 0) {
|
||||
$data[ 'status_name' ] = $this->status[ $status ] ?? '';
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoWithdrawList($condition = [], $field = '*', $order = '', $limit = null)
|
||||
{
|
||||
$list = model('fenxiao_withdraw')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销提现分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @param string $alias
|
||||
* @param array $join
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoWithdrawPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = '', $join = [])
|
||||
{
|
||||
$list = model('fenxiao_withdraw')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销佣金发放通知
|
||||
* @param $data
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function messageOrderCommissionGrant($data)
|
||||
{
|
||||
//发送短信
|
||||
$sms_model = new Sms();
|
||||
|
||||
// 分销订单
|
||||
$fenxiao_order_model = new FenxiaoOrder();
|
||||
$fenxiao_order_info = $fenxiao_order_model->getFenxiaoOrderInfo([ [ 'fenxiao_order_id', '=', $data[ 'order_id' ] ] ])[ 'data' ];
|
||||
$commission = $fenxiao_order_info[ $data[ 'level' ] . '_commission' ];
|
||||
|
||||
$fenxiao_id = $fenxiao_order_info[ $data[ 'level' ] . '_fenxiao_id' ];
|
||||
$fenxiao_model = new Fenxiao();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo([ [ 'fenxiao_id', '=', $fenxiao_id ] ], 'fenxiao_id, member_id')[ 'data' ];
|
||||
|
||||
$member_model = new MemberModel();
|
||||
$member_info_result = $member_model->getMemberInfo([ [ 'member_id', '=', $fenxiao_info[ 'member_id' ] ?? 0 ] ]);
|
||||
$member_info = $member_info_result[ 'data' ];
|
||||
|
||||
//绑定微信公众号才发送
|
||||
if (!empty($member_info) && !empty($member_info[ 'wx_openid' ])) {
|
||||
$wechat_model = new WechatMessage();
|
||||
$data[ 'openid' ] = $member_info[ 'wx_openid' ];
|
||||
$data[ 'template_data' ] = [
|
||||
'amount1' => $commission, // 提现金额
|
||||
'time3' => time_to_date($fenxiao_order_info[ 'create_time' ]), // 提现日期
|
||||
];
|
||||
$data[ 'page' ] = '';
|
||||
$wechat_model->sendMessage($data);
|
||||
}
|
||||
|
||||
//发送订阅消息
|
||||
if (!empty($member_info) && !empty($member_info[ 'weapp_openid' ])) {
|
||||
$weapp_model = new WeappMessage();
|
||||
$data[ 'openid' ] = $member_info[ 'weapp_openid' ];
|
||||
$data[ 'template_data' ] = [
|
||||
'amount1' => [
|
||||
'value' => $fenxiao_order_info[ 'real_goods_money' ]
|
||||
],
|
||||
'amount2' => [
|
||||
'value' => $commission
|
||||
],
|
||||
'thing3' => [
|
||||
'value' => $fenxiao_order_info[ 'sku_name' ]
|
||||
],
|
||||
'time4' => [
|
||||
'value' => time_to_date($fenxiao_order_info[ 'create_time' ]),
|
||||
],
|
||||
];
|
||||
$data[ 'page' ] = '';
|
||||
$weapp_model->sendMessage($data);
|
||||
}
|
||||
|
||||
$buyer_member = $member_model->getMemberInfo([ [ 'member_id', '=', $fenxiao_order_info[ 'member_id' ] ?? 0 ] ]);
|
||||
$buyer_member_info = $buyer_member[ 'data' ];
|
||||
|
||||
$var_parse = [
|
||||
'sitename' => replaceSpecialChar($data[ 'site_info' ][ 'site_name' ]),
|
||||
'level' => $data[ 'level' ],
|
||||
'username' => empty(replaceSpecialChar($buyer_member_info[ 'nickname' ])) ? $buyer_member_info[ 'mobile' ] : replaceSpecialChar($buyer_member_info[ 'nickname' ]),
|
||||
];
|
||||
$data[ 'sms_account' ] = $member_info[ 'mobile' ];
|
||||
$data[ 'var_parse' ] = $var_parse;
|
||||
$sms_model->sendMessage($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销提现成功通知
|
||||
* @param $data
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function messageFenxiaoWithdrawalSuccess($data)
|
||||
{
|
||||
//发送短信
|
||||
$sms_model = new Sms();
|
||||
|
||||
$var_parse = array (
|
||||
'username' => $data[ 'fenxiao_name' ],//会员名
|
||||
'money' => $data[ 'money' ]
|
||||
);
|
||||
|
||||
$data[ 'sms_account' ] = $data[ 'mobile' ];//手机号
|
||||
$data[ 'var_parse' ] = $var_parse;
|
||||
$sms_model->sendMessage($data);
|
||||
|
||||
$member_model = new MemberModel();
|
||||
$member_info_result = $member_model->getMemberInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ]);
|
||||
$member_info = $member_info_result[ 'data' ];
|
||||
|
||||
//绑定微信公众号才发送
|
||||
if (!empty($member_info) && !empty($member_info[ 'wx_openid' ])) {
|
||||
$wechat_model = new WechatMessage();
|
||||
$data[ 'openid' ] = $member_info[ 'wx_openid' ];
|
||||
$data[ 'template_data' ] = [
|
||||
'amount1' => $data[ 'money' ], // 提现金额
|
||||
'time3' => time_to_date($data[ 'payment_time' ]), // 提现日期
|
||||
];
|
||||
$data[ 'page' ] = '';
|
||||
$wechat_model->sendMessage($data);
|
||||
}
|
||||
|
||||
//发送订阅消息
|
||||
if (!empty($member_info) && !empty($member_info[ 'weapp_openid' ])) {
|
||||
$weapp_model = new WeappMessage();
|
||||
$data[ 'openid' ] = $member_info[ 'weapp_openid' ];
|
||||
$data[ 'template_data' ] = [
|
||||
'amount1' => [
|
||||
'value' => $data[ 'money' ]
|
||||
],
|
||||
'time2' => [
|
||||
'value' => time_to_date(time())
|
||||
],
|
||||
'thing3' => [
|
||||
'value' => '提现成功'
|
||||
]
|
||||
];
|
||||
$data[ 'page' ] = '';
|
||||
$weapp_model->sendMessage($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销提现失败通知
|
||||
* @param $data
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function messageFenxiaoWithdrawalError($data)
|
||||
{
|
||||
//发送短信
|
||||
$sms_model = new Sms();
|
||||
|
||||
$member_model = new MemberModel();
|
||||
$member_info_result = $member_model->getMemberInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ]);
|
||||
$member_info = $member_info_result[ 'data' ];
|
||||
|
||||
$var_parse = array (
|
||||
'fenxiaoname' => str_replace(' ', '', $data[ 'fenxiao_name' ]),//会员名
|
||||
'money' => $data[ 'money' ]
|
||||
);
|
||||
|
||||
$data[ 'sms_account' ] = $member_info[ 'mobile' ];//手机号
|
||||
$data[ 'var_parse' ] = $var_parse;
|
||||
$sms_model->sendMessage($data);
|
||||
|
||||
// 【弃用,暂无模板信息,无法使用,等待后续微信支持后开发】绑定微信公众号才发送
|
||||
// if (!empty($member_info) && !empty($member_info[ 'wx_openid' ])) {
|
||||
// $wechat_model = new WechatMessage();
|
||||
// $data[ 'openid' ] = $member_info[ 'wx_openid' ];
|
||||
// $data[ 'template_data' ] = [
|
||||
// 'keyword1' => time_to_date($data[ 'create_time' ]),
|
||||
// 'keyword2' => '审核失败',
|
||||
// 'keyword3' => '会员申请提现',
|
||||
// 'keyword4' => $data[ 'money' ],
|
||||
// ];
|
||||
// $data[ 'page' ] = '';
|
||||
// $wechat_model->sendMessage($data);
|
||||
// }
|
||||
|
||||
//发送订阅消息
|
||||
if (!empty($member_info) && !empty($member_info[ 'weapp_openid' ])) {
|
||||
$weapp_model = new WeappMessage();
|
||||
$data[ 'openid' ] = $member_info[ 'weapp_openid' ];
|
||||
$data[ 'template_data' ] = [
|
||||
'amount2' => [
|
||||
'value' => $data[ 'money' ]
|
||||
],
|
||||
'thing4' => [
|
||||
'value' => '提现审核失败'
|
||||
]
|
||||
];
|
||||
$data[ 'page' ] = '';
|
||||
$weapp_model->sendMessage($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销申请提现通知,卖家通知
|
||||
* @param $data
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function messageFenxiaoWithdrawalApply($data)
|
||||
{
|
||||
//发送短信
|
||||
$sms_model = new Sms();
|
||||
|
||||
$var_parse = array (
|
||||
'fenxiaoname' => replaceSpecialChar($data[ 'fenxiao_name' ]),//会员名
|
||||
'money' => $data[ 'money' ],//退款申请金额
|
||||
);
|
||||
// $site_id = $data['site_id'];
|
||||
// $shop_info = model('shop')->getInfo([['site_id', '=', $site_id]], 'mobile,email');
|
||||
// $message_data['sms_account'] = $shop_info['mobile'];//手机号
|
||||
$data[ 'var_parse' ] = $var_parse;
|
||||
|
||||
$shop_accept_message_model = new ShopAcceptMessage();
|
||||
$result = $shop_accept_message_model->getShopAcceptMessageList();
|
||||
$list = $result[ 'data' ];
|
||||
if (!empty($list)) {
|
||||
foreach ($list as $v) {
|
||||
$message_data = $data;
|
||||
$message_data[ 'sms_account' ] = $v[ 'mobile' ];//手机号
|
||||
$sms_model->sendMessage($message_data);
|
||||
|
||||
if ($v[ 'wx_openid' ] != '') {
|
||||
$wechat_model = new WechatMessage();
|
||||
$data[ 'openid' ] = $v[ 'wx_openid' ];
|
||||
$data[ 'template_data' ] = [
|
||||
'thing3' => replaceSpecialChar($data[ 'fenxiao_name' ]), // 客户名称
|
||||
'amount6' => $data[ 'money' ], // 提现金额
|
||||
'time8' => time_to_date($data[ 'create_time' ]) // 提现时间
|
||||
];
|
||||
$data[ 'page' ] = '';
|
||||
$wechat_model->sendMessage($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现数量
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFenxiaoWithdrawCount($condition = [], $field = '*')
|
||||
{
|
||||
$res = model('fenxiao_withdraw')->getCount($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
public function apply($data, $site_id = 0)
|
||||
{
|
||||
$config_model = new Config();
|
||||
$config = $config_model->getFenxiaoWithdrawConfig($site_id)[ 'data' ][ 'value' ] ?? [];
|
||||
|
||||
$withdraw_no = $this->createWithdrawNo();
|
||||
$apply_money = round($data[ 'apply_money' ], 2);
|
||||
|
||||
$withdraw_min_money = $config[ 'withdraw' ];
|
||||
$withdraw_max_money = $config[ 'max' ];
|
||||
if ($apply_money < $withdraw_min_money) return $this->error([], '申请提现金额不能小于最低提现额度' . $withdraw_min_money);
|
||||
if ($withdraw_max_money > 0 && $apply_money > $withdraw_max_money) return $this->error([], '申请提现金额不能大于最高提现额度' . $withdraw_max_money);
|
||||
|
||||
$member_id = $data[ 'member_id' ];
|
||||
$member_model = new Member();
|
||||
$member_condition = array (
|
||||
[ 'member_id', '=', $member_id ]
|
||||
);
|
||||
$member_info = $member_model->getMemberInfo($member_condition, 'balance_money,headimg,wx_openid,username,mobile,weapp_openid,nickname')[ 'data' ] ?? [];
|
||||
if (empty($member_info))
|
||||
return $this->error([], 'MEMBER_NOT_EXIST');
|
||||
|
||||
$fenxiao_model = new Fenxiao();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo($member_condition, 'fenxiao_id,fenxiao_name,account')[ 'data' ] ?? [];
|
||||
if (empty($fenxiao_info)) {
|
||||
return $this->error('该分销商不存在');
|
||||
}
|
||||
$fenxiao_account = $fenxiao_info[ 'account' ];//会员的分销佣金
|
||||
if ($fenxiao_account < $apply_money) {
|
||||
return $this->error('', '提现金额大于可提现金额');
|
||||
}
|
||||
|
||||
$transfer_type = $data[ 'transfer_type' ];
|
||||
$transfer_type_list = $this->getTransferType($site_id);
|
||||
$transfer_type_name = $transfer_type_list[ $transfer_type ] ?? '';
|
||||
if (empty($transfer_type_name))
|
||||
return $this->error([], '不支持的提现方式');
|
||||
|
||||
model('fenxiao_withdraw')->startTrans();
|
||||
try {
|
||||
$withdraw_rate = $config[ 'withdraw_rate' ];
|
||||
$bank_name = '';
|
||||
$account_number = '';
|
||||
$applet_type = 0;
|
||||
switch ( $transfer_type ) {
|
||||
case 'bank':
|
||||
$bank_name = $data[ 'bank_name' ];
|
||||
$account_number = $data[ 'account_number' ];
|
||||
break;
|
||||
case 'alipay':
|
||||
$bank_name = '';
|
||||
$account_number = $data[ 'account_number' ];
|
||||
break;
|
||||
case 'wechatpay':
|
||||
$bank_name = '';
|
||||
if (empty($member_info[ 'wx_openid' ]) && empty($member_info[ 'weapp_openid' ])) {
|
||||
return $this->error('', '请绑定微信或更换提现账户');
|
||||
}
|
||||
if ($data['app_type'] != 'weapp') {
|
||||
$account_number = $member_info[ 'wx_openid' ];
|
||||
$applet_type = 0; // 公众号
|
||||
} else {
|
||||
$account_number = $member_info[ 'weapp_openid' ];
|
||||
$applet_type = 1; // 小程序
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
if ($transfer_type == 'balance') {
|
||||
$withdraw_rate = 0;
|
||||
}
|
||||
$service_money = round($apply_money * $withdraw_rate / 100, 2);//手续费
|
||||
$real_money = $apply_money - $service_money;
|
||||
$data = array (
|
||||
'site_id' => $site_id,
|
||||
'withdraw_no' => $withdraw_no,
|
||||
'member_id' => $member_id,
|
||||
'fenxiao_id' => $fenxiao_info[ 'fenxiao_id' ],
|
||||
'fenxiao_name' => $fenxiao_info[ 'fenxiao_name' ],
|
||||
'transfer_type' => $transfer_type,
|
||||
'transfer_name' => $transfer_type_name,
|
||||
'money' => $apply_money,
|
||||
'withdraw_rate_money' => $service_money,
|
||||
'withdraw_rate' => $withdraw_rate,
|
||||
'real_money' => $real_money,
|
||||
'create_time' => time(),
|
||||
'status' => self::STATUS_WAIT_AUDIT,
|
||||
'status_name' => $this->status[self::STATUS_WAIT_AUDIT],
|
||||
|
||||
'member_headimg' => $member_info[ 'headimg' ],
|
||||
'realname' => $data[ 'realname' ],
|
||||
'bank_name' => $bank_name,
|
||||
'account_number' => $account_number,
|
||||
'mobile' => $data[ 'mobile' ],
|
||||
'applet_type' => $applet_type
|
||||
);
|
||||
|
||||
$result = model('fenxiao_withdraw')->add($data);
|
||||
|
||||
//添加转账记录
|
||||
$pay_transfer_model = new PayTransfer();
|
||||
$info = model('fenxiao_withdraw')->getInfo([['id', '=', $result]]);
|
||||
$pay_transfer_model->add([
|
||||
'real_name' => $info[ 'realname' ],
|
||||
'amount' => $info[ 'real_money' ],
|
||||
'desc' => '会员提现',
|
||||
'transfer_type' => $transfer_type,
|
||||
'account_number' => $info[ 'account_number' ],
|
||||
'site_id' => $info[ 'site_id' ],
|
||||
'is_weapp' => $info[ 'applet_type' ],
|
||||
'member_id' => $info[ 'member_id' ],
|
||||
'from_type' => 'fenxiao_withdraw',
|
||||
'relate_tag' => $info['id'],
|
||||
]);
|
||||
|
||||
//修改分销商提现中金额
|
||||
model('fenxiao')->setInc($member_condition, 'account_withdraw_apply', $apply_money);
|
||||
|
||||
//修改分销商可提现金额
|
||||
model('fenxiao')->setDec($member_condition, 'account', $apply_money);
|
||||
|
||||
//申请提现发送消息
|
||||
$data[ 'keywords' ] = 'FENXIAO_WITHDRAWAL_APPLY';
|
||||
$message_model = new Message();
|
||||
$message_model->sendMessage($data);
|
||||
|
||||
//判断是否需要审核
|
||||
if ($config[ 'withdraw_status' ] == 2) {//不需要
|
||||
$result = $this->agree([ 'id' => $result, 'site_id' => $site_id ]);
|
||||
if ($result[ 'code' ] < 0) {
|
||||
model('fenxiao_withdraw')->rollback();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
model('fenxiao_withdraw')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('fenxiao_withdraw')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现流水号
|
||||
*/
|
||||
private function createWithdrawNo()
|
||||
{
|
||||
$cache = Cache::get('member_withdraw_no' . time());
|
||||
if (empty($cache)) {
|
||||
Cache::set('niutk' . time(), 1000);
|
||||
$cache = Cache::get('member_withdraw_no' . time());
|
||||
} else {
|
||||
$cache = $cache + 1;
|
||||
Cache::set('member_withdraw_no' . time(), $cache);
|
||||
}
|
||||
$no = date('Ymdhis', time()) . rand(1000, 9999) . $cache;
|
||||
return $no;
|
||||
}
|
||||
|
||||
public function agree($params)
|
||||
{
|
||||
$id = $params[ 'id' ];
|
||||
$site_id = $params[ 'site_id' ];
|
||||
if (empty($site_id)) {
|
||||
return $this->error(-1, '参数错误');
|
||||
}
|
||||
$condition = array (
|
||||
[ 'id', '=', $id ],
|
||||
[ 'site_id', '=', $site_id ],
|
||||
);
|
||||
$info = model('fenxiao_withdraw')->getInfo($condition);
|
||||
|
||||
if (empty($info))
|
||||
return $this->error();
|
||||
|
||||
$config_model = new Config();
|
||||
$config = $config_model->getFenxiaoWithdrawConfig($site_id)[ 'data' ][ 'value' ] ?? [];
|
||||
|
||||
model('fenxiao_withdraw')->startTrans();
|
||||
try {
|
||||
$data = array (
|
||||
'status' => self::STATUS_WAIT_TRANSFER,
|
||||
'status_name' => $this->status[self::STATUS_WAIT_TRANSFER],//已审核待转账
|
||||
'audit_time' => time(),
|
||||
);
|
||||
$result = model('fenxiao_withdraw')->update($data, $condition);
|
||||
//是否启用自动转账(必须是微信或支付宝)
|
||||
if ($config[ 'is_auto_transfer' ] == 1) {
|
||||
$this->transfer([ 'id' => $id ]);
|
||||
}
|
||||
model('fenxiao_withdraw')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('fenxiao_withdraw')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账
|
||||
* @param $params
|
||||
* @return array|mixed|void
|
||||
*/
|
||||
public function transfer($params)
|
||||
{
|
||||
$id = $params[ 'id' ];
|
||||
$site_id = $params[ 'site_id' ] ?? 0;
|
||||
$condition = array (
|
||||
[ 'id', '=', $id ],
|
||||
);
|
||||
if ($site_id > 0) {
|
||||
$condition[] = [ 'site_id', '=', $site_id ];
|
||||
}
|
||||
$info = model('fenxiao_withdraw')->getInfo($condition);
|
||||
if (empty($info))
|
||||
return $this->error();
|
||||
$site_id = $info[ 'site_id' ];
|
||||
$transfer_type = $info[ 'transfer_type' ];
|
||||
$member_id = $info[ 'member_id' ];
|
||||
$real_money = $info[ 'real_money' ];
|
||||
if ($transfer_type == 'balance') {
|
||||
//添加会员账户流水
|
||||
$member_account = new MemberAccount();
|
||||
$member_result = $member_account->addMemberAccount($site_id, $member_id, 'balance_money', $real_money, 'fenxiao', '佣金提现', '分销佣金提现');
|
||||
if ($member_result[ 'code' ] < 0) {
|
||||
return $member_result;
|
||||
}
|
||||
return $this->transferFinish(['id' => $id, 'site_id' => $site_id]);
|
||||
} else {
|
||||
if (!in_array($transfer_type, [ 'wechatpay', 'alipay' ]))
|
||||
return $this->error('', '当前提现方式不支持在线转账');
|
||||
|
||||
$pay_transfer_model = new PayTransfer();
|
||||
$res = $pay_transfer_model->transfer('fenxiao_withdraw', $info['id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账结果通知
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function transferNotify($param)
|
||||
{
|
||||
$id = $param['relate_tag'];
|
||||
$site_id = $param['site_id'];
|
||||
$withdraw_info = model('fenxiao_withdraw')->getInfo([
|
||||
['id', '=', $id],
|
||||
['site_id', '=', $site_id],
|
||||
]);
|
||||
if(empty($withdraw_info)){
|
||||
return $this->error(null, '提现信息有误');
|
||||
}
|
||||
|
||||
//成功的处理
|
||||
switch($param['status']){
|
||||
case PayTransfer::STATUS_IN_PROCESS:
|
||||
model('fenxiao_withdraw')->update([
|
||||
'status' => self::STATUS_IN_PROCESS,
|
||||
'status_name' => $this->status[self::STATUS_IN_PROCESS],
|
||||
'modify_time' => time(),
|
||||
], [['id', '=', $withdraw_info['id']]]);
|
||||
return $this->success();
|
||||
break;
|
||||
case PayTransfer::STATUS_SUCCESS:
|
||||
//添加账户流水
|
||||
$account_model = new FenxiaoAccount();
|
||||
$account_model->addAccountLog($withdraw_info['fenxiao_id'], $withdraw_info[ 'fenxiao_name' ], 'withdraw', '-' . $withdraw_info['money'], $withdraw_info['id']);
|
||||
|
||||
return $this->transferFinish([ 'id' => $withdraw_info['id'], 'site_id' => $withdraw_info[ 'site_id' ] ]);
|
||||
break;
|
||||
case PayTransfer::STATUS_FAIL:
|
||||
$resp_data = json_decode($param['resp_data'], true);
|
||||
$fail_reason = $resp_data['fail_reason'] ?? '';
|
||||
model('fenxiao_withdraw')->update([
|
||||
'status' => self::STATUS_FAIL,
|
||||
'status_name' => $this->status[self::STATUS_FAIL],
|
||||
'fail_reason' => $fail_reason,
|
||||
'modify_time' => time(),
|
||||
], [['id', '=', $withdraw_info['id']]]);
|
||||
|
||||
//账户金额回退
|
||||
$member_condition = [['fenxiao_id', '=', $withdraw_info['fenxiao_id']]];
|
||||
$apply_money = $withdraw_info['money'];
|
||||
model('fenxiao')->setDec($member_condition, 'account_withdraw_apply', $apply_money);
|
||||
model('fenxiao')->setInc($member_condition, 'account', $apply_money);
|
||||
|
||||
return $this->success();
|
||||
break;
|
||||
default:
|
||||
return $this->error(null, '转账结果状态有误');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现转账完成
|
||||
* @param array $param
|
||||
* @return array
|
||||
*/
|
||||
public function transferFinish($param = [])
|
||||
{
|
||||
$condition = [
|
||||
[ 'id', '=', $param[ 'id' ] ],
|
||||
[ 'site_id', '=', $param[ 'site_id' ] ],
|
||||
[ 'status', 'in', [self::STATUS_WAIT_TRANSFER, self::STATUS_IN_PROCESS] ]
|
||||
];
|
||||
$info = model('fenxiao_withdraw')->getInfo($condition);
|
||||
if (empty($info)) return $this->error(null, '提现信息有误');
|
||||
|
||||
$fenxiao_id = $info[ 'fenxiao_id' ];
|
||||
$money = $info[ 'money' ];
|
||||
$payment_time = time();
|
||||
model('fenxiao_withdraw')->startTrans();
|
||||
try {
|
||||
$data = [
|
||||
'status' => self::STATUS_SUCCESS,
|
||||
'status_name' => $this->status[self::STATUS_SUCCESS],
|
||||
'payment_time' => $payment_time,
|
||||
'document' => $param[ 'certificate' ] ?? '',
|
||||
'transfer_remark' => $param[ 'certificate_remark' ] ?? ''
|
||||
];
|
||||
model('fenxiao_withdraw')->update($data, $condition);
|
||||
|
||||
$fenxiao_condition = array (
|
||||
[ 'fenxiao_id', '=', $fenxiao_id ]
|
||||
);
|
||||
//修改分销商提现中金额
|
||||
model('fenxiao')->setDec($fenxiao_condition, 'account_withdraw_apply', $money);
|
||||
//修改分销商已提现金额
|
||||
model('fenxiao')->setInc($fenxiao_condition, 'account_withdraw', $money);
|
||||
|
||||
model('fenxiao_withdraw')->commit();
|
||||
|
||||
$message_model = new Message();
|
||||
$info[ 'keywords' ] = 'FENXIAO_WITHDRAWAL_SUCCESS';
|
||||
$message_model->sendMessage($info);
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('fenxiao_withdraw')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝提现申请
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
public function refuse($params)
|
||||
{
|
||||
$id = $params[ 'id' ];
|
||||
$site_id = $params[ 'site_id' ];
|
||||
$condition = array (
|
||||
[ 'id', '=', $id ],
|
||||
[ 'site_id', '=', $site_id ]
|
||||
);
|
||||
$info = model('fenxiao_withdraw')->getInfo($condition, '*');
|
||||
if (empty($info)) return $this->error(null, '提现信息有误');
|
||||
if(!in_array($info['status'], [self::STATUS_WAIT_AUDIT, self::STATUS_WAIT_TRANSFER])){
|
||||
return $this->error(null, '提现状态有误');
|
||||
}
|
||||
|
||||
model('fenxiao_withdraw')->startTrans();
|
||||
try {
|
||||
$money = $info[ 'money' ];
|
||||
$fenxiao_id = $info[ 'fenxiao_id' ];
|
||||
$data = [
|
||||
'status' => self::STATUS_REFUSE,
|
||||
'status_name' => $this->status[self::STATUS_REFUSE],
|
||||
'refuse_reason' => $params['refuse_reason'],
|
||||
'audit_time' => time(),
|
||||
];
|
||||
model('fenxiao_withdraw')->update($data, $condition);
|
||||
$fenxiao_condition = array (
|
||||
[ 'fenxiao_id', '=', $fenxiao_id ]
|
||||
);
|
||||
//修改分销商提现中金额
|
||||
model('fenxiao')->setDec($fenxiao_condition, 'account_withdraw_apply', $money);
|
||||
|
||||
//修改分销商可提现金额
|
||||
model('fenxiao')->setInc($fenxiao_condition, 'account', $money);
|
||||
|
||||
//提现失败发送消息
|
||||
$message_model = new Message();
|
||||
$info[ 'keywords' ] = 'FENXIAO_WITHDRAWAL_ERROR';
|
||||
$message_model->sendMessage($info);
|
||||
model('fenxiao_withdraw')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('fenxiao_withdraw')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function exportFenxiaoWithdraw($condition, $order, $site_id)
|
||||
{
|
||||
try {
|
||||
$file_name = date('Y年m月d日-分销提现', time()) . '.csv';
|
||||
// $file_name = date('YmdHis').'.csv';//csv文件名
|
||||
//通过分批次执行数据导出(防止内存超出配置设置的)
|
||||
set_time_limit(0);
|
||||
ini_set('memory_limit', '256M');
|
||||
//设置header头
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename="' . $file_name . '"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
//打开php数据输入缓冲区
|
||||
$fp = fopen('php://output', 'a');
|
||||
// fwrite($fp, chr(0xEF).chr(0xBB).chr(0xBF)); // 添加 BOM
|
||||
$heade = [ '分销商', '提现方式', '申请提现金额', '提现手续费', '实际转账金额', '提现状态', '申请时间', '收款账号', '真实姓名', '手机号', '银行名称', '银行账号' ];
|
||||
//将数据编码转换成GBK格式
|
||||
mb_convert_variables('GBK', 'UTF-8', $heade);
|
||||
//将数据格式化为CSV格式并写入到output流中
|
||||
fputcsv($fp, $heade);
|
||||
$transfer_type_list = $this->getTransferType($site_id);
|
||||
$status_name = [ 1 => '待审核', 2 => '待转账', 3 => '已转账', -1 => '已拒绝', -2 => '转账失败'];
|
||||
//写入第一行表头
|
||||
Db::name('fenxiao_withdraw')->where($condition)->order($order)->chunk(500, function($item_list) use ($fp, $transfer_type_list, $status_name) {
|
||||
//写入导出信息
|
||||
foreach ($item_list as $k => $item_v) {
|
||||
$temp_data = [
|
||||
$item_v[ 'fenxiao_name' ] . "\t",
|
||||
$transfer_type_list[ $item_v[ 'transfer_type' ] ] . "\t",
|
||||
(float) $item_v[ 'money' ] . "\t",
|
||||
(float) $item_v[ 'withdraw_rate_money' ] . "\t",
|
||||
(float) $item_v[ 'real_money' ] . "\t",
|
||||
$status_name[ $item_v[ 'status' ] ] . "\t",
|
||||
time_to_date($item_v[ 'create_time' ]) . "\t",
|
||||
$item_v[ 'account_number' ] . "\t",
|
||||
$item_v[ 'realname' ] . "\t",
|
||||
$item_v[ 'mobile' ] . "\t",
|
||||
$item_v[ 'bank_name' ] . "\t",
|
||||
$item_v[ 'transfer_account_no' ] . "\t",
|
||||
];
|
||||
mb_convert_variables('GBK', 'UTF-8', $temp_data);
|
||||
fputcsv($fp, $temp_data);
|
||||
//将已经存储到csv中的变量数据销毁,释放内存
|
||||
unset($item_v);
|
||||
}
|
||||
unset($item_list);
|
||||
});
|
||||
|
||||
//关闭句柄
|
||||
fclose($fp);
|
||||
die;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->error([], $e->getMessage() . $e->getFile() . $e->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转账检测
|
||||
* @param $id
|
||||
*/
|
||||
public function transferCheck($id)
|
||||
{
|
||||
$info_result = $this->getFenxiaoWithdrawInfo([ [ "id", "=", $id ] ], "withdraw_no,account_number,realname,money,transfer_type,status");
|
||||
if (empty($info_result["data"]))
|
||||
return $this->error(null, '提现信息缺失');
|
||||
|
||||
$info = $info_result["data"];
|
||||
if(!in_array($info["transfer_type"], ["wechatpay","alipay"]))
|
||||
return $this->error('', "当前提现方式不支持在线转账");
|
||||
if($info['status'] != self::STATUS_WAIT_TRANSFER){
|
||||
return $this->error('', "当前提现单非待转账状态");
|
||||
}
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
290
addon/fenxiao/model/Poster.php
Executable file
290
addon/fenxiao/model/Poster.php
Executable file
@@ -0,0 +1,290 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use extend\Poster as PosterExtend;
|
||||
use app\model\upload\Upload;
|
||||
|
||||
/**
|
||||
* 海报生成类
|
||||
*/
|
||||
class Poster extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 获取分销海报
|
||||
* @param $param
|
||||
* @return array|\extend\multitype|PosterExtend|mixed|string|void
|
||||
*/
|
||||
public function getFenxiaoPoster($param)
|
||||
{
|
||||
$app_type = $param['app_type'] ?? 'h5';
|
||||
$qrcode_param = $param['qrcode_param'] ?? [];
|
||||
$site_id = $param['site_id'] ?? 0;
|
||||
$page = $param['page'] ?? '';
|
||||
$template_id = $param['template_id'] ?? 'default';
|
||||
|
||||
//海报信息
|
||||
if ($template_id == 'default') {
|
||||
$template_info = PosterTemplate::DEFAULT_CREATE_TEMPLATE;
|
||||
} else {
|
||||
$template_info = model('poster_template')->getInfo([
|
||||
['site_id', '=', $site_id],
|
||||
['template_type', '=', 'fenxiao'],
|
||||
['template_status', '=', 1],
|
||||
['template_id', '=', $template_id],
|
||||
]);
|
||||
if (empty($template_info)) return $this->error(null, '模板信息有误');
|
||||
$template_info['template_json'] = json_decode($template_info['template_json'], true);
|
||||
}
|
||||
//二维码信息
|
||||
$qrcode_info = $this->getQrcode($app_type, $page, $qrcode_param, $site_id);
|
||||
if ($qrcode_info['code'] < 0) return $qrcode_info;
|
||||
//会员信息
|
||||
$member_info = $this->getMemberInfo($qrcode_param['source_member']);
|
||||
if (empty($member_info)) return $this->error('未获取到会员信息');
|
||||
|
||||
$res = $this->createPoster([
|
||||
'qrcode_path' => $qrcode_info['data']['path'],
|
||||
'member_info' => $member_info,
|
||||
'template_info' => $template_info,
|
||||
'site_id' => $site_id,
|
||||
]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成海报
|
||||
*/
|
||||
public function createPoster($param)
|
||||
{
|
||||
$qrcode_path = $param['qrcode_path'];
|
||||
$template_info = $param['template_info'];
|
||||
$member_info = $param['member_info'];
|
||||
$site_id = $param['site_id'];
|
||||
|
||||
//如果有对应的数据则直接返回
|
||||
$param_md5 = $this->getPosterParamMd5($param);
|
||||
$poster_condition = [
|
||||
['site_id', '=', $site_id],
|
||||
['template_id', '=', $template_info['template_id'] ?? 0],
|
||||
['type', '=', 'fenxiao'],
|
||||
['param_md5', '=', $param_md5],
|
||||
];
|
||||
$poster_info = model('poster')->getInfo($poster_condition, 'file_path');
|
||||
if(!empty($poster_info)){
|
||||
$upload_model = new \app\model\upload\Upload();
|
||||
if($upload_model->isImageLinkValid($poster_info['file_path'])){
|
||||
return $this->success([
|
||||
'path' => $poster_info['file_path'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$params = $template_info;
|
||||
$params['background_width'] = $params['background_width'] ?? 740;
|
||||
$params['background_height'] = $params['background_height'] ?? 1250;
|
||||
$poster = new PosterExtend($params['background_width'], $params['background_height']);
|
||||
$fontRate = 0.725;
|
||||
$nickname_color = is_array($params['template_json']['nickname_color']) ? $params['template_json']['nickname_color'] : hex2rgb($params['template_json']['nickname_color']);
|
||||
//外网图片无法制作海报 本地化处理
|
||||
if (strpos($params['background'], "http") !== false) {
|
||||
$params['background'] = $this->createTempImage($params['background']);
|
||||
$temp_background = $params['background'];
|
||||
}
|
||||
if (strpos($member_info['headimg'], "http") !== false) {
|
||||
$member_info['headimg'] = $this->createTempImage($member_info['headimg']);
|
||||
$temp_headimg = $member_info['headimg'];
|
||||
}
|
||||
$option = [
|
||||
[
|
||||
'action' => 'imageCopy', // 写入背景图
|
||||
'data' => [
|
||||
img($params['background']),
|
||||
0,
|
||||
0,
|
||||
$params['background_width'],
|
||||
$params['background_height'],
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 写入二维码
|
||||
'data' => [
|
||||
$qrcode_path,
|
||||
(int)$params['qrcode_left'] * 2,
|
||||
(int)$params['qrcode_top'] * 2,
|
||||
(int)$params['qrcode_width'] * 2,
|
||||
(int)$params['qrcode_height'] * 2,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入分享语
|
||||
'data' => [
|
||||
$params['template_json']['share_content'],
|
||||
$params['template_json']['share_content_font_size'] * $fontRate * 2,
|
||||
is_array($params['template_json']['share_content_color']) ? $params['template_json']['share_content_color'] : hex2rgb($params['template_json']['share_content_color']),
|
||||
$params['template_json']['share_content_left'] * 2,
|
||||
($params['template_json']['share_content_top'] + $params['template_json']['share_content_font_size']) * 2,
|
||||
$params['template_json']['share_content_width'] * 2,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 写入用户头像
|
||||
'data' => [
|
||||
!empty($member_info['headimg']) ? img($member_info['headimg']) : img('public/static/img/default_img/head.png'),
|
||||
$params['template_json']['headimg_left'] * 2,
|
||||
$params['template_json']['headimg_top'] * 2,
|
||||
$params['template_json']['headimg_width'] * 2,
|
||||
$params['template_json']['headimg_height'] * 2,
|
||||
!empty($params['template_json']['headimg_shape']) ? $params['template_json']['headimg_shape'] : 'square',
|
||||
0,
|
||||
$params['template_json']['headimg_is_show']
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入分享人昵称
|
||||
'data' => [
|
||||
$member_info['nickname'],
|
||||
$params['template_json']['nickname_font_size'] * $fontRate * 2,
|
||||
$nickname_color,
|
||||
$params['template_json']['nickname_left'] * 2,
|
||||
($params['template_json']['nickname_top'] + $params['template_json']['nickname_font_size']) * 2,
|
||||
$params['template_json']['nickname_width'] * 2,
|
||||
1,
|
||||
true,
|
||||
$params['template_json']['nickname_is_show']
|
||||
]
|
||||
],
|
||||
];
|
||||
$option_res = $poster->create($option);
|
||||
if (is_array($option_res)) return $option_res;
|
||||
|
||||
$poster_dir = 'upload/poster/distribution';
|
||||
$res = $option_res->jpeg($poster_dir, $param_md5);
|
||||
|
||||
//删除本地临时生成文件。
|
||||
if (isset($temp_background)) unlink($temp_background);
|
||||
if (isset($temp_headimg)) unlink($temp_headimg);
|
||||
|
||||
$file_path = $res['data']['path'];
|
||||
if ($res['code'] == 0) {
|
||||
$upload = new Upload($site_id);
|
||||
$cloud_res = $upload->fileCloud($file_path);
|
||||
if ($cloud_res['code'] >= 0) {
|
||||
$file_path = $cloud_res['data'];
|
||||
}
|
||||
}
|
||||
|
||||
//添加或更新记录
|
||||
if(empty($poster_info)){
|
||||
model('poster')->add([
|
||||
'site_id' => $site_id,
|
||||
'template_id' => $template_info['template_id'] ?? 0,
|
||||
'type' => 'fenxiao',
|
||||
'file_path' => $file_path,
|
||||
'param_md5' => $param_md5,
|
||||
]);
|
||||
}else{
|
||||
model('poster')->update([
|
||||
'file_path' => $file_path,
|
||||
], $poster_condition);
|
||||
}
|
||||
|
||||
return $this->success(["path" => $file_path]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage() . $e->getFile() . $e->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成临时图片
|
||||
* @param $file_path
|
||||
* @return string
|
||||
*/
|
||||
public function createTempImage($file_path)
|
||||
{
|
||||
$temp_dir = "upload/fenxiao_poster/temp/";
|
||||
if (!is_dir($temp_dir)) mkdir($temp_dir, 0777, true);
|
||||
$upload_model = new \app\model\upload\Upload();
|
||||
$image_content = $upload_model->curlGetFile($file_path);
|
||||
$image_ext = $upload_model->getFileExt($file_path, 'png');
|
||||
$temp_file = $temp_dir . uniqid() . ".".$image_ext;
|
||||
file_put_contents($temp_file, $image_content);
|
||||
return $temp_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海报名称
|
||||
* @param $param
|
||||
* @return string
|
||||
*/
|
||||
public function getPosterParamMd5($param)
|
||||
{
|
||||
$qrcode_path = $param['qrcode_path'];
|
||||
$template_info = $param['template_info'];
|
||||
$member_info = $param['member_info'];
|
||||
|
||||
$params = $template_info;
|
||||
$data = [
|
||||
$qrcode_path,
|
||||
$params['background'],
|
||||
$params['qrcode_left'],
|
||||
$params['qrcode_left'],
|
||||
$params['qrcode_top'],
|
||||
$params['qrcode_width'],
|
||||
$params['qrcode_height'],
|
||||
$params['template_json'],
|
||||
$member_info['headimg'],
|
||||
$member_info['nickname'],
|
||||
];
|
||||
return md5(json_encode($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @param $member_id
|
||||
* @return mixed
|
||||
*/
|
||||
private function getMemberInfo($member_id)
|
||||
{
|
||||
$info = model('member')->getInfo(['member_id' => $member_id], 'nickname,headimg');
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取二维码
|
||||
* @param unknown $app_type 请求类型
|
||||
* @param unknown $page uniapp页面路径
|
||||
* @param unknown $qrcode_param 二维码携带参数
|
||||
* @param string $promotion_type 活动类型 null为无活动
|
||||
*/
|
||||
private function getQrcode($app_type, $page, $qrcode_param, $site_id)
|
||||
{
|
||||
$res = event('Qrcode', [
|
||||
'site_id' => $site_id,
|
||||
'app_type' => $app_type,
|
||||
'type' => 'get',
|
||||
'data' => $qrcode_param,
|
||||
'page' => $page,
|
||||
'qrcode_path' => 'upload/qrcode/distribution',
|
||||
'qrcode_name' => 'distribution' . '_' . $qrcode_param['source_member'] . '_' . $site_id,
|
||||
], true);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
218
addon/fenxiao/model/PosterTemplate.php
Executable file
218
addon/fenxiao/model/PosterTemplate.php
Executable file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 海报模板
|
||||
*/
|
||||
class PosterTemplate extends BaseModel
|
||||
{
|
||||
//默认模板数据
|
||||
const DEFAULT_TEMPLATE = [
|
||||
'template_id' => 0,
|
||||
'template_type' => 'fenxiao',
|
||||
'poster_name' => '',
|
||||
'background' => '',
|
||||
//二维码
|
||||
'qrcode_type' => '',
|
||||
'qrcode_width' => 80,
|
||||
'qrcode_height' => 80,
|
||||
'qrcode_top' => 540,
|
||||
'qrcode_left' => 260,
|
||||
//json数据
|
||||
'template_json' => [
|
||||
//头像
|
||||
'headimg_is_show' => 1,
|
||||
'headimg_shape' => 'circle',
|
||||
'headimg_width' => 56,
|
||||
'headimg_height' => 56,
|
||||
'headimg_top' => 426,
|
||||
'headimg_left' => 41,
|
||||
//昵称
|
||||
'nickname_is_show' => 1,
|
||||
'nickname_font_size' => 22,
|
||||
'nickname_color' => '#faa87a',
|
||||
'nickname_width' => 150,
|
||||
'nickname_height' => 30,
|
||||
'nickname_top' => 515,
|
||||
'nickname_left' => 20,
|
||||
//分享语
|
||||
'share_content' => '邀您一起分享赚佣金',
|
||||
'share_content_is_show' => 1,
|
||||
'share_content_font_size' => 14,
|
||||
'share_content_color' => '#8D8D8D',
|
||||
'share_content_width' => 130,
|
||||
'share_content_height' => 30,
|
||||
'share_content_top' => 550,
|
||||
'share_content_left' => 20,
|
||||
]
|
||||
];
|
||||
|
||||
//默认模板数据
|
||||
const DEFAULT_CREATE_TEMPLATE = [
|
||||
'template_id' => 0,
|
||||
'template_type' => 'fenxiao',
|
||||
'poster_name' => '',
|
||||
'background' => 'upload/poster/bg/fenxiao_2.png',
|
||||
'background_width' => 720,
|
||||
'background_height' => 1280,
|
||||
//二维码
|
||||
'qrcode_type' => '',
|
||||
'qrcode_width' => 75,
|
||||
'qrcode_height' => 75,
|
||||
'qrcode_top' => 517.5,
|
||||
'qrcode_left' => 246,
|
||||
//json数据
|
||||
'template_json' => [
|
||||
//头像
|
||||
'headimg_is_show' => 1,
|
||||
'headimg_shape' => 'circle',
|
||||
'headimg_width' => 50,
|
||||
'headimg_height' => 50,
|
||||
'headimg_top' => 510,
|
||||
'headimg_left' => 32.5,
|
||||
//昵称
|
||||
'nickname_is_show' => 1,
|
||||
'nickname_font_size' => 11 / 0.725,
|
||||
'nickname_color' => [255, 129, 61],
|
||||
'nickname_width' => 150,
|
||||
'nickname_height' => 30,
|
||||
'nickname_top' => 530 - 11 / 0.725,
|
||||
'nickname_left' => 90,
|
||||
//分享语
|
||||
'share_content' => '',
|
||||
'share_content_is_show' => 1,
|
||||
'share_content_font_size' => 14,
|
||||
'share_content_color' => '#8D8D8D',
|
||||
'share_content_width' => 130,
|
||||
'share_content_height' => 30,
|
||||
'share_content_top' => 550,
|
||||
'share_content_left' => 20,
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* 添加海报模板
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function addPosterTemplate($data)
|
||||
{
|
||||
$res = model('poster_template')->add($data);
|
||||
if ($res === false) {
|
||||
return $this->error('', 'RESULT_ERROR');
|
||||
}
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑海报模板
|
||||
* @param $data
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function editPosterTemplate($data, $condition)
|
||||
{
|
||||
$res = model('poster_template')->update($data, $condition);
|
||||
if ($res === false) {
|
||||
return $this->error('', 'SAVE_FAIL');
|
||||
}
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除海报模板
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function deletePosterTemplate($condition)
|
||||
{
|
||||
$res = model('poster_template')->delete($condition);
|
||||
if ($res === false) {
|
||||
return $this->error('', 'RESULT_ERROR');
|
||||
}
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海报模板信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getPosterTemplateInfo($condition = [], $field = '*')
|
||||
{
|
||||
$info = model('poster_template')->getInfo($condition, $field);
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海报模板列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getPosterTemplateList($condition = [], $field = '*', $order = 'create_time desc')
|
||||
{
|
||||
$list = model('poster_template')->getList($condition, $field, $order);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海报模板分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @return array
|
||||
*/
|
||||
public function getPosterTemplatePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $field = '*', $order = 'create_time desc')
|
||||
{
|
||||
$list = model('poster_template')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对之前的数据做兼容处理
|
||||
* @param $template_json
|
||||
* @return array
|
||||
*/
|
||||
public function correctTemplateJsonData($template_json)
|
||||
{
|
||||
//兼容处理
|
||||
if (!isset($template_json[ 'share_content_is_show' ])) $template_json[ 'share_content_is_show' ] = 1;
|
||||
if (!isset($template_json[ 'share_content_font_size' ])) $template_json[ 'share_content_font_size' ] = 14;
|
||||
if (!isset($template_json[ 'share_content_color' ])) $template_json[ 'share_content_color' ] = '#8D8D8D';
|
||||
return $this->success($template_json);
|
||||
}
|
||||
|
||||
/*************************** 模板默认数据 ********************************/
|
||||
|
||||
public function getMubanInfo($condition = [], $field = '*', $alias = 'a', $join = [])
|
||||
{
|
||||
$list = model('poster_muban')->getInfo($condition, $field, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
public function getMubanList($condition = [], $field = '*')
|
||||
{
|
||||
$list = model('poster_muban')->getList($condition, $field);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
}
|
||||
114
addon/fenxiao/model/share/WchatShare.php
Executable file
114
addon/fenxiao/model/share/WchatShare.php
Executable file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model\share;
|
||||
|
||||
use app\model\share\WchatShareBase as BaseModel;
|
||||
use app\model\member\Member as MemberModel;
|
||||
use app\model\system\Site as SiteModel;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*/
|
||||
class WchatShare extends BaseModel
|
||||
{
|
||||
protected $config = [
|
||||
[
|
||||
'title' => '分销推广',
|
||||
'config_key' => 'WCHAT_SHARE_CONFIG_FENXIAO_PROMOTE',
|
||||
'path' => [ '/pages_promotion/fenxiao/promote_code' ],
|
||||
'method_prefix' => 'promote',
|
||||
],
|
||||
];
|
||||
|
||||
protected $sort = 3;
|
||||
|
||||
/**
|
||||
* 推广分享数据
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function promoteShareData($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ] ?? 0;
|
||||
$member_id = $param[ 'member_id' ] ?? 0;
|
||||
$param[ 'url' ] = str_replace("/pages_promotion/fenxiao/promote_code", "/pages/index/index", $param[ 'url' ]);
|
||||
if (strpos($param[ 'url' ], '?')) $param[ 'url' ] = explode('?', $param[ 'url' ])[ 0 ];
|
||||
|
||||
//站点设置
|
||||
$site_model = new SiteModel();
|
||||
$site_info = $site_model->getSiteInfo([ [ 'site_id', '=', $site_id ] ])[ 'data' ];
|
||||
|
||||
//跳转路径
|
||||
$link = $this->getShareLink($param);
|
||||
|
||||
//会员信息
|
||||
$member_model = new MemberModel();
|
||||
$member_info = $member_model->getMemberInfo([ [ 'member_id', '=', $member_id ] ], 'nickname, headimg')[ 'data' ];
|
||||
|
||||
//获取和替换配置数据
|
||||
$config_data = $this->promoteShareConfig($param);
|
||||
$title = str_replace('{nickname}', $member_info[ 'nickname' ], $config_data[ 'value' ][ 'title' ]);
|
||||
$desc = str_replace('{nickname}', $member_info[ 'nickname' ], $config_data[ 'value' ][ 'desc' ]);
|
||||
$image_url = $config_data[ 'value' ][ 'imgUrl' ] ?: $site_info[ 'logo_square' ];
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'desc' => $desc,
|
||||
'link' => $link,
|
||||
'imgUrl' => $image_url,
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'hideOptionMenu' => false,
|
||||
'hideMenuItems' => [],
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 推广分享配置
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function promoteShareConfig($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ];
|
||||
$config = $param[ 'config' ];
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$data = $config_model->getConfig([
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'app_module', '=', 'shop' ],
|
||||
[ 'config_key', '=', $config[ 'config_key' ] ],
|
||||
])[ 'data' ];
|
||||
if (empty($data[ 'value' ])) {
|
||||
$data[ 'value' ] = [
|
||||
'title' => "快来加入{nickname}的团队吧,一起赚佣金哦",
|
||||
'desc' => "好物精选\n向您推荐",
|
||||
'imgUrl' => '',
|
||||
];
|
||||
}
|
||||
if (empty($data[ 'value' ][ 'imgUrl' ])) {
|
||||
$data[ 'value' ][ 'imgUrl' ] = img('addon/fenxiao/icon.png');
|
||||
}
|
||||
$variable = [
|
||||
[ 'title' => '用户昵称', 'name' => '{nickname}' ],
|
||||
];
|
||||
|
||||
return [
|
||||
'value' => $data[ 'value' ],
|
||||
'variable' => $variable,
|
||||
];
|
||||
}
|
||||
}
|
||||
100
addon/fenxiao/model/share/WeappShare.php
Executable file
100
addon/fenxiao/model/share/WeappShare.php
Executable file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\model\share;
|
||||
|
||||
use app\model\member\Member as MemberModel;
|
||||
use app\model\share\WeappShareBase as BaseModel;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*/
|
||||
class WeappShare extends BaseModel
|
||||
{
|
||||
protected $config = [
|
||||
[
|
||||
'title' => '分销推广',
|
||||
'config_key' => 'WEAPP_SHARE_CONFIG_FENXIAO_PROMOTE',
|
||||
'path' => [ '/pages_promotion/fenxiao/promote_code' ],
|
||||
'method_prefix' => 'promote',
|
||||
],
|
||||
];
|
||||
|
||||
protected $sort = 2;
|
||||
|
||||
/**
|
||||
* 首页分享数据
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function promoteShareData($param)
|
||||
{
|
||||
$member_id = $param[ 'member_id' ] ?? 0;
|
||||
$param[ 'path' ] = str_replace("/pages_promotion/fenxiao/promote_code", "/pages/index/index", $param[ 'path' ]);
|
||||
if (strpos($param[ 'path' ], '?')) $param[ 'path' ] = explode('?', $param[ 'path' ])[ 0 ];
|
||||
|
||||
//会员信息
|
||||
$member_model = new MemberModel();
|
||||
$member_info = $member_model->getMemberInfo([ [ 'member_id', '=', $member_id ] ], 'nickname, headimg')[ 'data' ];
|
||||
|
||||
//获取和替换配置数据
|
||||
$config_data = $this->promoteShareConfig($param);
|
||||
$title = str_replace('{nickname}', $member_info[ 'nickname' ], $config_data[ 'value' ][ 'title' ]);
|
||||
$image_url = $config_data[ 'value' ][ 'imageUrl' ] ? img($config_data[ 'value' ][ 'imageUrl' ]) : '';
|
||||
$path = $this->getSharePath($param);
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'path' => $path,
|
||||
'imageUrl' => $image_url,
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'onShareAppMessage' => true,
|
||||
'onShareTimeline' => true,
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页分享配置
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function promoteShareConfig($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ];
|
||||
$config = $param[ 'config' ];
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$data = $config_model->getConfig([
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'app_module', '=', 'shop' ],
|
||||
[ 'config_key', '=', $config[ 'config_key' ] ],
|
||||
])[ 'data' ];
|
||||
if (empty($data[ 'value' ])) {
|
||||
$data[ 'value' ] = [
|
||||
'title' => '快来加入{nickname}的团队吧,一起赚有佣金哦',
|
||||
'imageUrl' => '',
|
||||
];
|
||||
}
|
||||
$variable = [
|
||||
[ 'title' => '用户昵称', 'name' => '{nickname}' ],
|
||||
];
|
||||
|
||||
return [
|
||||
'value' => $data[ 'value' ],
|
||||
'variable' => $variable,
|
||||
];
|
||||
}
|
||||
}
|
||||
198
addon/fenxiao/shop/controller/Config.php
Executable file
198
addon/fenxiao/shop/controller/Config.php
Executable file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\shop\controller;
|
||||
|
||||
use addon\fenxiao\model\Config as ConfigModel;
|
||||
use addon\fenxiao\model\FenxiaoLevel as FenxiaoLevelModel;
|
||||
use addon\fenxiao\model\FenxiaoWithdraw;
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
use app\model\system\Document;
|
||||
use app\shop\controller\BaseShop;
|
||||
|
||||
/**
|
||||
* 分销设置
|
||||
*/
|
||||
class Config extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 分销基础设置
|
||||
*/
|
||||
public function basics()
|
||||
{
|
||||
$model = new ConfigModel();
|
||||
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'level' => input('level', ''),//分销层级
|
||||
'internal_buy' => input('internal_buy', ''),//分销内购
|
||||
'is_examine' => input('is_examine', ''),//是否需要审核(0关闭 1开启)
|
||||
'self_purchase_rebate' => input('self_purchase_rebate', ''),//是否开启分销商自购返佣(0关闭 1开启)
|
||||
'fenxiao_condition' => input('fenxiao_condition', ''),//成为分销商条件(0无条件 1申请 2消费次数 3消费金额 4购买指定商品)
|
||||
'consume_count' => input('consume_count', ''),//消费次数
|
||||
'consume_money' => input('consume_money', ''), //消费金额
|
||||
'goods_ids' => input('goods_ids', ''), //指定商品id
|
||||
'consume_condition' => input('consume_condition', ''),//消费条件(1付款后 2订单完成)
|
||||
'perfect_info' => input('perfect_info', ''),//完善资料
|
||||
'child_condition' => input('child_condition', ''),//成为下线条件
|
||||
'is_apply' => input('is_apply', ''),//是否开启分销申请(0关闭 1开启)
|
||||
'is_commission_money' => input('is_commission_money', ''),//是否开启商品详情一级佣金(0关闭 1开启)
|
||||
'one_rate' => input('one_rate', 0.00),
|
||||
'two_rate' => input('two_rate', 0.00),
|
||||
'three_rate' => input('three_rate', 0.00),
|
||||
];
|
||||
|
||||
$res = $model->setFenxiaoBasicsConfig($data, 1, $this->site_id);
|
||||
return $res;
|
||||
} else {
|
||||
$basics = $model->getFenxiaoBasicsConfig($this->site_id);
|
||||
$this->assign('basics_info', $basics[ 'data' ][ 'value' ]);
|
||||
|
||||
$fenxiao = $model->getFenxiaoConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
|
||||
$fenxiao[ 'goods_list' ] = '';
|
||||
if ($fenxiao[ 'fenxiao_condition' ] == 4) { // 购买指定商品
|
||||
$goods_model = new GoodsModel();
|
||||
$condition[] = [ 'goods_id', 'in', $fenxiao[ 'goods_ids' ] ];
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$fenxiao[ 'goods_list' ] = $goods_model->getGoodsList($condition, 'goods_id,goods_name,goods_image,price,goods_stock')[ 'data' ];
|
||||
}
|
||||
$this->assign('fenxiao_info', $fenxiao);
|
||||
|
||||
$relation = $model->getFenxiaoRelationConfig($this->site_id);
|
||||
$this->assign('relation_info', $relation[ 'data' ][ 'value' ]);
|
||||
|
||||
$level_model = new FenxiaoLevelModel();
|
||||
$level_info = $level_model->getLevelInfo([ [ 'site_id', '=', $this->site_id ], [ 'is_default', '=', 1 ] ], 'one_rate,two_rate,three_rate')[ 'data' ];
|
||||
$this->assign('level', $level_info);
|
||||
|
||||
return $this->fetch('config/basics');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销协议设置
|
||||
*/
|
||||
public function agreement()
|
||||
{
|
||||
$model = new ConfigModel();
|
||||
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'is_agreement' => input('is_agreement', ''),//是否显示申请协议
|
||||
'agreement_title' => input('agreement_title', ''),//协议标题
|
||||
'agreement_content' => input('agreement_content', ''),//协议内容
|
||||
'img' => input('img', ''),//申请页面顶部图片
|
||||
];
|
||||
$res = $model->setFenxiaoAgreementConfig($data, 1, $this->site_id);
|
||||
return $res;
|
||||
} else {
|
||||
$agreement = $model->getFenxiaoAgreementConfig($this->site_id);
|
||||
$this->assign('agreement_info', $agreement[ 'data' ][ 'value' ]);
|
||||
|
||||
$document_model = new Document();
|
||||
$document = $document_model->getDocument([ [ 'site_id', '=', $this->site_id ], [ 'app_module', '=', 'shop' ], [ 'document_key', '=', 'FENXIAO_AGREEMENT'] ]);
|
||||
$this->assign('document', $document[ 'data' ]);
|
||||
|
||||
return $this->fetch('config/agreement');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销结算设置
|
||||
*/
|
||||
public function settlement()
|
||||
{
|
||||
$model = new ConfigModel();
|
||||
if (request()->isJson()) {
|
||||
$transfer_type = '';
|
||||
if (!empty(input('transfer_type'))) {
|
||||
$transfer_type = implode(',', input('transfer_type'));
|
||||
}
|
||||
$data = [
|
||||
'account_type' => input('account_type', ''),//佣金计算方式
|
||||
'settlement_day' => input('settlement_day', ''),//天数
|
||||
'withdraw' => input('withdraw', ''),//最低提现额度
|
||||
'withdraw_rate' => input('withdraw_rate', ''),//佣金提现手续费
|
||||
// 'min_no_fee' => input('min_no_fee', ''),//最低免手续费区间
|
||||
// 'max_no_fee' => input('max_no_fee', ''),//最高免手续费区间
|
||||
'withdraw_status' => input('withdraw_status', ''),//提现审核
|
||||
'withdraw_type' => input('withdraw_type', ''),//提现方式,
|
||||
|
||||
'transfer_type' => $transfer_type,//转账方式,
|
||||
'is_auto_transfer' => input('is_auto_transfer', 0),//是否自动转账 1 手动转账 2 自动转账
|
||||
// 'min' => input('min', 0),//提现最低额度
|
||||
'max' => input('max', 0),//提现最高额度
|
||||
];
|
||||
$res = $model->setFenxiaoSettlementConfig($data, 1, $this->site_id);
|
||||
return $res;
|
||||
} else {
|
||||
// $settlement = $model->getFenxiaoSettlementConfig($this->site_id);
|
||||
// $this->assign('settlement_info', $settlement[ 'data' ][ 'value' ]);
|
||||
$withdraw_config = $model->getFenxiaoWithdrawConfig($this->site_id)[ 'data' ][ 'value' ] ?? [];
|
||||
$this->assign('withdraw_info', $withdraw_config);
|
||||
|
||||
$fenxiao_withdraw_model = new FenxiaoWithdraw();
|
||||
$transfer_type_list = $fenxiao_withdraw_model->getTransferType($this->site_id);
|
||||
$transfer_type_list[ 'balance' ] = '余额';
|
||||
$this->assign('transfer_type_list', $transfer_type_list);
|
||||
|
||||
return $this->fetch('config/settlement');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销文字设置
|
||||
*/
|
||||
public function words()
|
||||
{
|
||||
$model = new ConfigModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'concept' => input('concept', ''),//分销概念
|
||||
'fenxiao_name' => input('fenxiao_name', ''),//分销商名称
|
||||
'withdraw' => input('withdraw', ''),//提现名称
|
||||
'account' => input('account', ''),//佣金
|
||||
'my_team' => input('my_team', ''),//我的团队
|
||||
'child' => input('child', ''),//下线
|
||||
];
|
||||
|
||||
$res = $model->setFenxiaoWordsConfig($data, 1, $this->site_id);
|
||||
return $res;
|
||||
} else {
|
||||
$config_info = $model->getFenxiaoWordsConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('config_info', $config_info);
|
||||
|
||||
return $this->fetch('config/words');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动规则
|
||||
*/
|
||||
public function promoteRule()
|
||||
{
|
||||
$document_model = new Document();
|
||||
if (request()->isJson()) {
|
||||
$content = input('content', '');
|
||||
$res = $document_model->setDocument('分销推广规则', $content, [ [ 'site_id', '=', $this->site_id ], [ 'app_module', '=', 'shop' ], [ 'document_key', '=', 'FENXIAO_PROMOTE_RULE'] ]);
|
||||
return $res;
|
||||
} else {
|
||||
$document = $document_model->getDocument([ [ 'site_id', '=', $this->site_id ], [ 'app_module', '=', 'shop' ], [ 'document_key', '=', 'FENXIAO_PROMOTE_RULE'] ]);
|
||||
$this->assign('document', $document[ 'data' ]);
|
||||
|
||||
return $this->fetch('config/promote_rule');
|
||||
}
|
||||
}
|
||||
}
|
||||
695
addon/fenxiao/shop/controller/Fenxiao.php
Executable file
695
addon/fenxiao/shop/controller/Fenxiao.php
Executable file
@@ -0,0 +1,695 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\shop\controller;
|
||||
|
||||
use addon\fenxiao\model\Config as ConfigModel;
|
||||
use addon\fenxiao\model\Fenxiao as FenxiaoModel;
|
||||
use addon\fenxiao\model\FenxiaoAccount;
|
||||
use addon\fenxiao\model\FenxiaoApply;
|
||||
use addon\fenxiao\model\FenxiaoData;
|
||||
use addon\fenxiao\model\FenxiaoLevel as FenxiaoLevelModel;
|
||||
use addon\fenxiao\model\FenxiaoOrder as FenxiaoOrderModel;
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
use app\model\member\Member as MemberModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* 分销设置
|
||||
*/
|
||||
class Fenxiao extends BaseShop
|
||||
{
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
$this->replace = [
|
||||
'FENXIAO_JS' => __ROOT__ . '/addon/fenxiao/shop/view/public/js',
|
||||
'FENXIAO_CSS' => __ROOT__ . '/addon/fenxiao/shop/view/public/css'
|
||||
];
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销概况
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->fetch('fenxiao/index');
|
||||
}
|
||||
|
||||
public function stat()
|
||||
{
|
||||
$data = [
|
||||
'account_data' => [],
|
||||
'fenxiao_account' => 0.00,
|
||||
'shop_commission' => [],
|
||||
'shop_commission_end' => [],
|
||||
'commission_money' => 0.00,
|
||||
'fenxiao_apply_num' => 0,
|
||||
'fenxiao_num' => 0,
|
||||
'fenxiao_goods_num' => 0
|
||||
];
|
||||
|
||||
$fenxiao_data_model = new FenxiaoData();
|
||||
$account_data = $fenxiao_data_model->getFenxiaoAccountData($this->site_id);
|
||||
$data['account_data'] = $account_data;
|
||||
|
||||
//累计佣金
|
||||
$fenxiao_account = number_format($account_data[ 'account' ], 2, '.', '');
|
||||
$data['fenxiao_account'] = $fenxiao_account;
|
||||
|
||||
//获取分销的总金额
|
||||
$order_model = new FenxiaoOrderModel();
|
||||
$commission = $order_model->getFenxiaoOrderInfo([ [ 'site_id', '=', $this->site_id ] ], 'sum(real_goods_money) as real_goods_money,sum(commission) as commission')[ 'data' ];
|
||||
if ($commission[ 'real_goods_money' ] == null) {
|
||||
$commission[ 'real_goods_money' ] = '0.00';
|
||||
}
|
||||
if ($commission[ 'commission' ] == null) {
|
||||
$commission[ 'commission' ] = '0.00';
|
||||
}
|
||||
$data['shop_commission'] = $commission;
|
||||
|
||||
//获取已结算分销的总金额
|
||||
$commission_end = $order_model->getFenxiaoOrderInfo([ [ 'site_id', '=', $this->site_id ], [ 'is_settlement', '=', 1 ], [ 'is_refund', '=', 0 ] ], 'sum(real_goods_money) as real_goods_money,sum(commission) as commission')[ 'data' ];
|
||||
if ($commission_end[ 'real_goods_money' ] == null) {
|
||||
$commission_end[ 'real_goods_money' ] = '0.00';
|
||||
}
|
||||
if ($commission_end[ 'commission' ] == null) {
|
||||
$commission_end[ 'commission' ] = '0.00';
|
||||
}
|
||||
$data['shop_commission_end'] = $commission_end;
|
||||
|
||||
//获取已退款的佣金
|
||||
$commission_refund = $order_model->getFenxiaoOrderInfo([ [ 'site_id', '=', $this->site_id ], [ 'is_refund', '=', 1 ] ], 'sum(real_goods_money) as real_goods_money,sum(commission) as commission')[ 'data' ];
|
||||
if ($commission_refund[ 'real_goods_money' ] == null) {
|
||||
$commission_refund[ 'real_goods_money' ] = '0.00';
|
||||
}
|
||||
if ($commission_refund[ 'commission' ] == null) {
|
||||
$commission_refund[ 'commission' ] = '0.00';
|
||||
}
|
||||
$commission_money = round($commission[ 'commission' ], 2) - round($commission_end[ 'commission' ], 2) - round($commission_refund[ 'commission' ], 2);
|
||||
$commission_money = number_format($commission_money, 2);
|
||||
$data['commission_money'] = $commission_money;
|
||||
|
||||
$fenxiao_apply_num = $fenxiao_data_model->getFenxiaoApplyCount($this->site_id);
|
||||
$data['fenxiao_apply_num'] = $fenxiao_apply_num;
|
||||
|
||||
//分销商人数
|
||||
$fenxiao_num = $fenxiao_data_model->getFenxiaoCount($this->site_id);
|
||||
$data['fenxiao_num'] = $fenxiao_num;
|
||||
|
||||
$goods_model = new GoodsModel();
|
||||
$fenxiao_goods_num = $goods_model->getGoodsInfo([ [ 'site_id', '=', $this->site_id ], [ 'is_fenxiao', '=', 1 ], [ 'is_delete', '=', 0 ] ], 'count(goods_id) as fenxiao_goods_num')[ 'data' ];
|
||||
$data['fenxiao_goods_num'] = $fenxiao_goods_num[ 'fenxiao_goods_num' ];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销商列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$model = new FenxiaoModel();
|
||||
if (request()->isJson()) {
|
||||
|
||||
$condition[] = [ 'f.site_id', '=', $this->site_id ];
|
||||
$fenxiao_name = input('fenxiao_name', '');
|
||||
$nickname = input('nickname', '');
|
||||
$mobile = input('mobile', '');
|
||||
$parent_name = input('parent_name', '');
|
||||
$level_id = input('level_id', '');
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$status = input('status', '');
|
||||
|
||||
if ($fenxiao_name) {
|
||||
$condition[] = [ 'f.fenxiao_name', 'like', '%' . $fenxiao_name . '%' ];
|
||||
}
|
||||
if ($nickname) {
|
||||
$condition[] = [ 'm.nickname', 'like', '%' . $nickname . '%' ];
|
||||
}
|
||||
if ($mobile) {
|
||||
$condition[] = [ 'm.mobile', 'like', '%' . $mobile . '%' ];
|
||||
}
|
||||
|
||||
if ($parent_name) {
|
||||
$condition[] = [ 'pf.fenxiao_name', 'like', '%' . $parent_name . '%' ];
|
||||
}
|
||||
|
||||
if ($level_id) {
|
||||
$condition[] = [ 'f.level_id', '=', $level_id ];
|
||||
}
|
||||
if ($start_time && $end_time) {
|
||||
$condition[] = [ 'f.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'f.create_time', '<=', date_to_time($end_time) ];
|
||||
|
||||
} elseif ($start_time && !$end_time) {
|
||||
$condition[] = [ 'f.create_time', '>=', date_to_time($start_time) ];
|
||||
}
|
||||
|
||||
if (!empty($status)) {
|
||||
$condition[] = [ 'f.status', '=', $status ];
|
||||
}
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$list = $model->getFenxiaoPageList($condition, $page, $page_size, 'f.create_time desc', $this->site_id);
|
||||
return $list;
|
||||
|
||||
} else {
|
||||
$level_model = new FenxiaoLevelModel();
|
||||
$level_list = $level_model->getLevelList([ [ 'status', '=', 1 ], [ 'site_id', '=', $this->site_id ] ], 'level_id,level_name')[ 'data' ];
|
||||
$this->assign('level_list', $level_list);
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$basics = $config_model->getFenxiaoBasicsConfig($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign('basics_info', $basics);
|
||||
|
||||
|
||||
return $this->fetch('fenxiao/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分销商
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$fenxiao_data = [
|
||||
'site_id' => $this->site_id,
|
||||
'fenxiao_name' => input('fenxiao_name', ''),//分销商名称
|
||||
'level_id' => input('level_id', 0),//分销商等级
|
||||
'parent' => input('fenxiao_id', 0),//上级分销商ID
|
||||
'member_id' => input('member_id', 0),//关联会员ID
|
||||
];
|
||||
$apply_model = new FenxiaoApply();
|
||||
return $apply_model->addFenxiao($fenxiao_data);
|
||||
|
||||
} else {
|
||||
|
||||
//获取分销商等级
|
||||
$level_model = new FenxiaoLevelModel();
|
||||
$level_list = $level_model->getLevelList([ [ 'status', '=', 1 ], [ 'site_id', '=', $this->site_id ] ], 'level_id,level_name')[ 'data' ];
|
||||
$this->assign('level_list', $level_list);
|
||||
|
||||
//获取分销商列表
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$condition[] = [ 'status', '=', '1' ];
|
||||
$fenxiao_list = $fenxiao_model->getFenxiaoList($condition, 'fenxiao_id,fenxiao_name')[ 'data' ];
|
||||
$this->assign('fenxiao_list', $fenxiao_list);
|
||||
|
||||
//获取会员列表
|
||||
$member_model = new MemberModel();
|
||||
$where[] = [ 'is_fenxiao', '=', '0' ];
|
||||
$member_list = $member_model->getMemberList($where, 'member_id,nickname')[ 'data' ];
|
||||
$this->assign('member_list', $member_list);
|
||||
|
||||
return $this->fetch('fenxiao/add');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分销商列表
|
||||
*/
|
||||
public function getFenxiaoList()
|
||||
{
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$fenxiao_search = input('fenxiao_search', '');
|
||||
$condition = [];
|
||||
$condition[] = [ 'mobile|fenxiao_name', 'like', '%' . $fenxiao_search . '%' ];
|
||||
$condition[] = [ 'status', '=', 1 ];
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$list = $fenxiao_model->getFenxiaoPageLists($condition, $page_index, $page_size, '', 'fenxiao_id,fenxiao_name,account');
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员列表
|
||||
*/
|
||||
public function getMemberList()
|
||||
{
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$member_search = input('member_search', '');
|
||||
$condition = [];
|
||||
$condition[] = [ 'mobile|email|username|nickname', 'like', '%' . $member_search . '%' ];
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'is_fenxiao', '=', '0' ];
|
||||
$member_model = new MemberModel();
|
||||
$list = $member_model->getMemberPageList($condition, $page_index, $page_size, '', 'member_id,headimg,nickname,point,balance');
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$fenxiao_id = input('fenxiao_id', '');
|
||||
|
||||
$model = new FenxiaoModel();
|
||||
$fenxiao_leve_model = new FenxiaoLevelModel();
|
||||
|
||||
$condition[] = [ 'f.fenxiao_id', '=', $fenxiao_id ];
|
||||
$info = $model->getFenxiaoDetailInfo($condition);
|
||||
if (empty($info[ 'data' ])) $this->error('未获取到分销商数据', href_url('fenxiao://shop/fenxiao/lists'));
|
||||
//团队人员数据
|
||||
$info['data']['team_num'] = $model->getFenxiaoTeamNum($fenxiao_id, $this->site_id)['data'];
|
||||
|
||||
$fenxiao_level = $fenxiao_leve_model->getLevelInfo([ [ 'level_id', '=', $info[ 'data' ][ 'level_id' ] ] ]);
|
||||
|
||||
$this->assign('status', $model->fenxiao_status_zh);
|
||||
$this->assign('level', $fenxiao_level[ 'data' ]);
|
||||
$this->assign('info', $info[ 'data' ]);
|
||||
|
||||
$this->assign('fenxiao_id', $fenxiao_id);
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$basics_config = $config_model->getFenxiaoBasicsConfig($this->site_id);
|
||||
$this->assign('fenxiao_level_num', $basics_config[ 'data' ][ 'value' ][ 'level' ]);
|
||||
|
||||
return $this->fetch('fenxiao/fenxiao_detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销账户信息
|
||||
*/
|
||||
public function account()
|
||||
{
|
||||
$model = new FenxiaoModel();
|
||||
$fenxiao_id = input('fenxiao_id', '');
|
||||
|
||||
$condition[] = [ 'f.fenxiao_id', '=', $fenxiao_id ];
|
||||
$info = $model->getFenxiaoDetailInfo($condition);
|
||||
if (empty($info[ 'data' ])) $this->error('未获取到分销商数据', href_url('fenxiao://shop/fenxiao/lists'));
|
||||
$account = $info[ 'data' ][ 'account' ] - $info[ 'data' ][ 'account_withdraw_apply' ];
|
||||
$info[ 'data' ][ 'account' ] = number_format($account, 2, '.', '');
|
||||
$this->assign('fenxiao_info', $info[ 'data' ]);
|
||||
|
||||
if (request()->isJson()) {
|
||||
|
||||
$account_model = new FenxiaoAccount();
|
||||
$page = input('page', 1);
|
||||
$status = input('status', '');
|
||||
|
||||
$fenxiao_id = input('fenxiao_id', '');
|
||||
$list_condition[] = [ 'fenxiao_id', '=', $fenxiao_id ];
|
||||
if ($status) {
|
||||
if ($status == 1) {
|
||||
$list_condition[] = [ 'money', '>', 0 ];
|
||||
} else {
|
||||
$list_condition[] = [ 'money', '<', 0 ];
|
||||
}
|
||||
}
|
||||
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if ($start_time && $end_time) {
|
||||
$list_condition[] = [ 'create_time', 'between', [ $start_time, $end_time ] ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$list_condition[] = [ 'create_time', '<=', $end_time ];
|
||||
|
||||
} elseif ($start_time && !$end_time) {
|
||||
$list_condition[] = [ 'create_time', '>=', $start_time ];
|
||||
}
|
||||
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$list = $account_model->getFenxiaoAccountPageList($list_condition, $page, $page_size);
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商团队
|
||||
*/
|
||||
public function team()
|
||||
{
|
||||
$fenxiao_id = input('fenxiao_id', 0);
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
if (request()->isJson()) {
|
||||
$level = input('level', 1);
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$list = $fenxiao_model->getFenxiaoTeam($level, $fenxiao_id, $page, $page_size);
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单管理
|
||||
*/
|
||||
public function order()
|
||||
{
|
||||
$model = new FenxiaoOrderModel();
|
||||
if (request()->isJson()) {
|
||||
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$fenxiao_id = input('fenxiao_id', '');
|
||||
$status = input('status', 0);
|
||||
|
||||
$condition[] = [ 'one_fenxiao_id|two_fenxiao_id|three_fenxiao_id', '=', $fenxiao_id ];
|
||||
|
||||
$search_text_type = input('search_text_type', 'goods_name');//订单编号/商品名称
|
||||
$search_text = input('search_text', '');
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'fo.' . $search_text_type, 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
if (in_array($status, [ 1, 2 ])) {
|
||||
$condition[] = [ 'fo.is_settlement', '=', $status - 1 ];
|
||||
}
|
||||
|
||||
//下单时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ 'fo.create_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'fo.create_time', '<=', date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty(date_to_time($end_time))) {
|
||||
$condition[] = [ 'fo.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
|
||||
$list = $model->getFenxiaoOrderPage($condition, $page_index, $page_size);
|
||||
return $list;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
public function orderDetail()
|
||||
{
|
||||
$fenxiao_order_model = new FenxiaoOrderModel();
|
||||
$fenxiao_order_id = input('fenxiao_order_id', '');
|
||||
$order_info = $fenxiao_order_model->getFenxiaoOrderDetail([ [ 'fenxiao_order_id', '=', $fenxiao_order_id ] ]);
|
||||
$this->assign('order_info', $order_info[ 'data' ]);
|
||||
return $this->fetch('fenxiao/order_detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* 冻结
|
||||
*/
|
||||
public function frozen()
|
||||
{
|
||||
$fenxiao_id = input('fenxiao_id', '');
|
||||
$model = new FenxiaoModel();
|
||||
return $model->frozen($fenxiao_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复正常
|
||||
*/
|
||||
public function unfrozen()
|
||||
{
|
||||
$fenxiao_id = input('fenxiao_id', '');
|
||||
$model = new FenxiaoModel();
|
||||
return $model->unfrozen($fenxiao_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商申请列表
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$model = new FenxiaoApply();
|
||||
if (request()->isJson()) {
|
||||
|
||||
$condition[] = [ 'fa.site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'fa.status', '=', 1 ];
|
||||
$condition[] = [ 'm.is_delete', '=', 0 ];
|
||||
|
||||
$fenxiao_name = input('fenxiao_name', '');
|
||||
if ($fenxiao_name) {
|
||||
$condition[] = [ 'fenxiao_name', 'like', '%' . $fenxiao_name . '%' ];
|
||||
}
|
||||
$nickname = input('nickname', '');
|
||||
if ($nickname) {
|
||||
$condition[] = [ 'm.nickname', 'like', '%' . $nickname . '%' ];
|
||||
}
|
||||
$mobile = input('mobile', '');
|
||||
if ($mobile) {
|
||||
$condition[] = [ 'm.mobile', 'like', '%' . $mobile . '%' ];
|
||||
}
|
||||
$level_id = input('level_id', '');
|
||||
if ($level_id) {
|
||||
$condition[] = [ 'fa.level_id', '=', $level_id ];
|
||||
}
|
||||
$create_start_time = input('create_start_time', '');
|
||||
$create_end_time = input('create_end_time', '');
|
||||
if ($create_start_time && $create_end_time) {
|
||||
$condition[] = [ 'fa.create_time', 'between', [ strtotime($create_start_time), strtotime($create_end_time) ] ];
|
||||
} elseif (!$create_start_time && $create_end_time) {
|
||||
$condition[] = [ 'fa.create_time', '<=', strtotime($create_end_time) ];
|
||||
|
||||
} elseif ($create_start_time && !$create_end_time) {
|
||||
$condition[] = [ 'fa.create_time', '>=', strtotime($create_start_time) ];
|
||||
}
|
||||
|
||||
$rg_start_time = input('rg_start_time', '');
|
||||
$rg_end_time = input('rg_end_time', '');
|
||||
if ($rg_start_time && $rg_end_time) {
|
||||
$condition[] = [ 'fa.reg_time', 'between', [ strtotime($rg_start_time), strtotime($rg_end_time) ] ];
|
||||
} elseif (!$rg_start_time && $rg_end_time) {
|
||||
$condition[] = [ 'fa.reg_time', '<=', strtotime($rg_end_time) ];
|
||||
|
||||
} elseif ($rg_start_time && !$rg_end_time) {
|
||||
$condition[] = [ 'fa.reg_time', '>=', strtotime($rg_start_time) ];
|
||||
}
|
||||
|
||||
$join = [
|
||||
[ 'member m', 'fa.member_id = m.member_id', 'inner' ]
|
||||
];
|
||||
$field = 'fa.apply_id,fa.fenxiao_name,fa.parent,fa.member_id,fa.level_id,fa.level_name,fa.order_complete_money,fa.order_complete_num,fa.reg_time,fa.create_time,fa.status,m.mobile,m.nickname,m.headimg';
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$list = $model->getFenxiaoApplyPageList($condition, $page, $page_size, 'fa.create_time desc', $field, 'fa', $join);
|
||||
return $list;
|
||||
} else {
|
||||
|
||||
$level_model = new FenxiaoLevelModel();
|
||||
$level_list = $level_model->getLevelList([ [ 'status', '=', 1 ] ], 'level_id,level_name');
|
||||
$this->assign('level_list', $level_list[ 'data' ]);
|
||||
|
||||
return $this->fetch('fenxiao/apply');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商申请通过
|
||||
*/
|
||||
public function applyPass()
|
||||
{
|
||||
$apply_id = input('apply_id');
|
||||
|
||||
$model = new FenxiaoApply();
|
||||
$res = $model->pass($apply_id, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销商申请通过
|
||||
*/
|
||||
public function applyRefuse()
|
||||
{
|
||||
$apply_id = input('apply_id');
|
||||
$model = new FenxiaoApply();
|
||||
$res = $model->refuse($apply_id);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更上下级
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$member_id = input('member_id');
|
||||
$model = new FenxiaoModel();
|
||||
$member_model = new MemberModel();
|
||||
|
||||
//用户信息
|
||||
$member_info = $member_model->getMemberInfo([ [ 'member_id', '=', $member_id ] ], 'fenxiao_id,is_fenxiao')[ 'data' ];
|
||||
//获取分销信息
|
||||
$fenxiao_info = $model->getFenxiaoInfo([ [ 'fenxiao_id', '=', $member_info[ 'fenxiao_id' ] ] ], 'parent');
|
||||
//获取上级分销商信息
|
||||
$parent_info = [];
|
||||
if (!empty($fenxiao_info[ 'data' ])) {
|
||||
$parent_info = $model->getFenxiaoInfo([ [ 'fenxiao_id', '=', $fenxiao_info[ 'data' ][ 'parent' ] ] ], 'fenxiao_id,fenxiao_name')['data'];
|
||||
}
|
||||
if (request()->isJson()) {
|
||||
if ($member_info[ 'is_fenxiao' ] == 1) {
|
||||
$condition[] = [ 'f.fenxiao_id', '<>', $member_info[ 'fenxiao_id' ] ];
|
||||
$condition[] = [ 'f.parent', '<>', $member_info[ 'fenxiao_id' ] ];
|
||||
}
|
||||
|
||||
$condition[] = [ 'f.site_id', '=', $this->site_id ];
|
||||
$status = input('status', 1);
|
||||
if ($status) {
|
||||
$condition[] = [ 'f.status', '=', $status ];
|
||||
}
|
||||
|
||||
$fenxiao_name = input('fenxiao_name', '');
|
||||
if ($fenxiao_name) {
|
||||
$condition[] = [ 'f.fenxiao_name', 'like', '%' . $fenxiao_name . '%' ];
|
||||
}
|
||||
|
||||
$parent_name = input('parent_name', '');
|
||||
if ($parent_name) {
|
||||
$condition[] = [ 'pf.fenxiao_name', 'like', '%' . $parent_name . '%' ];
|
||||
}
|
||||
|
||||
$level_id = input('level_id', '');
|
||||
if ($level_id) {
|
||||
$condition[] = [ 'f.level_id', '=', $level_id ];
|
||||
}
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if ($start_time && $end_time) {
|
||||
$condition[] = [ 'f.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'f.create_time', '<=', date_to_time($end_time) ];
|
||||
|
||||
} elseif ($start_time && !$end_time) {
|
||||
$condition[] = [ 'f.create_time', '>=', date_to_time($start_time) ];
|
||||
}
|
||||
if(!empty($parent_info)){
|
||||
$order = \think\facade\Db::raw("IF(f.fenxiao_id = {$parent_info['fenxiao_id']}, 1, 2) asc,f.create_time desc");
|
||||
}else{
|
||||
$order = 'f.create_time desc';
|
||||
}
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$list = $model->getFenxiaoPageList($condition, $page, $page_size, $order);
|
||||
return $list;
|
||||
|
||||
} else {
|
||||
$level_model = new FenxiaoLevelModel();
|
||||
$level_list = $level_model->getLevelList([ [ 'status', '=', 1 ], [ 'site_id', '=', $this->site_id ] ], 'level_id,level_name');
|
||||
$this->assign('level_list', $level_list[ 'data' ]);
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$basics = $config_model->getFenxiaoBasicsConfig($this->site_id);
|
||||
$this->assign('basics_info', $basics[ 'data' ][ 'value' ]);
|
||||
|
||||
$this->assign('member_id', $member_id);
|
||||
$this->assign('parent_info', $parent_info);
|
||||
|
||||
$change_end_func = input('change_end_func', 'changeEnd');
|
||||
$this->assign('change_end_func', $change_end_func);
|
||||
|
||||
return $this->fetch('fenxiao/change');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认变更
|
||||
*/
|
||||
public function confirmChange()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$member_id = input('member_id', '');
|
||||
$parent = input('parent', '');
|
||||
$type = input('type', '');
|
||||
$model = new FenxiaoModel();
|
||||
if ($type == 1) {
|
||||
$res = $model->changeParentFenxiao($member_id, $parent);
|
||||
} else {
|
||||
$res = $model->cancelParentFenxiao($member_id);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员详情
|
||||
*/
|
||||
public function memberInfo()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$member_id = input('member_id', '');
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'member_id', '=', $member_id ];
|
||||
$member_model = new MemberModel();
|
||||
$member_info_result = $member_model->getMemberInfo($condition);
|
||||
$member_info = $member_info_result['data'];
|
||||
if (empty($member_info)) return $member_model->error([], '账号不存在!');
|
||||
return $member_info_result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分销商等级
|
||||
*/
|
||||
public function changeLevel()
|
||||
{
|
||||
$member_id = input('member_id', '');
|
||||
$fenxiao_id = input('fenxiao_id', '');
|
||||
if (request()->isJson()) {
|
||||
$level_model = new FenxiaoLevelModel();
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$fenxiao_info = $fenxiao_model->getFenxiaoInfo([ [ 'fenxiao_id', '=', $fenxiao_id ] ], 'member_id,level_id,level_name')[ 'data' ];
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
if (!empty($fenxiao_info)) {
|
||||
$condition[] = [ 'level_id', '<>', $fenxiao_info[ 'level_id' ] ];
|
||||
}
|
||||
|
||||
$lists = $level_model->getLevelPageList($condition, '1', PAGE_LIST_ROWS, 'level_num asc');
|
||||
return $lists;
|
||||
} else {
|
||||
$config_model = new ConfigModel();
|
||||
$basics = $config_model->getFenxiaoBasicsConfig($this->site_id);
|
||||
$this->assign('basics_info', $basics[ 'data' ][ 'value' ]);
|
||||
|
||||
$this->assign('member_id', $member_id);
|
||||
|
||||
$this->assign('fenxiao_id', $fenxiao_id);
|
||||
|
||||
$change_end_func = input('change_end_func', 'changeEnd');
|
||||
$this->assign('change_end_func', $change_end_func);
|
||||
|
||||
return $this->fetch('fenxiao/change_level');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认变更
|
||||
*/
|
||||
public function confirmChangeLevel()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$member_id = input('member_id', '');
|
||||
$level_id = input('level_id', '');
|
||||
|
||||
$level_model = new FenxiaoLevelModel();
|
||||
$level_data = $level_model->getLevelInfo([ [ 'level_id', '=', $level_id ] ], 'level_id,level_name')[ 'data' ];
|
||||
$fenxiao_model = new FenxiaoModel();
|
||||
$data = [
|
||||
'level_id' => $level_data[ 'level_id' ],
|
||||
'level_name' => $level_data[ 'level_name' ]
|
||||
];
|
||||
$res = $fenxiao_model->changeFenxiaoLevel($data, [ [ 'member_id', '=', $member_id ] ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
271
addon/fenxiao/shop/controller/Goods.php
Executable file
271
addon/fenxiao/shop/controller/Goods.php
Executable file
@@ -0,0 +1,271 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\shop\controller;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoGoodsSku as FenxiaoGoodsSkuModel;
|
||||
use addon\fenxiao\model\FenxiaoLevel as FenxiaoLevelModel;
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\fenxiao\model\FenxiaoGoods as FenxiaoGoodsModel;
|
||||
use think\facade\Db;
|
||||
use addon\fenxiao\model\Config as FenxiaoConfigModel;
|
||||
|
||||
/**
|
||||
* 分销商品
|
||||
*/
|
||||
class Goods extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 分销等级列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$model = new GoodsModel();
|
||||
|
||||
if (request()->isJson()) {
|
||||
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$condition = [
|
||||
[ 'is_delete', '=', 0 ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
$search_text_type = input('search_text_type', 'goods_name');//店铺名称或者商品名称
|
||||
$search_text = input('search_text', '');
|
||||
$goods_class = input('goods_class', '');//商品种类
|
||||
$goods_state = input('goods_state', '');//商品状态
|
||||
$category_id = input('category_id', '');//分类ID
|
||||
$is_fenxiao = input('is_fenxiao', '');
|
||||
$start_sale = input('start_sale', 0);
|
||||
$end_sale = input('end_sale', 0);
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ $search_text_type, 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
|
||||
if ($is_fenxiao !== '') {
|
||||
$condition[] = [ 'is_fenxiao', '=', $is_fenxiao ];
|
||||
}
|
||||
if (!empty($start_sale)) $condition[] = [ 'sale_num', '>=', $start_sale ];
|
||||
if (!empty($end_sale)) $condition[] = [ 'sale_num', '<=', $end_sale ];
|
||||
|
||||
if ($goods_class !== '') {
|
||||
$condition[] = [ 'goods_class', '=', $goods_class ];
|
||||
}
|
||||
|
||||
if ($goods_state !== '') {
|
||||
$condition[] = [ 'goods_state', '=', $goods_state ];
|
||||
}
|
||||
|
||||
if (!empty($category_id)) {
|
||||
$condition[] = [ 'category_id', 'like', '%,' . $category_id . ',%' ];
|
||||
}
|
||||
$list = $model->getGoodsPageList($condition, $page_index, $page_size);
|
||||
return $list;
|
||||
} else {
|
||||
|
||||
return $this->fetch('goods/lists');
|
||||
}
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$goods_id = input('goods_id');
|
||||
$goods_model = new GoodsModel();
|
||||
$fenxiao_sku_model = new FenxiaoGoodsSkuModel();
|
||||
$fenxiao_leve_model = new FenxiaoLevelModel();
|
||||
$goods_info = $goods_model->getGoodsDetail($goods_id);
|
||||
if (empty($goods_info[ 'data' ]) || $goods_info[ 'data' ][ 'site_id' ] != $this->site_id) $this->error('商品信息不存在');
|
||||
$fenxiao_skus = $fenxiao_sku_model->getSkuList([ 'goods_id' => $goods_id ]);
|
||||
$skus = [];
|
||||
foreach ($fenxiao_skus[ 'data' ] as $fenxiao_sku) {
|
||||
$skus[ $fenxiao_sku[ 'level_id' ] . '_' . $fenxiao_sku[ 'sku_id' ] ] = $fenxiao_sku;
|
||||
}
|
||||
$goods_info[ 'data' ][ 'fenxiao_skus' ] = $skus;
|
||||
$goods_info[ 'data' ][ 'goods_image' ] = explode(',', $goods_info[ 'data' ][ 'goods_image' ]);
|
||||
$fenxiao_level = $fenxiao_leve_model->getLevelList([ [ 'site_id', '=', $this->site_id ] ]);
|
||||
$this->assign('fenxiao_level', $fenxiao_level[ 'data' ]);
|
||||
$this->assign('goods_info', $goods_info[ 'data' ]);
|
||||
|
||||
$fenxiao_config_model = new FenxiaoConfigModel();
|
||||
$fenxiao_config = $fenxiao_config_model->getFenxiaoBasicsConfig($this->site_id)[ 'data' ] ?? [];
|
||||
$this->assign('fenxiao_config', $fenxiao_config[ 'value' ] ?? []);
|
||||
return $this->fetch('goods/detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加活动
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$goods_id = input('goods_id');
|
||||
$goods_model = new GoodsModel();
|
||||
$fenxiao_sku_model = new FenxiaoGoodsSkuModel();
|
||||
$fenxiao_leve_model = new FenxiaoLevelModel();
|
||||
$fenxiao_level = $fenxiao_leve_model->getLevelList([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 1 ] ], '*', 'level_num asc,one_rate asc');
|
||||
$goods_info = $goods_model->getGoodsDetail($goods_id);
|
||||
if (empty($goods_info[ 'data' ]) || $goods_info[ 'data' ][ 'site_id' ] != $this->site_id) $this->error('商品信息不存在');
|
||||
$fenxiao_config_model = new FenxiaoConfigModel();
|
||||
$fenxiao_config = $fenxiao_config_model->getFenxiaoBasicsConfig($this->site_id)[ 'data' ] ?? [];
|
||||
$fenxiao_config = $fenxiao_config[ 'value' ] ?? [];
|
||||
if (request()->isJson()) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$fenxiao_type = input('fenxiao_type', 1);
|
||||
$fenxiao_skus = input('fenxiao', []);
|
||||
$is_fenxiao = input('is_fenxiao', 0);
|
||||
$fenxiao_price = input('fenxiao_price', []);
|
||||
|
||||
$goods_data = [ 'is_fenxiao' => $is_fenxiao, 'fenxiao_type' => $fenxiao_type ];
|
||||
if ($fenxiao_type == 2) {
|
||||
$fenxiao_goods_sku_data = [];
|
||||
foreach ($fenxiao_skus as $level_id => $level_data) {
|
||||
foreach ($level_data[ 'sku_id' ] as $key => $sku_id) {
|
||||
$fenxiao_total = 0;
|
||||
$fenxiao_level = [ 'one', 'two', 'three' ];
|
||||
foreach ($fenxiao_level as $level) {
|
||||
$item_rate_array = $level_data[ $level . '_rate' ] ?? [];
|
||||
$item_rate = $item_rate_array[ $key ] ?? 0;
|
||||
$item_money_array = $level_data[ $level . '_money' ] ?? [];
|
||||
$item_money = $item_money_array[ $key ] ?? 0;
|
||||
$var_rate_name = $level . '_rate';
|
||||
$$var_rate_name = $item_rate;
|
||||
$var_money_name = $level . '_money';
|
||||
$$var_money_name = $item_money;
|
||||
if ($item_rate > 0) {
|
||||
$fenxiao_total += $level_data[ 'sku_price' ][ $key ] * $item_rate / 100;
|
||||
} elseif ($item_money > 0) {
|
||||
$fenxiao_total += $item_money;
|
||||
}
|
||||
}
|
||||
if (empty($fenxiao_total)) {
|
||||
return error(-1, '分销金额不可以为零');
|
||||
}
|
||||
if ($level_data[ 'sku_price' ][ $key ] < $fenxiao_total) {
|
||||
return error(-1, '分销总金额不能大于商品sku价格的100%!');
|
||||
}
|
||||
|
||||
if ($fenxiao_config[ 'level' ] < 3) {
|
||||
$three_rate = 0;
|
||||
$three_money = 0;
|
||||
//通过分销设置的等级配置
|
||||
if ($fenxiao_config[ 'level' ] < 2) {
|
||||
$two_rate = 0;
|
||||
$two_money = 0;
|
||||
}
|
||||
}
|
||||
$fenxiao_sku = [
|
||||
'goods_id' => $goods_id,
|
||||
'level_id' => $level_id,
|
||||
'sku_id' => $sku_id,
|
||||
'one_rate' => $one_rate ?? 0,
|
||||
'one_money' => $one_money ?? 0,
|
||||
'two_rate' => $two_rate ?? 0,
|
||||
'two_money' => $two_money ?? 0,
|
||||
'three_rate' => $three_rate ?? 0,
|
||||
'three_money' => $three_money ?? 0,
|
||||
];
|
||||
$fenxiao_goods_sku_data[] = $fenxiao_sku;
|
||||
}
|
||||
}
|
||||
$fenxiao_sku_model->deleteSku([ 'goods_id' => $goods_id ]);
|
||||
$fenxiao_sku_model->addSkuList($fenxiao_goods_sku_data);
|
||||
}
|
||||
if ($fenxiao_type == 1) {
|
||||
$fenxiao_goods_sku_data = [];
|
||||
foreach ($fenxiao_level[ 'data' ] as $level) {
|
||||
foreach ($goods_info[ 'data' ][ 'sku_data' ] as $sku) {
|
||||
$item_one_rate = $level[ 'one_rate' ] ?? 0;
|
||||
$item_two_rate = $level[ 'two_rate' ] ?? 0;
|
||||
$item_three_rate = $level[ 'three_rate' ] ?? 0;
|
||||
//通过分销设置的等级配置
|
||||
if ($fenxiao_config[ 'level' ] < 3) {
|
||||
$item_three_rate = 0;
|
||||
if ($fenxiao_config[ 'level' ] < 2) {
|
||||
$item_two_rate = 0;
|
||||
}
|
||||
}
|
||||
$fenxiao_sku = [
|
||||
'goods_id' => $goods_id,
|
||||
'level_id' => $level[ 'level_id' ],
|
||||
'sku_id' => $sku[ 'sku_id' ],
|
||||
'one_rate' => $item_one_rate,
|
||||
'one_money' => 0,
|
||||
'two_rate' => $item_two_rate,
|
||||
'two_money' => 0,
|
||||
'three_rate' => $item_three_rate,
|
||||
'three_money' => 0,
|
||||
];
|
||||
$fenxiao_goods_sku_data[] = $fenxiao_sku;
|
||||
}
|
||||
}
|
||||
$fenxiao_sku_model->deleteSku([ 'goods_id' => $goods_id ]);
|
||||
$fenxiao_sku_model->addSkuList($fenxiao_goods_sku_data);
|
||||
}
|
||||
|
||||
$fenxiao_goods_model = new FenxiaoGoodsModel();
|
||||
$re = $fenxiao_goods_model->editGoodsFenxiao($goods_data, [ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
|
||||
if ($is_fenxiao) {
|
||||
foreach ($fenxiao_price as $sku_id => $item) {
|
||||
if (empty($item) || $item < 0) $item = 0;
|
||||
$res = model('goods_sku')->update([ 'fenxiao_price' => $item ], [ [ 'sku_id', '=', $sku_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
return $re;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return error(-1, $e->getMessage());
|
||||
}
|
||||
}
|
||||
$fenxiao_skus = $fenxiao_sku_model->getSkuList([ 'goods_id' => $goods_id ]);
|
||||
$skus = [];
|
||||
foreach ($fenxiao_skus[ 'data' ] as $fenxiao_sku) {
|
||||
$skus[ $fenxiao_sku[ 'level_id' ] . '_' . $fenxiao_sku[ 'sku_id' ] ] = $fenxiao_sku;
|
||||
}
|
||||
$goods_info[ 'data' ][ 'fenxiao_skus' ] = $skus;
|
||||
$goods_info[ 'data' ][ 'goods_image' ] = explode(',', $goods_info[ 'data' ][ 'goods_image' ]);
|
||||
|
||||
$this->assign('fenxiao_level', $fenxiao_level[ 'data' ]);
|
||||
$this->assign('goods_info', $goods_info[ 'data' ]);
|
||||
|
||||
$this->assign('fenxiao_config', $fenxiao_config);
|
||||
return $this->fetch('goods/config');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分销状态
|
||||
*/
|
||||
public function modify()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$fenxiao_goods_model = new FenxiaoGoodsModel();
|
||||
$goods_id = input('goods_id');
|
||||
$is_fenxiao = input('is_fenxiao', 0);
|
||||
return $fenxiao_goods_model->modifyGoodsFenxiaoStatus($goods_id, $is_fenxiao ? 0 : 1, $this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置是否参与分销
|
||||
* @return array
|
||||
*/
|
||||
public function setGoodsIsFenxiao()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$fenxiao_goods_model = new FenxiaoGoodsModel();
|
||||
$goods_ids = input('goods_ids', '');
|
||||
$is_fenxiao = input('is_fenxiao', 0);
|
||||
return $fenxiao_goods_model->modifyGoodsIsFenxiao($goods_ids, $is_fenxiao, $this->site_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
160
addon/fenxiao/shop/controller/Level.php
Executable file
160
addon/fenxiao/shop/controller/Level.php
Executable file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\shop\controller;
|
||||
|
||||
use addon\fenxiao\model\Config as ConfigModel;
|
||||
use addon\fenxiao\model\FenxiaoLevel as FenxiaoLevelModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\fenxiao\model\Fenxiao;
|
||||
|
||||
/**
|
||||
* 分销等级管理
|
||||
*/
|
||||
class Level extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 分销等级列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$model = new FenxiaoLevelModel();
|
||||
$field = 'level_id,level_num,level_name,one_rate,two_rate,three_rate,status,create_time,is_default,one_fenxiao_order_num,one_fenxiao_order_money,one_fenxiao_total_order,order_num,order_money,one_child_num,one_child_fenxiao_num,upgrade_type';
|
||||
if (request()->isJson()) {
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$list = $model->getLevelPageListInAdmin([ [ 'site_id', '=', $this->site_id ], ['is_default', '=', 0] ], $page, $page_size, 'level_num asc,one_rate asc', $field);
|
||||
|
||||
return $list;
|
||||
|
||||
} else {
|
||||
|
||||
//获取系统配置
|
||||
$config_model = new ConfigModel();
|
||||
$basics = $config_model->getFenxiaoBasicsConfig($this->site_id);
|
||||
$this->assign("basics_info", $basics[ 'data' ][ 'value' ]);
|
||||
return $this->fetch('level/lists');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分销等级
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$model = new FenxiaoLevelModel();
|
||||
|
||||
if (request()->isJson()) {
|
||||
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'level_name' => input('level_name', ''),
|
||||
'one_rate' => input('one_rate', ''),
|
||||
'two_rate' => input('two_rate', ''),
|
||||
'three_rate' => input('three_rate', ''),
|
||||
'upgrade_type' => input('upgrade_type', ''),
|
||||
'level_num' => input('level_num', 1),
|
||||
'fenxiao_order_num' => input('fenxiao_order_num', ''),
|
||||
'fenxiao_order_meney' => input('fenxiao_order_meney', ''),
|
||||
'one_fenxiao_order_num' => input('one_fenxiao_order_num', ''),
|
||||
'one_fenxiao_order_money' => input('one_fenxiao_order_money', ''),
|
||||
'one_fenxiao_total_order' => input('one_fenxiao_total_order', ''),
|
||||
'order_num' => input('order_num', ''),
|
||||
'order_money' => input('order_money', ''),
|
||||
'child_num' => input('child_num', ''),
|
||||
'child_fenxiao_num' => input('child_fenxiao_num', ''),
|
||||
'one_child_num' => input('one_child_num', ''),
|
||||
'one_child_fenxiao_num' => input('one_child_fenxiao_num', ''),
|
||||
];
|
||||
$res = $model->addLevel($data);
|
||||
return $res;
|
||||
} else {
|
||||
//获取系统配置
|
||||
$config_model = new ConfigModel();
|
||||
$basics = $config_model->getFenxiaoBasicsConfig($this->site_id);
|
||||
$this->assign("basics_info", $basics[ 'data' ][ 'value' ]);
|
||||
|
||||
$level_weight = $model->getLevelList([ [ 'level_num', '<>', '' ], [ 'site_id', '=', $this->site_id ] ], 'level_num');
|
||||
$level_weight = $level_weight[ 'data' ];
|
||||
if (!empty($level_weight)) $level_weight = array_column($level_weight, 'level_num');
|
||||
$this->assign('level_weight', $level_weight);
|
||||
|
||||
return $this->fetch('level/add');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑分销等级
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$model = new FenxiaoLevelModel();
|
||||
|
||||
if (request()->isJson()) {
|
||||
|
||||
$data = [
|
||||
'level_name' => input('level_name', ''),
|
||||
'one_rate' => input('one_rate', ''),
|
||||
'two_rate' => input('two_rate', ''),
|
||||
'three_rate' => input('three_rate', ''),
|
||||
'upgrade_type' => input('upgrade_type', ''),
|
||||
'level_num' => input('level_num', 0),
|
||||
'fenxiao_order_num' => input('fenxiao_order_num', ''),
|
||||
'fenxiao_order_meney' => input('fenxiao_order_meney', ''),
|
||||
'one_fenxiao_order_num' => input('one_fenxiao_order_num', ''),
|
||||
'one_fenxiao_order_money' => input('one_fenxiao_order_money', ''),
|
||||
'one_fenxiao_total_order' => input('one_fenxiao_total_order', ''),
|
||||
'order_num' => input('order_num', ''),
|
||||
'order_money' => input('order_money', ''),
|
||||
'child_num' => input('child_num', ''),
|
||||
'child_fenxiao_num' => input('child_fenxiao_num', ''),
|
||||
'one_child_num' => input('one_child_num', ''),
|
||||
'one_child_fenxiao_num' => input('one_child_fenxiao_num', ''),
|
||||
];
|
||||
$level_id = input('level_id', '');
|
||||
|
||||
$res = $model->editLevel($data, [ [ 'level_id', '=', $level_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $res;
|
||||
} else {
|
||||
$level_id = input('level_id', '');
|
||||
$info = $model->getLevelInfo([ [ 'level_id', '=', $level_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
if (empty($info[ 'data' ])) $this->error('未获取到等级数据', href_url('fenxiao://shop/level/lists'));
|
||||
$this->assign('info', $info[ 'data' ]);
|
||||
|
||||
//获取系统配置
|
||||
$config_model = new ConfigModel();
|
||||
$basics = $config_model->getFenxiaoBasicsConfig($this->site_id);
|
||||
$this->assign("basics_info", $basics[ 'data' ][ 'value' ]);
|
||||
|
||||
$level_weight = $model->getLevelList([ [ 'level_num', '<>', '' ], [ 'level_id', '<>', $level_id ], [ 'site_id', '=', $this->site_id ] ], 'level_num');
|
||||
$level_weight = $level_weight[ 'data' ];
|
||||
if (!empty($level_weight)) $level_weight = array_column($level_weight, 'level_num');
|
||||
$this->assign('level_weight', $level_weight);
|
||||
}
|
||||
|
||||
return $this->fetch('level/edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分销等级
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$model = new FenxiaoLevelModel();
|
||||
|
||||
$level_id = input('level_id', '');
|
||||
$res = $model->deleteLevel($level_id, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
36
addon/fenxiao/shop/controller/Market.php
Executable file
36
addon/fenxiao/shop/controller/Market.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
|
||||
/**
|
||||
* 分销市场
|
||||
*/
|
||||
class Market extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 分销市场
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'name' => 'DIY_FENXIAO_MARKET',
|
||||
'support_diy_view' => [ '', 'DIY_FENXIAO_MARKET' ],
|
||||
];
|
||||
$edit_view = event('DiyViewEdit', $data, true);
|
||||
|
||||
return $edit_view;
|
||||
}
|
||||
|
||||
}
|
||||
122
addon/fenxiao/shop/controller/Order.php
Executable file
122
addon/fenxiao/shop/controller/Order.php
Executable file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\shop\controller;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoOrder;
|
||||
use app\shop\controller\BaseShop;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* 分销订单
|
||||
*/
|
||||
class Order extends BaseShop
|
||||
{
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
$this->replace = [
|
||||
'FENXIAO_JS' => __ROOT__ . '/addon/fenxiao/shop/view/public/js',
|
||||
'FENXIAO_CSS' => __ROOT__ . '/addon/fenxiao/shop/view/public/css'
|
||||
];
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销订单列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$model = new FenxiaoOrder();
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$status = input('status', 0);
|
||||
$condition = [ [ 'fo.site_id', '=', $this->site_id ] ];
|
||||
if ($status == 3) {
|
||||
$condition[] = [ 'fo.is_refund', '=', 1 ];
|
||||
}
|
||||
if (in_array($status, [ 1, 2 ])) {
|
||||
$condition[] = [ 'fo.is_settlement', '=', $status - 1 ];
|
||||
}
|
||||
$search_text_type = input('search_text_type', "sku_name");//商品名称/订单编号
|
||||
$search_text = input('search_text', "");
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'fo.' . $search_text_type, 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
//下单时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ 'fo.create_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'fo.create_time', '<=', date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty(date_to_time($end_time))) {
|
||||
$condition[] = [ 'fo.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
|
||||
$list = $model->getFenxiaoOrderPage($condition, $page_index, $page_size);
|
||||
|
||||
return $list;
|
||||
} else {
|
||||
|
||||
//订单状态
|
||||
return $this->fetch('order/lists');
|
||||
}
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$fenxiao_order_model = new FenxiaoOrder();
|
||||
$order_id = input('order_id', '');
|
||||
$order_info = $fenxiao_order_model->getFenxiaoOrderDetail([ [ 'order_id', '=', $order_id ] ]);
|
||||
if (empty($order_info[ 'data' ])) $this->error('未获取到订单数据', href_url('fenxiao://shop/order/lists'));
|
||||
$this->assign('order_detail', $order_info[ 'data' ]);
|
||||
return $this->fetch('order/detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单导出
|
||||
*/
|
||||
public function exportorder()
|
||||
{
|
||||
$model = new FenxiaoOrder();
|
||||
$status = input('status', 0);
|
||||
$fenxiao_order_id = input('order_ids', "");
|
||||
|
||||
$condition = [ [ 'fo.site_id', '=', $this->site_id ] ];
|
||||
if ($status == 3) {
|
||||
$condition[] = [ 'fo.is_refund', '=', 1 ];
|
||||
}
|
||||
if (in_array($status, [ 1, 2 ])) {
|
||||
$condition[] = [ 'fo.is_settlement', '=', $status - 1 ];
|
||||
}
|
||||
$search_text_type = input('search_text_type', "goods_name");//商品名称/订单编号
|
||||
$search_text = input('search_text', "");
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'fo.' . $search_text_type, 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
//下单时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = [ 'fo.create_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = [ 'fo.create_time', '<=', date_to_time($end_time) ];
|
||||
} elseif (!empty($start_time) && !empty(date_to_time($end_time))) {
|
||||
$condition[] = [ 'fo.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
if ($fenxiao_order_id) {
|
||||
$condition = [];
|
||||
$condition[] = [ "fo.fenxiao_order_id", "in", $fenxiao_order_id ];
|
||||
}
|
||||
$model->orderExport($condition);
|
||||
return;
|
||||
}
|
||||
}
|
||||
309
addon/fenxiao/shop/controller/Postertemplate.php
Executable file
309
addon/fenxiao/shop/controller/Postertemplate.php
Executable file
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\shop\controller;
|
||||
|
||||
use addon\fenxiao\model\PosterTemplate as PosterTemplateModel;
|
||||
use app\model\system\Site;
|
||||
use app\model\upload\Upload;
|
||||
use app\shop\controller\BaseShop;
|
||||
use extend\Poster as PosterExtend;
|
||||
|
||||
/**
|
||||
* 海报模板 控制器
|
||||
*/
|
||||
class Postertemplate extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 海报模板列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page_index = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$condition = [ [ 'site_id', '=', $this->site_id ] ];
|
||||
$condition[] = [ 'template_type', '=', 'fenxiao' ];
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'poster_name', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
$poster_template_model = new PosterTemplateModel();
|
||||
$res = $poster_template_model->getPosterTemplatePageList($condition, $page_index, $page_size);
|
||||
return $res;
|
||||
} else {
|
||||
return $this->fetch('poster_template/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加海报模板
|
||||
* @return mixed
|
||||
*/
|
||||
public function addPosterTemplate()
|
||||
{
|
||||
$poster_template_model = new PosterTemplateModel();
|
||||
if (request()->isJson()) {
|
||||
$default_template = PosterTemplateModel::DEFAULT_TEMPLATE;
|
||||
$add_data = [];
|
||||
$template_json = [];
|
||||
foreach ($default_template as $field => $field_value) {
|
||||
if ($field == 'template_json') {
|
||||
foreach ($default_template[ 'template_json' ] as $json_field => $json_field_value) {
|
||||
$template_json[ $json_field ] = input($json_field, $json_field_value);
|
||||
}
|
||||
} else {
|
||||
$add_data[ $field ] = input($field, $field_value);
|
||||
}
|
||||
}
|
||||
unset($add_data[ 'template_id' ]);
|
||||
$add_data[ 'site_id' ] = $this->site_id;
|
||||
$add_data[ 'template_json' ] = json_encode($template_json, true);
|
||||
|
||||
return $poster_template_model->addPosterTemplate($add_data);
|
||||
} else {
|
||||
//模板信息
|
||||
$muban_id = input('muban_id', 0);
|
||||
$muban_info = $poster_template_model->getMubanInfo([ [ 'muban_id', '=', $muban_id ] ])[ 'data' ];
|
||||
if (!empty($muban_info)) {
|
||||
$template_info = $muban_info;
|
||||
$template_info[ 'template_json' ] = json_decode($template_info[ 'template_json' ], true);
|
||||
$template_info[ 'template_id' ] = 0;
|
||||
} else {
|
||||
$template_info = PosterTemplateModel::DEFAULT_TEMPLATE;
|
||||
}
|
||||
$template_info[ 'template_json' ] = $poster_template_model->correctTemplateJsonData($template_info[ 'template_json' ])[ 'data' ];
|
||||
$template_info = array_merge($template_info, $template_info[ 'template_json' ]);
|
||||
unset($template_info[ 'template_json' ]);
|
||||
$this->assign('template_info', $template_info);
|
||||
|
||||
//站点信息
|
||||
$site_model = new Site();
|
||||
$site_info = $site_model->getSiteInfo([ [ "site_id", "=", $this->site_id ] ], 'site_name,logo,logo_square')[ 'data' ];
|
||||
$this->assign('site_data', $site_info);
|
||||
|
||||
return $this->fetch('poster_template/add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加海报模板
|
||||
* @return mixed
|
||||
*/
|
||||
public function editPosterTemplate()
|
||||
{
|
||||
$template_id = input('template_id', '');
|
||||
$poster_template_model = new PosterTemplateModel();
|
||||
if (request()->isJson()) {
|
||||
$default_template = PosterTemplateModel::DEFAULT_TEMPLATE;
|
||||
$edit_data = [];
|
||||
$template_json = [];
|
||||
foreach ($default_template as $field => $field_value) {
|
||||
if ($field == 'template_json') {
|
||||
foreach ($default_template[ 'template_json' ] as $json_field => $json_field_value) {
|
||||
$template_json[ $json_field ] = input($json_field, $json_field_value);
|
||||
}
|
||||
} else {
|
||||
$edit_data[ $field ] = input($field, $field_value);
|
||||
}
|
||||
}
|
||||
unset($edit_data[ 'template_id' ]);
|
||||
$edit_data[ 'site_id' ] = $this->site_id;
|
||||
$edit_data[ 'template_json' ] = json_encode($template_json, true);
|
||||
return $poster_data = $poster_template_model->editPosterTemplate($edit_data, [
|
||||
[ 'template_id', '=', $template_id ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
]);
|
||||
} else {
|
||||
//模板信息
|
||||
$template_info = $poster_template_model->getPosterTemplateInfo([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'template_id', '=', $template_id ],
|
||||
], '*')[ 'data' ];
|
||||
if (empty($template_info)) $this->error('模板信息有误');
|
||||
$template_info[ 'template_json' ] = json_decode($template_info[ 'template_json' ], true);
|
||||
$template_info[ 'template_json' ] = $poster_template_model->correctTemplateJsonData($template_info[ 'template_json' ])[ 'data' ];
|
||||
$template_info = array_merge($template_info, $template_info[ 'template_json' ]);
|
||||
unset($template_info[ 'template_json' ]);
|
||||
$this->assign('template_info', $template_info);
|
||||
|
||||
//站点信息
|
||||
$site_model = new Site();
|
||||
$site_info = $site_model->getSiteInfo([ [ "site_id", "=", $this->site_id ] ], 'site_name,logo,logo_square');
|
||||
$this->assign('site_data', $site_info[ 'data' ]);
|
||||
return $this->fetch('poster_template/add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海报模板预览
|
||||
* @return mixed
|
||||
*/
|
||||
public function posterTemplateDetail()
|
||||
{
|
||||
$template_id = input('template_id', '');
|
||||
$condition = [
|
||||
[ 'template_id', '=', $template_id ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
$poster_template_model = new PosterTemplateModel();
|
||||
$poster_data = $poster_template_model->getPosterTemplateInfo($condition);
|
||||
if (empty($poster_data[ 'data' ])) {
|
||||
return $poster_template_model->error(null, '海报数据有误');
|
||||
}
|
||||
|
||||
$poster_data[ 'data' ][ 'template_json' ] = json_decode($poster_data[ 'data' ][ 'template_json' ], true);
|
||||
$poster_data[ 'data' ][ 'template_json' ] = $poster_template_model->correctTemplateJsonData($poster_data[ 'data' ][ 'template_json' ])[ 'data' ];
|
||||
$site_model = new Site();
|
||||
$where = array (
|
||||
[ "site_id", "=", $this->site_id ]
|
||||
);
|
||||
$site_info = $site_model->getSiteInfo($where);
|
||||
$poster_width = 720;
|
||||
$poster_height = 1280;
|
||||
$poster = new PosterExtend($poster_width, $poster_height);
|
||||
$ground = [
|
||||
[
|
||||
'action' => 'setBackground', // 设背景色
|
||||
'data' => [ 255, 255, 255 ]
|
||||
],
|
||||
];
|
||||
|
||||
$fontRate = 0.725; // 20px 等于 14.5磅,换算比率 1px = 0.725磅
|
||||
$option = [
|
||||
[
|
||||
'action' => 'imageCopy', // 写入二维码
|
||||
'data' => [
|
||||
getUrl() . '/public/static/img/caner_erweima.png',
|
||||
$poster_data[ 'data' ][ 'qrcode_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_height' ] * 2,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入分享语
|
||||
'data' => [
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'share_content' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'share_content_font_size' ] * $fontRate * 2,
|
||||
is_array($poster_data[ 'data' ][ 'template_json' ][ 'share_content_color' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'share_content_color' ] : hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'share_content_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'share_content_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'share_content_top' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'share_content_width' ] * 2,
|
||||
1
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$nickname_color = is_array($poster_data[ 'data' ][ 'template_json' ][ 'nickname_color' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'nickname_color' ] : hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'nickname_color' ]);
|
||||
|
||||
$member_option = [
|
||||
[
|
||||
'action' => 'imageCopy', // 写入用户头像
|
||||
'data' => [
|
||||
getUrl() . '/public/static/img/default_img/head.png',
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_height' ] * 2,
|
||||
!empty($poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ] : 'square',
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入分享人昵称
|
||||
'data' => [
|
||||
'用户昵称',
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ] * $fontRate * 2,
|
||||
$nickname_color,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'nickname_top' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_height' ] * 2,
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_is_show' ]
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
$back_ground = [
|
||||
[
|
||||
'action' => 'imageCopy', // 写入背景图
|
||||
'data' => [
|
||||
img($poster_data[ 'data' ][ 'background' ]),
|
||||
0,
|
||||
0,
|
||||
720,
|
||||
1280,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
];
|
||||
$option = array_merge($ground, $back_ground, $option, $member_option);
|
||||
$option_res = $poster->create($option);
|
||||
|
||||
if (is_array($option_res)) return $option_res;
|
||||
$pic_name = rand(10000, 99999);
|
||||
$res = $option_res->jpeg('upload/poster/goods', 'fenxiao' . $pic_name);
|
||||
if ($res[ 'code' ] < 0) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
$upload = new Upload($this->site_id);
|
||||
$cloud_res = $upload->fileCloud($res[ 'data' ][ 'path' ]);
|
||||
return $cloud_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除海报模板
|
||||
* @return mixed
|
||||
*/
|
||||
public function delPosterTemplate()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$template_ids = input('template_ids', '');
|
||||
$condition = [
|
||||
[ 'template_id', 'in', $template_ids ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
];
|
||||
$poster_template_model = new PosterTemplateModel();
|
||||
$res = $poster_template_model->deletePosterTemplate($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑模板状态啊
|
||||
* @return array
|
||||
*/
|
||||
public function editstatus()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$template_id = input('template_id', 0);
|
||||
$template_status = input('template_status', 0);
|
||||
$condition = [
|
||||
[ 'template_id', 'in', $template_id ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
$data = [ 'template_status' => $template_status ];
|
||||
$poster_template_model = new PosterTemplateModel();
|
||||
$res = $poster_template_model->editPosterTemplate($data, $condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
242
addon/fenxiao/shop/controller/Withdraw.php
Executable file
242
addon/fenxiao/shop/controller/Withdraw.php
Executable file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\fenxiao\shop\controller;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoStat;
|
||||
use addon\fenxiao\model\FenxiaoWithdraw as FenxiaoWithdrawModel;
|
||||
use addon\wechatpay\model\Config as WechatPayConfig;
|
||||
use app\shop\controller\BaseShop;
|
||||
|
||||
/**
|
||||
* 分销等级管理
|
||||
*/
|
||||
class Withdraw extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 会员提现列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$model = new FenxiaoWithdrawModel();
|
||||
$transfer_type_list = $model->getTransferType($this->site_id);
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$withdraw_no = input('withdraw_no', '');
|
||||
$start_date = input('start_date', '');
|
||||
$end_date = input('end_date', '');
|
||||
$status = input('status', 'all');//提现状态
|
||||
$transfer_type = input('transfer_type', '');//提现转账方式
|
||||
$fenxiao_name = input('fenxiao_name', '');//提现转账方式
|
||||
|
||||
$payment_start_date = input('payment_start_date', '');
|
||||
$payment_end_date = input('payment_end_date', '');
|
||||
|
||||
$condition = [ [ 'fw.site_id', '=', $this->site_id ] ];
|
||||
if (!empty($withdraw_no)) {
|
||||
$condition[] = [ 'fw.withdraw_no', 'like', '%' . $withdraw_no . '%' ];
|
||||
}
|
||||
if (!empty($transfer_type)) {
|
||||
$condition[] = [ 'fw.transfer_type', '=', $transfer_type ];
|
||||
}
|
||||
if ($status != "all") {
|
||||
$condition[] = [ 'fw.status', '=', $status ];
|
||||
}
|
||||
if (!empty($fenxiao_name)) {
|
||||
$condition[] = [ 'm.nickname|fw.fenxiao_name', '=', $fenxiao_name ];
|
||||
}
|
||||
if ($start_date != '' && $end_date != '') {
|
||||
$condition[] = [ 'fw.create_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
|
||||
} else if ($start_date != '' && $end_date == '') {
|
||||
$condition[] = [ 'fw.create_time', '>=', strtotime($start_date) ];
|
||||
} else if ($start_date == '' && $end_date != '') {
|
||||
$condition[] = [ 'fw.create_time', '<=', strtotime($end_date) ];
|
||||
}
|
||||
|
||||
if ($payment_start_date != '' && $payment_end_date != '') {
|
||||
$condition[] = [ 'fw.payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_date) ] ];
|
||||
} else if ($payment_start_date != '' && $payment_end_date == '') {
|
||||
$condition[] = [ 'fw.payment_time', '>=', strtotime($payment_start_date) ];
|
||||
} else if ($payment_start_date == '' && $payment_end_date != '') {
|
||||
$condition[] = [ 'fw.payment_time', '<=', strtotime($payment_end_date) ];
|
||||
}
|
||||
|
||||
$order = 'fw.create_time desc';
|
||||
$field = 'fw.id,fw.site_id,fw.withdraw_no,fw.member_id,fw.fenxiao_id,fw.fenxiao_name,fw.withdraw_type,fw.bank_name,fw.account_number,fw.realname,fw.mobile,fw.money,fw.withdraw_rate,
|
||||
fw.withdraw_rate_money,fw.real_money,fw.`status`,fw.remark,fw.create_time,fw.payment_time,fw.modify_time,fw.transfer_type,fw.transfer_name,fw.transfer_remark,fw.transfer_no,
|
||||
fw.transfer_account_no,fw.document,fw.audit_time,fw.refuse_reason,fw.applet_type,fw.fail_reason, m.headimg,m.nickname,m.mobile as member_mobile,m.headimg';
|
||||
$join = [
|
||||
[ 'member m', 'fw.member_id = m.member_id', 'left' ]
|
||||
];
|
||||
$list = $model->getFenxiaoWithdrawPageList($condition, $page, $page_size, $order, $field, 'fw', $join);
|
||||
|
||||
foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
|
||||
$list[ 'data' ][ 'list' ][ $k ][ 'transfer_type_name' ] = $transfer_type_list[ $v[ 'transfer_type' ] ];
|
||||
}
|
||||
return $list;
|
||||
} else {
|
||||
$this->assign('transfer_type_list', $transfer_type_list);
|
||||
|
||||
$fenxiao_stat_model = new FenxiaoStat();
|
||||
$fenxiao_balance_sum = $fenxiao_stat_model->getFenxiaoAccountSum($this->site_id)[ 'data' ] ?? [];
|
||||
$this->assign('fenxiao_balance_sum', $fenxiao_balance_sum);
|
||||
|
||||
//提现状态
|
||||
$this->assign('status_list', $model->status);
|
||||
|
||||
$config_model = new WechatPayConfig();
|
||||
$config = $config_model->getPayConfig($this->site_id)[ 'data' ][ 'value' ];;
|
||||
$transfer_v3_type = $config['transfer_type'] == 'v3' && $config['transfer_v3_type'] == $config_model::TRANSFER_V3_TYPE_USER ;
|
||||
|
||||
$this->assign("transfer_v3_type",$transfer_v3_type);
|
||||
return $this->fetch("withdraw/lists");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现记录详情
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$fenxiao_withdraw_model = new FenxiaoWithdrawModel();
|
||||
$params = array (
|
||||
'id' => input('id', 0),
|
||||
'site_id' => $this->site_id
|
||||
);
|
||||
$detail = $fenxiao_withdraw_model->getFenxiaoWithdrawDetail($params)[ 'data' ] ?? [];
|
||||
if (empty($detail))
|
||||
$this->error('找不到提现账户记录');
|
||||
|
||||
$this->assign('info', $detail);
|
||||
return $this->fetch('withdraw/detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意
|
||||
* @return array
|
||||
*/
|
||||
public function agree()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input('id', 0);
|
||||
$fenxiao_withdraw_model = new FenxiaoWithdrawModel();
|
||||
$params = array (
|
||||
'site_id' => $this->site_id,
|
||||
"id" => $id,
|
||||
);
|
||||
$result = $fenxiao_withdraw_model->agree($params);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝
|
||||
* @return array
|
||||
*/
|
||||
public function refuse()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input('id', 0);
|
||||
$refuse_reason = input('refuse_reason', '');
|
||||
$fenxiao_withdraw_model = new FenxiaoWithdrawModel();
|
||||
$data = array (
|
||||
"refuse_reason" => $refuse_reason,
|
||||
'site_id' => $this->site_id,
|
||||
'id' => $id
|
||||
);
|
||||
$result = $fenxiao_withdraw_model->refuse($data);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
public function transferFinish()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input('id', 0);
|
||||
$certificate = input('certificate', '');
|
||||
$certificate_remark = input('certificate_remark', '');
|
||||
$fenxiao_withdraw_model = new FenxiaoWithdrawModel();
|
||||
$data = array (
|
||||
"id" => $id,
|
||||
"site_id" => $this->site_id,
|
||||
"certificate" => $certificate,
|
||||
"certificate_remark" => $certificate_remark,
|
||||
);
|
||||
$result = $fenxiao_withdraw_model->transferFinish($data);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
public function transfer()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input('id', 0);
|
||||
$fenxiao_withdraw_model = new FenxiaoWithdrawModel();
|
||||
$result = $fenxiao_withdraw_model->transfer([ 'id' => $id, 'site_id' => $this->site_id ]);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$fenxiao_withdraw_model = new FenxiaoWithdrawModel();
|
||||
|
||||
$withdraw_no = input('withdraw_no', '');
|
||||
$start_date = input('start_date', '');
|
||||
$end_date = input('end_date', '');
|
||||
$status = input('status', 'all');//提现状态
|
||||
$transfer_type = input('transfer_type', '');//提现转账方式
|
||||
$fenxiao_name = input('fenxiao_name', '');//提现转账方式
|
||||
|
||||
$payment_start_date = input('payment_start_date', '');
|
||||
$payment_end_date = input('payment_end_date', '');
|
||||
|
||||
$condition = [ [ 'site_id', '=', $this->site_id ] ];
|
||||
if (!empty($withdraw_no)) {
|
||||
$condition[] = [ 'withdraw_no', 'like', '%' . $withdraw_no . '%' ];
|
||||
}
|
||||
if (!empty($transfer_type)) {
|
||||
$condition[] = [ 'transfer_type', '=', $transfer_type ];
|
||||
}
|
||||
if ($status != "all") {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
if (!empty($fenxiao_name)) {
|
||||
$condition[] = [ 'fenxiao_name', '=', $fenxiao_name ];
|
||||
}
|
||||
if ($start_date != '' && $end_date != '') {
|
||||
$condition[] = [ 'create_time', 'between', [ strtotime($start_date), strtotime($end_date) ] ];
|
||||
} else if ($start_date != '' && $end_date == '') {
|
||||
$condition[] = [ 'create_time', '>=', strtotime($start_date) ];
|
||||
} else if ($start_date == '' && $end_date != '') {
|
||||
$condition[] = [ 'create_time', '<=', strtotime($end_date) ];
|
||||
}
|
||||
|
||||
if ($payment_start_date != '' && $payment_end_date != '') {
|
||||
$condition[] = [ 'payment_time', 'between', [ strtotime($payment_start_date), strtotime($payment_end_date) ] ];
|
||||
} else if ($payment_start_date != '' && $payment_end_date == '') {
|
||||
$condition[] = [ 'payment_time', '>=', strtotime($payment_start_date) ];
|
||||
} else if ($payment_start_date == '' && $payment_end_date != '') {
|
||||
$condition[] = [ 'payment_time', '<=', strtotime($payment_end_date) ];
|
||||
}
|
||||
$order = 'create_time desc';
|
||||
$fenxiao_withdraw_model->exportFenxiaoWithdraw($condition, $order, $this->site_id);
|
||||
}
|
||||
}
|
||||
135
addon/fenxiao/shop/view/config/agreement.html
Executable file
135
addon/fenxiao/shop/view/config/agreement.html
Executable file
@@ -0,0 +1,135 @@
|
||||
<div class="layui-form form-wrap">
|
||||
<!-- 基础上传 -->
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">分销商申请设置</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item apply">
|
||||
<label class="layui-form-label">显示申请协议:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_agreement" value="1" lay-filter="level" title="显示" {if $agreement_info.is_agreement == 1} checked {/if}/>
|
||||
<input type="radio" name="is_agreement" value="0" lay-filter="level" title="隐藏" {if $agreement_info.is_agreement != 1} checked {/if}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item apply_img">
|
||||
<label class="layui-form-label">申请页面顶部图片:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="upload-img-block">
|
||||
<div class="upload-img-box {notempty name="$agreement_info['img']"}hover{/notempty}">
|
||||
<div class="upload-default" id="applyImg">
|
||||
{if condition="$agreement_info.img"}
|
||||
<div id="preview_imgUpload" class="preview_img">
|
||||
<img layer-src src="{:img($agreement_info.img)}" class="img_prev"/>
|
||||
</div>
|
||||
{else/}
|
||||
<div class="upload">
|
||||
<i class="iconfont iconshangchuan"></i>
|
||||
<p>点击上传</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="operation">
|
||||
<div>
|
||||
<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
|
||||
<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
|
||||
</div>
|
||||
<div class="replace_img js-replace">点击替换</div>
|
||||
</div>
|
||||
<input type="hidden" name="img" value="{$agreement_info.img}">
|
||||
</div>
|
||||
<!-- <p id="applyImg" class=" {if condition='$agreement_info.img'} replace {else/} no-replace{/if}">替换</p>
|
||||
<input type="hidden" name="img" value="{$agreement_info.img}">
|
||||
<i class="del {if condition="$agreement_info.img"}show{/if}">x</i> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="word-aux">
|
||||
<p>建议尺寸:750*337像素</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">协议设置</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">协议名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="agreement_title" value="{$document.title}" lay-verify="required" class="layui-input len-mid new_pass" maxlength="18">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">协议内容:</label>
|
||||
<div class="layui-input-block">
|
||||
<script id="editor" type="text/plain" class="special-length" style="height:600px;"></script>
|
||||
<input type="hidden" name="agreement_content" id="agreement_content" value="{$document.content}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" style="margin-top:0;padding-left:20px;">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/ueditor.config.js?time=20240614"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/ueditor.all.js?time=20240614"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/lang/zh-cn/zh-cn.js"></script>
|
||||
<script>
|
||||
//实例化富文本
|
||||
var ue = UE.getEditor('editor');
|
||||
if($("#agreement_content").val()){
|
||||
ue.ready(function() {
|
||||
ue.setContent($("#agreement_content").val());
|
||||
});
|
||||
}
|
||||
|
||||
layui.use(['form'], function() {
|
||||
var form = layui.form,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
var upload = new Upload({
|
||||
elem: '#applyImg'
|
||||
});
|
||||
|
||||
form.on('submit(save)', function(data) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
var field = data.field;
|
||||
|
||||
// 删除图片
|
||||
if(!field.img) upload.delete();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("fenxiao://shop/config/agreement"),
|
||||
data: {
|
||||
'is_agreement' : field.is_agreement,
|
||||
'agreement_title' : field.agreement_title,
|
||||
'agreement_content' : ue.getContent(),
|
||||
'img' : field.img,
|
||||
},
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
482
addon/fenxiao/shop/view/config/basics.html
Executable file
482
addon/fenxiao/shop/view/config/basics.html
Executable file
@@ -0,0 +1,482 @@
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">分销设置</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否开启分销:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="level_config" value="1" lay-filter="open_distribution" title="开启" {if $basics_info.level > 0} checked {/if}/>
|
||||
<input type="radio" name="level_config" value="0" lay-filter="open_distribution" title="关闭" {if $basics_info.level == 0} checked {/if}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item distribution-index {if $basics_info.level == 0}layui-hide{/if}">
|
||||
<label class="layui-form-label">分销层级:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="level" value="1" title="一级分销" {if $basics_info.level == 1 || $basics_info.level == 0} checked {/if} lay-filter="level"/>
|
||||
<input type="radio" name="level" value="2" title="二级分销" {if $basics_info.level == 2} checked {/if} lay-filter="level"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item distribution-index {if $basics_info.level == 0}layui-hide{/if}">
|
||||
<label class="layui-form-label">是否开启自购分佣:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="self_purchase_rebate" value="1" title="开启" {if $basics_info.self_purchase_rebate == 1} checked {/if}/>
|
||||
<input type="radio" name="self_purchase_rebate" value="0" title="关闭" {if $basics_info.self_purchase_rebate != 1} checked {/if}/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux ">开启自购,分销商购买自身获得一级佣金<br/>关闭自购,分销商的上级分销商获得一级佣金,自身不再返佣</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item distribution-index {if $basics_info.level == 0}layui-hide{/if}">
|
||||
<label class="layui-form-label">是否展示商品详情一级佣金:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_commission_money" value="1" title="开启" {if $basics_info.is_commission_money == 1} checked {/if}/>
|
||||
<input type="radio" name="is_commission_money" value="0" title="关闭" {if $basics_info.is_commission_money != 1} checked {/if}/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux ">开启后,商品详情显示,关闭后,商品详情不显示</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief distribution-index {if $basics_info.level == 0}layui-hide{/if}">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">上下线关系</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">绑定下级条件:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="child_condition" value="1" lay-filter="child_condition" title="首次点击分享链接" checked />
|
||||
<input type="radio" name="child_condition" value="2" lay-filter="child_condition" title="首次下单" {if $relation_info.child_condition == 2} checked {/if}/>
|
||||
<input type="radio" name="child_condition" value="3" lay-filter="child_condition" title="首次付款" {if $relation_info.child_condition == 3} checked {/if}/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux" id="child_condition_desc"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief distribution-index {if $basics_info.level == 0}layui-hide{/if}">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">分销商资格</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item distribution-index">
|
||||
<label class="layui-form-label">分销商申请方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_apply" value="0" lay-filter="is_apply" title="人人分销" {if $basics_info.is_apply == 0} checked {/if}/>
|
||||
<input type="radio" name="is_apply" value="1" lay-filter="is_apply" title="申请分销" {if $basics_info.is_apply == 1} checked {/if}/>
|
||||
<input type="radio" name="is_apply" value="2" lay-filter="is_apply" title="手动设置" {if $basics_info.is_apply == 2} checked {/if}/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">人人分销:分销商不需要申请,达到条件自动成为分销商</div>
|
||||
<div class="word-aux">申请分销:会员达到条件需要申请才能成为分销商</div>
|
||||
<div class="word-aux">手动设置:分销商只有在后台进行添加,前台会员无法进行申请</div>
|
||||
</div>
|
||||
|
||||
<div class="fenxiao-condition" {if $basics_info.is_apply == 2}style="display:none;"{/if}>
|
||||
<div class="layui-form-item is-examine {if $basics_info.is_apply == 0}layui-hide{/if}">
|
||||
<label class="layui-form-label">是否需要审核:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_examine" value="1" title="开启" {if $basics_info.is_examine == 1} checked {/if}/>
|
||||
<input type="radio" name="is_examine" value="0" title="关闭" {if $basics_info.is_examine != 1} checked {/if}/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux ">开启后,分销商申请之后还需要后台审核</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item distributor">
|
||||
<label class="layui-form-label">成为分销商条件:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="fenxiao_condition" value="0" lay-filter="fenxiao_condition" title="无条件" {if $fenxiao_info.fenxiao_condition == 0} checked {/if}/>
|
||||
<!-- <input type="radio" name="fenxiao_condition" value="1" lay-filter="fenxiao_condition" title="申请" {if $fenxiao_info.fenxiao_condition == 1} checked {/if}/>-->
|
||||
<input type="radio" name="fenxiao_condition" value="2" lay-filter="fenxiao_condition" title="消费次数" {if $fenxiao_info.fenxiao_condition == 2} checked {/if}/>
|
||||
<input type="radio" name="fenxiao_condition" value="3" lay-filter="fenxiao_condition" title="消费金额" {if $fenxiao_info.fenxiao_condition == 3} checked {/if}/>
|
||||
<input type="radio" name="fenxiao_condition" value="4" lay-filter="fenxiao_condition" title="购买指定商品" {if $fenxiao_info.fenxiao_condition == 4} checked {/if}/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux"></div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide consume_count">
|
||||
<label class="layui-form-label">累计消费次数:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="consume_count" value="{$fenxiao_info.consume_count}" autocomplete="off" class="layui-input" onblur="checkInput(this, 'consume_count')">
|
||||
</div>
|
||||
<div class="layui-form-mid">次</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide consume_money">
|
||||
<label class="layui-form-label">累计消费金额:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="consume_money" value="{$fenxiao_info.consume_money}" autocomplete="off" class="layui-input" onblur="checkInput(this, 'consume_money')">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide consume_goods">
|
||||
<div class="layui-form-item goods_list">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<table id="selected_sku_list"></table>
|
||||
<input type="hidden" lay-verify="goods_ids" name="goods_ids">
|
||||
<button class="layui-btn" onclick="addGoods()">选择商品</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide consume_condition">
|
||||
<label class="layui-form-label">消费条件:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="consume_condition" value="1" title="付款后" checked/>
|
||||
<input type="radio" name="consume_condition" value="2" title="订单完成" {if $fenxiao_info.consume_condition == 2} checked {/if}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief distribution-index {if $basics_info.level == 0}layui-hide{/if}">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">默认分销佣金比率</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="fenxiao-rate">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级返佣比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_rate" value="{$level.one_rate ?? 0}" lay-verify="level_rate" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给对应分销商的返佣比例</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fenxiao-rate" {$basics_info.level >= 2}style="display:none"{/if}>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>二级返佣比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="two_rate" value="{$level.two_rate ?? 0}" lay-verify="level_rate" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给对应分销商的上级分销商返佣比例</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fenxiao-rate" {$basics_info.level == 3}style="display:none"{/if}>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>三级返佣比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="three_rate" value="{$level.three_rate ?? 0}" lay-verify="level_rate" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的上上级分销商返佣比例</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" style="margin-top:0;padding-left:20px;">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
</div>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" onclick="delGoods({{d.goods_id}})">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var selectedGoodsId = [], goods_id=[] ;
|
||||
var goods_list = {:json_encode($fenxiao_info.goods_list, JSON_UNESCAPED_UNICODE)};
|
||||
if (goods_list.length==0){
|
||||
goods_list = [];
|
||||
}
|
||||
$.each(goods_list, function(index, item) {
|
||||
var id = item.goods_id;
|
||||
selectedGoodsId.push(id);
|
||||
goods_id.push(id);
|
||||
});
|
||||
renderTable(goods_list);
|
||||
$("input[name='goods_ids']").val(goods_id.toString());
|
||||
layui.use(['form'], function() {
|
||||
var form = layui.form,
|
||||
openDistribution = "{$basics_info.level}",
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
renderTable(goods_list); // 初始化表格
|
||||
|
||||
form.verify({
|
||||
goods_ids: function(value){
|
||||
var type = $('[name="fenxiao_condition"]:checked').val();
|
||||
if(type==4){
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请选择商品';
|
||||
}
|
||||
}
|
||||
},
|
||||
level_rate: function (value, elem) {
|
||||
var title = $(elem).parents('.layui-form-item').find('.layui-form-label').text().replace('*', '').replace(':', '');
|
||||
if (!$(elem).is(':hidden')) {
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入' + title;
|
||||
}
|
||||
if (!/^(([0-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/.test(value)) {
|
||||
return title + `格式输入错误`;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(save)', function(data) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
if(!parseInt(openDistribution)){
|
||||
data.field.level = data.field.level_config;
|
||||
}
|
||||
if (data.field.level) {
|
||||
var rate = 0;
|
||||
$('.fenxiao-rate:not(:hidden)').each(function () {
|
||||
var value = parseFloat($(this).find('input').val());
|
||||
if (!isNaN(value)) rate += value;
|
||||
});
|
||||
if (rate > 100) {
|
||||
layer.msg('分销佣金比率之和不能超出100', {icon: 5});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("fenxiao://shop/config/basics"),
|
||||
data: data.field,
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on('radio(open_distribution)', function(data){
|
||||
openDistribution = data.value;
|
||||
if (!parseInt(openDistribution)){
|
||||
$(".distribution-index").addClass('layui-hide');
|
||||
return false;
|
||||
}
|
||||
$(".distribution-index").removeClass('layui-hide');
|
||||
});
|
||||
|
||||
form.on('radio(level)', function (data) {
|
||||
$('.fenxiao-rate').hide();
|
||||
$('.fenxiao-rate:lt('+ data.value +')').show()
|
||||
});
|
||||
|
||||
form.on('radio(is_apply)', function (data) {
|
||||
if (data.value == 0) {
|
||||
$('.is-examine').addClass('layui-hide');
|
||||
$('.fenxiao-condition').show();
|
||||
$('[name="is_examine"][value="0"]').prop('checked', true);
|
||||
} else if (data.value == 1) {
|
||||
$('.is-examine').removeClass('layui-hide');
|
||||
$('.fenxiao-condition').show();
|
||||
} else {
|
||||
$('.fenxiao-condition').hide();
|
||||
}
|
||||
});
|
||||
|
||||
//监听成为分销商条件选择
|
||||
form.on('radio(fenxiao_condition)', function(data){
|
||||
var value = data.value;
|
||||
distributionConditions(value);
|
||||
});
|
||||
|
||||
form.on('radio(child_condition)', function(data){
|
||||
childConditionChange(data.value);
|
||||
});
|
||||
|
||||
function childConditionChange(child_condition){
|
||||
var config = {
|
||||
1 : '非分销商用户在点击分销商的分享链接后即可成为该分销商的下线',
|
||||
2 : '非分销商用户在点击分销商的分享链接后在商城中创建订单即可成为该分销商的下线',
|
||||
3 : '非分销商用户在点击分销商的分享链接后在商城中创建订单并支付成功即可成为该分销商的下线',
|
||||
};
|
||||
$("#child_condition_desc").html(config[child_condition]);
|
||||
}
|
||||
|
||||
//默认选中
|
||||
childConditionChange('{$relation_info.child_condition}');
|
||||
|
||||
distributionConditions("{$fenxiao_info.fenxiao_condition}");
|
||||
function distributionConditions (value){
|
||||
value = parseInt(value);
|
||||
|
||||
$('.consume_count').addClass("layui-hide");
|
||||
$('.consume_money').addClass("layui-hide");
|
||||
$('.consume_goods').addClass("layui-hide");
|
||||
$('.consume_condition').addClass("layui-hide");
|
||||
$('.apply').addClass("layui-hide");
|
||||
|
||||
//无条件
|
||||
if(value == 0){
|
||||
$(".distributor .word-aux").text("不需要任何条件,申请注册即可成为分销商");
|
||||
}
|
||||
//申请
|
||||
if(value == 1){
|
||||
$('.apply').removeClass("layui-hide");
|
||||
$(".distributor .word-aux").text("需申请通过,才可以成为分销商");
|
||||
}
|
||||
//消费次数
|
||||
if(value == 2){
|
||||
$('.consume_count').removeClass("layui-hide");
|
||||
$('.consume_condition').removeClass("layui-hide");
|
||||
|
||||
$(".distributor .word-aux").text("当消费次数达到一定数量并申请通过才可以成为分销商");
|
||||
}
|
||||
//消费金额
|
||||
if(value == 3){
|
||||
$('.consume_money').removeClass("layui-hide");
|
||||
$('.consume_condition').removeClass("layui-hide");
|
||||
|
||||
$(".distributor .word-aux").text("当消费金额达到一定数量并申请通过才可以成为分销商");
|
||||
}
|
||||
//购买指定商品
|
||||
if(value == 4){
|
||||
$('.consume_goods').removeClass("layui-hide");
|
||||
$('.consume_condition').removeClass("layui-hide");
|
||||
|
||||
$(".distributor .word-aux").text("商品任选其-购买即可成为分销商");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/* 商品 */
|
||||
function addGoods(){
|
||||
goodsSelect(function (data) {
|
||||
|
||||
goods_list = [];
|
||||
goods_id = [];
|
||||
|
||||
for (var key in data) {
|
||||
goods_id.push(data[key].goods_id);
|
||||
goods_list.push(data[key]);
|
||||
}
|
||||
|
||||
renderTable(goods_list);
|
||||
$("input[name='goods_ids']").val(goods_id.toString());
|
||||
selectedGoodsId = goods_id;
|
||||
|
||||
}, selectedGoodsId, {mode: "spu"});
|
||||
}
|
||||
|
||||
// 删除选中商品
|
||||
function delGoods(id) {
|
||||
var i, j;
|
||||
$.each(goods_list, function(index, item) {
|
||||
var goods_id = item.goods_id;
|
||||
|
||||
if (id == Number(goods_id)) {
|
||||
i = index;
|
||||
}
|
||||
});
|
||||
goods_list.splice(i, 1);
|
||||
renderTable(goods_list);
|
||||
|
||||
$.each(selectedGoodsId, function(index, item) {
|
||||
if (id == Number(item)) {
|
||||
j = index;
|
||||
}
|
||||
});
|
||||
selectedGoodsId.splice(j, 1);
|
||||
goods_id = selectedGoodsId;
|
||||
$("input[name='goods_ids']").val(goods_id.toString());
|
||||
}
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(goods_list) {
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_sku_list',
|
||||
page: false,
|
||||
limit: Number.MAX_VALUE,
|
||||
cols: [
|
||||
[{
|
||||
field: 'goods_name',
|
||||
title: '商品名称',
|
||||
unresize: 'false',
|
||||
width: '50%',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `
|
||||
<div class="goods-title" style="display:flex;">
|
||||
<div class="goods-img">
|
||||
<img src="${data.goods_image ? ns.img(data.goods_image.split(",")[0],'small') : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name" style="margin:20px 0 0 10px;">${data.goods_name}</p>
|
||||
</div>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格(元)',
|
||||
unresize: 'false',
|
||||
align: 'right',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}, {
|
||||
field: 'goods_stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
align: 'center',
|
||||
width: '20%'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}],
|
||||
],
|
||||
data: goods_list,
|
||||
});
|
||||
}
|
||||
function checkInput(obj, type){
|
||||
if(type == 'consume_money'){
|
||||
$(obj).val(Math.abs($(obj).val()));
|
||||
}
|
||||
if(type == 'consume_count'){
|
||||
$(obj).val(Math.floor(Math.abs($(obj).val())));
|
||||
}
|
||||
}
|
||||
</script>
|
||||
58
addon/fenxiao/shop/view/config/promote_rule.html
Executable file
58
addon/fenxiao/shop/view/config/promote_rule.html
Executable file
@@ -0,0 +1,58 @@
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">推广活动规则设置</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">规则内容:</label>
|
||||
<div class="layui-input-block">
|
||||
<script id="editor" type="text/plain" class="special-length" style="height:600px;"></script>
|
||||
<input type="hidden" name="content" id="content" value="{$document.content}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/ueditor.config.js?time=20240614"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/ueditor.all.js?time=20240614"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/lang/zh-cn/zh-cn.js"></script>
|
||||
|
||||
<script>
|
||||
//实例化富文本
|
||||
var ue = UE.getEditor('editor');
|
||||
if($("#content").val()){
|
||||
ue.ready(function() {
|
||||
ue.setContent($("#content").val());
|
||||
});
|
||||
}
|
||||
|
||||
layui.use(['form'], function() {
|
||||
var form = layui.form,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
form.on('submit(save)', function(data) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("fenxiao://shop/config/promoterule"),
|
||||
data: {
|
||||
'content' : ue.getContent(),
|
||||
},
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
144
addon/fenxiao/shop/view/config/settlement.html
Executable file
144
addon/fenxiao/shop/view/config/settlement.html
Executable file
@@ -0,0 +1,144 @@
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">提现设置</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">提现审核:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="withdraw_status" value="1" title="手动审核" {if $withdraw_info.withdraw_status == 1} checked {/if} />
|
||||
<input type="radio" name="withdraw_status" value="2" title="自动审核" {if $withdraw_info.withdraw_status == 2} checked {/if}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">自动转账:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="is_auto_transfer" lay-filter="is_auto_transfer" value="1" lay-skin="switch" {if !empty($withdraw_info.is_auto_transfer) && $withdraw_info.is_auto_transfer==1 } checked {/if} >
|
||||
</div>
|
||||
<div class="word-aux">只有微信和支付宝支付支持自动转账</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">佣金提现手续费:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="withdraw_rate" lay-verify="positivEinteger" value="{$withdraw_info.withdraw_rate ?? 0}" autocomplete="off" class="layui-input len-short" >
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
</div>
|
||||
<div class="word-aux">比率必须为0-100的数且保留两位小数,提现到余额时没有手续费</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">最低提现金额:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="withdraw" id="min" value="{if condition="!empty($withdraw_info.withdraw)"}{$withdraw_info.withdraw ?: 0}{else/}0{/if}" lay-verify="growthMinInteger" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">最低提现金额必须大于0</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">最高提现额度:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="max" value="{if condition="!empty($withdraw_info.max)"}{$withdraw_info.max ?: 0}{else/}0{/if}" lay-verify="growthMaxInteger" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">额度设置为0为不限制</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">转账方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
{foreach $transfer_type_list as $k => $v}
|
||||
<input type="checkbox" lay-filter="transfer_type" name="transfer_type[]" title="{$v}" lay-skin="primary" value="{$k}" {if !empty($withdraw_info.transfer_type) && stripos($withdraw_info.transfer_type, $k) !== false}checked{/if}>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use(['form'], function() {
|
||||
var form = layui.form,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
form.on('submit(save)', function(data) {
|
||||
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("fenxiao://shop/config/settlement"),
|
||||
data: data.field,
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
max_no_fee: function(value){
|
||||
|
||||
var min_no_fee = $('input[name="min_no_fee"]').val();
|
||||
|
||||
if(parseFloat(min_no_fee) > parseFloat(value)){
|
||||
return '免手续费区间输入有误,区间最大值不能小于最小值';
|
||||
}
|
||||
},
|
||||
positivEinteger: function(value){
|
||||
if (parseFloat(value) < 0 || parseFloat(value) > 100) {
|
||||
return '请输入0-100之间的数';
|
||||
}
|
||||
if (value.split(".").length > 1) {
|
||||
var len = value.split(".")[1].length;
|
||||
if (len > 2) {
|
||||
return '门店抽成比率最多两位小数';
|
||||
}
|
||||
}
|
||||
},
|
||||
growthMinInteger: function (value) {
|
||||
if(value <= 0){
|
||||
return '最低提现金额必须大于0';
|
||||
}
|
||||
if (value.split(".").length > 1) {
|
||||
let len = value.split(".")[1].length;
|
||||
if (len > 2) {
|
||||
return '最低提现金额最多保留两位小数';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
growthMaxInteger: function (value) {
|
||||
var min = $('#min').val();
|
||||
if(parseFloat(value) < 0){
|
||||
return '最高提现额度不可为负数';
|
||||
}
|
||||
|
||||
if(parseInt(min) > 0 && parseInt(value) > 0 && parseInt(value) < parseInt(min)){
|
||||
return '不能小于最低提现额度';
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
96
addon/fenxiao/shop/view/config/words.html
Executable file
96
addon/fenxiao/shop/view/config/words.html
Executable file
@@ -0,0 +1,96 @@
|
||||
<div class="layui-form form-wrap">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分销概念:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="concept" lay-verify="required" {if condition="isset($config_info.concept)"} value='{$config_info.concept}' {/if} autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>更改分销概念的名称,在我的分销中心以及申请成为分销商页面,会用新的分销概念名称替换分销概念</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分销商名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="fenxiao_name" lay-verify="required" {if condition="isset($config_info.fenxiao_name)"} value='{$config_info.fenxiao_name}' {/if} autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>更改分销商的名称,在我的分销中心以及申请成为分销商页面,会用新的分销商名称替换分销商名称</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">提现:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="withdraw" lay-verify="required" {if condition="isset($config_info.withdraw)"} value='{$config_info.withdraw}' {/if} autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>更改提现名称,在我的分销中心以及申请成为分销商页面,会用新的提现名称替换提现</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">佣金:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="account" lay-verify="required" {if condition="isset($config_info.account)"} value='{$config_info.account}' {/if} autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>更改佣金名称,在我的分销中心以及申请成为分销商页面,会用新的分佣金名称替换佣金</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">我的团队:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="my_team" lay-verify="required" {if condition="isset($config_info.my_team)"} value='{$config_info.my_team}' {/if} autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>更改我的团队名称,在我的分销中心以及申请成为分销商页面,会用新的我的团队名称替换我的团队</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">下线:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="child" lay-verify="required" {if condition="isset($config_info.child)"} value='{$config_info.child}' {/if} autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>更改下线名称,在我的分销中心以及申请成为分销商页面,会用新的下线名称替换下线</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use(['form'], function() {
|
||||
var form = layui.form,
|
||||
repeat_flag = false;
|
||||
form.render();
|
||||
|
||||
/**
|
||||
* 表单提交
|
||||
*/
|
||||
form.on('submit(save)', function(data){
|
||||
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("fenxiao://shop/config/words"),
|
||||
data: data.field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
layer.msg(res.message);
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
||||
400
addon/fenxiao/shop/view/fenxiao/add.html
Executable file
400
addon/fenxiao/shop/view/fenxiao/add.html
Executable file
@@ -0,0 +1,400 @@
|
||||
<link rel="stylesheet" type="text/css" href="REPLACEBUY_CSS/index.css"/>
|
||||
<style>
|
||||
.layui-form {
|
||||
position: relative;
|
||||
}
|
||||
.layui-form-label {
|
||||
text-align: right;
|
||||
margin-left: 60px;
|
||||
}
|
||||
.layui-form-item {
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
.fenxiao-select {
|
||||
position: absolute;
|
||||
left: 400px;
|
||||
top: 135px;
|
||||
}
|
||||
.member-select {
|
||||
position: absolute;
|
||||
left: 400px;
|
||||
top: 175px;
|
||||
}
|
||||
.member-select-add{
|
||||
border:1px solid;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
.layui-unselect.layui-form-radio.layui-form-radioed i:after {
|
||||
background-color: #fff;
|
||||
}
|
||||
.layui-table-body {
|
||||
max-height: 530px;
|
||||
}
|
||||
.inline{width: 205px;}
|
||||
.layui-input{width: 205px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>分销商名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="fenxiao_name" type="text" lay-verify="required" class="layui-input len-mid">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>分销商等级:</label>
|
||||
<div class="layui-input-inline len-mid">
|
||||
<select name="level_id" lay-verify="required">
|
||||
<option value="">请选择</option>
|
||||
{volist name="$level_list" id="level"}
|
||||
<option value="{$level.level_id}">{$level.level_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">上级分销商:</label>
|
||||
<!-- <div class="layui-input-inline len-mid">
|
||||
<select name="fenxiao_id" lay-filter="fenxiao_id">
|
||||
<option value="">请选择</option>
|
||||
{volist name="$fenxiao_list" id="fenxiao"}
|
||||
<option value="{$fenxiao.fenxiao_id}">{$fenxiao.fenxiao_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div> -->
|
||||
<button class="layui-btn layui-btn1" onclick="addFenxiao()">选择分销商</button>
|
||||
</div>
|
||||
|
||||
<div class="fenxiao-select"></div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>关联会员:</label>
|
||||
<!-- <div class="layui-input-inline len-mid">
|
||||
<select name="member_id" lay-verify="required" lay-filter="member_id">
|
||||
<option value="">请选择</option>
|
||||
{volist name="$member_list" id="member"}
|
||||
<option value="{$member.member_id}">{$member.nickname}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div> -->
|
||||
<button class="layui-btn layui-btn2" onclick="addMember()">选择会员</button>
|
||||
</div>
|
||||
|
||||
<div class="member-select"></div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" type="reset" onclick="backFenxiaoList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="addFenxiao">
|
||||
<div class="layui-form">
|
||||
<div class="layui-input-inline inline">
|
||||
<input type="text" name="fenxiao_search" placeholder="请输入分销商名称" autocomplete="off" class="layui-input ">
|
||||
<button type="button" class="layui-btn layui-btn-primary fenxiao-search" lay-filter="search" lay-submit>
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
<table id="fenxiao_list" lay-filter="fenxiao_list"></table>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="addMember">
|
||||
<div class="layui-form">
|
||||
<div class="layui-input-inline inline">
|
||||
<input type="text" name="member_search" placeholder="请输入会员名称" autocomplete="off" class="layui-input ">
|
||||
<button type="button" class="layui-btn layui-btn-primary member-search" lay-filter="search" lay-submit>
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
<table id="member_list" lay-filter="member_list"></table>
|
||||
</div>
|
||||
</script>
|
||||
<!-- 会员详情 -->
|
||||
<script type="text/html" id="member_detail">
|
||||
<div class="member-detail">
|
||||
<div class="table-title checked-peo">
|
||||
<div class="title-pic">
|
||||
<img src="{{ns.img(d.headimg)}}" onerror=src="{:img('public/static/img/default_img/head.png')}" />
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<div class="member-con-first">
|
||||
<h3 class="nickname" title="{{d.nickname}}">{{d.nickname}}</h3>
|
||||
</div>
|
||||
<div class="member-con-second">
|
||||
<p class="text-color-gray"><span class="member-mobile">{{d.mobile == "" ? '--' : d.mobile}}</span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="layui-btn check-btn" lay-submit lay-filter="logout_member">重新选择</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var new_fenxiao_id = 0;var new_member_id = 0,repeat_flag = false,table;
|
||||
layui.use(['form', 'laytpl'], function() {
|
||||
laytpl = layui.laytpl;
|
||||
form = layui.form;
|
||||
|
||||
form.render();
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data) {
|
||||
data.field.fenxiao_id = new_fenxiao_id;
|
||||
data.field.member_id = new_member_id;
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/fenxiao/add"),
|
||||
data: data.field,
|
||||
dataType: 'JSON', //服务器返回json格式数据
|
||||
type: 'POST', //HTTP请求类型
|
||||
success: function(res) {
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.message);
|
||||
location.hash = ns.hash("fenxiao://shop/fenxiao/lists")
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
function backFenxiaoList() {
|
||||
location.hash = ns.hash("fenxiao://shop/fenxiao/lists");
|
||||
}
|
||||
|
||||
// 会员详情页面渲染
|
||||
function memberDetail(data) {
|
||||
laytpl($("#member_detail").html()).render(data, function(html) {
|
||||
$(".member").html(html);
|
||||
$("#member_id").val(data.member_id);
|
||||
})
|
||||
}
|
||||
|
||||
var add_attr_radioState = 0;
|
||||
var add_attr_radioState2 = 0;
|
||||
function addFenxiao() {
|
||||
var add_attr = $("#addFenxiao").html();
|
||||
var _this = this;
|
||||
form.on('radio(layfenxiaoid)', function(obj){
|
||||
new_fenxiao_id = obj.value;
|
||||
_this.add_attr_radioState = obj.value;
|
||||
var title_fenxiao = ($(this).data('index'));
|
||||
$('.layui-btn1').parents('.layui-form-item').next('.fenxiao-select').html(title_fenxiao)
|
||||
});
|
||||
|
||||
laytpl(add_attr).render({}, function(html) {
|
||||
|
||||
add_attr_index = layer.open({
|
||||
title: '选择分销商',
|
||||
skin: 'layer-tips-class',
|
||||
type: 1,
|
||||
area: ['1000px', '800px'],
|
||||
content: html,
|
||||
btn: ["保存", "返回"],
|
||||
yes: function () {
|
||||
layer.close(add_attr_index);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#fenxiao_list',
|
||||
url: ns.url("fenxiao://shop/fenxiao/getfenxiaolist"),
|
||||
cols: [
|
||||
[{
|
||||
width: "20%",
|
||||
title: '分销商选择',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
if(data.fenxiao_id == Number(add_attr_radioState)){
|
||||
html += `
|
||||
<div>
|
||||
<input type="radio" name="layTableRadioc" checked = true value="${data.fenxiao_id}" data-index="${data.fenxiao_name}" lay-type="layTableRadio" lay-filter="layfenxiaoid">
|
||||
</div>
|
||||
`;
|
||||
}else{
|
||||
html += `
|
||||
<div>
|
||||
<input type="radio" name="layTableRadioc" value="${data.fenxiao_id}" data-index="${data.fenxiao_name}" lay-type="layTableRadio" lay-filter="layfenxiaoid">
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
return html;
|
||||
}
|
||||
},{
|
||||
title: '分销商名称',
|
||||
width: '50%',
|
||||
unresize: 'false',
|
||||
field: 'fenxiao_name',
|
||||
}, {
|
||||
field: 'account',
|
||||
title: '佣金',
|
||||
unresize: 'false',
|
||||
width: '30%',
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function (data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
$(document).keydown(function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
$(".fenxiao-search").trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function addMember() {
|
||||
var _this = this;
|
||||
var add_attr2 = $("#addMember").html();
|
||||
form.on('radio(laymemberid)', function(obj){
|
||||
new_member_id = obj.value;
|
||||
_this.add_attr_radioState2 = obj.value;
|
||||
});
|
||||
|
||||
laytpl(add_attr2).render({}, function(html) {
|
||||
var add_attr_index2 = layer.open({
|
||||
title: '选择会员',
|
||||
skin: 'layer-tips-class',
|
||||
type: 1,
|
||||
area: ['1000px', '800px'],
|
||||
content: html,
|
||||
btn:["保存","返回"],
|
||||
yes: function(){
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/fenxiao/memberInfo"),
|
||||
data:{member_id: new_member_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
if (res.code == 0) {
|
||||
var html = '';
|
||||
html += '<div class="member-detail">'
|
||||
+'<div class="table-title checked-peo">'
|
||||
+'<div class="title-pic">'
|
||||
+'<img src="'+ns.img(res.data.headimg)+'" onerror=this.src="{:img('public/static/img/default_img/head.png')}" />'
|
||||
+'</div>'
|
||||
+'<div class="title-content">'
|
||||
+'<div class="member-con-first">'
|
||||
+'<h3 class="nickname" title="'+res.data.nickname+'">'+res.data.nickname+'</h3>'
|
||||
+'</div>'
|
||||
+'<div class="member-con-second">';
|
||||
if(res.data.mobile){
|
||||
html += '<p class="text-color-gray"><span class="member-mobile">'+res.data.mobile+'</span></p>'
|
||||
}else{
|
||||
html += '<p class="text-color-gray"><span class="member-mobile">'+'--'+'</span></p>'
|
||||
}
|
||||
|
||||
html+= '</div>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'</div>';
|
||||
// memberDetail(res.data);
|
||||
$('.layui-btn2').parents('.layui-form-item').next('.member-select').html(html);
|
||||
$('.layui-btn2').parents('.layui-form-item').next('.member-select').addClass('member-select-add border-color');
|
||||
layer.close(add_attr_index2);
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
// memberDetail(res.data);
|
||||
// layer.close(add_attr_index2);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#member_list',
|
||||
url: ns.url("fenxiao://shop/fenxiao/getmemberlist"),
|
||||
cols: [
|
||||
[{
|
||||
width: "12%",
|
||||
title: '会员选择',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
if(data.member_id == Number(add_attr_radioState2)){
|
||||
html += `
|
||||
<div>
|
||||
<input type="radio" name="layTableRadioc" checked = true value="${data.member_id}" data-index="${data.nickname}" lay-type="layTableRadio" lay-filter="laymemberid">
|
||||
</div>
|
||||
`;
|
||||
}else{
|
||||
html += `
|
||||
<div>
|
||||
<input type="radio" name="layTableRadioc" value="${data.member_id}" data-index="${data.nickname}" lay-type="layTableRadio" lay-filter="laymemberid">
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
return html;
|
||||
}
|
||||
},{
|
||||
title: '分销商名称',
|
||||
width: '50%',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `
|
||||
<div>
|
||||
<img style="width:40px; height:40px; margin-right:20px;" layer-src src="${ns.img(data.headimg)}" onerror="this.src = '{:img('public/static/img/default_img/head.png')}' "><span>${data.nickname}</span>
|
||||
</div>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'balance',
|
||||
title: '余额',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
},{
|
||||
field: 'point',
|
||||
title: '积分',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function (data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
$(document).keydown(function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
$(".member-search").trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
269
addon/fenxiao/shop/view/fenxiao/apply.html
Executable file
269
addon/fenxiao/shop/view/fenxiao/apply.html
Executable file
@@ -0,0 +1,269 @@
|
||||
<style>
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline {
|
||||
background-color: #fff;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="screen layui-collapse" lay-filter="">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">昵称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="nickname" placeholder="请输入申请人昵称" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">手机号:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="mobile" placeholder="请输入申请人手机号" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">申请等级:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="level_id" lay-filter="level_id">
|
||||
<option value="">全部</option>
|
||||
{volist name="$level_list" id="level"}
|
||||
<option value="{$level.level_id}">{$level.level_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">注册时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="rg_start_time" id="rg_start_time" autocomplete="off" placeholder="开始时间" >
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="rg_end_time" id="rg_end_time" autocomplete="off" placeholder="结束时间" >
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">申请时间:</label>
|
||||
<!-- <div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="expire_time" id="expire_time" autocomplete="off" >
|
||||
</div> -->
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="create_start_time" id="create_start_time" autocomplete="off" placeholder="开始时间" >
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="create_end_time" id="create_end_time" autocomplete="off" placeholder="结束时间" >
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="status">
|
||||
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="fenxiao_list" lay-filter="fenxiao_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 用户信息 -->
|
||||
<script type="text/html" id="member_info">
|
||||
<div class='table-title'>
|
||||
<div class='title-pic'>
|
||||
<img layer-src src="{{ns.img(d.headimg)}}" onerror="this.src = '{:img('public/static/img/default_img/head.png')}' ">
|
||||
</div>
|
||||
<div class='title-content'>
|
||||
<p class="layui-elip">{{d.nickname}}</p>
|
||||
<p class="layui-elip">{{d.mobile}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 1){ }}
|
||||
<span style="color: red;">待审核</span>
|
||||
{{# }else if(d.status == 2){ }}
|
||||
<span style="color: green;">审核通过</span>
|
||||
{{# }else if(d.status == -1){ }}
|
||||
<span style="color: gray;">审核拒绝</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 工具栏操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="detail">会员信息</a>
|
||||
{{# if(d.status == 1){ }}
|
||||
<a class="layui-btn" lay-event="pass">审核通过</a>
|
||||
<a class="layui-btn" lay-event="refuse">审核拒绝</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'laydate', 'element'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
element = layui.element,
|
||||
laydate = layui.laydate;
|
||||
var repeat_flag = false;
|
||||
form.render();
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#create_start_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
laydate.render({
|
||||
elem: '#create_end_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#rg_start_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
laydate.render({
|
||||
elem: '#rg_end_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
//监听Tab切换
|
||||
element.on('tab(status)', function(data) {
|
||||
var status = $(this).attr("lay-id");
|
||||
table.reload( {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': status
|
||||
}
|
||||
});
|
||||
});
|
||||
table = new Table({
|
||||
elem: '#fenxiao_list',
|
||||
url: ns.url("fenxiao://shop/fenxiao/apply"),
|
||||
cols: [
|
||||
[{
|
||||
field: 'member_name',
|
||||
title: '会员信息',
|
||||
unresize: 'false',
|
||||
templet:'#member_info'
|
||||
},{
|
||||
field: 'fenxiao_name',
|
||||
title: '申请分销商名称',
|
||||
unresize: 'false'
|
||||
}, {
|
||||
field: 'level_name',
|
||||
title: '申请分销等级',
|
||||
unresize: 'false',
|
||||
}, {
|
||||
field: 'child',
|
||||
title: '会员消费(次数/金额)',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
return data.order_complete_num+' / '+data.order_complete_money;
|
||||
}
|
||||
}, {
|
||||
field: 'create_time',
|
||||
title: '申请时间',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.create_time);
|
||||
}
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data,
|
||||
event = obj.event;
|
||||
switch (event) {
|
||||
case 'detail': //查看
|
||||
location.hash = ns.hash('shop/member/editmember?member_id='+data.member_id);
|
||||
break;
|
||||
case 'pass': //通过
|
||||
layer.confirm('确定要通过吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/fenxiao/applypass"),
|
||||
data: {apply_id:data.apply_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'refuse': //拒绝
|
||||
layer.confirm('确定要拒绝吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/fenxiao/applyrefuse"),
|
||||
data: {apply_id:data.apply_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
243
addon/fenxiao/shop/view/fenxiao/change.html
Executable file
243
addon/fenxiao/shop/view/fenxiao/change.html
Executable file
@@ -0,0 +1,243 @@
|
||||
<style>
|
||||
.screen {
|
||||
margin-top: 15px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
<div class="layui-form-item">
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">分销商名称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="fenxiao_name" name="fenxiao_name" placeholder="请输入分销商名称" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">分销等级:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="level_id" lay-filter="level_id">
|
||||
<option value="">全部</option>
|
||||
{volist name="$level_list" id="level"}
|
||||
<option value="{$level.level_id}">{$level.level_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">分销商状态:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="status" lay-filter="status">
|
||||
<option value="">全部</option>
|
||||
<option value="1">正常</option>
|
||||
<option value="-1">已冻结</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">添加时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" id="start_time" autocomplete="off" placeholder="开始时间" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" id="end_time" autocomplete="off" placeholder="结束时间" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="parent_fenxiao_id" id="" {if $parent_info}value="{$parent_info.fenxiao_id }"{/if}/>
|
||||
<!-- 列表 -->
|
||||
<table id="fenxiao_list" lay-filter="fenxiao_list"></table>
|
||||
|
||||
<input type="hidden" value="" id="param" />
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 1){ }}
|
||||
<span style="color: green;">正常</span>
|
||||
{{# }else if(d.status == -1){ }}
|
||||
<span style="color: gray;">冻结</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 工具栏操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
{{# if(d.fenxiao_id != parent_fenxiao_id){ }}
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="confirm">变更</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# if(d.fenxiao_id == parent_fenxiao_id){ }}
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn red-color" lay-event="cancelconfirm">取消</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var change_end_func = '{$change_end_func}';
|
||||
var repeat_flag = false;
|
||||
var parent_fenxiao_id = $("input[name='parent_fenxiao_id']").val();
|
||||
layui.use(['form', 'laydate'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
laydate = layui.laydate;
|
||||
form.render();
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#fenxiao_list',
|
||||
url: ns.url("fenxiao://shop/fenxiao/change"),
|
||||
where:{
|
||||
member_id : "{$member_id}"
|
||||
},
|
||||
cols: [
|
||||
[{
|
||||
field: 'fenxiao_name',
|
||||
title: '分销商名称',
|
||||
unresize: 'false',
|
||||
width: '30%'
|
||||
}
|
||||
, {
|
||||
field: 'level_name',
|
||||
title: '分销等级',
|
||||
unresize: 'false',
|
||||
width: '20%'
|
||||
}, {
|
||||
field: 'status',
|
||||
title: '当前状态',
|
||||
templet: '#status',
|
||||
unresize: 'false',
|
||||
width: '10%'
|
||||
}, {
|
||||
field: 'create_time',
|
||||
title: '添加时间',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.create_time);
|
||||
}
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作+
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data,
|
||||
event = obj.event;
|
||||
switch (event) {
|
||||
case 'confirm': //确认更改上下级关系
|
||||
layer.confirm('确定要变更该分销商为上级分销商吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/fenxiao/confirmChange"),
|
||||
data: {
|
||||
parent:data.fenxiao_id,
|
||||
member_id:"{$member_id}",
|
||||
type:1
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
$("#param").val(1);
|
||||
if(typeof parent[change_end_func] == 'function'){
|
||||
parent[change_end_func]();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'cancelconfirm': //确认更改上下级关系
|
||||
layer.confirm('确定要取消上级分销商吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/fenxiao/confirmChange"),
|
||||
data: {
|
||||
parent:data.fenxiao_id,
|
||||
member_id:"{$member_id}",
|
||||
type:2
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
$("#param").val(1);
|
||||
if(typeof parent[change_end_func] == 'function'){
|
||||
parent[change_end_func]();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function fun(callback) {
|
||||
var param = $("#param").val();
|
||||
callback(param);
|
||||
}
|
||||
</script>
|
||||
130
addon/fenxiao/shop/view/fenxiao/change_level.html
Executable file
130
addon/fenxiao/shop/view/fenxiao/change_level.html
Executable file
@@ -0,0 +1,130 @@
|
||||
<!-- 列表 -->
|
||||
<table id="level_list" lay-filter="level_list"></table>
|
||||
|
||||
<input type="hidden" value="" id="param" />
|
||||
|
||||
<!-- 工具栏操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="confirm">变更</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var change_end_func = '{$change_end_func}';
|
||||
var repeat_flag = false;
|
||||
layui.use(['form'], function() {
|
||||
var table, form = layui.form;
|
||||
form.render();
|
||||
|
||||
table = new Table({
|
||||
elem: '#level_list',
|
||||
url: ns.url("fenxiao://shop/fenxiao/changelevel"),
|
||||
where:{
|
||||
fenxiao_id : "{$fenxiao_id}"
|
||||
},
|
||||
cols: [
|
||||
[{
|
||||
title: '等级',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: function (data) {
|
||||
var level = new Array();
|
||||
level[0] = '默认等级';
|
||||
level[1] = '一级';
|
||||
level[2] = '二级';
|
||||
level[3] = '三级';
|
||||
level[4] = '四级';
|
||||
level[5] = '五级';
|
||||
level[6] = '六级';
|
||||
level[7] = '七级';
|
||||
level[8] = '八级';
|
||||
level[9] = '九级';
|
||||
level[10] = '十级';
|
||||
return level[data.level_num] != undefined ? level[data.level_num] : '';
|
||||
}
|
||||
}, {
|
||||
field: 'level_name',
|
||||
title: '等级名称',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
}, {
|
||||
field: 'one_rate',
|
||||
title: '一级佣金比例',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return data.one_rate + '%';
|
||||
},
|
||||
hide: {if $basics_info.level >= 1} false {else /} true {/if}
|
||||
}, {
|
||||
field: 'two_rate',
|
||||
title: '二级佣金比例',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return data.two_rate + '%';
|
||||
},
|
||||
hide: {if $basics_info.level >= 2} false {else /} true {/if}
|
||||
},{
|
||||
field:'three_rate',
|
||||
title: '三级佣金比例',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return data.three_rate + '%';
|
||||
},
|
||||
hide: {if $basics_info.level >= 3} false {else /} true {/if}
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data,
|
||||
event = obj.event;
|
||||
switch (event) {
|
||||
case 'confirm': //确认更改上下级关系
|
||||
layer.confirm('确定要变更为该等级吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/fenxiao/confirmChangeLevel"),
|
||||
data: {
|
||||
level_id:data.level_id,
|
||||
member_id:"{$member_id}"
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
$("#param").val(1);
|
||||
if(typeof parent[change_end_func] == 'function'){
|
||||
parent[change_end_func]();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function fun(callback) {
|
||||
var param = $("#param").val();
|
||||
callback(param);
|
||||
}
|
||||
</script>
|
||||
126
addon/fenxiao/shop/view/fenxiao/fenxiao_account.html
Executable file
126
addon/fenxiao/shop/view/fenxiao/fenxiao_account.html
Executable file
@@ -0,0 +1,126 @@
|
||||
<style>
|
||||
.layui-layout-admin .table-tab .layui-tab-title{margin-bottom: 15px;}
|
||||
.calendar{line-height: 34px;text-align: center;}
|
||||
</style>
|
||||
<!-- 筛选面板 -->
|
||||
<div class="single-filter-box" style="margin-top: 15px !important;">
|
||||
<div class="layui-form">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" id="start_time_account" autocomplete="off" placeholder="开始时间" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-input-inline end-time">
|
||||
<input type="text" class="layui-input" name="end_time" id="end_time_account" placeholder="结束时间" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<input id="fenxiao_id" value="{$fenxiao_id}" type="hidden" />
|
||||
<button class="layui-btn layui-btn-primary" lay-submit lay-filter="search_account">搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="status">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" lay-id="">全部</li>
|
||||
<li lay-id="1">收入</li>
|
||||
<li lay-id="2">支出</li>
|
||||
</ul>
|
||||
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="renewal_list" lay-filter="renewal_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var fx_account_table, form, laytpl, laydate, element, fenxiao_id = $("#fenxiao_id").val(), start_time, end_time;
|
||||
layui.use(['form', 'laytpl', 'laydate'], function() {
|
||||
form = layui.form;
|
||||
laytpl = layui.laytpl;
|
||||
laydate = layui.laydate;
|
||||
element = layui.element;
|
||||
form.render();
|
||||
|
||||
//监听Tab切换
|
||||
element.on('tab(status)', function(data) {
|
||||
var status = $(this).attr("lay-id");
|
||||
fx_account_table.reload( {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': status
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time_account', //指定元素
|
||||
});
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time_account', //指定元素
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search_account)', function (data) {
|
||||
if (start_time) {
|
||||
data.field.start_time = start_time;
|
||||
}
|
||||
if (end_time) {
|
||||
data.field.end_time = end_time;
|
||||
}
|
||||
|
||||
fx_account_table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 加载表格
|
||||
*/
|
||||
fx_account_table = new Table({
|
||||
elem: '#renewal_list',
|
||||
url: ns.url("fenxiao://shop/fenxiao/account"),
|
||||
where: {'fenxiao_id': fenxiao_id},
|
||||
cols: [
|
||||
[{
|
||||
field: 'account_no',
|
||||
title: '账单编号',
|
||||
unresize: 'false',
|
||||
width:'25%',
|
||||
}, {
|
||||
field: 'money',
|
||||
title: '金额(元)',
|
||||
unresize: 'false',
|
||||
width:'25%',
|
||||
}, {
|
||||
field: 'type_name',
|
||||
title: '金额类型',
|
||||
unresize: 'false',
|
||||
width:'25%',
|
||||
}, {
|
||||
field: 'create_time',
|
||||
title: '创建时间',
|
||||
unresize: 'false',
|
||||
width:'25%',
|
||||
templet: function(data) {
|
||||
if(data.create_time == 0){
|
||||
return '--';
|
||||
}else{
|
||||
return ns.time_to_date(data.create_time)
|
||||
}
|
||||
},
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
177
addon/fenxiao/shop/view/fenxiao/fenxiao_detail.html
Executable file
177
addon/fenxiao/shop/view/fenxiao/fenxiao_detail.html
Executable file
@@ -0,0 +1,177 @@
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/ext/layui/extend/cascader/cascader.css"/>
|
||||
<style>
|
||||
.layui-layer-page .layui-layer-content {overflow-y: auto!important;}
|
||||
.layui-layout-admin .layui-body .body-content {background: none;padding: 0}
|
||||
.info-wrap {display: flex}
|
||||
.info-wrap .layui-card {flex: 1;margin-top: 0}
|
||||
.info-wrap .layui-card:first-child {margin-right: 15px}
|
||||
.member-info {display: flex}
|
||||
.member-info .headimg {margin-right: 15px;width: 70px;height: 70px;display: flex;align-items: center;justify-content: center;overflow: hidden}
|
||||
.member-info .headimg img {max-width: 100%;height: auto}
|
||||
.member-info .info {flex: 1;width: 0;display: flex;flex-wrap: wrap}
|
||||
.member-info .info .data-item {width: 50%;padding-right: 10px;box-sizing: border-box;line-height: 30px}
|
||||
.member-info .data-item .layui-icon {cursor: pointer}
|
||||
.layui-tab-content {padding: 0}
|
||||
.card-brief .layui-card-header{padding-top: 5px !important;}
|
||||
.card-common .layui-card-body{padding-top: 10px;}
|
||||
</style>
|
||||
|
||||
<div class="info-wrap">
|
||||
<div class="layui-card card-common card-brief head top">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">基础信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="member-info">
|
||||
<div class="info">
|
||||
<div class="data-item">
|
||||
<span>分销商编号:</span>
|
||||
<span>{$info.fenxiao_no}</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>分销商:</span>
|
||||
<span>{$info.fenxiao_name}</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>会员账号:</span>
|
||||
<span><a href="{:href_url('shop/member/editmember?member_id=')}{$info.member_id}" target="_blank" class="text-color">{$info.username}</a></span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>上级分销商:</span>
|
||||
<span>{if $info.parent_name == ''} 无 {else /}{$info.parent_name} {/if}</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>分销商等级:</span>
|
||||
<span>{$level.level_name}</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>当前佣金:</span>
|
||||
<span>{$info.account} 元</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>已提现佣金:</span>
|
||||
<span>{$info.account_withdraw} 元</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>提现中佣金:</span>
|
||||
<span>{$info.account_withdraw_apply} 元</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>当前状态:</span>
|
||||
<span>{$status[$info['status']]}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief head top">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">账户信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="member-info">
|
||||
<div class="info">
|
||||
<div class="data-item">
|
||||
<span>一级分销订单总数:</span>
|
||||
<span id="member_balance">{$info.one_fenxiao_order_num}</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>一级分销订单总额:</span>
|
||||
<span>{$info.one_fenxiao_total_order} 元</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>下线总人数:</span>
|
||||
<span>{$info.team_num.num} 人</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>下线总分销商:</span>
|
||||
<span>{$info.team_num.fenxiao_num} 人</span>
|
||||
</div>
|
||||
{if $info.team_num.level >= 1}
|
||||
<div class="data-item">
|
||||
<span>一级下线人数:</span>
|
||||
<span>{$info.team_num.num_1} 人</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>一级下线分销商:</span>
|
||||
<span>{$info.team_num.fenxiao_num_1} 人</span>
|
||||
</div>
|
||||
{/if}
|
||||
{if $info.team_num.level >= 2}
|
||||
<div class="data-item">
|
||||
<span>二级下线人数:</span>
|
||||
<span>{$info.team_num.num_2} 人</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>二级下线分销商:</span>
|
||||
<span>{$info.team_num.fenxiao_num_2} 人</span>
|
||||
</div>
|
||||
{/if}
|
||||
{if $info.team_num.level >= 3}
|
||||
<div class="data-item">
|
||||
<span>三级下线人数:</span>
|
||||
<span>{$info.team_num.num_3} 人</span>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<span>三级下线分销商:</span>
|
||||
<span>{$info.team_num.fenxiao_num_3} 人</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief head top">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">分销商信息</span>
|
||||
</div>
|
||||
|
||||
<div class="layui-card-body layui-tab layui-tab-brief" lay-filter="fenxiao_tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li lay-id="fenxiao_team" class="layui-this" >分销商团队</li>
|
||||
<li lay-id="fenxiao_account">账户流水记录</li>
|
||||
<li lay-id="fenxiao_order">订单管理</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
{include file="fenxiao/fenxiao_team" /}
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
{include file="fenxiao/fenxiao_account" /}
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
{include file="fenxiao/order_lists" /}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
layui.use(['element', 'laytpl', 'form', 'laydate'], function () {
|
||||
var element = layui.element;
|
||||
var tab = 'fenxiao_team';
|
||||
|
||||
var hash_arr = getHashArr();
|
||||
$.each(hash_arr, function (index, itemobj) {
|
||||
var item_arr = itemobj.split("=");
|
||||
if (item_arr.length == 2) {
|
||||
if (item_arr[0].indexOf("tab") != "-1") {
|
||||
tab = item_arr[1];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
element.tabChange('fenxiao_tab', tab);
|
||||
|
||||
element.on('tab(fenxiao_tab)', function () {
|
||||
localStorage.setItem('formSubmit','search'); // 表单搜索标识,防止页面重新加载
|
||||
var hash = location.hash;
|
||||
if (hash.indexOf('tab=') != -1) {
|
||||
location.hash = hash.replace('tab=' + tab, '');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
124
addon/fenxiao/shop/view/fenxiao/fenxiao_team.html
Executable file
124
addon/fenxiao/shop/view/fenxiao/fenxiao_team.html
Executable file
@@ -0,0 +1,124 @@
|
||||
<style>
|
||||
.layui-layout-admin .table-tab .layui-tab-title{margin-bottom: 15px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="team_list_tab" style="margin-top: 15px !important;">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" data-status="1" data-type="live_status">一级</li>
|
||||
{if $fenxiao_level_num > 1}<li data-status="2" data-type="live_status">二级</li>{/if}
|
||||
{if $fenxiao_level_num > 2}<li data-status="3" data-type="live_status">三级</li>{/if}
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<table id="team_list" lay-filter="team_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 用户信息 -->
|
||||
<script type="text/html" id="userdetail">
|
||||
<div class='table-title'>
|
||||
<div class='title-pic'>
|
||||
<img layer-src src="{{ns.img(d.headimg)}}" onerror="this.src = '{:img('public/static/img/default_img/head.png')}' ">
|
||||
</div>
|
||||
<div class='title-content'>
|
||||
<p class="layui-elip">{{d.nickname}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 工具栏操作 -->
|
||||
<script type="text/html" id="action">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="detail">查看</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var form,fx_team_table,element = false;
|
||||
layui.use(['form', 'element'], function() {
|
||||
form = layui.form;
|
||||
element = layui.element;
|
||||
form.render();
|
||||
|
||||
fx_team_table = new Table({
|
||||
elem: '#team_list',
|
||||
url: ns.url("fenxiao://shop/fenxiao/team"),
|
||||
where:{fenxiao_id:"{$fenxiao_id}"},
|
||||
cols: [
|
||||
[ {
|
||||
field: 'userdetail',
|
||||
title: '账户信息',
|
||||
width: '18%',
|
||||
unresize: 'false',
|
||||
templet: '#userdetail'
|
||||
}, {
|
||||
field: 'is_fenxiao',
|
||||
title: '是否是分销商',
|
||||
width: '8%',
|
||||
unresize: 'false',
|
||||
templet: function (data) {
|
||||
return data.is_fenxiao ? '是' : '否';
|
||||
}
|
||||
}, {
|
||||
field: 'order_money',
|
||||
title: '消费额',
|
||||
width: '8%',
|
||||
unresize: 'false',
|
||||
}, {
|
||||
field: 'order_num',
|
||||
title: '消费量',
|
||||
width: '8%',
|
||||
unresize: 'false',
|
||||
}, {
|
||||
field: 'order_complete_money',
|
||||
title: '消费额(已完成)',
|
||||
width: '8%',
|
||||
unresize: 'false',
|
||||
}, {
|
||||
field: 'order_complete_num',
|
||||
title: '消费量(已完成)',
|
||||
width: '8%',
|
||||
unresize: 'false',
|
||||
}, {
|
||||
field: 'reg-login',
|
||||
title: '成为会员时间',
|
||||
width: '18%',
|
||||
unresize: 'false',
|
||||
templet: function (data) {
|
||||
return ns.time_to_date(data.reg_time);
|
||||
}
|
||||
}, {
|
||||
title: '操作',
|
||||
unresize: 'false',
|
||||
toolbar: '#action',
|
||||
align:'right'
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
fx_team_table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'detail': //编辑
|
||||
location.hash = ns.hash("shop/member/editmember?member_id=" + data.member_id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
element.on('tab(team_list_tab)', function () {
|
||||
fx_team_table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'level': this.getAttribute('data-status')
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
462
addon/fenxiao/shop/view/fenxiao/index.html
Executable file
462
addon/fenxiao/shop/view/fenxiao/index.html
Executable file
@@ -0,0 +1,462 @@
|
||||
|
||||
|
||||
<style>
|
||||
/* 总样式 */
|
||||
.summary-wrap { display: flex}
|
||||
.body-content {background: none !important;padding: 0 !important;margin: 0 !important;}
|
||||
.summary-wrap .common-wrap{margin:15px 15px 0 15px; flex: 1;padding: 15px; background: #fff;position: relative}
|
||||
/* 佣金概览 */
|
||||
.commission-wrap{height: 120px;background: #fff;position: relative;margin:25px 15px 0 15px;padding: 15px}
|
||||
.commission-wrap .commission-overview{display: flex;}
|
||||
.commission-wrap .li{width: 25%;height: 120px;text-align: left;display: flex;flex-direction: column;padding: 0 15px 10px 15px}
|
||||
.commission-wrap .li .title{display: flex;align-items: center;font-size: 14px;margin-top: 25px;color: #909399;}
|
||||
.commission-wrap .li .money{margin-top: 10px;font-size: 26px;color: #303133;}
|
||||
/* 分销商概览 */
|
||||
.summary-wrap .fenxiao-wrap{height: 120px;width: 40%;background: #fff;position: relative; margin:15px 0px 0 15px;padding: 15px}
|
||||
.summary-wrap .fenxiao-wrap .member-overview{display: flex;}
|
||||
.summary-wrap .fenxiao-wrap .li{width: 50%;height: 120px;text-align: left;display: flex;flex-direction: column;padding: 0 15px 10px 15px}
|
||||
.summary-wrap .fenxiao-wrap .li .title{display: flex;align-items: center;font-size: 14px;margin-top: 25px;color: #909399;}
|
||||
.summary-wrap .fenxiao-wrap .li .num{margin-top: 10px;font-size: 26px;color: #303133;}
|
||||
/* 分销订单金额概览 */
|
||||
.summary-wrap .order-wrap{height: 120px;width: 40%;background: #fff;position: relative; flex:1;margin:15px 15px 0 15px;padding: 15px}
|
||||
.summary-wrap .order-wrap .order-overview{display: flex;}
|
||||
.summary-wrap .order-wrap .li{width: 33%;height: 120px;text-align: left;display: flex;flex-direction: column;padding: 0 15px 10px 15px}
|
||||
.summary-wrap .order-wrap .li .title{display: flex;align-items: center;font-size: 14px;margin-top: 25px;color: #909399;}
|
||||
.summary-wrap .order-wrap .li .num{margin-top: 10px;font-size: 26px;color: #303133;}
|
||||
.summary-wrap .order-wrap .li .money{margin-top: 10px;font-size: 26px;color: #303133;}
|
||||
/* 分销商人数报表 */
|
||||
.summary-wrap .common-wrap:nth-child(1){margin-right: 0}
|
||||
/* 分销订单金额报表 */
|
||||
.trend-wrap {margin:15px 15px 0 15px;padding: 15px; background: #fff}
|
||||
/* 分销商等级比例 */
|
||||
.summary-wrap .common-wrap .body.level{position: absolute;top: 50%;margin-top: -75px !important;width: calc(100% - 30px)}
|
||||
</style>
|
||||
|
||||
|
||||
<div class="commission-wrap common-wrap">
|
||||
<div class="head">
|
||||
<span class="title">佣金概览</span>
|
||||
</div>
|
||||
<div class="commission-overview">
|
||||
<div class="li">
|
||||
<div class="title prompt-block">
|
||||
可提现佣金(元)
|
||||
<div class="prompt">
|
||||
<i class="iconfont iconwenhao1"></i>
|
||||
<div class="prompt-box">
|
||||
<div class="prompt-con">所有分销订单已完成,佣金已结算,可以提现的佣金(不包含已提现的佣金)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="money" id="fenxiao_account">0.00</p>
|
||||
</div>
|
||||
<div class="li">
|
||||
<div class="title prompt-block">
|
||||
提现待审核(元)
|
||||
<div class="prompt">
|
||||
<i class="iconfont iconwenhao1"></i>
|
||||
<div class="prompt-box">
|
||||
<div class="prompt-con">已申请提现等待管理审核的佣金</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="money" id="account_withdraw_apply">0.00</p>
|
||||
</div>
|
||||
<div class="li">
|
||||
<div class="title prompt-block">
|
||||
提现佣金(元)
|
||||
<div class="prompt">
|
||||
<i class="iconfont iconwenhao1"></i>
|
||||
<div class="prompt-box">
|
||||
<div class="prompt-con">所有已经提现成功的佣金总和</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="money" id="account_withdraw">0.00</p>
|
||||
</div>
|
||||
<div class="li">
|
||||
<div class="title prompt-block">
|
||||
进行中佣金(元)
|
||||
<div class="prompt">
|
||||
<i class="iconfont iconwenhao1"></i>
|
||||
<div class="prompt-box">
|
||||
<div class="prompt-con">指所有分销订单待结算佣金的和</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="money" id="commission_money">0.00</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary-wrap">
|
||||
<div class="fenxiao-wrap common-wrap">
|
||||
<div class="head">
|
||||
<span class="title">分销商概览</span>
|
||||
</div>
|
||||
<div class="member-overview">
|
||||
<div class="li">
|
||||
<div class="title">待审核(人)</div>
|
||||
<p class="num" id="fenxiao_apply_num">0</p>
|
||||
</div>
|
||||
<div class="li">
|
||||
<div class="title">分销商(人)</div>
|
||||
<p class="num" id="fenxiao_num">0</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="order-wrap common-wrap">
|
||||
<div class="head">
|
||||
<span class="title">分销概览</span>
|
||||
</div>
|
||||
<div class="order-overview">
|
||||
<div class="li">
|
||||
<div class="title prompt-block">
|
||||
分销订单总额(元)
|
||||
<div class="prompt">
|
||||
<i class="iconfont iconwenhao1"></i>
|
||||
<div class="prompt-box">
|
||||
<div class="prompt-con">指所有分销订单实付金额的和 (包含退款)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="num" id="real_goods_money">0.00</p>
|
||||
</div>
|
||||
<div class="li">
|
||||
<div class="title prompt-block">
|
||||
分销佣金总额(元)
|
||||
<div class="prompt">
|
||||
<i class="iconfont iconwenhao1"></i>
|
||||
<div class="prompt-box">
|
||||
<div class="prompt-con">指所有分销订单所得佣金的和</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="num" id="commission">0.00</p>
|
||||
</div>
|
||||
<div class="li">
|
||||
<div class="title">分销商品数(个)</div>
|
||||
<p class="money" id="fenxiao_goods_num">0</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary-wrap">
|
||||
<div class="common-wrap">
|
||||
<div class="head">
|
||||
<div class="title">新增分销商数(人)</div>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div id="fenxiao_member" style="width: 100%; height: 300px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="common-wrap">
|
||||
<div class="head">
|
||||
<div class="title">分销商等级比例</div>
|
||||
</div>
|
||||
<div class="body level">
|
||||
<div id="fenxiao_level" style="width: 100%; height: 150px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="trend-wrap common-wrap">
|
||||
<div class="head">
|
||||
<div class="title">分销订单金额(元)</div>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div id="order_money" style="width: 100%; height: 300px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="SHOP_JS/echarts.min.js"></script>
|
||||
<script src="SHOP_JS/china.js"></script>
|
||||
<script>
|
||||
getFenxiaoStat()
|
||||
function getFenxiaoStat(){
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
url: ns.url("fenxiao://shop/fenxiao/stat"),
|
||||
success:function(res){
|
||||
$('#fenxiao_account').html(res.fenxiao_account);
|
||||
$('#account_withdraw').html(res.account_data.account_withdraw);
|
||||
$('#account_withdraw_apply').html(res.account_data.account_withdraw_apply);
|
||||
$('#commission_money').html(res.commission_money);
|
||||
$('#fenxiao_apply_num').html(res.fenxiao_apply_num);
|
||||
$('#fenxiao_goods_num').html(res.fenxiao_goods_num);
|
||||
$('#fenxiao_num').html(res.fenxiao_num);
|
||||
$('#commission').html(res.shop_commission.commission);
|
||||
$('#real_goods_money').html(res.shop_commission.real_goods_money);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var baseColor = getComputedStyle(document.documentElement).getPropertyValue('--base-color');
|
||||
|
||||
function getDay(day){
|
||||
var today = new Date();
|
||||
var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
|
||||
today.setTime(targetday_milliseconds); //注意,这行是关键代码
|
||||
var tYear = today.getFullYear();
|
||||
var tMonth = today.getMonth();
|
||||
var tDate = today.getDate();
|
||||
tMonth = doHandleMonth(tMonth + 1);
|
||||
tDate = doHandleMonth(tDate);
|
||||
return tMonth + "-" + tDate;
|
||||
}
|
||||
|
||||
function doHandleMonth(month){
|
||||
var m = month;
|
||||
if(month.toString().length == 1){
|
||||
m = "0" + month;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
getFenxiaoOrder();
|
||||
getFenxiaoLevel();
|
||||
getFenixaoMmeber();
|
||||
|
||||
//图形统计
|
||||
function getFenxiaoOrder() {
|
||||
var dateObj = new Date(Date.now() - 1296000000);
|
||||
var date = dateObj.getFullYear() + '-' + (dateObj.getMonth() + 1) + '-' + (dateObj.getDate() + 1);
|
||||
$.ajax({
|
||||
type:'post',
|
||||
dataType:'json',
|
||||
url:ns.url("shop/stat/getStatData"),
|
||||
data : {
|
||||
start_time: new Date(date).getTime() / 1000
|
||||
},
|
||||
success:function(res){
|
||||
dealWithChart(res.fenxiao_order_total_money);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getFenixaoMmeber(){
|
||||
$.ajax({
|
||||
type:'post',
|
||||
dataType:'json',
|
||||
url:ns.url("shop/stat/getStatData"),
|
||||
success:function(res){
|
||||
dealWithChartTo(res.add_fenxiao_member_count);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function dealWithChart(ten_day_json){
|
||||
if(!$('#order_money').length) return;
|
||||
var data = [getDay(-14), getDay(-13), getDay(-12), getDay(-11), getDay(-10), getDay(-9), getDay(-8), getDay(-7), getDay(-6), getDay(-5), getDay(-4), getDay(-3), getDay(-2), getDay(-1), getDay(0)];
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var baseColor = getComputedStyle(document.documentElement).getPropertyValue('--base-color');
|
||||
// 指定图表的配置项和数据
|
||||
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var moneyChart = echarts.init(document.getElementById('order_money'));
|
||||
|
||||
// 指定图表的配置项和数据
|
||||
moneyOption = {
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: data
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
grid: {
|
||||
top: '8%',
|
||||
bottom: '9%',
|
||||
left: '5%',
|
||||
right: '4%'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
showContent: true,
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
||||
padding: [5, 10],
|
||||
textStyle: {
|
||||
color: '#fff',
|
||||
lineHeight: 30,
|
||||
},
|
||||
formatter: function(params, ticket, callback) {
|
||||
return "日期:" + params[0].axisValue + '<br />' + params[0].seriesName + ":" + params[0].value + "元";
|
||||
},
|
||||
},
|
||||
series: [{
|
||||
name: ['订单金额'],
|
||||
data: ten_day_json,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
itemStyle: {
|
||||
color: baseColor
|
||||
},
|
||||
areaStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
||||
offset: 0,
|
||||
color: baseColor
|
||||
}, {
|
||||
offset: 1,
|
||||
color: '#fff'
|
||||
}])
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
moneyChart.setOption(moneyOption);
|
||||
}
|
||||
|
||||
function getFenxiaoLevel(){
|
||||
$.ajax({
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
url: ns.url("fenxiao://shop/level/lists"),
|
||||
data: {
|
||||
page_size: 0,
|
||||
},
|
||||
success: function(res) {
|
||||
var level = res.data.list;
|
||||
if(!$('#fenxiao_level').length) return;
|
||||
var echart = echarts.init(document.getElementById('fenxiao_level'));
|
||||
|
||||
// 指定图表的配置项和数据
|
||||
var option = {
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b}: {c} ({d}%)'
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: '50%',
|
||||
top: '10%',
|
||||
align: 'auto',
|
||||
data: level.map(function (item) {
|
||||
return {
|
||||
name: item.level_name,
|
||||
icon: 'circle',
|
||||
}
|
||||
})
|
||||
},
|
||||
color: level.map(function (item) {
|
||||
return getRandomColor();
|
||||
}),
|
||||
series: [{
|
||||
width: 150,
|
||||
height: 150,
|
||||
top: '0',
|
||||
left: '10%',
|
||||
name: '',
|
||||
type: 'pie',
|
||||
radius: ['50%', '70%'],
|
||||
avoidLabelOverlap: false,
|
||||
label: {
|
||||
show: false,
|
||||
position: 'center'
|
||||
},
|
||||
emphasis: {
|
||||
label: {
|
||||
show: true,
|
||||
fontSize: '12',
|
||||
color: baseColor
|
||||
}
|
||||
},
|
||||
labelLine: {
|
||||
show: false
|
||||
},
|
||||
data: level.map(function (item) {
|
||||
return {
|
||||
value: item.fenxiao_num,
|
||||
name: item.level_name,
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.7)',
|
||||
borderColor: '#999',
|
||||
borderWidth: 1,
|
||||
padding: 10,
|
||||
textStyle: {
|
||||
fontSize: 12,
|
||||
color: '#333'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}]
|
||||
};
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
echart.setOption(option);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getRandomColor(){
|
||||
return '#' + (function(color){
|
||||
return (color += '0123456789abcdef'[Math.floor(Math.random()*16)])
|
||||
&& (color.length == 6) ? color : arguments.callee(color);
|
||||
})('');
|
||||
}
|
||||
|
||||
function dealWithChartTo(ten_day_json){
|
||||
if(!$('#fenxiao_member').length) return;
|
||||
|
||||
var data = [getDay(-6), getDay(-5), getDay(-4), getDay(-3), getDay(-2), getDay(-1), getDay(0)];
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var baseColor = getComputedStyle(document.documentElement).getPropertyValue('--base-color');
|
||||
// 指定图表的配置项和数据
|
||||
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var moneyChart = echarts.init(document.getElementById('fenxiao_member'));
|
||||
|
||||
// 指定图表的配置项和数据
|
||||
var moneyOption = {
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: data
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
grid: {
|
||||
top: '8%',
|
||||
bottom: '9%',
|
||||
left: '8%',
|
||||
right: '4%'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
showContent: true,
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
||||
padding: [5, 10],
|
||||
textStyle: {
|
||||
color: '#fff',
|
||||
lineHeight: 30,
|
||||
},
|
||||
formatter: function(params, ticket, callback) {
|
||||
return "日期:" + params[0].axisValue + '<br />' + params[0].seriesName + ":" + params[0].value + "人";
|
||||
},
|
||||
},
|
||||
series: [{
|
||||
name: ['新增分销商数'],
|
||||
data: ten_day_json,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
itemStyle: {
|
||||
color: baseColor
|
||||
},
|
||||
areaStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
||||
offset: 0,
|
||||
color: baseColor
|
||||
}, {
|
||||
offset: 1,
|
||||
color: '#fff'
|
||||
}])
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
moneyChart.setOption(moneyOption);
|
||||
}
|
||||
</script>
|
||||
|
||||
349
addon/fenxiao/shop/view/fenxiao/lists.html
Executable file
349
addon/fenxiao/shop/view/fenxiao/lists.html
Executable file
@@ -0,0 +1,349 @@
|
||||
<style>
|
||||
.screen{margin-top: 15px;}
|
||||
.goods-info{justify-content: left !important;float: unset !important;}
|
||||
.goods-info-name{max-width: 80px;overflow: hidden;cursor: pointer;}
|
||||
.change-name{cursor: pointer;}
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
.layui-layout-admin .screen{margin-bottom: 15px;}
|
||||
.layui-layout-admin .single-filter-box{padding-bottom: 0;}
|
||||
.time-lineheight {line-height: 1.3}
|
||||
</style>
|
||||
|
||||
<div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="clickAdd()">添加分销商</button>
|
||||
</div>
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
<div class="layui-form-item">
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">分销商昵称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="nickname" placeholder="请输入分销商昵称" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">分销商手机号:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="mobile" placeholder="请输入分销商手机号" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">上级分销商:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="parent_name" placeholder="请输入上级分销商" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">添加时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" id="start_time" autocomplete="off" placeholder="开始时间" readonly>
|
||||
<i class="iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" id="end_time" autocomplete="off" placeholder="结束时间" readonly>
|
||||
<i class="iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">分销等级:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="level_id" lay-filter="level_id">
|
||||
<option value="">全部</option>
|
||||
{volist name="$level_list" id="level"}
|
||||
<option value="{$level.level_id}">{$level.level_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">分销商状态:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="status" lay-filter="status">
|
||||
<option value="">全部</option>
|
||||
<option value="1">正常</option>
|
||||
<option value="-1">已冻结</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 列表 -->
|
||||
<table id="fenxiao_list" lay-filter="fenxiao_list"></table>
|
||||
|
||||
<!-- 用户信息 -->
|
||||
<script type="text/html" id="account">
|
||||
<div class="layui-elip">当前佣金:{{d.account}}</div>
|
||||
<div class="layui-elip">已提现佣金:{{d.account_withdraw}}</div>
|
||||
</script>
|
||||
|
||||
<!-- 会员信息 -->
|
||||
<script type="text/html" id="username">
|
||||
<a href="javascript:memberDetail({{ d.member_id }});">{{ d.username }}</a>
|
||||
</script>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 1){ }}
|
||||
<span style="color: green;">正常</span>
|
||||
{{# }else if(d.status == -1){ }}
|
||||
<span style="color: gray;">冻结</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 上级分销商 -->
|
||||
<script type="text/html" id="parent_name">
|
||||
<div class="table-btn goods-info">
|
||||
{{# if(d.parent_name){ }}
|
||||
<span class="line-hiding goods-info-name">{{d.parent_name}}</span> | <span class="text-color change-name" onclick="change({{d.member_id}})"><i class="layui-icon text-color-gray"> </i></span>
|
||||
{{# }else{ }}
|
||||
<span class="line-hiding goods-info-name">无</span> | <span class="text-color" onclick="change({{d.member_id}})"><i class="layui-icon text-color-gray"> </i></span>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 分销等级 -->
|
||||
<script type="text/html" id="level_name">
|
||||
<div class="table-btn goods-info">
|
||||
<span class="line-hiding goods-info-name">{{d.level_name}}</span> | <span class="text-color change-name" onclick="changeLevel({{d.member_id}},{{d.fenxiao_id}})"><i class="layui-icon text-color-gray"> </i></span>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="memberInfo">
|
||||
<div class='table-title'>
|
||||
<div class='title-pic'>
|
||||
<img layer-src src="{{ns.img(d.headimg)}}" onerror="this.src = '{:img('public/static/img/default_img/head.png')}' ">
|
||||
</div>
|
||||
<div class='title-content'>
|
||||
<p class="layui-elip">{{d.nickname}}</p>
|
||||
<p class="layui-elip">{{d.member_mobile}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 工具栏操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="detail">查看</a>
|
||||
{{# if(d.status == 1){ }}
|
||||
<a class="layui-btn" lay-event="frozen">冻结</a>
|
||||
<!-- <a class="layui-btn" lay-event="change">上级分销商变更</a> -->
|
||||
{{# } }}
|
||||
{{# if(d.status == -1){ }}
|
||||
<a class="layui-btn" lay-event="unfrozen">恢复正常</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var table,form,laydate, repeat_flag = false; //防重复标识;
|
||||
layui.use(['form', 'laydate'], function() {
|
||||
form = layui.form;
|
||||
laydate = layui.laydate;
|
||||
form.render();
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#fenxiao_list',
|
||||
url: ns.url("fenxiao://shop/fenxiao/lists"),
|
||||
cols: [
|
||||
[{
|
||||
title: '会员信息',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet:'#memberInfo'
|
||||
}, {
|
||||
field: 'fenxiao_name',
|
||||
title: '分销商名称',
|
||||
unresize: 'false',
|
||||
width: '10%'
|
||||
},{
|
||||
title: '上级分销商',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: '#parent_name',
|
||||
align:'left'
|
||||
}, {
|
||||
title: '分销等级',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: '#level_name',
|
||||
align:'left'
|
||||
}, {
|
||||
title: '佣金账户',
|
||||
width:'10%',
|
||||
unresize: 'false',
|
||||
templet: '#account'
|
||||
}, {
|
||||
|
||||
title: '团队人数',
|
||||
unresize: 'false',
|
||||
width: '8%',
|
||||
templet: function(data){
|
||||
return data.team_num;
|
||||
}
|
||||
}, {
|
||||
field: 'status',
|
||||
title: '当前状态',
|
||||
templet: '#status',
|
||||
unresize: 'false',
|
||||
width: '7%'
|
||||
}, {
|
||||
field: 'create_time',
|
||||
title: '添加时间',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
var time = ns.time_to_date(data.create_time).split(' ');
|
||||
return `<div class="time-lineheight">
|
||||
<div>`+ time[0] +`</div>
|
||||
<div>`+ time[1] +`</div>
|
||||
</div>`;
|
||||
}
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data,
|
||||
event = obj.event;
|
||||
switch (event) {
|
||||
case 'detail': //查看
|
||||
location.hash = ns.hash('fenxiao://shop/fenxiao/detail', {'fenxiao_id': data.fenxiao_id});
|
||||
break;
|
||||
case 'frozen': //冻结
|
||||
layer.confirm('确定要冻结该账户吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/fenxiao/frozen"),
|
||||
data: {fenxiao_id: data.fenxiao_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'unfrozen': //解冻
|
||||
layer.confirm('该账户确定要恢复正常吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/fenxiao/unfrozen"),
|
||||
data: {fenxiao_id: data.fenxiao_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'change':
|
||||
change(data.member_id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//改变上级分销商
|
||||
function change(member_id){
|
||||
var url = ns.url("fenxiao://shop/fenxiao/change", {request_mode: 'iframe',member_id:member_id,change_end_func:'changeEnd'});
|
||||
layer.open({
|
||||
title: "变更上级分销商",
|
||||
type: 2,
|
||||
area: ['1200px', '800px'],
|
||||
content: url,
|
||||
});
|
||||
}
|
||||
//改变上级分销商结束
|
||||
function changeEnd() {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.closeAll();
|
||||
}
|
||||
|
||||
//改变等级
|
||||
function changeLevel(member_id,fenxiao_id){
|
||||
var url = ns.url("fenxiao://shop/fenxiao/changeLevel", {request_mode: 'iframe',member_id:member_id,fenxiao_id:fenxiao_id,change_end_func:'changeLevelEnd'});
|
||||
layer.open({
|
||||
title: "变更分销商等级",
|
||||
type: 2,
|
||||
area: ['800px', '650px'],
|
||||
content: url,
|
||||
});
|
||||
}
|
||||
//改变等级结束
|
||||
function changeLevelEnd() {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.closeAll();
|
||||
}
|
||||
|
||||
function memberDetail(member_id){
|
||||
window.open(ns.href("shop/member/editMember?member_id=" + member_id));
|
||||
}
|
||||
|
||||
function clickAdd() {
|
||||
location.hash = ns.hash('fenxiao://shop/fenxiao/add');
|
||||
}
|
||||
</script>
|
||||
111
addon/fenxiao/shop/view/fenxiao/order_detail.html
Executable file
111
addon/fenxiao/shop/view/fenxiao/order_detail.html
Executable file
@@ -0,0 +1,111 @@
|
||||
<style>
|
||||
.good-name {
|
||||
line-height: 34px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="layui-form">
|
||||
<div class="layui-card card-common">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">商品信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item goods-image-wrap">
|
||||
<label class="layui-form-label">商品图片:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="js-goods-image"><img layer-src src="{:img($order_info.sku_image)}" width = "50px"/></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品名称:</label>
|
||||
<div class="layui-input-inline good-name">{$order_info.sku_name}</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品价格:</label>
|
||||
<div class="layui-input-inline good-name">¥{$order_info.price}</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">购买数量:</label>
|
||||
<div class="layui-input-inline good-name">{$order_info.num}</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">实际支付:</label>
|
||||
<div class="layui-input-inline good-name">¥{$order_info.real_goods_money}</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">结算状态:</label>
|
||||
<div class="layui-input-inline good-name">
|
||||
{if $order_info.is_refund == 1}
|
||||
已退款
|
||||
{else /}
|
||||
{if $order_info.is_settlement == 1}
|
||||
已结算
|
||||
{else /}
|
||||
未结算
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">结算总佣金:</label>
|
||||
<div class="layui-input-inline good-name">¥{$order_info.commission}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">返佣详情</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<table class="layui-table" id="default_rule_list" lay-skin="line" lay-size="lg">
|
||||
<colgroup>
|
||||
<col width="25%">
|
||||
<col width="25%">
|
||||
<col width="25%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>分销商等级</th>
|
||||
<th>分销商</th>
|
||||
<th>返佣金额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>一级分销商</td>
|
||||
<td>{$order_info.one_fenxiao_name}</td>
|
||||
<td>{$order_info.one_commission}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>二级分销商</td>
|
||||
<td>{$order_info.two_fenxiao_name}</td>
|
||||
<td>{$order_info.two_commission}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>三级分销商</td>
|
||||
<td>{$order_info.three_fenxiao_name}</td>
|
||||
<td>{$order_info.three_commission}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="form-row">
|
||||
<button class="layui-btn layui-btn-primary" onclick="backFenxiaoOrderList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function backFenxiaoOrderList() {
|
||||
location.hash = ns.hash("fenxiao://shop/order/lists");
|
||||
}
|
||||
</script>
|
||||
222
addon/fenxiao/shop/view/fenxiao/order_lists.html
Executable file
222
addon/fenxiao/shop/view/fenxiao/order_lists.html
Executable file
@@ -0,0 +1,222 @@
|
||||
<link rel="stylesheet" href="FENXIAO_CSS/order_list.css">
|
||||
<style>
|
||||
.screen .layui-colla-content {border: none;background-color: #F2F3F5;}
|
||||
.screen .layui-colla-content .layui-input{background-color: #fff !important;}
|
||||
</style>
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel" style="margin-top: 15px !important;">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">搜索方式:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="search_text_type">
|
||||
<option value="order_no">订单编号</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="search_text" autocomplete="off" class="layui-input" placeholder="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">结算状态:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="status">
|
||||
<option value="">全部</option>
|
||||
<option value="1">未结算</option>
|
||||
<option value="2">已结算</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">下单时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time_order" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time_order" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(7, this);return false;">近7天</button>
|
||||
<button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(30, this);return false;">近30天</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<input id="fenxiao_id" name="fenxiao_id" value="{$fenxiao_id}" type="hidden" />
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit id="" lay-filter="search_order">筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab">
|
||||
<div class="layui-tab-content">
|
||||
<div id="order_list"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="order_page"></div>
|
||||
<script src="FENXIAO_JS/order_list.js?time=20240827"></script>
|
||||
<script>
|
||||
var laypage,element, form;
|
||||
// 通过hash获取页数
|
||||
function getHashPage(){
|
||||
var page = 1;
|
||||
var hash_arr = getHashArr();
|
||||
$.each(hash_arr,function(index, itemobj){
|
||||
var item_arr = itemobj.split("=");
|
||||
if(item_arr.length == 2){
|
||||
if(item_arr[0].indexOf("page") != "-1"){
|
||||
page = item_arr[1];
|
||||
}
|
||||
}
|
||||
});
|
||||
return page;
|
||||
}
|
||||
|
||||
//从hash中获取数据
|
||||
function getHashData(){
|
||||
var hash_arr = getHashArr();
|
||||
var form_json = {
|
||||
"fenxiao_id":"",
|
||||
"end_time" : "",
|
||||
"search" : "",
|
||||
"start_time" : "",
|
||||
"page" : ""
|
||||
};
|
||||
if(hash_arr.length > 0){
|
||||
$.each(hash_arr,function(index, itemobj){
|
||||
var item_arr = itemobj.split("=");
|
||||
if(item_arr.length == 2){
|
||||
$.each(form_json,function(key, form_val){
|
||||
if(item_arr[0].indexOf(key) != "-1"){
|
||||
form_json[key] = item_arr[1];
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
form.val("order_list", form_json);
|
||||
return form_json;
|
||||
}
|
||||
|
||||
layui.use(['laypage','laydate','form', 'element'], function(){
|
||||
form = layui.form;
|
||||
laypage = layui.laypage;
|
||||
element = layui.element;
|
||||
var laydate = layui.laydate;
|
||||
form.render();
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time_order'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#end_time_order'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
|
||||
//监听筛选事件
|
||||
form.on('submit(search_order)', function(data){
|
||||
data.field.page = 1;
|
||||
setHashOrderList(data.field);
|
||||
return false;
|
||||
});
|
||||
|
||||
getOrderList();//筛选
|
||||
});
|
||||
|
||||
var order = new Order();
|
||||
function getOrderList(param){
|
||||
var url = ns.url("fenxiao://shop/fenxiao/order");
|
||||
|
||||
var data = {
|
||||
fenxiao_id: '{$fenxiao_id}'
|
||||
};
|
||||
if (param != undefined) Object.assign(data, param);
|
||||
|
||||
$.ajax({
|
||||
type : 'post',
|
||||
dataType: 'json',
|
||||
url :url,
|
||||
data: data,
|
||||
success : function(res){
|
||||
if(res.code == 0){
|
||||
order.setData(res.data);
|
||||
$("#order_list").html(order.fetch());
|
||||
laypage.render({
|
||||
elem: 'order_page',
|
||||
count: res.data.count,
|
||||
curr: getHashPage(),
|
||||
layout: ['count', 'prev', 'page', 'next'],
|
||||
jump: function(obj, first){
|
||||
//首次不执行
|
||||
if(!first){
|
||||
var hash_data = getHashData();
|
||||
hash_data.page = obj.curr;
|
||||
setHashOrderList(hash_data);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setHashOrderList(data){
|
||||
localStorage.setItem('formSubmit','search'); // 表单搜索标识,防止页面重新加载
|
||||
var hash = ['url=fenxiao://shop/fenxiao/detail','tab=fenxiao_order'];
|
||||
for (var key in data) {
|
||||
if (data[key] != '' && data[key] != 'all') {
|
||||
hash.push(`${key}=${data[key]}`)
|
||||
}
|
||||
}
|
||||
location.hash = hash.join('&');
|
||||
getOrderList(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 七天时间
|
||||
*/
|
||||
function datePick(date_num,event_obj){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
$(event_obj).addClass('selected');
|
||||
Date.prototype.Format = function (fmt,date_num) { //author: meizz
|
||||
this.setDate(this.getDate()-date_num);
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1, //月份
|
||||
"d+": this.getDate(), //日
|
||||
"H+": this.getHours(), //小时
|
||||
"m+": this.getMinutes(), //分
|
||||
"s+": this.getSeconds(), //秒
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
||||
"S": this.getMilliseconds() //毫秒
|
||||
};
|
||||
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
return fmt;
|
||||
};
|
||||
var now_time = new Date().Format("yyyy-MM-dd 23:59:59",0);//当前日期
|
||||
var before_time = new Date().Format("yyyy-MM-dd 00:00:00",date_num-1);//前几天日期
|
||||
$("#start_time_order").val(before_time,0);
|
||||
$("#end_time_order").val(now_time,date_num-1);
|
||||
}
|
||||
</script>
|
||||
54
addon/fenxiao/shop/view/goods/category_select.html
Executable file
54
addon/fenxiao/shop/view/goods/category_select.html
Executable file
@@ -0,0 +1,54 @@
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/ext/layui/extend/cascader/cascader.css"/>
|
||||
<style>
|
||||
.goods-category-container {display: inline-block;position: relative;z-index: 10}
|
||||
</style>
|
||||
<div class="goods-category-container">
|
||||
<input type="text" autocomplete="off" show="false" class="layui-input select-category" placeholder="选择商品分类" readonly />
|
||||
<input type="hidden" name="category_id">
|
||||
</div>
|
||||
<script>
|
||||
var form, layCascader, goodsCategory = [];
|
||||
$(function() {
|
||||
layui.use(['form', 'layCascader'], function () {
|
||||
form = layui.form;
|
||||
layCascader = layui.layCascader;
|
||||
form.render();
|
||||
fetchCategory($('.goods-category-container .select-category'), function (value, node) {
|
||||
$('[name="category_id"]').val(value);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 渲染分类选择
|
||||
* @param elem
|
||||
* @param callback
|
||||
*/
|
||||
function fetchCategory(elem, callback){
|
||||
if (!goodsCategory.length) {
|
||||
$.ajax({
|
||||
url : ns.url("shop/goodscategory/lists"),
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function(res) {
|
||||
goodsCategory = res.data;
|
||||
}
|
||||
})
|
||||
}
|
||||
if($('.select-category').length) {
|
||||
var _cascader = layCascader({
|
||||
elem: $('.select-category'),
|
||||
options: goodsCategory,
|
||||
props: {
|
||||
value: 'category_id',
|
||||
label: 'category_name',
|
||||
children: 'child_list'
|
||||
}
|
||||
});
|
||||
_cascader.changeEvent(function (value, node) {
|
||||
typeof callback == 'function' && callback(value, node)
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
377
addon/fenxiao/shop/view/goods/config.html
Executable file
377
addon/fenxiao/shop/view/goods/config.html
Executable file
@@ -0,0 +1,377 @@
|
||||
<style>
|
||||
.good-name {
|
||||
line-height: 34px;
|
||||
}
|
||||
|
||||
/* @media screen and (min-width: 1514px) {
|
||||
.len-short {width: 80px!important;}
|
||||
} */
|
||||
@media screen and (max-width: 1330px) {
|
||||
.len-short {width: 100px!important;}
|
||||
}
|
||||
#rule_list .layui-input {display: inline-block;}
|
||||
.layui-table[lay-size=lg] td, .layui-table[lay-size=lg] th {padding: 15px;}
|
||||
.align-right {text-align: right;}
|
||||
.align-center {text-align: center!important;}
|
||||
.line-height {line-height: 45px;}
|
||||
input[disabled] {background-color: #F5F5F5;}
|
||||
</style>
|
||||
|
||||
<div class="layui-collapse tips-wrap">
|
||||
<div class="layui-colla-item">
|
||||
<h2 class="layui-colla-title">操作提示</h2>
|
||||
<ul class="layui-colla-content layui-show">
|
||||
<li>分销商层级与后台配置有关,最多三级分销。</li>
|
||||
<li>分销商等级与分销商的分销订单数,分销订单总额,自购订单数,自购订单总额,分销商下线人数,分销商的下级分销商人数有关。</li>
|
||||
<li>商品分销总佣金不得超过商品实际价格的50%。</li>
|
||||
<li>分销佣金是根据当前分销订单所属分销商等级或者商品自定义的计算规则进行结算。</li>
|
||||
<li>分销结算说明: A 、B 、C是分销商,C的上级为B,B的上级为A。
|
||||
分佣按照所属分销商的等级佣金比率进行分配,分销商C的等级分佣比率为一级10%,二级5%,三级2%,
|
||||
订单属于分销商C,则C获得商品实付金额10%,B获得商品实付金额5%,A获得商品实付金额2%。
|
||||
若C推荐的普通用户D购买商品,则该订单属于C;若C购买商品,则该订单属于C。</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form">
|
||||
<div class="layui-card card-common">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">商品信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item goods-image-wrap">
|
||||
<label class="layui-form-label">商品图片:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="js-goods-image"><img layer-src src="{:img($goods_info.goods_image[0],'small')}" width="50px"/></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品名称:</label>
|
||||
<div class="layui-input-inline good-name">{$goods_info.goods_name}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">佣金设置</span>
|
||||
</div>
|
||||
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item goods-image-wrap">
|
||||
<label class="layui-form-label">是否参与分销:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="is_fenxiao" value="1" title="参与" lay-filter="is_fenxiao" {if $goods_info['is_fenxiao'] == 1 }checked{/if}>
|
||||
<input type="radio" name="is_fenxiao" value="0" title="不参与" lay-filter="is_fenxiao" {if $goods_info['is_fenxiao'] == 0 }checked{/if}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>设置参与分销时,佣金会按照如下规则进行计算,如果有分销计算价则分销计算价优先。佣金 = 销售价*对应分销等级比例 / 佣金 = 分销计算价*对应分销等级比例</p>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item goods-image-wrap {if $goods_info['is_fenxiao'] == 0}layui-hide{/if}" id="fenxiao_price">
|
||||
<label class="layui-form-label">分销计算价格:</label>
|
||||
<div class="layui-input-block">
|
||||
<table class="layui-table" lay-skin="line">
|
||||
<colgroup>
|
||||
<col width="40%">
|
||||
<col width="20%">
|
||||
<col width="20%">
|
||||
<col width="20%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>商品规格</th>
|
||||
<th>销售价</th>
|
||||
<th>成本价</th>
|
||||
<th class="align-center">分销计算价</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="line-hiding">{$sku.goods_name}</div>
|
||||
<div style="color:#B2B2B2;">{$sku.spec_name}</div>
|
||||
</td>
|
||||
<td>{$sku.discount_price}</td>
|
||||
<td>{$sku.cost_price}</td>
|
||||
<td class="align-center">
|
||||
<input type="number" name="fenxiao_price[{$sku.sku_id}]" class="layui-input len-short input-rate" value="{$sku.fenxiao_price}" style="display: inline-block;"> 元
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>未设置分销计算价以该商品实付金额来计算佣金,设置后以该价格来计算佣金。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if $goods_info['is_fenxiao'] == 0}layui-hide{/if}" id="fenxiao_type">
|
||||
<label class="layui-form-label">佣金规则:</label>
|
||||
<div class="layui-input-inline good-name">
|
||||
<input type="radio" name="fenxiao_type" value="1" title="默认规则" lay-filter="fenxiao_type" {if $goods_info['fenxiao_type'] == 1 }checked{/if}>
|
||||
<input type="radio" name="fenxiao_type" value="2" title="单独设置" lay-filter="fenxiao_type" {if $goods_info['fenxiao_type'] == 2 }checked{/if}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if $goods_info['is_fenxiao'] == 0 || $goods_info['fenxiao_type'] == 2}layui-hide{/if}" id="default_rule">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<table class="layui-table" id="default_rule_list" lay-skin="line" lay-size="lg">
|
||||
<colgroup>
|
||||
<col width="25%">
|
||||
<col width="25%">
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<col width="25%">
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<col width="25%">
|
||||
{/if}
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>默认规则</th>
|
||||
<th>一级佣金比例</th>
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<th>二级佣金比例</th>
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<th>三级佣金比例</th>
|
||||
{/if}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $fenxiao_level as $level}
|
||||
<tr>
|
||||
<td>{$level.level_name}</td>
|
||||
<td>{$level.one_rate}%</td>
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<td>{$level.two_rate}%</td>
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<td>{$level.three_rate}%</td>
|
||||
{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if $goods_info['is_fenxiao'] == 0 || $goods_info['fenxiao_type'] == 1}layui-hide{/if}" id="personal_rule">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<table class="layui-table" id="rule_list" lay-skin="line" lay-size="lg">
|
||||
<colgroup>
|
||||
<col width="15%">
|
||||
<col width="10%">
|
||||
<col width="5%">
|
||||
<col width="10%">
|
||||
<col width="20%">
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<col width="20%">
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<col width="20%">
|
||||
{/if}
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>商品规格</th>
|
||||
<th><p class="align-right">价格</p></th>
|
||||
<th></th>
|
||||
<th><p class="line-hiding" title="分销商等级名称">分销商等级名称</p></th>
|
||||
<th>一级佣金比例</th>
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<th>二级佣金比例</th>
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<th>三级佣金比例</th>
|
||||
{/if}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $fenxiao_level as $level}
|
||||
<tr>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
<input name="fenxiao[{$level['level_id']}][sku_id][]" value="{$sku.sku_id}" hidden />
|
||||
<input name="fenxiao[{$level['level_id']}][sku_price][]" value="{$sku.price}" hidden />
|
||||
{/foreach}
|
||||
<td>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
<p class="line-hiding line-height" title="{$sku.sku_name}">{$sku.sku_name}</p>
|
||||
{/foreach}
|
||||
</td>
|
||||
<td>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
<p class="align-right line-height" title="¥{$sku.price}">¥{$sku.price}</p>
|
||||
{/foreach}
|
||||
</td>
|
||||
<td></td>
|
||||
<td>{$level.level_name}</td>
|
||||
<td>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
{if isset($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id])}
|
||||
<div class="line-height">
|
||||
<div><input class="layui-input len-short input-rate" type="number" min="0" max="100" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][one_rate][]" value="{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['one_rate'] ?: ''}" {if $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['one_money'] > 0}disabled{/if} > %</div>
|
||||
<div><input class="layui-input len-short input-num" type="number" min="0" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][one_money][]" value="{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['one_money'] ?: ''}" {if $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['one_rate'] > 0}disabled{/if} > 元</div>
|
||||
</div>
|
||||
{else/}
|
||||
<div class="line-height">
|
||||
<div><input class="layui-input len-short input-rate" type="number" min="0" max="100" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][one_rate][]" value="" > %</div>
|
||||
<div><input class="layui-input len-short input-num" type="number" min="0" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][one_money][]" value="" > 元</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</td>
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<td>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
{if isset($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id])}
|
||||
<div class="line-height">
|
||||
<div><input class="layui-input len-short input-rate" type="number" min="0" max="100" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][two_rate][]" value="{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['two_rate'] ?: ''}" {if $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['two_money'] > 0}disabled{/if} > %</div>
|
||||
<div><input class="layui-input len-short input-num" type="number" min="0" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][two_money][]" value="{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['two_money'] ?: ''}" {if $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['two_rate'] > 0}disabled{/if} > 元</div>
|
||||
</div>
|
||||
{else/}
|
||||
<div class="line-height">
|
||||
<div><input class="layui-input len-short input-rate" type="number" min="0" max="100" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][two_rate][]" value=""> %</div>
|
||||
<div><input class="layui-input len-short input-num" type="number" min="0" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][two_money][]" value=""> 元</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</td>
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<td>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
{if isset($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id])}
|
||||
<div class="line-height">
|
||||
<div><input class="layui-input len-short input-rate" type="number" min="0" max="100" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][three_rate][]" value="{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['three_rate'] ?: ''}" {if $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['three_money'] > 0}disabled{/if} > %</div>
|
||||
<div><input class="layui-input len-short input-num" type="number" min="0" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][three_money][]" value="{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['three_money'] ?: ''}" {if $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['three_rate'] > 0}disabled{/if} > 元</div>
|
||||
</div>
|
||||
{else/}
|
||||
<div class="line-height">
|
||||
<div><input class="layui-input len-short input-rate" type="number" min="0" max="100" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][three_rate][]" value=""> %</div>
|
||||
<div><input class="layui-input len-short input-num" type="number" min="0" lay-verify="required|flnum" name="fenxiao[{$level.level_id}][three_money][]" value=""> 元</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</td>
|
||||
{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="single-filter-box">
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backFenxiaoGoodsList()">返回</button>
|
||||
</div>
|
||||
<input type="hidden" name="goods_id" value="{$goods_info.goods_id}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var fenxiao_type = {$goods_info.fenxiao_type};
|
||||
if (fenxiao_type == 1) {
|
||||
$(".layui-input").removeAttr("lay-verify");
|
||||
}
|
||||
layui.use(['form'], function() {
|
||||
var form = layui.form,
|
||||
repeat_flag = false;
|
||||
form.render();
|
||||
|
||||
$(".layui-input").each(function() {
|
||||
$(this).on('input', function(){
|
||||
var _this = $(this);
|
||||
if(Number($(_this).val()) > 0){
|
||||
$(this).parent().siblings().find("input").attr('disabled', true);
|
||||
$(this).parent().siblings().find("input").removeAttr("lay-verify");
|
||||
} else {
|
||||
$(this).parent().siblings().find("input").attr('disabled', false);
|
||||
$(this).parent().siblings().find("input").attr("lay-verify", "required|flnum");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 是否参与分销
|
||||
form.on("radio(is_fenxiao)", function (data) {
|
||||
if (data.value == 1) {
|
||||
$("#fenxiao_type,#fenxiao_price,#default_rule").removeClass("layui-hide");
|
||||
$(".layui-input").removeAttr("lay-verify");
|
||||
} else {
|
||||
$("#fenxiao_type,#fenxiao_price,#default_rule").addClass("layui-hide");
|
||||
$(".layui-input").attr("lay-verify", "required|flnum");
|
||||
}
|
||||
});
|
||||
|
||||
// 佣金规则
|
||||
form.on("radio(fenxiao_type)", function (data) {
|
||||
if (data.value == 1) {
|
||||
$("#default_rule").removeClass("layui-hide");
|
||||
$("#personal_rule").addClass("layui-hide");
|
||||
$(".layui-input").removeAttr("lay-verify");
|
||||
} else {
|
||||
$("#default_rule").addClass("layui-hide");
|
||||
$("#personal_rule").removeClass("layui-hide");
|
||||
$(".layui-input").attr("lay-verify", "required|flnum");
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单提交
|
||||
*/
|
||||
form.on('submit(save)', function(data){
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("fenxiao://shop/goods/config"),
|
||||
data: data.field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.msg('操作成功');
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
required: function (value) {
|
||||
if (value.trim() == '' || value < 0) {
|
||||
return '佣金比例不能为空,且必须大于0!';
|
||||
}
|
||||
},
|
||||
flnum: function (value) {
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return "佣金比例最多可保留两位小数";
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function backFenxiaoGoodsList() {
|
||||
location.hash = ns.hash("fenxiao://shop/goods/lists");
|
||||
}
|
||||
</script>
|
||||
187
addon/fenxiao/shop/view/goods/detail.html
Executable file
187
addon/fenxiao/shop/view/goods/detail.html
Executable file
@@ -0,0 +1,187 @@
|
||||
<style>
|
||||
.align-right {text-align: right;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form">
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">商品信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item goods-image-wrap">
|
||||
<label class="layui-form-label">商品图片:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="js-goods-image"><img layer-src src="{:img($goods_info.goods_image[0],'small')}" width = "50px"/></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品名称:</label>
|
||||
<div class="layui-input-inline good-name">{$goods_info.goods_name}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">佣金设置</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">佣金规则:</label>
|
||||
<div class="layui-input-inline good-name">
|
||||
{if $goods_info['fenxiao_type'] == 1 }默认规则{/if}
|
||||
{if $goods_info['fenxiao_type'] == 2 }单独设置{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" id="default_rule" {if condition="$goods_info['fenxiao_type'] == 2"} style="display:none" {/if}>
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<table class="layui-table" id="default_rule_list" lay-skin="line" lay-size="lg">
|
||||
<colgroup>
|
||||
<col width="25%">
|
||||
<col width="25%">
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<col width="25%">
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<col width="25%">
|
||||
{/if}
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>默认规则</th>
|
||||
<th>一级佣金比例</th>
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<th>二级佣金比例</th>
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<th>三级佣金比例</th>
|
||||
{/if}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $fenxiao_level as $level}
|
||||
<tr>
|
||||
<td>{$level.level_name}</td>
|
||||
<td>{$level.one_rate}%</td>
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<td>{$level.two_rate}%</td>
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<td>{$level.three_rate}%</td>
|
||||
{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" id="personal_rule" {if condition="$goods_info['fenxiao_type'] == 1"} style="display:none" {/if}>
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<table class="layui-table" id="rule_list" lay-skin="line" lay-size="lg">
|
||||
<colgroup>
|
||||
<col width="15%">
|
||||
<col width="10%">
|
||||
<col width="15%">
|
||||
<col width="20%">
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<col width="20%">
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<col width="20%">
|
||||
{/if}
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>商品规格</th>
|
||||
<th><p class="align-right">价格</p></th>
|
||||
<th><p class="line-hiding" title="分销商等级名称">分销商等级名称</p></th>
|
||||
<th>一级佣金比例</th>
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<th>二级佣金比例</th>
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<th>三级佣金比例</th>
|
||||
{/if}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $fenxiao_level as $level}
|
||||
<tr>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
{/foreach}
|
||||
<td>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
<p class="line-hiding line-height" title="{$sku.sku_name}">{$sku.sku_name}</p>
|
||||
{/foreach}
|
||||
</td>
|
||||
<td>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
<p class="align-right line-height" title="¥{$sku.price}">¥{$sku.price}</p>
|
||||
{/foreach}
|
||||
</td>
|
||||
<td>{$level.level_name}</td>
|
||||
<td>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
<p>
|
||||
{if !empty($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['one_rate']) && $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['one_rate'] > 0}
|
||||
{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['one_rate']}%
|
||||
{/if}
|
||||
{if !empty($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['one_money']) && $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['one_money'] > 0}
|
||||
{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['one_money']}元
|
||||
{/if}
|
||||
</p>
|
||||
{/foreach}
|
||||
</td>
|
||||
{if $fenxiao_config.level >= 2}
|
||||
<td>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
<p>
|
||||
{if !empty($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['two_rate']) && $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['two_rate'] > 0}
|
||||
{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['two_rate']}%
|
||||
{/if}
|
||||
{if !empty($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['two_money']) && $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['two_money'] > 0}
|
||||
{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['two_money']}元
|
||||
{/if}
|
||||
</p>
|
||||
{/foreach}
|
||||
</td>
|
||||
{/if}
|
||||
{if $fenxiao_config.level >= 3}
|
||||
<td>
|
||||
{foreach $goods_info['sku_data'] as $sku}
|
||||
<p>
|
||||
{if !empty($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['three_rate']) && $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['three_rate'] > 0}
|
||||
{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['three_rate']}%
|
||||
{/if}
|
||||
{if !empty($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['three_money']) && $goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['three_money'] > 0}
|
||||
{$goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id]['three_money']}元
|
||||
{/if}
|
||||
</p>
|
||||
{/foreach}
|
||||
</td>
|
||||
{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="form-row">
|
||||
<button class="layui-btn layui-btn-primary" onclick="backFenxiaoGoodsList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function backFenxiaoGoodsList() {
|
||||
location.hash = ns.hash("fenxiao://shop/goods/lists");
|
||||
}
|
||||
</script>
|
||||
409
addon/fenxiao/shop/view/goods/lists.html
Executable file
409
addon/fenxiao/shop/view/goods/lists.html
Executable file
@@ -0,0 +1,409 @@
|
||||
<style>.table-tab{margin-top: 0;}</style>
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品名称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="search_text" autocomplete="off" class="layui-input" placeholder="输入商品名称" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品类型:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="goods_class" lay-filter="goods_class">
|
||||
<option value="">全部</option>
|
||||
<option value="1">实物商品</option>
|
||||
<option value="2">虚拟商品</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">是否参与:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="is_fenxiao" lay-filter="is_fenxiao">
|
||||
<option value="">全部</option>
|
||||
<option value="1">已参与</option>
|
||||
<option value="0">未参与</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品分类:</label>
|
||||
<div class="layui-input-inline">
|
||||
{include file="goods/category_select" /}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">销量:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="start_sale" id="start_sale" lay-verify="int" placeholder="最低销量" class="layui-input" autocomplete="off">
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="end_sale" id="end_sale" lay-verify="int" placeholder="最高销量" class="layui-input" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="goods_state" />
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit id="" lay-filter="search">筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-tab table-tab" lay-filter="fenxiao_goods_tab">
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="fenxiao_list" lay-filter="fenxiao_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 商品 -->
|
||||
<script type="text/html" id="goods_info">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
<img layer-src src="{{ns.img(d.goods_image.split(',')[0], 'small')}}"/>
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color-sub" title="{{d.goods_name}}">{{d.goods_name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 0){ }}
|
||||
<span style="color: red;">待审核</span>
|
||||
{{# }else if(d.status == 1){ }}
|
||||
<span style="color: green;">审核通过</span>
|
||||
{{# }else if(d.status == 2){ }}
|
||||
<span style="color: gray;">审核拒绝</span>
|
||||
{{# }else if(d.status == -1){ }}
|
||||
<span style="color: gray;">冻结</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 工具栏操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="operation-wrap" data-goods-id="{{d.goods_id}}">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="detail">详情</a>
|
||||
{{# if(d.is_fenxiao == 1){ }}
|
||||
<a class="layui-btn" lay-event="config">佣金设置</a>
|
||||
{{# }else{ }}
|
||||
{{# } }}
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 批量操作 -->
|
||||
<script type="text/html" id="toolbarOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="join">参与</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="cancel">不参与</button>
|
||||
</script>
|
||||
|
||||
<!-- 批量操作 -->
|
||||
<script type="text/html" id="batchOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="join">参与</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="cancel">不参与</button>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var form, element, repeat_flag, table;
|
||||
layui.use(['form', 'laydate','element'], function() {
|
||||
form = layui.form, element = layui.element, laydate = layui.laydate;
|
||||
form.render();
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#fenxiao_list',
|
||||
url: ns.url("fenxiao://shop/goods/lists"),
|
||||
toolbar: '#toolbarOperation',
|
||||
bottomToolbar: "#batchOperation",
|
||||
cols: [
|
||||
[{
|
||||
type: 'checkbox',
|
||||
unresize: 'false',
|
||||
width: '3%'
|
||||
},
|
||||
{
|
||||
title: '商品名称',
|
||||
unresize: 'false',
|
||||
templet: '#goods_info',
|
||||
width: '21%'
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '价格',
|
||||
unresize: 'false',
|
||||
align: 'right',
|
||||
width: '13%',
|
||||
templet: function (data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}, {
|
||||
unresize: 'false',
|
||||
width: '4%'
|
||||
}, {
|
||||
field: 'goods_stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
width: '8%'
|
||||
}, {
|
||||
field: 'sale_num',
|
||||
title: '销量',
|
||||
unresize: 'false',
|
||||
width: '8%'
|
||||
}, {
|
||||
title: '销售状态',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function (data) {
|
||||
var str = '';
|
||||
if (data.goods_state == 1) {
|
||||
str = '<span style="color: green">销售中</span>';
|
||||
} else if (data.goods_state == 0) {
|
||||
str = '<span style="color: red">仓库中</span>';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}, {
|
||||
title: '是否参与',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function (data) {
|
||||
if(data.is_fenxiao == 1){
|
||||
return '<input type="checkbox" name="is_fenxiao" data-goods-id="'+ data.goods_id + '" value="1" lay-filter="is_fenxiao" lay-skin="switch" checked>';
|
||||
}else{
|
||||
return '<input type="checkbox" name="is_fenxiao" data-goods-id="'+ data.goods_id + '" value="0" lay-filter="is_fenxiao" lay-skin="switch">';
|
||||
}
|
||||
}
|
||||
}, {
|
||||
title: '<div class="prompt-block">' + '规则' +
|
||||
'<div class="prompt">' +
|
||||
'<i class="iconfont iconwenhao1 required growth"></i>' +
|
||||
'<div class="growth-box reason-box reason-growth prompt-box" >' +
|
||||
'<div class="prompt-con">' +
|
||||
'<ul style="font-weight: 100">' +
|
||||
'<li>1、分销商层级与后台配置有关,最多三级分销。</li>' +
|
||||
'<li>2、分销商等级与分销商的分销订单数,分销订单总额,自购订单数,自购订单总额,分销商下线人数,分销商的下级分销商人数有关。</li>' +
|
||||
'<li>3、商品分销总佣金不得超过商品实际价格的50%。</li>' +
|
||||
'<li>4、分销佣金是根据当前分销订单所属分销商等级或者商品自定义的计算规则进行结算。</li>' +
|
||||
'<li>5、分销结算说明: A 、B 、C是分销商,C的上级为B,B的上级为A。' +
|
||||
'分佣按照所属分销商的等级佣金比率进行分配,分销商C的等级分佣比率为一级10%,二级5%,三级2%,' +
|
||||
'订单属于分销商C,则C获得商品实付金额10%,B获得商品实付金额5%,A获得商品实付金额2%。' +
|
||||
'若C推荐的普通用户D购买商品,则该订单属于C;若C购买商品,则该订单属于C。</li>' +
|
||||
'</ul>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function (data) {
|
||||
var str = '';
|
||||
if (data.fenxiao_type == 1) {
|
||||
str = '默认规则';
|
||||
} else if (data.fenxiao_type == 2) {
|
||||
str = '单独设置';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
//按钮监控
|
||||
form.on('switch(is_fenxiao)', function(data){
|
||||
var goods_id = $(data.elem).attr('data-goods-id');
|
||||
modifyFenxiao(goods_id, data.value, data.elem);
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data,
|
||||
event = obj.event;
|
||||
switch (event) {
|
||||
case 'detail': //查看
|
||||
location.hash = ns.hash('fenxiao://shop/goods/detail', {'goods_id': data.goods_id});
|
||||
break;
|
||||
case 'config':
|
||||
//编辑
|
||||
location.hash = ns.hash("fenxiao://shop/goods/config", {"goods_id": data.goods_id});
|
||||
break;
|
||||
case 'modify':
|
||||
//删除
|
||||
modifyFenxiao(data.goods_id, data.is_fenxiao);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// 批量操作
|
||||
table.bottomToolbar(function (obj) {
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
var id_array = new Array();
|
||||
for (i in obj.data) id_array.push(obj.data[i].goods_id);
|
||||
switch (obj.event) {
|
||||
case "join":
|
||||
joinFenxiao(id_array);
|
||||
break;
|
||||
case 'cancel':
|
||||
//下架
|
||||
cancelFenxiao(id_array);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// 批量操作
|
||||
table.toolbar(function (obj) {
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
var id_array = new Array();
|
||||
for (i in obj.data) id_array.push(obj.data[i].goods_id);
|
||||
switch (obj.event) {
|
||||
case "join":
|
||||
joinFenxiao(id_array);
|
||||
break;
|
||||
case 'cancel':
|
||||
//下架
|
||||
cancelFenxiao(id_array);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//配置参与状态
|
||||
function modifyFenxiao(goods_id, is_fenxiao, data) {
|
||||
if(is_fenxiao == 0){
|
||||
var fenxiao_tip = "如果商品尚未设置佣金规则,首次开启默认按照分销等级发放佣金,是否继续开启?";
|
||||
}else{
|
||||
var fenxiao_tip = "是否设置商品不参与分销?";
|
||||
}
|
||||
layer.confirm(fenxiao_tip,{
|
||||
btn: ['确定', '取消'],
|
||||
cancel: function(index, layero){
|
||||
if(is_fenxiao == 1){
|
||||
$(data).prop("checked",true);
|
||||
}else{
|
||||
$(data).prop("checked",false);
|
||||
}
|
||||
form.render();
|
||||
layer.close(index);
|
||||
return false;
|
||||
}
|
||||
}, function () {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/goods/modify"),
|
||||
data: {goods_id: goods_id, is_fenxiao:is_fenxiao},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
},function () {
|
||||
if(is_fenxiao == 1){
|
||||
$(data).prop("checked",true);
|
||||
form.render();
|
||||
}else{
|
||||
$(data).prop("checked",false);
|
||||
form.render();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function joinFenxiao(goods_ids){
|
||||
layer.confirm('批量参与分销的商品,如果之前未配置佣金规则,则默认按照分销等级发放佣金,是否继续?', {title: '提示'}, function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/goods/setGoodsIsFenxiao"),
|
||||
data: {goods_ids: goods_ids.toString(), is_fenxiao: 1},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function cancelFenxiao(goods_ids) {
|
||||
layer.confirm('是否设置商品不参与分销?', {title: '提示'}, function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/goods/setGoodsIsFenxiao"),
|
||||
data: {goods_ids: goods_ids.toString()},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
380
addon/fenxiao/shop/view/level/add.html
Executable file
380
addon/fenxiao/shop/view/level/add.html
Executable file
@@ -0,0 +1,380 @@
|
||||
<style>
|
||||
.layui-btn+.layui-btn {margin-left: 0;}
|
||||
.layui-btn {margin-right: 10px; margin-bottom: 15px;}
|
||||
.weight-list span{display: inline-block;width: 60px;line-height: 30px;border:1px solid #eee;border-radius: 4px;text-align: center;font-size: 12px;cursor: pointer;}
|
||||
.weight-list span.disabled{background:#f1f1f1;cursor: not-allowed; }
|
||||
.layui-btn.layui-btn-primary.level-btn span{margin-left: 5px}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<!-- 基础上传 -->
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">等级佣金比例</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>等级权重:</label>
|
||||
<div class="layui-input-block weight-list">
|
||||
<span value="1" class="{if in_array(1, $level_weight)}disabled{/if}">一级</span>
|
||||
<span value="2" class="{if in_array(2, $level_weight)}disabled{/if}">二级</span>
|
||||
<span value="3" class="{if in_array(3, $level_weight)}disabled{/if}">三级</span>
|
||||
<span value="4" class="{if in_array(4, $level_weight)}disabled{/if}">四级</span>
|
||||
<span value="5" class="{if in_array(5, $level_weight)}disabled{/if}">五级</span>
|
||||
<span value="6" class="{if in_array(6, $level_weight)}disabled{/if}">六级</span>
|
||||
<span value="7" class="{if in_array(7, $level_weight)}disabled{/if}">七级</span>
|
||||
<span value="8" class="{if in_array(8, $level_weight)}disabled{/if}">八级</span>
|
||||
<span value="9" class="{if in_array(9, $level_weight)}disabled{/if}">九级</span>
|
||||
<span value="10" class="{if in_array(10, $level_weight)}disabled{/if}">十级</span>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>等级权重越大等级越高</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>等级名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="level_name" lay-verify="required" autocomplete="off" class="layui-input len-mid" maxlength="40">
|
||||
</div>
|
||||
</div>
|
||||
{if $basics_info.level == 1}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级佣金比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_rate" lay-verify="required|money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的佣金比例</p>
|
||||
</div>
|
||||
{elseif $basics_info.level == 2 /}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级佣金比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_rate" lay-verify="required|money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的佣金比例</p>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>二级佣金比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="two_rate" lay-verify="required|mondy" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的上级分销商佣金比例</p>
|
||||
</div>
|
||||
{elseif $basics_info.level == 3 /}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级佣金比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_rate" lay-verify="required|money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的佣金比例</p>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>二级佣金比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="two_rate" lay-verify="required|mondy" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的上级分销商佣金比例</p>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>三级佣金比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="three_rate" lay-verify="required|money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的上上级分销商佣金比例</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">升级条件</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">升级方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="upgrade_type" value="1" lay-filter="withdraw_type" title="满足以下任意条件" checked />
|
||||
<input type="radio" name="upgrade_type" value="2" lay-filter="withdraw_type" title="满足以下全部条件" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<!-- <button class="layui-btn layui-btn-primary level-btn">分销订单总额<input type="hidden" value="2" /></button> -->
|
||||
<!-- <button class="layui-btn layui-btn-primary level-btn">分销订单总数<input type="hidden" value="1" /></button> -->
|
||||
<button class="layui-btn layui-btn-primary level-btn">一级分销订单总数<span class="iconfont iconwenhao1" title="分销商自己购买和自己推荐的直属会员购买的订单次数"></span><input type="hidden" value="1" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn">一级分销订单佣金总额<span class="iconfont iconwenhao1" title="分销商自己购买和自己推荐的直属会员购买的订单佣金总额"></span><input type="hidden" value="2" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn">一级分销订单总额<span class="iconfont iconwenhao1" title="分销商自己购买和推荐的直属会员购买的订单的总额"></span><input type="hidden" value="2" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn">自购订单总数<span class="iconfont iconwenhao1" title="分销商自己购买的订单次数"></span><input type="hidden" value="1" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn">自购订单总额<span class="iconfont iconwenhao1" title="分销商自己购买的订单总额"></span><input type="hidden" value="2" /></button>
|
||||
<!-- <button class="layui-btn layui-btn-primary level-btn">下线人数<input type="hidden" value="1" /></button> -->
|
||||
<!-- <button class="layui-btn layui-btn-primary level-btn">下线分销商人数<input type="hidden" value="1" /></button> -->
|
||||
<button class="layui-btn layui-btn-primary level-btn">一级下线人数<span class="iconfont iconwenhao1" title="分销商的直属下级会员(包含已经申请成为分销商的)"></span><input type="hidden" value="1" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn">一级下线分销商<span class="iconfont iconwenhao1" title="分销商的直属下级分销商"></span><input type="hidden" value="1" /></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">升级条件限制</span>
|
||||
</div>
|
||||
<div class="layui-card-body level-term">
|
||||
<!-- <div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>分销订单总数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="fenxiao_order_num" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">个</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>分销订单总额:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="fenxiao_order_meney" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div> -->
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级分销订单总数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_fenxiao_order_num" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">个</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级分销订单佣金总额:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_fenxiao_order_money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级分销订单总额:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_fenxiao_total_order" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>自购订单总数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="order_num" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">个</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>自购订单总额:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="order_money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>下线人数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="child_num" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">人</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>下线分销商人数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="child_fenxiao_num" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">人</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div> -->
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级下线人数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_child_num" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">人</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级下线分销商:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_child_fenxiao_num" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">人</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backFenxiaoLevelList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
$('.weight-list span').not('.disabled').eq(0).addClass("border-color");
|
||||
});
|
||||
|
||||
layui.use(['form'], function() {
|
||||
var form = layui.form,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
$(".weight-list span").click(function() {
|
||||
if (!$(this).hasClass("disabled")) {
|
||||
$(this).addClass("border-color");
|
||||
$(this).siblings().removeClass("border-color");
|
||||
}
|
||||
});
|
||||
|
||||
$(".level-btn").click(function() {
|
||||
var _index = $(this).index();
|
||||
|
||||
if (!$(this).hasClass("border-color")) {
|
||||
$(this).addClass("border-color");
|
||||
$(".level-term>div").eq(_index).removeClass("layui-hide");
|
||||
if ($(this).find("input").val() == 1) {
|
||||
$(".level-term>div").eq(_index).find("input").attr("lay-verify", "required|num");
|
||||
} else {
|
||||
$(".level-term>div").eq(_index).find("input").attr("lay-verify", "required|money");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(save)', function(data) {
|
||||
data.field.level_num = $(".weight-list span.border-color").attr('value');
|
||||
var arr = $(".layui-card-body").eq(2).children('.layui-form-item').length;
|
||||
var arr1 = $(".layui-card-body").eq(2).children('.layui-form-item.layui-hide').length;
|
||||
if (data.field.level_num == undefined){
|
||||
layer.msg('请选择等级权重');
|
||||
return;
|
||||
}
|
||||
if(arr==arr1){
|
||||
layer.msg('请选择升级条件');
|
||||
return;
|
||||
}
|
||||
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("fenxiao://shop/level/add"),
|
||||
data: data.field,
|
||||
success: function(res) {
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.confirm('添加成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续添加'],
|
||||
closeBtn: 0,
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("fenxiao://shop/level/lists");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
num: function(value, item) {
|
||||
var str = $(item).parents(".layui-form-item").find("label").text().split("*").join("");
|
||||
str = str.substring(0, str.length - 1);
|
||||
|
||||
if (value <= 0) {
|
||||
return str + '必须大于0';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return str + '必须为整数';
|
||||
}
|
||||
},
|
||||
money: function(value, item) {
|
||||
var str = $(item).parents(".layui-form-item").find("label").text().split("*").join("");
|
||||
str = str.substring(0, str.length - 1);
|
||||
|
||||
if (value < 0) {
|
||||
return str + '不能小于0';
|
||||
}
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return str + "最多可保留两位小数";
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function delDiv(e) {
|
||||
var _len = $(e).parents(".layui-form-item").index();
|
||||
$(e).parents(".layui-form-item").addClass("layui-hide");
|
||||
$(e).parents(".layui-form-item").find("input").removeAttr("lay-verify");
|
||||
$(e).parents(".layui-form-item").find("input").val("");
|
||||
$(".level-btn").eq(_len).removeClass("border-color");
|
||||
}
|
||||
|
||||
function backFenxiaoLevelList() {
|
||||
location.hash = ns.hash("fenxiao://shop/level/lists");
|
||||
}
|
||||
</script>
|
||||
397
addon/fenxiao/shop/view/level/edit.html
Executable file
397
addon/fenxiao/shop/view/level/edit.html
Executable file
@@ -0,0 +1,397 @@
|
||||
<style>
|
||||
.layui-btn+.layui-btn {margin-left: 0;}
|
||||
.layui-btn {margin-right: 10px; margin-bottom: 15px;}
|
||||
.weight-list span{display: inline-block;width: 60px;line-height: 30px;border:1px solid #eee;border-radius: 4px;text-align: center;font-size: 12px;cursor: pointer;}
|
||||
.weight-list span.disabled{background:#f1f1f1;cursor: not-allowed; }
|
||||
.layui-btn.layui-btn-primary.level-btn span{margin-left: 5px}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<!-- 基础上传 -->
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">等级佣金比例</span>
|
||||
</div>
|
||||
|
||||
<div class="layui-card-body">
|
||||
{if $info.is_default eq 0}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>等级权重:</label>
|
||||
<div class="layui-input-block weight-list">
|
||||
<span value="1" class="{if $info.level_num eq 1}border-color{/if} {if in_array(1, $level_weight)}disabled{/if}">一级</span>
|
||||
<span value="2" class="{if $info.level_num eq 2}border-color{/if} {if in_array(2, $level_weight)}disabled{/if}">二级</span>
|
||||
<span value="3" class="{if $info.level_num eq 3}border-color{/if} {if in_array(3, $level_weight)}disabled{/if}">三级</span>
|
||||
<span value="4" class="{if $info.level_num eq 4}border-color{/if} {if in_array(4, $level_weight)}disabled{/if}">四级</span>
|
||||
<span value="5" class="{if $info.level_num eq 5}border-color{/if} {if in_array(5, $level_weight)}disabled{/if}">五级</span>
|
||||
<span value="6" class="{if $info.level_num eq 6}border-color{/if} {if in_array(6, $level_weight)}disabled{/if}">六级</span>
|
||||
<span value="7" class="{if $info.level_num eq 7}border-color{/if} {if in_array(7, $level_weight)}disabled{/if}">七级</span>
|
||||
<span value="8" class="{if $info.level_num eq 8}border-color{/if} {if in_array(8, $level_weight)}disabled{/if}">八级</span>
|
||||
<span value="9" class="{if $info.level_num eq 9}border-color{/if} {if in_array(9, $level_weight)}disabled{/if}">九级</span>
|
||||
<span value="10" class="{if $info.level_num eq 10}border-color{/if} {if in_array(10, $level_weight)}disabled{/if}">十级</span>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>等级权重越大等级越高</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>等级名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="level_name" value="{$info.level_name}" lay-verify="required" autocomplete="off" class="layui-input len-mid" maxlength="40">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if $basics_info.level == 1}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级佣金比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_rate" value="{$info.one_rate}" lay-verify="required|money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的佣金比例</p>
|
||||
</div>
|
||||
</div>
|
||||
{elseif $basics_info.level == 2 /}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级佣金比例:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_rate" lay-verify="required|money" value="{$info.one_rate}" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的佣金比例</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>二级佣金比例:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="two_rate" value="{$info.two_rate}" lay-verify="required|money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
</div>
|
||||
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的上级分销商佣金比例</p>
|
||||
</div>
|
||||
</div>
|
||||
{elseif $basics_info.level == 3 /}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级佣金比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_rate" value="{$info.one_rate}" lay-verify="required|money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的佣金比例</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>二级佣金比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="two_rate" value="{$info.two_rate}" lay-verify="required|money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的上级分销商佣金比例</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>三级佣金比例:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="three_rate" value="{$info.three_rate}" lay-verify="required|money" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">%</div>
|
||||
<div class="word-aux">
|
||||
<p>会员购买后给当前等级分销商的上上级分销商佣金比例</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{if $info.is_default eq 0}
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">升级条件</span>
|
||||
</div>
|
||||
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">升级方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="upgrade_type" value="1" lay-filter="withdraw_type" title="满足以下任意条件" checked />
|
||||
<input type="radio" name="upgrade_type" value="2" lay-filter="withdraw_type" {if $info.upgrade_type == 2} checked {/if} title="满足以下全部条件" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<!-- <button class="layui-btn layui-btn-primary level-btn {if $info.fenxiao_order_num > 0}border-color{/if}">分销订单总数<input type="hidden" value="1" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn {if $info.fenxiao_order_meney > 0}border-color{/if}">分销订单总额<input type="hidden" value="2" /></button> -->
|
||||
<button class="layui-btn layui-btn-primary level-btn {if $info.one_fenxiao_order_num > 0}border-color{/if}">一级分销订单总数<span class="iconfont iconwenhao1" title="分销商自己购买和自己推荐的直属会员购买的订单次数"></span><input type="hidden" value="1" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn {if $info.one_fenxiao_order_money > 0}border-color{/if}">一级分销订单佣金总额<span class="iconfont iconwenhao1" title="分销商自己购买和自己推荐的直属会员购买的订单佣金总额"></span><input type="hidden" value="2" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn {if $info.one_fenxiao_total_order > 0}border-color{/if}">一级分销订单总额<span class="iconfont iconwenhao1" title="分销商自己购买和自己推荐的直属会员购买的订单的总额"></span><input type="hidden" value="2" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn {if $info.order_num > 0}border-color{/if}">自购订单总数<span class="iconfont iconwenhao1" title="分销商自己购买的订单次数"></span><input type="hidden" value="1" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn {if $info.order_money > 0}border-color{/if}">自购订单总额<span class="iconfont iconwenhao1" title="分销商自己购买的订单总额"></span><input type="hidden" value="2" /></button>
|
||||
<!-- <button class="layui-btn layui-btn-primary level-btn {if $info.child_num > 0}border-color{/if}">下线人数<input type="hidden" value="1" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn {if $info.child_fenxiao_num > 0}border-color{/if}">下线分销商人数<input type="hidden" value="1" /></button> -->
|
||||
<button class="layui-btn layui-btn-primary level-btn {if $info.one_child_num > 0}border-color{/if}">一级下线人数<span class="iconfont iconwenhao1" title="分销商的直属下级会员(包含已经申请成为分销商的)"></span><input type="hidden" value="1" /></button>
|
||||
<button class="layui-btn layui-btn-primary level-btn {if $info.one_child_fenxiao_num > 0}border-color{/if}">一级下线分销商<span class="iconfont iconwenhao1" title="分销商的直属下级分销商"></span><input type="hidden" value="1" /></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">升级条件限制</span>
|
||||
</div>
|
||||
<div class="layui-card-body level-term">
|
||||
|
||||
<!-- <div class="layui-form-item {if $info.fenxiao_order_num <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>分销订单总数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="fenxiao_order_num" value="{$info.fenxiao_order_num}" {if $info.fenxiao_order_num > 0}lay-verify="required|num"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">个</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if $info.fenxiao_order_meney <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>分销订单总额:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="fenxiao_order_meney" value="{$info.fenxiao_order_meney}" {if $info.fenxiao_order_meney > 0}lay-verify="required|money"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div> -->
|
||||
|
||||
<div class="layui-form-item {if $info.one_fenxiao_order_num <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级分销订单总数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_fenxiao_order_num" value="{$info.one_fenxiao_order_num}" {if $info.one_fenxiao_order_num > 0}lay-verify="required|num"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">个</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if $info.one_fenxiao_order_money <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级分销订单佣金总额:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_fenxiao_order_money" value="{$info.one_fenxiao_order_money}" {if $info.one_fenxiao_order_money >0}lay-verify="required|money"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if $info.one_fenxiao_total_order <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级分销订单总额:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_fenxiao_total_order" value="{$info.one_fenxiao_total_order}" {if $info.one_fenxiao_total_order >0}lay-verify="required|money"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if $info.order_num <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>自购订单总数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="order_num" value="{$info.order_num}" {if $info.order_num > 0}lay-verify="required|num"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">个</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if $info.order_money <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>自购订单总额:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="order_money" value="{$info.order_money}" {if $info.order_money > 0}lay-verify="required|money"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-form-item {if $info.child_num <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>下线人数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="child_num" value="{$info.child_num}" {if $info.child_num > 0}lay-verify="required|num"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">人</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if $info.child_fenxiao_num <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>下线分销商人数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="child_fenxiao_num" value="{$info.child_fenxiao_num}" {if $info.child_fenxiao_num > 0}lay-verify="required|num"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">人</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div> -->
|
||||
|
||||
<div class="layui-form-item {if $info.one_child_num <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级下线人数:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_child_num" value="{$info.one_child_num}" {if $info.one_child_num > 0}lay-verify="required|num"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">人</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if $info.one_child_fenxiao_num <= 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"><span class="required">*</span>一级下线分销商:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" min="0" name="one_child_fenxiao_num" value="{$info.one_child_fenxiao_num}" {if $info.one_child_fenxiao_num > 0}lay-verify="required|num"{/if} autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">人</div>
|
||||
<a href="javascript:;" class="text-color layui-form-mid" onclick="delDiv(this)">删除</a>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<input type="hidden" name="level_id" value="{$info.level_id}">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backFenxiaoLevelList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{else/}
|
||||
<div class="form-row">
|
||||
<input type="hidden" name="level_id" value="{$info.level_id}">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backFenxiaoLevelList()">返回</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
{empty name="$level_weight"}
|
||||
$(function(){
|
||||
$('.weight-list span').not('.disabled').eq(0).addClass("border-color");
|
||||
});
|
||||
{/empty}
|
||||
|
||||
layui.use(['form'], function() {
|
||||
var form = layui.form,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
$(".weight-list span").click(function() {
|
||||
if (!$(this).hasClass("disabled")) {
|
||||
$(this).addClass("border-color");
|
||||
$(this).siblings().removeClass("border-color");
|
||||
}
|
||||
});
|
||||
|
||||
$(".level-btn").click(function() {
|
||||
var _index = $(this).index();
|
||||
|
||||
if (!$(this).hasClass("border-color")) {
|
||||
$(this).addClass("border-color");
|
||||
$(".level-term>div").eq(_index).removeClass("layui-hide");
|
||||
if ($(this).find("input").val() == 1) {
|
||||
$(".level-term>div").eq(_index).find("input").attr("lay-verify", "required|num");
|
||||
} else {
|
||||
$(".level-term>div").eq(_index).find("input").attr("lay-verify", "required|money");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(save)', function(data) {
|
||||
{if $info.is_default eq 0}
|
||||
data.field.level_num = $(".weight-list span.border-color").attr('value');
|
||||
var arr = $(".layui-card-body").eq(2).children('.layui-form-item').length;
|
||||
var arr1 = $(".layui-card-body").eq(2).children('.layui-form-item.layui-hide').length;
|
||||
if (data.field.level_num == undefined){
|
||||
layer.msg('请选择等级权重');
|
||||
return;
|
||||
}
|
||||
if(arr==arr1){
|
||||
layer.msg('请选择升级条件');
|
||||
return;
|
||||
}
|
||||
{/if}
|
||||
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("fenxiao://shop/level/edit"),
|
||||
data: data.field,
|
||||
success: function(res) {
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续编辑'],
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("fenxiao://shop/level/lists");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
num: function(value, item) {
|
||||
var str = $(item).parents(".layui-form-item").find("label").text().split("*").join("");
|
||||
str = str.substring(0, str.length - 1);
|
||||
|
||||
if (value <= 0) {
|
||||
return str + '必须大于0';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return str + '必须为整数';
|
||||
}
|
||||
},
|
||||
money: function(value, item) {
|
||||
var str = $(item).parents(".layui-form-item").find("label").text().split("*").join("");
|
||||
str = str.substring(0, str.length - 1);
|
||||
|
||||
if (value < 0) {
|
||||
return str + '不能小于0';
|
||||
}
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return str + "最多可保留两位小数";
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function delDiv(e) {
|
||||
var _len = $(e).parents(".layui-form-item").index();
|
||||
$(e).parents(".layui-form-item").addClass("layui-hide");
|
||||
$(e).parents(".layui-form-item").find("input").removeAttr("lay-verify");
|
||||
$(e).parents(".layui-form-item").find("input").val("");
|
||||
$(".level-btn").eq(_len).removeClass("border-color");
|
||||
}
|
||||
|
||||
function backFenxiaoLevelList() {
|
||||
location.hash = ns.hash("fenxiao://shop/level/lists");
|
||||
}
|
||||
</script>
|
||||
260
addon/fenxiao/shop/view/level/lists.html
Executable file
260
addon/fenxiao/shop/view/level/lists.html
Executable file
@@ -0,0 +1,260 @@
|
||||
<div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="clickAdd()">添加等级</button>
|
||||
</div>
|
||||
<!-- 列表 -->
|
||||
<table id="level_list" lay-filter="level_list"></table>
|
||||
|
||||
<!-- 商品 -->
|
||||
<script type="text/html" id="goods">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
<img layer-src src="{{ns.img(d.goods_image.split(',')[0],'small')}}"/>
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color">{{d.goods_name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 时间 -->
|
||||
<script id="time" type="text/html">
|
||||
<div class="layui-elip">开始时间:{{ns.time_to_date(d.start_time)}}</div>
|
||||
<div class="layui-elip">结束时间:{{ns.time_to_date(d.end_time)}}</div>
|
||||
</script>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 0){ }}
|
||||
停用
|
||||
{{# }else if(d.status == 1){ }}
|
||||
启用
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
{{# if(d.is_default == 0){ }}
|
||||
<a class="layui-btn" lay-event="del">删除</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use('form', function() {
|
||||
var table,
|
||||
repeat_flag = false; //防重复标识
|
||||
|
||||
table = new Table({
|
||||
elem: '#level_list',
|
||||
url: ns.url("fenxiao://shop/level/lists"),
|
||||
cols: [
|
||||
[{
|
||||
title: '等级',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function (data) {
|
||||
var level = new Array();
|
||||
level[0] = '默认等级';
|
||||
level[1] = '一级';
|
||||
level[2] = '二级';
|
||||
level[3] = '三级';
|
||||
level[4] = '四级';
|
||||
level[5] = '五级';
|
||||
level[6] = '六级';
|
||||
level[7] = '七级';
|
||||
level[8] = '八级';
|
||||
level[9] = '九级';
|
||||
level[10] = '十级';
|
||||
return level[data.level_num] != undefined ? level[data.level_num] : '';
|
||||
}
|
||||
}, {
|
||||
field: 'level_name',
|
||||
title: '等级名称',
|
||||
unresize: 'false',
|
||||
width: '10%'
|
||||
}, {
|
||||
field: 'one_rate',
|
||||
title: '一级佣金比例',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return data.one_rate + '%';
|
||||
},
|
||||
hide: {if $basics_info.level >= 1} false {else /} true {/if}
|
||||
}, {
|
||||
field: 'two_rate',
|
||||
title: '二级佣金比例',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return data.two_rate + '%';
|
||||
},
|
||||
hide: {if $basics_info.level >= 2} false {else /} true {/if}
|
||||
}, {
|
||||
field:'three_rate',
|
||||
title: '三级佣金比例',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: function(data) {
|
||||
return data.three_rate + '%';
|
||||
},
|
||||
hide: {if $basics_info.level >= 3} false {else /} true {/if}
|
||||
}, {
|
||||
title: '升级条件',
|
||||
unresize: 'false',
|
||||
width: '35%',
|
||||
templet: function(data) {
|
||||
if(data.level_num == 0){
|
||||
return "默认等级";
|
||||
}else{
|
||||
var upgrade_content = '';
|
||||
if(data.upgrade_type == 1){
|
||||
upgrade_content += data.one_fenxiao_order_num == 0 ? '' : '一级分销订单总数大于等于' + data.one_fenxiao_order_num + ' 或者 ';
|
||||
upgrade_content += data.one_fenxiao_order_money == 0 ? '' : '一级分销订单佣金总额大于等于' + data.one_fenxiao_order_money + ' 或者 ';
|
||||
upgrade_content += data.one_fenxiao_total_order == 0 ? '' : '一级分销订单总额大于等于' + data.one_fenxiao_total_order + ' 或者 ';
|
||||
upgrade_content += data.order_num == 0 ? '' : '自购订单总数大于等于' + data.order_num + ' 或者 ';
|
||||
upgrade_content += data.order_money == 0 ? '' : '自购订单总额大于等于' + data.order_money + ' 或者 ';
|
||||
upgrade_content += data.one_child_num == 0 ? '' : '下线人数大于等于' + data.one_child_num + ' 或者 ';
|
||||
upgrade_content += data.one_child_fenxiao_num == 0 ? '' : '下线分销商人数大于等于' + data.one_child_fenxiao_num + ' 或者 ';
|
||||
}else if(data.upgrade_type == 2){
|
||||
upgrade_content += data.one_fenxiao_order_num == 0 ? '' : '一级分销订单总数大于等于' + data.one_fenxiao_order_num + ' 并且 ';
|
||||
upgrade_content += data.one_fenxiao_order_money == 0 ? '' : '一级分销订单佣金总额大于等于' + data.one_fenxiao_order_money + ' 并且 ';
|
||||
upgrade_content += data.one_fenxiao_total_order == 0 ? '' : '一级分销订单总额大于等于' + data.one_fenxiao_total_order + ' 并且 ';
|
||||
upgrade_content += data.order_num == 0 ? '' : '自购订单总数大于等于' + data.order_num + ' 并且 ';
|
||||
upgrade_content += data.order_money == 0 ? '' : '自购订单总额大于等于' + data.order_money + ' 并且 ';
|
||||
upgrade_content += data.one_child_num == 0 ? '' : '下线人数大于等于' + data.one_child_num + ' 并且 ';
|
||||
upgrade_content += data.one_child_fenxiao_num == 0 ? '' : '下线分销商人数大于等于' + data.one_child_fenxiao_num + ' 并且 ';
|
||||
}
|
||||
var upgrade_content = upgrade_content.replace(/ 或者 $/g,"");
|
||||
var upgrade_content = upgrade_content.replace(/ 并且 $/g,"");
|
||||
return upgrade_content;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'del': //删除
|
||||
del(data.level_id);
|
||||
break;
|
||||
case 'start': //启用
|
||||
start_status(data.level_id,1);
|
||||
break;
|
||||
case 'stop': //停用
|
||||
stop_status(data.level_id,0);
|
||||
break;
|
||||
case 'edit': //编辑
|
||||
location.hash = ns.hash("fenxiao://shop/level/edit", {"level_id": data.level_id});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function del(level_id){
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
layer.confirm('确定要删除该分销等级吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/level/delete"),
|
||||
data: {level_id:level_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 停用
|
||||
*/
|
||||
function stop_status(level_id,type){
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
layer.confirm('确定要停用该分销等级吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/level/status"),
|
||||
data: {level_id:level_id,type:type},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
function start_status(level_id,type){
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
layer.confirm('确定要启用该分销等级吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("fenxiao://shop/level/status"),
|
||||
data: {level_id:level_id,type:type},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function clickAdd()
|
||||
{
|
||||
location.hash = ns.hash('fenxiao://shop/level/add');
|
||||
}
|
||||
|
||||
</script>
|
||||
202
addon/fenxiao/shop/view/order/detail.html
Executable file
202
addon/fenxiao/shop/view/order/detail.html
Executable file
@@ -0,0 +1,202 @@
|
||||
<style>
|
||||
.layui-form-item{margin-bottom: 0;}
|
||||
.product-info .img-block{width:60px;height:60px;float:left;border:1px solid #e2e2e2;display: flex;align-items: center;justify-content: center;}
|
||||
.product-info .img-block>img{max-width:100%;max-height:100%;}
|
||||
.product-info .info{margin-left:70px}
|
||||
.product-info .info p{color:#8e8c8c;font-size:12px}
|
||||
.commission-info dl{display: flex;align-items: center;margin-bottom: 10px}
|
||||
.commission-info dl:last-child{margin-bottom: 0;}
|
||||
.commission-info dl dd{flex: 1;padding-left: 10px;}
|
||||
.address{height: 0;width: 1px; border: none; overflow: hidden;}
|
||||
</style>
|
||||
|
||||
<div class="order-detail">
|
||||
<div class="layui-row layui-col-space1 order-detail-info" >
|
||||
<div class="order-detail-left" >
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header nav-title">
|
||||
<span class="card-title">订单信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">订单编号:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">{$order_detail['order_no']}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">订单类型:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">{$order_detail['order_type_name']}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">订单来源:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail.order_from_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">付款方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">{$order_detail.pay_type_name}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">买家:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">{$order_detail.nickname}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item order-detail-hr"></div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">配送方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['delivery_type_name']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收货人:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['name']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">联系电话:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['mobile']}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收货地址:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-mid layui-word-aux">
|
||||
<p>{$order_detail['full_address']}-{$order_detail['address']}
|
||||
<input type="text" class="address" id="address" value="{$order_detail['full_address']}-{$order_detail['address']}">
|
||||
<a href="javascript:ns.copy('address');" class="iconfont iconfuzhi" style="margin-top: 4px"></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="height: 15px;"></div>
|
||||
|
||||
{notempty name="$order_detail['order_goods']"}
|
||||
<div class="order-detail-table">
|
||||
<table class="layui-table" lay-filter="parse-table-order-product" lay-skin="line" lay-size="lg">
|
||||
<thead>
|
||||
<colgroup>
|
||||
<col width="35%">
|
||||
<col width="20%">
|
||||
<col width="30%">
|
||||
<col width="15%">
|
||||
</colgroup>
|
||||
<tr>
|
||||
<th>商品信息</th>
|
||||
<th style="text-align:right">单价(元) / 数量</th>
|
||||
<th>分佣信息</th>
|
||||
<th>佣金状态</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $order_detail['order_goods'] as $list_k => $order_goods_item}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="product-info">
|
||||
<div class="img-block">';
|
||||
<img layer-src src="{:img($order_goods_item.sku_image, 'small')}">
|
||||
</div>
|
||||
<div class="info">
|
||||
<span title="{$order_goods_item.sku_name}" class="multi-line-hiding text-color">{$order_goods_item.sku_name}</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align:right;">
|
||||
<div>{$order_goods_item.price}</div>
|
||||
<div>{$order_goods_item.num}件</div>
|
||||
</td>
|
||||
<td class="commission-info">
|
||||
<dl>
|
||||
<dt>一级分佣</dt>
|
||||
<dd>
|
||||
{if $order_goods_item.one_commission > 0}
|
||||
<div class="title-left">分销商:{$order_goods_item.one_fenxiao_name}</div>
|
||||
<div class="title-left">佣金:¥{$order_goods_item.one_commission}</div>
|
||||
{else/}
|
||||
<div class="title-left">分销商:--</div>
|
||||
<div class="title-left">佣金:--</div>
|
||||
<div class="title-left">分佣比率:--</div>
|
||||
{/if}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>二级分佣</dt>
|
||||
<dd>
|
||||
{if $order_goods_item.two_commission > 0}
|
||||
<div class="title-left">分销商:{$order_goods_item.two_fenxiao_name}</div>
|
||||
<div class="title-left">佣金:¥{$order_goods_item.two_commission}</div>
|
||||
{else/}
|
||||
<div class="title-left">分销商:--</div>
|
||||
<div class="title-left">佣金:--</div>
|
||||
{/if}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>三级分佣</dt>
|
||||
<dd>
|
||||
{if $order_goods_item.three_commission > 0}
|
||||
<div class="title-left">分销商:{$order_goods_item.three_fenxiao_name}</div>
|
||||
<div class="title-left">佣金:¥{$order_goods_item.three_commission}</div>
|
||||
{else/}
|
||||
<div class="title-left">分销商:--</div>
|
||||
<div class="title-left">佣金:--</div>
|
||||
{/if}
|
||||
</dd>
|
||||
</dl>
|
||||
</td>
|
||||
<td colspan="{:count($order_detail['order_goods'])}">
|
||||
{if $order_detail.order_status == -1}
|
||||
{$order_detail.order_status_name}
|
||||
{else/}
|
||||
{$order_detail['order_goods'][0]['is_settlement'] == 1 ? '已结算': '待结算'}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{/notempty}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user