164 lines
6.6 KiB
C#
164 lines
6.6 KiB
C#
using AllBase;
|
|
using TemuKJD.KJDForms.BaseForms;
|
|
using NaiBa.Util.Extension;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace TemuKJD.KJDForms.SalesCenterForms
|
|
{
|
|
public partial class CouponMulitAddForm : LRBaseForm
|
|
{
|
|
int number = 1;
|
|
public CouponShopForm couponShopForm = null;
|
|
|
|
public CouponMulitAddForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void couponAddParamControl1_OnClose(object obj)
|
|
{
|
|
int i = 0;
|
|
foreach (var c in panel3.Controls)
|
|
{
|
|
var couponControl = c as UcCouponAddParam;
|
|
if (couponControl == null)
|
|
continue;
|
|
|
|
couponControl.Location = new Point(0, i * (couponControl.Height + 2));
|
|
lblAdd.Location = new Point(20, (i + 1) * (couponControl.Height + 2) + 10);
|
|
i++;
|
|
}
|
|
|
|
if (panel3.Controls.Count == 1)
|
|
lblAdd.Location = new Point(20, 12);
|
|
}
|
|
|
|
private void lblAdd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
{
|
|
this.number++;
|
|
|
|
UcCouponAddParam co = new UcCouponAddParam(number);
|
|
if (rbUseTypePeriod.Checked)
|
|
co.pnlTimePeriod.Visible = true;
|
|
else
|
|
co.pnlTimePeriod.Visible = false;
|
|
|
|
panel3.Controls.Add(co);
|
|
co.OnClose += couponAddParamControl1_OnClose;
|
|
|
|
int i = 0;
|
|
foreach (var c in panel3.Controls)
|
|
{
|
|
var couponControl = c as UcCouponAddParam;
|
|
if (couponControl == null)
|
|
continue;
|
|
|
|
couponControl.Location = new Point(0, i * (couponControl.Height + 2));
|
|
lblAdd.Location = new Point(20, (i + 1) * (couponControl.Height + 2) + 10);
|
|
i++;
|
|
}
|
|
}
|
|
|
|
private void btnGetProduct_Click(object sender, EventArgs e)
|
|
{
|
|
if (couponShopForm == null)
|
|
return;
|
|
|
|
this.btnSet.Enabled = false;
|
|
Task.Run(() =>
|
|
{
|
|
foreach (var c in this.panel3.Controls)
|
|
{
|
|
var couponControl = c as UcCouponAddParam;
|
|
if (couponControl == null)
|
|
continue;
|
|
|
|
int periodType = this.rbUseTypePeriod.Checked ? 1 : 2;
|
|
int favouredType = 41;
|
|
Invoke(new Action(() =>
|
|
{
|
|
if (couponControl.cmbType.Text == "商品直减券")
|
|
favouredType = 42;
|
|
else if (couponControl.cmbType.Text == "商品满减券")
|
|
favouredType = 43;
|
|
}));
|
|
int days = couponControl.nudDays.Text.ParseToInt();
|
|
int startApplyTime = BaseClass.DateTimeToTimestampSeconds(couponControl.dtpStartApplyTime.Value);
|
|
int endApplyTime = BaseClass.DateTimeToTimestampSeconds(couponControl.dtpEndApplyTime.Value);
|
|
int startUseTime = BaseClass.DateTimeToTimestampSeconds(couponControl.dtpStartUseTime.Value.Date);
|
|
int endUseTime = BaseClass.DateTimeToTimestampSeconds(couponControl.dtpEndUseTime.Value.Date.AddDays(1).AddSeconds(-1));
|
|
int totalCount = couponControl.nudTotalCount.Value.ParseToInt();
|
|
int countLimit = 1;
|
|
decimal discount = couponControl.nudCredit.Value.ParseToDecimal();
|
|
int thresHold = couponControl.nudThresHold.Value.ParseToInt(); // 满x元 单位元
|
|
int credit = couponControl.nudCredit.Value.ParseToInt(); // 减x元 单位元
|
|
bool ignore = couponControl.rbNotReckonIn.Checked;
|
|
string couponName = couponControl.txtName.Text;
|
|
bool oneProductEachCoupon = this.rbOneProductEachCoupon.Checked;
|
|
|
|
var result = couponShopForm.SetCoupon(periodType, favouredType, startApplyTime, endApplyTime, startUseTime, endUseTime, days, totalCount, countLimit, discount, thresHold, credit, ignore, oneProductEachCoupon, couponName);
|
|
//if (result.Contains("\"msg\":\"成功\""))
|
|
// Invoke(new Action(() => { couponControl.lblMsg.Text = "设置成功"; }));
|
|
//else
|
|
// Invoke(new Action(() => { couponControl.lblMsg.Text = "设置失败"; }));
|
|
if (result.Contains("success") && !result.Contains("error"))
|
|
Invoke(new Action(() => { couponControl.lblMsg.Text = "设置成功"; }));
|
|
else if (result.Contains("success") && result.Contains("error"))
|
|
Invoke(new Action(() => { couponControl.lblMsg.Text = "部分成功"; }));
|
|
else
|
|
Invoke(new Action(() => { couponControl.lblMsg.Text = "设置失败"; }));
|
|
|
|
if ("18565722666,13928836672,18565722666,13928836672,18937517772,18135637272,18888888888".Contains(BaseClass.UserName))
|
|
Thread.Sleep(Randomx.GetId(200, 700));
|
|
else
|
|
Thread.Sleep(Randomx.GetId(1000, 2000));
|
|
}
|
|
BaseMsgForm.ShowInfo("优惠券批量设置结束!");
|
|
Invoke(new Action(() =>
|
|
{
|
|
this.btnSet.Enabled = true;
|
|
}));
|
|
});
|
|
}
|
|
|
|
private void rbUseTypePeriod_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (rbUseTypePeriod.Checked)
|
|
{
|
|
lblUseTypeText.Text = "日期范围";
|
|
|
|
foreach (var c in this.panel3.Controls)
|
|
{
|
|
var couponControl = c as UcCouponAddParam;
|
|
if (couponControl == null)
|
|
continue;
|
|
|
|
couponControl.pnlTimePeriod.Visible = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblUseTypeText.Text = "领券当日起";
|
|
|
|
foreach (var c in this.panel3.Controls)
|
|
{
|
|
var couponControl = c as UcCouponAddParam;
|
|
if (couponControl == null)
|
|
continue;
|
|
|
|
couponControl.pnlTimePeriod.Visible = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|