黄梓健 5 years ago
parent
commit
e33ff60738
  1. 2
      controllers/client/good.go
  2. 10
      controllers/common/im.go
  3. 5
      log/hdzj.log
  4. 2
      models/customer_goods.go
  5. 14
      models/customer_order.go
  6. 4
      models/customer_order_sub.go
  7. 14
      services/pay/handle.go

2
controllers/client/good.go

@ -98,7 +98,7 @@ func (t *GoodCtl) ListOrder() {
for index, order := range orders {
order.ServicePhone = option.MainServicePhone
for _, sub := range subs {
if order.OrderNo == sub.OrderNo {
if order.OrderNo == sub["order_no"] {
orders[index].SubOrders = append(orders[index].SubOrders, sub)
}
}

10
controllers/common/im.go

@ -115,11 +115,11 @@ func (t *ImTestCtl) SendGood() {
for _, sub := range subs {
err = im_service.SendGroupCustomMessage(userId, activityId, im_service.NoticeLiveGoodBuy,
map[string]interface{}{
"goods_pic_url": sub.GoodsPicUrl,
"goods_num": sub.GoodsNum,
"good_name": sub.GoodName,
"good_price": sub.GoodPrice,
"goods_id": sub.GoodsId,
"goods_pic_url": sub["goods_pic_url"],
"goods_num": sub["goods_num"],
"good_name": sub["good_name"],
"good_price": sub["good_price"],
"goods_id": sub["goods_id"],
"timestamp": time.Now().Unix(),
})
if err != nil {

5
log/hdzj.log

@ -103,3 +103,8 @@
2020-05-22 16:08:14.919 ERROR logger/logger.go:87 获取过期打赏错误原因Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
2020-05-22 16:08:14.920 ERROR logger/logger.go:87 定时任务错误原因Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
2020-05-22 16:35:51.409 ERROR logger/logger.go:87 check err{error 25 0 sql: expected 3 arguments, got 2}
2020-05-22 17:36:39.314 ERROR logger/logger.go:87 获取过期打赏错误原因Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
2020-05-22 17:36:39.316 ERROR logger/logger.go:87 定时任务错误原因Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
2020-05-22 17:43:01.374 ERROR logger/logger.go:87 不存在客户订单: err-> invalid connection, out_trade_no->grc418sZOaBZsQDzbIeMPjafk3E6Z1sl
2020-05-22 17:43:01.374 ERROR logger/logger.go:87 check err{error 25 0 invalid connection}
2020-05-22 17:43:01.375 ERROR logger/logger.go:87 check err{error 25 0 invalid connection}

2
models/customer_goods.go

@ -44,6 +44,6 @@ func GetGoodsByActivityId(activityId, areaId int64) ([]*CustomerGoods, error) {
return goods, err
}
func (t *CustomerGoods) IncrStockById(id interface{}, num int) (int64, error) {
func (t *CustomerGoods) IncrStockById(id, num interface{}) (int64, error) {
return core.GetXormAuto().ID(id).Incr("stock", num).Cols("stock").Update(t)
}

14
models/customer_order.go

@ -43,13 +43,13 @@ type CustomerOrder struct {
AutoReceiveTime time.Time `json:"auto_receive_time" xorm:"comment('自动收货时间') DATETIME"`
// 无关变量
OrderTime string `json:"order_time,omitempty" xorm:"-"`
Good *CustomerGoods `json:"good,omitempty" xorm:"-"`
User *User `json:"user,omitempty" xorm:"-"`
OrderEntryPersonName string `json:"order_entry_person_name,omitempty" xorm:"-"`
ServicePhone string `json:"service_phone" xorm:"-"`
SubOrders []*CustomerOrderSub `json:"sub_orders" xorm:"-"`
//SubOrders []map[string]string `json:"sub_orders,omitempty" xorm:"-"`
OrderTime string `json:"order_time,omitempty" xorm:"-"`
Good *CustomerGoods `json:"good,omitempty" xorm:"-"`
User *User `json:"user,omitempty" xorm:"-"`
OrderEntryPersonName string `json:"order_entry_person_name,omitempty" xorm:"-"`
ServicePhone string `json:"service_phone" xorm:"-"`
//SubOrders []*CustomerOrderSub `json:"sub_orders" xorm:"-"`
SubOrders []map[string]string `json:"sub_orders,omitempty" xorm:"-"`
}
func (t *CustomerOrder) TableName() string {

4
models/customer_order_sub.go

@ -21,7 +21,7 @@ type CustomerOrderSub struct {
GoodPrice float64 `json:"good_price" xorm:"not null default 0.00 comment('商品价格') DECIMAL(18)"`
// 无关变量
GoodsPicUrl string `json:"goods_pic_url" xorm:"-"`
GoodsPicUrl string `json:"goods_pic_url" xorm:"extends"`
}
func (t *CustomerOrderSub) TableName() string {
@ -32,7 +32,7 @@ func (t *CustomerOrderSub) Alias(n string) string {
return fmt.Sprintf("%s as %s", t.TableName(), n)
}
func GetCustomerOrderSubsByOrderNos(orderNos ...string) (subs []*CustomerOrderSub, err error) {
func GetCustomerOrderSubsByOrderNos(orderNos ...string) (subs []map[string]string, err error) {
err = core.GetXormAuto().Table(new(CustomerOrderSub)).Alias("s").
Select("s.order_no, s.goods_id, s.goods_num, s.good_name, s.good_price, g.goods_pic_url").
Join("left", new(CustomerGoods).Alias("g"), "g.id=s.goods_id").

14
services/pay/handle.go

@ -116,11 +116,11 @@ func HandleSuccess(order *models.UserOrder) error {
for _, sub := range subs {
err = im_service.SendGroupCustomMessage(customerOrder.BuyerId, order.ActivityId, im_service.NoticeLiveGoodBuy,
map[string]interface{}{
"goods_pic_url": sub.GoodsPicUrl,
"goods_num": sub.GoodsNum,
"good_name": sub.GoodName,
"good_price": sub.GoodPrice,
"goods_id": sub.GoodsId,
"goods_pic_url": sub["goods_pic_url"],
"goods_num": sub["goods_num"],
"good_name": sub["good_name"],
"good_price": sub["good_price"],
"goods_id": sub["goods_id"],
"timestamp": time.Now().Unix(),
})
if err != nil {
@ -267,9 +267,9 @@ func HandleFailed(order *models.UserOrder) error {
return err
}
for _, sub := range subs {
_, err = new(models.CustomerGoods).IncrStockById(sub.GoodsId, sub.GoodsNum)
_, err = new(models.CustomerGoods).IncrStockById(sub["goods_id"], sub["goods_num"])
if err != nil {
err = fmt.Errorf("库存返回失败: err->%v, out_trade_no->%v, sub_id->%v", err, order.OutTradeNo, sub.Id)
err = fmt.Errorf("库存返回失败: err->%v, out_trade_no->%v", err, order.OutTradeNo)
return err
}
}

Loading…
Cancel
Save