|
@@ -7,7 +7,9 @@ import (
|
|
|
"log"
|
|
|
qutil "qfw/util"
|
|
|
// "strings"
|
|
|
+ "fmt"
|
|
|
"pay"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
"util"
|
|
@@ -38,6 +40,7 @@ func (this *RenewUpgrade) GetBuyMsg() {
|
|
|
start := time.Unix(starttime, 0).Format("2006-01-02")
|
|
|
endtime := qutil.Int64All((*data)["l_vip_endtime"])
|
|
|
end := time.Unix(endtime, 0).Format("2006-01-02")
|
|
|
+ now := time.Unix(time.Now().Unix(), 0).Format("2006-01-02")
|
|
|
areaArr := qutil.ObjToMap(area)
|
|
|
buyerclassArr := qutil.ObjArrToStringArr(buyerclass.([]interface{}))
|
|
|
monthprice := entity.JyVipSubStruct.GetSubVipPrice(areaArr, buyerclassArr, 1, 2)
|
|
@@ -54,6 +57,7 @@ func (this *RenewUpgrade) GetBuyMsg() {
|
|
|
"endtime": endtime,
|
|
|
"start": start,
|
|
|
"end": end,
|
|
|
+ "now": now,
|
|
|
"monthprice": float64(monthprice) / 100,
|
|
|
"yearprice": float64(yearprice) / 100,
|
|
|
}
|
|
@@ -121,6 +125,8 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
|
|
|
industry := strings.Split(this.GetString("industry"), ",")
|
|
|
date := this.GetString("time")
|
|
|
payWay := this.GetString("payWay")
|
|
|
+ effect := this.GetString("effect")
|
|
|
+ pay_source := this.GetString("pay_source")
|
|
|
userId := qutil.ObjToString(this.GetSession("userId"))
|
|
|
openId := qutil.ObjToString(this.GetSession("s_m_openid"))
|
|
|
r := func() *entity.FuncResult {
|
|
@@ -132,27 +138,64 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
|
|
|
if !(payWay == "wx_js" || payWay == "wx_app" || payWay == "ali_app") {
|
|
|
return &entity.FuncResult{false, errors.New("未知支付"), nil}
|
|
|
}
|
|
|
- date_count, date_unit, err := checkReqDate(date)
|
|
|
- if err != nil {
|
|
|
- return &entity.FuncResult{false, err, nil}
|
|
|
+ var date_count int
|
|
|
+ var date_unit int
|
|
|
+ var pro_count int
|
|
|
+ var pro_unit int
|
|
|
+ var err error
|
|
|
+ if effect != "" {
|
|
|
+ if date != "" {
|
|
|
+ pro_count, pro_unit, err = checkReqDates(date)
|
|
|
+ if err != nil {
|
|
|
+ return &entity.FuncResult{false, err, nil}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ date_count, date_unit, err = checkReqDates(date)
|
|
|
+ if err != nil {
|
|
|
+ return &entity.FuncResult{false, err, nil}
|
|
|
+ }
|
|
|
}
|
|
|
+ log.Println("effect", effect)
|
|
|
+ log.Println("pay_source", pay_source)
|
|
|
+ log.Println("pro_count", pro_count)
|
|
|
+ log.Println("pro_unit", pro_unit)
|
|
|
+ log.Println("effect", effect)
|
|
|
log.Println(area, industry, date, payWay)
|
|
|
- //插入订单表
|
|
|
- mog_id := util.MQFW.Save("subvip_select", map[string]interface{}{
|
|
|
- "o_area": area, //地区(对象)
|
|
|
- "a_industry": industry, //行业(数组)
|
|
|
- "s_userid": userId,
|
|
|
- "s_openid": openId,
|
|
|
- "i_cyclecount": date_count, //时长
|
|
|
- "i_cycleunit": date_unit, //单位
|
|
|
- "i_comeintime": now.Unix(),
|
|
|
- })
|
|
|
+ mog_id := ""
|
|
|
+ if effect != "" {
|
|
|
+ //插入订单表
|
|
|
+ mog_id = util.MQFW.Save("subvip_select", map[string]interface{}{
|
|
|
+ "o_area": area, //地区(对象)
|
|
|
+ "a_industry": industry, //行业(数组)
|
|
|
+ "s_userid": userId,
|
|
|
+ "s_openid": openId,
|
|
|
+ "i_comeintime": now.Unix(),
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ mog_id = util.MQFW.Save("subvip_select", map[string]interface{}{
|
|
|
+ "o_area": area, //地区(对象)
|
|
|
+ "a_industry": industry, //行业(数组)
|
|
|
+ "s_userid": userId,
|
|
|
+ "s_openid": openId,
|
|
|
+ "i_cyclecount": date_count, //时长
|
|
|
+ "i_cycleunit": date_unit, //单位
|
|
|
+ "i_comeintime": now.Unix(),
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
if mog_id == "" {
|
|
|
return &entity.FuncResult{false, errors.New("创建订单出错"), nil}
|
|
|
}
|
|
|
//计算价格
|
|
|
- //totalfee := entity.GetSubVipPrice(area, industry, date_count, date_unit)
|
|
|
- totalfee := 1
|
|
|
+ var totalfee int
|
|
|
+ if effect != "" {
|
|
|
+ totalfee = qutil.IntAll(this.GetString("price")) * 100
|
|
|
+ } else {
|
|
|
+ totalfee = entity.JyVipSubStruct.GetSubVipPrice(area, industry, date_count, date_unit)
|
|
|
+ }
|
|
|
+ log.Println("price", totalfee)
|
|
|
+
|
|
|
//创建订单
|
|
|
tradeno, prepayid, payStr := "", "", ""
|
|
|
|
|
@@ -185,13 +228,27 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
|
|
|
prepayid = qutil.ObjToString((*ret)["prepayid"])
|
|
|
payStr = pay.WxStruct.GetAppWxPayStr(prepayid)
|
|
|
}
|
|
|
- filter := entity.VipSimpleMsg{
|
|
|
- mog_id,
|
|
|
- area,
|
|
|
- industry,
|
|
|
- date_count,
|
|
|
- date_unit,
|
|
|
+ var filter interface{}
|
|
|
+ if effect != "" {
|
|
|
+ filter = VipSimpleMsg{
|
|
|
+ mog_id,
|
|
|
+ area,
|
|
|
+ industry,
|
|
|
+ pay_source,
|
|
|
+ pro_count,
|
|
|
+ pro_unit,
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ filter = entity.VipSimpleMsg{
|
|
|
+ mog_id,
|
|
|
+ area,
|
|
|
+ industry,
|
|
|
+ date_count,
|
|
|
+ date_unit,
|
|
|
+ pay_source,
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
filterStr, _ := json.Marshal(filter)
|
|
|
ordercode := pay.GetOrderCode(userId)
|
|
|
orderid := util.Mysql.Insert("dataexport_order", map[string]interface{}{
|
|
@@ -222,3 +279,35 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
|
|
|
}
|
|
|
this.ServeJson(r.Format())
|
|
|
}
|
|
|
+
|
|
|
+//cycleunit(1:年 2:月)
|
|
|
+//cyclecount 数字长度
|
|
|
+func checkReqDates(dateStr string) (cyclecount, cycleunit int, err error) {
|
|
|
+ if strings.HasSuffix(dateStr, "年") {
|
|
|
+ cycleunit = 1
|
|
|
+ dateStr = strings.Replace(dateStr, "年", "", -1)
|
|
|
+ cyclecount, err = strconv.Atoi(dateStr)
|
|
|
+ if cyclecount > 3 && err == nil {
|
|
|
+ err = errors.New(fmt.Sprintf("日期%s返回超出最大值", dateStr))
|
|
|
+ }
|
|
|
+ return
|
|
|
+ } else if strings.HasSuffix(dateStr, "月") {
|
|
|
+ cycleunit = 2
|
|
|
+ dateStr = strings.Replace(dateStr, "个月", "", -1)
|
|
|
+ cyclecount, err = strconv.Atoi(dateStr)
|
|
|
+ if cyclecount > 12 && err == nil {
|
|
|
+ err = errors.New(fmt.Sprintf("日期%s范围超出最大值", dateStr))
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return -1, -1, errors.New(fmt.Sprintf("日期%s格式化出错", dateStr))
|
|
|
+}
|
|
|
+
|
|
|
+type VipSimpleMsg struct {
|
|
|
+ Id string `json:"_id"`
|
|
|
+ Area *map[string]interface{} `json:"area"`
|
|
|
+ Industry []string `json:"industry"`
|
|
|
+ PaySource string `json:"paysource"`
|
|
|
+ ProCyclecount int `json:"procyclecount"`
|
|
|
+ ProCycleunit int `json:"procycleunit"`
|
|
|
+}
|