| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | 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.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.TErpGoodsAddDto; |
| | | import com.ruoyi.system.dto.TErpGoodsInfoSaveDto; |
| | | import com.ruoyi.system.dto.TErpGoodsUpdateStatusDto; |
| | | import com.ruoyi.system.dto.*; |
| | | import com.ruoyi.system.importExcel.TErpGoodsExcel; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TErpGoodsQuery; |
| | |
| | | /** |
| | | * 获取erp问题上报管理列表 |
| | | */ |
| | | @ApiOperation(value = "供应商获取商品分页列表") |
| | | @ApiOperation(value = "供应商 诊所 获取商品分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<TErpGoodsVO>> pageList(@RequestBody TErpGoodsQuery query) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | |
| | | query.setSupplierClinicId(crmClinic.getId()); |
| | | } |
| | | return R.ok(erpGoodsService.pageList(query,user)); |
| | | } |
| | | /** |
| | | * 获取erp问题上报管理列表 |
| | | */ |
| | | @ApiOperation(value = "诊所 一键获取商品分页列表") |
| | | @PostMapping(value = "/pageAddList") |
| | | public R<Page<TErpGoods>> pageAddList(BasePage query) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | Integer roleType = user.getRoleType(); |
| | | String clinicSupplierId=null; |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | clinicSupplierId = crmClinic.getId(); |
| | | } |
| | | Page<TErpGoods> tErpGoodsPage = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | |
| | | Page<TErpGoods> page = erpGoodsService.page(tErpGoodsPage, new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getGoodsSource, 1).eq(BaseModel::getDisabled, 0).isNotNull(TErpGoods::getPlatformCommissionPrice).last(" NOT FIND_IN_SET(" + clinicSupplierId + ",clinic_ids)")); |
| | | for (TErpGoods record : page.getRecords()) { |
| | | TCrmSupplier byId = crmSupplierService.getById(record.getSupplierClinicId()); |
| | | record.setSupplierName(byId.getSupplierName()); |
| | | |
| | | |
| | | TErpGoodsType byId1 = erpGoodsTypeService.getById(record.getTypeId()); |
| | | record.setTypeName(byId1.getTypeName()); |
| | | |
| | | } |
| | | return R.ok(page); |
| | | } |
| | | |
| | | |
| | |
| | | goods.setFormulationSpec(dto.getFormulationSpec()); |
| | | goods.setPackingSpec(dto.getPackingSpec()); |
| | | goods.setGoodsName(dto.getGoodsName()); |
| | | return R.ok(erpGoodsService.save(goods)); |
| | | } |
| | | @ApiOperation(value = "诊所添加商品") |
| | | @PostMapping(value = "/clinicAdd") |
| | | public R<Boolean> clinicAdd(@Validated @RequestBody TErpClinicGoodsAddDto dto) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber())) { |
| | | return R.fail("erp商品已存在"); |
| | | } |
| | | Integer roleType = user.getRoleType(); |
| | | TErpGoods goods = new TErpGoods(); |
| | | BeanUtils.copyProperties(dto,goods); |
| | | if(roleType == 5){ |
| | | // 诊所 |
| | | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getUserId, user.getUserId()) |
| | | .last("LIMIT 1")); |
| | | goods.setSupplierClinicId(crmClinic.getId()); |
| | | goods.setGoodsSource(2); |
| | | } |
| | | goods.setCreateId(user.getUserId().toString()); |
| | | goods.setGoodsIdCode(dto.getGoodsIdCode()); |
| | | return R.ok(erpGoodsService.save(goods)); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "平台设置分佣") |
| | | @PostMapping(value = "/setCommission") |
| | | public R<Boolean> setCommission(@RequestBody @Valid TErpGoodsSetCommissionDto dto) { |
| | | |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | if(user.getRoleType()==1){ |
| | | TErpGoods goods = erpGoodsService.getById(dto.getId()); |
| | | goods.setClinicPurchasePrice(BigDecimal.valueOf(dto.getClinicPurchasePrice()).setScale(2,RoundingMode.HALF_UP)); |
| | | goods.setPlatformCommissionPrice(BigDecimal.valueOf(dto.getPlatformCommissionPrice()).setScale(2,RoundingMode.HALF_UP)); |
| | | erpGoodsService.updateById( goods); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |