Beispiel #1
0
        public IHttpActionResult GetUseWalletInfoByUserCode(string userCode)
        {
            LogHelper.WriteLog("GetUseWalletInfoByUserCode userCode" + userCode);

            SimpleResult           result   = new SimpleResult();
            IUseWalletService      _service = new UseWalletService();
            ITopupOrderServrce     tos      = new TopupOrderServrce();
            IRechargeRecordService _RechargeRecordService = new RechargeRecordService();
            IStoreService          _Storeservice          = new StoreService();
            IUserStoreService      _userStoreService      = new UserStoreService();

            try
            {
                if (UserAuthorization)
                {
                    //查看没有给微信支付核对的订单继续核对
                    var topupOrder = tos.GetTopupOrderbyuserCode(userCode);
                    var userSotre  = _userStoreService.GetUserStorebyUserCode(userCode);
                    var store      = _Storeservice.GetStore(userSotre.MembershipCardStore);

                    if (store != null)
                    {
                        foreach (var item in topupOrder)
                        {
                            if (!string.IsNullOrEmpty(item.WallePrCode) && item.PayDatetime == null)
                            {
                                var PayTime = Common.wxPayOrderQuery(item.WallePrCode, store.appid.Trim(), store.mchid);
                                if (!string.IsNullOrEmpty(PayTime))
                                {
                                    LogHelper.WriteLog("GetUseWalletInfoByUserCode PayTime" + PayTime);
                                    DateTime dt = DateTime.ParseExact(PayTime, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
                                    item.PayDatetime = dt;
                                    tos.UpdateTopupOrder(item.WallePrCode, item.PayDatetime);
                                    _RechargeRecordService.Recharge(item.RechargeTypeCode, item.UserCode, item.RecordsMoney, store.StoreCode);
                                }
                            }
                        }
                    }
                    var list = _service.GetUseWalletInfoByUserCode(userCode);
                    result.Resource = list;
                    result.Status   = Result.SUCCEED;
                }
                else
                {
                    result.Status   = ResultType;
                    result.Resource = ReAccessToken;
                    result.Msg      = TokenMessage;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("GetUseWalletInfoByUserCode userCode" + userCode, ex);
                result.Status = Result.FAILURE;
                result.Msg    = ex.Message;
            }
            LogHelper.WriteLog("GetUseWalletInfoByUserCode result" + Json(result));
            return(Json(result));
        }
Beispiel #2
0
        public IHttpActionResult GetUserInfoByCode(string usercode, string store)
        {
            LogHelper.WriteLog("GetUserInfoByCode usercode" + usercode);
            LogHelper.WriteLog("GetUserInfoByCode store" + store);
            SimpleResult      result            = new SimpleResult();
            IUserInfo         _service          = new UserInfo();
            ICustomerServiceS _customerServiceS = new CustomerServiceS();
            IOrderService     _OrderService     = new OrderService();
            ICouponService    _CouponService    = new CouponService();
            UserInfoModel     userInfo          = new UserInfoModel();
            IUseWalletService _useWalletService = new UseWalletService();
            IUserTaskService  _userTaskService  = new UserTaskService();

            try
            {
                if (UserAuthorization)
                {
                    var user = _service.GetUserByCode(usercode);
                    userInfo.user = user;
                    var customerService = _customerServiceS.GetCustomerService(store);
                    userInfo.customerService = customerService;
                    var orders = _OrderService.GetOrderList(usercode);
                    userInfo.useWalletInfo = _useWalletService.GetUseWalletInfoByUserCode(usercode);
                    var conponList = _CouponService.GetUserCoupon(usercode);
                    userInfo.useCouponCount = conponList.Any()?conponList.Count:0;
                    if (orders != null)
                    {
                        userInfo.orders = orders.Where(p => p.PayTime != null && p.IsWriteOff == false).Count();
                    }
                    var coupons = _CouponService.GetCouponList(usercode);
                    if (coupons != null)
                    {
                        userInfo.coupons = coupons.Where(c => c.IsUsed == false).Count();
                    }
                    var userTask = _userTaskService.GetUserTaskList(user.Code);
                    if (userTask != null)
                    {
                        userInfo.userTask = userTask.Where(t => t.IsComplete == false).Count();
                    }
                    userInfo.openCard = new OpenCard();
                    var cardId = ConfigurationManager.AppSettings["cardId"].ToString();
                    userInfo.openCard.cardId = cardId;
                    userInfo.openCard.code   = userInfo.user?.ReferenceNumber;
                    result.Resource          = userInfo;
                    result.Status            = Result.SUCCEED;
                }
                else
                {
                    result.Status   = ResultType;
                    result.Resource = ReAccessToken;
                    result.Msg      = TokenMessage;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("GetUserInfoByCode usercode" + usercode + "store" + store, ex);
                result.Status = Result.FAILURE;
                result.Msg    = ex.Message;
            }
            LogHelper.WriteLog("GetUserInfoByCode result" + Json(result));
            return(Json(result));
        }