|
|
|
@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
@ -225,13 +226,20 @@ public class AcitveProductInfoServiceImpl extends BaseServiceImpl<AcitveProductI |
|
|
|
public Result<PointExchangeResultDTO> getProductExchange(PointExchangeFormDTO formDTO) { |
|
|
|
// 根据token的部门权限效验是否有权限购买商品。
|
|
|
|
int productByDeptId = acitveProductDeptService.getProductByDeptId(formDTO); |
|
|
|
if (productByDeptId > 0) { |
|
|
|
if (productByDeptId == 0) { |
|
|
|
PointExchangeResultDTO pointExchangeResultDTO = new PointExchangeResultDTO(); |
|
|
|
pointExchangeResultDTO.setSuccess(false); |
|
|
|
pointExchangeResultDTO.setMessage("无权限购买此商品"); |
|
|
|
return new Result<PointExchangeResultDTO>().ok(pointExchangeResultDTO); |
|
|
|
|
|
|
|
} |
|
|
|
// 根据效验商品是否有库存 库存数量-兑换数量>0 ,
|
|
|
|
int residue = baseDao.getResidueByProductId(formDTO); |
|
|
|
if(residue>0){ |
|
|
|
|
|
|
|
if (residue == 0) { |
|
|
|
PointExchangeResultDTO pointExchangeResultDTO = new PointExchangeResultDTO(); |
|
|
|
pointExchangeResultDTO.setSuccess(false); |
|
|
|
pointExchangeResultDTO.setMessage("抱歉,库存不足"); |
|
|
|
return new Result<PointExchangeResultDTO>().ok(pointExchangeResultDTO); |
|
|
|
} |
|
|
|
// 效验可用积分是否足够兑换。 并且扣除积分
|
|
|
|
AcitveProductInfoEntity acitveProductInfoEntity = baseDao.selectById(formDTO.getProductId()); |
|
|
|
@ -259,15 +267,20 @@ public class AcitveProductInfoServiceImpl extends BaseServiceImpl<AcitveProductI |
|
|
|
acitveProductExchangeDTO.setExchangeState("0"); |
|
|
|
acitveProductExchangeService.save(acitveProductExchangeDTO); |
|
|
|
// 根据核销兑换接口链接 生成核销二维码。
|
|
|
|
String qrcodeUrl =null; |
|
|
|
try { |
|
|
|
String imageBase64 = QRCodeGenerator.createImage("https://epdc-shibei.elinkservice.cn/epdc-api/api/work/points/exchangedCheck?exchangeId="+acitveProductExchangeDTO.getId()); |
|
|
|
String imageBase64 = QRCodeGenerator.createImage("https://epdc-shibei.elinkservice.cn/epdc-api/api/work/points/exchangedCheck?exchangeId=" + acitveProductExchangeDTO.getId()); |
|
|
|
UploadFormDTO uploadFormDTO = new UploadFormDTO(); |
|
|
|
uploadFormDTO.setBase64String(imageBase64); |
|
|
|
ossFeignClientFallback.upload(uploadFormDTO); |
|
|
|
Result<String> upload = ossFeignClientFallback.upload(uploadFormDTO); |
|
|
|
qrcodeUrl= upload.getData(); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
|
|
|
|
return new Result<>(); |
|
|
|
PointExchangeResultDTO pointExchangeResultDTO = new PointExchangeResultDTO(); |
|
|
|
pointExchangeResultDTO.setSuccess(true); |
|
|
|
pointExchangeResultDTO.setMessage("兑换成功"); |
|
|
|
pointExchangeResultDTO.setQrcodeUrl(qrcodeUrl); |
|
|
|
return new Result<PointExchangeResultDTO>().ok(pointExchangeResultDTO); |
|
|
|
} |
|
|
|
} |
|
|
|
|