diff --git a/addon/fenxiao/api/controller/Account.php b/addon/fenxiao/api/controller/Account.php index def5536..d9b56fe 100644 --- a/addon/fenxiao/api/controller/Account.php +++ b/addon/fenxiao/api/controller/Account.php @@ -14,6 +14,7 @@ namespace addon\fenxiao\api\controller; use addon\fenxiao\model\FenxiaoAccount; use addon\fenxiao\model\Fenxiao as FenxiaoModel; use app\api\controller\BaseApi; +use app\model\member\MemberAccount; /** * 分销商流水 @@ -33,6 +34,7 @@ class Account extends BaseApi $page = isset($this->params['page']) ? $this->params['page'] : 1; $page_size = isset($this->params['page_size']) ? $this->params['page_size'] : PAGE_LIST_ROWS; + $type = isset($this->params['type']) ? $this->params['type'] : ''; $model = new FenxiaoModel(); $fenxiao_info = $model->getFenxiaoInfo([['member_id', '=', $this->member_id]], 'fenxiao_id'); @@ -41,6 +43,11 @@ class Account extends BaseApi $condition = [ ['fenxiao_id', '=', $fenxiao_info['fenxiao_id']] ]; + if($type != '' && $type != 'undefined'){ + $condition[] = [ + ['type', '=', $type] + ]; + } $account_model = new FenxiaoAccount(); $list = $account_model->getFenxiaoAccountPageList($condition, $page, $page_size); @@ -49,4 +56,41 @@ class Account extends BaseApi return $this->response($this->error('', 'FENXIAO_NOT_EXIST')); } + public function goufang_to_balance(){ + $token = $this->checkToken(); + if ($token['code'] < 0) return $this->response($token); + + $apply_money = isset($this->params['apply_money']) ? $this->params['apply_money'] : 0; + $type = isset($this->params['type']) ? $this->params['type'] : ''; + if($apply_money <= 0 || $type == ''){ + return $this->response($this->error('','参数错误')); + } + if($apply_money % 100 != 0){ + return $this->response($this->error('','转换金额需为100的整数倍')); + } + $model = new FenxiaoModel(); + $menber_account = new MemberAccount(); + $fenxiao_account = new FenxiaoAccount(); + $fenxiao_info = $model->getFenxiaoInfo([['member_id', '=', $this->member_id]])['data']; + switch($type){ + case 'goufang_to_balance': + if($fenxiao_info['house_purchase'] < $apply_money){ + return $this->response($this->error('','购房券不足')); + } + $menber_account->addMemberAccount($fenxiao_info[ 'site_id' ], $fenxiao_info['member_id'], 'balance_money', $apply_money, 'goufang_to_balance', '购房券转换', '购房券转换'); + $fenxiao_account->addAccount($fenxiao_info['fenxiao_id'], $fenxiao_info['fenxiao_name'], 'house_purchase', -$apply_money, 0,'house_purchase', '购房券转换'); + break; + case 'balance_to_goufang': + $res = $menber_account->addMemberAccount($fenxiao_info[ 'site_id' ], $fenxiao_info['member_id'], 'balance_money', -$apply_money, 'goufang_to_balance', '购房券转换', '购房券转换'); + if($res['code'] < 0){ + return $this->response($res); + } + $fenxiao_account->addAccount($fenxiao_info['fenxiao_id'], $fenxiao_info['fenxiao_name'], 'house_purchase', $apply_money, 0,'house_purchase', '购房券转换'); + break; + default: + return $this->response($this->error('','参数错误')); + } + return $this->response($this->success()); + } + } \ No newline at end of file diff --git a/addon/fenxiao/api/controller/Order.php b/addon/fenxiao/api/controller/Order.php index 6059eb0..5509e17 100644 --- a/addon/fenxiao/api/controller/Order.php +++ b/addon/fenxiao/api/controller/Order.php @@ -115,9 +115,9 @@ class Order extends BaseApi return $this->response($list); } - // public function testDaySettlement(){ - // return $this->response(event("DaySettlement")); - // } + public function testDaySettlement(){ + return $this->response(event("DaySettlement")); + } // // public function testAreaMonthlyReward(){ // event("AreaMonthlyReward"); diff --git a/addon/fenxiao/model/Ageen.php b/addon/fenxiao/model/Ageen.php index 4238b03..f06a785 100644 --- a/addon/fenxiao/model/Ageen.php +++ b/addon/fenxiao/model/Ageen.php @@ -99,7 +99,7 @@ class Ageen extends BaseModel 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'; + $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,pa.name as province_name,ca.name as city_name,da.name as district_name,a.province_id,a.city_id,a.district_id'; $alias = 'a'; $join = [ [ @@ -117,6 +117,21 @@ class Ageen extends BaseModel 'm.member_id = f.member_id', 'left' ], + [ + 'area pa', + 'pa.id = a.province_id', + 'left' + ], + [ + 'area ca', + 'ca.id = a.city_id', + 'left' + ], + [ + 'area da', + 'da.id = a.district_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); diff --git a/addon/fenxiao/model/FenxiaoOrder.php b/addon/fenxiao/model/FenxiaoOrder.php index 5e40fd3..79020da 100644 --- a/addon/fenxiao/model/FenxiaoOrder.php +++ b/addon/fenxiao/model/FenxiaoOrder.php @@ -519,10 +519,10 @@ class FenxiaoOrder extends BaseModel /** * 查询分销订单列表(管理端调用) */ - public function getFenxiaoOrderPage($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'order_id DESC') + public function getFenxiaoOrderPage($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'fo.order_id DESC') { - $field = 'order_id,order_no,site_name,member_name,create_time,is_settlement,fenxiao_order_id'; - $list = model('fenxiao_order')->pageList($condition, $field, $order, $page, $page_size, 'fo', [], 'order_id'); + $field = 'fo.order_id,fo.order_no,fo.site_name,fo.member_name,fo.create_time,fo.is_settlement,fo.fenxiao_order_id'; + $list = model('fenxiao_order')->pageList($condition, $field, $order, $page, $page_size, 'fo', [['order o','fo.order_id=o.order_id','LEFT']], 'fo.order_id'); if (!empty($list[ 'list' ])) { foreach ($list[ 'list' ] as $k => $item) { $order_info = model('order')->getInfo([ [ 'order_id', '=', $item[ 'order_id' ] ] ], 'name,full_address,mobile,order_status_name'); diff --git a/addon/fenxiao/shop/controller/Order.php b/addon/fenxiao/shop/controller/Order.php index a368291..90d5991 100644 --- a/addon/fenxiao/shop/controller/Order.php +++ b/addon/fenxiao/shop/controller/Order.php @@ -11,6 +11,7 @@ namespace addon\fenxiao\shop\controller; use addon\fenxiao\model\FenxiaoOrder; +use app\model\system\Address as AddressModel; use app\shop\controller\BaseShop; /** @@ -61,6 +62,19 @@ class Order extends BaseShop } elseif (!empty($start_time) && !empty(date_to_time($end_time))) { $condition[] = [ 'fo.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ]; } + $province_id = input('province_id', 0); + $city_id = input('city_id', 0); + $district_id = input('district_id', 0); + + if($province_id != 0){ + $condition[] = ['o.province_id', '=', $province_id]; + } + if($city_id != 0){ + $condition[] = ['o.city_id', '=', $city_id]; + } + if($district_id != 0){ + $condition[] = ['o.district_id', '=', $district_id]; + } $list = $model->getFenxiaoOrderPage($condition, $page_index, $page_size); @@ -69,6 +83,10 @@ class Order extends BaseShop } else { // $this->forthMenu(); //订单状态 + //查询省级数据列表 + $address_model = new AddressModel(); + $list = $address_model->getAreaList([["pid", "=", 0], ["level", "=", 1]]); + $this->assign("province_list", $list["data"]); return $this->fetch('order/lists', [], $this->replace); } } diff --git a/addon/fenxiao/shop/view/area/lists.html b/addon/fenxiao/shop/view/area/lists.html index 1a39175..98250b0 100644 --- a/addon/fenxiao/shop/view/area/lists.html +++ b/addon/fenxiao/shop/view/area/lists.html @@ -117,6 +117,7 @@
查看 + 查看区域订单 移除代理
@@ -150,7 +151,7 @@ field: 'fenxiao_name', title: '代理名称', unresize: 'false', - width: '8%' + width: '12%' },{ templet: function(data) { var html = "" @@ -166,7 +167,7 @@ field: 'parent_name', title: '推荐人', unresize: 'false', - width: '5%', + width: '10%', templet: function(data) { if(data.parent_name){ return data.parent_name; @@ -179,6 +180,22 @@ title: '代理等级', unresize: 'false', width: '10%' + },{ + field: 'agent_level_name', + title: '代理区域', + unresize: 'false', + width: '20%', + templet: function(data) { + if(data.agent_level_id == 1){ + return data.province_name + } + if(data.agent_level_id == 2){ + return data.province_name + '-' + data.city_name + } + if(data.agent_level_id == 3){ + return data.province_name + '-' + data.city_name + '-' + data.district_name + } + } }, // { // field: 'total_order_money', @@ -218,7 +235,7 @@ field: 'create_time', title: '添加时间', unresize: 'false', - width: '10%', + width: '12%', templet: function(data) { return ns.time_to_date(data.create_time); } @@ -254,6 +271,17 @@ case 'detail': //查看 location.href = ns.url('fenxiao://shop/fenxiao/detail', {'fenxiao_id': data.fenxiao_id}) break; + case 'agent_order': //查看 + if(data.agent_level_id == 1){ + location.href = ns.url('fenxiao://shop/order/lists.html#!search_text_type=order_no&province_id='+data.province_id+'&page=1') + } + if(data.agent_level_id == 2){ + location.href = ns.url('fenxiao://shop/order/lists.html#!search_text_type=order_no&province_id='+data.province_id+'&city_id='+data.city_id+'&page=1') + } + if(data.agent_level_id == 3){ + location.href = location.origin + '/fenxiao/shop/order/lists.html#!search_text_type=order_no&province_id='+data.province_id+'&city_id='+data.city_id+'&district_id='+data.district_id+'&page=1' + } + break; case 'remove': //冻结 layer.confirm('确定要移除该账户吗?', function () { if (repeat_flag) return; diff --git a/addon/fenxiao/shop/view/order/lists.html b/addon/fenxiao/shop/view/order/lists.html index 2420519..5bd238d 100644 --- a/addon/fenxiao/shop/view/order/lists.html +++ b/addon/fenxiao/shop/view/order/lists.html @@ -51,6 +51,28 @@ + +
+ +
+ +
+
+ +
+
+ +
+
@@ -72,11 +94,30 @@ {/block} {block name="script"} +