| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524 |
- <?php
- /**
- * @package merchant
- *
- * @author xaboy
- * @day 2020-05-07
- *
- *
- */
- namespace app\controller\admin\user;
- use app\common\model\merchant\order\OrderMerchant;
- use app\common\model\system\admin\Admin;
- use app\common\model\system\auth\Role;
- use app\common\model\user\UserCertification;
- use app\common\repositories\merchant\order\OrderMerchantRepository;
- use app\common\repositories\user\UserExtractRepository;
- use app\controller\api\merchant\sxy\Access;
- use app\controller\api\user\Im;
- use crmeb\basic\BaseController;
- use app\common\repositories\store\coupon\StoreCouponUserRepository;
- use app\common\repositories\store\order\StoreOrderRepository;
- use app\common\repositories\user\UserBillRepository;
- use app\common\repositories\user\UserGroupRepository;
- use app\common\repositories\user\UserLabelRepository;
- use app\common\repositories\user\UserRepository;
- use app\common\repositories\wechat\WechatNewsRepository;
- use app\common\repositories\wechat\WechatUserRepository;
- use app\validate\admin\UserNowMoneyValidate;
- use app\validate\admin\UserValidate;
- use FormBuilder\Exception\FormBuilderException;
- use think\App;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- use think\Exception;
- use think\facade\Cache;
- use think\facade\Db;
- use think\Log;
- /**
- * Class User
- * @package app\controller\admin\user
- * @author xaboy
- * @day 2020-05-07
- */
- class User extends BaseController
- {
- /**
- * @var UserRepository
- */
- protected $repository;
- /**
- * User constructor.
- * @param App $app
- * @param UserRepository $repository
- */
- public function __construct(App $app, UserRepository $repository)
- {
- parent::__construct($app);
- $this->repository = $repository;
- }
- /**
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- * @author xaboy
- * @day 2020-05-07
- */
- public function lst()
- {
- /*
- * 昵称,分组,标签,地址,性别,
- */
- $where = $this->request->params([
- 'label_id',
- 'user_type',
- 'sex',
- 'is_promoter',
- 'country',
- 'pay_count',
- 'user_time_type',
- 'user_time',
- 'nickname',
- 'province',
- 'city',
- 'group_id',
- 'identity',
- 'now_money',
- 'account',
- 'user_card',
- 'user_rich_type',
- 'stockholder',
- 'subIdentify',
- 'user_group',
- 'is_show'
- ]);
- [$page, $limit] = $this->getPage();
- return app('json')->success($this->repository->getList($where, $page, $limit));
- }
- /**
- * 协议
- * @return mixed
- */
- public function xieyi(){
- var_dump(111);die;
- return app('json')->success($this->repository->getXieYi());
- }
- /**
- * 批量设置星级
- * @return mixed
- * @throws DbException
- */
- public function start_level(){
- $ids = (array)$this->request->param('ids', []);
- $admin_start_level = $this->request->param('admin_start_level', '0');
- if (!count($ids))
- return app('json')->fail('数据不存在');
- foreach ($ids as $id){
- $rich=Db::name('user_rich')->where('uid',$id)->count();
- if($rich){
- Db::name('user_rich')->where('uid',$id)->update(['admin_start_level'=>$admin_start_level]);
- }else{
- $insert=['uid' => $id, 'admin_start_level' => $admin_start_level];
- Db::name('user_rich')->insert($insert);
- }
- }
- return app('json')->success('修改成功');
- }
- public function spreadList($uid)
- {
- $where = $this->request->params(['level', 'keyword', 'date','identity']);
- [$page, $limit] = $this->getPage();
- return app('json')->success($this->repository->getLevelList($uid, $where, $page, $limit));
- }
- public function spreadOrder($uid)
- {
- $where = $this->request->params(['level', 'keyword', 'date']);
- [$page, $limit] = $this->getPage();
- return app('json')->success($this->repository->subOrder($uid, $page, $limit, $where));
- }
- public function clearSpread($uid)
- {
- $this->repository->update($uid, ['spread_uid' => 0]);
- return app('json')->success('清除成功');
- }
- /**
- * @param $id
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws FormBuilderException
- * @throws ModelNotFoundException
- * @author xaboy
- * @day 2020-05-09
- */
- public function updateForm($id)
- {
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->userForm($id)));
- }
- public function get_info($id)
- {
- // ini_set('display_errors','On');
- //
- // error_reporting(E_ALL);
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- $user=Db::name('user')->find($id);
- $certification = Db::name('user_certification')->where("uid", $id)->find();
- $user['real_name'] = $certification['user_name'] ?? '';
- $user['card_id'] = $certification['user_card'] ?? '';
- $user_rich=Db::name('user_rich')->where('uid',$id)->find();
- $user['admin_start_level'] =$user_rich?$user_rich['admin_start_level']:'0';
- $user['user_rich_type'] =$user_rich?$user_rich['type']:'0';
- $user['area_manage_pics'] =[];
- $user['area_manage_obtain'] ='0';
- if($user_rich){
- $user['area_manage_obtain'] =$user_rich['obtain'];
- if($user_rich['pics']){
- $user['area_manage_pics']=explode(',',$user_rich['pics']);
- }
- }
- $code_list_province=DB::name('user')->where('user_group',6)->where('manage_address!=""')->column('manage_address');
- $code_list_district=DB::name('user')->where('user_group',5)->where('manage_address!=""')->column('manage_address');
- // 省
- $code_list_province_arr=[];
- foreach ($code_list_province as $v){
- $v_explode=explode(',',$v);
- $code_list_province_arr[$v_explode[0]][]=$v_explode[0];
- }
- //区县
- $code_list_district_arr=[];
- foreach ($code_list_district as $v){
- $v_explode=explode(',',$v);
- $code_list_district_arr[$v_explode[1]][]=$v_explode[0];
- }
- if( $user['manage_address']){
- $code_list_explode=explode(',',$user['manage_address']);
- }
- $regions1 = Db::name('regions') -> field('id as value,name as label')->where('level',1) ->select();
- $regions2 = Db::name('regions') -> field('id as value,name as label,pid')->where('level',2) ->select();
- $regions3 = Db::name('regions') -> field('id as value,name as label,pid')->where('level',3) ->select();
- $regions3_data=[];
- foreach ($regions3 as $v){
- $v['disabled']=false;
- if(isset($code_list_district_arr[$v['pid']]) && in_array($v['value'],$code_list_district_arr[$v['pid']])){
- if(!isset($code_list_explode[2]) || $code_list_explode[2]!=$v['value']){
- $v['disabled']=true;
- }
- }
- $regions3_data[$v['pid']][]=$v;
- }
- $regions2_data=[];
- foreach ($regions2 as $v){
- $v['children']=isset( $regions3_data[$v['value']])? $regions3_data[$v['value']]:[];
- $regions2_data[$v['pid']][]=$v;
- }
- $city_area=[];
- foreach ($regions1 as $v){
- $v['children']=isset( $regions2_data[$v['value']])? $regions2_data[$v['value']]:[];
- $city_area[]=$v;
- }
- $regions2_data2=[];
- foreach ($regions2 as $v){
- $v['disabled']=false;
- if(isset($code_list_province_arr[$v['pid']]) && in_array($v['value'],$code_list_province_arr[$v['pid']])){
- if(!isset($code_list_explode[0]) || $code_list_explode[0]!=$v['value']){
- $v['disabled']=true;
- }
- }
- $regions2_data2[$v['pid']][]=$v;
- }
- $city_area_2=[];
- foreach ($regions1 as $v){
- $v['children']=isset( $regions2_data2[$v['value']])? $regions2_data2[$v['value']]:[];
- $city_area_2[]=$v;
- }
- $user['city_area_1']=$city_area;
- $user['city_area_2']=$city_area_2;
- //查询当前团队的用户列表
- $sql = "select getUserSpreadId($id) as uids";
- //\think\facade\Log::info("lplpDB".$sql);
- try{
- $spread_user_list = Db::query($sql);
- }catch (Exception $exception){
- return app('json')->success($exception);
- }
- $spread_user_list = array_diff(explode(",", trim($spread_user_list[0]['uids'],'$,')), [$id]);
- //查询创客手机号
- $marker_phone_list = [];
- $marker_user_list = Db::name("user")->whereIn("uid", $spread_user_list)->where('is_shop_partner', 1)->select()->toArray();
- foreach ($marker_user_list as $k=>$v){
- $marker_phone_list[] = $v['account'];
- }
- $user['marker_phone_list'] = $marker_phone_list;
- return app('json')->success($user);
- }
- /**
- * @param $id
- * @param UserValidate $validate
- * @param UserLabelRepository $labelRepository
- * @param UserGroupRepository $groupRepository
- * @return mixed
- * @throws DbException
- * @author xaboy
- * @day 2020-05-09
- */
- public function update($id, UserValidate $validate, UserLabelRepository $labelRepository, UserGroupRepository $groupRepository)
- {
- $data = $this->request->params(['real_name', 'agent_rebate', "mer_rebate", "promoter_rebate", "cross_store", "jurisdiction", "other_jurisdictions", "xqxiaofei", 'phone', 'birthday', 'card_id', 'addres', 'mark', 'group_id', 'user_group', ['label_id', []], ['is_promoter', 0], ['maker_phone_list', []]]);
- $validate->check($data);
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- // if ($data['group_id'] && !$groupRepository->exists($data['group_id']))
- // return app('json')->fail('分组不存在');
- $label_id = (array)$data['label_id'];
- $maker_phone_list = (array)$data['maker_phone_list'] ?? [];
- foreach ($label_id as $k => $value) {
- $label_id[$k] = (int)$value;
- if (!$labelRepository->exists((int)$value))
- return app('json')->fail('标签不存在');
- }
- //查询当前团队的用户列表,判断当前用户是否为团队成员
- $sql = "select getUserSpreadId($id) as uids";
- $spread_user_list = Db::query($sql);
- $spread_user_list = trim($spread_user_list[0]['uids'],'$,');
- $error_maker_phone = [
- 'no_registry' => [],
- 'no_team' => [],
- ];
- foreach ($maker_phone_list as $k => $maker_phone) {
- //检查手机号是否已注册
- $user = Db::name('user')->where('account', $maker_phone)->find();
- if (empty($user)) {
- $error_maker_phone['not_sign'][] = $maker_phone;
- }
- if (!in_array($user['uid'], explode(",", $spread_user_list))) {
- $error_maker_phone['no_team'][] = $maker_phone;
- }
- }
- if (count($error_maker_phone['no_registry']) > 0 || count($error_maker_phone['no_team']) > 0) {
- return app('json')->fail("创客手机号校验异常", [
- 'error_maker_phone' => $error_maker_phone,
- ]);
- } else {
- foreach ($maker_phone_list as $k => $maker_phone) {
- Db::name('user')
- ->where('account', $maker_phone)
- ->update([
- 'is_shop_partner' => 1,
- ]);
- }
- }
- unset($data['maker_phone_list']);
- $data['label_id'] = implode(',', $label_id);
- if(!$data['birthday']) unset($data['birthday']);
- $user_group=input('post.user_group','');
- if(in_array($user_group,[5,6])){
- $city_list=input('post.city',[]);
- $city_string = implode(",", $city_list);
- if(!$city_list){
- return app('json')->fail('请选择代理区域');
- }
- $code_list_count=Db::name('user')->where('manage_address', $city_string)->where('uid !='.$id)->count();
- if($code_list_count){
- return app('json')->fail('改区域已经分配给其他人了');
- }
- $data['manage_address']=$city_string;
- $data['up_agency_time']=date('Y-m-d H:i:s');
- }else{
- $data['up_agency_time']=null;
- }
- if ($user_group == 3) {
- $mer = Db::name('merchant')->where('uid', $id)->find();
- if ($mer)
- return app('json')->fail('已经是创客,不可调整成大V经理身份');
- $data['up_vip_time'] = date('Y-m-d H:i:s');
- } else {
- $data['up_vip_time'] = null;
- }
- if ($user_group == 4) {
- $new_user_group = Db::name('user')->where('uid', $id)->value('user_group');
- if ($new_user_group == 3)
- return app('json')->fail('已经是大V经理,不可调整成创客身份');
- $data['up_vip_time'] = date('Y-m-d H:i:s');
- } else {
- $data['up_vip_time'] = null;
- }
- $this->repository->update($id, $data);
- //更新身份证信息
- $cardData = [];
- if ($data['card_id']) {
- $cardData['user_card'] = $data['card_id'];
- }
- if ($data['real_name']) {
- $cardData['user_name'] = $data['real_name'];
- }
- if (!empty($cardData)) {
- Db::name('user_certification')->where("uid", $id)->update($cardData);
- }
- // $admin_start_level=input('post.admin_start_level',0);
- // if (!empty($admin_start_level)) {
- // }
- $pics=input('post.area_manage_pics',[]);
- $user_rich_ypdate['type']=input('post.user_rich_type',0);
- $user_rich_ypdate['obtain']=input('post.area_manage_obtain',0);
- $user_rich_ypdate['admin_start_level']=input('post.admin_start_level',0);
- if($pics){
- $user_rich_ypdate['pics']=implode(',',$pics);
- }
- $rich=Db::name('user_rich')->where('uid',$id)->count();
- if($rich){
- Db::name('user_rich')->where('uid',$id)->update($user_rich_ypdate);
- }else{
- $user_rich_ypdate['uid']=$id;
- Db::name('user_rich')->insert($user_rich_ypdate);
- }
- return app('json')->success('编辑成功');
- }
- public function maker_check_phone($id)
- {
- $params = $this->request->params(['phone']);
- $user = Db::name('user')->where('account', $params['phone'])->find();
- if (empty($user)) {
- return app('json')->fail('该用户未注册,请先邀请用户注册~');
- }
- //查询当前团队的用户列表,判断当前用户是否为团队成员
- $sql = "select getUserSpreadId($id) as uids";
- $spread_user_list = Db::query($sql);
- $spread_user_list = trim($spread_user_list[0]['uids'],'$,');
- if (!in_array($user['uid'], explode(",", $spread_user_list))) {
- return app('json')->fail('该用户不属于您团队,不可设置为合伙人~');
- }
- return app('json')->success();
- }
- /**
- * 设为合伙人
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- */
- public function setAreaManage()
- {
- $area_type = $this->request->param('area_type', 0);//类型 district town village
- $area_manage_address_ids = $this->request->param('area_manage_address_ids', 0);//
- $uid = $this->request->param('uid', 0);//用户id
- // $area_manage = Db::name('area_manage')->where('code_list', $area_manage_address_ids)->find();
- // if ($area_manage) {
- // return app('json')->fail('该地区已有代理!');
- // }
- // $area_manage = Db::name('area_manage')->where('uid', $uid)->find();
- // if ($area_manage) {
- // return app('json')->fail('该用户已经是代理了!');
- // }
- $area_manage_address_list = explode(',', $area_manage_address_ids);
- switch ($area_type) {
- case 'district':
- if (count($area_manage_address_list) != 3)
- return app('json')->fail('请输入正确的高级合伙人代理地址!');
- break;
- case 'town':
- if (count($area_manage_address_list) != 4)
- return app('json')->fail('请输入正确的中级合伙人代理地址!');
- break;
- case 'village':
- if (count($area_manage_address_list) != 3)
- return app('json')->fail('请输入正确的初级合伙人代理地址!');
- break;
- default :
- return app('json')->fail('请输入正确的初级合伙人代理地址!');
- }
- $end_address = Db::name('regions_new')->where('id', end($area_manage_address_list))->find();
- if (empty($end_address))
- return app('json')->fail('该地址不存在!');
- // 查询当时是否已有未支付的合伙人商品订单
- $hehuo_store_group_order = DB::name('store_order')
- ->alias('store_order')
- ->leftJoin('store_order_product store_order_product', 'store_order.order_id=store_order_product.order_id')
- ->where('store_order.uid', $uid)
- ->where('store_order.paid', 0)
- ->where('store_order_product.type', 'in', [11, 12, 13])
- ->find();
- if($hehuo_store_group_order)
- return app('json')->fail('该用户当前有待支付的合伙人商品,不可下单!');
- $key = 'area_manage_order:' . $area_manage_address_ids;
- $redis = Cache::store('redis')->handler();
- if (!$redis->setnx($key, 1))
- return app('json')->fail('该地区已有用户锁定,请稍后再试!');
- // 区域设置成功 记录
- Db::name('area_manage')->insert([
- 'uid' => $uid,
- 'type' => $area_type,
- 'order_sn' => '',
- 'code_list' => $area_manage_address_ids,
- 'create_time' => date('Y-m-d H:i:s')
- ]);
- Db::name('log')->insert(['data' => "后台修改{$uid}为{$area_type}区域成功,code_list:{$area_manage_address_ids}!"]);
- return app('json')->success('修改成功');
- }
- /**
- * 设为回填
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- */
- public function setHuiTian()
- {
- $uid = $this->request->param('uid', 0);//用户id
- $user_rich = Db::name('user_rich')->where('uid', $uid)->find();
- if ($user_rich) {
- if ($user_rich['is_huitian'] == 1)
- return app('json')->fail('该用户已经是回填!');
- if ($user_rich['type'] != 0)
- return app('json')->fail('只有普通用户可以设置为回填!');
- Db::name('user_rich')->where('uid', $uid)->update([
- 'type' => 4,
- 'is_huitian' => 1,
- ]);
- } else {
- Db::name('user_rich')->where('uid', $uid)->insert([
- 'uid' => $uid,
- 'type' => 4,
- 'is_huitian' => 1,
- ]);
- }
- Db::name('log')->insert(['data' => "后台修改{$uid}为回填成功!"]);
- return app('json')->success('修改成功');
- }
- /**
- * @param $id
- * @param UserLabelRepository $labelRepository
- * @return mixed
- * @throws DbException
- * @author xaboy
- * @day 2020-05-08
- */
- public function changeLabel($id, UserLabelRepository $labelRepository)
- {
- $label_id = (array)$this->request->param('label_id', []);
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- foreach ($label_id as $k => $value) {
- $label_id[$k] = (int)$value;
- if (!$labelRepository->exists((int)$value))
- return app('json')->fail('标签不存在');
- }
- $label_id = implode(',', $label_id);
- $this->repository->update($id, compact('label_id'));
- return app('json')->success('修改成功');
- }
- /**
- * @param UserLabelRepository $labelRepository
- * @return mixed
- * @throws DbException
- * @author xaboy
- * @day 2020-05-08
- */
- public function batchChangeLabel(UserLabelRepository $labelRepository)
- {
- $label_id = (array)$this->request->param('label_id', []);
- $ids = (array)$this->request->param('ids', []);
- if (!count($ids))
- return app('json')->fail('数据不存在');
- foreach ($label_id as $k => $value) {
- $label_id[$k] = (int)$value;
- if (!$labelRepository->exists((int)$value))
- return app('json')->fail('标签不存在');
- }
- $this->repository->batchChangeLabelId($ids, $label_id);
- return app('json')->success('修改成功');
- }
- /**
- * @param $id
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws FormBuilderException
- * @throws ModelNotFoundException
- * @author xaboy
- * @day 2020-05-08
- */
- public function changeLabelForm($id)
- {
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->changeLabelForm($id)));
- }
- /**
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws FormBuilderException
- * @throws ModelNotFoundException
- * @author xaboy
- * @day 2020-05-08
- */
- public function batchChangeLabelForm()
- {
- $ids = $this->request->param('ids', '');
- $ids = array_filter(explode(',', $ids));
- if (!count($ids))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->changeLabelForm($ids)));
- }
- /**
- * 批量微信入账公证处
- * @return mixed
- * @author php迷途小书童
- * @created 2021/3/10 15:37
- */
- public function batchGzc()
- {
- $ids = $this->request->param('ids', '');
- $type = $this->request->param('type', '');
- $ids = array_filter(explode(',', $ids));
- if (!count($ids))
- return app('json')->fail('数据不存在');
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- foreach ($ids as $id) {
- $user = $this->repository->get($id);
- switch ($type) {
- case 'WX':
- if (!$user->wechat_user_id)
- return app('json')->fail('账号:'.$user->account.'暂未微信授权,操作停止');
- $pay_user_id = $user->wechat_user_id;
- break;
- case 'ALI':
- if (!$user->ali_user_id)
- return app('json')->fail('账号:'.$user->account.'暂未支付宝授权,操作停止');
- $pay_user_id = $user->ali_user_id;
- break;
- default:
- return app('json')->fail('请求参数错误');
- break;
- }
- $count = OrderMerchant::getDB()
- ->where('pay_user_id', $pay_user_id)
- ->where('paid', 1)
- ->where('gzc', 0)
- ->count();
- if (!$count)
- return app('json')->fail('账号:'.$user->account.'暂无要发起的入账信息,操作停止');
- $certification = UserCertification::getDB()
- ->where('uid', $user->uid)
- ->find();
- if (!$certification)
- return app('json')->fail('账号:'.$user->account.'暂未实名认证,操作停止');
- $OrderMerchantRepository->batchGzc($certification,$user,$type);
- }
- return app('json')->success('发起成功');
- }
- /**
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws FormBuilderException
- * @throws ModelNotFoundException
- * @author xaboy
- * @day 2020-05-08
- */
- public function batchChangeGroupForm()
- {
- $ids = $this->request->param('ids', '');
- $ids = array_filter(explode(',', $ids));
- if (!count($ids))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->changeGroupForm($ids)));
- }
- /**
- * @param $id
- * @param UserGroupRepository $groupRepository
- * @return mixed
- * @throws DbException
- * @author xaboy
- * @day 2020-05-07
- */
- public function changeGroup($id, UserGroupRepository $groupRepository)
- {
- $group_id = (int)$this->request->param('group_id', 0);
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- if ($group_id && !$groupRepository->exists($group_id))
- return app('json')->fail('分组不存在');
- $this->repository->update($id, compact('group_id'));
- return app('json')->success('修改成功');
- }
- /**
- * @param UserGroupRepository $groupRepository
- * @return mixed
- * @throws DbException
- * @author xaboy
- * @day 2020-05-07
- */
- public function batchChangeGroup(UserGroupRepository $groupRepository)
- {
- $group_id = (int)$this->request->param('group_id', 0);
- $ids = (array)$this->request->param('ids', []);
- if (!count($ids))
- return app('json')->fail('数据不存在');
- if ($group_id && !$groupRepository->exists($group_id))
- return app('json')->fail('分组不存在');
- $this->repository->batchChangeGroupId($ids, $group_id);
- return app('json')->success('修改成功');
- }
- /**
- * @param $id
- * @return mixed
- * @throws FormBuilderException
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- * @author xaboy
- * @day 2020-05-07
- */
- public function changeGroupForm($id)
- {
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->changeGroupForm($id)));
- }
- /**
- * @param $id
- * @return mixed
- * @throws FormBuilderException
- * @author xaboy
- * @day 2020-05-07
- */
- public function changeNowMoneyForm($id)
- {
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->changeNowMoneyForm($id)));
- }
- /**
- * @param $id
- * @param UserNowMoneyValidate $validate
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- * @author xaboy
- * @day 2020-05-07
- */
- public function changeNowMoney($id, UserNowMoneyValidate $validate)
- {
- $data = $this->request->params(['now_money', 'type']);
- $validate->check($data);
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- $this->repository->changeNowMoney($id, $this->request->adminId(), $data['type'], $data['now_money']);
- return app('json')->success('修改成功');
- }
- /**
- * @param $id
- * @return mixed
- * @throws FormBuilderException
- * @author xaboy
- * @day 2020-05-07
- */
- public function changeProForm($id)
- {
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->changeProForm($id)));
- }
- /*
- * 更改用户推荐信息
- * cabbage
- * 2020-11-04
- * */
- public function changePro($id,UserRepository $repository)
- {
- $spread_account = $this->request->param('spread_account');
- if (!$spread_account || !$id){
- return app('json')->fail('参数丢失');
- }
- if($repository->update_spread($id,$spread_account)){
- return app('json')->success("修改成功");
- }else{
- return app('json')->fail("失败");
- }
- }
- /**
- * 修改用户奖励表单
- * @param $id
- * @return mixed
- * @throws FormBuilderException
- */
- public function changeAwardForm($id)
- {
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->changeAwardForm($id)));
- }
- /**
- * 修改用户奖励
- * @param $id
- * @param UserRepository $repository
- * @return mixed
- */
- public function changeAward($id,UserRepository $repository)
- {
- $type = $this->request->param('type');
- $award_type = $this->request->param('award_type');
- $num = $this->request->param('num');
- $mark = $this->request->param('mark','');
- $admin_id = $this->request->param('admin_id');
- if (!$id || !$award_type || !$num){
- return app('json')->fail('参数丢失');
- }
- if($repository->changeAward($id,$type,$award_type,$num,$mark,$admin_id)){
- return app('json')->success("修改成功");
- }else{
- return app('json')->fail("失败");
- }
- }
- /**
- * @param $id
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws FormBuilderException
- * @throws ModelNotFoundException
- * @author xaboy
- * @day 2020-05-08
- */
- public function changePassForm($id)
- {
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- return app('json')->success(formToData($this->repository->changePassForm($id)));
- }
- /*
- * 更改用户密码
- * cabbage
- * 2021-2-23
- * */
- public function changePass($id,UserRepository $repository)
- {
- $pass_word = $this->request->param('pass_word');
- if (!$pass_word || !$id){
- return app('json')->fail('参数丢失');
- }
- if($repository->changePass($id,$pass_word)){
- return app('json')->success("修改成功");
- }else{
- return app('json')->fail("失败");
- }
- }
- /**
- * @param WechatNewsRepository $wechatNewsRepository
- * @param WechatUserRepository $wechatUserRepository
- * @return mixed
- * @author xaboy
- * @day 2020-05-11
- */
- public function sendNews(WechatNewsRepository $wechatNewsRepository, WechatUserRepository $wechatUserRepository)
- {
- $ids = array_filter(array_unique(explode(',', $this->request->param('ids'))));
- $news_id = (int)$this->request->param('news_id', 0);
- if (!$news_id)
- return app('json')->fail('请选择图文消息');
- if (!$wechatNewsRepository->exists($news_id))
- return app('json')->fail('数据不存在');
- if (!count($ids))
- return app('json')->fail('请选择微信用户');
- $wechatUserRepository->sendNews($news_id, $ids);
- return app('json')->success('发送成功');
- }
- // public function promoterList()
- // {
- // $where = $this->request->params(['keyword', 'user_type', 'status', 'sex', 'group_id']);
- //// $where['is_promoter'] = 1;
- // [$page, $limit] = $this->getPage();
- // return app('json')->success($this->repository->getList($where, $page, $limit));
- // }
- public function promoterList()
- {
- $where = $this->request->params(['keyword']);
- // $where['is_promoter'] = 1;
- [$page, $limit] = $this->getPage();
- return app('json')->success($this->repository->getAgent($where, $page, $limit));
- }
- public function promoterAgent()
- {
- $where = $this->request->params(['keyword', 'identity']);
- // $where['is_promoter'] = 1;
- [$page, $limit] = $this->getPage();
- return app('json')->success($this->repository->getAgentList($where, $page, $limit));
- }
- public function getPromoter($id)
- {
- // $where = $this->request->params(['id']);
- $where['id'] =$id;
- // [$page, $limit] = $this->getPage();s
- return app('json')->success($this->repository->getonePromoter($where));
- }
- public function updateAgent($id)
- {
- $where = $this->request->params(["status"]);
- $res = $this->repository->updateAgent($where,$id);
- if($res['code'] == 400){
- return app('json')->fail($res['msg']);
- }
- return app('json')->success("审核成功");
- }
- /*线下支付*/
- public function xianPay($id){
- $mark = input("mark");
- $res = $this->repository->xianPayAgent($id,$mark);
- if($res['code'] == 400){
- return app('json')->fail($res['msg']);
- }
- return app('json')->success("线下支付成功");
- }
- public function detail($id)
- {
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- $data = $this->repository->userOrderDetail($id);
- $data['enterprise_user'] = null;
- $where=["uid"=>$id,"type"=>"commission","commission_type"=>5];
- $ylj=Db::name("user_bill")->where($where)->whereIn('status',[0,1])->sum('number');
- $data['ylj']=$ylj?$ylj:0;
- return app('json')->success($data);
- }
- public function order($id, StoreOrderRepository $repository)
- {
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- [$page, $limit] = $this->getPage();
- return app('json')->success($repository->userList($id, $page, $limit));
- }
- public function coupon($id, StoreCouponUserRepository $repository)
- {
- if (!$this->repository->exists($id))
- return app('json')->fail('数据不存在');
- [$page, $limit] = $this->getPage();
- return app('json')->success($repository->userList($id, $page, $limit));
- }
- public function bill($id, UserBillRepository $repository)
- {
- if (!$this->repository->exists(intval($id)))
- return app('json')->fail('数据不存在');
- [$page, $limit] = $this->getPage();
- return app('json')->success($repository->userList([
- 'now_money' => 0,
- 'status' => 1
- ], $id, $page, $limit));
- }
- /**
- * @return mixed
- * @author xaboy
- * @day 2020/6/22
- */
- public function new_bill($id, UserBillRepository $billRepository)
- {
- [$page, $limit] = $this->getPage();
- $where = [
- // 'now_money' => $this->request->param('type', 0),
- 'status' => $this->request->param('status'),
- // 'mer_id' => $this->request->merId()
- 'not_commission_type' => [5, 7, 17, 19],
- ];
- if ($this->request->param('is_red') == true) {
- $where['is_red_brokerage'] = 1;
- }
- $bill_list = $billRepository->userList($where, $id, $page, $limit);
- foreach ($bill_list['list'] as $key => $item) {
- if ($item['status'] == 1) $bill_list['list'][$key]['jiesuan_string'] = "已结算";
- if ($item['status'] == 0) $bill_list['list'][$key]['jiesuan_string'] = "未结算";
- if ($item['status'] == -1) $bill_list['list'][$key]['jiesuan_string'] = "已失效";
- }
- return app('json')->success($bill_list);
- }
- /*
- * 用户养老金信息
- * @author cabbage
- * @date 2020-11-03
- * */
- public function annuity($id, UserRepository $repository)
- {
- if (!$this->repository->exists(intval($id)))
- return app('json')->fail('数据不存在');
- return app('json')->success($repository->get_yanglao($id));
- }
- /**
- * 养老金明细
- */
- public function annuitylog($id, UserRepository $repository){
- [$page, $limit] = $this->getPage();
- $where=["uid"=>$id,"type"=>"commission","commission_type"=>5];
- $res = $repository->yanglaolog($where,$page,$limit);
- return app('json')->success($res);
- }
- /*用户银行卡信息*/
- public function getAccount($id){
- $where['user_id']=$id;
- $data = app()->make(UserExtractRepository::class)->list($where);
- return app('json')->success($data);
- }
- /*设置用户身份*/
- /*
- * pay:1-付费。2-未付费
- * type:3-银卡。4-金卡。5-商户。6-渠道商
- * */
- public function setIdentity(){
- $data = $this->request->params(["uid","pay","type","dc_id","recommend_phone"]);
- $dc_id = $data['dc_id'];
- if(empty($data['uid'])){
- return app('json')->fail('参数错误');
- }
- $time = date('Y-m-d', time());
- $time = strtotime($time);
- $end_time = $time + 31536000 - 1;
- $recommend = Db::name('user') -> where('account',$data['recommend_phone']) -> value('uid');
- $storeOrderRepository = app()->make(StoreOrderRepository::class);
- $access = new Access();
- //付费
- if($data['pay'] == 1){
- switch ($data['type']){
- case 3:
- case 4:
- if($data['type'] == 3){
- $order['pay_price'] = '399';
- }else{
- $order['pay_price'] = '999';
- }
- $order['uid'] = $data['uid'];
- $order['order_id'] = 0;
- $order['order_sn'] = 'sIO'.$storeOrderRepository->getNewOrderId();
- $order['mer_id'] = 0;
- $order['dacang_id'] = $dc_id;
- if($data['type'] == 3){
- $storeOrderRepository -> dacang_yin($order,0);
- }elseif($data['type'] == 4){
- $storeOrderRepository -> dacang($order,0);
- }
- break;
- case 5:
- //赠送商户
- $merchant=Db::name('merchant')->where('uid',$data['uid'])->find();
- if(!$merchant)
- Db::name('merchant_intention')->insert(['uid'=>$data['uid'],'status'=>3,'activation_code'=>rand('000000000','999999999')]);
- $mer = Db::name('user_mer') -> where('uid',$data['uid']) -> find();
- if(!$mer){
- Db::name('user_mer') -> insert(['uid'=>$data['uid'],'mer'=>2]);
- }else{
- Db::name('user_mer') -> where('uid',$data['uid'])->inc('mer', 2) ->update();
- }
- $order_sn = 'sIM'.$storeOrderRepository->getNewOrderId();
- $insertData=[
- 'mer_id'=>0,
- 'pay_price'=>systemConfig("annual"),
- 'status'=>1,
- 'order_no'=>$order_sn,
- 'uid'=>$data['uid']
- ];
- $id = Db::name('merchant_annual_cost_order')->insertGetId($insertData);
- $access->nianfei_yj($id);
- break;
- case 6:
- //赠送返本商户
- $mer = Db::name('user_mer') -> where('uid',$data['uid']) -> find();
- if(!$mer){
- Db::name('user_mer') -> insert(['uid'=>$data['uid'],'mer'=>10]);
- }else{
- Db::name('user_mer') -> where('uid',$data['uid'])->inc('mer', 10) ->update();;
- }
- //赠送商户
- $merchant=Db::name('merchant')->where('uid',$data['uid'])->find();
- if(!$merchant)
- Db::name('merchant_intention')->insert(['uid'=>$data['uid'],'activation_code'=>rand('000000000','999999999')]);
- //赠送大仓会员资格
- $dacang_user = Db::name('da_cang_user')->where('uid', $data['uid'])->find();
- $dc_id = 1;
- //如果不是金卡会员,赠送金卡会员一年
- if (!$dacang_user) {
- Db::name('da_cang_user')->insert(['uid' => $data['uid'], 'ctime' => time(), 'end_time' => $end_time, 'dc_id' => $dc_id,'status'=>1,'type'=>1]);
- }else{
- //如果是银卡会员,变成金卡,一年 || 是否已过期,如果已过期,赠送金卡会员一年
- if($dacang_user['type'] == 2 || $dacang_user['end_time'] < $time){
- Db::name('da_cang_user')->where('uid', $data['uid'])->where('dc_id', $dc_id)->update(['end_time' => $end_time,'status'=>1,'type'=>1]);
- }
- }
- $order_sn = 'sIC'.$storeOrderRepository->getNewOrderId();
- $insertData=[
- 'pay_price'=>systemConfig("channel_price"),
- 'status'=>1,
- 'order_no'=>$order_sn,
- 'uid'=>$data['uid']
- ];
- Db::name('channel_order')->insertGetId($insertData);
- //渠道商
- $channel_user=Db::name('channel_user')->where('uid',$data['uid']) -> find();
- if($channel_user){
- Db::name('channel_user')->where('uid',$data['uid'])->update(['status'=>1]);
- }else{
- Db::name('channel_user')->insert(['uid'=>$data['uid'],'status'=>1,'ctime'=>time(),'recommend_uid'=>$recommend]);
- }
- $access->channel_fenyong($order_sn);
- break;
- }
- return app('json')->success('付费身份设置成功');
- }else{
- //未付费
- switch ($data['type']){
- case 3:
- case 4:
- $dacang_user = Db::name('da_cang_user')->where('uid', $data['uid'])->find();
- $type = $data['type'] == 3 ? 2 : 1;
- //如果原来有大仓会员。修改
- if ($dacang_user) {
- Db::name('da_cang_user')->where('uid', $data['uid'])->where('dc_id', $dc_id)->update(['end_time' => $end_time,'status'=>1,'type'=>$type]);
- } else {
- //新会员
- Db::name('da_cang_user')->insert(['uid' => $data['uid'], 'ctime' => time(), 'end_time' => $end_time, 'dc_id' => $dc_id,'status'=>1,'type'=>$type]);
- }
- break;
- case 5:
- //赠送商户
- $merchant=Db::name('merchant')->where('uid',$data['uid'])->find();
- if(!$merchant)
- Db::name('merchant_intention')->insert(['uid'=>$data['uid'],'status'=>3,'activation_code'=>rand('000000000','999999999')]);
- break;
- case 6:
- //渠道商
- $channel_user=Db::name('channel_user')->where('uid',$data['uid']) -> find();
- if($channel_user){
- Db::name('channel_user')->where('uid',$data['uid'])->update(['status'=>1]);
- }else{
- Db::name('channel_user')->insert(['uid'=>$data['uid'],'status'=>1,'ctime'=>time(),'recommend_uid'=>$recommend]);
- }
- }
- return app('json')->success('未付费身份设置成功');
- }
- }
- public function gongfu_user(){
- $data = $this->request->params(["uid","red","type"]);
- if(empty($data['uid']) || empty($data['type'])){
- return app('json')->fail('参数错误');
- }
- $type = $data['type'];
- $red = $data['red'];
- $uid = $data['uid'];
- $check = Db::name('user_rich')->where('uid',$uid)->find();
- if($check){
- $update['type'] = $type;
- Db::name('user_rich')->where('uid',$uid)->update($update);
- }else{
- Db::name('user_rich')->insert(['uid' => $uid, 'type' => $type]);
- }
- if ($red > 0){
- Db::name('user_rich')->where('uid',$uid)->inc('red', $red)->update();
- Db::name('user_rich_log')->insert([
- 'uid' => $uid,
- 'red' => $red,
- 'pm' => 1,
- 'time' => time(),
- 'order_id' => 0,
- 'mark' => '系统赠送红积分'
- ]);
- }
- return app('json')->success('身份设置成功');
- }
- public function bangfu(){
- $data = $this->request->params(["uid"]);
- if(empty($data['uid'])){
- return app('json')->fail('参数错误');
- }
- $uid = $data['uid'];
- $check = Db::name('user_bangfu') -> where('uid', $uid) -> find();
- if (!$check){
- Db::name('user_bangfu')->insert([
- 'uid' => $uid,
- 'time' => time(),
- 'status' => 1
- ]);
- }
- return app('json')->success('身份设置成功');
- }
- public function bangfu_list(){
- [$page, $limit] = $this->getPage();
- $list = Db::name('user_bangfu')
- -> alias('ub')
- -> join('user u', 'u.uid = ub.uid')
- -> leftJoin('user_rich ur', 'ub.uid = ur.uid')
- -> field('u.nickname,u.account,ub.status,ur.type,ub.id as uid')
- -> page($page, $limit)
- -> select();
- return app('json')->success($list);
- }
- public function bangfu_examine(){
- $data = $this->request->params(["uid","status"]);
- if(empty($data['uid'])){
- return app('json')->fail('参数错误');
- }
- $uid = $data['uid'];
- $check = Db::name('user_bangfu') -> where('id', $uid) -> find();
- if (!$check){
- return app('json')->fail('不存在');
- }
- $save = Db::name('user_bangfu') -> where('uid', $uid) -> update(['status'=>$data['status']]);
- if ($save){
- return app('json')->success('修改成功');
- }
- return app('json')->fail('出错');
- }
- public function importExcel()
- {
- $file = request()->file('file');
- if(!$file){
- return app('json')->fail('请上传文件');
- }
- $extension = pathinfo($file->getOriginalName(), PATHINFO_EXTENSION);
- if ($extension != 'xlsx' && $extension != 'xls') {
- return app('json')->fail('请上传xlx或xlsx文件');
- }
- // 创建一个新的Excel读取器对象
- $objReader = \PHPExcel_IOFactory::createReader('Excel2007');
- $objPHPExcel = $objReader->load($file);
- // 选择活动工作表
- $objPHPExcel->setActiveSheetIndex(0);
- $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
- // 循环遍历行和列
- $yonghu=[];
- foreach ($sheetData as $k=>$row) {
- if($k==1){
- continue;
- }
- if($row['A'] && $row['A']!=NULL && $row['A']!=''){
- $yonghu[]=array('a'=>$row['A'],'b'=>$row['B']);
- }
- }
- if(count($yonghu)<1){
- return app('json')->fail('未获取到数据');
- }
- $repository = app()->make(UserRepository::class);
- foreach ($yonghu as $k=>$v){
- $user = $repository->accountByUser($v['a']);
- if ($user){
- // return app('json')->fail('手机号已存在');
- $yonghu[$k]['user'] = $user;
- }else{
- $yonghu[$k]['user'] = $repository->registr($v['a'],'A123456','APP',0);
- }
- }
- foreach ($yonghu as $v){
- $user=$v['user'];
- $spread_uid=$v['user']['spread_uid'];
- if($v['b'] && $v['b']!=null && $v['b']!=''){
- $pid=Db::name('user')->where('account',$v['b'])->value('uid');
- if($pid){
- $repository->bindSpread($user, intval($pid));
- $spread_uid=$pid;
- }
- }
- $mer_count=Db::name('merchant')->where('uid',$user['uid'])->count();
- if(!$mer_count){
- // $code_insert['uid']=$v['uid'];
- // $code_insert['code']=time().'_'.$this->generateRandomCode(20);
- // $code_insert['ctime']=time();
- // $code_insert['type']=2;
- // $re=Db::name('activation_code')->insertGetId($code_insert);
- $mer_insert['uid']=$user['uid'];
- $mer_insert['spread_uid']=$spread_uid;
- $mer_id=Db::name('merchant')->insertGetId($mer_insert);
- $merchant_admin_insert['mer_id']=$mer_id;
- $merchant_admin_insert['uid']= $user['uid'];
- $merchant_admin_insert['account']= $user['account'];
- $merchant_admin_insert['real_name']= $user['account'];
- $merchant_admin_insert['phone']= $user['account'];
- $merchant_admin_insert['level']= 0;
- $re=Db::name('merchant_admin')->insertGetId($merchant_admin_insert);
- $merchant_intention['mer_id']=$mer_id;
- $merchant_intention['uid']= $user['uid'];
- $merchant_intention['phone']= $user['account'];
- Db::name('merchant_intention')->insertGetId($merchant_intention);
- // insert into rrx_merchant_admin(mer_id,uid,account,pwd,phone,real_name,level) values (#{mer_id},#{uid},#{account},#{pwd},#{phone},#{real_name},#{level})
- }
- }
- return app('json')->success('导入成功');
- }
- public function getImAdmin(){
- try {
- $data = json_decode('{
- "im_pass": 873947,
- "im_user_id": "admin",
- "im_uuid": "53d0f370-f104-11ee-8cd6-45641584429c"
- }',true);
- return app('json')->success($data);
- $im = new Im();
- $data = [];
- $data['im_pass'] = mt_rand(100000,999999);
- $data['im_user_id'] = 'admin';
- $data['im_uuid']= $im->createImUser('useradmin', 'admin',$data['im_pass']);
- return app('json')->success($data);
- } catch (\Exception $e) {
- Db::name('log')->insert(['data'=>'注册异常'.$e->getFile().$e->getMessage().$e->getLine()]);
- }
- return app('json')->fail('注册失败');
- }
- public function enterpriseUserScoreApi(){
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['uid']);
- $list=Db::name('user_sign_score')->where($where)->page($page, $limit)->order('id desc')->select();
- foreach ($list as $k=>$v){
- $v['pm_text']='收入';
- if($v['pm']==2 || $v['pm']==4){
- $v['pm_text']='支出';
- $v['reward_socre']='-'.$v['reward_socre'];
- }else{
- $v['pm_text']='收入';
- $v['reward_socre']='+'.$v['reward_socre'];
- }
- if($v['order_id'] && empty($v['order_sn'])){
- $v['order_sn']=Db::name('store_order')->where('order_id',$v['order_id'])->value('order_sn');
- }
- if(empty($v['order_sn'])){
- $v['order_sn']='--';
- }
- $v['create_time'] = $v['settlement_time'];
- $v['create_time'] = date("Y-m-d H:i:s", $v['addtime']);
- $list[$k]=$v;
- }
- $data['list']=$list;
- $data['count']=Db::name('user_sign_score')->where($where)->count();
- return app('json')->success($data);
- }
- /**
- * 获取合伙人分红记录
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- */
- public function getWeekAwardList()
- {
- [$page, $limit] = $this->getPage();
- $nickname = request()->param('nickname','');
- $account = request()->param('account','');
- $where = [];
- if($nickname) $where[] = ['u.nickname','like','%'.$nickname.'%'];
- if($account) $where[] = ['u.account','=',$account];
- $query = Db::name('old_user_weekaward')->alias('w')
- ->leftJoin('user u','w.user_id=u.uid')
- ->leftJoin('old_user_starlevel star','star.id=w.user_star_id')
- ->field('w.*,u.uid,u.real_name,u.nickname,star.title')
- ->where($where);
- $data = $query->page($page)
- ->limit($limit)
- ->order('w.id desc')
- ->select();
- $count = $query->count();
- if($data) {
- $data = $data->toArray();
- foreach ($data as $k => $v){
- $data[$k]['award_num'] = bcadd($v['award_num'],$v['award_num_sm'],2);
- $data[$k]['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
- $data[$k]['radio'] = $v['radio'] == 2 ? '已发放' : '未发放';
- }
- }
- $return_data['list'] = $data;
- $return_data['count'] = $count;
- return app('json')->success($return_data);
- }
- /**
- * 获取联创奖励记录
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- */
- public function getOriginatorList()
- {
- [$page, $limit] = $this->getPage();
- $nickname = request()->param('nickname','');
- $account = request()->param('account','');
- $where = [];
- if($nickname) $where[] = ['u.nickname','like','%'.$nickname.'%'];
- if($account) $where[] = ['u.account','=',$account];
- $query = Db::name('old_user_originator')->alias('o')
- ->leftJoin('user u','o.user_id=u.uid')
- ->leftJoin('old_user_lianc lianc','lianc.id=o.user_lianc_id')
- ->field('o.*,u.uid,u.real_name,u.nickname,lianc.title')
- ->where($where);
- $data = $query->page($page)
- ->limit($limit)
- ->order('o.id desc')
- ->select();
- $count = $query->count();
- if($data) {
- $data = $data->toArray();
- foreach ($data as $k=>$v){
- $data[$k]['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
- }
- }
- $return_data['list'] = $data;
- $return_data['count'] = $count;
- return app('json')->success($return_data);
- }
- /**
- * 获取股权分红记录
- * @return mixed
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- */
- public function getStockList()
- {
- [$page, $limit] = $this->getPage();
- $nickname = request()->param('nickname','');
- $account = request()->param('account','');
- $where = [];
- if($nickname) $where[] = ['u.nickname','like','%'.$nickname.'%'];
- if($account) $where[] = ['u.account','=',$account];
- $query = Db::name('old_user_stock')->alias('o')
- ->leftJoin('user u','o.user_id=u.uid')
- ->field('o.*,u.uid,u.real_name,u.nickname')
- ->where($where);
- $data = $query->page($page)
- ->limit($limit)
- ->order('o.id desc')
- ->select();
- $count = $query->count();
- if($data) {
- $data = $data->toArray();
- foreach ($data as $k=>$v){
- $data[$k]['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
- $data[$k]['update_time'] = date('Y-m-d H:i:s',$v['update_time']);
- }
- }
- $return_data['list'] = $data;
- $return_data['count'] = $count;
- return app('json')->success($return_data);
- }
- }
|