Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /** * The file was created by Assimon. * * @author assimon<[email protected]> * ..

Decoded Output download

<?php
/**
 * The file was created by Assimon.
 *
 * @author    assimon<[email protected]>
 * @copyright assimon<[email protected]>
 * @link      http://utf8.hk/
 */

namespace App\Service;


use App\Exceptions\RuleValidationException;
use App\Models\BaseModel;
use App\Models\Coupon;
use App\Models\Goods;
use App\Models\Carmis;
use App\Models\Order;
use App\Rules\SearchPwd;
use App\Rules\VerifyImg;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class OrderService
{

    /**
     * .
     * @var \App\Service\PayService
     */
    private $goodsService;


    /**
     * 
     * @var \App\Service\CouponService
     */
    private $couponService;

    public function __construct()
    {
        $this->goodsService = app('Service\GoodsService');
        $this->couponService = app('Service\CouponService');
    }


    /**
     * 
     *
     * @param Request $request
     * @throws RuleValidationException
     * @throws \Illuminate\Validation\ValidationException
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function validatorCreateOrder(Request $request): void
    {
        $validator = Validator::make($request->all(), [
            'gid' => 'required' ,
            'email' => ['required', 'email'],
            'payway' => ['required', 'integer'],
            'search_pwd' => [new SearchPwd()],
            'by_amount' => ['required', 'integer', 'min:1'],
            'img_verify_code' => [new VerifyImg()],
        ], [
            'by_amount.required' =>  __('dujiaoka.prompt.buy_amount_format_error'),
            'by_amount.integer' =>  __('dujiaoka.prompt.buy_amount_format_error'),
            'by_amount.min' =>  __('dujiaoka.prompt.buy_amount_format_error'),
            'payway.required' =>  __('dujiaoka.prompt.please_select_mode_of_payment'),
            'payway.integer' =>  __('dujiaoka.prompt.please_select_mode_of_payment'),
            'email.required' =>  __('dujiaoka.prompt.email_format_error'),
            'email.email' =>  __('dujiaoka.prompt.email_format_error'),
            'gid.required' =>  __('dujiaoka.prompt.goods_does_not_exist'),
        ]);
        if ($validator->fails()) {
            throw new RuleValidationException($validator->errors()->first());
        }
        // 
        if (
            dujiaoka_config_get('is_open_geetest') == BaseModel::STATUS_OPEN
            &&
            !Validator::make($request->all(),
                ['geetest_challenge' => 'geetest',],
                [ 'geetest' => __('dujiaoka.prompt.geetest_validate_fail')])

        ) {
            throw new RuleValidationException(__('dujiaoka.prompt.geetest_validate_fail'));
        }
    }

    /**
     * 
     *
     * @param Request $request 
     * @throws RuleValidationException
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function validatorGoods(Request $request): Goods
    {
        // 
        $goods = $this->goodsService->detail($request->input('gid'));
        // 
        $this->goodsService->validatorGoodsStatus($goods);
        // 
        if ($goods->buy_limit_num > 0 && $request->input('by_amount') > $goods->buy_limit_num) {
            throw new RuleValidationException(__('dujiaoka.prompt.purchase_limit_exceeded'));
        }
        // 
        if ($request->input('by_amount') > $goods->in_stock) {
            throw new RuleValidationException(__('dujiaoka.prompt.inventory_shortage'));
        }
        return $goods;
    }
	
    /**
     * 
     *
     * @param int $goodsID id
     * @return array|null
     *
     * @author    ZhangYiQiu<[email protected]>
     * @copyright ZhangYiQiu<[email protected]>
     * @link      http://zhangyiqiu.net/
     */
    public function validatorLoopCarmis(Request $request)
    {
        $carmis = Carmis::query()
            ->where('goods_id', $request->input('gid'))
            ->where('status', Carmis::STATUS_UNSOLD)
            ->where('is_loop', true)
            ->count();
        if($carmis > 0 && $request->input('by_amount') > 1){
			throw new RuleValidationException(__('dujiaoka.prompt.loop_carmis_limit'));
		}
		return $carmis;
    }

    /**
     * 
     *
     * @param Request $request
     * @return Coupon|null
     * @throws RuleValidationException
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function validatorCoupon(Request $request):? Coupon
    {
        // 
        if ($request->filled('coupon_code')) {
            // 
            $coupon = $this->couponService->withHasGoods($request->input('coupon_code'), $request->input('gid'));
            // 
            if (empty($coupon)) {
                throw new RuleValidationException(__('dujiaoka.prompt.coupon_does_not_exist'));
            }
            // 
            if ($coupon->ret <= 0) {
                throw new RuleValidationException(__('dujiaoka.prompt.coupon_lack_of_available_opportunities'));
            }
            return $coupon;
        }
        return null;
    }

    /**
     * .
     *
     * @param Goods $goods
     * @param Request $request
     * @return string
     * @throws RuleValidationException
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function validatorChargeInput(Goods $goods, Request $request): string
    {
        $otherIpt = '';
        // 
        if ($goods->type == Goods::MANUAL_PROCESSING && !empty($goods->other_ipu_cnf)) {
            //    
            $formatIpt = format_charge_input($goods->other_ipu_cnf);
            foreach ($formatIpt as $item) {
                if ($item['rule'] && !$request->filled($item['field'])) {
                    $errMessage = $item['desc'] . __('dujiaoka.prompt.can_not_be_empty');
                    throw new RuleValidationException($errMessage);
                }
                $otherIpt .= $item['desc'].':'.$request->input($item['field']) . PHP_EOL;
            }
        }
        return $otherIpt;
    }

    /**
     * 
     * @param string $orderSN
     * @return Order
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function detailOrderSN(string $orderSN):? Order
    {
        $order = Order::query()->with(['coupon', 'pay', 'goods'])->where('order_sn', $orderSN)->first();
        return $order;
    }

    /**
     * .
     *
     * @param string $orderSN
     * @return bool
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function expiredOrderSN(string $orderSN): bool
    {
        return Order::query()->where('order_sn', $orderSN)->update(['status' => Order::STATUS_EXPIRED]);
    }

    /**
     * 
     *
     * @param string $orderSN
     * @return bool
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function couponIsBack(string $orderSN): bool
    {
        return Order::query()->where('order_sn', $orderSN)->update(['coupon_ret_back' => Order::COUPON_BACK_OK]);
    }

    /**
     * 
     *
     * @param string $email 
     * @param string $searchPwd 
     * @return array|\Illuminate\Database\Concerns\BuildsQueries[]|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Query\Builder[]|\Illuminate\Support\Collection
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function withEmailAndPassword(string $email, string $searchPwd = '')
    {
        return Order::query()
            ->where('email', $email)
            ->when(!empty($searchPwd), function ($query) use ($searchPwd) {
                $query->where('search_pwd', $searchPwd);
            })
            ->orderBy('created_at', 'DESC')
            ->take(5)
            ->get();
    }

    /**
     * 
     *
     * @param array $orderSNS 
     * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Query\Builder[]|\Illuminate\Support\Collection
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function byOrderSNS(array $orderSNS)
    {
        return Order::query()
            ->whereIn('order_sn', $orderSNS)
            ->orderBy('created_at', 'DESC')
            ->take(5)
            ->get();
    }

}
 ?>

Did this file decode correctly?

Original Code

<?php
/**
 * The file was created by Assimon.
 *
 * @author    assimon<[email protected]>
 * @copyright assimon<[email protected]>
 * @link      http://utf8.hk/
 */

namespace App\Service;


use App\Exceptions\RuleValidationException;
use App\Models\BaseModel;
use App\Models\Coupon;
use App\Models\Goods;
use App\Models\Carmis;
use App\Models\Order;
use App\Rules\SearchPwd;
use App\Rules\VerifyImg;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class OrderService
{

    /**
     * .
     * @var \App\Service\PayService
     */
    private $goodsService;


    /**
     * 
     * @var \App\Service\CouponService
     */
    private $couponService;

    public function __construct()
    {
        $this->goodsService = app('Service\GoodsService');
        $this->couponService = app('Service\CouponService');
    }


    /**
     * 
     *
     * @param Request $request
     * @throws RuleValidationException
     * @throws \Illuminate\Validation\ValidationException
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function validatorCreateOrder(Request $request): void
    {
        $validator = Validator::make($request->all(), [
            'gid' => 'required' ,
            'email' => ['required', 'email'],
            'payway' => ['required', 'integer'],
            'search_pwd' => [new SearchPwd()],
            'by_amount' => ['required', 'integer', 'min:1'],
            'img_verify_code' => [new VerifyImg()],
        ], [
            'by_amount.required' =>  __('dujiaoka.prompt.buy_amount_format_error'),
            'by_amount.integer' =>  __('dujiaoka.prompt.buy_amount_format_error'),
            'by_amount.min' =>  __('dujiaoka.prompt.buy_amount_format_error'),
            'payway.required' =>  __('dujiaoka.prompt.please_select_mode_of_payment'),
            'payway.integer' =>  __('dujiaoka.prompt.please_select_mode_of_payment'),
            'email.required' =>  __('dujiaoka.prompt.email_format_error'),
            'email.email' =>  __('dujiaoka.prompt.email_format_error'),
            'gid.required' =>  __('dujiaoka.prompt.goods_does_not_exist'),
        ]);
        if ($validator->fails()) {
            throw new RuleValidationException($validator->errors()->first());
        }
        // 
        if (
            dujiaoka_config_get('is_open_geetest') == BaseModel::STATUS_OPEN
            &&
            !Validator::make($request->all(),
                ['geetest_challenge' => 'geetest',],
                [ 'geetest' => __('dujiaoka.prompt.geetest_validate_fail')])

        ) {
            throw new RuleValidationException(__('dujiaoka.prompt.geetest_validate_fail'));
        }
    }

    /**
     * 
     *
     * @param Request $request 
     * @throws RuleValidationException
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function validatorGoods(Request $request): Goods
    {
        // 
        $goods = $this->goodsService->detail($request->input('gid'));
        // 
        $this->goodsService->validatorGoodsStatus($goods);
        // 
        if ($goods->buy_limit_num > 0 && $request->input('by_amount') > $goods->buy_limit_num) {
            throw new RuleValidationException(__('dujiaoka.prompt.purchase_limit_exceeded'));
        }
        // 
        if ($request->input('by_amount') > $goods->in_stock) {
            throw new RuleValidationException(__('dujiaoka.prompt.inventory_shortage'));
        }
        return $goods;
    }
	
    /**
     * 
     *
     * @param int $goodsID id
     * @return array|null
     *
     * @author    ZhangYiQiu<[email protected]>
     * @copyright ZhangYiQiu<[email protected]>
     * @link      http://zhangyiqiu.net/
     */
    public function validatorLoopCarmis(Request $request)
    {
        $carmis = Carmis::query()
            ->where('goods_id', $request->input('gid'))
            ->where('status', Carmis::STATUS_UNSOLD)
            ->where('is_loop', true)
            ->count();
        if($carmis > 0 && $request->input('by_amount') > 1){
			throw new RuleValidationException(__('dujiaoka.prompt.loop_carmis_limit'));
		}
		return $carmis;
    }

    /**
     * 
     *
     * @param Request $request
     * @return Coupon|null
     * @throws RuleValidationException
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function validatorCoupon(Request $request):? Coupon
    {
        // 
        if ($request->filled('coupon_code')) {
            // 
            $coupon = $this->couponService->withHasGoods($request->input('coupon_code'), $request->input('gid'));
            // 
            if (empty($coupon)) {
                throw new RuleValidationException(__('dujiaoka.prompt.coupon_does_not_exist'));
            }
            // 
            if ($coupon->ret <= 0) {
                throw new RuleValidationException(__('dujiaoka.prompt.coupon_lack_of_available_opportunities'));
            }
            return $coupon;
        }
        return null;
    }

    /**
     * .
     *
     * @param Goods $goods
     * @param Request $request
     * @return string
     * @throws RuleValidationException
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function validatorChargeInput(Goods $goods, Request $request): string
    {
        $otherIpt = '';
        // 
        if ($goods->type == Goods::MANUAL_PROCESSING && !empty($goods->other_ipu_cnf)) {
            //    
            $formatIpt = format_charge_input($goods->other_ipu_cnf);
            foreach ($formatIpt as $item) {
                if ($item['rule'] && !$request->filled($item['field'])) {
                    $errMessage = $item['desc'] . __('dujiaoka.prompt.can_not_be_empty');
                    throw new RuleValidationException($errMessage);
                }
                $otherIpt .= $item['desc'].':'.$request->input($item['field']) . PHP_EOL;
            }
        }
        return $otherIpt;
    }

    /**
     * 
     * @param string $orderSN
     * @return Order
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function detailOrderSN(string $orderSN):? Order
    {
        $order = Order::query()->with(['coupon', 'pay', 'goods'])->where('order_sn', $orderSN)->first();
        return $order;
    }

    /**
     * .
     *
     * @param string $orderSN
     * @return bool
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function expiredOrderSN(string $orderSN): bool
    {
        return Order::query()->where('order_sn', $orderSN)->update(['status' => Order::STATUS_EXPIRED]);
    }

    /**
     * 
     *
     * @param string $orderSN
     * @return bool
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function couponIsBack(string $orderSN): bool
    {
        return Order::query()->where('order_sn', $orderSN)->update(['coupon_ret_back' => Order::COUPON_BACK_OK]);
    }

    /**
     * 
     *
     * @param string $email 
     * @param string $searchPwd 
     * @return array|\Illuminate\Database\Concerns\BuildsQueries[]|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Query\Builder[]|\Illuminate\Support\Collection
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function withEmailAndPassword(string $email, string $searchPwd = '')
    {
        return Order::query()
            ->where('email', $email)
            ->when(!empty($searchPwd), function ($query) use ($searchPwd) {
                $query->where('search_pwd', $searchPwd);
            })
            ->orderBy('created_at', 'DESC')
            ->take(5)
            ->get();
    }

    /**
     * 
     *
     * @param array $orderSNS 
     * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Query\Builder[]|\Illuminate\Support\Collection
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function byOrderSNS(array $orderSNS)
    {
        return Order::query()
            ->whereIn('order_sn', $orderSNS)
            ->orderBy('created_at', 'DESC')
            ->take(5)
            ->get();
    }

}

Function Calls

None

Variables

None

Stats

MD5 a7e170e0e833a37b8a023dd9547cd3c8
Eval Count 0
Decode Time 98 ms