优化预付款的功能

This commit is contained in:
季圣华 2017-06-29 00:27:19 +08:00
parent f8f61c64db
commit a9377a0669
7 changed files with 141 additions and 50 deletions

View File

@ -423,6 +423,7 @@ public class AccountAction extends BaseAction<AccountModel>
*/ */
Map<String,Object> condition = new HashMap<String,Object>(); Map<String,Object> condition = new HashMap<String,Object>();
condition.put("AccountId_n_eq", id); condition.put("AccountId_n_eq", id);
condition.put("PayType_s_neq", "预付款");
if(!monthTime.equals("")){ if(!monthTime.equals("")){
condition.put("OperTime_s_gteq", monthTime + "-01 00:00:00"); condition.put("OperTime_s_gteq", monthTime + "-01 00:00:00");
condition.put("OperTime_s_lteq", monthTime + "-31 00:00:00"); condition.put("OperTime_s_lteq", monthTime + "-31 00:00:00");

View File

@ -421,6 +421,7 @@ public class SupplierAction extends BaseAction<SupplierModel>
item.put("id", supplier.getId()); item.put("id", supplier.getId());
//客户名称 //客户名称
item.put("supplier", supplier.getSupplier()); item.put("supplier", supplier.getSupplier());
item.put("advanceIn", supplier.getAdvanceIn()); //预付款金额
dataArray.add(item); dataArray.add(item);
} }
} }

View File

@ -282,6 +282,7 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
item.put("AllocationProjectId", depotHead.getAllocationProjectId()==null?"":depotHead.getAllocationProjectId().getId()); item.put("AllocationProjectId", depotHead.getAllocationProjectId()==null?"":depotHead.getAllocationProjectId().getId());
item.put("AllocationProjectName", depotHead.getAllocationProjectId()==null?"":depotHead.getAllocationProjectId().getName()); item.put("AllocationProjectName", depotHead.getAllocationProjectId()==null?"":depotHead.getAllocationProjectId().getName());
item.put("TotalPrice", depotHead.getTotalPrice()==null?"":Math.abs(depotHead.getTotalPrice())); item.put("TotalPrice", depotHead.getTotalPrice()==null?"":Math.abs(depotHead.getTotalPrice()));
item.put("payType", depotHead.getPayType()==null?"":depotHead.getPayType());
item.put("Remark", depotHead.getRemark()); item.put("Remark", depotHead.getRemark());
item.put("op", 1); item.put("op", 1);
dataArray.add(item); dataArray.add(item);

View File

@ -17,6 +17,7 @@
var listTitle = ""; //单据标题 var listTitle = ""; //单据标题
var payTypeTitle = "";//收入 支出 var payTypeTitle = "";//收入 支出
var organUrl = ""; //组织数据接口地址 var organUrl = ""; //组织数据接口地址
var amountNum = ""; //单据编号开头字符
var itemType = true; //隐藏当前列 var itemType = true; //隐藏当前列
var moneyType = true; //隐藏当前列 var moneyType = true; //隐藏当前列
var inOrOut = ""; //链接类型为收入或者支出 var inOrOut = ""; //链接类型为收入或者支出
@ -45,6 +46,7 @@
payTypeTitle = "收入项目"; payTypeTitle = "收入项目";
inOrOut = "in"; inOrOut = "in";
organUrl = cusUrl; organUrl = cusUrl;
amountNum = "SR";
} }
else if(listTitle === "支出单列表"){ else if(listTitle === "支出单列表"){
listType = "支出"; listType = "支出";
@ -53,6 +55,7 @@
payTypeTitle = "支出项目"; payTypeTitle = "支出项目";
inOrOut = "out"; inOrOut = "out";
organUrl = supUrl; organUrl = supUrl;
amountNum = "ZC";
} }
else if(listTitle === "收款单列表"){ else if(listTitle === "收款单列表"){
listType = "收款"; listType = "收款";
@ -61,6 +64,7 @@
payTypeTitle = "无标题"; payTypeTitle = "无标题";
inOrOut = ""; inOrOut = "";
organUrl = cusUrl; organUrl = cusUrl;
amountNum = "SK";
} }
else if(listTitle === "付款单列表"){ else if(listTitle === "付款单列表"){
listType = "付款"; listType = "付款";
@ -69,6 +73,7 @@
payTypeTitle = "无标题"; payTypeTitle = "无标题";
inOrOut = ""; inOrOut = "";
organUrl = supUrl; organUrl = supUrl;
amountNum = "FK";
} }
else if(listTitle === "转账单列表"){ else if(listTitle === "转账单列表"){
listType = "转账"; listType = "转账";
@ -77,6 +82,7 @@
payTypeTitle = "无标题"; payTypeTitle = "无标题";
inOrOut = ""; inOrOut = "";
organUrl = supUrl; organUrl = supUrl;
amountNum = "ZZ";
} }
else if(listTitle === "收预付款列表"){ else if(listTitle === "收预付款列表"){
listType = "收预付款"; listType = "收预付款";
@ -85,6 +91,7 @@
payTypeTitle = "无标题"; payTypeTitle = "无标题";
inOrOut = ""; inOrOut = "";
organUrl = retailUrl; organUrl = retailUrl;
amountNum = "SYF";
} }
} }
//获取账户信息 //获取账户信息
@ -599,10 +606,13 @@
function addAccountHead(){ function addAccountHead(){
$("#clientIp").val(clientIp); $("#clientIp").val(clientIp);
$('#accountHeadFM').form('clear'); $('#accountHeadFM').form('clear');
var thisDate = getNowFormatDate(); //当前日期
$("#BillTime").val(thisDate);
var thisNumber = getNowFormatDateNum(); //根据时间生成编号
$("#BillNo").val(amountNum + thisNumber).focus();
var addTitle = listTitle.replace("列表","信息"); var addTitle = listTitle.replace("列表","信息");
$('#accountHeadDlg').dialog('open').dialog('setTitle','<img src="' + path + '/js/easyui-1.3.5/themes/icons/edit_add.png"/>&nbsp;增加' + addTitle); $('#accountHeadDlg').dialog('open').dialog('setTitle','<img src="' + path + '/js/easyui-1.3.5/themes/icons/edit_add.png"/>&nbsp;增加' + addTitle);
$(".window-mask").css({ width: webW ,height: webH}); $(".window-mask").css({ width: webW ,height: webH});
$("#BillNo").val("").focus();
orgAccountHead = ""; orgAccountHead = "";
accountHeadID = 0; accountHeadID = 0;

View File

@ -12,7 +12,8 @@
var depotHeadMaxId=null; //获取最大的Id var depotHeadMaxId=null; //获取最大的Id
var accepId=null; //保存的主表id var accepId=null; //保存的主表id
var url; var url;
var depotHeadID = 0; var depotHeadID = 0;
var preTotalPrice = 0; //前一次加载的金额
var orgDepotHead = ""; var orgDepotHead = "";
var editIndex = undefined; var editIndex = undefined;
var listTitle = ""; //单据标题 var listTitle = ""; //单据标题
@ -58,7 +59,7 @@
} }
else if(listTitle === "零售退货列表"){ else if(listTitle === "零售退货列表"){
listType = "入库"; listType = "入库";
listSubType = "零售退货"; listSubType = "零售退货"; //注:用预付款购买的产品不能退货
payTypeTitle = "付款"; payTypeTitle = "付款";
organUrl = retailUrl; organUrl = retailUrl;
amountNum = "LSTH"; amountNum = "LSTH";
@ -219,6 +220,19 @@
orgDefaultId = data[i].id; orgDefaultId = data[i].id;
} }
} }
},
onSelect: function(rec){
if(listSubType === "零售"){
var option = "";
if(rec.supplier !== "非会员" && rec.advanceIn >0){
option = '<option value="预付款">预付款(' + rec.advanceIn + ')</option>';
option += '<option value="现付">现付</option>';
}
else {
option += '<option value="现付">现付</option>';
}
$("#payType").empty().append(option);
}
} }
}); });
} }
@ -337,6 +351,7 @@
pageList: initPageNum, pageList: initPageNum,
columns:[[ columns:[[
{ field: 'Id',width:35,align:"center",checkbox:true}, { field: 'Id',width:35,align:"center",checkbox:true},
{field: 'OrganId',width:5, hidden:true},
{ title: '单据编号',field: 'Number',width:100}, { title: '单据编号',field: 'Number',width:100},
{ title: '单据日期 ',field: 'OperTime',width:100}, { title: '单据日期 ',field: 'OperTime',width:100},
{ title: '创建时间',field: 'CreateTime',width:100}, { title: '创建时间',field: 'CreateTime',width:100},
@ -351,12 +366,13 @@
+ 'AaBb' + rec.OperTime+ 'AaBb' + rec.OrganId+ 'AaBb' + rec.HandsPersonId + 'AaBb' + rec.OperTime+ 'AaBb' + rec.OrganId+ 'AaBb' + rec.HandsPersonId
+ 'AaBb' + rec.AccountId+ 'AaBb' + rec.ChangeAmount+ 'AaBb' + rec.Remark + 'AaBb' + rec.AccountId+ 'AaBb' + rec.ChangeAmount+ 'AaBb' + rec.Remark
+ 'AaBb' + rec.ProjectName+ 'AaBb' + rec.OrganName+ 'AaBb' + rec.HandsPersonName + 'AaBb' + rec.ProjectName+ 'AaBb' + rec.OrganName+ 'AaBb' + rec.HandsPersonName
+ 'AaBb' + rec.AccountName + 'AaBb' + rec.TotalPrice + 'AaBb' + rec.AllocationProjectId + 'AaBb' + rec.AllocationProjectName; + 'AaBb' + rec.AccountName + 'AaBb' + rec.TotalPrice + 'AaBb' + rec.AllocationProjectId
+ 'AaBb' + rec.AllocationProjectName + 'AaBb' + rec.payType;
if(1 == value) if(1 == value)
{ {
str += '<a onclick="showDepotHead(\'' + rowInfo + '\');" style="text-decoration:none;color:black;" href="javascript:void(0)"><span class="action-show">查看</span></a>'; str += '<a onclick="showDepotHead(\'' + rowInfo + '\');" style="text-decoration:none;color:black;" href="javascript:void(0)"><span class="action-show">查看</span></a>';
str += '<a onclick="editDepotHead(\'' + rowInfo + '\');" style="text-decoration:none;color:black;" href="javascript:void(0)"><span class="action-edit">编辑</span></a>'; str += '<a onclick="editDepotHead(\'' + rowInfo + '\');" style="text-decoration:none;color:black;" href="javascript:void(0)"><span class="action-edit">编辑</span></a>';
str += '<a onclick="deleteDepotHead('+ rec.Id +');" style="text-decoration:none;color:black;" href="javascript:void(0)"><span class="action-delete">删除</span></a>'; str += '<a onclick="deleteDepotHead('+ rec.Id +',' + rec.OrganId +',' + rec.TotalPrice+ ');" style="text-decoration:none;color:black;" href="javascript:void(0)"><span class="action-delete">删除</span></a>';
} }
return str; return str;
} }
@ -621,9 +637,9 @@
} }
} }
//删除采购入库信息 //删除单据信息
function deleteDepotHead(depotHeadID){ function deleteDepotHead(depotHeadID, thisOrganId, totalPrice){
$.messager.confirm('删除确认','确定要删除此采购入库信息吗?',function(r) $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r)
{ {
if (r) if (r)
{ {
@ -644,20 +660,42 @@
$("#searchBtn").click(); $("#searchBtn").click();
} }
else else
$.messager.alert('删除提示','删除采购入库信息失败,请稍后再试!','error'); $.messager.alert('删除提示','删除单据信息失败,请稍后再试!','error');
}, },
//此处添加错误处理 //此处添加错误处理
error:function() error:function()
{ {
$.messager.alert('删除提示','删除采购入库信息异常,请稍后再试!','error'); $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
return; return;
} }
}); });
//更新会员的预收款信息
if(listSubType === "零售") {
$.ajax({
type:"post",
url: path + "/supplier/updateAdvanceIn.action",
dataType: "json",
data:{
SupplierID: thisOrganId, //会员id
AdvanceIn: totalPrice //删除时同时返还用户的预付款
},
success: function(res){
if(res) {
//保存会员预收款成功
}
},
error: function(){
$.messager.alert('提示','保存信息异常,请稍后再试!','error');
return;
}
});
}
} }
}); });
} }
//批量删除采购入库 //批量删除单据信息
function batDeleteDepotHead(){ function batDeleteDepotHead(){
var row = $('#tableData').datagrid('getChecked'); var row = $('#tableData').datagrid('getChecked');
if(row.length == 0) if(row.length == 0)
@ -667,7 +705,7 @@
} }
if(row.length > 0) if(row.length > 0)
{ {
$.messager.confirm('删除确认','确定要删除选中的' + row.length + '条采购入库信息吗?',function(r) $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
{ {
if (r) if (r)
{ {
@ -682,6 +720,30 @@
//alert(row[i].id); //alert(row[i].id);
ids += row[i].Id + ","; ids += row[i].Id + ",";
} }
//批量更新会员的预收款信息
for(var i = 0;i < row.length; i ++) {
if(listSubType === "零售") {
$.ajax({
type:"post",
url: path + "/supplier/updateAdvanceIn.action",
dataType: "json",
data:{
SupplierID: row[i].OrganId, //会员id
AdvanceIn: row[i].TotalPrice //删除时同时返还用户的预付款
},
success: function(res){
if(res) {
//保存会员预收款成功
}
},
error: function(){
$.messager.alert('提示','保存信息异常,请稍后再试!','error');
return;
}
});
}
}
//批量删除
$.ajax({ $.ajax({
type:"post", type:"post",
url: path + "/depotHead/batchDelete.action", url: path + "/depotHead/batchDelete.action",
@ -701,12 +763,12 @@
$(":checkbox").attr("checked",false); $(":checkbox").attr("checked",false);
} }
else else
$.messager.alert('删除提示','删除采购入库信息失败,请稍后再试!','error'); $.messager.alert('删除提示','删除单据信息失败,请稍后再试!','error');
}, },
//此处添加错误处理 //此处添加错误处理
error:function() error:function()
{ {
$.messager.alert('删除提示','删除采购入库信息异常,请稍后再试!','error'); $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
return; return;
} }
}); });
@ -768,12 +830,25 @@
$("#ChangeAmount").attr("data-changeamount", depotHeadInfo[8]); $("#ChangeAmount").attr("data-changeamount", depotHeadInfo[8]);
$("#Remark").val(depotHeadInfo[9]); $("#Remark").val(depotHeadInfo[9]);
var TotalPrice = depotHeadInfo[14]; var TotalPrice = depotHeadInfo[14];
preTotalPrice = depotHeadInfo[14]; //记录前一次合计金额,用于扣预付款
$("#AllocationProjectId").val(depotHeadInfo[15]); $("#AllocationProjectId").val(depotHeadInfo[15]);
//orgDepotHead = depotHeadInfo[1]; //orgDepotHead = depotHeadInfo[1];
var editTitle = listTitle.replace("列表","信息"); var editTitle = listTitle.replace("列表","信息");
$('#depotHeadDlg').dialog('open').dialog('setTitle','<img src="' + path + '/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑' + editTitle); $('#depotHeadDlg').dialog('open').dialog('setTitle','<img src="' + path + '/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑' + editTitle);
$(".window-mask").css({ width: webW ,height: webH}); $(".window-mask").css({ width: webW ,height: webH});
depotHeadID = depotHeadInfo[0]; depotHeadID = depotHeadInfo[0];
if(listSubType === "零售" ){
var option = "";
if(depotHeadInfo[17] === "预付款"){
option = '<option value="预付款">预付款</option>';
option += '<option value="现付">现付</option>';
}
else {
option += '<option value="现付">现付</option>';
}
$("#payType").empty().append(option);
}
initTableData_material("edit",TotalPrice); //商品列表 initTableData_material("edit",TotalPrice); //商品列表
reject(); //撤销下、刷新商品列表 reject(); //撤销下、刷新商品列表
@ -791,6 +866,7 @@
$("#AccountIdShow").text(depotHeadInfo[13]); $("#AccountIdShow").text(depotHeadInfo[13]);
$("#ChangeAmountShow").text(depotHeadInfo[8]); $("#ChangeAmountShow").text(depotHeadInfo[8]);
$("#RemarkShow").text(depotHeadInfo[9]); $("#RemarkShow").text(depotHeadInfo[9]);
$("#payTypeShow").text(depotHeadInfo[17]);
var TotalPrice = depotHeadInfo[14]; var TotalPrice = depotHeadInfo[14];
$("#AllocationProjectIdShow").text(depotHeadInfo[16]); $("#AllocationProjectIdShow").text(depotHeadInfo[16]);
var showTitle = listTitle.replace("列表","信息"); var showTitle = listTitle.replace("列表","信息");
@ -860,7 +936,7 @@
} }
//零售时候,可以从会员预付款中扣款 //零售时候,可以从会员预付款中扣款
var thisPayType = "现付"; var thisPayType = "现付";
if(listSubType === "零售" || listSubType === "零售退货") { if(listSubType === "零售") {
if($("#payType").val() ==="预付款") { if($("#payType").val() ==="预付款") {
thisPayType = "预付款"; thisPayType = "预付款";
} }
@ -895,34 +971,41 @@
var opts = $("#tableData").datagrid('options'); var opts = $("#tableData").datagrid('options');
showDepotHeadDetails(opts.pageNumber,opts.pageSize); showDepotHeadDetails(opts.pageNumber,opts.pageSize);
} }
if(thisPayType === "预付款") {
//更新用户信息-预付款
var advanceIn = 0; //预付款金额
if(depotHeadID){
advanceIn = TotalPrice - preTotalPrice; //修改时,预付款=合计金额-加载金额
}
else{
advanceIn = TotalPrice; //新增时,预付款=合计金额
}
$.ajax({
type:"post",
url: path + "/supplier/updateAdvanceIn.action",
dataType: "json",
data:{
SupplierID: OrganId, //会员id
AdvanceIn: 0 - advanceIn //保存的同时扣掉用户的预付款
},
success: function(res){
if(res) {
//保存会员预收款成功
}
},
error: function(){
$.messager.alert('提示','保存信息异常,请稍后再试!','error');
return;
}
});
}
//保存明细记录 //保存明细记录
if(depotHeadID ==0) if(depotHeadID ==0)
{ {
getMaxId(); //查找最大的Id getMaxId(); //查找最大的Id
accept(depotHeadMaxId); //新增 accept(depotHeadMaxId); //新增
if(thisPayType === "预付款") {
//更新用户信息-预付款
$.ajax({
type:"post",
url: path + "/supplier/updateAdvanceIn.action",
dataType: "json",
data:{
SupplierID: OrganId, //会员id
AdvanceIn: 0 - ChangeAmount //保存的同时扣掉用户的预付款
},
success: function(res){
if(res) {
//保存会员预收款成功
}
},
error: function(){
$.messager.alert('提示','保存信息异常,请稍后再试!','error');
return;
}
});
}
closeDialog(); closeDialog();
} }
else else

View File

@ -123,10 +123,6 @@
<label id="descriptionLabel">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述&nbsp;&nbsp;</label> <label id="descriptionLabel">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述&nbsp;&nbsp;</label>
<textarea name="description" id="description" rows="2" cols="2" style="width: 230px;"></textarea> <textarea name="description" id="description" rows="2" cols="2" style="width: 230px;"></textarea>
</div> </div>
<div class="fitem" style="padding:5px">
<label id="enabledLabel">启&nbsp;&nbsp;&nbsp;&nbsp;动&nbsp;&nbsp;</label>
<input name="enabled" id="enabled" type="checkbox" style="width: 230px;height: 20px"/>
</div>
<input type="hidden" name="clientIp" id="clientIp" value="<%=clientIp %>"/> <input type="hidden" name="clientIp" id="clientIp" value="<%=clientIp %>"/>
</form> </form>
</div> </div>
@ -207,13 +203,10 @@
{ title: '期初应收',field: 'BeginNeedGet',width:70,align:"center"}, { title: '期初应收',field: 'BeginNeedGet',width:70,align:"center"},
{ title: '期初应付',field: 'BeginNeedPay',width:70,align:"center"}, { title: '期初应付',field: 'BeginNeedPay',width:70,align:"center"},
{ title: '类型',field: 'type',width:50}, { title: '类型',field: 'type',width:50},
{ title: '启动',field: 'enabled',width:40,formatter:function(value){
return value? "开":"关";
}},
{ title: '操作',field: 'op',align:"center",width:130,formatter:function(value,rec) { title: '操作',field: 'op',align:"center",width:130,formatter:function(value,rec)
{ {
var str = ''; var str = '';
var rowInfo = rec.id + 'AaBb' + rec.supplier +'AaBb' + rec.contacts + 'AaBb'+ rec.phonenum + 'AaBb'+ rec.email + 'AaBb'+ rec.BeginNeedGet + 'AaBb'+ rec.BeginNeedPay + 'AaBb' + rec.isystem + 'AaBb' + rec.description+ 'AaBb' + rec.type+ 'AaBb' + rec.enabled; var rowInfo = rec.id + 'AaBb' + rec.supplier +'AaBb' + rec.contacts + 'AaBb'+ rec.phonenum + 'AaBb'+ rec.email + 'AaBb'+ rec.BeginNeedGet + 'AaBb'+ rec.BeginNeedPay + 'AaBb' + rec.isystem + 'AaBb' + rec.description+ 'AaBb' + rec.type;
if(1 == value) if(1 == value)
{ {
str += '<img src="<%=path%>/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editSupplier(\'' + rowInfo + '\');"/>&nbsp;<a onclick="editSupplier(\'' + rowInfo + '\');" style="text-decoration:none;color:black;" href="javascript:void(0)">编辑</a>&nbsp;&nbsp;'; str += '<img src="<%=path%>/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editSupplier(\'' + rowInfo + '\');"/>&nbsp;<a onclick="editSupplier(\'' + rowInfo + '\');" style="text-decoration:none;color:black;" href="javascript:void(0)">编辑</a>&nbsp;&nbsp;';
@ -480,7 +473,6 @@
BeginNeedPay : supplierInfo[6], BeginNeedPay : supplierInfo[6],
description : supplierInfo[8], description : supplierInfo[8],
type : supplierInfo[9], type : supplierInfo[9],
enabled : supplierInfo[10],
clientIp:'<%=clientIp %>' clientIp:'<%=clientIp %>'
}; };
orgSupplier = supplierInfo[1]; orgSupplier = supplierInfo[1];

View File

@ -94,7 +94,6 @@
<td style="padding:5px"> <td style="padding:5px">
<select name="payType" id="payType" style="width:130px;"> <select name="payType" id="payType" style="width:130px;">
<option value="现付">现付</option> <option value="现付">现付</option>
<option value="预付款">预付款</option>
</select> </select>
</td> </td>
</tr> </tr>
@ -175,9 +174,13 @@
</tr> </tr>
<tr> <tr>
<td>单据备注:</td> <td>单据备注:</td>
<td style="padding:5px;width:292px;" colspan="5"> <td style="padding:5px;width:292px;" colspan="3">
<span id="RemarkShow"></span> <span id="RemarkShow"></span>
</td> </td>
<td>付款类型:</td>
<td style="padding:5px">
<span id="payTypeShow"></span>
</td>
</tr> </tr>
<tr> <tr>
<td colspan="6"> <td colspan="6">