Exemplo n.º 1
0
        public async Task <string> CanlOrder(CancelOrderHC cancelOrder, string OrderNo)
        {
            T_ORDER order  = new T_ORDER();
            var     result = new HCResult();

            order = await GetOrderByOrderNo(cancelOrder.logisticCode);

            if (order == null)
            {
                return(ResponseHandle(cancelOrder.logisticCode, false, 1001, "订单不存在", " 订单不存在"));
            }
            if (order.ORDER_STATUS >= 30)
            {
                return(ResponseHandle(cancelOrder.logisticCode, false, 1003, "该订单不允许撤销", " 订单已经接单或已经撤销"));
            }
            var ret = CancelOrder(order).Result;

            if (ret > 0)
            {
                return(ResponseHandle(cancelOrder.logisticCode, true, 1000, "撤销成功", " 撤销成功"));
            }
            else
            {
                return(ResponseHandle(cancelOrder.logisticCode, false, 9000, "系统数据库错误", " 系统数据库处理数据出错"));
            }
        }
        public async Task <int> CancelOrderByOrderNo(T_ORDER order)
        {
            try
            {
                var count = await GetWayBillCount(order.BILL_NO);

                var ret = 0;
                if (count > 0)
                {
                    ret = -2;
                }
                else
                {
                    ret = await base.UpdateAsync(_scope, new { ORDER_CANCEL_REMARK = order.ORDER_CANCEL_REMARK, OUTSYS_CODE = order.OUTSYS_CODE }, "Cancel");
                }
                return(ret);
            }
            catch (Exception e)
            {
                var message = new StringBuilder();
                message.Append("取消订单时,数据库发生错误:\n" + "订单号:" + order.ORDER_NO);
                message.Append("订单表内容:" + order.ToJson());
                message.Append(e.Message + e.StackTrace);
                message.ToString().WriteToLog(LogerType.Error);
                return(0);
            }
        }
Exemplo n.º 3
0
 public Task <int> UpdateOrderByOutCode(T_ORDER order)
 {
     return(OracleScope.Repository.UpdateAsync <T_ORDER>("T_ORDER.UpdateORDER_STATUSByOutCode",
                                                         new
     {
         order.ORDER_STATUS,
         order.ORDER_CANCEL_TIME,
         order.ORDER_CANCEL_REMARK,
         order.ORDER_CANCEL_BY,
         order.NEED_ADD_RECORD_BOS,
         order.OUTSYS_CODE
     }));
 }
        /// <summary>
        /// 撤销订单
        /// </summary>
        /// <param name="txLogisticId"></param>
        /// <param name="remark"></param>
        /// <returns></returns>
        private async Task <Response> Cancel(string txLogisticId, string remark)
        {
            var response = new Response();
            var order    = new T_ORDER();

            //查询订单
            order = await GetOrderByOutSysNo(txLogisticId);

            if (order == null)
            {
                response.success = false;
                response.reason  = "订单不存在";
                return(response);
            }

            //order.OUTSYS_CODE = txLogisticId;
            //order.ORDER_STATUS = 30;
            //order.ORDER_CANCEL_TIME = DateTime.Now;
            order.ORDER_CANCEL_REMARK = remark;
            //order.NEED_ADD_RECORD_BOS = 1;

            var ret = await CancelOrderByOrderNo(order);

            if (ret > 0)
            {
                response.success = true;
                response.reason  = "订单撤销成功";
            }
            else
            {
                switch (ret)
                {
                case 0:
                    response.success = false;
                    response.reason  = "订单撤销失败或此单不存在";
                    break;

                case -2:
                    response.success = false;
                    response.reason  = "此单号已接单,不允许取消操作";
                    break;
                }
            }
            return(response);
        }
        public async Task <int> UpdateMailNo(T_ORDER order, string mailNo)
        {
            try
            {
                sqlMapper.BeginTransaction();
                order.BILL_NO = mailNo;
                int rows = await base.UpdateAsync("T_ORDER_WAYBILL_MAP", new { MAIL_NO = mailNo, ORDER_NO = order.ORDER_NO });

                int ret = await base.UpdateAsync(_scope, new { BILL_NO = order.BILL_NO, REMARK2 = order.REMARK2, OUTSYS_CODE = order.OUTSYS_CODE }, "UpdateMailNo");

                sqlMapper.CommitTransaction();
                return(ret);
            }
            catch (Exception e)
            {
                sqlMapper.RollbackTransaction();
                var message = new StringBuilder();
                message.Append("更新订单的运单号时,数据库发生错误:\n" + "订单号:" + order.ORDER_NO);
                message.Append(e.Message + e.StackTrace);
                message.ToString().WriteToLog(LogerType.Error);
                return(0);
            }
        }
        async Task <bool> UpdateSite(T_ORDER dbOrder)
        {
            try
            {
                List <SiteDetail> sd         = null;
                List <MQuerySite> lQuerySite = new List <MQuerySite>();
                MQuerySite        site       = null;
                site            = new MQuerySite();
                site.orderid    = dbOrder.ORDER_NO + "-send";
                site.address    = dbOrder.SENDER_PROVINCE + dbOrder.SENDER_CITY + dbOrder.SENDER_COUNTY + dbOrder.SENDER_ADDRESS;
                site.operSource = "OMS";
                if (!lQuerySite.Contains(site))
                {
                    lQuerySite.Add(site);
                }
                site            = new MQuerySite();
                site.orderid    = dbOrder.ORDER_NO + "-rec";
                site.address    = dbOrder.RECEIVER_PROVINCE + dbOrder.RECEIVER_CITY + dbOrder.RECEIVER_COUNTY + dbOrder.RECEIVER_ADDRESS;
                site.operSource = "OMS";
                if (!lQuerySite.Contains(site))
                {
                    lQuerySite.Add(site);
                }
                sd = AliHandler.GetSite(lQuerySite);
                SiteDetail          resultsite = null;
                T_NAVIGATE_DISTANCE distance;
                bool bdistance = false;//是否插入距离表,如果2端距离都没有则不插入
                if (sd != null && sd.Count > 0)
                {
                    distance          = new T_NAVIGATE_DISTANCE();
                    distance.MAIL_NO  = dbOrder.BILL_NO;
                    distance.ORDER_NO = dbOrder.ORDER_NO;
                    //distance.PICKUP_DISTANCE = "0";
                    //distance.SEND_DISTANCE = "0";
                    resultsite = sd.FirstOrDefault(p => p.orderid == dbOrder.ORDER_NO + "-send");
                    if (resultsite != null)
                    {
                        distance.PICKUP_DISTANCE = resultsite.distance;
                        //distance.PICKUP_DISTANCE = resultsite.distance == null ? "0" : resultsite.distance;
                        if (!string.IsNullOrEmpty(resultsite.bizAreaValue))
                        {
                            if (dbOrder.PICKUP_SITE != resultsite.bizAreaValue && !string.IsNullOrEmpty(distance.PICKUP_DISTANCE))//如果是修改订单,网点可能没做修改
                            {
                                bdistance = true;
                            }
                            dbOrder.PICKUP_SITE = resultsite.bizAreaValue;                             //取件网点编号
                            string sitename = await AppService.QuerySiteName(resultsite.bizAreaValue); //dbHelper.mapper.QueryForObject<string>("T_SITE_INFO.GetName", resultsite.bizAreaValue);

                            if (!string.IsNullOrEmpty(sitename))
                            {
                                if (dbOrder.ORDER_STATUS == 10)
                                {
                                    dbOrder.ORDER_STATUS = 20;
                                }
                                dbOrder.PICKUP_SITECODE      = sitename; //名称
                                dbOrder.ASSIGNED_SITE_CODE   = sitename; //名称
                                dbOrder.PUSH_OUTSYS_STATUS   = 1;
                                dbOrder.PUSH_OUTSYS_FAIL_NUM = 0;
                                dbOrder.ASSIGNSITE_TYPE      = 0;
                            }
                        }
                    }
                    resultsite = sd.FirstOrDefault(p => p.orderid == dbOrder.ORDER_NO + "-rec");
                    if (resultsite != null)
                    {
                        distance.SEND_DISTANCE = resultsite.distance;
                        if (!string.IsNullOrEmpty(resultsite.bizAreaValue))
                        {
                            if (dbOrder.SENDTO_SITE != resultsite.bizAreaValue && !string.IsNullOrEmpty(distance.SEND_DISTANCE))//如果是修改订单,网点可能没做修改
                            {
                                bdistance = true;
                            }
                            dbOrder.SENDTO_SITE = resultsite.bizAreaValue;
                            string sitename = await AppService.QuerySiteName(resultsite.bizAreaValue);//dbHelper.mapper.QueryForObject<string>("T_SITE_INFO.GetName", resultsite.bizAreaValue);

                            if (!string.IsNullOrEmpty(sitename))
                            {
                                dbOrder.SENDTO_SITECODE = sitename;//名称
                            }
                        }
                    }

                    int i = await AppService.UpdateSite(dbOrder);//dbHelper.mapper.Update("T_ORDER.UpdateSite", dbOrder);

                    if (bdistance)
                    {
                        await AppService.Add(distance); //dbHelper.mapper.Insert("T_NAVIGATE_DISTANCE.Insert", distance);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
        public async Task QueryOrder([FromBody] object model)
        {
            //获取请求报文
            var requestContent = "";

            if (Request.ContentType == "application/octet-stream")
            {
                var bytePacket = (byte[])model;
                requestContent = Encoding.UTF8.GetString(bytePacket);
            }
            else
            {
                if (model == null)
                {
                    model = "";
                }
                requestContent = model.ToString();
            }
            if (string.IsNullOrWhiteSpace(requestContent))
            {
                var log = $"请求类型是{Request.ContentType}的请求要求报文不允许为空,CancelOrder查询订单操作终止";
                LogWarn($"{log} 日期:{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
                await WriteAsync(log);

                return;
            }
            LogInfo($"查询订单QueryOrder原始请求报文:{requestContent}");

            //解析报文
            var dic = requestContent.UrlFormat();
            var logisticsInterface = dic.ContainsKey("logistics_interface") ? dic["logistics_interface"] : "";
            var dataDigest         = dic.ContainsKey("data_digest") ? dic["data_digest"] : "";

            var requestType = "query";

            //身份验证
            if (!AliHandler.CheckRequest(logisticsInterface, dataDigest))
            {
                var log = AliHandler.ErrDetail(2001, requestType);
                LogError($"身份验证失败,订单数据原始报文:{logisticsInterface}\r\n接收到的签名:{dataDigest}");
                await WriteAsync(log);

                return;
            }

            string error       = "ERROR";
            string logisticID  = "";
            string mailNo      = "";
            string CustomerID  = "";
            string returnOrder = "";

            try
            {
                JObject jo = JObject.Parse(logisticsInterface);
                CustomerID = jo["logisticCompanyID"].ToString();
                logisticID = jo["logisticID"].ToString();
                //Hashtable ht = new Hashtable();
                //ht.Add("OUTSYS_UID", CustomerID);
                //ht.Add("OUTSYS_CODE", logisticID);
                //dbHelper.mapper.QueryForObject<T_ORDER>("T_ORDER.FindByOutSysNo", ht);

                T_ORDER order = await AppService.QueryByOutSysNo(logisticID, CustomerID);

                if (order == null)
                {
                    await WriteAsync(AliHandler.ErrDetail(1002, requestType));

                    return;
                }
                //string StatusCode = FindStatusCode(order.StatusCode);
                if (order.ORDER_STATUS == 30)
                {
                    await WriteAsync(AliHandler.ErrDetail(1003, requestType));

                    return;
                }
                string    StatusCode = AliHandler.FindStatusCode(order.ORDER_STATUS.ToString());
                T_WAYBILL wayBill    = null;
                //mailNo = dbHelper.mapper.QueryForObject<string>("T_ORDER_WAYBILL_MAP.GetBillCode", order.ORDER_NO);
                //if (string.IsNullOrEmpty(order.))
                //wayBill = dbHelper.mapper.QueryForObject<T_WAYBILL>("T_WAYBILL.GetByOrderNo", order.ORDER_NO);
                wayBill = await AppService.QueryWayBillByOrderNo(order.ORDER_NO);

                if (wayBill != null)
                {
                    mailNo = wayBill.BILL_CODE;
                    StringBuilder MywayBill = new StringBuilder();
                    MywayBill.Append("{\"result\":true,\"resultCode\":\"1000\",\"resultInfo\":\"true\",\"reason\":\"\",");
                    MywayBill.Append("\"responseParam\":{\"logisticCompanyID\":\"" + CustomerID);
                    MywayBill.Append("\",\"logisticID\":\"" + logisticID);
                    MywayBill.Append("\",\"businessNetworkNo\":\"" + wayBill.SEND_SITE);
                    MywayBill.Append("\",\"mailNo\":\"" + mailNo);
                    MywayBill.Append("\",\"sender\":{\"companyName\":\"" + wayBill.SENDER_COMPANYNAME);
                    MywayBill.Append("\",\"name\":\"" + wayBill.SEND_MAN + "\",\"postCode\":\"" + wayBill.SENDER_POSTCODE);

                    MywayBill.Append("\",\"phone\":\"" + wayBill.SEND_MAN_PHONE + "\",\"mobile\":\"" + wayBill.SEND_MAN_PHONE + "\",\"province\":\"" + wayBill.SENDER_PROVINCE);
                    MywayBill.Append("\",\"city\":\"" + wayBill.SENDER_CITY + "\",\"county\":\"" + wayBill.SENDER_COUNTY + "\",\"address\":\"" + wayBill.SEND_MAN_ADDRESS);
                    MywayBill.Append("\"},\"receiver\":{\"companyName\":\"" + wayBill.ACCEPT_COMPANYNAME + "\",\"name\":\"" + wayBill.ACCEPT_MAN);
                    MywayBill.Append("\",\"postCode\":\"" + wayBill.ACCEPT_POSTCODE + "\",\"phone\":\"" + wayBill.ACCEPT_MAN_PHONE + "\",\"mobile\":\"" + wayBill.ACCEPT_MAN_MOBILE);
                    MywayBill.Append("\",\"province\":\"" + wayBill.ACCEPT_PROVINCE + "\",\"city\":\"" + wayBill.ACCEPT_CITY + "\",\"county\":\"" + wayBill.ACCEPT_COUNTY);
                    MywayBill.Append("\",\"address\":\"" + wayBill.ACCEPT_MAN_ADDRESS + "\"},\"statusType\":\"" + StatusCode);

                    MywayBill.Append("\",\"cargoName\":\"" + wayBill.GOODS_NAME + "\",\"totalWeight\":" + wayBill.FEE_WEIGHT + ",\"totalVolume\":" + wayBill.CUBE);
                    MywayBill.Append(",\"totalNumber\":" + wayBill.PIECE_NUMBER + ",\"totalPrice\":" + wayBill.TOTAL_PRICE + ",\"transportPrice\":" + wayBill.FREIGHT);
                    MywayBill.Append(",\"weightRate\":" + wayBill.WEIGHT_RATE + ",\"volumeRate\":" + wayBill.VOLUME_RATE + ",\"leastExpenses\":" + wayBill.LEAST_EXPENSES);
                    MywayBill.Append(",\"payType\":\"" + wayBill.OUTSYS_PAYTYPE + "\",\"transportType\":\"" + wayBill.TRANSPORT_TYPE + "\",\"insuranceValue\":" + wayBill.SUPPORTVALUE);
                    MywayBill.Append(",\"insurancePrice\":" + wayBill.INSURANCE + ",\"codType\":\"" + order.COD_TYPE + "\",\"codValue\":" + wayBill.GOODS_PAYMENT);

                    MywayBill.Append(",\"codPrice\":" + wayBill.CODPRICE + ",\"vistReceive\":\"" + order.VISIT_RECEIVE + "\",\"vistReceivePrice\":\"" + order.VISIT_RECEIVEPRICE);
                    MywayBill.Append("\",\"deliveryType\":\"" + order.DELIVERY_TYPE + "\",\"deliveryPrice\":" + wayBill.DELIVERYPRICE + ",\"backSignBill\":\"" + wayBill.BL_RETURN_BILL + "\",\"backSignBillPrice\":" + wayBill.BACKSIGNBILLPRICE);
                    MywayBill.Append(",\"packageService\":\"" + order.PACKAGE_SERVICE + "\",\"packageServicePrice\":" + order.PACKAGE_SERVICEPRICE);
                    MywayBill.Append(",\"waitewaitNotifySend\":\"" + order.WAIT_NOTIFYSEND + "\",\"waitewaitNotifySendPrice\":" + order.WAIT_NOTIFYSENDPRICE);
                    MywayBill.Append(",\"smsNotify\":\"" + order.SMS_NOTIFY + "\",\"smsNotifyPrice\":" + order.SMS_NOTIFYPRICE + ",\"fuelSurcharge\":\"" + order.FUEL_SURCHARGE);
                    MywayBill.Append("\",\"fuelSurchargePrice\":" + order.FUEL_SURCHARGE_PRICE + ",\"materialCost\":\"" + order.MATERIAL_COST + "\",\"materialCostPrice\":" + order.MATERIAL_COSTPRICE);
                    MywayBill.Append(",\"otherPrice\":" + order.OTHER_PRICE + ",\"comments\":\"" + "" + "\",\"remark\":\"" + wayBill.REMARK + "\"}}");

                    returnOrder = MywayBill.ToString();
                }
                else
                {
                    StringBuilder MyOrder = new StringBuilder();
                    MyOrder.Append("{\"result\":true,\"resultCode\":\"1000\",\"resultInfo\":\"成功\",\"reason\":\"\",");
                    MyOrder.Append("\"responseParam\":{\"logisticCompanyID\":\"" + CustomerID);
                    MyOrder.Append("\",\"logisticID\":\"" + logisticID);
                    MyOrder.Append("\",\"businessNetworkNo\":\"" + order.PICKUP_SITECODE);
                    MyOrder.Append("\",\"mailNo\":\"" + mailNo);
                    MyOrder.Append("\",\"sender\":{\"companyName\":\"" + order.SENDER_COMPANYNAME);
                    MyOrder.Append("\",\"name\":\"" + order.SENDER_NAME + "\",\"postCode\":\"" + order.SENDER_POSTCODE);
                    MyOrder.Append("\",\"phone\":\"" + order.SENDER_PHONE + "\",\"mobile\":\"" + order.SENDER_MOBILE + "\",\"province\":\"" + order.SENDER_PROVINCE);
                    MyOrder.Append("\",\"city\":\"" + order.SENDER_CITY + "\",\"county\":\"" + order.SENDER_COUNTY + "\",\"address\":\"" + order.SENDER_ADDRESS);
                    MyOrder.Append("\"},\"receiver\":{\"companyName\":\"" + order.RECEIVER_COMPANYNAME + "\",\"name\":\"" + order.RECEIVER_NAME);
                    MyOrder.Append("\",\"postCode\":\"" + order.RECEIVER_POSTCODE + "\",\"phone\":\"" + order.RECEIVER_PHONE + "\",\"mobile\":\"" + order.RECEIVER_MOBILE);
                    MyOrder.Append("\",\"province\":\"" + order.RECEIVER_PROVINCE + "\",\"city\":\"" + order.RECEIVER_CITY + "\",\"county\":\"" + order.RECEIVER_COUNTY);
                    MyOrder.Append("\",\"address\":\"" + order.RECEIVER_ADDRESS + "\"},\"statusType\":\"" + StatusCode);
                    MyOrder.Append("\",\"cargoName\":\"" + order.CARGO_NAME + "\",\"totalWeight\":" + order.TOTAL_WEIGHT + ",\"totalVolume\":" + order.TOTAL_VOLUME);
                    MyOrder.Append(",\"totalNumber\":" + order.TOTAL_NUMBER + ",\"totalPrice\":" + order.TOTAL_PRICE + ",\"transportPrice\":" + order.TRANSPORT_PRICE);
                    MyOrder.Append(",\"weightRate\":" + order.WEIGHT_RATE + ",\"volumeRate\":" + order.VOLUME_RATE + ",\"leastExpenses\":" + order.LEAST_EXPENSES);
                    MyOrder.Append(",\"payType\":\"" + order.OUTSYS_PAYTYPE + "\",\"transportType\":\"" + order.TRANSPORT_TYPE + "\",\"insuranceValue\":" + order.INSURANCE_VALUE);
                    MyOrder.Append(",\"insurancePrice\":" + order.INSURANCE_PRICE + ",\"codType\":\"" + order.COD_TYPE + "\",\"codValue\":" + order.COD_VALUE);
                    MyOrder.Append(",\"codPrice\":" + order.COD_PRICE + ",\"vistReceive\":\"" + order.VISIT_RECEIVE + "\",\"vistReceivePrice\":\"" + order.VISIT_RECEIVEPRICE);
                    MyOrder.Append("\",\"deliveryType\":\"" + order.DELIVERY_TYPE + "\",\"deliveryPrice\":" + order.DELIVERY_PRICE + ",\"backSignBill\":\"" + order.BACKSIGNBILL + "\",\"backSignBillPrice\":" + order.BACKSIGNBILL_PRICE);
                    MyOrder.Append(",\"packageService\":\"" + order.PACKAGE_SERVICE + "\",\"packageServicePrice\":" + order.PACKAGE_SERVICEPRICE);
                    MyOrder.Append(",\"waitewaitNotifySend\":\"" + order.WAIT_NOTIFYSEND + "\",\"waitewaitNotifySendPrice\":" + order.WAIT_NOTIFYSENDPRICE);
                    MyOrder.Append(",\"smsNotify\":\"" + order.SMS_NOTIFY + "\",\"smsNotifyPrice\":" + order.SMS_NOTIFYPRICE + ",\"fuelSurcharge\":\"" + order.FUEL_SURCHARGE);
                    MyOrder.Append("\",\"fuelSurchargePrice\":" + order.FUEL_SURCHARGE_PRICE + ",\"materialCost\":\"" + order.MATERIAL_COST + "\",\"materialCostPrice\":" + order.MATERIAL_COSTPRICE);
                    MyOrder.Append(",\"otherPrice\":" + order.OTHER_PRICE + ",\"comments\":\"" + "" + "\",\"remark\":\"" + order.REMARK + "\"}}");
                    returnOrder = MyOrder.ToString();
                }
                LogInfo($"{logisticID}订单查询成功,查询订单操作原始报文:{logisticsInterface}");
                await WriteAsync(returnOrder);
            }
            catch
            {
                await WriteAsync(AliHandler.ErrDetail(3001, "query"));

                return;
            }
        }
        public async Task CancelOrder([FromBody] object model)
        {
            //获取请求报文
            var requestContent = "";

            if (Request.ContentType == "application/octet-stream")
            {
                var bytePacket = (byte[])model;
                requestContent = Encoding.UTF8.GetString(bytePacket);
            }
            else
            {
                if (model == null)
                {
                    model = "";
                }
                requestContent = model.ToString();
            }
            if (string.IsNullOrWhiteSpace(requestContent))
            {
                var log = $"请求类型是{Request.ContentType}的请求要求报文不允许为空,CancelOrder撤销订单操作终止";
                LogWarn($"{log} 日期:{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
                await WriteAsync(log);

                return;
            }
            LogInfo($"取消订单CancelOrder原始请求报文:{requestContent}");

            //解析报文
            var dic = requestContent.UrlFormat();
            var logisticsInterface = dic.ContainsKey("logistics_interface") ? dic["logistics_interface"] : "";
            var dataDigest         = dic.ContainsKey("data_digest") ? dic["data_digest"] : "";

            //签名检查
            if (!AliHandler.CheckRequest(logisticsInterface, dataDigest))
            {
                var log = AliHandler.ErrDetail(2001, "sub");
                LogError($"身份验证失败,订单数据原始报文:{logisticsInterface}\r\n接收到的签名:{dataDigest}");
                await WriteAsync(log);

                return;
            }

            string    error      = "ERROR";
            string    logisticID = "";
            Hashtable ht         = null;

            try
            {
                JObject jo         = JObject.Parse(logisticsInterface);
                string  CustomerID = jo["logisticCompanyID"].ToString();
                logisticID = jo["logisticID"].ToString();
                string   remark    = jo["remark"].ToString();
                DateTime dtStart   = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
                long     TimeSta   = long.Parse(jo["gmtCancel"].ToString() + "0000");
                TimeSpan toNow     = new TimeSpan(TimeSta);
                DateTime gmtCancel = DateTime.Parse(dtStart.Add(toNow).ToString());
                //int iCount = dbHelper.mapper.QueryForObject<int>("T_ORDER.GetCountByOutSysNo", logisticID);
                //if (iCount > 0)
                //{

                T_ORDER dbOrder = await AppService.QueryById(logisticID);//dbHelper.mapper.QueryForObject<T_ORDER>("T_ORDER.FindByOrderNo", logisticID);

                if (dbOrder == null)
                {
                    LogInfo($"{logisticID}订单不存在,取消订单操作原始报文:{logisticsInterface}");
                    await WriteAsync(AliHandler.ErrDetail(logisticID, 1002, "cancel"));

                    return;
                }
                decimal iStatus = dbOrder.ORDER_STATUS;
                int     count   = await AppService.QueryCount(dbOrder.BILL_NO); //dbHelper.mapper.QueryForObject<int>("T_WAYBILL.Count", dbOrder.BILL_NO);

                //状态中不存在0
                if (iStatus == 0)
                {
                    LogInfo($"{logisticID}订单状态不存在,取消订单操作原始报文:{logisticsInterface}");
                    await WriteAsync(AliHandler.ErrDetail(logisticID, 1002, "cancel"));

                    return;
                }
                if (iStatus == 30)
                {
                    LogInfo($"{logisticID}此单号已撤销,请勿重复操作,取消订单操作原始报文:{logisticsInterface}");
                    await WriteAsync(AliHandler.ErrDetail(logisticID, 1003, "cancel"));

                    return;
                }
                //10待受理,20已分派 40 已接单 45 接单失败
                if (iStatus != 10 && iStatus != 20 && iStatus != 40 && iStatus != 45 && (iStatus == 70 && count > 0))
                {
                    LogInfo($"{logisticID}此单已确认,无法进行此操作,取消订单操作原始报文:{logisticsInterface}");
                    await WriteAsync(AliHandler.ErrDetail(logisticID, 1001, "cancel"));

                    return;
                }

                var podr = new T_ORDER
                {
                    ORDER_STATUS        = 30,
                    ORDER_CANCEL_TIME   = gmtCancel,
                    ORDER_CANCEL_REMARK = remark,
                    NEED_ADD_RECORD_BOS = 1,
                    OUTSYS_CODE         = logisticID,
                    ORDER_CANCEL_BY     = AppSettings.CreateBy
                };
                await AppService.UpdateOrderByOutCode(podr);//dbHelper.mapper.Update("T_ORDER.UpdateORDER_STATUSByOutCode", ht);

                LogInfo($"{logisticID}订单已经撤销,撤销订单操作原始报文:{logisticsInterface}");
                await WriteAsync(AliHandler.ErrDetail(logisticID, 1000, "cancel"));
            }
            catch (Exception e)
            {
                LogFatal($"{logisticID}订单撤销异常终止,撤销订单操作原始报文:{logisticsInterface}", e.Message, e.StackTrace);
                await WriteAsync(AliHandler.ErrDetail(logisticID, 3001, "cancel"));
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// 更新订单
 /// </summary>
 public Task <int> UpdateOrder(T_ORDER order)
 {
     return(OracleScope.Repository.UpdateAsync <T_ORDER>("T_ORDER.Update", order));
 }