store_id)) { $this->ajaxReturn(['status' => 0, 'msg' => '登录超时']); } } /** * 门店基本设置 * */ public function baseSet() { $StoreConfigModel = new StoreConfigModel(); $config = $StoreConfigModel->getFind(['store_id' => $this->store_id], 'is_check_show_invenum,code_price_state'); $is_check_show_invenum = $config['is_check_show_invenum'] == 1 ? '1' : '2'; $this->assign('is_check_show_invenum', $is_check_show_invenum); $this->assign('code_price_state', $config['code_price_state']?$config['code_price_state']:0); $StoreModel = new RetailStoreModel(); $store = $StoreModel->getFind(['id' => $this->store_id]); $this->assign('preferential', $store['preferential']); $this->assign('manual_discount', $store['manual_discount']); $this->assign('sku_discount', $store['sku_discount']); // 单品折扣 $this->assign('goods_empty_sell_status', $store['goods_empty_sell_status']); $this->assign('default_delivery', $store['default_delivery']); //默认配送方式 $this->assign('modify_order_state', $store['modify_order_state']); $this->assign('day', $store['modify_order_day']); $this->assign('small_change_state', $store['small_change_state']); $this->assign('density_free_state', $store['density_free_state']); $this->assign('refund_time_limit', $store['refund_time_limit']); $this->assign('cashier_refund_time', $store['cashier_refund_time']); $this->assign('deposit_price_state', $store['deposit_price_state']); $this->assign('screen_percent', $store['screen_percent']); $this->assign('is_resolution', $store['is_resolution']); $this->assign('automatic_delivery', $store['automatic_delivery']); $PlugClass = new Plug(); $plugResult = $PlugClass->PlugPermissions([ 'merchant_id' => $this->merchant_id, 'identification_arr' => [ 'make' ] ]); if (!empty($plugResult['data']['plug']['make'])) { $this->assign('make_state', true); } else { $this->assign('make_state', false); } $DefaultImgModel = new GoodsDefaultImgModel(); $default_goods_img_id = $DefaultImgModel->getFindField(['storeid' => $this->store_id], 'default_goods_img_id'); $defaultImg = $default_goods_img_id ? getGoodsImage($default_goods_img_id, $this->store_id) : ''; $this->assign('default_goods_img', $defaultImg); $this->display(); } //基础数据 public function baseSetBasics() { $InventorySetClass = new InventorySet(); $inventory_set = $InventorySetClass->getInfo([ 'merchant_id' => $this->merchant_id, 'store_id' => $this->store_id, 'user_type' => 4 ]); //进销存设置 $this->ajaxReturn([ 'status' => 1, 'message' => '查询成功', 'data' => [ 'inventory_set' => $inventory_set ] ]); } /** * 修改门店表信息 * @param $param * $param['key'] 修改的字段 * $param['value'] 修改的值 * $param['desc'] 描述 * @return array */ private function updateStoreSet($param) { if (!isset($param['value'])) { return ['status' => 0, 'msg' => '缺少参数']; } else { $StoreModel = new RetailStoreModel(); $update = $StoreModel->updateOrder(['id' => $this->store_id], [$param['key'] => $param['value']]); if ($update) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 action_log($source, $type, $request_data, $param['desc']); return ['status' => 1, 'msg' => '保存成功']; } else { return ['status' => 0, 'msg' => '保存失败']; } } } /** * 修改折上折状态 */ public function openPreferential() { $status = I('post.status'); $this->ajaxReturn($this->updateStoreSet([ 'key' => 'preferential', 'value' => $status, 'desc' => '基本设置-折上折' . ($status == 1 ? '开启' : '关闭'), ])); } /** * 修改单品折上折状态 */ public function openManualDiscount() { $status = I('post.status'); $this->ajaxReturn($this->updateStoreSet([ 'key' => 'manual_discount', 'value' => $status, 'desc' => '基本设置-单品折上折' . ($status == 1 ? '开启' : '关闭'), ])); } /** * 修改商品库存为0允许出售状态 */ public function openEmptySell() { $status = I('post.status'); $this->ajaxReturn($this->updateStoreSet([ 'key' => 'goods_empty_sell_status', 'value' => $status, 'desc' => '基本设置-库存为0允许出售-' . ($status == 1 ? '开启' : '关闭'), ])); } /** * 商品出售自动拆分开关 */ public function openResolution() { $status = I('post.status'); $this->ajaxReturn($this->updateStoreSet([ 'key' => 'is_resolution', 'value' => $status, 'desc' => '基本设置-是否开启自动拆分-' . ($status == 1 ? '开启' : '关闭'), ])); } /** * 自动发货 */ public function automaticDelivery() { $automatic_delivery = I('post.automatic_delivery'); $this->ajaxReturn($this->updateStoreSet([ 'key' => 'automatic_delivery', 'value' => $automatic_delivery, 'desc' => '基本设置-自动发货-' . ($automatic_delivery == 1 ? '开启' : '关闭'), ])); } /** * 设置默认配送方式 */ public function setDefaultDelivery() { $delivery = I('post.delivery'); $desc = ''; switch ($delivery) { case 0: $desc = '基本设置-默认配送方式-自主选择'; //操作行为描述 break; case 1: $desc = '基本设置-默认配送方式-门店配送'; //操作行为描述 break; case 2: $desc = '基本设置-默认配送方式-达达配送'; //操作行为描述 break; case 3: $desc = '基本设置-默认配送方式-UU配送'; //操作行为描述 break; case 5: $desc = '基本设置-默认配送方式-码科配送'; //操作行为描述 break; case 6: $desc = '基本设置-默认配送方式-麦芽田配送'; //操作行为描述 break; } $this->ajaxReturn($this->updateStoreSet([ 'key' => 'default_delivery', 'value' => $delivery, 'desc' => $desc, ])); } /** * 设置客服类型 * @param [array] $customer_service 客服类型 * @return [array] $res */ public function setCustomerService() { $customer_service = I('post.customer_service'); $this->ajaxReturn($this->updateStoreSet([ 'key' => 'customer_service', 'value' => $customer_service, 'desc' => '基本设置-商城客服类型-' . ($customer_service == 1 ? '拨打电话' : '微信客服'), ])); } /** * 修改自动修改商城订单状态 */ public function OrderStateModify() { $data['modify_order_day'] = I('post.day') ? I('post.day') : 0; $data['modify_order_state'] = I('post.status'); if (!$data['modify_order_day']) { $res['status'] = 0; $res['msg'] = '请输入天数'; $this->ajaxReturn($res); } $StoreModel = new RetailStoreModel(); $save = $StoreModel->updateOrder(['id' => $this->store_id], $data); if ($save) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 $desc = '基本设置-自定义商城订单默认完成时间修改'; //操作行为描述 action_log($source, $type, $request_data, $desc); $res['status'] = 1; $res['msg'] = '操作成功'; } else { $res['status'] = 0; $res['msg'] = '暂无修改'; } $this->ajaxReturn($res); } /** * 自动抹零设置 */ public function smallState() { $small_change_state = I('post.small_change_state') ? I('post.small_change_state') : 0; $desc = ''; switch ($small_change_state) { case 1: $desc = '基本设置-收银默认抹零方式-抹分'; //操作行为描述 break; case 2: $desc = '基本设置-收银默认抹零方式-抹角'; //操作行为描述 break; case 3: $desc = '基本设置-收银默认抹零方式-抹元'; //操作行为描述 break; } $this->ajaxReturn($this->updateStoreSet([ 'key' => 'small_change_state', 'value' => $small_change_state, 'desc' => $desc, ])); } /** * 找零金额自动存余额设置 */ public function DepositBalanceAct() { $deposit_price_state = I('post.deposit_price_state'); $this->ajaxReturn($this->updateStoreSet([ 'key' => 'deposit_price_state', 'value' => $deposit_price_state, 'desc' => '基本设置-收银会员现金支付提示-' . ($deposit_price_state == 1 ? '开启' : '关闭'), ])); } /** * 盘点是否显示库存--门店 * @param status 1开启 2关闭 */ public function takeStockInventory() { $store_id = $this->store_id; $status = I('post.status'); if (!in_array($status, [1, 2])) { $this->ajaxReturn(['status' => 0, 'msg' => '参数不正确']); } if (empty($store_id)) { $res = ['status' => 0, 'msg' => '登录超时']; } else { $StoreConfigModel = new StoreConfigModel(); $update = $StoreConfigModel->updateOrder(['store_id' => $store_id], ['is_check_show_invenum' => $status]); if ($update) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 if ($status == 1) { $desc = '基本设置-盘点是否显示库存-开启'; //操作行为描述 } elseif ($status == 2) { $desc = '基本设置-盘点是否显示库存-关闭'; //操作行为描述 } action_log($source, $type, $request_data, $desc); $res['status'] = 1; $res['msg'] = '修改成功'; } else { $res['status'] = 0; $res['msg'] = '修改失败'; } } $this->ajaxReturn($res); } /** * 设置默认商品图片 */ public function setDefaultImg() { if (IS_POST) { $image_id = I('post.image_id'); $image = I('post.image'); if (!$image_id || !$image) { $res['status'] = 0; $res['msg'] = '请选择图片'; $this->ajaxReturn($res); } $add['default_goods_img'] = $image; $add['default_goods_img_id'] = $image_id; $DefaultImgModel = new GoodsDefaultImgModel(); $old = $DefaultImgModel->getFind(['storeid' => $this->store_id]); if ($old) { $ret = $DefaultImgModel->updateOrder(['storeid' => $this->store_id], $add); } else { $add['storeid'] = $this->store_id; $add['merchantid'] = $this->merchant_id; $add['default_goods_img_id'] = $image_id; $ret = $DefaultImgModel->addOrder($add); } if ($ret) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 $desc = '基本设置-商品默认图片设置'; //操作行为描述 action_log($source, $type, $request_data, $desc); $res['status'] = 1; $res['msg'] = '设置成功'; } else { $res['status'] = 0; $res['msg'] = '设置失败'; } } $this->ajaxReturn($res); } /** * 获取客服类型 * @return [array] $res */ public function getCustomerService() { $StoreModel = new RetailStoreModel(); $customer_service = $StoreModel->getFindField(['id' => $this->store_id, 'state' => 0], 'customer_service'); $res['status'] = 1; $res['customer_service'] = $customer_service ? $customer_service : 1; $this->ajaxReturn($res); } /** * 获取商品详情页标签列表 */ public function getLabel() { $page = I('post.page'); $limit = I('post.limit'); $map['store_id'] = $this->store_id; $labelList = D('StoreLabel')->getSelect($map, '*', 'id asc', $page . ',' . $limit); foreach ($labelList as &$v) { if ($v['img_id'] != '') { $v['img'] = D('ImageGallery')->getFieldPath(array('id' => $v['img_id'])); } else { $v['img'] = ''; } } $count = D('StoreLabel')->getCount($map); $res['status'] = 1; $res['count'] = (int)$count; $res['list'] = $labelList; $this->ajaxReturn($res); } /** * 添加/编辑商品详情页标签 */ public function labelAdd() { if (IS_POST) { $store_id = $this->store_id; $merchant_id = $this->merchant_id; $label_name = I('post.label_name'); $id = I('post.id'); $label_img_id = I('post.img_id'); if (empty($label_name)) { $res['status'] = 0; $res['msg'] = '请填写标签名称'; $this->ajaxReturn($res); } if (empty($label_img_id)) { $res['status'] = 0; $res['msg'] = '请选择图片'; $this->ajaxReturn($res); } $repeatName = D('StoreLabel')->getFind(array('store_id' => $store_id, 'label_name' => $label_name)); if (!empty($repeatName) && $repeatName['id'] != $id) { $res['status'] = 0; $res['msg'] = '标签名称重复'; $this->ajaxReturn($res); } $data['img_id'] = $label_img_id; $data['label_name'] = $label_name; if (!empty($id)) { $map['id'] = $id; $num = D('StoreLabel')->updateOrder($map, $data); if ($num) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 $desc = '基本设置-商品标签-编辑标签'; //操作行为描述 action_log($source, $type, $request_data, $desc); } } else { $data['store_id'] = $store_id; $data['merchant_id'] = $merchant_id; $num = D('StoreLabel')->addOrder($data); if ($num) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 $desc = '基本设置-商品标签-添加标签'; //操作行为描述 action_log($source, $type, $request_data, $desc); } } if ($num) { $res['status'] = 1; $res['msg'] = '操作成功'; $this->ajaxReturn($res); } else { $res['status'] = 2; $res['msg'] = '操作出错'; $this->ajaxReturn($res); } } else { $res['status'] = 2; $res['msg'] = '数据出错'; $this->ajaxReturn($res); } } /** * 修改商品详情页标签状态 */ public function labelStatus() { if (IS_POST) { $id = I('post.id'); $status = I('post.status'); $map['id'] = $id; $data['status'] = $status; $num = D('StoreLabel')->updateOrder($map, $data); if ($num) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 if ($status == 1) { $desc = '基本设置-商品标签-开启'; //操作行为描述 } else { $desc = '基本设置-商品标签-关闭'; //操作行为描述 } action_log($source, $type, $request_data, $desc); $res['status'] = 1; $res['msg'] = '操作成功'; $this->ajaxReturn($res); } else { $res['status'] = 2; $res['msg'] = '操作出错'; $this->ajaxReturn($res); } } else { $res['status'] = 2; $res['msg'] = '数据出错'; $this->ajaxReturn($res); } } /** * 删除商品详情页标签 */ public function delLabel() { if (IS_POST) { $id = I('post.id'); $map['id'] = $id; $num = D('StoreLabel')->toDelete($map); if ($num) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 $desc = '基本设置-商品标签-删除'; //操作行为描述 action_log($source, $type, $request_data, $desc); $res['status'] = 1; $res['msg'] = '操作成功'; $this->ajaxReturn($res); } else { $res['status'] = 2; $res['msg'] = '操作出错'; $this->ajaxReturn($res); } } else { $res['status'] = 2; $res['msg'] = '数据出错'; $this->ajaxReturn($res); } } /** * 修改免密支付状态 */ public function densityFree() { $status = I('post.status'); $this->ajaxReturn($this->updateStoreSet([ 'key' => 'density_free_state', 'value' => $status, 'desc' => '基本设置-店内收款免密支付-' . ($status == 1 ? '开启' : '关闭'), ])); } /** * 设置退款换货时间限制 * type 1商城 2店内 * time_limit 时间 */ public function setRefundTimeLimit() { $time_limit = I('post.time_limit'); $type = I('post.type'); if (!verifyNumber($time_limit, 0, 0, 9999)) { $res['status'] = 0; $res['msg'] = '时间设置有误'; } else if (empty($type)) { $res['status'] = 0; $res['msg'] = '参数缺失'; } else { $StoreModel = new RetailStoreModel(); $map = array( $StoreModel::ID => $this->store_id, $StoreModel::STATE => 0, ); switch ($type) { case 1: $save = array( $StoreModel::REFUND_TIME_LIMIT => $time_limit, ); $desc = '基本设置-线上退款换货时间范围修改'; //操作行为描述 break; case 2: $save = array( $StoreModel::CASHIER_REFUND_TIME => $time_limit, ); $desc = '基本设置-线下退款换货时间范围修改'; //操作行为描述 break; } $update = $StoreModel->updateOrder($map, $save); if ($update) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 action_log($source, $type, $request_data, $desc); $res['status'] = 1; $res['msg'] = '保存成功'; } else { $res['status'] = 0; $res['msg'] = '保存失败'; } } $this->ajaxReturn($res); } /** * 进销存打印字体个数设置 */ public function fontSet() { $store_id = session("storeid"); $where = array( 'type' => 2, 'store_id' => $store_id ); $info = D("InventoryPrint")->getFind($where); $content['font_num'] = I("post.font_num"); $content['sku_num'] = I("post.sku_num"); if ($info) { $res = D("InventoryPrint")->updateData($where, $content); } else { $content['store_id'] = $store_id; $content['merchant_id'] = session("ls_userinfo")['merchantid'];; $content['type'] = 2; $res = D("InventoryPrint")->addData($content); } if ($res['status'] == 1) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 $desc = '基本设置-进销存打印设置'; //操作行为描述 action_log($source, $type, $request_data, $desc); } $this->ajaxReturn($res); } /** * 收银副屏宣传图比例修改 */ public function screen_percent() { $screen_percent = I("post.screen_percent"); if (!$screen_percent) { $res['status'] = 0; $res['msg'] = '请输入比例值'; $this->ajaxReturn($res); } $save = D("RetailStore")->updateOrder(['id' => $this->store_id], ['screen_percent' => $screen_percent]); if ($save) { //操作日志记录 $source = 0; //请求来源: 0pc系统 1小助手 $type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端 $request_data = json_encode($_POST); //请求参数 json数据 $desc = '基本设置-收银副屏宣传图比例修改'; //操作行为描述 action_log($source, $type, $request_data, $desc); $res['status'] = 1; $res['msg'] = '操作成功'; } else { $res['status'] = 0; $res['msg'] = '请勿重复操作'; } $this->ajaxReturn($res); } //采购修改售价开关 public function modifyPriceState() { $data = I('post.'); $data['user_type'] = 4; $data['merchant_id'] = $this->merchant_id; $data['store_id'] = $this->store_id; $inventorySet = new InventorySet(); $result = $inventorySet->modifyPriceState($data); $this->ajaxReturn($result); } //价格按条码秤价格权限 public function codePriceState() { $data = I('post.'); $data['store_id'] = $this->store_id; $StoreAuthorityClass = new StoreAuthority(); $result = $StoreAuthorityClass->codePriceState($data); $this->ajaxReturn($result); } }