Ejemplo n.º 1
0
        public IHttpActionResult ExChangeCoupon(string openId = "", string couponConfigId = "")
        {
            var vip    = _vipService.GetVipInfo(openId);
            var coupon = _couponService.GetShopCoupon(couponConfigId);

            if (coupon != null && vip != null)
            {
                var point = _pointService.GetVipPoint(vip);
                if (point != null)
                {
                    if (point.VipPoint >= coupon.CouponPoint)
                    {
                        if (_couponService.ExChangeCoupon(vip.VipId, coupon.CouponConfigId))
                        {
                            return(Json(new { success = true, message = "兑换成功!" }));
                        }
                    }
                    return(Json(new { success = false, message = "积分不足!" }));
                }
            }
            return(Json(new { success = false, message = "发生错误!" }));
        }