1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package order
- import (
- "context"
- "jyOrderManager/internal/model"
- )
- // SaveOrder 订单保存
- func SaveOrder(ctx context.Context, param model.OrderParams, creatUser string) (string, error) {
- //var (
- // productArr []product.JyProduct
- // orderCode = fmt.Sprintf("%s%s", time.Now().Format("150405"), common.GetRandom(6))
- // actProduct = map[string]map[string]product.JyProduct{}
- //)
- //for _, tParam := range param.ProductArr {
- // //参数注入
- // tParam["phone"] = param.PersonPhone //开通手机号
- // tParam["order_code"] = orderCode //订单号
- // tParam["reqBuySet"] = param.BuySubject //购买主体
- // tParam["reqCompanyName"] = param.CompanyName //公司名称
- // productCode := gconv.String(tParam["product_code"])
- // pFunc, err := product.JyProFunc.GetProductInitFuncByCode(productCode)
- // if err != nil {
- // return "", err
- // }
- // pObj, err := pFunc(tParam)
- // if err != nil {
- // return "", gerror.Wrap(err, fmt.Sprintf("获取%s商品异常", productCode))
- // }
- //
- // var (
- // actCode = gconv.String(tParam["activityCode"]) //活动code
- // checkCode = common.If(actCode != "", 2, 1).(int) //1:普通商品 2:活动商品
- // )
- // if actCode != "" {
- // if _, ok := actProduct[actCode]; ok {
- // actProduct[actCode][productCode] = pObj
- // } else {
- // actProduct[actCode] = map[string]product.JyProduct{productCode: pObj}
- // }
- // }
- //
- // if err := pObj.Check(checkCode); err != nil {
- // return "", err
- // }
- //
- // productArr = append(productArr, pObj)
- //}
- //
- //// 活动商品校验完整,防止缺少增加商品
- //if len(actProduct) > 0 {
- // now := time.Now()
- // for actCode, productList := range actProduct {
- // act := service.Product().GetActivityByCode(actCode)
- // if act == nil {
- // return "", fmt.Errorf("未知活动code %s", actCode)
- // }
- // if now.After(act.EndTime) || now.Before(act.StartTime) {
- // return "", fmt.Errorf("活动%s不在有效期", actCode)
- // }
- // if len(productList) != len(act.Products) {
- // return "", fmt.Errorf("活动产品不完整 %s", actCode)
- // }
- // }
- //}
- //
- ////数据库操作
- //return orderCode, g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
- // //todo 插入订单表
- // if _, err := g.DB().Ctx(ctx).Insert(ctx, "dataexport_order", g.Map{
- // "order_code": orderCode,
- // "order_money": param.OrderMoney,
- // "pay_money": param.ContractMoney,
- // "product_type": "组合商品",
- // "create_person": "xxxx",
- // }); err != nil {
- // return gerror.Wrap(err, "插入订单表异常")
- // }
- // //todo 订单详情表
- // for _, p := range productArr {
- // if err := p.SaveUpdate(ctx); err != nil {
- // return err
- // }
- // }
- // //todo 销售业绩
- // SaveOrUpdateSaleMoneyTmp(ctx, orderCode)
- // return nil
- //})
- }
|