欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

跨境电商申报订单加签申报

程序员文章站 2023-10-16 22:07:09
public class CEBSignClient { public void StartSignClient() { } private static SignClientConfig _signClientConfig; public static SignClientConfig CebSi ......

 public class cebsignclient
    {

        public void startsignclient()
        {

        }

        private static signclientconfig _signclientconfig;
        public static signclientconfig cebsignclientconfig
        {
            get { return _signclientconfig; }
            set { _signclientconfig = value; }
        }
        public static signclientconfig getcebsignclientconfig()
        {
            if (_signclientconfig == null)
            {
                _signclientconfig = new signclientconfig();
            }
            return _signclientconfig;
        }
        public static void setcebsignclientconfig(signclientconfig cebsignclientconfig)
        {
            _signclientconfig = cebsignclientconfig;
        }


        /// <summary>
        /// 处理报文加签服务64位
        /// </summary>
        /// <param name="cebmessagesxml"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static string startsigntransform(string cebmessagesxml, string filename, ref bool retunvalue)
        {
            string statuscode = string.empty;
            string statusmessage = string.empty;
            retunvalue = true;
            signhelper signhelper = new signhelper();
            getcebsignclientconfig();
            string centino = "";
            signhelper.password = cebsignclientconfig.signpwd;
            signhelper.msgtype = cebsignclientconfig.msgtype;
            signhelper.receiverid = cebsignclientconfig.receiverid;
            signhelper.senderid = cebsignclientconfig.senderid;
            try
            {
                if (signhelper.isicorukeyok(out centino))
                {
                    string text = cebsignclientconfig.receivesignin;//接收文件夹
                    string text2 = cebsignclientconfig.sendin;//发送文件夹
                                                              //改造
                    string text4;
                    try
                    {

                        signhelper.copmsgid = guid.newguid().tostring();
                        text4 = signhelper.signinfo(cebmessagesxml, centino);
                        //是否生成终端报文
                        if (cebsignclientconfig.checkedterminal)
                        {
                            text4 = signhelper.shellinfo(text4);
                        }
                    }
                    catch (exception ex)
                    {
                        //this.transformexception("文件" + text3 + "异常:" + ex.message);
                        statusmessage = ex.message;
                        return statusmessage;
                    }
                    //拼接目标文件夹和文件路径
                    //string path = path.combine(text2, path.getfilename(filename));
                    var cebmessage = signhelper.formatxml(text4);
                    statusmessage = cebmessage;
                    //file.writealltext(path, cebmessage);
                    //file.delete(filename);

                }
                else
                {
                    //this.transformexception("卡信息读取失败");
                    statusmessage = "卡信息读取失败";
                    retunvalue = false;
                }
            }
            catch (exception ex)
            {
                //this.transformexception(ex.message);
                statusmessage = ex.message;
                retunvalue = false;
            }
            return statusmessage;
        }

        /// <summary>
        /// 处理报文加签服务64位
        /// </summary>
        /// <param name="cebmessagesxml"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static string startsigntransform(string cebmessagesxml, ref bool retunvalue)
        {
            string statuscode = string.empty;
            string statusmessage = string.empty;
            retunvalue = true;
            signhelper signhelper = new signhelper();
            getcebsignclientconfig();
            string centino = "";
            signhelper.password = cebsignclientconfig.signpwd;
            signhelper.msgtype = cebsignclientconfig.msgtype;
            signhelper.receiverid = cebsignclientconfig.receiverid;
            signhelper.senderid = cebsignclientconfig.senderid;
            try
            {
                if (signhelper.isicorukeyok(out centino))
                {
                    string text = cebsignclientconfig.receivesignin;//接收文件夹
                    string text2 = cebsignclientconfig.sendin;//发送文件夹
                                                              //改造
                    string text4;
                    try
                    {

                        signhelper.copmsgid = guid.newguid().tostring();
                        text4 = signhelper.signinfo(cebmessagesxml, centino);
                        //是否生成终端报文
                        if (cebsignclientconfig.checkedterminal)
                        {
                            text4 = signhelper.shellinfo(text4);
                        }
                    }
                    catch (exception ex)
                    {
                        //this.transformexception("文件" + text3 + "异常:" + ex.message);
                        statusmessage = ex.message;
                        return statusmessage;
                    }
                    //拼接目标文件夹和文件路径
                    //string path = path.combine(text2, path.getfilename(filename));
                    var cebmessage = signhelper.formatxml(text4);
                    statusmessage = cebmessage;
                    //file.writealltext(path, cebmessage);
                    //file.delete(filename);

                }
                else
                {
                    //this.transformexception("卡信息读取失败");
                    statusmessage = "卡信息读取失败";
                    retunvalue = false;
                }
            }
            catch (exception ex)
            {
                //this.transformexception(ex.message);
                statusmessage = ex.message;
                retunvalue = false;
            }
            return statusmessage;
        }
    }

    public class signclientconfig
    {
        public signclientconfig()
        {
            signpwd = "88888888";
            receivesignin = @"d:\跨境通\customsdeclarationwebmvcwms3.5\dotnet.winform\bin\debug\eportexchange\signin";
            sendin = @"d:\跨境通\customsdeclarationwebmvcwms3.5\dotnet.winform\bin\debug\eportexchange\in";
            checkedterminal = false;
            msgtype = "";
            receiverid = "";
            senderid = "";
        }
        /// <summary>
        /// 密码
        /// </summary>
        public string signpwd { get; set; }
        /// <summary>
        /// 加签后的文件夹 接收文件夹
        /// </summary>
        public string receivesignin { get; set; }
        /// <summary>
        /// 待加签文件夹 发送文件夹
        /// </summary>
        public string sendin { get; set; }
        /// <summary>
        /// 消息类型
        /// </summary>
        public string msgtype { get; set; }
        /// <summary>
        /// 接收id
        /// </summary>
        public string receiverid { get; set; }
        /// <summary>
        /// 发送id
        /// </summary>
        public string senderid { get; set; }
        /// <summary>
        /// 是否生成终端报文
        /// </summary>
        public bool checkedterminal { get; set; }



    }

 

 

 //杭州版报文组装    //报文组装 按多条订单批量发送
                    foreach (kcyceb311messageorderheadentity item in ceb311messagelist)
                    {
                        progress.setprogressvalue(1);
                        if (string.isnullorwhitespace(item.waybills))
                        {
                            statusmessage = "发现订单运单不存在!";
                            
                            return;
                        }
                        //每条订单不同的guid
                        ceb311hzsendmodel.guid = cebhelputilities.getguid();
                        ceb311messageordersendmodel sendmodel = new ceb311messageordersendmodel();
                        sendmodel.ceb311orderheadinfo = item;//主体信息
                        condition = new searchcondition();
                        sqlcondition = string.empty;
                        condition.addcondition(kcyceb311messageorderlistentity.fieldorderheadid, item.orderheadid, sqloperator.equal)//
                         .addcondition(kcyceb311messageorderlistentity.fieldcompanyid, userinfo.companyid, sqloperator.equal)
                         .addcondition(kcyceb311messageorderlistentity.fielddeletionstatecode, 0, sqloperator.equal)//删除状态
                        .addcondition(kcyceb311messageorderlistentity.fieldenabled, 1, sqloperator.equal);//有效的
                        sqlcondition = condition.buildconditionsql(databasetype.sqlserver);
                        list<kcyceb311messageorderlistentity> ceb311messageorderlist = new list<kcyceb311messageorderlistentity>();
                        ceb311messageorderlist = new kcyceb311messageorderlistmanager().getlist<kcyceb311messageorderlistentity>(sqlcondition);
                        sendmodel.ceb311orderdateillist = ceb311messageorderlist;//明细信息
                        ceb311hzsendmodel.ceb311messagehzsendlist.add(sendmodel);
                        bool returnvalue = true;
                        //报文校验
                        returnvalue = hzceb311message.checkceb311message(ceb311hzsendmodel, out statuscode, out statusmessage);
                        if (!returnvalue)
                        {
                            // 消息提醒   
                            loadingutil.showinformationmessage(statusmessage, appmessage.msg0000);
                            return;
                        }
                        if (statuscode.equals("isstockqty"))
                        {

                        }
                        statusmessage = "杭州报文发送";
                        progress.setprogressvalue(10);
                        progress.setstatusinfo.text = string.format("操作{0}:{1}条 " + "错误:{2} 条", statusmessage, itemcount, itemerrcount);
                        progress.setstatusinfo.update();
                        //生成杭州版报文
                        string ceb311messagexml = hzceb311message.getcareatehzorderxml(ceb311hzsendmodel);
                        ceb311hzsendmodel.cebsoapordersxml = ceb311messagexml;//原始报文
                        ceb311hzsendmodel.sendordersxml = ceb311messagexml;//杭州版报文
                        //报文加密私钥
                        ceb311hzsendmodel.secretkey = ceb311hzsendmodel.ceb311storesorderdeclareparameterinfo.aessign;//aes
                        ceb311hzsendmodel.privatekey = ceb311hzsendmodel.ceb311storesorderdeclareparameterinfo.privatekey.trim();
                        ceb311hzsendmodel.sendurl = ceb311hzsendmodel.ceb311storesorderdeclareparameterinfo.declareaddress;//订单申报地址
                        //aes加密
                        ceb311hzsendmodel.sendordersxml = kuangbaseaesutil.encrypt(ceb311hzsendmodel.sendordersxml, ceb311hzsendmodel.secretkey);
                        cebmessagehzjkfsignmodel.sign(ref ceb311hzsendmodel);
                        if (!ceb311hzsendmodel.status)
                        {
                            // 消息提醒   
                            loadingutil.showinformationmessage(ceb311hzsendmodel.statusmessage, appmessage.msg0000);
                            return;
                        }
                        ceb311hzsendmodel.sendordersxml = hzoperationhttp.datasoap(ceb311hzsendmodel.sendordersxml, ceb311hzsendmodel.businesstype, ceb311hzsendmodel.datadigest, ceb311hzsendmodel.companycode);
                        ceb311hzsendmodel.responseordersxml = hzoperationhttp.httppost(ceb311hzsendmodel);
                        if (ceb311hzsendmodel.status)
                        {
                            statusmessage = "处理回执消息";
                            progress.setprogressvalue(10);
                            progress.setstatusinfo.text = string.format("操作{0}:{1}条 " + "错误:{2} 条", statusmessage, itemcount, itemerrcount);
                            progress.setstatusinfo.update();
                            //读取返回消息处理状态
                            hzjkforderresultmodel responseordersresultmodel = new hzjkforderresultmodel();
                            //处理返回的xml报文
                            responseordersresultmodel.deccontentxml = jkfmessagexmloperation.readreturnxml(ceb311hzsendmodel.responseordersxml.trim());
                            list<basejkfordermessagemodel> listbasejkfmessagemodel = jkfmessagexmloperation.readjkfresultmessage(responseordersresultmodel);
                            foreach (var jkfitem in listbasejkfmessagemodel)
                            {
                                jkfitem.jkfcustomsorderloginfo.orderno = jkfitem.jkfresultinfo.businessno;
                                jkfitem.jkfcustomsorderloginfo.servicename = "ceb311订单服务";
                                jkfitem.jkfcustomsorderloginfo.operationname = "ceb311杭州申报";
                                jkfitem.jkfcustomsorderloginfo.createuserid = userinfo.id;
                                jkfitem.jkfcustomsorderloginfo.createby = userinfo.realname;
                                jkfitem.jkfcustomsorderloginfo.operation = userinfo.username;
                                jkfitem.jkfcustomsorderloginfo.companyid = userinfo.companyid;
                            }
                            bool returnlogvalue = hzjkforderresultservice.addjkfresponseresult(listbasejkfmessagemodel);
                        }

                        //发送成功,再发送总署报文
                        if (ceb311hzsendmodel.status)
                        {
                            statusmessage = "进行总署加签";
                            progress.setstatusinfo.text = string.format("操作{0}:{1}条 " + "错误:{2} 条", statusmessage, itemcount, itemerrcount);
                            progress.setprogressvalue(50);
                            progress.setstatusinfo.update();
                            //总署版报文生成 //生成报文 本地加签
                            ceb311hzsendmodel = hzceb311message.getsendsignatureceb311message(ceb311hzsendmodel);
                            //生成报文 本地加签
                            bool retunvalue = true;
                            string filename = "ceb311_zongshu_" + ceb311hzsendmodel.guid + ".xml";
                            //是否生成终端报文
                            signclientconfig signclientconfig = cebsignclient.getcebsignclientconfig();
                            signclientconfig.checkedterminal = true;
                            signclientconfig.signpwd = ceb311hzsendmodel.cebbasetransferinfo.note;// "88888888";
                            signclientconfig.senderid = ceb311hzsendmodel.dxpid;
                            signclientconfig.receiverid = ceb311hzsendmodel.receiverid;
                            signclientconfig.msgtype = ceb311hzsendmodel.messagetype;
                            cebsignclient.setcebsignclientconfig(signclientconfig);
                            //进行签名
                            ceb311hzsendmodel.cebdeclareservicexml = cebsignclient.startsigntransform(ceb311hzsendmodel.sendordersxml, filename, ref retunvalue);
                            if (!retunvalue)
                            {
                                statusmessage = ceb311hzsendmodel.cebdeclareservicexml;
                                //消息提醒
                                //loadingutil.showinformationmessage(statusmessage, appmessage.msg0000);
                                return;
                            }
                            else
                            {
                                statusmessage = "加签完成";
                                progress.setstatusinfo.text = string.format("操作{0}:{1}条 " + "错误:{2} 条", statusmessage, itemcount, itemerrcount);
                                progress.setprogressvalue(50);
                                progress.setstatusinfo.update();
                                ceb311hzsendmodel.eportexchangepath = appdomain.currentdomain.basedirectory + @"\eportexchange\in";
                                string path = path.combine(ceb311hzsendmodel.eportexchangepath, filename);
                                file.writealltext(path, ceb311hzsendmodel.cebdeclareservicexml);
                            }
                            //包装总署发送报文 包装saop格式发送
                            ceb311hzsendmodel.cebsoapordersxml = hzoperationhttp.cebdeclaredatasoap(ceb311hzsendmodel.cebdeclareservicexml);
                            ceb311hzsendmodel.sendurl = "http://api.kjeport.com/newyorkws/ws/receivecebdeclare";
                            //测试环璋地址 "http://122.224.230.4:18003/newyorkws/ws/receivecebdeclare";正试环璋地址//http://api.kjeport.com/newyorkws/ws/receivecebdeclare?wsdl//
                            ceb311hzsendmodel.responseordersxml = hzoperationhttp.cebdeclareservicehttppost(ceb311hzsendmodel);//发送总署申报
                            //处理总署发送报文返回消息
                            #region 处理总署发送报文返回消息
                            //处理返回的xml报文
                            ceb311hzsendmodel.responseordersxml = jkfmessagexmloperation.readcebzongshureturnxml(ceb311hzsendmodel.responseordersxml.trim());
                            list<basejkfordermessagemodel> listbasejkfmessagemodel = jkfmessagexmloperation.readceb311hzzongshuresultmessage(ceb311hzsendmodel, sendmodel);
                            bool returnlogvalue = false;
                            foreach (basejkfordermessagemodel jkfitem in listbasejkfmessagemodel)
                            {
                                //jkfitem.jkfcustomsorderloginfo.orderno = jkfitem.jkfresultinfo.businessno;
                                jkfitem.jkfcustomsorderloginfo.servicename = "ceb311杭州总署申报";
                                jkfitem.jkfcustomsorderloginfo.operationname = "ceb311杭州总署申报";
                                jkfitem.jkfcustomsorderloginfo.createuserid = userinfo.id;
                                jkfitem.jkfcustomsorderloginfo.createby = userinfo.realname;
                                jkfitem.jkfcustomsorderloginfo.operation = userinfo.username;
                                jkfitem.jkfcustomsorderloginfo.companyid = userinfo.companyid;
                            }
                            returnlogvalue = hzjkforderresultservice.addjkfresponseresult(listbasejkfmessagemodel);
                            #endregion
                            //申报中状态
                            if (returnlogvalue)
                            {
                                int stateint = ((int)orderstate.indeclaration);//订单状态申报中
                                ceb311messageorderservice.uptateceb311orderstate(sendmodel.ceb311orderheadinfo.orderno, stateint);
                                //生成总署报文发送成功
                                statuscode = status.ok.tostring();
                                statusmessage = "发送成功!";
                                itemcount++;
                                progress.setprogressvalue(100);
                                progress.setstatusinfo.text = string.format("操作{0}:{1}条 " + "错误:{2} 条", statusmessage, itemcount, itemerrcount);
                                progress.update();
                            }
                            else
                            {
                                statuscode = status.error.tostring();
                                statusmessage = "发送失败!";
                                itemerrcount++;
                                progress.setprogressvalue(100);
                                progress.setstatusinfo.text = string.format("操作{0}:{1}条 " + "错误:{2} 条", statusmessage, itemcount, itemerrcount);
                                progress.update();
                            }
                        }

                    }

这是本人的关于跨境的仓储管理系统,跨境申报,打单发货一体,支持普贸中境一起操作。

跨境电商申报订单加签申报

 

 这是本人的关于跨境的仓储管理系统,跨境申报,打单发货一体,支持普贸中境一起操作。

 

跨境电商申报订单加签申报

 

 

 

插上ic卡即可加签发送申报,目前支持杭州,海南,上海,深圳等海关对接申报。

 

跨境电商申报订单加签申报

 

 

就展示到这里了,希望有关做这方面的公司使用帮你快速进行跨境贸易通关服务。15557148372,qq:183840232