Browse Source

暂时关闭登录验证码,新增测试接口

Kirin 2 years ago
parent
commit
3aecdb9655

+ 88 - 84
app/controller/api/v1/PublicController.php

@@ -24,6 +24,7 @@ use app\services\system\attachment\SystemAttachmentServices;
 use app\services\system\config\SystemConfigServices;
 use app\services\store\SystemStoreServices;
 use app\services\store\SystemStoreStaffServices;
+use app\services\user\UserAwardIntegralServices;
 use app\services\user\UserBillServices;
 use app\services\user\UserInvoiceServices;
 use app\services\user\UserServices;
@@ -50,7 +51,7 @@ class PublicController extends BaseController
      */
     public function index(Request $request)
     {
-		$uid = $request->hasMacro('uid') ? (int)$request->uid() : 0;
+        $uid = $request->hasMacro('uid') ? (int)$request->uid() : 0;
         $banner = sys_data('routine_home_banner') ?: [];// 首页banner图
         $menus = sys_data('routine_home_menus') ?: [];// 首页按钮
         $roll = sys_data('routine_home_roll_news') ?: [];// 首页滚动新闻
@@ -92,7 +93,10 @@ class PublicController extends BaseController
         }
         $newGoodsBananr = sys_config('new_goods_bananr');
         $tengxun_map_key = sys_config('tengxun_map_key');
-        return app('json')->successful(compact('banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'site_name', 'subscribe', 'newGoodsBananr', 'tengxun_map_key', 'explosive_money'));
+        $award_integral_service = app()->make(UserAwardIntegralServices::class);
+        $award_lack = $award_integral_service->getLake();
+        $integral_price = $award_integral_service->getPrice();
+        return app('json')->successful(compact('award_lack', 'integral_price', 'banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'site_name', 'subscribe', 'newGoodsBananr', 'tengxun_map_key', 'explosive_money'));
     }
 
     /**
@@ -205,26 +209,26 @@ class PublicController extends BaseController
         $routine_contact_type = sys_config('routine_contact_type', 0);
         /** @var DiyServices $diyServices */
         $diyServices = app()->make(DiyServices::class);
-		$diy_data = $diyServices->cacheRemember('diy_data_member_3', function () use ($diyServices) {
-			$diy_data = $diyServices->get(['template_name' => 'member', 'type' => 3], ['value', 'status', 'order_status', 'my_banner_status', 'menu_status', 'service_status']);
-			$diy_data = $diy_data ? $diy_data->toArray() : [];
-			return $diy_data;
-		});
-		if ($diy_data) {
-			$diy_value = json_decode($diy_data['value'], true);
-			$new_value = [];
-			if (is_int($diy_value)) {
-				$new_value['status'] = $diy_value;
-				$new_value['vip_type'] = 1;
-				$new_value['newcomer_status'] = 1;
-				$new_value['newcomer_style'] = 1;
-			} else {
-				$new_value = $diy_value;
-			}
-			$diy_data = array_merge($diy_data, $new_value);
-			$diy_data['order_status'] = (int)$diy_data['order_status'];
-		}
-		unset($diy_data['value']);
+        $diy_data = $diyServices->cacheRemember('diy_data_member_3', function () use ($diyServices) {
+            $diy_data = $diyServices->get(['template_name' => 'member', 'type' => 3], ['value', 'status', 'order_status', 'my_banner_status', 'menu_status', 'service_status']);
+            $diy_data = $diy_data ? $diy_data->toArray() : [];
+            return $diy_data;
+        });
+        if ($diy_data) {
+            $diy_value = json_decode($diy_data['value'], true);
+            $new_value = [];
+            if (is_int($diy_value)) {
+                $new_value['status'] = $diy_value;
+                $new_value['vip_type'] = 1;
+                $new_value['newcomer_status'] = 1;
+                $new_value['newcomer_style'] = 1;
+            } else {
+                $new_value = $diy_value;
+            }
+            $diy_data = array_merge($diy_data, $new_value);
+            $diy_data['order_status'] = (int)$diy_data['order_status'];
+        }
+        unset($diy_data['value']);
         return app('json')->successful(['routine_my_menus' => array_merge($menusInfo), 'routine_my_banner' => $my_banner, 'routine_spread_banner' => $bannerInfo, 'routine_contact_type' => $routine_contact_type, 'diy_data' => $diy_data]);
     }
 
@@ -370,12 +374,12 @@ class PublicController extends BaseController
             ['image', ''],
             ['code', ''],
         ], true);
-		if ($imageUrl !== '' && !preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $imageUrl)) {
-			return app('json')->success(['code' => false, 'image' => false]);
-		}
-		if ($codeUrl !== '' && !(preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $codeUrl) || strpos($codeUrl, 'https://mp.weixin.qq.com/cgi-bin/showqrcode') !== false)) {
-			return app('json')->success(['code' => false, 'image' => false]);
-		}
+        if ($imageUrl !== '' && !preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $imageUrl)) {
+            return app('json')->success(['code' => false, 'image' => false]);
+        }
+        if ($codeUrl !== '' && !(preg_match('/.*(\.png|\.jpg|\.jpeg|\.gif)$/', $codeUrl) || strpos($codeUrl, 'https://mp.weixin.qq.com/cgi-bin/showqrcode') !== false)) {
+            return app('json')->success(['code' => false, 'image' => false]);
+        }
         try {
             $code = CacheService::get($codeUrl, function () use ($codeUrl) {
                 $codeTmp = $code = $codeUrl ? image_to_base64($codeUrl) : false;
@@ -418,14 +422,14 @@ class PublicController extends BaseController
             ['latitude', ''],
             ['longitude', ''],
             ['product_id', 0],
-			['type', 0],//商品类型 0:普通 1:秒杀
+            ['type', 0],//商品类型 0:普通 1:秒杀
             ['is_store', 1],    //前端传值为 1|商城配送 2|门店自提 3|门店配送
             ['store_id', 0],    //前端传值为 1|商城配送 2|门店自提 3|门店配送
         ], true);
         //判断是否门店自提
         $is_store == 2 ? $is_store = 1 : $is_store = '';
-		$where = ['type' => 0, 'is_store' => $is_store];
-		$field = ['id', 'name', 'phone', 'image', 'latitude', 'longitude', 'address', 'detailed_address', 'is_show', 'is_store', 'day_time', 'day_start', 'day_end', 'valid_range'];
+        $where = ['type' => 0, 'is_store' => $is_store];
+        $field = ['id', 'name', 'phone', 'image', 'latitude', 'longitude', 'address', 'detailed_address', 'is_show', 'is_store', 'day_time', 'day_start', 'day_end', 'valid_range'];
         $data['list'] = $services->getStoreList($where, $field, $latitude, $longitude, (int)$product_id, [], (int)$type, $store_id);
         $data['tengxun_map_key'] = sys_config('tengxun_map_key');
         return app('json')->successful($data);
@@ -449,13 +453,13 @@ class PublicController extends BaseController
      */
     public function pink(Request $request, StorePinkServices $pink, UserServices $user)
     {
-		[$type] = $request->getMore([
+        [$type] = $request->getMore([
             ['type', 1],
         ], true);
-		$where = ['is_refund' => 0];
-		if ($type == 1) {
-			$where['status'] = 2;
-		}
+        $where = ['is_refund' => 0];
+        if ($type == 1) {
+            $where['status'] = 2;
+        }
         $data['pink_count'] = $pink->getCount($where);
         $uids = array_flip($pink->getColumn($where, 'uid'));
         if (count($uids)) {
@@ -507,18 +511,18 @@ class PublicController extends BaseController
         return app('json')->successful($services->getDiyInfo((int)$id));
     }
 
-	/**
-	 * @param DiyServices $services
-	 * @param int $id
-	 * @return mixed
-	 * @author 等风来
-	 * @email 136327134@qq.com
-	 * @date 2022/11/9
-	 */
-	public function getDiyVersion(DiyServices $services, $id = 0)
-	{
-		return app('json')->successful(['version' => $services->getDiyVersion((int)$id)]);
-	}
+    /**
+     * @param DiyServices $services
+     * @param int $id
+     * @return mixed
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2022/11/9
+     */
+    public function getDiyVersion(DiyServices $services, $id = 0)
+    {
+        return app('json')->successful(['version' => $services->getDiyVersion((int)$id)]);
+    }
 
     /**
      * 获取底部导航
@@ -567,8 +571,8 @@ class PublicController extends BaseController
         /** @var CacheServices $cache */
         $cache = app()->make(CacheServices::class);
         $data = $cache->getDbCache('open_adv', '');
-		$data['time'] = (float)($data['time'] ?? 3);
-		$data['interval_time'] = (float)($data['interval_time'] ?? 24);
+        $data['time'] = (float)($data['time'] ?? 3);
+        $data['interval_time'] = (float)($data['interval_time'] ?? 24);
         return app('json')->success($data);
     }
 
@@ -595,49 +599,49 @@ class PublicController extends BaseController
             $copyright = $this->__z6uxyJQ4xYa5ee1mx5();
         } catch (\Throwable $e) {
             $copyright = [
-						'copyrightContext' => '',
-						'copyrightImage' => '',
-					];
+                'copyrightContext' => '',
+                'copyrightImage' => '',
+            ];
         }
-		$copyright['record_No'] = sys_config('record_No');
-		$copyright['version'] = get_crmeb_version();
-		$copyright['routine_contact_type'] = sys_config('routine_contact_type');
-		$copyright['store_user_agreement'] = (int)sys_config('store_user_agreement');
-		$copyright['routine_auth_type'] = sys_config('routine_auth_type', []);
-		$copyright['wechat_auth_switch'] = (int)in_array(1, $copyright['routine_auth_type']);//微信登录开关
-		$copyright['phone_auth_switch'] = (int)in_array(2, $copyright['routine_auth_type']);//手机号登录开关
-		$copyright['site_name'] = sys_config('site_name', '');
-		$copyright['site_logo'] = sys_config('wap_login_logo', '');
-		$copyright['wechat_status'] = sys_config('wechat_appid') && sys_config('wechat_appsecret');
+        $copyright['record_No'] = sys_config('record_No');
+        $copyright['version'] = get_crmeb_version();
+        $copyright['routine_contact_type'] = sys_config('routine_contact_type');
+        $copyright['store_user_agreement'] = (int)sys_config('store_user_agreement');
+        $copyright['routine_auth_type'] = sys_config('routine_auth_type', []);
+        $copyright['wechat_auth_switch'] = (int)in_array(1, $copyright['routine_auth_type']);//微信登录开关
+        $copyright['phone_auth_switch'] = (int)in_array(2, $copyright['routine_auth_type']);//手机号登录开关
+        $copyright['site_name'] = sys_config('site_name', '');
+        $copyright['site_logo'] = sys_config('wap_login_logo', '');
+        $copyright['wechat_status'] = sys_config('wechat_appid') && sys_config('wechat_appsecret');
         return $this->success($copyright);
     }
 
-	/**
- 	* 登录页面获取logo以及版本全新
-	* @return mixed
- 	*/
-	public function getLogo()
-	{
-		try {
+    /**
+     * 登录页面获取logo以及版本全新
+     * @return mixed
+     */
+    public function getLogo()
+    {
+        try {
             $copyright = $this->__z6uxyJQ4xYa5ee1mx5();
         } catch (\Throwable $e) {
             $copyright = [
-						'copyrightContext' => '',
-						'copyrightImage' => '',
-					];
+                'copyrightContext' => '',
+                'copyrightImage' => '',
+            ];
         }
-		$copyright['record_No'] = sys_config('record_No');
-		$copyright['version'] = get_crmeb_version();
-		$logo = sys_config('wap_login_logo');
+        $copyright['record_No'] = sys_config('record_No');
+        $copyright['version'] = get_crmeb_version();
+        $logo = sys_config('wap_login_logo');
         if (strstr($logo, 'http') === false && $logo) $logo = sys_config('site_url') . $logo;
-		$copyright['site_name'] = sys_config('site_name');
-		$copyright['logo_url'] = str_replace('\\', '/', $logo);
-		$copyright['store_user_agreement'] = (int)sys_config('store_user_agreement');
-		$copyright['routine_auth_type'] = sys_config('routine_auth_type', []);
-		$copyright['wechat_auth_switch'] = (int)in_array(1, $copyright['routine_auth_type']);//微信登录开关
-		$copyright['phone_auth_switch'] = (int)in_array(2, $copyright['routine_auth_type']);//手机号登录开关
-		$copyright['wechat_status'] = sys_config('wechat_appid') && sys_config('wechat_appsecret');
+        $copyright['site_name'] = sys_config('site_name');
+        $copyright['logo_url'] = str_replace('\\', '/', $logo);
+        $copyright['store_user_agreement'] = (int)sys_config('store_user_agreement');
+        $copyright['routine_auth_type'] = sys_config('routine_auth_type', []);
+        $copyright['wechat_auth_switch'] = (int)in_array(1, $copyright['routine_auth_type']);//微信登录开关
+        $copyright['phone_auth_switch'] = (int)in_array(2, $copyright['routine_auth_type']);//手机号登录开关
+        $copyright['wechat_status'] = sys_config('wechat_appid') && sys_config('wechat_appsecret');
         return app('json')->successful($copyright);
 
-	}
+    }
 }

+ 53 - 0
app/dao/system/AwardLakeDao.php

@@ -0,0 +1,53 @@
+<?php
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\dao\system;
+
+use app\dao\BaseDao;
+use app\model\system\AwardLake;
+
+/**
+ *
+ * Class UserRechargeDao
+ * @package app\dao\user
+ */
+class AwardLakeDao extends BaseDao
+{
+
+    /**
+     * 设置模型
+     * @return string
+     */
+    protected function setModel(): string
+    {
+        return AwardLake::class;
+    }
+
+    /**
+     * 获取奖池记录
+     * @param array $where
+     * @param string $filed
+     * @param int $page
+     * @param int $limit
+     * @param array $with
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getList(array $where, string $filed = "*", int $page = 0, int $limit = 0, array $with = [])
+    {
+        return $this->search($where)->field($filed)->with($with)->when($page && $limit, function ($query) use ($page, $limit) {
+            $query->page($page, $limit);
+        })->order('id desc')->select()->toArray();
+    }
+}

+ 56 - 0
app/dao/user/UserIntegralDao.php

@@ -0,0 +1,56 @@
+<?php
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\dao\user;
+
+use app\dao\BaseDao;
+use app\model\user\UserIntegral;
+
+/**
+ *
+ * Class UserRechargeDao
+ * @package app\dao\user
+ */
+class UserIntegralDao extends BaseDao
+{
+
+    /**
+     * 设置模型
+     * @return string
+     */
+    protected function setModel(): string
+    {
+        return UserIntegral::class;
+    }
+
+    /**
+     * 获取积分记录
+     * @param array $where
+     * @param string $filed
+     * @param int $page
+     * @param int $limit
+     * @param array $with
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getList(array $where, string $filed = "*", int $page = 0, int $limit = 0, array $with = [])
+    {
+        return $this->search($where)->field($filed)->with(array_merge([
+            'user' => function ($query) {
+                $query->field('uid,phone,nickname,avatar,delete_time');
+            }], $with))->when($page && $limit, function ($query) use ($page, $limit) {
+            $query->page($page, $limit);
+        })->order('id desc')->select()->toArray();
+    }
+}

+ 12 - 1
app/jobs/integral/IntegralJob.php

@@ -14,6 +14,17 @@ class IntegralJob extends BaseJobs
 {
     use QueueTrait;
 
+
+    public function dealOrderIntegral($order)
+    {
+        $integral_price =
+        $total_price = $order['total_price'];
+        $static_integral_ratio = sys_config('static_integral_ratio', 0);
+        $give_static_integral = bcdiv(bcmul($total_price, $static_integral_ratio), 100, 2);
+
+
+    }
+
     /**
      * 减积分
      * @param int $uid 用户
@@ -25,7 +36,7 @@ class IntegralJob extends BaseJobs
      */
     public function decIntegral(int $uid, float $static, float $action, float $cash, int $link_id = 0, string $mark = '')
     {
-        
+
     }
 
     /**

+ 57 - 0
app/model/system/AwardLake.php

@@ -0,0 +1,57 @@
+<?php
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+
+namespace app\model\system;
+
+use app\model\order\StoreOrder;
+use app\model\store\SystemStoreStaff;
+use crmeb\basic\BaseModel;
+use crmeb\traits\ModelTrait;
+use think\model;
+
+/**
+ * Class UserRecharge
+ * @package app\model\user
+ */
+class AwardLake extends BaseModel
+{
+    use ModelTrait;
+
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'award_lake';
+
+    protected $insert = ['add_time'];
+
+    protected function setAddTimeAttr()
+    {
+        return time();
+    }
+
+
+    /**
+     * 订单号
+     * @param Model $query
+     * @param $value
+     */
+    public function searchOrderIdAttr($query, $value)
+    {
+        $query->where('link_id', $value);
+    }
+}

+ 110 - 0
app/model/user/UserIntegral.php

@@ -0,0 +1,110 @@
+<?php
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+
+namespace app\model\user;
+
+use app\model\order\StoreOrder;
+use app\model\store\SystemStoreStaff;
+use crmeb\basic\BaseModel;
+use crmeb\traits\ModelTrait;
+use think\model;
+
+/**
+ * Class UserRecharge
+ * @package app\model\user
+ */
+class UserIntegral extends BaseModel
+{
+    use ModelTrait;
+
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'user_integral';
+
+    protected $insert = ['add_time'];
+
+    protected function setAddTimeAttr()
+    {
+        return time();
+    }
+
+    /**
+     * 关联user
+     * @return model\relation\HasOne
+     */
+    public function user()
+    {
+        return $this->hasOne(User::class, 'uid', 'uid', false)->bind([
+            'nickname' => 'nickname',
+            'avatar' => 'avatar',
+            'phone' => 'phone',
+            'now_money' => 'now_money',
+            'integral' => 'integral',
+            'delete_time' => 'delete_time'
+        ]);
+    }
+
+    public function user_order()
+    {
+        return $this->hasOne(StoreOrder::class, 'id', 'link_id');
+    }
+
+    /**
+     * 用户uid
+     * @param Model $query
+     * @param $value
+     */
+    public function searchUidAttr($query, $value)
+    {
+        if (is_array($value))
+            $query->whereIn('uid', $value);
+        else
+            $query->where('uid', $value);
+    }
+
+    /**
+     * 门店ID
+     * @param $query
+     * @param $value
+     */
+    public function searchStatusAttr($query, $value)
+    {
+        $query->where('status', $value);
+    }
+
+    /**
+     * 门店店员ID
+     * @param $query
+     * @param $value
+     */
+    public function searchTypeAttr($query, $value)
+    {
+        $query->where('type', $value);
+    }
+
+    /**
+     * 订单号
+     * @param Model $query
+     * @param $value
+     */
+    public function searchOrderIdAttr($query, $value)
+    {
+        $query->where('link_id', $value);
+    }
+}

+ 35 - 33
app/services/order/StoreOrderTakeServices.php

@@ -13,6 +13,7 @@ namespace app\services\order;
 
 
 use app\dao\order\StoreOrderDao;
+use app\jobs\integral\IntegralJob;
 use app\jobs\order\AutoTakeOrderJob;
 use app\jobs\notice\SmsAdminJob;
 use app\services\BaseServices;
@@ -44,37 +45,37 @@ class StoreOrderTakeServices extends BaseServices
         $this->dao = $dao;
     }
 
-	/**
-	 * 小程序订单服务收货
-	 * @param $order_id
-	 * @return bool
-	 * @throws \think\db\exception\DataNotFoundException
-	 * @throws \think\db\exception\DbException
-	 * @throws \think\db\exception\ModelNotFoundException
-	 */
-	public function miniOrderTakeOrder($order_id)
-	{
-		$orderArr = explode('_', $order_id);
-		if (count($orderArr) == 2) {
-			$order_id = $orderArr[1] ?? $order_id;
-		}
-		//查找订单信息
-		$order = $this->dao->getOne(['order_id' => $order_id]);
-		if (!$order) {
-			return true;
-		}
-		if ($order['pid'] == -1) {  // 有子订单
-			// 查找待收货的子订单
-			$son_order_list = $this->dao->getSubOrderNotSendList((int)$order['id']);
-			foreach ($son_order_list as $son_order) {
-				$this->takeOrder($son_order['order_id'], $son_order['uid']);
-			}
-		} else {
-			$this->takeOrder($order_id, $order['uid']);
-		}
+    /**
+     * 小程序订单服务收货
+     * @param $order_id
+     * @return bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function miniOrderTakeOrder($order_id)
+    {
+        $orderArr = explode('_', $order_id);
+        if (count($orderArr) == 2) {
+            $order_id = $orderArr[1] ?? $order_id;
+        }
+        //查找订单信息
+        $order = $this->dao->getOne(['order_id' => $order_id]);
+        if (!$order) {
+            return true;
+        }
+        if ($order['pid'] == -1) {  // 有子订单
+            // 查找待收货的子订单
+            $son_order_list = $this->dao->getSubOrderNotSendList((int)$order['id']);
+            foreach ($son_order_list as $son_order) {
+                $this->takeOrder($son_order['order_id'], $son_order['uid']);
+            }
+        } else {
+            $this->takeOrder($order_id, $order['uid']);
+        }
 
-		return true;
-	}
+        return true;
+    }
 
     /**
      * 用户订单收货
@@ -154,6 +155,7 @@ class StoreOrderTakeServices extends BaseServices
                 if (!($res1 && $res2 && $res3)) {
                     throw new ValidateException('收货失败!');
                 }
+                IntegralJob::dispatchDo('dealOrderIntegral', [$order]);
                 return true;
             }, $isTran);
         }
@@ -265,11 +267,11 @@ class StoreOrderTakeServices extends BaseServices
         $brokeragePrice = $orderInfo['one_brokerage'] ?? 0;
         // 一级返佣金额小于等于0
         if ($brokeragePrice <= 0) {//直接二级返佣
-			return $this->backOrderBrokerageTwo($orderInfo, $userInfo, $isSelfBrokerage, $frozen_time);
+            return $this->backOrderBrokerageTwo($orderInfo, $userInfo, $isSelfBrokerage, $frozen_time);
         }
         // 获取上级推广员信息
-		/** @var UserServices $userServices */
-		$userServices = app()->make(UserServices::class);
+        /** @var UserServices $userServices */
+        $userServices = app()->make(UserServices::class);
         $spreadPrice = $userServices->value(['uid' => $one_spread_uid], 'brokerage_price');
         // 上级推广员返佣之后的金额
         $balance = bcadd($spreadPrice, $brokeragePrice, 2);

+ 96 - 0
app/services/user/UserAwardIntegralServices.php

@@ -0,0 +1,96 @@
+<?php
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\services\user;
+
+use app\dao\system\AwardLakeDao;
+use app\dao\user\UserIntegralDao;
+use app\services\BaseServices;
+use crmeb\traits\ServicesTrait;
+use app\webscoket\SocketPush;
+use think\db\exception\DataNotFoundException;
+use think\db\exception\DbException;
+use think\db\exception\ModelNotFoundException;
+
+/**
+ *
+ * Class UserRechargeServices
+ * @package app\services\user
+ * @mixin UserIntegralDao
+ */
+class UserAwardIntegralServices extends BaseServices
+{
+
+    use ServicesTrait;
+
+    private $lake_dao;
+
+    /**
+     * UserRechargeServices constructor.
+     * @param UserIntegralDao $dao
+     */
+    public function __construct(UserIntegralDao $dao, AwardLakeDao $awardLakeDao)
+    {
+        $this->dao = $dao;
+        $this->lake_dao = $awardLakeDao;
+    }
+
+    /**
+     * 获取单条数据
+     * @param int $id
+     * @param array $field
+     */
+    public function getIntegral(int $id, array $field = [])
+    {
+        return $this->dao->get($id, $field);
+
+    }
+
+
+    /**
+     * 获取单条数据
+     * @return float
+     */
+    public function getIntegralSum($where)
+    {
+        return $this->dao->sum($where, 'num', true);
+    }
+
+    /**
+     * 获取单条数据
+     * @return float
+     */
+    public function getLake()
+    {
+        return $this->lake_dao->sum([], 'num');
+    }
+
+    /**
+     * 获取单条数据
+     * @param int $link_id
+     * @return string|null
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
+     */
+    public function getPrice(int $link_id = 0)
+    {
+        if ($link_id > 0) {
+            $info = $this->dao->getOne(['link_id' => $link_id]);
+            if ($info) return (string)($info['price'] ?: 0);
+        }
+        $lake_sum = $this->getLake();
+        $sum_integral = $this->getIntegralSum(['status' => 0]);
+        return bcdiv((string)$lake_sum, (string)$sum_integral, 8);
+    }
+
+}