username@email.com
2025-05-21 a980cd04341d71216e0f59bd4b7327fe9fc50032
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CY.Infrastructure.Common;
namespace CY.WebForm.Pages.sysInquiry
{
    /// <summary>
    /// CalculatePaperPriceHandler 的摘要说明
    /// </summary>
    public class CalculatePaperPriceHandler : IHttpHandler
    {
 
        public void ProcessRequest(HttpContext context)
        {
            string paperSize = string.Empty;
            int? gramWeight = null;
            decimal? tonsPrice = null;
            decimal? reamPrice = null;
            paperSize = context.Request.Params["paperSize"].ToString();
            if (!string.IsNullOrEmpty(context.Request.Params["gramWeight"].ToString()))
            {
                gramWeight = int.Parse(context.Request.Params["gramWeight"].ToString());
            }
            if (!string.IsNullOrEmpty(context.Request.Params["tonsPrice"].ToString()))
            {
                tonsPrice = Convert.ToDecimal(context.Request.Params["tonsPrice"].ToString());
            }
            if (!string.IsNullOrEmpty(context.Request.Params["reamPrice"].ToString()))
            {
                reamPrice = Convert.ToDecimal(context.Request.Params["reamPrice"].ToString());
            }
            context.Response.Write(CalculatePaperPrice(paperSize, gramWeight, tonsPrice, reamPrice));
            context.Response.End();
        }
 
        /// <summary>
        /// 纸价转换计算
        /// </summary>
        /// <param name="paperSize">纸张尺寸</param>
        /// <param name="gramgramWeight">克重</param>
        /// <param name="tonsPrice">吨价</param>
        /// <param name="reamPrice">令价</param>
        /// <returns>前台显示json字符串</returns>
        public string CalculatePaperPrice(string paperSize, int? gramWeight, decimal? tonsPrice, decimal? reamPrice)
        {
            //纸张单价
            decimal? price = 0;
 
            //令重
            decimal? reamWeight = 0;
 
            //令数
            double? reamNumber = 0;
 
            string html = "";
 
            if (gramWeight != null)
            {
                if (reamPrice == null)
                {
 
                    if (!string.IsNullOrEmpty(paperSize) && gramWeight != null && tonsPrice != null)
                    {
                        string[] paperSizes = paperSize.Split('×');
 
                        double widht = paperSizes[0].ToDouble2().Value / 1000;
                        double height = paperSizes[1].ToDouble2().Value / 1000;
 
                        double _gramWeight = gramWeight.ToDouble2().Value / 1000;
 
                        double area = widht * height;
 
                        price = (area * _gramWeight * (tonsPrice.ToDouble2() / 1000)).ToDecimal2();
 
                        reamWeight = (widht * height * _gramWeight * 500).ToDecimal2();
 
                        reamWeight = reamWeight.ToDecimal2();
 
                        reamNumber = (1000 / reamWeight).ToDouble2().Value.ToString("0.00").ToDouble2();
 
                        reamPrice = price * 500;
 
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(paperSize) && gramWeight != null && reamPrice != null)
                    {
                        string[] paperSizes = paperSize.Split('×');
 
                        double widht = paperSizes[0].ToDouble2().Value / 1000;
 
                        double height = paperSizes[1].ToDouble2().Value / 1000;
 
                        double _gramWeight = gramWeight.ToDouble2().Value / 1000;
 
                        double area = (widht * height) / 2;
 
                        price = reamPrice / 500;
 
                        tonsPrice = (reamPrice.ToDouble2() / (area.ToDouble2() * (gramWeight.ToDouble2())) * 1000).ToDecimal2();
 
                        tonsPrice = tonsPrice.ToDecimal2();
 
                        reamWeight = (widht * height * _gramWeight * 500).ToDecimal2();
 
                        reamWeight = reamWeight.ToDecimal2();
 
                        reamNumber = (1000 / reamWeight).ToDouble2().Value.ToString("0.00").ToDouble2();
                    }
                }
            }
            else
            {
                string[] paperSizes = paperSize.Split('×');
 
                double widht = paperSizes[0].ToDouble2().Value / 1000;
 
                double height = paperSizes[1].ToDouble2().Value / 1000;
 
                double area = (widht * height) / 2;
 
                price = reamPrice / 500;
 
                gramWeight = ((reamPrice.ToDouble2() / (tonsPrice.ToDouble2() / 1000)) / area).ToInt32();
 
                double _gramWeight = gramWeight.ToDouble2().Value / 1000;
 
                reamWeight = (widht * height * _gramWeight * 500).ToDecimal2();
 
                reamWeight = reamWeight.ToDecimal2();
 
                reamNumber = (1000 / reamWeight).ToDouble2().Value.ToString("0.00").ToDouble2();
            }
 
            html = paperSize + "|" + gramWeight.ToDecimal2Yen() + "|" + reamWeight.ToDecimal2Yen() + "|" + reamNumber.ToDecimal2Yen() + "|" + tonsPrice.ToDecimal2Yen() + "|" + reamPrice.ToDecimal2Yen() + "|" + price.ToDecimal2Yen();
            return html;
        }
 
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}