/// <summary> /// 获取优惠券 /// </summary> /// <param name="openid"></param> /// <returns></returns> public MEMBER_COUPON GetCoupon(string openid) { MEMBER_COUPON coupon = new MEMBER_COUPON(); //查询会员主数据信息 CUST_MEMBER member = _repo.GetMemberByOpenId(openid); dt_Dyn_PosCpSearch_req reqs = new dt_Dyn_PosCpSearch_req(); reqs.ACCOUNT_ID = member.MEMBERNO;//会员账号和MOB_NUMBER至少输入一个 reqs.DATA_SOURCE = "0002"; reqs.LOYALTY_BRAND = AppConfig.LOYALTY_BRAND; //忠诚度品牌 reqs.SOURCE_SYSTEM = AppConfig.SOURCE_SYSTEM; //来源系统 reqs.VGROUP = AppConfig.VGROUP; //销售组织 dt_Dyn_PosCpSearch_res resok = WebApiHelp.PosCpSearch(reqs); if (resok.ZTYPE != "Y") { return(null); } //已使用 List <COUPONS> shiyong = new List <COUPONS>(); //未使用 List <COUPONS> meiyou = new List <COUPONS>(); //已过期 List <COUPONS> guoqi = new List <COUPONS>(); if (resok.ZPARTERN_CP2.Count() > 0) { foreach (ZPARTERN_CP2 item in resok.ZPARTERN_CP2) { //查询另外一个集合的数据 dt_Dyn_PosCpSearch_resITEM resout = resok.ZCPQ_RESULT.Where(a => a.ZCP_NUM == item.ZCP_NUM). ToList().FirstOrDefault(); COUPONS one = new COUPONS() { BPEXT = item.BPEXT, ZCP_EDATE = resout.ZCP_EDATE, ZCP_EDATE_EX = resout.ZCP_EDATE, ZCP_JE = resout.ZCP_JE, ZCP_POINT = resout.ZCP_POINT, ZCP_PROD = resout.ZCP_PROD, ZCP_TYPE = item.ZCP_TYPE, ZCP_YHQDES = resout.ZCP_YHQDES, ZCP_ZK = resout.ZCP_ZK, ZCP_NUM = resout.ZCP_NUM, ZCP_YHQ = resout.ZCP_YHQ, ZCP_BDATE = resout.ZCP_BDATE, ZCP_PASSW = resout.ZCP_PASSW, IS_BOOK = 0 }; one.ZCPUDATE = item.ZCPUDATE; //已使用 if (item.ZCP_USE_FLAG == "X") { shiyong.Add(one); } //未使用 if (string.IsNullOrEmpty(item.ZCP_USE_FLAG)) { DateTime endTime = one.ZCP_EDATE; if (endTime > DateTime.Now) { HMJ_BOOK_EX book = _book.GetBookByNo(one.ZCP_NUM); if (book != null) { if (book.STATUS == 1) { shiyong.Add(one); } else if (book.STATUS == 0) { one.IS_BOOK = 1; meiyou.Add(one); } } else { meiyou.Add(one); } } else { guoqi.Add(one); } } } } coupon.ALREADY_USE = shiyong.OrderByDescending(a => a.ZCPUDATE).ToList(); coupon.NOT_USE = meiyou.OrderBy(a => a.ZCP_EDATE_EX).ToList(); coupon.OBSOLETE = guoqi.OrderByDescending(a => a.ZCP_EDATE_EX).ToList(); return(coupon); }
/// <summary> /// 获取优惠券 /// </summary> /// <param name="openid"></param> /// <returns></returns> public MEMBER_COUPON GetCoupon(string account_id) { MEMBER_COUPON coupon = new MEMBER_COUPON(); dt_Dyn_PosCpSearch_req reqs = new dt_Dyn_PosCpSearch_req(); reqs.ACCOUNT_ID = account_id; //会员账号和MOB_NUMBER至少输入一个 reqs.DATA_SOURCE = "0000"; //0002为 佰草集 reqs.LOYALTY_BRAND = AppConfig.LOYALTY_BRAND; //忠诚度品牌 reqs.SOURCE_SYSTEM = AppConfig.SOURCE_SYSTEM; //来源系统 reqs.VGROUP = AppConfig.VGROUP; //销售组织 dt_Dyn_PosCpSearch_res resok = WebApiHelp.PosCpSearch(reqs); //已使用 List <COUPONS> shiyong = new List <COUPONS>(); //未使用 List <COUPONS> meiyou = new List <COUPONS>(); //已过期 List <COUPONS> guoqi = new List <COUPONS>(); if (resok != null) { if (resok.ZTYPE != "Y") { return(null); } if (resok.ZPARTERN_CP2.Count() > 0) { foreach (ZPARTERN_CP2 item in resok.ZPARTERN_CP2) { //查询另外一个集合的数据 dt_Dyn_PosCpSearch_resITEM resout = resok.ZCPQ_RESULT.Where(a => a.ZCP_NUM == item.ZCP_NUM). ToList().FirstOrDefault(); string QrCode = resout.ZCP_PASSW + ".jpg"; GenerateCode(resout.ZCP_PASSW); //RULE = {"type":"DJQ","value":"100"} 这个就解析成100元代金券 //RULE = {"type":"ZKQ","value":"5"} 解析成 5者折扣券 string RULE = ""; if (!string.IsNullOrWhiteSpace(resout.RULE)) { CouponRule CouponRule = JsonHelper.DeserializeObject <CouponRule>(resout.RULE); if (CouponRule != null) { if (CouponRule.type == "DJQ") { RULE = CouponRule.value; } else if (CouponRule.type == "ZKQ") { RULE = CouponRule.value; } } } COUPONS one = new COUPONS() { BPEXT = item.BPEXT, ZCP_EDATE = resout.ZCP_EDATE, ZCP_EDATE_EX = resout.ZCP_EDATE, ZCP_JE = resout.ZCP_JE, ZCP_POINT = resout.ZCP_POINT, ZCP_PROD = resout.ZCP_PROD, ZCP_TYPE = item.ZCP_TYPE, ZCP_YHQDES = resout.ZCP_YHQDES, ZCP_ZK = resout.ZCP_ZK, ZCP_NUM = resout.ZCP_NUM, ZCP_YHQ = resout.ZCP_YHQ, ZCP_BDATE = resout.ZCP_BDATE, ZCP_PASSW = resout.ZCP_PASSW, IS_BOOK = 0, QrCode = AppConfig.HmjWebApi_https + "/QrCode/" + QrCode, CONTENT = resout.CONTENT, RULE = RULE, ZCP_USE_FLAG = item.ZCP_USE_FLAG }; one.ZCPUDATE = item.ZCPUDATE; //已使用 if (item.ZCP_USE_FLAG == "X") { shiyong.Add(one); } //未使用 if (string.IsNullOrEmpty(item.ZCP_USE_FLAG) || item.ZCP_USE_FLAG == "N") //item.ZCP_USE_FLAG="N" 未使用未激活 { DateTime endTime = one.ZCP_EDATE; if (endTime >= DateTime.Parse(DateTime.Now.ToShortDateString())) { //BCJ_BOOK_EX book = _book.GetBookByNo(one.ZCP_NUM); //if (book != null) //{ // if (book.STATUS == 1) // { // shiyong.Add(one); // } // else if (book.STATUS == 0) // { // one.IS_BOOK = 1; // meiyou.Add(one); // } //} //else //{ // meiyou.Add(one); //} meiyou.Add(one); } else { guoqi.Add(one); } } } } } coupon.ALREADY_USE = shiyong.OrderByDescending(a => a.ZCPUDATE).ToList(); coupon.NOT_USE = meiyou.OrderBy(a => a.ZCP_EDATE_EX).ToList(); coupon.OBSOLETE = guoqi.OrderByDescending(a => a.ZCP_EDATE_EX).ToList(); return(coupon); }
/// <summary> /// 获取并更新会员信息 /// </summary> /// <param name="openid"></param> /// <returns></returns> public MemberInfo GetLoadMember(string openid) { //查询会员主数据信息 CUST_MEMBER member = _repo.GetMemberByOpenId(openid); #region 得到最新会员信息 //接口查询会员主数据 dt_Dyn_DispMember_req w = new dt_Dyn_DispMember_req(); w.DATA_SOURCE = "0002"; w.LOYALTY_BRAND = AppConfig.LOYALTY_BRAND; //忠诚度品牌 w.SOURCE_SYSTEM = AppConfig.SOURCE_SYSTEM; //来源系统 w.VGROUP = AppConfig.VGROUP; //销售组织 w.PARTNER = member.PARTNER; //会员唯一标示 dt_Dyn_DispMember_res dt = WebApiHelp.DispMember(w); if (dt.ZCRMT316 == null || dt.ZCRMT316.Count() <= 0) { return(null); } if (dt.ZCRMT316.Count() > 1) { return(null); } ZCRMT302_Dyn newmeber = dt.ZCRMT316[0]; #region 接口查询兑礼密码 dt_Dyn_ChangeMemberStatus_req req = new dt_Dyn_ChangeMemberStatus_req(); req.DATA_SOURCE = AppConfig.DATA_SOURCE; req.ZVTWEG = "102"; //来源渠道 req.ACCOUNT_ID = newmeber.ACCOUNT_ID; req.FLAG = "Q"; //查询 req.LOYALTY_BRAND = AppConfig.LOYALTY_BRAND; //忠诚度品牌 req.SOURCE_SYSTEM = AppConfig.SOURCE_SYSTEM; //来源系统 req.VGROUP = AppConfig.VGROUP; //销售组织 req.PASS_FLAG = "Y"; req.REASON = "查询密码"; dt_Dyn_ChangeMemberStatus_res res = WebApiHelp.ChangeMemberStatus(req); #endregion CUST_MEMBER mebers = new CUST_MEMBER() { ID = member.ID, ADDRESS = newmeber.PSTREET, AVA_POINTS = (int?)newmeber.ZCCUR_POINT, BIRTHDAY = string.IsNullOrEmpty(newmeber.BIRTHDT) ? null : (DateTime?)DateTime.Parse(newmeber.BIRTHDT), GENDER = newmeber.XSEX == "2" ? true : false, MEMBERNO = newmeber.ACCOUNT_ID, MOBILE = newmeber.MOB_NUMBER, MEM_LEVEL = newmeber.ZTIER, NAME = newmeber.NAME1_TEXT, PARTNER = newmeber.PARTNER, STORE = newmeber.ZH003, LOGINPASSON = res.ZPASS, NAME_FIRST = newmeber.NAME_FIRST, NAME_LAST = newmeber.NAME_LAST, ZZAFLD000004 = newmeber.ZZAFLD000004 }; #endregion dt_Dyn_PosCpSearch_req reqs = new dt_Dyn_PosCpSearch_req(); reqs.ACCOUNT_ID = member.MEMBERNO;//会员账号和MOB_NUMBER至少输入一个 reqs.DATA_SOURCE = AppConfig.DATA_SOURCE; reqs.LOYALTY_BRAND = AppConfig.LOYALTY_BRAND; //忠诚度品牌 reqs.SOURCE_SYSTEM = AppConfig.SOURCE_SYSTEM; //来源系统 reqs.VGROUP = AppConfig.VGROUP; //销售组织 dt_Dyn_PosCpSearch_res resok = WebApiHelp.PosCpSearch(reqs); int allcount = 0; foreach (ZPARTERN_CP2 item in resok.ZPARTERN_CP2) { //未使用 if (string.IsNullOrEmpty(item.ZCP_USE_FLAG)) { //查询另外一个集合的数据 dt_Dyn_PosCpSearch_resITEM resout = resok.ZCPQ_RESULT.Where(a => a.ZCP_NUM == item.ZCP_NUM). ToList().FirstOrDefault(); DateTime endTime = resout.ZCP_EDATE;// DateTime.Parse(resout.ZCP_EDATE); if (endTime >= DateTime.Now) { allcount++; } } } //更新本地会员信息 int count = _repo.UpdateMember(mebers); return(new MemberInfo() { AVA_POINTS = (int?)newmeber.ZCCUR_POINT, MOBILE = newmeber.MOB_NUMBER, SEX = newmeber.XSEX == "2" ? 1 : 0, COUPON_COUNT = allcount.ToString(), MEM_LEVEL = Utility.GetMemberLvl(newmeber.ZTIER) }); }