|
@@ -21,7 +21,7 @@ func (im *InvoiceManager) simpleMakeInvoice(ctx context.Context) (total, okNum i
|
|
//查询需要开票的数据
|
|
//查询需要开票的数据
|
|
//(新开发票【a.invoice_status=0 AND a.invoice_changed=0】,红冲后新开【a.invoice_status=2 AND a.invoice_changed=1】)
|
|
//(新开发票【a.invoice_status=0 AND a.invoice_changed=0】,红冲后新开【a.invoice_status=2 AND a.invoice_changed=1】)
|
|
//线上申请发票【invoice_order_code is null 】, 管理后台一个订单拆分多个发票【invoice_order_code not like '%,%'】
|
|
//线上申请发票【invoice_order_code is null 】, 管理后台一个订单拆分多个发票【invoice_order_code not like '%,%'】
|
|
- res, err = g.DB().Query(ctx, "SELECT a.id,a.invoice_type,a.remark,a.invoice_variety,a.taxpayer_identnum,a.company_name,a.invoice_content,a.invoice_money,b.pay_money FROM invoice a INNER JOIN dataexport_order b ON a.order_code=b.order_code WHERE a.invoice_variety like '%电子%' AND ((a.invoice_status=0 AND a.invoice_changed=0) or (a.invoice_status=2 AND a.invoice_changed=1 )) AND (a.invoice_order_code is NULL OR a.invoice_order_code not like '%,%') AND a.create_time > ? ", consts.InvoiceStartTime.Unix())
|
|
|
|
|
|
+ res, err = g.DB().Query(ctx, "SELECT a.*,b.pay_money FROM invoice a INNER JOIN dataexport_order b ON a.order_code=b.order_code WHERE a.invoice_variety like '%电子%' AND ((a.invoice_status=0 AND a.invoice_changed=0) or (a.invoice_status=2 AND a.invoice_changed=1 )) AND (a.invoice_order_code is NULL OR a.invoice_order_code not like '%,%') AND a.create_time > ? ", consts.InvoiceStartTime.Unix())
|
|
if err != nil {
|
|
if err != nil {
|
|
err = gerror.Wrap(err, "simpleMakeInvoice-查询待开票异常")
|
|
err = gerror.Wrap(err, "simpleMakeInvoice-查询待开票异常")
|
|
return
|
|
return
|
|
@@ -48,10 +48,13 @@ func (im *InvoiceManager) simpleMakeInvoice(ctx context.Context) (total, okNum i
|
|
}
|
|
}
|
|
|
|
|
|
c := MakeInvoiceData{
|
|
c := MakeInvoiceData{
|
|
- Type: "2",
|
|
|
|
- Id: fmt.Sprintf("id:%d", id), //因为orderCode不唯一,此处禁止使用orderCode
|
|
|
|
- Notes: remark,
|
|
|
|
- Fhr: g.Cfg().MustGet(ctx, "company.hfr", "贺鹏飞").String(),
|
|
|
|
|
|
+ Type: "2",
|
|
|
|
+ Id: fmt.Sprintf("id:%d", id), //因为orderCode不唯一,此处禁止使用orderCode
|
|
|
|
+ Notes: remark,
|
|
|
|
+ Lxdh: gconv.String(m["phone"]),
|
|
|
|
+ Fhr: g.Cfg().MustGet(ctx, "company.hfr", "贺鹏飞").String(),
|
|
|
|
+ Xsfkhh: g.Cfg().MustGet(ctx, "company.bank", "").String(),
|
|
|
|
+ Xsfyhzh: g.Cfg().MustGet(ctx, "company.bankNum", "").String(),
|
|
InvoiceArr: []MakeInvoiceItems{{
|
|
InvoiceArr: []MakeInvoiceItems{{
|
|
Xmmc: consts.GetTaxCodeByName(invoiceContent), //开票项
|
|
Xmmc: consts.GetTaxCodeByName(invoiceContent), //开票项
|
|
WhStatus: 1, //开票项是否维护
|
|
WhStatus: 1, //开票项是否维护
|
|
@@ -68,6 +71,9 @@ func (im *InvoiceManager) simpleMakeInvoice(ctx context.Context) (total, okNum i
|
|
if iType == "单位" {
|
|
if iType == "单位" {
|
|
c.Gmfmc = gconv.String(m["company_name"])
|
|
c.Gmfmc = gconv.String(m["company_name"])
|
|
c.Gmfnsrsbh = gconv.String(m["taxpayer_identnum"])
|
|
c.Gmfnsrsbh = gconv.String(m["taxpayer_identnum"])
|
|
|
|
+ c.Gmfdz = gconv.String(m["company_address"]) //"购买方地址"
|
|
|
|
+ c.Yhyywdmc = gconv.String(m["bank_name"]) //"购买方开户行"
|
|
|
|
+ c.Yhzh = gconv.String(m["bank_account"]) //"购买方银行账号"
|
|
} else {
|
|
} else {
|
|
c.Gmfmc = iType
|
|
c.Gmfmc = iType
|
|
}
|
|
}
|
|
@@ -98,7 +104,7 @@ func (im *InvoiceManager) multipleOrdersMakeInvoice(ctx context.Context) (total,
|
|
res gdb.Result
|
|
res gdb.Result
|
|
)
|
|
)
|
|
//(新开发票【a.invoice_status=0 AND a.invoice_changed=0】,红冲后新开【a.invoice_status=2 AND a.invoice_changed=1】)
|
|
//(新开发票【a.invoice_status=0 AND a.invoice_changed=0】,红冲后新开【a.invoice_status=2 AND a.invoice_changed=1】)
|
|
- res, err = g.DB().Query(ctx, "SELECT a.only_Identifying,a.invoice_type,a.remark,a.invoice_variety,a.taxpayer_identnum,a.company_name,a.invoice_content,a.invoice_money FROM invoice a WHERE a.invoice_variety like '%电子%' AND ((a.invoice_status=0 AND a.invoice_changed=0) or (a.invoice_status=2 AND a.invoice_changed=1)) AND a.invoice_order_code like '%,%' AND a.create_time > ? GROUP BY invoice_order_code", consts.InvoiceStartTime.Unix())
|
|
|
|
|
|
+ res, err = g.DB().Query(ctx, "SELECT a.only_Identifying,a.invoice_type,a.remark,a.invoice_variety,a.taxpayer_identnum,a.company_name,a.invoice_content,a.invoice_money,a.company_address,a.phone,a.bank_account,a.bank_name FROM invoice a WHERE a.invoice_variety like '%电子%' AND ((a.invoice_status=0 AND a.invoice_changed=0) or (a.invoice_status=2 AND a.invoice_changed=1)) AND a.invoice_order_code like '%,%' AND a.create_time > ? GROUP BY only_Identifying", consts.InvoiceStartTime.Unix())
|
|
if err != nil {
|
|
if err != nil {
|
|
err = gerror.Wrap(err, "multipleOrdersMakeInvoice-查询待开票异常")
|
|
err = gerror.Wrap(err, "multipleOrdersMakeInvoice-查询待开票异常")
|
|
return
|
|
return
|
|
@@ -125,10 +131,13 @@ func (im *InvoiceManager) multipleOrdersMakeInvoice(ctx context.Context) (total,
|
|
}
|
|
}
|
|
|
|
|
|
c := MakeInvoiceData{
|
|
c := MakeInvoiceData{
|
|
- Type: "2",
|
|
|
|
- Id: fmt.Sprintf("only_Identifying:%s", onlyIdentifying),
|
|
|
|
- Notes: remark,
|
|
|
|
- Fhr: g.Cfg().MustGet(ctx, "company.hfr", "贺鹏飞").String(),
|
|
|
|
|
|
+ Type: "2",
|
|
|
|
+ Id: fmt.Sprintf("only_Identifying:%s", onlyIdentifying),
|
|
|
|
+ Notes: remark,
|
|
|
|
+ Lxdh: gconv.String(m["phone"]),
|
|
|
|
+ Fhr: g.Cfg().MustGet(ctx, "company.hfr", "贺鹏飞").String(),
|
|
|
|
+ Xsfkhh: g.Cfg().MustGet(ctx, "company.bank", "").String(),
|
|
|
|
+ Xsfyhzh: g.Cfg().MustGet(ctx, "company.bankNum", "").String(),
|
|
InvoiceArr: []MakeInvoiceItems{{
|
|
InvoiceArr: []MakeInvoiceItems{{
|
|
Xmmc: consts.GetTaxCodeByName(invoiceContent), //开票项
|
|
Xmmc: consts.GetTaxCodeByName(invoiceContent), //开票项
|
|
WhStatus: 1, //开票项是否维护
|
|
WhStatus: 1, //开票项是否维护
|
|
@@ -144,6 +153,9 @@ func (im *InvoiceManager) multipleOrdersMakeInvoice(ctx context.Context) (total,
|
|
if iType == "单位" {
|
|
if iType == "单位" {
|
|
c.Gmfmc = gconv.String(m["company_name"])
|
|
c.Gmfmc = gconv.String(m["company_name"])
|
|
c.Gmfnsrsbh = gconv.String(m["taxpayer_identnum"])
|
|
c.Gmfnsrsbh = gconv.String(m["taxpayer_identnum"])
|
|
|
|
+ c.Gmfdz = gconv.String(m["company_address"]) //"购买方地址"
|
|
|
|
+ c.Yhyywdmc = gconv.String(m["bank_name"]) //"购买方开户行"
|
|
|
|
+ c.Yhzh = gconv.String(m["bank_account"]) //"购买方银行账号"
|
|
} else {
|
|
} else {
|
|
c.Gmfmc = iType
|
|
c.Gmfmc = iType
|
|
}
|
|
}
|
|
@@ -215,7 +227,7 @@ func (im *InvoiceManager) multipleOrdersMakeRedInvoice(ctx context.Context) (tot
|
|
res gdb.Result
|
|
res gdb.Result
|
|
)
|
|
)
|
|
//冲红任务
|
|
//冲红任务
|
|
- res, err = g.DB().Query(ctx, "SELECT invoice_number,billing_time FROM invoice a WHERE a.invoice_variety like '%电子%' AND a.invoice_status=0 AND a.invoice_changed=1 AND a.invoice_order_code like '%,%' AND a.create_time > ? GROUP BY invoice_order_code", consts.InvoiceStartTime.Unix())
|
|
|
|
|
|
+ res, err = g.DB().Query(ctx, "SELECT invoice_number,billing_time FROM invoice a WHERE a.invoice_variety like '%电子%' AND a.invoice_status=0 AND a.invoice_changed=1 AND a.invoice_order_code like '%,%' AND a.create_time > ? GROUP BY only_Identifying", consts.InvoiceStartTime.Unix())
|
|
if err != nil {
|
|
if err != nil {
|
|
err = gerror.Wrap(err, "multipleOrdersMakeRedInvoice-查询待冲红订单异常")
|
|
err = gerror.Wrap(err, "multipleOrdersMakeRedInvoice-查询待冲红订单异常")
|
|
return
|
|
return
|