123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- <?php
- namespace app\mainapp\controller;
- use app\mainapp\BaseController;
- use think\facade\Session;
- use app\common\model\Param as ParamModel;
- use app\common\model\User as UserModel;
- use app\common\model\UserFollow as UserFollowModel;
- use app\common\model\UserPart as UserPartModel;
- use app\common\model\Agent as AgentModel;
- use app\common\model\Broker as BrokerModel;
- use app\common\model\BrokerForm as BrokerFormModel;
- use app\common\model\ReportEntry as ReportEntryModel;
- use app\common\model\ReportFactory as ReportFactoryModel;
- use app\common\model\ReportOrder as ReportOrderModel;
- use app\common\model\ReportOrderlog as ReportOrderlogModel;
- use echowx\WxProgram;
- class Broker extends BaseController
- {
-
-
-
- public function getListBroker()
- {
- $ppage = input('ppage/d', 1);
- $psize = input('psize/d', 20);
- $map = array();
- $map[] = ['status','=',1];
- $searchval = input('searchval/s', "");
- if (!empty($searchval)){
- $map[] =['title', 'like', '%'.$searchval.'%'];
- }
- $district = input('district/s', "");
- if (!empty($district)){
- $map[] = ['district', '=', $district];
- }
- $plist = BrokerModel::with(['muser'])->where($map)->order(['id'=>'desc'])->page($ppage)->limit($psize)->select();
- page_result(0, "", array(
- 'plist' => $plist,
- 'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
- ));
- }
-
-
-
-
-
- // 申请注册职业顾问
- public function pageForm()
- {
- $param = ParamModel::where(1)->find();
- page_result(0, "", array(
- 'param' => $param
- ));
- }
-
- public function regBroker()
- {
- $realname = input('realname/s', "");
- $mobile = input('mobile/s', "");
- $address = input('address/s', "");
- $idcard = input('idcard/s', "");
- $recommender = input('recommender/s', "");
- if ( empty($realname) || empty($mobile) || empty($address) || empty($idcard) ){
- page_result(1, "姓名、手机号、当前住址、身份证号均不能为空。");
- }
- $form = new BrokerFormModel;
- $form->save([
- 'realname' => $realname,
- 'mobile' => $mobile,
- 'address' => $address,
- 'idcard' => $idcard,
- 'recommender' => $recommender,
- 'status' => 1,
- 'remark' => "",
- 'createtime' => time()
- ]);
- page_result(0, "", array());
- }
-
-
-
- // 报备信息
- public function getOrder()
- {
- $orderid = input('orderid/d',0);
- $agentid = input('agentid/d',0);
- $order = ReportOrderModel::with(['reportFactory'])->where(['id'=>$orderid])->find();
- $orderlog = ReportOrderlogModel::where(['agentid'=>$agentid,'orderid'=>$orderid])->order(['id'=>"DESC"])->select();
- ReportOrderlogModel::update(['status' => 2], ['agentid'=>$agentid,'orderid'=>$orderid]);
- page_result(0, "", array(
- 'order' => $order,
- 'orderlog' => $orderlog
- ));
- }
-
- // 订单信息
- public function listOrder()
- {
- $brokerid = input('brokerid/d',0);
- $broker = BrokerModel::findOrEmpty($brokerid);
- $agentid = $broker->agentid;
- $ppage = input('ppage/d', 1);
- $psize = input('psize/d', 20);
- $map = array();
- $map[] = ['ReportOrder.status', '>', 1];
- $plist = ReportOrderModel::hasWhere('reportOrderlog',['agentid'=>$agentid])->with(['reportFactory'])->where($map)->order(['status'=>'ASC','id'=>'DESC'])->page($ppage)->limit($psize)->select()->toArray();
- foreach($plist as $key=>$val){
- $plist[$key]['log'] = ReportOrderlogModel::where(['agentid'=>$agentid,'orderid'=>$val['id']])->order(['id'=>'DESC'])->findOrEmpty()->toArray();
- }
- page_result(0, "", array(
- 'plist' => $plist,
- 'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
- ));
- }
-
-
-
- // 数据信息
- public function pageBroker()
- {
- $brokerid = input('brokerid/d', 0);
- $stime = strtotime(date("Y-m-d"),time());
-
- $tuserCount = UserModel::where('brokerid', '=', $brokerid)->where('createtime','between',[$stime,$stime+86400])->count();
- $userCount = UserModel::where('brokerid', '=', $brokerid)->count();
-
- $tentryCount = ReportEntryModel::where('brokerid', '=', $brokerid)->where('createtime','between',[$stime,$stime+86400])->count();
- $entryCount = ReportEntryModel::where('brokerid', '=', $brokerid)->count();
-
- page_result(0, "", array('countobj' => array(
- 'tuser' => $tuserCount,
- 'user' => $userCount,
- 'tentry' => $tentryCount,
- 'entry' => $entryCount
- )));
- }
-
- // 报备信息
- public function getEntry()
- {
- $entryid = input('entryid/d',0);
- $brokerid = input('brokerid/d',0);
- $entry = ReportEntryModel::with(['reportFactory'])->where(['brokerid'=>$brokerid,'id'=>$entryid])->find();
- $broker = BrokerModel::with('agent')->findOrEmpty($brokerid);
- $factorylist = ReportFactoryModel::order(['priority'=>'desc','id'=>'desc'])->select()->toArray();
- $factoryidarr = ReportFactoryModel::order(['priority'=>'desc','id'=>'desc'])->column('title');
- page_result(0, "", array(
- 'entry' => $entry,
- 'broker' => $broker,
- 'factorylist' => $factorylist,
- 'factoryidarr' => array_values($factoryidarr),
- 'today' => date("Y-m-d")
- ));
- }
-
- public function statusEntry()
- {
- $entryid = input('entryid/d',0);
- $brokerid = input('brokerid/d',0);
- $entry = ReportEntryModel::with(['reportFactory'])->where('brokerid','=',$brokerid)->findOrEmpty($entryid);
- if ($entry->isEmpty()){
- page_result(1, "报备信息不存在。");
- }
- if ($entry->status > 1){
- page_result(1, "报备信息已确认过。");
- }
- $entry->save(['status'=>2]);
- page_result(0, "", array(
- 'entry' => $entry
- ));
- }
-
- public function deleteEntry()
- {
- $entryid = input('entryid/d',0);
- $brokerid = input('brokerid/d',0);
- $entry = ReportEntryModel::with(['reportFactory'])->where('brokerid','=',$brokerid)->findOrEmpty($entryid);
- if ($entry->isEmpty()){
- page_result(1, "报备信息不存在。");
- }
- if ($entry->status > 1){
- page_result(1, "报备信息已确认过,不能删除。");
- }
- $entry->delete();
- page_result(0, "", array());
- }
-
- public function addEntry()
- {
- $brokerid = input('brokerid/d',0);
- $broker = BrokerModel::with('agent')->findOrEmpty($brokerid);
- if ($broker->isEmpty()){
- page_result(1, "职业顾问信息不存在。");
- }
- $data = array(
- 'workerid' => $broker->workerid,
- 'agentid' => $broker->agentid,
- 'brokerid' => $brokerid,
- 'factoryid' => input('factoryid/d', 0),
- 'realname' => input('realname/s', ""),
- 'mobile' => input('mobile/s', ""),
- 'idcard' => input('idcard/s', ""),
- 'gender' => input('gender/s', ""),
- 'nation' => input('nation/s', ""),
- 'address' => input('address/s', ""),
- 'startdate' => input('startdate/s', ""),
- 'enddate' => input('enddate/s', ""),
- 'reftype' => input('reftype/s', ""),
- 'refpolicy' => input('refpolicy/s', ""),
- 'agentremark' => input('agentremark/s', ""),
- 'status' => input('status/d', ""),
- 'remark' => "",
- 'createtime' => time()
- );
- $entry = new ReportEntryModel;
- $entry->save($data);
- $newentry = ReportEntryModel::with(['reportFactory'])->where('brokerid','=',$brokerid)->find($entry->id);
- page_result(0, "", array(
- 'entry' => $newentry
- ));
- }
-
- public function setIdcard()
- {
- $picpath = input('picpath/s',"");
- $picpath = root_path()."public".$picpath;
- $idcard = aliyun_ocr_idcard( $picpath );
- if ($idcard==false){
- page_result(1, "身份证信息识别失败。");
- }
- page_result(0, "", array(
- 'idcard' => $idcard
- ));
- }
-
- public function pageEntry()
- {
- $brokerid = input('brokerid/d',0);
- $statuslist = array(
- array('value'=>"", 'title'=>'状态不限'),
- array('value'=>1, 'title'=>'待确认'),
- array('value'=>2, 'title'=>'已确认'),
- array('value'=>3, 'title'=>'已入职'),
- array('value'=>4, 'title'=>'未通过')
- );
- $factorylist = ReportFactoryModel::field('id as value, title, priority')->order(['priority'=>'desc','id'=>'desc'])->select()->toArray();
- array_unshift($factorylist, array('value'=>"", 'title'=>'工厂不限'));
- page_result(0, "", array(
- 'statuslist' => $statuslist,
- 'factorylist' => $factorylist
- ));
- }
-
- public function listEntry()
- {
- $ppage = input('ppage/d', 1);
- $psize = input('psize/d', 20);
- $map = array();
- $brokerid = input('brokerid/d', 0);
- $map[] = ['brokerid', '=', $brokerid];
- $status = input('status/d', 0);
- if (!empty($status)){
- $map[] = ['status', '=', $status];
- }
- $factoryid = input('factoryid/d', 0);
- if (!empty($factoryid)){
- $map[] = ['factoryid', '=', $factoryid];
- }
- $searchval = input('searchval/s', "");
- if (!empty($searchval)){
- $map[] =['realname|mobile', 'like', '%'.$searchval.'%', 'OR'];
- }
- $plist = ReportEntryModel::with(['reportFactory'])->where($map)->order(['id'=>'desc'])->page($ppage)->limit($psize)->select();
- page_result(0, "", array(
- 'plist' => $plist,
- 'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
- ));
- }
-
-
- // 我的邀请
- public function getMyuser()
- {
- $userid = input('userid/d',0);
- $brokerid = input('brokerid/d',0);
- $user = UserModel::with(['userFollow'])->where('brokerid','=',$brokerid)->findOrEmpty($userid);
- if ($user->isEmpty()){
- page_result(1, "用户信息不存在");
- }
- page_result(0, "", array(
- 'user' => $user,
- ));
- }
-
- public function sendFollow()
- {
- $userid = input('userid/d',0);
- $ftype = input('ftype/s',"");
- $remark = input('remark/s',"");
- if (empty($remark)){
- page_result(1, "请输入跟进的具体内容。");
- }
- $followstatus = input('followstatus/d',1);
- UserModel::update(['followstatus'=>$followstatus],['id'=>$userid]);
- $data = array(
- 'userid' => $userid,
- 'ftype' => $ftype,
- 'remark' => $remark,
- 'createtime' => time()
- );
- $follow = new UserFollowModel;
- $follow->save($data);
-
- $user = UserModel::with(['userFollow'])->findOrEmpty($userid);
- page_result(0, "", array(
- 'user' => $user,
- ));
- }
-
- public function listUser()
- {
- $ppage = input('ppage/d', 1);
- $psize = input('psize/d', 20);
- $map = array();
- $brokerid = input('brokerid/d', 0);
- $map[] = ['brokerid', '=', $brokerid];
- $followstatus = input('followstatus/d', 0);
- if (!empty($followstatus)){
- $map[] = ['followstatus', '=', $followstatus];
- }
- $plist = UserModel::with(['userFollow'])->where($map)->order(['id'=>'desc'])->page($ppage)->limit($psize)->select();
- page_result(0, "", array(
- 'plist' => $plist,
- 'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
- ));
- }
-
- }
|