Exemple #1
0
 //会员特选商品逻辑
 private void IsUserProduct(M_Product proMod, string olduids, string newuids)
 {
     #region 特选商品
     //有更改则执行特选商品
     string uids = StrHelper.IDS_GetChange(olduids, newuids);//uprouids_old_hid.Value, uprouids_hid.Value
     if (!string.IsNullOrEmpty(uids))
     {
         //1,目标表中可能无数据
         //2,只对变更部分操作
         //目的:会员可知道自己有哪些商品,商品处也可知道可有哪些特选
         string[] add    = uids.Split('|')[0].Split(',');
         string[] remove = uids.Split('|')[1].Split(',');
         foreach (string id in add)
         {
             int uid = DataConvert.CLng(id);
             if (uid < 1)
             {
                 continue;
             }
             M_User_BindPro bindMod = bindBll.SelModelByUid(uid);
             if (bindMod == null)
             {
                 bindMod = new M_User_BindPro()
                 {
                     UserID = uid
                 };
             }
             bindMod.ProIDS = StrHelper.AddToIDS(bindMod.ProIDS, proMod.ID.ToString());
             if (bindMod.ID > 0)
             {
                 bindBll.UpdateByID(bindMod);
             }
             else
             {
                 bindBll.Insert(bindMod);
             }
         }
         foreach (string id in remove)
         {
             int uid = DataConvert.CLng(id);
             if (uid < 1)
             {
                 continue;
             }
             M_User_BindPro bindMod = bindBll.SelModelByUid(uid);
             if (bindMod == null)
             {
                 bindMod = new M_User_BindPro()
                 {
                     UserID = uid
                 };
             }
             bindMod.ProIDS = StrHelper.RemoveToIDS(bindMod.ProIDS, proMod.ID.ToString());
             if (bindMod.ID > 0)
             {
                 bindBll.UpdateByID(bindMod);
             }
             else
             {
                 bindBll.Insert(bindMod);
             }
         }
     }
     #endregion
 }