| @@ -219,19 +219,18 @@ public class WxFinanceController extends BaseController { | |||
| @PostMapping("setoff") | |||
| public ResultData setoff(@RequestBody FinanceSetOffDTO dto) { | |||
| dto.updateTenantInfo(getTenantInfo()); | |||
| wxFinanceService.setOff(dto); | |||
| wxFinanceService.setOff(dto,this.getUser()); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("新增收款单") | |||
| @PostMapping("createReceive") | |||
| public ResultData createReceive(@RequestBody WxFinanceAdvanceType record) { | |||
| public ResultData createReceive(@RequestBody WxFinanceReceive record) { | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| if (new BigDecimal(record.getRate()).compareTo(new BigDecimal(100)) > 0 ) { | |||
| return new ResultData(Result.ERROR,"冲抵比例不能超过100"); | |||
| if (null == record.getBills() || null == record.getPayWays()) { | |||
| return new ResultData(Result.ERROR,"请选择账单和支付方式"); | |||
| } | |||
| wxFinanceService.saveOrUpdateAdvanceType(record); | |||
| return new ResultData(); | |||
| return new ResultData(wxFinanceService.createReceive(record,this.getUser())); | |||
| } | |||
| // @ApiOperation("收款记录列表") | |||
| @@ -2619,6 +2619,25 @@ insert into wx_energy_fees_89 (id,tenant_id,parent_tenant_id,create_time,upda | |||
| (5,'789',null,now(),now(),0,'物业费',1,1,0), | |||
| (6,'789',null,now(),now(),0,'物业押金',1,1,1); | |||
| CREATE TABLE `wx_finance_advance` ( | |||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||
| `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||
| `create_time` timestamp NULL DEFAULT NULL, | |||
| `update_time` timestamp NULL DEFAULT NULL, | |||
| `is_del` int(1) NOT NULL DEFAULT '0', | |||
| `advance_type_id` bigint(20) NOT NULL COMMENT '类型id', | |||
| `merchant_id` bigint(20) NOT NULL COMMENT '商户编码', | |||
| `create_by` bigint(20) DEFAULT NULL COMMENT '创建人', | |||
| `create_by_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||
| `update_by` bigint(20) DEFAULT NULL, | |||
| `update_by_name` bigint(100) DEFAULT NULL, | |||
| `money` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '金额', | |||
| `remain_money` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '剩余金额', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `id_UNIQUE` (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表'; | |||
| CREATE TABLE `wx_finance_receive` ( | |||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||
| @@ -2633,6 +2652,8 @@ CREATE TABLE `wx_finance_receive` ( | |||
| `update_by_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人名称', | |||
| `money_detail` text COLLATE utf8mb4_unicode_ci COMMENT '收款详细', | |||
| `merchant_id` bigint(20) NOT NULL COMMENT '商户编号', | |||
| `remark` varchar(300) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', | |||
| `type` int(1) NOT NULL COMMENT '类型', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `id_UNIQUE` (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表'; | |||
| @@ -2646,30 +2667,10 @@ CREATE TABLE `wx_finance_receive_bill` ( | |||
| `bill_id` bigint(20) NOT NULL COMMENT '账单id', | |||
| `bill_type` int(3) NOT NULL COMMENT '账单类型', | |||
| `fees_id` bigint(20) NOT NULL COMMENT '费用科目', | |||
| `pay_way` bigint(20) NOT NULL COMMENT '支付方式', | |||
| `pay_way` bigint(20) DEFAULT NULL COMMENT '支付方式', | |||
| `receive_id` bigint(20) NOT NULL COMMENT '收款编号', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `id_UNIQUE` (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表'; | |||
| CREATE TABLE `wx_finance_advance` ( | |||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||
| `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||
| `create_time` timestamp NULL DEFAULT NULL, | |||
| `update_time` timestamp NULL DEFAULT NULL, | |||
| `is_del` int(1) NOT NULL DEFAULT '0', | |||
| `advance_type_id` bigint(20) NOT NULL COMMENT '类型id', | |||
| `merchant_id` bigint(20) NOT NULL COMMENT '商户编码', | |||
| `create_by` bigint(20) DEFAULT NULL COMMENT '创建人', | |||
| `create_by_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||
| `update_by` bigint(20) DEFAULT NULL, | |||
| `update_by_name` bigint(100) DEFAULT NULL, | |||
| `money` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '金额', | |||
| `remain_money` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '剩余金额', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `id_UNIQUE` (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表'; | |||
| @@ -15,6 +15,7 @@ public class WxBillPayDTO extends TenantEntity{ | |||
| private Long id; | |||
| private Integer billTypeValue;// EnumBillAllType | |||
| private String addpay;//支付金额 | |||
| private boolean isSetOff = false;//是否冲抵 | |||
| private WxBillPayWay payWayObject;//支付方式 | |||
| private Long payWay;//传值 | |||
| private String remark; | |||
| @@ -41,10 +41,6 @@ public class WxBillDaily extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="截止收款日期",name="receiveDate") | |||
| private Date receiveDate; | |||
| @Excel(name = "收款日期", format = "yyyy-MM-dd", width = 20, orderNum = "12") | |||
| @io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate") | |||
| private Date payDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="逾期天数",name="expiredDay") | |||
| private Long expiredDay; | |||
| @@ -63,9 +59,6 @@ public class WxBillDaily extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="商铺",name="shopName") | |||
| private String shopName; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付方式:见枚举EnumBillPayWay", name = "payWay") | |||
| private Long payWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "费用明细", name = "priceDetail") | |||
| private String priceDetail; | |||
| @@ -30,9 +30,6 @@ public class WxBillDeposit extends WxBillBaseEntity { | |||
| private String needPay; | |||
| @io.swagger.annotations.ApiModelProperty(value="收款日期",name="receiveDate") | |||
| private Date receiveDate; | |||
| @Excel(name = "收款日期", format = "yyyy-MM-dd", width = 20, orderNum = "12") | |||
| @io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate") | |||
| private Date payDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="逾期天数",name="expiredDay") | |||
| private Long expiredDay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "账单审核状态EnumBillRentApplyStatus", name = "applyStatus") | |||
| @@ -62,9 +59,6 @@ public class WxBillDeposit extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "商铺信息", name = "shopInfo") | |||
| private String shopInfo; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付方式:见枚举EnumBillPayWay", name = "payWay") | |||
| private Long payWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "冻结状态,0正常1冻结", name = "freeze") | |||
| private Integer freeze; | |||
| @@ -44,10 +44,6 @@ public class WxBillOther extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="截止收款日期",name="receiveDate") | |||
| private Date receiveDate; | |||
| @Excel(name = "收款日期", orderNum = "8", width = 20, format = "yyyy-MM-dd") | |||
| @io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate") | |||
| private Date payDate; | |||
| //@Excel(name = "逾期(天)", orderNum = "10", width = 20) | |||
| @io.swagger.annotations.ApiModelProperty(value="逾期天数",name="expiredDay") | |||
| private Long expiredDay; | |||
| @@ -65,9 +61,6 @@ public class WxBillOther extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="商铺ID",name="shopId") | |||
| private Long shopId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付方式", name = "payWay") | |||
| private Long payWay; | |||
| @TableField(exist = false) | |||
| private Integer allPeriod; | |||
| @@ -38,10 +38,6 @@ public class WxBillOtherDeposit extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "截止收款日期", name = "receiveDate") | |||
| private Date receiveDate; | |||
| @Excel(name = "收款日期", orderNum = "6", width = 20, format = "yyyy-MM-dd") | |||
| @io.swagger.annotations.ApiModelProperty(value = "到账日期", name = "payDate") | |||
| private Date payDate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "逾期天数", name = "expiredDay") | |||
| private Long expiredDay; | |||
| @@ -69,9 +65,6 @@ public class WxBillOtherDeposit extends WxBillBaseEntity { | |||
| return new BigDecimal(getOwe()).subtract(new BigDecimal(returnPrice)).toPlainString(); | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付方式", name = "payWay") | |||
| private Long payWay; | |||
| @TableField(exist = false) | |||
| private Integer allPeriod; | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| @@ -34,4 +35,7 @@ public class WxBillPayWay extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "isSystem", name = "isSystem") | |||
| private Integer isSystem; | |||
| @TableField(exist = false) | |||
| private String money; | |||
| } | |||
| @@ -42,10 +42,6 @@ public class WxBillProperty extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="收款日期",name="receiveDate") | |||
| private Date receiveDate; | |||
| @Excel(name = "收款日期", format = "yyyy-MM-dd", width = 20, orderNum = "11") | |||
| @io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate") | |||
| private Date payDate; | |||
| //@Excel(name = "逾期(天) ", width = 20, orderNum = "13") | |||
| @io.swagger.annotations.ApiModelProperty(value="逾期天数",name="expiredDay") | |||
| private Long expiredDay; | |||
| @@ -86,9 +82,6 @@ public class WxBillProperty extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "商铺信息", name = "shopInfo") | |||
| private String shopInfo; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付方式", name = "payWay") | |||
| private Long payWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "滞纳金状态", name = "latePayStatus") | |||
| private Integer latePayStatus; | |||
| @@ -33,9 +33,6 @@ public class WxBillPropertyDeposit extends WxBillBaseEntity { | |||
| private String needPay; | |||
| @io.swagger.annotations.ApiModelProperty(value="收款日期",name="receiveDate") | |||
| private Date receiveDate; | |||
| @Excel(name = "收款日期", format = "yyyy-MM-dd", width = 20, orderNum = "12") | |||
| @io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate") | |||
| private Date payDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="逾期天数",name="expiredDay") | |||
| private Long expiredDay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "账单审核状态EnumBillRentApplyStatus", name = "applyStatus") | |||
| @@ -66,9 +63,6 @@ public class WxBillPropertyDeposit extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "商铺信息", name = "shopInfo") | |||
| private String shopInfo; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付方式", name = "payWay") | |||
| private Long payWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "冻结状态,0正常1冻结", name = "freeze") | |||
| private Integer freeze; | |||
| @@ -39,10 +39,6 @@ public class WxBillRent extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="收款截止日期,过了有手续费",name="receiveDate") | |||
| private Date receiveDate; | |||
| @Excel(name = "收款日期", format = "yyyy-MM-dd", width = 20, orderNum = "12") | |||
| @io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate") | |||
| private Date payDate; | |||
| //@Excel(name = "逾期(天) ", width = 20, orderNum = "14") | |||
| @io.swagger.annotations.ApiModelProperty(value="逾期天数",name="expiredDay") | |||
| private Long expiredDay; | |||
| @@ -157,9 +153,6 @@ public class WxBillRent extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "商铺信息", name = "shopInfo") | |||
| private String shopInfo; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付方式", name = "payWay") | |||
| private Long payWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "滞纳金状态", name = "latePayStatus") | |||
| private Integer latePayStatus; | |||
| @@ -37,10 +37,6 @@ public class WxBillRentManage extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="收款日期",name="receiveDate") | |||
| private Date receiveDate; | |||
| @Excel(name = "收款日期", format = "yyyy-MM-dd", width = 20, orderNum = "12") | |||
| @io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate") | |||
| private Date payDate; | |||
| //@Excel(name = "逾期(天) ", width = 20, orderNum = "14") | |||
| @io.swagger.annotations.ApiModelProperty(value="逾期天数",name="expiredDay") | |||
| private Long expiredDay; | |||
| @@ -89,10 +85,6 @@ public class WxBillRentManage extends WxBillBaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "商铺信息", name = "shopInfo") | |||
| private String shopInfo; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付方式", name = "payWay") | |||
| private Long payWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "滞纳金状态", name = "latePayStatus") | |||
| private Integer latePayStatus; | |||
| @@ -1,11 +1,15 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.base.WxBillBaseEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| /** | |||
| */ | |||
| @TableName(value = "wx_finance_receive") | |||
| @@ -31,6 +35,9 @@ public class WxFinanceReceive extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "状态EnumFinanceReceiveStatus", name = "status") | |||
| private Integer status; | |||
| @io.swagger.annotations.ApiModelProperty(value = "类型EnumFinanceReceiveType", name = "type") | |||
| private Integer type; | |||
| @io.swagger.annotations.ApiModelProperty(value="createBy",name="createBy") | |||
| private Long createBy; | |||
| @io.swagger.annotations.ApiModelProperty(value="createByName",name="createByName") | |||
| @@ -47,4 +54,12 @@ public class WxFinanceReceive extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "merchantId", name = "merchantId") | |||
| private Long merchantId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "remark", name = "remark") | |||
| private String remark; | |||
| @TableField(exist = false) | |||
| private List<WxBillBaseEntity> bills; | |||
| @TableField(exist = false) | |||
| private List<WxBillPayWay> payWays; | |||
| } | |||
| @@ -69,6 +69,13 @@ public class WxBillBaseEntity extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="实收金额",name="pay") | |||
| public String pay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付方式", name = "payWay") | |||
| public Long payWay; | |||
| @Excel(name = "收款日期", format = "yyyy-MM-dd", width = 20, orderNum = "12") | |||
| @io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate") | |||
| public Date payDate; | |||
| @Excel(name = "实收账款(元)", width = 20, orderNum = "10") | |||
| @io.swagger.annotations.ApiModelProperty(value="冲抵金额",name="setOff") | |||
| public String setOff; | |||
| @@ -16,7 +16,8 @@ public enum EnumBillAction { | |||
| UPDATE_SERVICE_MONEY(9, "手续费变更"), | |||
| NOTIFY(10,"催缴"), | |||
| BAD(11,"坏账"), | |||
| STATUS_CHANGE(12,"状态变更"); | |||
| STATUS_CHANGE(12,"状态变更"), | |||
| SETOFF(13,"冲抵"); | |||
| public static EnumBillAction getEnum(Integer code) { | |||
| for (EnumBillAction value : values()) { | |||
| @@ -69,6 +70,8 @@ public enum EnumBillAction { | |||
| sb.append("欠缴金额").append(oldMoney).append("元"); | |||
| }else if (code.intValue() == STATUS_CHANGE.code.intValue()){ | |||
| sb.append("状态由[").append(oldStatus.getMessage()).append("]变更为[").append(newStatus.getMessage()).append("]"); | |||
| }else if (code.intValue() == SETOFF.code.intValue()){ | |||
| sb.append("预收冲抵").append(newMoney).append("元"); | |||
| }else { | |||
| sb.append("应付金额").append(oldMoney).append("元变更成").append(newMoney).append("元"); | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| */ | |||
| public enum EnumFinanceReceiveType { | |||
| RECEIVE(1,"收单"), | |||
| SETOFF(2,"冲抵") | |||
| ; | |||
| public static EnumFinanceReceiveType getEnum(Integer code) { | |||
| for (EnumFinanceReceiveType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumFinanceReceiveType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -9,7 +9,9 @@ import com.iformall.domain.po.WxBillPayWay; | |||
| import com.iformall.domain.po.WxFinanceAdvance; | |||
| import com.iformall.domain.po.WxFinanceAdvanceType; | |||
| import com.iformall.domain.po.WxFinanceReceive; | |||
| import com.iformall.domain.po.WxFinanceReceiveBill; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.base.WxBillBaseEntity; | |||
| /** | |||
| */ | |||
| public interface WxFinanceService { | |||
| @@ -36,9 +38,11 @@ public interface WxFinanceService { | |||
| void updateAdvanceIsDel(WxFinanceAdvance record); | |||
| List<WxFinanceAdvance> getMerchantAdvanceGroupSumList(WxFinanceAdvance record); | |||
| List<Map> getSetOffList(FinanceSetOffDTO dto); | |||
| void setOff(FinanceSetOffDTO dto); | |||
| void setOff(FinanceSetOffDTO dto,MallUserInfo user); | |||
| //收款 | |||
| PageInfo<WxFinanceReceive> receiveListAsPage(WxFinanceReceive record, Integer pageIndex, Integer pageSize); | |||
| List<WxBillBaseEntity> createReceive(WxFinanceReceive record,MallUserInfo user); | |||
| void saveOrUpdateReceive(WxFinanceReceive record,MallUserInfo user); | |||
| void saveOrUpdateReceiveBill(WxFinanceReceiveBill record); | |||
| } | |||
| @@ -537,7 +537,11 @@ public class WxBillDailyServiceImpl extends WxBillBaseService implements WxBillD | |||
| @Override | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user) { | |||
| WxBillDaily wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = EnumBillAction.OFFLINE_PAY; | |||
| if (dto.isSetOff()) { | |||
| action = EnumBillAction.SETOFF; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWayObject(), dto.getRemark(),null,null, user); | |||
| } | |||
| @@ -485,7 +485,11 @@ public class WxBillDepositServiceImpl extends WxBillBaseService implements WxBil | |||
| @Override | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user) { | |||
| WxBillDeposit wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = EnumBillAction.OFFLINE_PAY; | |||
| if (dto.isSetOff()) { | |||
| action = EnumBillAction.SETOFF; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWayObject(), dto.getRemark(),null,null, user); | |||
| } | |||
| @@ -495,7 +495,11 @@ public class WxBillOtherDepositServiceImpl extends WxBillBaseService implements | |||
| @Override | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user) { | |||
| WxBillOtherDeposit wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = EnumBillAction.OFFLINE_PAY; | |||
| if (dto.isSetOff()) { | |||
| action = EnumBillAction.SETOFF; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWayObject(), dto.getRemark(), null,null,user); | |||
| } | |||
| @@ -440,7 +440,11 @@ public class WxBillOtherServiceImpl extends WxBillBaseService implements WxBillO | |||
| @Override | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user) { | |||
| WxBillOther wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = EnumBillAction.OFFLINE_PAY; | |||
| if (dto.isSetOff()) { | |||
| action = EnumBillAction.SETOFF; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWayObject(), dto.getRemark(),null,null, user); | |||
| } | |||
| @@ -470,7 +470,11 @@ public class WxBillPropertyDepositServiceImpl extends WxBillBaseService implemen | |||
| @Override | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user) { | |||
| WxBillPropertyDeposit wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = EnumBillAction.OFFLINE_PAY; | |||
| if (dto.isSetOff()) { | |||
| action = EnumBillAction.SETOFF; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWayObject(), dto.getRemark(),null,null, user); | |||
| } | |||
| @@ -583,7 +583,11 @@ public class WxBillPropertyServiceImpl extends WxBillBaseService implements WxBi | |||
| @Override | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user) { | |||
| WxBillProperty wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = EnumBillAction.OFFLINE_PAY; | |||
| if (dto.isSetOff()) { | |||
| action = EnumBillAction.SETOFF; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWayObject(),dto.getRemark(),null,null, user); | |||
| } | |||
| @@ -496,7 +496,11 @@ public class WxBillRentManageServiceImpl extends WxBillBaseService implements W | |||
| @Override | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user) { | |||
| WxBillRentManage wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = EnumBillAction.OFFLINE_PAY; | |||
| if (dto.isSetOff()) { | |||
| action = EnumBillAction.SETOFF; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWayObject(),dto.getRemark(),null,null, user); | |||
| } | |||
| @@ -692,7 +692,11 @@ public class WxBillRentServiceImpl extends WxBillBaseService implements WxBillRe | |||
| @Override | |||
| public void updatePay(WxBillPayDTO dto, MallUserInfo user) { | |||
| WxBillRent wxBillRent = updateBillPay(dto); | |||
| this.addBillAction(EnumBillAction.OFFLINE_PAY, dto.getBillTypeValue(),dto.getId(), | |||
| EnumBillAction action = EnumBillAction.OFFLINE_PAY; | |||
| if (dto.isSetOff()) { | |||
| action = EnumBillAction.SETOFF; | |||
| } | |||
| this.addBillAction(action, dto.getBillTypeValue(),dto.getId(), | |||
| dto.getAddpay(), dto.getAddpay(),wxBillRent.getPayDate(),dto.getPayWayObject(),dto.getRemark(),null,null, user); | |||
| } | |||
| @@ -1,26 +1,33 @@ | |||
| package com.iformall.service.impl; | |||
| import com.alibaba.fastjson.JSON; | |||
| 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.dto.WxBillPayDTO; | |||
| 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.EnumFinanceReceiveStatus; | |||
| import com.iformall.enums.EnumFinanceReceiveType; | |||
| 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 com.iformall.utils.DateUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Lazy; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.math.BigDecimal; | |||
| import java.util.*; | |||
| @@ -366,14 +373,53 @@ public class WxFinanceServiceImpl implements WxFinanceService { | |||
| } | |||
| private String calcuteSetOffMoney(String rate,String money) { | |||
| if (new BigDecimal(money).compareTo(new BigDecimal(0)) <= 0) { | |||
| return "0"; | |||
| } | |||
| return new BigDecimal(money).multiply(new BigDecimal(rate)).divide(new BigDecimal(100)).toPlainString(); | |||
| } | |||
| @Override | |||
| public void setOff(FinanceSetOffDTO dto) { | |||
| public void setOff(FinanceSetOffDTO dto,MallUserInfo user) { | |||
| //TODO | |||
| //根据预充规则计算冲抵费用 | |||
| WxMerchant merchant = new WxMerchant(); | |||
| merchant.updateTenantInfo(dto); | |||
| WxBillBaseEntity bill = wxBillAllHelper.getBillDetail(EnumBillAllType.getEnum(dto.getBillType()), merchant, dto.getBillId()); | |||
| if (new BigDecimal(bill.getOwe()).compareTo(new BigDecimal(0)) <= 0) { | |||
| return; | |||
| } | |||
| WxFinanceAdvance advance = this.getAdvanceById(dto, dto.getFinanceAdvanceId()); | |||
| WxFinanceAdvanceType advanceType= getAdvanceTypeById(dto,advance.getAdvanceTypeId()); | |||
| //设置账单冲抵金额 | |||
| //新增收款记录,冲抵,关联冲抵账单 | |||
| WxFinanceReceive addreceive = new WxFinanceReceive(); | |||
| String money = calcuteSetOffMoney(advanceType.getRate(),bill.getOwe()); | |||
| addreceive.updateTenantInfo(dto); | |||
| addreceive.setTotalMoney(money); | |||
| addreceive.setMoneyDetail(JSON.toJSONString(advance)); | |||
| addreceive.setMerchantId(bill.getMerchantId()); | |||
| addreceive.setRemark(advanceType.getName()+"冲抵"); | |||
| addreceive.setType(EnumFinanceReceiveType.SETOFF.getCode()); | |||
| this.saveOrUpdateReceive(addreceive,user); | |||
| //更新账单 | |||
| WxBillPayDTO payDto = new WxBillPayDTO(); | |||
| payDto.updateTenantInfo(dto); | |||
| payDto.setId(bill.getId()); | |||
| payDto.setBillTypeValue(bill.getBillType()); | |||
| payDto.setAddpay(money); | |||
| payDto.setSetOff(true); | |||
| payDto.setRemark("冲抵单["+addreceive.getId()+"]"); | |||
| wxBillAllHelper.updatePay(payDto, user); | |||
| //插入关联账单信息 | |||
| WxFinanceReceiveBill rb = new WxFinanceReceiveBill(); | |||
| rb.updateTenantInfo(dto); | |||
| rb.setReceiveId(addreceive.getId()); | |||
| rb.setBillId(bill.getId()); | |||
| rb.setBillType(bill.getBillType()); | |||
| rb.setFeesId(bill.getEnergyFeesId()); | |||
| saveOrUpdateReceiveBill(rb); | |||
| } | |||
| @Override | |||
| @@ -382,6 +428,153 @@ public class WxFinanceServiceImpl implements WxFinanceService { | |||
| return page; | |||
| } | |||
| @Override | |||
| public void saveOrUpdateReceive(WxFinanceReceive record, MallUserInfo user) { | |||
| Date date = new Date(); | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateTime(date); | |||
| record.setUpdateTime(date); | |||
| record.setCreateBy(user.getId()); | |||
| record.setCreateByName(user.getName()); | |||
| record.setUpdateBy(user.getId()); | |||
| record.setUpdateByName(user.getName()); | |||
| record.setStatus(EnumFinanceReceiveStatus.NORMAL.getCode()); | |||
| try { | |||
| wxFinanceReceiveMapper.insert(record); | |||
| } catch (Exception e) { | |||
| logger.error("保存失败,e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| } else { | |||
| record.setUpdateBy(user.getId()); | |||
| record.setUpdateByName(user.getName()); | |||
| record.setUpdateTime(date); | |||
| wxFinanceReceiveMapper.updateById(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void saveOrUpdateReceiveBill(WxFinanceReceiveBill record) { | |||
| Date date = new Date(); | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateTime(date); | |||
| record.setUpdateTime(date); | |||
| try { | |||
| wxFinanceReceiveBillMapper.insert(record); | |||
| } catch (Exception e) { | |||
| logger.error("保存失败,e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| } else { | |||
| record.setUpdateTime(date); | |||
| wxFinanceReceiveBillMapper.updateById(record); | |||
| } | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @Override | |||
| public List<WxBillBaseEntity> createReceive(WxFinanceReceive record,MallUserInfo user) { | |||
| //所选的账单按照时间先后排序,优先结清时间靠前的 | |||
| List<WxBillBaseEntity> billList = new ArrayList<WxBillBaseEntity>(); | |||
| WxMerchant merchant = new WxMerchant(); | |||
| merchant.updateTenantInfo(record); | |||
| BigDecimal b0 = new BigDecimal(0); | |||
| for (int i = 0 ; i < record.getBills().size(); i ++) { | |||
| WxBillBaseEntity be = record.getBills().get(i); | |||
| WxBillBaseEntity bill = wxBillAllHelper.getBillDetail(EnumBillAllType.getEnum(be.getBillType()), merchant, be.getId()); | |||
| if (new BigDecimal(bill.getOwe()).compareTo(b0) <= 0 ) { | |||
| }else { | |||
| billList.add(bill); | |||
| } | |||
| } | |||
| if (billList.size() <= 0 ) { | |||
| return null; | |||
| } | |||
| Collections.sort(billList, new Comparator<WxBillBaseEntity>() { | |||
| @Override | |||
| public int compare(WxBillBaseEntity o1, WxBillBaseEntity o2) { | |||
| if (o1.getStarttime().before(o2.getStarttime())) { | |||
| return -1; | |||
| }else if (o1.getStarttime().equals(o2.getStarttime())) { | |||
| if (o1.getEndtime().before(o2.getEndtime())) { | |||
| return -1; | |||
| }else if (o1.getEndtime().equals(o2.getEndtime())) { | |||
| return 0; | |||
| }else { | |||
| return 1; | |||
| } | |||
| }else { | |||
| return 1; | |||
| } | |||
| } | |||
| }); | |||
| //增加一条收款记录。关联账单,账单更新收款信息 | |||
| BigDecimal total = new BigDecimal(0); | |||
| for (int i = 0 ; i < record.getPayWays().size() ; i ++) { | |||
| WxBillPayWay payWay = record.getPayWays().get(i); | |||
| total = total.add(new BigDecimal(payWay.getMoney())); | |||
| } | |||
| WxFinanceReceive addreceive = new WxFinanceReceive(); | |||
| addreceive.updateTenantInfo(record); | |||
| addreceive.setTotalMoney(total.toPlainString()); | |||
| addreceive.setMoneyDetail(JSON.toJSONString(record.getPayWays())); | |||
| addreceive.setMerchantId(record.getMerchantId()); | |||
| addreceive.setRemark(record.getRemark()); | |||
| addreceive.setType(EnumFinanceReceiveType.RECEIVE.getCode()); | |||
| this.saveOrUpdateReceive(record,user); | |||
| WxBillPayWay payWay = record.getPayWays().get(0); | |||
| List<WxBillBaseEntity> updateList = new ArrayList<WxBillBaseEntity>(); | |||
| for (int i = 0 ; i < billList.size(); i ++) { | |||
| WxBillBaseEntity bill = billList.get(i); | |||
| if (total.compareTo(b0) > 0 ) { | |||
| //更新账单收款信息 | |||
| String money = ""; | |||
| BigDecimal oweDecimal = new BigDecimal(bill.getOwe()); | |||
| if (oweDecimal.compareTo(total) < 0 ) { | |||
| money = bill.getOwe(); | |||
| total = total.subtract(oweDecimal); | |||
| }else { | |||
| money = total.toPlainString(); | |||
| total = b0; | |||
| } | |||
| WxBillPayDTO payDto = new WxBillPayDTO(); | |||
| payDto.setId(bill.getId()); | |||
| payDto.setBillTypeValue(bill.getBillType()); | |||
| payDto.setAddpay(money); | |||
| payDto.setPayWay(payWay.getId()); | |||
| payDto.setPayWayObject(payWay); | |||
| payDto.setRemark("系统收款:收款单["+addreceive.getId()+"]"+record.getRemark()); | |||
| wxBillAllHelper.updatePay(payDto, user); | |||
| //插入关联账单信息 | |||
| WxFinanceReceiveBill rb = new WxFinanceReceiveBill(); | |||
| rb.updateTenantInfo(record); | |||
| rb.setReceiveId(addreceive.getId()); | |||
| rb.setBillId(bill.getId()); | |||
| rb.setBillType(bill.getBillType()); | |||
| rb.setFeesId(bill.getEnergyFeesId()); | |||
| rb.setPayWay(payWay.getId()); | |||
| saveOrUpdateReceiveBill(rb); | |||
| updateList.add(bill); | |||
| } | |||
| } | |||
| if (updateList.size() <= 0 ) { | |||
| return null; | |||
| } | |||
| return updateList; | |||
| } | |||
| @@ -9,17 +9,19 @@ | |||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||
| <result column="total_money" jdbcType="VARCHAR" property="totalMoney"/> | |||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="money_detail" jdbcType="VARCHAR" property="moneyDetail"/> | |||
| <result column="create_by" jdbcType="BIGINT" property="createBy"/> | |||
| <result column="create_by_name" jdbcType="VARCHAR" property="createByName"/> | |||
| <result column="update_by" jdbcType="BIGINT" property="updateBy"/> | |||
| <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/> | |||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`total_money`,`status`,`money_detail`, | |||
| `create_by`,`create_by_name`,`update_by`,`update_by_name`,`merchant_id` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`total_money`,`status`,`type`,`money_detail`, | |||
| `create_by`,`create_by_name`,`update_by`,`update_by_name`,`merchant_id`,`remark` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -32,6 +34,7 @@ | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != status ">and `status` = #{status}</if> | |||
| <if test=" null != type ">and `type` = #{type}</if> | |||
| <if test=" null != merchantId ">and `merchantId` = #{merchant_id}</if> | |||
| <if test=" null != ids "> | |||
| and id in | |||