Пример #1
0
        ///// <summary>
        ///// 跟进 退款状态 (退款是否成功)
        ///// </summary>
        ///// <returns></returns>
        public bool FoodUpdateReFundQueueState()
        {
            TransactionModel      tranModel    = new TransactionModel();
            List <FoodGoodsOrder> itemList     = FoodGoodsOrderBLL.SingleModel.GetList($" State = {(int)miniAppFoodOrderState.退款中} and outOrderDate <= (NOW()-interval 17 second) ", 1000, 1) ?? new List <FoodGoodsOrder>();
            List <CityMorders>    orderList    = new List <CityMorders>();
            List <ReFundResult>   outOrderList = new List <ReFundResult>();

            if (itemList.Any())
            {
                orderList = _cityMordersBLL.GetList($" Id in ({string.Join(",", itemList.Select(x => x.OrderId))}) ", 1000, 1) ?? new List <CityMorders>();
                if (orderList.Any())
                {
                    outOrderList = RefundResultBLL.SingleModel.GetList($" transaction_id in ('{string.Join("','", orderList.Select(x => x.trade_no))}') and retype = 1") ?? new List <ReFundResult>();
                    itemList.ForEach(x =>
                    {
                        CityMorders curOrder = orderList.Where(y => y.Id == x.OrderId).FirstOrDefault();
                        if (curOrder != null)
                        {
                            //退款是排程处理,故无法确定何时执行退款,而现阶段退款操作成败与否都会记录在系统内
                            ReFundResult curOutOrder = outOrderList.Where(y => y.transaction_id == curOrder.trade_no).FirstOrDefault();
                            if (curOutOrder != null && curOutOrder.result_code.Equals("SUCCESS"))
                            {
                                x.State = (int)miniAppFoodOrderState.已退款;
                                tranModel.Add(FoodGoodsOrderBLL.SingleModel.BuildUpdateSql(x, "State"));
                            }
                            else if (curOutOrder != null && !curOutOrder.result_code.Equals("SUCCESS"))
                            {
                                x.State = (int)miniAppFoodOrderState.退款失败;
                                tranModel.Add(FoodGoodsOrderBLL.SingleModel.BuildUpdateSql(x, "State"));
                            }
                        }
                    });
                }
            }
            return(ExecuteTransactionDataCorect(tranModel.sqlArray, tranModel.ParameterArray));
        }
Пример #2
0
        /// <summary>
        /// 添加达达订单
        /// </summary>
        /// <param name="rid">权限表ID</param>
        /// <param name="userid">用户ID</param>
        /// <param name="orderid">订单ID</param>
        /// <param name="cityname">订单所在城市名</param>
        /// <param name="price">价格(分)</param>
        /// <param name="receivername">收货人姓名</param>
        /// <param name="receivertel">收货人电话</param>
        /// <param name="address">收货地址</param>
        /// <param name="lat">收货地址纬度</param>
        /// <param name="lnt">收货地址经度</param>
        /// <param name="desc">备注</param>
        /// <param name="ordertype">看枚举TmpType</param>
        /// <returns></returns>
        public string AddDadaOrder(DistributionApiModel model)
        {
            string       msg      = "";
            DadaRelation relation = DadaRelationBLL.SingleModel.GetModelByRid(model.aid);

            if (relation != null)
            {
                DadaMerchant merchant = DadaMerchantBLL.SingleModel.GetModel(relation.merchantid);
                if (merchant != null)
                {
                    DadaCity city = DadaCityBLL.SingleModel.GetModelName(model.cityname);
                    if (city == null)
                    {
                        msg = "物流到不了城市" + model.cityname;
                        return(msg);
                    }

                    DadaShop shop = DadaShopBLL.SingleModel.GetModelByMId(merchant.id);
                    if (shop == null)
                    {
                        msg = "物流到不了城市" + model.cityname;
                        return(msg);
                    }

                    TransactionModel tran      = new TransactionModel();
                    string           timestamp = _dadaapi.GetTimeStamp();
                    string           callback  = _dadaapi._ordercallback;
                    string           order_id  = model.userid + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string           shopno    = shop.origin_shop_id;
                    float            buyprice  = model.buyprice / 100.0f;

                    DadaOrder data = new DadaOrder(order_id, city.cityCode, shopno, buyprice, model.accepterName, model.accepterTelePhone, model.address, model.lat, model.lnt, model.remark, timestamp, callback);
                    //data.id = Convert.ToInt32(base.Add(data));
                    tran.Add(base.BuildAddSql(data));

                    DadaOrderRelation orderrelation = new DadaOrderRelation();
                    orderrelation.dataid        = model.aid;
                    orderrelation.orderid       = model.orderid;
                    orderrelation.ordertype     = model.temptype;
                    orderrelation.uniqueorderno = order_id;

                    //orderrelation.id = Convert.ToInt32(DadaOrderRelationBLL.SingleModel.Add(orderrelation));
                    tran.Add(DadaOrderRelationBLL.SingleModel.BuildAddSql(orderrelation));

                    if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray))
                    {
                        msg = "添加达达物流出错";
                    }
                }
                else
                {
                    msg = "找不到商户号";
                }
            }
            else
            {
                msg = "找不到管理表";
            }

            return(msg);
        }
Пример #3
0
        /// <summary>
        /// 推单
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="aid"></param>
        /// <param name="tmptype"></param>
        /// <param name="getway"></param>
        /// <param name="tran"></param>
        /// <param name="getsql"></param>
        /// <param name="storeid"></param>
        /// <returns></returns>
        public string UpdatePeiSongOrder(int orderid, int aid, int tmptype, int getway, ref TransactionModel tran, bool getsql, int storeid = 0)
        {
            switch (getway)
            {
            case (int)miniAppOrderGetWay.达达配送:
                return(new DadaOrderBLL().GetDadaOrderUpdateSql(orderid, aid, tmptype, ref tran, getsql));

            case (int)miniAppOrderGetWay.蜂鸟配送:
                return(FNOrderBLL.SingleModel.GetFNOrderUpdateSql(orderid, aid, tmptype, ref tran, getsql));

            case (int)miniAppOrderGetWay.快跑者配送:
                return(KPZOrderBLL.SingleModel.GetKPZOrderUpdateSql(orderid, aid, storeid, ref tran, getsql));

            case (int)miniAppOrderGetWay.UU配送:
                return(UUOrderBLL.SingleModel.GetUUOrderUpdateSql(orderid, aid, storeid, ref tran, getsql));
            }

            return("");
        }
Пример #4
0
        /// <summary>
        /// 拼团退款
        /// </summary>
        /// <param name="item"></param>
        /// <param name="type">0:拼团失败退款,1:店主手动退款</param>
        /// <returns></returns>
        public bool GroupReFundQueue(GroupUser item, ref string msg, int type = 0)
        {
            //0:微信支付,1:储值卡支付
            int paytype = item.PayType;

            TransactionModel tranmodel = new TransactionModel();
            Groups           csg       = GroupsBLL.SingleModel.GetModel(item.GroupId);

            if (csg == null)
            {
                msg        = "小程序拼团商品不存在啦=" + item.GroupId;
                item.State = (int)MiniappPayState.已失效;
                GroupUserBLL.SingleModel.Update(item, "State");
                return(false);
            }
            GroupSponsor gsinfo = GroupSponsorBLL.SingleModel.GetModel(item.GroupSponsorId);

            if (gsinfo == null && item.IsGroup == 1)
            {
                msg        = "小程序拼团团购不存在啦=" + item.GroupSponsorId;
                item.State = (int)MiniappPayState.已失效;
                GroupUserBLL.SingleModel.Update(item, "State");
                return(false);
            }

            if (item.BuyPrice <= 0)
            {
                msg = "xxxxxxxxxxxxx小程序拼团价格为0不需要退款=" + item.Id;
                return(false);
            }

            if (item.PayState == (int)MiniappPayState.已退款)
            {
                msg = "xxxxxxxxxxxxx小程序拼团状态有误,不能退款=" + item.Id + ",paystate=" + item.PayState + "," + (int)MiniappPayState.已退款;
                return(false);
            }

            item.State = (int)MiniappPayState.已退款;
            //更新用户订单状态
            tranmodel.Add($"update GroupUser set State={item.State} where id={item.Id}");

            //判断是否是微信支付
            if (paytype == 0)
            {
                CityMorders order = _cityMordersBLL.GetModel(item.OrderId);
                if (order == null)
                {
                    msg        = "xxxxxxxxxxxxxxxxxx小程序拼团退款查不到支付订单 ID=" + item.Id;
                    item.State = (int)MiniappPayState.已失效;
                    GroupUserBLL.SingleModel.Update(item, "State");
                    return(false);
                }

                //插入退款队列
                ReFundQueue reModel = new ReFundQueue();
                reModel.minisnsId = -5;
                reModel.money     = item.BuyPrice;
                reModel.orderid   = item.OrderId;
                reModel.traid     = order.trade_no;
                reModel.addtime   = DateTime.Now;
                reModel.note      = "小程序拼团退款";
                reModel.retype    = 1;
                tranmodel.Add(base.BuildAddSql(reModel));
            }
            else if (paytype == 1)
            {
                //储值卡退款
                tranmodel.Add(SaveMoneySetUserBLL.SingleModel.GetCommandCarPriceSql(item.AppId, item.ObtainUserId, item.BuyPrice, 1, item.OrderId, item.OrderNo).ToArray());
                if (tranmodel.sqlArray.Length <= 0)
                {
                    msg = "xxxxxxxxxxxxxxxxxx拼团储值卡退款失败,ID=" + item.Id;
                    return(false);
                }
            }

            //是店主手动退款不加库存 --统一,只要是退款就加库存
            //if (type == 0)
            {
                if (gsinfo.State == 2 && item.IsGroup == 1)
                {
                    msg = "小程序团购成功,不能退款=" + item.GroupSponsorId;
                    return(false);
                }

                //退款成功,更新剩余数量
                tranmodel.Add($"update groups set RemainNum ={(csg.RemainNum + item.BuyNum)} where id={csg.Id}");
                //LogHelper.WriteInfo(GetType(), $"修改拼团失败库存:update groups set RemainNum ={(csg.RemainNum + item.BuyNum)} where id={csg.Id}");
            }

            if (tranmodel.sqlArray.Length <= 0)
            {
                msg = "xxxxxxxxxxxxxxxxxx拼团退款失败,ID=" + item.Id;
                return(false);
            }

            if (!ExecuteTransactionDataCorect(tranmodel.sqlArray, tranmodel.ParameterArray))
            {
                msg = "xxxxxxxxxxxxxxxxxx拼团退款事务执行失败,ID=" + item.Id + "sql:" + string.Join(";", tranmodel.sqlArray);
                return(false);
            }

            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(item.AppId);

            if (xcx == null)
            {
                log4net.LogHelper.WriteError(GetType(), new Exception($"发送模板消息,参数不足,XcxAppAccountRelation_null:appId = {item.AppId}"));
                return(true);
            }

            //发给用户发货通知
            object groupData = TemplateMsg_Miniapp.GroupGetTemplateMessageData("商家操作退款", item, SendTemplateMessageTypeEnum.拼团基础版订单退款通知);

            TemplateMsg_Miniapp.SendTemplateMessage(item.ObtainUserId, SendTemplateMessageTypeEnum.拼团基础版订单退款通知, xcx.Type, groupData);
            msg = "xxxxxxxxxxxxxxxxxx拼团退款成功,ID=" + item.Id;
            return(true);
        }
Пример #5
0
        /// <summary>
        /// 砍价退款(照搬后台的)
        /// </summary>
        /// <param name="bargainUser"></param>
        /// <param name="bargain"></param>
        /// <param name="appId"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool BargainReFundQueue(BargainUser bargainUser, Bargain bargain, string appId, out string msg)
        {
            bargainUser.State        = 2;
            bargainUser.outOrderDate = DateTime.Now;

            if (bargainUser.PayType == (int)miniAppBuyMode.储值支付)
            {
                bargainUser.refundFee = bargainUser.CurrentPrice + bargain.GoodsFreight;
                bargainUser.State     = 3;
                SaveMoneySetUser saveMoneyUser = SaveMoneySetUserBLL.SingleModel.getModelByUserId(appId, bargainUser.UserId);
                TransactionModel tran          = new TransactionModel();
                tran.Add(SaveMoneySetUserLogBLL.SingleModel.BuildAddSql(new SaveMoneySetUserLog()
                {
                    AppId          = appId,
                    UserId         = bargainUser.UserId,
                    MoneySetUserId = saveMoneyUser.Id,
                    Type           = 1,
                    BeforeMoney    = saveMoneyUser.AccountMoney,
                    AfterMoney     = saveMoneyUser.AccountMoney + bargainUser.refundFee,
                    ChangeMoney    = bargainUser.refundFee,
                    ChangeNote     = $"小程序砍价购买商品[{bargainUser.BName}]退款,订单号:{bargainUser.OrderId} ",
                    CreateDate     = DateTime.Now,
                    State          = 1
                }));

                tran.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney + {bargainUser.refundFee} where id =  {saveMoneyUser.Id} ; ");

                string updateBargainUser = BargainUserBLL.SingleModel.BuildUpdateSql(bargainUser, "State,outOrderDate,refundFee");

                tran.Add(updateBargainUser);

                bool isok = BargainBLL.SingleModel.ExecuteTransactionDataCorect(tran.sqlArray);
                if (isok)
                {
                    object orderData = TemplateMsg_Miniapp.BargainGetTemplateMessageData(bargainUser, SendTemplateMessageTypeEnum.价订单退款通知, "商家操作退款");
                    TemplateMsg_Miniapp.SendTemplateMessage(bargainUser, SendTemplateMessageTypeEnum.价订单退款通知, orderData);
                    msg = "退款成功,请查看账户余额!";
                }
                else
                {
                    msg = "退款异常!";//返回订单信息
                }
                return(isok);
            }
            else
            {
                bool isok = false;

                CityMorders order = _cityMordersBLL.GetModel(bargainUser.CityMordersId);
                if (order == null)
                {
                    msg = "订单信息有误!";
                    return(isok);
                }
                bargainUser.refundFee = bargainUser.CurrentPrice + bargain.GoodsFreight;
                if (BargainUserBLL.SingleModel.Update(bargainUser, "State,outOrderDate,refundFee"))
                {
                    ReFundQueue reModel = new ReFundQueue
                    {
                        minisnsId = -5,
                        money     = bargainUser.refundFee,
                        orderid   = order.Id,
                        traid     = order.trade_no,
                        addtime   = DateTime.Now,
                        note      = "小程序砍价订单退款",
                        retype    = 1
                    };
                    try
                    {
                        int funid = Convert.ToInt32(base.Add(reModel));
                        if (funid > 0)
                        {
                            object orderData = TemplateMsg_Miniapp.BargainGetTemplateMessageData(bargainUser, SendTemplateMessageTypeEnum.价订单退款通知, "商家操作退款");
                            TemplateMsg_Miniapp.SendTemplateMessage(bargainUser, SendTemplateMessageTypeEnum.价订单退款通知, orderData);
                            isok = true;
                            msg  = "操作成功,已提交退款申请!";
                            return(isok);
                        }
                        else
                        {
                            isok = false;
                            msg  = "退款异常插入队列小于0!";
                            return(isok);
                        }
                    }
                    catch (Exception ex)
                    {
                        log4net.LogHelper.WriteInfo(GetType(), $"{ex.Message} xxxxxxxxxxxxxxxx小程序砍价退款订单插入队列失败 ID={order.Id}");
                        isok = false;
                        msg  = "退款异常(插入队列失败)!";
                        return(isok);
                    }
                }
                else
                {
                    isok = false;
                    msg  = "退款异常!";
                    return(isok);
                }
            }
        }
Пример #6
0
        /// <summary>
        ///  订单退款
        /// </summary>
        /// <param name="item"></param>
        /// <param name="oldState"></param>
        /// <param name="BuyMode">默认微信支付</param>
        /// <param name="isPartOut">是否部分退款</param>
        /// <returns></returns>
        public bool EntReFundQueue(EntGoodsOrder item, int oldState, int BuyMode = (int)miniAppBuyMode.微信支付, int?newState = null, bool isPartOut = false)
        {
            //重新加回库存
            if (EntGoodsOrderBLL.SingleModel.updateStock(item, oldState))
            {
                int money = isPartOut ? item.refundFee : item.BuyPrice;//兼容多版本,目前只有专业版订单有部分退款
                item.refundFee = money;
                if (BuyMode == (int)miniAppBuyMode.微信支付)
                {
                    try
                    {
                        item.outOrderDate = DateTime.Now;
                        if (item.BuyPrice == 0)  //金额为0时,回滚库存后,默认退款成功
                        {
                            item.State = (int)MiniAppEntOrderState.退款成功;
                        }
                        else
                        {
                            CityMorders order = _cityMordersBLL.GetModel(item.OrderId);
                            item.State = (int)MiniAppEntOrderState.退款中;
                            if (newState.HasValue)
                            {
                                item.State = newState.Value;
                            }
                            if (order == null)
                            {
                                item.State = (int)MiniAppEntOrderState.退款失败;
                                EntGoodsOrderBLL.SingleModel.Update(item, "State,outOrderDate,Remark,refundFee");
                                return(false);
                            }
                            //微信支付
                            ReFundQueue reModel = new ReFundQueue
                            {
                                minisnsId = -5,
                                money     = item.refundFee,
                                orderid   = order.Id,
                                traid     = order.trade_no,
                                addtime   = DateTime.Now,
                                note      = "小程序行业版退款",
                                retype    = 1
                            };
                            base.Add(reModel);
                        }
                        bool isSuccess = EntGoodsOrderBLL.SingleModel.Update(item, "State,outOrderDate,Remark,refundFee");
                        if (isSuccess)
                        {
                            //发给用户退款通知
                            object orderData = TemplateMsg_Miniapp.EnterpriseGetTemplateMessageData(item, SendTemplateMessageTypeEnum.专业版订单退款通知, "商家操作退款");
                            TemplateMsg_Miniapp.SendTemplateMessage(item.UserId, SendTemplateMessageTypeEnum.专业版订单退款通知, TmpType.小程序专业模板, orderData);
                        }
                    }
                    catch (Exception ex)
                    {
                        log4net.LogHelper.WriteInfo(GetType(), $"{ex.Message} xxxxxxxxxxxxxxxx小程序餐饮退款订单插入队列失败 ID={item.Id}");
                    }
                }
                else
                {
                    XcxAppAccountRelation r = XcxAppAccountRelationBLL.SingleModel.GetModel(item.aId);
                    if (r == null)
                    {
                        return(false);
                    }

                    SaveMoneySetUser saveMoneyUser = SaveMoneySetUserBLL.SingleModel.getModelByUserId(r.AppId, item.UserId);
                    TransactionModel tran          = new TransactionModel();
                    tran.Add(SaveMoneySetUserLogBLL.SingleModel.BuildAddSql(new SaveMoneySetUserLog()
                    {
                        AppId          = r.AppId,
                        UserId         = item.UserId,
                        MoneySetUserId = saveMoneyUser.Id,
                        Type           = 1,
                        BeforeMoney    = saveMoneyUser.AccountMoney,
                        AfterMoney     = saveMoneyUser.AccountMoney + item.refundFee,
                        ChangeMoney    = item.refundFee,
                        ChangeNote     = $"专业版购买商品退款,订单号:{item.OrderNum} ",
                        CreateDate     = DateTime.Now,
                        State          = 1
                    }));

                    item.State = (int)MiniAppEntOrderState.退款成功;
                    if (newState.HasValue)
                    {
                        item.State = newState.Value;
                    }
                    tran.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney + {item.refundFee} where id =  {saveMoneyUser.Id} ; ");
                    tran.Add($" update EntGoodsOrder set State = {item.State },outOrderDate = '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}',Remark = @Remark where Id = {item.Id} and state <> {item.State} ; ",
                             new MySqlParameter[] { new MySqlParameter("@Remark", item.Remark) });//防止重复退款

                    //记录订单储值支付退款日志
                    tran.Add(EntGoodsOrderLogBLL.SingleModel.BuildAddSql(new EntGoodsOrderLog()
                    {
                        GoodsOrderId = item.Id, UserId = item.UserId, LogInfo = $" 储值支付订单退款成功:{item.refundFee * 0.01} 元 ", CreateDate = DateTime.Now
                    }));
                    bool isSuccess = ExecuteTransaction(tran.sqlArray, tran.ParameterArray);

                    if (isSuccess)
                    {
                        //发给用户退款通知
                        object orderData = TemplateMsg_Miniapp.EnterpriseGetTemplateMessageData(item, SendTemplateMessageTypeEnum.专业版订单退款通知, "商家操作退款");
                        TemplateMsg_Miniapp.SendTemplateMessage(item.UserId, SendTemplateMessageTypeEnum.专业版订单退款通知, TmpType.小程序专业模板, orderData);
                    }
                    return(isSuccess);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
Пример #7
0
        /// <summary>
        /// 足浴版退款
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="orderInfo"></param>
        /// <returns></returns>
        public bool ZYReFundQueue(string appId, EntGoodsOrder orderInfo, ServiceTime serviceTime)
        {
            bool result = false;

            if (orderInfo == null || orderInfo.Id <= 0)
            {
                return(result);
            }
            orderInfo.outOrderDate = DateTime.Now;
            if (orderInfo.BuyMode == (int)miniAppBuyMode.储值支付)
            {
                var saveMoneyUser = new SaveMoneySetUser();
                saveMoneyUser = SaveMoneySetUserBLL.SingleModel.getModelByUserId(appId, orderInfo.UserId);
                if (saveMoneyUser == null || saveMoneyUser.Id <= 0)
                {
                    return(result);
                }

                TransactionModel tran = new TransactionModel();
                tran.Add(SaveMoneySetUserLogBLL.SingleModel.BuildAddSql(new SaveMoneySetUserLog()
                {
                    AppId          = saveMoneyUser.AppId,
                    UserId         = orderInfo.UserId,
                    MoneySetUserId = saveMoneyUser.Id,
                    Type           = 1,
                    BeforeMoney    = saveMoneyUser.AccountMoney,
                    AfterMoney     = saveMoneyUser.AccountMoney + orderInfo.BuyPrice,
                    ChangeMoney    = orderInfo.BuyPrice,
                    ChangeNote     = $" 购买商品,订单号:{orderInfo.OrderNum} ",
                    CreateDate     = DateTime.Now,
                    State          = 1
                }));
                saveMoneyUser.AccountMoney += orderInfo.BuyPrice;
                tran.Add($" update SaveMoneySetUser set AccountMoney = AccountMoney + {orderInfo.BuyPrice} where id =  {saveMoneyUser.Id} ; ");
                tran.Add($" update EntGoodsOrder set state = {(int)MiniAppEntOrderState.退款成功 },outOrderDate = '{orderInfo.outOrderDate.ToString("yyyy-MM-dd HH:mm:ss")}',Remark = @Remark where Id = {orderInfo.Id} and state <> {(int)MiniAppEntOrderState.退款成功 } ; ", new MySqlParameter[] { new MySqlParameter("@Remark", orderInfo.Remark) });//防止重复退款
                if (serviceTime != null)
                {
                    tran.Add($"update servicetime set time='{serviceTime.time}' where id={serviceTime.Id}");//取消已预订的技师服务时间
                }
                //记录订单退款日志
                tran.Add(EntGoodsOrderLogBLL.SingleModel.BuildAddSql(new EntGoodsOrderLog()
                {
                    GoodsOrderId = orderInfo.Id, UserId = orderInfo.UserId, LogInfo = $" 订单储值支付,退款成功:{orderInfo.BuyPrice * 0.01} 元 ", CreateDate = DateTime.Now
                }));
                result = ExecuteTransaction(tran.sqlArray, tran.ParameterArray);
                if (result)
                {
                    object objData = TemplateMsg_Miniapp.FootbathGetTemplateMessageData(orderInfo, SendTemplateMessageTypeEnum.足浴退款通知);
                    TemplateMsg_Miniapp.SendTemplateMessage(orderInfo.UserId, SendTemplateMessageTypeEnum.足浴退款通知, TmpType.小程序足浴模板, objData);
                }
                return(result);
            }

            if (orderInfo.BuyMode == (int)miniAppBuyMode.微信支付)
            {
                CityMorders order = new CityMordersBLL().GetModel(orderInfo.OrderId);
                orderInfo.State = (int)MiniAppEntOrderState.退款中;

                if (order == null)
                {
                    orderInfo.State = (int)MiniAppEntOrderState.退款失败;
                    EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State,outOrderDate,Remark");
                    return(result);
                }

                //微信支付
                ReFundQueue reModel = new ReFundQueue
                {
                    minisnsId = -5,
                    money     = orderInfo.BuyPrice,
                    orderid   = order.Id,
                    traid     = order.trade_no,
                    addtime   = DateTime.Now,
                    note      = "小程序足浴版退款",
                    retype    = 1
                };
                try
                {
                    base.Add(reModel);
                    result = EntGoodsOrderBLL.SingleModel.Update(orderInfo, "State,outOrderDate");
                    return(result);
                }
                catch (Exception ex)
                {
                    log4net.LogHelper.WriteInfo(GetType(), $"{ex.Message} xxxxxxxxxxxxxxxx小程序足浴退款订单插入队列失败 ID={orderInfo.Id}");
                }
            }
            return(result);
        }
Пример #8
0
        /// <summary>
        /// 生成蜂鸟物流订单
        /// </summary>
        /// <param name="rid">权限表ID</param>
        /// <param name="userinfo">用户信息</param>
        /// <param name="orderid">订单ID</param>
        /// <param name="goodcars">购物车</param>
        /// <param name="price">订单价格</param>
        /// <param name="receviename">收货人姓名</param>
        /// <param name="receviephone">收货人电话</param>
        /// <param name="address">收货人地址</param>
        /// <param name="lat">纬度</param>
        /// <param name="lnt">经度</param>
        /// <param name="ordertype">看枚举TmpType</param>
        /// <returns></returns>
        public string AddFNOrder(List <elegood> fngoods, DistributionApiModel model)
        {
            string          msg      = "";
            FNStoreRelation relation = FNStoreRelationBLL.SingleModel.GetModelByRid(model.aid);

            if (relation != null)
            {
                msg = "请先配置蜂鸟门店";
                return(msg);
            }
            FNStore fnstore = FNStoreBLL.SingleModel.GetModel(relation.fnstoreid);

            if (fnstore != null)
            {
                msg = "没有找到蜂鸟门店信息";
                return(msg);
            }
            if (fngoods == null || fngoods.Count <= 0)
            {
                msg = "商品信息不能为空";
                return(msg);
            }

            TransactionModel tran      = new TransactionModel();
            long             timestamp = Convert.ToInt64(FNApi.SingleModel.GetTimeStamp());
            string           callback  = FNApi._callbackurl;
            string           orderno   = model.userid + DateTime.Now.ToString("yyyyMMddHHmmss");
            string           storecode = fnstore.chain_store_code;
            float            buyprice  = model.buyprice / 100.0f;
            int goodcount = 0;

            //收货人信息
            FNReceiverInfo reciverifo = new FNReceiverInfo()
            {
                receiver_name          = model.accepterName,
                receiver_primary_phone = model.accepterTelePhone,
                receiver_address       = model.address,
                receiver_longitude     = model.lnt,
                receiver_latitude      = model.lat,
            };

            //门店信息
            FNStoreInfo storeinfo = new FNStoreInfo()
            {
                transport_name      = fnstore.chain_store_name,
                transport_address   = fnstore.address,
                transport_longitude = Convert.ToDouble(fnstore.longitude),
                transport_latitude  = Convert.ToDouble(fnstore.latitude),
                transport_tel       = fnstore.contact_phone,
            };

            //生成订单实体类对象
            FNOrder data = new FNOrder(storecode, goodcount, callback, buyprice, timestamp, buyprice, orderno, model.remark, fngoods, reciverifo, storeinfo);

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

            //订单与系统订单关联
            FNOrderRelation orderrelation = new FNOrderRelation();

            orderrelation.dataid        = model.aid;
            orderrelation.orderid       = model.orderid;
            orderrelation.ordertype     = model.temptype;
            orderrelation.uniqueorderno = orderno;

            tran.Add(FNOrderRelationBLL.SingleModel.BuildAddSql(orderrelation));

            if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray))
            {
                msg = "添加蜂鸟物流出错";
            }
            return(msg);
        }
Пример #9
0
        /// <summary>
        /// 普通用户开通体验版
        /// </summary>
        /// <param name="agentInfo"></param>
        /// <param name="tIds"></param>
        /// <param name="userAccount"></param>
        /// <param name="erroMsg"></param>
        /// <param name="dayLength"></param>
        /// <returns></returns>
        public bool OpenExperience(string tIds, Account userAccount, ref string erroMsg, int dayLength = 3)
        {
            TransactionModel tranModel = new TransactionModel();

            //判断要开通的模板是否还没体验过
            bool canOpen = IsOpenExperience(tIds, userAccount.Id.ToString());

            if (canOpen)
            {
                erroMsg = "模板已开通过,请刷新重试";
                return(false);
            }

            List <XcxTemplate> xcxList = XcxTemplateBLL.SingleModel.GetListByIds(tIds);

            //添加模板记录
            foreach (XcxTemplate xcx in xcxList)
            {
                AgentdepositLog agentLog = new AgentdepositLog();
                agentLog.agentid       = 0;
                agentLog.addtime       = DateTime.Now;
                agentLog.templateCount = 1;
                agentLog.customerid    = userAccount.Id.ToString();
                agentLog.tid           = xcx.Id;
                agentLog.type          = 2;
                agentLog.templateCount = 1;
                agentLog.costdetail    = $"开通体验{xcx.TName}模板";
                tranModel.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(agentLog));

                XcxAppAccountRelation xcxappaccountrelation = new XcxAppAccountRelation()
                {
                    TId          = xcx.Id,
                    AccountId    = userAccount.Id,
                    AddTime      = DateTime.Now,
                    agentId      = 0,
                    Url          = xcx.Link,
                    price        = xcx.Price,
                    TimeLength   = xcx.year,
                    outtime      = DateTime.Now.AddDays(dayLength),
                    SCount       = xcx.SCount,
                    IsExperience = true,
                };
                xcxappaccountrelation.Id = Convert.ToInt32(base.Add(xcxappaccountrelation));

                if (xcx.Type == (int)TmpType.小程序多门店模板)
                {
                    tranModel.Add(FootBathBLL.SingleModel.GetAddFootbathSQL(xcxappaccountrelation.AccountId, xcx.SCount - 1, xcxappaccountrelation.Id, xcxappaccountrelation.outtime).ToArray());
                }
            }

            //执行事务
            bool success = false;

            try
            {
                success = base.ExecuteTransactionDataCorect(tranModel.sqlArray, tranModel.ParameterArray);
            }
            catch (Exception ex)
            {
                erroMsg = ex.Message;
            }
            return(success);
        }