Core.php 749 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Code\Lib;
  3. use Dever;
  4. class Core
  5. {
  6. public function createCode($product, $cate_id, $product_id, $seller_id, $product_num = 1, $create_uid = -1)
  7. {
  8. $code = Dever::rand(8, 0);
  9. $data['code'] = $code;
  10. $total = Dever::db('code/info')->total($data);
  11. if ($total > 0) {
  12. return $this->createCode($product, $cate_id, $product_id, $seller_id, $product_num, $create_uid);
  13. }
  14. //$data['product'] = $product;
  15. $data['cate_id'] = $cate_id;
  16. $data['product_id'] = $product_id;
  17. $data['seller_id'] = $seller_id;
  18. $data['product_num'] = $product_num;
  19. $data['type'] = 1;
  20. if ($create_uid > 0) {
  21. $data['create_uid'] = $create_uid;
  22. }
  23. Dever::db('code/info')->insert($data);
  24. return $code;
  25. }
  26. }