From ac649c026d2453a09a320d964254aa03e4a9e294 Mon Sep 17 00:00:00 2001 From: liqianjin <949671634@qq.com> Date: Mon, 20 Feb 2023 16:36:56 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=AF=8F=E6=97=A5=E7=BB=93=E7=AE=97=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addon/fenxiao/api/controller/Order.php | 46 ++- addon/fenxiao/config/event.php | 5 +- addon/fenxiao/event/AutoAreaMonthlyReward.php | 23 ++ addon/fenxiao/model/Ageen.php | 125 ++++++++ addon/fenxiao/model/AgeenLevel.php | 140 +++++++++ addon/fenxiao/model/FenxiaoOrder.php | 64 ++-- addon/fenxiao/shop/controller/Agentlevel.php | 97 ++++++ addon/fenxiao/shop/controller/Area.php | 160 ++++++++++ addon/fenxiao/shop/controller/Fenxiao.php | 29 +- addon/fenxiao/shop/controller/Goods.php | 2 +- addon/fenxiao/shop/controller/Order.php | 2 +- addon/fenxiao/shop/view/agentlevel/add.html | 135 +++++++++ addon/fenxiao/shop/view/agentlevel/edit.html | 113 +++++++ addon/fenxiao/shop/view/agentlevel/lists.html | 212 +++++++++++++ addon/fenxiao/shop/view/area/add.html | 207 +++++++++++++ addon/fenxiao/shop/view/area/lists.html | 285 ++++++++++++++++++ addon/fenxiao/shop/view/fenxiao/lists.html | 123 +++++++- .../pointexchange/shop/view/exchange/add.html | 6 +- .../shop/view/exchange/edit.html | 6 +- addon/weapp/config/menu_shop.php | 2 +- addon/wechat/config/menu_shop.php | 2 +- addon/wechatpay/config/menu_shop.php | 2 +- app/api/controller/Addon.php | 4 +- app/model/member/Member.php | 2 + app/model/member/MemberAccount.php | 3 + app/model/member/Register.php | 3 + app/model/order/OrderCommon.php | 1 + config/menu_shop.php | 82 ++++- 28 files changed, 1816 insertions(+), 65 deletions(-) create mode 100644 addon/fenxiao/event/AutoAreaMonthlyReward.php create mode 100644 addon/fenxiao/model/Ageen.php create mode 100644 addon/fenxiao/model/AgeenLevel.php create mode 100644 addon/fenxiao/shop/controller/Agentlevel.php create mode 100644 addon/fenxiao/shop/controller/Area.php create mode 100644 addon/fenxiao/shop/view/agentlevel/add.html create mode 100644 addon/fenxiao/shop/view/agentlevel/edit.html create mode 100644 addon/fenxiao/shop/view/agentlevel/lists.html create mode 100644 addon/fenxiao/shop/view/area/add.html create mode 100644 addon/fenxiao/shop/view/area/lists.html diff --git a/addon/fenxiao/api/controller/Order.php b/addon/fenxiao/api/controller/Order.php index adaa58dc..23280b4f 100644 --- a/addon/fenxiao/api/controller/Order.php +++ b/addon/fenxiao/api/controller/Order.php @@ -16,6 +16,7 @@ use addon\fenxiao\model\FenxiaoOrder as FenxiaoOrderModel; use addon\fenxiao\model\Fenxiao; use think\Exception; use think\facade\Log; +use app\model\order\Order as BaseOrder; /** * 分销订单 @@ -118,14 +119,45 @@ class Order extends BaseApi return $this->response(event("DaySettlement")); } - public function testOrderPay(){ - try{ - event("OrderPay",model('order')->getInfo([['order_id','=',220]])); - Log::debug('11111111111111111111111111111'); - }catch(Exception $exception){ - $this->response($exception->getMessage()); - } + public function testAreaMonthlyReward(){ + event("AreaMonthlyReward"); return $this->response([]); } + public function testPointexchangeOrderPayNotify(){ + return $this->response(event("PointexchangeOrderPayNotify",['out_trade_no'=>'16768593884624691000'])); + + $order = new BaseOrder; + + // return $this->response( $order->addOrderLog(["id" => 265, + // "site_id" => 1, + // "out_trade_no" => "16768593884624691000", + // "pay_type" => "POINT", + // "trade_no" => "", + // "pay_no" => "", + // "pay_body" => "测试商品 【商品】", + // "pay_detail" => "测试商品 【商品】", + // "pay_money" => "0.00", + // "pay_addon" => "", + // "pay_voucher" => "", + // "pay_status" => 2, + // "return_url" => "", + // "event" => "PointexchangeOrderPayNotify", + // "mch_info" => "", + // "create_time" => 1676859389, + // "pay_time" => 1676859389, + // "balance" => "0.00", + // "balance_money" => "0.00", + // "member_id" => 0, + // "pay_json" => "", + // "order_id" => 262, + // "action" => "商家对订单进行了线下支付", + // "order_status" => 1, + // "order_status_name" => "待发货"])); + } + + public function testPayType(){ + return $this->response(event('PayType', [])); + } + } \ No newline at end of file diff --git a/addon/fenxiao/config/event.php b/addon/fenxiao/config/event.php index aab5124f..41f91393 100644 --- a/addon/fenxiao/config/event.php +++ b/addon/fenxiao/config/event.php @@ -84,7 +84,10 @@ return [ //每日结算 'DaySettlement' => [ 'addon\fenxiao\event\DaySettlement', - ] + ], + 'AreaMonthlyReward'=>[ //区域代理月结 + 'addon\fenxiao\event\AutoAreaMonthlyReward', //区域代理月结 + ], ], 'subscribe' => [ diff --git a/addon/fenxiao/event/AutoAreaMonthlyReward.php b/addon/fenxiao/event/AutoAreaMonthlyReward.php new file mode 100644 index 00000000..70cfed17 --- /dev/null +++ b/addon/fenxiao/event/AutoAreaMonthlyReward.php @@ -0,0 +1,23 @@ +areaMonthlySettlement(); + return $res; + } +} \ No newline at end of file diff --git a/addon/fenxiao/model/Ageen.php b/addon/fenxiao/model/Ageen.php new file mode 100644 index 00000000..4238b03c --- /dev/null +++ b/addon/fenxiao/model/Ageen.php @@ -0,0 +1,125 @@ +add($data); + return $this->success($res); + } + + /** + * 编辑分销等级 + * @param $data + * @param array $condition + * @return array + */ + public function edit($data, $condition = []) + { + $data['update_time'] = time(); + $res = model('fenxiao_agent')->update($data, $condition); + return $this->success($res); + } + + /** + * 删除分销等级 + * @param array $condition + * @return array + */ + public function delete($id) + { + $fenxiao_model = new Fenxiao(); + $res = model('fenxiao_agent')->delete([['id', '=', $id]]); + return $this->success($res); + } + + /** + * 获取分销等级信息 + * @param array $condition + * @param string $field + * @return array + */ + public function getInfo($condition = [], $field = '*') + { + $res = model('fenxiao_agent')->getInfo($condition, $field); + return $this->success($res); + } + + /** + * @param array $condition + * @param string $field + * @return array + */ + public function getColumn($condition = [], $field = 'level_id') + { + $list = model('fenxiao_agent')->getColumn($condition, $field); + return $this->success($list); + } + + /** + * 获取分销商等级列表 + * @param array $condition + * @param string $field + * @param string $order + * @param string $limit + */ + public function getList($condition = [], $field = '*', $order = '', $limit = null) + { + $list = model('fenxiao_agent')->getList($condition, $field, $order, '', '', '', $limit); + return $this->success($list); + } + + /** + * 获取分销商等级分页列表 + * @param array $condition + * @param number $page + * @param string $page_size + * @param string $order + * @param string $field + */ + public function getPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*') + { + $condition[] = [ 'f.is_delete', '=', 0 ]; + $field = 'f.*,pf.fenxiao_name as parent_name,m.username,m.nickname,m.mobile as member_mobile,m.headimg,a.agent_level_id,a.agent_level_name,a.id'; + $alias = 'a'; + $join = [ + [ + 'fenxiao f', + 'a.fenxiao_id = f.fenxiao_id', + 'left' + ], + [ + 'fenxiao pf', + 'pf.fenxiao_id = f.parent', + 'left' + ], + [ + 'member m', + 'm.member_id = f.member_id', + 'left' + ], + ]; + $list = model('fenxiao_agent')->pageList($condition, $field, $order, $page, $page_size, $alias, $join); + // $list = model('fenxiao_agent')->pageList($condition, $field, $order, $page, $page_size); + return $this->success($list); + } +} \ No newline at end of file diff --git a/addon/fenxiao/model/AgeenLevel.php b/addon/fenxiao/model/AgeenLevel.php new file mode 100644 index 00000000..a3a50a78 --- /dev/null +++ b/addon/fenxiao/model/AgeenLevel.php @@ -0,0 +1,140 @@ +add($data); + return $this->success($res); + } + + /** + * 编辑分销等级 + * @param $data + * @param array $condition + * @return array + */ + public function editLevel($data, $condition = []) + { + $data['update_time'] = time(); + $res = model('fenxiao_agent_level')->update($data, $condition); + if ($res) { + if (isset($data['level_name']) && $data['level_name'] != '') { + $condition[0][0] = 'agent_level_id'; + model('fenxiao')->update(['agent_level_name' => $data['level_name']], $condition); + } + } + return $this->success($res); + } + + /** + * 删除分销等级 + * @param array $condition + * @return array + */ + public function deleteLevel($level_id, $site_id) + { + $fenxiao_model = new Fenxiao(); + $fenxiao_list = $fenxiao_model->getFenxiaoList([['agent_level_id', '=', $level_id]], 'fenxiao_id'); + if (empty($fenxiao_list['data'])) { + $res = model('fenxiao_agent_level')->delete([['level_id', '=', $level_id], ['site_id', '=', $site_id]]); + return $this->success($res); + } else { + return $this->error('', '该分销等级存在其他分销商,无法删除'); + } + } + + /** + * 获取分销等级信息 + * @param array $condition + * @param string $field + * @return array + */ + public function getLevelInfo($condition = [], $field = '*') + { + $res = model('fenxiao_agent_level')->getInfo($condition, $field); + return $this->success($res); + } + + /** + * @param array $condition + * @param string $field + * @return array + */ + public function getLevelColumn($condition = [], $field = 'level_id') + { + $list = model('fenxiao_agent_level')->getColumn($condition, $field); + return $this->success($list); + } + + /** + * 获取分销商等级列表 + * @param array $condition + * @param string $field + * @param string $order + * @param string $limit + */ + public function getLevelList($condition = [], $field = '*', $order = '', $limit = null) + { + $list = model('fenxiao_agent_level')->getList($condition, $field, $order, '', '', '', $limit); + return $this->success($list); + } + + /** + * 获取分销商等级分页列表 + * @param array $condition + * @param number $page + * @param string $page_size + * @param string $order + * @param string $field + */ + public function getLevelPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*') + { + $list = model('fenxiao_agent_level')->pageList($condition, $field, $order, $page, $page_size); + return $this->success($list); + } + + /** + * 获取最低的分销商等级 + * @param array $condition + * @param string $field + * @return array + */ + public function getMinLevel($condition = [], $field = '*') + { + $info = model('fenxiao_agent_level')->getFirstData($condition, $field, 'level_num asc,one_rate asc'); + return $this->success($info); + } + + /** + * 某项排序的第一个 + * @param $condition + * @param $field + * @param $order + * @return array + */ + public function getLevelFirst($condition, $field, $order) + { + $first = model('fenxiao_agent_level')->getFirstData($condition, $field, $order); + return $this->success($first); + } +} \ No newline at end of file diff --git a/addon/fenxiao/model/FenxiaoOrder.php b/addon/fenxiao/model/FenxiaoOrder.php index bcb38347..443bb1a8 100644 --- a/addon/fenxiao/model/FenxiaoOrder.php +++ b/addon/fenxiao/model/FenxiaoOrder.php @@ -14,6 +14,7 @@ use app\model\BaseModel; use app\model\member\MemberAccount; use app\model\message\Message; use app\model\system\Stat; +use think\facade\Db; use think\facade\Log; /** @@ -34,16 +35,20 @@ class FenxiaoOrder extends BaseModel //上月 $begin_time = strtotime(date('Y-m-01 00:00:00', strtotime('-1 month'))); $end_time = strtotime(date("Y-m-d 23:59:59", strtotime(-date('d') . 'day'))); - $fenxiao = Db::name('fenxiao')->where([['is_area_agent', '=', 1],['status','=',1]])->column('fenxiao_id,site_id,member_id,fenxiao_name,agent_level_id,province_id,city_id,district_id,parent', 'fenxiao_id'); + $fenxiao = Db::name('fenxiao_agent')->alias('a')->join( + 'fenxiao f', + 'a.fenxiao_id = f.fenxiao_id', + 'left' + )->where([['f.status','=',1]])->column('f.fenxiao_id,f.site_id,member_id,fenxiao_name,agent_level_id,province_id,city_id,district_id,parent', 'f.fenxiao_id'); //获取分销基础配置 $config_model = new Config(); $fenxiao_basic_config = $config_model->getFenxiaoBasicsConfig(1); - $fenxiao_account = new FenxiaoAccount(); + $fenxiao_member_account = new MemberAccount(); foreach ($fenxiao as $fenxiao_id => $item) { $fenxiao_agent_level = Db::name('fenxiao_agent_level')->where('level_id', '=', $item['agent_level_id'])->field('type,flower_multiple,status')->find(); $where = [ - ['fo.create_time', 'BETWEEN', [$begin_time, $end_time]], - // ['fo.create_time', 'BETWEEN', [$beginThismonth, $endThismonth]], + // ['fo.create_time', 'BETWEEN', [$begin_time, $end_time]], + ['fo.create_time', 'BETWEEN', [$beginThismonth, $endThismonth]], ['o.'.$fenxiao_agent_level['type'].'_id', '=', $item[$fenxiao_agent_level['type'].'_id']] ]; $fenxia_area_order_info = Db::name('fenxiao_order') @@ -53,30 +58,31 @@ class FenxiaoOrder extends BaseModel ->field('sum(real_goods_money) as real_goods_money') ->find(); $money = $fenxia_area_order_info['real_goods_money'] * $fenxiao_agent_level['flower_multiple']/100; - $fruit_num = $money * $fenxiao_basic_config['data']['value']['fruit_flower_rate']; - $account_model = new FenxiaoAccount(); - //添加茶果 - $udata = [ - 'flower_num' => Db::raw('flower_num -' . $money), - 'fruit_num' => Db::raw('fruit_num +' . $fruit_num), - ]; - Db::name('fenxiao')->where([[ 'fenxiao_id', '=', $fenxiao_id ]])->update($udata); - $account_model->addAccountLog($fenxiao_id, $item['fenxiao_name'], 'fruit', $fruit_num, '', "代理奖励茶果-{$fruit_num}"); - $account_model->addAccountLog($fenxiao_id, $item['fenxiao_name'], 'flower', '-' . $money, '', "茶花转茶果{$money}"); + $fenxiao_member_account->addMemberAccount($item[ 'site_id' ], $item['member_id'], 'balance_money', $money, 'area', '区域代理结算', '区域代理结算'); - if($fenxiao_basic_config['data']['value']['agent_level_parent_rate'] > 0){ - $money = $money * $fenxiao_basic_config['data']['value']['agent_level_parent_rate'] / 100; - $fruit_num = $money * $fenxiao_basic_config['data']['value']['fruit_flower_rate']; - //添加茶果 - $udata = [ - 'flower_num' => Db::raw('flower_num -' . $money), - 'fruit_num' => Db::raw('fruit_num +'.$fruit_num) - ]; - $fenxiaoParent = Db::name('fenxiao')->where('fenxiao_id','=',$item['parent'])->alias('fenxiao_name')->find(); - Db::name('fenxiao')->where([['fenxiao_id','=',$item['parent']]])->update($udata); - $account_model->addAccountLog($item['parent'],$fenxiaoParent['fenxiao_name'],'fruit',$fruit_num,'',"推荐代理奖励茶果-{$fruit_num}"); - $account_model->addAccountLog($item['parent'],$fenxiaoParent['fenxiao_name'], 'flower', '-' . $money, '', "茶花转茶果{$money}"); - } + + // //添加茶果 + // $udata = [ + // 'flower_num' => Db::raw('flower_num -' . $money), + // 'fruit_num' => Db::raw('fruit_num +' . $fruit_num), + // ]; + // Db::name('fenxiao')->where([[ 'fenxiao_id', '=', $fenxiao_id ]])->update($udata); + // $account_model->addAccountLog($fenxiao_id, $item['fenxiao_name'], 'fruit', $fruit_num, '', "代理奖励茶果-{$fruit_num}"); + // $account_model->addAccountLog($fenxiao_id, $item['fenxiao_name'], 'flower', '-' . $money, '', "茶花转茶果{$money}"); + // + // if($fenxiao_basic_config['data']['value']['agent_level_parent_rate'] > 0){ + // $money = $money * $fenxiao_basic_config['data']['value']['agent_level_parent_rate'] / 100; + // $fruit_num = $money * $fenxiao_basic_config['data']['value']['fruit_flower_rate']; + // //添加茶果 + // $udata = [ + // 'flower_num' => Db::raw('flower_num -' . $money), + // 'fruit_num' => Db::raw('fruit_num +'.$fruit_num) + // ]; + // $fenxiaoParent = Db::name('fenxiao')->where('fenxiao_id','=',$item['parent'])->alias('fenxiao_name')->find(); + // Db::name('fenxiao')->where([['fenxiao_id','=',$item['parent']]])->update($udata); + // $account_model->addAccountLog($item['parent'],$fenxiaoParent['fenxiao_name'],'fruit',$fruit_num,'',"推荐代理奖励茶果-{$fruit_num}"); + // $account_model->addAccountLog($item['parent'],$fenxiaoParent['fenxiao_name'], 'flower', '-' . $money, '', "茶花转茶果{$money}"); + // } } return $this->success(); } @@ -260,7 +266,9 @@ class FenxiaoOrder extends BaseModel 'three_fenxiao_name' => empty($grand_parent_fenxiao_info) ? '' : $grand_parent_fenxiao_info[ 'fenxiao_name' ], 'create_time' => time() ]; - $this->orderGive($data); + if($order['promotion_type'] != 'pointexchange'){ + $this->orderGive($data); + } model("fenxiao_order")->add($data); } // 分销商检测升级 diff --git a/addon/fenxiao/shop/controller/Agentlevel.php b/addon/fenxiao/shop/controller/Agentlevel.php new file mode 100644 index 00000000..cc18a0e2 --- /dev/null +++ b/addon/fenxiao/shop/controller/Agentlevel.php @@ -0,0 +1,97 @@ +isAjax()) { + $page = input('page', 1); + $page_size = input('page_size', PAGE_LIST_ROWS); + $list = $model->getLevelPageList([['site_id', '=', $this->site_id]], $page, $page_size, '', '*'); + return $list; + } else { +// //获取系统配置 +// $config_model = new ConfigModel(); +// $basics = $config_model->getFenxiaoBasicsConfig($this->site_id); +// $this->assign("basics_info", $basics['data']['value']); + return $this->fetch('agentlevel/lists'); + } + } + + /** + * 添加等级 + */ + public function add() + { + $model = new AgeenLevel(); + if (request()->isAjax()) { + $data = [ + 'site_id' => $this->site_id, + 'level_name' => input('level_name', ''), + 'type' => input('type', ''), + 'remark' => input('remark', ''), + 'flower_multiple' => input('flower_multiple', ''), + 'flower_times' => input('flower_times', '') + ]; + $res = $model->addLevel($data); + return $res; + } else { + return $this->fetch('agentlevel/add'); + } + } + + /** + * 编辑等级 + */ + public function edit() + { + $model = new AgeenLevel(); + if (request()->isAjax()) { + $data = [ + 'level_name' => input('level_name', ''), + 'type' => input('type', ''), + 'remark' => input('remark', ''), + 'flower_multiple' => input('flower_multiple', 0), + 'flower_times' => input('flower_times', '') + ]; + $level_id = input('level_id', ''); + $res = $model->editLevel($data, [['level_id', '=', $level_id], ['site_id', '=', $this->site_id]]); + return $res; + } else { + $level_id = input('level_id', ''); + $info = $model->getLevelInfo([['level_id', '=', $level_id], ['site_id', '=', $this->site_id]]); + if (empty($info['data'])) return $this->error('未获取到等级数据', addon_url('fenxiao://shop/agentlevel/lists')); + $this->assign('info', $info['data']); + } + return $this->fetch('agentlevel/edit'); + } + + /** + * 删除分销等级 + */ + public function delete() + { + $model = new AgeenLevel(); + $level_id = input('level_id', ''); + $res = $model->deleteLevel($level_id, $this->site_id); + return $res; + } +} \ No newline at end of file diff --git a/addon/fenxiao/shop/controller/Area.php b/addon/fenxiao/shop/controller/Area.php new file mode 100644 index 00000000..190bfefe --- /dev/null +++ b/addon/fenxiao/shop/controller/Area.php @@ -0,0 +1,160 @@ +isAjax()) { + $condition = []; + $condition[] = ['f.site_id', '=', $this->site_id]; + // $condition[] = ['f.is_area_agent', '=', 1]; + $search_text_type=input('search_text_type'); + $search_text=input('search_text'); + switch ($search_text_type){ + case 'fenxiao_name' : + $condition[] = ['f.fenxiao_name', 'like', '%' . $search_text . '%']; + break; + case 'mobile' : + $condition[] = ['m.mobile', '=', $search_text]; + break; + case 'nickname' : + $condition[] = ['f.nickname', 'like', '%' . $search_text . '%']; + break; + case 'member_id' : + $condition[] = ['f.member_id', '=', $search_text]; + break; + } + $level_id = input('level_id', ''); + if ($level_id) { + $condition[] = ['f.level_id', '=', $level_id]; + } + $start_time = input('start_time', ''); + $end_time = input('end_time', ''); + if ($start_time && $end_time) { + $condition[] = ['f.create_time', 'between', [date_to_time($start_time), date_to_time($end_time)]]; + } elseif (!$start_time && $end_time) { + $condition[] = ['f.create_time', '<=', date_to_time($end_time)]; + + } elseif ($start_time && !$end_time) { + $condition[] = ['f.create_time', '>=', date_to_time($start_time)]; + } + $status = input('status', ''); + if (!empty($status)) { + $condition[] = ['f.status', '=', $status]; + } + $page = input('page', 1); + $page_size = input('page_size', PAGE_LIST_ROWS); + // $list = $model->getPageList($condition, $page, $page_size, 'f.create_time desc,a.create_time desc'); + $list = $model->getPageList($condition, $page, $page_size, ''); + return $list; + + } else { + $level_model = new AgeenLevel(); + $level_list = $level_model->getLevelList([['status', '=', 1], ['site_id', '=', $this->site_id]], 'level_id,level_name'); + $this->assign('level_list', $level_list['data']); + $config_model = new ConfigModel(); + $basics = $config_model->getFenxiaoBasicsConfig($this->site_id); + $this->assign("basics_info", $basics['data']['value']); + // $this->forthMenu(); + return $this->fetch('area/lists'); + } + } + /*** + * 添加代理商 + * @return array|mixed + */ + public function add(){ + //获取分销商列表 + $ageen_model = new Ageen(); + $fenxiao_model = new FenxiaoModel(); + //获取分销商等级 + $level_model = new AgeenLevel(); + if (request()->isAjax()) { + $fenxiao_id= input('fenxiao_id',0);//上级分销商ID + $province_id= input('province_id',0); + $city_id= input('city_id',0); + $district_id= input('district_id',0); + $level_id= input('level_id',0); + $fenxiao_data = [ + 'fenxiao_id' => $fenxiao_id, + 'agent_level_id' => input('level_id',''), + 'agent_level_name' => input('agent_level_name',''), + // 'is_area_agent' => 1, + 'province_id' => input('province_id',0), + 'city_id' => input('city_id',0), + 'district_id' => input('district_id',0) + ]; + $fenxiao=Db::name('fenxiao_agent') + ->whereOr('province_id','=',$province_id) + ->whereOr('city_id','=',$city_id) + ->whereOr('district_id','=',$district_id) + ->field('province_id,city_id,district_id,agent_level_id,fenxiao_id') + ->select(); + if($fenxiao){ + $area=array_column($fenxiao->toArray(),'agent_level_id'); + if(in_array($level_id,$area)){ + return error(-1,'当前区域已存在代理商'); + } + } + return $ageen_model->add($fenxiao_data); + } else { + $level_list = $level_model->getLevelList([['status', '=', 1], ['site_id', '=', $this->site_id]], 'level_id,level_name'); + $this->assign('level_list', $level_list['data']); + $condition[] = ['status','=','1']; + // $condition[] = ['is_area_agent','=','0']; + $fenxiao_list = $fenxiao_model->getFenxiaoList($condition, 'fenxiao_id,fenxiao_name'); + $this->assign('fenxiao_list', $fenxiao_list['data']); + //查询省级数据列表 + $address_model = new AddressModel(); + $list = $address_model->getAreaList([["pid", "=", 0], ["level", "=", 1]]); + $this->assign("province_list", $list["data"]); + return $this->fetch('area/add'); + } + } + public function remove(){ + //获取分销商列表 + $fenxiao_model = new Ageen(); + $id= input('id',0);//上级分销商ID + if(request()->isAjax()&&$id){ + return $fenxiao_model->delete($id); + } + } + /*** + * 查询分销商 + * @return array + */ + public function getfenxiaolist(){ + $page_index = input('page', 1); + $page_size = input('page_size', PAGE_LIST_ROWS); + $fenxiao_search = input("fenxiao_search", ''); + $condition = []; + $condition[] = [ 'mobile|fenxiao_name', 'like', '%'.$fenxiao_search.'%' ]; + $condition[] = [ 'status', '=', 1 ]; + // $condition[] = [ 'is_area_agent', '=', 0 ]; + $fenxiao_model = new FenxiaoModel(); + $list = $fenxiao_model->getFenxiaoPageLists($condition,$page_index,$page_size,'','fenxiao_id,fenxiao_name,account'); + return $list; + } +} \ No newline at end of file diff --git a/addon/fenxiao/shop/controller/Fenxiao.php b/addon/fenxiao/shop/controller/Fenxiao.php index d4719cff..7240f3c2 100644 --- a/addon/fenxiao/shop/controller/Fenxiao.php +++ b/addon/fenxiao/shop/controller/Fenxiao.php @@ -92,7 +92,7 @@ class Fenxiao extends BaseShop $commission_money = number_format($commission_money, 2); $this->assign('commission_money', $commission_money); - $this->forthMenu(); + // $this->forthMenu(); return $this->fetch('fenxiao/index'); } @@ -157,7 +157,7 @@ class Fenxiao extends BaseShop $basics = $config_model->getFenxiaoBasicsConfig($this->site_id); $this->assign("basics_info", $basics[ 'data' ][ 'value' ]); - $this->forthMenu(); + // $this->forthMenu(); return $this->fetch('fenxiao/lists'); } } @@ -252,7 +252,7 @@ class Fenxiao extends BaseShop $this->assign('level', $fenxiao_level[ 'data' ]); $this->assign('info', $info[ 'data' ]); - $this->forthMenu([ 'fenxiao_id' => $fenxiao_id ]); + // $this->forthMenu([ 'fenxiao_id' => $fenxiao_id ]); return $this->fetch('fenxiao/fenxiao_detail'); } @@ -304,7 +304,7 @@ class Fenxiao extends BaseShop } $this->assign('fenxiao_id', $fenxiao_id); - $this->forthMenu([ 'fenxiao_id' => $fenxiao_id ]); + // $this->forthMenu([ 'fenxiao_id' => $fenxiao_id ]); return $this->fetch('fenxiao/fenxiao_account'); } @@ -323,7 +323,7 @@ class Fenxiao extends BaseShop return $list; } else { $this->assign('fenxiao_id', $fenxiao_id); - $this->forthMenu([ 'fenxiao_id' => $fenxiao_id ]); + // $this->forthMenu([ 'fenxiao_id' => $fenxiao_id ]); $config_model = new ConfigModel(); $basics_config = $config_model->getFenxiaoBasicsConfig($this->site_id); @@ -376,7 +376,7 @@ class Fenxiao extends BaseShop } else { //订单状态 $this->assign('fenxiao_id', $fenxiao_id); - $this->forthMenu([ 'fenxiao_id' => $fenxiao_id ]); + // $this->forthMenu([ 'fenxiao_id' => $fenxiao_id ]); return $this->fetch('fenxiao/order_lists', [], $this->replace); } } @@ -484,7 +484,7 @@ class Fenxiao extends BaseShop $level_list = $level_model->getLevelList([ [ 'status', '=', 1 ] ], 'level_id,level_name'); $this->assign('level_list', $level_list[ 'data' ]); - $this->forthMenu(); + // $this->forthMenu(); return $this->fetch('fenxiao/apply'); } } @@ -682,4 +682,19 @@ class Fenxiao extends BaseShop return $res; } } + + /** + * 购房券 + */ + public function adjustHousePurchase() + { + $fenxiao_id = input('fenxiao_id', 0); + $adjust_num = input('adjust_num', 0); + // $remark = input('remark', '商家调整'); + $remark = '后台核销'; + // $this->addLog("会员消费券调整id:" . $member_id . "金额" . $adjust_num); + $fenxiao = model('fenxiao')->getInfo(['fenxiao_id' => $fenxiao_id, 'site_id' => $this->site_id], 'fenxiao_id,fenxiao_name,parent,grand_parent'); + $fenxiao_account_model = new FenxiaoAccount(); + return $fenxiao_account_model->addAccount($fenxiao['fenxiao_id'], $fenxiao['fenxiao_name'], 'house_purchase', -$adjust_num, $fenxiao['fenxiao_id'], 'house_purchase', $remark); + } } \ No newline at end of file diff --git a/addon/fenxiao/shop/controller/Goods.php b/addon/fenxiao/shop/controller/Goods.php index 3fa7e08f..e3fd4051 100644 --- a/addon/fenxiao/shop/controller/Goods.php +++ b/addon/fenxiao/shop/controller/Goods.php @@ -68,7 +68,7 @@ class Goods extends BaseShop $list = $model->getGoodsPageList($condition, $page_index, $page_size); return $list; } else { - $this->forthMenu(); + // $this->forthMenu(); return $this->fetch('goods/lists'); } } diff --git a/addon/fenxiao/shop/controller/Order.php b/addon/fenxiao/shop/controller/Order.php index 7194696a..a3682913 100644 --- a/addon/fenxiao/shop/controller/Order.php +++ b/addon/fenxiao/shop/controller/Order.php @@ -67,7 +67,7 @@ class Order extends BaseShop return $list; } else { - $this->forthMenu(); + // $this->forthMenu(); //订单状态 return $this->fetch('order/lists', [], $this->replace); } diff --git a/addon/fenxiao/shop/view/agentlevel/add.html b/addon/fenxiao/shop/view/agentlevel/add.html new file mode 100644 index 00000000..4ea91dfd --- /dev/null +++ b/addon/fenxiao/shop/view/agentlevel/add.html @@ -0,0 +1,135 @@ +{extend name="app/shop/view/base.html"/} +{block name="resources"} + +{/block} +{block name="main"} +