WYB
2021-03-22 91b8cdad021ab052e4991f3d41834a6f0ddc36b8
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
 
using JiepeiWMS.IServices;
using JiepeiWMS.Model.Models;
using JiepeiWMS.Services.BASE;
using JiepeiWMS.IRepository.Base;
using System.Threading.Tasks;
using System.Linq.Expressions;
using JiepeiWMS.Model;
using System;
using SqlSugar;
using JiepeiWMS.Extends;
 
namespace JiepeiWMS.Services
{
    public class WMOrderMainServices : BaseServices<WMOrderMain>, IWMOrderMainServices
    {
        private readonly IBaseRepository<WMOrderMain> _dal;
        public WMOrderMainServices(IBaseRepository<WMOrderMain> dal)
        {
            this._dal = dal;
            base.BaseDal = dal;
        }
 
        /// <summary>
        /// 获取订单分页
        /// </summary>
        /// <returns></returns>
        public async Task<PageModel<WMOrderMain>> GetWMOrderMainPage(int page, int intPageSize, string key = "")
        {
            Expression<Func<WMOrderMain, bool>> whereExpression = OrderMain => OrderMain.Id > 0;
 
            if (!string.IsNullOrWhiteSpace(key))
            {
                whereExpression = whereExpression.And(OrderMain => OrderMain.OrderNo == key || OrderMain.GroupNo == key);
            }
 
            var PageList = await base.QueryTabsPage<WMOrderMain, WMOrderInfo, WMOrderMain>(
                (OrderMain, OrderInfo) => new object[]
                {
                    JoinType.Left,OrderMain.OrderNo==OrderInfo.OrderNo,
                },
                (OrderMain, OrderInfo) => new WMOrderMain()
                {
                    Id = OrderMain.Id,
                    SourceType = OrderMain.SourceType,
                    OrderNo = OrderMain.OrderNo,
                    GroupNo = OrderMain.GroupNo,
                    CreateTime = OrderMain.CreateTime,
                    SureConfirmTime = OrderMain.SureConfirmTime,
                    PayTime = OrderMain.PayTime,
                    SendTime = OrderMain.SendTime,
                    ProType = OrderMain.ProType,
                    DataType = OrderMain.DataType,
                    PCBATotalMoney = OrderMain.PCBATotalMoney,
                    PCBACostMoney = OrderMain.PCBACostMoney,
                    OutType = OrderMain.OutType,
                    FinanceTarget = OrderMain.FinanceTarget,
                    MbNo = OrderMain.MbNo,
                    MainStatus = OrderMain.MainStatus
                },
                whereExpression,
                page,
                intPageSize,
                " OrderMain.Id desc"
                );
 
            foreach (var item in PageList.data)
            {
 
            }
 
            return PageList;
        }
 
        /// <summary>
        /// 验证订单信息非空字段
        /// </summary>
        /// <param name="orderMainModel"></param>
        /// <returns></returns>
        public async Task<string> ValidateReconParams(WMOrderMain orderMainModel)
        {
            var msg = "";
 
            //验证非空
            if (orderMainModel == null)
                return msg = "订单信息不能为空";
 
            if (orderMainModel.SourceType <= 0)
                return msg = "来源类型不能为空";
 
            if (!string.IsNullOrWhiteSpace(orderMainModel.OrderNo))
                return msg = "订单编号不能为空";
 
            if (orderMainModel.Status <= 0)
                return msg = "状态不能为空";
 
            if (string.IsNullOrWhiteSpace(orderMainModel.GroupNo))
                return msg = "订单包编号不能为空";
 
            if (orderMainModel.CreateTime == null)
                return msg = "下单时间不能为空";
 
            if (orderMainModel.SureConfirmTime == null)
                return msg = "投产时间不能为空";
 
            if (orderMainModel.PayTime == null)
                return msg = "付款时间不能为空";
 
            if (orderMainModel.SendTime == null)
                return msg = "发货时间不能为空";
 
            if (orderMainModel.ProType <= 0)
                return msg = "产品类型不能为空";
 
            if (orderMainModel.DataType <= 0)
                return msg = "数据类型不能为空";
 
            if (orderMainModel.TotalMoney <= 0)
                return msg = "产品费不能为0";
 
            if (orderMainModel.ShipMoney <= 0)
                return msg = "运费不能为0";
 
            if (orderMainModel.PreferentialMoney <= 0)
                return msg = "浮动金额不能为0";
 
            if (orderMainModel.TaxMoney <= 0)
                return msg = "税费不能为0";
 
            if (orderMainModel.PaypalPayMoney <= 0)
                return msg = "手续费(外贸)不能为0";
 
            if (orderMainModel.PresentMoney <= 0)
                return msg = "赠送金额不能为0";
 
            if (orderMainModel.PaidMoney <= 0)
                return msg = "实收金额不能为0";
 
            if (orderMainModel.CostMoney <= 0)
                return msg = "成本金额不能为0";
 
            if (orderMainModel.PCBATotalMoney <= 0)
                return msg = "PCBA总收入金额不能为0";
 
            if (orderMainModel.PCBACostMoney <= 0)
                return msg = "PCBA成本金额不能为0";
 
            if (orderMainModel.PCBACostMoney <= 0)
                return msg = "PCBA成本金额不能为0";
 
            if (orderMainModel.OutType <= 0)
                return msg = "外发类型不能为空";
 
            if (string.IsNullOrWhiteSpace(orderMainModel.JoinFactoryName))
                return msg = "外发工厂名称不能为空";
 
            if (orderMainModel.FinanceTarget <= 0)
                return msg = "财务对象类型不能为空";
 
            if (orderMainModel.IsTJ <= 0)
                return msg = "是否特价不能为空";
 
            if (orderMainModel.MainStatus <= 0)
                return msg = "订单包状态不能为空";
 
 
            return msg;
        }
    }
}