Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop

This commit is contained in:
eson 2023-07-06 18:23:50 +08:00
commit 0a5da30062
12 changed files with 436 additions and 128 deletions

View File

@ -6,10 +6,7 @@ import (
func (od *FsOrderDetailModel) GetOrderDetailsByOrderId(ctx context.Context, orderId int64) (resp []FsOrderDetail, err error) {
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_id` = ?", orderId).Find(&resp).Error
if err != nil {
return nil, err
}
return
return resp, err
}
func (od *FsOrderDetailModel) FindOneByOrderDetailTemplateId(ctx context.Context, templateId int64) (resp *FsOrderDetail, err error) {
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_detail_template_id` = ?", templateId).Take(&resp).Error
@ -18,3 +15,12 @@ func (od *FsOrderDetailModel) FindOneByOrderDetailTemplateId(ctx context.Context
func (od *FsOrderDetailModel) Create(ctx context.Context, data *FsOrderDetail) error {
return od.db.WithContext(ctx).Model(&FsOrderDetail{}).Create(&data).Error
}
func (od *FsOrderDetailModel) GetOneOrderDetailByOrderId(ctx context.Context, orderId int64) (resp *FsOrderDetail, err error) {
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_id` = ?", orderId).Take(&resp).Error
return resp, err
}
func (d *FsProductDesignModel) FindOne(ctx context.Context, id int64, userId int64) (resp *FsProductDesign, err error) {
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`id` = ? and `user_id` = ? and `status` = ?", id, userId, 1).First(&resp).Error
return resp, err
}

View File

@ -21,3 +21,7 @@ func (dt *FsOrderDetailTemplateModel) FindOneBySn(ctx context.Context, sn string
func (dt *FsOrderDetailTemplateModel) Create(ctx context.Context, data *FsOrderDetailTemplate) error {
return dt.db.WithContext(ctx).Model(&FsOrderDetailTemplate{}).Create(&data).Error
}
func (dt *FsOrderDetailTemplateModel) FindOne(ctx context.Context, id int64) (resp *FsOrderDetailTemplate, err error) {
err = dt.db.WithContext(ctx).Model(&FsOrderDetailTemplate{}).Where("`id` = ?", id).Take(&resp).Error
return resp, err
}

View File

@ -45,3 +45,9 @@ func (o *FsOrderModel) FindOneAndCreateServiceContact(ctx context.Context, userI
})
return order, err
}
// 获取用户最近下单成功的订单
func (o *FsOrderModel) FindLastSuccessOneOrder(ctx context.Context, userId int64, statusGt int64) (order *FsOrder, err error) {
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where("`user_id` = ? and `status` > ?", userId, statusGt).Order("id DESC").Find(&order).Error
return order, err
}

View File

@ -64,7 +64,7 @@ func (d *FsProductModel3dModel) GetAllBySizeIdsTag(ctx context.Context, sizeIds
if len(sizeIds) == 0 {
return
}
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`size_id` in (?) and `tag` = ?", sizeIds, 1, tag).Find(&resp).Error
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`size_id` in (?) and `tag` = ?", sizeIds, tag).Find(&resp).Error
return resp, err
}
func (d *FsProductModel3dModel) GetAll(ctx context.Context) (resp []FsProductModel3d, err error) {

View File

@ -102,14 +102,14 @@ func (c *FsProductPriceModel) GetAllSelectBySizeId(ctx context.Context, sizeIds
}
return prices, err
}
func (p *FsProductPriceModel) GetPriceListByIds(ctx context.Context, Ids []int64) (resp []FsProductPrice, err error) {
func (p *FsProductPriceModel) GetAllByIdsWithoutStatus(ctx context.Context, Ids []int64) (resp []FsProductPrice, err error) {
if len(Ids) == 0 {
return nil, nil
}
db := p.db.WithContext(ctx).Model(&FsProductPrice{}).
Where("`id` in (?)", Ids)
if err = db.Find(&resp).Error; err != nil {
return nil, err
}
return
err = p.db.WithContext(ctx).Model(&FsProductPrice{}).Where("`id` in (?)", Ids).Find(&resp).Error
return resp, err
}
func (p *FsProductPriceModel) GetAllByProductIdStatus(ctx context.Context, productId int64, status int64) (resp []FsProductPrice, err error) {
err = p.db.WithContext(ctx).Model(&FsProductPrice{}).Where("`product_id` = ? and `status` = ?", productId, status).Find(&resp).Error
return resp, err
}

View File

@ -1,2 +1,37 @@
package gmodel
// TODO: 使用model的属性做你想做的
import "context"
// TODO: 使用model的属性做你想做的
type FindOneRenderDesignByParamsReq struct {
ClientNo *string
UserId *int64
SortType int
Fields string
Id *int
}
func (r *FsProductRenderDesignModel) FindOneRenderDesignByParams(ctx context.Context, req FindOneRenderDesignByParamsReq) (resp *FsProductRenderDesign, err error) {
db := r.db.WithContext(ctx).Model(&FsProductRenderDesign{})
if req.ClientNo != nil {
db = db.Where("`client_no` = ?", *req.ClientNo)
}
if req.Id != nil {
db = db.Where("`id` = ?", *req.Id)
}
if req.UserId != nil {
db = db.Where("`user_id` = ?", *req.UserId)
}
if req.Fields != "" {
db = db.Select(req.Fields)
}
switch req.SortType {
case 1: //id asc
db = db.Order("`id` ASC")
case 2: //id desc
db = db.Order("`id` DESC")
}
err = db.Take(&resp).Error
return resp, err
}

View File

@ -61,10 +61,14 @@ func (t *FsProductTemplateV2Model) FindAllByModelIds(ctx context.Context, modelI
}
return
}
func (t *FsProductTemplateV2Model) FindAllByProductIdModelIds(ctx context.Context, ids []int64, productId int64) (resp []FsProductTemplateV2, err error) {
if len(ids) == 0 {
func (t *FsProductTemplateV2Model) FindAllByProductIdModelIds(ctx context.Context, modelIds []int64, productId int64) (resp []FsProductTemplateV2, err error) {
if len(modelIds) == 0 {
return
}
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` in (?) and `product_id` ", ids, productId).Find(&resp).Error
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `product_id` = ? ", modelIds, productId).Find(&resp).Error
return resp, err
}
func (t *FsProductTemplateV2Model) FindOneByModelId(ctx context.Context, modelId int64) (resp *FsProductTemplateV2, err error) {
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` = ? ", modelId).Take(&resp).Error
return resp, err
}

View File

@ -2,8 +2,20 @@ package logic
import (
"context"
"encoding/json"
"errors"
"fmt"
"fusenapi/constants"
"fusenapi/model/gmodel"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/color_list"
"fusenapi/utils/format"
"fusenapi/utils/image"
"fusenapi/utils/step_price"
"gorm.io/gorm"
"strconv"
"strings"
"fusenapi/server/product/internal/svc"
"fusenapi/server/product/internal/types"
@ -27,7 +39,7 @@ func NewGetProductInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, userinfo *auth.UserInfo) (resp *basic.Response) {
//获取产品信息
/*productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid)
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the product is not exists")
@ -43,15 +55,11 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse product material Id list")
}
type Material struct {
Id int64 `json:"id"`
Title string `json:"title"`
}
//材料列表
materials := make([]Material, 0, len(materialIdSlice))
materials := make([]types.MaterialItem, 0, len(materialIdSlice))
for _, v := range materialIdSlice {
if title, ok := constants.MAP_MATERIAL[v]; ok {
materials = append(materials, Material{
materials = append(materials, types.MaterialItem{
Id: v,
Title: title,
})
@ -130,10 +138,10 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse model info")
}
cover := ""
if modelInfo["cover"] != nil {
coverArr := strings.Split(modelInfo["cover"].(string), ".")
if modelInfo["cover"] != nil && modelInfo["cover"].(string) != "" {
cover = modelInfo["cover"].(string)
if req.Size >= 200 {
coverArr := strings.Split(modelInfo["cover"].(string), ".")
cover = fmt.Sprintf("%s_%d.%s", coverArr[0], req.Size, coverArr[1])
}
}
@ -152,6 +160,10 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag list")
}
mapTag := make(map[string]int)
for k, v := range tagList {
mapTag[fmt.Sprintf("%d", v.Id)] = k
}
//获取全部模型信息
allModel3dList, err := l.svcCtx.AllModels.FsProductModel3d.GetAll(l.ctx)
if err != nil {
@ -186,10 +198,18 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
for k, v := range lightList {
mapLight[v.Id] = k
}
//材料尺寸模板
mapMaterialSizeTmp := make(map[string][]interface{})
//循环阶梯价计算
type MaterialSizePrice struct {
Items []interface{} `json:"items"`
MinPrice string `json:"min_price"`
MaxPrice string `json:"max_price"`
}
mapMaterialSizePrice := make(map[string]*MaterialSizePrice)
//循环处理组装模板信息
template484List := make([]interface{}, 0, len(productTemplateList))
for _, v := range productTemplateList {
allModel3dIndex, ok := mapAllmodel3d[*v.ModelId]
for _, tmp := range productTemplateList {
allModel3dIndex, ok := mapAllmodel3d[*tmp.ModelId]
if !ok {
continue
}
@ -198,38 +218,38 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
continue
}
//未编辑模板信息的数据跳过
if v.TemplateInfo == nil || *v.TemplateInfo == "" {
if tmp.TemplateInfo == nil || *tmp.TemplateInfo == "" {
continue
}
model3dInfo := allModel3dList[allModel3dIndex]
//解码template info
var templateInfo map[string]interface{}
if err = json.Unmarshal([]byte(*v.TemplateInfo), &templateInfo); err != nil {
var templateInfoRsp map[string]interface{}
if err = json.Unmarshal([]byte(*tmp.TemplateInfo), &templateInfoRsp); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse template info")
}
if templateInfo["cover"] != nil && templateInfo["cover"].(string) != "" {
cover := templateInfo["cover"].(string)
if templateInfoRsp["cover"] != nil && templateInfoRsp["cover"].(string) != "" {
cover := templateInfoRsp["cover"].(string)
if req.Size >= 200 {
coverArr := strings.Split(templateInfo["cover"].(string), ".")
coverArr := strings.Split(templateInfoRsp["cover"].(string), ".")
cover = fmt.Sprintf("%s_%d.%s", coverArr[0], req.Size, coverArr[1])
}
templateInfo["cover"] = cover
delete(templateInfo, "isPublic")
delete(templateInfo, "name")
templateInfoRsp["cover"] = cover
delete(templateInfoRsp, "isPublic")
delete(templateInfoRsp, "name")
}
//解码模型数据
var modelInfo map[string]interface{}
if err = json.Unmarshal([]byte(*model3dInfo.ModelInfo), &modelInfo); err != nil {
var modelInfoRsp map[string]interface{}
if err = json.Unmarshal([]byte(*model3dInfo.ModelInfo), &modelInfoRsp); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse template info")
}
modelInfo["id"] = allModel3dList[allModel3dIndex].Id
modelInfoRsp["id"] = allModel3dList[allModel3dIndex].Id
//解码灯光数据
var lightInfo interface{}
var lightInfoRsp interface{}
lightIndex, ok := mapLight[*model3dInfo.Light]
if ok && lightList[lightIndex].Info != nil && *lightList[lightIndex].Info != "" {
if err = json.Unmarshal([]byte(*lightList[lightIndex].Info), &lightInfo); err != nil {
if err = json.Unmarshal([]byte(*lightList[lightIndex].Info), &lightInfoRsp); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse light info")
}
@ -240,7 +260,7 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse 3d model`s part_list")
}
partList := make([]interface{}, 0, len(modelPartIds))
partListRsp := make([]interface{}, 0, len(modelPartIds))
for _, partId := range modelPartIds {
//判断配件信息是否正常
key, ok := mapAllmodel3d[partId]
@ -250,77 +270,236 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
var thisInfo map[string]interface{}
temBytes, _ := json.Marshal(allModel3dList[key])
_ = json.Unmarshal(temBytes, &thisInfo)
thisInfo["material_img"] = ""
if *allModel3dList[key].OptionTemplate != 0 {
if optionTemplateIndex, ok := mapOptionTemplate[*allModel3dList[key].OptionTemplate]; ok {
thisInfo["material_img"] = *optionTemplateList[optionTemplateIndex].MaterialImg
}
} else {
tmpv2, err := l.svcCtx.AllModels.FsProductTemplateV2.FindOneByModelId(l.ctx, partId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
} else {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product template")
}
}
thisInfo["material_img"] = *tmpv2.MaterialImg
}
partListRsp = append(partListRsp, thisInfo)
}
}*/
//**************************************************
/*
//循环处理组装模板信息
foreach ($templates as $temp) {
foreach ($modelPart as $row) {
//判断配件信息是否正常
if (isset($models[$row]) && !empty($models[$row]) && $models[$row]['status'] == 1) {
$thisInfo = $models[$row];
$thisInfo['id'] = $models[$row]['id'];
if (!empty($models[$row]['option_template']) && !is_null($models[$row]['option_template'])) {
$thisInfo['material_img'] = $optionTemlateData[$models[$row]['option_template']]['material_img'];
} else {
$thisInfo['material_img'] = ProductTemplateV2::find()->where(['model_id' => $row])->select(['material_img'])->scalar();
}
$thisInfo['model_info'] = json_decode($thisInfo['model_info'], true);
$partArr[] = $thisInfo;
}
}
tagName := ""
if tagIndex, ok := mapTag[*tmp.Tag]; ok {
tagName = *tagList[tagIndex].Title
}
//按照材质和尺寸来存放模板信息
mapMaterialSizeTmpKey := l.getMapMaterialSizeTmpKey(*productInfo.MaterialIds, *model3dInfo.SizeId)
mapMaterialSizeTmp[mapMaterialSizeTmpKey] = append(mapMaterialSizeTmp[mapMaterialSizeTmpKey], map[string]interface{}{
"id": tmp.Id,
"title": *tmp.Title,
"templateData": templateInfoRsp,
"modelData": modelInfoRsp,
"lightData": lightInfoRsp,
"partList": partListRsp,
"tag_name": tagName,
})
}
//产品价格查询
productPriceList, err := l.svcCtx.AllModels.FsProductPrice.GetAllByProductIdStatus(l.ctx, productInfo.Id, 1)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product price list")
}
for _, priceItem := range productPriceList {
stepNumSlice, err := format.StrSlicToIntSlice(strings.Split(*priceItem.StepNum, ","))
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "split step num err")
}
stepPriceSlice, err := format.StrSlicToIntSlice(strings.Split(*priceItem.StepPrice, ","))
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "split step price err")
}
lenStepNum := len(stepNumSlice)
lenStepPrice := len(stepPriceSlice)
if lenStepNum == 0 {
return resp.SetStatusWithMessage(basic.CodeServiceErr, "count of step num is empty")
}
for *priceItem.MinBuyNum < int64(stepNumSlice[lenStepNum-1]+5) {
price := step_price.GetCentStepPrice(int(*priceItem.MinBuyNum), stepNumSlice, stepPriceSlice)
mapMaterialSizePriceKey := l.getMapMaterialSizePriceKey(*priceItem.MaterialId, *priceItem.SizeId)
if _, ok := mapMaterialSizePrice[mapMaterialSizePriceKey]; ok {
mapMaterialSizePrice[mapMaterialSizePriceKey].Items = append(mapMaterialSizePrice[mapMaterialSizePriceKey].Items, map[string]interface{}{
"num": *priceItem.MinBuyNum,
"total_num": *priceItem.MinBuyNum * (*priceItem.EachBoxNum),
"price": price,
})
mapMaterialSizePrice[mapMaterialSizePriceKey].MinPrice = fmt.Sprintf("%.2f", float64(stepPriceSlice[lenStepPrice-1])/100)
mapMaterialSizePrice[mapMaterialSizePriceKey].MaxPrice = fmt.Sprintf("%.2f", float64(stepPriceSlice[0])/100)
} else {
items := map[string]interface{}{
"num": *priceItem.MinBuyNum,
"total_num": *priceItem.MinBuyNum * (*priceItem.EachBoxNum),
"price": price,
}
mapMaterialSizePrice[mapMaterialSizePriceKey] = &MaterialSizePrice{
Items: []interface{}{items},
MinPrice: fmt.Sprintf("%.2f", float64(stepPriceSlice[lenStepPrice-1])/100),
MaxPrice: fmt.Sprintf("%.2f", float64(stepPriceSlice[0])/100),
}
}
*priceItem.MinBuyNum++
}
}
isLowRendering := false
isRemoveBg := false
var lastDesign interface{}
if userinfo.UserId != 0 {
//获取用户信息
user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "user info not found")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get user info")
}
isLowRendering = *user.IsLowRendering > 0
isRemoveBg = *user.IsRemoveBg > 0
lastDesign = l.getLastDesign(user)
}
var renderDesign interface{}
if req.HaveCloudRendering == true {
renderDesign = l.getRenderDesign(req.ClientNo)
}
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetProductInfoRsp{
Id: productInfo.Id,
Type: *productInfo.Type,
Title: *productInfo.Title,
IsEnv: *productInfo.IsProtection,
IsMicro: *productInfo.IsMicrowave,
TypeName: typeName,
IsLowRendering: isLowRendering,
IsRemoveBg: isRemoveBg,
Materials: materials,
Sizes: sizeListRsp,
Templates: mapMaterialSizeTmp,
Price: mapMaterialSizePrice,
LastDesign: lastDesign,
RenderDesign: renderDesign,
Colors: color_list.GetColor(),
})
//按照材质和尺寸来存放模板信息
$product['templates']["{$materialId}_{$models[$temp['model_id']]['size_id']}"][] = [
'id' => $temp['id'],
'title' => $temp['title'],
'templateData' => $info,
'modelData' => $modelData,
'lightData' => $lightData,
'partList' => $partArr,
'tag_name' => isset($tags[$temp['tag']]) ? $tags[$temp['tag']]['title'] : '',
];
}
//产品价格查询
$prices = ProductPrice::find()
->andFilterWhere(['product_id' => $product['id']])
->statusOn(ProductPrice::STATUS_ON)
->asArray()
->all();
//循环阶梯价计算
foreach ($prices as $price) {
$price['step_num'] = explode(',', $price['step_num']);
$price['step_price'] = explode(',', $price['step_price']);
while ($price['min_buy_num'] < end($price['step_num']) + 5) {
$product['prices']["{$price['material_id']}_{$price['size_id']}"]['items'][] = [
'num' => intval($price['min_buy_num']),
'total_num' => $price['min_buy_num'] * $price['each_box_num'],
'price' => ProductPriceService::getPrice($price['min_buy_num'], $price['step_num'], $price['step_price'])
];
$price['min_buy_num'] += 1;
}
$product['prices']["{$price['material_id']}_{$price['size_id']}"]['min_price'] = floatval(end($price['step_price']) / 100);
$product['prices']["{$price['material_id']}_{$price['size_id']}"]['max_price'] = floatval(reset($price['step_price']) / 100);
}
//这里加一个字段返回数据格式为最新的设计(只有当又用户信息是才会又这个)
$uid = intval(\Yii::$app->getUser()->id);
$product['last_design'] = (new ProductService())->getLastDesign($uid);
$product['render_design'] = $haveCloudRendering == 'true' ? (new ProductService())->getRenderDesign($clientNo) : null;
//获取色系数据
$product['colors'] = ProductService::getColor();
//获取用户信息
$userInfo = User::find()->where(['id' => $uid])->asArray()->one();
$product['is_low_rendering'] = $userInfo && $userInfo['is_low_rendering'] ? true : false;
$product['is_remove_bg'] = $userInfo && $userInfo['is_remove_bg'] ? true : false;*/
return resp.SetStatus(basic.CodeOK)
}
// 获取渲染设计
func (l *GetProductInfoLogic) getRenderDesign(clientNo string) interface{} {
if clientNo == "" {
return nil
}
renderDesign, err := l.svcCtx.AllModels.FsProductRenderDesign.FindOneRenderDesignByParams(l.ctx, gmodel.FindOneRenderDesignByParamsReq{
ClientNo: &clientNo,
Fields: "id,info,material_id,optional_id,size_id,template_id",
SortType: 2,
})
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil
}
logx.Error(err)
return nil
}
var info interface{}
if renderDesign.Info != nil && *renderDesign.Info != "" {
if err = json.Unmarshal([]byte(*renderDesign.Info), &info); err != nil {
logx.Error(err)
return nil
}
}
return map[string]interface{}{
"id": renderDesign.Id,
"info": info,
"material_id": *renderDesign.MaterialId,
"optional_id": *renderDesign.OptionalId,
"size_id": *renderDesign.SizeId,
"template_id": *renderDesign.TemplateId,
}
}
// 获取用户最新设计
func (l *GetProductInfoLogic) getLastDesign(userInfo gmodel.FsUser) interface{} {
//查询用户最近下单成功的数据
orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userInfo.Id, int64(constants.STATUS_NEW_NOT_PAY))
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil
}
logx.Error(err)
return nil
}
//获取该订单相关设计信息
orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil
}
logx.Error(err)
return nil
}
//获取设计模板详情便于获得design_id
orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil
}
logx.Error(err)
return nil
}
//若没打开了个性化渲染按钮或者最后一次设计不存在,则不返回该设计相关数据
if *userInfo.IsOpenRender != 1 || *orderDetailTemplate.DesignId <= 0 {
return nil
}
//获取设计数据
productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, userInfo.Id)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil
}
logx.Error(err)
return nil
}
var info interface{}
if productDesign.Info != nil && *productDesign.Info != "" {
if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
logx.Error(err)
return nil
}
}
var logoColor interface{}
if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
logx.Error(err)
return nil
}
}
return map[string]interface{}{
"id": productDesign.Id,
"info": info,
"logo_color": logoColor,
"material_id": *productDesign.MaterialId,
"optional_id": *productDesign.OptionalId,
"size_id": *productDesign.SizeId,
}
}
// 获取按照材料跟尺寸分类的模板map key
func (l *GetProductInfoLogic) getMapMaterialSizeTmpKey(materialIds string, sizeId int64) string {
return fmt.Sprintf("%s_%d", materialIds, sizeId)
}
// 获取按照材料跟尺寸分类的价格map key
func (l *GetProductInfoLogic) getMapMaterialSizePriceKey(materialId int64, sizeId int64) string {
return fmt.Sprintf("%d_%d", materialId, sizeId)
}

View File

@ -106,7 +106,7 @@ type GetProductInfoReq struct {
Pid string `form:"pid"`
Size uint32 `form:"size"`
ClientNo string `form:"client_no"`
HaveCloudRendering bool `form:"haveCloudRendering"`
HaveCloudRendering bool `form:"haveCloudRendering,optional"`
}
type GetProductInfoRsp struct {
@ -120,15 +120,11 @@ type GetProductInfoRsp struct {
IsRemoveBg bool `json:"is_remove_bg"`
Materials []MaterialItem `json:"materials"`
Sizes []SizeItem `json:"sizes"`
Templates Templates `json:"templates"`
Templates interface{} `json:"templates"`
Price interface{} `json:"price"`
LastDesign interface{} `json:"last_design"`
RenderDesign interface{} `json:"render_design"`
Colors []interface{} `json:"colors"`
}
type Templates struct {
Template484List []interface{} `json:"4_84"`
Colors interface{} `json:"colors"`
}
type SizeItem struct {

View File

@ -65,7 +65,7 @@ func (l *CreateOrderLogic) CreateOrder(req *types.CreateOrderReq, userinfo *auth
optionalIds = append(optionalIds, *v.OptionalId)
}
//获取价格
priceList, err := l.svcCtx.AllModels.FsProductPrice.GetPriceListByIds(l.ctx, priceIds)
priceList, err := l.svcCtx.AllModels.FsProductPrice.GetAllByIdsWithoutStatus(l.ctx, priceIds)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product price list")

View File

@ -127,7 +127,7 @@ type GetProductInfoReq {
Pid string `form:"pid"`
Size uint32 `form:"size"`
ClientNo string `form:"client_no"`
HaveCloudRendering bool `form:"haveCloudRendering"`
HaveCloudRendering bool `form:"haveCloudRendering,optional"`
}
type GetProductInfoRsp {
Id int64 `json:"id"`
@ -140,14 +140,11 @@ type GetProductInfoRsp {
IsRemoveBg bool `json:"is_remove_bg"`
Materials []MaterialItem `json:"materials"`
Sizes []SizeItem `json:"sizes"`
Templates Templates `json:"templates"`
Templates interface{} `json:"templates"`
Price interface{} `json:"price"`
LastDesign interface{} `json:"last_design"`
RenderDesign interface{} `json:"render_design"`
Colors []interface{} `json:"colors"`
}
type Templates {
Template484List []interface{} `json:"4_84"`
Colors interface{} `json:"colors"`
}
type SizeItem {
Id int64 `json:"id"`

81
utils/color_list/color.go Normal file
View File

@ -0,0 +1,81 @@
package color_list
type GetColorResponse struct {
Color string `json:"color"`
ColorItems []string `json:"color_items"`
}
func GetColor() []GetColorResponse {
return []GetColorResponse{
{
Color: "#ffda00", //黄色系列
ColorItems: []string{
"#cddb00", "#cdde00", "#e0e621", "#ebe717", "#eddb00", "#ffda00", "#ffd040", "#ffc629", "#ffb71b",
"#a8ad00", "#b4bd00", "#bfb800", "#aca300", "#ffdd00", "#ffd100", "#daa900", "#eba900", "#c89211",
"#949300", "#989400", "#695c21", "#8a7a28", "#b09700", "#ab8900", "#b68400", "#ae841f", "#896b25",
},
},
{
Color: "#ff5100", //橙色系
ColorItems: []string{
"#ffbf3c", "#ffa400", "#f5b335", "#ffb259", "#f1bc7c", "#f09f54", "#ff9d6c", "#ff7f40", "#ff8d6b",
"#e07c00", "#f18a00", "#ff8300", "#ff6b00", "#ff5100", "#e04403", "#ff671d", "#e65300", "#ff4d00",
"#d47e00", "#aa6c10", "#e87200", "#c06b13", "#ac441e", "#96460a", "#d15e14", "#a4541c", "#c1531b",
},
},
{
Color: "#FF0000", //红色系
ColorItems: []string{
"#ff8672", "#ff595a", "#fd4a5c", "#ff647d", "#ff8189", "#ff8e9f", "#fe9bb1", "#fb5373", "#fa7598",
"#e43d30", "#ff4438", "#f32735", "#f5333f", "#ea0029", "#ce0e2d", "#eb0045", "#c40d3c", "#f93549",
"#993921", "#d2451e", "#c23b33", "#d7282f", "#a73439", "#aa182c", "#9f2842", "#7f2629", "#653334",
},
},
{
Color: "#d6006d", //粉红色系
ColorItems: []string{
"#eeb2ca", "#f89aba", "#ec9bad", "#eb80a8", "#f97fb5", "#f095cd", "#f478c4", "#e96bb0", "#e95ebe",
"#f44c7f", "#e6427a", "#e81f76", "#e7004c", "#d50057", "#c40069", "#e50695", "#e31d93", "#f45197",
"#8a1e41", "#7f2346", "#aa004f", "#ae1857", "#af0061", "#cb007b", "#c92c99", "#b31983", "#870f54",
},
},
{
Color: "#c028b9", //紫色系
ColorItems: []string{
"#f1b9df", "#edb7e3", "#e17fd2", "#cf63ce", "#daa8e2", "#d8c4e5", "#cca2d7", "#c29fd8", "#9164cc",
"#ba4795", "#c017a2", "#b4008d", "#c028b9", "#8f4899", "#b14fc5", "#a25eb5", "#8347ad", "#60269e",
"#53284f", "#672666", "#83276b", "#870064", "#8a1a9b", "#722282", "#3d1152", "#510c76", "#522d6d",
},
},
{
Color: "#000f9f", //深蓝色系
ColorItems: []string{
"#9578d3", "#ae95da", "#8a84d6", "#9594d2", "#9eade5", "#a5c5ed", "#8ab7e9", "#6aaae4", "#5580c1",
"#410099", "#655dc6", "#7473c0", "#3a8dde", "#2a7de1", "#0071ce", "#425cc7", "#0047ba", "#1226aa",
"#21145f", "#31006f", "#270089", "#000b8c", "#000f9f", "#001689", "#002d74", "#0f206c", "#00205c",
},
},
{
Color: "#0082ca", //浅蓝色系
ColorItems: []string{
"#97caeb", "#65b2e8", "#5eb3e4", "#3cb4e5", "#00b2e3", "#54c8e8", "#00c1de", "#00bed6", "#1ecad3",
"#00a0df", "#009ade", "#0082ca", "#005cb9", "#0069a7", "#00a6ce", "#0099a8", "#008996", "#007078",
"#003764", "#004987", "#004a98", "#003da6", "#00567d", "#007da5", "#00758d", "#006580", "#006072",
},
},
{
Color: "#00a887", //绿色系
ColorItems: []string{
"#10cfc9", "#45c2b1", "#87e1d1", "#6bcdb2", "#3bd4ae", "#6cca98", "#79dea8", "#a1d683", "#cbe880",
"#00a19b", "#00a887", "#00c08b", "#009845", "#00ae42", "#3dae2b", "#76bc21", "#93d500", "#a2d45e",
"#005850", "#006853", "#007960", "#00945e", "#006548", "#006937", "#007934", "#638c1c", "#789904",
},
},
{
Color: "#ffffff", //灰色系
ColorItems: []string{
"#ffffff", "#eaeaea", "#d3d3d3", "#bababa", "#a0a0a0", "#828181", "#646565", "#3b3c3c", "#000000",
},
},
}
}