|
|
|
@@ -4,12 +4,16 @@ import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.domain.dto.FinanceSetOffDTO; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.domain.po.base.WxBillBaseEntity; |
|
|
|
import com.iformall.enums.EnumBillAllType; |
|
|
|
import com.iformall.enums.EnumYesOrNo; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.*; |
|
|
|
import com.iformall.service.*; |
|
|
|
import com.iformall.service.helper.WxBillAllHelper; |
|
|
|
import com.iformall.utils.Constant; |
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
@@ -17,6 +21,8 @@ import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -48,6 +54,10 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
@Lazy |
|
|
|
@Autowired |
|
|
|
WxShopService wxShopService; |
|
|
|
@Lazy |
|
|
|
@Autowired |
|
|
|
WxBillAllHelper wxBillAllHelper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -278,6 +288,7 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
record.setCreateByName(user.getName()); |
|
|
|
record.setUpdateBy(user.getId()); |
|
|
|
record.setUpdateByName(user.getName()); |
|
|
|
record.setRemainMoney(record.getMoney()); |
|
|
|
try { |
|
|
|
wxFinanceAdvanceMapper.insert(record); |
|
|
|
} catch (Exception e) { |
|
|
|
@@ -303,6 +314,67 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
return wxFinanceAdvanceMapper.getMerchantAdvanceGroupSumList(record); |
|
|
|
} |
|
|
|
|
|
|
|
private List<WxFinanceAdvance> getAdvanceListByFeesId(TenantEntity tenantEntity,Long feesId) { |
|
|
|
WxFinanceAdvanceTypeFees tf = new WxFinanceAdvanceTypeFees(); |
|
|
|
tf.updateTenantInfo(tenantEntity); |
|
|
|
tf.setFeesId(feesId); |
|
|
|
List<Long> advanceTypeIdList = wxFinanceAdvanceTypeFeesMapper.findadvanceTypeIdList(tf); |
|
|
|
if (null != advanceTypeIdList && advanceTypeIdList.size() > 0 ) { |
|
|
|
WxFinanceAdvance faq = new WxFinanceAdvance(); |
|
|
|
faq.updateTenantInfo(tenantEntity); |
|
|
|
faq.setAdvanceTypeIdList(advanceTypeIdList); |
|
|
|
return wxFinanceAdvanceMapper.findList(faq); |
|
|
|
}else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Map> getSetOffList(FinanceSetOffDTO dto) { |
|
|
|
//根据账单的科目查询可抵扣的预充值 |
|
|
|
WxMerchant merchant = new WxMerchant(); |
|
|
|
merchant.updateTenantInfo(dto); |
|
|
|
WxBillBaseEntity be = wxBillAllHelper.getBillDetail(EnumBillAllType.getEnum(dto.getBillType()), merchant, dto.getBillId()); |
|
|
|
if (null == be) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
//通过科目去查询可以抵扣的预充费用 |
|
|
|
List<WxFinanceAdvance> advanceList = getAdvanceListByFeesId(dto, be.getEnergyFeesId()); |
|
|
|
|
|
|
|
if (null != advanceList && advanceList.size() > 0 ) { |
|
|
|
WxFinanceAdvanceType atq = new WxFinanceAdvanceType(); |
|
|
|
atq.updateTenantInfo(dto); |
|
|
|
Map<Long, WxFinanceAdvanceType> typeMap = this.getAdvanceTypeMap(atq); |
|
|
|
List retList = new ArrayList(); |
|
|
|
for (int i = 0 ; i < advanceList.size() ; i ++) { |
|
|
|
WxFinanceAdvance a = advanceList.get(i); |
|
|
|
Map m = new HashMap(); |
|
|
|
m.put("id", a.getId()); |
|
|
|
if (null != typeMap) { |
|
|
|
WxFinanceAdvanceType fat = typeMap.get(a.getAdvanceTypeId()); |
|
|
|
if (null != fat) { |
|
|
|
m.put("name", fat.getName()); |
|
|
|
m.put("rate", fat.getRate()); |
|
|
|
m.put("money", calcuteSetOffMoney(fat.getRate(),be.getOwe())); |
|
|
|
} |
|
|
|
} |
|
|
|
retList.add(m); |
|
|
|
} |
|
|
|
return retList; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private String calcuteSetOffMoney(String rate,String money) { |
|
|
|
return new BigDecimal(money).multiply(new BigDecimal(rate)).divide(new BigDecimal(100)).toPlainString(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void setOff(FinanceSetOffDTO dto) { |
|
|
|
//根据预充规则计算冲抵费用 |
|
|
|
//设置账单冲抵金额 |
|
|
|
//新增收款记录,冲抵,关联冲抵账单 |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxFinanceReceive> receiveListAsPage(WxFinanceReceive record, Integer pageIndex, Integer pageSize) { |
|
|
|
@@ -314,4 +386,8 @@ public class WxFinanceServiceImpl implements WxFinanceService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |