|
@@ -6,6 +6,8 @@ import (
|
|
|
"fmt"
|
|
|
"time"
|
|
|
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
+
|
|
|
. "bp.jydev.jianyu360.cn/BaseService/orderCenter/entity"
|
|
|
"bp.jydev.jianyu360.cn/BaseService/orderCenter/rpc/ordercenter"
|
|
|
)
|
|
@@ -21,7 +23,8 @@ func GetOrderCode(*ordercenter.GetOrderCodeReq) *ordercenter.GetOrderCodeResp {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func OrderAddUpdate(this *ordercenter.OrderAddUpdateReq) *ordercenter.OrderAddUpdateResp {
|
|
|
+func OrderAdd(this *ordercenter.OrderAddUpdateReq) *ordercenter.OrderAddUpdateResp {
|
|
|
+ status := 0
|
|
|
orderCode := fmt.Sprint(Node.Generate())
|
|
|
flag := false
|
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
@@ -49,7 +52,6 @@ func OrderAddUpdate(this *ordercenter.OrderAddUpdateReq) *ordercenter.OrderAddUp
|
|
|
}
|
|
|
return orderId > 0 && extendId > 0 && isOk1 && isOk2
|
|
|
})
|
|
|
- status := 0
|
|
|
if flag {
|
|
|
status = 1
|
|
|
}
|
|
@@ -59,6 +61,86 @@ func OrderAddUpdate(this *ordercenter.OrderAddUpdateReq) *ordercenter.OrderAddUp
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func OrderUpdate(this *ordercenter.OrderAddUpdateReq) *ordercenter.OrderAddUpdateResp {
|
|
|
+ status := 0
|
|
|
+ if this.OrderCode != "" {
|
|
|
+ flag := false
|
|
|
+ // nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
|
+ flag = Mysql.ExecTx("", func(tx *sql.Tx) bool {
|
|
|
+ isOk1, isOk2, isOk3 := true, true, true
|
|
|
+ if this.Order.UserId > 0 {
|
|
|
+ ok := Mysql.UpdateByTx(tx, Order, map[string]interface{}{"appid": this.Appid, "order_code": this.OrderCode}, map[string]interface{}{
|
|
|
+ "order_money": this.Order.OrderMoney,
|
|
|
+ "original_price": this.Order.OriginalPrice,
|
|
|
+ "order_status": this.Order.OrderStatus,
|
|
|
+ "user_id": this.Order.UserId,
|
|
|
+ "ent_id": this.Order.EntId,
|
|
|
+ })
|
|
|
+ if !ok {
|
|
|
+ isOk1 = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if this.OrderExtend != nil {
|
|
|
+ ok := Mysql.UpdateByTx(tx, OrderExtend, map[string]interface{}{"appid": this.Appid, "order_code": this.OrderCode}, map[string]interface{}{
|
|
|
+ "pay_type": this.OrderExtend.PayType,
|
|
|
+ "source": this.OrderExtend.Source,
|
|
|
+ "dis_word": this.OrderExtend.DisWord,
|
|
|
+ "iscan_invoice": this.OrderExtend.IscanInvoice,
|
|
|
+ "iscan_evaluate": this.OrderExtend.IscanEvaluate,
|
|
|
+ })
|
|
|
+ if !ok {
|
|
|
+ isOk2 = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if this.OrderBusiness.GoodsSpecId != 0 {
|
|
|
+ ok := Mysql.UpdateByTx(tx, OrderBusiness, map[string]interface{}{"appid": this.Appid, "order_code": this.OrderCode}, map[string]interface{}{
|
|
|
+ "service_status": this.OrderBusiness.ServiceStatus,
|
|
|
+ "service_time": this.OrderBusiness.ServiceTime,
|
|
|
+ "filter": this.OrderBusiness.Filter,
|
|
|
+ "filter_keys": this.OrderBusiness.FilterKeys,
|
|
|
+ "filter_publishtime": this.OrderBusiness.FilterPublishtime,
|
|
|
+ "data_count": this.OrderBusiness.DataCount,
|
|
|
+ "filter_id": this.OrderBusiness.FilterId,
|
|
|
+ "download_url": this.OrderBusiness.DownloadUrl,
|
|
|
+ "goods_code": this.OrderBusiness.GoodsCode,
|
|
|
+ "goods_spec_id": this.OrderBusiness.GoodsSpecId,
|
|
|
+ "user_phone": this.OrderBusiness.UserPhone,
|
|
|
+ "user_mail": this.OrderBusiness.UserMail,
|
|
|
+ })
|
|
|
+ if !ok {
|
|
|
+ isOk3 = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return isOk1 && isOk2 && isOk3
|
|
|
+ })
|
|
|
+ if flag {
|
|
|
+ status = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return &ordercenter.OrderAddUpdateResp{
|
|
|
+ ErrorCode: 1,
|
|
|
+ Data: &ordercenter.DataStatus{Status: int64(status)},
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func OrderStatusUpdate(this *ordercenter.OrderStatusUpdateReq) *ordercenter.OrderAddUpdateResp {
|
|
|
+ status, ok := 0, false
|
|
|
+ if this.OrderCode != "" && this.OrderStatus != 0 {
|
|
|
+ if this.DataType == 1 {
|
|
|
+ ok = Mysql.Update(Order, map[string]interface{}{"appid": this.Appid, "order_code": this.OrderCode}, map[string]interface{}{"order_status": this.OrderStatus})
|
|
|
+ } else {
|
|
|
+ ok = JyMysql.Update(OrderOld, map[string]interface{}{"order_code": this.OrderCode}, map[string]interface{}{"order_status": this.OrderStatus})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ok {
|
|
|
+ status = 1
|
|
|
+ }
|
|
|
+ return &ordercenter.OrderAddUpdateResp{
|
|
|
+ ErrorCode: 1,
|
|
|
+ Data: &ordercenter.DataStatus{Status: int64(status)},
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func OrderDel(this *ordercenter.OrderDelReq) *ordercenter.OrderAddUpdateResp {
|
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
|
ok := Mysql.Update(Order, map[string]interface{}{"appid": this.Appid, "order_code": this.OrderCode}, map[string]interface{}{"del_time": nowTime, "del_status": 1})
|
|
@@ -73,18 +155,48 @@ func OrderDel(this *ordercenter.OrderDelReq) *ordercenter.OrderAddUpdateResp {
|
|
|
}
|
|
|
|
|
|
func OrderList(this *ordercenter.OrderListReq) *ordercenter.OrderListResp {
|
|
|
- OrderLists := []*ordercenter.OrderAddUpdateReq{}
|
|
|
- order := Mysql.Find(Order, map[string]interface{}{"appid": this.Appid, "user_id": this.UserId}, "", "", 0, 0)
|
|
|
- if order != nil && len(*order) > 0 {
|
|
|
- for _, v := range *order {
|
|
|
- orderData1 := &ordercenter.OrderAddUpdateReq{}
|
|
|
+ OrderLists := []*ordercenter.OrderLists{}
|
|
|
+ orderNew := Mysql.Find(Order, map[string]interface{}{"appid": this.Appid, "user_id": this.NewUserId}, "", "create_time desc", -1, -1)
|
|
|
+ orderOld := JyMysql.Find(OrderOld, map[string]interface{}{"user_id": this.UserId}, "", "create_time desc", -1, -1)
|
|
|
+ if orderNew != nil && len(*orderNew) > 0 {
|
|
|
+ for _, v := range *orderNew {
|
|
|
+ orderData1 := &ordercenter.OrderLists{}
|
|
|
orderData2 := &ordercenter.Order{}
|
|
|
orderByte, _ := json.Marshal(v)
|
|
|
json.Unmarshal(orderByte, orderData2)
|
|
|
orderData1.Order = orderData2
|
|
|
+ orderData1.OrderCode = common.ObjToString(v["order_code"])
|
|
|
+ OrderLists = append(OrderLists, orderData1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if orderOld != nil && len(*orderOld) > 0 {
|
|
|
+ for _, v := range *orderOld {
|
|
|
+ orderData1 := &ordercenter.OrderLists{
|
|
|
+ OrderCode: common.ObjToString(v["order_code"]),
|
|
|
+ Order: &ordercenter.Order{
|
|
|
+ OrderMoney: common.Int64All(v["order_money"]),
|
|
|
+ OriginalPrice: common.Int64All(v["original_price"]),
|
|
|
+ OrderStatus: common.Int64All(v["order_ststus"]),
|
|
|
+ },
|
|
|
+ OrderBusiness: &ordercenter.OrderBusiness{
|
|
|
+ ServiceStatus: common.Int64All(v["service_status"]),
|
|
|
+ Filter: common.ObjToString(v["filter"]),
|
|
|
+ FilterKeys: common.ObjToString(v["filter_keys"]),
|
|
|
+ FilterPublishtime: common.ObjToString(v["filter_publishtime"]),
|
|
|
+ ServiceTime: common.ObjToString(v["service_time"]),
|
|
|
+ DataCount: common.Int64All(v["data_count"]),
|
|
|
+ FilterId: common.ObjToString(v["filter_id"]),
|
|
|
+ DownloadUrl: common.ObjToString(v["download_url"]),
|
|
|
+ UserPhone: common.ObjToString(v["user_phone"]),
|
|
|
+ UserMail: common.ObjToString(v["user_mail"]),
|
|
|
+ // GoodsCode: 0,
|
|
|
+ // GoodsSpecId: 0,
|
|
|
+ },
|
|
|
+ }
|
|
|
OrderLists = append(OrderLists, orderData1)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return &ordercenter.OrderListResp{
|
|
|
ErrorCode: 1,
|
|
|
Data: &ordercenter.OrderList{OrderList: OrderLists},
|