QyzxController.java 19.3 KB
Newer Older
yuquan.zhu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
package cn.timer.api.controller.qyzx;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Stream;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.additional.query.impl.LambdaQueryChainWrapper;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.timer.api.bean.qyzx.QyzxAttaFpgl;
import cn.timer.api.bean.qyzx.QyzxAttaFpzl;
import cn.timer.api.bean.qyzx.QyzxAttaFwjsb;
import cn.timer.api.bean.qyzx.QyzxEmpEntAsso;
import cn.timer.api.bean.qyzx.QyzxEmpLogin;
import cn.timer.api.bean.qyzx.QyzxEntAuth;
import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import cn.timer.api.bean.qyzx.QyzxLogBuy;
import cn.timer.api.bean.qyzx.QyzxPayServe;
import cn.timer.api.bean.zzgl.ZzglAuth;
import cn.timer.api.bean.zzgl.ZzglBmgwM;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enums.CommonEnum;
import cn.timer.api.dao.qyzx.QyzxAttaFpzlMapper;
import cn.timer.api.dao.qyzx.QyzxEmpEntAssoMapper;
import cn.timer.api.dao.qyzx.QyzxEmpLoginMapper;
import cn.timer.api.dao.qyzx.QyzxEntInfoMMapper;
import cn.timer.api.dao.qyzx.QyzxLogBuyMapper;
import cn.timer.api.dao.zzgl.ZzglBmgwMMapper;
import cn.timer.api.dto.login.QysDto;
import cn.timer.api.dto.qyzx.AdminListDto;
import cn.timer.api.dto.qyzx.AttaFpglQueryDto;
import cn.timer.api.dto.qyzx.LogBuyDto;
import cn.timer.api.dto.qyzx.QyzxAttaFpzlQueryDto;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@Api(tags = "4.0企业中心")
// @RequestMapping(value = "/qyzx", produces = { "application/json",
// "multipart/form-data", "form-data" }, consumes = { "application/json",
// "multipart/form-data" })
@RequestMapping(value = "/qyzx", produces = { "application/json" })
public class QyzxController {
	@Autowired
	private HttpSession session;

	@Autowired
	private QyzxEmpEntAssoMapper qyzxEmpEntAssoMapper;

	@Autowired
	private QyzxEntInfoMMapper qyzxEntInfoMMapper;

	@Autowired
	private QyzxEmpLoginMapper qyzxEmpLoginMapper;

	@Autowired
	private QyzxLogBuyMapper qyzxLogBuyMapper;

	@Autowired
	private QyzxAttaFpzlMapper qyzxAttaFpzlMapper;

	/**
	 * 获取企业信息
	 * 
	 * @param
	 * @return
	 */
	@GetMapping(value = "/ent")
	@ApiOperation(value = "获取企业信息", httpMethod = "GET", notes = "接口发布说明")
	public Result<QyzxEntInfoM> selectent(@CurrentUser UserBean userBean) {
		Integer orgCode = userBean.getOrgCode();
		QyzxEntInfoM qyzxEntInfoM = new LambdaQueryChainWrapper<QyzxEntInfoM>(qyzxEntInfoMMapper)
				.eq(orgCode != null, QyzxEntInfoM::getId, orgCode).one();
		return ResultUtil.data(qyzxEntInfoM, "获取企业信息成功");
	}

	/**
	 * 返回类名
	 * 
	 * @return
	 */
	/*
	 * private String className() { return this.getClass().getName(); }
	 */

	/**
	 * 企业认证-申请
	 * 
	 * @param qyzxEntAuth
	 * @return
	 */

	@PostMapping(value = "/entauth")
	@ApiOperation(value = "企业认证", httpMethod = "POST", notes = "接口发布说明")
	public Result<QyzxEntAuth> entauth(@CurrentUser UserBean userBean, @RequestBody QyzxEntAuth qyzxEntAuth) {
		// 查询表结果
		// QyzxEntAuth result = qyzxEntAuth.selectById();
		// System.err.println(result);
		// if (result == null) {
		// 设置审核状态
		qyzxEntAuth.setAuthType(CommonEnum.AUTH_TYPE_UNDEREVIEW.getType());
		// 插入数据
		qyzxEntAuth.insert();
		// }
		return ResultUtil.data(qyzxEntAuth, "申请企业认证中");
	}

	/**
	 * 企业认证-审核-通过/未通过
	 * 
	 * @param qyzxEntAuth
	 * @return
	 */
	@PostMapping(value = "/entauthcheck")
	@ApiOperation(value = "企业认证", httpMethod = "POST", notes = "接口发布说明")
	public Result<QyzxEntAuth> entauthcheck1(@CurrentUser UserBean userBean, @RequestBody QyzxEntAuth qyzxEntAuth) {
		Integer id = qyzxEntAuth.getId();
		Integer authType = qyzxEntAuth.getAuthType();
		if (id == null || authType == null) {
			return ResultUtil.error("参数缺少/异常");
		}

		QyzxEntAuth entAuth = QyzxEntAuth.builder().id(id).authType(authType).build();
		boolean b = entAuth.updateById();
		if (b) {
			return ResultUtil.data(qyzxEntAuth, "企业认证-审批成功");
		} else {
			return ResultUtil.error("企业认证-审批失败");
		}

	}

	/**
	 * 企业列表
	 * 
	 * @param
	 * @return
	 */
	@GetMapping(value = "/entlist")
	@ApiOperation(value = "企业列表", httpMethod = "GET", notes = "接口发布说明", position = 98)
	public Result<List<QyzxEntInfoM>> entlist1(@CurrentUser UserBean userBean) {
		Integer empNum = userBean.getEmpNum();
		QueryWrapper<QyzxEmpEntAsso> queryWrapper = new QueryWrapper<>();
		queryWrapper.select("org_code").eq("emp_num", empNum);
		List<Object> orgCodes = qyzxEmpEntAssoMapper.selectObjs(queryWrapper);
		List<QyzxEntInfoM> qyzxEntInfoMs = new LambdaQueryChainWrapper<QyzxEntInfoM>(qyzxEntInfoMMapper)
				.in(CollUtil.isNotEmpty(orgCodes), QyzxEntInfoM::getId, orgCodes).list();
		return ResultUtil.data(qyzxEntInfoMs, "获取企业信息成功");
	}

	@Autowired
	ZzglBmgwMMapper zzglBmgwMMapper;

	/**
	 * 切换企业
	 * 
	 * @param org_num
	 * @return
	 */
	@GetMapping(value = "/changeent/{orgCode}")
	@ApiOperation(value = "切换企业", httpMethod = "GET", notes = "接口发布说明", position = 97)
	public Result<List<String>> changeent(@CurrentUser UserBean userBean, @PathVariable Integer orgCode) {
		// 查询该员工加入的企业id列表
		QyzxEmpLogin emp = userBean.getQyzxEmpLogin();
		Stream<QysDto> s = emp.getQys().stream().filter(o ->orgCode.equals( o.getId()));
		// 判断 切换目标企业id 是否包含在 企业id列表 内
		if (s != null) {
			List<String> menus = new ArrayList<>();
			QysDto ctrl = s.findFirst().get();
			if (  CommonEnum.U_TYPE_ADMIN.getType().equals(ctrl.getUserType())
					||  CommonEnum.U_TYPE_C_ADMIN.getType().equals(ctrl.getUserType())) {
			} else {
				// 获取权限
				ArrayList<Integer> list = new ArrayList<Integer>();
				List<ZzglBmgwM> zzglBmgwMs = new LambdaQueryChainWrapper<ZzglBmgwM>(zzglBmgwMMapper)
						.eq(ZzglBmgwM::getOrgCode, ctrl.getId()).list();
				// 传入的部门岗位是登录者的岗位id.获取的list中只有一个元素,不必要
				ZzglBmgwM.getupDepts(list, ctrl.getBmgwId(), zzglBmgwMs);
				if (list != null && list.size() > 0) {
					LambdaQueryWrapper<ZzglAuth> wp = new LambdaQueryWrapper<>();
					wp.select(ZzglAuth::getMenuId).eq(ZzglAuth::getOrgCode, ctrl.getId())
							.and(i -> i.in(ZzglAuth::getBmgwId, list.toArray()));
					List<ZzglAuth> zas = ZzglAuth.builder().build().selectList(wp);
					if(zas.size()==0)
						return ResultUtil.error(null, "切换企业失败,在该公司没有权限");
					zas.stream().forEach(o -> menus.add(o.getMenuId()));
				}else{
					return ResultUtil.error(null, "切换企业失败,在该公司没有权限");
				}
			}
			emp.setOrgId(orgCode);
			session.setAttribute("ui", emp);
			qyzxEmpLoginMapper.updateById(emp);
			return ResultUtil.data(menus, "切换企业成功");
		} else {
			return ResultUtil.error();
		}
	}

	/**
	 * 获取开票资料
	 */
	/*
	 * @Override public Result<QyzxEntInfoM> selectfpzl() { Integer orgCode =
	 * List<QyzxAttaFpzl> qyzxAttaFpzl =
	 * QyzxAttaFpzl.builder().build().selectList(new
	 * QueryWrapper<QyzxAttaFpzl>().eq("org_code", orgCode)); return new
	 * ResultUtil.data("获取发票资料成功", qyzxAttaFpzl); }
	 */

	/**
	 * 添加/修改开票资料
	 * 
	 * @param
	 * @return
	 */
	@PostMapping(value = "/fpzl")
	@ApiOperation(value = "添加/修改发票资料", httpMethod = "POST", notes = "接口发布说明")
	public Result<QyzxAttaFpzl> addfpzl(@CurrentUser UserBean userBean, @RequestBody QyzxAttaFpzl qyzxAttaFpzl) {
		qyzxAttaFpzl.setOrgCode(userBean.getOrgCode());
		qyzxAttaFpzl.insertOrUpdate();
		return ResultUtil.data(qyzxAttaFpzl, "添加/修改发票资料成功");
	}

	/**
	 * 设置默认发票
	 * 
	 * @param
	 * @return
	 */
	@GetMapping(value = "/defaultfp/{id}")
	@ApiOperation(value = "设置默认发票", httpMethod = "GET", notes = "接口发布说明")
	public Result<Void> setdef(@CurrentUser UserBean userBean, @PathVariable("id") Integer id) {
		// 将所有地址设为非默认
		UpdateWrapper<QyzxAttaFpzl> updateWrapper = new UpdateWrapper<QyzxAttaFpzl>();
		QyzxAttaFpzl q = QyzxAttaFpzl.builder().orgCode(userBean.getOrgCode()).isDefault(2).build();
		qyzxAttaFpzlMapper.update(q, updateWrapper);

		// 根据id将发票设为默认
		updateWrapper.eq("id", id);
		QyzxAttaFpzl w = QyzxAttaFpzl.builder().orgCode(userBean.getOrgCode()).id(id).isDefault(1).build();
		qyzxAttaFpzlMapper.update(w, updateWrapper);

		// 返回成功
		return ResultUtil.success("设置成功");
	}

	/**
	 * 删除开票资料
	 * 
	 * @param
	 * @return
	 */
	@DeleteMapping(value = "/fpzl/{id}")
	@ApiOperation(value = "删除发票资料", httpMethod = "DELETE", notes = "接口发布说明")
	public Result<Integer> deletefpzl(@PathVariable Integer id) {
		QyzxAttaFpzl.builder().build().deleteById(id);
		return ResultUtil.data(id, "删除发票资料成功");
	}

	// 获取发票管理
	/*
	 * @Override public Result<QyzxEntInfoM> selectfpgl() { Integer orgCode =
	 * qyzxAttaFpgl = QyzxAttaFpgl.builder().build().selectList(new
	 * QueryWrapper<QyzxAttaFpgl>().eq("org_code", orgCode)); return new
	 * ResultUtil.data("获取发票管理成功", qyzxAttaFpgl); }
	 */

	/**
	 * 添加/修改发票管理
	 * 
	 * @param
	 * @return
	 */
	@PostMapping(value = "/fpgl")
	@ApiOperation(value = "添加/修改发票管理", httpMethod = "POST", notes = "接口发布说明")
	public Result<QyzxAttaFpgl> addfpgl(@CurrentUser UserBean userBean, @RequestBody QyzxAttaFpgl qyzxAttaFpgl) {
		qyzxAttaFpgl.setOrgCode(userBean.getOrgCode());
		qyzxAttaFpgl.insertOrUpdate();
		return ResultUtil.data(qyzxAttaFpgl, "添加/修改发票管理成功");
	}

	/**
	 * 删除开票资料
	 * 
	 * @param
	 * @return
	 */
	@DeleteMapping(value = "/fpgl/{id}")
	@ApiOperation(value = "删除发票管理", httpMethod = "DELETE", notes = "接口发布说明")
	public Result<Integer> deletefpgl(@PathVariable Integer id) {
		QyzxAttaFpgl.builder().build().deleteById(id);
		return ResultUtil.data(id, "删除发票管理成功");
	}

	/**
	 * 开票资料查询
	 * 
	 * @param
	 * @return
	 */
	@PostMapping(value = "/fpzlquery")
	@ApiOperation(value = "发票资料查询", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> queryfpzl(@CurrentUser UserBean userBean,
			@RequestBody QyzxAttaFpzlQueryDto qyzxAttaFpzlQueryDto) {
		String titleOrAddress = qyzxAttaFpzlQueryDto.getNameOrAddress();

		Page<QyzxAttaFpzl> page = new Page<QyzxAttaFpzl>(
				qyzxAttaFpzlQueryDto.getCurrentPage() == null ? 1 : qyzxAttaFpzlQueryDto.getCurrentPage(),
				qyzxAttaFpzlQueryDto.getTotalPage() == null ? 10 : qyzxAttaFpzlQueryDto.getTotalPage());

		QueryWrapper<QyzxAttaFpzl> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("org_code", userBean.getOrgCode()).and(!StrUtil.hasBlank(titleOrAddress),
				wq -> wq.likeRight("address", titleOrAddress).or().likeRight("title", titleOrAddress));
		IPage<QyzxAttaFpzl> qyzxAttaFpzlPage = QyzxAttaFpzl.builder().build().selectPage(page, queryWrapper);
		List<QyzxAttaFpzl> qyzxAttaFpzls = qyzxAttaFpzlPage.getRecords();
		qyzxAttaFpzlPage.getCurrent();
		qyzxAttaFpzlPage.getPages();
		qyzxAttaFpzlPage.getTotal();
		qyzxAttaFpzlPage.getSize();
		return ResultUtil.data(qyzxAttaFpzlPage, qyzxAttaFpzls, "发票资料查询成功");
	}

	/**
	 * 发票管理查询
	 * 
	 * @param
	 * @return
	 */
	@PostMapping(value = "/fpglquery")
	@ApiOperation(value = "发票管理查询", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> queryfpgl(@CurrentUser UserBean userBean, @RequestBody AttaFpglQueryDto attaFpglQueryDto) {
		String query = attaFpglQueryDto.getQuery();
		String startTime = attaFpglQueryDto.getStartTime();
		String endTime = attaFpglQueryDto.getEndTime();
		Page<QyzxAttaFpgl> page = new Page<QyzxAttaFpgl>(
				attaFpglQueryDto.getCurrentPage() == null ? 1 : attaFpglQueryDto.getCurrentPage(),
				attaFpglQueryDto.getTotalPage() == null ? 10 : attaFpglQueryDto.getTotalPage());
		Integer orgCode = userBean.getOrgCode();
		QueryWrapper<QyzxAttaFpgl> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("org_code", orgCode).gt(!StrUtil.hasBlank(startTime), "create_time", startTime)
				.lt(!StrUtil.hasBlank(endTime), "create_time", endTime)
				.and(!StrUtil.hasBlank(query), wq -> wq.likeRight("title", query).or().likeRight("project", query));
		List<QyzxAttaFpgl> qyzxAttaFpgls = QyzxAttaFpgl.builder().build().selectList(queryWrapper);
		/*
		 * queryWrapper.eq("org_code", orgCode) .between(!StrUtil.hasBlank(startTime) &&
		 * !StrUtil.hasBlank(endTime), "create_time", !StrUtil.hasBlank(startTime) ?
		 * startTime : "1000-01-01 00:00:00", !StrUtil.hasBlank(endTime) ? endTime :
		 * "9999-01-01 00:00:00") .and(!StrUtil.hasBlank(query), wq ->
		 * wq.likeRight("title", query).or().likeRight("project", query));
		 */

		/*
		 * IPage<QyzxAttaFpgl> qyzxAttaFpglPage =
		 * QyzxAttaFpgl.builder().build().selectPage(page, queryWrapper);
		 * List<QyzxAttaFpgl> qyzxAttaFpgls = qyzxAttaFpglPage.getRecords();
		 * qyzxAttaFpglPage.getCurrent(); qyzxAttaFpglPage.getPages();
		 * qyzxAttaFpglPage.getTotal(); qyzxAttaFpglPage.getSize();
		 */

		return ResultUtil.data(page, qyzxAttaFpgls, "发票资料查询成功");
	}

	// 下载系统使用手册 直接提供(OSS公共读权限文件)url地址到前端按钮

	/**
	 * 购买服务(添加服务计算,添加购买记录)
	 * 
	 * @param
	 * @return
	 */
	@PostMapping(value = "/gmfw")
	@ApiOperation(value = " 购买服务(添加服务计算,添加购买记录)", httpMethod = "POST", notes = "接口发布说明")
	public Result<QyzxLogBuy> addgmfw(@CurrentUser UserBean userBean, @RequestBody QyzxLogBuy qyzxLogBuy) {
		Integer payServeId = qyzxLogBuy.getPayServeId();// 套餐的付费服务的id
		Integer num = qyzxLogBuy.getNum();// 套餐的购买次数
		QyzxPayServe qyzxPayServe = QyzxPayServe.builder().id(payServeId).build().selectById();
		Integer code = qyzxPayServe.getCode();// 获取套餐的付费服务代码

		Double o = qyzxPayServe.getOriginalPrice();
		Double s = qyzxPayServe.getSpecialPrice();
		Double price = (s != null && s > 0d ? s : o);
		Double money = NumberUtil.round(NumberUtil.mul(price, num), 4).doubleValue();
		log.info("money:" + money);
		Date date = new Date();
		log.info("date:" + date);
		// 添加购买记录表
		QyzxLogBuy.builder().empNum(userBean.getEmpNum()).payServeId(payServeId).money(money).num(num).createTime(date)
				.build().insertOrUpdate();
		// 添加或修改服务计算表
		Integer number = qyzxPayServe.getNum();
		QueryWrapper<QyzxAttaFwjsb> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("emp_num", userBean.getEmpNum()).eq("code", code);
		Integer result = QyzxAttaFwjsb.builder().build().selectCount(queryWrapper);
		if (result != null && result > 0) {
			QyzxAttaFwjsb fwjb = QyzxAttaFwjsb.builder().build().selectOne(queryWrapper);
			// 续费
			QyzxAttaFwjsb.builder().id(fwjb.getId()).empNum(userBean.getEmpNum()).code(code)
					.hasNum(fwjb.getHasNum() + num * number).createTime(date).build().insertOrUpdate();
		} else {
			// 新增
			QyzxAttaFwjsb.builder().empNum(userBean.getEmpNum()).code(code).hasNum(num * number).createTime(date)
					.build().insertOrUpdate();
		}
		return ResultUtil.data(qyzxLogBuy, "添加/修改发票资料成功");
	}

	// 使用系统购买服务
	/**
	 * 获取服务计算
	 * 
	 * @param
	 * @return
	 */
	@GetMapping(value = "/fwjs")
	@ApiOperation(value = "查看服务计算", httpMethod = "GET", notes = "接口发布说明")
	public Result<List<QyzxAttaFwjsb>> fwjs(@CurrentUser UserBean userBean) {
		List<QyzxAttaFwjsb> qyzxAttaFpgl = QyzxAttaFwjsb.builder().build()
				.selectList(new QueryWrapper<QyzxAttaFwjsb>().eq("emp_num", userBean.getEmpNum()));
		return ResultUtil.data(qyzxAttaFpgl, "获取服务计算成功");
	}

	/**
	 * 获取购买记录
	 * 
	 * @param
	 * @return
	 */
	@GetMapping(value = "/gmjl")
	@ApiOperation(value = "获取购买记录", httpMethod = "GET", notes = "接口发布说明")
	public Result<List<QyzxLogBuy>> selectgmjl(@CurrentUser UserBean userBean) {
		List<QyzxLogBuy> qyzxLogBuy = QyzxLogBuy.builder().build()
				.selectList(new QueryWrapper<QyzxLogBuy>().eq("emp_num", userBean.getEmpNum()));
		return ResultUtil.data(qyzxLogBuy, "获取购买记录成功");
	}

	/**
	 * 查询购买记录
	 * 
	 * @param
	 * @return
	 */
	@PostMapping(value = "/gmjlquery")
	@ApiOperation(value = "查询购买记录", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> querygmjl(@CurrentUser UserBean userBean, @RequestBody AttaFpglQueryDto attaFpglQueryDto) {

		Integer empNum = userBean.getEmpNum();
		attaFpglQueryDto.setEmpNum(empNum);

		IPage<LogBuyDto> page = new Page<LogBuyDto>(
				attaFpglQueryDto.getCurrentPage() == null ? 1 : attaFpglQueryDto.getCurrentPage(),
				attaFpglQueryDto.getTotalPage() == null ? 10 : attaFpglQueryDto.getTotalPage());

		List<LogBuyDto> logBuyDto = qyzxLogBuyMapper.selectByName(page, attaFpglQueryDto);

		return ResultUtil.data(page, logBuyDto, "查询成功");
	}

	/**
	 * 添加/修改企业
	 * 
	 * @param
	 * @return
	 */
	@PostMapping(value = "/ent")
	@ApiOperation(value = "添加/修改企业", httpMethod = "POST", notes = "接口发布说明")
	public Result<QyzxEntInfoM> addent(@CurrentUser UserBean userBean, @RequestBody QyzxEntInfoM qyzxEntInfoM) {
		qyzxEntInfoM.insertOrUpdate();
		Integer count = qyzxEmpEntAssoMapper.selectCount(new QueryWrapper<QyzxEmpEntAsso>()
				.eq("emp_num", userBean.getEmpNum()).eq("org_code", qyzxEntInfoM.getId()));
		if (count == null || count <= 0)
			QyzxEmpEntAsso.builder().empNum(userBean.getEmpNum()).orgCode(qyzxEntInfoM.getId()).userType(1).status(1)
					.build().insert();
		// 添加关联表
		QyzxEmpEntAsso.builder().empNum(userBean.getEmpNum()).orgCode(qyzxEntInfoM.getId()).userType(1).build()
				.insertOrUpdate();
		return ResultUtil.data(qyzxEntInfoM, "添加/修改企业");
	}

	/**
	 * 账号管理   获取账号
	 * 
	 * @param
	 * @return
	 */
	@GetMapping(value = "/adminlist/{page}/{limit}")
	@ApiOperation(value = "获取账号", httpMethod = "GET", notes = "接口发布说明")
	public Result<Object> adminlist(@CurrentUser UserBean userBean ,@PathVariable("page") Integer page ,@PathVariable("limit") Integer limit) {
		IPage<AdminListDto> page1  = new Page<AdminListDto>(page,limit );
		return ResultUtil.data(page1, qyzxEmpEntAssoMapper.adminlist(page1,userBean.getOrgCode()), "获取账号");
	}


}