Merge branch 'master' of http://122.114.239.145:7070/r/php/iem_shop
2 files added
3 files modified
New file |
| | |
| | | <?php |
| | | /** |
| | | * 调用的对外接口地址 |
| | | * 创建日期 2018-12-4 |
| | | * by 王腾宇 |
| | | */ |
| | | $setAuth_path = "https://we.xiaoweizhongguo.com/api/appGroupApi.php/setAuth"; |
| | | ?> |
| | |
| | | } else { |
| | | if (checkSign($param,$sysKey)){ |
| | | $retData["rspCode"] = "e00000"; |
| | | |
| | | $retData["repData"] = json_decode($param["data"],true); |
| | | } else { |
| | | $retData["rspCode"] = "e00002"; |
| | |
| | | |
| | | $param["id"]=$appId.date("Ymd").getRandomNumber(9); |
| | | $paramJson = json_encode($param,JSON_UNESCAPED_UNICODE); |
| | | return |
| | | "id=".$param["id"]. |
| | | $url= "id=".$param["id"]. |
| | | "&data=".urlencode($paramJson). |
| | | "&sign=".getSign($paramJson,$appId,$param["id"]); |
| | | return $url; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | function getSign($param,$appId,$id){ |
| | | global $systemId; |
| | | if ($systemId==null){ |
| | | $systemId = array( |
| | | "1000001"=>"3a03c2e6f2f911e8b9245254009bf9ba", |
| | | "1000002"=>"466a50d8f2f911e8b9245254009bf9ba", |
| | | "1000003"=>"53cfae5df2f911e8b9245254009bf9ba", |
| | | ); |
| | | } |
| | | return md5( |
| | | "id=".$id. |
| | | "&data=".$param. |
| | | "&key=".$systemId["$appId"] |
| | | "&key=".$systemId[$appId] |
| | | ); |
| | | } |
| | | |
| | |
| | | return $str; |
| | | } |
| | | |
| | | function toPost($url, $param, $appId){ |
| | | return doCurlPostRequest($url, makeInterfaceParam($param,$appId)); |
| | | } |
| | | |
| | | function doCurlPostRequest($url,$requestString,$timeout = 5){ |
| | | if($url == '' || $requestString == '' || $timeout <=0){ |
| | | return false; |
| | | } |
| | | $con = curl_init((string)$url); |
| | | curl_setopt($con, CURLOPT_HEADER, false); |
| | | curl_setopt($con, CURLOPT_POSTFIELDS, $requestString); |
| | | curl_setopt($con, CURLOPT_POST,true); |
| | | curl_setopt($con, CURLOPT_RETURNTRANSFER,true); |
| | | curl_setopt($con, CURLOPT_TIMEOUT,(int)$timeout); |
| | | $data = curl_exec($con); |
| | | if (curl_errno($url)) { |
| | | return curl_error($url); |
| | | } else { |
| | | curl_close($url); |
| | | return json_decode($data,true); |
| | | } |
| | | } |
| | | |
| | | |
| | | function send_post($url, $post_data) { |
| | | $postdata = http_build_query($post_data); |
| | |
| | | ); |
| | | $context = stream_context_create($options); |
| | | $result = file_get_contents($url, false, $context); |
| | | |
| | | return $result; |
| | | return json_decode($result,true); |
| | | } |
| | |
| | | /* 载入语言文件 */ |
| | | require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/user.php'); |
| | | require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/shopping_flow.php'); |
| | | require(dirname(__FILE__).'/mobile/weiqing/open_application.php'); |
| | | |
| | | if($_REQUEST['act'] == 'edit_user_mobile'){ |
| | | include('includes/cls_json.php'); |
| | |
| | | $split_order['sub_order_count'] = count($order_info); |
| | | //生成订单 |
| | | //$payment_www_com['www_ecshop68_com_alipay_bank'] = $_POST['www_68ecshop_com_bank'] ? trim($_POST['www_68ecshop_com_bank']) : "www_ecshop68_com"; |
| | | |
| | | // 订单编号 |
| | | $order_ids = array(); |
| | | foreach($order_info as $ok=>$order){ |
| | | |
| | | $cart_goods = $cart_goods_new[$ok]['goodlist']; |
| | |
| | | $order['order_id'] = $new_order_id; |
| | | |
| | | $parent_order_id = ($parent_order_id>0) ? $parent_order_id : $new_order_id; |
| | | |
| | | array_push($order_ids,$new_order_id); |
| | | /* 插入订单商品 下面这个SQL有修改 注意末尾那个字段 */ |
| | | /* 代码增加_start By Jarod qi */ |
| | | $sql = "INSERT INTO " . $ecs->table('order_goods') . "( " . |
| | |
| | | //$smarty->assign('total', $total); |
| | | //$smarty->assign('goods_list', $cart_goods); |
| | | //$smarty->assign('order_submit_back', sprintf($_LANG['order_submit_back'], $_LANG['back_home'], $_LANG['goto_user_center'])); // 返回提示 |
| | | |
| | | |
| | | open_application($_SESSION['user_id'],$order_ids); |
| | | unset($_SESSION['flow_consignee']); // 清除session中保存的收货人信息 |
| | | unset($_SESSION['flow_order']); |
| | | unset($_SESSION['direct_shopping']); |
| | |
| | | * ============================================================================ |
| | | */ |
| | | |
| | | |
| | | // TODO 设置购买流程 |
| | | define('IN_ECS', true); |
| | | |
| | | require(dirname(__FILE__) . '/includes/init.php'); |
| | |
| | | /* 载入语言文件 */ |
| | | require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/user.php'); |
| | | require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/shopping_flow.php'); |
| | | require(dirname(__FILE__) . '/weiqing/open_application.php'); |
| | | |
| | | //购物车打开修改商品属性页面 |
| | | if(isset($_REQUEST['is_ajax']) && $_REQUEST['step']=='show_choose_attr'){ |
| | |
| | | } |
| | | |
| | | $consignee = get_consignee($_SESSION['user_id']); |
| | | // TODO 获取openid |
| | | |
| | | /* 检查收货人信息是否完整 */ |
| | | if (!check_consignee_info($consignee, $flow_type)) |
| | |
| | | $split_order['sub_order_count'] = count($order_info); |
| | | //生成订单 |
| | | //$payment_www_com['www_ecshop68_com_alipay_bank'] = $_POST['www_68ecshop_com_bank'] ? trim($_POST['www_68ecshop_com_bank']) : "www_ecshop68_com"; |
| | | |
| | | // 订单编号 |
| | | $order_ids = array(); |
| | | foreach($order_info as $ok=>$order){ |
| | | |
| | | $cart_goods = $cart_goods_new[$ok]['goodlist']; |
| | |
| | | |
| | | $parent_order_id = ($parent_order_id>0) ? $parent_order_id : $new_order_id; |
| | | |
| | | array_push($order_ids,$new_order_id); |
| | | /* 插入订单商品 下面这个SQL有修改 by 注意末尾那个字段 */ |
| | | /* 代码增加_start */ |
| | | $sql = "INSERT INTO " . $ecs->table('order_goods') . "( " . |
| | |
| | | $order['shipping_name']=trim(stripcslashes($order['shipping_name'])); |
| | | } |
| | | |
| | | // TODO 接口调用 by kill |
| | | open_application($_SESSION['user_id'],$order_ids); |
| | | |
| | | /* 订单信息 */ |
| | | $smarty->assign('order', $order); |
| | | //$smarty->assign('total', $total); |
| | |
| | | unset($_SESSION['flow_consignee']); // 清除session中保存的收货人信息 |
| | | unset($_SESSION['flow_order']); |
| | | unset($_SESSION['direct_shopping']); |
| | | |
| | | |
| | | } |
| | | |
| | | /*------------------------------------------------------ */ |
| | |
| | | |
| | | return $goods; |
| | | } |
| | | ?> |
| | | ?> |
New file |
| | |
| | | <?php |
| | | |
| | | /** |
| | | * 连接微擎的相关逻辑 |
| | | * 创建日期 2018-12-4 |
| | | * by 王腾宇 |
| | | */ |
| | | |
| | | require dirname(__FILE__)."/../../api/common/interface.func.php"; |
| | | require dirname(__FILE__)."/../../api/common/api_path_conf.php"; |
| | | |
| | | /** |
| | | * 支付动作成功后 调用 调用微擎接口开通 app |
| | | * 创建日期 2018-12-4 |
| | | * by 王腾宇 |
| | | */ |
| | | function open_application($user_id,$order_ids) { |
| | | // TODO 调用接口 |
| | | |
| | | // name 对应 goods_sn |
| | | // type 8:小程序 9:app |
| | | $name = ''; |
| | | $types = ''; |
| | | |
| | | foreach (get_goods_sn($order_ids) as $order) { |
| | | $name = $name.$order["goods_sn"].","; |
| | | // $type = getType($order["attr_value"]); |
| | | $types = $types."8".","; |
| | | } |
| | | if (toPost($GLOBALS["setAuth_path"],array( |
| | | "openid" => get_open_Id($user_id), |
| | | "name" => substr($name,0,strlen($name)-1), |
| | | "type" => substr($types,0,strlen($types)-1) |
| | | ),'1000002')["rspCode"] == "e00000") { |
| | | update_order_status($order_ids,'1'); |
| | | } else { |
| | | // TODO 接口调用异常处理 |
| | | } |
| | | |
| | | } |
| | | |
| | | function get_open_Id($userId){ |
| | | $data = $GLOBALS['db'] -> getRow("select openid from ecs_users where user_id ="."'".$userId."'"); |
| | | return $data["openid"]; |
| | | } |
| | | |
| | | |
| | | function get_goods_sn($order_ids){ |
| | | $sql = "select goods_sn, (select attr_value from ecs_goods_attr a where a.goods_attr_id = g.goods_attr_id) as attr_value from ecs_order_goods g where order_id in ("; |
| | | $in = ""; |
| | | foreach ($order_ids as $order_id) { |
| | | $in = $in."'".$order_id."',"; |
| | | } |
| | | return $GLOBALS['db'] -> getAll($sql.substr($in,0,strlen($in)-1).")"); |
| | | } |
| | | |
| | | // function getType($attr_value) { |
| | | // switch ($attr_value) { |
| | | // case "微信小程序" : return "8"; |
| | | // case "微信公众号" : return "9"; |
| | | // default : return "-1"; |
| | | // } |
| | | // } |
| | | |
| | | function update_order_status($order_ids,$status) { |
| | | $in = "("; |
| | | foreach ($order_ids as $order_id) { |
| | | $in = $in."'".$order_id."',"; |
| | | } |
| | | $in = substr($in,0,strlen($in)-1).")"; |
| | | $GLOBALS['db'] -> query("update ecs_order_goods set send_number='".$status."' where order_id in ".$in); |
| | | $GLOBALS['db'] -> query("update ecs_order_action set shipping_status='".$status."' where order_id in ".$in); |
| | | $GLOBALS['db'] -> query("update ecs_order_info set shipping_status='".$status."' where order_id in ".$in); |
| | | } |
| | | |
| | | ?> |