|
@@ -46,9 +46,10 @@ func Detail(ctx context.Context, param model.OrderDetailParams) (map[string]inte
|
|
|
orderMap["pay_way"] = "测试使用"
|
|
|
}
|
|
|
orderMap["pure_amount"] = common.If(gconv.Int(orderMap["pay_money"])-gconv.Int(orderMap["commission"]) > 0, gconv.Int(orderMap["pay_money"])-gconv.Int(orderMap["commission"]), 0)
|
|
|
- result["orderData"] = orderMap
|
|
|
+
|
|
|
//产品
|
|
|
productData, err := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM jy_order_detail WHERE order_code =%s `, param.OrderCode))
|
|
|
+ var productArr []map[string]interface{}
|
|
|
if err != nil || productData.IsEmpty() {
|
|
|
return nil, err
|
|
|
}
|
|
@@ -59,24 +60,39 @@ func Detail(ctx context.Context, param model.OrderDetailParams) (map[string]inte
|
|
|
m["activityName"] = gconv.String(activityData.Map()["name"])
|
|
|
}
|
|
|
}
|
|
|
- productItem, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT jpi.name,jpc.auto FROM jy_product_item jpi
|
|
|
+ productItem, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT jpi.name,jpc.auto,jpc.code FROM jy_product_item jpi
|
|
|
INNER JOIN jy_product_class jpc on jpi.product_class_id = jpc.id WHERE jpi.code = '%s'`, gconv.String(m["product_code"])))
|
|
|
if !productItem.IsEmpty() {
|
|
|
m["productName"] = productItem.Map()["name"]
|
|
|
+ m["productItemCode"] = productItem.Map()["code"]
|
|
|
m["auto"] = productItem.Map()["auto"]
|
|
|
+ } else {
|
|
|
+ m["productName"] = productItem.Map()["product_type"]
|
|
|
}
|
|
|
+
|
|
|
if gconv.String(m["product_type"]) == "大会员" && gconv.Int(gconv.Map(m["filter"])["comboId"]) == 0 {
|
|
|
supMap := make(map[string]bool)
|
|
|
for _, s := range gconv.Strings(gconv.Map(m["filter"])["supServiceIds"]) {
|
|
|
supMap[s] = true
|
|
|
}
|
|
|
- bigService, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT id,s_name FROM bigmember_service WHERE id in (%s) order by id`, gconv.Strings(gconv.Map(m["filter"])["serviceId"])))
|
|
|
+ var ids []string
|
|
|
+ serviceIds := gconv.Strings(gconv.Map(m["filter"])["serviceIds"])
|
|
|
+ for _, id := range serviceIds {
|
|
|
+ ids = append(serviceIds, gconv.String(id))
|
|
|
+ }
|
|
|
+ bigService, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT id,s_name FROM bigmember_service WHERE id in (%s) order by id`, strings.Join(ids, ",")))
|
|
|
if !bigService.IsEmpty() {
|
|
|
var (
|
|
|
bigServiceNames []string
|
|
|
supBigServiceNames []string
|
|
|
)
|
|
|
for _, m1 := range bigService.List() {
|
|
|
+ switch gconv.Int(m1["id"]) {
|
|
|
+ case 1:
|
|
|
+ m1["s_name"] = "基础服务"
|
|
|
+ case 30051, 30052, 30053: //0分报告过滤
|
|
|
+ continue
|
|
|
+ }
|
|
|
if supMap[gconv.String(m1["id"])] {
|
|
|
supBigServiceNames = append(supBigServiceNames, gconv.String(m1["s_name"]))
|
|
|
} else {
|
|
@@ -87,7 +103,6 @@ INNER JOIN jy_product_class jpc on jpi.product_class_id = jpc.id WHERE jpi.code
|
|
|
m["bigServiceNames"] = fmt.Sprintf("[补充服务]: %s ;[原已购服务]:%s", strings.Join(supBigServiceNames, "、"), strings.Join(bigServiceNames, "、"))
|
|
|
} else {
|
|
|
m["bigServiceNames"] = strings.Join(bigServiceNames, "、")
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -199,10 +214,11 @@ WHERE eo.wait_empower_id = %s and jod.is_service_open =1 ORDER BY do.create_time
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ productArr = append(productArr, m)
|
|
|
}
|
|
|
- result["productData"] = productData.List()
|
|
|
+ result["productData"] = productArr
|
|
|
//对公转账审核记录
|
|
|
- orderTransfer, _ := g.DB().Query(ctx, "jy_order_transfer", fmt.Sprintf(`SELECT * FROM jy_order_transfer WHERE order_code = '%s' order by create_time desc `, param.OrderCode))
|
|
|
+ orderTransfer, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM jy_order_transfer WHERE order_code = '%s' order by create_time desc `, param.OrderCode))
|
|
|
if !orderTransfer.IsEmpty() {
|
|
|
result["orderTransfer"] = orderTransfer.List()
|
|
|
}
|
|
@@ -211,6 +227,7 @@ WHERE eo.wait_empower_id = %s and jod.is_service_open =1 ORDER BY do.create_time
|
|
|
//佣金 手续费 合同金额 企业
|
|
|
isCommission, isProceduresMoney, isCash, isEnt bool
|
|
|
newEntName string
|
|
|
+ moneyCorrectionArr []map[string]interface{}
|
|
|
)
|
|
|
//红冲
|
|
|
redPunch := make(map[string]interface{})
|
|
@@ -240,41 +257,41 @@ WHERE eo.wait_empower_id = %s and jod.is_service_open =1 ORDER BY do.create_time
|
|
|
newEntName = newSigningSubject
|
|
|
}
|
|
|
}
|
|
|
+ moneyCorrectionArr = append(moneyCorrectionArr, m)
|
|
|
}
|
|
|
if newEntName != "" {
|
|
|
- orderData.Map()["return_commpany"] = newEntName
|
|
|
+ orderMap["return_commpany"] = newEntName
|
|
|
}
|
|
|
- redPunch["moneyCorrectionData"] = moneyCorrectionData.List()
|
|
|
- redPunch["isUpCash"] = isCash
|
|
|
- redPunch["isUpCommission"] = isCommission
|
|
|
- redPunch["isUpProceduresMoney"] = isProceduresMoney
|
|
|
- redPunch["isUpEnt"] = isEnt
|
|
|
- result["redPunchData"] = redPunch
|
|
|
}
|
|
|
-
|
|
|
+ result["orderData"] = orderMap
|
|
|
+ redPunch["moneyCorrectionData"] = moneyCorrectionArr
|
|
|
+ redPunch["isUpCash"] = isCash
|
|
|
+ redPunch["isUpCommission"] = isCommission
|
|
|
+ redPunch["isUpProceduresMoney"] = isProceduresMoney
|
|
|
+ redPunch["isUpEnt"] = isEnt
|
|
|
+ result["redPunchData"] = redPunch
|
|
|
//合同
|
|
|
contractData, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT * FROM contract WHERE order_code =%s `, param.OrderCode))
|
|
|
if !contractData.IsEmpty() {
|
|
|
+ contractMap := contractData.Map()
|
|
|
// 合同信息
|
|
|
- if contractData.Map()["contract_file_url"] != nil && len(contractData.Map()["contract_file_url"].(string)) > 0 {
|
|
|
- index_ := strings.LastIndex(contractData.Map()["contract_file_url"].(string), "/")
|
|
|
+ if contractMap["contract_file_url"] != nil && len(contractMap["contract_file_url"].(string)) > 0 {
|
|
|
+ index_ := strings.LastIndex(contractMap["contract_file_url"].(string), "/")
|
|
|
if index_ != -1 {
|
|
|
- contractData.Map()["contract_file_name"] = contractData.Map()["contract_file_url"].(string)[index_+1:]
|
|
|
+ contractMap["contract_file_name"] = contractMap["contract_file_url"].(string)[index_+1:]
|
|
|
}
|
|
|
}
|
|
|
- result["contractRes"] = contractData.Map()
|
|
|
+ result["contractRes"] = contractMap
|
|
|
}
|
|
|
// 回款信息
|
|
|
var (
|
|
|
returnMoney, plantMoney int
|
|
|
+ returnArr []map[string]interface{}
|
|
|
)
|
|
|
|
|
|
returnInfo, _ := g.DB().Query(ctx, fmt.Sprintf("SELECT * from return_money_record WHERE order_code=%s and state=1", param.OrderCode))
|
|
|
// 回款交易详情列表
|
|
|
if !returnInfo.IsEmpty() {
|
|
|
- var (
|
|
|
- returnArr []map[string]interface{}
|
|
|
- )
|
|
|
for _, d := range returnInfo.List() {
|
|
|
returnMoney += gconv.Int(d["return_money"])
|
|
|
if d["return_voucher_url"] != nil && len(d["return_voucher_url"].(string)) > 0 {
|
|
@@ -285,46 +302,42 @@ WHERE eo.wait_empower_id = %s and jod.is_service_open =1 ORDER BY do.create_time
|
|
|
}
|
|
|
returnArr = append(returnArr, d)
|
|
|
}
|
|
|
- result["returnRes"] = map[string]interface{}{
|
|
|
- "returnMoney": returnMoney,
|
|
|
- "remainingMoney": gconv.Int(orderData.Map()["pay_money"]) - returnMoney,
|
|
|
- "returnInfo": returnArr,
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
+ result["returnRes"] = map[string]interface{}{
|
|
|
+ "returnMoney": returnMoney,
|
|
|
+ "remainingMoney": gconv.Int(orderData.Map()["pay_money"]) - returnMoney,
|
|
|
+ "returnInfo": returnArr,
|
|
|
+ }
|
|
|
//回款计划
|
|
|
- returnMoneyPlant, err := g.DB().Query(ctx, "SELECT * from return_money_plant where order_code = ? order by create_time desc", param.OrderCode)
|
|
|
+ returnMoneyPlant, err := g.DB().GetOne(ctx, "SELECT * from return_money_plant where order_code = ? order by create_time desc", param.OrderCode)
|
|
|
if !returnMoneyPlant.IsEmpty() {
|
|
|
- for _, m := range returnMoneyPlant.List() {
|
|
|
- for _, m2 := range gconv.Maps(m["plantList"]) {
|
|
|
- if gconv.String(m2["code"]) == "合计" {
|
|
|
- plantMoney = gconv.Int(m2["money"])
|
|
|
- }
|
|
|
+ for _, m2 := range gconv.Maps(returnMoneyPlant.Map()["plantList"]) {
|
|
|
+ if gconv.String(m2["code"]) == "合计" {
|
|
|
+ plantMoney = gconv.Int(m2["money"])
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
result["returnMoneyPlant"] = map[string]interface{}{
|
|
|
- "list": returnMoneyPlant.List(),
|
|
|
+ "list": returnMoneyPlant.Map(),
|
|
|
"returnMoney": returnMoney,
|
|
|
"plantMoney": plantMoney,
|
|
|
}
|
|
|
//退款
|
|
|
+ var refundMoney int
|
|
|
refundData, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT rr.*,jpi.name FROM refund_record rr
|
|
|
LEFT JOIN jy_order_detail jod on rr.refund_detail_id = jod.id
|
|
|
LEFT JOIN jy_product_item jpi on jod.product_code = jpi.code
|
|
|
WHERE rr.order_code =%s`, param.OrderCode))
|
|
|
if !refundData.IsEmpty() {
|
|
|
- var refundMoney int
|
|
|
for _, datum := range refundData.List() {
|
|
|
refundMoney += gconv.Int(datum["refund_money"])
|
|
|
}
|
|
|
- result["refundRes"] = map[string]interface{}{
|
|
|
- "refundMoney": refundMoney,
|
|
|
- "remainingMoney": gconv.Int(orderData.Map()["pay_money"]) - refundMoney,
|
|
|
- "refundInfo": refundData.List(),
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
+ result["refundRes"] = map[string]interface{}{
|
|
|
+ "refundMoney": refundMoney,
|
|
|
+ "remainingMoney": gconv.Int(orderData.Map()["pay_money"]) - refundMoney,
|
|
|
+ "refundInfo": refundData.List(),
|
|
|
+ }
|
|
|
//审核轨迹详情
|
|
|
recordsData, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM audit_records WHERE order_code =%s and audit_type = 2 order by create_time desc `, param.OrderCode))
|
|
|
if !recordsData.IsEmpty() {
|
|
@@ -358,7 +371,7 @@ WHERE rr.order_code =%s`, param.OrderCode))
|
|
|
var saleData = map[string]interface{}{
|
|
|
"saleEdit": SaleChangePower, //销售业绩变更展示
|
|
|
}
|
|
|
- saleRes, _ := g.DB().Query(ctx, fmt.Sprintf("SELECT d.*,(select a.item_name AS order_parent_name from dict_item a where a.item_code=d.distribution_channel ) AS order_channel_new FROM order_sale_record d WHERE d.ordercode='%s' and d.state in (1,-1,2) order by d.create_time asc", param.OrderCode))
|
|
|
+ saleRes, _ := g.DB().Query(ctx, fmt.Sprintf("SELECT d.*,(select CONCAT_WS('/', a.item_name, a.parent_name) AS order_parent_name from dict_item a where a.item_code=d.distribution_channel ) AS order_channel_new FROM order_sale_record d WHERE d.ordercode='%s' and d.state in (1,-1,2) order by d.create_time asc", param.OrderCode))
|
|
|
if !saleRes.IsEmpty() {
|
|
|
var (
|
|
|
//最终业绩
|
|
@@ -430,20 +443,19 @@ WHERE rr.order_code =%s`, param.OrderCode))
|
|
|
result["saleDataRes"] = saleData
|
|
|
}
|
|
|
//发票信息
|
|
|
+ var invoiceMoney int
|
|
|
invoiceRes, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT *,(
|
|
|
SELECT count(1) as count FROM invoice b WHERE b.order_code = a.order_code and b.only_Identifying is not null and b.only_Identifying = a.only_Identifying
|
|
|
) as isChanged FROM invoice a WHERE order_code = '%s' and invoice_status != -2 and invoice_variety is not null and invoice_variety is not null and invoice_variety not LIKE '%s' ORDER BY create_time DESC`, param.OrderCode, "%纸质%"))
|
|
|
if !invoiceRes.IsEmpty() {
|
|
|
- var invoiceMoney int
|
|
|
for _, datum := range invoiceRes.List() {
|
|
|
invoiceMoney += gconv.Int(datum["invoice_money"])
|
|
|
}
|
|
|
-
|
|
|
- result["invoiceData"] = map[string]interface{}{
|
|
|
- "invoiceMoney": invoiceMoney,
|
|
|
- "remainingMoney": gconv.Int(orderData.Map()["pay_money"]) - invoiceMoney,
|
|
|
- "invoiceInfo": invoiceRes.List(),
|
|
|
- }
|
|
|
+ }
|
|
|
+ result["invoiceData"] = map[string]interface{}{
|
|
|
+ "invoiceMoney": invoiceMoney,
|
|
|
+ "remainingMoney": gconv.Int(orderData.Map()["pay_money"]) - invoiceMoney,
|
|
|
+ "invoiceInfo": invoiceRes.List(),
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|