|
@@ -5,6 +5,7 @@ import (
|
|
|
"fmt"
|
|
|
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
+ "github.com/gogf/gf/v2/os/gfile"
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
|
"github.com/google/uuid"
|
|
|
"strings"
|
|
@@ -39,7 +40,9 @@ var (
|
|
|
codeDeptMapping = map[string]*newDept{}
|
|
|
beforeMoneyMap = map[string]int{} //红冲单子
|
|
|
hasSaleMap = map[string]bool{} //已存在业绩
|
|
|
- table = "order_sale_record_release"
|
|
|
+ table = "order_sale_record_release1"
|
|
|
+
|
|
|
+ updateSaleTimeMapping = map[string]interface{}{}
|
|
|
)
|
|
|
|
|
|
type (
|
|
@@ -163,6 +166,28 @@ func CreateSaleRecord(ctx context.Context) {
|
|
|
statistics_time = gconv.String(m["pay_time"])
|
|
|
}
|
|
|
}
|
|
|
+ if statistics_time != sale_time && statistics_time != "" {
|
|
|
+ isSame := false
|
|
|
+ if sale_time != "" {
|
|
|
+ newData, old := "", ""
|
|
|
+ if arr := strings.Split(statistics_time, " "); len(arr) == 2 {
|
|
|
+ newData = arr[0]
|
|
|
+ }
|
|
|
+ if arr := strings.Split(sale_time, " "); len(arr) == 2 {
|
|
|
+ old = arr[0]
|
|
|
+ }
|
|
|
+ if newData == old && newData != "" {
|
|
|
+ isSame = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !isSame {
|
|
|
+ updateSaleTimeMapping[order_code] = map[string]interface{}{
|
|
|
+ "old_sale_time": sale_time,
|
|
|
+ "new_sale_time": statistics_time,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if salesperson_id != "" {
|
|
|
if strings.Contains(salesperson, ",") {
|
|
@@ -287,9 +312,14 @@ func CreateSaleRecord(ctx context.Context) {
|
|
|
SaveDb(ctx, insertArr)
|
|
|
insertArr = []map[string]interface{}{}
|
|
|
}
|
|
|
+ g.Log().Printf(ctx, "%d", len(updateSaleTimeMapping))
|
|
|
+ if err := gfile.PutContents("./aaa.json", gconv.String(updateSaleTimeMapping)); err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func SaveDb(ctx context.Context, data []map[string]interface{}) {
|
|
|
+ return
|
|
|
_, err := g.DB().Save(ctx, table, data, 10)
|
|
|
if err != nil {
|
|
|
g.Log().Errorf(ctx, "插入数据异常 %v", err)
|