123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- class Goodsclassstaple extends BaseModel {
-
- public function getGoodsclassstapleList($condition, $field = '*', $order = 'staple_counter desc', $limit = 20) {
- $result = Db::name('goodsclassstaple')->field($field)->where($condition)->order($order)->limit($limit)->select()->toArray();
- return $result;
- }
-
- public function getGoodsclassstapleInfo($condition, $field = '*') {
- $result = Db::name('goodsclassstaple')->field($field)->where($condition)->find();
- return $result;
- }
-
- public function autoIncrementStaple($data, $member_id) {
- $where = array(
- 'gc_id_1' => intval($data['gc_id_1']),
- 'gc_id_2' => intval($data['gc_id_2']),
- 'gc_id_3' => intval($data['gc_id_3']),
- 'member_id' => $member_id
- );
- $staple_info = $this->getGoodsclassstapleInfo($where);
- if (empty($staple_info)) {
- $insert = array(
- 'staple_name' => $data['gctag_name'],
- 'gc_id_1' => intval($data['gc_id_1']),
- 'gc_id_2' => intval($data['gc_id_2']),
- 'gc_id_3' => intval($data['gc_id_3']),
- 'type_id' => $data['type_id'],
- 'member_id' => $member_id
- );
- $this->addGoodsclassstaple($insert);
- } else {
- $update = array('staple_counter' => Db::raw('staple_counter+1'));
- $where = array('staple_id' => $staple_info['staple_id']);
- $this->editGoodsclassstaple($update, $where);
- }
- return true;
- }
-
- public function addGoodsclassstaple($data) {
- $result = Db::name('goodsclassstaple')->insertGetId($data);
- return $result;
- }
-
- public function editGoodsclassstaple($update, $where) {
- $result = Db::name('goodsclassstaple')->where($where)->update($update);
- return $result;
- }
-
- public function delGoodsclassstaple($condition) {
- $result = Db::name('goodsclassstaple')->where($condition)->delete();
- return $result;
- }
- }
- ?>
|