mirror of
				https://gitee.com/zoujingli/ThinkAdmin.git
				synced 2025-11-04 05:32:09 +08:00 
			
		
		
		
	方法静态化
This commit is contained in:
		
							parent
							
								
									4db65f5203
								
							
						
					
					
						commit
						c7d2eb27a8
					
				@ -26,7 +26,7 @@ class ExpressService extends Service
 | 
			
		||||
     * @throws \think\db\exception\DbException
 | 
			
		||||
     * @throws \think\db\exception\ModelNotFoundException
 | 
			
		||||
     */
 | 
			
		||||
    public function amount(array $codes, string $provName, string $cityName, int $truckCount = 0): array
 | 
			
		||||
    public static function amount(array $codes, string $provName, string $cityName, int $truckCount = 0): array
 | 
			
		||||
    {
 | 
			
		||||
        if (empty($codes)) return [0, $truckCount, '', '邮费模板编码为空!'];
 | 
			
		||||
        $map = [['status', '=', 1], ['deleted', '=', 0], ['code', 'in', $codes]];
 | 
			
		||||
@ -56,7 +56,7 @@ class ExpressService extends Service
 | 
			
		||||
     * 获取快递模板数据
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public function templates(): array
 | 
			
		||||
    public static function templates(): array
 | 
			
		||||
    {
 | 
			
		||||
        $query = BasePostageTemplate::mk()->where(['status' => 1, 'deleted' => 0]);
 | 
			
		||||
        return $query->order('sort desc,id desc')->column('code,name,normal,content', 'code');
 | 
			
		||||
@ -68,7 +68,7 @@ class ExpressService extends Service
 | 
			
		||||
     * @param null|integer $status 状态筛选
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public function region(int $level = 3, ?int $status = null): array
 | 
			
		||||
    public static function region(int $level = 3, ?int $status = null): array
 | 
			
		||||
    {
 | 
			
		||||
        $query = BasePostageRegion::mk();
 | 
			
		||||
        if (is_numeric($level)) $query->where('level', '<=', $level);
 | 
			
		||||
@ -91,9 +91,9 @@ class ExpressService extends Service
 | 
			
		||||
     * @return array
 | 
			
		||||
     * @throws \think\admin\Exception
 | 
			
		||||
     */
 | 
			
		||||
    public function query(string $code, string $number): array
 | 
			
		||||
    public static function query(string $code, string $number): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->_getInterface()->doRequest('api.auth.express/query', [
 | 
			
		||||
        return static::getInterface()->doRequest('api.auth.express/query', [
 | 
			
		||||
            'type' => 'free', 'express' => $code, 'number' => $number,
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
@ -103,16 +103,16 @@ class ExpressService extends Service
 | 
			
		||||
     * @return array
 | 
			
		||||
     * @throws \think\admin\Exception
 | 
			
		||||
     */
 | 
			
		||||
    public function company(): array
 | 
			
		||||
    public static function company(): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->_getInterface()->doRequest('api.auth.express/getCompany');
 | 
			
		||||
        return static::getInterface()->doRequest('api.auth.express/getCompany');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取楚才开放平台接口实例
 | 
			
		||||
     * @return InterfaceService
 | 
			
		||||
     */
 | 
			
		||||
    private function _getInterface(): InterfaceService
 | 
			
		||||
    private static function getInterface(): InterfaceService
 | 
			
		||||
    {
 | 
			
		||||
        $service = InterfaceService::instance();
 | 
			
		||||
        // 测试的账号及密钥随时可能会变更,请联系客服更新
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,7 @@ class GoodsService extends Service
 | 
			
		||||
     * @throws \think\db\exception\DbException
 | 
			
		||||
     * @throws \think\db\exception\ModelNotFoundException
 | 
			
		||||
     */
 | 
			
		||||
    public function stock(string $code): bool
 | 
			
		||||
    public static function stock(string $code): bool
 | 
			
		||||
    {
 | 
			
		||||
        // 商品入库统计
 | 
			
		||||
        $query = ShopGoodsStock::mk()->field('goods_code,goods_spec,ifnull(sum(goods_stock),0) stock_total');
 | 
			
		||||
@ -67,7 +67,7 @@ class GoodsService extends Service
 | 
			
		||||
     * @throws \think\db\exception\DbException
 | 
			
		||||
     * @throws \think\db\exception\ModelNotFoundException
 | 
			
		||||
     */
 | 
			
		||||
    public function bindData(array &$data = [], bool $simple = true): array
 | 
			
		||||
    public static function bindData(array &$data = [], bool $simple = true): array
 | 
			
		||||
    {
 | 
			
		||||
        $marks = ShopGoodsMark::items();
 | 
			
		||||
        $cates = ShopGoodsCate::treeTable();
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ class OrderService extends Service
 | 
			
		||||
     * 获取随机减免金额
 | 
			
		||||
     * @return float
 | 
			
		||||
     */
 | 
			
		||||
    public function getReduct(): float
 | 
			
		||||
    public static function getReduct(): float
 | 
			
		||||
    {
 | 
			
		||||
        return rand(1, 100) / 100;
 | 
			
		||||
    }
 | 
			
		||||
@ -33,7 +33,7 @@ class OrderService extends Service
 | 
			
		||||
     * @throws \think\db\exception\DbException
 | 
			
		||||
     * @throws \think\db\exception\ModelNotFoundException
 | 
			
		||||
     */
 | 
			
		||||
    public function stock(string $orderNo): bool
 | 
			
		||||
    public static function stock(string $orderNo): bool
 | 
			
		||||
    {
 | 
			
		||||
        $map = ['order_no' => $orderNo];
 | 
			
		||||
        $codes = ShopOrderItem::mk()->where($map)->column('goods_code');
 | 
			
		||||
@ -49,7 +49,7 @@ class OrderService extends Service
 | 
			
		||||
     * @throws \think\db\exception\DbException
 | 
			
		||||
     * @throws \think\db\exception\ModelNotFoundException
 | 
			
		||||
     */
 | 
			
		||||
    public function upgrade(string $orderNo): ?array
 | 
			
		||||
    public static function upgrade(string $orderNo): ?array
 | 
			
		||||
    {
 | 
			
		||||
        // 目标订单数据
 | 
			
		||||
        $map = [['order_no', '=', $orderNo], ['status', '>=', 4]];
 | 
			
		||||
@ -59,7 +59,7 @@ class OrderService extends Service
 | 
			
		||||
        $user = DataUser::mk()->where(['id' => $order['uuid']])->find();
 | 
			
		||||
        if (empty($user)) return null;
 | 
			
		||||
        // 更新用户购买资格
 | 
			
		||||
        $entry = $this->vipEntry($order['uuid']);
 | 
			
		||||
        $entry = static::vipEntry($order['uuid']);
 | 
			
		||||
        // 尝试绑定代理用户
 | 
			
		||||
        if (empty($user['pids']) && ($order['puid1'] > 0 || $user['pid1'] > 0)) {
 | 
			
		||||
            $puid1 = $order['puid1'] > 0 ? $order['puid1'] : $user['pid0'];
 | 
			
		||||
@ -82,7 +82,7 @@ class OrderService extends Service
 | 
			
		||||
     * @param integer $uuid 用户UID
 | 
			
		||||
     * @return integer
 | 
			
		||||
     */
 | 
			
		||||
    private function vipEntry(int $uuid): int
 | 
			
		||||
    private static function vipEntry(int $uuid): int
 | 
			
		||||
    {
 | 
			
		||||
        // 检查是否购买入会礼包
 | 
			
		||||
        $query = ShopOrder::mk()->alias('a')->join('shop_order_item b', 'a.order_no=b.order_no');
 | 
			
		||||
@ -102,7 +102,7 @@ class OrderService extends Service
 | 
			
		||||
     * @param float $disRate 默认比例
 | 
			
		||||
     * @return array [方案编号, 折扣比例]
 | 
			
		||||
     */
 | 
			
		||||
    public function discount(int $disId, int $vipCode, float $disRate = 100.00): array
 | 
			
		||||
    public static function discount(int $disId, int $vipCode, float $disRate = 100.00): array
 | 
			
		||||
    {
 | 
			
		||||
        if ($disId > 0) {
 | 
			
		||||
            $map = ['id' => $disId, 'status' => 1, 'deleted' => 0];
 | 
			
		||||
@ -124,7 +124,7 @@ class OrderService extends Service
 | 
			
		||||
     * @throws \think\db\exception\DbException
 | 
			
		||||
     * @throws \think\db\exception\ModelNotFoundException
 | 
			
		||||
     */
 | 
			
		||||
    public function buildData(array &$data = [], bool $from = true): array
 | 
			
		||||
    public static function buildData(array &$data = [], bool $from = true): array
 | 
			
		||||
    {
 | 
			
		||||
        if (empty($data)) return $data;
 | 
			
		||||
        // 关联发货信息
 | 
			
		||||
 | 
			
		||||
@ -100,7 +100,7 @@ class UserAdminService extends Service
 | 
			
		||||
     * @param int $uuid 用户UID
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public function total(int $uuid): array
 | 
			
		||||
    public static function total(int $uuid): array
 | 
			
		||||
    {
 | 
			
		||||
        return ['my_invite' => DataUser::mk()->where(['pid1' => $uuid])->count()];
 | 
			
		||||
    }
 | 
			
		||||
@ -131,7 +131,7 @@ class UserAdminService extends Service
 | 
			
		||||
     * @param string $cols 返回用户字段
 | 
			
		||||
     * @return array
 | 
			
		||||
     */
 | 
			
		||||
    public function buildByUid(array &$list, string $keys = 'uuid', string $bind = 'user', string $cols = '*'): array
 | 
			
		||||
    public static function buildByUid(array &$list, string $keys = 'uuid', string $bind = 'user', string $cols = '*'): array
 | 
			
		||||
    {
 | 
			
		||||
        if (count($list) < 1) return $list;
 | 
			
		||||
        $uids = array_unique(array_column($list, $keys));
 | 
			
		||||
 | 
			
		||||
@ -30,7 +30,7 @@ class UserBalanceService extends Service
 | 
			
		||||
        $order = ShopOrder::mk()->where([['status', '>=', 4], ['order_no', '=', $orderNo]])->find();
 | 
			
		||||
        if (empty($order)) throw new Exception('需处理的订单状态异常');
 | 
			
		||||
 | 
			
		||||
        if ($order['reward_balance'] > 0) data_save(DataUserBalance::class, [
 | 
			
		||||
        if ($order['reward_balance'] > 0) DataUserBalance::mUpdate([
 | 
			
		||||
            'uuid'   => $order['uuid'],
 | 
			
		||||
            'code'   => "CZ{$order['order_no']}",
 | 
			
		||||
            'name'   => "订单余额充值",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user