Example #1
0
File: User.php Project: name3/cheng
 public static function register($kvs)
 {
     extract($kvs);
     $type = 'customer';
     Pdb::insert(array('name' => $username, 'password' => md5($password), 'type' => $type, 'realname' => $realname, 'phone' => $phone, 'email' => $email, 'create_time=NOW()' => null), self::$table);
     return new self(Pdb::lastInsertId());
 }
Example #2
0
 public static function add($info)
 {
     $order_id = $info['order'];
     $images = $info['images'];
     foreach ($images as $i) {
         Pdb::insert(array('image' => $i, '`order`' => $order_id), self::$table);
     }
 }
Example #3
0
 public function createFromCart(Cart $cart)
 {
     // but big order need customer or something else??
     Pdb::insert(array('id=id' => null), self::$table);
     $id = Pdb::lastInsertId();
     foreach ($cart->orders() as $order) {
         Pdb::insert(array('big' => $id, 'small' => $order->id), 'big_to_small_order');
         $order->submit();
     }
 }
Example #4
0
 public function visitProduct(Product $prd)
 {
     $expire = '20';
     //???
     if (!in_array($prd->id, self::visitingProducts())) {
         Pdb::insert(array('user' => $this->user->id, 'time=NOW()' => null, 'action' => 'visitProduct', 'target' => $prd->id), UserLog::$table);
         self::addVisitingProduct($prd);
     }
 }
Example #5
0
 public function createAdmin($opts)
 {
     Pdb::insert(array('name' => $opts['username'], 'password' => md5($opts['password']), 'type' => 'Admin', 'create_time=NOW()' => null), User::$table);
     return new Admin(Pdb::lastInsertId());
 }
Example #6
0
 public static function add($info)
 {
     Pdb::insert(array('weight' => $info['weight']), self::$table);
     return new self(Pdb::lastInsertId());
 }
Example #7
0
 public static function create()
 {
     Pdb::insert(array('remain' => 0, 'done' => 0, 'undone' => 0), Account::$table);
     return new self(Pdb::lastInsertId());
 }
Example #8
0
 public static function adminDealOrder(Admin $admin, $action, Order $order, $remark = '')
 {
     Pdb::insert(array('subject' => $admin->id, 'action' => $action . 'Order', 'target' => $order->id, 'info' => $remark, 'time=NOW()' => null), self::$table);
 }
Example #9
0
 public static function addCustomized($info)
 {
     Pdb::insert(array_merge($info, array('is_customized' => 1)), self::$table);
     return new self(Pdb::lastInsertId());
 }
Example #10
0
 public static function create($info = array())
 {
     $self = get_called_class();
     Pdb::insert($info, $self::$table);
     return new self(Pdb::lastInsertId());
 }
Example #11
0
 public static function update($type, $price)
 {
     Pdb::insert(array('type' => $type, 'price' => $price, 'time=NOW()' => null), self::$table);
 }
Example #12
0
 public static function create($info)
 {
     Pdb::insert($info, self::$table);
     return new self(Pdb::lastInsertId());
 }
Example #13
0
 public function payFactoryForOrder($factory, $order, $money, $remark = '')
 {
     $account = $factory->account();
     $account->deduct($money);
     Pdb::update(array('paid_factory = paid_factory + ?' => $money), Order::$table, $order->selfCond());
     Pdb::update(array('undone = undone - ?' => $money), Factory::$table, $factory->selfCond());
     $arr = array('account' => $account->id, '`order`' => $order->id, 'money' => $money, 'remark' => $remark, '`time`=NOW()' => null);
     Pdb::insert($arr, AccountHistory::$table);
 }
Example #14
0
 public function submit()
 {
     $this->info = $this->info();
     // why here?
     $material = $this->info['material'];
     $product = $this->product();
     $info = array('small_stone' => $product->small_stone, 'gold_price' => Price::current($material), 'labor_expense' => Setting::get('labor_expense'), 'wear_tear' => Setting::get('wear_tear'), 'st_price' => Setting::get('st_price'), 'st_expense' => Setting::get('st_expense'), 'st_weight' => $product->st_weight, 'model_expense' => 0, 'risk_expense' => Setting::get('risk_expense'));
     $factory_price = PriceData::create($info);
     $customer_price = PriceData::create($info);
     Pdb::update(array('state' => 'ToBeConfirmed', 'submit_time=NOW()' => null, 'factory_price' => $factory_price->id, 'customer_price' => $customer_price->id, 'real_price' => $this->info['estimate_price'], 'weight_ratio' => $material === 'PT950' ? Setting::get('weight_ratio') : 1), self::$table, $this->selfCond());
     $customer = $this->customer();
     Pdb::insert(array('subject' => $customer->id, 'action' => 'SubmitOrder', 'target' => $this->id, 'time=NOW()' => null, 'info' => $customer->user()->realname . ' 提交订单'), UserLog::$table);
 }