diff --git a/app/common/dao/user/UserAssetsDao.php b/app/common/dao/user/UserAssetsDao.php new file mode 100644 index 0000000..e17ff31 --- /dev/null +++ b/app/common/dao/user/UserAssetsDao.php @@ -0,0 +1,39 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\dao\user; + + +use app\common\dao\BaseDao; +use app\common\model\BaseModel; +use app\common\model\user\UserSpreadLog; + +class UserAssetsDao extends BaseDao +{ + + protected function getModel(): string + { + return UserSpreadLog::class; + } + + public function add($uid, $spread_uid, $old_spread_uid, $admin_id = 0) + { + $this->create(compact('uid', 'spread_uid', 'admin_id', 'old_spread_uid')); + } + + public function search($where) + { + return UserSpreadLog::getDB()->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) { + $query->where('uid', $where['uid']); + })->order('create_time DESC'); + } +} diff --git a/app/common/dao/user/UserAssetsLogDao.php b/app/common/dao/user/UserAssetsLogDao.php new file mode 100644 index 0000000..1f0391a --- /dev/null +++ b/app/common/dao/user/UserAssetsLogDao.php @@ -0,0 +1,39 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\dao\user; + + +use app\common\dao\BaseDao; +use app\common\model\BaseModel; +use app\common\model\user\UserSpreadLog; + +class UserAssetsLogDao extends BaseDao +{ + + protected function getModel(): string + { + return UserSpreadLog::class; + } + + public function add($uid, $spread_uid, $old_spread_uid, $admin_id = 0) + { + $this->create(compact('uid', 'spread_uid', 'admin_id', 'old_spread_uid')); + } + + public function search($where) + { + return UserSpreadLog::getDB()->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) { + $query->where('uid', $where['uid']); + })->order('create_time DESC'); + } +} diff --git a/app/common/model/user/UserAssets.php b/app/common/model/user/UserAssets.php new file mode 100644 index 0000000..88736ce --- /dev/null +++ b/app/common/model/user/UserAssets.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\user; + + +use app\common\model\BaseModel; + +class UserAssets extends BaseModel +{ + + public static function tablePk(): ?string + { + return 'uid'; + } + + public static function tableName(): string + { + return 'user_assets'; + } + + public function user() + { + return $this->hasOne(User::class, 'uid', 'uid'); + } +} diff --git a/app/common/model/user/UserAssetsLog.php b/app/common/model/user/UserAssetsLog.php new file mode 100644 index 0000000..464b8b2 --- /dev/null +++ b/app/common/model/user/UserAssetsLog.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\user; + + +use app\common\model\BaseModel; + +class UserAssetsLog extends BaseModel +{ + + public static function tablePk(): ?string + { + return 'id'; + } + + public static function tableName(): string + { + return 'user_assets_log'; + } + + public function user() + { + return $this->hasOne(User::class, 'uid', 'uid'); + } +} diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 0e8cb82..8a5bf80 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -1121,7 +1121,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository 'give_integral' => $orderInfo['order_total_give_integral'], ]; event('order.create.before', compact('groupOrder', 'orderList')); - $group = Db::transaction(function () use ($ex, $user, $topUid, $spreadUid, $uid, $receipt_data, $cartIds, $allUseCoupon, $groupOrder, $orderList, $orderInfo) { + $group = Db::transaction(function () use ($ex, $user, $topUid, $spreadUid, $uid, $receipt_data, $cartIds, $allUseCoupon, $groupOrder, $orderList, $orderInfo, $address) { $storeGroupOrderRepository = app()->make(StoreGroupOrderRepository::class); $storeCartRepository = app()->make(StoreCartRepository::class); $attrValueRepository = app()->make(ProductAttrValueRepository::class); @@ -1214,6 +1214,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository $cartInfo = $order['cartInfo']; unset($order['cartInfo']); //创建子订单 + $order['district_id'] = $address['district_id'] ?? 0; $_order = $this->dao->create($order); if ($order['integral'] > 0) { diff --git a/app/common/repositories/user/UserAssetsLogRepository.php b/app/common/repositories/user/UserAssetsLogRepository.php new file mode 100644 index 0000000..bb6876c --- /dev/null +++ b/app/common/repositories/user/UserAssetsLogRepository.php @@ -0,0 +1,39 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\repositories\user; + + +use app\common\dao\user\UserSpreadLogDao; +use app\common\repositories\BaseRepository; + +/** + * @mixin UserSpreadLogDao + */ +class UserAssetsLogRepository extends BaseRepository +{ + public function __construct(UserSpreadLogDao $dao) + { + $this->dao = $dao; + } + + public function getList(array $where, $page, $limit) + { + $query = $this->dao->search($where); + $count = $query->count(); + $list = $query->page($page, $limit)->with(['spread' => function ($query) { + $query->field('uid,nickname,avatar'); + }])->select(); + + return compact('count', 'list'); + } +} diff --git a/app/common/repositories/user/UserAssetsRepository.php b/app/common/repositories/user/UserAssetsRepository.php new file mode 100644 index 0000000..a2a8b72 --- /dev/null +++ b/app/common/repositories/user/UserAssetsRepository.php @@ -0,0 +1,39 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\repositories\user; + + +use app\common\dao\user\UserSpreadLogDao; +use app\common\repositories\BaseRepository; + +/** + * @mixin UserSpreadLogDao + */ +class UserAssetsRepository extends BaseRepository +{ + public function __construct(UserSpreadLogDao $dao) + { + $this->dao = $dao; + } + + public function getList(array $where, $page, $limit) + { + $query = $this->dao->search($where); + $count = $query->count(); + $list = $query->page($page, $limit)->with(['spread' => function ($query) { + $query->field('uid,nickname,avatar'); + }])->select(); + + return compact('count', 'list'); + } +}