添加:区域代理插件

This commit is contained in:
wuhui_zzw 2023-10-24 15:41:10 +08:00
parent 3fc6fca7fb
commit 5448537816
61 changed files with 2514 additions and 1236 deletions

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddExtraPluginIdAndExtraIdToYzAreaDividendTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('yz_area_dividend')) {
Schema::table('yz_area_dividend', function (Blueprint $table) {
if (!Schema::hasColumn('yz_area_dividend', 'extra_plugin_id')) {
$table->integer('extra_plugin_id')->default(0)->comment('区域分红特殊插件ID');
}
});
Schema::table('yz_area_dividend', function (Blueprint $table) {
if (!Schema::hasColumn('yz_area_dividend', 'extra_id')) {
$table->integer('extra_id')->default(0)->comment('区域分红特殊插件关联表ID');
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddSettlementTypeToYzAreaDividendTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('yz_area_dividend')) {
Schema::table('yz_area_dividend', function (Blueprint $table) {
if (!Schema::hasColumn('yz_area_dividend', 'settlement_type')) {
$table->integer('settlement_type')->default(0)->comment('区域分红佣金类型');
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -1,7 +1,7 @@
{
"name": "area-dividend",
"terminal": "wechat|min|wap",
"version": "1.0.171",
"version": "1.0.194",
"title": "区域分红",
"description": "线上实现行政区域代理渠道,依据地址进行分红。",
"author": "",

View File

@ -1,26 +1,29 @@
<?php
/**
* Created by PhpStorm.
*
* User: king/QQ995265288
* Date: 2018/5/8 下午2:17
* Email: livsyitian@163.com
*/
namespace Yunshop\AreaDividend\Frontend\Services;
use app\frontend\modules\finance\interfaces\IIncomePage;
use Yunshop\AreaDividend\models\AreaDividendAgent;
use Yunshop\AreaDividend\services\UpgradeService;
class IncomePageService implements IIncomePage
{
private $itemModel;
private $upgrade_h5_url;
private $upgrade_min_url;
public function __construct()
{
$this->itemModel = $this->getItemModel();
$upgrade_service = new UpgradeService(\YunShop::app()->getMemberId());
$upgrade_check = $upgrade_service->check();
if ($upgrade_check['status'] == 1 && !$upgrade_service->hasApply()) {
$this->upgrade_h5_url = 'outAreaSelect';
$this->upgrade_min_url = '/packageJ/outArea/areaSelect/areaSelect';
}
}
@ -47,7 +50,7 @@ class IncomePageService implements IIncomePage
*/
public function isAvailable()
{
if($this->itemModel) return true; else return false;
if ($this->itemModel) return true; else return false;
}
@ -90,6 +93,12 @@ class IncomePageService implements IIncomePage
public function getAppUrl()
{
$teamManage = app('plugins')->isEnabled('team-manage');
if ($this->upgrade_h5_url) {
return $this->upgrade_h5_url;
}
if ($teamManage) {
$url = 'selectionarea';
} else {
@ -102,6 +111,11 @@ class IncomePageService implements IIncomePage
public function getMiniUrl()
{
$teamManage = app('plugins')->isEnabled('team-manage');
if ($this->upgrade_min_url) {
return $this->upgrade_min_url;
}
if ($teamManage) {
$mini_url = '';
} else {
@ -139,7 +153,7 @@ class IncomePageService implements IIncomePage
{
$member_id = \YunShop::app()->getMemberId();
$levelModel = AreaDividendAgent::uniacid()->where('member_id',$member_id)->where('status',1)->first();
$levelModel = AreaDividendAgent::uniacid()->where('member_id', $member_id)->where('status', 1)->first();
return $levelModel;
}

View File

@ -0,0 +1,36 @@
<?php
namespace Yunshop\AreaDividend\Listener;
use app\common\events\order\AfterOrderPaidEvent;
use app\common\exceptions\ShopException;
use app\common\models\Order;
use Illuminate\Contracts\Events\Dispatcher;
use Yunshop\AreaDividend\services\UpgradeService;
class AfterOrderPaidListener
{
public function subscribe(Dispatcher $events)
{
$events->listen(AfterOrderPaidEvent::class, static::class . "@handle");
}
public function handle(AfterOrderPaidEvent $event)
{
$order = $event->getOrder();
try {
$this->run($order);
} catch (ShopException $e) {
\Log::debug('--区域分红升级条件--AfterOrderPaidListener', $e->getMessage());
return;
}
}
public function run(Order $order)
{
$service = new UpgradeService($order->uid);
$service->afterPay();
}
}

View File

@ -36,6 +36,15 @@ class CreatedCommissionListener
public function handle($orderModel, $amount)
{
if (in_array($orderModel->plugin_id, [54, 144]) &&
app('plugins')->isEnabled('coupon-store')
&& \Yunshop\CouponStore\models\StoreOrder::uniacid()->where('order_id', $orderModel->id)->first()
) {
\Log::debug('区域分红:消费券终止执行分销事件');
return;
}
\Log::debug('区域分红:一级分销事件handle()');
$this->orderModle = $orderModel;
@ -117,16 +126,16 @@ class CreatedCommissionListener
$order = Order::find($this->orderModle->id);//订单信息
$order['goods'] = $this->orderModle->orderGoods;//订单商品
\Log::error('区域分红订单'.$this->model->id.'开始分红');
\Log::debug('区域分红订单'.$this->model->id.'开始分红');
$service = new OrderCreatedNewService($order,$area_level,false,$this->commission);
foreach ($area_agent as $key => $time) {
$service->addAreaDividendData($time,$key);
}
//预计分红
$this->totalDividend = $service->expectedDividend();
\Log::error('区域分红订单'.$this->model->id.'预计分红',[$this->totalDividend,$service->amount]);
\Log::debug('区域分红订单'.$this->model->id.'预计分红',[$this->totalDividend,$service->amount]);
\Log::error('区域分红订单'.$this->model->id.'分红结束');
\Log::debug('区域分红订单'.$this->model->id.'分红结束');
}
/**

View File

@ -1,10 +1,13 @@
<?php
namespace Yunshop\AreaDividend\Listener;
use app\common\models\Order;
use app\Jobs\OrderBonusJob;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Yunshop\AreaDividend\event\AfterDetermineRegionEvent;
use Yunshop\AreaDividend\event\BeforeAreaDividendCreatedEvent;
use Yunshop\AreaDividend\models\AreaDividendAgent;
use Yunshop\AreaDividend\services\OrderCreatedNewService;
@ -17,6 +20,9 @@ class OrderCreatedListener
public $model;
public $is_fix;
public $totalDividend;
public $extra_plugin_id;
public $extra_id;
public $extra_address;
/**
* @param Dispatcher $events
@ -24,19 +30,34 @@ class OrderCreatedListener
public function subscribe(Dispatcher $events)
{
$events->listen(\app\common\events\order\AfterOrderCreatedEvent::class, function ($event) {
$this->setExtra(0, 0, null);
$this->handle($event->getOrderModel());
});
}
public function handle($order,$is_fix = false)
public function setExtra($extra_plugin_id, $extra_id, $extra_address = null)
{
$this->extra_plugin_id = $extra_plugin_id;
$this->extra_id = $extra_id;
$this->extra_address = $extra_address;
}
public function handle($order, $is_fix = false)
{
$this->is_fix = $is_fix;
\Log::debug('区域分红:订单创建事件handle()');
$before_event = new BeforeAreaDividendCreatedEvent($order, $this->extra_plugin_id, $this->extra_id);
event($before_event);
if ($before_event->isBreak()) {
\Log::debug('区域分红订单监听事件终止创建:' . $before_event->breakMessage());
}
$this->set = $order->getSetting('plugin.area_dividend');
\Log::debug('区域分红执行设置:', json_encode($this->set, 256));
$this->dividend($order);
\Log::debug('区域分红' . $this->model->id .'完成');
\Log::debug('区域分红' . $this->model->id . '完成');
$order_bonus_job = new OrderBonusJob('yz_area_dividend', 'area-dividend', 'order_sn', 'order_sn', 'dividend_amount', $this->model, $this->totalDividend);
$order_bonus_job->handle();
@ -45,7 +66,8 @@ class OrderCreatedListener
/**
* @param $order
*/
public function dividend($order){
public function dividend($order)
{
\Log::debug('dividend()');
//订单model
$this->model = $order;
@ -59,8 +81,23 @@ class OrderCreatedListener
\Log::debug('基础设置没有开启区域分红,返回');
return;
}
\Log::debug('区域分红订单模型:', json_encode($this->model, 256));
$order['address'] = $this->model->address;//订单地址
\Log::debug('区域分红特殊数据:', [
'extra_plugin_id' => $this->extra_plugin_id,
'extra_id' => $this->extra_id,
]);
if ($this->extra_address) {
\Log::debug('区域分红特殊地址', [
'province_id' => $this->extra_address && intval($this->extra_address->province_id) ? intval($this->extra_address->province_id) : 0,
'city_id' => $this->extra_address && intval($this->extra_address->city_id) ? intval($this->extra_address->city_id) : 0,
'district_id' => $this->extra_address && intval($this->extra_address->district_id) ? intval($this->extra_address->district_id) : 0,
'street_id' => $this->extra_address && intval($this->extra_address->street_id) ? intval($this->extra_address->street_id) : 0,
]);
$order['address'] = $this->extra_address;
} else {
$order['address'] = $this->model->address;//订单地址
}
if ($order->plugin_id == 0 || $order->plugin_id == 92 || $order->plugin_id == 32) {
\Yunshop\AreaDividend\models\Order::agentOrder($order);
@ -99,6 +136,8 @@ class OrderCreatedListener
$area_level['level_4'] = $this->getLevelStatus($area_agent['street']);
}
event(new AfterDetermineRegionEvent($this->model, $area_agent, $area_level));
if (!$area_agent) {
\Log::debug('区域代理为空,返回');
} else {
@ -117,16 +156,17 @@ class OrderCreatedListener
$order = Order::find($this->model->id);//订单信息
$order['goods'] = $this->model->hasManyOrderGoods;//订单商品
\Log::error('区域分红订单'.$this->model->id.'开始分红');
$service = new OrderCreatedNewService($order,$area_level,$this->is_fix);
\Log::error('区域分红订单' . $this->model->id . '开始分红');
$service = new OrderCreatedNewService($order, $area_level, $this->is_fix);
$service->setExtra($this->extra_plugin_id, $this->extra_id);
foreach ($area_agent as $key => $time) {
$service->addAreaDividendData($time,$key);
$service->addAreaDividendData($time, $key);
}
//预计分红
$this->totalDividend = $service->expectedDividend();
\Log::error('区域分红订单'.$this->model->id.'预计分红',[$this->totalDividend,$service->amount]);
\Log::error('区域分红订单' . $this->model->id . '预计分红', [$this->totalDividend, $service->amount]);
\Log::error('区域分红订单'.$this->model->id.'分红结束');
\Log::error('区域分红订单' . $this->model->id . '分红结束');
}

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: yunzhong
* Date: 2018/5/24
* Time: 17:03
*/
namespace Yunshop\AreaDividend\Listener;

View File

@ -3,20 +3,28 @@
namespace Yunshop\AreaDividend\Listener;
use app\common\exceptions\ShopException;
use app\common\facades\Setting;
use app\common\models\Order;
use Illuminate\Contracts\Events\Dispatcher;
use Yunshop\AreaDividend\models\AreaDividend;
use Yunshop\AreaDividend\models\AreaDividendAgent;
use Yunshop\AreaDividend\services\OrderCreatedService;
use Yunshop\Commission\models\AgentLevel;
use Yunshop\AreaDividend\services\UpgradeService;
class OrderReceiveListener
{
public function subscribe(Dispatcher $events)
{
$events->listen(\app\common\events\order\AfterOrderReceivedEvent::class, function ($event) {
$this->handle($event->getOrderModel());
$order = $event->getOrderModel();
$this->handle($order);
try {
$this->run($order);
} catch (ShopException $e) {
\Log::debug('--区域分红升级条件--OrderReceiveListener', $e->getMessage());
return;
}
});
}
@ -28,17 +36,21 @@ class OrderReceiveListener
AreaDividend::updatedAreaDividend($areaDividendData, $areaDividendWhere);
// 奖励积分 todo 查询订单所有奖励,每个代理商都获得奖励
$areaDividendModels = AreaDividend::select('member_id','area_level','status')
$areaDividendModels = AreaDividend::select('member_id', 'area_level', 'status')
->where('order_id', $order->id)
->get();
if ($areaDividendModels->isEmpty()) {
$areaDividendModels = AreaDividend::select('member_id','area_level','status')
$areaDividendModels = AreaDividend::select('member_id', 'area_level', 'status')
->where('order_sn', $order->order_sn)
->get();
}
if ($areaDividendModels->isEmpty()) {
return;
}
if ($order->plugin_id == 70 && !Setting::get('plugin.aggregation-cps.area_dividend.point_open_state')) {
\Log::debug('聚合cps订单未开启区域分红积分奖励');
return;
}
$set = Setting::get('plugin.area_dividend');
foreach ($areaDividendModels as $areaDividendModel) {
// $agent = $areaDividendModel->hasOneAgent;
@ -50,26 +62,31 @@ class OrderReceiveListener
continue;
}
$point_ratio = AgentLevel::getUserRate($areaDividendModel->member_id,$areaDividendModel->agent_level);
// switch ($areaDividendModel->area_level) {
// case 1:
// $point_ratio = $set['province_point'];
// break;
// case 2:
// $point_ratio = $set['city_point'];
// break;
// case 3:
// $point_ratio = $set['area_point'];
// break;
// default:
// $point_ratio = $set['street_point'];
// break;
// }
switch ($areaDividendModel->area_level) {
case 1:
$point_ratio = $set['province_point'];
break;
case 2:
$point_ratio = $set['city_point'];
break;
case 3:
$point_ratio = $set['area_point'];
break;
default:
$point_ratio = $set['street_point'];
break;
}
$dividendRate['rate_' . $areaDividendModel->area_level]['point_ratio'] = $point_ratio;
// 额外赠送积分
AreaDividendAgent::awardPoint($dividendRate, $areaDividendModel->area_level,$areaDividendModel->member_id, $order, $set);
AreaDividendAgent::awardPoint($dividendRate, $areaDividendModel->area_level, $areaDividendModel->member_id, $order, $set);
}
}
public function run(Order $order)
{
$service = new UpgradeService($order->uid);
$service->afterComplete();
}
}

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: shenyang
* Date: 2018/12/24
* Time: 3:38 PM
*/
namespace Yunshop\AreaDividend;
@ -13,12 +8,14 @@ use app\common\facades\Setting;
use app\common\models\MemberCart;
use app\common\modules\shop\ShopConfig;
use Config;
use Yunshop\AreaDividend\Listener\AfterOrderPaidListener;
use Yunshop\AreaDividend\Listener\CreatedCommissionListener;
use Yunshop\AreaDividend\Listener\OrderCreatedListener;
use Yunshop\AreaDividend\Listener\OrderFailureListener;
use Yunshop\AreaDividend\Listener\OrderReceiveListener;
use Yunshop\AreaDividend\models\AreaDividendAgent;
use Yunshop\AreaDividend\services\TimedTaskService;
use Yunshop\AreaDividend\widgets\AreaDividendLangWidget;
use Yunshop\Supplier\common\modules\order\OrderManager;
class PluginApplication extends \app\common\services\PluginApplication
@ -45,21 +42,32 @@ class PluginApplication extends \app\common\services\PluginApplication
public function getTemplateItems()
{
return ['area_dividend_become_agent' => [
'title' => trans('Yunshop\AreaDividend::index.title') . "成为区域代理通知",
'subtitle' => '成为区域代理通知',
'value' => 'area_dividend_become_agent',
'param' => [
'昵称', '时间', '省', '市', '区/县', '街道/乡镇'
return [
'area_dividend_become_agent' => [
'title' => trans('Yunshop\AreaDividend::index.title') . "成为区域代理通知",
'subtitle' => '成为区域代理通知',
'value' => 'area_dividend_become_agent',
'param' => [
'昵称', '时间', '省', '市', '区/县', '街道/乡镇'
]
],
'area_dividend_statement_notice' => [
'title' => trans('Yunshop\AreaDividend::index.title') . "分红结算通知",
'subtitle' => '分红结算通知',
'value' => 'area_dividend_statement_notice',
'param' => [
'昵称', '时间', '等级', '金额'
]
],
'area_dividend_upgrade_notice' => [
'title' => "满足升级条件通知",
'subtitle' => '满足升级条件通知',
'value' => 'area_dividend_upgrade_notice',
'param' => [
'昵称', '时间'
]
]
], 'area_dividend_statement_notice' => [
'title' => trans('Yunshop\AreaDividend::index.title') . "分红结算通知",
'subtitle' => '分红结算通知',
'value' => 'area_dividend_statement_notice',
'param' => [
'昵称', '时间', '等级', '金额'
]
]];
];
}
protected function setConfig()
@ -98,6 +106,10 @@ class PluginApplication extends \app\common\services\PluginApplication
'function_save' => 'relationSave'
]);
\app\common\modules\shop\ShopConfig::current()->set('appointment_area_reward', [
'class' => 'Yunshop\AreaDividend\services\AppointmentService',
'function' => 'appointmentReward'
]);
\app\common\modules\shop\ShopConfig::current()->push('shop-foundation.member-cart.with', 'goods.areaDividendGoods');
\app\common\modules\shop\ShopConfig::current()->push('shop-foundation.member-cart.with', 'goods.areaDividendGoods');
@ -120,7 +132,11 @@ class PluginApplication extends \app\common\services\PluginApplication
], 'vue-goods.area_dividend' => [
'title' => trans('Yunshop\AreaDividend::index.title'),
'class' => \Yunshop\AreaDividend\widgets\DividendVueWidget::class,
]];
], 'lang.area_dividend' => [
'title' => '语言设置',
'class' => AreaDividendLangWidget::class,
]
];
}
protected function setMenuConfig()
@ -273,8 +289,17 @@ class PluginApplication extends \app\common\services\PluginApplication
]
]);
$area = \Yunshop\AreaDividend\models\AreaDividendAgent::getAgentByUserId(\YunShop::app()->uid)->first();
if ($area) {
$coupon_menu = [];
if (app('plugins')->isEnabled('coupon-store') && \Yunshop\CouponStore\services\SettingService::getSetting()['open_state']) {
$coupon_menu = \Yunshop\CouponStore\services\MenuService::getMenu();
}
if ($area || $coupon_menu) {
Config::set('menu', []);
}
if ($coupon_menu) {
Menu::current()->setMainMenu('coupon_store_menu', $coupon_menu);
}
if ($area) {
Menu::current()->setMainMenu('area_admin_menu', [
'name' => '区域',
'url' => 'plugin.area-dividend.area.order-manage.index',// url 可以填写http 也可以直接写路由
@ -464,6 +489,25 @@ class PluginApplication extends \app\common\services\PluginApplication
],
]
],
'area_admin_point_log_list' => [
'name' => '赠送积分明细',
'url' => 'plugin.area-dividend.area.point-log.index',
'url_params' => '',
'permit' => 0,
'menu' => 1,
'icon' => '',
'item' => 'area_admin_point_log_list',
'parents' => ['area_admin_menu'],
'child' => [
'area_admin_point_log_export' => [
'name' => '积分导出',
'url' => 'plugin.area-dividend.area.point-log.export',
'permit' => 0,
'menu' => 0,
'parents' => ['area_admin_menu', 'area_admin_point_log_list'],
],
]
],
]
]);
@ -492,6 +536,12 @@ class PluginApplication extends \app\common\services\PluginApplication
$events->subscribe(OrderCreatedListener::class);
$events->subscribe(CreatedCommissionListener::class);
/**
* 支付后
* OrderCreatedListener
*/
$events->subscribe(AfterOrderPaidListener::class);
/**
* 订单收货
* OrderReceiveListener
@ -506,16 +556,7 @@ class PluginApplication extends \app\common\services\PluginApplication
$events->subscribe(OrderFailureListener::class);
/*
* 定时任务处理
*
*/
\Event::listen('cron.collectJobs', function () {
\Cron::add('Area-dividend', '*/1 * * * *', function () {
(new TimedTaskService())->handle();
return;
});
});
}
@ -526,5 +567,18 @@ class PluginApplication extends \app\common\services\PluginApplication
return new \Yunshop\Supplier\common\models\MemberCart($params[0]);
});
}
public function cronConfig()
{
/*
* 定时任务处理
*
*/
\Event::listen('cron.collectJobs', function () {
\Cron::add('Area-dividend', '*/1 * * * *', function () {
(new TimedTaskService())->handle();
});
});
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace Yunshop\AreaDividend\admin;
use app\common\components\BaseController;
@ -7,31 +8,27 @@ use app\common\facades\Setting;
use app\common\helpers\PaginationHelper;
use app\common\helpers\Url;
use app\common\models\Member;
use Illuminate\Support\Facades\Storage;
use app\common\services\ExportService;
use app\platform\modules\user\models\YzUserProfile;
use Yunshop\AreaDividend\models\AreaDividendAgent;
use Yunshop\AreaDividend\models\Lock;
use Yunshop\AreaDividend\models\weiqing\WeiQingUsers;
use Yunshop\AreaDividend\services\AgentService;
use Yunshop\AreaDividend\services\MessageService;
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/4/24
* Time: 下午4:50
*/
class AgentController extends BaseController
{
public function index()
{
$search = \YunShop::request()->search;
$pageSize = 20;
$list = AreaDividendAgent::getAgents($search)->orderBy('id','DESC')->paginate($pageSize);
$list = AreaDividendAgent::getAgents($search)->profileWith()->paginate($pageSize);
$pager = PaginationHelper::show($list->total(), $list->currentPage(), $list->perPage());
if(!$search['time']){
$search['time']['start'] = date("Y-m-d H:i:s",time());
$search['time']['end'] = date("Y-m-d H:i:s",time());
if (!$search['time']) {
$search['time']['start'] = date("Y-m-d H:i:s", time());
$search['time']['end'] = date("Y-m-d H:i:s", time());
}
return view('Yunshop\AreaDividend::admin.list', [
'list' => $list->toarray(),
@ -48,26 +45,74 @@ class AgentController extends BaseController
$wq_data = \YunShop::request()->wq;
if ($agentData) {
$agent = AreaDividendAgent::getAgentByMemberId($agentData['member_id'])->where('status','<>',-1)->first();
if(!empty($agent)){
$set = Setting::get('plugin.area_dividend');
if($agent->status == 0){
$agent = AreaDividendAgent::getAgentByMemberId($agentData['member_id'])->where('status', '<>', -1)
->first();
$set = Setting::get('plugin.area_dividend');
if (!empty($agent)) {
if ($agent->status == 0) {
return $this->message('添加失败,此会员已进行申请,请在申请列表进行审核', '', 'error');
}else if($agent->status == 1 && !$set['agent_many']){
} else if ($agent->status == 1 && !$set['agent_many']) {
return $this->message('添加失败,此会员已是代理商', '', 'error');
}
}
$agentData = AgentService::setAgentData($agentData);
if ($set['agent_many']) {//一人可代理多个区域
$hasAgent = AreaDividendAgent::uniacid()
->where('member_id', \YunShop::app()->getMemberId())
->where('agent_level', $agentData['agent_level'])
->where('province_name', $agentData['province_name']);
switch ($agentData['agent_level']) {
case 1:
$hasAgent = $hasAgent->first();
break;
case 2:
$hasAgent = $hasAgent->where('city_name', $agentData['city_name'])
->first();
break;
case 3:
$hasAgent = $hasAgent->where('city_name', $agentData['city_name'])
->where('district_name', $agentData['district_name'])
->first();
break;
case 4:
$hasAgent = $hasAgent->where('city_name', $agentData['city_name'])
->where('district_name', $agentData['district_name'])
->where('street_name', $agentData['street_name'])
->first();
break;
default:
return $this->errorJson('申请信息错误');
}
if ($hasAgent && in_array($hasAgent->status, [0, 1])) {
return $this->errorJson('添加失败,此会员已是该区域代理商');
} elseif ($hasAgent && $hasAgent->status == -1) {
AreaDividendAgent::uniacid()
->where('id', $hasAgent->id)->delete();
}
}
$retLock = Lock::verify($agentData);
if ($retLock) return $this->message('该区域已被锁定', '', 'error');
if ($retLock) {
return $this->message('该区域已被锁定', '', 'error');
}
$verifyPasswordStrength = true;
if ((!$wq_data['username'] || !$wq_data['password']) && AreaDividendAgent::subPlatformOpen()) {
$accountPwd = \Yunshop\SubPlatform\services\AdminUserServices::createAccountPwd('agent', 8, true);
$wq_data['username'] = $accountPwd['account'];
$wq_data['password'] = $accountPwd['password'];
$wq_data['password_again'] = $accountPwd['password'];
$verifyPasswordStrength = false;
}
if (trim($wq_data['username']) && trim($wq_data['password'])) {
if (trim($wq_data['password_again']) != trim($wq_data['password'])) {
return $this->message('两次密码不相同', '', 'error');
}
$verifyPassword = verifyPasswordStrength(trim($wq_data['password']));
if($verifyPassword !== true){
if ($verifyPasswordStrength && $verifyPassword !== true) {
return $this->message($verifyPassword, '', 'error');
}
@ -89,15 +134,6 @@ class AgentController extends BaseController
$agentModel->uniacid = \YunShop::app()->uniacid;
$agentModel->status = 1;
$agentModel->agent_at = time();
$agentModel->title = request()->title;
$agentModel->min_status = request()->min_status;
$agentModel->min_app_id = request()->min_app_id;
$agentModel->min_app_secret = request()->min_app_secret;
$agentModel->min_mch_id = request()->min_mch_id;
$agentModel->min_api_secret = request()->min_api_secret;
if (request()->file('apiclient_cert')) $agentModel->min_apiclient_cert = $this->uploadFile('apiclient_cert', $agentModel->min_app_id);
if (request()->file('apiclient_key')) $agentModel->min_apiclient_key = $this->uploadFile('apiclient_key', $agentModel->min_app_id);
//字段检测
$validator = $agentModel->validator($agentModel->getAttributes());
if ($validator->fails()) {
@ -106,15 +142,19 @@ class AgentController extends BaseController
} else {
//数据保存
if ($agentModel->save()) {
$data=[
'member_id'=>$agentData['member_id'],
'username'=>$agentData['username'],
YzUserProfile::syncMobile($agentModel->user_id, $agentModel->mobile);
$data = [
'member_id' => $agentData['member_id'],
'username' => $agentData['username'],
'created_at' => time(),
];
event(new \app\common\events\plugin\AreaDividendEvent($data));
// 发送消息
$member = Member::getMemberByUid($agentModel->member_id)->with('hasOneFans')->first();
MessageService::becomeAgent($agentModel, $member->hasOneFans);
if (app('plugins')->isEnabled('coupon-store')) {
\Yunshop\CouponStore\models\Log::areaChange($agentModel->id, 1);
}
//显示信息并跳转
return $this->message('添加成功', yzWebUrl('plugin.area-dividend.admin.agent'));
} else {
@ -127,15 +167,23 @@ class AgentController extends BaseController
])->render();
}
public function editAgency(){
public function editAgency()
{
$id = \YunShop::request()->id;
$agency = AreaDividendAgent::find($id);
if(!$agency) return $this->message('无此区域代理或已经删除','','error');
if (!$agency) {
return $this->message('无此区域代理或已经删除', '', 'error');
}
if ($agency->user_id) {
$user = WeiQingUsers::getUserByUid($agency->user_id)->first();
if (!$user) return $this->message('微擎账号不存在','','error');
if (!$user) {
return $this->message('微擎账号不存在', '', 'error');
}
}
if (request()->isMethod('post')) {
$wq_data = \YunShop::request()->wq;
if ($wq_data['password'] && $wq_data['password_again']) {
if (trim($wq_data['password_again']) != trim($wq_data['password'])) {
@ -143,7 +191,7 @@ class AgentController extends BaseController
}
$verifyPassword = verifyPasswordStrength(trim($wq_data['password']));
if($verifyPassword !== true){
if ($verifyPassword !== true) {
return $this->message($verifyPassword, '', 'error');
}
@ -166,14 +214,17 @@ class AgentController extends BaseController
$agency->setRawAttributes($agentData);
if ($agency->save()) {
if (app('plugins')->isEnabled('coupon-store')) {
\Yunshop\CouponStore\models\Log::areaChange($agency->id, 2);
}
//显示信息并跳转
return $this->message('账号添加成功', yzWebUrl('plugin.area-dividend.admin.agent'));
} else {
return $this->message('账号添加失败', '', 'error');
}
}
}
else {
} else {
if (request()->order_manage == 1) {
$whereColumn = 'province_id';
if ($agency->agent_level == 4) {
@ -194,32 +245,30 @@ class AgentController extends BaseController
return $this->message('该区域下已存在[订单管理权限]的代理商', '', 'error');
}
}
$agency->manage = request()->order_manage;
$agency->ratio = request()->ratio;
$agency->has_ratio = request()->has_ratio;
$agency->title = request()->title;
// 支付信息修改
$agency->min_status = request()->min_status;
$agency->min_app_id = request()->min_app_id;
$agency->min_app_secret = request()->min_app_secret;
$agency->min_mch_id = request()->min_mch_id;
$agency->min_api_secret = request()->min_api_secret;
if (request()->file('apiclient_cert')) $agency->min_apiclient_cert = $this->uploadFile('apiclient_cert', $agency->min_app_id);
if (request()->file('apiclient_key')) $agency->min_apiclient_key = $this->uploadFile('apiclient_key', $agency->min_app_id);
if (intval(request()->input('agent')['investor_uid'])) $agency->investor_uid = intval(request()->input('agent')['investor_uid']);
if (intval(request()->input('agent')['investor_uid'])) {
$agency->investor_uid = intval(request()->input('agent')['investor_uid']);
}
$agency->save();
return $this->message('账号编辑成功', yzWebUrl('plugin.area-dividend.admin.agent'));
if (app('plugins')->isEnabled('coupon-store')) {
\Yunshop\CouponStore\models\Log::areaChange($agency->id, 2);
}
return $this->message('账号添加成功', yzWebUrl('plugin.area-dividend.admin.agent'));
}
}
return view('Yunshop\AreaDividend::admin.change-pwd', [
'username' => $user->username,
'agency' => $agency->toArray()
'real_name' => $agency->real_name,
'order_manage' => $agency->manage,
'agency' => $agency
])->render();
}
public function agentApply()
{
$search = request()->search;
@ -258,7 +307,7 @@ class AgentController extends BaseController
if ($agentModel->username) {
$user = WeiQingUsers::getUserByUserName($agentModel->username)->first();
if ($user) {
return $this->message('用户名已存在,请驳回后重新申请','','error');
return $this->message('用户名已存在,请驳回后重新申请', '', 'error');
}
}
$result = static::setApplyAdopt($agentModel, $status);
@ -271,9 +320,9 @@ class AgentController extends BaseController
$member = Member::getMemberByUid($agentModel->member_id)->with('hasOneFans')->first();
MessageService::becomeAgent($agentModel, $member->hasOneFans);
}
$data=[
'member_id'=>$agentModel['member_id'],
'username'=>$agentModel['real_name'],
$data = [
'member_id' => $agentModel['member_id'],
'username' => $agentModel['real_name'],
'created_at' => time(),
];
event(new \app\common\events\plugin\AreaDividendEvent($data));
@ -284,6 +333,8 @@ class AgentController extends BaseController
event(new \Yunshop\InstationMessage\event\AreaDividendEvent($agentModelNew));
}
//同步手机号
YzUserProfile::syncMobile($agentModel->user_id, $agentModel->mobile);
return $this->message('操作成功', yzWebUrl('plugin.area-dividend.admin.agent.agent-apply'));
} else {
return $this->message('操作失败', '', 'error');
@ -293,8 +344,8 @@ class AgentController extends BaseController
protected static function setApplyAdopt($agentModel, $status)
{
$agentModel->status = $status;
if (!empty($agentModel->username) && !empty($agentModel->password)) {
$user_uid= WeiQingUsers::registerBySalt($agentModel->username, $agentModel->password, $agentModel->salt);
if (!empty($agentModel->username) && !empty($agentModel->password)) {
$user_uid = WeiQingUsers::registerBySalt($agentModel->username, $agentModel->password, $agentModel->salt);
$agentModel->user_id = $user_uid;
}
$agentModel->agent_at = time();
@ -315,10 +366,12 @@ class AgentController extends BaseController
{
$file_name = date('Ymdhis', time()) . '区域代理导出';
$search = \YunShop::request()->search;
$list = AreaDividendAgent::getAgents($search)
->get()
->toArray();
$export_page = request()->export_page ? request()->export_page : 1;
$builder = AreaDividendAgent::getAgents($search);
$export_model = new ExportService($builder, $export_page);
if ($export_model->builder_model->isEmpty()) {
return $this->message('导出数据为空', Url::absoluteWeb('plugin.area-dividend.admin.agent.index'), 'error');
}
$export_data[0] = [
'ID',
'会员id',
@ -334,7 +387,7 @@ class AgentController extends BaseController
'未结算分红金额'
];
foreach ($list as $key => $item) {
foreach ($export_model->builder_model->toArray() as $key => $item) {
$area = '';
if ($item['province_name']) {
$area .= $item['province_name'];
@ -352,19 +405,20 @@ class AgentController extends BaseController
$item['id'],
$item['has_one_member']['uid'] ?: '',
$item['has_one_member']['nickname'] ?: '',
$item['has_one_member']['realname'].'/'.$item['has_one_member']['mobile'],
$item['has_one_member']['realname'] . '/' . $item['has_one_member']['mobile'],
$item['created_at'],
$area,
$item['level_name'],
$item['count_order_amount']."",
$item['rate']."%",
$item['count_settle_amount']."",
$item['settle_dividend_amount']."",
$item['unsettled_dividend_amount'].""
$item['count_order_amount'] . "",
$item['rate'] . "%",
$item['count_settle_amount'] . "",
$item['settle_dividend_amount'] . "",
$item['unsettled_dividend_amount'] . ""
];
}
return \app\exports\ExcelService::fromArrayExport($export_data,$file_name);
$export_model->export($file_name, $export_data, 'plugin.area-dividend.admin.agent.index');
return true;
// 商城更新,无法使用
// \Excel::create($file_name, function ($excel) use ($export_data) {
@ -390,7 +444,9 @@ class AgentController extends BaseController
public function change()
{
$id = \YunShop::request()->id;
$agent = AreaDividendAgent::find($id);
if (!$agent = AreaDividendAgent::find($id)) {
return $this->errorJson('代理不存在');
}
$agentData = \YunShop::request()->value;
$agentData = AgentService::setAgentData($agentData);
@ -414,6 +470,9 @@ class AgentController extends BaseController
} else {
$agent->setRawAttributes($agentData);
$agent->save();
if (app('plugins')->isEnabled('coupon-store')) {
\Yunshop\CouponStore\models\Log::areaChange($id, 2);
}
return $this->errorJson('成功');
}
}
@ -422,46 +481,21 @@ class AgentController extends BaseController
{
$id = \YunShop::request()->id;
$agency = AreaDividendAgent::find($id);
if(!$agency) {
return $this->message('无此区域代理或已经删除','','error');
if (!$agency) {
return $this->message('无此区域代理或已经删除', '', 'error');
}
//删除登录
if ($agency->user_id) {
WeiQingUsers::delUser($agency->user_id);
}
$result = AreaDividendAgent::daletedAgency($id);
if($result) {
return $this->message('删除成功',Url::absoluteWeb('plugin.area-dividend.admin.agent'));
}else{
return $this->message('删除失败','','error');
if ($result) {
if (app('plugins')->isEnabled('coupon-store')) {
\Yunshop\CouponStore\models\Log::areaChange($id, 3);
}
return $this->message('删除成功', Url::absoluteWeb('plugin.area-dividend.admin.agent'));
} else {
return $this->message('删除失败', '', 'error');
}
}
/**
* Common: 证书上传 - 仅用于区域代理中的微信小程序配置中证书文件上传
* Author: wu-hui
* Time: 2023/05/31 17:08
* @param $fileKey
* @param $appId
* @return string
* @throws ShopException
*/
private function uploadFile($fileKey,$appId){
$file = request()->file($fileKey);
if ($file->isValid()) {
//文件原名
$originalName = $file->getClientOriginalName();
//扩展名
$fileExt = $file->getClientOriginalExtension();
//临时文件的绝对路径
$realPath = $file->getRealPath();
//新文件名
$fileName = "area_pem_{$appId}_{$originalName}";
if ($fileExt != 'pem') throw new ShopException("{$originalName}文件格式错误");
$bool = Storage::disk('cert')->put($fileName, file_get_contents($realPath));
if ($bool) return storage_path("cert/{$fileName}");
}
throw new ShopException("{$fileKey}.pem文件上传错误");
}
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace Yunshop\AreaDividend\admin;
use app\common\components\BaseController;
@ -7,34 +8,44 @@ use app\common\helpers\Url;
use app\common\models\notice\MessageTemp;
use Illuminate\Support\Facades\DB;
use Yunshop\AreaDividend\models\AreaDividendAgent;
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/4/24
* Time: 下午4:50
*/
class AreaDividendSetController extends BaseController
{
public function index()
{
$set = Setting::get('plugin.area_dividend');
$upgrade = Setting::get('plugin.area_dividend.upgrade');
//升级条件设置
$agreement = Setting::get('area_dividend.agreement');
$team_dividend_level_list = [];
if (app('plugins')->isEnabled('team-dividend')) {
$team_dividend_level_list = TeamDividendLevelModel::uniacid()->select(['id', 'level_name'])->orderByDesc('level_weight')->get();
}
if ($upgrade['goods_ids']) {
$goods = \app\common\models\Goods::uniacid()->whereIn('id', $upgrade['goods_ids'])->get();
if (!$goods->isEmpty()) {
$goods = set_medias($goods->toArray(), array('thumb', 'share_icon'));
}
}
$requestModel = \YunShop::request()->setdata;
if($requestModel){
if ($requestModel) {
Setting::set('area_dividend.agreement', $requestModel['agreement']);
unset($requestModel['agreement']);
if ($requestModel['agent_many'] == 0) {
$has_count = AreaDividendAgent::uniacid()
->select('member_id')
->whereIn('status',[0,1])
->whereIn('status', [0, 1])
->groupBy('member_id')
->havingRaw('COUNT(*) > 1')
->count();
if ($has_count) {
return $this->message('存在一人代理多个区域情况,不能关闭代理多个区域功能', Url::absoluteWeb('plugin.area-dividend.admin.area-dividend-set'),'error');
return $this->message('存在一人代理多个区域情况,不能关闭代理多个区域功能', Url::absoluteWeb('plugin.area-dividend.admin.area-dividend-set'), 'error');
}
}
@ -50,7 +61,30 @@ class AreaDividendSetController extends BaseController
'set' => $set,
'agreement' => $agreement,
'temp_list' => $temp_list,
'goods' => $goods,
'team_dividend_level_list' => $team_dividend_level_list,
'upgrade' => $upgrade,
'appointment' => app('plugins')->isEnabled('appointment') ? true : false
])->render();
}
}
/**
* 搜索商品
* @return array|string
* @throws \Throwable
*/
public function searchGoods()
{
$search['keyword'] = \YunShop::request()->keyword;
$goods = \app\common\models\Goods::uniacid()->search($search)->get();
if (!$goods->isEmpty()) {
$goods = set_medias($goods->toArray(), array('thumb', 'share_icon'));
}
return view('Yunshop\AreaDividend::admin.tpl.goods_query', [
'goods' => $goods
])->render();
}
}

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/5/15
* Time: 下午4:49
*/
namespace Yunshop\AreaDividend\admin;
@ -40,6 +35,7 @@ class DividendController extends BaseController
'pager' => $pager,
'statisti' => $statisti,
'search' => $search,
'appointment' => app('plugins')->isEnabled('appointment')
])->render();
}

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: shenyang
* Date: 2018/10/29
* Time: 下午7:55
*/
namespace Yunshop\AreaDividend\admin;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: shenyang
* Date: 2018/10/30
* Time: 上午9:45
*/
namespace Yunshop\AreaDividend\admin\modules\dividend;
use app\common\facades\Setting;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: shenyang
* Date: 2018/11/2
* Time: 4:14 PM
*/
namespace Yunshop\AreaDividend\admin\modules\dividend;

View File

@ -6,6 +6,7 @@ namespace Yunshop\AreaDividend\api;
use app\common\components\ApiController;
use app\common\facades\Setting;
use app\common\models\Goods;
use app\common\models\Member;
use app\common\services\SystemMsgService;
use Carbon\Carbon;
@ -16,6 +17,8 @@ use Yunshop\AreaDividend\models\weiqing\WeiQingUsers;
use Yunshop\AreaDividend\services\AgentService;
use Yunshop\AreaDividend\services\MessageService;
use app\common\helpers\PaginationHelper;
use Yunshop\AreaDividend\services\UpgradeService;
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
class AreaDividendController extends ApiController
{
@ -23,18 +26,18 @@ class AreaDividendController extends ApiController
{
//plugin.area-dividend.api.area-dividend.get-area-agent
$request = AreaDividendAgent::getAgentByMemberId(\YunShop::app()->getMemberId())
->select('member_id', 'real_name', 'mobile', 'agent_level','status','province_name', 'city_name', 'district_name', 'street_name')
->where('status',1)
->orderBy('created_at','desc')
->select('member_id', 'real_name', 'mobile', 'agent_level', 'status', 'province_name', 'city_name', 'district_name', 'street_name')
->where('status', 1)
->orderBy('created_at', 'desc')
->first();
$agent_many = Setting::get('plugin.area_dividend.agent_many') ? : 0;
$agent_many = Setting::get('plugin.area_dividend.agent_many') ?: 0;
if ($request) {
$request = $request->toArray();
$request['level_name']='代理区域:'.$request['province_name'];
$request['city_name'] ? $request['level_name']=$request['level_name'].'-'.$request['city_name'] : '';
$request['district_name'] ? $request['level_name']=$request['level_name'].'-'.$request['district_name'] : '';
$request['street_name'] ? $request['level_name']=$request['level_name'].'-'.$request['street_name'] : '';
$request['level_name'] = '代理区域:' . $request['province_name'];
$request['city_name'] ? $request['level_name'] = $request['level_name'] . '-' . $request['city_name'] : '';
$request['district_name'] ? $request['level_name'] = $request['level_name'] . '-' . $request['district_name'] : '';
$request['street_name'] ? $request['level_name'] = $request['level_name'] . '-' . $request['street_name'] : '';
$request['agent_many'] = $agent_many;
return $this->successJson('成功', $request);
}
@ -45,16 +48,16 @@ class AreaDividendController extends ApiController
public function getAllAreaAgent()
{
$requests = AreaDividendAgent::getAgentByMemberId(\YunShop::app()->getMemberId())
->select('member_id', 'real_name', 'mobile', 'agent_level','status','province_name', 'city_name', 'district_name', 'street_name')
->where('status',1)
->orderBy('created_at','desc')
->select('member_id', 'real_name', 'mobile', 'agent_level', 'status', 'province_name', 'city_name', 'district_name', 'street_name')
->where('status', 1)
->orderBy('created_at', 'desc')
->get()->toArray();
if ($requests) {
foreach ($requests as &$request) {
$request['level_name'] = $request['province_name'];
$request['city_name'] ? $request['level_name'] = $request['level_name'].'-'.$request['city_name'] : '';
$request['district_name'] ? $request['level_name'] = $request['level_name'].'-'.$request['district_name'] : '';
$request['street_name'] ? $request['level_name'] = $request['level_name'].'-'.$request['street_name'] : '';
$request['city_name'] ? $request['level_name'] = $request['level_name'] . '-' . $request['city_name'] : '';
$request['district_name'] ? $request['level_name'] = $request['level_name'] . '-' . $request['district_name'] : '';
$request['street_name'] ? $request['level_name'] = $request['level_name'] . '-' . $request['street_name'] : '';
}
unset($request);
}
@ -105,7 +108,7 @@ class AreaDividendController extends ApiController
if (empty($create_month) && empty($status)){
$create_month = $dividendList[0]->create_month;
}
$list_data = AreaDividend::getStatusDividendList($create_month,$status)->where('member_id', \YunShop::app()->getMemberId())->paginate(10);
PaginationHelper::show($list_data->total(), $list_data->currentPage(), $list_data->perPage());
$list['time'] = $dividendList;
@ -139,6 +142,12 @@ class AreaDividendController extends ApiController
//plugin.area-dividend.api.area-dividend.set-agent-apply
$set = Setting::get('plugin.area_dividend');
$agentData = \YunShop::request()->get('data');
$upgrade_service = new UpgradeService(\YunShop::app()->getMemberId());
$upgrade_check = $upgrade_service->check();
if ($upgrade_check['status'] == 1 && !$upgrade_service->hasApply()) {
return $this->errorJson('未通过升级条件!');
}
if (!$agentData) {
return $this->errorJson('未检测到数据!');
}
@ -149,6 +158,11 @@ class AreaDividendController extends ApiController
return $this->errorJson('未检测到申请区域数据!');
}
$subPlatformOpen = AreaDividendAgent::subPlatformOpen();
if (!$subPlatformOpen && (!$agentData['username'] || !$agentData['password'])) {
return $this->errorJson('未检测到申请账号密码数据!');
}
if (!$set['agent_many']) {//一人可代理多个区域
$agent = AreaDividendAgent::getAgentByMemberId(\YunShop::app()->getMemberId())
->first();
@ -199,7 +213,15 @@ class AreaDividendController extends ApiController
return $this->errorJson('该区域已被锁定!');
}
if (trim($agentData['username']) && trim($agentData['password'])) {
$verifyPasswordStrength = true;
if ($subPlatformOpen) {
$accountPwd = \Yunshop\SubPlatform\services\AdminUserServices::createAccountPwd('agent',8,true);
$agentData['username'] = $accountPwd['account'];
$agentData['password'] = $accountPwd['password'];
$verifyPasswordStrength = false;
}
if (trim($agentData['username']) /*&& trim($agentData['password'])*/) {
$user = WeiQingUsers::getUserByUserName($agentData['username'])->first();
if ($user) {
return $this->errorJson('账号重复!');
@ -208,7 +230,7 @@ class AreaDividendController extends ApiController
}
$verifyPassword = verifyPasswordStrength($agentData['password']);
if($verifyPassword !== true){
if($verifyPasswordStrength && $verifyPassword !== true){
return $this->errorJson($verifyPassword);
}
@ -234,6 +256,12 @@ class AreaDividendController extends ApiController
//数据保存
if ($agentModel->save()) {
if (!$set['become_check']) {
$data=[
'member_id'=>$agentModel['member_id'],
'username'=>$agentModel['real_name'],
'created_at' => time(),
];
event(new \app\common\events\plugin\AreaDividendEvent($data));
// 发送消息
$member = Member::getMemberByUid($agentModel->member_id)->with('hasOneFans')->first();
MessageService::becomeAgent($agentModel, $member->hasOneFans);
@ -343,27 +371,4 @@ class AreaDividendController extends ApiController
return $this->errorJson('未检测到数据!');
}
/**
* Common: 根据条件获取区域代理列表
* Author: wu-hui
* Time: 2023/06/01 16:55
* @return \Illuminate\Http\JsonResponse
*/
public function getAreaDividendAgent(){
// 参数获取
$provinceId = request()->input('province_id');
// 列表获取
$list = AreaDividendAgent::uniacid()
->select(['id','title','real_name','province_name','city_name','district_name'])
->where('province_id',$provinceId)
->where('status',1)
->where('min_status',1)
->get();
if($list) $list = $list->toArray();
return $this->successJson('区域代理列表',$list);
}
}

View File

@ -1,125 +0,0 @@
<?php
namespace Yunshop\AreaDividend\api;
use app\backend\modules\member\models\MemberRecord;
use app\common\components\ApiController;
use app\common\exceptions\AppException;
use app\common\models\member\ParentOfMember;
use app\common\services\payment\WechatPayCodePay;
use app\frontend\modules\member\models\SubMemberModel;
use app\Jobs\ModifyRelationshipChainJob;
use Illuminate\Support\Facades\DB;
use Matrix\Exception;
use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
use Yunshop\TeamDividend\services\UpgradeService;
class PaymentCodeController extends ApiController{
/**
* Common: 付款码支付
* Author: wu-hui
* Time: 2023/06/03 11:01
* @return \Illuminate\Http\JsonResponse
* @throws Exception
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function createOrder(){
// 参数获取
request()->offsetSet('is_auto_order', true);// 标识为自动下单
$params = [
'auth_code' => request()->input('auth_code'),// 扫码支付付款码,设备读取用户微信中的条码或者二维码信息
'parent_id' => (int)\YunShop::app()->getMemberId(),// 上级用户id
'nickname' => request()->input('nickname'),// 用户昵称
'mobile' => request()->input('mobile'),// 用户手机号
'area_id' => request()->input('area_id'),// 区域代理id
'pay_uid' => (int)request()->input('pay_uid'),// 付款用户id
'operate_type' => (int)request()->input('operate_type'),// 操作类型 0=获取用户信息1=下单支付
];
if($params['parent_id'] <= 0) throw new Exception('请登录后操作!');
$weChatMinPaymentCodeModel = new WechatPayCodePay();
// 开始进行付款码付款处理流程
DB::beginTransaction();
try{
$result = [];
// 判断:获取用户信息 or 下单付款
if($params['operate_type'] != 1){
// 获取用户信息
$result['pay_uid'] = $weChatMinPaymentCodeModel->getPayUserId($params);
$message = '用户信息处理成功';
}else{
if($params['pay_uid'] <= 0) throw new AppException('付款用户信息获取失败!');
// 用户信息处理
$memberId = (int)$weChatMinPaymentCodeModel->userManage($params);
\Log::debug('微信付款码支付 - 用户信息处理 - UID',$memberId);
// 上下级关系绑定
$this->parentSubRelationship($params['parent_id'],$memberId);
// 付款码下单处理
$_COOKIE['imitate_login_member_id'] = $memberId;// 变更登录用户 模拟为付款人下单
$orderIds = $weChatMinPaymentCodeModel->createOrder($memberId);
// 开始支付
$weChatMinPaymentCodeModel->orderPay($orderIds,$params);
// 不是经销商成为经销商
\Log::debug('微信付款码支付 - 经销商处理 - UID',$memberId);
if((int)TeamDividendAgencyModel::where('uid',$memberId)->value('id') <= 0){
$levelId = (new TeamDividendLevelModel())->orderBy('level_weight', 'ASC')->value('id');
(new UpgradeService())->memberUpgradeToAgency($memberId, $levelId);
}
// 开启推广员权限
\Log::debug('微信付款码支付 - 开启推广员权限 - UID',$memberId);
SubMemberModel::where('member_id',$memberId)->update([
'is_agent' => 1
]);
$message = '支付成功';
}
DB::commit();
return $this->successJson($message,$result);
}
catch(\Exception $e){
DB::rollBack();
return $this->errorJson($e->getMessage());
}
}
/**
* Common: 上下级绑定 存在上级则不改变,不存在或者为绑定则改变
* Author: wu-hui
* Time: 2023/06/02 16:46
* @param $parent_id
* @param $uid
* @throws AppException
* @throws Exception
*/
public function parentSubRelationship($parent_id,$uid){
$member = SubMemberModel::getMemberShopInfo($uid);
if($member['inviter'] != 1 || $member['parent_id'] <= 0){
// 判断修改的上级是否推广员
if ($parent_id != 0) {
$parent = SubMemberModel::getMemberShopInfo($parent_id);
if (!($parent->is_agent == 1 && $parent->status == 2)) throw new Exception('上线没有推广权限!');
if ($parent->parent_id == $uid) throw new Exception('会员上下线冲突!');
//验证是否闭环关系链
$chain = ParentOfMember::where('member_id', $parent_id)->pluck('parent_id');
$chain->push($uid);
$chain->push($parent_id);
if ($chain->count() != $chain->unique()->count()) throw new Exception('关系链闭环,请检测关系链!');
}
$record_data = [
'uid' => $uid,
'parent_id' => $member->parent_id,
'after_parent_id' => $parent_id,
'status' => 0,
'uniacid' => \YunShop::app()->uniacid
];
$member_record = MemberRecord::create($record_data);
$this->dispatch(new ModifyRelationshipChainJob($uid, $parent_id, $member_record->id, \YunShop::app()->uniacid));
}
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace Yunshop\AreaDividend\api;
use app\common\components\BaseController;
use app\common\facades\Setting;
use app\common\models\Goods;
use Yunshop\AreaDividend\services\UpgradeService;
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
class UpgradeController extends BaseController
{
public function index()
{
$upgrade_service = new UpgradeService(\YunShop::app()->getMemberId());
$check_result = $upgrade_service->check();
if (!$check_result['status']) {
return $this->errorJson($check_result['msg']);
}
$level_name = TeamDividendLevelModel::where('id', $upgrade_service->upgrade['push_level'])->value('level_name');
$goods_list = Goods::whereIn('id', $upgrade_service->upgrade['goods_ids'] ?: [])
->select(['id', 'thumb', 'title', 'price', 'description'])
->paginate();
foreach ($goods_list as $goods) {
$goods->thumb = yz_tomedia($goods->thumb);
}
$upgrade_data = [
'level_name' => $level_name,
'push_num' => $upgrade_service->upgrade['push_num'],
'price' => $upgrade_service->upgrade['price'],
'have_push_num' => $upgrade_service->getAgencyCount(),
'self_price' => $upgrade_service->getSelfPrice(),
'has_buy_goods' => $upgrade_service->hasBuyGoods(),
'goods_list' => $goods_list,
'apply_background' => yz_tomedia(Setting::get('plugin.area_dividend.apply_background')),
];
return $this->successJson('ok', $upgrade_data);
}
}

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/29
* Time: 14:23
*/
namespace Yunshop\AreaDividend\area;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/30
* Time: 9:46
*/
namespace Yunshop\AreaDividend\area;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/29
* Time: 14:25
*/
namespace Yunshop\AreaDividend\area;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/30
* Time: 13:46
*/
namespace Yunshop\AreaDividend\area;
@ -43,6 +38,7 @@ class DividendLogController extends CommonController
'pager' => $pager,
'search' => $search,
'statisti' => $statisti,
'appointment' => app('plugins')->isEnabled('appointment')
])->render();
}

View File

@ -0,0 +1,94 @@
<?php
namespace Yunshop\AreaDividend\area;
use app\common\helpers\Url;
use app\common\models\finance\PointLog;
use app\common\services\finance\PointService;
use app\common\services\OrderExportService;
class PointLogController extends CommonController
{
protected function search($query, $search = [])
{
if ($search['order_sn']) {
$query->whereHas('hasOneOrder', function ($query) use ($search) {
$query->where('order_sn', 'like', "%{$search['order_sn']}%");
});
}
if (in_array($search['time_search'], ['created_at']) && $search['time_arr'] && is_array($search['time_arr']) && $search['time_arr'][0] && $search['time_arr'][1]) {
if (strlen($search['time_arr'][0]) == 13) {
$search['time_arr'][0] = bcdiv($search['time_arr'][0], 1000, 0);
}
if (strlen($search['time_arr'][1]) == 13) {
$search['time_arr'][1] = bcdiv($search['time_arr'][1], 1000, 0);
}
$query->whereBetween($search['time_search'], $search['time_arr']);
}
return $query;
}
public function index()
{
if (!request()->is_json) {
return view('Yunshop\AreaDividend::area.point-log-list', [])->render();
}
$query = PointLog::uniacid()->orderBy('id', 'DESC')
->where('member_id', $this->agent_model->member_id)
->whereIn('point_mode', [PointService::POINT_MODE_AREA_DIVIDEND_AWARD,PointService::POINT_MODE_AREA_DIVIDEND]);
$search = \YunShop::request()->search_data ?: [];
$query = $this->search($query, $search);
$sum = 0;
if ($search['is_count']) {
$sum = $query->sum('point');
}
$list = $query->with(['hasOneOrder' => function ($query) {
$query->select('id', 'order_sn');
}])->paginate();
return $this->successJson('成功', ['list' => $list, 'is_count' => $search['is_count'], 'sum_point' => $sum]);
}
public function export()
{
$export_page = intval(request()->export_page) ?: 1;
$query = PointLog::uniacid()->orderBy('id', 'DESC')
->where('member_id', $this->agent_model->member_id)
->where('point_mode', PointService::POINT_MODE_AREA_DIVIDEND_AWARD)
->with(['hasOneOrder' => function ($query) {
$query->select('id', 'order_sn');
}]);
$export_model = new OrderExportService($this->search($query, json_decode(request()->search_data, true) ?: []), $export_page);
$route = 'plugin.area-dividend.area.point-log.index';
if ($export_model->builder_model->isEmpty()) {
return $this->message('没有可导出的数据', Url::absoluteWeb($route), 'fail');
}
$file_name = date('Ymdhis', time()) . '区域分红赠送积分明细数据导出' . $export_page;
$export_data[] = ['ID', '订单号', '赠送积分', '赠送时间'];
$k = 1;
$export_model->builder_model->each(function ($v) use (&$export_data, &$k) {
$export_data[$k] = [
$v->id,
$v->hasOneOrder->order_sn ?: '',
$v->point,
$v->created_at,
];
$k++;
});
$export_model->export($file_name, $export_data, $route);
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Yunshop\AreaDividend\event;
use app\common\events\Event;
use app\common\models\Order;
class AfterDetermineRegionEvent extends Event
{
protected $order;
protected $areaAgent;
protected $areaLevel;
/**
* 确定区域等级后事件
* @param Order $order
* @param $areaAgent
*/
public function __construct(Order $order, $areaAgent, $areaLevel)
{
$this->order = $order;
$this->areaAgent = $areaAgent;
$this->areaLevel = $areaLevel;
}
/**
* @return Order
*/
public function getOrder()
{
return $this->order;
}
/**
* @return mixed
*/
public function getAreaAgent()
{
return $this->areaAgent;
}
/**
* @return mixed
*/
public function getAreaLevel()
{
return $this->areaLevel;
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace Yunshop\AreaDividend\event;
use app\common\events\Event;
class BeforeAreaDividendCreatedEvent extends Event
{
protected $order;
protected $extra_plugin_id;
protected $extra_id;
protected $is_break;
protected $break_message;
public function __construct($order, $extra_plugin_id, $extra_id)
{
\Log::debug('区域分红:创建执行前事件', $order->id);
$this->order = $order;
$this->extra_plugin_id = $extra_plugin_id;
$this->extra_id = $extra_id;
$this->is_break = 0;
$this->break_message = '';
}
public function getOrderModel()
{
return $this->order;
}
public function getExtraPluginId()
{
return $this->extra_plugin_id;
}
public function getExtraId()
{
return $this->extra_id;
}
public function isBreak()
{
return $this->is_break;
}
public function setBreak($message = '')
{
$this->is_break = 1;
$this->break_message = $message ?: '';
}
public function breakMessage()
{
return $this->break_message;
}
}

View File

@ -1,11 +1,6 @@
<?php
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/4/27
* Time: 上午9:16
*/
namespace Yunshop\AreaDividend\models;
@ -32,22 +27,20 @@ use Yunshop\TeamDividend\models\ErrorTeamDividend;
*/
class AreaDividend extends BaseModel
{
use SoftDeletes;
public $table = 'yz_area_dividend';
public $timestamps = true;
protected $guarded = [''];
public $StatusService;
public $SettlementService;
public $LevelService;
protected $appends = ['status_name', 'level_name'];
protected $appends = ['status_name', 'level_name','settlement_name'];
public static function getDividends($search)
{
$model = self::uniacid();
if (!empty($search['member'])) {
$model->whereHas('hasOneMember', function ($query) use ($search) {
return $query->searchLike($search['member']);
});
$model->where('member_id',$search['member']);
}
if (!empty($search['area_name'])) {
$model->where('agent_area', 'like', '%' . $search['area_name'] . '%');
@ -64,6 +57,10 @@ class AreaDividend extends BaseModel
});
}
if($search['extra_plugin_id'] > 0){
$model->where('extra_plugin_id', $search['extra_plugin_id']);
}
if (!empty($search['area_level'])) {
$model->where('area_level', $search['area_level']);
}
@ -80,8 +77,6 @@ class AreaDividend extends BaseModel
}
}
$model->where('dividend_amount' , '>', 0);
$model->with([
'hasOneMember' => function ($query) {
$query->select(['uid', 'avatar', 'nickname', 'realname', 'mobile'])->uniacid();
@ -279,6 +274,22 @@ class AreaDividend extends BaseModel
}
return $this->StatusService;
}
public function getSettlementNameAttribute()
{
if (!isset($this->SettlementService)) {
switch ($this->settlement_type) {
case 0:
$this->SettlementService = '收入';
break;
case 1:
$this->SettlementService = '积分';
break;
default : $this->SettlementService = '收入';
}
}
return $this->SettlementService;
}
public function getLevelNameAttribute()

View File

@ -1,20 +1,15 @@
<?php
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/4/27
* Time: 上午9:16
*/
namespace Yunshop\AreaDividend\models;
use app\common\facades\Setting;
use app\common\models\BaseModel;
use app\common\services\finance\PointService;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
use Yunshop\AreaDividend\services\AgentService;
use Yunshop\Commission\models\AgentLevel;
/**
* Class AreaDividendAgent
@ -114,15 +109,31 @@ class AreaDividendAgent extends BaseModel
}
return $this->LevelService;
}
/**
* Common: 获取器 —— 分润比例
* Author: wu-hui
* Time: 2022/09/27 17:38
* @return mixed|void
*/
public function getRateAttribute(){
if (!isset($this->Rate)) return AgentLevel::getUserRate($this->member_id,$this->agent_level,FALSE);
if ($this->has_ratio == 1) $this->Rate = $this->ratio;
public function getRateAttribute()
{
$set = Setting::get('plugin.area_dividend');
if (!isset($this->Rate)) {
switch ($this->agent_level) {
case 1:
return $set['province_rate'];
break;
case 2:
return $set['city_rate'];
break;
case 3:
return $set['area_rate'];
break;
case 4:
return $set['street_rate'];
break;
}
}
if ($this->has_ratio == 1) {
$this->Rate = $this->ratio;
}
return $this->Rate;
}
@ -215,6 +226,8 @@ class AreaDividendAgent extends BaseModel
}
// dump('costPrice:'.$costPrice);
$calculatePrice = $order->price - $costPrice;
} elseif ($set['calculate_type'] == 2) {
$calculatePrice = $order->goods_price;
}
// dump($calculatePrice);
@ -238,10 +251,11 @@ class AreaDividendAgent extends BaseModel
$point_data = [
'point_income_type' => PointService::POINT_INCOME_GET,
'point_mode' => PointService::POINT_MODE_TEAM,
'point_mode' => PointService::POINT_MODE_AREA_DIVIDEND_AWARD,
'member_id' => $member_id,
'point' => $point,
'remark' => '区域分红奖励'
'remark' => '区域分红奖励',
'order_id' => $order->id,
];
// dump($point_data);
@ -258,4 +272,27 @@ class AreaDividendAgent extends BaseModel
->where('manage', 1)
->first();
}
}
public function scopeProfileWith(Builder $builder)
{
return $builder->with([
'hasOneProfile:uid,mobile'
]);
}
/**
* 获取与用户表相关的用户信息
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function hasOneProfile()
{
return $this->hasOne(\app\platform\modules\user\models\YzUserProfile::class, 'uid', 'user_id');
}
public static function subPlatformOpen()
{
//子平台插件开启可不填账号密码
return app('plugins')->isEnabled('sub-platform') && \Yunshop\SubPlatform\services\SettingService::applySwitch();
}
}

View File

@ -1,11 +1,6 @@
<?php
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/4/27
* Time: 上午9:16
*/
namespace Yunshop\AreaDividend\models;
use app\common\facades\Setting;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: shenyang
* Date: 2018/11/5
* Time: 11:39 AM
*/
namespace Yunshop\AreaDividend\models;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/30
* Time: 10:05
*/
namespace Yunshop\AreaDividend\models\area;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/29
* Time: 14:44
*/
namespace Yunshop\AreaDividend\models\area;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/29
* Time: 15:46
*/
namespace Yunshop\AreaDividend\models\area;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: shenyang
* Date: 2018/9/21
* Time: 上午9:53
*/
namespace Yunshop\AreaDividend\models\expansions;
use app\common\models\ModelExpansion;

View File

@ -4,12 +4,7 @@ namespace Yunshop\AreaDividend\services;
use app\common\models\Address;
use app\common\models\Street;
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/5/4
* Time: 下午3:05
*/
class AgentService
{
public static function setAgentData($agentData)

View File

@ -0,0 +1,202 @@
<?php
namespace Yunshop\AreaDividend\services;
use app\common\models\Order;
use Yunshop\AreaDividend\models\AreaDividendAgent;
use Yunshop\AreaDividend\models\AreaDividend;
class AppointmentService
{
protected $order;
protected $appointment;
protected $appointment_basic_pay;
//门店预约区域奖励相关
public function appointmentReward($appointment_order, $area_arr)
{
$this->appointment = $appointment_order;
$this->order = Order::find($appointment_order->order_id);
if($appointment_order->area_set != 1) return;
$set = \Setting::get('plugin.area_dividend');
$appointment_basic_pay = false;
if($set['appointment_basic'] == 1) $appointment_basic_pay = true;
$this->appointment_basic_pay = $appointment_basic_pay;
//区域代理
$area_level = [];
$area_agent = [];
if ($area_arr['province_id']) {
$area_agent['province'] = $this->getProvince($area_arr['province_id']);
$area_level['level_1'] = $this->getLevelStatus($area_agent['province']);
}
if ($area_arr['city_id']) {
$area_agent['city'] = $this->getCity($area_arr['city_id']);
$area_level['level_2'] = $this->getLevelStatus($area_agent['city']);
}
if ($area_arr['district_id']) {
$area_agent['district'] = $this->getDistrict($area_arr['district_id']);
$area_level['level_3'] = $this->getLevelStatus($area_agent['district']);
}
if ($area_arr['street_id']) {
$area_agent['street'] = $this->getStreet($area_arr['street_id']);
$area_level['level_4'] = $this->getLevelStatus($area_agent['street']);
}
if (!$area_agent) {
\Log::info('门店预约区域代理为空,返回');
} else {
\Log::info('门店预约区域代理不为空,继续');
$this->runDividendData($area_agent);
}
}
public function runDividendData($area_agents)
{
foreach ($area_agents as $areaLevel => $area_agent) {
if ($area_agent->isEmpty()) {
\Log::debug('门店预约区域分红' . $this->order->id .$areaLevel.'团队为空');
continue;
}
$same_level_num = $area_agent->count('id'); //同级人数
\Log::debug('门店预约区域分红' . $this->order->id .$areaLevel.'同级人数'.$same_level_num);
$areaDividendData = [
'uniacid' => \YunShop::app()->uniacid,
'order_sn' => $this->order->order_sn,
'order_id' => $this->order->id,
'order_amount' => $this->order->price,
'settle_days' => $this->getSet()['settle_days'] ?: 0,
'create_month' => date('Y-m'),
'same_level_number' => $same_level_num,
'created_at' => time(),
'extra_plugin_id' => 101,//门店预约插件
'extra_id' => $this->appointment->id,
];
foreach ($area_agent as $agent) {
if ($agent['agent_at'] > $areaDividendData['created_at']) {
\Log::debug("门店预约区域分红{$this->order->id}: {$areaLevel}{$agent['id']}成为区域代理的时间大于下单时间");
continue;
}
$areaDividendData['member_id'] = $agent['member_id'];
$areaDividendData['area_level'] = $agent['agent_level'];
$areaDividendData['agent_area'] = $this->getAreaName($agent);
$areaDividendData['dividend_rate'] = $this->dividendRate($agent,$areaLevel);
$price = $this->appointment->$areaLevel;
if ($this->appointment_basic_pay) $price = $this->order->price;
$dividend_amount = $this->getDividendAmount($areaDividendData,$price);
\Log::debug('门店预约区域分红-分红金额',[$dividend_amount,$areaDividendData['dividend_rate'],$price]);
if ($dividend_amount <= 0) {
continue;
}
$areaDividendData['dividend_amount'] = $dividend_amount;
$areaDividendData['amount'] = bcdiv($price,$this->appointment->total_count,2);
//todo 防止多队列支付先走
$order = \app\common\models\Order::find($this->order->id);
if ($order->status >= 3) {
$areaDividendData['recrive_at'] = strtotime($order->finish_time);
}
$dividendModel = AreaDividend::create($areaDividendData);
$agentData = [
'unsettled_dividend_amount' => bcadd($areaDividendData['dividend_amount'],$agent['unsettled_dividend_amount'],2),
];
AreaDividendAgent::updatedAgentById($agentData, $agent['id']);
}
}
}
/**
* @param $provinceId
* @return mixed
*/
private function getProvince($provinceId)
{
return AreaDividendAgent::getAreaAgentByAddressId($provinceId, $level = 1)->get();
}
/**
* @param $cityId
* @return mixed
*/
private function getCity($cityId)
{
return AreaDividendAgent::getAreaAgentByAddressId($cityId, $level = 2)->get();
}
/**
* @param $districtId
* @return mixed
*/
private function getDistrict($districtId)
{
return AreaDividendAgent::getAreaAgentByAddressId($districtId, $level = 3)->get();
}
/**
* @param $streetId
* @return mixed
*/
private function getStreet($streetId)
{
return AreaDividendAgent::getAreaAgentByAddressId($streetId, $level = 4)->get();
}
/**
* @param $value
* @return int
*/
private function getLevelStatus($value)
{
return !$value->isEmpty() ? 1 : 0;
}
private function getSet()
{
return \Setting::get('plugin.area_dividend');
}
/**
* @param $agent
* @return int
*/
private function getDividendAmount($areaDividendData,$price)
{
$basic = bcmul($price, $areaDividendData['dividend_rate']/100,2);
return bcdiv($basic,$this->appointment->total_count,2);
}
protected function dividendRate($agent,$areaLevel)
{
if($areaLevel == 'district') $areaLevel = 'area';
$ratio = $this->getSet()[$areaLevel.'_rate'];
if ($agent->has_ratio == 1) {
$ratio = $agent->ratio;
}
return $ratio;
}
private function getAreaName($agent)
{
$areaName = $agent->province_name;
$areaName .= $agent->city_name ? "-" . $agent->city_name : '';
$areaName .= $agent->district_name ? "-" . $agent->district_name : '';
$areaName .= $agent->street_name ? "-" . $agent->street_name : '';
return $areaName;
}
}

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: weifeng
* Date: 2019-04-15
* Time: 12:04
*/
namespace Yunshop\AreaDividend\services;

View File

@ -1,10 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/4/15
* Time: 下午2:49
*/
namespace Yunshop\AreaDividend\services;
@ -55,7 +50,7 @@ class MessageService
// }
// return;
}
public static function statementNotice($data)
{
$areaDividendNotice = Setting::get('plugin.area_dividend');
@ -85,6 +80,7 @@ class MessageService
// }
// return;
}
public static function messageNotice($temp_id, $member, $data = [], $uniacid = '')
{
@ -107,4 +103,18 @@ class MessageService
\app\common\services\MessageService::notice(MessageTemp::$template_id, $msg, $member->uid, $uniacid);
}
}
public static function meetUpgradeMessage($temp_id, Member $member, $uniacid = '')
{
$params = [
['name' => '昵称', 'value' => $member->nickname],
['name' => '时间', 'value' => date('Y-m-d H:i:s', time())],
];
$msg = MessageTemp::getSendMsg($temp_id, $params);
if (!$msg) {
return;
}
\app\common\services\MessageService::notice(MessageTemp::$template_id, $msg, $member->uid, $uniacid);
}
}

View File

@ -7,7 +7,6 @@ use Yunshop\AreaDividend\event\CreatedAreaDividendBonusEvent;
use Yunshop\AreaDividend\models\AreaDividend;
use Yunshop\AreaDividend\models\AreaDividendAgent;
use Yunshop\AreaDividend\models\AreaDividendGoods;
use Yunshop\Commission\models\AgentLevel;
use Yunshop\Hotel\common\models\HotelGoods;
use Yunshop\Hotel\common\models\HotelSetting;
use Yunshop\StoreCashier\common\models\CashierGoods;
@ -26,6 +25,8 @@ class OrderCreatedNewService
public $commission;
public $alone_dividend_rate = false;
public $lower_level_rate = false;
public $extra_plugin_id;
public $extra_id;
public function __construct($order,$areaLevel,$is_fix,$commission=false)
{
@ -33,6 +34,13 @@ class OrderCreatedNewService
$this->areaLevel = $areaLevel;
$this->is_fix = $is_fix;
$this->commission = $commission;
$this->setExtra(0, 0);
}
public function setExtra($extra_plugin_id, $extra_id)
{
$this->extra_plugin_id = $extra_plugin_id;
$this->extra_id = $extra_id;
}
protected function getSet()
@ -47,31 +55,12 @@ class OrderCreatedNewService
{
if (!isset($this->dividendRate)) {
$set = $this->getSet();
// 获取分红设置
$uid = $this->order['uid'] > 0 ? $this->order['uid'] : \YunShop::app()->getMemberId();
\Log::debug("用户分红比例 - uid",$uid);
if($uid > 0){
$originalStreetRate = AgentLevel::getUserRate($uid,4);
$originalAreaRate = AgentLevel::getUserRate($uid,3);
$originalCityRate = AgentLevel::getUserRate($uid,2);
$originalProvinceRate = AgentLevel::getUserRate($uid,1);
}else{
$originalStreetRate = $set['street_rate'] ? : 0;
$originalAreaRate = $set['area_rate'] ? : 0;
$originalCityRate = $set['city_rate'] ? : 0;
$originalProvinceRate = $set['province_rate'] ? : 0;
}
\Log::debug("用户分红比例 - 全部比例:",[$originalStreetRate,$originalAreaRate,$originalCityRate,$originalProvinceRate]);
// 分红配置
if ($set['is_distinction']) {
//开启极差
$street_rate = $this->areaLevel['level_4'] ? $originalStreetRate : 0;
$area_rate = $this->areaLevel['level_3'] ? $originalAreaRate : $street_rate;
$city_rate = $this->areaLevel['level_2'] ? $originalCityRate : $area_rate;
$province_rate = $this->areaLevel['level_1'] ? $originalProvinceRate : $city_rate;
$street_rate = $this->areaLevel['level_4'] ? $set['street_rate'] : 0;
$area_rate = $this->areaLevel['level_3'] ? $set['area_rate'] : $street_rate;
$city_rate = $this->areaLevel['level_2'] ? $set['city_rate'] : $area_rate;
$province_rate = $this->areaLevel['level_1'] ? $set['province_rate'] : $city_rate;
$rates = [
'province_rate' => $province_rate - $city_rate,
@ -101,11 +90,11 @@ class OrderCreatedNewService
],
'rate_3' => [
'rate' => $rates['area_rate'] > 0 ? $rates['area_rate'] : 0,
'lower_level_rate' => $originalStreetRate ? $originalStreetRate : 0,
'lower_level_rate' => $set['street_rate'] ? $set['street_rate'] : 0,
'point_ratio' => $set['area_point']
],
'rate_4' => [
'rate' => $originalStreetRate ? $originalStreetRate : 0,
'rate' => $set['street_rate'] ? $set['street_rate'] : 0,
'lower_level_rate' => '0',
'point_ratio' => $set['street_point']
]
@ -113,31 +102,28 @@ class OrderCreatedNewService
} else {
$this->dividendRate = [
'rate_1' => [
'rate' => $originalProvinceRate,
'lower_level_rate' => $originalCityRate,
'rate' => $set['province_rate'],
'lower_level_rate' => $set['city_rate'],
'point_ratio' => $set['province_point']
],
'rate_2' => [
'rate' => $originalCityRate,
'lower_level_rate' => $originalAreaRate,
'rate' => $set['city_rate'],
'lower_level_rate' => $set['area_rate'],
'point_ratio' => $set['city_point']
],
'rate_3' => [
'rate' => $originalAreaRate,
'lower_level_rate' => $originalStreetRate,
'rate' => $set['area_rate'],
'lower_level_rate' => $set['street_rate'],
'point_ratio' => $set['area_point']
],
'rate_4' => [
'rate' => $originalStreetRate,
'rate' => $set['street_rate'],
'lower_level_rate' => '',
'point_ratio' => $set['street_point']
]
];
}
}
\Log::debug("用户分红比例 - 最终比例:",$this->dividendRate);
return $this->dividendRate;
}
@ -161,7 +147,15 @@ class OrderCreatedNewService
'create_month' => date('Y-m'),
'same_level_number' => $same_level_num,
'created_at' => $this->order->create_time->timestamp,
'extra_plugin_id' => $this->extra_plugin_id,
'extra_id' => $this->extra_id,
];
if (app('plugins')->isEnabled('coupon-store') && $this->extra_plugin_id == 144) {
$coupon_count = \Yunshop\CouponStore\models\Coupon::uniacid()->where('order_id', $this->order->id)->count();
$areaDividendData['order_amount'] = bcdiv($this->order->price, $coupon_count, 2);
}
foreach ($area_agents as $agent) {
if($agent['agent_at'] > $areaDividendData['created_at']){
\Log::debug("区域分红{$this->order->id}: {$areaLevel}{$agent['id']}成为区域代理的时间大于下单时间");
@ -172,6 +166,8 @@ class OrderCreatedNewService
'member_id' => $agent['member_id'],
'area_level' => $agent['agent_level'],
'order_sn' => $areaDividendData['order_sn'],
'extra_plugin_id' => $areaDividendData['extra_plugin_id'],
'extra_id' => $areaDividendData['extra_id'],
])->count();
if ($exist) {
\Log::info("订单{$areaDividendData['order_sn']}:", "{$agent['member_id']}的分红记录已存在");
@ -344,10 +340,9 @@ class OrderCreatedNewService
return $dividendAmount;
}
protected function getAloneRate($areaDividendGoods,$agent){
protected function getAloneRate($areaDividendGoods,$agent)
{
$set = $this->getSet();
if ($set['is_distinction']) {
//开启极差
$street_rate = $this->areaLevel['level_4'] ? $areaDividendGoods['street_rate'] : 0;
@ -425,7 +420,8 @@ class OrderCreatedNewService
protected function setDividendPrice($goods)
{
if ($this->getSet()['culate_method']) {
\Log::debug("区域分红计算订单价格价格",[$this->getSet()['culate_method']]);
if ($this->getSet()['culate_method'] == 1) {
//利润
$price = $goods->payment_amount - $goods->goods_cost_price;
if (app('plugins')->isEnabled('store-cashier')) {
@ -441,7 +437,7 @@ class OrderCreatedNewService
}
} elseif ($store_good) {
$store_setting = StoreSetting::where('store_id', $store_good->store_id)->where('key', 'store')->first();
$shop_commission = (integer)$store_setting->value['shop_commission'];
$shop_commission = $store_setting->value['shop_commission'];
$price = proportionMath($goods->payment_amount , $shop_commission);
if (app('plugins')->isEnabled('consumer-reward') && \Setting::get('plugin.consumer_reward.is_open')==1) {
if (\Setting::get('plugin.consumer_reward.store_profit')) {
@ -455,14 +451,24 @@ class OrderCreatedNewService
$hotel_good = HotelGoods::select('id', 'hotel_id', 'goods_id')->where('goods_id', $goods->goods_id)->first();
if ($hotel_good) {
$hotel_setting = HotelSetting::where('hotel_id', $hotel_good->hotel_id)->where('key', 'hotel')->first();
$shop_commission = (integer)$hotel_setting->value['shop_commission'];
$shop_commission = $hotel_setting->value['shop_commission'];
$price = proportionMath($goods->payment_amount , $shop_commission);
}
}
} elseif ($this->getSet()['culate_method'] == 2) {
//商品现价
$price = $goods->goods_price;
} else {
//订单金额
$price = $goods->payment_amount;
}
//消费券联盟根据核销次数对金额进行等分
if (app('plugins')->isEnabled('coupon-store') && $this->extra_plugin_id == 144 && bccomp($price, 0, 2) == 1) {
$coupon_count = \Yunshop\CouponStore\models\Coupon::uniacid()->where('order_id', $this->order->id)->count();
$price = bcdiv($price, $coupon_count, 2);
}
return $price;
}
@ -479,12 +485,10 @@ class OrderCreatedNewService
{
$set = $this->order->getSetting('plugin.area_dividend');
$totalDividend = 0.00;
$rates['province_rate'] = $set['province_rate'];
$rates['city_rate'] = $set['city_rate'];
$rates['area_rate'] = $set['area_rate'];
$rates['street_rate'] = $set['street_rate'];
if ($set['is_distinction']) {
$totalDividend = round(max($rates) / 100 * $this->amount, 2);
} else {

View File

@ -5,19 +5,13 @@ namespace Yunshop\AreaDividend\services;
use app\common\facades\Setting;
use Yunshop\AreaDividend\models\AreaDividendAgent;
use Yunshop\AreaDividend\models\AreaDividendGoods;
use Yunshop\Commission\models\AgentLevel;
use Yunshop\Hotel\common\models\HotelGoods;
use Yunshop\Hotel\common\models\HotelSetting;
use Yunshop\StoreCashier\common\models\CashierGoods;
use Yunshop\StoreCashier\common\models\StoreSetting;
use Yunshop\StoreCashier\store\models\StoreGoods;
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/5/8
* Time: 上午10:04
*/
class OrderCreatedService
{
/**
@ -150,35 +144,29 @@ class OrderCreatedService
* @param $areaLevel
* @return array
*/
public static function getRateByAgent($set, $areaLevel){
// 获取分红设置
$uid = \YunShop::app()->getMemberId();
if($uid > 0){
$originalStreetRate = AgentLevel::getUserRate($uid,4);
$originalAreaRate = AgentLevel::getUserRate($uid,3);
$originalCityRate = AgentLevel::getUserRate($uid,2);
$originalProvinceRate = AgentLevel::getUserRate($uid,1);
}else{
$originalStreetRate = $set['street_rate'] ? : 0;
$originalAreaRate = $set['area_rate'] ? : 0;
$originalCityRate = $set['city_rate'] ? : 0;
$originalProvinceRate = $set['province_rate'] ? : 0;
}
// 其他操作
public static function getRateByAgent($set, $areaLevel)
{
$rateData = [];
if ($areaLevel['level_4']) $street_rate = $originalStreetRate;
else $street_rate = 0;
if ($areaLevel['level_3']) $area_rate = $originalAreaRate;
else $area_rate = $street_rate;
if ($areaLevel['level_2']) $city_rate = $originalCityRate;
else $city_rate = $area_rate;
if ($areaLevel['level_1']) $province_rate = $originalProvinceRate;
else $province_rate = $city_rate;
if ($areaLevel['level_4']) {
$street_rate = $set['street_rate'];
} else {
$street_rate = 0;
}
if ($areaLevel['level_3']) {
$area_rate = $set['area_rate'];
} else {
$area_rate = $street_rate;
}
if ($areaLevel['level_2']) {
$city_rate = $set['city_rate'];
} else {
$city_rate = $area_rate;
}
if ($areaLevel['level_1']) {
$province_rate = $set['province_rate'];
} else {
$province_rate = $city_rate;
}
$street_point = $set['street_point'];
$area_point = $set['area_point'];
@ -206,22 +194,8 @@ class OrderCreatedService
{
$set = Setting::get('plugin.area_dividend');
$dividendRate = [];
// 获取分红设置
$uid = \YunShop::app()->getMemberId();
if($uid > 0){
$originalStreetRate = AgentLevel::getUserRate($uid,4);
$originalAreaRate = AgentLevel::getUserRate($uid,3);
$originalCityRate = AgentLevel::getUserRate($uid,2);
$originalProvinceRate = AgentLevel::getUserRate($uid,1);
}else{
$originalStreetRate = $set['street_rate'] ? : 0;
$originalAreaRate = $set['area_rate'] ? : 0;
$originalCityRate = $set['city_rate'] ? : 0;
$originalProvinceRate = $set['province_rate'] ? : 0;
}
if ($set['is_distinction']) {
$rates = static::getRateByAgent($set, $areaLevel);
$province_rate = $rates['province_rate'];
$city_rate = $rates['city_rate'];
@ -240,11 +214,11 @@ class OrderCreatedService
],
'rate_3' => [
'rate' => $area_rate > 0 ? $area_rate : 0,
'lower_level_rate' => $originalStreetRate ? $originalStreetRate : 0,
'lower_level_rate' => $set['street_rate'] ? $set['street_rate'] : 0,
'point_ratio' => $set['area_point']
],
'rate_4' => [
'rate' => $originalStreetRate ? $originalStreetRate : 0,
'rate' => $set['street_rate'] ? $set['street_rate'] : 0,
'lower_level_rate' => '0',
'point_ratio' => $set['street_point']
]
@ -252,22 +226,22 @@ class OrderCreatedService
} else {
$dividendRate = [
'rate_1' => [
'rate' => $originalProvinceRate,
'lower_level_rate' => $originalCityRate,
'rate' => $set['province_rate'],
'lower_level_rate' => $set['city_rate'],
'point_ratio' => $set['province_point']
],
'rate_2' => [
'rate' => $originalCityRate,
'lower_level_rate' => $originalAreaRate,
'rate' => $set['city_rate'],
'lower_level_rate' => $set['area_rate'],
'point_ratio' => $set['city_point']
],
'rate_3' => [
'rate' => $originalAreaRate,
'lower_level_rate' => $originalStreetRate,
'rate' => $set['area_rate'],
'lower_level_rate' => $set['street_rate'],
'point_ratio' => $set['area_point']
],
'rate_4' => [
'rate' => $originalStreetRate,
'rate' => $set['street_rate'],
'lower_level_rate' => '',
'point_ratio' => $set['street_point']
]

View File

@ -1,16 +1,13 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/11
* Time: 17:52
*/
namespace Yunshop\AreaDividend\services;
use app\common\facades\Setting;
use Yunshop\AreaDividend\event\SettleAreaDividendBonusEvent;
use Yunshop\AreaDividend\models\AreaDividend;
use Yunshop\Love\Common\Services\CommonService;
class ReturnFormatService
{
@ -27,12 +24,23 @@ class ReturnFormatService
protected function defaultFormat($data)
{
return [
$res = [
'id' => $data->id,
'order_sn' => $data->order_sn,
'amount' => $data->dividend_amount,
'order' => $data->hasOneOrder ? $data->hasOneOrder->toArray() : [],
];
$settlement_option = \Setting::get('plugin.area_dividend.settlement_option');
if ($settlement_option == 1) {
return array_merge($res,['reward_type' => \Setting::get('shop.shop')['credit1'] ?: '积分']);
}
if ($settlement_option == 2) {
return array_merge($res,['reward_type' => \Setting::get('shop.shop')['credit'] ?: '余额']);
}
if ($settlement_option == 3) {
return array_merge($res,['reward_type' => '直接结算']);
}
return $res;
}
@ -48,7 +56,10 @@ class ReturnFormatService
public function setSettlement($result)
{
$data = ['status'=>'1','statement_at'=>time()];
// $data = ['status'=>'1','statement_at'=>time()];
//AreaDividend::where('id', $result->id)->update($data);
$settlement_type = Setting::get('plugin.area_dividend.settlement_option') ?: 0;
$data = ['status'=>'1','statement_at'=>time(),'settlement_type' => $settlement_type];
AreaDividend::where('id', $result->id)->update($data);
$areaDividend = collect([])->push($result);

View File

@ -3,6 +3,8 @@ namespace Yunshop\AreaDividend\services;
use app\common\facades\Setting;
use app\common\models\Member;
use app\common\models\UniAccount;
use app\common\services\finance\BalanceChange;
use app\common\services\finance\PointService;
use app\common\services\income\IncomeService;
use Illuminate\Support\Facades\Log;
use Yunshop\AreaDividend\event\SettleAreaDividendBonusEvent;
@ -12,12 +14,7 @@ use app\common\models\Income;
use app\common\events\ProfitEvent;
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/5/12
* Time: 下午09:52
*/
class TimedTaskService
{
public function handle()
@ -54,34 +51,50 @@ class TimedTaskService
*/
public function setStatement($areaDividend)
{
$set = Setting::get('plugin.area_dividend');
foreach ($areaDividend as $item)
{
//增加区域代理已结算金额
$this->addAgentDividend($item);
$send_msg = true;
if (isset($set['settlement_option']) && $set['settlement_option'] == 1) {
//转入积分
$this->addPoint($item);
} else if (isset($set['settlement_option']) && $set['settlement_option'] == 2) {
//转入积分
$this->addBalance($item);
} elseif (isset($set['settlement_option']) && $set['settlement_option'] == 3) {
//直接结算 代理商分红在用
\Log::info('----区域分红选择直接结算----',$item->id);
$send_msg = false;
}else {
//加入分红收入
$this->addAreaDividendIncome($item);
}
//加入分红收入
$this->addAreaDividendIncome($item);
//招商专员插件分红
if(app('plugins')->isEnabled('invest-people')) {
(new \Yunshop\InvestPeople\services\IncomeWithdrawService())->areaDividend($item);
}
if ($item->dividend_amount > 0) {
MessageService::statementNotice($item);
}
if($send_msg){
if ($item->dividend_amount > 0) {
MessageService::statementNotice($item);
}
if (app('plugins')->isEnabled('instation-message')) {
//开启了站内消息插件
event(new \Yunshop\InstationMessage\event\AreaDividendSettlementEvent([
'changeTime'=>date('Y-m-d H:i:s', time()),
'order_sn'=>$item->hasOneOrder->order_sn,
'order_amount'=>$item->hasOneOrder->price,
'amount'=>$item->amount,
'dividend_amount'=>$item->dividend_amount,
'member_id'=>$item->member_id,
'uniacid'=>\YunShop::app()->uniacid
]));
if (app('plugins')->isEnabled('instation-message')) {
//开启了站内消息插件
event(new \Yunshop\InstationMessage\event\AreaDividendSettlementEvent([
'changeTime'=>date('Y-m-d H:i:s', time()),
'order_sn'=>$item->hasOneOrder->order_sn,
'order_amount'=>$item->hasOneOrder->price,
'amount'=>$item->amount,
'dividend_amount'=>$item->dividend_amount,
'member_id'=>$item->member_id,
'uniacid'=>\YunShop::app()->uniacid
]));
}
}
}
}
@ -92,7 +105,8 @@ class TimedTaskService
*/
public function updatedStatement($dividendData)
{
$data = ['status'=>'1','statement_at'=>time()];
$settlement_type = Setting::get('plugin.area_dividend.settlement_option') ?: 0;
$data = ['status'=>'1','statement_at'=>time(),'settlement_type' => $settlement_type];
$ids = $dividendData->pluck('id');
return AreaDividend::whereIn('id', $ids)->update($data);
@ -164,11 +178,6 @@ class TimedTaskService
]
];
//收入明细数据
$incomeDetail = json_encode($data);
$config = \app\backend\modules\income\Income::current()->getItem('areaDividend');
//收入明细数据
$incomeDetail = json_encode($data);
@ -213,4 +222,43 @@ class TimedTaskService
// }
// return $requestIncome;
}
/**
* @param $dividendData
* @throws \app\common\exceptions\ShopException
*/
public function addPoint($dividendData)
{
$point_data = [
'point_income_type' => PointService::POINT_INCOME_GET,
'point_mode' => PointService::POINT_MODE_AREA_DIVIDEND,
'member_id' => $dividendData['member_id'],
'point' => $dividendData['dividend_amount'],
'order_id' => $dividendData['order_id'],
'remark' => "区域分红结算积分{$dividendData['id']}"
];
(new PointService($point_data))->changePoint();
}
/**
* @param $dividendData
* @return void
* @throws \app\common\exceptions\AppException
*/
public function addBalance($dividendData)
{
$data = [
'member_id' => $dividendData->member_id,
'change_value' => $dividendData->dividend_amount,
'operator' => \app\common\services\credit\ConstService::OPERATOR_SHOP,
'operator_id' => $dividendData->id,
'remark' => 'id'.$dividendData->id.',结算金额:'.$dividendData->dividend_amount,
'relation' => '',
'source' => \app\common\services\credit\ConstService::AREA_DIVIDEND,
'type' => \app\common\services\credit\ConstService::TYPE_INCOME,
];
(new BalanceChange())->universal($data);
}
}

View File

@ -0,0 +1,271 @@
<?php
namespace Yunshop\AreaDividend\services;
use app\common\exceptions\ShopException;
use app\common\facades\Setting;
use app\common\models\Member;
use app\common\models\member\MemberParent;
use app\common\models\Order;
use app\common\models\OrderGoods;
use Yunshop\AreaDividend\models\AreaDividendAgent;
use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
class UpgradeService
{
protected $setting;
public $upgrade;
protected $memberId;
protected $member;
public function __construct($memberId = null)
{
$this->setting = Setting::get('plugin.area_dividend');
//升级条件的设置(不是总设置)
$this->upgrade = $this->setting['upgrade'];
$this->memberId = $memberId;
$this->member = Member::find($memberId);
}
/**
* 是否为区域代理
* @return bool
*/
protected function hasDividendAgent()
{
return AreaDividendAgent::uniacid()->where('status', 1)->where('member_id', $this->memberId)->exists();
}
/**
* 订单支付后
* @return void
*/
public function afterPay()
{
if ($this->upgrade['event_type'] == 1) {
\Log::debug('--区域分红升级条件开始--afterPay');
if ($this->verification()) {
$this->sendMessage();
}
\Log::debug('--区域分红升级条件--结束');
}
}
/**
* 订单完成后
* @return void
*/
public function afterComplete()
{
if ($this->upgrade['event_type'] == 2) {
\Log::debug('--区域分红升级条件开始--afterComplete');
if ($this->verification()) {
$this->sendMessage();
}
\Log::debug('--区域分红升级条件--结束');
}
}
/**
* 校验升级条件
* @return bool
*/
public function verification(): bool
{
\Log::debug('--区域分红升级条件--升级设置', $this->upgrade);
$result = $this->check();
if ($result['status'] == 0) {
\Log::debug('--区域分红升级条件--失败', $result['msg']);
return false;
}
$one_result = $this->hasConditionOne();
$two_result = $this->hasConditionTwo();
if (!$two_result['status'] && !$one_result['status']) {
\Log::debug('--UpgradeService--hasConditionTwo', $two_result['msg']);
\Log::debug('--UpgradeService--hasConditionOne', $one_result['msg']);
return false;
}
return true;
}
/**
* @return bool
*/
public function hasApply()
{
if ($this->hasDividendAgent()) {
return true;
}
$one_result = $this->hasConditionOne();
$two_result = $this->hasConditionTwo();
if ($one_result['status'] || $two_result['status']) {
return true;
}
return false;
}
protected function sendMessage()
{
try {
if (!$this->upgrade['template_id']) {
\Log::debug('--区域分红升级条件--没有设置模板');
return false;
} else {
MessageService::meetUpgradeMessage($this->upgrade['template_id'], $this->member, $this->member->uniacid);
}
} catch (ShopException $e) {
\Log::debug('--区域分红升级条件--模板信息发送失败:', $e->getMessage());
return false;
}
}
/**
* 升级条件1
* @return array
*/
public function hasConditionOne()
{
if (!$this->upgrade['push_level']) {
return $this->error('没有设置经销商等级!');
}
if (!$this->upgrade['push_num']) {
return $this->error('没有设置直推数量!');
}
if (!$this->upgrade['price']) {
return $this->error('没有设置消费金额!');
}
if (!$this->upgrade['level_type']) {
return $this->error('没有设置等级类型!');
}
if (!$this->upgrade['push_level']) {
return $this->error('没有设置经销商等级!');
}
$push_count = $this->getAgencyCount();
if ($push_count < $this->upgrade['push_num']) {
return $this->error('经销商直推数量不符合条件!--' . ($this->upgrade['level_type'] ? '本级' : '以上') . '--经销商数量=' . $push_count);
}
$self_price = $this->getSelfPrice();
if ($self_price < $this->upgrade['price']) {
return $this->error("没有设置累计消费!--self_price={$self_price}--upgrade_price={$this->upgrade['price']}");
}
return $this->success();
}
/**
* 升级条件2
* @return array
*/
public function hasConditionTwo()
{
if (empty($this->upgrade['goods_ids'])) {
return $this->error('没有设置指定商品');
}
if (!$this->hasBuyGoods()) {
return $this->error('不符合购买指定商品');
}
return $this->success();
}
/**
* 自身团队已消费金额
* @return float
*/
public function getSelfPrice()
{
$child_ids = MemberParent::where('parent_id', $this->memberId)->pluck('member_id');
return Order::whereIn('status', [1, 2, 3])->whereIn('uid', $child_ids)->sum('price');
}
/**
* 是否有购买指定商品
* @return mixed
*/
public function hasBuyGoods()
{
return OrderGoods::where('uid', $this->memberId)
->whereIn('goods_id', $this->upgrade['goods_ids'] ?: [])
->whereHas('hasOneOrder', function ($order) {
if ($this->upgrade['event_type'] == 1) {
$order->where('status', ">=", 1);
} elseif ($this->upgrade['event_type'] == 2) {
$order->where('status', 3);
}
})
->exists();
}
/**
* 经销商人数
* @return int
*/
public function getAgencyCount()
{
$child_ids = MemberParent::where('parent_id', $this->memberId)->where('level', 1)->pluck('member_id');
//经销商
$agency_list = TeamDividendAgencyModel::whereIn('uid', $child_ids)->where('is_black', 0)->get();
$push_count = 0;
if ($this->upgrade['level_type'] == 1) {
$push_count = $agency_list->filter(function ($agency) {
return $this->upgrade['push_level'] == $agency->level;
})->count();
} elseif ($this->upgrade['level_type'] == 2) {
$start_level = TeamDividendLevelModel::where('id', $this->upgrade['push_level'])->value('level_weight');
if ($start_level) {
//获取设置等级以上的等级
$level_ids = TeamDividendLevelModel::where('level_weight', '>=', $start_level)->pluck('id')->toArray();
$push_count = $agency_list->filter(function ($agency) use ($level_ids) {
return in_array($agency->level, $level_ids);
})->count();
}
}
return $push_count;
}
protected function success($data = null, $mgs = 'success')
{
return ['status' => 1, 'msg' => $mgs, 'data' => $data];
}
protected function error($mgs = 'error', $data = null)
{
return ['status' => 0, 'msg' => $mgs, 'data' => $data];
}
public function check()
{
//未开启区域分红 || 未开启升级条件设置
if ($this->setting['is_area_dividend'] != 1 || $this->upgrade['is_open'] != 1) {
return $this->error('未开启相关设置!');
}
if (!isset($this->memberId)) {
return $this->error('缺少会员id');
}
if (!app('plugins')->isEnabled('team-dividend')) {
return $this->error('未开启经销商管理插件!');
}
if ($this->hasDividendAgent()) {
return $this->error('已成为区域代理!');
}
return $this->success();
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace Yunshop\AreaDividend\widgets;
class AreaDividendLangWidget
{
public function getData()
{
return [
'area_dividend' => [
'tab' => '区域分红设置',
'data' => [
[
'key' => 'title',
'default' => '区域分红',
'remark' => '插件名称'
],
[
'key' => 'area_dividend_center',
'default' => '区域分红中心',
'remark' => ''
],
[
'key' => 'dividend_amount',
'default' => '佣金',
'remark' => ''
]
]
]
];
}
}

View File

@ -1,11 +1,6 @@
<?php
namespace Yunshop\AreaDividend\widgets;
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/3/18
* Time: 下午5:36
*/
use app\common\components\Widget;
use app\common\facades\Setting;

View File

@ -1,12 +1,5 @@
<?php
/**
* Created by PhpStorm.
* Name: 芸众商城系统
* Author: 广州市芸众信息科技有限公司
* Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 www.yunzmall.com www.yunzshop.com
* Date: 2021/9/9
* Time: 17:39
*/
namespace Yunshop\AreaDividend\widgets;

View File

@ -1,11 +1,6 @@
<?php
namespace Yunshop\AreaDividend\widgets;
/**
* Created by PhpStorm.
* User: yanglei
* Date: 2017/5/15
* Time: 下午4:06
*/
use app\common\components\Widget;
use app\common\facades\Setting;

View File

@ -1,224 +1,94 @@
@extends('layouts.base')
@section('content')
@section('title', '编辑信息')
@section('title', '修改密码')
<div class="rightlist">
<div id="editAgentContent">
{{--表单内容--}}
<form action="" method='post' class='form-horizontal' id="editAgent" enctype="multipart/form-data">
<div class='panel panel-default'>
<el-tabs>
<el-tab-pane label="基本信息">
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">代理名称</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="title" class="form-control" value="{{$agency['title']}}" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单管理权限(唯一)</label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="order_manage" value="0" @if(!$agency['manage']) checked="checked" @endif /> 关闭
</label>
<label class="radio-inline">
<input type="radio" name="order_manage" value="1" @if($agency['manage'] == 1) checked="checked" @endif /> 开启
</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">独立分红比例</label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="has_ratio" value="0" @if(!$agency['has_ratio']) checked="checked" @endif /> 关闭</label>
<label class="radio-inline">
<input type="radio" name="has_ratio" value="1" @if($agency['has_ratio'] == 1) checked="checked" @endif/> 开启</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">分红比例</label>
<div class="col-sm-6 col-xs-6">
<div class='input-group'>
<input type='text' name='ratio' class="form-control discounts_value" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" value="{{$agency['ratio']}}"/>
<div class='input-group-addon waytxt'>%</div>
</div>
</div>
</div>
{{--招商专员插件--}}
@if(app('plugins')->isEnabled('invest-people'))
{!! \Yunshop\InvestPeople\services\InvestMemberView::areaDividend($agency['investor_uid']) !!}
@endif
@if (!empty($username))
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">账号:</label>
<div class="col-sm-9 col-xs-12">
{{$username}}
</div>
</div>
@else
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">添加账号</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="wq[username]" placeholder="登录账号" class="form-control" value="" />
</div>
</div>
@endif
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">密码</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="wq[password]" class="form-control" value="" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">验证密码</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="wq[password_again]" class="form-control" value="" />
</div>
</div>
</el-tab-pane>
<el-tab-pane label="微信小程序">
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">小程序状态</label>
<div class="col-sm-9 col-xs-12">
<label class='radio-inline'>
<input type='radio' name='min_status' value='0' @if ($agency['min_status'] != 1) checked @endif/>关闭
</label>
<label class='radio-inline'>
<input type='radio' name='min_status' value='1' @if ($agency['min_status'] == 1) checked @endif />使用中
</label>
</div>
</div>
<div class="min-config-content" @if($agency['min_status'] != 1) style="display: none;" @endif>
{{--<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">App ID</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="min_app_id" class="form-control" value="{{ $agency['min_app_id'] }}"/>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">App Secret</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="min_app_secret" class="form-control @if($agency['min_app_secret']) hidden @endif " value="{{ $agency['min_app_secret'] }}" id="secret"/>
<span class='label label-success @if(!$agency['min_app_secret']) hidden @endif ' id="secret_label" >已上传</span>
<input type="button" name="" value="重设" onclick="removeHiddent1()" class="btn btn-danger @if(!$agency['min_app_secret']) hidden @endif" id="secret_btn" />
</div>
</div>--}}
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">支付商户号</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="min_mch_id" class="form-control" value="{{ $agency['min_mch_id'] }}"/>
</div>
</div>
{{--<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">支付密钥</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="min_api_secret" id="api_secret" class="form-control @if($agency['min_api_secret']) hidden @endif" value="{{ $agency['min_api_secret'] }}"/>
<span class='label label-success @if(!$agency['min_api_secret']) hidden @endif ' id="api_secret_label" >已上传</span>
<input type="button" name="" value="重设" onclick="removeHiddent()" class="btn btn-danger @if(!$agency['min_api_secret']) hidden @endif" id="api_secret_btn" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">CERT证书文件</label>
<div class="col-sm-9 col-xs-12">
<input type="hidden" name="min_apiclient_cert" value="{{ $agency['min_apiclient_cert'] }}"/>
<input type="file" name="apiclient_cert" class="form-control"/>
<span class="help-block">
@if (!empty($agency['min_apiclient_cert']))
<span class='label label-success'>已上传</span>
@else
<span class='label label-danger'>未上传</span>
@endif
下载证书 cert.zip 中的 apiclient_cert.pem 文件
</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">KEY密钥文件</label>
<div class="col-sm-9 col-xs-12">
<input type="hidden" name="min_apiclient_key" value="{{ $agency['min_apiclient_key'] }}"/>
<input type="file" name="apiclient_key" class="form-control"/>
<span class="help-block">
@if (!empty($agency['min_apiclient_key']))
<span class='label label-success'>已上传</span>
@else
<span class='label label-danger'>未上传</span>
@endif
下载证书 cert.zip 中的 apiclient_key.pem 文件
</span>
</div>
</div>--}}
</div>
</el-tab-pane>
</el-tabs>
{{--提交按钮--}}
<div class="form-group"></div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-sm-9 col-xs-12">
<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
<input type="button" name="back" onclick='history.back()' value="返回列表" class="btn btn-default" />
<form action="" method='post' class='form-horizontal'>
<div class='panel panel-default'>
<div class='panel-heading'>
<span>修改密码</span>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">区域代理</label>
<div class="col-sm-9 col-xs-12">
{{$real_name}}
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单管理权限(唯一)</label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="order_manage" value="0"
@if(!$order_manage) checked="checked" @endif /> 关闭</label>
<label class="radio-inline">
<input type="radio" name="order_manage" value="1"
@if($order_manage == 1) checked="checked" @endif /> 开启</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">独立分红比例</label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="has_ratio" value="0" @if(!$agency->has_ratio) checked="checked" @endif /> 关闭</label>
<label class="radio-inline">
<input type="radio" name="has_ratio" value="1" @if($agency->has_ratio == 1) checked="checked" @endif/> 开启</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">分红比例</label>
<div class="col-sm-6 col-xs-6">
<div class='input-group'>
<input type='text' name='ratio' class="form-control discounts_value" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''"
value="{{$agency->ratio}}"/>
<div class='input-group-addon waytxt'>%</div>
</div>
</div>
</div>
</form>
</div>
</div>
<script>
$(function () {
// 小程序状态改变
$("[name='min_status']").on('change',function () {
let val = parseInt($(this).val());
val = isNaN(val) ? parseInt(0) : parseInt(val);
if(val === 1) $(".min-config-content").show();
else $(".min-config-content").hide();
});
// 表单验证
$("#editAgent").submit(function(){
// 表单信息处理
let list = $("#editAgent").serializeArray();
let newList = {};
$.each(list,function (k,v) {
let name = v.name.replace(/data\[/g, "").replace(/]/g, "");
newList[name] = v.value;
});
console.log(newList);
// 内容校验列表
let defaultRule = [
{name: 'title', checkType: 'required', errorMsg: '请输入代理名称'},
];
if(newList['min_status'] == 1){
// defaultRule.push({name: 'min_app_id', checkType: 'required', errorMsg: '请输入App ID'});
// defaultRule.push({name: 'min_app_secret', checkType: 'required', errorMsg: '请输入App Secret'});
defaultRule.push({name: 'min_mch_id', checkType: 'required', errorMsg: '请输入支付商户号'});
// defaultRule.push({name: 'min_api_secret', checkType: 'required', errorMsg: '请输入支付密钥'});
}
let result = util.verify(newList,defaultRule);
return result === true;
})
})
// 重新设置支付秘钥
function removeHiddent(){
$("#api_secret").removeClass('hidden')
$("#api_secret").val('')
$("#api_secret_btn").addClass('hidden')
$("#api_secret_label").addClass('hidden')
}
// 重新设置app Secret
function removeHiddent1(){
$("#secret").removeClass('hidden')
$("#secret").val('')
$("#secret_btn").addClass('hidden')
$("#secret_label").addClass('hidden')
}
var vm = new Vue({
el: "#editAgentContent",
delimiters: ['[[', ']]'],
data() {
return {}
},
created () {},
methods: {},
});
</script>
{{--招商专员插件--}}
@if(app('plugins')->isEnabled('invest-people'))
{!! \Yunshop\InvestPeople\services\InvestMemberView::areaDividend($agency->investor_uid) !!}
@endif
@if (!empty($username))
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">账号:</label>
<div class="col-sm-9 col-xs-12">
{{$username}}
</div>
</div>
@else
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">添加账号</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="wq[username]" placeholder="登录账号" class="form-control" value="" />
</div>
</div>
@endif
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">密码</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="wq[password]" class="form-control" value="" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">验证密码</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="wq[password_again]" class="form-control" value="" />
</div>
</div>
<div class="form-group"></div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-sm-9 col-xs-12">
<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
<input type="button" name="back" onclick='history.back()' value="返回列表" class="btn btn-default" />
</div>
</div>
</div>
</form>
</div>
@endsection

View File

@ -1,295 +1,213 @@
@extends('layouts.base')
@section('content')
@section('title', '添加区域代理')
<style>
select{width: 25%; height: 34px;}
#saleravatar img{width: 200px; height: 200px;}
</style>
<div class="w1200 ">
<div class="rightlist">
<div id="AddAgentContent">
{{--表单内容--}}
<form action="" method='post' class='form-horizontal' id="addAgent" enctype="multipart/form-data">
<div class='panel panel-default'>
<el-tabs>
<el-tab-pane label="基本信息">
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">代理名称</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="title" class="form-control"/>
</div>
</div>
<div class="form-group notice">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">微信角色</label>
<div class="col-xs-6">
<input type='hidden' id='uid' name='agent[member_id]' value=""/>
<div class='input-group'>
<input type="text" name="saler" maxlength="30"
value="" id="saler" class="form-control" readonly/>
<div class='input-group-btn'>
<button class="btn btn-default" type="button"
onclick="popwin = $('#modal-module-menus-notice').modal();">选择角色
</button>
<button class="btn btn-danger" type="button"
onclick="$('#uid').val('');$('#saler').val('');$('#saleravatar').hide()">
清除选择
</button>
</div>
</div>
<span id="saleravatar" class='help-block' style="display:none">
<img style="" src=""/></span>
<div id="modal-module-menus-notice" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">
×
</button>
<h3>选择角色</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="input-group">
<input type="text" class="form-control" name="keyword" value=""
id="search-kwd-notice"
placeholder="请输入粉丝昵称/姓名/手机号"/>
<span class='input-group-btn'>
<div class="w1200 ">
<div class=" rightlist ">
<div class="right-titpos">
<ul class="add-snav">
<li class="active"><a href="#">添加区域代理</a></li>
</ul>
</div>
<div class="right-addbox"><!-- 此处是右侧内容新包一层div -->
<div class="panel panel-default">
<div class="panel-body">
<form id="" action="" method="post" class="form-horizontal form">
<div class="info">
<div class="panel-body">
<div class="form-group notice">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">微信角色</label>
<div class="col-xs-6">
<input type='hidden' id='uid' name='agent[member_id]' value=""/>
<div class='input-group'>
<input type="text" name="saler" maxlength="30"
value="" id="saler" class="form-control" readonly/>
<div class='input-group-btn'>
<button class="btn btn-default" type="button"
onclick="popwin = $('#modal-module-menus-notice').modal();">选择角色
</button>
<button class="btn btn-danger" type="button"
onclick="$('#uid').val('');$('#saler').val('');$('#saleravatar').hide()">
清除选择
</button>
</div>
</div>
<span id="saleravatar" class='help-block' style="display:none">
<img style="" src=""/></span>
<div id="modal-module-menus-notice" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">
×
</button>
<h3>选择角色</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="input-group">
<input type="text" class="form-control" name="keyword" value=""
id="search-kwd-notice"
placeholder="请输入粉丝昵称/姓名/手机号"/>
<span class='input-group-btn'>
<button type="button" class="btn btn-default"
onclick="search_members();">搜索
onclick="search_members();">搜索
</button>
</span>
</div>
</div>
<div id="module-menus-notice"></div>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a>
</div>
</div>
</div>
<div id="module-menus-notice"></div>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">独立分红比例</label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="agent[has_ratio]" value="0" checked="checked" /> 关闭</label>
<label class="radio-inline">
<input type="radio" name="agent[has_ratio]" value="1"/> 开启</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">分红比例</label>
<div class="col-sm-6 col-xs-6">
<div class='input-group'>
<input type='text' name='agent[ratio]' class="form-control discounts_value" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''"
value=""/>
<div class='input-group-addon waytxt'>%</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">独立分红比例</label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="agent[has_ratio]" value="0" checked="checked" /> 关闭</label>
<label class="radio-inline">
<input type="radio" name="agent[has_ratio]" value="1"/> 开启</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">分红比例</label>
<div class="col-sm-6 col-xs-6">
<div class='input-group'>
<input type='text' name='agent[ratio]' class="form-control discounts_value" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''"
value=""/>
<div class='input-group-addon waytxt'>%</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">账号</label>
<div class="col-xs-6">
<input type="text" id="username" name="wq[username]" class="form-control" value="{{$wq_data['username']}}" placeholder="请输入账号" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">登录密码</label>
<div class="col-xs-6">
<input type="password" id="password" name="wq[password]" class="form-control" value="" placeholder="请输入密码" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">验证密码</label>
<div class="col-xs-6">
<input type="password" id="password_again" name="wq[password_again]" class="form-control" value="" placeholder="请输入密码" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">真实姓名</label>
<div class="col-xs-6">
<input type="text" name="agent[real_name]" class="form-control"
value=""/>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">联系方式</label>
<div class="col-xs-6">
<input type="text" name="agent[mobile]" class="form-control"
value=""/>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">代理区域</label>
<div class="col-xs-6">
{!! app\common\helpers\AddressHelper::tplLinkedAddress(['agent[province_id]','agent[city_id]','agent[district_id]','agent[street_id]'], [])!!}
</div>
</div>
{{--招商专员插件--}}
@if(app('plugins')->isEnabled('invest-people'))
{!! \Yunshop\InvestPeople\services\InvestMemberView::areaDividend() !!}
@endif
</el-tab-pane>
<el-tab-pane label="微信小程序">
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">小程序状态</label>
<div class="col-sm-9 col-xs-12">
<label class='radio-inline'>
<input type='radio' name='min_status' value='0' checked/>关闭
</label>
<label class='radio-inline'>
<input type='radio' name='min_status' value='1'/>使用中
</label>
</div>
</div>
<div class="min-config-content" style="display: none;">
{{-- <div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">App ID</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="min_app_id" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">App Secret</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="min_app_secret" class="form-control" id="secret"/>
</div>
</div>--}}
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">支付商户号</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="min_mch_id" class="form-control"/>
</div>
</div>
{{-- <div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">支付密钥</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="min_api_secret" id="api_secret" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">CERT证书文件</label>
<div class="col-sm-9 col-xs-12">
<input type="file" name="apiclient_cert" class="form-control"/>
<span class="help-block">
<span class='label label-danger'>未上传</span>
下载证书 cert.zip 中的 apiclient_cert.pem 文件
</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">KEY密钥文件</label>
<div class="col-sm-9 col-xs-12">
<input type="file" name="apiclient_key" class="form-control"/>
<span class="help-block">
<span class='label label-danger'>未上传</span>
下载证书 cert.zip 中的 apiclient_key.pem 文件
</span>
</div>
</div>--}}
</div>
</el-tab-pane>
</el-tabs>
{{--提交按钮--}}
<div class="form-group"></div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-sm-9 col-xs-12">
<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
<input type="button" name="back" onclick='history.back()' value="返回列表" class="btn btn-default" />
</div>
</div>
</div>
</form>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">账号</label>
<div class="col-xs-6">
<input type="text" id="username" name="wq[username]" class="form-control" value="{{$wq_data['username']}}" placeholder="请输入账号" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">登录密码</label>
<div class="col-xs-6">
<input type="password" id="password" name="wq[password]" class="form-control" value="" placeholder="请输入密码" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">验证密码</label>
<div class="col-xs-6">
<input type="password" id="password_again" name="wq[password_again]" class="form-control" value="" placeholder="请输入密码" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">真实姓名</label>
<div class="col-xs-6">
<input type="text" name="agent[real_name]" class="form-control"
value=""/>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">联系方式</label>
<div class="col-xs-6">
<input type="text" name="agent[mobile]" class="form-control"
value=""/>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">代理区域</label>
<div class="col-xs-6">
{!! app\common\helpers\AddressHelper::tplLinkedAddress(['agent[province_id]','agent[city_id]','agent[district_id]','agent[street_id]'], [])!!}
</div>
</div>
{{--招商专员插件--}}
@if(app('plugins')->isEnabled('invest-people'))
{!! \Yunshop\InvestPeople\services\InvestMemberView::areaDividend() !!}
@endif
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-xs-6">
<input type="submit" name="submit" value="提交" class="btn btn-success"
onclick="return formcheck()"/>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="{{static_url('js/area/cascade_street.js')}}"></script>
<script language='javascript'>
cascdeInit();
function search_members() {
if ($('#search-kwd-notice').val() == '') {
Tip.focus('#search-kwd-notice', '请输入关键词');
return;
}
$("#module-menus-notice").html("正在搜索....");
$.get("{!! yzWebUrl('member.member.get-search-member') !!}", {
keyword: $.trim($('#search-kwd-notice').val())
}, function (dat) {
$('#module-menus-notice').html(dat);
});
}
function select_member(o) {
$("#uid").val(o.uid);
$("#saleravatar").show();
$("#saleravatar").find('img').attr('src', o.avatar);
$("#saler").val(o.nickname + "/" + o.realname + "/" + o.mobile);
$("#modal-module-menus-notice .close").click();
}
<script type="text/javascript" src="{{static_url('js/area/cascade_street.js')}}"></script>
<script>
cascdeInit();
function search_members() {
if ($('#search-kwd-notice').val() == '') {
Tip.focus('#search-kwd-notice', '请输入关键词');
return;
}
$("#module-menus-notice").html("正在搜索....");
$.get("{!! yzWebUrl('member.member.get-search-member') !!}", {
keyword: $.trim($('#search-kwd-notice').val())
}, function (dat) {
$('#module-menus-notice').html(dat);
});
}
function select_member(o) {
$("#uid").val(o.uid);
$("#saleravatar").show();
$("#saleravatar").find('img').attr('src', o.avatar);
$("#saler").val(o.nickname + "/" + o.realname + "/" + o.mobile);
$("#modal-module-menus-notice .close").click();
}
function formcheck() {
if($('#saler').val() == ''){
Tip.focus($('#saler'),'请选择微信角色!');
return false;
}
// if($('#username').val() == ''){
// Tip.focus($('#username'),'请输入账号!');
// return false;
// }
// if($('#password').val() == ''){
// Tip.focus($('#password'),'请输入密码!');
// return false;
// }
// if($('#password_again').val() == ''){
// Tip.focus($('#password_again'),'请输入密码!');
// return false;
// }
$(function () {
// 小程序状态改变
$("[name='min_status']").on('change',function () {
let val = parseInt($(this).val());
val = isNaN(val) ? parseInt(0) : parseInt(val);
if(val === 1) $(".min-config-content").show();
else $(".min-config-content").hide();
});
// 表单验证
$("#addAgent").submit(function(){
// 表单信息处理
let list = $("#addAgent").serializeArray();
let newList = {};
$.each(list,function (k,v) {
let name = v.name.replace(/data\[/g, "").replace(/]/g, "");
newList[name] = v.value;
});
console.log(newList);
// 内容校验列表
let defaultRule = [
{name: 'title', checkType: 'required', errorMsg: '请输入代理名称'},
{name: 'saler', checkType: 'required', errorMsg: '请选择微信角色'},
];
if(newList['min_status'] == 1){
// defaultRule.push({name: 'min_app_id', checkType: 'required', errorMsg: '请输入App ID'});
// defaultRule.push({name: 'min_app_secret', checkType: 'required', errorMsg: '请输入App Secret'});
defaultRule.push({name: 'min_mch_id', checkType: 'required', errorMsg: '请输入支付商户号'});
// defaultRule.push({name: 'min_api_secret', checkType: 'required', errorMsg: '请输入支付密钥'});
}
let result = util.verify(newList,defaultRule);
return true;
}
return result === true;
})
})
// 重新设置支付秘钥
function removeHiddent(){
$("#api_secret").removeClass('hidden')
$("#api_secret").val('')
$("#api_secret_btn").addClass('hidden')
$("#api_secret_label").addClass('hidden')
}
// 重新设置app Secret
function removeHiddent1(){
$("#secret").removeClass('hidden')
$("#secret").val('')
$("#secret_btn").addClass('hidden')
$("#secret_label").addClass('hidden')
}
var vm = new Vue({
el: "#AddAgentContent",
delimiters: ['[[', ']]'],
data() {
return {}
},
created () {},
methods: {},
});
</script>
</script>
@endsection

View File

@ -125,6 +125,15 @@
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">分红类型</label>
<div class="col-sm-9 col-xs-12">
<div class='form-control-static'>
<label class='label label-success'>{{$info['settlement_name']}}</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">分红时间</label>

View File

@ -76,7 +76,16 @@
</select>
</div>
@if($appointment)
<div class="form-group col-xs-12 col-sm-3">
<select name='search[extra_plugin_id]' class='form-control'>
<option value='0' @if($search['extra_plugin_id'] == '0') selected @endif>全部</option>
<option value='101' @if($search['extra_plugin_id'] == '101') selected @endif>门店预约分润</option>
</select>
</div>
@endif
<div class="form-group col-xs-12 col-sm-8">
<div class="col-sm-3">

View File

@ -2,45 +2,10 @@
@section('content')
@section('title', trans('区域代理列表'))
<style>
.user-info{
min-height: 80px;
min-width: 150px;
width: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
}
.user-info .user-avatar{
height: 50px;
width: 50px;
margin-right: 10px;
}
.user-info .user-avatar .avatar{
width: 100% !important;
height: 100% !important;
border-radius: 50%;
}
.user-info .user-nickname{
font-size: 14px;
text-align: left;
height: 50px;
width: calc(100% - 50px - 10px);
line-height: 25px;
}
#info-list a{
color: #000000!important;
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
-webkit-user-select: none;
-moz-user-focus: none;
-moz-user-select: none;
border: none!important;
}
</style>
<div class="w1200 ">
<div class="rightlist">
<div class=" rightlist ">
<div class="right-titpos">
<ul class="add-snav">
{{--<li class="active"><a href="#">区域代理</a></li>--}}
@ -132,61 +97,91 @@
</form>
<div class="clearfix">
<div class='panel panel-default' id="info-list">
<div class='panel-body table-responsive'>
<div class='panel panel-default'>
<div class='panel-body table-responsive'>
<table class="table table-hover" style="overflow:visible;">
<thead>
<tr>
<th style='text-align:center;width:50px;'>ID</th>
<th style='text-align:center;width:120px;'>代理名称</th>
<th style='text-align:center;width:180px;'>会员信息</th>
<th style='text-align:center;width:150px;'>成为代理时间</th>
<th style='text-align:center;width:200px;'>申请区域</th>
<th style='text-align:center'>申请等级</th>
<th style='text-align:center'>消费总额</th>
<th style='text-align:center'>分红比例</th>
<th style='text-align:center'>累计结算金额</th>
<th style='text-align:center'>已结算分红佣金</th>
<th style='text-align:center'>未结算分红佣金</th>
<th style='text-align:center'>操作</th>
<th style='width:8%;'>ID</th>
<th style='width:10%;'>会员Id</th>
<th style='width:10%;'>会员</th>
<th style='width:10%;'>姓名</br>手机</th>
<th style='width:12%;'>成为代理时间</th>
<th style='width:15%;'>申请区域</th>
<th style='width:10%;'>申请等级</th>
<th style='width:10%;'>区域消费总额</th>
<th style='width:10%;'>分红比例</th>
<th style='width:10%;'>累计结算金额</th>
<th style='width:10%;'>已结算分红佣金</th>
<th style='width:10%;'>未结算分红佣金</th>
<th style='width:10%;'>操作</th>
</tr>
</thead>
<tbody>
@foreach($list['data'] as $row)
<tr>
<td style='text-align:center'>{{$row['id']}}</td>
<td style='text-align:center'>{{$row['title']}}</td>
<td style="text-align:center">
<a target="_blank" href="{{yzWebUrl('member.member.detail',['id'=>$row['has_one_member']['uid']])}}">
<div class="user-info" title="{{ $row['has_one_member']['nickname'] }}">
<div class="user-avatar">
<img class="avatar" src="{{ $row['has_one_member']['avatar_image'] }}" />
</div>
<div class="user-nickname">
{{ $row['has_one_member']['nickname'] }} <br />
ID{{ $row['has_one_member']['uid'] }}
</div>
</div>
</a>
<td>{{$row['id']}}</td>
<td>{{$row['has_one_member']['uid']}}</td>
<td>
<img src="{{tomedia($row['has_one_member']['avatar'])}}"
style="width: 30px; height: 30px;border:1px solid #ccc;padding:1px;">
</br>
{{$row['has_one_member']['nickname']}}
</td>
<td style="text-align:center">{{date("Y-m-d H:i",$row['agent_at'])}}</td>
<td style="text-align:center" class='tdedit'>
<span class='fa-edit-item' style='cursor:pointer' data-agentid="{{$row['id']}}">
<span class="title">
@if($row['province_name']){{$row['province_name']}}@endif
@if($row['city_name']){{$row['city_name']}}@endif
@if($row['district_name']){{$row['district_name']}}@endif
@if($row['street_name']){{$row['street_name']}}@endif
</span>
<i class='fa fa-pencil' style="display:none"></i>
</span>
<td>
{{$row['real_name']}} </br>
{{$row['has_one_profile']['mobile']}}
</td>
<td>
{{date("Y-m-d H:i",$row['agent_at'])}}
</td>
<td title="" class='tdedit' width="26%">
<span class=' fa-edit-item' style='cursor:pointer'
data-agentid="{{$row['id']}}">
<span class="title">
@if($row['province_name'])
{{$row['province_name']}}
@endif
@if($row['city_name'])
-{{$row['city_name']}}
@endif
@if($row['district_name'])
-{{$row['district_name']}}
@endif
@if($row['street_name'])
-{{$row['street_name']}}
@endif
</span>
<i class='fa fa-pencil' style="display:none"></i>
</span>
</td>
<td>
{{$row['level_name']}}
</td>
<td>
{{$row['has_one_dividend']['total_order_amount'] ?: '0.00'}}
</td>
<td>
{{$row['rate']}}%
{{--分红比例--}}
</td>
<td>
{{$row['has_one_dividend']['total_amount'] ?: '0.00'}}
</td>
<td>
{{$row['has_one_dividend']['settle'] ?: '0.00'}}
</td>
<td>
{{$row['has_one_dividend']['unsettled'] ?: '0.00'}}
</td>
<td style='text-align:center'>{{$row['level_name']}}</td>
<td style='text-align:center'>{{$row['has_one_dividend']['total_order_amount'] ?: '0.00'}}</td>
<td style='text-align:center'>{{$row['ratio']}}%</td>
<td style='text-align:center'>{{$row['has_one_dividend']['total_amount'] ?: '0.00'}}</td>
<td style='text-align:center'>{{$row['has_one_dividend']['settle'] ?: '0.00'}}</td>
<td style='text-align:center'>{{$row['has_one_dividend']['unsettled'] ?: '0.00'}}</td>
<td style="position:relative; overflow:visible;">
<a href="{{yzWebUrl('plugin.area-dividend.admin.agent.daletedAgency',['id'=>$row['id']])}}"
onclick="return confirm('是否确认删除?');
@ -197,6 +192,7 @@
class="btn btn-default btn-sm" title="编辑账号"><i class="fa fa-edit"></i></a>
</td>
</tr>
@endforeach
</tbody>
</table>
@ -305,4 +301,4 @@
});
});
</script>
@endsection
@endsection

View File

@ -33,6 +33,8 @@
<div class="tab-pane" id="tab_agreement">@include('Yunshop\AreaDividend::admin.tpl.agreement')</div>
<div class="tab-pane" id="tab_rangecommission">@include('Yunshop\AreaDividend::admin.tpl.range_commission')</div>
<div class="tab-pane" id="tab_apply_background">@include('Yunshop\AreaDividend::admin.tpl.apply_background')</div>
@if($appointment) <div class="tab-pane" id="tab_appointment">@include('Yunshop\AreaDividend::admin.tpl.appointment')</div> @endif
<div class="tab-pane" id="tab_update_condition">@include('Yunshop\AreaDividend::admin.tpl.upgrade_condition')</div>
</div>
<div class="form-group">
@ -42,14 +44,14 @@
onclick="return formcheck()"/>
</div>
</div>
</div>
</div>
</form>
</section>
</div>
</div>
<script language='javascript'>

View File

@ -12,5 +12,7 @@
<li><a href="#tab_agreement">申请协议</a></li>
<li><a href="#tab_rangecommission">分销极差</a></li>
<li><a href="#tab_apply_background">申请页面背景图</a></li>
@if($appointment) <li><a href="#tab_appointment">门店预约</a></li> @endif
<li><a href="#tab_update_condition">升级条件</a></li>
</ul>
</div>
</div>

View File

@ -0,0 +1,16 @@
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单计算方式</label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="setdata[appointment_basic]" value="0"
@if($set['appointment_basic'] == 0) checked="checked" @endif /> 固定金额</label>
<label class="radio-inline">
<input type="radio" name="setdata[appointment_basic]" value="1"
@if($set['appointment_basic'] == 1) checked="checked" @endif /> 订单实付金额</label>
</div>
</div>

View File

@ -0,0 +1,17 @@
<div style='max-height:500px;overflow:auto;min-width:850px;'>
<table class="table table-hover" style="min-width:850px;">
<tbody>
@foreach($goods as $row)
<tr>
<td><img src='{{tomedia($row['thumb'])}}' style='width:30px;height:30px;padding1px;border:1px solid #ccc' /> {{$row['title']}}</td>
<td style="width:80px;"><a href="javascript:;" onclick='select_good_two({{json_encode($row)}})'>选择</a></td>
</tr>
@endforeach
@if (count($goods) <= 0)
<tr>
<td colspan='4' align='center'>未找到商品</td>
</tr>
@endif
</tbody>
</table>
</div>

View File

@ -51,6 +51,26 @@
</div>
</div>
</div>
<div class='panel-body'>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">满足升级条件后通知</label>
<div class="col-sm-8 col-xs-12">
<select name='setdata[upgrade][template_id]' class='form-control diy-notice'>
<option @if(\app\common\models\notice\MessageTemp::getIsDefaultById($upgrade['template_id'])) value="{{$upgrade['template_id']}}"
selected @else value="" @endif>
默认消息模板
</option>
@foreach ($temp_list as $item)
<option value="{{$item['id']}}"
@if($upgrade['template_id'] == $item['id'])
selected
@endif>{{$item['title']}}</option>
@endforeach
</select>
</div>
</div>
</div>
<script>
function message_default(name) {
var id = "#" + name;
@ -93,4 +113,4 @@
}, 2000
);
}
</script>
</script>

View File

@ -1,12 +1,33 @@
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">算方式</label>
<label class="col-xs-12 col-sm-3 col-md-2 control-label">佣金计算方式</label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="setdata[culate_method]" value="0"
@if($set['culate_method'] == 0) checked="checked" @endif /> 订单价格:(不包括运费及抵扣金额)</label>
@if($set['culate_method'] == 0) checked="checked" @endif /> 实付金额:(不包括运费及抵扣金额)</label>
<label class="radio-inline">
<input type="radio" name="setdata[culate_method]" value="1"
@if($set['culate_method'] == 1) checked="checked" @endif /> 利润:(订单最终价格-成本负数取0)</label>
<label class="radio-inline">
<input type="radio" name="setdata[culate_method]" value="2"
@if($set['culate_method'] == 2) checked="checked" @endif /> 商品现价:(订单商品现价负数取0)</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">佣金类型</label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="setdata[settlement_option]" value="0"
@if($set['settlement_option'] == 0) checked="checked" @endif /> 收入提现</label>
<label class="radio-inline">
<input type="radio" name="setdata[settlement_option]" value="1"
@if($set['settlement_option'] == 1) checked="checked" @endif /> 转入积分</label>
<label class="radio-inline">
<input type="radio" name="setdata[settlement_option]" value="2"
@if($set['settlement_option'] == 2) checked="checked" @endif /> 转入余额</label>
<label class="radio-inline">
<input type="radio" name="setdata[settlement_option]" value="3"
@if($set['settlement_option'] == 3) checked="checked" @endif /> 直接结算</label>
</div>
</div>
@ -79,8 +100,9 @@
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单计算方式</label>
<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单计算方式(赠送积分)</label>
<div class="col-sm-6 col-xs-6">
<div class='input-group'>
<label class="radio-inline">
@ -91,10 +113,13 @@
<input type="radio" name="setdata[calculate_type]" value="1" @if($set['calculate_type'] == '1') checked @endif />
利润
</label>
<label class="radio-inline">
<input type="radio" name="setdata[calculate_type]" value="2" @if($set['calculate_type'] == '2') checked @endif />
现价
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">赠送积分计算方式</label>
<div class="col-sm-6 col-xs-6">
@ -109,6 +134,7 @@
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-sm-6 col-xs-6">

View File

@ -0,0 +1,165 @@
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">区域代理升级条件</label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="setdata[upgrade][is_open]" value="1"
@if($upgrade['is_open'] == 1) checked="checked" @endif /> 开启</label>
<label class="radio-inline">
<input type="radio" name="setdata[upgrade][is_open]" value="0"
@if($upgrade['is_open'] == 0) checked="checked" @endif /> 关闭</label>
<span style="" class='help-block'>
开启后后会员需要满足一下任意一个条件才可以申请区域代理
</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">升级条件</label>
<div class="col-sm-9 col-xs-12">
<div style="width: 100%;display: -webkit-box">
<div class="control-label" style="margin-right: 5px;">直推</div>
<input type="text" style="width: 10%" class="form-control" name="setdata[upgrade][push_num]"
value="{{$upgrade['push_num']}}">
<div class="control-label" style="margin-left: 5px;margin-right: 5px;"></div>
<select class="form-control" style="width: 10%" name="setdata[upgrade][push_level]">
<option value="0">请选择</option>
@foreach($team_dividend_level_list as $level)
<option
@if($upgrade['push_level'] == $level->id)
selected="selected"
@endif
value="{{$level->id}}">{{$level->level_name}}</option>
@endforeach
</select>
<div style="padding-left: 7px">
<label class="radio-inline"><input type="radio" name="setdata[upgrade][level_type]"
@if($upgrade['level_type'] == 1) checked="checked" @endif
value="1"> 本级</label>
</div>
<div style="padding-left: 7px">
<label class="radio-inline">
<input type="radio" name="setdata[upgrade][level_type]" value="2"
@if($upgrade['level_type'] == 2) checked="checked" @endif
>
以上</label>
</div>
<div class="control-label" style="margin-left: 5px;margin-right: 5px">并且团队累计消费(已支付)达到</div>
<input type="text" style="width: 10%" class="form-control" name="setdata[upgrade][price]"
value="{{$upgrade['price']}}">
<div class="control-label" style="margin-left: 5px;margin-right: 5px;"></div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-sm-9 col-xs-12">
<div>购买指定商品之一</div>
<div style="display: flex;">
<div class="input-group multi-img-details" id='goods_id'>
@foreach ($goods as $goods_id => $good)
<div class="multi-item saler-item" style="height: 100px;width: 100px ; margin-bottom: 70px;" openid="{{ $good['id'] }}">
<img class="img-responsive img-thumbnail" src='{{ tomedia($good['thumb']) }}'
onerror="this.src='{{static_url('resource/images/nopic.jpg')}}'; this.title='图片未找到.'">
<div class='img-nickname' style="max-height: 58px;overflow: hidden">{{ $good['title'] }}</div>
<input type="hidden" value="{{ $good['id'] }}"
name="setdata[upgrade][goods_ids][{{ $good['id'] }}]" class="opt-multi-item">
<em onclick="remove_member(this)" class="close">×</em>
</div>
@endforeach
</div>
<div class="choose-goods" style="width: 100px;height: 100px;border: 1px dotted #bfbbbb; display: flex;justify-content: center;align-items: center;flex-direction: column;margin: 10px 0; " onclick="$('#modal-goods').modal()">
<i class="el-icon-plus" style="font-size: 22px;color: #a7a2a2;"></i>
<button type="button" style="margin-top: 10px;color: #a7a2a2;border: none;background-color: white;">选择商品</button>
</div>
</div>
<div id="modal-goods" class="modal fade" tabindex="-1">
<div class="modal-dialog" style='width: 920px;'>
<div class="modal-content">
<div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>选择商品</h3></div>
<div class="modal-body" >
<div class="row">
<div class="input-group">
<input type="text" class="form-control" name="keyword" value="" id="search-kwd-goods-dividend" placeholder="请输入商品名称" />
<span class='input-group-btn'><button type="button" class="btn btn-default" onclick="search_goods_two();">搜索</button></span>
</div>
</div>
<div id="module-menus-goods-two" style="padding-top:5px;"></div>
</div>
<div class="modal-footer"><a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a></div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-sm-9 col-xs-12">
<label class="radio-inline">
<input type="radio" name="setdata[upgrade][event_type]" value="1"
@if($upgrade['event_type'] == 1) checked="checked" @endif /> 支付后</label>
<label class="radio-inline">
<input type="radio" name="setdata[upgrade][event_type]" value="2"
@if($upgrade['event_type'] == 2) checked="checked" @endif /> 完成后</label>
<span style="" class='help-block'>
备注:支付后/完成后仅针对购买指定商品之一
</span>
</div>
</div>
<script>
function search_goods_two() {
if( $.trim($('#search-kwd-goods-dividend').val())==''){
Tip.focus('#search-kwd-goods-dividend','请输入关键词');
return;
}
$("#module-goods").html("正在搜索....")
$.get('{!! yzWebUrl('plugin.area-dividend.admin.area-dividend-set.searchGoods') !!}', {
keyword: $.trim($('#search-kwd-goods-dividend').val())
}, function(dat){
$('#module-menus-goods-two').html(dat);
});
}
function select_good_two(op) {
let info = true
if($('.opt-multi-item').length > 0) {
$('.opt-multi-item').map((index) => {
if($('.opt-multi-item').eq(index)[0].name.replace(/[^0-9]/g,"")*1 == op.id) {
info = false;
}
})
}
if(info) {
var html = '<div class="multi-item" style="height: 100px;width: 100px ; margin-bottom: 70px;" openid="' + op.id + '">';
html += '<img class="img-responsive img-thumbnail" src="' + op.thumb + '" onerror="this.src=\'{{static_url('resource/images/nopic.jpg')}}\'; this.title=\'图片未找到.\'">';
html += '<div class="img-nickname" style="max-height: 58px;overflow: hidden">' + op.title + '</div>';
html += '<input type="hidden" value="' + op.id + '" name="setdata[upgrade][goods_ids][' + op.id + ']" class="opt-multi-item">';
html += '<em onclick="remove_member(this)" class="close">×</em>';
html += '</div>';
$("#goods_id").append(html);
refresh_members();
}
}
function refresh_members() {
var nickname = "";
$('.multi-item').each(function () {
nickname += " " + $(this).find('.img-nickname').html() + "; ";
});
$('#many_good').val(nickname);
}
function remove_member(obj) {
$(obj).parent().remove();
refresh_members();
}
</script>

View File

@ -28,7 +28,16 @@
</select>
</div>
@if($appointment)
<div class="form-group col-xs-12 col-sm-3">
<select name='search[extra_plugin_id]' class='form-control'>
<option value='0' @if($search['extra_plugin_id'] == '0') selected @endif>全部</option>
<option value='101' @if($search['extra_plugin_id'] == '101') selected @endif>门店预约分润</option>
</select>
</div>
@endif
<div class="form-group col-xs-12 col-sm-8">
<div class="col-sm-3">
<label class='radio-inline'>

View File

@ -0,0 +1,281 @@
@extends('layouts.base')
@section('title', '赠送积分明细')
@section('content')
<link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}"/>
<link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-ohter.css')}}"/>
<style>
.edit-i {
display: none;
}
.el-table_1_column_2:hover .edit-i {
font-weight: 900;
padding: 0;
margin: 0;
display: inline-block;
}
.el-tabs__item, .is-top {
font-size: 16px
}
.el-tabs__active-bar {
height: 3px;
}
/*.el-select .el-input {*/
/* width: 120px;*/
/*}*/
.input-with-select .el-input-group__prepend {
background-color: #fff;
}
</style>
<div class="all">
<div id="app" v-cloak>
<div class="vue-head">
<div class="vue-search">
<el-form :inline="true" :model="search_form" class="demo-form-inline">
<el-form-item>
<el-input placeholder="订单号" v-model="search_form.order_sn"></el-input>
</el-form-item>
{{-- <el-form-item>--}}
{{-- <el-input placeholder="消费券码" v-model="search_form.coupon_sn"></el-input>--}}
{{-- </el-form-item>--}}
<el-form-item>
<el-select clearable v-model="search_form.is_count">
<el-option label="不统计" value="0"></el-option>
<el-option label="统计" value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select clearable v-model="search_form.time_search" placeholder="搜索时间类型">
<el-option
v-for="(item,index) in ts_arr"
:key="index"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<div class="block">
<span class="demonstration"></span>
<el-date-picker
v-model="search_form.time_arr"
type="datetimerange"
:picker-options="pickerOptions"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="timestamp"
align="right">
</el-date-picker>
</div>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button style="margin-bottom:10px;margin-left:0;" type="primary"
@click="changeForm()">搜索
</el-button>
<el-button style="margin-bottom:10px;margin-left:0;" type=""
@click="export1()">导出
</el-button>
</el-button-group>
</el-form-item>
</el-row>
</el-form>
</div>
</div>
<div class="vue-main">
<div class="vue-main-form">
<div class="vue-main-title" style="margin-top:-10px">
<div class="title"><span
style="width: 4px;height: 18px;background-color: #29ba9c;margin-right:15px;display:inline-block;"></span><b>区域分红</b>
</div>
<div class="tip" style="margin-left: 10px;margin-top:5px;display:inline-block;">
<b>总数:[[total]]</b>&nbsp;
<template v-if="is_count==1">
<b>&nbsp;&nbsp;积分:[[sum_point]]</b>
</template>
</div>
</div>
</div>
<div style="margin-bottom:20px">
</div>
<el-table v-if="show_table" :data="list" style="width: 100%;margin-bottom: 20px;"
:fit="true"
default-expand-all
row-key="id"
ref="table">
<el-table-column prop="id" label="ID" align="center">
</el-table-column>
<el-table-column prop="created_at" label="赠送时间" align="center">
</el-table-column>
<el-table-column label="订单号" align="center">
<template slot-scope="scope">
[[scope.row.has_one_order.order_sn]]
</template>
</el-table-column>
<el-table-column prop="point" label="赠送积分" align="center">
</el-table-column>
</el-table>
</div>
<div class="vue-page" v-if="total > 0">
<el-row>
<el-col align="right">
<el-pagination layout="prev, pager, next,jumper" @current-change="getData"
:total="total"
:page-size="per_page" :current-page="current_page" background
></el-pagination>
</el-col>
</el-row>
</div>
</div>
<!-- 分页 -->
</div>
</div>
<script>
var app = new Vue({
el: "#app",
delimiters: ['[[', ']]'],
name: 'test',
data() {
{{--let store_id = '{!!($_GET['store_id']) !!}' ? '{!!($_GET['store_id']) !!}' : '0';--}}
return {
tabActiveName: 'third',
show_table: false,
sum_point:0,
is_count:0,
list: [],
total: 1,
per_page: 1,
current_page: 1,
search_form: {
order_sn: '',
is_count: '0',
time_search: '',
time_arr: [new Date().getTime(), new Date().getTime()],
},
search_data: {},
ts_arr: [
{value: 'created_at', label: '赠送时间'},
],
pickerOptions: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
}]
},
}
},
created() {
},
mounted() {
this.changeForm();
},
methods: {
export1(){
let json = JSON.parse(JSON.stringify(this.search_data));
let newTime = JSON.parse(JSON.stringify(this.search_data.time_arr));
newTime[0] = newTime !== null ? newTime[0] / 1000 : '';
newTime[1] = newTime !== null ? newTime[1] / 1000 : '';
json.time_arr = newTime;
let search_data = JSON.stringify(json);
let url = `{!! yzWebFullUrl('plugin.area-dividend.area.point-log.export') !!}`;
url = url + '&search_data=' + search_data;
window.open(url);
},
{{--tabChange() {--}}
{{-- var url = '';--}}
{{-- url = '{!! yzWebFullUrl('plugin.coupon-store.store.income.areaIndex') !!}';--}}
{{-- window.location.href = url;--}}
{{--},--}}
{{--memberDetail: function (id) {--}}
{{-- window.open("{!! yzWebFullUrl('member.member.detail') !!}" + '&id=' + id);--}}
{{--},--}}
{{--orderDetail: function (id) {--}}
{{-- window.open("{!! yzWebFullUrl(' plugin.coupon-store.store.detail.vue-index') !!}" + '&id=' + id + '&order_id=' + id);--}}
{{--},--}}
search: function () {
this.show_table = false;
this.$http.post('{!! yzWebFullUrl('plugin.area-dividend.area.point-log.index') !!}', {
'page': this.current_page,
'is_json': 1,
'search_data': this.search_data,
}).then(function (response) {
console.log(response);
if (response.data.result) {
let this_data = response.data.data.list;
this.current_page = this_data.current_page;
this.list = this_data.data;
this.total = this_data.total;
this.per_page = this_data.per_page;
this.sum_point = response.data.data.sum_point;
this.is_count = response.data.data.is_count;
// this.$message({message: response.data.msg,type: 'success'});
// location.reload();
this.show_table = true;
} else {
this.$message({message: response.data.msg, type: 'error'});
this.show_table = true;
}
}, function (response) {
this.$message({message: response.data.msg, type: 'error'});
this.show_table = true;
})
},
getData: function (val) {
this.current_page = val;
this.search();
},
changeForm: function () {
this.search_data = this.search_form;
this.current_page = 1;
this.search();
}
},
})
</script>
@endsection