Ejemplo n.º 1
0
        /// <summary>
        /// 生成UU配送订单
        /// </summary>
        /// <returns></returns>
        public string AddUUOrder(DistributionApiModel model)
        {
            string             msg = "";
            UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(model.aid, model.storeid, 0);

            if (customerRelation == null)
            {
                msg = "请先配置UU配送";
                return(msg);
            }
            UUOrderFee feeResult = GetUUFee(model.storeid, model.aid, model.address, ref msg);

            if (msg.Length > 0)
            {
                return(msg);
            }
            string orderNum  = CommonCore.GetOrderNumByUserId(model.userid.ToString());
            string appid     = UUApi._appid;
            string timestamp = UUApi.GetTimestamp();
            //店铺信息
            ShopInfo shopInfo = GetStoreAddressPoint(customerRelation.AId, customerRelation.StoreId, model.temptype);

            //生成订单实体类对象
            UUOrder data = new UUOrder(appid, timestamp, customerRelation.OpenId, feeResult.price_token, feeResult.total_money, feeResult.need_paymoney, model.accepterName, model.accepterTelePhone, model.remark, UUApi._notisUrl, customerRelation.AId, customerRelation.StoreId, model.temptype, model.ordertype, model.orderid, orderNum);

            TransactionModel tran = new TransactionModel();

            tran.Add(base.BuildAddSql(data));

            if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray))
            {
                msg = "添加UU配送订单出错";
            }
            return(msg);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取UU配送运费
        /// </summary>
        /// <param name="storeId"></param>
        /// <param name="aid"></param>
        /// <param name="lat"></param>
        /// <param name="lnt"></param>
        /// <param name="orderPrice"></param>
        /// <returns></returns>
        public UUOrderFee GetUUFee(int storeId, int aid, string toAddress, ref string msg)
        {
            msg = "获取运费出错";
            UUOrderFee         feeResult        = new UUOrderFee();
            UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(aid, storeId, 0);

            if (customerRelation == null)
            {
                msg = "UU配送:未设置UU配置";
                return(feeResult);
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                msg = "UU配送:权限模板不存在";
                return(feeResult);
            }

            XcxTemplate xcxtemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxtemplate == null)
            {
                msg = "UU配送:小程序模板不存在";
                return(feeResult);
            }

            //店铺信息
            ShopInfo shopinfo = GetStoreAddressPoint(aid, storeId, xcxtemplate.Type);

            UUGetPriceResult result = UUApi.GetOrderPrice(customerRelation.OpenId, shopinfo.ShopAddress, "", toAddress, "", shopinfo.CityName, shopinfo.CountyName);

            if (result == null)
            {
                LogHelper.WriteInfo(this.GetType(), "UU配送:返回结果为null,");
                return(feeResult);
            }
            if (result.return_code != "ok")
            {
                LogHelper.WriteInfo(this.GetType(), $"UU配送配送:请求参数,aid【{aid}】storeid【{storeId}】" + JsonConvert.SerializeObject(result));
                msg = result.return_msg;
                return(feeResult);
            }
            else
            {
                decimal maxFee = Math.Max(Convert.ToDecimal(result.total_money), Convert.ToDecimal(result.need_paymoney));
                int     fee    = Convert.ToInt32(maxFee * 100);
                feeResult.Fee           = fee;
                feeResult.price_token   = result.price_token;
                feeResult.total_money   = result.total_money;
                feeResult.need_paymoney = result.need_paymoney;
                msg = "";
                return(feeResult);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// UU配送推单
        /// </summary>
        /// <param name="orderId">小程序订单表ID</param>
        /// <param name="rid"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public string GetUUOrderUpdateSql(int orderId, int aid, int storeId, ref TransactionModel tran, bool getTranSql = false)
        {
            UUOrder order = GetModelByOrerId(aid, storeId, orderId);

            if (order == null)
            {
                return("UU配送:订单不存在(推单)");
            }
            UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(aid, storeId, 0);

            if (customerRelation == null)
            {
                return("UU配送:未设置UU配置(推单)");
            }

            UUBaseResult result = UUApi.AddOrder(order);

            if (result == null)
            {
                return("UU配送:推送订单接口异常(推单)");
            }

            if (result.return_code == "ok")
            {
                order.State = (int)UUOrderEnum.单成功;
                if (result == null || string.IsNullOrEmpty(result.ordercode))
                {
                    LogHelper.WriteInfo(this.GetType(), "UU配送:推送订单接口返回值异常(推单)" + JsonConvert.SerializeObject(result));
                    return("UU配送:推送订单接口返回值异常(推单)");
                }
                order.order_code = result.ordercode;
                if (getTranSql)
                {
                    return(base.ExecuteNonQuery($"update UUOrder set state={order.State},order_code='{order.order_code}' where id={order.Id}") > 0 ? "" : "UU配送:修改UU订单状态出错(推单)");
                }
                else
                {
                    tran.Add($"update UUOrder set state={order.State},order_code='{order.order_code}' where id={order.Id}");
                }

                return("");
            }

            return(result.return_msg);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="storeId"></param>
        /// <param name="orderId"></param>
        /// <param name="reason"></param>
        /// <returns></returns>
        public bool CancelOrder(int aid, int storeId, int orderId, string reason = "")
        {
            bool    success = false;
            UUOrder model   = GetModelByOrerId(aid, storeId, orderId);

            if (model == null)
            {
                LogHelper.WriteInfo(this.GetType(), $"UU配送:没有找到快跑者订单数据_{aid}_{storeId}_{orderId}(取消订单)");
                return(success);
            }
            UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(aid, storeId, 0);

            if (customerRelation == null)
            {
                LogHelper.WriteInfo(this.GetType(), $"UU配送:无效UU配置{aid}_{storeId}_{orderId}(取消订单)");
                return(success);
            }

            if (!(model.State == (int)UUOrderEnum.单成功 || model.State == (int)UUOrderEnum.已到达 || model.State == (int)UUOrderEnum.跑男抢单))
            {
                LogHelper.WriteInfo(this.GetType(), $"UU配送:取件前才能取消_{aid}_{storeId}_{orderId}(取消订单)");
                return(success);
            }

            UUBaseResult result = UUApi.CanecelOrder(model.openid, model.order_code, reason);

            if (result == null || result.return_code != "ok")
            {
                LogHelper.WriteInfo(this.GetType(), $"UU配送:接口返回异常(取消订单)_{model.order_code}_{customerRelation.Id}" + (result != null ? result.return_msg : ""));
            }
            else
            {
                model.State = (int)UUOrderEnum.订单取消中;
                success     = base.Update(model, "State");
                if (!success)
                {
                    LogHelper.WriteInfo(this.GetType(), $"UU配送:更新系统订单状态失败(取消订单)_{model.Id}");
                }
            }
            return(success);
        }