예제 #1
0
        public Order WxPayOrder(string productCode, string userCode, string peopleCount, DateTime dateTime, decimal money, string wxPrepayId, string storeId, string orderCode = "", string couponCode = "")
        {
            IProductInfoService _productInfoService = new ProductInfoService();
            DateTime            now = DateTime.Now;

            IOrderService     _orderService     = new OrderService();
            IUserStoreService _userStoreService = new UserStoreService();


            var   userSotre = _userStoreService.GetUserStorebyUserCode(userCode);
            var   tempOrder = _orderService.GetOrderByCode(orderCode);
            Order order     = new Order();

            if (tempOrder != null && tempOrder.UserCode == userCode)
            {
                order.CreateTime = tempOrder.CreateTime;
                order.OrderCode  = tempOrder.OrderCode;
                order.OrderNO    = tempOrder.OrderNO;
            }
            else
            {
                order.CreateTime = now;
                order.OrderCode  = Guid.NewGuid().ToString();
                order.OrderNO    = WxPayApi.GenerateOutTradeNo().ToString();
                order.CreateTime = now;
            }
            order.Money = money;
            int ss = 0;

            if (int.TryParse(peopleCount, out ss))
            {
                order.Number = ss;
            }
            order.PayTime               = null;
            order.StoreCode             = storeId;
            order.UserCode              = userCode;
            order.ProductCode           = productCode;
            order.ExperienceVoucherCode = couponCode;
            order.AppointmentTime       = dateTime;
            order.WxPrepayId            = wxPrepayId;


            LogHelper.WriteLog("订单编码OrderCode " + order.OrderCode);
            LogHelper.WriteLog("订单号OrderNO " + order.OrderNO);
            if (tempOrder != null && tempOrder.UserCode == userCode)
            {
                _orderService.UpdateOrderbyWxorder(order);
            }
            else
            {
                if (string.IsNullOrEmpty(order.OrderCode))
                {
                    order.OrderCode = Guid.NewGuid().ToString();
                    order.OrderNO   = WxPayApi.GenerateOutTradeNo().ToString();
                    orderCode       = order.OrderCode;
                }
                _orderService.InsertOrder(order);
            }
            return(order);
        }
예제 #2
0
        /// <summary>
        /// 充值
        /// </summary>
        /// <param name="userCode"></param>
        /// <param name="order"></param>
        /// <param name="payType"></param>
        /// <returns></returns>
        public financialStatements getDataRechargeRecord(string userCode, string typeCode, UseWallet useWallet, string storeCode, decimal?ratio, string payType)
        {
            ICouponService       _couponService      = new CouponService();
            IRechargeTypeService rt                  = new RechargeTypeService();
            IProductInfoService  _productInfoService = new ProductInfoService();
            ICouponTypeService   _couponTypeService  = new CouponTypeService();
            IUseWalletService    _useWalletService   = new UseWalletService();
            IUserStoreService    _userStoreService   = new UserStoreService();
            IStoreService        _storeService       = new StoreService();
            IUserInfo            _userService        = new UserInfo();
            var rechargetype = rt.GetRechargeTypeByCode(typeCode);
            var uw           = _useWalletService.GetUseWalletCountMoney(userCode);

            if (string.IsNullOrEmpty(storeCode))
            {
                var us = _userStoreService.GetUserStorebyUserCode(userCode);
                storeCode = us.MembershipCardStore;
            }
            var s = _storeService.GetStore(storeCode);
            var u = _userService.GetUserByCode(userCode);
            financialStatements fs = new financialStatements();

            fs.Code           = Guid.NewGuid().ToString();
            fs.CreateTime     = DateTime.Now;
            fs.UserPhone      = u?.Phone;
            fs.UserCreateTime = u?.CreateTime;
            fs.StoreName      = s?.StoreName;
            fs.ProductionType = "体验服务";
            fs.Cstname        = "普通销售";
            fs.ProductionCode = rechargetype?.RechargeTypeCode;
            fs.ProductionName = rechargetype?.RechargeTypeName;
            fs.Iquantity      = 1;
            fs.Itaxunitprice  = useWallet?.AccountPrincipal;
            fs.Isum           = useWallet?.AccountPrincipal;
            fs.CpersonName    = "业务员";
            fs.PayType        = payType;
            fs.AmountOfIncome = useWallet?.AccountPrincipal;
            fs.DonationAmount = useWallet?.DonationAmount;
            fs.CouponUseCode  = "";
            fs.CouponUseMoney = 0;
            fs.UseWalletMoney = uw?.TotalAmount + useWallet?.AccountPrincipal + useWallet?.DonationAmount;

            if (ratio != null)
            {
                fs.Ratio = Math.Round(100 - Convert.ToDouble(ratio) * 100, 2).ToString() + '%';
            }

            fs.UseWalletMoney1           = fs?.UseWalletMoney;
            fs.UseWalletAccountPrincipal = uw?.AccountPrincipal + useWallet?.AccountPrincipal;

            fs.ProductInfoRate = "0";
            return(fs);
        }