isAjax()) { $store_model = new StoreModel(); $order_model = new Order(); $withdrawal_model = new StoreWithdraw(); $data = [ 'store_num' => $store_model->getStoreCount([['site_id', '=', $this->site_id]])['data'], 'in_business_num' => $store_model->getStoreCount([['site_id', '=', $this->site_id], ['status', '=', 1]])['data'], 'total_order_num' => $order_model->getOrderCount([['site_id', '=', $this->site_id], ['store_id', '>', 0], ['is_delete', '=', 0], ['pay_status', '=', 1]])['data'], 'total_order_money' => $order_model->getOrderMoneySum([['site_id', '=', $this->site_id], ['store_id', '>', 0], ['is_delete', '=', 0], ['pay_status', '=', 1]])['data'], 'account_apply' => $store_model->getStoreSum([['site_id', '=', $this->site_id]], 'account_apply')['data'], 'wait_audit_num' => $withdrawal_model->getStoreWithdrawCount([['site_id', '=', $this->site_id], ['status', '=', 0]])['data'], 'wait_audit_money' => $withdrawal_model->getStoreWithdrawSum([['site_id', '=', $this->site_id], ['status', '=', 0]], 'money')['data'], 'wait_transfer_num' => $withdrawal_model->getStoreWithdrawCount([['site_id', '=', $this->site_id], ['status', '=', 1]])['data'], 'wait_transfer_money' => $withdrawal_model->getStoreWithdrawSum([['site_id', '=', $this->site_id], ['status', '=', 1]], 'money')['data'], ]; return $store_model->success($data); } return $this->fetch("store/index"); } /** * 门店排行 */ public function storeRanking() { if (request()->isAjax()) { $order = input('order', 'num'); $stat_model = new \addon\store\model\Stat(); $data = $stat_model->getStoreOrderRank([ 'site_id' => $this->site_id, 'order' => $order, ]); return $data; } } /** * 商品排行 */ public function goodsRanking() { if (request()->isAjax()) { $order_model = new Order(); $order = input('order', 'num'); $condition = [ ['og.site_id', '=', $this->site_id], ['og.store_id', '>', 0], ['o.pay_status', '=', 1], ['o.is_delete', '=', 0] ]; $join = [ ['order o', 'o.order_id = og.order_id', 'inner'], ['store s', 's.store_id = o.store_id', 'inner'] ]; $order = $order == 'num' ? 'goods_num desc' : 'goods_money desc'; $data = $order_model->getOrderGoodsList($condition, 'sum(og.num) as goods_num, sum(o.goods_money) as goods_money,og.goods_name', $order, 5, 'og.goods_id', 'og', $join); return $data; } } /** * 门店列表 * @return mixed */ public function lists() { if (request()->isAjax()) { $store_model = new StoreModel(); $page = input('page', 1); $page_size = input('page_size', PAGE_LIST_ROWS); // $order = input("order", "create_time desc"); $keyword = input("search_text", ''); $status = input("status", ''); $type = input("type", ''); $condition = []; if ($type == 1) { if ($status != null) { $condition[] = ['status', '=', $status]; $condition[] = ['is_frozen', '=', 0]; } } else if ($type == 2) { $condition[] = ['is_frozen', '=', $status]; } $condition[] = ['site_id', "=", $this->site_id]; //关键字查询 if (!empty($keyword)) { $condition[] = ["store_name", "like", "%" . $keyword . "%"]; } $order = 'is_default desc,store_id desc'; $list = $store_model->getStorePageList($condition, $page, $page_size, $order); return $list; } else { //判断门店插件是否存在 $store_is_exit = addon_is_exit('store', $this->site_id); $this->assign('store_is_exit', $store_is_exit); $this->assign('title', $store_is_exit ? '门店' : '自提点'); $this->assign('store_type', (new StoreModel())->getStoreType()); $config_model = new ConfigModel(); $default_img = $config_model->getDefaultImg($this->site_id, $this->app_module)['data']['value']; $this->assign("default_img", $default_img); return $this->fetch("store/lists"); } } /** * 添加门店 * @return mixed */ public function addStore() { $is_store = addon_is_exit('store'); if (request()->isAjax()) { $store_name = input("store_name", ''); $telphone = input("telphone", ''); $store_image = input("store_image", ''); $province_id = input("province_id", 0); $city_id = input("city_id", 0); $district_id = input("district_id", 0); $community_id = input("community_id", 0); $address = input("address", ''); $full_address = input("full_address", ''); $longitude = input("longitude", 0); $latitude = input("latitude", 0); $is_pickup = input("is_pickup", 0); $is_o2o = input("is_o2o", 0); $open_date = input("open_date", ''); $start_time = input('start_time', 0); $end_time = input('end_time', 0); $time_type = input('time_type', 0); $time_week = input('time_week', ''); $stock_type = input('stock_type', ''); $is_mystore = input('is_mystore', 0); if (!empty($time_week)) { $time_week = implode(',', $time_week); } $data = array( "store_name" => $store_name, "telphone" => $telphone, "store_image" => $store_image, "province_id" => $province_id, "city_id" => $city_id, "district_id" => $district_id, "community_id" => $community_id, "address" => $address, "full_address" => $full_address, "longitude" => $longitude, "latitude" => $latitude, "open_date" => $open_date, "site_id" => $this->site_id, 'start_time' => $start_time, 'end_time' => $end_time, 'time_type' => $time_type, 'time_week' => $time_week, 'stock_type' => $stock_type, 'is_pickup' => $is_pickup, 'is_o2o' => $is_o2o, 'is_mystore' => $is_mystore, 'store_type' => input('store_type', ''), 'category_id' => input('category_id', 0), 'category_name' => input('category_name', ''), 'label_id' => input('label_id', ''), 'label_name' => input('label_name', ''), 'store_images' => input('store_images', ''), 'store_introduce' => input('store_introduce', ''), 'username' => input('username', ''), 'password' => input('password', ''), 'merchants_member_id' => input('merchants_member_id', '') ); //判断是否开启多门店 if ($is_store == 1) { $user_data = [ 'username' => input('username', ''), 'password' => data_md5(input('password', '')), ]; } else { $user_data = []; } $store_model = new StoreModel(); if ($is_mystore) { //添加蚂蚁门店 $shop_type = [ 'directsale' => '01', 'franchise' => '02' ]; $myData = [ 'business_address' => [ 'province_code' => input('province_id'), 'city_code' => input('city_id'), 'district_code' => input('city_id'), 'address' => input('address'), 'longitude' => input('longitude'), 'latitude' => input('latitude'), 'poiid' => input('poiid'), ], 'store_id' => date('YmdHis'), 'shop_category' => input('two_code'), 'shop_type' => $shop_type[input('store_type')] ?? '01', 'ip_role_id' => input('ip_role_id', ''), 'shop_name' => input('store_name'), 'one_code' => input('one_code'), 'two_code' => input('two_code'), ]; if (empty($myData['business_address']['poiid'])) { $url = 'https://restapi.amap.com/v3/place/text?'; $config_model = new ConfigModel(); $config = $config_model->getMapConfig()['data']['value']; if (!isset($config['amap_map_key']) || !$config['amap_map_key']) return $this->error('请设置高德KEY', url('shop/config/map')); $param = [ 'key' => $config['amap_map_key'], 'city' => $full_address, 'keywords' => $address, 'citylimit' => true, ]; $http = http($url . http_build_query($param)); $pois = json_decode($http, true); if (isset($pois['pois'])) { $myData['business_address']['poiid'] = $pois['pois'][0]['id']; } } $business_time = [ 'week_day' => '1', 'open_time' => '09:00', 'close_time' => '18:00', ]; for ($i = 1; $i <= 7; $i++) { $business_time['week_day'] = $i; $myData['business_time'][] = $business_time; } if ($telphone) { $myData['contact_mobile'] = $telphone; } $alistore = new MaYiStore($this->site_id); $result = $alistore->StoreCreate($myData); //创建门店 if ($result['code'] == '10000') { $myData['order_id'] = $result['order_id']; $data['myorder_id'] = $result['order_id']; } else { $result['message'] = $result['sub_msg']; return $result; } $data['storeinfo'] = json_encode($myData); } $result = $store_model->addStore($data, $user_data, $is_store); return $result; } else { //查询省级数据列表 $address_model = new AddressModel(); $list = $address_model->getAreaList([["pid", "=", 0], ["level", "=", 1]]); $mycategory = new MayiCategory(); $this->assign("mycategory", $mycategory->getCategory()['data']); $config = new Config(); $config_info = $config->getAppConfig($this->site_id)['data']['value']; if (isset($config_info['account'])) { $this->assign("ismystore", 1); $pay = new \addon\alipay\model\Config(); $payConfig = $pay->getPayConfig($this->site_id)['data']['value']; if (isset($payConfig['merchant_smid']) && $payConfig['merchant_smid']) { $config_info['account'] = $payConfig['merchant_smid']; } $this->assign("aliapp", $config_info); } else { $this->assign("ismystore", 0); } $this->assign("province_list", $list["data"]); $this->assign("is_exit", $is_store); $this->assign('title', $is_store ? '门店' : '自提点'); $this->assign("http_type", get_http_type()); $config_model = new ConfigModel(); $mp_config = $config_model->getMapConfig($this->site_id); $this->assign('tencent_map_key', $mp_config['data']['value']['tencent_map_key']); $this->assign('amap_map_key', $mp_config['data']['value']['amap_map_key']); //效验腾讯地图KEY $check_map_key = $config_model->checkQqMapKey($mp_config['data']['value']['tencent_map_key']); $this->assign('check_map_key', $check_map_key); $express_type = (new ExpressConfig())->getEnabledExpressType($this->site_id); if (isset($express_type['express'])) unset($express_type['express']); $this->assign('express_type', $express_type); $this->assign('store_type', (new StoreModel())->getStoreType()); // $user_list = (new User())->getUserList([['site_id', '=', $this->site_id]], 'uid,username')['data']; // $this->assign('user_list', $user_list); $category = new Category(); $category_config = $category->getCategoryConfig($this->site_id)['data']['value']; if ($category_config['status']) { $category_list = $category->getStoreCategoryList([['site_id', '=', $this->site_id]], 'category_id,category_name')['data']; $this->assign('category_list', $category_list); } $this->assign('category_status', $category_config['status']); $label_list = (new Label())->getStoreLabelList([['site_id', '=', $this->site_id]], 'label_id,label_name')['data']; $this->assign('label_list', $label_list); return $this->fetch("store/add_store"); } } /** * 编辑门店 * @return mixed */ public function editStore() { $is_exit = addon_is_exit("store"); $store_id = input("store_id", 0); $condition = array( ["site_id", "=", $this->site_id], ["store_id", "=", $store_id] ); $store_model = new StoreModel(); if (request()->isAjax()) { $store_name = input("store_name", ''); $telphone = input("telphone", ''); $store_image = input("store_image", ''); $province_id = input("province_id", 0); $city_id = input("city_id", 0); $district_id = input("district_id", 0); $community_id = input("community_id", 0); $address = input("address", ''); $full_address = input("full_address", ''); $longitude = input("longitude", 0); $latitude = input("latitude", 0); $is_pickup = input("is_pickup", 0); $is_o2o = input("is_o2o", 0); $open_date = input("open_date", ''); $start_time = input('start_time', 0); $end_time = input('end_time', 0); $time_type = input('time_type', 0); $time_week = input('time_week', ''); $stock_type = input('stock_type', ''); if (!empty($time_week)) { $time_week = implode(',', $time_week); } $data = array( "store_name" => $store_name, "telphone" => $telphone, "store_image" => $store_image, "province_id" => $province_id, "city_id" => $city_id, "district_id" => $district_id, "community_id" => $community_id, "address" => $address, "full_address" => $full_address, "longitude" => $longitude, "latitude" => $latitude, "open_date" => $open_date, 'start_time' => $start_time, 'end_time' => $end_time, 'time_type' => $time_type, 'time_week' => $time_week, 'stock_type' => $stock_type, 'is_pickup' => $is_pickup, 'is_o2o' => $is_o2o, 'store_type' => input('store_type', ''), 'category_id' => input('category_id', 0), 'category_name' => input('category_name', ''), 'label_id' => input('label_id', ''), 'label_name' => input('label_name', ''), 'store_images' => input('store_images', ''), 'store_introduce' => input('store_introduce', ''), 'merchants_member_id' => input('merchants_member_id', '') ); $user_type = input('user_type', 1); if ($is_exit == 1 && $user_type == 0) { $user_data = [ 'username' => input('username', ''), 'password' => data_md5(input('password', '')), ]; }else{ $user_data = []; } $result = $store_model->editStore($data, $condition, $user_data, $is_exit, $user_type); return $result; } else { //查询省级数据列表 $address_model = new AddressModel(); $list = $address_model->getAreaList([["pid", "=", 0], ["level", "=", 1]]); $this->assign("province_list", $list["data"]); $info_result = $store_model->getStoreDetail($condition);//门店信息 $info = $info_result["data"]; if (empty($info)) $this->error('未获取到门店数据', addon_url('store://shop/store/lists')); $this->assign("info", $info); $this->assign("store_id", $store_id); $this->assign("is_exit", $is_exit); $this->assign('title', $is_exit ? '门店' : '自提点'); $this->assign("http_type", get_http_type()); $config_model = new ConfigModel(); $mp_config = $config_model->getMapConfig($this->site_id); $this->assign('tencent_map_key', $mp_config['data']['value']['tencent_map_key']); //效验腾讯地图KEY $check_map_key = $config_model->checkQqMapKey($mp_config['data']['value']['tencent_map_key']); $this->assign('check_map_key', $check_map_key); $express_type = (new ExpressConfig())->getEnabledExpressType($this->site_id); if (isset($express_type['express'])) unset($express_type['express']); $this->assign('express_type', $express_type); $this->assign('store_type', (new StoreModel())->getStoreType()); $this->forthMenu(['store_id' => $store_id]); $category = new Category(); $category_config = $category->getCategoryConfig($this->site_id)['data']['value']; if ($category_config['status']) { $category_list = $category->getStoreCategoryList([['site_id', '=', $this->site_id]], 'category_id,category_name')['data']; $this->assign('category_list', $category_list); } $this->assign('category_status', $category_config['status']); $label_list = (new Label())->getStoreLabelList([['site_id', '=', $this->site_id]], 'label_id,label_name')['data']; $this->assign('label_list', $label_list); // 获取招商员信息 $merchantsMember = []; if($info['merchants_member_id'] > 0) $merchantsMember = model('member')->getInfo(['member_id'=>$info['merchants_member_id']],'member_id,nickname,headimg'); $this->assign('merchantsMember', $merchantsMember); return $this->fetch("store/edit_store"); } } /*** * 编辑蚂蚁门店 * @return array|mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function mystore() { $store_id = input("store_id", 0); $condition = array( ["site_id", "=", $this->site_id], ["store_id", "=", $store_id] ); $store_model = new StoreModel(); $store_info = $store_model->getStoreDetail($condition)['data'];//门店信息 $storeinfo = json_decode($store_info['storeinfo'], true);//门店信息 $alistore = new MaYiStore($this->site_id); if (request()->isAjax()) { $post = request()->post(); $is_exit = addon_is_exit("store"); $storeinfo['business_address'] = [ 'province_code' => $store_info['province_id'], 'city_code' => $store_info['city_id'], 'district_code' => $store_info['city_id'], 'address' => $store_info['address'], 'longitude' => $store_info['longitude'], 'latitude' => $store_info['latitude'] ]; $storeinfo['shop_category'] = $post['two_code']; $data['store_name'] = input('shop_name', ''); $data['is_mystore'] = input('is_mystore', 0); $business_time = [ 'week_day' => '1', 'open_time' => '07:00', 'close_time' => '21:00', ]; if ($store_info['start_time']) { $open_time = strtotime(date('Y-m-d')) + $store_info['start_time']; $close_time = strtotime(date('Y-m-d')) + $store_info['end_time']; $business_time['open_time'] = date('H:i', $open_time); $business_time['close_time'] = date('H:i', $close_time); } unset($storeinfo['business_time']); for ($i = 1; $i <= 7; $i++) { $business_time['week_day'] = $i; $storeinfo['business_time'][] = $business_time; } if (input('legal_name') && input('contact_mobile')) { $storeinfo['contact_infos'][] = [ 'name' => input('legal_name'), 'mobile' => input('contact_mobile'), 'type' => 'LEGAL_PERSON', 'tag' => ['06'], ]; } $info = array_merge($storeinfo, $post); if ($data['is_mystore'] == 1) { if (!$post['is_ali_store_reg']) { $result = $alistore->StoreCreate(array_filter($info)); //创建门店 if ($result['code'] == '10000') { $storeinfo['order_id'] = $result['order_id']; $data['myorder_id'] = $result['order_id']; $storeinfo['shop_id'] = $result['exist_shop_id'] ?? ''; } else { $result['message'] = $result['sub_msg']; return $result; } } else if ($storeinfo['shop_id']) { $result = $alistore->modifyStore(array_filter($info)); //编辑门店 if ($result['code'] == '10000') { $storeinfo['order_id'] = $result['order_id']; $data['myorder_id'] = $result['order_id']; $data['my_status'] = 0; } else { $result['message'] = $result['sub_msg']; return $result; } } $data['storeinfo'] = json_encode(array_merge($storeinfo, $post)); } else if (isset($storeinfo['shop_id'])) { $result = $alistore->CloseStore($storeinfo['shop_id']); //关闭门店 } $result = $store_model->editStore($data, $condition, [], $is_exit, 1); return $result; } if ($store_info['my_status'] != 1 && isset($storeinfo['shop_id'])) { $res = $alistore->shopQuery($storeinfo['shop_id']); $arr['my_reason'] = ''; if ($res['code'] == '10000') { switch ($res['shop_info_status']) { case '01': $arr['my_status'] = 1; break; case '02': $arr['my_status'] = 2; $arr['my_reason'] = '待优化'; break; case '03': $arr['my_status'] = 0; $arr['my_reason'] = '审核中'; break; case '99': $arr['my_status'] = 0; $arr['my_reason'] = '未知'; break; } } Db::name('store')->json(['storeinfo'])->where($condition)->update($arr); } $storeinfo['is_mystore'] = $store_info['is_mystore'];//门店信息 $mycategory = new MayiCategory(); $this->assign("mycategory", $mycategory->getCategory()['data']); if (isset($storeinfo['one_code'])) { $this->assign("twocategory", $mycategory->getCategory($storeinfo['one_code'])['data']['child']); } else { $this->assign("twocategory", []); } if (!isset($storeinfo['cert_no'])) { $shop_pay = Db::name('pay_shop') ->where('site_id', '=', $this->site_id)->json(['alipay_value'], true)->field('alipay_value,pay_type,merchant_smid')->find(); $alipay_value = $shop_pay['alipay_value'] ?? ''; if ($alipay_value && strpos($shop_pay['pay_type'], 'alipay') > -1) { if ($store_info['storeinfo']) $storeinfo['ip_role_id'] = $shop_pay['merchant_smid']; $storeinfo['cert_image'] = $alipay_value['cert_image'] ?? ''; $storeinfo['cert_image_show_image'] = $alipay_value['cert_image_show_image'] ?? ''; $storeinfo['cert_name'] = $alipay_value['cert_name'] ?? ''; $storeinfo['cert_no'] = $alipay_value['cert_no'] ?? ''; $storeinfo['legal_name'] = $alipay_value['legal_name'] ?? ''; $storeinfo['legal_cert_no'] = $alipay_value['legal_cert_no'] ?? ''; $storeinfo['contact_mobile'] = $storeinfo['contact_mobile'] ?? $alipay_value['contact_infos_mobile'] ?? ''; $storeinfo['ip_role_id'] = $storeinfo['ip_role_id'] ?? $shop_pay['merchant_smid'] ?? ''; } } if (isset($storeinfo['order_id'])) { $this->assign('is_ali_store_reg', 1); } else { $this->assign('is_ali_store_reg', 0); } if (empty($store_info)) $this->error('未获取到门店信息'); if (!$store_info['address']) $this->error('您还未设置门店经营地址', url('store/shop/store/editstore', ['store_id' => $store_id])); if (!isset($storeinfo['cert_type'])) { $storeinfo['shop_name'] = $store_info['store_name']; $storeinfo['cert_type'] = ''; $storeinfo['shop_type'] = '01'; } $storeinfo['one_code'] = $storeinfo['one_code'] ?? ''; $url = 'https://restapi.amap.com/v3/place/text?'; $config_model = new ConfigModel(); $config = $config_model->getMapConfig()['data']['value']; if (!isset($config['amap_map_key']) || !$config['amap_map_key']) return $this->error('请设置高德KEY', url('shop/config/map')); $param = [ 'key' => $config['amap_map_key'], 'city' => $store_info['full_address'], 'keywords' => $store_info['address'], 'citylimit' => true, ]; $http = http($url . http_build_query($param)); $pois = json_decode($http, true); if (isset($pois['pois'])) { $this->assign('pois', $pois['pois'][0]); } else { $this->assign('pois', []); } $this->forthMenu(['store_id' => $store_id]); $this->assign('time_week', []); $this->assign('info', $storeinfo); $this->assign('store_info', $store_info); $this->assign('store_id', $store_id); return $this->fetch("store/mystore"); } /*** * 刷新蚂蚁门店状态 * @throws \think\db\exception\DbException */ public function refreshMayiStore() { $store_id = input("store_id", 0); $condition = array( ["site_id", "=", $this->site_id], ["store_id", "=", $store_id] ); $store_model = new StoreModel(); $store_info = $store_model->getStoreDetail($condition)['data'];//门店信息 $storeinfo = json_decode($store_info['storeinfo'], true);//门店信息 $alistore = new MaYiStore($this->site_id); if (isset($storeinfo['shop_id'])) { $res = $alistore->shopQuery($storeinfo['shop_id']); $arr['my_reason'] = ''; if ($res['code'] == '10000') { switch ($res['shop_info_status']) { case '01': $arr['my_status'] = 1; break; case '02': $arr['my_status'] = 2; $arr['my_reason'] = '待优化'; break; case '03': $arr['my_status'] = 0; $arr['my_reason'] = '审核中'; break; case '99': $arr['my_status'] = 0; $arr['my_reason'] = '未知'; break; } } $arr['storeinfo'] = $storeinfo; Db::name('store')->json(['storeinfo'], true)->where($condition)->update($arr); } return success(0, '刷新成功'); } /*** * 获取蚂蚁分类 * @return array */ public function getMyCategory() { $mycategory = new MayiCategory(); $code = input('code'); return $mycategory->getCategory($code); } /** * @return mixed */ public function operate() { $store_id = input("store_id", 0); $condition = array( ["site_id", "=", $this->site_id], ["store_id", "=", $store_id] ); $store_model = new StoreModel(); if (request()->isAjax()) { $status = input("status", 0); $is_pickup = input("is_pickup", 0); $is_o2o = input("is_o2o", 0); $start_time = input('start_time', 0); $end_time = input('end_time', 0); $time_type = input('time_type', 0); $time_week = input('time_week', ''); $stock_type = input('stock_type', ''); if (!empty($time_week)) { $time_week = implode(',', $time_week); } $data = array( "status" => $status, 'start_time' => $start_time, 'end_time' => $end_time, 'time_type' => $time_type, 'time_week' => $time_week, 'stock_type' => $stock_type, 'is_pickup' => $is_pickup, 'is_o2o' => $is_o2o, 'time_interval' => input('time_interval', 30), 'delivery_time' => input('delivery_time', ''), 'advance_day' => input('advance_day', 0), 'most_day' => input('most_day', 7), 'is_express' => input('is_express', 0) ); $result = $store_model->editStore($data, $condition, [], 1, 1); return $result; } $store_info = $store_model->getStoreDetail($condition)['data'];//门店信息 if (empty($store_info)) $this->error('未获取到门店信息'); $this->assign('info', $store_info); $this->assign('store_id', $store_id); $business_config = (new StoreConfig())->getStoreBusinessConfig($this->site_id); $this->assign('business_config', $business_config['data']['value']); $this->forthMenu(['store_id' => $store_id]); return $this->fetch("store/operate"); } public function frozenStore() { if (request()->isAjax()) { $store_id = input('store_id', 0); $is_frozen = input('is_frozen', 0); $condition = [ ["site_id", "=", $this->site_id], ["store_id", "=", $store_id] ]; $store_model = new StoreModel(); $res = $store_model->frozenStore($condition, $is_frozen); return $res; } } /** * 重置密码 */ public function modifyPassword() { if (request()->isAjax()) { $store_id = input('store_id', ''); $password = input('password', '123456'); $store_model = new StoreModel(); return $store_model->resetStorePassword($password, [['store_id', '=', $store_id]]); } } /** * 同城配送 */ public function local() { $store_id = input('store_id', 0); $store_model = new StoreModel(); $info_result = $store_model->getStoreInfo([['site_id', '=', $this->site_id], ['store_id', '=', $store_id]]);//门店信息 $info = $info_result["data"]; if (empty($info)) { $this->error([], '门店未找到'); } $local_model = new LocalModel(); if (request()->isAjax()) { $data = [ 'type' => input('type', 'default'),//配送方式 default 商家自配送 other 第三方配送 'area_type' => input('area_type', 1),//配送区域 'local_area_json' => input('local_area_json', ''),//区域及业务集合json 'time_is_open' => input('time_is_open', 0), 'time_type' => input('time_type', 0),//时间选取类型 0 全天 1 自定义 'time_week' => input('time_week', ''), 'start_time' => input('start_time', 0), 'end_time' => input('end_time', 0), 'update_time' => time(), 'is_open_step' => input('is_open_step', 0), 'start_distance' => input('start_distance', 0), 'start_delivery_money' => input('start_delivery_money', 0), 'continued_distance' => input('continued_distance', 0), 'continued_delivery_money' => input('continued_delivery_money', 0), 'start_money' => input('start_money', 0), 'delivery_money' => input('delivery_money', 0), 'area_array' => input('area_array', ''),//地域集合 'man_money' => input('man_money', ''), 'man_type' => input('man_type', ''), 'man_discount' => input('man_discount', ''), 'time_interval' => input('time_interval', 30), 'delivery_time' => input('delivery_time', ''), 'advance_day' => input('advance_day', 0), 'most_day' => input('most_day', 7) ]; $condition = array( ['site_id', '=', $this->site_id], ['store_id', '=', $store_id], ); return $local_model->editLocal($data, $condition); } else { $this->assign('store_detail', $info); $local_result = $local_model->getLocalInfo([['site_id', '=', $this->site_id], ['store_id', '=', $store_id]]); $district_list = []; if ($info['province_id'] > 0 && $info['city_id'] > 0) { //查询省级数据列表 $address_model = new AddressModel(); $list = $address_model->getAreaList([["pid", "=", $info['city_id']], ["level", "=", 3]]); $district_list = $list["data"]; } $this->assign('district_list', $district_list); $this->assign('local_info', $local_result['data']); $config_model = new WebConfig(); $mp_config = $config_model->getMapConfig($this->site_id); $this->assign('tencent_map_key', $mp_config['data']['value']['tencent_map_key']); $this->assign('store_id', $store_id); $this->forthMenu(['store_id' => $store_id]); return $this->fetch('store/local'); } } /** * 结算设置 */ public function settlement() { $store_id = input('store_id', 0); if (empty($store_id)) { $this->error('未获取到门店信息'); } $store_model = new StoreModel(); if (request()->isAjax()) { $is_settlement = input("is_settlement", 0); if (empty($is_settlement)) { $data = [ 'is_settlement' => 0, 'settlement_rate' => 0 ]; } else { $data = [ 'is_settlement' => 1, 'settlement_rate' => input("settlement_rate", 0),//跟随系统传入0,独立设置大于0 'bank_type' => input("bank_type", 0),//1微信 2.支付宝 3,银行卡 'bank_type_name' => input("bank_type_name", ''), //账户类型名称 微信默认为微信 支付宝默认是支付宝 银行卡需要传银行名称 'bank_user_name' => input("bank_user_name", ''), //账户所属人姓名 针对银行卡需要传入 'bank_type_account' => input("bank_type_account", ''), //具体账户信息,微信需要传入微信名称 'aliapy_auto_settlement' => input("aliapy_auto_settlement", 0), //具体账户信息,微信需要传入微信名称 ]; } $condition = array( ['site_id', '=', $this->site_id], ['store_id', '=', $store_id], ); $result = $store_model->editStore($data, $condition, [], 1, 1); return $result; } $this->forthMenu(['store_id' => $store_id]); $store_info = $store_model->getStoreInfo([['site_id', '=', $this->site_id], ['store_id', '=', $store_id]]);//门店信息 if (empty($store_info)) $this->error('未获取到门店信息'); $this->assign('info', $store_info['data']); $this->assign('store_id', $store_id); $withdraw_config = (new StoreConfig())->getStoreWithdrawConfig($this->site_id); $this->assign('withdraw_config', $withdraw_config['data']['value']); return $this->fetch('store/settlement'); } /** * 配送员列表 */ public function deliverLists() { $store_id = input('store_id', 0); $deliver_model = new ExpressDeliver(); if (request()->isAjax()) { $page = input('page', '1'); $page_size = input('page_size', PAGE_LIST_ROWS); $condition = [ [ 'site_id', '=', $this->site_id, ], [ 'store_id', '=', $store_id, ] ]; $search_text = input('search_text', ''); if (!empty($search_text)) { $condition[] = ['deliver_name', 'like', '%' . $search_text . '%']; } $deliver_lists = $deliver_model->getDeliverPageLists($condition, '*', 'create_time desc', $page, $page_size); return $deliver_lists; } else { $this->assign('store_id', $store_id); $this->forthMenu(['store_id' => $store_id]); return $this->fetch('store/deliverlists'); } } /** * 添加配送员 */ public function addDeliver() { $store_id = input('store_id', 0); $this->assign('store_id', $store_id); return $this->fetch('store/adddeliver'); } /** * 编辑配送员 */ public function editDeliver() { $store_id = input('store_id', 0); $this->assign('store_id', $store_id); $deliver_model = new ExpressDeliver(); $deliver_id = input('deliver_id', 0); $this->assign('deliver_id', $deliver_id); $deliver_info = $deliver_model->getDeliverInfo($deliver_id, $this->site_id); $this->assign('deliver_info', $deliver_info['data']); return $this->fetch('store/editdeliver'); } /** * 选择门店 * @return mixed */ public function selectStore() { $store_list = (new StoreModel())->getStoreList([['site_id', '=', $this->site_id]], 'store_id,store_name,status,address,full_address,is_frozen'); $this->assign('store_list', $store_list['data']); $store_id = explode(',', input('store_id', '')); $this->assign('store_id', $store_id); return $this->fetch('store/select'); } /** * 门店主页装修 */ public function diy() { $data = [ 'site_id' => $this->site_id, 'name' => 'DIY_STORE' ]; $edit_view = event('DiyViewEdit', $data, true); return $edit_view; } /** * 门店分类 * @return mixed */ public function category() { $category = new Category(); if (request()->isAjax()) { $page = input('page', 1); $page_size = input('page_size', PAGE_LIST_ROWS); $condition = [ ['site_id', '=', $this->site_id] ]; if (!empty($search_text)) $condition[] = ['category_name', 'like', "%{$search_text}%"]; return $category->getStoreCategoryPageList($condition, $page, $page_size); } $config = $category->getCategoryConfig($this->site_id)['data']['value']; $this->assign('status', $config['status']); return $this->fetch('store/category'); } /** * 添加分类 * @return array */ public function addCategory() { if (request()->isAjax()) { $data = [ 'category_name' => input('category_name', ''), 'site_id' => $this->site_id ]; return (new Category())->addStoreCategory($data); } } /** * 编辑分类 * @return array */ public function editCategory() { if (request()->isAjax()) { $category_id = input('category_id', 0); $data = [ 'category_name' => input('category_name', ''), 'sort' => input('sort', 0) ]; return (new Category())->editStoreCategory($data, [['category_id', '=', $category_id], ['site_id', '=', $this->site_id]]); } } /** * 删除分类 * @return array */ public function deleteCategory() { if (request()->isAjax()) { $category_id = input('category_id', 0); return (new Category())->deleteStoreCategory([['category_id', 'in', $category_id], ['site_id', '=', $this->site_id]]); } } /** * 门店分类是否启用 */ public function categoryConfig() { if (request()->isAjax()) { $status = input('status', 0); return (new Category())->setCategoryConfig(['status' => $status], $this->site_id); } } /** * 门店标签 * @return mixed */ public function tag() { if (request()->isAjax()) { $page = input('page', 1); $page_size = input('page_size', PAGE_LIST_ROWS); $search_text = input('search_text', ''); $condition = [ ['site_id', '=', $this->site_id] ]; if (!empty($search_text)) $condition[] = ['label_name', 'like', "%{$search_text}%"]; return (new Label())->getStoreLabelPageList($condition, $page, $page_size); } return $this->fetch('store/tag'); } /** * 添加标签 * @return array */ public function addLabel() { if (request()->isAjax()) { $data = [ 'label_name' => input('label_name', ''), 'site_id' => $this->site_id, 'create_time' => time() ]; return (new Label())->addStoreLabel($data); } } /** * 编辑标签 * @return array */ public function editLabel() { if (request()->isAjax()) { $label_id = input('label_id', 0); $data = [ 'label_name' => input('label_name', ''), 'sort' => input('sort', 0) ]; return (new Label())->editStoreLabel($data, [['label_id', '=', $label_id], ['site_id', '=', $this->site_id]]); } } /** * 删除标签 * @return array */ public function deleteLabel() { if (request()->isAjax()) { $label_id = input('label_id', 0); return (new Label())->deleteStoreLabel([['label_id', '=', $label_id], ['site_id', '=', $this->site_id]]); } } /** * 门店标签选择框 * @return mixed */ public function labelSelect() { if (request()->isAjax()) { $page = input('page', 1); $page_size = input('page_size', PAGE_LIST_ROWS); $search_text = input('search_text', ''); $condition = [ ['site_id', '=', $this->site_id] ]; if (!empty($search_text)) $condition[] = ['label_name', 'like', "%{$search_text}%"]; return (new Label())->getStoreLabelPageList($condition, $page, $page_size); } else { $select_id = input('select_id', ''); $this->assign('select_id', $select_id); return $this->fetch('store/label_select'); } } /** * 修改排序 */ public function modifySort() { if (request()->isAjax()) { $sort = input('sort', 0); $label_id = input('label_id', 0); $label_model = new Label(); $res = $label_model->modifySort($sort, $label_id, $this->site_id); return $res; } } /*** * 获取门店二维码 * @return void */ public function storeqr() { $site_id = $this->site_id; $store_id = input('store_id'); $qrcode_param = [ 'store_id' => $store_id ]; $page = '/pages/index/index'; $promotion_type = ''; $params = [ 'site_id' => $site_id, 'data' => $qrcode_param, 'page' => $page, 'promotion_type' => '', 'h5_path' => $page . '?store_id=' . $store_id, 'qrcode_path' => 'upload/qrcode/bale', 'qrcode_name' => [ 'h5_name' => 'bale_qrcode_' . $promotion_type . '_h5_' . $store_id . '_' . $site_id, 'alipay_name' => 'bale_qrcode_' . $promotion_type . '_alipay_name_' . $store_id . '_' . $site_id, 'weapp_name' => 'bale_qrcode_' . $promotion_type . '_weapp_' . $store_id . '_' . $site_id ] ]; $solitaire = event('ExtensionInformation', $params, true); return success(0, '成功', $solitaire); } // 门店收款码 public function payQrCode(){ $site_id = $this->site_id; $store_id = input('store_id'); $qrcode_param = [ 'store_id' => $store_id ]; $page = '/pages_tool/pay/online_payment'; $promotion_type = ''; $params = [ 'site_id' => $site_id, 'data' => $qrcode_param, 'page' => $page, 'promotion_type' => '', 'h5_path' => $page . '?store_id=' . $store_id, 'qrcode_path' => 'upload/qrcode/bale', 'qrcode_name' => [ 'h5_name' => 'bale_qrcode_' . $promotion_type . '_h5_' . $store_id . '_' . $site_id, 'alipay_name' => 'bale_qrcode_' . $promotion_type . '_alipay_name_' . $store_id . '_' . $site_id, 'weapp_name' => 'bale_qrcode_' . $promotion_type . '_weapp_' . $store_id . '_' . $site_id ] ]; $solitaire = event('ExtensionInformation', $params, true); return success(0, '成功', $solitaire); } }