fubin 2 лет назад
Родитель
Сommit
bae78f4b43

+ 13 - 11
src/main/java/com/dk/mdm/mapper/mac/AccountItemMapper.xml

@@ -162,31 +162,31 @@
     <!-- 查询应收账款明细 -->
     <select id="getReceivableAccountItem" resultMap="BaseResultMapResponse">
         SELECT t.item_id,
-               t.item_id               as "accItemId",
+               t.item_id        as "accItemId",
                t.acc_item_type,
                t.object_id,
-               tmc.cus_code            as "cusCode",
-               tmc.cus_name            as "cusName",
-               tmc.cus_phone           as "cusPhone",
-               tmc.address_full        as "addressFull",
+               tmc.cus_code     as "cusCode",
+               tmc.cus_name     as "cusName",
+               tmc.cus_phone    as "cusPhone",
+               tmc.address_full as "addressFull",
                t.org_id,
-               tmo.org_name            as "orgName",
+               tmo.org_name     as "orgName",
                t.staff_id,
-               tms.staff_name          as "staffName",
+               tms.staff_name   as "staffName",
                t.biznis_type,
                t.biznis_id,
                t.biznis_no,
                t.acc_date,
                t.rec_status,
-               sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "recStatusName",
-               sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n}) as "biznisTypeName",
+               sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n})                   as "recStatusName",
+               coalesce(sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n}), '其他收入') as "biznisTypeName",
                t.amt_rec,
                t.amt_pay,
                t.amt_should,
                t.amt_handle,
                t.amt_waive,
-               t.amt_residue           as "amtNotHandle",
-               t.amt_residue           as "amtReceivableHandle",
+               t.amt_residue    as "amtNotHandle",
+               t.amt_residue    as "amtReceivableHandle",
                t.amt_residue,
                t.remarks,
                t.make_staff,
@@ -196,6 +196,8 @@
         FROM dkic_b.t_mac_account_item as t
                  left join dkic_b.t_psi_outbound as tpo on tpo.out_id = t.biznis_id and t.biznis_type = 't_psi_outbound'
                  LEFT JOIN sys.t_data_kind tdk2 ON tdk2.kind_code = tpo.out_type
+                 left join dkic_b.t_mac_other_receivable as tmor
+                           on tmor.receivable_id = t.biznis_id and t.biznis_type = 't_mac_other_receivable'
                  left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.object_id
                  left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
                  left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id

+ 2 - 2
src/main/java/com/dk/mdm/mapper/mac/OtherReceivableItemMapper.xml

@@ -72,14 +72,14 @@
         SELECT t.item_id,
                t.receivable_id,
                t.receivable_type,
-               sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "receivableTypeName",
+               tmda.data_value as "receivableTypeName",
                t.qty_receivable,
                t.amt_receivable,
                t.remarks,
                t.flg_valid,
                t.cp_id
         FROM dkic_b.t_mac_other_receivable_item as t
-                 left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.receivable_type
+                 LEFT JOIN dkic_b.t_mst_dictionary_data as tmda ON tmda.data_id = t.receivable_type
         <include refid="Condition"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}

+ 3 - 3
src/main/java/com/dk/mdm/model/pojo/mac/OtherReceivable.java

@@ -18,7 +18,7 @@ import io.swagger.annotations.ApiModelProperty;
 import com.alibaba.fastjson.JSONObject;
 
 import java.math.BigDecimal;
-import java.util.List;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 /**
@@ -112,9 +112,9 @@ public class OtherReceivable extends PageInfo<OtherReceivable> implements Serial
      */
     @Excel(name = "账务日期 (账务日期)")
     @ApiModelProperty(value = "账务日期 (账务日期)")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime accDate;
+    private LocalDate accDate;
 
 
     /**

+ 2 - 2
src/main/java/com/dk/mdm/model/query/mac/OtherReceivableQuery.java

@@ -116,9 +116,9 @@ public class OtherReceivableQuery extends PageInfo<OtherReceivableQuery> impleme
      */
     @Excel(name = "账务日期 (账务日期)")
     @ApiModelProperty(value = "账务日期 (账务日期)")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime accDate;
+    private LocalDate accDate;
 
 
     /**

+ 3 - 2
src/main/java/com/dk/mdm/model/response/mac/OtherReceivableResponse.java

@@ -21,6 +21,7 @@ import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 /**
@@ -114,9 +115,9 @@ public class OtherReceivableResponse extends PageInfo<OtherReceivableResponse> i
      */
     @Excel(name = "账务日期 (账务日期)")
     @ApiModelProperty(value = "账务日期 (账务日期)")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime accDate;
+    private LocalDate accDate;
 
 
     /**

+ 3 - 2
src/main/java/com/dk/mdm/model/vo/mac/OtherReceivableVO.java

@@ -21,6 +21,7 @@ import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -115,9 +116,9 @@ public class OtherReceivableVO extends PageInfo<OtherReceivableVO> implements Se
      */
     @Excel(name = "账务日期 (账务日期)")
     @ApiModelProperty(value = "账务日期 (账务日期)")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime accDate;
+    private LocalDate accDate;
 
 
     /**

+ 54 - 6
src/main/java/com/dk/mdm/service/mac/AccountService.java

@@ -11,6 +11,7 @@ import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.mapper.ivt.InboundMapper;
 import com.dk.mdm.mapper.ivt.OutboundMapper;
 import com.dk.mdm.mapper.mac.AccountItemMapper;
+import com.dk.mdm.mapper.mac.OtherReceivableMapper;
 import com.dk.mdm.mapper.mst.MoneyAccountItemMapper;
 import com.dk.mdm.model.pojo.ivt.Inbound;
 import com.dk.mdm.model.pojo.ivt.Outbound;
@@ -19,12 +20,11 @@ import com.dk.mdm.mapper.mac.AccountMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.pojo.mac.AccountItem;
+import com.dk.mdm.model.pojo.mac.OtherReceivable;
 import com.dk.mdm.model.pojo.mst.MoneyAccount;
 import com.dk.mdm.model.query.mac.AccountItemQuery;
 import com.dk.mdm.model.response.mac.AccountItemResponse;
 import com.dk.mdm.model.response.mac.AccountResponse;
-import com.dk.mdm.service.ivt.inbound.InboundService;
-import com.dk.mdm.service.ivt.outbound.OutboundService;
 import com.dk.mdm.service.mst.MoneyAccountService;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -67,6 +67,9 @@ public class AccountService extends BaseService<Account> {
     @Autowired
     private InboundMapper inboundMapper;
 
+    @Autowired
+    private OtherReceivableMapper otherReceivableMapper;
+
     /**
      * @desc : 查看来源单据,总单加明细
      * @author : 姜永辉
@@ -224,8 +227,34 @@ public class AccountService extends BaseService<Account> {
             LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(Outbound::getReceivableId, UUID.fromString(accountItemInsert.getItemId())).eq(Outbound::getOutId, UUID.fromString(invoiceId));
             outboundMapper.update(null, updateWrapper);
-        } else if ("t_mac_income".equals(biznisType)) {
-            // 其它收入单 todo
+        }
+        // 其它收入单
+        else if ("t_mac_other_receivable".equals(biznisType)) {
+            OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
+            objectId = otherReceivable.getObjectId();
+
+            // 当前单据已经记账
+            if (otherReceivable.getAccItemId() != null) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISACC.getMessage());
+            }
+            // 账务日期不能为空
+            if (otherReceivable.getAccDate() == null) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ACC_DATE_ISNULL.getMessage());
+            }
+
+            // 插入账款明细
+            accountItemInsert.setAccItemType(Constant.accItemType.YING_SHOU.getName())
+                    .setObjectId(objectId).setOrgId(otherReceivable.getOrgId()).setStaffId(otherReceivable.getStaffId())
+                    .setAccDate(otherReceivable.getAccDate()).setRecStatus(Constant.recStatuse.QUE_DING.getName())
+                    .setAmtShould(otherReceivable.getSumAmtReceivable()).setAmtResidue(otherReceivable.getSumAmtReceivable())
+                    .setBiznisType(biznisType).setBiznisId(otherReceivable.getReceivableId()).setBiznisNo(otherReceivable.getReceivableNo())
+                    .setMakeStaff(otherReceivable.getMakeStaff()).setCpId(otherReceivable.getCpId());
+            accountItemMapper.insert(accountItemInsert);
+
+            // 更新出库单上的账款明细Id
+            LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.set(OtherReceivable::getAccItemId, UUID.fromString(accountItemInsert.getItemId())).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
+            otherReceivableMapper.update(null, updateWrapper);
         }
 
         // 更新账款总表上的总应收账款和总剩余应收
@@ -267,8 +296,27 @@ public class AccountService extends BaseService<Account> {
             LambdaUpdateWrapper<Outbound> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(Outbound::getReceivableId, null).eq(Outbound::getOutId, UUID.fromString(invoiceId));
             outboundMapper.update(null, updateWrapper);
-        } else if ("t_mac_income".equals(biznisType)) {
-            // 其它支出单 todo
+        }
+        // 其它收入单
+        else if ("t_mac_other_receivable".equals(biznisType)) {
+            OtherReceivable otherReceivable = otherReceivableMapper.selectByIdForUpdate(invoiceId);
+            objectId = otherReceivable.getObjectId();
+
+            // 当前单据已经记账
+            if (otherReceivable.getAccItemId() == null) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISREVERSE.getMessage());
+            }
+
+            accountItemForUpdate = accountItemMapper.selectByIdForUpdate(otherReceivable.getAccItemId());
+            // 如果核销金额不为0,说明当前单据已核销
+            if (accountItemForUpdate.getAmtHandle().compareTo(BigDecimal.ZERO) != 0) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CURRENT_INVOICE_ISHANDLE.getMessage());
+            }
+
+            // 更新出库单上的账款明细Id
+            LambdaUpdateWrapper<OtherReceivable> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.set(OtherReceivable::getAccItemId, null).eq(OtherReceivable::getReceivableId, UUID.fromString(invoiceId));
+            otherReceivableMapper.update(null, updateWrapper);
         }
 
         // 删除账款明细

+ 5 - 1
src/main/java/com/dk/mdm/service/mac/OtherReceivableService.java

@@ -54,6 +54,9 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
 	private CommonService commonService;
 
 	@Autowired
+	private AccountService accountService;
+
+	@Autowired
 	private OtherReceivableConvert otherReceivableConvert;
 
 	@Autowired
@@ -113,7 +116,8 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
 				otherReceivableItemMapper.insert(otherReceivableItem);
 			}
 		}
-		
+
+		accountService.accReceivable(otherReceivable.getReceivableId(),"t_mac_other_receivable");
 		return ResponseResultUtil.success();
 	}