Browse Source

fix:bug

token_replace
黄梓健 5 years ago
parent
commit
163ea3d7d9
  1. 49
      controllers/client/order_entry.go
  2. 1
      services/invitation/setting.go

49
controllers/client/order_entry.go

@ -1,6 +1,7 @@
package client
import (
"encoding/json"
"fmt"
"hudongzhuanjia/controllers"
"hudongzhuanjia/models"
@ -72,6 +73,27 @@ func (t *OrderEntryCtl) Order() {
t.CheckErr(err)
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
letter := &models.InvitationLetter{}
exist, err = letter.GetByUserIdAndActivityId(userId, activity.Id, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
t.Assert(exist, code.MSG_INVITE_LETTER_NOT_EXIST, "邀请函不存在")
items, err := invitation_service.GetOptionItem(activity.Id)
t.CheckErr(err)
values, err := invitation_service.GetOptionValue(items, letter.ExtraData)
t.CheckErr(err)
var name, phone, address = "", "", ""
for _, value := range values {
if v, ok := value["姓名"]; ok {
name = fmt.Sprint(v)
} else if v, ok := value["手机"]; ok {
phone = fmt.Sprint(v)
} else if v, ok := value["地址"]; ok {
address = fmt.Sprint(v)
}
}
s := core.GetXormAuto().NewSession()
defer s.Close()
err = s.Begin()
@ -121,6 +143,9 @@ func (t *OrderEntryCtl) Order() {
order.OrderEntryPersonId = entryPerson.Id
order.OrderEntryPersonName = entryPerson.Name
order.TotalAmount = good.Price
order.Receiver = name
order.Phone = phone
order.Address = address
order.OutTradeNo = utils.RandomStr(32)
order.OrderNo = fmt.Sprint(define.DefaultOrderNo + int(total))
order.Status = 1
@ -197,9 +222,10 @@ func (t *OrderEntryCtl) Order() {
t.SUCCESS("成功录入订单")
}
// 手动下单
type ManualOrderGood struct {
GoodId int
GoodNum int
GoodId int `json:"good_id"`
GoodNum int `json:"good_num"`
}
type ManualOrderParam struct {
Name string `json:"name"`
@ -207,11 +233,12 @@ type ManualOrderParam struct {
Goods []*ManualOrderGood `json:"goods"`
}
// 手动下单
func (t *OrderEntryCtl) ManualOrder() {
entryId := t.GetAccountId() // 录入人员id
param := &ManualOrderParam{}
err := t.Bind(param)
t.Bind(param)
param.Goods = make([]*ManualOrderGood, 0)
err := json.Unmarshal([]byte(t.Request.REQUEST["goods"]), &param.Goods)
t.CheckErr(err)
if len(param.Goods) <= 0 {
@ -320,6 +347,8 @@ func (t *OrderEntryCtl) ManualOrder() {
order.OrderEntryPersonId = entryPerson.Id
order.OrderEntryPersonName = entryPerson.Name
order.TotalAmount = totalAmount
order.Receiver = param.Name
order.Phone = param.Phone
order.OutTradeNo = utils.RandomStr(32)
order.OrderNo = fmt.Sprint(define.DefaultOrderNo + int(count))
order.Status = 1
@ -393,6 +422,10 @@ func (t *OrderEntryCtl) ManualOrder() {
t.SUCCESS("成功录入订单")
}
// 订单列表
func (t *OrderEntryCtl) ListOrder() {
}
func (t *OrderEntryCtl) DeleteOrder() {
orderId := t.MustGetInt("order_id")
order := new(models.CustomerOrder)
@ -415,6 +448,9 @@ type OrderListResult struct {
GoodName string `json:"good_name"`
OrderTime string `json:"order_time"`
OrderMoney float64 `json:"order_money"`
Receiver string `json:"receiver"`
Phone string `json:"phone"`
Address string `json:"address"`
Extra []map[string]interface{} `json:"extra"` // 额外信息
ExtraData string `json:"-"`
}
@ -435,8 +471,9 @@ func (t *OrderEntryCtl) EntryOrders() {
list := make([]*OrderListResult, 0)
err = core.GetXormAuto().Table(new(models.CustomerOrder)).Alias("o").
Select("l.extra_data as extra_data, g.name as good_name, o.buyer_id as user_id, o.total_amount as order_money, "+
" o.id as order_id, DATE_FORMAT(o.created_at, '%Y-%m-%d %H:%i:%S') AS order_time").
Select("o.receiver as receiver, o.phone as phone, o.address as address,l.extra_data as extra_data, "+
" g.name as good_name, o.buyer_id as user_id, o.total_amount as order_money, o.id as order_id, "+
" DATE_FORMAT(o.created_at, '%Y-%m-%d %H:%i:%S') AS order_time").
Join("LEFT", new(models.CustomerGoods).Alias("g"),
"o.goods_id=g.id and o.activity_id=g.activity_id and g.is_delete=0").
Join("LEFT", new(models.InvitationLetter).Alias("l"),

1
services/invitation/setting.go

@ -7,6 +7,7 @@ import (
"strings"
)
// [{"type":"输入框","name":"姓名","label":"姓名","options":[],"val":"体重"},{"type":"输入框","name":"手机","label":"手机","options":[],"val":"17688184874"},{"type":"输入框","name":"地址","label":"地址","options":[],"val":"5(๑>؂<๑)好吃喵!"}]
func GetOptionItem(aid int) ([]string, error) {
// 添加邀请函的内容
option := new(models.CustomerOrderOption)

Loading…
Cancel
Save