123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package main
- import (
- qu "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/mysql"
- "encoding/json"
- "log"
- )
- type sysConfig struct {
- Mysql map[string]interface{} `json:"mysql"`
- }
- var SysConfig sysConfig
- var Mysql *mysql.Mysql
- func init() {
- qu.ReadConfig("./config.json", &SysConfig)
- Mysql = &mysql.Mysql{
- Address: SysConfig.Mysql["address"].(string),
- UserName: SysConfig.Mysql["userName"].(string),
- PassWord: SysConfig.Mysql["passWord"].(string),
- DBName: SysConfig.Mysql["dbName"].(string),
- MaxOpenConns: qu.IntAll(SysConfig.Mysql["maxOpenConns"]),
- MaxIdleConns: qu.IntAll(SysConfig.Mysql["maxIdleConns"]),
- }
- Mysql.Init()
- }
- func main() {
- log.Println("回款信息同步。。。开始")
- query := `select order_code,filter from dataexport_order where (locate('"isAll":1', filter) > 0 or locate('"isAll":2', filter) > 0 or locate('"isAll":3', filter) > 0)`
- log.Println("query :", query)
- data := Mysql.SelectBySql(query)
- if data != nil && *data != nil && len(*data) > 0 {
- for _, v := range *data {
- order_code := qu.ObjToString(v["order_code"])
- filterMap := map[string]interface{}{}
- filterData := qu.ObjToString(v["filter"])
- if err := json.Unmarshal([]byte(filterData), &filterMap); err == nil {
- transferV := qu.ObjToString(filterMap["transferV"])
- transferVTime := qu.ObjToString(filterMap["transferVTime"])
- isAll := qu.IntAll(filterMap["isAll"])
- return_status := 0
- if transferV != "" {
- refund_id := Mysql.Insert("return_money_record", map[string]interface{}{
- "order_code": order_code,
- "return_time": transferVTime,
- "return_voucher_url": transferV,
- "operate_time": qu.NowFormat(qu.Date_Full_Layout),
- "state": 1,
- })
- if refund_id > 0 {
- log.Println("回款表插入成功 ", order_code)
- } else {
- log.Println("回款表插入失败 ", order_code)
- }
- }
- if filterMap["collects"] != nil {
- collects := qu.ObjArrToMapArr(filterMap["collects"].([]interface{}))
- for _, vv := range collects {
- tV := qu.ObjToString(vv["transferV"])
- tVTime := qu.ObjToString(vv["transferVTime"])
- price := qu.IntAll(vv["price"]) * 100
- refund_id := Mysql.Insert("return_money_record", map[string]interface{}{
- "order_code": order_code,
- "return_time": tVTime,
- "return_voucher_url": tV,
- "operate_time": qu.NowFormat(qu.Date_Full_Layout),
- "return_money": price,
- "state": 1,
- })
- if refund_id > 0 {
- log.Println("回款表collects插入成功 ", order_code)
- } else {
- log.Println("回款表collects插入失败 ", order_code)
- }
- }
- }
- if isAll > 0 {
- if isAll == 1 {
- return_status = 1
- } else if isAll == 2 {
- return_status = 0
- } else if isAll == 3 {
- return_status = 2
- }
- ok := Mysql.Update("dataexport_order", map[string]interface{}{"order_code": order_code}, map[string]interface{}{"return_status": return_status})
- if ok {
- log.Println("回款状态修改成功 ", order_code)
- }
- }
- }
- }
- } else {
- log.Println("未查询到回款数据")
- }
- log.Println("回款信息同步。。。结束")
- }
|