json字符串{ * id 合伙人路径配置id * type 模块类型 * status 1开启 2关闭 * route_url 路径 * third_id 商户表中的合伙人路径配置id * } * ] * @return mixed */ public function ThirdErpSetOperation($param) { if (empty($param['merchant_id']) || empty($param['info'])) { return callBack(statusCode()['error'], '参数有误'); } $info = json_decode($param['info'], true); if (!is_array($info)) { return callBack(statusCode()['error'], '参数格式有误'); } $data = [ 'merchant_id' => $param['merchant_id'], 'update_time' => $_SERVER['REQUEST_TIME'] ]; $add_arr = []; try { $ThirdSetModel = new ThirdErpSetModel(); foreach ($info as $val) { $data['status'] = $val['status'] ? $val['status'] : 2; if (!empty($val['third_id'])) { //编辑 $ThirdSetModel->updateOrder([ 'third_id' => $val['third_id'], 'merchant_id' => $param['merchant_id'] ], $data); } else { //添加 $data['third_id'] = $val['id']; $add_arr[] = $data; } } if (!empty($add_arr)) { $id = $ThirdSetModel->addAll($add_arr); if (!empty($id)) { return callBack(statusCode()['success'], '配置成功'); } else { return callBack(statusCode()['error'], '路径配置失败'); } } return callBack(statusCode()['success'], '配置成功'); } catch (\Exception $e) { return callBack(statusCode()['error'], '路径配置失败'); } } /** * 第三方平台的配置参数 * @param $param * [ * merchant_id * platform_type 2 微礼平台 * info=>json字符串{ * third_domain_url * third_account_number * third_password * token * } * ] * @return mixed */ public function addThirdConfig($param) { try { $data = json_decode($param['info'], true); if (!is_array($data) || empty($data)) { return callBack(statusCode()['error'], '参数格式有误'); } $data['merchant_id'] = $param['merchant_id']; $data['platform_type'] = $param['platform_type']; $data['add_time'] = $_SERVER['REQUEST_TIME']; $data['third_update_time'] = $_SERVER['REQUEST_TIME']; $where = [ 'merchant_id' => $param['merchant_id'], 'platform_type' => $param['platform_type'] ]; $ThirdConfigModel = new ThirdConfigModel(); $id = $ThirdConfigModel->getFindField($where, 'id'); if (!empty($id)) { unset($data['id']); $ThirdConfigModel->updateOrder($where, $data); return callBack(statusCode()['success'], '修改成功'); } else { $id = $ThirdConfigModel->addOrder($data); if (!empty($id)) { return callBack(statusCode()['success'], '保存成功'); } else { return callBack(statusCode()['error'], '插件参数配置失败'); } } } catch (\Exception $e) { return callBack(statusCode()['error'], '插件参数配置失败'); } } /** * 支付时代金券核销类型 * @param $param * [ * operator_type 1后台 * user_type 3商户 * merchant_id * pay_coupon_goods_tag 代金券核销指定类型 1指定商品id 2指定商品条码 * ] * @return mixed */ public function payCouponType($param) { $VerifyClass = new VerifyParam(); $verifyResult = $VerifyClass->identityVerify($param); if ($verifyResult['status'] != 1) { return $verifyResult; } $where = [ 'merchant_id' => $param['merchant_id'] ]; try { $ConfigModel = new RetailMerchantConfigModel(); $info = $ConfigModel->getFind($where); $data = [ 'pay_coupon_goods_tag' => $param['pay_coupon_goods_tag'] ? $param['pay_coupon_goods_tag'] : 1 ]; if (!empty($info)) { //编辑 $state = $ConfigModel->updateOrder($where, $data); } else { //添加 $data['merchant_id'] = $param['merchant_id']; $state = $ConfigModel->addOrder($data); } if ($state) { return callBack(statusCode()['success'], '操作成功'); } else { return callBack(statusCode()['error'], '暂无修改'); } } catch (\Exception $e) { return callBack(statusCode()['error'], '暂无修改'); } } /** * 商家券logo设置 * @param $param * [ * merchant_id * shop_coupon_simple_image 本地图片 普通模式 * shop_coupon_service_image 本地图片 服务商模式 * shop_coupon_simple_wx_image 微信 普通模式 * shop_coupon_service_wx_image 微信 服务商模式 * ] * @return mixed */ public function shopCouponImgSet($param) { if (!empty($param['shop_coupon_simple_image'])) { $content['shop_coupon_simple_image'] = $param['shop_coupon_simple_image']; $content['shop_coupon_simple_wx_image'] = $param['shop_coupon_simple_wx_image']; } else if (!empty($param['shop_coupon_service_image'])) { $content['shop_coupon_service_image'] = $param['shop_coupon_service_image']; $content['shop_coupon_service_wx_image'] = $param['shop_coupon_service_wx_image']; } $configModel = new RetailMerchantConfigModel(); $config = $configModel->getFind([ 'merchant_id' => $param['merchant_id'] ]); if (!empty($config)) { $configModel->updateOrder([ 'merchant_id' => $param['merchant_id'] ], $content); } else { $content['merchant_id'] = $param['merchant_id']; $configModel->addOrder($content); } return callBack(statusCode()['success'], "修改成功"); } /** * 获取商户小程序功能配置 * @param $param * $param['merchant_id'] 商户ID * @return mixed */ public function getXcxConfig($param) { if (empty($param['merchant_id'])) { return callBack(statusCode()['error'], "缺少商户ID"); } $ConfigModel = new RetailMerchantConfigModel(); $data = $ConfigModel->getFind(array('merchant_id' => $param['merchant_id']), 'store_access,store_switch,tourist_store_access'); $MerchantModel = new RetailMerchantModel(); $data['nearby_status'] = $MerchantModel->getFindField(array('id' => $param['merchant_id']), 'nearby_status'); return callBack(statusCode()['success'], "获取成功", $data); } /** * 获取次卡基本设置 * @param $param * $param['merchant_id'] 商户ID * @return mixed */ public function getCardBaseData($param) { if (!$param['merchant_id']) { return callBack(statusCode()['error'], '缺少参数'); } $MerchantConfigModel = new RetailMerchantConfigModel(); $use_sub_card_code = $MerchantConfigModel->getFindField(['merchant_id' => $param['merchant_id']], 'use_sub_card_code'); return callBack(statusCode()['success'], '获取成功', ['use_sub_card_code' => $use_sub_card_code == 2 ? 2 : 1]); } /** * 保存次卡基本设置 * @param $param * $param['merchant_id'] 商户ID * $param['use_sub_card_code'] 次卡面核销码状态 1需要核销码 2不需要 * @return mixed */ public function setCardBaseData($param) { if (!$param['merchant_id'] || !$param['use_sub_card_code'] || !in_array($param['use_sub_card_code'], ['1', '2'])) { return callBack(statusCode()['error'], '缺少参数'); } $MerchantConfigModel = new RetailMerchantConfigModel(); $res = $MerchantConfigModel->updateOrder(['merchant_id' => $param['merchant_id']], ['use_sub_card_code' => $param['use_sub_card_code']]); if ($res) { return callBack(statusCode()['success'], '修改成功'); } else { return callBack(statusCode()['error'], '您未修改设置'); } } }