package order import ( "app.yhyue.com/moapp/jybase/common" "app.yhyue.com/moapp/jybase/date" "context" "fmt" "github.com/gogf/gf/v2/frame/g" "io/ioutil" "jyOrderManager/internal/model" "k8s.io/apimachinery/pkg/util/json" "log" "net/http" "net/url" "strconv" ) // OrderLogicalDelOrder 删除 func OrderLogicalDelOrder(ctx context.Context, param model.OrderCopyLinkParams) (interface{}, error) { ok := true _, err := g.DB().Ctx(ctx).Update(ctx, "dataexport_order", map[string]interface{}{"del_status": 1, "del_time": date.NowFormat(date.Date_Full_Layout), "last_update_time": date.NowFormat(date.Date_Full_Layout)}, map[string]interface{}{"id": param.Id}) if err == nil { orderData, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf("SELECT * FROM dataexport_order WHERE id =%s", param.Id)) if !orderData.IsEmpty() { userId := common.ObjToString(orderData.Map()["user_id"]) disRelationId := common.ObjToString(orderData.Map()["d_relation_id"]) orderStatus := common.IntAll(orderData.Map()["order_status"]) if orderStatus != 1 { //调用活动中台,释放优惠券 ok = UpdateCouponState(userId, disRelationId, 0) } } else { ok = false } } return map[string]interface{}{ "status": ok, }, nil } // UpdateCouponState 更新当前卡卷状态model: 1使用、3待使用、0未使用 productType: 商品类型0普通的1线上课程 useProduct:产品名称 discountId:满赠id func UpdateCouponState(userId, userLotteryId string, model int) (b bool) { data := url.Values{ "userId": []string{userId}, "appId": []string{"10000"}, "userLotteryId": []string{userLotteryId}, "model": []string{strconv.Itoa(model)}, } log.Println("参数:", data) // g.Cfg().MustGet(context.Background(), "couponUpdate").string() res, err := http.PostForm(g.Cfg().MustGet(context.Background(), "couponUpdate").String(), data) if err != nil { log.Println(err.Error()) return false } defer res.Body.Close() bs, _ := ioutil.ReadAll(res.Body) resMap := map[string]interface{}{} err = json.Unmarshal(bs, &resMap) if err != nil { log.Println("json.unmarshal err", resMap) } else { if common.IntAll(resMap["Code"]) == 1 { b = true } } return b }