284 lines
14 KiB
C#
284 lines
14 KiB
C#
using System;
|
||
using SuperMap.RealEstate.ServiceModel;
|
||
using SuperMap.RealEstate.Utility;
|
||
using SuperMap.RealEstate.Web.UI;
|
||
using SuperMap.RealEstate.Web.UI.WebControls;
|
||
using SuperMap.RealEstate.FrameWork.Business;
|
||
using EDB = SuperMap.RealEstate.ExchangeData.Business;
|
||
using HWSB = SuperMap.RealEstate.HighWay.Storage.Business;
|
||
using Business = SuperMap.RealEstate.HighWay.SellData.Business;
|
||
using HZQR.Common.Models;
|
||
using HZQR.Common;
|
||
|
||
namespace SuperMap.RealEstate.HighWay.Modules.ProblemDeal
|
||
{
|
||
public partial class ENDACCOUNTPage : SuperMap.RealEstate.Web.UI.Page
|
||
{
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (IsPostBack) return;
|
||
|
||
//载入数据
|
||
ButtonDelete.Enabled = ENDACCOUNT1.LoadData();
|
||
//显示图片上传功能
|
||
if (ENDACCOUNT1.CurrObject.ENDACCOUNT_ID != null)
|
||
{
|
||
bool UploadFlag = false;
|
||
if (new HWSB.IMAGE(Transaction).GetCount("WHERE TABLE_ID = " + ENDACCOUNT1.CurrObject.KeyID +
|
||
" AND TABLE_NAME = 'HIGHWAY_SELLDATA.T_ENDACCOUNT'") > 0)
|
||
{
|
||
//已经上传过凭证,日结账期审结后不允许修改
|
||
UploadFlag = true;
|
||
}
|
||
BtnSearch.OnClientClick = GetOpenPopDialogClientScript("http://eshangtech.com/uploadPhoto/index.html?id=" +
|
||
ENDACCOUNT1.CurrObject.ENDACCOUNT_ID + "&tablename=ENDACCOUNT&readonly=" +
|
||
((UploadFlag && ENDACCOUNT1.CurrObject.TREATMENT_MARK == 2) || ENDACCOUNT1.CurrObject.VALID == 0 ?
|
||
"true" : Request["readonly"]), "IMAGEPage", 1140, 720);
|
||
|
||
if (Request["DATATYPE"] == "CHECK")
|
||
{
|
||
ButtonDelete.Visible = false;
|
||
}
|
||
else if (ENDACCOUNT1.CurrObject.TREATMENT_MARK == 2 || ENDACCOUNT1.CurrObject.VALID == 0)
|
||
{
|
||
ButtonSave.Visible = false;
|
||
ButtonDelete.Visible = false;
|
||
}
|
||
else if (!string.IsNullOrWhiteSpace(Request["readonly"]))
|
||
{
|
||
ButtonSave.Visible = false;
|
||
}
|
||
|
||
//设置“查看视频”按钮点击事件
|
||
if (!string.IsNullOrWhiteSpace(ENDACCOUNT1.CurrObject.SERVERPARTCODE) &&
|
||
!string.IsNullOrWhiteSpace(ENDACCOUNT1.CurrObject.SHOPCODE))
|
||
{
|
||
//查询视频监控连接地址
|
||
EDB.SHOPVIDEO _SHOPVIDEO = new EDB.SHOPVIDEO(Transaction);
|
||
_SHOPVIDEO.AddSearchParameter("SERVERPARTCODE", ENDACCOUNT1.CurrObject.SERVERPARTCODE);
|
||
_SHOPVIDEO.AddSearchParameter("SHOPCODE", ENDACCOUNT1.CurrObject.SHOPCODE);
|
||
if (_SHOPVIDEO.Search())
|
||
{
|
||
OpenUrl.Text = ENDACCOUNT1.CurrObject.SERVERPARTCODE + "|" +
|
||
ENDACCOUNT1.CurrObject.SHOPCODE + "|1000|" + ENDACCOUNT1.CurrObject.KeyID;
|
||
|
||
SearchVideo.Visible = true;
|
||
}
|
||
}
|
||
}
|
||
//设置删除提示
|
||
SetControlConfirm(ButtonDelete, "您确认删除该记录,删除后将无法恢复数据?");
|
||
//设置按钮状态
|
||
SetControlClientAction(ButtonDelete, false, true, true);
|
||
SetControlClientAction(ButtonSave);
|
||
//注册遮罩式窗口关闭脚本
|
||
SetControlClosePopDialog(ButtonClose);
|
||
}
|
||
|
||
protected void ButtonSave_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
//刷新类型
|
||
bool _RefreshType = ButtonDelete.Enabled;
|
||
//保存数据
|
||
|
||
ButtonDelete.Enabled = ENDACCOUNT1.Save();
|
||
//刷新弹出页列表
|
||
RefreshOpenerGridPage(_RefreshType ? RefreshGridPageType.Update : RefreshGridPageType.Insert);
|
||
|
||
#region 微信小程序推送
|
||
Business.ENDACCOUNT _ENDACCOUNT = ENDACCOUNT1.CurrObject;
|
||
try
|
||
{
|
||
//当前环节日结校验,推送给日结审核权限
|
||
string moduleGuid = "43ecf139-66a7-421b-ba0f-bf7ddd77437d";
|
||
if (_ENDACCOUNT.REVIEW_STATE == 1)
|
||
{
|
||
Storage.Business.CommonHelper.PushEndAccountMessage(this.Transaction, "2", null, _ENDACCOUNT, moduleGuid,
|
||
this.PassportInfo.ID.ToString(), this.PassportInfo.Name);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ex = ex ?? ex.InnerException;
|
||
LogUtil.WriteLog("推送ex=" + ex.Message.ToString());
|
||
}
|
||
#endregion
|
||
|
||
//提示信息
|
||
Alert("保存成功!", 3);
|
||
ClosePopDialog();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//回滚事务
|
||
Transaction.Rollback();
|
||
//记录日志
|
||
ErrorLogHelper.Write(ex);
|
||
|
||
#region 记录日结账期单品销售日志,默认单品数据和实收金额不一致
|
||
//结账单内码
|
||
TextBoxEx _ENDACCOUNT_ID = ENDACCOUNT1.FindControl("ENDACCOUNT_ID") as TextBoxEx;
|
||
//结账人员
|
||
TextBoxEx _WORKER_NAME = ENDACCOUNT1.FindControl("WORKER_NAME") as TextBoxEx;
|
||
//校验人员
|
||
TextBoxEx _DESCRIPTION_STAFF = ENDACCOUNT1.FindControl("DESCRIPTION_STAFF") as TextBoxEx;
|
||
//单品金额
|
||
TextBoxEx _FACTAMOUNT_SALE = ENDACCOUNT1.FindControl("FACTAMOUNT_SALE") as TextBoxEx;
|
||
//销售金额
|
||
TextBoxEx _TOTALSELLAMOUNT = ENDACCOUNT1.FindControl("TOTALSELLAMOUNT") as TextBoxEx;
|
||
//实收金额
|
||
TextBoxEx _CASHPAY = ENDACCOUNT1.FindControl("CASHPAY") as TextBoxEx;
|
||
//流水冲正金额
|
||
string _CORRECT_AMOUNT = (ENDACCOUNT1.FindControl("CORRECT_AMOUNT") as TextBoxEx).Text.Split('/')[0];
|
||
//单品冲正金额
|
||
string _FACTAMOUNT = (ENDACCOUNT1.FindControl("FACTAMOUNT") as TextBoxEx).Text;
|
||
|
||
//获取结账单数据对象
|
||
Business.ENDACCOUNT _ENDACCOUNT = ENDACCOUNT1.CurrObject;
|
||
if (_ENDACCOUNT.PropertyObject == null || _ENDACCOUNT.ENDACCOUNT_ID == null)
|
||
{
|
||
//实例化数据对象,根据内码查询
|
||
_ENDACCOUNT.ENDACCOUNT_ID_Encrypt = _ENDACCOUNT_ID.Text.ToEncrypt();
|
||
_ENDACCOUNT.Select();
|
||
}
|
||
//如果门店编码不为空,则通过服务区内码+门店编码查询门店数据
|
||
if (!_WORKER_NAME.Text.Contains("【扫码】") && !_WORKER_NAME.Text.Contains("【接口】") &&
|
||
!_DESCRIPTION_STAFF.Text.Contains("【补】") && !string.IsNullOrWhiteSpace(_ENDACCOUNT.SHOPCODE))
|
||
{
|
||
HWSB.SERVERPARTSHOP _SERVERPARTSHOP = new HWSB.SERVERPARTSHOP(Transaction);
|
||
_SERVERPARTSHOP.AddSearchParameter("SERVERPART_ID", _ENDACCOUNT.SERVERPART_ID);
|
||
_SERVERPARTSHOP.AddSearchParameter("SHOPCODE", _ENDACCOUNT.SHOPCODE);
|
||
if (_SERVERPARTSHOP.Search())
|
||
{
|
||
//判断日结数据是否从接口上传,若是从接口上传,则不记录单品数据和销售额的一致性
|
||
if (_SERVERPARTSHOP.TRANSFER_TYPE == null || _SERVERPARTSHOP.TRANSFER_TYPE == 0)
|
||
{
|
||
BusinessLogModel businessLogModel = new BusinessLogModel();
|
||
businessLogModel.BUSINESSLOG_TYPE = 100000;
|
||
businessLogModel.BUSINESS_ID = _ENDACCOUNT.ENDACCOUNT_ID;
|
||
businessLogModel.TABLE_NAME = "T_ENDACCOUNT";
|
||
businessLogModel.OWNER_NAME = "HIGHWAY_SELLDATA";
|
||
businessLogModel.UNIQUECODE = _ENDACCOUNT.SERVERPARTCODE + "|" + _ENDACCOUNT.SHOPCODE + "|" +
|
||
_ENDACCOUNT.ENDACCOUNT_DATE + "|" + _ENDACCOUNT.MACHINECODE + "|" +
|
||
_CASHPAY.Text + "|" + _SERVERPARTSHOP.SHOPTRADE;
|
||
businessLogModel.SERVERPARTCODE = _ENDACCOUNT.SERVERPARTCODE;
|
||
businessLogModel.SHOPCODE = _ENDACCOUNT.SHOPCODE;
|
||
businessLogModel.MACHINECODE = _ENDACCOUNT.MACHINECODE;
|
||
businessLogModel.BUSINESSTYPE = _SERVERPARTSHOP.SHOPTRADE.TryParseToInt();
|
||
businessLogModel.SALE_AMOUNT = double.Parse(_FACTAMOUNT_SALE.Text).Round(2);
|
||
businessLogModel.CASHPAY_AMOUNT = double.Parse(_CASHPAY.Text).Round(2);
|
||
businessLogModel.ENDACCOUNT_ID = _ENDACCOUNT.ENDACCOUNT_ID;
|
||
businessLogModel.STATISTICS_DATE = _ENDACCOUNT.ENDACCOUNT_DATE.Value.ToString("yyyyMMddHHmmss").TryParseToLong();
|
||
|
||
//删除已存储到日志表的结账单品日志信息
|
||
string SQLString = "DELETE FROM PLATFORM_FRAMEWORK.T_BUSINESSLOG WHERE BUSINESS_ID = " +
|
||
_ENDACCOUNT.ENDACCOUNT_ID + " AND TABLE_NAME = 'T_ENDACCOUNT' AND OWNER_NAME = 'HIGHWAY_SELLDATA'";
|
||
new User(Transaction).ExecuteNonQuery(SQLString, null);
|
||
if (!string.IsNullOrWhiteSpace(_ENDACCOUNT.WORKER_NAME) &&
|
||
_ENDACCOUNT.WORKER_NAME.Contains("【扫】"))
|
||
{
|
||
//如果是收银机离线扫码上传的数据,则加上扫码标识
|
||
businessLogModel.BUSINESSLOG_CONTENT = "【扫】" + businessLogModel.BUSINESSLOG_CONTENT;
|
||
}
|
||
//单品数据和实收金额一致,则标记Data_Consistency为1
|
||
if (_FACTAMOUNT_SALE.Text.TryParseToDecimal() == _TOTALSELLAMOUNT.Text.TryParseToDecimal() ||
|
||
_FACTAMOUNT_SALE.Text.TryParseToDecimal() == _CASHPAY.Text.TryParseToDecimal())
|
||
{
|
||
businessLogModel.DATA_CONSISTENCY = 1;
|
||
businessLogModel.CHECK_STATE = 0;
|
||
}
|
||
else
|
||
{
|
||
//单品金额和实收金额不一致时,只记录收银机上传的单品金额,方便收银机重传数据
|
||
businessLogModel.SALE_AMOUNT = (businessLogModel.SALE_AMOUNT.Value -
|
||
_CORRECT_AMOUNT.TryParseToDouble() - _FACTAMOUNT.TryParseToDouble()).Round(2);
|
||
|
||
businessLogModel.DATA_CONSISTENCY = 0;
|
||
businessLogModel.CHECK_STATE = 0;
|
||
}
|
||
//定义日志记录内容
|
||
businessLogModel.BUSINESSLOG_CONTENT = _ENDACCOUNT.SERVERPART_NAME + _ENDACCOUNT.SHOPNAME +
|
||
"【" + _ENDACCOUNT.ENDACCOUNT_DATE + "】" + _ENDACCOUNT.MACHINECODE +
|
||
",单品销售金额:" + businessLogModel.SALE_AMOUNT + ",实收金额:" + businessLogModel.CASHPAY_AMOUNT;
|
||
|
||
HZQR.Common.Common.BusinessHelper.RecordBusinessLog(Transaction, businessLogModel);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
if (ex.Message != "0" && ex.Message != "1" && ex.Message != "2" && ex.Message != "3" && ex.Message != "4")
|
||
{
|
||
#if DEBUG
|
||
Alert("保存失败!\n" + ex.Message);
|
||
#else
|
||
Alert("保存失败!");
|
||
#endif
|
||
}
|
||
else
|
||
{
|
||
//定义触发页面跳转的按钮ClientID
|
||
string ButtonClientID = (ENDACCOUNT1.FindControl("CallBackButton_Add") as CallBackButton).ClientID;
|
||
switch (ex.Message)
|
||
{
|
||
case "0":
|
||
Alert("日结营收信息不符,请先进行流水冲正处理...", 2);
|
||
break;
|
||
case "1":
|
||
Alert("移动支付金额与系统不一致,请先进行流水冲正处理...", 2);
|
||
break;
|
||
}
|
||
|
||
System.Threading.Thread.Sleep(3000);
|
||
|
||
string RETURNRESULE = string.Format("document.getElementById('{0}').click();", ButtonClientID);
|
||
ClientScript.RegisterStartupScript(GetType(), "confirm", RETURNRESULE, true);
|
||
}
|
||
}
|
||
}
|
||
|
||
protected void ButtonDelete_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
//删除数据
|
||
ButtonDelete.Enabled = !ENDACCOUNT1.Delete();
|
||
//刷新弹出页列表
|
||
RefreshOpenerGridPage(RefreshGridPageType.Delete);
|
||
//提示信息
|
||
Alert("删除成功!", 3);
|
||
ClosePopDialog();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//回滚事务
|
||
Transaction.Rollback();
|
||
//记录日志
|
||
ErrorLogHelper.Write(ex);
|
||
#if DEBUG
|
||
Alert("删除失败!可能的原因:\n" + ex.Message);
|
||
#else
|
||
Alert("删除失败!");
|
||
#endif
|
||
}
|
||
}
|
||
|
||
protected void BtnCorrect_Click(object sender, EventArgs e)
|
||
{
|
||
if (ENDACCOUNT1.CorrectPrice())
|
||
{
|
||
Alert("校验成功!", 3);
|
||
ENDACCOUNT1.Save();
|
||
Refresh();
|
||
RefreshOpenerGridPage(RefreshGridPageType.Update);
|
||
}
|
||
else
|
||
{
|
||
Alert("校验失败!");
|
||
}
|
||
}
|
||
}
|
||
}
|