0, 'msg' => '请输入消费金额或积分'); return $res; } if (!preg_match($reg, $data['plus_flower_price'])) { $res = array('status' => 0, 'msg' => '请输入正确的消费金额'); return $res; } if (!preg_match($bg, $data['plus_flower_percent'])) { $res = array('status' => 0, 'msg' => '请输入正确的消费获得的积分'); return $res; } } else { if (empty($data['plus_percent']) || !preg_match($reg, $data['plus_percent'])) { $res = array('status' => 0, 'msg' => '请输入正确的消费获得的积分倍数'); return $res; } } } if ($data['plus_recharge_state'] == 1) { if ($data['plus_recharge_type'] == 2) { //plus会员开启充多少获得多少积分 if (empty($data['plus_recharge_price']) || empty($data['plus_recharge_get_integral'])) { $res = array('status' => 0, 'msg' => '请输入消费金额或积分'); return $res; } if (!preg_match($reg, $data['plus_recharge_price'])) { $res = array('status' => 0, 'msg' => '请输入正确的充值金额'); return $res; } if (!preg_match($bg, $data['plus_recharge_get_integral'])) { $res = array('status' => 0, 'msg' => '请输入正确的充值获得的积分'); return $res; } } else { if (empty($data['plus_recharge_integral']) || !preg_match($reg, $data['plus_recharge_integral'])) { $res = array('status' => 0, 'msg' => '请输入正确的充值获得的积分倍数'); return $res; } } } $res = array('status' => 1, 'msg' => '验证成功'); return $res; } /** * plus会员积分设置 * @param $data * @return mixed */ public function addPlusData($data) { //plus会员积分验证 $signin_give = $data['plus_signin_give']; $infoscore = $data['plus_infoscore']; $preg_match = "/^[0-9]*$/"; if($signin_give !== '' && !preg_match($preg_match,$signin_give)){ $res['status'] = 0; $res['msg'] = '请输入正确的赠送积分'; return $res; } if($infoscore !== '' && !preg_match($preg_match,$infoscore)){ $res['status'] = 0; $res['msg'] = '请输入正确的赠送积分'; return $res; } $content = array( 'plus_signin_give' => $data['plus_signin_give'], 'plus_infoscore' => $data['plus_infoscore'], 'plus_percent_state' => $data['plus_percent_state'], 'plus_pay_integral_state' => $data['plus_pay_integral_state'], 'plus_recharge_state' => $data['plus_recharge_state'], 'goods_integral_plus_state' => $data['goods_integral_plus_state'], 'goods_integral_multiple' => $data['goods_integral_multiple'], 'plus_flower_type' => $data['plus_flower_type'] ? $data['plus_flower_type'] : 1, 'plus_recharge_type' => $data['plus_recharge_type'] ? $data['plus_recharge_type'] : 1, ); if ($data['plus_percent_state'] == 1) { //开启消费送积分 if ($data['plus_flower_type'] == 2) { $content['plus_flower_price'] = $data['plus_flower_price'] ? $data['plus_flower_price'] : null; $content['plus_flower_percent'] = $data['plus_flower_percent'] ? $data['plus_flower_percent'] : null; } else { $content['plus_percent'] = $data['plus_percent']; } } if ($data['plus_recharge_state'] == 1) { //开启充值送积分 if ($data['plus_recharge_type'] == 2) { $content['plus_recharge_price'] = $data['plus_recharge_price'] ? $data['plus_recharge_price'] : null; $content['plus_recharge_get_integral'] = $data['plus_recharge_get_integral'] ? $data['plus_recharge_get_integral'] : null; } else { $content['plus_recharge_integral'] = $data['plus_recharge_integral']; } } if (!empty($data['id'])) { $state = $this->updateOrder(array('id' => $data['id']), $content); } else { $content['merchantid'] = $data['merchantid']; $state = $this->addOrder($content); } if ($state) { $res = array('status' => 1, 'msg' => '操作成功'); } else { $res = array('status' => 1, 'msg' => '暂无修改'); } return $res; } /** * 基于订单消费送积分验证用户身份是否开启送积分 * @param $parameter * @return bool */ public function buy_integral_config($parameter) { $vip_type = $parameter['vip_type']; $vipConfig = $parameter['vip_config']; $percent_state = false; if ($vip_type == 2 && $vipConfig['plus_percent_state'] == 1) { //商户开启plus会员买单送积分 switch ($vipConfig['plus_flower_type']) { case 1: //1消费是常规会员的倍数 if ($vipConfig['plus_percent'] > 0 && $vipConfig['flower_price'] > 0 && $vipConfig['percent'] > 0) { $percent_state = true; } break; case 2: if ($vipConfig['plus_flower_price'] > 0 && $vipConfig['plus_flower_percent'] > 0) { $percent_state = true; } break; } } else { //商户开启普通会员买单送积分 if ($vipConfig['percent_state'] == 1 && $vipConfig['flower_price'] > 0 && $vipConfig['percent'] > 0) { $percent_state = true; } } return $percent_state; } /** * 基于订单消费送积分 * @param $parameter [vip_type 2plus会员] * @return mixed */ public function buy_get_integral($parameter) { $vip_type = $parameter['vip_type']; $vip_config = $parameter['vip_config']; $all_money = $parameter['all_money']; $get_integral = 0; if ($vip_type == 2 && $vip_config['plus_percent_state'] == 1) { //plus会员消费多少元获得多少积分 switch ($vip_config['plus_flower_type']) { case 1: $get_integral = floor($all_money / $vip_config['flower_price'] * $vip_config['percent'] * $vip_config['plus_percent']); break; case 2: $get_integral = floor($all_money / $vip_config['plus_flower_price'] * $vip_config['plus_flower_percent']); break; } } else { $get_integral = floor($all_money / $vip_config['flower_price'] * $vip_config['percent']); } return $get_integral; } /** * 基于商品送积分 * @param $parameter[vip_type=>[2plus会员],vip_config=>设置,integral=>积分,num=>数量] * @return float|int */ public function buy_goods_get_integral($parameter) { $vip_type = $parameter['vip_type']; $vip_config = $parameter['vip_config']; $integral = $parameter['integral']; $num = $parameter['num']; $get_integral = 0; if ($vip_type == 2 && $vip_config['goods_integral_plus_state'] == 1 && $vip_config['goods_integral_multiple'] > 0) { $get_integral = round($integral * $num * $vip_config['goods_integral_multiple']); //Plus会员开启 } else if ($vip_config['goods_integral_state'] == 1) { $get_integral = round($integral * $num); } return $get_integral; } /** * 充值送积分验证用户身份是否开启送积分 * @param $parameter [vip_type=>[3plus会员其他普通会员]] * @return bool */ public function recharge_integral_config($parameter) { $vip_type = $parameter['vip_type']; $vip_config = $parameter['vip_config']; $percent_state = false; if ($vip_type == 3 && $vip_config['plus_recharge_state'] == 1) { //商户开启plus会员买单送积分 switch ($vip_config['plus_recharge_type']) { case 1: //1充值是常规会员的倍数 if ($vip_config['recharge_price'] > 0 && $vip_config['recharge_integral'] > 0 && $vip_config['plus_recharge_integral'] > 0) { $percent_state = true; } break; case 2: if ($vip_config['plus_recharge_price'] > 0 && $vip_config['plus_recharge_get_integral'] > 0) { $percent_state = true; } break; } } else { //商户开启普通会员充值送积分 if ($vip_config['recharge_state'] == 1 && $vip_config['recharge_price'] > 0 && $vip_config['recharge_integral'] > 0) { $percent_state = true; } } return $percent_state; } /** * 充值获取积分 * @param $parameter * @return bool */ public function recharge_get_integral($parameter) { $vip_info = $parameter['vip_info']; $vip_config = $parameter['vip_config']; $vip_type = $parameter['vip_type']; $recharge_order = $parameter['recharge_order']; $integral = 0; if ($vip_type == 3 && $vip_config['plus_recharge_state'] == 1) { switch ($vip_config['plus_recharge_type']) { case 1: $integral = floor($recharge_order['money'] / $vip_config['recharge_price'] * $vip_config['recharge_integral'] * $vip_config['plus_recharge_integral']); break; case 2: $integral = floor($recharge_order['money'] / $vip_config['plus_recharge_price'] * $vip_config['plus_recharge_get_integral']); break; } } else { $integral = floor($recharge_order['money'] / $vip_config['recharge_price'] * $vip_config['recharge_integral']); } return $integral; } }