From f5620e397e82d5391a9ad244890215906f693bd5 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Sat, 7 Oct 2023 16:58:00 +0800 Subject: [PATCH] fix --- service/repositories/order.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/service/repositories/order.go b/service/repositories/order.go index 30bbda8c..d312ec40 100644 --- a/service/repositories/order.go +++ b/service/repositories/order.go @@ -744,8 +744,8 @@ func (d *defaultOrder) CreatePrePaymentByDeposit(ctx context.Context, in *Create var table = gmodel.NewAllModels(d.MysqlConn).FsOrder.TableName() var resUpdate *gorm.DB if in.DeliveryMethod == constants.DELIVERYMETHODDIRECTMAIL { - var oosql = fmt.Sprintf("UPDATE %s SET `order_address` = JSON_MERGE_PATCH(`order_address`,?), `status_link` = JSON_MERGE_PATCH(`status_link`,?), `delivery_method` = ? , `utime` = ? WHERE `id` = ?", table) - resUpdate = d.MysqlConn.Exec(oosql, orderAddressByte, statusLinkByte, in.DeliveryMethod, ntime, orderInfo.Id) + var oosql = fmt.Sprintf("UPDATE %s SET `utime` = ?, `order_address` = JSON_MERGE_PATCH(`order_address`,?), `status_link` = JSON_MERGE_PATCH(`status_link`,?), `delivery_method` = ? WHERE `id` = ?", table) + resUpdate = d.MysqlConn.Exec(oosql, ntime, orderAddressByte, statusLinkByte, in.DeliveryMethod, orderInfo.Id) } else { resUpdate = d.MysqlConn.Exec(fmt.Sprintf("UPDATE %s SET `delivery_method` = ? , `utime` = ? WHERE `id` = ?", table), in.DeliveryMethod, ntime, orderInfo.Id) } @@ -1154,7 +1154,10 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe var statusLink = order.GenerateOrderStatusLink(in.DeliveryMethod, nowTime, in.ExpectedDeliveryTime) byteOrderProduct, _ := json.Marshal(orderProductList) - byteOrderAddress, _ := json.Marshal(orderAddress) + var byteOrderAddress []byte + if orderAddress != nil { + byteOrderAddress, _ = json.Marshal(orderAddress) + } byteOrderAmount, _ := json.Marshal(orderAmount) byteShoppingCartSnapshot, _ := json.Marshal(shoppingCartSnapshotList)