|
|
|
@ -17,6 +17,7 @@ use app\common\dao\user\UserAssetsDao; |
|
|
|
|
use app\common\repositories\BaseRepository; |
|
|
|
|
use app\common\repositories\store\order\StoreOrderBaseRepository; |
|
|
|
|
use app\common\repositories\system\groupData\GroupDataRepository; |
|
|
|
|
use app\common\repositories\system\HuitongRepository; |
|
|
|
|
use think\db\exception\DataNotFoundException; |
|
|
|
|
use think\db\exception\DbException; |
|
|
|
|
use think\db\exception\ModelNotFoundException; |
|
|
|
@ -76,7 +77,7 @@ class UserAssetsRepository extends BaseRepository |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* notes 用户资产变更 |
|
|
|
|
* notes 订单事件同步更新用户资产 |
|
|
|
|
* @param $uid |
|
|
|
|
* @param $status |
|
|
|
|
* @param $data |
|
|
|
@ -88,7 +89,7 @@ class UserAssetsRepository extends BaseRepository |
|
|
|
|
* @author zhangkxiang |
|
|
|
|
* @editor |
|
|
|
|
*/ |
|
|
|
|
public function changeEvent($uid, $status, $data = array()) |
|
|
|
|
public function orderEvent($uid, $status, $data = array()) |
|
|
|
|
{ |
|
|
|
|
$assets = array(); |
|
|
|
|
$info = $this->dao->get($uid); |
|
|
|
@ -145,7 +146,7 @@ class UserAssetsRepository extends BaseRepository |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* notes 分红福利积分 |
|
|
|
|
* notes 分红福利积分定时任务 |
|
|
|
|
* @throws DataNotFoundException |
|
|
|
|
* @throws DbException |
|
|
|
|
* @throws ModelNotFoundException |
|
|
|
@ -154,7 +155,7 @@ class UserAssetsRepository extends BaseRepository |
|
|
|
|
* @author zhangkxiang |
|
|
|
|
* @editor |
|
|
|
|
*/ |
|
|
|
|
public function sharePoint() |
|
|
|
|
public function sharePointTask() |
|
|
|
|
{ |
|
|
|
|
$config = $this->getConfig(); |
|
|
|
|
/** |
|
|
|
@ -189,8 +190,8 @@ class UserAssetsRepository extends BaseRepository |
|
|
|
|
'count' => $welfare, |
|
|
|
|
); |
|
|
|
|
// 增加福利积分 |
|
|
|
|
$this->changeEvent($item['uid'], UserAssetsLogRepository::STATUS_SUCCESS, array('welfare' => $welfare)); |
|
|
|
|
|
|
|
|
|
$assets = $this->assets($item['uid']); |
|
|
|
|
$this->update($item['uid'], array('welfare' => $assets['welfare'] + $welfare)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 增加记录 |
|
|
|
@ -235,11 +236,23 @@ class UserAssetsRepository extends BaseRepository |
|
|
|
|
'count' => $count, |
|
|
|
|
); |
|
|
|
|
app()->make(UserAssetsLogRepository::class)->addLog($logList); |
|
|
|
|
$this->changeEvent($uid, UserAssetsLogRepository::STATUS_SUCCESS, array('consume' => $consume)); |
|
|
|
|
$this->dao->update($uid, array('share_point' => $assets['share_point'] + $count, 'share_point_time' => time())); |
|
|
|
|
$this->dao->update($uid, array('consume' => $assets['consume'] + $consume, 'share_point' => $assets['share_point'] + $count, 'share_point_time' => time())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* notes 惠通宝转账 |
|
|
|
|
* @param $uid |
|
|
|
|
* @param $phone |
|
|
|
|
* @param $count |
|
|
|
|
* @throws DataNotFoundException |
|
|
|
|
* @throws DbException |
|
|
|
|
* @throws ModelNotFoundException |
|
|
|
|
* @create 2024/3/20 11:01 |
|
|
|
|
* @update 2024/3/20 11:01 |
|
|
|
|
* @author zhangkxiang |
|
|
|
|
* @editor |
|
|
|
|
*/ |
|
|
|
|
public function sendHuitong($uid, $phone, $count){ |
|
|
|
|
$assets = $this->assets($uid); |
|
|
|
|
if($assets['huitong'] < $count){ |
|
|
|
@ -269,8 +282,73 @@ class UserAssetsRepository extends BaseRepository |
|
|
|
|
'count' => -1 * $count, |
|
|
|
|
); |
|
|
|
|
app()->make(UserAssetsLogRepository::class)->addLog($logList); |
|
|
|
|
$this->changeEvent($uid, UserAssetsLogRepository::STATUS_SUCCESS, array('huitong' => -1 * $count)); |
|
|
|
|
$this->dao->update($toUser['uid'], array('huitong' => $assets['huitong'] - $count)); |
|
|
|
|
$toAssets = $this->assets($toUser['uid']); |
|
|
|
|
$this->dao->update($toUser['uid'], array('huitong' => $toAssets['huitong'] + $count)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* notes |
|
|
|
|
* @param $uid |
|
|
|
|
* @param $count |
|
|
|
|
* @throws DataNotFoundException |
|
|
|
|
* @throws DbException |
|
|
|
|
* @throws ModelNotFoundException |
|
|
|
|
* @create 2024/3/19 22:33 |
|
|
|
|
* @update 2024/3/19 22:33 |
|
|
|
|
* @author zhangkxiang |
|
|
|
|
* @editor |
|
|
|
|
*/ |
|
|
|
|
public function huitongToConsume($uid, $count){ |
|
|
|
|
$current = app(HuitongRepository::class)->getCurrent(); |
|
|
|
|
$assets = $this->assets($uid); |
|
|
|
|
if($assets['huitong'] < $count){ |
|
|
|
|
throw new \Exception('惠通宝不足'); |
|
|
|
|
} |
|
|
|
|
$logList = array(); |
|
|
|
|
$consume = $current * $count; |
|
|
|
|
$logList[] = array( |
|
|
|
|
'uid' => $uid, |
|
|
|
|
'asset_type' => UserAssetsLogRepository::ASSET_TYPE_CONSUME, |
|
|
|
|
'type' => UserAssetsLogRepository::CHANGE_TYPE_HUITONG, |
|
|
|
|
'status' => UserAssetsLogRepository::STATUS_SUCCESS, |
|
|
|
|
'count' => $consume, |
|
|
|
|
); |
|
|
|
|
$huitong = -1 * $count; |
|
|
|
|
$logList[] = array( |
|
|
|
|
'uid' => $uid, |
|
|
|
|
'asset_type' => UserAssetsLogRepository::ASSET_TYPE_HUITONG, |
|
|
|
|
'type' => UserAssetsLogRepository::CHANGE_TYPE_HUITONG, |
|
|
|
|
'status' => UserAssetsLogRepository::STATUS_SUCCESS, |
|
|
|
|
'count' => $huitong, |
|
|
|
|
); |
|
|
|
|
app()->make(UserAssetsLogRepository::class)->addLog($logList); |
|
|
|
|
$this->dao->update($uid, array('consume' => $assets['consume'] + $consume, 'huitong' => $assets['huitong'] + $huitong)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* notes |
|
|
|
|
* @param $uid |
|
|
|
|
* @param $consume |
|
|
|
|
* @create 2024/3/20 16:36 |
|
|
|
|
* @update 2024/3/20 16:36 |
|
|
|
|
* @author zhangkxiang |
|
|
|
|
* @editor |
|
|
|
|
*/ |
|
|
|
|
public function sign($uid, $consume){ |
|
|
|
|
$logList = array(); |
|
|
|
|
$logList[] = array( |
|
|
|
|
'uid' => $uid, |
|
|
|
|
'asset_type' => UserAssetsLogRepository::ASSET_TYPE_CONSUME, |
|
|
|
|
'type' => UserAssetsLogRepository::CHANGE_TYPE_SIGN, |
|
|
|
|
'status' => UserAssetsLogRepository::STATUS_SUCCESS, |
|
|
|
|
'count' => $consume, |
|
|
|
|
); |
|
|
|
|
app()->make(UserAssetsLogRepository::class)->addLog($logList); |
|
|
|
|
$assets = $this->assets($uid); |
|
|
|
|
$this->dao->update($uid, array('consume' => $assets['consume'] + $consume)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|