• 大小: 37.88MB
    文件类型: .7z
    金币: 1
    下载: 0 次
    发布日期: 2023-06-28
  • 语言: 其他
  • 标签: 微信  开发  

资源简介

微信公众平台,微信商城系统源码,.NET平台

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MxWeiXinPF.Common;
using System.Text;

namespace MxWeiXinPF.Web.shop
{
    /// 
    /// shopmgr 的摘要说明
    /// 

    public class shopmgr : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = “text/json“;
            BLL.wx_shop_cart cartBll = new BLL.wx_shop_cart();
            string _action = MyCommFun.QueryString(“myact“);       
            string openid = MyCommFun.RequestOpenid();  //得到微信用户的openid
            Dictionary jsonDict = new Dictionary();
            if (_action == “addCart“)
            {
                #region 添加购物车
                try
                {
                    int wid = MyCommFun.RequestInt(“wid“);
                    int productId = MyCommFun.RequestInt(“productid“);
                    int skuId = MyCommFun.RequestInt(“mid“);
                    string skuInfo = MyCommFun.QueryString(“attr“);
                    int productNum = MyCommFun.RequestInt(“bc“);
                    decimal totalPrice = (decimal)MyCommFun.RequestFloat(“totprice“ 0);
                
                    Model.wx_shop_cart cart = new Model.wx_shop_cart();

                    IList cartList = cartBll.GetModelList(“productId=“ + productId + “ and openid=‘“ + openid + “‘ and skuId=“+skuId);
                    bool isAdd = true;
                    if (cartList != null && cartList.Count > 0)
                    {
                        isAdd = false;
                        cart = cartList[0];
                    }
                    if (isAdd)
                    {
                        cart.createDate = DateTime.Now;
                        cart.openid = openid;
                        cart.productId = productId;
                        cart.productNum = productNum;
                        cart.skuId = skuId;
                        cart.skuInfo = skuInfo;
                        cart.totPrice = totalPrice * productNum;
                        cart.wid = wid;
                        int ret = cartBll.Add(cart);
                        if (ret > 0)
                        {
                            jsonDict.Add(“errCode“ “false“);
                        }
                        else
                        {
                            jsonDict.Add(“errCode“ “true“);
                        }
                    }
                    else
                    {

                        cart.openid = openid;

                        cart.productNum += productNum;
                        cart.skuId = skuId;
                        cart.skuInfo = skuInfo;
                        cart.totPrice += totalPrice * productNum;
                        cart.wid = wid;
                        bool ret = cartBll.Update(cart);
          

评论

共有 条评论