TG.WXCRM.V4/WEB/Views/WeiXin/OrderDeposit/Pay.cshtml

397 lines
15 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@model CRM.Core.DTO.Ord.OrderPayDto
@using WX.CRM.WebHelper;
@using WX.CRM.Model.Entity;
@{
ViewBag.Title = "支付记录录入";
Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
}
<style>
/*.layui-table td, .layui-table th {
padding: 5px 15px;
}*/
.flowinput{
width:80px;
}
.dlg2Tip {
background: #e9e2e2;
width: 500px;
filter: grayscale(100%);
margin-top: 15px;
}
.dlg2Remark {
margin-bottom: 5px;
font-size: 14px;
margin-left: 5px;
padding: 3px;
}
</style>
<div class="mvctool bgb">
@Html.ToolButtonPlain("btnSave", "icon-save", "保存", false, "")
</div>
@using (Html.BeginForm("Pay", "OrderDeposit", null, FormMethod.Post, new { Id = "CreateForm" }))
{
@Html.ValidationSummary(true)
<table class="fromEditTable ">
<tr>
<td style="width:130px;">订单号:</td>
<td style="padding-left:22px;">
@Request.QueryString["orderid"]
<input type="hidden" name="orderid" value="@Request.QueryString["orderid"]" />
<input type="hidden" name="resid" value="@Request.QueryString["resid"]" />
</td>
<td></td>
</tr>
<tr>
<td style="width:130px;">姓名:</td>
<td style="padding-left: 22px; color: red; font-weight: bold;">
@ViewBag.Name
</td>
<td></td>
</tr>
<tr>
<td>下单金额: </td>
<td style="padding-left:22px;">
@ViewBag.needpay
<input type="hidden" id="needpay" name="needpay" value="@ViewBag.needpay" />
</td>
<td></td>
</tr>
<tr>
<td>确认使用金额: </td>
<td style="padding-left:22px;">
@ViewBag.arrivalpay
<input type="hidden" id="arrivalpay" name="arrivalpay" value="@ViewBag.arrivalpay" />
</td>
<td></td>
</tr>
<tr>
<td>剩余使用金额: </td>
<td>
<input type="text" id="deppriceTxt" value="@ViewBag.deppay" disabled readonly> @*<input type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="UsePriceShow()" value="使用金额">*@
<input type="hidden" id="depprice" name="depprice" value="@ViewBag.deppay" />
剩余金额:@ViewBag.alldeppay
</td>
<td></td>
</tr>
<tr>
<td>还需支付金额: </td>
<td style="padding-left:22px;">
<span id="justpayTxt">@ViewBag.justpay</span>
<input type="hidden" id="justpay" name="juetpay" value="@ViewBag.justpay" />
</td>
<td></td>
</tr>
</table>
<hr style="background-color:red" />
<table class="fromEditTable ">
<tr>
<td style="width:130px;">支付类型:</td>
<td>
@Html.DropDownList("PAYTYPE", new List<SelectListItem>() {
new SelectListItem(){Text="支付宝",Value="1"},
new SelectListItem(){Text="银行转账",Value="3"},
new SelectListItem(){Text="微信支付",Value="5", Selected=true}})
</td>
<td></td>
</tr>
<tr>
<td>付款日期:</td>
<td>
<input id="paydate" name='paydate' class='Wdate' type='text' value='@DateTime.Now.ToString("yyy-MM-dd")' onclick='javascript: WdatePicker();' />
</td>
<td></td>
</tr>
<tr>
<td>付款金额:</td>
<td>
<input type="text" id="payprice" name="payprice" placeholder="¥">
</td>
<td></td>
</tr>
<tr>
<td>付款人姓名:</td>
<td>
<input type="text" id="payname" name="payname" placeholder="请输入">
</td>
<td></td>
</tr>
<tr>
<td>支付流水号:</td>
<td>
<input type="text" id="payno" name="payno" placeholder="请输入" style="width:350px">
<input type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="ShowFlow" onclick="FlowShow()" value="银行转账样式" style="display:none">
</td>
<td></td>
</tr>
<tr>
<td>备注:</td>
<td>
<textarea placeholder="请输入内容" name="remark" class="layui-textarea" rows="3"></textarea>
</td>
<td></td>
</tr>
</table>
<div id="modalwindow" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
}
<div id="dlg" class="easyui-dialog" closed="true" style="width: 400px; height: 400px; padding: 10px;">
<table class="fromEditTable">
<tr>
<td>剩余金额:</td>
<td>@ViewBag.alldeppay</td>
</tr>
<tr>
<td>使用金额:</td>
<td><input type="text" id="usePrice" /></td>
</tr>
<tr>
<td></td>
<td>
<input id="BtnUse" type="button" class="layui-btn layui-btn-sm layui-btn-normal" value="确认" onclick="Use()" />
</td>
</tr>
</table>
</div>
<div id="dlg2" class="easyui-dialog" closed="true" style="width: 400px; height: 400px; padding: 10px;">
<input type="text" id="flowitem1" class="flowinput" placeholder="银行" />
<input type="text" id="flowitem2" class="flowinput" placeholder="姓名" />
<input type="text" id="flowitem3" class="flowinput" placeholder="金额" />
<input type="text" id="flowitem4" class="flowinput" placeholder="年" />
<input type="text" id="flowitem5" class="flowinput" placeholder="月" />
<input type="text" id="flowitem6" class="flowinput" placeholder="日" />
<input type="text" id="flowitem7" class="flowinput" placeholder="时" />
<input type="text" id="flowitem8" class="flowinput" style="width:100px" placeholder="银行卡号后四位" />
<div class="dlg2Tip">
<div class="dlg2Remark">比如: 张三中国银行尾号04068.15日15点30分打款15800元</div>
<div class="dlg2Remark" style=" margin-bottom: 20px;">银行付款流水号: 中国银行-张三-15800-2022-08-15-1530-0406</div>
<div class="dlg2Remark">比如: 王删珊农行现金打款8.16日21点06分付款2500元</div>
<div class="dlg2Remark">银行付款流水号: 农业银行-王珊珊-2500-2022-08-16-2106-现金转账</div>
</div>
<div>
<input id="BtnUse" type="button" class="layui-btn layui-btn-sm layui-btn-normal" value="保存" style=" margin-top: 20px; width:100px" onclick="SetFlowNo()" />
</div>
</div>
<script type="text/javascript">
$(function () {
$("#btnSave").click(function () {
if ($("#CreateForm").valid()) {
var paydate = $("#paydate").val();
var payprice = $("#payprice").val();
var payname = $("#payname").val();
var payno = $.trim($("#payno").val());
var paytype = $("#PAYTYPE").val();
var justpay = $("#justpay").val();
if (justpay > 0) {
if (paydate == "") {
$.messager.alert("错误", "支付日期不能为空!", "error");
return;
}
if (payprice == "") {
$.messager.alert("错误", "付款金额不能为空!", "error");
return;
}
else {
if (!validate(payprice)) {
$.messager.alert("错误", "请输入数字!", "error");
return;
}
else {
if (parseFloat(payprice) > 1000000) {
$.messager.alert("错误", "金额太大了!", "error");
return;
}
}
}
if (payname == "") {
$.messager.alert("错误", "付款人姓名不能为空!", "error");
return;
}
if (payno == "") {
$.messager.alert("错误", "支付流水号不能为空!", "error");
return;
}
else {
if (paytype == 1 || paytype == 5) {
var len = payno.length;
if (len < 28) {
$.messager.alert("错误", "支付流水号错误!", "error");
return;
}
//if (len > 28) {
// payno = payno.substring(0, 28);
//}
//console.log(payno);
if (isNaN(payno)) {
$.messager.alert("错误", "支付流水号只能是数字,不能有字符或者空格!", "error");
return;
}
var start = payno.substring(0, 1);
//console.log(start);
if (start == 2 && paytype != 1) {
$.messager.alert("错误", "支付流水号跟支付类型不匹配!", "error");
return;
}
if (start == 4 && paytype != 5) {
$.messager.alert("错误", "支付流水号跟支付类型不匹配!", "error");
return;
}
}
}
}
else {
if (payno != '') {
$.messager.alert("错误", "付款金额已经足够,不需要在提交付款了,请确认!", "error");
return;
}
}
$.r_ajax({
url: "/WeiXin/OrderDeposit/Pay",
type: "Post",
data: $("#CreateForm").serialize(),
dataType: "json",
loading: true,
success: function (data) {
console.log(data);
if (data.result) {
if (data.retcode == 200) {
$.messager.alert("提示", '提交成功!', "info", function () { window.parent.location.reload(); });
}else if (data.retcode == 500) {
$.messager.alert("提示", data.msgretmsg, "info", function () { window.parent.location.reload(); });
}
}
else {
$.messager.alert("警告", data.msgretmsg , "error");
}
}
});
}
return false;
});
$("#PAYTYPE").change(function () {
var paytype = $("#PAYTYPE").val();
if (paytype == 3) {
$("#ShowFlow").show();
} else {
$("#ShowFlow").hide();
}
});
});
function UsePriceShow() {
$('#dlg').dialog({
title: "使用金额",
width: 400,
height: 250,
closed: false,
cache: false,
modal: true
});
}
function FlowShow() {
$('#dlg2').dialog({
title: "银行转账样式",
width: 800,
height: 350,
closed: false,
cache: false,
modal: true
});
}
function Use() {
var usePrice = $("#usePrice").val();
if (usePrice == '') {
$.messager.alert("错误", "使用金额不能为空!", "error");
return;
}
if (!validate(usePrice)) {
$.messager.alert("错误", "金额必须是数字!", "error");
return;
}
var alldeppay = @ViewBag.alldeppay;
var diffpay = alldeppay - usePrice;
if (diffpay < 0) {
$.messager.alert("错误", "使用金额不能超过剩余金额!", "error");
return;
}
$("#depprice").val(usePrice);
$("#deppriceTxt").val(usePrice);
var needpay = $("#needpay").val();
var arrivalpay = $("#arrivalpay").val();
console.log("needpay:" + needpay);
console.log("arrivalpay:" + arrivalpay);
console.log("usePrice:" + usePrice);
//重新计算金额
var justpay = needpay - arrivalpay - usePrice;
if (justpay < 0) {
$.messager.alert("错误", "超过了需要支付的金额,请确认!", "error");
return;
}
console.log("justpay:" + justpay);
$("#justpay").val(justpay);
$("#justpayTxt").html(justpay);
$('#dlg').dialog('close');
}
function SetFlowNo() {
var flowitem1 = $("#flowitem1").val();
var flowitem2 = $("#flowitem2").val();
var flowitem3 = $("#flowitem3").val();
var flowitem4 = $("#flowitem4").val();
var flowitem5 = $("#flowitem5").val();
var flowitem6 = $("#flowitem6").val();
var flowitem7 = $("#flowitem7").val();
var flowitem8 = $("#flowitem8").val();
var flowStr = "";
if (flowitem1 != "") {
flowStr += "-"+flowitem1;
}
if (flowitem2 != "") {
flowStr += "-" + flowitem2;
}
if (flowitem3 != "") {
flowStr += "-" + flowitem3;
}
if (flowitem4 != "") {
flowStr += "-" + flowitem4;
}
if (flowitem5 != "") {
flowStr += "-" + flowitem5;
}
if (flowitem6 != "") {
flowStr += "-" + flowitem6;
}
if (flowitem7 != "") {
flowStr += "-" + flowitem7;
}
if (flowitem8 != "") {
flowStr += "-" + flowitem8;
}
if (flowStr.length > 0) {
flowStr = flowStr.substring(1, flowStr.length);
}
$("#payno").val(flowStr);
$('#dlg2').dialog('close');
}
function validate(num) {
var reg = /^\d+(?=\.{0,1}\d+$|$)/
if (reg.test(num)) return true;
return false;
}
function GetIframeHtml(src) {
return "<iframe width='100%' height='98%' scrolling='no' frameborder='0'' src='" + src + "'></iframe>";
}
function frameReturnByClose() {
$("#modalwindow").window('close');
}
</script>