| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <?php
- namespace addons\AvoidTax\common\service;
- use addons\AvoidTax\common\enums\StatusEnum;
- use addons\AvoidTax\common\models\TaxConfig;
- use addons\AvoidTax\common\models\TaxOrder;
- use addons\AvoidTax\common\models\TaxOrderLog;
- use common\models\user\UserWithdrawLog;
- /**
- * SokabeService class
- * @package addons\AvoidTax\common\service
- */
- class SokabeService extends BaseService
- {
- /**
- * 手续费未成功的列表
- *
- * @param array $params
- * @return array
- */
- public function getTaxList(array $params = [])
- {
- $page = $this->getPage($params);
- $limit = $this->getLimit($params);
- return TaxOrder::getPageList($page, $limit, function($model) use ($params) {
- // 手续费未成功
- $batch_nums = TaxOrder::find()->where([
- 'mall_id' => $this->mall_id,
- 'sub_type' => 1,
- 'status' => 5,
- ])->select('batch_num');
- // 但是用户打款成功
- $model->with(['withdraw'])->where(['batch_num' => $batch_nums, 'status' => 1]);
- });
- }
- /**
- * 重新提交
- *
- * @param integer $id
- * @return boolean
- */
- public function resub(int $id)
- {
- $order = TaxOrder::find()->where([
- 'mall_id' => $this->mall_id, 'id' => $id, 'sub_type' => TaxOrder::SUB_TYPE_TAX
- ])->one();
- if (empty($order)) {
- return $this->error('订单不存在');
- }
- $type = (new TaxConfigService(['mall_id' => $this->mall_id]))->getType();
- $service = new OrderService(['mall_id' => $this->mall_id]);
- // 自用版手续费打款
- if ($type == TaxConfig::PERSONAL) {
- if ($service->transToTaxByOrder($order) === false) {
- return $this->error($service->getError());
- }
- }
- // 服务商版手续费打款
- if ($type == TaxConfig::SERVICE) {
- if ($service->bookTransToTaxByOrder($order) === false) {
- return $this->error($service->getError());
- }
- }
- return true;
- }
- /**
- * 列表
- *
- * @param array $params
- * @return array
- */
- public function getOrderList(array $params = [])
- {
- $page = $this->getPage($params);
- $limit = $this->getLimit($params);
- return TaxOrder::getPageList($page, $limit, function($model) use ($params) {
- $model->andWhere(['mall_id' => $this->mall_id])
- // ->andWhere(['status' => [-1, 1]])
- ->andWhere(['sub_type' => 1]);
- });
- }
- /**
- * 失败提交
- *
- * @param integer $id
- * @return boolean
- */
- public function toFail(int $id)
- {
- $order = TaxOrder::find()->where([
- 'mall_id' => $this->mall_id, 'id' => $id
- // , 'status' => [1, -1]
- , 'sub_type' => 1
- ])->one();
- if (empty($order)) {
- return $this->error('订单不存在');
- }
- if ($this->getConfigService()->isLYApiType()) {
- // 发送订单成功通知
- if ($this->getLyService()->asyncTransferResultNotifyNo($order) === false) {
- return $this->error('支付时异步请求接口请求失败');
- }
- }
- return true;
- }
- public function toSuccess(int $id)
- {
- $order = TaxOrder::find()->where(['id' => $id, 'sub_type' => 1])->one();
- if ($this->getConfigService()->isLYApiType()) {
- // 发送订单成功通知
- if ($this->getLyService()->asyncTransferResultNotifyOk($order) === false) {
- return $this->error('支付时异步请求接口请求失败');
- }
- }
- return true;
- }
- /**
- * @param array $params
- * @return array
- */
- public function getList(array $params = [])
- {
- return TaxOrder::getPageList(1, 20, function($model) use ($params) {
- $model->andWhere(['mall_id' => $this->mall_id])
- ->andWhere(['status' => 1])
- ->andWhere(['sub_type' => 2]);
- if (isset($params['keyword'])) {
- $model->andWhere([
- 'or',
- ['like', 'order_sn', '%' . $params['keyword'] . '%'],
- ['like', 'batch_num', '%' . $params['keyword'] . '%']
- ]);
- }
- });
- }
- /**
- * @param integer $id
- * @return boolean
- */
- public function subSuccess(int $id)
- {
- $order = TaxOrder::find()->where([
- 'mall_id' => $this->mall_id, 'id' => $id, 'sub_type' => 2, 'status' => 1
- ])->one();
- if (empty($order)) return $this->error('订单不存在');
- /**
- * @var OrderService
- */
- $service = new OrderService(['mall_id' => $this->mall_id]);
- $service->setUserOrder($order->userLog);
- $service->setSignUser($order->userLog->withdraw2);
- $service->setFeeOrder($order);
- if ($service->orderSuccess($order) === false) return $this->error($service->getError());
- $order->status = StatusEnum::STATUS_OUT_OK;
- $order->save();
- return true;
- }
- /**
- * @param integer $id
- * @return boolean
- */
- public function subFial(int $id)
- {
- $order = TaxOrder::find()->where([
- 'mall_id' => $this->mall_id, 'id' => $id, 'sub_type' => 2, 'status' => 1
- ])->one();
- if (empty($order)) return $this->error('订单不存在');
- return $this->error('未完善');
- return true;
- }
- }
|