security->generateRandomString(8); $security = Yii::createObject("yii\base\Security"); $n = 0; for ($i = 1; $i < 1000; $i++) { //$key = $security->generateRandomString(8); $key = rand(10000000, 99999999); //$key = strtolower($key); //$key = str_replace(['_', '-'], 'a', $key); $ret[$key] += 1; } $this->stdout("duplicate data:\n", Console::FG_RED); foreach ($ret as $k => $v) { if ($v > 1) { echo "$k $v\n"; } } } /** * 增加订单商品测试数据 */ public function actionOrderGoods() { $transaction = Yii::$app->db->beginTransaction(); try { $order = new Order(); $order->user_id = 1; $order->status = Order::STATUS_TO_BE_SHIPPING; $order->type = Order::TYPE_SHOPPING; $order->order_sn = date('Ymd', time()) . rand(0, 100); $order->invoice_id = date('Ymd', time()) . rand(0, 100); $order->consignee = '温xx'; $order->phone = '17727716697'; $order->goods_count = rand(10, 33); $order->goods_amount = rand(10, 100); $order->shipping_type = 0; $order->shipping_amount = rand(10, 100); $order->address = '地址地址测试地址'; if (!$order->save()) { throw new Exception('save order false'); } for ($i = 1; $i <= 3; $i++) { $orderGoods = new OrderGoods(); $orderGoods->order_id = $order->id; $orderGoods->goods_id = $i; $orderGoods->goods_name = '测试商品' . $i; $orderGoods->goods_count = rand(1, 10); $orderGoods->sku_value = 'sku值1'; $orderGoods->price = rand(100, 999); $orderGoods->market_price = $orderGoods->price + 166; $orderGoods->weight = rand(1, 10); $orderGoods->sku_id = 0; if (!$orderGoods->save()) { throw new Exception('orderGoods save false'); } } $transaction->commit(); echo "ok\n"; } catch (Exception $e) { $transaction->rollBack(); print_r($e->getMessage()); } } public function actionUser() { $user = new User(); $user->auth_key = '111'; $user->password_hash = '111'; if ($user->save()) { echo 'ok'."\n"; } else { print_r($user->errors); echo 'fail'."\n"; } } public function actionWxPayConfig() { $wxPayConfig = WxPayConfig::find()->one(); if (!$wxPayConfig) { $wxPayConfig = new WxPayConfig(); } $wxPayConfig->user_id = 1; $wxPayConfig->mch_id = 1395812402; $wxPayConfig->key = '51CF5EE3B2E35B9843E17E6099325A65'; $wxPayConfig->key_path = ''; $wxPayConfig->cert_path = ''; if ($wxPayConfig->save()) { echo "ok\n"; } else { echo "fail\n"; } } }