123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- /**
- * ============================================================================
- *
- * ============================================================================
- * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
- * 网站地址: https://www.valimart.net/
- * ----------------------------------------------------------------------------
- *
- * ============================================================================
- * 数据层模型
- */
- class Offpayarea extends BaseModel
- {
- /**
- * 增加某店铺设置
- * @access public
- * @author csdeshang
- * @param array $data 参数内容
- * @return bool
- */
- public function addOffpayarea($data)
- {
- return Db::name('offpayarea')->insert($data);
- }
- /**
- * 取得某店铺设置
- * @access public
- * @author csdeshang
- * @param array $condition 条件
- * @return array
- */
- public function getOffpayareaInfo($condition)
- {
- return Db::name('offpayarea')->where($condition)->find();
- }
- /**
- * 更新某店铺设置
- * @access public
- * @author csdeshang
- * @param array $condition 条件
- * @param array $data 数据
- * @return bool
- */
- public function editOffpayarea($condition, $data)
- {
- return Db::name('offpayarea')->where($condition)->update($data);
- }
- /**
- * 某县级地区是否支持货到付款
- * @access public
- * @author csdeshang
- * @param int $area_id 地区ID
- * @param int $store_id 店铺ID(目前只会传平台店铺)
- * @return bool
- */
- public function checkSupportOffpay($area_id, $store_id)
- {
- if (empty($area_id)) return false;
- $area = $this->getOffpayareaInfo(array('store_id' => $store_id));
- if (!empty($area['area_id'])) {
- $area_id_array = unserialize($area['area_id']);
- } else {
- $area_id_array = array();
- }
- if (empty($area_id_array)) {
- $area_id_array = array();
- }
- return in_array($area_id, $area_id_array) ? true : false;
- }
- /**
- * 某县级地区是否支持货到付款(多个店铺)
- * @access public
- * @author csdeshang
- * @param int $area_id 地区ID
- * @param array $store_ids 店铺IDs
- * @return array
- */
- public function checkSupportOffpayBatch($area_id, array $store_ids)
- {
- if (empty($area_id))
- return array_fill($store_ids, false);
- $area = Db::name('offpayarea')->where('store_id','in',$store_ids)->select()->toArray();
- $area = ds_change_arraykey($area, 'store_id');
- $ret = array();
- foreach ($store_ids as $sid) {
- $ret[$sid] = false;
- if (empty($area[$sid]['area_id']))
- continue;
- $area_id_array = unserialize($area[$sid]['area_id']);
- if (!is_array($area_id_array))
- continue;
- if (!in_array($area_id, $area_id_array))
- continue;
- $ret[$sid] = true;
- }
- return $ret;
- }
- }
|