| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 | <?php/** * AgentOrder.php UTF-8 * 渠道收益订单 * * @date    : 2018/5/18 14:12 * * @license 这不是一个自由软件,未经授权不许任何使用和传播。 * @author  : wuyonghong <wyh@huosdk.com> * @version : HUOSDK 8.0 */namespace huo\controller\agent;use huo\controller\common\Base;use huo\controller\finance\AoRequest;use huo\model\agent\AgentOrderModel;use huolib\constant\CommonConst;use huolib\constant\SettleConst;use huolib\status\SettleStatus;use huolib\tool\StrUtils;use think\Log;class AgentOrder extends Base {    /**     * 创建渠道收益订单     *     * @param AoRequest $aor     *     * @return int     */    public function createAoOrder(AoRequest $aor) {        /* 查询次订单是否获取过收益 */        $_ao_model = new AgentOrderModel();        $_ao_info = $_ao_model->getInfoByOrderId($aor->getOrderId());        if (!empty($_ao_info)) {            $_code = SettleStatus::ORDER_HAS_SHARE;            Log::write(                "func=".__FUNCTION__."&class=".__CLASS__."&code=".$_code.'&msg='.SettleStatus::getMsg($_code)."&order="                .http_build_query($aor->toArray()),                LOG::ERROR            );            return $_code;        }        $_aw_class = new AgentWallet();        if (!empty($aor->getAgentId())            && StrUtils::compareNumber($aor->getAgentGain(), CommonConst::CONST_ZERO_COMPARE) > 0) {            /* 添加余额 */            $_rs = $_aw_class->updateWallet($aor->getAgentId(), $aor->getAgentGain(), SettleConst::SETTLE_WALLET_ADD);            if (SettleStatus::NO_ERROR != $_rs) {                return $_rs;            }        }        if (!empty($aor->getParentId())            && StrUtils::compareNumber(                $aor->getParentGain(), CommonConst::CONST_ZERO_COMPARE            ) > 0) {            /* 添加余额 */            $_rs = $_aw_class->updateWallet($aor->getParentId(), $aor->getParentGain(), SettleConst::SETTLE_WALLET_ADD);            if (SettleStatus::NO_ERROR != $_rs) {                return $_rs;            }        }        /* 插入渠道消费订单 */        $_ao_data = $aor->toArray();        $_rs = (new AgentOrderModel())->createOrder($_ao_data);        if (false == $_rs) {            return SettleStatus::ORDER_CREATE_FAIL;        }        return SettleStatus::NO_ERROR;    }}
 |