| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import com.ruoyi.common.core.domain.BasePage; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.ExchangeGoodsDto; |
| | | import com.ruoyi.system.dto.TErpGoodsUpdateStatusDto; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.ExchangeGoodsRecordQuery; |
| | | import com.ruoyi.system.query.TSysGoodsExchangeQuery; |
| | | import com.ruoyi.system.query.TSysGoodsQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.ExchangeGoodsRecordDetailVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private final TSysGoodsExchangeService sysGoodsExchangeService; |
| | | private final TCrmClinicService crmClinicService; |
| | | private final TCrmClinicPointsService crmClinicPointsService; |
| | | private final TCrmChangePointsService crmChangePointsService; |
| | | |
| | | |
| | | @Autowired |
| | | public TSysGoodsController(TokenService tokenService, TSysGoodsService sysGoodsService, TCrmSupplierService crmSupplierService, TSysGoodsExchangeService sysGoodsExchangeService, TCrmClinicService crmClinicService, TCrmClinicPointsService crmClinicPointsService) { |
| | | public TSysGoodsController(TokenService tokenService, TSysGoodsService sysGoodsService, TCrmSupplierService crmSupplierService, TSysGoodsExchangeService sysGoodsExchangeService, TCrmClinicService crmClinicService, TCrmClinicPointsService crmClinicPointsService, TCrmChangePointsService crmChangePointsService) { |
| | | this.sysGoodsService = sysGoodsService; |
| | | this.tokenService = tokenService; |
| | | this.crmSupplierService = crmSupplierService; |
| | | this.sysGoodsExchangeService = sysGoodsExchangeService; |
| | | this.crmClinicService = crmClinicService; |
| | | this.crmClinicPointsService = crmClinicPointsService; |
| | | |
| | | this.crmChangePointsService = crmChangePointsService; |
| | | |
| | | } |
| | | |
| | |
| | | return R.fail("请选择正确的角色"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 兑换商品记录 |
| | | */ |
| | | @ApiOperation(value = "兑换商品记录--诊所") |
| | | @PostMapping(value = "/exchangeGoodsRecord") |
| | | public R<?> exchangeGoodsRecord(@RequestBody ExchangeGoodsRecordQuery query) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | |
| | | LambdaQueryWrapper<TSysGoodsExchange> eq = new LambdaQueryWrapper<TSysGoodsExchange>().eq(TSysGoodsExchange::getClinicId, crmClinic.getId()); |
| | | if (query.getName() != null && !query.getName().isEmpty()) { |
| | | eq.like(TSysGoodsExchange::getGoodsName, query.getName()); |
| | | } |
| | | eq.orderByDesc(BaseModel::getCreateTime); |
| | | |
| | | |
| | | PageInfo<TSysGoodsExchange> page = sysGoodsExchangeService.page(new PageInfo<>(query.getPageNum(), query.getPageSize()), eq); |
| | | return R.ok(page); |
| | | } |
| | | return R.fail("请选择正确的角色"); |
| | | } |
| | | |
| | | /** |
| | | * 兑换商品记录 |
| | | */ |
| | | @ApiOperation(value = "兑换商品记录详情--诊所") |
| | | @GetMapping(value = "/exchangeGoodsRecordDetail/{id}") |
| | | public R<ExchangeGoodsRecordDetailVo> exchangeGoodsRecord(@PathVariable String id) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | TSysGoodsExchange exchangeServiceById = sysGoodsExchangeService.getById(id); |
| | | if (exchangeServiceById.getClinicId().equals(crmClinic.getId())) { |
| | | ExchangeGoodsRecordDetailVo vo = new ExchangeGoodsRecordDetailVo(); |
| | | BeanUtils.copyProperties(exchangeServiceById, vo); |
| | | |
| | | String goodsId = vo.getGoodsId(); |
| | | TSysGoods sysGoods = sysGoodsService.getById(goodsId); |
| | | vo.setGoodsDetail(sysGoods.getGoodsDetail()); |
| | | vo.setGoodsCover(sysGoods.getGoodsCover()); |
| | | |
| | | |
| | | return R.ok(vo); |
| | | } |
| | | } |
| | | return R.fail("请选择正确的角色"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 兑换商品记录 |
| | | */ |
| | | @ApiOperation(value = "积分变更记录--诊所") |
| | | @PostMapping(value = "/pointsRecordDetail") |
| | | public R<PageInfo<TCrmChangePoints>> pointsRecordDetail(@RequestBody BasePage page) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | if (roleType == 5) { |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | |
| | | PageInfo<TCrmChangePoints> page1 = crmChangePointsService.page(new PageInfo<>(page.getPageNum(), page.getPageSize()), new LambdaQueryWrapper<TCrmChangePoints>().eq(TCrmChangePoints::getBranchSalespersonId, crmClinic.getId()).eq(TCrmChangePoints::getUserType, 3).orderByDesc(BaseModel::getCreateTime)); |
| | | |
| | | return R.ok(page1); |
| | | } |
| | | return R.fail("请选择正确的角色"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |