'0%','radio_num'=>'0.0'], ['radio'=>'10%','radio_num'=>'0.1'], ['radio'=>'20%','radio_num'=>'0.2'], ['radio'=>'30%','radio_num'=>'0.3'], ['radio'=>'40%','radio_num'=>'0.4'], ['radio'=>'50%','radio_num'=>'0.5'], ['radio'=>'60%','radio_num'=>'0.6'], ['radio'=>'70%','radio_num'=>'0.7'], ['radio'=>'80%','radio_num'=>'0.8'], ['radio'=>'90%','radio_num'=>'0.9'], ['radio'=>'100%','radio_num'=>'1'], ); //通过自增id获取平台列表的信息 public function actionApplyDetails() { $request = Yii::$app->request; if ($request->isGet) { $id = Yii::$app->request->get('id'); $data = (new \yii\db\Query()) ->select('sort,apply_name,apply_image,apply_qr_code,apply_type,channel_str,use_str,plug_str,dt_operdate,time_type,time_type,end_time') ->from('{{%ybwm_apply}}') ->where(['id' => $id]) ->orderBy(['id' => 'asc']) ->one(); //var_dump($re);die; $row = getSysInfo(); $channelArr = $row['authData']['channel']; $plugArr = $row['authData']['plug']; $channelConfig = Config::channelConfig(); foreach ($channelConfig as $v) { if (in_array($v['name'], $channelArr)) { $channel_list[] = $v; } } $data['channel_list'] = $channel_list; $plug_list = []; $plugConfig = Config::plugConfig(); foreach ($plugConfig as $v) { if (in_array($v['name'], $plugArr)) { $plug_list[] = $v; } } $data['plug_list'] = $plug_list; $data['service_list'] = Config::serviceConfig(); $data['use_list'] = Config::menuConfig(); $data['app_name'] = $row['appName']; $sysInfo = Config::getSystemSet('sysTopImage', $id); $data['channel_str'] = $sysInfo['channel_arr'] ?: $row['authData']['channel']; $data['plug_str'] = $sysInfo['plug_str'] ?: []; $data['instore'] = $sysInfo['instore'] ?: '2'; $data['takeout'] = $sysInfo['takeout'] ?: '1'; $data['use_str'] = $sysInfo['use_str'] ?: []; $data['service'] = $row['authData']['service']; //$data['service']=$sysInfo['service']?:$row['authData']['service']; $data['shopModel'] = $sysInfo['shopModel'] ?: 2; $data['shopNum'] = $sysInfo['shopNum'] ?: 0; $data['deliveryMode'] = $sysInfo['deliveryMode'] ?: []; $superPowerData = Config::getSystemSet('sysTopImage', $id); if (!$superPowerData) { $superPowerData = Config::getSystemSet('superPower', 0); } $data['deliveryModeData'] = array( array( 'value' => '9', 'name' => $superPowerData['yunbeiName'] ?: '云贝配送' ), array( 'value' => '2', 'name' => '达达配送' ), array( 'value' => '3', 'name' => '点我达' ), array( 'value' => '5', 'name' => '顺丰同城' ), array( 'value' => '6', 'name' => '蜂鸟即配' ), array( 'value' => '7', 'name' => '闪送' ), array( 'value' => '8', 'name' => 'uu跑腿' ), array( 'value' => '4', 'name' => $superPowerData['makeName'] ?: '码科配送' ), array( 'value' => '1', 'name' => '商家配送' ), ); return $this->result(1, '成功', $data); } return $this->result(2, '请求异常'); } //获取可用插件 public function actionGetplug_str() { $request = Yii::$app->request; if ($request->isGet) { $sql = 'select * from {{%ybwm_plug_unit}} where status=1'; $page = Yii::$app->request->get('page') ? Yii::$app->request->get('page') : 1; $num = 10 * $page; if ($page == 1) { $sql .= " limit 10"; } else { $sql .= " limit 10,$num"; } $re = YII::$app->db->createCommand($sql)->queryAll(); return $this->result(1, '成功', $re); } return $this->result(2, '请求异常'); } //获取可用渠道 public function actionGetchannel_str() { $request = Yii::$app->request; if ($request->isGet) { $re = YII::$app->db->createCommand('select * from {{%ybwm_channel_list}} where status=:status', ['status' => 1])->queryAll(); return $this->result(1, '成功', $re); } return $this->result(2, '请求异常'); } //添加平台表单页面 public function actionPlatform_add() { // if('192.168.3.14' == $_SERVER['REMOTE_ADDR']){ // $this->actionPassivescanpay(); // } // $data=array('web_url'=>Yii::$app->request->hostInfo,'status'=>1); // //获取项目的应用列表 // $url=Yii::$app->params['domain_url'].'/cloud/upgraded/getapp'; // $data=json_decode(httpRequest($url,$data)); return $this->renderpartial('platform_add'); } //门店列表页面 public function actionPlatform_storelist() { $id = ''; $request = Yii::$app->request; if ($request->isGet) { $result = axios_request(); $id = $result['id']; } return $this->renderpartial('platform_storelist',['id'=>$id]); } //门店列表 public function actionGetstorelist() { $request = Yii::$app->request; if ($request->isGet) { $result = axios_request(); $id = $result['id']; $page = Yii::$app->request->get('page') ? Yii::$app->request->get('page') : 1; $num = ($page - 1) * 10; $limit = 10; $query = (new \yii\db\Query()) // ->select('a.id as store_id,a.uniacid as apply_id,a.name as store_name, b.apply_name,sp.channel_id') ->select('a.id as store_id,a.uniacid as apply_id,a.name as store_name, b.apply_name') ->from('{{%ybwm_store}} a') ->leftJoin('{{%ybwm_apply}} b', 'b.id=a.uniacid') // ->leftJoin('{{%ybwm_store_paychannel}} sp', 'sp.apply_id=a.uniacid and a.id=sp.store_id') // ->leftJoin('{{%ybwm_pay_channel}} pc', 'pc.channel_id=sp.channel_id') ->where(['a.uniacid' => $id]); $count = count($query->all()); $re = $query->offset($num) ->limit($limit) ->all(); if($re){ $store_id_arr = array_column($re,'store_id'); $store_id_str = implode(',',$store_id_arr); $sql = "select pc.channel_name as channel_name,sp.channel_radio as channel_radio from {{%ybwm_store_paychannel}} as sp join {{%ybwm_pay_channel}} as pc on sp.channel_id = pc.channel_id where sp.is_del = 0 and sp.store_id in ($store_id_str)"; $channel_data = Yii::$app->db->createCommand($sql)->queryAll(); if($channel_data){ $temp = []; foreach ($channel_data as $val){ $temp[] = $val['channel_name'] . ($val['channel_radio'] >= 0 ? ('(' . $val['channel_radio']*100 . '%)') : '') ; } } foreach ($re as $key=>$val){ $temp = []; if(!empty($val['store_id'])){ $sql = "select pc.channel_name as channel_name,sp.channel_radio as channel_radio from {{%ybwm_store_paychannel}} as sp join {{%ybwm_pay_channel}} as pc on sp.channel_id = pc.channel_id where sp.is_del = 0 and sp.store_id = '{$val['store_id']}'"; $channel_data = Yii::$app->db->createCommand($sql)->queryAll(); if($channel_data){ foreach ($channel_data as $c_val){ $temp[] = $c_val['channel_name'] . (($c_val['channel_radio'] >=0) ? '(' . $c_val['channel_radio']*100 . '%)' : ''); } } } $re[$key]['channel_name'] = $temp ? implode(' , ',$temp) : ''; } } echo json_encode(['code' => 1, 'msg' => '成功', 'data' => $re, 'count' => intval($count)]); die; } } //通道配置保存 public function actionPaymentstoresave() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $connection = Yii::$app->db; $store_id = $result['store_id']; $apply_id = $result['apply_id']; $bind_id_arr = $result['bind_id']; $channel_select_arr = array_filter($result['channel_select']); $public_key_arr = array_filter($result['public_key']); $private_key_arr = array_filter($result['private_key']); $ins_num_arr = array_filter($result['ins_num']); $merchant_num_arr = array_filter($result['merchant_num']); $channel_select_arr_len = count($channel_select_arr); $public_key_arr_len = count($public_key_arr); $private_key_arr_len = count($private_key_arr); $ins_num_arr_len = count($ins_num_arr); $merchant_num_arr_len = count($merchant_num_arr); $num_arr = [$channel_select_arr_len,$public_key_arr_len,$private_key_arr_len,$ins_num_arr_len,$merchant_num_arr_len]; $unique_num_arr = array_unique($num_arr); if(empty($store_id) || empty($apply_id)){ return $this->result(2, '参数错误,请重新加载页面尝试!'); } if(count($unique_num_arr) != 1) { return $this->result(2, '请完成信息的填写!'); } if(empty($store_id) || empty($apply_id)){ return $this->result(2, '参数错误,请重新加载页面尝试!'); } $channel_select_arrs = []; foreach ($channel_select_arr as $key=>$val){ $channel_select_arrs[$key] = '"'.$val.'"'; } $channel_select_str = implode(',',$channel_select_arrs); $channel_all_data = $connection->createCommand("select * from {{%ybwm_pay_channel}} where status=1 and channel_name in ({$channel_select_str})")->queryAll(); $channel_all_data_arr = []; foreach ($channel_all_data as $key=>$val){ $channel_all_data_arr[$val['channel_name']] = $val['channel_id']; } $info_data = []; for($i=0;$i<$channel_select_arr_len;$i++){ if(!isset($channel_all_data_arr[$channel_select_arr[$i]])){ return $this->result(2, '参数错误,请重新加载页面尝试!'); } $tem['bind_id'] = $bind_id_arr[$i]; $tem['channel_id'] = $channel_all_data_arr[$channel_select_arr[$i]]; $tem['public_key'] = $public_key_arr[$i]; $tem['private_key'] = $private_key_arr[$i]; $tem['ins_num'] = $ins_num_arr[$i]; $tem['merchant_num'] = $merchant_num_arr[$i]; $info_data[] = $tem; } $is_exist_data = $connection->createCommand("select * from {{%ybwm_store_paychannel}} where is_del = 0 and store_id='{$store_id}' and apply_id = '{$apply_id}'")->queryAll(); if($is_exist_data){ $transaction = Yii::$app->db->beginTransaction(); try { foreach ($info_data as $info_key=>$info_val) { $ins_data['apply_id'] = $apply_id; $ins_data['store_id'] = $store_id; $ins_data['channel_id'] = $info_val['channel_id']; $ins_data['public_key'] = $info_val['public_key']; $ins_data['private_key'] = $info_val['private_key']; $ins_data['ins_num'] = $info_val['ins_num']; $ins_data['merchant_num'] = $info_val['merchant_num']; if($info_val['bind_id']){//更新 $ins_data['update_time'] = time(); $ins_data['update_user_id'] = $this->getUserId(); $connection->createCommand()->update('{{%ybwm_store_paychannel}}', $ins_data, 'id=:id', ['id' => $info_val['bind_id']])->execute(); } else {//新加 $ins_data['create_time'] = time(); $ins_data['create_user_id'] = $this->getUserId(); $connection->createCommand()->insert('{{%ybwm_store_paychannel}}', $ins_data)->execute(); } } $transaction->commit(); //只有执行了commit(),对于上面数据库的操作才会真正执行 return $this->result(1, '操作成功'); } catch (Exception $e) { $error = $e->getMessage(); //获取抛出的错误 $transaction->rollBack(); return $this->result(2, '网络异常,请稍后再试'); } } else {//新增 $transaction = Yii::$app->db->beginTransaction(); try { foreach ($info_data as $info_key=>$info_val) { $ins_data = []; $ins_data['apply_id'] = $apply_id; $ins_data['store_id'] = $store_id; $ins_data['channel_id'] = $info_val['channel_id']; $ins_data['public_key'] = $info_val['public_key']; $ins_data['private_key'] = $info_val['private_key']; $ins_data['ins_num'] = $info_val['ins_num']; $ins_data['merchant_num'] = $info_val['merchant_num']; $ins_data['create_time'] = time(); $ins_data['create_user_id'] = $this->getUserId(); $connection->createCommand()->insert('{{%ybwm_store_paychannel}}', $ins_data)->execute(); } $transaction->commit(); //只有执行了commit(),对于上面数据库的操作才会真正执行 return $this->result(1, '操作成功'); } catch (Exception $e) { $error = $e->getMessage(); //获取抛出的错误 $transaction->rollBack(); return $this->result(2, '网络异常,请稍后再试'); } } return $this->result(2, '网络异常,请稍后再试'); } return $this->result(2, '请求异常'); } //通道设置-获取已设置通道 function actionGetPaymentList(){ $request = Yii::$app->request; if ($request->isGet) { $result = axios_request(); $store_id = $result['store_id']; $res = (new \yii\db\Query()) // ->select('channel_id,channel_radio') ->from('{{%ybwm_store_paychannel}}') ->where(['store_id' => $store_id,'is_del'=>0]) ->all(); } $data = (new \yii\db\Query()) ->select('channel_id,channel_name') ->from('{{%ybwm_pay_channel}}') ->where(['status' => 1]) ->orderBy(['channel_id' => 'asc']) ->all(); $select_data_len = empty($res) ? [1] : range(1,count($res)); return $this->renderpartial('payment_store', [ 'data'=>json_encode($data,true), 'select_data'=>json_encode($res,true), 'select_data_len'=>json_encode($select_data_len,true), ] ); } //规则设置-获取已设置的通道规则(交易占比) function actionGetBindChannelList(){ $request = Yii::$app->request; if ($request->isGet) { $result = axios_request(); $store_id = $result['store_id']; $res = (new \yii\db\Query()) // ->select('channel_id,channel_radio') ->from('{{%ybwm_store_paychannel}}') ->where(['store_id' => $store_id,'is_del'=>0]) ->all(); } $data = (new \yii\db\Query()) ->select('channel_id,channel_name') ->from('{{%ybwm_pay_channel}}') ->where(['status' => 1]) ->orderBy(['channel_id' => 'asc']) ->all(); $select_data_len = empty($res) ? [1] : range(1,count($res)); return $this->renderpartial('payment_rulesetting', [ 'data'=>json_encode($data,true), 'select_data'=>json_encode($res,true), 'select_data_len'=>json_encode($select_data_len,true), ] ); } //规则设置-保存设置的交易占比规则 public function actionPaymentRadioSave() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $connection = Yii::$app->db; $store_id = $result['store_id']; $apply_id = $result['apply_id']; $bind_id_arr = array_filter($result['bind_id']); $channel_radio_arr = $result['channel_radio']; $bind_id_arr_len = count($bind_id_arr); $channel_radio_arr_len = count($channel_radio_arr); if(empty($store_id) || empty($apply_id) || ($channel_radio_arr_len != $bind_id_arr_len)){ return $this->result(2, '参数错误,请重新加载页面尝试!'); } $radio_arr = []; $store_channel_radio_data = []; for ($i=0;$i<$bind_id_arr_len;$i++){ $radio_arr[] = (int)($channel_radio_arr[$i]*100); $temp['bind_id'] = $bind_id_arr[$i]; $temp['channel_radio'] = $channel_radio_arr[$i]; $store_channel_radio_data[] = $temp; } if(array_sum($radio_arr) != 100) { return $this->result(2, '交易占比之和必须为1'); } $transaction = Yii::$app->db->beginTransaction(); try { foreach ($store_channel_radio_data as $key=>$val){ $sql = "select * from {{%ybwm_store_paychannel}} where is_del=0 and id = '{$val['bind_id']}'"; $is_exist_data = $connection->createCommand($sql)->queryone(); if($is_exist_data && $is_exist_data['channel_radio'] != $val['channel_radio']){ $up_data['channel_radio'] = $val['channel_radio']; $up_data['update_time'] = time(); $up_data['update_user_id'] = $val['channel_radio']; $re = $connection->createCommand()->update('{{%ybwm_store_paychannel}}', $up_data, ['id' => $val['bind_id']])->execute(); } } $transaction->commit(); //只有执行了commit(),对于上面数据库的操作才会真正执行 return $this->result(1, '操作成功'); } catch (Exception $e) { $error = $e->getMessage(); //获取抛出的错误 $transaction->rollBack(); return $this->result(2, '网络异常,请稍后再试'); } } return $this->result(2, '请求异常'); } //规则通道 function actionGetPaymentList1(){ $request = Yii::$app->request; $bind_channel_id = ''; if ($request->isGet) { $result = axios_request(); $store_id = $result['store_id']; $res = (new \yii\db\Query()) ->select('channel_id,channel_radio') ->from('{{%ybwm_store_paychannel}}') ->where(['store_id' => $store_id,'is_del'=>0]) ->one(); if($res){ $bind_channel_id = $res['channel_id'] ? explode(',',$res['channel_id']) : ''; $channel_radio_data = json_decode($res['channel_radio'],true); if($channel_radio_data){ foreach ($channel_radio_data as $key=>$val){ $channel_radio_data[$key]['pay_radio'] = $val['pay_radio']*100 .'%'; } } } } $data = (new \yii\db\Query()) ->select('channel_id,channel_name') ->from('{{%ybwm_pay_channel}}') ->where(['status' => 1]) ->orderBy(['channel_id' => 'asc']) ->all(); $channel_radio_data = empty($channel_radio_data) ? [1] : $channel_radio_data; return $this->renderpartial('payment_store', [ 'data'=>json_encode($data,true), 'bind_store_id'=>json_encode($bind_channel_id,true), 'pay_radio_arr'=>json_encode($this->pay_radio_arr,true), 'channel_radio_data'=>json_encode($channel_radio_data,true), ] ); } //门店列表根据条件搜索出结果 public function actionStorebysearch() { $request = Yii::$app->request; if ($request->isPost) { $request = axios_request(); $store_id = trim($request['store_id']); $apply_id = $request['apply_id']; $store_name = trim($request['store_name']); $start_time = $request['start_time'] ? strtotime($request['start_time']) : ''; $end_time = $request['end_time'] ? strtotime($request['end_time'])+86399 : ''; if(!$apply_id){ return $this->result(2, '参数错误请重试!'); } $page = Yii::$app->request->get('page') ? Yii::$app->request->get('page') : 1; $num = ($page - 1) * 10; $limit = 10; $query = (new \yii\db\Query()) ->select('a.id as store_id,a.uniacid as apply_id,a.name as store_name, b.apply_name,pc.channel_name' ) ->from('{{%ybwm_store}} a') ->leftJoin('{{%ybwm_apply}} b', 'b.id=a.uniacid') ->leftJoin('{{%ybwm_store_paychannel}} sp', 'sp.apply_id=a.uniacid and a.id=sp.store_id') ->leftJoin('{{%ybwm_pay_channel}} pc', 'pc.channel_id=sp.channel_id') ->andWhere(['a.uniacid'=>$apply_id,'sp.is_del'=>0]); if ($store_id) { $query->andWhere(['a.id'=>$store_id]); } if ($store_name) { $query->andWhere(['like', 'a.name', $store_name]); } if ($start_time && $end_time) { $query->andWhere(['between', 'create_time',$start_time,$end_time]); } if ($page == 1) { $query->limit($limit); } else { $query->limit($limit, $num); } $count = count($query->all()); $re = $query->all(); return $this->result(1, '成功', $re, intval($count)); } return $this->result(2, '请求异常'); } public function actionGetApplyStoreInfo() { $request = Yii::$app->request; $sql = " select a.id as apply_id,a.apply_name,b.id as store_id,b.name as store_name from {{%ybwm_apply}} a left join {{%ybwm_store}} b on a.id = b.uniacid where a.status = 1 and b.display = 1 order by a.id asc "; $data = Yii::$app->db->createCommand($sql)->queryAll(); $apply_data = $store_data = []; if (!empty($data)) { foreach ($data as $key => $val) { $temp['store_id'] = $val['store_id']; $temp['store_name'] = $val['store_name']; $temp['apply_name'] = $val['apply_name']; $store_data[] = $temp; // if (!isset($apply_data[$val['apply_id']])) { // $apply_data[$val['apply_id']] = $val['apply_name']; // } // $temp['store_id'] = $val['store_id']; // $temp['store_name'] = $val['store_name']; // $store_data[$val['apply_name']][] = $temp; } } // $res['apply_data'] = $apply_data; $res['store_data'] = $store_data; return $this->result(1, '成功', $res); } //获取应用版本 插件 渠道 列表 public function actionGetAppInfo() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); //$data=array('web_url'=>Yii::$app->request->hostInfo,'status'=>$result['status']); //获取项目的应用列表 $res = getSysInfo(); $channelArr = $res['authData']['channel']; $plugArr = $res['authData']['plug']; $channel_list = []; //获取可用渠道 $channelConfig = Config::channelConfig(); foreach ($channelConfig as $v) { if (in_array($v['name'], $channelArr)) { $channel_list[] = $v; } } $plug_list = []; $plugConfig = Config::plugConfig(); foreach ($plugConfig as $v) { if (in_array($v['name'], $plugArr)) { $plug_list[] = $v; } } //获取连锁版的证书配置 $appConfig = Config::appConfig(); foreach ($appConfig as $v) { if ($v['use_name'] == $res['appName']) { $app_list[] = $v; } } $superPowerData = Config::getSystemSet('superPower', 0); $data['deliveryMode'] = array( array( 'value' => '9', 'name' => $superPowerData['yunbeiName'] ?: '云贝配送' ), array( 'value' => '2', 'name' => '达达配送' ), array( 'value' => '3', 'name' => '点我达' ), array( 'value' => '5', 'name' => '顺丰同城' ), array( 'value' => '6', 'name' => '蜂鸟即配' ), array( 'value' => '7', 'name' => '闪送' ), array( 'value' => '8', 'name' => 'uu跑腿' ), array( 'value' => '4', 'name' => $superPowerData['makeName'] ?: '码科配送' ), array( 'value' => '1', 'name' => '商家配送' ), ); $data['app'] = $app_list; $data['channel_list'] = $channel_list; $data['use_list'] = Config::menuConfig(); $data['plug_list'] = $plug_list; $data['service_list'] = Config::serviceConfig(); $data['service'] = $res['authData']['service']; // $url=Yii::$app->params['domain_url'].'/cloud/upgraded/getapp'; // $data=httpRequest($url,$data); return $this->result(1, '成功', $data); //echo $app_data;die; } return $this->result(2, '请求异常'); } public function actionPlatform_recycle() { return $this->renderpartial('platform_recycle'); } //平台应用添加 public function actionApplyadd() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $connection = Yii::$app->db; $apply_name = $result['apply_name']; $command = $connection->createCommand("select * from {{%ybwm_apply}} where apply_name='$apply_name'"); $re = $command->queryOne(); if ($re) { return $this->result(2, '平台名称已存在'); } $time_type = $result['time_type']; if ($time_type == 2) { $result['end_time'] = '3000-12-31 23:59:59'; } $data = array( 'sort' => $result['sort'], 'apply_name' => $result['apply_name'], 'apply_type' => $result['apply_type'], 'create_shop_count' => $result['create_shop_count'], 'end_time' => $result['end_time'], 'start_time' => $result['end_time'], 'dt_operdate' => date('Y-m-d H:i:s', time()), 'plug_str' => json_encode($result['plug_str']) ?: '', 'time_type' => $time_type, 'channel_str' => json_encode($result['channel_str']) ?: '', 'use_str' => json_encode($result['use_str']) ?: '', ); $data['apply_image'] = $result['apply_image']; $data['apply_qr_code'] = $result['apply_qr_code']; $res = $connection->createCommand()->insert('{{%ybwm_apply}}', $data)->execute(); $id = Yii::$app->db->getLastInsertID(); //保存权限到设置表 $plug = getSysInformation(); $superData = array( 'channel_arr' => $result['channel_str'] ?: '', 'plug_str' => $result['plug_str'] ?: '', 'use_str' => $result['use_str'] ?: '', 'app' => $plug['appData'], 'shopModel' => $result['shopModel'], 'shopNum' => $result['shopNum'], 'instore' => $result['instore'], 'deliveryMode' => $result['deliveryMode'], 'cashierName' => $result['cashierName'], 'cashierIcon' => $result['cashierIcon'], 'cashierBg' => $result['cashierBg'], 'takeout' => $result['takeout'], ); Config::saveSystemSet($superData, 'sysTopImage', $id, '网站头部LOGO'); if ($res) { return $this->result(1, '成功', $id); } else { return $this->result(2, '网络异常,请稍后再试'); } } return $this->result(2, '请求异常'); } //平台应用修改 public function actionApplyusave() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $config = getSysInfo(); $time_type = $result['time_type']; if ($time_type == 2) { $result['end_time'] = '3000-12-31 23:59:59'; } $data = array( 'sort' => $result['sort'], 'apply_name' => $result['apply_name'], 'apply_type' => $result['apply_type'], 'channel_str' => json_encode($result['channel_str']) ?: '', 'plug_str' => json_encode($result['plug_str']) ?: '', 'use_str' => json_encode($result['use_str']) ?: '', 'create_shop_count' => $result['create_shop_count'], 'start_time' => $result['end_time'], 'end_time' => $result['end_time'], 'up_operdate' => date('Y-m-d H:i:s', time()), 'time_type' => $time_type, 'apply_image' => $result['apply_image'], 'apply_qr_code' => $result['apply_qr_code'], ); //保存权限到设置表 $superData = Config::getSystemSet('sysTopImage', $result['id']); $superData['channel_arr'] = $result['channel_str'] ?: ''; $superData['plug_str'] = $result['plug_str'] ?: ''; $superData['use_str'] = $result['use_str'] ?: ''; $superData['service'] = $config['authData']['service']; $superData['shopModel'] = $result['shopModel']; $superData['shopNum'] = $result['shopNum']; $superData['instore'] = $result['instore']; $superData['deliveryMode'] = $result['deliveryMode']; $superData['cashierName'] = $result['cashierName']; $superData['cashierIcon'] = $result['cashierIcon']; $superData['cashierBg'] = $result['cashierBg']; $superData['takeout'] = $result['takeout']; Config::saveSystemSet($superData, 'sysTopImage', $result['id'], '网站头部LOGO'); $res = YII::$app->db->createCommand()->update('{{%ybwm_apply}}', $data, 'id=:id', ['id' => $result['id']])->execute(); if ($res !== false) { return $this->result(1, '成功'); } else { return $this->result(2, '网络异常,请稍后再试'); } } return $this->result(2, '请求异常'); } //平台列表 public function actionApplylist() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $keyword = $result['apply_name']; $satus = $result['status'] ? $result['status'] : 2; $sql = "select *,count(*)as count from {{%ybwm_users}} where status='$satus'"; if ($keyword) { $sql .= " and CONCAT(IFNULL(username,''),IFNULL(phone,'')) LIKE CONCAT('%','$keyword','%')"; } $page = $result['page'] ? $result['page'] : 1; $num = 10 * $page; if ($page == 1) { $sql .= " limit 10"; } else { $sql .= " limit 10,$num"; } $data = YII::$app->db->createCommand($sql)->queryAll(); if ($data) { $count = count($data); echo json_encode(['code' => 1, 'msg' => $data, 'count' => $count]); } else { echo json_encode(['code' => 2, 'msg' => '没有您搜索的条件']); } } } //停用平台 public function actionDelapply() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $status = $result['status']; $id = $result['id']; if (is_string($id)) { $res = YII::$app->db->createCommand("select * from {{%ybwm_apply}} where id='$id'")->queryOne(); } if (is_array($id)) { $where = '(' . implode(',', $id) . ')'; $res = YII::$app->db->createCommand("select * from {{%ybwm_apply}} where id in" . $where)->queryOne(); } if (!$res) { return $this->result(2, '平台信息不存在'); } else { if (is_array($id)) { if ($status < 3) { $re = YII::$app->db->createCommand()->update('{{%ybwm_apply}}', ['status' => $status, 'up_operdate' => date('Y-m-d H:i:s', time())], "id in $where")->execute(); } if ($status == 3) { $re = YII::$app->db->createCommand()->delete('{{%ybwm_apply}}', ['in', 'id', $id])->execute(); Yii::$app->db->createCommand() ->delete('{{%ybwm_users}}', ['in', 'uniacid', $id]) ->execute(); } } else { if ($status < 3) { $re = YII::$app->db->createCommand()->update('{{%ybwm_apply}}', ['status' => $status, 'up_operdate' => date('Y-m-d H:i:s', time())], ['id' => $id])->execute(); } if ($status == 3) { $re = YII::$app->db->createCommand()->delete('{{%ybwm_apply}}', ['id' => $id])->execute(); Yii::$app->db->createCommand() ->delete('{{%ybwm_users}}', 'uniacid=:uniacid', [':uniacid' => $id]) ->execute(); } } if ($re !== false) { return $this->result(1, '成功'); } } } return $this->result(2, '请求异常'); } //平台列表展示页面 public function actionPlatform_management() { //同步网站名称 // $fileData=file_get_contents('./web/secret.json'); // $jsonData=json_decode(ybwmDecrypt($fileData,Yii::$app->params['channel_model_name']),true); // if(!$jsonData['domainName']){ // $re=(new \yii\db\Query()) // ->from('{{%ybwm_admin}}') // ->one(); // $data=array( // 'domainName'=>$re['domainName'], // 'domainUrl'=>Yii::$app->request->hostInfo, // 'isDev'=>Yii::$app->params['isDev'] // ); // $url=Yii::$app->params['domain_url'].'/cloud/safe/sendDomainName'; // $file_arr=httpRequest($url,$data); // } //$domianInfo=getVersion(); $fileData = file_get_contents('./web/secret.json'); $domianInfo = json_decode(ybwmDecrypt($fileData, Yii::$app->params['channel_model_name']), true); //dd($domianInfo);die; if (Yii::$app->session->get('adminInfo')['loginType'] <> 2) { $table = (new \yii\db\Query()) ->from('{{%ybwm_apply}}'); $data['created'] = $table ->where('status=1 AND end_time>:end_time', [':end_time' => date("Y-m-d H:i:s")]) ->count(); $data['recycle'] = $table ->where('status=2') ->count(); $data['expire'] = $table ->where('status=1 AND end_time<:end_time', [':end_time' => date("Y-m-d H:i:s")]) ->count(); if ($domianInfo['account_type'] == 1) { $data['surplus'] = '无限'; } else { $all = $table ->where('status!=3') ->count(); if ($domianInfo['account_type'] == 2) { $num = bcsub($domianInfo['account_number'], $all, 0); if ($num > 0) { $data['surplus'] = $num; } else { $data['surplus'] = 0; } } else { $data['surplus'] = '无限'; } } } else { $phone = Yii::$app->session->get('adminInfo')['phone']; $table = (new \yii\db\Query()) ->from('{{%ybwm_apply}} a') ->leftJoin('{{%ybwm_users}} b', 'a.id=b.uniacid'); $data['created'] = $table ->where('a.status=1 and b.type=1 and b.phone=' . $phone) ->count(); $data['recycle'] = $table ->where('a.status=2 and b.type=1 and b.phone=' . $phone) ->count(); $data['expire'] = $table ->where('a.status=1 and b.type=1 and b.phone=' . $phone . ' AND end_time<:end_time', [':end_time' => date("Y-m-d H:i:s")]) ->count(); if ($domianInfo['account_type'] == 1) { $data['surplus'] = '无限'; } else { $all = $table ->where('a.status!=3 and b.type=1 and b.phone=' . $phone) ->count(); if ($domianInfo['account_type'] == 2) { $num = bcsub($domianInfo['account_number'], $all, 0); if ($num > 0) { $data['surplus'] = $num; } else { $data['surplus'] = 0; } } else { $data['surplus'] = '无限'; } } $applyOper = (new \yii\db\Query()) ->from('{{%ybwm_users}}') ->where(['phone' => Yii::$app->session->get('adminInfo')['phone'], 'type' => 1])->one(); $data['surplus'] = $applyOper['appNum'] - $data['created']; } $this->view->params['userType'] = Yii::$app->session->get('adminInfo')['userType']; //dd($domianInfo);die; return $this->renderPartial('platform_management', ['data' => $data]); } //支付通道列表展示页面 public function actionPlatform_payment() { return $this->renderPartial('platform_payment', ['data' => '']); } //支付通道添加 public function actionPayment_add() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $connection = Yii::$app->db; $channel_name = $result['channel_name']; $command = $connection->createCommand("select * from {{%ybwm_pay_channel}} where channel_name='{$channel_name}' and status = 1"); $re = $command->queryOne(); if ($re) { return $this->result(2, '支付通道已存在!'); } $now_time = time(); $data = array( 'channel_name' => $result['channel_name'], 'status' => $result['status'], 'create_time' => $now_time, 'create_user_id' => $this->getUserId(), ); if(isset($result['store_id'])) { $store_ids_str = trim($result['store_id']); $store_data = $connection->createCommand("select uniacid,id as store_id from {{%ybwm_store}} where id in ({$store_ids_str})")->queryAll(); $store_data_arr = []; if(!empty($store_data)){ foreach ($store_data as $val){ $store_data_arr[$val['store_id']] = $val['uniacid']; } } $store_id_arr = explode(',',$store_ids_str); $transaction = Yii::$app->db->beginTransaction(); try { $res = $connection->createCommand()->insert('{{%ybwm_pay_channel}}', $data)->execute(); //如果执行失败则抛出错误 if($res == false) { throw new \Exception('操作失败'); } $id = Yii::$app->db->getLastInsertID(); $bind_data['channel_id'] = $id; $bind_data['create_time'] = $now_time; $bind_data['create_user_id'] = $this->getUserId(); foreach ($store_id_arr as $store_id){ $bind_data['apply_id'] = $store_data_arr[$store_id]; $bind_data['store_id'] = $store_id; $res2 = $connection->createCommand()->insert('{{%ybwm_store_paychannel}}', $bind_data)->execute(); } $transaction->commit(); //只有执行了commit(),对于上面数据库的操作才会真正执行 return $this->result(1, '成功'); } catch (Exception $e) { $error = $e->getMessage(); //获取抛出的错误 $transaction->rollBack(); return $this->result(2, '网络异常,请稍后再试'); } } else { if($connection->createCommand()->insert('{{%ybwm_pay_channel}}', $data)->execute()){ return $this->result(1, '成功'); } } return $this->result(2, '网络异常,请稍后再试'); } return $this->renderPartial('payment_add' ); } //获取支付渠道列表 public function actionGetpaychannellist() { $request = Yii::$app->request; if ($request->isGet) { $page = Yii::$app->request->get('page') ? Yii::$app->request->get('page') : 1; $num = ($page - 1) * 10; $limit = 10; $query = (new \yii\db\Query()) ->select("channel_id,channel_name,status,create_time") ->from('{{%ybwm_pay_channel}}') ; $count = count($query->all()); $res = $query->offset($num) ->limit($limit) ->orderBy('channel_id desc') ->all(); if($res){ foreach ($res as $key=>$val){ $res[$key]['status_name'] = $val['status'] == 1 ? '启用' : '禁用'; $res[$key]['create_time'] = $val['create_time'] ? date('Y-m-d H:i:s',$val['create_time']) : ''; } } echo json_encode(['code' => 1, 'msg' => '成功', 'data' => $res, 'count' => intval($count)]); die; } } //删除店铺绑定的支付通道 function actionDelpaychannel(){ $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $store_id = $result['store_id']; $id = $result['id']; if(!$id || !$store_id) { return $this->result(2, '参数错误请重新尝试!'); } $data = YII::$app->db->createCommand("select * from {{%ybwm_store_paychannel}} where id='{$id}' and store_id = '{$store_id}' and is_del=0")->queryOne(); $up_data['is_del'] = 1; $up_data['update_time'] = time(); $up_data['update_user_id'] = $this->getUserId(); if($data){ $res = YII::$app->db->createCommand()->update('{{%ybwm_store_paychannel}}', $up_data,['id' => $id])->execute(); if($res){ return $this->result(1, '删除成功'); } else { return $this->result(2, '删除失败,请稍后重试!'); } } else { return $this->result(2, '数据不存在,删除失败!'); } } } //停用支付通道 public function actionStoppaychannel() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $status = $result['status']; $id = $result['id']; if (is_string($id)) { $res = YII::$app->db->createCommand("select * from {{%ybwm_pay_channel}} where channel_id='$id'")->queryOne(); } if (is_array($id)) { $where = '(' . implode(',', $id) . ')'; $res = YII::$app->db->createCommand("select * from {{%ybwm_pay_channel}} where channel_id in" . $where)->queryOne(); } $now_time = time(); if (!$res) { return $this->result(2, '支付渠道不存在不存在'); } else { $update_data = [ 'status' => $status, 'update_time' => $now_time, 'update_user_id'=>$this->getUserId() ]; if (is_array($id)) { $re = YII::$app->db->createCommand()->update('{{%ybwm_pay_channel}}',$update_data , "channel_id in $where")->execute(); } else { $re = YII::$app->db->createCommand()->update('{{%ybwm_pay_channel}}', $update_data, ['channel_id' => $id])->execute(); } if ($re !== false) { return $this->result(1, '成功'); } } } return $this->result(2, '请求异常'); } //平台列表根据条件搜索出结果 public function actionPaychennelbysearch() { $request = Yii::$app->request; if ($request->isPost) { $request = axios_request(); $sql = (new \yii\db\Query())->from('{{%ybwm_pay_channel}}') ->select('channel_id,channel_name,status,create_time'); $channel_name = $request['channel_name']; $start_time = $request['start_time'] ? strtotime($request['start_time']) : ''; $end_time = $request['end_time'] ? strtotime($request['end_time']) + 86399 : ''; if ($channel_name) { $sql->andWhere(['like', 'channel_name', $channel_name]); } if ($start_time && $end_time) { $sql->andWhere(['between', 'create_time',$start_time,$end_time]); } $desc = $request['desc'] ?: 'desc'; if ($desc) { $sql->orderBy('channel_id ' . $desc); } $page = $request['page'] ? $request['page'] : 1; $num = 10 * $page; if ($page == 1) { $sql->limit(10); } else { $sql->limit(10, $num); } $count = count($sql->all()); $res = $sql->all(); if($res){ foreach ($res as $key=>$val){ $res[$key]['status_name'] = $val['status'] == 1 ? '启用' : '禁用'; $res[$key]['create_time'] = $val['create_time'] ? date('Y-m-d H:i:s',$val['create_time']) : ''; } } return $this->result(1, '成功', $res, intval($count)); } return $this->result(2, '请求异常'); } //支付通道修改跳转指定页面 public function actionPayment_edit(){ return $this->renderpartial('payment_edit'); } //通过自增id获取修改的的详细信息 public function actionPaymentDetails() { $request = Yii::$app->request; if ($request->isGet) { $channel_id = Yii::$app->request->get('channel_id'); $data = (new \yii\db\Query()) ->select('channel_id,channel_name,status') ->from('{{%ybwm_pay_channel}}') ->where(['channel_id' => $channel_id]) ->one(); if($data){ $sql = " select a.store_id,s.name as store_name from {{%ybwm_store_paychannel}} a left join {{%ybwm_store}} s on a.store_id=s.id where a.channel_id='$channel_id' and a.is_del = 0 order by a.store_id asc "; $bind_data = YII::$app->db->createCommand($sql)->queryAll(); $temp = []; if($bind_data){ foreach ($bind_data as $val){ $temp[] = $val['store_id']; } } $data['bind_data'] = $temp; } return $this->result(1, '成功', $data); } return $this->result(2, '请求异常'); } //支付通道修改保存 public function actionPaychannelsave() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $connection = Yii::$app->db; $channel_id = $result['channel_id']; if(empty($channel_id)){ return $this->result(2, '参数错误,请重新加载页面尝试!'); } $channel_name = $result['channel_name']; $sql = "select * from {{%ybwm_pay_channel}} where channel_name='{$channel_name}' and status = 1 and channel_id != '{$channel_id}'"; $re = $connection->createCommand($sql)->queryOne(); if ($re) { return $this->result(2, '支付通道已存在!'); } $now_time = time(); $data = array( 'channel_name' => $result['channel_name'], 'status' => $result['status'], 'update_time' => $now_time, 'update_user_id' => $this->getUserId(), ); $res = $connection->createCommand()->update('{{%ybwm_pay_channel}}', $data,['channel_id' => $channel_id])->execute(); if($res){ return $this->result(1, '操作成功'); } // $store_ids_str = trim($result['store_id']); // $store_id_arr = explode(',',$store_ids_str); // if(!empty($result['store_id'])) { // $store_data = $connection->createCommand("select uniacid,id as store_id from {{%ybwm_store}} where id in ({$store_ids_str})")->queryAll(); // $store_data_arr = []; // if(!empty($store_data)){ // foreach ($store_data as $val){ // $store_data_arr[$val['store_id']] = $val['uniacid']; // } // } // $transaction = Yii::$app->db->beginTransaction(); // try { // $is_exist_data = $connection->createCommand("select * from {{%ybwm_store_paychannel}} where channel_id ='{$channel_id}' ")->queryAll(); // //若绑定店铺存在,先删除原来绑定的,在重新入库 // if($is_exist_data){ // $del_res = YII::$app->db->createCommand()->delete('{{%ybwm_store_paychannel}}', "channel_id = {$channel_id}")->execute(); // if(!$del_res){ // throw new \Exception('操作失败1'); // } // } // $res = $connection->createCommand()->update('{{%ybwm_pay_channel}}', $data,['channel_id' => $channel_id])->execute(); // //如果执行失败则抛出错误 // if($res == false) { // throw new \Exception('操作失败'); // } // $bind_data['channel_id'] = $channel_id; // $bind_data['create_time'] = $now_time; // $bind_data['create_user_id'] = $this->getUserId(); // // foreach ($store_id_arr as $store_id){ // $bind_data['apply_id'] = $store_data_arr[$store_id]; // $bind_data['store_id'] = $store_id; // $res2 = $connection->createCommand()->insert('{{%ybwm_store_paychannel}}', $bind_data)->execute(); // } // $transaction->commit(); //只有执行了commit(),对于上面数据库的操作才会真正执行 // return $this->result(1, '修改成功'); // } // catch (Exception $e) { // $error = $e->getMessage(); //获取抛出的错误 // $transaction->rollBack(); // return $this->result(2, '网络异常,请稍后再试'); // } // } else { // $transaction = Yii::$app->db->beginTransaction(); // try { // //修改如果没有绑定店铺,则表示删除了绑定店铺 // $is_exist_data = $connection->createCommand("select * from {{%ybwm_store_paychannel}} where channel_id ='{$channel_id}' ")->queryAll(); // //若绑定店铺存在,先删除原来绑定的,在重新入库 // if($is_exist_data){ // $del_res = YII::$app->db->createCommand()->delete('{{%ybwm_store_paychannel}}', "channel_id = {$channel_id}")->execute(); // if(!$del_res){ // throw new \Exception('操作失败1'); // } // } // $res = $connection->createCommand()->update('{{%ybwm_pay_channel}}', $data,['channel_id' => $channel_id])->execute(); // $transaction->commit(); //只有执行了commit(),对于上面数据库的操作才会真正执行 // return $this->result(1, '修改成功'); // } // catch (Exception $e) { // $error = $e->getMessage(); //获取抛出的错误 // $transaction->rollBack(); // return $this->result(2, '网络异常,请稍后再试'); // } // } return $this->result(2, '网络异常,请稍后再试'); } return $this->result(2, '请求异常'); } //启用支付通道 public function actionOpenpaychannel() { $request = Yii::$app->request; if ($request->isPost) { $result = axios_request(); $status = $result['status']; $id = $result['id']; if (is_string($id)) { $res = YII::$app->db->createCommand("select * from {{%ybwm_pay_channel}} where channel_id='$id'")->queryOne(); } if (is_array($id)) { $where = '(' . implode(',', $id) . ')'; $res = YII::$app->db->createCommand("select * from {{%ybwm_pay_channel}} where channel_id in" . $where)->queryOne(); } $now_time = time(); if (!$res) { return $this->result(2, '支付渠道不存在不存在'); } else { $update_data = [ 'status' => $status, 'update_time' => $now_time, 'update_user_id'=>$this->getUserId() ]; if (is_array($id)) { $re = YII::$app->db->createCommand()->update('{{%ybwm_pay_channel}}',$update_data , "channel_id in $where")->execute(); } else { $re = YII::$app->db->createCommand()->update('{{%ybwm_pay_channel}}', $update_data, ['channel_id' => $id])->execute(); } if ($re !== false) { return $this->result(1, '成功'); } } } return $this->result(2, '请求异常'); } //获取平台列表所有信息 public function actionGetapplylist() { $request = Yii::$app->request; if ($request->isGet) { $page = Yii::$app->request->get('page') ? Yii::$app->request->get('page') : 1; $num = ($page - 1) * 10; $limit = 10; $query = (new \yii\db\Query()) ->select('a.id,a.dt_operdate,a.apply_type,a.apply_image,a.apply_name,a.time_type,a.end_time, (SELECT id FROM {{%ybwm_users}} b WHERE type = 1 AND b.uniacid = a.id limit 1) AS userId, (SELECT userName FROM {{%ybwm_users}} b WHERE type = 1 AND b.uniacid = a.id limit 1) AS userName, (SELECT phone FROM {{%ybwm_users}} b WHERE type = 1 AND b.uniacid = a.id limit 1) AS phone' ) ->from('{{%ybwm_apply}} a') ->where(['a.status' => 1]); $userType = 0; // dd(Yii::$app->session->get('adminInfo')['loginType']);die; if (Yii::$app->session->get('adminInfo')['loginType'] == 3) { $userType = 1; $count = count($query->all()); //var_dump(ddSql($query));die; $re = $query->offset($num) ->limit($limit) ->orderBy('a.sort asc,a.id desc') ->all(); } if (Yii::$app->session->get('adminInfo')['loginType'] == 1) { $query = ''; $query = (new \yii\db\Query())->from('{{%ybwm_apply}} a') ->select('a.id,b.phone,apply_type,apply_image,apply_name,time_type,start_time,end_time,b.id userId,b.userName') ->leftJoin('{{%ybwm_users}} b', 'a.id=b.uniacid') ->where(['a.status' => 1, 'userName' => Yii::$app->session->get('adminInfo')['userName'], 'b.type' => 1]) ->andWhere(['>=', 'a.end_time', date('Y-m-d H:i:s', time())]); $count = count($query->all()); $re = $query->offset($num) ->limit($limit) ->orderBy('a.sort asc,a.id desc') ->all(); } if (Yii::$app->session->get('adminInfo')['loginType'] == 2) { $query = ''; $query = (new \yii\db\Query())->from('{{%ybwm_apply}} a') ->select('b.appNum,a.id,b.phone,apply_type,apply_image,apply_name,time_type,start_time,end_time,b.id userId,b.userName') ->leftJoin('{{%ybwm_users}} b', 'a.id=b.uniacid') ->where(['a.status' => 1, 'phone' => Yii::$app->session->get('adminInfo')['phone'], 'b.type' => 1]) ->andWhere(['>=', 'a.end_time', date('Y-m-d H:i:s', time())]);; //var_dump(ddSql($query));die; $count = count($query->all()); $appNumRe = (new \yii\db\Query())->from('{{%ybwm_users}}')->where(['phone' => Yii::$app->session->get('adminInfo')['phone']])->one(); if ($appNumRe['appNum'] > $count) { $userType = 1; } $re = $query->offset($num) ->limit($limit) ->orderBy('a.sort asc,a.id desc') ->all(); } foreach ($re as $k => $v) { if ($v['time_type'] == 1 && strtotime($v['end_time']) < time()) { $re[$k]['status'] = 2; } else { $re[$k]['status'] = 1; } } echo json_encode(['code' => 1, 'msg' => '成功', 'data' => $re, 'count' => intval($count), 'userType' => $userType]); die; } } //平台列表根据条件搜索出结果 public function actionApplybysearch() { $request = Yii::$app->request; if ($request->isPost) { $request = axios_request(); $status = $request['apply_status'] ?: 1; $sql = (new \yii\db\Query())->from('{{%ybwm_apply}} a') ->select('a.*,b.userName,b.id userId') ->leftJoin('{{%ybwm_users}} b', 'a.id=b.uniacid') ->where(['a.status' => $status, 'type' => 1]); $apply_type = $request['apply_type']; $apply_name = $request['apply_name']; $start_time = $request['start_time']; $end_time = $request['end_time']; $phone = $request['phone']; if ($apply_type) { $sql->andWhere(['a.apply_type' => $apply_type]); } if ($apply_name) { $sql->andWhere(['like', 'a.apply_name', $apply_name]); } if ($phone) { $sql->andWhere(['b.user_phone' => $phone]); } if ($start_time && $end_time) { $sql->andWhere(['>=', 'a.dt_operdate' => $phone])->andWhere(['<=', 'a.dt_operdate' => $phone]); } if (!Yii::$app->session->get('adminInfo')['userType']) { $phone = Yii::$app->session->get('adminInfo')['phone']; $sql->andWhere(['b.phone' => $phone])->andWhere(['b.type' => 1])->andWhere(['>', 'b.phone', '']); } $desc = $request['desc'] ?: 'desc'; if ($desc) { $sql->orderBy('a.dt_operdate ' . $desc); } $page = $request['page'] ? $request['page'] : 1; $num = 10 * $page; if ($page == 1) { $sql->limit(10); } else { $sql->limit(10, $num); } $count = count($sql->all()); $re = $sql->all(); return $this->result(1, '成功', $re, intval($count)); } return $this->result(2, '请求异常'); } //获取平台回收站的数据 public function actionGetrecycle() { $request = Yii::$app->request; if ($request->isPost) { $sessionData = Yii::$app->session->get('adminInfo'); $request = axios_request(); // $sql="select * from {{%ybwm_apply}} where status=2"; $sql = "select a.*,b.userName,b.phone from {{%ybwm_apply}} a left join {{%ybwm_users}} b on a.id=b.uniacid where a.status=2"; //dd($sql);die; $apply_type = $request['apply_type']; $apply_name = $request['apply_name']; if ($apply_type) { $sql = " and apply_type='$apply_type'"; } if ($apply_name) { $sql = " and apply_name='$apply_name'"; } //var_dump(Yii::$app->session->get('adminInfo')['loginType']);die; if (Yii::$app->session->get('adminInfo')['loginType'] < 3) { $phone = Yii::$app->session->get('adminInfo')['phone']; $sql .= " and b.phone=$phone and b.type=1"; } $count = count(Yii::$app->db->createCommand($sql)->queryAll()); $page = $request['page'] ? $request['page'] : 1; $num = 10 * $page; if ($page == 1) { $sql .= " order by a.dt_operdate desc limit 10"; } else { $sql .= " order by a.dt_operdate desc limit 10,$num"; } $re = Yii::$app->db->createCommand($sql)->queryAll(); return $this->result(1, '成功', $re, intval($count)); } return $this->result(2, '请求异常'); } //平台回收站恢复 public function actionRecovery() { $request = Yii::$app->request; if ($request->isPost) { $request = axios_request(); //$status 1恢复平台 3删除平台 $status = $request['status']; $id = $request['id']; $res = YII::$app->db->createCommand()->update('{{%ybwm_apply}}', ['status' => $status, 'up_operdate' => date('Y-m-d H:i:s', time())], 'id=:id', ['id' => $id])->execute(); if ($res !== false) { return $this->result(1, '成功'); } else { return $this->result(2, '网络异常,请稍后再试'); } } return $this->result(2, '请求异常'); } //平台应用后台业务管理员添加 public function actionPlatform_userm() { $this->view->params['userType'] = Yii::$app->session->get('adminInfo')['userType']; return $this->renderpartial('platform_userm'); } //平台应用修改页面 public function actionPlatform_edit() { if (!Yii::$app->session->get('adminInfo')['userType']) { $request = axios_request(); Yii::$app->response->redirect(['admin/apply/platform_userm', 'id' => $request['id']], 301)->send(); die; } return $this->renderpartial('platform_edit'); } //平台应用后台业务管理员添加 public function actionUseradd() { $request = Yii::$app->request; if ($request->isPost) { $request = axios_request(); $connection = Yii::$app->db; $user_name = $request['user_name']; $command = $connection->createCommand("select * from {{%ybwm_users}} where userName='$user_name'"); $re = $command->queryOne(); if ($re) { return $this->result(2, '用户已存在'); } $salt = random(8); $auth_key = Yii::$app->params['authkey']; if (!$request['unionid']) { $request['unionid'] = $connection->createCommand("select * from {{%ybwm_apply}} where user_bind='0'")->queryOne()['id']; } $data = array( 'uniacid' => $request['unionid'], 'userName' => $request['user_name'], 'passWord' => sha1($request['password'] . '--' . $salt . '--' . $auth_key), 'salt' => $salt, 'createdAt' => time(), 'phone' => $request['user_phone'], ); $res = $connection->createCommand()->insert('{{%ybwm_users}}', $data)->execute(); if ($res) { $connection->createCommand()->update('{{%ybwm_apply}}', ['user_bind' => 1], ['id' => $request['unionid']])->execute(); return $this->result(1, '成功'); } else { return $this->result(2, '网络异常,请稍后再试'); } } return $this->result(2, '请求异常'); } public function actionCeshidemo() { // Yii::$app->session['var']='viva'; echo Yii::$app->request->referrer; } public function actionPlatform_enclosure() { return $this->renderpartial('platform_enclosure'); } public function actionOther_set() { if (!Yii::$app->session->get('adminInfo')['userType']) { Yii::$app->response->redirect(['admin/apply/platform_management'], 301)->send(); die; } return $this->renderpartial('other_set'); } public function menuConfig() { $data = [ [ 'id' => 1, 'use_name' => '堂食' ], [ 'id' => 2, 'use_name' => '会员卡' ], [ 'id' => 3, 'use_name' => '会员储值' ], [ 'id' => 4, 'use_name' => '积分签到' ], [ 'id' => 5, 'use_name' => '积分商城' ], ]; return $data; } }