|
@@ -197,10 +197,8 @@ func (o *OrderListDetails) DeleteOrder() error {
|
|
|
typ := o.GetString("type")
|
|
|
cancel := o.GetString("cancel")
|
|
|
pageNum, _ := o.GetInteger("pageNum")
|
|
|
- log.Println("typ", typ)
|
|
|
if typ != "0" && typ != "" {
|
|
|
var status string
|
|
|
- log.Println("typ", typ)
|
|
|
if typ == "1" {
|
|
|
status = orderStatus_unPaid
|
|
|
} else if typ == "2" {
|
|
@@ -509,6 +507,8 @@ func (o *OrderListDetails) GetEntnicheDetails() {
|
|
|
}
|
|
|
|
|
|
func (o *OrderListDetails) SetRes(res []map[string]interface{}, queryM map[string]interface{}) {
|
|
|
+ entid := o.GetUserEntId() //用户购买的entid
|
|
|
+ ent_ordercode := GetEntOrdercode(queryM, entid)
|
|
|
var create_time_stamp int64 = 0
|
|
|
//获取最后一次购买的vip订单
|
|
|
queryM["product_type"] = "VIP订阅"
|
|
@@ -518,13 +518,7 @@ func (o *OrderListDetails) SetRes(res []map[string]interface{}, queryM map[strin
|
|
|
lastbuy_code = qutil.ObjToString(lastbuy[0]["order_code"])
|
|
|
}
|
|
|
delete(queryM, "product_type")
|
|
|
- queryM["product_type"] = "企业商机管理"
|
|
|
- lastbuy_ent := *util.Mysql.Find(tableName_order, queryM, "order_code,pay_time", "pay_time desc", -1, 0)
|
|
|
- lastbuy_code_ent := ""
|
|
|
- if len(lastbuy_ent) > 0 && lastbuy_ent != nil {
|
|
|
- lastbuy_code_ent = qutil.ObjToString(lastbuy_ent[0]["order_code"])
|
|
|
- }
|
|
|
- delete(queryM, "product_type")
|
|
|
+
|
|
|
for _, v := range res {
|
|
|
//获取单号 如果是vip xx小时取消
|
|
|
order_code := qutil.ObjToString(v["order_code"])
|
|
@@ -579,11 +573,6 @@ func (o *OrderListDetails) SetRes(res []map[string]interface{}, queryM map[strin
|
|
|
if lastbuy_code == v["order_code"] {
|
|
|
v["lastbuy_code"] = lastbuy_code
|
|
|
}
|
|
|
- //最后一次购买的ent订单
|
|
|
- if lastbuy_code_ent == v["order_code"] {
|
|
|
- v["lastbuy_code_ent"] = lastbuy_code_ent
|
|
|
- }
|
|
|
- //
|
|
|
if v["pay_time"] != nil && ((v["product_type"] == "VIP订阅") || (v["product_type"] == "VIP订阅")) {
|
|
|
data, err := util.MQFW.FindOne("user", bson.M{"_id": bson.ObjectIdHex(qutil.ObjToString(o.GetSession("userId")))})
|
|
|
if len(*data) > 0 && err {
|
|
@@ -592,22 +581,16 @@ func (o *OrderListDetails) SetRes(res []map[string]interface{}, queryM map[strin
|
|
|
}
|
|
|
//
|
|
|
if v["pay_time"] != nil && v["product_type"] == "企业商机管理" {
|
|
|
- isExpire := isEntExpire(qutil.ObjToString(o.GetSession("userId")))
|
|
|
- filter := map[string]interface{}{}
|
|
|
- if err := json.Unmarshal([]byte(qutil.ObjToString(v["filter"].(interface{}))), &filter); err == nil {
|
|
|
- ent := util.Mysql.FindOne("entniche_info", map[string]interface{}{
|
|
|
- "name": filter["entname"],
|
|
|
- "phone": filter["phone"],
|
|
|
- }, "startdate,enddate", "id desc")
|
|
|
- //计算周期
|
|
|
- start_year := time.Unix(qutil.Int64All((*ent)["startdate"]), 0).Format("2006")
|
|
|
- end_year := time.Unix(qutil.Int64All((*ent)["enddate"]), 0).Format("2006")
|
|
|
- effective_cycle := qutil.IntAll(end_year) - qutil.IntAll(start_year) //生效周期
|
|
|
- if isExpire && effective_cycle < 2 {
|
|
|
- v["i_ent_status"] = true
|
|
|
+ if IsContain(ent_ordercode, qutil.ObjToString(v["order_code"])) {
|
|
|
+ renew, repurchase := isEntExpire(qutil.ObjToString(o.GetSession("userId")), qutil.ObjToString(v["order_code"]))
|
|
|
+ if renew {
|
|
|
+ v[qutil.ObjToString(v["order_code"])] = true
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if repurchase {
|
|
|
+ v[qutil.ObjToString(v["order_code"])] = false
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -671,7 +654,6 @@ func isEmail(value string) bool {
|
|
|
|
|
|
//获取支付单号
|
|
|
func getPayTransactionId(payWay, tradeNo string) (transaction_id string) {
|
|
|
- log.Println(payWay, tradeNo)
|
|
|
if payWay == "" || tradeNo == "" {
|
|
|
return
|
|
|
}
|
|
@@ -724,35 +706,80 @@ func FortyEightHoursCancel(order string, create_time_stamp, now_time_stamp int64
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//判断用户购买的企业商机管理是否到期
|
|
|
-func isEntExpire(userid string) bool {
|
|
|
+//判断用户购买的企业商机管理是否显示续费按钮 --返回值第一个参数 是判断是否显示续费按钮 第二个参数 是判断是否显示再次购买按钮
|
|
|
+func isEntExpire(userid, order_code string) (bool, bool) {
|
|
|
u, ok := util.MQFW.FindById("user", userid, `{"s_phone":1}`)
|
|
|
if ok && u != nil && (*u)["s_phone"] != nil {
|
|
|
- // list := util.Mysql.SelectBySql(`SELECT DISTINCT a.id,a.name,a.phone,a.startdate,a.enddate from entniche_info a
|
|
|
- // INNER JOIN entniche_user b on (a.id=b.ent_id)
|
|
|
- // where a.phone=? or b.phone=?
|
|
|
- // order by convert(a.name using gbk) COLLATE gbk_chinese_ci asc`, (*u)["s_phone"].(string), (*u)["s_phone"].(string))
|
|
|
- list := util.Mysql.SelectBySql(`select filter from dataexport_order where user_id=? and product_type=? and order_status=?`, userid, "企业商机管理", 1)
|
|
|
- if len(*list) > 0 {
|
|
|
- for _, v := range *list {
|
|
|
- filterStr := qutil.ObjToString(v["filter"])
|
|
|
- var filter map[string]interface{}
|
|
|
- if err := json.Unmarshal([]byte(filterStr), &filter); err != nil {
|
|
|
- log.Printf("%s 判断用户购买的企业商机管理是否到期 isEntExpire Unmarshal 出错 [%s]\n", userid, filterStr)
|
|
|
- return false
|
|
|
+ //list := util.Mysql.SelectBySql(`select filter from dataexport_order where user_id=? and product_type=? and order_status=?`, userid, "企业商机管理", 1)
|
|
|
+ list := util.Mysql.FindOne("dataexport_order", bson.M{"order_code": order_code}, "filter", "")
|
|
|
+ if list != nil {
|
|
|
+ //for _, v := range *list {
|
|
|
+ filterStr := qutil.ObjToString((*list)["filter"])
|
|
|
+ var filter map[string]interface{}
|
|
|
+ if err := json.Unmarshal([]byte(filterStr), &filter); err != nil {
|
|
|
+ log.Printf("%s 判断用户购买的企业商机管理是否到期 isEntExpire Unmarshal 出错 [%s]\n", userid, filterStr)
|
|
|
+ return false, false
|
|
|
+ }
|
|
|
+ date := util.Mysql.FindOne("entniche_info", bson.M{"name": qutil.ObjToString(filter["entname"])}, "startdate,enddate", "")
|
|
|
+ if date != nil {
|
|
|
+ startdate := qutil.Int64All((*date)["startdate"])
|
|
|
+ enddate := qutil.Int64All((*date)["enddate"])
|
|
|
+ start_year := time.Unix(qutil.Int64All((*date)["startdate"]), 0).Format("2006")
|
|
|
+ end_year := time.Unix(qutil.Int64All((*date)["enddate"]), 0).Format("2006")
|
|
|
+ effective_cycle := qutil.IntAll(end_year) - qutil.IntAll(start_year) //生效周期
|
|
|
+ now := time.Now().Unix()
|
|
|
+ if now >= startdate && now < enddate && effective_cycle < 3 {
|
|
|
+ return true, false
|
|
|
}
|
|
|
- date := util.Mysql.FindOne("entniche_info", bson.M{"name": qutil.ObjToString(filter["entname"])}, "startdate,enddate", "")
|
|
|
- log.Println(date)
|
|
|
- if date != nil {
|
|
|
- startdate := qutil.Int64All((*date)["startdate"])
|
|
|
- enddate := qutil.Int64All((*date)["enddate"])
|
|
|
- log.Println(startdate)
|
|
|
- now := time.Now().Unix()
|
|
|
- if now >= startdate && now < enddate {
|
|
|
- return true
|
|
|
- }
|
|
|
+ if now > enddate {
|
|
|
+ return false, true
|
|
|
}
|
|
|
}
|
|
|
+ //}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false, false
|
|
|
+}
|
|
|
+
|
|
|
+func (o *OrderListDetails) GetUserEntId() []int {
|
|
|
+ userid := o.GetSession("userId").(string)
|
|
|
+ ids := []int{}
|
|
|
+ if userid != "" {
|
|
|
+ phone, ok := util.MQFW.FindById("user", userid, "s_phone")
|
|
|
+ if ok && (*phone)["s_phone"] != nil {
|
|
|
+ id := util.Mysql.Find("entniche_info", bson.M{"phone": qutil.ObjToString((*phone)["s_phone"])}, "id", "", -1, -1)
|
|
|
+ if id != nil {
|
|
|
+ for _, v := range *id {
|
|
|
+ ids = append(ids, qutil.IntAll(v["id"]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ids
|
|
|
+}
|
|
|
+
|
|
|
+func GetEntOrdercode(query map[string]interface{}, entid []int) []string {
|
|
|
+ //获取购买的所有企业最近一次的ordercode
|
|
|
+ entordercode := []string{}
|
|
|
+ query["product_type"] = "企业商机管理"
|
|
|
+ for _, v := range entid {
|
|
|
+ query["filter_id"] = v
|
|
|
+ lastbuy_ent := *util.Mysql.Find(tableName_order, query, "order_code,pay_time", "pay_time desc", -1, 0)
|
|
|
+ if len(lastbuy_ent) > 0 && lastbuy_ent != nil {
|
|
|
+ entordercode = append(entordercode, qutil.ObjToString(lastbuy_ent[0]["order_code"]))
|
|
|
+ }
|
|
|
+ delete(query, "filter")
|
|
|
+
|
|
|
+ }
|
|
|
+ delete(query, "product_type")
|
|
|
+ return entordercode
|
|
|
+}
|
|
|
+
|
|
|
+//判断数组是否包含
|
|
|
+func IsContain(slice []string, s string) bool {
|
|
|
+ for _, qq := range slice {
|
|
|
+ if qq == s {
|
|
|
+ return true
|
|
|
}
|
|
|
}
|
|
|
return false
|