Esempio n. 1
0
        public void SendCardCouponsByCurrUserInfo(UserInfo currUserInfo, string cardId)
        {
            try
            {
                BLLWeixin bllWeixin = new BLLWeixin();

                BLLWebsiteDomainInfo bllDomain = new BLLWebsiteDomainInfo();

                CardCoupons cardCoupon = Get <CardCoupons>(string.Format(" WebsiteOwner='{0}' AND CardId={1} ", currUserInfo.WebsiteOwner, int.Parse(cardId)));

                MyCardCoupons model = new MyCardCoupons();
                model.CardCouponNumber = GetGUID(BLLJIMP.TransacType.CommAdd);
                model.CardCouponType   = cardCoupon.CardCouponType;
                model.CardId           = cardCoupon.CardId;
                model.InsertDate       = DateTime.Now;
                model.UserId           = currUserInfo.UserID;
                model.WebSiteOwner     = currUserInfo.WebsiteOwner;
                if (Add(model))
                {
                    string title     = "您收到一张优惠券";
                    string content   = string.Format("{0}", cardCoupon.Name);
                    string redicturl = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/mycoupons#/mycoupons", bllDomain.GetWebsiteDoMain(currUserInfo.WebsiteOwner));
                    bllWeixin.SendTemplateMessageNotifyComm(currUserInfo, title, content, redicturl);
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 关注自动送券
        /// </summary>
        public void SubscribeGive(UserInfo userInfo)
        {
            try
            {
                BLLDistribution      bllDis         = new BLLDistribution();
                BLLWeixin            bllWeixin      = new BLLWeixin();
                BLLWebsiteDomainInfo bllDomain      = new BLLWebsiteDomainInfo();
                List <CardCoupons>   cardCouponList = GetList <CardCoupons>(string.Format("WebsiteOwner='{0}' And IsSubscribeGive='1'", userInfo.WebsiteOwner));
                foreach (var cardCoupon in cardCouponList)
                {
                    if (GetCount <MyCardCoupons>(string.Format("CardId='{0}' And UserId='{1}'", cardCoupon.CardId, userInfo.UserID)) > 0)
                    {
                        continue;//已经发过了
                    }
                    if (!string.IsNullOrEmpty(cardCoupon.BindChannelUserId))
                    {
                        if (bllDis.GetUserChannel(userInfo) != cardCoupon.BindChannelUserId)
                        {
                            continue;
                        }
                    }
                    if (cardCoupon.MaxCount > 0)
                    {
                        int sendCount = GetCount <MyCardCoupons>(string.Format(" CardID={0}", cardCoupon.CardId));
                        if (sendCount >= cardCoupon.MaxCount)
                        {
                            continue;
                        }
                    }


                    //给用户发满送券
                    MyCardCoupons model = new MyCardCoupons();
                    model.CardCouponNumber = string.Format("No.{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), GetGUID(BLLJIMP.TransacType.CommAdd));
                    model.CardCouponType   = cardCoupon.CardCouponType;
                    model.CardId           = cardCoupon.CardId;
                    model.InsertDate       = DateTime.Now;
                    model.UserId           = userInfo.UserID;
                    model.WebSiteOwner     = userInfo.WebsiteOwner;
                    if (Add(model))
                    {
                        string title     = "您收到一张优惠券";
                        string content   = string.Format("{0}", cardCoupon.Name);
                        string redicturl = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/mycoupons#/mycoupons", bllDomain.GetWebsiteDoMain(userInfo.WebsiteOwner));
                        bllWeixin.SendTemplateMessageNotifyComm(userInfo, title, content, redicturl);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 冻结积分结算
        /// </summary>
        /// <param name="orderInfo"></param>
        /// <returns></returns>
        public bool SettlementOrderLockScore(WXMallOrderInfo orderInfo, out string msg)
        {
            BLLMall bllMall = new BLLMall();
            BLLWebsiteDomainInfo bllWebsiteDomain = new BLLWebsiteDomainInfo();
            BLLWeixin            bllWeixin        = new BLLWeixin();

            msg = "";
            var lockModel = GetLockScoreByOrder(orderInfo.OrderID);

            int addScore = (int)lockModel.Score;

            if (addScore > 0)
            {
                UserInfo orderUserInfo = bllUser.GetUserInfo(orderInfo.OrderUserID, orderInfo.WebsiteOwner);
                if (orderUserInfo == null)
                {
                    return(false);
                }
                WebsiteInfo websiteInfo = bllMall.Get <WebsiteInfo>(string.Format(" WebsiteOwner='{0}'", orderInfo.WebsiteOwner));

                ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZentCloud.ZCBLLEngine.BLLTransaction();
                try
                {
                    UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo();
                    scoreRecord.AddTime      = DateTime.Now;
                    scoreRecord.Score        = addScore;
                    scoreRecord.TotalScore   = orderUserInfo.TotalScore;
                    scoreRecord.ScoreType    = "OrderSuccess";
                    scoreRecord.UserID       = orderInfo.OrderUserID;
                    scoreRecord.AddNote      = "微商城-交易成功获得积分";
                    scoreRecord.WebSiteOwner = orderInfo.WebsiteOwner;
                    scoreRecord.RelationID   = orderInfo.OrderID;

                    if (!bllMall.Add(scoreRecord, tran))
                    {
                        tran.Rollback();
                        return(false);
                    }
                    if (bllUser.Update(orderUserInfo, string.Format(" TotalScore+={0},HistoryTotalScore+={0}", addScore), string.Format(" AutoID={0}", orderUserInfo.AutoID), tran) <= 0)
                    {
                        tran.Rollback();
                        return(false);
                    }

                    #region 宏巍加积分
                    if (websiteInfo.IsUnionHongware == 1)
                    {
                        Open.HongWareSDK.Client hongWareClient = new Open.HongWareSDK.Client(orderInfo.WebsiteOwner);
                        var hongWareMemberInfo = hongWareClient.GetMemberInfo(orderUserInfo.WXOpenId);
                        if (hongWareMemberInfo.member != null)
                        {
                            if (!hongWareClient.UpdateMemberScore(hongWareMemberInfo.member.mobile, orderUserInfo.WXOpenId, addScore))
                            {
                                tran.Rollback();
                                return(false);
                            }
                        }
                    }
                    #endregion

                    //积分解冻
                    if (!string.IsNullOrWhiteSpace(lockModel.Memo))
                    {
                        lockModel.Memo += ";交易成功获得积分解冻";
                    }
                    else
                    {
                        lockModel.Memo = "交易成功获得积分解冻";
                    }

                    if (Update(
                            new ScoreLockInfo(),
                            string.Format(" Memo+='{0}',LockStatus=1,UnLockTime=GETDATE() ", lockModel.Memo),
                            string.Format(" ForeignkeyId='{0}' AND LockType = 1 ", orderInfo.OrderID),
                            tran
                            ) > 0)
                    {
                        #region 微信通知
                        try
                        {
                            string url = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/myscores#/myscores", bllWebsiteDomain.GetWebsiteDoMain(orderInfo.WebsiteOwner));
                            bllWeixin.SendTemplateMessageNotifyCommTask(orderUserInfo.WXOpenId, "您有一笔积分已经到账", string.Format("积分:{0}分", (int)lockModel.Score), url, "", "", "", orderInfo.WebsiteOwner);
                        }
                        catch
                        {
                        }
                        #endregion
                    }
                    else
                    {
                        msg = string.Format("处理即将到账积分失败!订单号:{0}", orderInfo.OrderID);
                        tran.Rollback();
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                    tran.Rollback();
                    return(false);
                }

                tran.Commit();
            }

            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// 赠送满送券
        /// </summary>
        public void Give(decimal totalAmount, UserInfo userInfo)
        {
            try
            {
                BLLWeixin            bllWeixin      = new BLLWeixin();
                BLLWebsiteDomainInfo bllDomain      = new BLLWebsiteDomainInfo();
                List <CardCoupons>   cardCouponList = GetList <CardCoupons>(string.Format("WebsiteOwner='{0}' And CardCouponType='MallCardCoupon_BuckleGive'", userInfo.WebsiteOwner)).OrderBy(p => p.Ex5).ToList();
                foreach (var cardCoupon in cardCouponList)
                {
                    if (totalAmount >= decimal.Parse(cardCoupon.Ex5))
                    {
                        if (cardCoupon.MaxCount > 0)
                        {
                            int sendCount = GetCount <MyCardCoupons>(string.Format(" CardID={0}", cardCoupon.CardId));
                            if (sendCount >= cardCoupon.MaxCount)
                            {
                                break;
                            }
                        }
                        //给用户发满送券
                        MyCardCoupons model = new MyCardCoupons();
                        model.CardCouponNumber = string.Format("No.{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), GetGUID(BLLJIMP.TransacType.CommAdd));
                        model.CardCouponType   = cardCoupon.CardCouponType;
                        model.CardId           = cardCoupon.CardId;
                        model.InsertDate       = DateTime.Now;
                        model.UserId           = userInfo.UserID;
                        model.WebSiteOwner     = userInfo.WebsiteOwner;
                        if (Add(model))
                        {
                            string title     = "您收到一张优惠券";
                            string content   = string.Format("{0}", cardCoupon.Name);
                            string redicturl = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/mycoupons#/mycoupons", bllDomain.GetWebsiteDoMain(userInfo.WebsiteOwner));
                            bllWeixin.SendTemplateMessageNotifyComm(userInfo, title, content, redicturl);
                        }


                        //给用户发满送券
                        //break;
                    }
                }


                #region New
                List <CardCoupons> cardCouponListNew = GetList <CardCoupons>(string.Format("WebsiteOwner='{0}' And FullGive!=''", userInfo.WebsiteOwner));

                foreach (var cardCoupon in cardCouponListNew)
                {
                    if (totalAmount >= decimal.Parse(cardCoupon.FullGive))
                    {
                        if (cardCoupon.MaxCount > 0)
                        {
                            int sendCount = GetCount <MyCardCoupons>(string.Format(" CardID={0}", cardCoupon.CardId));
                            if (sendCount >= cardCoupon.MaxCount)
                            {
                                break;
                            }
                        }
                        //给用户发券
                        MyCardCoupons model = new MyCardCoupons();
                        model.CardCouponNumber = string.Format("No.{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), GetGUID(BLLJIMP.TransacType.CommAdd));
                        model.CardCouponType   = cardCoupon.CardCouponType;
                        model.CardId           = cardCoupon.CardId;
                        model.InsertDate       = DateTime.Now;
                        model.UserId           = userInfo.UserID;
                        model.WebSiteOwner     = userInfo.WebsiteOwner;
                        if (Add(model))
                        {
                            string title     = "您收到一张优惠券";
                            string content   = string.Format("{0}", cardCoupon.Name);
                            string redicturl = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/mycoupons#/mycoupons", bllDomain.GetWebsiteDoMain(userInfo.WebsiteOwner));
                            bllWeixin.SendTemplateMessageNotifyComm(userInfo, title, content, redicturl);
                        }
                        else
                        {
                        }


                        //给用户发券
                        //break;
                    }
                    else
                    {
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
        }