TP5 Serialization of 'Closure' is not allowed

本文介绍了一个园区设施支付下单接口的实现细节,重点解决了优惠券对象序列化的问题,确保了订单创建流程的正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误:[ 2019-03-26T21:37:10+08:00 ]  POST zjhcom/api/consume/chain_order
[ error ] [0]Serialization of 'Closure' is not allowed[E:\wwwroot\zjh\application\common\core\BaseModel.php:762]

解决:优惠卷$envelope如果存在返回的是对象, 所以写入表中报错!

如果还有更加正规的答案希望大佬指教!

/**
 * 园区设施支付下单接口
 * @return void
 * @throws Exception
 */
public function facilities_order()
{
    $facilities_id = $this->get_param('facilities_id');

    $this->check_login();

    $facilities = FacilitiesModel::facilities_info($facilities_id);
    empty($facilities) AND output_error('设施已停用!');

    ConsumeModel::order_cancel_batch($this->member_id, ConsumeModel::TYPE_FACILITIES);

    $money    = $facilities['price'];
    $envelope = MemberEnvelopeModel::envelope_use_info($this->member_id, $money);

    try {
        Db::startTrans();
        if (!empty($envelope)) {
            MemberEnvelopeModel::envelope_use($envelope['envelope_id'], $this->member_id);
            $envelope = $envelope->toArray();
        }


        $order = ConsumeModel::facilities_order($this->member_id, $facilities_id, $money, $envelope, $facilities);
        empty($order) AND output_error('下单失败!');
        Db::commit();
    } catch (Exception $e) {
        Db::rollback();
        throw $e;
    }

    output_success('', $order);
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值