Example #1
0
 public function deduct($money, $num = 0)
 {
     if (!is_numeric($money) || !is_numeric($num)) {
         throw new Exception("money must be numeric: {$money}");
     }
     Pdb::update(array("remain = remain - ?" => $money), self::$table, $this->selfCond());
 }
Example #2
0
 public function edit($key_or_array, $value = null)
 {
     if ($value !== null) {
         // give by key => value
         $arr = array($key_or_array, $value);
     } else {
         $arr = $key_or_array;
     }
     Pdb::update($arr, self::$table, $this->selfCond());
 }
Example #3
0
 public function update($key_or_array, $value = null)
 {
     if ($value !== null) {
         // given by key => value
         $arr = array($key_or_array => $value);
     } else {
         $arr = $key_or_array;
     }
     $self = get_called_class();
     Pdb::update($arr, $self::$table, $this->selfCond());
     // why we need that? that doesn't make any sense
     $this->info = $this->info();
     // refresh data
 }
Example #4
0
 public static function set($ka, $value = null)
 {
     if ($value !== null && is_string($ka)) {
         $arr = array();
         $arr[$ka] = $value;
     } elseif (is_array($ka)) {
         $arr = $ka;
     } else {
         throw new Exception('no array');
     }
     d($arr);
     foreach ($arr as $key => $value) {
         Pdb::update(compact('value'), self::$table, array('`key`=?' => $key));
     }
 }
Example #5
0
 public function changePassword($new_password)
 {
     Pdb::update(array('password' => md5($new_password)), self::$table, $this->selfCond());
 }
Example #6
0
 public function edit($para)
 {
     Pdb::update($para, self::$table, $this->selfCond());
 }
Example #7
0
 public function setDefault()
 {
     Pdb::update(array('is_default' => 1), 'customer_address', array('address=?' => $this->id));
 }
Example #8
0
 public function doneOrder(Order $order)
 {
     $state = 'Done';
     Pdb::update(array('state' => $state, 'done_time=NOW()' => null), Order::$table, array('id=?', $order->id));
     UserLog::adminDealOrder($this, 'done', $order, '交易完成');
     return $state;
 }
Example #9
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);
 }