username@email.com
2022-01-07 f83fb19d3f31c2c48390da94740c68ffd07a6f12
订单收款改造
2个文件已修改
257 ■■■■ 已修改文件
zhengcaioa/zhengcaioa/Controllers/Finance/FiOrderrecievemoneyController.cs 118 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/zhengcaioa/Views/FiOrderrecievemoney/Edit.cshtml 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/zhengcaioa/Controllers/Finance/FiOrderrecievemoneyController.cs
@@ -131,9 +131,7 @@
            ViewBag.accounttype = _liaotianService.GetSYScode("fi_account", "accounttype");
            ViewBag.FiSubject = _ifiSubjectService.GetList().Where(x => x.Subjecttype == "01").ToList();
            ViewBag.cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(cooperOrderDTO.Khdw);
            ViewData.Model = dto;
            return View();
@@ -152,7 +150,13 @@
            ResultEntity resultEntity = new ResultEntity();
                var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
                ViewData["curentuser"] = curentuser;
            using (TransactionScope scope = new TransactionScope())
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
           new TransactionOptions
           {
               IsolationLevel = IsolationLevel.ReadCommitted,
               Timeout = TransactionManager.MaximumTimeout
           }
           ))
            {
                data.RecStatus = "A";
                if (String.IsNullOrEmpty(data.Id))
@@ -162,39 +166,73 @@
                }
                data.Modifier = curentuser.Id;
                data.Modifytime = DateTime.Now;
                resultEntity = _fiOrderrecievemoneyService.save(data);
                CooperOrderDTO cooperOrderDTO = _cooperOrderService.Get(data.OrderId);
                CooperatecustomCustomerDTO cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(cooperOrderDTO.Khdw);
                FiAccountRecordDTO data1 = new FiAccountRecordDTO();
                data1.RecStatus = "A";
                data1.Creater = curentuser.Id;
                data1.Createtime = DateTime.Now;
                data1.Modifier = curentuser.Id;
                data1.Modifytime = DateTime.Now;
                data1.SubjectId = data.SubjectId;
                if (data.PayType == "03")
                {
                    if(data.Recievemoney>((cooperatecustomCustomerDTO.Yufukuan ?? 0)+ (cooperatecustomCustomerDTO.Shouxinedu ?? 0) - (cooperatecustomCustomerDTO.Shenyushouxin ?? 0)))
                    {
                        resultEntity.Result = false;
                        resultEntity.Message = "剩余预付款和剩余授信不足!";
                        return new JsonResult(resultEntity);
                    }
                    else
                    {
                        if (data.Recievemoney > (cooperatecustomCustomerDTO.Yufukuan??0))
                        {
                            cooperatecustomCustomerDTO.Shenyushouxin = data.Recievemoney - (cooperatecustomCustomerDTO.Yufukuan??0);
                            if (cooperatecustomCustomerDTO.Shenyushouxin> (cooperatecustomCustomerDTO.Shouxinedu??0))
                            {
                                resultEntity.Result = false;
                                resultEntity.Message = "剩余授信不足!";
                                return new JsonResult(resultEntity);
                            }
                            cooperatecustomCustomerDTO.Yufukuan = 0;
                        }
                        else
                        {
                            cooperatecustomCustomerDTO.Yufukuan = cooperatecustomCustomerDTO.Yufukuan - data.Recievemoney;
                        }
                        resultEntity = _cooperatecustomCustomerService.saveyufukuan(cooperatecustomCustomerDTO);
                    }
                }
                data1.AccountId = data.AccountId;
                data1.Money = data.Recievemoney;
                data1.PaymentUnit = cooperatecustomCustomerDTO.Name;
                data1.OperationalMatters = "订单收款"+ cooperOrderDTO.OrderNo;
                resultEntity = _fiOrderrecievemoneyService.save(data);
                if (data.PayType != "03")
                {
                    FiAccountRecordDTO data1 = new FiAccountRecordDTO();
                    data1.RecStatus = "A";
                    data1.Creater = curentuser.Id;
                    data1.Createtime = DateTime.Now;
                    data1.Modifier = curentuser.Id;
                    data1.Modifytime = DateTime.Now;
                    data1.SubjectId = data.SubjectId;
                    data1.AccountId = data.AccountId;
                    data1.Money = data.Recievemoney;
                    data1.PaymentUnit = cooperatecustomCustomerDTO.Name;
                    data1.OperationalMatters = "订单收款" + cooperOrderDTO.OrderNo;
                    FiAccountDTO firmAccount = _fiAccountService.Get(data1.AccountId);
                    data1.RecordTypeId = "1";//收入
                    data1.Department = "";
                FiAccountDTO firmAccount = _fiAccountService.Get(data1.AccountId);
                    firmAccount.AllIncome = (firmAccount.AllIncome ?? 0) + data1.Money;
                    firmAccount.Balance = (firmAccount.Balance ?? 0) + data1.Money;
                    data1.AccountMoney = firmAccount.Balance;
                    resultEntity = _iFiAccountRecordService.save(data1);
                    resultEntity = _fiAccountService.save(firmAccount);
                }
                data1.RecordTypeId = "1";//收入
                data1.Department = "";
                firmAccount.AllIncome = (firmAccount.AllIncome ?? 0) + data1.Money;
                firmAccount.Balance = (firmAccount.Balance ?? 0) + data1.Money;
                data1.AccountMoney = firmAccount.Balance;
                resultEntity = _iFiAccountRecordService.save(data1);
                resultEntity = _fiAccountService.save(firmAccount);
                scope.Complete();
            }
@@ -308,7 +346,13 @@
            ResultEntity resultEntity = new ResultEntity();
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            using (TransactionScope scope = new TransactionScope())
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
           new TransactionOptions
           {
               IsolationLevel = IsolationLevel.ReadCommitted,
               Timeout = TransactionManager.MaximumTimeout
           }
           ))
            {
                data.RecStatus = "A";
                if (String.IsNullOrEmpty(data.Id))
@@ -321,6 +365,20 @@
                resultEntity = _fiCustomerrecievemoneyService.save(data);
                CooperatecustomCustomerDTO cooperatecustomCustomerDTO = _cooperatecustomCustomerService.Get(data.CustomerId);
                if (cooperatecustomCustomerDTO.Shenyushouxin.HasValue)
                {
                    if(data.Recievemoney.Value> cooperatecustomCustomerDTO.Shenyushouxin.Value)
                    {
                        data.Recievemoney = data.Recievemoney.Value - cooperatecustomCustomerDTO.Shenyushouxin.Value;
                        cooperatecustomCustomerDTO.Shenyushouxin = 0;
                    }
                    else
                    {
                        cooperatecustomCustomerDTO.Shenyushouxin = cooperatecustomCustomerDTO.Shenyushouxin.Value - data.Recievemoney.Value;
                        data.Recievemoney = 0;
                    }
                }
                if(cooperatecustomCustomerDTO.Yufukuan.HasValue)
                    cooperatecustomCustomerDTO.Yufukuan = cooperatecustomCustomerDTO.Yufukuan.Value + data.Recievemoney.Value;
                 else
zhengcaioa/zhengcaioa/Views/FiOrderrecievemoney/Edit.cshtml
@@ -11,6 +11,8 @@
    List<SysCodeDtl> accounttype = ViewData["accounttype"] as List<SysCodeDtl>; //账户类型
    CooperatecustomCustomerDTO cooperatecustomCustomerDTO = ViewData["cooperatecustomCustomerDTO"] as CooperatecustomCustomerDTO; //客户
}
@{
    Layout = null;
@@ -108,7 +110,7 @@
                                    <label class="text-left col-sm-1 col-md-1 control-label"> @Model.YishouMoney.ToString("F2") </label>
                                    <label class="text-left col-sm-1 col-md-1 control-label">   </label>
                                    <label class="text-right col-sm-1 col-md-1 control-label">未收款(元)</label>
                                    <label id="WeishouMoney"  class="text-left col-sm-1 col-md-1 control-label"> @Model.WeishouMoney.ToString("F2") </label>
                                    <label id="WeishouMoney" class="text-left col-sm-1 col-md-1 control-label"> @Model.WeishouMoney.ToString("F2") </label>
                                    <label class="text-left col-sm-1 col-md-1 control-label">  </label>
                                </div>
                                <div class="clearfix layer-area" style="padding-bottom:15px;">
@@ -117,31 +119,46 @@
                                        <input class="form-control" label="收款金额(元)" name="Recievemoney" id="Recievemoney" labtype="txt" addvisible="true" editvisible="true" reg="" ismust="true" type="number" value="@Model.WeishouMoney.ToString("F2")" oninput="if(value.length>8)value=value.slice(0,18)" onkeyup="value=value.toString().match(/^\d+(?:\.\d{0,2})?/)">
                                    </div>
                                </div>
                                <div class="clearfix layer-area" style="padding-bottom:15px;">
                                    <label class="text-right col-sm-1 col-md-1 control-label">收款方式<i class="red">*</i></label>
                                    <div class="col-sm-2 col-md-2">
                                        <select id="PayType" class="form-control" name="PayType" data-placeholder="选择 序列 ...">
                                            @foreach (var item in PayType)
                                            {
                                                @if (!item.CodeSn.Equals(Model.PayType))
                                                {
                                                    <option value="@item.CodeSn" hassubinfo="true">
                                                        @item.Comments
                                                    </option>
                                                }
                                                else
                                                {
                                                    <option value="@item.CodeSn" hassubinfo="true" selected="selected">
                                                        @item.Comments
                                                    </option>
                                                }
                                    <div class="col-sm-10 col-md-10">
                                        @for (int i = 0; i < PayType.Count; i++)
                                        {
                                            <input type="radio" name="PayType" id="PayType@(i)" value="@(PayType[i].CodeSn)" onclick="CheckedChanging(this.value)" truetype="radio">
                                            <label for="PayType@(i)">@(PayType[i].Comments)</label>
                                        }
                                            }
                                            }
                                        <input type="radio" name="PayType" id="PayType2" value="03" onclick="CheckedChanging(this.value)" checked="checked" truetype="radio">
                                        <label for="PayType2">预付款</label>
                                        </select>
                                        (剩余预付款:<span id="nowCustomMoney" class="moneystyle">¥@((cooperatecustomCustomerDTO.Yufukuan??0).ToString("f2"))</span>,剩余授信:<span id="nowCredit" class="moneystyle">¥@((cooperatecustomCustomerDTO.Shouxinedu??0 - cooperatecustomCustomerDTO.Shenyushouxin??0).ToString("f2"))</span>)
                                        @*<select id="PayType" class="form-control" name="PayType" data-placeholder="选择 序列 ...">
            @foreach (var item in PayType)
            {
                @if (!item.CodeSn.Equals(Model.PayType))
                {
                    <option value="@item.CodeSn" hassubinfo="true">
                        @item.Comments
                    </option>
                }
                else
                {
                    <option value="@item.CodeSn" hassubinfo="true" selected="selected">
                        @item.Comments
                    </option>
                }
            }
            }
        </select>*@
                                    </div>
                                </div>
                                <div class="clearfix layer-area" style="padding-bottom:15px;">
                                    <label class="text-right col-sm-1 col-md-1 control-label">收款日期<i class="red">*</i></label>
                                    <div class="col-sm-2 col-md-2">
                                        <input id="PayTime" class="form-control" label="收款日期" name="PayTime" labtype="txt" addvisible="true" editvisible="true" reg="" ismust="true" type="text" value="@Model.PayTime.ToString("yyyy/MM/dd")" readonly="readonly">
@@ -153,7 +170,7 @@
                                </div>
                                <div class="clearfix layer-area" style="padding-bottom:15px;">
                                <div class="clearfix layer-area" style="padding-bottom:15px;" id="AccountSubject">
                                    <label grouptype="Vdata" class="text-right col-sm-1 col-md-1 control-label">账户名称<i class="red">*</i></label>
                                    <div class="col-sm-2 col-md-2" grouptype="Vdata">
@@ -164,7 +181,7 @@
                                        </select>
                                    </div>
                                    <label grouptype="Vdata" class="text-right col-sm-1 col-md-1 control-label">科目名称<i class="red">*</i></label>
                                    <div class="col-sm-2 col-md-2" grouptype="Vdata">
@@ -260,28 +277,27 @@
        // 保存岗位信息
        var savePosition = function () {
            if ($("input[name='PayType']:checked").val()!= '03') {
                if ($("#AccountId").val() == '') {
                    toastr.warning("收款账户不能为空");
                    return;
                }
                if ($("#SubjectId").val() == '') {
                    toastr.warning("收款科目不能为空");
                    return;
                }
            }
            if ($("#Recievemoney").val() == '') {
                toastr.warning("收款金额不能为空");
                return;
            }
            if ($("#PayType").val() == '') {
                toastr.warning("收款方式不能为空");
                return;
            }
            if ($("#PayTime").val() == '') {
                toastr.warning("收款日期不能为空");
                return;
            }
            if ($("#AccountId").val() == '') {
                toastr.warning("收款账户不能为空");
                return;
            }
            if ($("#SubjectId").val() == '') {
                toastr.warning("收款科目不能为空");
                return;
            }
            if (parseFloat($("#Recievemoney").val()) < 0) {
                toastr.warning("收款金额不能小于0");
                return;
@@ -333,12 +349,13 @@
                }
            });
        }
        $("#PayType").change(function () {
            var PayType = $("#PayType").val();
        function CheckedChanging(obj) {
            var PayType = obj;
            if (PayType == "03") {
                $("#AccountSubject").hide();
            } else {
                $("#AccountSubject").show();
            }
            $.ajax({
                type: "GET",
                url: "/FiAccountIncome/getAccount?Accounttype=" + PayType,
@@ -346,7 +363,7 @@
                global: false,
                data: "",
                success: function (data) {
                    var city = $("#AccountId");
                    city.find('option').remove();
                    var aaa = '<option value="" hassubinfo="true">请选择</option>';
@@ -365,9 +382,41 @@
                    parent.layer.msg('失败', { icon: 5 });
                }
            });
        });
        }
        CheckedChanging(03);
        $("#PayType").trigger("change");
        //$("#PayType").change(function () {
        //    var PayType = $("#PayType").val();
        //    $.ajax({
        //        type: "GET",
        //        url: "/FiAccountIncome/getAccount?Accounttype=" + PayType,
        //        dataType: "json",
        //        global: false,
        //        data: "",
        //        success: function (data) {
        //            var city = $("#AccountId");
        //            city.find('option').remove();
        //            var aaa = '<option value="" hassubinfo="true">请选择</option>';
        //            city.append(aaa);
        //            if (data.length > 0) {
        //                for (var i = 0; i < data.length; i++) {
        //                    var o = '<option value="' + data[i].Id + '" hassubinfo="true">' + data[i].Accountname + '</option>';
        //                    city.append(o);
        //                }
        //            }
        //        },
        //        error: function () {
        //            parent.layer.msg('失败', { icon: 5 });
        //        }
        //    });
        //});
        //$("#PayType").trigger("change");
        function _pageAutoClose() {