feat: order
This commit is contained in:
@@ -16,6 +16,7 @@ use App\Cache\Redis\Api\SiteCache;
|
||||
use App\Cache\Redis\RedisCache;
|
||||
use App\Constants\ApiCode;
|
||||
use App\Constants\Common\GoodCode;
|
||||
use App\Constants\Common\OrderCode;
|
||||
use App\Constants\ConfigCode;
|
||||
use App\Exception\ErrException;
|
||||
use Hyperf\Amqp\Producer;
|
||||
@@ -38,6 +39,20 @@ trait OrderTrait
|
||||
#[Inject]
|
||||
protected RedisCache $redis;
|
||||
|
||||
/**
|
||||
* 生成订单号
|
||||
* @param int $type
|
||||
* @param int $userId
|
||||
* @return string
|
||||
*/
|
||||
protected function generateOrderNo(int $type,int $userId): string
|
||||
{
|
||||
return match ($type) {
|
||||
OrderCode::ORDER_TYPE_GOOD => OrderCode::ORDER_TYPE_GOOD_PREFIX . '_' .date("YmdHis") . $userId . mt_rand(10000000, 99999999),
|
||||
OrderCode::ORDER_TYPE_BALANCE => OrderCode::ORDER_TYPE_BALANCE_PREFIX. '_' .date("YmdHis"). $userId. mt_rand(10000000, 99999999),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成购物车数据
|
||||
* @param array $data
|
||||
|
||||
Reference in New Issue
Block a user