1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- 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 {
-
- 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;
- }
- }
|