| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.dto.FinanceSetOffDTO; | |||
| import com.iformall.domain.po.WxBillPayWay; | |||
| import com.iformall.domain.po.WxEnergyFees; | |||
| import com.iformall.domain.po.WxFinanceAdvance; | |||
| @@ -207,6 +208,21 @@ public class WxFinanceController extends BaseController { | |||
| return new ResultData(retMap); | |||
| } | |||
| @ApiOperation("查询冲抵列表") | |||
| @GetMapping("setoffList") | |||
| public ResultData setoffList(@ModelAttribute FinanceSetOffDTO dto) { | |||
| dto.updateTenantInfo(getTenantInfo()); | |||
| return new ResultData(wxFinanceService.getSetOffList(dto)); | |||
| } | |||
| @ApiOperation("冲抵") | |||
| @PostMapping("setoff") | |||
| public ResultData setoff(@RequestBody FinanceSetOffDTO dto) { | |||
| dto.updateTenantInfo(getTenantInfo()); | |||
| wxFinanceService.setOff(dto); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("新增收款单") | |||
| @PostMapping("createReceive") | |||
| public ResultData createReceive(@RequestBody WxFinanceAdvanceType record) { | |||
| @@ -0,0 +1,15 @@ | |||
| package com.iformall.domain.dto; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| /** | |||
| */ | |||
| @Data | |||
| public class FinanceSetOffDTO extends TenantEntity{ | |||
| private static final long serialVersionUID = 3024690696283760441L; | |||
| private Long billId; | |||
| private Integer billType; | |||
| private Long financeAdvanceId; | |||
| } | |||
| @@ -7,6 +7,7 @@ import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| /** | |||
| */ | |||
| @@ -38,6 +39,8 @@ public class WxFinanceAdvance extends TenantEntity { | |||
| private Long advanceTypeId; | |||
| @TableField(exist = false) | |||
| private String advanceTypeName; | |||
| @TableField(exist = false) | |||
| private List<Long> advanceTypeIdList; | |||
| @io.swagger.annotations.ApiModelProperty(value="advanceTypeId",name="advanceTypeId") | |||
| private Long merchantId; | |||
| @@ -90,8 +90,11 @@ public class WxBillBaseEntity extends TenantEntity { | |||
| public String owe; | |||
| public String getOwe() { | |||
| if (StringUtils.isBlank(setOff)) { | |||
| setOff = "0"; | |||
| } | |||
| if (StringUtils.isNotBlank(receivePay) && StringUtils.isNotBlank(pay)) { | |||
| return new BigDecimal(receivePay).subtract(new BigDecimal(pay)).toPlainString(); | |||
| return new BigDecimal(receivePay).subtract(new BigDecimal(pay)).subtract(new BigDecimal(setOff)).toPlainString(); | |||
| } | |||
| return "0"; | |||
| } | |||
| @@ -13,6 +13,8 @@ public interface WxFinanceAdvanceTypeFeesMapper extends CommonMapper<WxFinanceAd | |||
| List<WxFinanceAdvanceTypeFees> findList(WxFinanceAdvanceTypeFees wxBillRent); | |||
| List<Long> findFeesIdList(WxFinanceAdvanceTypeFees wxBillRent); | |||
| List<Long> findadvanceTypeIdList(WxFinanceAdvanceTypeFees wxBillRent); | |||
| WxFinanceAdvanceTypeFees selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| @@ -3,6 +3,7 @@ package com.iformall.service; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.dto.FinanceSetOffDTO; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxBillPayWay; | |||
| import com.iformall.domain.po.WxFinanceAdvance; | |||
| @@ -34,6 +35,9 @@ public interface WxFinanceService { | |||
| void saveOrUpdateAdvance(WxFinanceAdvance record,MallUserInfo user); | |||
| void updateAdvanceIsDel(WxFinanceAdvance record); | |||
| List<WxFinanceAdvance> getMerchantAdvanceGroupSumList(WxFinanceAdvance record); | |||
| List<Map> getSetOffList(FinanceSetOffDTO dto); | |||
| void setOff(FinanceSetOffDTO dto); | |||
| //收款 | |||
| PageInfo<WxFinanceReceive> receiveListAsPage(WxFinanceReceive record, Integer pageIndex, Integer pageSize); | |||
| @@ -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 { | |||
| } | |||
| @@ -38,6 +38,12 @@ | |||
| <if test=" null != createByName and '' != createByName ">and create_by_name like concat('%', #{createByName},'%')</if> | |||
| <if test=" null != createBegin ">and `create_time` >= #{createBegin}</if> | |||
| <if test=" null != createEnd ">and `create_time` <= #{createEnd}</if> | |||
| <if test=" null != advanceTypeIdList "> | |||
| and advance_type_id in | |||
| <foreach collection="advanceTypeIdList" index="index" item="atidItem" open="(" separator="," close=")"> | |||
| #{atidItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -48,6 +48,12 @@ | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="findadvanceTypeIdList" parameterType="com.iformall.domain.po.WxFinanceAdvanceTypeFees" resultType="Long"> | |||
| select distinct advance_type_id | |||
| from wx_finance_advance_type_fees | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||