前端对接农资商城

农资优惠券

小程序端领券中心 / 券包 / 下单用券,运营后台模板 / 投放活动 / 券包与核销明细;含鉴权约定、枚举、状态流转与请求响应示例

端
农资小程序 / 运营后台
后端服务
supplier / admin
更新
2026-09-27
接口数
34

Markdown 原文(给 AI 用):https://doc.xfun.fun/peasant-coupon-api.md

两端接口分开列出:先「小程序端」(supplier 服务,供应商登录态),后「运营后台」(admin 服务)。2026-09-27 更新:领券中心 tab、领取记录、sourceDesc、定向发放重试口径。

小程序端 · 通用约定

共 9 个接口。

枚举

枚举取值
券实例状态 status10 可使用 · 20 已锁定(被待支付订单占用) · 30 已使用 · 40 已过期 · 50 已作废(运营作废)
领券中心 tab1 可领取(默认) · 2 即将开始(开始时间在未来)
我的券包 tab1 可使用(status 10/20 且未过期,按 validEnd 升序) · 2 已使用(status 30,按更新时间倒序) · 3 已失效(status 40/50,以及 status 10 但已过期,按更新时间倒序)
优惠类型 discountType1 满减券(需 thresholdPrice 门槛) · 2 无门槛券
适用商品 productScopeType0 全场通用 · 1 指定商品(只对范围内商品金额计算门槛与优惠)
获取方式 sourceType1 自主领取(sourceDesc=自主领取) · 2 定向发放(sourceDesc=平台发放) · 3 积分兑换(sourceDesc=积分兑换,积分商城上线后出现)
有效期类型 validType(影响 validDesc 文案)1 固定有效期:"2026.09.18 00:00 至 2026.10.18 23:59" · 2 领取后生效:"领取后N天内有效",validStart=领取时刻,validEnd=领取时刻+N天

小程序端 · 领券中心

POST/peasant/coupon/center/list领券中心列表(09-23 新增 tab)

按 tab 返回当前供应商在投放范围内的自主领取活动,不分页。请求体可不传或传 {},等同 tab=1。tab=1 可领取:活动进行中且当前时间在活动起止内、模板进行中且未结束,按开始时间倒序。tab=2 即将开始:活动待生效或进行中但开始时间在未来、活动与模板都未到结束时间,按开始时间升序;此时 claimedCount 恒为 0,remainCount 为预计可领张数,领取按钮应禁用并用 startTime 展示“x月x日 开始”。公共前置:供应商审核通过且类型为种植户/供应商/包花厂,否则返回空数组;供应商需在活动投放范围及模板适用范围内。remainCount = min(活动剩余, 模板剩余, 活动每家限领-已领, 模板每家限领-已领),为 0 时展示“已领完/已达上限”并禁用领取按钮。注意:活动点过“立即开始”后 startTime 会被改成实际开始时刻。

请求参数

字段类型必填说明
tabint可选1-可领取(默认) 2-即将开始

响应

字段类型说明
activityIdlong投放活动 id,领取时传此值
activityNostring活动编号
activityNamestring活动名称
templateIdlong券模板 id
couponNamestring券名称
discountTypeint1-满减 2-无门槛
thresholdPricestring(BigDecimal)满减门槛金额,无门槛券为 0
discountPricestring(BigDecimal)优惠金额
productScopeTypeint0-全场 1-指定商品
ruleDescstring规则文案,如“满100减10”/“无门槛减5”
validDescstring有效期文案
usageDescstring使用说明
startTimedatetime活动开始时间
endTimedatetime活动结束时间(领取截止)
perSupplierLimitint活动每家限领张数,null 或 0 表示不限
claimedCountint我在本活动已领取张数
remainCountint我还可领取张数(>=0)

可能的失败 msg

请求示例

json
{
  "tab": 1
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": [
    {
      "activityId": 12,
      "activityNo": "ACT20260918001",
      "activityName": "九月农资满减",
      "templateId": 5,
      "couponName": "满100减10",
      "discountType": 1,
      "thresholdPrice": "100.00",
      "discountPrice": "10.00",
      "productScopeType": 0,
      "ruleDesc": "满100减10",
      "validDesc": "领取后30天内有效",
      "usageDesc": "仅限农资商城下单使用,每单限用一张",
      "startTime": "2026-09-18 00:00:00",
      "endTime": "2026-09-30 23:59:59",
      "perSupplierLimit": 2,
      "claimedCount": 1,
      "remainCount": 1
    }
  ]
}

POST/peasant/coupon/claim领取优惠券

对某个自主领取活动领 1 张券,成功返回新券码。服务端按 supplierId 做 1 秒防重。校验顺序:账号可领 → 活动存在且为自主领取 → 活动进行中且在时间窗内 → 模板进行中 → 供应商在投放范围 → 事务内加锁校验每家上限与库存并落库。成功后刷新领券中心和券包。

请求参数

字段类型必填说明
activityIdlong必填领券中心返回的 activityId

响应

字段类型说明
datastring新券码,格式 SIM + 8位模板id + 8位序号

可能的失败 msg

请求示例

json
{
  "activityId": 12
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": "SIM0000000500000012"
}

小程序端 · 我的券包

POST/peasant/coupon/my/list我的券包列表

按 tab 分页查询当前供应商的券。tab=1 可使用:status 10/20 且未过期,按 validEnd 升序(快过期在前),status=20 展示“订单占用中”并禁止选用;tab=2 已使用;tab=3 已失效(含 status 10 但已过期、定时任务尚未扫到的券)。

请求参数

字段类型必填说明
tabint可选1-可使用 2-已使用 3-已失效,默认 1
currentlong可选页码,默认 1
sizelong可选每页条数,默认 20

响应

字段类型说明
recordsarray券列表
records.idlong券实例 id,下单时作为 couponInstanceId 传入
records.couponCodestring券码
records.templateIdlong券模板 id
records.couponNamestring券名称(领取时快照)
records.discountTypeint1-满减 2-无门槛
records.thresholdPricestring(BigDecimal)满减门槛
records.discountPricestring(BigDecimal)优惠金额
records.productScopeTypeint0-全场 1-指定商品
records.sourceTypeint1-自主领取 2-定向发放 3-积分兑换
records.sourceDescstring来源文案:自主领取 / 平台发放 / 积分兑换(09-27 新增)
records.statusint10-可使用 20-已锁定 30-已使用 40-已过期 50-已作废
records.validStartdatetime生效时间
records.validEnddatetime失效时间
records.orderIdstring锁定/核销的订单号,未使用为空字符串
records.useTimedatetime核销时间,未使用为 null
records.createTimedatetime领取/到账时间
records.ruleDescstring规则文案
records.validDescstring有效期文案
records.usageDescstring使用说明,无则空字符串
totallong总条数
sizelong每页条数
currentlong当前页
pageslong总页数

可能的失败 msg

请求示例

json
{
  "tab": 1,
  "current": 1,
  "size": 20
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "records": [
      {
        "id": 1001,
        "couponCode": "SIM0000000500000012",
        "templateId": 5,
        "couponName": "满100减10",
        "discountType": 1,
        "thresholdPrice": "100.00",
        "discountPrice": "10.00",
        "productScopeType": 0,
        "sourceType": 1,
        "sourceDesc": "自主领取",
        "status": 10,
        "validStart": "2026-09-18 10:05:32",
        "validEnd": "2026-10-18 10:05:32",
        "orderId": "",
        "useTime": null,
        "createTime": "2026-09-18 10:05:32",
        "ruleDesc": "满100减10",
        "validDesc": "2026.09.18 10:05 至 2026.10.18 10:05",
        "usageDesc": "仅限农资商城下单使用,每单限用一张"
      }
    ],
    "total": 1,
    "size": 20,
    "current": 1,
    "pages": 1
  }
}

POST/peasant/coupon/my/records领取记录(09-27 新增)

“我的优惠券 - 领取记录”页。分页返回当前供应商领到的全部券,不分状态(含已使用/已过期/已作废),按到账时间 createTime 倒序。data.total 即“共领取 N 张优惠券”。每行展示 couponName、sourceDesc、createTime;右侧状态文案由前端按 sourceType 决定:2 显示“发放成功”,1 和 3 显示“领取成功”。请求体可不传,默认第 1 页 20 条;tab 字段在本接口无效。返回结构与“我的券包列表”完全一致。

请求参数

字段类型必填说明
currentlong可选页码,默认 1
sizelong可选每页条数,默认 20

响应

字段类型说明
recordsarray券列表
records.idlong券实例 id,下单时作为 couponInstanceId 传入
records.couponCodestring券码
records.templateIdlong券模板 id
records.couponNamestring券名称(领取时快照)
records.discountTypeint1-满减 2-无门槛
records.thresholdPricestring(BigDecimal)满减门槛
records.discountPricestring(BigDecimal)优惠金额
records.productScopeTypeint0-全场 1-指定商品
records.sourceTypeint1-自主领取 2-定向发放 3-积分兑换
records.sourceDescstring来源文案:自主领取 / 平台发放 / 积分兑换(09-27 新增)
records.statusint10-可使用 20-已锁定 30-已使用 40-已过期 50-已作废
records.validStartdatetime生效时间
records.validEnddatetime失效时间
records.orderIdstring锁定/核销的订单号,未使用为空字符串
records.useTimedatetime核销时间,未使用为 null
records.createTimedatetime领取/到账时间
records.ruleDescstring规则文案
records.validDescstring有效期文案
records.usageDescstring使用说明,无则空字符串
totallong总条数
sizelong每页条数
currentlong当前页
pageslong总页数

可能的失败 msg

请求示例

json
{
  "current": 1,
  "size": 20
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "records": [
      {
        "id": 4305,
        "couponCode": "SIM0000000600000001",
        "templateId": 6,
        "couponName": "农资采购满减券",
        "discountType": 1,
        "thresholdPrice": "200.00",
        "discountPrice": "10.00",
        "productScopeType": 0,
        "sourceType": 1,
        "sourceDesc": "自主领取",
        "status": 10,
        "validStart": "2026-09-23 17:02:29",
        "validEnd": "2026-10-23 17:02:29",
        "orderId": "",
        "useTime": null,
        "createTime": "2026-09-23 17:02:29",
        "ruleDesc": "满200减10",
        "validDesc": "2026.09.23 17:02 至 2026.10.23 17:02",
        "usageDesc": "全场农资商品可用,每单限用一张"
      },
      {
        "id": 1,
        "couponCode": "SIM0000000200000001",
        "templateId": 2,
        "couponName": "测试模板2",
        "discountType": 1,
        "thresholdPrice": "100.00",
        "discountPrice": "10.00",
        "productScopeType": 1,
        "sourceType": 2,
        "sourceDesc": "平台发放",
        "status": 10,
        "validStart": "2026-09-21 08:27:58",
        "validEnd": "2026-09-30 08:28:22",
        "orderId": "",
        "useTime": null,
        "createTime": "2026-09-23 11:13:00",
        "ruleDesc": "满100减10",
        "validDesc": "2026.09.21 08:27 至 2026.09.30 08:28",
        "usageDesc": ""
      }
    ],
    "total": 2,
    "size": 20,
    "current": 1,
    "pages": 1
  }
}

POST/peasant/coupon/my/count可使用张数

返回当前供应商 status=10(不含已锁定)且未过期的券数量,用于“我的”页角标。无请求体。

请求参数

无

响应

字段类型说明
datalong可使用张数

可能的失败 msg

请求示例

json
{}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": 3
}

小程序端 · 下单用券

POST/peasant/coupon/usable下单页可用券

确认订单页调用。购物车下单传 cartIds,商品直接下单传 skuIdPriceList(只用 skuId/buyCount);cartIds 优先。服务端用 sku 当前价(斗南基地用斗南价)×数量算商品金额,对所有可使用券逐张计算:指定商品券只累计范围内商品金额;满减券需适用金额 >= 门槛;优惠上限为 商品总额-0.01(实付最低 0.01 元)。返回 usable/unusable 两组,各按 discount 降序(可默认选中 usable[0])。无可用券时直接返回两个空数组(此时不校验商品参数)。

请求参数

字段类型必填说明
cartIdsarray可选购物车下单:购物车行 id 列表
skuIdPriceListarray可选商品直接下单:sku 与数量
skuIdPriceList.skuIdlong必填sku id
skuIdPriceList.buyCountint必填购买数量
skuIdPriceList.pricestring(BigDecimal)可选本接口忽略,可不传

响应

字段类型说明
usablearray本单可用券,按 discount 降序
usable.…MyCouponDto 全部字段-同我的券包 records 元素
usable.discountstring(BigDecimal)本单可优惠金额
usable.reasonstring可用时为空字符串
unusablearray本单不可用券
unusable.…MyCouponDto 全部字段-同上
unusable.discountstring(BigDecimal)固定 0
unusable.reasonstring不可用原因:无适用商品 / 未满100元 / 订单金额过低 / 优惠券未到生效时间 / 优惠券已过期 / 优惠券不可用

可能的失败 msg

请求示例

json
{
  "cartIds": [
    8801,
    8802
  ]
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "usable": [
      {
        "id": 1001,
        "couponCode": "SIM0000000500000012",
        "couponName": "满100减10",
        "discountType": 1,
        "thresholdPrice": "100.00",
        "discountPrice": "10.00",
        "productScopeType": 0,
        "status": 10,
        "validStart": "2026-09-18 10:05:32",
        "validEnd": "2026-10-18 10:05:32",
        "ruleDesc": "满100减10",
        "validDesc": "2026.09.18 10:05 至 2026.10.18 10:05",
        "usageDesc": "仅限农资商城下单使用,每单限用一张",
        "discount": "10.00",
        "reason": ""
      }
    ],
    "unusable": [
      {
        "id": 1002,
        "couponCode": "SIM0000000700000003",
        "couponName": "指定肥料满300减50",
        "discountType": 1,
        "thresholdPrice": "300.00",
        "discountPrice": "50.00",
        "productScopeType": 1,
        "status": 10,
        "validStart": "2026-09-01 00:00:00",
        "validEnd": "2026-09-30 23:59:59",
        "ruleDesc": "满300减50",
        "validDesc": "2026.09.01 00:00 至 2026.09.30 23:59",
        "usageDesc": "",
        "discount": "0",
        "reason": "未满300元"
      }
    ]
  }
}

POST/peasant/order/cart/create购物车创建订单(新增 couponInstanceId)

已有接口,公共下单参数新增 couponInstanceId。price 仍传商品合计(券前金额),服务端先校验 price==商品合计,再按 couponInstanceId 重新计算优惠并锁券(10→20),实付 = 商品合计 - 优惠;订单 orderPrice=商品合计,totalPrice=券后实付。券不可用时整单失败。待支付取消/超时关单自动释放券;支付成功后券变已使用。

请求参数

字段类型必填说明
couponInstanceIdlong可选新增:使用的券实例 id(可用券接口 usable[].id),不用券不传
addressIdlong必填收货地址 id(原有)
pricestring(BigDecimal)必填商品合计金额(券前,原有口径不变)
payTypeint必填1-余额支付 2-微信支付(原有)
buyerMemostring可选买家留言(原有)
cartIds 等-必填原有字段不变

响应

字段类型说明
datastring订单号(原有)

可能的失败 msg

请求示例

json
{
  "addressId": 301,
  "price": "120.00",
  "payType": 2,
  "buyerMemo": "",
  "couponInstanceId": 1001
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": "NZ20260918100532123456"
}

POST/peasant/order/product/create商品直接创建订单(新增 couponInstanceId)

已有接口,用券规则与购物车下单完全一致:price 传商品合计(券前),skuIdPriceList 每项 price 需与 sku 当前价一致,couponInstanceId 传所选券实例 id。

请求参数

字段类型必填说明
couponInstanceIdlong可选新增:使用的券实例 id,不用券不传
addressIdlong必填收货地址 id
pricestring(BigDecimal)必填商品合计金额(券前)
payTypeint必填1-余额 2-微信
buyerMemostring可选买家留言
skuIdPriceListarray必填商品列表
skuIdPriceList.skuIdlong必填sku id
skuIdPriceList.pricestring(BigDecimal)必填单价,需与当前售价一致
skuIdPriceList.buyCountint必填数量

响应

字段类型说明
datastring订单号

可能的失败 msg

请求示例

json
{
  "addressId": 301,
  "price": "120.00",
  "payType": 1,
  "buyerMemo": "尽快发货",
  "skuIdPriceList": [
    {
      "skuId": 5001,
      "price": "60.00",
      "buyCount": 2
    }
  ],
  "couponInstanceId": 1001
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": "NZ20260918100532123457"
}

POST /peasant/order/list 、 /peasant/order/detail · 订单列表 / 订单详情(新增券字段)

已有接口,列表元素与详情均新增 4 个券字段。展示口径:orderPrice=商品合计,couponPrice=券优惠(平台承担),totalPrice=实付(=orderPrice-couponPrice)。退款金额为商品口径,用券订单买家实际到账按比例扣减券优惠,最后一笔退完时清零剩余实付。

请求参数

字段类型必填说明
--可选请求参数不变

响应

字段类型说明
couponInstanceIdlong新增:券实例 id,0 表示未用券
couponCodestring新增:券码,未用券为空
couponNamestring新增:券名称快照
couponPricestring(BigDecimal)新增:券优惠金额,未用券为 0
orderPricestring(BigDecimal)原有:商品合计(券前)
totalPricestring(BigDecimal)原有:券后实付金额

可能的失败 msg

请求示例

json
{
  "orderSn": "NZ20260918100532123456"
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "orderId": "NZ20260918100532123456",
    "orderPrice": "120.00",
    "totalPrice": "110.00",
    "couponInstanceId": 1001,
    "couponCode": "SIM0000000500000012",
    "couponName": "满100减10",
    "couponPrice": "10.00",
    "payType": 2,
    "orderStatus": 1,
    "createTime": "2026-09-18 10:05:32"
  }
}

运营后台 · 通用约定

共 26 个接口。

成功示例:

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

失败示例:

json
{
  "code": 1,
  "msg": "仅进行中的模板可以暂停",
  "data": null
}

分页约定

字段说明
入参 indexInteger,页码,不传默认 1
入参 sizeInteger,页大小,不传默认 10
入参 searchCountBoolean,是否查询总数,默认 true
出参 indexInteger,当前页
出参 sizeInteger,页大小
出参 searchCountBoolean,是否查了总数
出参 totalNumber,总条数
出参 recordsArray,当前页记录
出参 otherObject,扩展数据,本组接口恒为 null

菜单

枚举

枚举取值
模板/活动状态 status0 草稿 · 10 待生效 · 20 进行中 · 30 已暂停 · 40 已结束 · 50 已作废
券实例状态 status(券包)10 可使用 · 20 已锁定(下单占用中) · 30 已使用 · 40 已过期 · 50 已作废
模板用途 useType1 通用券 · 2 积分商城专用券
优惠类型 discountType1 满减券 · 2 无门槛券
适用商品 productScopeType0 全场 · 1 指定商品
适用供应商 supplierScopeType(模板)0 全部 · 1 指定基地 · 2 指定供应商
有效期类型 validType1 固定有效期 · 2 领取后生效
模板 saveMode1 保存草稿 · 2 定时生效(startTime 必填;startTime<=当前时间则直接进行中)
投放方式 issueType1 自主领取 · 2 定向发放
投放对象 targetType(活动)0 全部供应商 · 1 指定基地 · 2 指定供应商
活动 saveMode1 仅保存(待生效) · 2 保存并启用(保存后立即调用开始)
券获取方式 sourceType(券实例)1 自主领取 · 2 定向发放 · 3 积分兑换
活动最近记录类型 recordType1 领取/发放 · 2 核销
操作日志 bizType1 模板 · 2 活动 · 3 券实例
操作日志 action1 创建 · 2 编辑 · 3 排期/立即开始(模板定时生效或立即生效、活动立即开始) · 5 暂停 · 6 恢复 · 7 手工结束 · 8 自动结束(模板结束/作废联动,或定时任务到期) · 9 作废
操作日志 operatorType0 系统 · 1 平台(运营后台) · 2 供应商

状态流转

对象从动作到接口
模板无新建 saveMode=1草稿POST /peasantCoupon/template/save
模板无新建 saveMode=2(startTime>当前时间)待生效POST /peasantCoupon/template/save
模板无新建 saveMode=2(startTime<=当前时间)进行中POST /peasantCoupon/template/save
模板草稿编辑 saveMode=2待生效 或 进行中(按 startTime 与当前时间比较)POST /peasantCoupon/template/update
模板草稿编辑 saveMode=1草稿POST /peasantCoupon/template/update
模板待生效编辑(服务端强制按 saveMode=2 校验;把 startTime 改到过去)进行中POST /peasantCoupon/template/update
模板待生效到达 startTime(supplier 侧定时任务,admin 无接口)进行中定时任务
模板进行中暂停已暂停POST /peasantCoupon/template/pause
模板已暂停恢复(要求 endTime>当前时间)进行中POST /peasantCoupon/template/resume
模板待生效/进行中/已暂停结束(其下待生效/进行中/已暂停的活动同步自动结束,活动日志 action=8)已结束POST /peasantCoupon/template/end
模板草稿/待生效/进行中/已暂停作废(要求无任何券实例且 issuedCount=0,需 reason;其下活动同步自动结束)已作废POST /peasantCoupon/template/void
模板进行中/已暂停到达 endTime(定时任务)已结束定时任务
活动无新建 saveMode=1待生效POST /peasantCoupon/activity/save
活动无新建 saveMode=2(保存后立即开始)进行中(开始失败则停留待生效并返回失败文案)POST /peasantCoupon/activity/save
活动草稿/待生效编辑(全量字段)状态不变POST /peasantCoupon/activity/update
活动进行中/已暂停编辑(仅名称、结束时间、自主领取的投放总量)状态不变POST /peasantCoupon/activity/update
活动待生效立即开始(模板须进行中且活动 endTime>当前时间;定向发放桥调 supplier 立即发券,失败回到待生效并写 issueFailMsg)进行中POST /peasantCoupon/activity/start
活动待生效到达 startTime(定时任务)进行中定时任务
活动进行中暂停已暂停POST /peasantCoupon/activity/pause
活动已暂停恢复(要求 endTime>当前时间)进行中POST /peasantCoupon/activity/resume
活动待生效/进行中/已暂停结束已结束POST /peasantCoupon/activity/end
活动草稿/待生效/进行中/已暂停作废(要求 issuedCount=0,需 reason)已作废POST /peasantCoupon/activity/void
活动待生效/进行中/已暂停所属模板结束或作废(联动)已结束由 /template/end、/template/void 触发
券实例可使用(10)人工作废(需 reason)已作废(50)POST /peasantCoupon/instance/void
券实例可使用/已锁定/已使用/已过期下单锁定、支付核销、退款解锁、到期过期(均由 supplier 侧完成,admin 只读)20/30/10/40无(admin 不提供)

公共模型

CouponScopeItemDto

字段类型说明
targetIdLong对象 id(商品 id / 基地 id / 供应商 id)
targetNameString对象名称快照,保存时服务端补齐,最长 64 字

XmPeasantCouponOpLog

字段类型说明
idLong日志 id
bizTypeInteger1-模板 2-活动 3-券实例
bizIdLong模板/活动/券实例 id
actionInteger动作,见枚举“操作日志 action”
beforeStatusInteger操作前状态(创建时为 0)
afterStatusInteger操作后状态
contentString内容:创建模板 / 编辑差异“名称:旧 → 新;发行总量:100 → 200” / 暂停 / 恢复 / 手工结束 / 作废 / 立即开始 / 定时生效 2026-09-20T10:00 / 模板结束 等,最长 1024 字
reasonString作废原因,其他动作为空串
orderIdString券实例锁定/核销相关订单号,运营端操作为空
operatorTypeInteger0-系统 1-平台 2-供应商
operatorIdLong操作人 id(平台=运营账号 userId)
operatorNameString操作人昵称
createTimeString操作时间 yyyy-MM-dd HH:mm:ss

运营后台 · 券模板

POST/peasantCoupon/template/list模板列表

分页查询模板(排除已删除 dataStatus!=0 的数据),按 id 倒序。keyword 对券名称/券编号模糊匹配;useType/discountType/status 精确过滤。列表项不含范围明细与日志,instanceCount 为 null

请求参数

字段类型必填说明
indexInteger可选页码,默认 1
sizeInteger可选页大小,默认 10
searchCountBoolean可选是否查总数,默认 true
keywordString可选券名称/券编号,模糊匹配
useTypeInteger可选用途 1-通用券 2-积分商城专用券
discountTypeInteger可选优惠类型 1-满减 2-无门槛
statusInteger可选状态 0/10/20/30/40/50

响应

字段类型说明
indexInteger当前页
sizeInteger页大小
searchCountBoolean是否查总数
totalNumber总条数
recordsArray模板列表
records.idLong模板 id
records.templateNoString券编号,NZQ+yyyyMMdd+6 位随机数,如 NZQ20260918123456
records.nameString券名称
records.useTypeInteger用途 1-通用券 2-积分商城专用券
records.discountTypeInteger1-满减券 2-无门槛券
records.thresholdPriceString(BigDecimal)使用门槛 满 X 元,无门槛券为 0
records.discountPriceString(BigDecimal)优惠金额
records.productScopeTypeInteger适用商品 0-全场 1-指定商品
records.supplierScopeTypeInteger适用供应商 0-全部 1-指定基地 2-指定供应商
records.validTypeInteger有效期类型 1-固定有效期 2-领取后生效
records.validStartString固定有效期开始,validType=2 时为 null
records.validEndString固定有效期结束,validType=2 时为 null
records.validDaysInteger领取后有效天数,validType=1 时为 0
records.totalCountInteger发行总量
records.issuedCountInteger已发放张数(各活动/积分兑换累计)
records.perSupplierLimitInteger每家供应商上限,0-不限
records.startTimeString模板生效时间(可领取/发放期起点),草稿可为 null
records.endTimeString模板结束时间,固定有效期时等于 validEnd
records.statusInteger0-草稿 10-待生效 20-进行中 30-已暂停 40-已结束 50-已作废
records.usageDescString使用说明
records.creatorIdLong创建人 id
records.creatorNameString创建人昵称
records.dataStatusInteger0-正常,固定 0
records.createTimeString创建时间
records.updateTimeString更新时间
records.ruleDescString优惠规则文案:满减“满100减20”,无门槛“无门槛减10”
records.validDescString有效期文案:固定“2026.09.20 00:00 至 2026.10.20 23:59”,领取后“领取后30天内有效”
records.instanceCountLong已产生券实例数,列表中为 null,详情才返回
records.productScopesArray列表中为 null
records.baseScopesArray列表中为 null
records.supplierScopesArray列表中为 null
records.logsArray列表中为 null
otherObject恒为 null

可能的失败 msg

请求示例

json
{
  "index": 1,
  "size": 10,
  "keyword": "秋种",
  "useType": 1,
  "status": 20
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "index": 1,
    "size": 10,
    "searchCount": true,
    "total": 1,
    "records": [
      {
        "id": 12,
        "templateNo": "NZQ20260918305127",
        "name": "秋种满100减20",
        "useType": 1,
        "discountType": 1,
        "thresholdPrice": "100.00",
        "discountPrice": "20.00",
        "productScopeType": 0,
        "supplierScopeType": 1,
        "validType": 1,
        "validStart": "2026-09-20 00:00:00",
        "validEnd": "2026-10-20 23:59:59",
        "validDays": 0,
        "totalCount": 1000,
        "issuedCount": 236,
        "perSupplierLimit": 2,
        "startTime": "2026-09-18 10:00:00",
        "endTime": "2026-10-20 23:59:59",
        "status": 20,
        "usageDesc": "仅限农资商城下单使用,不可叠加",
        "creatorId": 3,
        "creatorName": "沈浩",
        "dataStatus": 0,
        "createTime": "2026-09-18 09:30:12",
        "updateTime": "2026-09-18 10:00:00",
        "ruleDesc": "满100减20",
        "validDesc": "2026.09.20 00:00 至 2026.10.20 23:59",
        "instanceCount": null,
        "productScopes": null,
        "baseScopes": null,
        "supplierScopes": null,
        "logs": null
      }
    ],
    "other": null
  }
}

POST/peasantCoupon/template/detail模板详情

按 id 查模板,附带范围明细(指定商品 productScopes、指定基地 baseScopes、指定供应商 supplierScopes,未选的为空数组)、已产生券实例数 instanceCount、最近 20 条操作日志 logs(id 倒序)。新建/编辑接口成功后也返回本结构

请求参数

字段类型必填说明
idLong必填模板 id,>=1

响应

字段类型说明
(模板基础字段)PeasantCouponTemplateDto与 /template/list records 项字段完全相同
instanceCountLong已产生券实例数(含各状态),>0 时不可作废
productScopesArrayproductScopeType=1 时的指定商品;targetId=农资商品 id,targetName=商品名
baseScopesArraysupplierScopeType=1 时的指定基地;targetId=xm_bulky_base_config.id,targetName=基地名
supplierScopesArraysupplierScopeType=2 时的指定供应商;targetId=供应商 id,targetName=供应商名
logsArray最近 20 条操作日志,字段见 commonModels.XmPeasantCouponOpLog;全部日志用 /template/logList

可能的失败 msg

请求示例

json
{
  "id": 12
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "id": 12,
    "templateNo": "NZQ20260918305127",
    "name": "秋种满100减20",
    "useType": 1,
    "discountType": 1,
    "thresholdPrice": "100.00",
    "discountPrice": "20.00",
    "productScopeType": 0,
    "supplierScopeType": 1,
    "validType": 1,
    "validStart": "2026-09-20 00:00:00",
    "validEnd": "2026-10-20 23:59:59",
    "validDays": 0,
    "totalCount": 1000,
    "issuedCount": 236,
    "perSupplierLimit": 2,
    "startTime": "2026-09-18 10:00:00",
    "endTime": "2026-10-20 23:59:59",
    "status": 20,
    "usageDesc": "仅限农资商城下单使用,不可叠加",
    "creatorId": 3,
    "creatorName": "沈浩",
    "dataStatus": 0,
    "createTime": "2026-09-18 09:30:12",
    "updateTime": "2026-09-18 10:00:00",
    "ruleDesc": "满100减20",
    "validDesc": "2026.09.20 00:00 至 2026.10.20 23:59",
    "instanceCount": 236,
    "productScopes": [],
    "baseScopes": [
      {
        "targetId": 5,
        "targetName": "斗南基地"
      },
      {
        "targetId": 8,
        "targetName": "晋宁基地"
      }
    ],
    "supplierScopes": [],
    "logs": [
      {
        "id": 88,
        "bizType": 1,
        "bizId": 12,
        "action": 3,
        "beforeStatus": 0,
        "afterStatus": 20,
        "content": "立即生效",
        "reason": "",
        "orderId": null,
        "operatorType": 1,
        "operatorId": 3,
        "operatorName": "沈浩",
        "createTime": "2026-09-18 10:00:00"
      },
      {
        "id": 87,
        "bizType": 1,
        "bizId": 12,
        "action": 1,
        "beforeStatus": 0,
        "afterStatus": 0,
        "content": "创建模板",
        "reason": "",
        "orderId": null,
        "operatorType": 1,
        "operatorId": 3,
        "operatorName": "沈浩",
        "createTime": "2026-09-18 10:00:00"
      }
    ]
  }
}

POST/peasantCoupon/template/save新建模板

创建模板。saveMode=1 保存为草稿(0);saveMode=2 定时生效:startTime>当前时间进入待生效(10),startTime<=当前时间直接进行中(20)。范围只传 id,名称由服务端补齐。校验顺序:名称非空且<=64字 → useType∈{1,2} → discountType∈{1,2} → discountPrice 0.015000 → 满减券 thresholdPrice 110000 且 discountPrice<thresholdPrice → productScopeType=1 须传 productIds → supplierScopeType=1 须传 baseIds、=2 须传 supplierIds → validType∈{1,2} → 积分商城专用券(useType=2) 只能 validType=2 → validType=1 时 validStart<validEnd 且 startTime<=validEnd(endTime 自动取 validEnd,validDays 置 0);validType=2 时 validDays>=1,saveMode=2 必填 endTime,且 startTime<endTime → saveMode=2 必填 startTime 且结束时间>当前时间 → totalCount>=1 → perSupplierLimit>=0 → usageDesc<=500字。无门槛券 thresholdPrice 服务端强制写 0。券编号 NZQ+日期+6 位随机自动生成。成功返回模板详情

请求参数

字段类型必填说明
nameString必填券名称,<=64 字
useTypeInteger必填1-通用券 2-积分商城专用券(2 只能领取后生效,且不能被活动选用)
discountTypeInteger必填1-满减券 2-无门槛券
thresholdPriceBigDecimal可选满 X 元,满减券必填 1~10000;无门槛券传 0 或不传
discountPriceBigDecimal必填优惠金额 0.01~5000,满减券须小于门槛
productScopeTypeInteger可选0-全场(默认) 1-指定商品
productIdsArray可选指定商品 id 列表,productScopeType=1 时必填(农资商品 xm_peasant_product.id)
supplierScopeTypeInteger可选0-全部(默认) 1-指定基地 2-指定供应商
baseIdsArray可选指定基地 id 列表(xm_bulky_base_config.id),supplierScopeType=1 时必填
supplierIdsArray可选指定供应商 id 列表,supplierScopeType=2 时必填
validTypeInteger必填1-固定有效期 2-领取后生效
validStartString可选yyyy-MM-dd HH:mm:ss,validType=1 必填
validEndString可选yyyy-MM-dd HH:mm:ss,validType=1 必填,同时作为模板 endTime
validDaysInteger可选领取后有效天数,validType=2 必填且>=1
totalCountInteger必填发行总量 >=1
perSupplierLimitInteger可选每家上限,0-不限(默认 0)
startTimeString可选模板生效时间,saveMode=2 必填;<=当前时间则立即进行中
endTimeString可选模板结束时间,validType=2 且 saveMode=2 时必填;validType=1 时忽略(取 validEnd)
usageDescString可选使用说明 <=500 字
saveModeInteger可选1-保存草稿(默认) 2-定时生效

响应

字段类型说明
dataPeasantCouponTemplateDto同 /template/detail 返回结构

可能的失败 msg

请求示例

json
{
  "name": "秋种满100减20",
  "useType": 1,
  "discountType": 1,
  "thresholdPrice": 100,
  "discountPrice": 20,
  "productScopeType": 0,
  "supplierScopeType": 1,
  "baseIds": [
    5,
    8
  ],
  "validType": 1,
  "validStart": "2026-09-20 00:00:00",
  "validEnd": "2026-10-20 23:59:59",
  "totalCount": 1000,
  "perSupplierLimit": 2,
  "startTime": "2026-09-18 10:00:00",
  "usageDesc": "仅限农资商城下单使用,不可叠加",
  "saveMode": 2
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "id": 12,
    "templateNo": "NZQ20260918305127",
    "name": "秋种满100减20",
    "status": 20,
    "issuedCount": 0,
    "instanceCount": 0,
    "baseScopes": [
      {
        "targetId": 5,
        "targetName": "斗南基地"
      },
      {
        "targetId": 8,
        "targetName": "晋宁基地"
      }
    ],
    "productScopes": [],
    "supplierScopes": [],
    "logs": [
      {
        "id": 88,
        "action": 3,
        "beforeStatus": 0,
        "afterStatus": 20,
        "content": "立即生效",
        "operatorName": "沈浩",
        "createTime": "2026-09-18 10:00:00"
      },
      {
        "id": 87,
        "action": 1,
        "beforeStatus": 0,
        "afterStatus": 0,
        "content": "创建模板",
        "operatorName": "沈浩",
        "createTime": "2026-09-18 10:00:00"
      }
    ],
    "其余字段": "同详情"
  }
}

POST/peasantCoupon/template/update编辑模板

请求体与新建相同,另需 id。已结束/已作废不可编辑。草稿/待生效:全量字段可改,按新建规则完整校验并重写范围明细;待生效模板服务端强制按 saveMode=2 校验(startTime/endTime 必填),且若把 startTime 改到当前时间之前则直接进入进行中;草稿传 saveMode=2 等价于排期生效。进行中/已暂停:只接受 name、usageDesc、totalCount、endTime 四个字段(其余字段忽略),校验 name 非空、totalCount>=已发放数、endTime>当前时间、固定有效期时 endTime 不早于 validStart、endTime 不早于其下未结束活动的最晚结束时间;固定有效期模板改 endTime 会同步改 validEnd(新发的券按新有效期)。更新采用当前状态做乐观条件,状态被定时任务改变会返回“模板状态已变更,请刷新后重试”。字段差异写入操作日志。成功返回模板详情

请求参数

字段类型必填说明
idLong必填模板 id
nameString必填券名称(所有状态均可改)
usageDescString可选使用说明(所有状态均可改)
totalCountInteger必填发行总量,进行中/已暂停时须>=issuedCount
endTimeString可选结束时间;进行中/已暂停时必填且>当前时间;草稿/待生效固定有效期时忽略(取 validEnd)
saveModeInteger可选草稿时 1-仍为草稿 2-排期生效;待生效时服务端固定按 2 处理;进行中/已暂停忽略
(其余字段)同新建可选useType/discountType/thresholdPrice/discountPrice/productScopeType/productIds/supplierScopeType/baseIds/supplierIds/validType/validStart/validEnd/validDays/perSupplierLimit/startTime 仅草稿/待生效生效;因 @Validated 注解,useType、discountType、discountPrice、validType 即使进行中也必须传值(可原样回传)

响应

字段类型说明
dataPeasantCouponTemplateDto同 /template/detail 返回结构

可能的失败 msg

请求示例

json
{
  "id": 12,
  "name": "秋种满100减20(加量)",
  "useType": 1,
  "discountType": 1,
  "thresholdPrice": 100,
  "discountPrice": 20,
  "validType": 1,
  "totalCount": 2000,
  "endTime": "2026-10-31 23:59:59",
  "usageDesc": "仅限农资商城下单使用,不可叠加"
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "id": 12,
    "name": "秋种满100减20(加量)",
    "totalCount": 2000,
    "endTime": "2026-10-31 23:59:59",
    "validEnd": "2026-10-31 23:59:59",
    "status": 20,
    "logs": [
      {
        "id": 90,
        "action": 2,
        "beforeStatus": 20,
        "afterStatus": 20,
        "content": "名称:秋种满100减20 → 秋种满100减20(加量);发行总量:1000 → 2000;结束时间:2026-10-20T23:59:59 → 2026-10-31T23:59:59",
        "operatorName": "沈浩",
        "createTime": "2026-09-18 11:20:05"
      }
    ],
    "其余字段": "同详情"
  }
}

POST/peasantCoupon/template/pause暂停模板

进行中(20) → 已暂停(30),CAS 更新。暂停后供应商端不可领取/发放,已发出的券不受影响

请求参数

字段类型必填说明
idLong必填模板 id

响应

字段类型说明
dataBooleantrue

可能的失败 msg

请求示例

json
{
  "id": 12
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

POST/peasantCoupon/template/resume恢复模板

已暂停(30) → 进行中(20)。前置:endTime 必须晚于当前时间(已到期的只能保持暂停或结束)

请求参数

字段类型必填说明
idLong必填模板 id

响应

字段类型说明
dataBooleantrue

可能的失败 msg

请求示例

json
{
  "id": 12
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

POST/peasantCoupon/template/end结束模板

待生效/进行中/已暂停 → 已结束(40),不可逆。其下所有待生效/进行中/已暂停的投放活动同步置为已结束(活动日志 action=8,内容“模板结束”)。已发出的券按各自有效期继续可用。草稿不能结束(请用作废)

请求参数

字段类型必填说明
idLong必填模板 id

响应

字段类型说明
dataBooleantrue

可能的失败 msg

请求示例

json
{
  "id": 12
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

POST/peasantCoupon/template/void作废模板

草稿/待生效/进行中/已暂停 → 已作废(50),需填写原因。前置:该模板未产生任何券实例(instanceCount=0 且 issuedCount=0,CAS 同时校验以防并发领取);已有券的请用“结束”。其下未结束活动同步置为已结束(日志内容“模板作废”)。前端建议:detail.instanceCount>0 时隐藏作废按钮

请求参数

字段类型必填说明
idLong必填模板 id
reasonString必填作废原因,非空且<=255 字

响应

字段类型说明
dataBooleantrue

可能的失败 msg

请求示例

json
{
  "id": 13,
  "reason": "配置错误,重新建券"
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

POST/peasantCoupon/template/logList模板操作日志

分页查询某模板的全部操作日志(bizType=1),按 id 倒序。详情里只带最近 20 条,需要看全部时用本接口

请求参数

字段类型必填说明
idLong必填模板 id
indexInteger可选页码,默认 1
sizeInteger可选页大小,默认 10
searchCountBoolean可选是否查总数,默认 true

响应

字段类型说明
index/size/searchCount/total/other分页信息同 pageEnvelope
recordsArray日志列表,字段见 commonModels.XmPeasantCouponOpLog

可能的失败 msg

请求示例

json
{
  "id": 12,
  "index": 1,
  "size": 20
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "index": 1,
    "size": 20,
    "searchCount": true,
    "total": 3,
    "records": [
      {
        "id": 90,
        "bizType": 1,
        "bizId": 12,
        "action": 2,
        "beforeStatus": 20,
        "afterStatus": 20,
        "content": "发行总量:1000 → 2000",
        "reason": "",
        "orderId": null,
        "operatorType": 1,
        "operatorId": 3,
        "operatorName": "沈浩",
        "createTime": "2026-09-18 11:20:05"
      },
      {
        "id": 88,
        "bizType": 1,
        "bizId": 12,
        "action": 3,
        "beforeStatus": 0,
        "afterStatus": 20,
        "content": "立即生效",
        "reason": "",
        "orderId": null,
        "operatorType": 1,
        "operatorId": 3,
        "operatorName": "沈浩",
        "createTime": "2026-09-18 10:00:00"
      },
      {
        "id": 87,
        "bizType": 1,
        "bizId": 12,
        "action": 1,
        "beforeStatus": 0,
        "afterStatus": 0,
        "content": "创建模板",
        "reason": "",
        "orderId": null,
        "operatorType": 1,
        "operatorId": 3,
        "operatorName": "沈浩",
        "createTime": "2026-09-18 10:00:00"
      }
    ],
    "other": null
  }
}

POST/peasantCoupon/template/options模板下拉

活动新建/编辑表单的模板选择器数据:只返回通用券(useType=1)且状态为待生效(10)/进行中(20)的模板,id 倒序,不分页。无请求体(可传 {})。前端可用 totalCount-issuedCount 显示剩余可发、用 startTime/endTime 限制活动时间选择范围、用 supplierScopeType 提示投放对象会与模板适用供应商取交集

请求参数

无

响应

字段类型说明
dataArray模板选项列表
data.idLong模板 id(活动 templateId)
data.templateNoString券编号
data.nameString券名称
data.ruleDescString优惠规则文案
data.validDescString有效期文案
data.statusInteger10-待生效 20-进行中(活动只能在模板进行中时开始)
data.startTimeString模板生效时间,活动开始时间不能早于它
data.endTimeString模板结束时间,活动结束时间不能晚于它
data.totalCountInteger发行总量
data.issuedCountInteger已发放
data.perSupplierLimitInteger模板每家上限,0-不限;定向发放每家张数受其约束
data.supplierScopeTypeInteger模板适用供应商 0-全部 1-指定基地 2-指定供应商

请求示例

json
{}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": [
    {
      "id": 12,
      "templateNo": "NZQ20260918305127",
      "name": "秋种满100减20",
      "ruleDesc": "满100减20",
      "validDesc": "2026.09.20 00:00 至 2026.10.20 23:59",
      "status": 20,
      "startTime": "2026-09-18 10:00:00",
      "endTime": "2026-10-20 23:59:59",
      "totalCount": 2000,
      "issuedCount": 236,
      "perSupplierLimit": 2,
      "supplierScopeType": 1
    },
    {
      "id": 11,
      "templateNo": "NZQ20260915880213",
      "name": "新客无门槛10元",
      "ruleDesc": "无门槛减10",
      "validDesc": "领取后30天内有效",
      "status": 10,
      "startTime": "2026-09-25 00:00:00",
      "endTime": "2026-12-31 23:59:59",
      "totalCount": 500,
      "issuedCount": 0,
      "perSupplierLimit": 1,
      "supplierScopeType": 0
    }
  ]
}

运营后台 · 投放活动

POST/peasantCoupon/activity/list活动列表

分页查询投放活动,id 倒序。keyword 对活动名/活动编号/模板名/模板编号模糊匹配;issueType/status/templateId 精确过滤(模板详情页“查看活动”可传 templateId)。列表项带 ruleDesc/validDesc(来自模板),不含范围、效果、记录、日志 【10-10 调整】已作废活动返回 voidReason/voidOperatorName/voidTime(与券包明细字段名一致)。

请求参数

字段类型必填说明
indexInteger可选页码,默认 1
sizeInteger可选页大小,默认 10
searchCountBoolean可选是否查总数,默认 true
keywordString可选活动名/券名/券编号/活动编号
issueTypeInteger可选投放方式 1-自主领取 2-定向发放
statusInteger可选状态 0/10/20/30/40/50
templateIdLong可选按模板过滤

响应

字段类型说明
index/size/searchCount/total/other分页信息同 pageEnvelope
recordsArray活动列表
records.idLong活动 id
records.activityNoString活动编号,TFL+yyyyMMdd+6 位随机数
records.nameString活动名称
records.templateIdLong模板 id
records.templateNoString模板券编号快照
records.templateNameString模板券名称快照
records.issueTypeInteger投放方式 1-自主领取 2-定向发放
records.targetTypeInteger投放对象 0-全部供应商 1-指定基地 2-指定供应商
records.perSupplierLimitInteger自主领取=每家限领;定向发放=每家发放张数
records.totalCountInteger投放总量;定向发放为 有效对象数×每家张数(服务端重算)
records.issuedCountInteger已发放/已领取张数
records.targetCountInteger有效对象数(定向发放),自主领取为 0
records.startTimeString活动开始时间
records.endTimeString活动结束时间
records.statusInteger0-草稿 10-待生效 20-进行中 30-已暂停 40-已结束 50-已作废(admin 新建直接为 10,不产生草稿)
records.issueTimeString定向发放实际执行时间,未执行为 null
records.issueFailMsgString定向发放失败原因,成功/未执行为空串;待生效且非空时应在页面提示。业务性失败(库存不足/无有效投放对象)不会自动重试,需运营编辑活动或再点“立即开始”
records.creatorIdLong创建人 id
records.creatorNameString创建人昵称
records.dataStatusInteger固定 0
records.createTimeString创建时间
records.updateTimeString更新时间
records.ruleDescString券优惠规则文案(取自模板)
records.validDescString券有效期文案(取自模板)
records.baseScopesArray列表中为 null
records.supplierScopesArray列表中为 null
records.effectCouponActivityEffectDto列表中为 null
records.recentRecordsArray列表中为 null
records.logsArray列表中为 null
voidReasonString【10-10 新增】作废原因,仅已作废(50)有值,其余为空
voidOperatorNameString【10-10 新增】作废操作人,仅已作废有值
voidTimeString【10-10 新增】作废时间 yyyy-MM-dd HH:mm:ss,仅已作废有值

请求示例

json
{
  "index": 1,
  "size": 10,
  "issueType": 2,
  "status": 20
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "index": 1,
    "size": 10,
    "searchCount": true,
    "total": 1,
    "records": [
      {
        "id": 31,
        "activityNo": "TFL20260918417702",
        "name": "斗南基地秋种定向发券",
        "templateId": 12,
        "templateNo": "NZQ20260918305127",
        "templateName": "秋种满100减20",
        "issueType": 2,
        "targetType": 1,
        "perSupplierLimit": 2,
        "totalCount": 236,
        "issuedCount": 236,
        "targetCount": 118,
        "startTime": "2026-09-18 12:00:00",
        "endTime": "2026-10-20 23:59:59",
        "status": 20,
        "issueTime": "2026-09-18 12:00:03",
        "issueFailMsg": "",
        "creatorId": 3,
        "creatorName": "沈浩",
        "dataStatus": 0,
        "createTime": "2026-09-18 11:50:00",
        "updateTime": "2026-09-18 12:00:03",
        "ruleDesc": "满100减20",
        "validDesc": "2026.09.20 00:00 至 2026.10.20 23:59",
        "baseScopes": null,
        "supplierScopes": null,
        "effect": null,
        "recentRecords": null,
        "logs": null
      }
    ],
    "other": null
  }
}

POST/peasantCoupon/activity/detail活动详情

活动基础信息 + 投放范围(baseScopes/supplierScopes)+ 效果指标 effect + 最近领取与核销记录 recentRecords(最近 10 条领取/发放 ∪ 最近 10 条核销,按时间倒序取 10)+ 最近 20 条操作日志。新建/编辑成功后同样返回本结构。效果口径:issuedCount 等来自券实例表按状态聚合;订单指标来自已支付订单(order_status∈1,2,3,5 且 pay_time 非空),整单退款(5)计入 orderSupplierCount 但不计入 orderCount/成本/实付 【10-10 调整】已作废活动返回 voidReason/voidOperatorName/voidTime(与券包明细字段名一致)。

请求参数

字段类型必填说明
idLong必填活动 id

响应

字段类型说明
(活动基础字段)PeasantCouponActivityDto与 /activity/list records 项相同
baseScopesArraytargetType=1 的指定基地列表,其他为空数组
supplierScopesArraytargetType=2 的指定供应商列表,其他为空数组
effectCouponActivityEffectDto效果指标
effect.issuedCountLong已发放/领取张数(券实例总数)
effect.totalCountInteger投放总量
effect.issueRateString(BigDecimal)投放达成率 % = issuedCount/totalCount×100,两位小数,如 "100.00"
effect.supplierCountLong覆盖供应商数(去重)
effect.usedCountLong已核销张数(status=30)
effect.useRateString(BigDecimal)核销转化率 % = usedCount/issuedCount×100
effect.usableCountLong可使用张数(10)
effect.lockedCountLong已锁定张数(20)
effect.expiredCountLong已过期张数(40)
effect.voidCountLong已作废张数(50)
effect.couponCostString(BigDecimal)估算优惠成本 = Σ关联订单 coupon_price(剔除整单退款)
effect.paidAmountString(BigDecimal)关联订单实付金额合计
effect.driveRatioString(BigDecimal)|null消费带动比 = paidAmount/couponCost,成本为 0 时 null,前端显示“—”
effect.avgOrderAmountString(BigDecimal)关联订单客单价 = paidAmount/orderCount,无订单为 0
effect.orderCountLong关联订单数(剔除整单退款)
effect.orderCoverRateString(BigDecimal)订单关联覆盖率 % = 下单供应商数/覆盖供应商数×100
recentRecordsArray最近领取与核销 10 条
recentRecords.instanceIdLong券实例 id,可跳转 /instance/detail
recentRecords.couponCodeString券码
recentRecords.supplierNameString供应商名
recentRecords.recordTypeInteger1-领取/发放 2-核销
recentRecords.statusInteger券当前状态 10/20/30/40/50
recentRecords.timeString领取/发放时间(券创建时间)或核销时间
recentRecords.orderIdString锁定/核销订单号,未使用为 null
logsArray最近 20 条操作日志(bizType=2)
voidReasonString【10-10 新增】作废原因,仅已作废(50)有值,其余为空
voidOperatorNameString【10-10 新增】作废操作人,仅已作废有值
voidTimeString【10-10 新增】作废时间 yyyy-MM-dd HH:mm:ss,仅已作废有值

可能的失败 msg

请求示例

json
{
  "id": 31
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "id": 31,
    "activityNo": "TFL20260918417702",
    "name": "斗南基地秋种定向发券",
    "templateId": 12,
    "templateNo": "NZQ20260918305127",
    "templateName": "秋种满100减20",
    "issueType": 2,
    "targetType": 1,
    "perSupplierLimit": 2,
    "totalCount": 236,
    "issuedCount": 236,
    "targetCount": 118,
    "startTime": "2026-09-18 12:00:00",
    "endTime": "2026-10-20 23:59:59",
    "status": 20,
    "issueTime": "2026-09-18 12:00:03",
    "issueFailMsg": "",
    "creatorId": 3,
    "creatorName": "沈浩",
    "dataStatus": 0,
    "createTime": "2026-09-18 11:50:00",
    "updateTime": "2026-09-18 12:00:03",
    "ruleDesc": "满100减20",
    "validDesc": "2026.09.20 00:00 至 2026.10.20 23:59",
    "baseScopes": [
      {
        "targetId": 5,
        "targetName": "斗南基地"
      }
    ],
    "supplierScopes": [],
    "effect": {
      "issuedCount": 236,
      "totalCount": 236,
      "issueRate": "100.00",
      "supplierCount": 118,
      "usedCount": 41,
      "useRate": "17.37",
      "usableCount": 180,
      "lockedCount": 3,
      "expiredCount": 0,
      "voidCount": 12,
      "couponCost": "820.00",
      "paidAmount": "9865.50",
      "driveRatio": "12.03",
      "avgOrderAmount": "246.64",
      "orderCount": 40,
      "orderCoverRate": "28.81"
    },
    "recentRecords": [
      {
        "instanceId": 5120,
        "couponCode": "NZ2609180000512",
        "supplierName": "云南丰花种植",
        "recordType": 2,
        "status": 30,
        "time": "2026-09-18 15:32:10",
        "orderId": "PO2609181532001"
      },
      {
        "instanceId": 5236,
        "couponCode": "NZ2609180000628",
        "supplierName": "晋宁兴农合作社",
        "recordType": 1,
        "status": 10,
        "time": "2026-09-18 12:00:03",
        "orderId": null
      }
    ],
    "logs": [
      {
        "id": 102,
        "bizType": 2,
        "bizId": 31,
        "action": 3,
        "beforeStatus": 10,
        "afterStatus": 20,
        "content": "立即开始",
        "reason": "",
        "orderId": null,
        "operatorType": 1,
        "operatorId": 3,
        "operatorName": "沈浩",
        "createTime": "2026-09-18 12:00:00"
      },
      {
        "id": 101,
        "bizType": 2,
        "bizId": 31,
        "action": 1,
        "beforeStatus": 0,
        "afterStatus": 10,
        "content": "创建活动",
        "reason": "",
        "orderId": null,
        "operatorType": 1,
        "operatorId": 3,
        "operatorName": "沈浩",
        "createTime": "2026-09-18 11:50:00"
      }
    ]
  }
}

POST/peasantCoupon/activity/targetCount有效对象数

定向发放表单联动接口:按当前选择实时计算有效对象数与投放总量(=对象数×每家张数),表单里模板/投放对象/基地/供应商/每家张数变化时调用。口径:审核通过的种植户/供应商/包花厂 ∩ 活动投放范围 ∩ 模板适用供应商范围 ∩ 未达模板每家上限(模板 perSupplierLimit>0 时,已获得数+本次张数 <= 上限)∩ 未在该活动获得过(编辑时传 activityId 排除)。自主领取表单不需要调用

请求参数

字段类型必填说明
templateIdLong必填模板 id
targetTypeInteger可选0-全部供应商(默认) 1-指定基地 2-指定供应商
baseIdsArray可选targetType=1 时的基地 id 列表(为空则对象数为 0)
supplierIdsArray可选targetType=2 时的供应商 id 列表(为空则对象数为 0)
perSupplierLimitInteger可选每家发放张数,默认 1,<1 按 1 计
activityIdLong可选编辑已有活动时传,排除该活动已发放过的对象

响应

字段类型说明
targetCountInteger有效对象数
totalCountInteger投放总量 = targetCount × 每家张数,用于表单只读回显

可能的失败 msg

请求示例

json
{
  "templateId": 12,
  "targetType": 1,
  "baseIds": [
    5
  ],
  "perSupplierLimit": 2
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "targetCount": 118,
    "totalCount": 236
  }
}

POST/peasantCoupon/activity/save新建活动(10-10 调整:支持草稿)

创建投放活动。【10-10 调整】saveMode=1 存为草稿(0):不会自动开始、供应商端不可见,需编辑时传 saveMode=2 或调 /activity/enable 启用;saveMode=2 存为待生效(10)。校验顺序:模板存在 → 模板为通用券 → 模板状态待生效/进行中 → 名称非空<=64字 → issueType∈{1,2} → targetType=1 须传 baseIds、=2 须传 supplierIds → perSupplierLimit>=1 → startTime<endTime → startTime>=模板 startTime → endTime<=模板 endTime → endTime>当前时间 → 自主领取 totalCount>=perSupplierLimit。定向发放的 totalCount 忽略前端值,服务端按有效对象数×每家张数重算并写 targetCount。saveMode=2 在保存事务提交后:开始时间在未来则保持待生效(10)、startTime 不变,到点由定时任务自动开始;开始时间已到则自动调用“立即开始”,成功返回进行中的详情,失败返回 code=1、msg=“活动已保存为待生效,但启用失败:<原因>”,此时活动已存在(前端应刷新列表而非重复提交)。活动编号 TFL+日期+6 位随机

请求参数

字段类型必填说明
nameString必填活动名称 <=64 字
templateIdLong必填模板 id,取自 /template/options
issueTypeInteger必填1-自主领取 2-定向发放
targetTypeInteger可选0-全部供应商(默认) 1-指定基地 2-指定供应商
baseIdsArray可选targetType=1 必填
supplierIdsArray可选targetType=2 必填
perSupplierLimitInteger必填自主领取=每家限领;定向发放=每家发放张数;>=1
totalCountInteger可选投放总量,自主领取必填且>=perSupplierLimit;定向发放忽略(服务端重算)
startTimeString必填活动开始 yyyy-MM-dd HH:mm:ss,不早于模板生效时间(逻辑校验必填)
endTimeString必填活动结束,不晚于模板结束时间且晚于当前时间(逻辑校验必填)
saveModeInteger可选1-仅保存草稿(默认,状态 0,不会自动开始) 2-保存并启用(开始时间未到为待生效 10,已到立即开始 20)

响应

字段类型说明
dataPeasantCouponActivityDto同 /activity/detail 返回结构

可能的失败 msg

请求示例

json
{
  "name": "斗南基地秋种定向发券",
  "templateId": 12,
  "issueType": 2,
  "targetType": 1,
  "baseIds": [
    5
  ],
  "perSupplierLimit": 2,
  "startTime": "2026-09-18 12:00:00",
  "endTime": "2026-10-20 23:59:59",
  "saveMode": 2
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "id": 31,
    "activityNo": "TFL20260918417702",
    "name": "斗南基地秋种定向发券",
    "status": 20,
    "issueType": 2,
    "targetType": 1,
    "perSupplierLimit": 2,
    "targetCount": 118,
    "totalCount": 236,
    "issuedCount": 236,
    "issueTime": "2026-09-18 12:00:03",
    "issueFailMsg": "",
    "baseScopes": [
      {
        "targetId": 5,
        "targetName": "斗南基地"
      }
    ],
    "effect": {
      "issuedCount": 236,
      "totalCount": 236,
      "issueRate": "100.00",
      "supplierCount": 118,
      "usedCount": 0,
      "useRate": "0.00",
      "usableCount": 236,
      "lockedCount": 0,
      "expiredCount": 0,
      "voidCount": 0,
      "couponCost": "0",
      "paidAmount": "0",
      "driveRatio": null,
      "avgOrderAmount": "0",
      "orderCount": 0,
      "orderCoverRate": "0.00"
    },
    "其余字段": "同详情"
  }
}

POST/peasantCoupon/activity/update编辑活动

请求体同新建,另需 id。已结束/已作废不可编辑。草稿/待生效:全量字段可改(可换模板),按新建规则完整校验,重写范围明细,定向发放重算 targetCount/totalCount;更新以当前状态为乐观条件,状态被定时任务改变返回“活动状态已变更,请刷新后重试”。进行中/已暂停:只接受 name、endTime、(自主领取时)totalCount,校验 name 非空、endTime>当前时间且<=模板 endTime、totalCount>=issuedCount;定向发放进行中不能改总量。【10-10 调整】草稿编辑时传 saveMode=2 则保存后启用(效果同 /activity/enable),传 1 或不传仍为草稿;非草稿状态忽略 saveMode。字段差异写日志。成功返回详情。【09-23 调整】待生效活动编辑成功会清空 issueFailMsg,已到开始时间的定向发放活动会在下一分钟由定时任务自动重发一次

请求参数

字段类型必填说明
idLong必填活动 id
nameString必填活动名称
templateIdLong必填模板 id(@Validated 必传;进行中/已暂停时忽略,原样回传)
issueTypeInteger必填投放方式(@Validated 必传;进行中/已暂停时忽略)
perSupplierLimitInteger必填每家张数(@Validated 必传;进行中/已暂停时忽略)
endTimeString必填结束时间,进行中/已暂停时必填且>当前时间、<=模板结束时间
totalCountInteger可选自主领取的投放总量,进行中/已暂停时须>=issuedCount
targetType/baseIds/supplierIds/startTime同新建可选仅草稿/待生效生效
saveModeInteger可选仅草稿生效:2-保存并启用;1/不传-仍为草稿

响应

字段类型说明
dataPeasantCouponActivityDto同 /activity/detail 返回结构

可能的失败 msg

请求示例

json
{
  "id": 32,
  "name": "全场自主领取(延期)",
  "templateId": 12,
  "issueType": 1,
  "targetType": 0,
  "perSupplierLimit": 1,
  "totalCount": 800,
  "startTime": "2026-09-19 00:00:00",
  "endTime": "2026-10-15 23:59:59"
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "id": 32,
    "name": "全场自主领取(延期)",
    "totalCount": 800,
    "endTime": "2026-10-15 23:59:59",
    "status": 20,
    "logs": [
      {
        "id": 110,
        "action": 2,
        "beforeStatus": 20,
        "afterStatus": 20,
        "content": "名称:全场自主领取 → 全场自主领取(延期);结束时间:2026-10-10T23:59:59 → 2026-10-15T23:59:59;投放总量:500 → 800",
        "operatorName": "沈浩",
        "createTime": "2026-09-18 14:02:11"
      }
    ],
    "其余字段": "同详情"
  }
}

POST/peasantCoupon/activity/enable启用草稿(10-10 新增)

草稿(0) → 待生效(10)。前置:活动为草稿;活动 endTime>当前时间;所属模板为待生效或进行中。启用后:开始时间在未来则停在待生效,到点由定时任务自动开始;开始时间已到则立即执行“立即开始”(startTime 改为当前时间,定向发放同步发券,可能耗时数秒,前端加 loading),开始失败返回 code=1 msg=“活动已保存为待生效,但启用失败:<原因>”,此时活动已是待生效。成功返回活动详情,按返回的 status 刷新行。列表操作建议:草稿显示“启用/编辑/作废”,待生效显示“立即开始/编辑/结束/作废”。

请求参数

字段类型必填说明
idLong必填活动 id

响应

字段类型说明
dataPeasantCouponActivityDto同 /activity/detail 返回结构

可能的失败 msg

请求示例

json
{
  "id": 20
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "id": 20,
    "status": 10,
    "startTime": "2026-10-10 20:00:00"
  }
}

POST/peasantCoupon/activity/start立即开始

待生效(10) → 进行中(20),并把 startTime 改为当前时间。前置:活动待生效;所属模板必须是进行中(20)(待生效模板需先到生效时间或编辑生效时间);活动 endTime>当前时间。自主领取:直接进行中,供应商端开始可领。定向发放:置进行中后桥调 supplier 侧 /peasant/coupon/activity/issue 同步发券(可能耗时数秒,前端加 loading);发放失败时活动回到待生效并写 issueFailMsg,接口返回 code=1 msg=失败原因,前端提示后刷新详情可见 issueFailMsg。成功时 data 为 true(自主领取)或 supplier 返回的数据。【09-23 调整】发放失败后的自动重试:库存不足、无有效投放对象等业务性失败不再自动重试,活动停在待生效并保留 issueFailMsg,需运营处理后再次点“立即开始”,或编辑活动(编辑会清空 issueFailMsg,定时任务下一分钟自动重发一次);只改模板总量不会清活动的 issueFailMsg。仅“发放异常…”这类系统错误会每 10 分钟自动重试

请求参数

字段类型必填说明
idLong必填活动 id

响应

字段类型说明
dataBoolean|Object自主领取 true;定向发放为 supplier 发放结果数据(前端可忽略,重新拉详情)

可能的失败 msg

请求示例

json
{
  "id": 31
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

POST/peasantCoupon/activity/pause暂停活动

进行中(20) → 已暂停(30)。自主领取暂停后供应商端不可领取;定向发放已发完的暂停无实际影响

请求参数

字段类型必填说明
idLong必填活动 id

响应

字段类型说明
dataBooleantrue

可能的失败 msg

请求示例

json
{
  "id": 32
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

POST/peasantCoupon/activity/resume恢复活动

已暂停(30) → 进行中(20)。前置:活动 endTime 晚于当前时间

请求参数

字段类型必填说明
idLong必填活动 id

响应

字段类型说明
dataBooleantrue

可能的失败 msg

请求示例

json
{
  "id": 32
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

POST/peasantCoupon/activity/end结束活动

待生效/进行中/已暂停 → 已结束(40),不可逆;已发出的券不受影响

请求参数

字段类型必填说明
idLong必填活动 id

响应

字段类型说明
dataBooleantrue

可能的失败 msg

请求示例

json
{
  "id": 32
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

POST/peasantCoupon/activity/void作废活动

草稿/待生效/进行中/已暂停 → 已作废(50),需原因。前置:issuedCount=0(从未发放/领取过,CAS 同时校验防并发领取);已有发放的请用“结束”。前端建议:issuedCount>0 时隐藏作废按钮

请求参数

字段类型必填说明
idLong必填活动 id
reasonString必填作废原因,非空且<=255 字

响应

字段类型说明
dataBooleantrue

可能的失败 msg

请求示例

json
{
  "id": 33,
  "reason": "投放对象选错"
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

POST/peasantCoupon/activity/logList活动操作日志

分页查询某活动的全部操作日志(bizType=2),id 倒序

请求参数

字段类型必填说明
idLong必填活动 id
indexInteger可选页码,默认 1
sizeInteger可选页大小,默认 10
searchCountBoolean可选是否查总数,默认 true

响应

字段类型说明
index/size/searchCount/total/other分页信息同 pageEnvelope
recordsArray日志列表,字段见 commonModels.XmPeasantCouponOpLog

可能的失败 msg

请求示例

json
{
  "id": 31,
  "index": 1,
  "size": 20
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "index": 1,
    "size": 20,
    "searchCount": true,
    "total": 2,
    "records": [
      {
        "id": 102,
        "bizType": 2,
        "bizId": 31,
        "action": 3,
        "beforeStatus": 10,
        "afterStatus": 20,
        "content": "立即开始",
        "reason": "",
        "orderId": null,
        "operatorType": 1,
        "operatorId": 3,
        "operatorName": "沈浩",
        "createTime": "2026-09-18 12:00:00"
      },
      {
        "id": 101,
        "bizType": 2,
        "bizId": 31,
        "action": 1,
        "beforeStatus": 0,
        "afterStatus": 10,
        "content": "创建活动",
        "reason": "",
        "orderId": null,
        "operatorType": 1,
        "operatorId": 3,
        "operatorName": "沈浩",
        "createTime": "2026-09-18 11:50:00"
      }
    ],
    "other": null
  }
}

运营后台 · 券包与核销明细

POST/peasantCoupon/instance/list券包列表

分页查询券实例(供应商券包),id 倒序。keyword:券码/券名称/供应商名模糊匹配,来源单号/订单号精确匹配;sourceType/status/templateId/activityId/supplierId 精确过滤。活动页“已发放 N 张”跳转时传 activityId,模板页跳转传 templateId。列表项 logs 为 null

请求参数

字段类型必填说明
indexInteger可选页码,默认 1
sizeInteger可选页大小,默认 10
searchCountBoolean可选是否查总数,默认 true
keywordString可选券码/券名称/供应商名(模糊)、来源单号/订单号(精确)
sourceTypeInteger可选获取方式 1-自主领取 2-定向发放 3-积分兑换
statusInteger可选券状态 10-可使用 20-已锁定 30-已使用 40-已过期 50-已作废
templateIdLong可选按模板过滤
activityIdLong可选按活动过滤
supplierIdLong可选按供应商过滤

响应

字段类型说明
index/size/searchCount/total/other分页信息同 pageEnvelope
recordsArray券实例列表
records.idLong券实例 id
records.couponCodeString券码
records.templateIdLong模板 id
records.templateNoString券编号
records.couponNameString券名称快照
records.useTypeInteger1-通用券 2-积分商城专用券
records.discountTypeInteger1-满减 2-无门槛
records.thresholdPriceString(BigDecimal)使用门槛
records.discountPriceString(BigDecimal)优惠金额
records.productScopeTypeInteger适用商品 0-全场 1-指定商品
records.supplierIdLong持有供应商 id
records.supplierNameString供应商名
records.baseNameString供应商所属基地名
records.sourceTypeInteger获取方式 1-自主领取 2-定向发放 3-积分兑换
records.activityIdLong来源活动 id,积分兑换为 null/0
records.sourceNoString来源单号(活动编号或积分兑换单号)
records.statusInteger10-可使用 20-已锁定 30-已使用 40-已过期 50-已作废
records.validStartString本券有效期开始
records.validEndString本券有效期结束
records.orderIdString当前锁定/核销订单号
records.lockTimeString锁定时间
records.useTimeString核销时间
records.voidReasonString作废原因
records.voidOperatorIdLong作废操作人 id
records.voidOperatorNameString作废操作人
records.voidTimeString作废时间
records.dataStatusInteger固定 0
records.createTimeString领取/发放时间
records.updateTimeString更新时间
records.ruleDescString优惠规则文案
records.validDescString有效期文案“2026.09.20 00:00 至 2026.10.20 23:59”
records.logsArray列表中为 null

请求示例

json
{
  "index": 1,
  "size": 10,
  "activityId": 31,
  "status": 30
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "index": 1,
    "size": 10,
    "searchCount": true,
    "total": 41,
    "records": [
      {
        "id": 5120,
        "couponCode": "NZ2609180000512",
        "templateId": 12,
        "templateNo": "NZQ20260918305127",
        "couponName": "秋种满100减20",
        "useType": 1,
        "discountType": 1,
        "thresholdPrice": "100.00",
        "discountPrice": "20.00",
        "productScopeType": 0,
        "supplierId": 2088,
        "supplierName": "云南丰花种植",
        "baseName": "斗南基地",
        "sourceType": 2,
        "activityId": 31,
        "sourceNo": "TFL20260918417702",
        "status": 30,
        "validStart": "2026-09-20 00:00:00",
        "validEnd": "2026-10-20 23:59:59",
        "orderId": "PO2609181532001",
        "lockTime": "2026-09-18 15:30:02",
        "useTime": "2026-09-18 15:32:10",
        "voidReason": null,
        "voidOperatorId": null,
        "voidOperatorName": null,
        "voidTime": null,
        "dataStatus": 0,
        "createTime": "2026-09-18 12:00:03",
        "updateTime": "2026-09-18 15:32:10",
        "ruleDesc": "满100减20",
        "validDesc": "2026.09.20 00:00 至 2026.10.20 23:59",
        "logs": null
      }
    ],
    "other": null
  }
}

POST/peasantCoupon/instance/detail券详情

单张券的全部字段 + 该券的全部业务历史 logs(bizType=3,不限条数,id 倒序),包括供应商端领取、下单锁定、核销、退款解锁、过期、运营作废等,operatorType 区分系统/平台/供应商,orderId 为相关订单号(supplier 侧写入的日志 action/content 以 supplier-core 为准,示例仅示意)

请求参数

字段类型必填说明
idLong必填券实例 id

响应

字段类型说明
(券实例字段)PeasantCouponInstanceDto与 /instance/list records 项相同
logsArray全部业务历史,字段见 commonModels.XmPeasantCouponOpLog

可能的失败 msg

请求示例

json
{
  "id": 5120
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "id": 5120,
    "couponCode": "NZ2609180000512",
    "couponName": "秋种满100减20",
    "supplierName": "云南丰花种植",
    "status": 30,
    "orderId": "PO2609181532001",
    "useTime": "2026-09-18 15:32:10",
    "ruleDesc": "满100减20",
    "validDesc": "2026.09.20 00:00 至 2026.10.20 23:59",
    "logs": [
      {
        "id": 3302,
        "bizType": 3,
        "bizId": 5120,
        "action": 0,
        "beforeStatus": 20,
        "afterStatus": 30,
        "content": "支付核销",
        "reason": "",
        "orderId": "PO2609181532001",
        "operatorType": 0,
        "operatorId": 0,
        "operatorName": "",
        "createTime": "2026-09-18 15:32:10"
      },
      {
        "id": 3290,
        "bizType": 3,
        "bizId": 5120,
        "action": 0,
        "beforeStatus": 10,
        "afterStatus": 20,
        "content": "下单锁定",
        "reason": "",
        "orderId": "PO2609181532001",
        "operatorType": 2,
        "operatorId": 2088,
        "operatorName": "云南丰花种植",
        "createTime": "2026-09-18 15:30:02"
      },
      {
        "id": 3001,
        "bizType": 3,
        "bizId": 5120,
        "action": 1,
        "beforeStatus": 0,
        "afterStatus": 10,
        "content": "定向发放",
        "reason": "",
        "orderId": null,
        "operatorType": 1,
        "operatorId": 3,
        "operatorName": "沈浩",
        "createTime": "2026-09-18 12:00:03"
      }
    ],
    "其余字段": "同列表项"
  }
}

POST/peasantCoupon/instance/void作废券

可使用(10) → 已作废(50),CAS 更新,需填写原因;记录作废人/时间/原因并写券日志(action=9,内容“人工作废”)。已锁定/已使用/已过期/已作废的券不可作废。前端建议只在 status=10 时显示作废按钮

请求参数

字段类型必填说明
idLong必填券实例 id
reasonString必填作废原因,非空且<=255 字

响应

字段类型说明
dataBooleantrue

可能的失败 msg

请求示例

json
{
  "id": 5236,
  "reason": "供应商账号异常,收回优惠券"
}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": true
}

POST/peasantCoupon/overview顶部概览

农资优惠券页面顶部指标卡,全局统计(不分时间段)。无请求体(可传 {})。口径:templateCount=未删除模板总数(含各状态);runningActivityCount=进行中(20)活动数;instanceCount=券实例总数;usedCount=已使用(30)券数;useRate=usedCount/instanceCount×100;couponCost=已支付未整单退款订单(order_status∈1,2,3)的 coupon_price 合计

请求参数

无

响应

字段类型说明
templateCountLong优惠券(模板)总数
runningActivityCountLong有效(进行中)活动数
instanceCountLong已进入券包的券总数
usedCountLong累计核销张数
useRateString(BigDecimal)核销率 %,两位小数
couponCostString(BigDecimal)平台优惠成本(元)

请求示例

json
{}

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "templateCount": 6,
    "runningActivityCount": 2,
    "instanceCount": 1320,
    "usedCount": 187,
    "useRate": "14.17",
    "couponCost": "3560.00"
  }
}