|
|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.platform.b2c.fa.settlement.service.impl;
|
|
|
|
|
|
+import com.uas.platform.b2c.common.account.model.User;
|
|
|
import com.uas.platform.b2c.common.base.model.FileUpload;
|
|
|
import com.uas.platform.b2c.common.base.service.FileService;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
@@ -45,8 +46,6 @@ public class BillServiceImpl implements BillService {
|
|
|
|
|
|
@Override
|
|
|
public Page<Bill> findBills(final PageInfo info, String keyword) {
|
|
|
- // Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- // info.filter("enuu", enuu);
|
|
|
if (StringUtils.hasText(keyword)) {
|
|
|
info.filter("orderid", keyword);
|
|
|
}
|
|
|
@@ -62,17 +61,27 @@ public class BillServiceImpl implements BillService {
|
|
|
public Bill save(Bill bill, FileUpload fileItem, Long useruu, Long enuu) {
|
|
|
if (bill.getId() == null) {
|
|
|
List<Bill> billList = new ArrayList<Bill>();
|
|
|
- if (Type.ENTERPRISING.value() == bill.getDissociative())
|
|
|
- billList = billDao.getBillByEnuuAndKind(enuu, bill.getKind());
|
|
|
- if (Type.PERSONAL.value() == bill.getDissociative())
|
|
|
- billList = billDao.getBillByUseruuAndEnuuAndKindAndDissociative(useruu, Type.PERSONAL.value(),bill.getKind());
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ Long userUu = useruu, enUU = enuu;
|
|
|
+ if ((enUU == null) && (user.getEnterprise() != null)) {
|
|
|
+ userUu = user.getEnterprise().getUu();
|
|
|
+ }
|
|
|
+ if (enUU == null && userUu == null) {
|
|
|
+ userUu = user.getUserUU();
|
|
|
+ }
|
|
|
+ bill.setCreateTime(new Date());
|
|
|
+ if (enUU == null) {
|
|
|
+ bill.setDissociative(Type.PERSONAL.value());
|
|
|
+ bill.setUseruu(userUu);
|
|
|
+ billList = billDao.getBillByUseruuAndKindAndDissociative(user.getUserUU(), Type.PERSONAL.value(),bill.getKind());
|
|
|
+ } else {
|
|
|
+ bill.setDissociative(Type.ENTERPRISING.value());
|
|
|
+ bill.setEnuu(enUU);
|
|
|
+ billList = billDao.getBillByEnuuAndKindAndDissociative(user.getEnterprise().getUu(), bill.getKind(), Type.ENTERPRISING.value());
|
|
|
+ }
|
|
|
if (billList.size() > 0) {
|
|
|
throw new IllegalOperatorException("相同类型的发票信息不能同时存在两条!");
|
|
|
}
|
|
|
- bill.setCreateTime(new Date());
|
|
|
- if (Type.ENTERPRISING.value() == bill.getDissociative())
|
|
|
- bill.setEnuu(enuu);
|
|
|
- bill.setUseruu(useruu);
|
|
|
}
|
|
|
if ((fileItem != null) && (fileItem.getFile() != null)) {
|
|
|
String attachUrl = fileService.save(fileItem);
|
|
|
@@ -83,9 +92,10 @@ public class BillServiceImpl implements BillService {
|
|
|
|
|
|
@Override
|
|
|
public List<Bill> getBills() {
|
|
|
- Long useruu = SystemSession.getUser().getUserUU();
|
|
|
- if (SystemSession.getUser().getEnterprise() != null) {
|
|
|
- return billDao.getBillByEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ Long useruu = user.getUserUU();
|
|
|
+ if (user.getEnterprise() != null) {
|
|
|
+ return billDao.getBillByEnuuAndDissociative(user.getEnterprise().getUu(), Type.ENTERPRISING.value());
|
|
|
} else {
|
|
|
return billDao.getBillByUseruuAndDissociative(useruu, Type.PERSONAL.value());
|
|
|
}
|
|
|
@@ -108,21 +118,23 @@ public class BillServiceImpl implements BillService {
|
|
|
|
|
|
@Override
|
|
|
public List<Bill> getAdminBills() {
|
|
|
- Long useruu = sysConf.getAdminUU();
|
|
|
- Long enuu = sysConf.getEnUU();
|
|
|
- List<Bill> billList = billDao.getBillByUseruuAndEnuu(useruu, enuu);
|
|
|
+ List<Bill> billList = billDao.getBillByEnuuAndDissociative(sysConf.getEnUU(), Type.ENTERPRISING.value());
|
|
|
return billList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Bill getPersonalSpecial() {
|
|
|
- Long userUU = SystemSession.getUser().getUserUU();
|
|
|
- Long uu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- List<Bill> billByUseruuAndEnuuAndKind = billDao.getBillByUseruuAndEnuuAndKind(userUU, uu, Type.Bill_Deduct.value());
|
|
|
- if(CollectionUtils.isEmpty(billByUseruuAndEnuuAndKind)) {
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ List<Bill> bills = null;
|
|
|
+ if (user.getEnterprise() == null) {
|
|
|
+ bills = billDao.getBillByUseruuAndDissociativeAndKind(user.getUserUU(), Type.PERSONAL.value(), Type.Bill_Deduct.value());
|
|
|
+ } else {
|
|
|
+ bills = billDao.getBillByEnuuAndKindAndDissociative(user.getEnterprise().getUu(), Type.Bill_Deduct.value(), Type.ENTERPRISING.value());
|
|
|
+ }
|
|
|
+ if(CollectionUtils.isEmpty(bills)) {
|
|
|
return null;
|
|
|
}else {
|
|
|
- return billByUseruuAndEnuuAndKind.get(0);
|
|
|
+ return bills.get(0);
|
|
|
}
|
|
|
}
|
|
|
}
|