goods_fcode.model.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * 商品F码模型
  4. *
  5. */
  6. defined('InShopNC') or exit('Access Invalid!');
  7. class goods_fcodeModel extends Model {
  8. public function __construct(){
  9. parent::__construct('goods_fcode');
  10. }
  11. /**
  12. * 插入数据
  13. *
  14. * @param unknown $insert
  15. * @return boolean
  16. */
  17. public function addGoodsFCodeAll($insert) {
  18. return $this->insertAll($insert);
  19. }
  20. public function getUsableFcodeCount($mobile) {
  21. if(empty($mobile)) {
  22. return 0;
  23. }
  24. else {
  25. return $this->where(['mobile' => $mobile,'usable_time' => ['gt',time()],'fc_state' => 0])->count();
  26. }
  27. }
  28. /**
  29. * 取得F码列表
  30. *
  31. * @param array $condition
  32. * @param string $order
  33. */
  34. public function getGoodsFCodeList($condition, $order = 'fc_state asc,fc_id asc') {
  35. return $this->where($condition)->order($order)->select();
  36. }
  37. public function getFcodeList($condition,$field='*', $order = 'fc_state asc,fc_id asc',$page = 0,$limit = 0, $lock = false)
  38. {
  39. return $this->field($field)->where($condition)->page($page)->order($order)->limit($limit)->lock($lock)->select();
  40. }
  41. /**
  42. * 删除F码
  43. */
  44. public function delGoodsFCode($condition) {
  45. return $this->where($condition)->delete();
  46. }
  47. /**
  48. * 取得F码
  49. */
  50. public function getGoodsFCode($condition,$master=false) {
  51. return $this->where($condition)->lock($master)->find();
  52. }
  53. /**
  54. * 更新F码
  55. */
  56. public function editGoodsFCode($data, $condition) {
  57. return $this->where($condition)->update($data);
  58. }
  59. }